@remit/web-client-dist 0.0.629 → 0.0.631

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 (165) hide show
  1. package/assets/BriefPane-8DVHJA2P.js +1 -0
  2. package/assets/{CalendarComposePane-Ct2l8PGF.js → CalendarComposePane-D9qd7bGZ.js} +1 -1
  3. package/assets/{CalendarComposeSeed-BAUjJ5e1.js → CalendarComposeSeed-B2PT6DIT.js} +1 -1
  4. package/assets/{CalendarShell-Csd16Skk.js → CalendarShell-BQ1WtyNw.js} +1 -1
  5. package/assets/{EmptyState-B3SKuNr0.js → EmptyState-B3OfXxGc.js} +1 -1
  6. package/assets/{ErrorState-DRZtXgYN.js → ErrorState-BMamrpRe.js} +1 -1
  7. package/assets/FlaggedPane-CRbYRcWP.js +1 -0
  8. package/assets/{FullCompose-D3rfYvQR.js → FullCompose-DerQv8yu.js} +1 -1
  9. package/assets/MailListHeader-p1q7jsyl.js +7 -0
  10. package/assets/{MailNav-BtW59Nse.js → MailNav-BFwTrlMb.js} +1 -1
  11. package/assets/{MailShell-CYnLaaio.js → MailShell-CdlKuAJL.js} +1 -1
  12. package/assets/{MailViewChrome-BPlYBsFJ.js → MailViewChrome-B80rNMML.js} +1 -1
  13. package/assets/MailboxPane-M52fsGFN.js +1 -0
  14. package/assets/{NavMenuButton-CyLOK_Fk.js → NavMenuButton-D50RaMZU.js} +1 -1
  15. package/assets/OnboardingWizard-CEl2lJ7U.js +1 -0
  16. package/assets/OpenCalendarEvent-D5hdoozI.js +2 -0
  17. package/assets/{OutboxPane-CrGnKSCL.js → OutboxPane-CB96afOq.js} +1 -1
  18. package/assets/_calendarObjectId-BN3X9UxR.js +1 -0
  19. package/assets/_mailboxId-B-9_qjCT.js +1 -0
  20. package/assets/_messageId-BjFEbYZ3.js +1 -0
  21. package/assets/_messageId-BxwJ1oiy.js +1 -0
  22. package/assets/_messageId-DKYMc_-8.js +1 -0
  23. package/assets/_outboxMessageId-psa_yGuH.js +1 -0
  24. package/assets/_recurrenceId-BzKomMk0.js +1 -0
  25. package/assets/_threadId-B8EcS7Wd.js +1 -0
  26. package/assets/_threadId-Dmv-wr_F.js +1 -0
  27. package/assets/_threadId-JlzfAJ6D.js +1 -0
  28. package/assets/{_view._date-CCgrV0Do.js → _view._date-BwqM0JvI.js} +1 -1
  29. package/assets/accounts-DmUwj43_.js +1 -0
  30. package/assets/{advanced-_0mtfFtE.js → advanced-r7Vg3s8i.js} +1 -1
  31. package/assets/{appearance-BLCfg6Ms.js → appearance-D2yGFSyi.js} +1 -1
  32. package/assets/attendee-row-DUsYrdln.js +1 -0
  33. package/assets/{avatar-C6rJXQ1w.js → avatar-BZB5Hlpq.js} +1 -1
  34. package/assets/{bell-off-Cj-19EBu.js → bell-off-DwXjf1FL.js} +1 -1
  35. package/assets/{bottom-sheet-cfK6fTr2.js → bottom-sheet-nV19J7QD.js} +1 -1
  36. package/assets/{brief-D6d93plO.js → brief-B2ypgeON.js} +1 -1
  37. package/assets/brief-DzsHhQWL.js +1 -0
  38. package/assets/{browser-ponyfill-BJcRCbCi.js → browser-ponyfill-Bnv3NEhX.js} +1 -1
  39. package/assets/{bug-CJ2-DjZO.js → bug-umU_Hhi4.js} +1 -1
  40. package/assets/{calendar-BgX2FlCk.js → calendar-BXASaoDs.js} +1 -1
  41. package/assets/{calendar-clash-strip-I8NCaBf8.js → calendar-clash-strip-6sedBGkk.js} +1 -1
  42. package/assets/{calendar-format-BCjw6Wdf.js → calendar-format-DsR-4j-9.js} +1 -1
  43. package/assets/{calendar-report-CWyeC8kX.js → calendar-report-Becs8mIN.js} +1 -1
  44. package/assets/calendar-subscription-B-aAc2Gy.js +1 -0
  45. package/assets/{calendar-suggestion-DwQe-DW4.js → calendar-suggestion-BXJh4QEG.js} +1 -1
  46. package/assets/calendars-C7S_I6-m.js +1 -0
  47. package/assets/{card-6a_o3foG.js → card-C0IHDAlx.js} +1 -1
  48. package/assets/checkbox-BeWcYpqA.js +1 -0
  49. package/assets/chevron-left-DOe-RBwH.js +1 -0
  50. package/assets/{circle-check-DC8HnBjT.js → circle-check-D-kPomlF.js} +1 -1
  51. package/assets/{circle-check-big-BfiUJz9g.js → circle-check-big-B39GqMyR.js} +1 -1
  52. package/assets/{circle-help-DWoa8Ct-.js → circle-help-DRIXmYoN.js} +1 -1
  53. package/assets/{clock-DpXdz1Nu.js → clock-gr-cmcGz.js} +1 -1
  54. package/assets/compose._-_outboxMessageId_-B2eswXYM.js +1 -0
  55. package/assets/compose._-_outboxMessageId_-DqqMcAlY.js +1 -0
  56. package/assets/compose._-_outboxMessageId_-K5592Vip.js +1 -0
  57. package/assets/compose._-_outboxMessageId_-kO-1u07G.js +1 -0
  58. package/assets/{config-import-BYvmrFUu.js → config-import-Co83DTb5.js} +1 -1
  59. package/assets/{confirm-dialog-DOM1mbt4.js → confirm-dialog-GyEqvQcg.js} +1 -1
  60. package/assets/{copy-CrcnK6wu.js → copy-8ycixQYh.js} +1 -1
  61. package/assets/{credential-steps-CyekqOKR.js → credential-steps-DaDeTeqr.js} +1 -1
  62. package/assets/{download-D2-NUPGx.js → download-Cfm8O5nH.js} +1 -1
  63. package/assets/{file-json-DS63hnh9.js → file-json-C9ug2H7s.js} +1 -1
  64. package/assets/{filters-BG_lcZYK.js → filters-fViDxfvJ.js} +1 -1
  65. package/assets/{flagged-XVLchKuy.js → flagged-DT1PrPKY.js} +1 -1
  66. package/assets/flagged-gArKmb7J.js +1 -0
  67. package/assets/{folders-C00jwzez.js → folders-CY8l7ouS.js} +1 -1
  68. package/assets/{help-copy-B65YMhau.js → help-copy-f-EXil2C.js} +1 -1
  69. package/assets/{import-DsorKD37.js → import-Da5lsAbO.js} +1 -1
  70. package/assets/index-B-LTaGCL.js +1 -0
  71. package/assets/{index-Dq0vpG8a.js → index-BNAV6NNi.js} +20 -20
  72. package/assets/index-BP4TLloi.js +1 -0
  73. package/assets/{index-DBfeW6p_.css → index-BZsbyrwY.css} +1 -1
  74. package/assets/index-BjFEbYZ3.js +1 -0
  75. package/assets/index-BxwJ1oiy.js +1 -0
  76. package/assets/index-C7CTxfSm.js +1 -0
  77. package/assets/{index-B8TTkszh.js → index-CSyKycBp.js} +4 -4
  78. package/assets/index-Cnhlqy9N.js +1 -0
  79. package/assets/index-CyHF54Mo.js +1 -0
  80. package/assets/{index-GoftGdCh.js → index-DDna6BIu.js} +1 -1
  81. package/assets/index-DKOrTYxk.js +1 -0
  82. package/assets/index-DOjVIZFA.js +1 -0
  83. package/assets/{kbd-DWOMKFVK.js → kbd-tyVb1kmX.js} +1 -1
  84. package/assets/{labels-NgRyQzax.js → labels-J6NzYHnv.js} +1 -1
  85. package/assets/{mail-C0muzgMb.js → mail-BR9qGPwI.js} +1 -1
  86. package/assets/{mail-CxDqKP0C.js → mail-Be_WuC_w.js} +1 -1
  87. package/assets/{menu-2BgPrZbs.js → menu-DHbVKrar.js} +1 -1
  88. package/assets/minus-DbGv0Sob.js +1 -0
  89. package/assets/new-BwzwU9dD.js +1 -0
  90. package/assets/onboarding-BvFSEHqA.js +1 -0
  91. package/assets/{onboarding-completion-BENx1pJ3.js → onboarding-completion-CNa7a55J.js} +1 -1
  92. package/assets/outbox-eG1sJHnN.js +1 -0
  93. package/assets/{pencil-BoE6dIe7.js → pencil-CfMqBuNm.js} +1 -1
  94. package/assets/{popover-menu-Dci8SQJT.js → popover-menu-RTTJnmds.js} +1 -1
  95. package/assets/{refresh-cw-BLxv_R1t.js → refresh-cw-DEjJXAwL.js} +1 -1
  96. package/assets/{rich-text-JeoGAXcr.js → rich-text-BkfVEWrH.js} +1 -1
  97. package/assets/{rich-text-spellcheck-worker-provider-VT9NFRFA.js → rich-text-spellcheck-worker-provider-MmHdR5b9.js} +1 -1
  98. package/assets/{rotate-ccw-DDVMkqGb.js → rotate-ccw-BePj1nOz.js} +1 -1
  99. package/assets/{roving-focus-Cs6iWufr.js → roving-focus-DxibL2s7.js} +1 -1
  100. package/assets/{row-actions-B4tnhuQT.js → row-actions-vG1W9M0b.js} +1 -1
  101. package/assets/{search-mirror-Bl-Z8zrH.js → search-mirror-B3Rb2QFP.js} +1 -1
  102. package/assets/{search-token-index-DdA7BFEr.js → search-token-index-CbMoDJvO.js} +1 -1
  103. package/assets/{sections-gAf5RAcd.js → sections-D-5U_zIy.js} +1 -1
  104. package/assets/{senders-BYQobI9i.js → senders-BYxpXipO.js} +1 -1
  105. package/assets/settings-CnmG0G_i.js +1 -0
  106. package/assets/{settings-screen-CJYSyIrG.js → settings-screen-DYrNnBXL.js} +1 -1
  107. package/assets/{shield-check-BbOZU-ha.js → shield-check-BR1Itb39.js} +1 -1
  108. package/assets/{suggested-vips-DEV2pvsA.js → suggested-vips-DeCvC6kO.js} +1 -1
  109. package/assets/{undo-2-EliG40fh.js → undo-2-C9sVZCD4.js} +1 -1
  110. package/assets/{useCalendarData-uJPI0R64.js → useCalendarData-xtRjqQ4v.js} +1 -1
  111. package/assets/{useCalendarWrites-yZ3wFhqW.js → useCalendarWrites-D8fkN8Zj.js} +1 -1
  112. package/assets/useCalendars-6Gx83pIc.js +1 -0
  113. package/assets/{useDebouncedValue-BlQHSXzq.js → useDebouncedValue-DBZDUjAb.js} +1 -1
  114. package/assets/{useFilters-BM8eI3xc.js → useFilters-B1O1c8J0.js} +1 -1
  115. package/assets/{useLabels-DCAn9Wiq.js → useLabels-CqJaWt3E.js} +1 -1
  116. package/assets/{useLayoutTier-DV_uk1qc.js → useLayoutTier-B0CJkqKe.js} +1 -1
  117. package/assets/{useMessageBodyContent-SaudvJ_f.js → useMessageBodyContent-CAy2uoxy.js} +1 -1
  118. package/assets/{useQueries-BLlTxIMR.js → useQueries-0wkiftqA.js} +1 -1
  119. package/assets/{useRefreshControl-Dwjheutp.js → useRefreshControl-VAzesut8.js} +1 -1
  120. package/assets/{useResultFolderIndex-HJDBM-FF.js → useResultFolderIndex-BkUvHwSd.js} +1 -1
  121. package/assets/{useSearchTokenContext-CwqK76g8.js → useSearchTokenContext-AypRRqG2.js} +1 -1
  122. package/assets/{useSemanticSearch-BmktGXpn.js → useSemanticSearch-DLp4ptAj.js} +1 -1
  123. package/assets/{useSignature-DsTucVsn.js → useSignature-CWPSLmMO.js} +1 -1
  124. package/index.html +2 -2
  125. package/package.json +1 -1
  126. package/assets/BriefPane-BYct_UtO.js +0 -1
  127. package/assets/FlaggedPane-Co2R0OJZ.js +0 -1
  128. package/assets/MailListHeader-_GRJzk6x.js +0 -7
  129. package/assets/MailboxPane-DRrbQAo3.js +0 -1
  130. package/assets/OnboardingWizard-DLhtJpGm.js +0 -1
  131. package/assets/OpenCalendarEvent-3AF2sHo_.js +0 -2
  132. package/assets/_calendarObjectId-D8U9KvAE.js +0 -1
  133. package/assets/_mailboxId-vktIVctd.js +0 -1
  134. package/assets/_messageId-BfmpGpHr.js +0 -1
  135. package/assets/_messageId-Blt9LZ9Q.js +0 -1
  136. package/assets/_messageId-ClgqHxMZ.js +0 -1
  137. package/assets/_outboxMessageId-y3qV3xL5.js +0 -1
  138. package/assets/_recurrenceId-CDWZOYlU.js +0 -1
  139. package/assets/_threadId-2_3UIOYD.js +0 -1
  140. package/assets/_threadId-BPyTy-By.js +0 -1
  141. package/assets/_threadId-DGPMII_L.js +0 -1
  142. package/assets/accounts-DOaiKAwu.js +0 -1
  143. package/assets/attendee-row-lGaZ_txP.js +0 -1
  144. package/assets/brief-CGtfHT7J.js +0 -1
  145. package/assets/calendars-CGoAiczp.js +0 -1
  146. package/assets/chevron-left-FV6t-DmA.js +0 -1
  147. package/assets/compose._-_outboxMessageId_-BAIi3EPa.js +0 -1
  148. package/assets/compose._-_outboxMessageId_-Bo9y4T_R.js +0 -1
  149. package/assets/compose._-_outboxMessageId_-CTRmYotA.js +0 -1
  150. package/assets/compose._-_outboxMessageId_-DImV9MBm.js +0 -1
  151. package/assets/flagged-DaX5J8Ls.js +0 -1
  152. package/assets/index-B8dy8ZEr.js +0 -1
  153. package/assets/index-B_g7B3Va.js +0 -1
  154. package/assets/index-BfmpGpHr.js +0 -1
  155. package/assets/index-BqLh-WVK.js +0 -1
  156. package/assets/index-CYoWtNGH.js +0 -1
  157. package/assets/index-D4MEpmhl.js +0 -1
  158. package/assets/index-DBzJ3Srp.js +0 -1
  159. package/assets/index-ivD7U85s.js +0 -1
  160. package/assets/index-uwheFgWq.js +0 -1
  161. package/assets/new-BxSfNRA3.js +0 -1
  162. package/assets/onboarding-BnOvNFBK.js +0 -1
  163. package/assets/outbox-Bd9_meE1.js +0 -1
  164. package/assets/settings-C7cdcIE5.js +0 -1
  165. package/assets/useCalendars-Dtgsk_ok.js +0 -1
@@ -1 +0,0 @@
1
- import{j as r,bU as ws,c1 as js,c2 as Ms,cP as Rs,B as ft,f as X,W as Es,t as Re,g as Wt,r as c,_ as Os,$ as As,bw as Ns,cQ as Ge,h as jt,c as mt,ad as zs,i as Mt,cR as Fs,cL as Ds,I as _s,a7 as Ls,a3 as Kt,cS as Ps,cT as Vt,bY as $s,bq as Bs,cU as Ws,cV as Ks,at as qt,cW as Vs,cX as qs,aH as Hs,aI as Qs,cY as Us,cZ as Js,q as Rt,m as Gs,Q as Ht,bt as Ys,K as Xs,bu as Zs,bv as en,c_ as tn,o as sn,E as nn,F as on,c$ as rn,cz as an,s as ln,d0 as cn,d1 as un,d2 as Qt,d3 as Ut,C as Jt,ai as dn,d4 as hn,d5 as fn,ak as mn,bF as gn}from"./index-Dq0vpG8a.js";import{u as pn,p as Dt,R as xn}from"./useSearchTokenContext-CwqK76g8.js";import{u as bn,a as vn,R as Sn}from"./useRefreshControl-Dwjheutp.js";import{C as Gt,r as Et,a as Yt,c as Xt,j as yn,M as Cn,t as Zt,u as In,b as kn,d as es,e as ts,f as Tn,g as wn,h as jn,n as Mn,i as Rn,k as En,S as On,l as An,D as Nn,m as zn,o as Fn,p as ss,q as Dn,s as _n,v as Ln,w as Pn,x as $n,y as ns,z as Bn,A as Wn,B as Kn,E as Vn,F as qn,G as Hn,H as Qn,I as Un,J as Jn,K as _t,L as Lt,N as Gn,O as Yn,P as Xn,Q as Zn,R as eo,T as to,U as so,V as no,W as oo,X as io,Y as ro,Z as ao,_ as os,$ as is,a0 as rs,a1 as lo,a2 as co,a3 as uo,a4 as ho,a5 as fo,a6 as mo,a7 as go,a8 as po}from"./MailListHeader-_GRJzk6x.js";import{S as xo,M as bo,a as vo,u as So,l as yo,b as Co}from"./MailViewChrome-BPlYBsFJ.js";import{A as Ot}from"./avatar-C6rJXQ1w.js";import{c as Io,f as ko,a as To,u as wo}from"./useMessageBodyContent-SaudvJ_f.js";import{e as Ye,f as jo,g as Mo,h as Ro,i as Eo}from"./search-token-index-DdA7BFEr.js";import{N as Oo}from"./NavMenuButton-CyLOK_Fk.js";import{C as Ao}from"./confirm-dialog-DOM1mbt4.js";import{f as No}from"./ErrorState-DRZtXgYN.js";import{a as zo}from"./useLabels-DCAn9Wiq.js";import{L as Fo,r as Do,t as _o,s as Lo,u as Po}from"./useSemanticSearch-BmktGXpn.js";import{S as gt}from"./shield-check-BbOZU-ha.js";import{B as $o}from"./bottom-sheet-cfK6fTr2.js";import{C as Bo}from"./circle-help-DWoa8Ct-.js";import{C as Wo}from"./circle-check-DC8HnBjT.js";import{u as Ko}from"./useLayoutTier-DV_uk1qc.js";import{n as Vo}from"./search-query-Cr_ZXBCp.js";import{u as qo}from"./sections-gAf5RAcd.js";const Ho=e=>e.toLocaleString(),Qo=(e,o)=>{if(e.kind==="unknown")return`Results for “${o}”`;const t=e.value===1?"result":"results";return`${Ho(e.value)} ${t} for “${o}”`};function Uo({query:e,count:o}){return r.jsxs("div",{className:"flex items-center gap-2 border-b border-line bg-surface-sunken/30 px-3 py-2",children:[r.jsx(ws,{className:"size-4 text-fg-muted","aria-hidden":"true"}),r.jsx("span",{className:"text-sm text-fg-muted",children:Qo(o,e)})]})}const Jo=({children:e,onRefresh:o,isRefreshing:t})=>js(Ms)?e:r.jsx(Rs,{onRefresh:o,isPullable:!t,children:e}),Go=e=>e===1?"message":"messages";function Yo({count:e,onReview:o,onDismiss:t,actionLabel:s="Review & rescue"}){return r.jsx(ft,{tone:"info",variant:"soft",onDismiss:t,children:r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsxs("p",{className:"flex items-start gap-2 text-sm text-fg",children:[r.jsx(gt,{className:"mt-0.5 size-4 shrink-0 text-positive","aria-hidden":!0}),r.jsxs("span",{children:[r.jsx("span",{className:"font-semibold text-fg",children:`${e} ${Go(e)} here`})," ","may not be spam — they're from senders we can verify."]})]}),r.jsx(X,{variant:"primary",size:"sm",onClick:o,className:"self-start",children:s})]})})}const Xo=(e,o)=>e==="vip"?"vip":e==="unknown"&&o==="md"?"unknown-pill":"hidden",as=({senderTrust:e,size:o="sm",className:t})=>{const s=Xo(e,o);return s==="vip"?r.jsx(Es,{className:Re("text-warning shrink-0",o==="sm"&&"size-3.5",o==="md"&&"size-4",t),"aria-label":"VIP sender","data-testid":"sender-trust-vip"}):s==="unknown-pill"?r.jsx("span",{className:Re("inline-flex items-center rounded border border-dashed border-fg-subtle/40 font-medium uppercase tracking-wide text-fg-muted/80 shrink-0","px-2 py-0.5 text-xs",t),title:"First message from this sender","aria-label":"First message from this sender","data-testid":"sender-trust-unknown",children:"new"}):null};function Zo({candidate:e,selected:o,onToggle:t,hideSender:s=!1}){const{senderName:n,senderAddress:i,subject:l,snippet:a,trustReason:u,trustSubReason:d,senderTrust:h}=e;return r.jsxs("label",{className:Re("flex w-full cursor-pointer items-start gap-3 px-3 py-2.5 text-left transition-colors",s&&"pl-11",o?"bg-positive/10":"bg-surface hover:bg-surface-sunken"),children:[r.jsx(Gt,{className:"mt-0.5",checked:o,onChange:t,"aria-label":`${o?"Deselect":"Select"} ${s?l:`message from ${n}`}`}),!s&&r.jsx(Ot,{name:n,email:i,size:"sm"}),r.jsxs("span",{className:"min-w-0 flex-1",children:[!s&&r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"truncate text-sm font-medium text-fg",children:n}),h&&r.jsx(as,{senderTrust:h,size:"sm"}),r.jsx("span",{className:"truncate text-2xs text-fg-subtle",children:i})]}),r.jsx("span",{className:"block truncate text-sm text-fg-muted",children:l}),r.jsx("span",{className:"block line-clamp-1 text-xs text-fg-subtle",children:a}),!s&&r.jsxs("span",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[r.jsxs(Wt,{tone:"positive",children:[r.jsx(gt,{className:"size-3","aria-hidden":!0}),u]}),r.jsx("span",{className:"text-2xs text-fg-subtle",children:d})]})]})]})}const ei=e=>{const o=new Map,t=[];for(const s of e){const n=(s.senderAddress||s.senderName).toLowerCase(),i=o.get(n);if(i){i.messages.push(s);continue}o.set(n,{key:n,senderName:s.senderName,senderAddress:s.senderAddress,trustReason:s.trustReason,trustSubReason:s.trustSubReason,senderTrust:s.senderTrust,messages:[s]}),t.push(n)}return t.map(s=>o.get(s)).sort((s,n)=>n.messages.length-s.messages.length)},ti=(e,o)=>{const t=e.messages.filter(s=>o.has(s.id)).length;return t===0?"none":t===e.messages.length?"all":"some"},Pt=e=>e===1?"message":"messages";function si({group:e,selected:o,onToggleGroup:t,onToggleMessage:s}){const[n,i]=c.useState(!1),l=ti(e,o),a=e.messages.length,u=n?Os:As;return r.jsxs("div",{className:Re(l!=="none"?"bg-positive/10":"bg-surface"),children:[r.jsxs("div",{className:"flex w-full items-start gap-3 px-3 py-2.5",children:[r.jsx(Gt,{className:"mt-0.5",checked:l==="all",indeterminate:l==="some",onChange:()=>t(e,l!=="all"),"aria-label":`${l==="all"?"Deselect":"Select"} all ${a} ${Pt(a)} from ${e.senderName}`}),r.jsx(Ot,{name:e.senderName,email:e.senderAddress,size:"sm"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"truncate text-sm font-medium text-fg",children:e.senderName}),e.senderTrust&&r.jsx(as,{senderTrust:e.senderTrust,size:"sm"}),r.jsx("span",{className:"truncate text-2xs text-fg-subtle",children:e.senderAddress})]}),r.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[r.jsxs(Wt,{tone:"positive",children:[r.jsx(gt,{className:"size-3","aria-hidden":!0}),e.trustReason]}),r.jsx("span",{className:"text-2xs text-fg-subtle",children:e.trustSubReason})]})]}),r.jsxs("button",{type:"button",onClick:()=>i(d=>!d),"aria-expanded":n,className:"flex shrink-0 items-center gap-1 rounded-md px-1.5 py-1 text-2xs text-fg-muted transition-colors hover:bg-surface-sunken hover:text-fg",children:[`${a} ${Pt(a)}`,r.jsx(u,{className:"size-3.5","aria-hidden":!0})]})]}),n&&r.jsx("div",{className:"divide-y divide-line border-t border-line",children:e.messages.map(d=>r.jsx(Zo,{candidate:d,selected:o.has(d.id),onToggle:()=>s(d.id),hideSender:!0},d.id))})]})}const At=e=>e===1?"message":"messages",ni=(e,o)=>`Moves ${e===1?"this message":`these ${e} ${At(e)}`} out of Spam to ${o} now. Nothing later.`,wt=(e,o)=>e.find(t=>t.id===o)?.label??"Inbox";function oi(){return r.jsx(ft,{tone:"info",variant:"soft",children:r.jsx("p",{className:"text-2xs text-fg-muted",children:"We list a message here only when we can confirm the sender is who they say — usually someone you've emailed before, write to often, or a service that consistently checks out. We never guess from words in the subject. Anything we can't confirm stays in Spam."})})}function ii({candidates:e,selected:o,onToggle:t,onToggleGroup:s,onSelectAll:n,onSelectNone:i,onContinue:l,onCancel:a}){const[u,d]=c.useState(!1),h=o.size,g=c.useMemo(()=>ei(e),[e]);return r.jsxs("div",{className:"flex min-h-0 flex-col",children:[r.jsxs("div",{className:"px-row-inset pb-2 pt-1",children:[r.jsxs("div",{className:"flex items-start justify-between gap-2",children:[r.jsxs("h2",{className:"flex items-center gap-2 text-sm font-semibold text-fg",children:[r.jsx(gt,{className:"size-4 text-positive","aria-hidden":!0}),"Rescue from Spam"]}),r.jsx(X,{variant:"ghost",size:"sm",icon:r.jsx(Bo,{className:"size-3.5"}),onClick:()=>d(m=>!m),className:"-mr-1.5 -mt-0.5",children:"Why these?"})]}),r.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:"These look safe — from senders we can verify. Uncheck any sender that belongs in Spam, or open a sender to pick individual messages."}),u&&r.jsx("div",{className:"mt-2",children:r.jsx(oi,{})})]}),r.jsxs("div",{className:"flex items-center justify-between px-row-inset pb-1.5",children:[r.jsx("span",{className:"text-2xs font-medium text-fg-muted",children:`${h} of ${e.length} selected · ${g.length} ${g.length===1?"sender":"senders"}`}),r.jsxs("span",{className:"flex gap-1",children:[r.jsx(X,{variant:"ghost",size:"sm",onClick:n,children:"Select all"}),r.jsx(X,{variant:"ghost",size:"sm",onClick:i,children:"Select none"})]})]}),r.jsx("div",{className:"min-h-0 flex-1 divide-y divide-line overflow-y-auto border-y border-line",children:g.map(m=>r.jsx(si,{group:m,selected:o,onToggleGroup:s,onToggleMessage:t},m.key))}),r.jsxs("div",{className:"space-y-2 border-t border-line bg-surface px-row-inset py-3",children:[r.jsx(X,{variant:"primary",onClick:l,className:"h-11 w-full font-semibold",children:`Continue with ${h} ${At(h)}`}),r.jsx(X,{variant:"ghost",onClick:a,className:"h-11 w-full",children:"Cancel"})]})]})}function ri({count:e,folders:o,delimiter:t,destination:s,onPick:n,onMove:i,onBack:l}){const[a,u]=c.useState(!1);return r.jsxs("div",{className:"flex min-h-0 flex-col",children:[r.jsxs("div",{className:"px-row-inset pb-2 pt-1",children:[r.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Where should they go?"}),r.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:"Pick a folder, then we move them out of Spam."})]}),r.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-y-auto px-row-inset py-2",children:a?r.jsx("div",{className:"flex min-h-0 flex-1 overflow-hidden rounded-xl border border-line bg-surface",children:r.jsx(Ns,{folders:o,selectedId:s,delimiter:t,onSelect:n,onCancel:()=>u(!1)})}):r.jsxs("div",{className:"rounded-xl border border-line bg-surface-sunken p-3",children:[r.jsx("p",{className:"text-2xs text-fg-subtle",children:"Destination"}),r.jsx("p",{className:"mt-0.5 text-sm font-medium text-fg",children:wt(o,s)}),r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>u(!0),className:"mt-2 px-0",children:"Move to a different folder"})]})}),r.jsxs("div",{className:"space-y-2 border-t border-line bg-surface px-row-inset py-3",children:[r.jsx("p",{className:"text-2xs text-fg-subtle",children:ni(e,wt(o,s))}),r.jsx(X,{variant:"primary",onClick:i,className:"h-11 w-full font-semibold",children:`Move ${e} out of Spam`}),r.jsx(X,{variant:"ghost",onClick:l,className:"h-11 w-full",children:"Back"})]})]})}function ai({count:e,destinationLabel:o,onClose:t}){return r.jsxs("div",{className:"flex min-h-0 flex-col",children:[r.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-row-inset py-10 text-center",children:[r.jsx(Wo,{className:"size-10 text-positive","aria-hidden":!0}),r.jsx("p",{className:"text-base font-semibold text-fg",children:`Moved ${e} ${At(e)} out of Spam.`}),r.jsx("p",{className:"text-2xs text-fg-subtle",children:`You'll find them in ${o}.`})]}),r.jsx("div",{className:"border-t border-line bg-surface px-row-inset py-3",children:r.jsx(X,{variant:"primary",onClick:t,className:"h-11 w-full font-semibold",children:"Done"})})]})}function li({open:e,candidates:o,defaultDestinationId:t,availableFolders:s,delimiter:n,onConfirmMove:i,onCancel:l}){const[a,u]=c.useState("review"),[d,h]=c.useState(()=>e?new Set(o.map(k=>k.id)):new Set),[g,m]=c.useState(t),[p,S]=c.useState(0),y=c.useRef(!1);c.useEffect(()=>{e&&!y.current&&(u("review"),h(new Set(o.map(k=>k.id))),m(t),S(0)),y.current=e},[e,o,t]);const I=d.size,b=k=>{h(w=>{const O=new Set(w);return O.has(k)?O.delete(k):O.add(k),O})},x=(k,w)=>{h(O=>{const A=new Set(O);for(const B of k.messages)w?A.add(B.id):A.delete(B.id);return A})},j=()=>{const k=Array.from(d);S(k.length),i(k,g),u("done")};return r.jsxs($o,{open:e,onClose:l,label:"Rescue from spam",dismissLabel:"Close rescue",children:[a==="review"&&r.jsx(ii,{candidates:o,selected:d,onToggle:b,onToggleGroup:x,onSelectAll:()=>h(new Set(o.map(k=>k.id))),onSelectNone:()=>h(new Set),onContinue:()=>u("destination"),onCancel:l}),a==="destination"&&r.jsx(ri,{count:I,folders:s,delimiter:n,destination:g,onPick:m,onMove:j,onBack:()=>u("review")}),a==="done"&&r.jsx(ai,{count:p,destinationLabel:wt(s,g),onClose:l})]})}function ci(e){const o=e.toAddresses.join(", ");return{id:e.outboxMessageId,accountId:e.accountId,fromName:e.fromName??e.fromAddress??"Me",fromEmail:e.fromAddress??"",subject:e.subject??"(No subject)",snippet:o?`To: ${o}`:"(No recipients)",timeLabel:Ge(e.updatedAt),isRead:!0}}function ui(e){return{id:e.messageId,accountId:e.accountId,fromName:e.fromName??e.fromEmail??"Unknown",fromEmail:e.fromEmail??"",subject:e.subject??"(No subject)",snippet:e.snippet??"",timeLabel:Ge(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,...Et(e)}}function di({outboxMessages:e,accountId:o,imapThreads:t}){const s=e.filter(l=>l.status==="draft"&&l.accountId===o).map(ci),n=t.map(ui),i=[];return s.length>0&&i.push({id:"remit-drafts",label:"Not yet sent (Remit)",threads:s}),n.length>0&&i.push({id:"imap-drafts",label:"On the server",threads:n}),i}const hi=({label:e,count:o})=>r.jsxs("div",{className:"sticky top-0 z-10 flex items-baseline justify-between border-b border-line bg-surface-sunken px-row-inset py-1",children:[r.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:e}),r.jsx("span",{className:"text-2xs text-fg-subtle tabular-nums",children:o})]}),fi=({row:e,isSelected:o,onOpen:t,onDelete:s,isDeleting:n})=>r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:Re("group",Xt({active:o})),children:[r.jsx(Ls,{className:"size-7 shrink-0 text-fg-muted mt-0.5"}),r.jsx(Yt,{thread:e}),r.jsx("div",{className:"flex items-center gap-1 shrink-0",children:r.jsx("button",{type:"button",onClick:i=>{i.stopPropagation(),s(e.id)},disabled:n,className:"p-1.5 rounded-md text-fg-muted hover:text-danger hover:bg-surface-raised transition-colors opacity-0 group-hover:opacity-100 focus:opacity-100",title:"Delete draft",children:r.jsx(Kt,{className:"size-3.5"})})})]}),mi=({row:e,isSelected:o,onOpen:t})=>{const s=!e.isRead;return r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:Re("group",Xt({active:o})),children:[s&&r.jsx("span",{className:"absolute left-1.5 top-1/2 size-1.5 -translate-y-1/2 rounded-full bg-accent"}),r.jsx(Ot,{name:e.fromName,email:e.fromEmail,size:"sm"}),r.jsx(Yt,{thread:e})]})};function gi({accountId:e,selectedMessageId:o,imapThreads:t,title:s,unreadCount:n}){const i=Io(),l=ko(),a=Ye(),u=jt(),{data:d}=mt(zs()),h=c.useMemo(()=>di({outboxMessages:d?.items??[],accountId:e,imapThreads:t}),[d?.items,e,t]),g=Mt({...Ds(),onSuccess:()=>{u.invalidateQueries({queryKey:Fs()})}}),m=y=>{g.mutate({path:{outboxMessageId:y}})},p=y=>{const I=t.find(b=>b.messageId===y)?.threadId;I&&a({threadId:I,messageId:y})},S=h.length===0;return r.jsxs("section",{className:"flex h-full w-full flex-col bg-surface",children:[r.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[r.jsx(Oo,{}),r.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:s}),(n??0)>0&&r.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:[n," unread"]})]}),r.jsx("div",{className:"flex-1 overflow-y-auto",children:S?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 text-center px-4",children:[r.jsx(_s,{className:"size-8 text-fg-subtle"}),r.jsx("p",{className:"text-sm font-medium text-fg",children:"No drafts"}),r.jsx("p",{className:"text-xs text-fg-subtle",children:"Messages you start composing will appear here."})]}):h.map(y=>r.jsxs("div",{children:[y.label&&r.jsx(hi,{label:y.label,count:y.threads.length}),r.jsx("div",{className:"divide-y divide-line",children:y.threads.map(I=>y.id==="remit-drafts"?r.jsx(fi,{row:I,isSelected:I.id===i,onOpen:l,onDelete:m,isDeleting:g.isPending},I.id):r.jsx(mi,{row:I,isSelected:I.id===o,onOpen:p},I.id))})]},y.id))})]})}const ls=e=>e===1?"1 message":`${Vt(e)} messages`,pi=e=>({title:"Empty Trash?",description:`${ls(e)} ${e===1?"is":"are"} erased from the mail server and cannot be restored.`,confirmLabel:"Empty Trash"}),xi=(e,o={})=>{const{trashFolderLabel:t,staleFolderLabel:s}=o;if(e==="unconfirmed"){const n=Ps(0,"unconfirmed",{trashFolderLabel:t});return{headline:n.title,body:n.description,actionLabel:n.confirmLabel}}return e==="stale"?{headline:"Nothing was emptied.",body:s?`The folder you chose for Trash — ${s} — is gone from the mail server.`:"The folder you chose for Trash is gone from the mail server.",actionLabel:"Pick another folder"}:{headline:"Nothing was emptied.",body:"No folder on this account is set as Trash.",actionLabel:"Pick a folder"}};function bi({messageCount:e,isEmptying:o,deletedCount:t,refusalReason:s,trashFolderLabel:n,staleFolderLabel:i,onEmpty:l,onRepair:a,children:u}){const[d,h]=c.useState(!1);if(e<1&&s===void 0&&t===void 0)return r.jsx(r.Fragment,{children:u});const g=s?xi(s,{trashFolderLabel:n,staleFolderLabel:i}):void 0,m=pi(e);return r.jsxs("div",{className:"relative flex h-full min-h-0 flex-col",children:[r.jsx("div",{className:"shrink-0 px-row-inset pt-2",children:r.jsxs("div",{className:"flex flex-col gap-2 rounded-md border border-line px-3 py-2",children:[r.jsxs("div",{className:"flex items-center justify-end gap-2",children:[t!==void 0&&r.jsx("p",{className:"mr-auto text-2xs text-fg-subtle",role:"status",children:`${ls(t)} erased from the mail server.`}),r.jsx(X,{variant:"ghost",size:"sm",icon:r.jsx(Kt,{className:"size-3.5","aria-hidden":!0}),disabled:o||e<1,"aria-busy":o,onClick:()=>h(!0),children:o?"Emptying…":"Empty Trash"})]}),g&&r.jsx(ft,{tone:"warning",variant:"soft",children:r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx("p",{className:"font-semibold text-fg",children:g.headline}),r.jsx("p",{className:"text-sm",children:g.body}),r.jsx(X,{variant:"primary",size:"sm",className:"self-start",onClick:a,children:g.actionLabel})]})})]})}),r.jsx("div",{className:"min-h-0 flex-1",children:u}),r.jsx(Ao,{isOpen:d,title:m.title,description:m.description,confirmLabel:m.confirmLabel,destructive:!0,onConfirm:()=>{h(!1),l()},onCancel:()=>h(!1)})]})}function vi(e,o,t){const s=new Array(e);return new Proxy(s,{get(n,i,l){if(typeof i=="string"){const a=i.charCodeAt(0);if(a>=48&&a<=57){const u=+i;if(Number.isInteger(u)&&u>=0&&u<e){let d=n[u];if(!d){const h=o[u*2];d=n[u]={index:u,key:t(u),start:h,size:o[u*2+1],end:h+o[u*2+1],lane:0}}return d}}if(i==="length")return e}return Reflect.get(n,i,l)}})}function Le(e,o,t){let s=t.initialDeps??[],n,i=!0;function l(){const a=e();return(a.length!==s.length||a.some((d,h)=>s[h]!==d))&&(s=a,n=o(...a),t?.onChange&&!(i&&t.skipInitialOnChange)&&t.onChange(n),i=!1),n}return l.updateDeps=a=>{s=a},l}function $t(e,o){if(e===void 0)throw new Error("Unexpected undefined");return e}const Si=(e,o)=>Math.abs(e-o)<1.01,yi=(e,o,t)=>{let s;return function(...n){e.clearTimeout(s),s=e.setTimeout(()=>o.apply(this,n),t)}};let Je;const kt=()=>{if(Je!==void 0)return Je;if(typeof navigator>"u")return Je=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Je=!0;const e=navigator.maxTouchPoints;return Je=navigator.platform==="MacIntel"&&e!==void 0&&e>0},Bt=e=>{const{offsetWidth:o,offsetHeight:t}=e;return{width:o,height:t}},Ci=e=>e,Ii=e=>{const o=Math.max(e.startIndex-e.overscan,0),s=Math.min(e.endIndex+e.overscan,e.count-1)-o+1,n=new Array(s);for(let i=0;i<s;i++)n[i]=o+i;return n},ki=(e,o)=>{const t=e.scrollElement;if(!t)return;const s=e.targetWindow;if(!s)return;const n=l=>{const{width:a,height:u}=l;o({width:Math.round(a),height:Math.round(u)})};if(n(Bt(t)),!s.ResizeObserver)return()=>{};const i=new s.ResizeObserver(l=>{const a=()=>{const u=l[0];if(u?.borderBoxSize){const d=u.borderBoxSize[0];if(d){n({width:d.inlineSize,height:d.blockSize});return}}n(Bt(t))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return i.observe(t,{box:"border-box"}),()=>{i.unobserve(t)}},ht={passive:!0},Ti=typeof window>"u"?!0:"onscrollend"in window,wi=(e,o,t)=>{const s=e.scrollElement;if(!s)return;const n=e.targetWindow;if(!n)return;const i=e.options.useScrollendEvent&&Ti;let l=0;const a=i?null:yi(n,()=>o(l,!1),e.options.isScrollingResetDelay),u=g=>()=>{l=t(s),a?.(),o(l,g)},d=u(!0),h=u(!1);return s.addEventListener("scroll",d,ht),i&&s.addEventListener("scrollend",h,ht),()=>{s.removeEventListener("scroll",d),i&&s.removeEventListener("scrollend",h)}},ji=(e,o)=>wi(e,o,t=>{const{horizontal:s,isRtl:n}=e.options;return s?t.scrollLeft*(n&&-1||1):t.scrollTop}),Mi=(e,o,t)=>{if(t.options.useCachedMeasurements){const s=t.indexFromElement(e),n=t.options.getItemKey(s);return t.itemSizeCache.get(n)??t.options.estimateSize(s)}if(o?.borderBoxSize){const s=o.borderBoxSize[0];if(s)return Math.round(s[t.options.horizontal?"inlineSize":"blockSize"])}if(!o){const s=t.indexFromElement(e),n=t.options.getItemKey(s),i=t.itemSizeCache.get(n);if(i!==void 0)return i}return e[t.options.horizontal?"offsetWidth":"offsetHeight"]},Ri=(e,{adjustments:o=0,behavior:t},s)=>{var n,i;(i=(n=s.scrollElement)==null?void 0:n.scrollTo)==null||i.call(n,{[s.options.horizontal?"left":"top"]:e+o,behavior:t})},Ei=Ri;class Oi{constructor(o){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var t,s,n;return((n=(s=(t=this.targetWindow)==null?void 0:t.performance)==null?void 0:s.now)==null?void 0:n.call(s))??Date.now()},this.observer=(()=>{let t=null;const s=()=>t||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:t=new this.targetWindow.ResizeObserver(n=>{n.forEach(i=>{const l=()=>{const a=i.target,u=this.indexFromElement(a);if(!a.isConnected){this.observer.unobserve(a);for(const[d,h]of this.elementsCache)if(h===a){this.elementsCache.delete(d);break}return}this.shouldMeasureDuringScroll(u)&&this.resizeItem(u,this.options.measureElement(a,i,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()})}));return{disconnect:()=>{var n;(n=s())==null||n.disconnect(),t=null},observe:n=>{var i;return(i=s())==null?void 0:i.observe(n,{box:"border-box"})},unobserve:n=>{var i;return(i=s())==null?void 0:i.unobserve(n)}}})(),this.range=null,this.setOptions=t=>{var s,n;const i={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Ci,rangeExtractor:Ii,onChange:()=>{},measureElement:Mi,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const m in t){const p=t[m];p!==void 0&&(i[m]=p)}const l=this.options;let a=null,u=null,d=!1;if(l!==void 0&&l.enabled&&i.enabled&&i.anchorTo==="end"&&this.scrollElement!==null){const m=l.count,p=i.count,S=this.getMeasurements(),y=m>0?((s=S[0])==null?void 0:s.key)??l.getItemKey(0):null,I=m>0?((n=S[m-1])==null?void 0:n.key)??l.getItemKey(m-1):null;if(p!==m||m>0&&p>0&&(i.getItemKey(0)!==y||i.getItemKey(p-1)!==I)){d=!0;const j=m>0?this.getVirtualItemForOffset(this.getScrollOffset())??S[0]:null;j&&(a=[j.key,this.getScrollOffset()-j.start]);const k=i.followOnAppend===!0?"auto":i.followOnAppend||null;k&&p>m&&this.isAtEnd(l.scrollEndThreshold)&&(m===0||i.getItemKey(p-1)!==I)&&(u=k)}}this.options=i,d&&(this.pendingMin=0,this.itemSizeCacheVersion++);let h=!1,g=0;if(a&&this.scrollOffset!==null){const[m,p]=a,S=this.getMeasurements(),{count:y,getItemKey:I}=this.options;let b=0;for(;b<y&&I(b)!==m;)b++;if(b<y){const x=S[b];if(x){const j=x.start+p;j!==this.scrollOffset&&(g=j-this.scrollOffset,this.scrollOffset=j,h=!0)}}}(h||u)&&(this.pendingScrollAnchor=[h?a[0]:null,h?a[1]:0,u,g])},this.notify=t=>{var s,n;(n=(s=this.options).onChange)==null||n.call(s,this,t)},this.maybeNotify=Le(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),t=>{this.notify(t)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(t=>t()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var t;const s=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==s){if(this.cleanup(),!s){this.maybeNotify();return}if(this.scrollElement=s,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((t=this.scrollElement)==null?void 0:t.window)??null,this.elementsCache.forEach(i=>{this.observer.observe(i)}),this.unsubs.push(this.options.observeElementRect(this,i=>{this.scrollRect=i,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(i,l)=>{if(l&&this._intendedScrollOffset===null&&i===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(i-this._intendedScrollOffset)<1.5&&(i=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;const a=this.getScrollOffset();this.scrollDirection=l?a===i?this.scrollDirection:a<i?"forward":"backward":null,this.scrollOffset=i,this.isScrolling=l,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const i=this.scrollElement,l=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},a=()=>{this._iosTouching=!1,!(!kt()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};i.addEventListener("touchstart",l,ht),i.addEventListener("touchend",a,ht),this.unsubs.push(()=>{i.removeEventListener("touchstart",l),i.removeEventListener("touchend",a),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const n=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,n&&this.scrollElement&&this.options.enabled){const[i,l,a,u]=n;i!==null&&!a&&(kt()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?u!==0&&(this._iosDeferredAdjustment+=u):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),a&&this.scrollToEnd({behavior:a})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const t=this.getScrollOffset(),s=this.getMaxScrollOffset();if(t<0||t>s)return;const n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(t,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=Le(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(t,s,n,i,l,a,u,d)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:t,paddingStart:s,scrollMargin:n,getItemKey:i,enabled:l,lanes:a,laneAssignmentMode:u,gap:d}),{key:!1}),this.getMeasurements=Le(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:t,paddingStart:s,scrollMargin:n,getItemKey:i,enabled:l,lanes:a,laneAssignmentMode:u,gap:d},h)=>{const g=this.itemSizeCache;if(!l)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>t)for(const b of this.laneAssignments.keys())b>=t&&this.laneAssignments.delete(b);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(b=>{this.itemSizeCache.set(b.key,b.size)}));const m=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===t&&(this.lanesSettling=!1),a===1){const b=t*2;let x=this._flatMeasurements;if(!x||x.length<b){const w=new Float64Array(b);x&&m>0&&w.set(x.subarray(0,m*2)),x=w,this._flatMeasurements=x}let j;if(m===0)j=s+n;else{const w=m-1;j=x[w*2]+x[w*2+1]+d}for(let w=m;w<t;w++){const O=i(w),A=g.get(O),B=typeof A=="number"?A:this.options.estimateSize(w);x[w*2]=j,x[w*2+1]=B,j+=B+d}const k=vi(t,x,i);return this.measurementsCache=k,k}const p=this.measurementsCache.slice(0,m),S=new Array(a).fill(void 0),y=new Float64Array(a);let I=0;for(let b=0;b<m;b++){const x=p[b];x&&(S[x.lane]===void 0&&I++,S[x.lane]=b,y[x.lane]=x.end)}for(let b=m;b<t;b++){const x=i(b),j=this.laneAssignments.get(b);let k,w;const O=u==="estimate"||g.has(x);if(j!==void 0&&this.options.lanes>1){k=j;const G=S[k],R=G!==void 0?p[G]:void 0;w=R?R.end+d:s+n}else if(I===a){let G=0,R=y[0],oe=S[0];for(let F=1;F<a;F++){const P=y[F];(P<R||P===R&&S[F]<oe)&&(G=F,R=P,oe=S[F])}k=G,w=R+d,O&&this.laneAssignments.set(b,k)}else k=b%this.options.lanes,w=s+n,O&&this.laneAssignments.set(b,k);const A=g.get(x),B=typeof A=="number"?A:this.options.estimateSize(b),J=w+B;p[b]={index:b,start:w,size:B,end:J,key:x,lane:k},S[k]===void 0&&I++,S[k]=b,y[k]=J}return this.measurementsCache=p,p},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Le(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,s,n,i)=>t.length===0||s===0?(this.range=null,null):(this.range=Ni(t,s,n,i,i===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Le(()=>{let t=null,s=null;const n=this.calculateRange();return n&&(t=n.startIndex,s=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,s]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,s]},(t,s,n,i,l)=>i===null||l===null?[]:t({startIndex:i,endIndex:l,overscan:s,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=t=>{const s=this.options.indexAttribute,n=t.getAttribute(s);return n?parseInt(n,10):(console.warn(`Missing attribute name '${s}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=t=>{var s;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const n=this.scrollState.index??((s=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:s.index);if(n!==void 0&&this.range){const i=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),l=Math.max(0,n-i),a=Math.min(this.options.count-1,n+i);return t>=l&&t<=a}return!0},this.measureElement=t=>{if(!t){this.elementsCache.forEach((l,a)=>{l.isConnected||(this.observer.unobserve(l),this.elementsCache.delete(a))});return}const s=this.indexFromElement(t),n=this.options.getItemKey(s),i=this.elementsCache.get(n);i!==t&&(i&&this.observer.unobserve(i),this.observer.observe(t),this.elementsCache.set(n,t)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(s)&&this.resizeItem(s,this.options.measureElement(t,void 0,this))},this.resizeItem=(t,s)=>{var n,i;if(t<0||t>=this.options.count)return;let l,a,u;const d=this._flatMeasurements;if(this.options.lanes===1&&d!==null)u=this.options.getItemKey(t),a=d[t*2],l=d[t*2+1];else{const m=this.measurementsCache[t];if(!m)return;u=m.key,a=m.start,l=m.size}const h=this.itemSizeCache.get(u)??l,g=s-h;if(g!==0){const m=this.options.anchorTo==="end"&&((n=this.scrollState)==null?void 0:n.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,p=m?this.getTotalSize():0,S=((i=this.scrollState)==null?void 0:i.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[t]??{index:t,key:u,start:a,size:l,end:a+l,lane:0},g,this):a<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(u)||this.scrollDirection!=="backward"));(this.pendingMin===null||t<this.pendingMin)&&(this.pendingMin=t),this.itemSizeCache.set(u,s),this.itemSizeCacheVersion++,m?this.applyScrollAdjustment(this.getTotalSize()-p):S&&this.applyScrollAdjustment(g),this.notify(!1)}},this.getVirtualItems=Le(()=>[this.getVirtualIndexes(),this.getMeasurements()],(t,s)=>{const n=[];for(let i=0,l=t.length;i<l;i++){const a=t[i],u=s[a];n.push(u)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=t=>{const s=this.getMeasurements();if(s.length===0)return;const n=this._flatMeasurements,i=this.options.lanes===1&&n!=null,l=cs(0,s.length-1,i?a=>n[a*2]:a=>$t(s[a]).start,t);return $t(s[l])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const t=this.scrollElement.document.documentElement;return this.options.horizontal?t.scrollWidth-this.scrollElement.innerWidth:t.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(t=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=t,this.getOffsetForAlignment=(t,s,n=0)=>{if(!this.scrollElement)return 0;const i=this.getSize(),l=this.getScrollOffset();s==="auto"&&(s=t>=l+i?"end":"start"),s==="center"?t+=(n-i)/2:s==="end"&&(t-=i);const a=this.getMaxScrollOffset();return Math.max(Math.min(a,t),0)},this.getOffsetForIndex=(t,s="auto")=>{t=Math.max(0,Math.min(t,this.options.count-1));const n=this.getSize(),i=this.getScrollOffset(),l=this.measurementsCache[t];if(!l)return;if(s==="auto")if(l.end>=i+n-this.options.scrollPaddingEnd)s="end";else if(l.start<=i+this.options.scrollPaddingStart)s="start";else return[i,s];if(s==="end"&&t===this.options.count-1)return[this.getMaxScrollOffset(),s];const a=s==="end"?l.end+this.options.scrollPaddingEnd:l.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,s,l.size),s]},this.scrollToOffset=(t,{align:s="start",behavior:n="auto"}={})=>{const i=this.getOffsetForAlignment(t,s),l=this.now();this.scrollState={index:null,align:s,behavior:n,startedAt:l,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(t,{align:s="auto",behavior:n="auto"}={})=>{t=Math.max(0,Math.min(t,this.options.count-1));const i=this.getOffsetForIndex(t,s);if(!i)return;const[l,a]=i,u=this.now();this.scrollState={index:t,align:a,behavior:n,startedAt:u,lastTargetOffset:l,stableFrames:0},this._scrollToOffset(l,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(t,{behavior:s="auto"}={})=>{const n=this.getScrollOffset()+t,i=this.now();this.scrollState={index:null,align:"start",behavior:s,startedAt:i,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:s}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:t="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:t});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:t})},this.getTotalSize=()=>{var t;const s=this.getMeasurements();let n;if(s.length===0)n=this.options.paddingStart;else if(this.options.lanes===1){const i=s.length-1,l=this._flatMeasurements;l!=null?n=l[i*2]+l[i*2+1]:n=((t=s[i])==null?void 0:t.end)??0}else{const i=Array(this.options.lanes).fill(null);let l=s.length-1;for(;l>=0&&i.some(a=>a===null);){const a=s[l];i[a.lane]===null&&(i[a.lane]=a.end),l--}n=Math.max(...i.filter(a=>a!==null))}return Math.max(n-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const t=[];if(this.itemSizeCache.size===0)return t;const s=this.getMeasurements();for(const n of s)n&&this.itemSizeCache.has(n.key)&&t.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return t},this._scrollToOffset=(t,{adjustments:s,behavior:n})=>{this._intendedScrollOffset=t+(s??0),this.options.scrollToFn(t,{behavior:n,adjustments:s},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(o)}applyScrollAdjustment(o,t){o!==0&&(kt()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=o:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=o,behavior:t}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollAdjustments=0)))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const s=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,n=s?s[0]:this.scrollState.lastTargetOffset,i=1,l=n!==this.scrollState.lastTargetOffset;if(!l&&Si(n,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=i){this.getScrollOffset()!==n&&this._scrollToOffset(n,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,l){const a=this.getSize()||600,u=Math.abs(n-this.getScrollOffset()),d=this.scrollState.behavior==="smooth"&&u>a;this.scrollState.lastTargetOffset=n,d||(this.scrollState.behavior="auto"),this._scrollToOffset(n,{adjustments:void 0,behavior:d?"smooth":"auto"})}this.scheduleScrollReconcile()}}const cs=(e,o,t,s)=>{for(;e<=o;){const n=(e+o)/2|0,i=t(n);if(i<s)e=n+1;else if(i>s)o=n-1;else return n}return e>0?e-1:0};function Ai(e,o,t){let s=0;for(;s<=o;){const n=(s+o)/2|0,i=e[n*2];if(i<t)s=n+1;else if(i>t)o=n-1;else return n}return s>0?s-1:0}function Ni(e,o,t,s,n){const i=e.length-1;if(e.length<=s)return{startIndex:0,endIndex:i};if(s===1&&n!==null){const d=Ai(n,i,t);let h=d;const g=t+o;for(;h<i&&n[h*2]+n[h*2+1]<g;)h++;return{startIndex:d,endIndex:h}}let a=cs(0,i,d=>e[d].start,t),u=a;if(s===1)for(;u<i&&e[u].end<t+o;)u++;else if(s>1){const d=Array(s).fill(0);for(;u<i&&d.some(g=>g<t+o);){const g=e[u];d[g.lane]=g.end,u++}const h=Array(s).fill(t+o);for(;a>=0&&h.some(g=>g>=t);){const g=e[a];h[g.lane]=g.start,a--}a=Math.max(0,a-a%s),u=Math.min(i,u+(s-1-u%s))}return{startIndex:a,endIndex:u}}const Tt=typeof document<"u"?c.useLayoutEffect:c.useEffect;function zi({useFlushSync:e=!0,directDomUpdates:o=!1,directDomUpdatesMode:t="transform",...s}){const n=c.useReducer(d=>d+1,0)[1],i=c.useRef({enabled:o,mode:t,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});i.current.enabled=o,i.current.mode=t;const l=d=>{const h=i.current;if(!h.enabled||!h.container)return;const g=d.getTotalSize();if(g!==h.lastSize){h.lastSize=g;const b=d.options.horizontal?"width":"height";h.container.style[b]=`${g}px`}const m=!!d.options.horizontal,p=h.mode==="transform",S=m?"left":"top",y=d.options.scrollMargin,I=d.getVirtualItems();for(const b of I){const x=b.start-y,j=d.elementsCache.get(b.key);j&&h.lastPositions.get(j)!==x&&(h.lastPositions.set(j,x),p?j.style.transform=m?`translate3d(${x}px, 0, 0)`:`translate3d(0, ${x}px, 0)`:j.style[S]=`${x}px`)}},a={...s,onChange:(d,h)=>{var g;const m=i.current;let p=!0;if(m.enabled){l(d);const S=d.range,y=m.prevRange;p=!y||y.isScrolling!==d.isScrolling||y.startIndex!==S?.startIndex||y.endIndex!==S?.endIndex,p&&(m.prevRange=S?{startIndex:S.startIndex,endIndex:S.endIndex,isScrolling:d.isScrolling}:null)}p&&(e&&h?$s.flushSync(n):n()),(g=s.onChange)==null||g.call(s,d,h)}},[u]=c.useState(()=>{const d=new Oi(a);return Object.assign(d,{containerRef:h=>{const g=i.current;if(g.container=h,g.lastSize=null,h&&g.enabled){const m=d.getTotalSize();g.lastSize=m;const p=d.options.horizontal?"width":"height";h.style[p]=`${m}px`}}})});return u.setOptions(a),Tt(()=>u._didMount(),[]),Tt(()=>u._willUpdate()),Tt(()=>{l(u)}),u}function Fi(e){return zi({observeElementRect:ki,observeElementOffset:ji,scrollToFn:Ei,...e})}const Nt=e=>e.query?`matching "${e.query}"`:e.from?`from "${e.from}"`:"matching your search",Di=e=>`Select all ${Nt(e)}`,_i=(e,o)=>`All ${Vt(o)} ${Nt(e)} selected`,Li=({verb:e,confirmingDelete:o,hasSelection:t,junkMailboxId:s,currentMailboxId:n,deletableMessageId:i})=>{if(o)return{kind:"withheld"};if(e==="junk"){const l=yn(s,n);if(l!==void 0)return{kind:"unavailable",reason:l}}return t?{kind:"openWizard"}:e!=="delete"||i===void 0?{kind:"declined"}:{kind:"confirmDelete",messageId:i}},Pi=(e,o,t)=>e==="BACK"&&o&&t===void 0,$i=(e,o)=>({id:e.messageId,accountId:e.accountId,mailboxId:e.mailboxId,threadId:e.threadId,fromName:e.fromName??e.fromEmail??"Unknown",fromEmail:e.fromEmail??"",subject:e.subject??"(No subject)",snippet:e.snippet??"",timeLabel:Ge(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:Zt(e.category),messageCount:o,suspicious:e.authenticity?.dkimMismatch===!0,labels:e.labels,...Et(e)}),Bi=({thread:e,mailboxId:o,isSelected:t,isFocused:s,isTabStop:n,onFocusRow:i,isChecked:l,onToggleCheck:a,onRowSelect:u,messageCount:d,isMultiSelectMode:h,onLongPress:g,isDesktop:m,density:p})=>r.jsx(Cn,{thread:$i(e,d),link:{mailboxId:o,threadId:e.threadId},inListbox:!0,active:t,focused:s,isTabStop:n,density:p,isDesktop:m,onFocusRow:i,selection:{isChecked:l,onToggleCheck:a,onRowSelect:u,isMultiSelectMode:h,onLongPress:g}}),Wi=c.memo(Bi),Ki=e=>{const o=e.authenticity?.dkimMismatch===!0;return{id:e.messageId,accountId:e.accountId,fromName:e.fromName??e.fromEmail??"Unknown",fromEmail:e.fromEmail??"",subject:e.subject??"(No subject)",snippet:e.snippet??"",timeLabel:Ge(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:Zt(e.category),suspicious:o,...Et(e)}},Vi=({thread:e,mailboxId:o,isSelected:t,isFocused:s,isTabStop:n,onFocusRow:i,isChecked:l,onToggleCheck:a,onRowSelect:u,isMultiSelectMode:d,onLongPress:h,isDesktop:g,onDelete:m,onToggleRead:p,density:S})=>{const[y,I]=c.useState("none"),b=Ye(),x=c.useCallback(A=>{navigator.vibrate?.(10),A==="trailing"?m(e.messageId):p(e.messageId,e.isRead),I("none")},[m,p,e.messageId,e.isRead]),j=c.useCallback(()=>{h(e.messageId)},[h,e.messageId]),k=c.useCallback(()=>{a(e.messageId)},[a,e.messageId]),w=c.useCallback(()=>{b({threadId:e.threadId,messageId:e.messageId})},[b,e.threadId,e.messageId]),O=In(e.messageId,u);return g||d?r.jsx(Wi,{thread:e,mailboxId:o,isSelected:t,isFocused:s,isTabStop:n,onFocusRow:i,isChecked:l,onToggleCheck:a,onRowSelect:u,isMultiSelectMode:d,onLongPress:h,isDesktop:g,density:S}):r.jsx("div",{role:"presentation",onPointerDownCapture:O.onMouseDown,onClickCapture:O.claimClick,onContextMenu:O.onContextMenu,children:r.jsx(xo,{thread:Ki(e),selectionMode:!1,checked:!1,active:t,peek:y,onPeek:I,onToggleCheck:k,onLongPress:j,onOpen:w,onAct:x})})},qi=72,Hi=32,Qi=5,us="remit:list-density",Ui=()=>{try{const e=localStorage.getItem(us);if(e==="compact"||e==="comfortable")return e}catch{}return"comfortable"},Ji=(e,o,t)=>Do(e.filter(s=>o.has(s.messageId)).map(s=>s.accountId??t)).moveDisabledHint,Gi=({mailboxId:e,threads:o,selectedMessageId:t,isLoading:s,isError:n=!1,error:i,onRetry:l,searchQuery:a,searchPredicate:u,resultCount:d={kind:"unknown"},onDeleteMessages:h,isDeleting:g=!1,isMoving:m=!1,onLoadMore:p,hasMore:S=!1,isLoadingMore:y=!1,accountId:I,listTitle:b,listMeta:x,listFilter:j,listSearchText:k,listScopeLabel:w,onTriageContextChange:O,commandsRef:A,hideHeader:B=!1})=>{const J=c.useRef(null),G=Ye(),R=Bs(),oe=Ws(),{verb:F,start:P,startFromSearch:Ee}=oe,Se=Ks(),ye=!!a?.trim(),W=kn(),{labels:Pe}=zo(I),{pushError:ie}=qt(),[M,Ce]=c.useState(t),[Oe,Ie]=c.useState(),N=c.useCallback(f=>{Ie(v=>v===f?v:void 0),Ce(f)},[]),[Z,$e]=c.useState(Ui),K=c.useCallback(()=>{$e(f=>{const v=f==="comfortable"?"compact":"comfortable";try{localStorage.setItem(us,v)}catch{}return v})},[]),{toggleReadFor:ke}=es({mailboxId:e}),{junkMailboxId:fe}=ts(I),me=ss(fe,e),Ae=c.useMemo(()=>[{accountId:I,mailboxId:e}],[I,e]),{outcome:re,staleFolderLabel:Be,guessedMailboxId:Ne}=Tn(Ae),{selectedIds:z,selectedCount:_,hasSelection:ne,isSelected:ee,toggle:Y,select:Te,clearSelection:we,selectRange:ge,setAnchor:V,selectAll:pe,toggleAll:te,intersectWith:Xe}=wn(),We=Fn(_,R),[xe,E]=c.useState(null),Ze=c.useCallback((f,v,he)=>{const Q=Vs(f,v,he,re);Q&&ie(Q)},[ie,re]),je=ye&&!!u,et=`${e}|${JSON.stringify(u??{})}`,T=jn({mailboxId:e,mailboxLabel:b,accountId:I,enabled:je,predicateKey:et,searchQuery:u??{},reportEnding:Ze}),tt=T.phase.kind,Ke=T.clear,L=c.useCallback(()=>{tt==="escalated"&&Ke(),we()},[we,Ke,tt]),[st,ae]=c.useState(null),be=c.useRef(null),le=c.useRef(!1),ze=c.useRef(null),Me=!s&&o.length>0,ce=Fi({count:o.length,getScrollElement:()=>J.current,estimateSize:()=>Z==="compact"?Hi:qi,overscan:Qi}),Ve=t?o.findIndex(f=>f.messageId===t):-1,q=M?o.findIndex(f=>f.messageId===M):-1,se=c.useCallback(f=>{if(f<0||f>=o.length)return;const v=o[f];if(We){Y(v.messageId);return}be.current=v.messageId,le.current=!1,Ie(v.messageId),Ce(v.messageId)},[o,We,Y]),Fe=c.useCallback(()=>{if(o.length===0)return;const f=q<0?0:Math.min(q+1,o.length-1);se(f)},[o.length,q,se]),nt=c.useCallback(()=>{if(o.length===0)return;const f=q<=0?0:q-1;se(f)},[o.length,q,se]),qe=c.useCallback(()=>se(0),[se]),He=c.useCallback(()=>se(o.length-1),[se,o.length]),ve=c.useCallback(()=>{M&&Y(M)},[M,Y]),D=c.useMemo(()=>o.map(f=>f.messageId),[o]),De=c.useMemo(()=>{const f=[];for(const v of o)z.has(v.messageId)&&f.push({id:v.messageId,sender:v.fromName??v.fromEmail??"Unknown",email:v.fromEmail??"",subject:v.subject??"(No subject)",date:Ge(v.sentDate),accountId:I});return f},[o,z,I]),xt=c.useCallback((f,v)=>v.shiftKey?(ge(D,f,M),!0):v.metaKey||v.ctrlKey?(Y(f),!0):(L(),V(f),!1),[D,M,ge,Y,L,V]),ot=c.useCallback(f=>{!h||f.length===0||(ze.current=M??null,E(f))},[h,M]),_e=c.useCallback(f=>{const v=Mn(D,M,f);v!==void 0&&(ge(D,v),be.current=v,le.current=!1,Ie(void 0),Ce(v))},[D,M,ge]),ue=c.useCallback(()=>_e(-1),[_e]),it=c.useCallback(()=>_e(1),[_e]),rt=c.useCallback(()=>{D.length>0&&pe(D)},[D,pe]),at=c.useCallback(f=>{const v=Li({verb:f,confirmingDelete:xe!==null,hasSelection:ne,junkMailboxId:fe,currentMailboxId:e,deletableMessageId:h?M:void 0});return v.kind==="openWizard"?(P(f),!0):v.kind==="confirmDelete"?(ot([v.messageId]),!0):v.kind==="unavailable"?(ie({severity:"warning",title:v.reason}),!0):v.kind==="withheld"},[xe,h,ne,fe,e,P,M,ot,ie]),de=c.useCallback((f,v)=>{const he=o.find(Q=>Q.messageId===f)?.threadId;he&&G({threadId:he,messageId:f},{replace:v?.replace})},[G,o]),lt=c.useCallback(()=>{M&&de(M)},[M,de]),bt=c.useCallback(f=>de(f,{replace:!0}),[de]);Rn({keyboardFocusedMessageId:Oe,openMessageId:t,enabled:R&&_===0,open:bt});const Qe=T.phase.kind==="escalated"?{scope:Nt(u??{}),total:T.phase.total,searchQuery:u??{},run:(f,v)=>T.runAction(f,void 0,v),stop:T.stop}:void 0,ct=c.useCallback(f=>{if(f.length===0){E(null);return}const v=new Set(f),he=o.findIndex(U=>v.has(U.messageId));let Q;for(let U=he+1;U<o.length;U++)if(!v.has(o[U].messageId)){Q=o[U].messageId;break}if(Q===void 0){for(let U=he-1;U>=0;U--)if(!v.has(o[U].messageId)){Q=o[U].messageId;break}}h?.(f),L(),ze.current=null,E(null),Q!==void 0&&(be.current=Q,le.current=!1,N(Q),R&&de(Q,{replace:!0})),R||ae(qs("delete",f.length,re))},[o,h,L,de,R,N,re]),ut=c.useCallback(()=>{const f=ze.current;ze.current=null,E(null),f!==null&&(be.current=f,le.current=!1,N(f))},[N]),Ue=c.useMemo(()=>Ji(o,z,I),[I,z,o]),vt=c.useCallback(()=>{if(Qe){Ee();return}P("organize")},[Qe,Ee,P]),St=c.useCallback(f=>{h?.([f])},[h]),dt=c.useCallback((f,v)=>{ke([f],!v)},[ke]),yt=c.useCallback(f=>{R||Te(f)},[R,Te]),C=c.useCallback(()=>{if(T.isRunning||T.phase.kind==="counting"){T.stop();return}L()},[T,L]),H=c.useCallback(()=>{T.clear()},[T]);c.useEffect(()=>{if(le.current||!R&&t)return;const f=q>=0?q:Ve;f>=0&&ce.scrollToIndex(f,{align:"auto"})},[q,Ve,ce,R,t]),c.useEffect(()=>{t&&(le.current=!1,N(t))},[t,N]),c.useEffect(()=>{M&&(o.some(f=>f.messageId===M)||N(o[0]?.messageId))},[o,M,N]),c.useEffect(()=>{O?.({focusedMessageId:M,selectedIds:Array.from(z),hasList:Me})},[M,z,Me,O]);const $=c.useRef(O);$.current=O,c.useEffect(()=>()=>$.current?.({focusedMessageId:void 0,selectedIds:[],hasList:!1}),[]),c.useEffect(()=>{T.phase.kind!=="idle"||T.isRunning||Xe(o.map(f=>f.messageId))},[o,Xe,T.phase,T.isRunning]);const zt=c.useRef(e);c.useEffect(()=>{zt.current!==e&&(zt.current=e,L())},[e,L]),En({shouldBlockFn:({action:f})=>Pi(f,ne,Se)?(L(),!0):!1,enableBeforeUnload:!1,disabled:!ne||Se!==void 0}),c.useEffect(()=>{const f=J.current;if(!f||!S||!p)return;const v=()=>{if(y)return;const{scrollTop:he,scrollHeight:Q,clientHeight:U}=f;he+U>=Q-200&&p()};return f.addEventListener("scroll",v,{passive:!0}),v(),()=>f.removeEventListener("scroll",v)},[S,y,p]),c.useEffect(()=>{const f=be.current;if(!f)return;const v=J.current?.querySelector(`[data-message-id="${f}"]`);v&&(be.current=null,v.focus({preventScroll:!0}))}),c.useEffect(()=>{if(A){if(!Me){A.current=null;return}return A.current={focusNext:Fe,focusPrevious:nt,focusFirst:qe,focusLast:He,openFocused:lt,toggleSelect:ve,extendSelectDown:it,extendSelectUp:ue,selectAll:rt,clearSelection:()=>ne?(L(),!0):!1,requestVerb:at,toggleDensity:K},()=>{A.current=null}}},[A,Me,Fe,nt,qe,He,lt,ve,it,ue,rt,ne,L,at,K]);const Ft=s?"loading":n?"error":o.length===0?"empty":"ready",fs=n?No(i):void 0,ms=c.useCallback(()=>{const f=Hs(Qs());window.open(f,"_blank","noopener,noreferrer")},[]),gs=[{id:"inbox",threads:[]}],Ct=D.length>0&&D.every(f=>z.has(f)),ps=je&&S&&Ct&&!g&&!m&&T.phase.kind==="idle"&&!T.isRunning,xs=g||m||T.isRunning,It=T.phase.kind==="escalated"?T.phase.total:T.progress?T.progress.total:_,bs=T.runningAction?Us(T.runningAction.kind,T.progress?.done??0,T.progress?.total??It):T.phase.kind==="counting"?"Counting matches…":T.phase.kind==="escalated"?_i(u??{},T.phase.total):void 0,vs=T.phase.kind!=="escalated"&&D.length>0?{checked:Ct,indeterminate:_>0&&!Ct,onChange:()=>te(D)}:void 0,Ss=T.runningAction?{value:T.progress?.done??0,max:T.progress?.total??It,tone:Js(T.runningAction.kind)}:void 0,ys=(T.isRunning||T.phase.kind==="counting"?{tone:"info",text:"",action:{label:"Stop",onClick:T.stop}}:T.phase.kind==="escalated"?{tone:"info",text:"",action:{label:"Clear selection",onClick:H}}:ps?{tone:"info",text:"",action:{label:Di(u??{}),onClick:T.escalate}}:void 0)??(Ue?{tone:"warning",text:Ue}:void 0),Cs=r.jsx(On,{title:W.title||b,navSlot:W.navSlot,titleMeta:W.titleMeta,searchSlot:W.searchSlot,searchField:W.searchField,idleSlot:W.makeFilterSlot,count:It,onCancel:C,onDelete:()=>P("delete"),onMove:()=>P("move"),onOrganize:vt,onJunk:me?()=>P("junk"):void 0,onMarkRead:()=>P("markRead"),overflowSlot:I&&e&&_>0&&Pe.length>0?r.jsx(Fo,{accountId:I,mailboxId:e,messageIds:Array.from(z)}):void 0,isBusy:xs,isCounting:T.phase.kind==="counting",selectAll:vs,statusLabel:bs,progress:Ss,notice:ys}),Is=An(D,M),ks=c.useCallback(f=>{le.current=!0,N(f)},[N]),Ts=r.jsxs(r.Fragment,{children:[ye&&a&&r.jsx(Uo,{query:a,count:d}),r.jsxs("div",{ref:J,role:"listbox","aria-multiselectable":!0,"aria-label":b,className:"flex-1 overflow-y-auto",children:[r.jsx("div",{role:"presentation",className:"relative w-full",style:{height:`${ce.getTotalSize()}px`},children:ce.getVirtualItems().map(f=>{const v=o[f.index];return r.jsx("div",{role:"presentation","data-index":f.index,ref:ce.measureElement,className:Re("absolute left-0 top-0 w-full border-b border-line",T.isRunning&&"pointer-events-none opacity-50"),style:{transform:`translateY(${f.start}px)`},children:r.jsx(Vi,{thread:v,mailboxId:e,isSelected:t===v.messageId,isFocused:M===v.messageId,isTabStop:Is===v.messageId,onFocusRow:ks,isChecked:ee(v.messageId),onToggleCheck:Y,onRowSelect:xt,isMultiSelectMode:We,onLongPress:yt,isDesktop:R,onDelete:St,onToggleRead:dt,density:Z})},f.key)})}),y&&r.jsx(bo,{})]})]});return r.jsxs(r.Fragment,{children:[st&&!R&&r.jsx(ft,{tone:"success",variant:"soft",className:"m-2 rounded-md",onDismiss:()=>ae(null),children:st}),r.jsx(vo,{listTitle:b,listMeta:x,sections:gs,flatList:!0,listState:W.searchResults?"ready":Ft,searchQuery:k,listFilter:j,listScopeLabel:w,errorMessage:fs,onRetry:l,onReportError:ms,density:Z,selectedThreadId:t,onSelectThread:f=>de(f),isDesktop:R,hideHeader:B,selectionBar:Cs,listBody:W.searchResults??(Ft==="ready"?Ts:void 0)}),r.jsx(Nn,{isOpen:xe!==null,messageIds:xe??[],outcome:re,accountId:I,trashFolderLabel:b,staleFolderLabel:Be,guessedMailboxId:Ne,isDeleting:g,onConfirm:ct,onCancel:ut}),r.jsx(zn,{verb:F,accountId:I,mailboxId:e,mailboxLabel:b,selection:De,selectionRestriction:Ue?"spansAccounts":void 0,escalated:Qe,escalatedProgress:T.progress,onFinished:L,onRunEnded:Ze})]})},Yi=e=>Ht({path:{accountId:e}}),Xi=e=>{const o=jt(),t=Rt(),s=Mt({...Gs(),onSuccess:()=>{t.recordEvent("sync.triggered"),o.invalidateQueries({queryKey:Yi(e)})}});return{trigger:()=>{s.mutate({path:{accountId:e}})},triggerAsync:()=>s.mutateAsync({path:{accountId:e}}),isPending:s.isPending,error:s.error,reset:s.reset}},Zi=({accountId:e,children:o})=>{const{triggerAsync:t,isPending:s}=Xi(e);return r.jsx(Jo,{onRefresh:t,isRefreshing:s,children:o})};function er({accountId:e,currentMailboxId:o,candidates:t,onMove:s,children:n}){const[i,l]=c.useState(!1),a=Rt(),u=Ys(),{inboxMailboxId:d}=Dn(e),h=_n(e),{data:g}=mt({...Xs({path:{accountId:e}}),staleTime:1/0}),m=c.useMemo(()=>Zs({mailboxes:g?.items??[],folderAppointments:h,currentMailboxId:o,translator:u}),[g?.items,h,o,u]),p=c.useMemo(()=>d||(m.find(x=>x.label.toLowerCase()==="inbox")?.id??m.find(x=>!x.isCurrent)?.id??""),[d,m]),S=c.useRef(!1);c.useEffect(()=>{S.current||(S.current=!0,Ln(a,t.length))},[a,t.length]);const y=c.useCallback(()=>{Pn(a,t.length),l(!0)},[a,t.length]),I=c.useCallback((b,x)=>{$n(a,{selected:b.length,total:t.length,toInbox:x===d}),s(b,x)},[a,t.length,d,s]);return r.jsxs("div",{className:"relative flex h-full min-h-0 flex-col",children:[r.jsx("div",{className:"shrink-0 px-row-inset pt-2",children:r.jsx(Yo,{count:t.length,onReview:y})}),r.jsx("div",{className:"min-h-0 flex-1",children:n}),r.jsx(li,{open:i,candidates:t,defaultDestinationId:p,availableFolders:m,delimiter:en(g?.items??[]),onConfirmMove:I,onCancel:()=>l(!1)})]})}const tr=(e,o,t,s)=>`${e??""}|${o}|${t??""}|${s??""}`,sr=({accountId:e,mailboxId:o})=>{const t=jt(),{pushError:s}=qt(),{requestAppointment:n}=tn(),{trashByAccount:i}=ns(),l=e?i.get(e):void 0,a=tr(e,o,l?.mailboxId,l?.source),[u,d]=c.useState({scope:a});u.scope!==a&&d({scope:a});const h=u.scope===a?u:void 0,g=c.useCallback(()=>t.getQueryData(sn())?.accounts.find(w=>w.accountId===e)?.folderAppointments.find(w=>w.role==="Trash")?.mailboxId??o,[t,e,o]),m=c.useRef(void 0),{mutateAsync:p,isPending:S}=Mt({...cn(),meta:ln(409),onMutate:()=>(m.current=a,{scope:a,listMailboxId:g()}),onSuccess:(x,j,k)=>{k.scope===a&&d({scope:a,deletedCount:x.deletedCount})},onError:(x,j,k)=>{const w=rn(x);if(!w){s({title:"Couldn't empty Trash",detail:an(x),error:x});return}k?.scope===a&&d({scope:a,refusal:w})},onSettled:(x,j,k,w)=>{m.current===w?.scope&&(m.current=void 0),nn(t,on([w?.listMailboxId??o])),e&&t.invalidateQueries({queryKey:Ht({path:{accountId:e}})})}}),y=c.useCallback(()=>e?(d({scope:a}),p({path:{accountId:e}}).then(()=>{},()=>{})):Promise.resolve(),[e,a,p]),I=c.useCallback(()=>{y()},[y]),b=c.useCallback(()=>{const x=h?.refusal;x&&n({accountId:x.accountId,role:x.role,reason:x.reason,action:{kind:"emptyTrash"},onAppointed:y})},[h,n,y]);return{emptyTrash:I,isEmptying:S&&m.current===a,deletedCount:h?.deletedCount,refusal:h?.refusal,repair:b}},nr="We can verify this sender";function or(e){const{data:o}=mt({...un({path:{mailboxId:e??""},query:{senderTrust:["vip","wellknown"],dkimMismatch:!1,results:!0,limit:500}}),enabled:!!e,staleTime:6e4});return{candidates:(o?.items??[]).map(s=>({id:s.messageId,senderName:s.fromName||s.fromEmail||"Unknown sender",senderAddress:s.fromEmail??"",subject:s.subject||"(no subject)",snippet:s.snippet??"",trustReason:nr,trustSubReason:Bn(s.senderTrust),senderTrust:s.senderTrust}))}}const ir=6e4,rr=({mailboxId:e,criteria:o,enabled:t})=>{const s={...o,count:!0,results:!1},{data:n}=mt({queryKey:Qt({path:{mailboxId:e},query:s}),queryFn:async()=>{const{data:i}=await Ut({path:{mailboxId:e},query:s,throwOnError:!0});return i},enabled:t,staleTime:ir});return t?_o(n?.count):{kind:"unknown"}},ar=e=>{const o=new Set,t=[];for(const s of e)o.has(s.threadMessageId)||(o.add(s.threadMessageId),t.push(s));return t},lr=50,ds=c.createContext(null);function pt(){const e=c.useContext(ds);if(!e)throw new Error("MailboxPane.* must be used inside <MailboxPane>");return e}function cr({mailboxId:e,thread:o,children:t}){const s=Ye(),n=jo(),i=qo(),l=o?.threadId,a=o?.messageId,u=Rt(),{accounts:d,searchQuery:h,onToggleIntelligence:g,onSearchClearQuery:m}=Jt(),p=pn(),S=Vo(h),y=S.length>0,{freeText:I,tokens:b}=Dt(S,p),x=Dt(h.trim(),p).freeText,[j,k]=c.useState("all"),[w,O]=c.useState(new Set),A=c.useMemo(()=>({category:j,attributes:w}),[j,w]),B=c.useMemo(()=>Wn(A),[A]),J=y||Kn(A),{params:G,residual:R}=Vn(b,B),oe={order:"desc",...I?{query:I}:{},...G,...B},F={...oe,limit:lr},P={category:F.category,unread:F.unread,starred:F.starred,attachments:F.attachments},Ee=J?Qt({path:{mailboxId:e},query:F}):dn({path:{mailboxId:e},query:{order:"desc"}}),{data:Se,isLoading:ye,isError:W,error:Pe,refetch:ie,fetchNextPage:M,hasNextPage:Ce,isFetchingNextPage:Oe}=So({queryKey:Ee,queryFn:async({pageParam:C})=>{if(J){const{data:$}=await Ut({path:{mailboxId:e},query:{...F,continuationToken:C},throwOnError:!0});return $}const{data:H}=await gn({path:{mailboxId:e},query:{order:"desc",continuationToken:C},throwOnError:!0});return H},initialPageParam:void 0,getNextPageParam:C=>C.continuationToken,placeholderData:(C,H)=>po(H?.queryKey,P)?C:void 0}),Ie=rr({mailboxId:e,criteria:oe,enabled:Lo({hasSearchQuery:y,freeText:I,residualTokenCount:R.length})}),{accountId:N,isLoading:Z}=qn(e),$e=Mo({accounts:d}),K=Hn(Qn(ar(Se?.pages.flatMap(C=>C.items??[])??[])),R,N),ke=c.useCallback(C=>{k(C)},[]),fe=c.useCallback(C=>{O(H=>{const $=new Set(H);return $.has(C)?$.delete(C):$.add(C),$})},[]),me=c.useCallback(()=>{k("all"),O(new Set)},[]),Ae=c.useCallback(()=>{me(),m()},[me,m]),re=yo({chips:A,tokens:b,reach:R.length>0?"loaded-pages":Un(F),onClear:Ae}),Be=l?K.find(C=>C.messageId===a)??K.find(C=>C.threadId===l):void 0,Ne=Jn(l,a),z=Be??Ne,_=a??z?.messageId,ne=c.useMemo(()=>{if(l)return{threadId:l,mailboxId:z?.mailboxId??e,subject:z?.subject,messageId:_,authenticity:z?.authenticity}},[l,z,_,e]),ee=c.useCallback(C=>{_&&C.includes(_)&&n()},[_,n]),{deleteMessages:Y,isPending:Te}=_t({mailboxId:e,onAfterOptimisticRemove:ee}),{moveMessages:we,isPending:ge}=Lt({mailboxId:e,accountId:N,onAfterOptimisticRemove:ee}),V=c.useRef(null),pe=Gn(),{listCommandsRef:te,onTriageContextChange:Xe,focusedMessageId:We,selectedIds:xe}=pe,E=K.find(C=>C.messageId===We)??z,Ze=Ro({accounts:d})??null,je=Yn({thread:z,isOpen:!0,mailboxId:e,accountId:N,onAfterOptimisticRemove:ee}),{draftsMailboxId:et}=Xn(N),T=et!==void 0&&et===e,{archiveMailboxId:tt}=Zn(N),Ke=eo(),L=hn(),st=c.useMemo(()=>fn(L,l,_),[L,l,_]),ae=c.useMemo(()=>{if(E)return C=>L({threadId:E.threadId,messageId:E.messageId,mode:C})},[L,E]),be=To(),le=mn(),ze=wo(),Me=c.useCallback(C=>C?Ke(C):[],[Ke]),{toggleStar:ce}=to({threadId:E?.threadId??"",mailboxId:e}),{toggleReadFor:Ve}=es({mailboxId:e,accountId:N}),{junkMailboxId:q}=ts(N),se=q!=null&&q===e,Fe=ss(q,e),{candidates:nt}=or(se?q:void 0),{moveMessages:qe}=Lt({mailboxId:e,threadId:E?.threadId,accountId:N,onAfterOptimisticRemove:ee}),{deleteMessages:He}=_t({mailboxId:e,threadId:E?.threadId,onAfterOptimisticRemove:ee}),{addressId:ve,address:D}=so(E),{updateFlags:De}=no({addressId:ve,senderEmail:E?.fromEmail??void 0}),xt=c.useCallback(()=>ae?.("reply"),[ae]),ot=c.useCallback(()=>ae?.("reply-all"),[ae]),_e=c.useCallback(()=>ae?.("forward"),[ae]),ue=c.useCallback(()=>Me(E),[Me,E]),it=c.useCallback(()=>{if(te.current?.requestVerb("delete"))return;const C=ue();C.length>0&&He(C)},[te,ue,He]),rt=c.useCallback(()=>{if(te.current?.requestVerb("junk")||!Fe)return;const C=ue();C.length!==0&&(oo(u,{count:C.length,senderTrust:E?.senderTrust??"unknown",wasRescuable:E?io(E):!1}),qe(C,Fe))},[te,Fe,ue,qe,u,E]),at=c.useCallback(()=>{if(xe.length>0){const C=!(E?.hasStars??!1),H=new Set(xe);for(const $ of K)H.has($.messageId)&&$.hasStars!==C&&ce($.messageId,$.hasStars);return}E&&ce(E.messageId,E.hasStars)},[xe,K,E,ce]),de=c.useCallback(()=>{if(te.current?.requestVerb("markRead"))return;const C=ue();if(C.length===0)return;const H=!(E?.isRead??!1);Ve(C,H)},[te,ue,E,Ve]),lt=c.useCallback(()=>{if(!ve)return;const C=D?.flags?.muted?.value!==!0;De({muted:{value:C}})},[ve,D,De]),bt=c.useCallback(()=>{if(!ve)return;const C=D?.flags?.vip?.value!==!0;De({vip:{value:C}})},[ve,D,De]),Qe=c.useCallback(()=>{V.current?.open()},[]),ct=T?"drafts":tt===e?"archive":q===e?"junk":"inbox",ut=c.useRef("");c.useEffect(()=>{const C=ut.current;ut.current=S,S.length>0&&C.length===0&&u.recordEvent("search.submitted",{mailboxType:ct})},[S,ct,u]);const{goBack:Ue,nextMessageId:vt,previousMessageId:St}=ro({context:pe,orderedIds:K.map(C=>C.messageId),selectedMessageId:_,enabled:!be&&!le,hasOpenThread:l!==void 0,onClose:n,handlers:{reply:xt,replyAll:ot,forward:_e,delete:it,toggleStar:at,toggleRead:de,muteSender:lt,blockSender:z?Qe:void 0,vipSender:bt,markJunk:rt,toggleIntelligence:z?()=>V.current?.toggle():void 0,compose:ze,goBrief:()=>i("brief"),goInbox:()=>i("brief"),goSent:()=>i("brief"),goFlagged:()=>i("flagged"),goSettings:()=>i("settings")}}),dt=C=>{if(!C)return;const H=K.find($=>$.messageId===C);return H?{threadId:H.threadId,messageId:C}:void 0},yt={mailboxId:e,selectedMessageId:_,selectedThread:z,conversation:ne,onOpenThread:s,threads:K,isLoading:ye,isError:W,error:Pe,mailboxAccountId:N,mailboxAccountLoading:Z,mailboxName:$e,unreadCount:Ze,isDraftsMailbox:T,isSpamFolder:se,rescueCandidates:nt,filterCategory:j,filterAttributes:w,onSelectFilterCategory:ke,onToggleFilterAttribute:fe,onClearFilters:me,listFilter:re,listSearchText:x||void 0,onToggleIntelligence:g,intelligenceRef:V,handleDeselectIfRemoved:ee,searchPredicate:y&&R.length===0?F:void 0,resultCount:Ie,onDeleteMessages:Y,onMoveMessages:we,isDeleting:Te,isMoving:ge,onLoadMore:M,hasMore:Ce,isLoadingMore:Oe,onTriageContextChange:Xe,listCommandsRef:te,onRetry:()=>ie(),onReply:st,onToolbarDelete:je.deleteThread,onToolbarStar:je.toggleStar,isStarred:je.isStarred,onToolbarMove:je.moveThread,onBack:Ue,nextThread:dt(vt),previousThread:dt(St)};return r.jsx(ds.Provider,{value:yt,children:t})}function hs(){const{mailboxId:e,selectedMessageId:o,threads:t,isLoading:s,isError:n,error:i,onDeleteMessages:l,onMoveMessages:a,isDeleting:u,isMoving:d,onLoadMore:h,hasMore:g,isLoadingMore:m,mailboxAccountId:p,mailboxName:S,unreadCount:y,isDraftsMailbox:I,isSpamFolder:b,rescueCandidates:x,onTriageContextChange:j,listCommandsRef:k,onRetry:w,filterCategory:O,filterAttributes:A,onSelectFilterCategory:B,onToggleFilterAttribute:J,onClearFilters:G,listFilter:R,listSearchText:oe,searchPredicate:F,resultCount:P}=pt(),{searchQuery:Ee,searchInput:Se,accounts:ye,resultFolderIndex:W}=Jt(),Pe=Ko(),ie=Ye(),M=S??"Inbox",Ce=c.useMemo(()=>ho(),[]),{trashMailboxId:Oe}=fo(p),Ie=Eo({accounts:ye}),{trashByAccount:N}=ns(),Z=sr({accountId:p,mailboxId:e}),$e=Oe!=null&&Oe===e,K=c.useMemo(()=>p?[p]:[],[p]),{hasNewMail:ke}=bn(),{state:fe,errorMessage:me,refresh:Ae}=vn(K,{onSettled:w}),re=c.useMemo(()=>r.jsx(Sn,{state:fe,onRefresh:Ae,label:`Refresh ${M}`,errorMessage:me,hasUpdate:ke(K)}),[fe,Ae,M,me,ke,K]),Be=c.useMemo(()=>t.map(V=>mo(V,W)),[t,W]),{hits:Ne,isLoading:z}=Po({mailboxId:e,filterCategory:O}),_=c.useMemo(()=>go(Ne,t.map(V=>V.threadId),W),[Ne,t,W]),ne=c.useCallback(V=>{const pe=V.threadId??t.find(te=>te.messageId===V.id)?.threadId;pe&&ie({threadId:pe,messageId:V.id},{mailboxId:V.mailboxId??e,query:Se})},[e,ie,Se,t]);if(I&&p)return r.jsx(gi,{accountId:p,selectedMessageId:o,imapThreads:t,title:S??"Drafts",unreadCount:y??void 0});const ee=r.jsx(Gi,{mailboxId:e,threads:t,selectedMessageId:o,isLoading:s,isError:n,error:i,onRetry:w,searchQuery:Ee,searchPredicate:F,resultCount:P,onDeleteMessages:l,isDeleting:u,isMoving:d,onLoadMore:h,hasMore:g,isLoadingMore:m,accountId:p,listTitle:M,listFilter:R,listSearchText:oe,listScopeLabel:M,hideHeader:!0,onTriageContextChange:j,commandsRef:k}),Y=ye[0]?.accountId,Te=Pe==="phone"&&Y?r.jsx(Zi,{accountId:Y,children:ee}):ee,we=b&&x.length>0&&p?r.jsx(er,{accountId:p,currentMailboxId:e,candidates:x,onMove:a,children:Te}):Te,ge=$e?r.jsx(bi,{messageCount:Ie,isEmptying:Z.isEmptying,deletedCount:Z.deletedCount,refusalReason:Z.refusal?.reason,trashFolderLabel:S??void 0,staleFolderLabel:p?N.get(p)?.staleFolderPath:void 0,onEmpty:Z.emptyTrash,onRepair:Z.repair,children:we}):we;return r.jsx(Co,{title:M,unreadCount:y,preset:Ce,selectedCategory:O,activeFilters:A,onSelectCategory:B,onToggleFilter:J,onClearFilters:G,searchResults:Be,searchLoading:s,relatedResults:_,relatedLoading:z,onSelectSearchResult:ne,searchResultsInBody:!0,refreshControl:re,children:ge})}function ur(){const{mailboxId:e,mailboxAccountId:o,mailboxAccountLoading:t,selectedThread:s,conversation:n,onReply:i,onToolbarDelete:l,onToolbarStar:a,isStarred:u,onToolbarMove:d,handleDeselectIfRemoved:h,intelligenceRef:g}=pt(),m=!!n,p=co(n?.threadId);os(g,p);const S=c.useRef(null),{railFits:y,openRail:I}=p;c.useEffect(()=>{if(!y)return;const x=s?.messageId??null;x&&S.current!==x&&s?.authenticity?.dkimMismatch&&(S.current=x,I())},[y,I,s?.messageId,s?.authenticity?.dkimMismatch]);const b=n?r.jsx(is,{threadId:n.threadId,mailboxId:n.mailboxId,subject:n.subject,selectedMessageId:n.messageId,authenticity:n.authenticity,onOpenIntelligence:p.open,listOnScreen:!0}):r.jsx(xn,{});return r.jsxs(r.Fragment,{children:[r.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[r.jsx(uo,{hasThread:m,messageId:n?.messageId,intelligenceOpen:p.isShowing,canToggleIntelligence:p.canToggle,onToggleIntelligence:p.toggle,onReply:i?()=>i("reply"):void 0,onReplyAll:i?()=>i("reply-all"):void 0,onForward:i?()=>i("forward"):void 0,onDelete:m?l:void 0,onToggleStar:m?a:void 0,isStarred:u,moveContext:m&&o?{accountId:o,currentMailboxId:e,onMove:d}:void 0,moveContextLoading:t}),r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:b})]}),r.jsx(rs,{isOpen:p.drawerOpen,onClose:p.closeDrawer,thread:s,mailboxId:e,accountId:o,onAfterOptimisticRemove:h})]})}function dr(){const{mailboxId:e,mailboxAccountId:o,selectedThread:t,onToggleIntelligence:s,handleDeselectIfRemoved:n}=pt();return r.jsx(lo,{onClose:s,thread:t,mailboxId:e,accountId:o,onAfterOptimisticRemove:n})}function hr(){const{mailboxId:e,mailboxAccountId:o,selectedThread:t,conversation:s,onOpenThread:n,onBack:i,nextThread:l,previousThread:a,handleDeselectIfRemoved:u,intelligenceRef:d}=pt(),h=ao(s?.threadId??null);return os(d,h),s?r.jsxs(r.Fragment,{children:[r.jsx(is,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onBack:i,onOpenIntelligence:h.toggle,onSwipeNext:l?()=>n(l):void 0,onSwipePrevious:a?()=>n(a):void 0,mobileIntelligenceOpen:h.isOpen}),r.jsx(rs,{isOpen:h.isOpen,onClose:h.close,thread:t,mailboxId:e,accountId:o,onAfterOptimisticRemove:u})]}):r.jsx(hs,{})}const Fr=Object.assign(cr,{List:hs,Reading:ur,Intelligence:dr,Phone:hr});export{Fr as M};
@@ -1 +0,0 @@
1
- import{e as ie,r as t,j as e,h as ce,i as J,o as le,ax as de,c as W,aT as U,d as Z,f as k,L as _,B as H,aU as G,ay as ue,az as q,n as me,I as pe}from"./index-Dq0vpG8a.js";import{K as he}from"./kbd-DWOMKFVK.js";import{A as fe,c as xe,d as ye,s as $,W as L,C as D,g as ge,e as Q,f as ve,h as Se,b as be,R as je,a as K,S as we}from"./credential-steps-CyekqOKR.js";import{c as Ce}from"./account-form-helpers-DhckT_PN.js";import{M as ke}from"./mail-CxDqKP0C.js";import{F as Ee}from"./file-json-DS63hnh9.js";const ee=ie("AtSign",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]]),te=[{id:"icloud",label:"iCloud",username:"full-email",imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},passwordHelp:{text:"iCloud requires an app-specific password, not your Apple ID password. Generate one under Sign-In & Security → App-Specific Passwords.",url:"https://support.apple.com/en-us/102654"}},{id:"yahoo",label:"Yahoo",username:"full-email",imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},passwordHelp:{text:"Yahoo requires an app password, not your login password. Generate one under Account Security.",url:"https://help.yahoo.com/kb/generate-manage-third-party-passwords-sln15241.html"}},{id:"aol",label:"AOL",username:"full-email",imap:{host:"imap.aol.com",port:993,security:"tls"},smtp:{host:"smtp.aol.com",port:465,security:"tls"},passwordHelp:{text:"AOL requires an app password, not your login password. Generate one under Account Security.",url:"https://login.aol.com/account/security"}},{id:"fastmail",label:"Fastmail",username:"full-email",imap:{host:"imap.fastmail.com",port:993,security:"tls"},smtp:{host:"smtp.fastmail.com",port:465,security:"tls"},passwordHelp:{text:"Fastmail requires an app password, not your login password. Create one under Settings → Privacy & Security → App passwords.",url:"https://www.fastmail.help/hc/en-us/articles/360058752854"}},{id:"gmail",label:"Gmail",username:"full-email",imap:{host:"imap.gmail.com",port:993,security:"tls"},smtp:{host:"smtp.gmail.com",port:587,security:"starttls"},passwordHelp:{text:"Gmail requires an app password, not your Google password. First turn on 2-Step Verification for your Google Account, then create an app password under Security → 2-Step Verification → App passwords.",url:fe["gmail.com"]}}];function X(a){return te.find(d=>d.id===a)}const Ne={"icloud.com":"icloud","me.com":"icloud","mac.com":"icloud","yahoo.com":"yahoo","yahoo.co.uk":"yahoo","ymail.com":"yahoo","aol.com":"aol","fastmail.com":"fastmail","fastmail.fm":"fastmail","gmail.com":"gmail","googlemail.com":"gmail"};function Pe(a){const d=a.indexOf("@");if(d===-1)return"";const c=a.slice(d+1).toLowerCase();return Ne[c]??""}const T=["Connector","Address","Servers","Credentials","Test","Sync"],A={connector:0,address:1,servers:2,credentials:3,test:4,sync:5},V={host:"",port:993,security:"tls"},Y={host:"",port:587,security:"starttls"};function Te({onStart:a,onImportConfig:d}){return t.useEffect(()=>{const c=p=>{p.key==="Enter"&&a()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[a]),e.jsx(L,{steps:T,activeStep:0,hideSteps:!0,title:"Welcome to Remit",subtitle:d?"Set up your first account, or bring the settings from another Reader.":"One inbox for all your mail, with context about every message.",footer:e.jsxs(e.Fragment,{children:[d?e.jsx(k,{variant:"secondary",icon:e.jsx(Ee,{className:"size-4"}),onClick:d,children:"Import a config file"}):e.jsxs("span",{className:"text-2xs text-fg-subtle",children:[e.jsx(he,{children:"Enter"})," to continue"]}),e.jsx(k,{variant:"primary",onClick:a,children:"Add your first account"})]}),children:e.jsxs("div",{className:"flex flex-col items-start py-5",children:[e.jsx("span",{className:"flex size-14 items-center justify-center rounded-md bg-accent-soft",children:e.jsx(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."}),d&&e.jsx("p",{className:"mt-3 max-w-sm text-sm leading-relaxed text-fg-muted",children:"A config file carries your accounts, folder roles, rules, flagged senders and appearance from another Reader. It never carries passwords, so you sign in again here."})]})})}function Ae({onContinue:a,onMicrosoft:d,onBack:c,showBack:p}){const[h,o]=t.useState("imap");t.useEffect(()=>{const y=i=>{i.key==="Enter"&&(h==="microsoft"?d():a()),i.key==="Escape"&&c()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[a,d,c,h]);const n=()=>{h==="microsoft"?d():a()};return e.jsx(L,{steps:T,activeStep:A.connector,title:"How does this account connect?",subtitle:"Choose a sign-in method. IMAP works with any provider.",footer:e.jsxs(e.Fragment,{children:[p?e.jsx(k,{variant:"ghost",onClick:c,children:"Back"}):e.jsx("span",{}),e.jsx(k,{variant:"primary",onClick:n,children:h==="microsoft"?"Continue with Microsoft":"Continue with IMAP"})]}),children:e.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[e.jsx(K,{name:"IMAP / SMTP",description:"Any mail provider — Fastmail, iCloud, your own server.",icon:e.jsx(we,{className:"size-5"}),selected:h==="imap",onSelect:()=>o("imap")}),e.jsx(K,{name:"Outlook / Microsoft 365",description:"Sign in with Microsoft. Works with Outlook.com and work accounts.",icon:e.jsx(pe,{className:"size-5"}),selected:h==="microsoft",onSelect:()=>o("microsoft")})]})})}function Ie({onBack:a,onConnected:d}){const[c,p]=t.useState(""),[h,o]=t.useState(null),[n,y]=t.useState(!1),[i,g]=t.useState(!1),v=t.useRef(!0);t.useEffect(()=>(v.current=!0,()=>{v.current=!1}),[]);const E=t.useRef(new Set),{refetch:w}=W(Z()),j=be(r=>{if(g(!1),r==="stalled"){y(!1),o(je);return}w().then(({data:u,isError:N})=>{if(!v.current)return;if(N||!u){o("Couldn't check whether the sign-in finished. Open Settings › Accounts to see whether the account is connected.");return}o(null);const C=u.accounts.find(P=>!E.current.has(P.accountId));C&&d(C.accountId)})}),S=J({...me(),onSuccess:r=>{v.current&&(j(),y(!0),window.location.assign(r.authorizationUrl))},onError:r=>{g(!1),o(r instanceof Error?r.message:"Failed to start sign-in")}}),l=i||S.isPending,f=()=>{l||(o(null),g(!0),w().then(({data:r,isError:u})=>{if(v.current){if(u||!r){g(!1),o("Couldn't read this instance's accounts, so sign-in can't be tracked. Check your connection and try again.");return}E.current=new Set(r.accounts.map(N=>N.accountId)),S.mutate({body:{email:c.trim()||void 0}})}}))},x=t.useRef(f);return x.current=f,t.useEffect(()=>{const r=u=>{u.key==="Enter"&&x.current(),u.key==="Escape"&&a()};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[a]),e.jsx(L,{steps:T,activeStep:A.connector,title:"Sign in with Microsoft",subtitle:"You'll be redirected to Microsoft to sign in securely.",footer:e.jsxs(e.Fragment,{children:[e.jsx(k,{variant:"ghost",onClick:a,children:"Back"}),e.jsx(k,{variant:"primary",onClick:f,disabled:l,icon:l?e.jsx(_,{className:"size-4 animate-spin"}):void 0,children:l?"Redirecting…":n?"Start over":"Sign in with Microsoft"})]}),children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(G,{htmlFor:"microsoft-email",children:"Email address (optional)"}),e.jsx(q,{id:"microsoft-email",icon:e.jsx(ee,{className:"size-4"}),placeholder:"you@outlook.com",value:c,onChange:r=>p(r.target.value),type:"email",autoComplete:"email"}),e.jsx("p",{className:"mt-1.5 text-2xs text-fg-subtle",children:"Pre-fills the Microsoft sign-in form. Leave blank to choose on the Microsoft page."})]}),n&&e.jsx(H,{tone:"info",children:"Waiting for Microsoft. Finish signing in — this window carries on the moment the account is connected, wherever you finished."}),h&&e.jsx(H,{tone:"danger",children:h})]})})}function Me({initialEmail:a,initialDisplayName:d,onContinue:c,onBack:p}){const[h,o]=t.useState(a),[n,y]=t.useState(d),[i,g]=t.useState(!1),[v,E]=t.useState(""),[w,j]=t.useState(null),S=t.useCallback(async()=>{const l=h.trim();if(!l.includes("@")||!l.includes(".")){j("Enter a valid email address.");return}j(null),g(!0),E(ve(l));try{const f=await Se(l);c(l,n.trim(),f)}finally{g(!1)}},[h,n,c]);return t.useEffect(()=>{const l=f=>{f.key==="Enter"&&!i&&S(),f.key==="Escape"&&p()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[S,i,p]),e.jsx(L,{steps:T,activeStep:A.address,title:"What's the email address?",subtitle:"We'll detect the server settings for you.",footer:e.jsxs(e.Fragment,{children:[e.jsx(k,{variant:"ghost",onClick:p,children:"Back"}),e.jsx(k,{variant:"primary",disabled:i,onClick:()=>{S()},children:"Continue"})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(G,{htmlFor:"onboarding-email",children:"Email address"}),e.jsx(q,{id:"onboarding-email",icon:e.jsx(ee,{className:"size-4"}),placeholder:"you@example.com",value:h,onChange:l=>{o(l.target.value),j(null)},type:"email",autoComplete:"email"})]}),e.jsxs("div",{children:[e.jsx(G,{htmlFor:"onboarding-display-name",children:"Display name (optional)"}),e.jsx(q,{id:"onboarding-display-name",placeholder:"Alice",value:n,onChange:l=>y(l.target.value)}),e.jsx("p",{className:"mt-1.5 text-2xs text-fg-subtle",children:"What to call this account in Remit. Leave blank to use a name derived from the address."})]}),i&&e.jsxs("div",{className:"mt-3 flex items-center gap-2 text-xs text-fg-muted",children:[e.jsx(_,{className:"size-3.5 animate-spin text-accent"}),v]}),w&&!i&&e.jsx("div",{className:"mt-3",children:e.jsx(H,{tone:"danger",children:w})})]})})}function Le({email:a,imapConfig:d,smtpConfig:c,discovered:p,onContinue:h,onBack:o,onChange:n}){const[y,i]=t.useState(d),[g,v]=t.useState(c),[E,w]=t.useState(()=>Pe(a)),[j,S]=t.useState(!1),[l,f]=t.useState(null),x=X(E),r=x!==void 0&&!j,u=t.useCallback(m=>{w(m),S(!1),f(null);const s=X(m);s&&(i({host:s.imap.host,port:s.imap.port,security:s.imap.security}),v({host:s.smtp.host,port:s.smtp.port,security:s.smtp.security}))},[]);t.useEffect(()=>{n(y,g)},[y,g,n]);const N=y.host.trim()!=="",C=t.useCallback(()=>{if(!N){f("Enter the IMAP host.");return}f(null),h()},[N,h]);t.useEffect(()=>{const m=s=>{s.key==="Enter"&&C(),s.key==="Escape"&&o()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[C,o]);const P=a.split("@")[1]??"your domain",R=x?"Pick your provider to fill in the right settings — or choose Custom to enter them by hand.":p?"Found via autodiscovery — adjust anything that looks off.":`We couldn't detect settings for ${P} — enter them manually.`,I=r?{label:"preset",tone:"neutral"}:!x&&p?{label:"detected",tone:"positive"}:void 0,M=x?.passwordHelp.url??ge(a);return e.jsx(L,{steps:T,activeStep:A.servers,title:"Confirm server settings",subtitle:R,footer:e.jsxs(e.Fragment,{children:[e.jsx(k,{variant:"ghost",onClick:o,children:"Back"}),e.jsx(k,{variant:"primary",onClick:C,children:"Continue"})]}),children:e.jsxs("div",{className:"space-y-5",children:[l&&e.jsx(H,{tone:"danger",children:l}),e.jsxs("div",{children:[e.jsx(G,{htmlFor:"provider-select",children:"Provider"}),e.jsxs(ue,{id:"provider-select",value:E,onChange:m=>u(m.target.value),children:[e.jsx("option",{value:"",children:"Custom / other"}),te.map(m=>e.jsx("option",{value:m.id,children:m.label},m.id))]}),x&&e.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:r?e.jsxs(e.Fragment,{children:["Server settings are pre-filled for ",x.label," and locked."," ",e.jsx("button",{type:"button",className:"text-accent underline",onClick:()=>S(!0),children:"Advanced"})," ","lets you edit them by hand."]}):e.jsxs(e.Fragment,{children:["Editing ",x.label,"'s settings by hand."]})})]}),e.jsx(Q,{legend:"IMAP — incoming",badge:I,readOnly:r,host:y.host,port:String(y.port),security:y.security,hostPlaceholder:"imap.example.com",portPlaceholder:"993",onHostChange:m=>{i(s=>({...s,host:m})),f(null)},onPortChange:m=>i(s=>({...s,port:Number(m)})),onSecurityChange:m=>i(s=>({...s,security:m}))}),e.jsx("p",{className:"text-2xs text-fg-subtle",children:"Sending (SMTP) is optional — leave it blank to set up a receive-only account and add sending later in Settings."}),e.jsx(Q,{legend:"SMTP — outgoing (optional)",badge:I,readOnly:r,host:g.host,port:String(g.port),security:g.security,hostPlaceholder:"smtp.example.com",portPlaceholder:"587",onHostChange:m=>{v(s=>({...s,host:m})),f(null)},onPortChange:m=>v(s=>({...s,port:Number(m)})),onSecurityChange:m=>v(s=>({...s,security:m}))}),x&&e.jsxs("p",{className:"text-2xs text-fg-subtle",children:[x.passwordHelp.text," ",M&&e.jsx("a",{href:M,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"Get an app password"})]})]})})}const Re=2e4;function Fe({email:a,displayName:d,imapConfig:c,smtpConfig:p,username:h,password:o,onGoToInbox:n}){const y=ce(),[i,g]=t.useState(null),[v,E]=t.useState(null),w=t.useRef(!1),j=$(c.security),S=$(p.security),l=J({...de(),onSuccess:b=>{g(b.accountId),y.invalidateQueries({queryKey:le()})},onError:b=>{E(b instanceof Error?b.message:"Failed to create account")}});t.useEffect(()=>{if(w.current)return;w.current=!0;const b=p.host.trim()!=="",F=Ce({imapHost:c.host,smtpHost:p.host,smtpPort:p.port}),O=b?F??{smtpHost:p.host,smtpPort:p.port,smtpTls:S.tls,smtpStartTls:S.startTls}:null;l.mutate({body:{email:a,displayName:d||void 0,username:h!==a?h:void 0,password:o,imapHost:c.host,imapPort:c.port,imapTls:j.tls,imapStartTls:j.startTls,smtpHost:O?.smtpHost||void 0,smtpPort:O?.smtpPort||void 0,smtpTls:O?.smtpTls??!1,smtpStartTls:O?.smtpStartTls??!1}})},[]);const{data:f,isError:x}=W({...U({path:{accountId:i??""}}),enabled:!!i,refetchInterval:b=>{const F=b.state.data?.syncPhase;return F==="complete"||F==="error"?!1:2e3}}),r=f?.syncPhase==="error",{data:u}=W({...Z(),enabled:!!i&&r}),N=u?.accounts.find(b=>b.accountId===i)?.lastError,C=f?.mailboxes.find(b=>b.fullPath==="INBOX"||b.fullPath==="Inbox"),P=f?.mailboxCountTotal??0,R=f?.mailboxCountSynced??0,I=C?.messagesTotal??0,M=C?.messagesSynced??0,m=I>0?M/I:0,s=f?.syncPhase,se=r?"failed":s==="idle"||s===void 0||s==="discovering_mailboxes"?"running":P>0?"ok":"running",z=r?"failed":!s||s==="idle"||s==="discovering_mailboxes"?"pending":s==="syncing_inbox"||s==="syncing_others"?"running":"ok",B=r?"failed":!s||s==="idle"||s==="discovering_mailboxes"||s==="syncing_inbox"?"pending":s==="syncing_others"?"running":"ok",ne=M>0||C?.phase==="complete"||s==="complete"||r,[ae,oe]=t.useState(!1);t.useEffect(()=>{if(!i)return;const b=setTimeout(()=>oe(!0),Re);return()=>clearTimeout(b)},[i]);const re=!!i&&(ne||x||ae);return v?e.jsx(L,{steps:T,activeStep:A.sync,title:"Couldn't create account",subtitle:"Something went wrong saving your account.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{}),e.jsx(k,{variant:"primary",onClick:()=>{w.current=!1,E(null),l.mutate({body:{email:a,displayName:d||void 0,username:h!==a?h:void 0,password:o,imapHost:c.host,imapPort:c.port,imapTls:j.tls,imapStartTls:j.startTls,smtpHost:p.host||void 0,smtpPort:p.port||void 0,smtpTls:S.tls,smtpStartTls:S.startTls}})},children:"Retry"})]}),children:e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:v})}):e.jsx(L,{steps:T,activeStep:A.sync,title:`Syncing ${a}`,subtitle:"Newest mail first — you can start reading right away.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"Sync continues in the background"}),re?e.jsx(k,{variant:"primary",onClick:()=>i&&n(i),children:"Go to inbox"}):e.jsx(k,{variant:"primary",disabled:!0,icon:e.jsx(_,{className:"size-3.5 animate-spin"}),children:"Getting your mail…"})]}),children:l.isPending?e.jsxs("div",{className:"flex items-center gap-2 py-4 text-sm text-fg-muted",children:[e.jsx(_,{className:"size-4 animate-spin text-accent"}),"Creating your account…"]}):e.jsxs("div",{className:"space-y-3",children:[I>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-baseline justify-between text-xs",children:[e.jsx("span",{className:"font-medium text-fg",children:"INBOX"}),e.jsxs("span",{className:"text-fg-subtle tabular-nums",children:[M.toLocaleString()," / ",I.toLocaleString()," ","messages"]})]}),e.jsx("div",{className:"mt-1 h-1.5 overflow-hidden rounded-full bg-surface-sunken",children:e.jsx("div",{className:"h-full rounded-full bg-accent transition-all duration-500",style:{width:`${Math.max(2,m*100)}%`}})})]}),e.jsxs("div",{className:"divide-y divide-line",children:[e.jsx(D,{label:"Mailboxes discovered",detail:P>0?`${P} mailbox${P===1?"":"es"} found`:"Discovering…",state:se}),e.jsx(D,{label:"INBOX",detail:z==="ok"?`${M.toLocaleString()} messages synced`:z==="running"?"Syncing newest first…":"Queued",state:z}),R>1||s==="syncing_others"||s==="complete"?e.jsx(D,{label:"Other mailboxes",detail:B==="ok"?`${R-1} mailboxes synced`:B==="running"?"Syncing…":"Queued",state:B}):null]}),r&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("p",{className:"text-xs text-danger",children:["Sync stalled. The account is still active —"," ",e.jsx("button",{type:"button",className:"underline",onClick:()=>{y.invalidateQueries({queryKey:U({path:{accountId:i??""}}).queryKey})},children:"retry"})]}),N&&e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:N})]})]})})}function De({skipWelcome:a=!1,onComplete:d,onCancel:c,onImportConfig:p}){const[h,o]=t.useState(a?"connector":"welcome"),[n,y]=t.useState({email:"",displayName:"",imapConfig:V,smtpConfig:Y,username:"",password:"",discoveryResult:null,discovered:!1,createdAccountId:null}),i=t.useCallback(()=>o("connector"),[]),g=t.useCallback(()=>o("address"),[]),v=t.useCallback(()=>o("microsoft-email"),[]),E=t.useCallback(()=>{a?c?.():o("welcome")},[a,c]),w=t.useCallback((x,r,u)=>{let N=V,C=Y,P=!1;u&&(P=u.source!=="heuristic",N={host:u.imap.host,port:u.imap.port,security:u.imap.security},C={host:u.smtp.host,port:u.smtp.port,security:u.smtp.security}),y(R=>({...R,email:x,displayName:r,imapConfig:N,smtpConfig:C,discoveryResult:u,discovered:P,username:x})),o("servers")},[]),j=t.useCallback((x,r)=>{y(u=>({...u,imapConfig:x,smtpConfig:r}))},[]),S=t.useCallback((x,r)=>{y(u=>({...u,username:x,password:r}))},[]),l=t.useCallback(()=>o("sync"),[]),f=t.useCallback(x=>{d(x)},[d]);switch(h){case"welcome":return e.jsx(Te,{onStart:i,onImportConfig:p});case"connector":return e.jsx(Ae,{onContinue:g,onMicrosoft:v,onBack:E,showBack:!a});case"microsoft-email":return e.jsx(Ie,{onBack:()=>o("connector"),onConnected:f});case"address":return e.jsx(Me,{initialEmail:n.email,initialDisplayName:n.displayName,onContinue:w,onBack:()=>o("connector")});case"servers":return e.jsx(Le,{email:n.email,imapConfig:n.imapConfig,smtpConfig:n.smtpConfig,discovered:n.discovered,onContinue:()=>o("credentials"),onBack:()=>o("address"),onChange:j});case"credentials":return e.jsx(ye,{steps:T,activeStep:A.credentials,title:`Sign in to ${n.email.split("@")[1]||"your mail server"}`,subtitle:"Many providers require an app password instead of your normal one.",email:n.email,username:n.username,password:n.password,onContinue:()=>o("test"),onBack:()=>o("servers"),onChange:S});case"test":return e.jsx(xe,{steps:T,activeStep:A.test,email:n.email,imapConfig:n.imapConfig,smtpConfig:n.smtpConfig,username:n.username,password:n.password,onSuccess:l,onBackToCredentials:()=>o("credentials"),onBackToServers:()=>o("servers")});case"sync":return e.jsx(Fe,{email:n.email,displayName:n.displayName,imapConfig:n.imapConfig,smtpConfig:n.smtpConfig,username:n.username,password:n.password,onGoToInbox:f})}}export{De as O,te as P,X as g};
@@ -1,2 +0,0 @@
1
- import{j as t,t as k,f as P,a3 as he,X as pe,c as R,eW as ie,s as _,r as E,eE as Q,b5 as W,Y as ge,a0 as ve,an as L,ab as be}from"./index-Dq0vpG8a.js";import{u as Ne,e as je,m as ke,t as we,C as Ce,d as ye,p as Se}from"./CalendarComposePane-Ct2l8PGF.js";import{c as Ee,R as Te,F as oe,u as De,n as Ie}from"./calendar-format-BCjw6Wdf.js";import{R as Fe,A as Re}from"./attendee-row-lGaZ_txP.js";import{C as Oe}from"./clock-DpXdz1Nu.js";import{G as X,M as Ae,a as ze}from"./calendar-report-CWyeC8kX.js";import{M as $e}from"./mail-CxDqKP0C.js";import{P as Le}from"./pencil-BoE6dIe7.js";import{f as Pe,d as le,j as ee,u as We,c as Me,s as Ze,U as te,h as _e}from"./useCalendars-Dtgsk_ok.js";import{a as Ue}from"./useCalendarWrites-yZ3wFhqW.js";import{b as Ve}from"./useCalendarData-uJPI0R64.js";function S({icon:e,children:s}){return t.jsxs("div",{className:"flex items-start gap-2.5 py-1",children:[t.jsx("span",{className:"mt-0.5 shrink-0 text-fg-subtle",children:e}),t.jsx("div",{className:"min-w-0 flex-1 text-sm text-fg",children:s})]})}function qe({event:e,calendar:s,whenText:r,onEdit:n,onDelete:i,onOpenThread:c,onClose:d,activeAttendee:l="",onActivateAttendee:m,renderAttendeeContext:x,touch:p=!1,chrome:g="header",className:b}){const a=Ee(s.color),u=t.jsxs(t.Fragment,{children:[t.jsx("h1",{className:"text-xl font-semibold text-fg",children:e.title}),t.jsxs("div",{className:"mt-3 flex flex-col border-b border-line pb-3",children:[t.jsx(S,{icon:t.jsx(Oe,{className:"size-4"}),children:t.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[r,e.attendees.length>0&&t.jsx(Fe,{rsvp:e.myRsvp})]})}),e.zoneCertainty==="ambiguous"?t.jsx(S,{icon:t.jsx(X,{className:"size-4 text-warning"}),children:t.jsx("span",{className:"text-warning",children:"The mail said a time but never a zone. Shown in your own; confirm before you travel for it."})}):e.timeZone!==""&&t.jsx(S,{icon:t.jsx(X,{className:"size-4"}),children:e.timeZone}),e.recurrenceRule!==""&&t.jsx(S,{icon:t.jsx(Te,{className:"size-4"}),children:t.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[e.recurrenceRule,e.seriesException&&t.jsx("span",{className:"rounded-xs bg-warning-soft px-1.5 py-0.5 text-2xs text-warning",children:"Moved out of the series"})]})}),e.location!==""&&t.jsx(S,{icon:t.jsx(Ae,{className:"size-4"}),children:e.location})]}),e.threadId!==""&&c&&t.jsxs("button",{type:"button",onClick:c,className:"mt-3 flex w-full items-center gap-2.5 rounded-md border border-line bg-surface-sunken px-3 py-2 text-left outline-none hover:border-line-strong focus-visible:ring-2 focus-visible:ring-ring",children:[t.jsx($e,{className:"size-4 shrink-0 text-accent-2"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block text-2xs uppercase tracking-wider text-fg-subtle",children:"From this thread"}),t.jsx("span",{className:"block truncate text-sm text-fg",children:e.threadSubject})]})]}),e.attendees.length>0&&t.jsx(Re,{attendees:e.attendees,activeEmail:l,onActivate:m,renderContext:x,touch:p,className:"mt-3"}),e.notes!==""&&t.jsx("p",{className:"mt-3 whitespace-pre-wrap text-sm text-fg-muted",children:e.notes})]});return g==="bare"?t.jsx("div",{className:k("flex flex-col",b),children:u}):t.jsxs("article",{className:k("flex h-full w-full flex-col bg-surface",b),children:[t.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[t.jsx("span",{className:k("size-2.5 shrink-0 rounded-full",a.solid)}),t.jsxs("span",{className:"min-w-0 flex-1 truncate text-xs text-fg-muted",children:[s.name," · ",s.accountLabel]}),n&&t.jsx(P,{variant:"ghost",size:"sm",icon:t.jsx(Le,{className:"size-3.5"}),onClick:n,children:"Edit"}),i&&t.jsx(P,{variant:"ghost",size:"sm",icon:t.jsx(he,{className:"size-3.5"}),onClick:i,className:"text-danger",children:"Delete"}),d&&t.jsx("button",{type:"button","aria-label":"Close event",onClick:d,className:"flex size-7 items-center justify-center rounded-md text-fg-subtle outline-none hover:bg-surface-sunken hover:text-fg focus-visible:ring-2 focus-visible:ring-ring",children:t.jsx(pe,{className:"size-4"})})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-row-inset py-3",children:u})]})}const Be=[{scope:"this",label:"This event",note:"Leaves the rest of the series alone"},{scope:"following",label:"This and everything after",note:"Splits the series here"},{scope:"all",label:"The whole series",note:"Rewrites the rule itself"}];function Ge({title:e,ruleText:s,instanceText:r,onChoose:n,onCancel:i,touch:c,className:d}){return t.jsxs("div",{className:k("flex flex-col gap-3",d),children:[t.jsxs("div",{children:[t.jsxs("h2",{className:"text-md font-semibold text-fg",children:[e," repeats"]}),t.jsx("p",{className:"text-xs text-fg-muted",children:s}),t.jsxs("p",{className:"text-xs text-fg-subtle",children:["You clicked ",r,"."]})]}),t.jsx("p",{className:"text-sm text-fg",children:"What should the change apply to?"}),t.jsx("div",{className:"flex flex-col gap-1.5",children:Be.map(l=>t.jsxs("button",{type:"button",onClick:()=>n(l.scope),className:k("flex flex-col rounded-md border border-line bg-surface px-3 py-2 text-left outline-none transition-colors hover:border-line-strong hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring",c&&"min-h-11 justify-center"),children:[t.jsx("span",{className:"text-sm font-medium text-fg",children:l.label}),t.jsx("span",{className:"text-2xs text-fg-subtle",children:l.note})]},l.scope))}),t.jsx(P,{variant:"ghost",size:c?"md":"sm",onClick:i,className:k("self-start",c&&"min-h-11"),children:"Cancel"})]})}const ce=e=>e.replace(/\r?\n[ \t]/g,""),se=e=>e.replace(/\\n/gi,`
2
- `).replace(/\\,/g,",").replace(/\\;/g,";").replace(/\\\\/g,"\\");function M(e,s){let r=!1;for(let n=s.length;n<e.length;n+=1){const i=e[n];if(n===s.length&&i!==";"&&i!==":")return;if(i==='"'){r=!r;continue}if(!r&&i===":")return e.slice(n+1).trim()}}function Z(e,s){for(const r of ce(e).split(/\r?\n/)){if(!r.startsWith(s))continue;const n=M(r,s);if(n!==void 0)return n}return""}const He=e=>Z(e,"RRULE"),Ye=e=>({location:se(Z(e,"LOCATION")),description:se(Z(e,"DESCRIPTION"))});function Je(e,s){const r=ce(e).split(/\r?\n/).find(i=>i.startsWith("DTSTART")&&M(i,"DTSTART")!==void 0);if(r===void 0)return Pe(s);const n=/;TZID="?([^;:"]+)"?/i.exec(r)?.[1];return n!==void 0?Intl.supportedValuesOf("timeZone").includes(n)?n:s:M(r,"DTSTART")?.toUpperCase().endsWith("Z")?"":s}const Ke=_(404);function Qe(e,s){const{data:r,isLoading:n,error:i,refetch:c}=R({...ie({path:{calendarObjectId:e},query:{calendarId:s}}),meta:Ke,enabled:e!==""&&s!==""});return{resource:r,isLoading:n,error:i,refetch:()=>{c()}}}const ne=365*24*60*6e4,Xe=1440*6e4,re=_(401),et=_(401,404),F=e=>new Date(e).toISOString().replace(/\.\d{3}Z$/,"+00:00"),tt=e=>{const s=e instanceof Error&&e.message!==""?e.message:"no reason given",r=W(e);return r===void 0?s:`${s} (HTTP ${r})`};function st(e,s){const[r]=E.useState(()=>Date.now()),n=le(),i=new Date(r).toISOString(),c=R({...Q({query:{from:F(r),to:F(r+ne),calendarObjectId:e}}),meta:re,retry:!1,enabled:s}),d=c.data?ee(c.data.items,e,i,n):void 0,l=R({...ie({path:{calendarObjectId:e}}),meta:et,retry:!1,enabled:s&&c.data!==void 0&&d===void 0}),m=Date.parse(l.data?.dtStart??""),x=l.data!==void 0&&Number.isNaN(m),p=Number.isNaN(m)?0:m-Xe,g=R({...Q({query:{from:F(p),to:F(p+ne),calendarObjectId:e}}),meta:re,retry:!1,enabled:s&&l.data!==void 0&&!x}),b=g.data?ee(g.data.items,e,i,n):void 0;if(!s)return{kind:"Idle"};if(d)return{kind:"Found",jump:d};if(b)return{kind:"Found",jump:b};const a=W(l.error)===404,u=[c.error,a?null:l.error,g.error].find(w=>w!==null);return u!==void 0?W(u)===401?{kind:"SignedOut"}:{kind:"Failed",reason:tt(u)}:a?{kind:"Deleted"}:x?{kind:"Failed",reason:`the stored event names no readable start (${l.data?.dtStart??""})`}:g.data!==void 0?{kind:"NoOccurrenceFound"}:{kind:"Searching"}}const nt={kind:"NotInView"},ae="rounded-md border border-line px-2.5 py-1 text-sm font-medium text-fg outline-none hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring";function rt(e){switch(e.kind){case"Finding":return{title:"Finding the event",detail:"Looking for the day it falls on."};case"Deleted":return{title:"This event was deleted",detail:"None of your calendars holds it any more."};case"NoOccurrenceFound":return{title:"No occurrence in its first year or the coming year",detail:"Its repeat rule, or the days taken out of it, leave it no day in either."};case"SignedOut":return{title:"Your session has ended",detail:"Sign in again to open this event."};case"Failed":return{title:"The event couldn't be looked up",detail:e.reason};case"NotInView":return{title:"That event isn't on this week",detail:"The address names an event the calendar doesn't have here."}}}function at({event:e,calendar:s,isOccurrence:r,absence:n=nt,problem:i="",onEdit:c,onDelete:d,onClose:l}){if(!e||!s){const{title:m,detail:x}=rt(n),p=n.kind==="Failed"||n.kind==="SignedOut";return t.jsxs("div",{role:p?"alert":void 0,className:"flex h-full flex-col items-center justify-center gap-2 bg-surface p-8 text-center",children:[t.jsx(ge,{className:"size-8 text-fg-subtle","aria-hidden":"true"}),t.jsx("p",{className:"text-sm font-medium text-fg",children:m}),t.jsx("p",{className:"max-w-xs break-words text-sm text-fg-muted",children:x}),t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[n.kind==="SignedOut"&&n.signIn,n.kind==="Failed"&&t.jsx("a",{href:n.reportHref,target:"_blank",rel:"noreferrer",className:ae,children:"Report an issue"}),t.jsx("button",{type:"button",onClick:l,className:ae,children:"Back to the calendar"})]})]})}return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-surface",children:[r&&t.jsx("p",{className:"shrink-0 border-b border-line bg-surface-sunken px-row-inset py-1.5 text-2xs uppercase tracking-wider text-fg-subtle",children:"One occurrence of a repeating event"}),i!==""&&t.jsxs("div",{role:"alert",className:"flex shrink-0 items-start gap-2 border-b border-danger/40 bg-danger-soft px-row-inset py-2 text-sm",children:[t.jsx(ve,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":"true"}),t.jsx("p",{className:"min-w-0 flex-1 break-words text-fg",children:i})]}),t.jsx(qe,{event:e,calendar:s,whenText:oe(e),onEdit:c,onDelete:d,onClose:l,className:"min-h-0 flex-1"})]})}const it="This event changed somewhere else — over CalDAV, or in another tab. Nothing was saved. Close it and open it again to see the version that's stored now.";function ot(){const{Account:e}=be();return t.jsx(e,{children:({signOut:s})=>t.jsx("button",{type:"button",onClick:()=>s(),className:"rounded-md border border-line px-2.5 py-1 text-sm font-medium text-fg outline-none hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring",children:"Sign in again"})})}const lt=(e,s)=>{switch(e.kind){case"Deleted":case"NoOccurrenceFound":return{kind:e.kind};case"SignedOut":return{kind:"SignedOut",signIn:t.jsx(ot,{})};case"Failed":return{kind:"Failed",reason:e.reason,reportHref:ze(`opening an event failed: ${e.reason}`)};case"Searching":return{kind:"Finding"};default:return{kind:s?"Finding":"NotInView"}}};function Nt({calendarObjectId:e,recurrenceId:s}){const{view:r,date:n,calendarIds:i}=De(),{events:c,isLoading:d}=Ve({view:r,date:n,calendarIds:i}),{calendars:l,timeZoneByCalendarId:m}=We(),{closeEvent:x}=Ie(),{updateEvent:p,deleteEvent:g,isWriting:b}=Ue(),a=c.find(o=>o.id===Me(e,s??"")),u=s===void 0&&a===void 0,w=u?Ze(c,e,new Date().toISOString()):void 0,O=st(e,u&&!d&&w===void 0),de=l.find(o=>o.id===a?.calendarId),{resource:v}=Qe(e,a?.calendarId??""),[U,C]=E.useState(void 0),[N,A]=E.useState(void 0),[j,T]=E.useState(void 0),[V,y]=E.useState(""),ue=Ne(j??je("",""),e),D=v?Ye(v.icalData):void 0,z=v?He(v.icalData):"",fe=a&&!a.allDay?a.start.slice(11,16):"",$=v?Je(v.icalData,m[a?.calendarId??""]??te):te,me=a&&!a.allDay?ke(z,_e(a.start,$===""?"UTC":$).slice(0,10),a.start.slice(0,10)):z,I=z===""?"":we(me,fe)??"Repeats",q=a!==void 0&&a.seriesId!==""&&s!==void 0&&s!=="",B=a!==void 0&&v!==void 0,G=(o,f)=>{if(o.kind==="written"){y(""),f();return}y(o.kind==="conflict"?it:o.message)},H=o=>({calendarObjectId:e,calendarId:a?.calendarId??"",recurrenceId:s??"",scope:o,etag:v?.etag??""}),Y=o=>{if(!a)return;const f=ye(a,{repeat:I,location:D?.location??"",notes:D?.description??""});C(void 0),A({before:f,scope:o}),T(f),y("")},J=o=>{C(void 0),g(H(o)).then(f=>G(f,x))},xe=()=>{if(!N||!j)return;const o=Se(N.before,j,{clock:le(),anchor:$});if(!o.ok){y(o.problem);return}p(H(N.scope),o.patch).then(f=>G(f,()=>{A(void 0),T(void 0)}))};if(w)return t.jsx(L,{to:"/calendar/$view/$date/$calendarObjectId/$recurrenceId",params:{view:r,date:n,calendarObjectId:e,recurrenceId:w.recurrenceId},search:!0,hash:!0,replace:!0});const h=O.kind==="Found"?O.jump:void 0,K=h!==void 0&&i.length>0&&!i.includes(h.calendarId);if(h&&(h.date!==n||K)){const o=K?f=>({...f,calendarId:[...i,h.calendarId]}):!0;return h.recurrenceId===""?t.jsx(L,{to:"/calendar/$view/$date/$calendarObjectId",params:{view:r,date:h.date,calendarObjectId:e},search:o,hash:!0,replace:!0}):t.jsx(L,{to:"/calendar/$view/$date/$calendarObjectId/$recurrenceId",params:{view:r,date:h.date,calendarObjectId:e,recurrenceId:h.recurrenceId},search:o,hash:!0,replace:!0})}return U!==void 0&&a?t.jsx("div",{className:"flex h-full flex-col justify-center bg-surface px-row-inset",children:t.jsx(Ge,{className:"mx-auto w-full max-w-md",title:a.title,ruleText:I===""?"It repeats":I,instanceText:oe(a),onChoose:U==="edit"?Y:J,onCancel:()=>C(void 0)})}):N&&j?t.jsx(Ce,{title:"Edit event",subtitle:N.scope==="this"?"This occurrence only":j.date,calendars:l,draft:j,onChange:T,problem:V,saveLabel:"Save",isSaving:b,repeatEditable:N.scope===void 0||N.scope==="all",calendarEditable:!1,clashes:ue,onSave:xe,onCancel:()=>{A(void 0),T(void 0),y("")}}):t.jsx(at,{event:a&&{...a,location:D?.location??"",notes:D?.description??"",recurrenceRule:I},calendar:de,isOccurrence:s!==void 0,absence:lt(O,u&&d),problem:V,onEdit:B?()=>q?C("edit"):Y(void 0):void 0,onDelete:B?()=>q?C("delete"):J(void 0):void 0,onClose:x})}export{Nt as O};
@@ -1 +0,0 @@
1
- import{O as o}from"./index-Dq0vpG8a.js";const n=o;export{n as component};
@@ -1 +0,0 @@
1
- import{aj as m,j as o,O as p}from"./index-Dq0vpG8a.js";import{a}from"./MailShell-CYnLaaio.js";import{M as r}from"./MailboxPane-DRrbQAo3.js";import{a as e}from"./search-token-index-DdA7BFEr.js";import{u as s}from"./search-mirror-Bl-Z8zrH.js";import"./FullCompose-D3rfYvQR.js";import"./ErrorState-DRZtXgYN.js";import"./index-B8TTkszh.js";import"./useMessageBodyContent-SaudvJ_f.js";import"./useSignature-DsTucVsn.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-BlQHSXzq.js";import"./sections-gAf5RAcd.js";import"./confirm-dialog-DOM1mbt4.js";import"./useSearchTokenContext-CwqK76g8.js";import"./kbd-DWOMKFVK.js";import"./search-scope-B5-OK3Cq.js";import"./useRefreshControl-Dwjheutp.js";import"./circle-check-big-BfiUJz9g.js";import"./refresh-cw-BLxv_R1t.js";import"./useQueries-BLlTxIMR.js";import"./MailListHeader-_GRJzk6x.js";import"./roving-focus-Cs6iWufr.js";import"./popover-menu-Dci8SQJT.js";import"./mail-CxDqKP0C.js";import"./avatar-C6rJXQ1w.js";import"./EmptyState-B3SKuNr0.js";import"./undo-2-EliG40fh.js";import"./download-D2-NUPGx.js";import"./calendar-suggestion-DwQe-DW4.js";import"./calendar-format-BCjw6Wdf.js";import"./useCalendars-Dtgsk_ok.js";import"./calendar-report-CWyeC8kX.js";import"./attendee-row-lGaZ_txP.js";import"./clock-DpXdz1Nu.js";import"./calendar-clash-strip-I8NCaBf8.js";import"./bell-off-Cj-19EBu.js";import"./copy-CrcnK6wu.js";import"./shield-check-BbOZU-ha.js";import"./useFilters-BM8eI3xc.js";import"./useLayoutTier-DV_uk1qc.js";import"./menu-2BgPrZbs.js";import"./MailViewChrome-BPlYBsFJ.js";import"./NavMenuButton-CyLOK_Fk.js";import"./useLabels-DCAn9Wiq.js";import"./useSemanticSearch-BmktGXpn.js";import"./search-query-Cr_ZXBCp.js";import"./bottom-sheet-cfK6fTr2.js";import"./circle-help-DWoa8Ct-.js";import"./circle-check-DC8HnBjT.js";function po(){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{po as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-Dq0vpG8a.js";import{M as r}from"./MailboxPane-DRrbQAo3.js";import"./useSearchTokenContext-CwqK76g8.js";import"./kbd-DWOMKFVK.js";import"./useMessageBodyContent-SaudvJ_f.js";import"./search-scope-B5-OK3Cq.js";import"./useRefreshControl-Dwjheutp.js";import"./circle-check-big-BfiUJz9g.js";import"./refresh-cw-BLxv_R1t.js";import"./useQueries-BLlTxIMR.js";import"./MailListHeader-_GRJzk6x.js";import"./roving-focus-Cs6iWufr.js";import"./search-token-index-DdA7BFEr.js";import"./popover-menu-Dci8SQJT.js";import"./mail-CxDqKP0C.js";import"./avatar-C6rJXQ1w.js";import"./index-B8TTkszh.js";import"./useSignature-DsTucVsn.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-BlQHSXzq.js";import"./sections-gAf5RAcd.js";import"./EmptyState-B3SKuNr0.js";import"./ErrorState-DRZtXgYN.js";import"./undo-2-EliG40fh.js";import"./download-D2-NUPGx.js";import"./calendar-suggestion-DwQe-DW4.js";import"./calendar-format-BCjw6Wdf.js";import"./useCalendars-Dtgsk_ok.js";import"./calendar-report-CWyeC8kX.js";import"./attendee-row-lGaZ_txP.js";import"./clock-DpXdz1Nu.js";import"./calendar-clash-strip-I8NCaBf8.js";import"./bell-off-Cj-19EBu.js";import"./copy-CrcnK6wu.js";import"./shield-check-BbOZU-ha.js";import"./useFilters-BM8eI3xc.js";import"./confirm-dialog-DOM1mbt4.js";import"./useLayoutTier-DV_uk1qc.js";import"./menu-2BgPrZbs.js";import"./MailViewChrome-BPlYBsFJ.js";import"./NavMenuButton-CyLOK_Fk.js";import"./useLabels-DCAn9Wiq.js";import"./useSemanticSearch-BmktGXpn.js";import"./search-query-Cr_ZXBCp.js";import"./bottom-sheet-cfK6fTr2.js";import"./circle-help-DWoa8Ct-.js";import"./circle-check-DC8HnBjT.js";function X(){return o.jsx(r.Reading,{})}export{X as component};
@@ -1 +0,0 @@
1
- import{j as r}from"./index-Dq0vpG8a.js";import{B as o}from"./BriefPane-BYct_UtO.js";import"./useSearchTokenContext-CwqK76g8.js";import"./kbd-DWOMKFVK.js";import"./useMessageBodyContent-SaudvJ_f.js";import"./search-scope-B5-OK3Cq.js";import"./MailListHeader-_GRJzk6x.js";import"./roving-focus-Cs6iWufr.js";import"./search-token-index-DdA7BFEr.js";import"./useQueries-BLlTxIMR.js";import"./popover-menu-Dci8SQJT.js";import"./mail-CxDqKP0C.js";import"./avatar-C6rJXQ1w.js";import"./index-B8TTkszh.js";import"./useSignature-DsTucVsn.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-BlQHSXzq.js";import"./sections-gAf5RAcd.js";import"./EmptyState-B3SKuNr0.js";import"./ErrorState-DRZtXgYN.js";import"./undo-2-EliG40fh.js";import"./download-D2-NUPGx.js";import"./calendar-suggestion-DwQe-DW4.js";import"./calendar-format-BCjw6Wdf.js";import"./useCalendars-Dtgsk_ok.js";import"./calendar-report-CWyeC8kX.js";import"./attendee-row-lGaZ_txP.js";import"./clock-DpXdz1Nu.js";import"./calendar-clash-strip-I8NCaBf8.js";import"./bell-off-Cj-19EBu.js";import"./copy-CrcnK6wu.js";import"./shield-check-BbOZU-ha.js";import"./useFilters-BM8eI3xc.js";import"./confirm-dialog-DOM1mbt4.js";import"./useLayoutTier-DV_uk1qc.js";import"./menu-2BgPrZbs.js";import"./useRefreshControl-Dwjheutp.js";import"./circle-check-big-BfiUJz9g.js";import"./refresh-cw-BLxv_R1t.js";import"./useSemanticSearch-BmktGXpn.js";import"./useLabels-DCAn9Wiq.js";import"./search-query-Cr_ZXBCp.js";import"./wizard-selection-DxUM65kM.js";function T(){return r.jsx(o.Reading,{})}export{T as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-Dq0vpG8a.js";import{F as r}from"./FlaggedPane-Co2R0OJZ.js";import"./useSearchTokenContext-CwqK76g8.js";import"./kbd-DWOMKFVK.js";import"./useMessageBodyContent-SaudvJ_f.js";import"./search-scope-B5-OK3Cq.js";import"./MailListHeader-_GRJzk6x.js";import"./roving-focus-Cs6iWufr.js";import"./search-token-index-DdA7BFEr.js";import"./useQueries-BLlTxIMR.js";import"./popover-menu-Dci8SQJT.js";import"./mail-CxDqKP0C.js";import"./avatar-C6rJXQ1w.js";import"./index-B8TTkszh.js";import"./useSignature-DsTucVsn.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-BlQHSXzq.js";import"./sections-gAf5RAcd.js";import"./EmptyState-B3SKuNr0.js";import"./ErrorState-DRZtXgYN.js";import"./undo-2-EliG40fh.js";import"./download-D2-NUPGx.js";import"./calendar-suggestion-DwQe-DW4.js";import"./calendar-format-BCjw6Wdf.js";import"./useCalendars-Dtgsk_ok.js";import"./calendar-report-CWyeC8kX.js";import"./attendee-row-lGaZ_txP.js";import"./clock-DpXdz1Nu.js";import"./calendar-clash-strip-I8NCaBf8.js";import"./bell-off-Cj-19EBu.js";import"./copy-CrcnK6wu.js";import"./shield-check-BbOZU-ha.js";import"./useFilters-BM8eI3xc.js";import"./confirm-dialog-DOM1mbt4.js";import"./useLayoutTier-DV_uk1qc.js";import"./menu-2BgPrZbs.js";import"./MailViewChrome-BPlYBsFJ.js";import"./refresh-cw-BLxv_R1t.js";import"./wizard-selection-DxUM65kM.js";function N(){return o.jsx(r.Reading,{})}export{N as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-Dq0vpG8a.js";import{O as t}from"./OutboxPane-CrGnKSCL.js";import"./roving-focus-Cs6iWufr.js";import"./useSearchTokenContext-CwqK76g8.js";import"./kbd-DWOMKFVK.js";import"./useMessageBodyContent-SaudvJ_f.js";import"./search-scope-B5-OK3Cq.js";import"./circle-check-big-BfiUJz9g.js";import"./clock-DpXdz1Nu.js";import"./row-actions-B4tnhuQT.js";import"./rotate-ccw-DDVMkqGb.js";import"./NavMenuButton-CyLOK_Fk.js";import"./menu-2BgPrZbs.js";import"./outbox-status-BlKn6P0x.js";import"./search-query-Cr_ZXBCp.js";function P(){return o.jsx(t.Reading,{})}export{P as component};
@@ -1 +0,0 @@
1
- import{eX as o,j as m}from"./index-Dq0vpG8a.js";import{O as p}from"./OpenCalendarEvent-3AF2sHo_.js";import"./CalendarComposePane-Ct2l8PGF.js";import"./calendar-format-BCjw6Wdf.js";import"./useQueries-BLlTxIMR.js";import"./useCalendars-Dtgsk_ok.js";import"./calendar-clash-strip-I8NCaBf8.js";import"./attendee-row-lGaZ_txP.js";import"./avatar-C6rJXQ1w.js";import"./clock-DpXdz1Nu.js";import"./calendar-report-CWyeC8kX.js";import"./mail-CxDqKP0C.js";import"./pencil-BoE6dIe7.js";import"./useCalendarWrites-yZ3wFhqW.js";import"./ErrorState-DRZtXgYN.js";import"./useCalendarData-uJPI0R64.js";function I(){const{calendarObjectId:r,recurrenceId:t}=o.useParams();return m.jsx(p,{calendarObjectId:r,recurrenceId:t})}export{I as component};
@@ -1 +0,0 @@
1
- import{O as o}from"./index-Dq0vpG8a.js";const n=o;export{n as component};
@@ -1 +0,0 @@
1
- import{O as o}from"./index-Dq0vpG8a.js";const n=o;export{n as component};
@@ -1 +0,0 @@
1
- import{O as o}from"./index-Dq0vpG8a.js";const n=o;export{n as component};
@@ -1 +0,0 @@
1
- import{j as r,r as D,t as De,ao as Ve,f as te,Z as Us,X as Fe,ap as Hs,aq as zs,ar as ht,G as $s,H as Bs,as as ee,h as Ye,at as qs,c as ns,d as os,au as Ws,i as ge,av as Gs,o as je,l as gt,aw as Ks,ax as Qs,ay as Ys,az as ve,aA as _t,L as nt,aB as Pt,aC as Zs,aD as Me,aE as Se,aF as Ct,aG as ot,B as lt,aH as Js,aI as Xs,aJ as Vt,n as ls,ab as er,aK as tr,aL as sr,aM as cs,aN as Dt,u as rr,aO as ir,aP as ar,g as nr,aQ as Ft,aR as or,a3 as lr,aS as cr}from"./index-Dq0vpG8a.js";import{R as dr}from"./row-actions-B4tnhuQT.js";import{S as ur,A as fr}from"./settings-screen-CJYSyIrG.js";import{g as Ot,P as mr,O as pr}from"./OnboardingWizard-DLhtJpGm.js";import{s as Be,b as ds,R as us,u as hr}from"./credential-steps-CyekqOKR.js";import{u as gr}from"./useSignature-DsTucVsn.js";import{c as yr,a as Rt,d as xr}from"./account-form-helpers-DhckT_PN.js";import{C as br}from"./confirm-dialog-DOM1mbt4.js";import{f as It,E as vr}from"./ErrorState-DRZtXgYN.js";import{D as Sr}from"./download-D2-NUPGx.js";import{a as jr}from"./help-copy-B65YMhau.js";import"./avatar-C6rJXQ1w.js";import"./chevron-left-FV6t-DmA.js";import"./menu-2BgPrZbs.js";import"./circle-help-DWoa8Ct-.js";import"./kbd-DWOMKFVK.js";import"./mail-CxDqKP0C.js";import"./file-json-DS63hnh9.js";import"./card-6a_o3foG.js";const wr={Mail:"Mail already in Remit stays, and you can keep reading it.",Calendar:"Events already in Remit stay on your calendar."},Nr={Mail:"New mail stops arriving until you turn it back on.",Calendar:"Changes stop arriving until you turn it back on."},Ar={Mail:"mail",Calendar:"calendar"};function Tr(e,s){const t=Ar[e.service];return e.kind==="enable"?{title:`Sign in with ${s} to add ${t}?`,description:`This account was never asked for ${t} access. Remit sends you to ${s} to ask for it, and brings you back here when you are done. Nothing changes until you get back.`,confirmLabel:`Continue to ${s}`,cancelLabel:"Cancel",destructive:!1}:e.kind==="last"?{title:`${e.service} is the only thing this account syncs`,description:`An account has to sync something. To stop this one entirely, remove the account — that deletes what Remit stored for it, which switching ${t} off never does.`,confirmLabel:"Remove account",cancelLabel:`Keep syncing ${t}`,destructive:!0}:{title:`Stop syncing ${t} for this account?`,description:`${wr[e.service]} ${Nr[e.service]} Nothing is deleted.`,confirmLabel:`Stop syncing ${t}`,cancelLabel:"Cancel",destructive:!1}}function Er({change:e,providerName:s,onConfirm:t,onCancel:a,isBusy:n}){if(e===null)return null;const l=Tr(e,s);return r.jsx(br,{isOpen:!0,title:l.title,description:l.description,confirmLabel:l.confirmLabel,cancelLabel:l.cancelLabel,destructive:l.destructive,isBusy:n??!1,onConfirm:t,onCancel:a})}const kr=[{id:"Mail",label:"Mail",description:"Messages, folders and sending."},{id:"Calendar",label:"Calendar",description:"This account's provider calendar, read into Remit."}];function _r({checked:e,label:s,describedBy:t,disabled:a,onToggle:n}){return r.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":s,"aria-describedby":t,disabled:a,onClick:n,className:De("relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors","outline-none disabled:cursor-not-allowed disabled:opacity-60 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-surface",e?"border-positive bg-positive":"border-line-strong bg-surface-sunken"),children:r.jsx("span",{"aria-hidden":!0,className:De("size-4 rounded-full bg-canvas transition-transform",e?"translate-x-6":"translate-x-1")})})}function Pr({providerName:e,offered:s,enabled:t,consented:a,disabled:n=!1,onRequestChange:l}){const o=D.useId(),u=kr.filter(x=>s.includes(x.id));return u.length<2?null:r.jsxs("fieldset",{children:[r.jsx("legend",{className:"text-sm font-semibold text-fg",children:"What this account syncs"}),r.jsx("div",{className:"mt-1 divide-y divide-line",children:u.map(x=>{const N=t.includes(x.id),T=`${o}-${x.id}`,L=!N&&!a.includes(x.id);return r.jsxs("div",{className:"flex min-h-11 items-center gap-3 py-2 text-left",children:[r.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[r.jsx("span",{className:"text-sm text-fg",children:x.label}),r.jsx("span",{id:T,className:"text-xs text-fg-subtle",children:L?`${x.description} Turning this on means signing in with ${e} again.`:x.description})]}),r.jsx(_r,{checked:N,label:`Sync ${x.label.toLowerCase()}`,describedBy:T,disabled:n,onToggle:()=>l(x.id,N?"off":"on")})]},x.id)})})]})}const Cr=e=>{const s=new Set(e.map(Hs));return zs.map(t=>t.tag).filter(t=>!s.has(t)).sort((t,a)=>Ve(t).localeCompare(Ve(a)))},Vr=({value:e,onChange:s,busy:t=!1})=>{const a=Cr(e);return r.jsxs("div",{className:"space-y-2","data-testid":"compose-language-setting",children:[r.jsx("ul",{className:"space-y-1",children:e.map((n,l)=>r.jsxs("li",{"data-testid":`compose-language-row-${n}`,className:"flex items-center gap-2 rounded-md border border-line bg-surface-sunken px-3 py-1.5",children:[r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-fg",lang:n,children:Ve(n)}),l===0?r.jsx("span",{className:"shrink-0 text-2xs uppercase tracking-wider text-fg-subtle",children:"Default"}):r.jsx(te,{variant:"ghost",size:"sm",icon:r.jsx(Us,{className:"size-3.5"}),disabled:t,"aria-label":`Write new messages in ${Ve(n)} by default`,onClick:()=>s([n,...e.filter(o=>o!==n)]),children:"Default"}),r.jsx(te,{variant:"ghost",size:"sm",icon:r.jsx(Fe,{className:"size-3.5"}),disabled:t||e.length===1,"aria-label":`Remove ${Ve(n)}`,onClick:()=>s(e.filter(o=>o!==n))})]},n))}),r.jsxs("select",{"aria-label":"Add a language",value:"",disabled:t||a.length===0,onChange:n=>{n.target.value!==""&&s([...e,n.target.value])},className:"w-full rounded-md border border-line bg-surface-sunken px-3 py-2 text-sm text-fg outline-none transition-colors focus-within:border-line-strong focus-within:ring-2 focus-within:ring-ring/30",children:[r.jsx("option",{value:"",children:"Add a language…"}),a.map(n=>r.jsx("option",{value:n,children:Ve(n)},n))]}),r.jsx("p",{className:"text-xs text-fg-muted",children:"A message is tagged with the language you write it in, picked from this list. Your browser, not this app, decides which dictionaries it spellchecks against — add the language there too to get its underlines."})]})};function Dr({title:e,description:s,action:t}){return r.jsxs("div",{className:"rounded-sm border border-danger/50",children:[r.jsxs("div",{className:"flex items-center gap-2 border-b border-danger/30 bg-danger-soft px-row-inset py-2",children:[r.jsx(ht,{className:"size-4 text-danger"}),r.jsx("h2",{className:"text-sm font-semibold text-danger",children:"Danger zone"})]}),r.jsxs("div",{className:"flex flex-col gap-3 px-row-inset py-3 sm:flex-row sm:items-center sm:justify-between sm:gap-4",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"text-sm font-medium text-fg",children:e}),r.jsx("p",{className:"text-xs text-fg-muted",children:s})]}),r.jsx("div",{className:"shrink-0",children:t})]})]})}function Mt({isOpen:e,onClose:s,title:t,children:a,footer:n}){$s({id:"slide-panel",open:e,answers:{back:s}});const l=D.useRef(null);return Bs(l,e),r.jsxs(r.Fragment,{children:[r.jsx("div",{className:De("fixed inset-0 z-40 bg-black/30 transition-opacity",e?"opacity-100":"pointer-events-none opacity-0"),onClick:s,"aria-hidden":"true"}),r.jsxs("div",{ref:l,className:De("safe-area-frame fixed top-0 right-0 z-50 flex h-full w-full flex-col border-l border-line bg-canvas shadow-xl sm:w-[400px] sm:max-w-[90vw]","transform transition-transform duration-200 ease-out",e?"translate-x-0":"pointer-events-none translate-x-full"),role:"dialog","aria-modal":"true","aria-hidden":!e,inert:!e,"aria-labelledby":"slide-panel-title",tabIndex:-1,children:[r.jsxs("div",{className:"flex h-14 shrink-0 items-center justify-between border-b border-line px-4",children:[r.jsx("h2",{id:"slide-panel-title",className:"font-semibold",children:t}),r.jsx("button",{type:"button",onClick:s,className:"rounded-md p-1.5 transition-colors hover:bg-surface-raised","aria-label":"Close",children:r.jsx(Fe,{className:"size-5"})})]}),r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[r.jsx("div",{className:"flex-1 overflow-auto p-4",children:a}),n&&r.jsx("div",{className:"flex justify-end gap-3 border-t border-line bg-canvas p-4",children:n})]})]})]})}var He=e=>e.type==="checkbox",we=e=>e instanceof Date,K=e=>e==null;const yt=e=>typeof e=="object";var z=e=>!K(e)&&!Array.isArray(e)&&yt(e)&&!we(e),Fr=e=>z(e)&&e.target?He(e.target)?e.target.checked:e.target.value:e,Or=(e,s)=>s.split(".").some((t,a,n)=>!isNaN(Number(t))&&e.has(n.slice(0,a).join("."))),fs=e=>{const s=e.constructor&&e.constructor.prototype;return z(s)&&s.hasOwnProperty("isPrototypeOf")},Ze=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function $(e){if(e instanceof Date)return new Date(e);const s=typeof FileList<"u"&&e instanceof FileList;if(Ze&&(e instanceof Blob||s))return e;const t=Array.isArray(e);if(!t&&!(z(e)&&fs(e)))return e;const a=t?[]:Object.create(Object.getPrototypeOf(e));for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(a[n]=$(e[n]));return a}const Pe={BLUR:"blur",FOCUS_OUT:"focusout",SUBMIT:"submit",TRIGGER:"trigger",VALID:"valid"},ue={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},de={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},ms="root",xt=["__proto__","constructor","prototype"],Rr=/^\w*$/;var ze=e=>Rr.test(e),U=e=>e===void 0;const Ir=/[.[\]'"]/;var Je=e=>e.split(Ir).filter(Boolean),b=(e,s,t)=>{if(!s||!z(e))return t;const a=ze(s)?[s]:Je(s);if(a.some(l=>xt.includes(l)))return t;const n=a.reduce((l,o)=>K(l)?void 0:l[o],e);return U(n)||n===e?U(e[s])?t:e[s]:n},pe=e=>typeof e=="boolean",ne=e=>typeof e=="function",M=(e,s,t)=>{let a=-1;const n=ze(s)?[s]:Je(s),l=n.length,o=l-1;for(;++a<l;){const u=n[a];let x=t;if(a!==o){const N=e[u];x=z(N)||Array.isArray(N)?N:isNaN(+n[a+1])?{}:[]}if(xt.includes(u))return;e[u]=x,e=e[u]}};const Mr=ee.createContext(null);Mr.displayName="HookFormControlContext";var Lr=(e,s,t,a=!0)=>{const n={};for(const l in e)Object.defineProperty(n,l,{get:()=>{const o=l;return s._proxyFormState[o]!==ue.all&&(s._proxyFormState[o]=!a||ue.all),e[o]}});return n};const Ur=Ze?ee.useLayoutEffect:ee.useEffect;var Q=e=>typeof e=="string",Hr=(e,s,t,a,n)=>Q(e)?(a&&s.watch.add(e),b(t,e,n)):Array.isArray(e)?e.map(l=>(a&&s.watch.add(l),b(t,l))):(a&&(s.watchAll=!0),t),ct=e=>K(e)||!yt(e);const Lt=(e,s)=>s.length===0&&!Array.isArray(e)&&!fs(e);function he(e,s,t=new WeakMap){if(e===s)return!0;if(ct(e)||ct(s))return Object.is(e,s);if(we(e)&&we(s))return Object.is(e.getTime(),s.getTime());const a=Object.keys(e),n=Object.keys(s);if(a.length!==n.length)return!1;if(Lt(e,a)||Lt(s,n))return Object.is(e,s);if(!a.length&&Array.isArray(e)!==Array.isArray(s))return!1;const l=t.get(e);if(l&&l.has(s))return!0;if(l)l.add(s);else{const o=new WeakSet;o.add(s),t.set(e,o)}for(const o of a){const u=e[o];if(!(o in s))return!1;if(o!=="ref"){const x=s[o];if(we(u)&&we(x)||(z(u)||Array.isArray(u))&&(z(x)||Array.isArray(x))?!he(u,x,t):!Object.is(u,x))return!1}}return!0}var qe=e=>({isOnSubmit:!e||e===ue.onSubmit,isOnBlur:e===ue.onBlur,isOnChange:e===ue.onChange,isOnAll:e===ue.all,isOnTouch:e===ue.onTouched}),rt=(e,s,t)=>{if(t)return!1;if(s.watchAll||s.watch.has(e))return!0;for(const a of s.watch)if(e.startsWith(a)&&e.charAt(a.length)===".")return!0;return!1};const Ue=(e,s,t,a)=>{for(const n of t||Object.keys(e)){const l=b(e,n);if(l){const{_f:o,...u}=l;if(o){if(o.refs&&o.refs[0]&&s(o.refs[0],n)&&!a)return!0;if(o.ref&&s(o.ref,o.name)&&!a)return!0;if(Ue(u,s))break}else if(z(u)&&Ue(u,s))break}}};var Ut=(e,s,t)=>{const a=b(e,t),n=Array.isArray(a)?a:[];return M(n,ms,s[t]),M(e,t,n),e},G=e=>z(e)&&!Object.keys(e).length,bt=e=>e.type==="file",Ke=e=>{if(!Ze)return!1;const s=e?e.ownerDocument:0;return e instanceof(s&&s.defaultView?s.defaultView.HTMLElement:HTMLElement)},vt=e=>e.type==="radio",Qe=e=>e instanceof RegExp,St=(e,s,t,a,n)=>s?{...t[e],types:{...t[e]&&t[e].types?t[e].types:{},[a]:n||!0}}:{};const Ht={value:!1,isValid:!1},zt={value:!0,isValid:!0};var ps=e=>{if(Array.isArray(e)){if(e.length>1){const s=e.filter(t=>t&&t.checked&&!t.disabled).map(t=>t.value);return{value:s,isValid:!!s.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!U(e[0].attributes.value)?U(e[0].value)||e[0].value===""?zt:{value:e[0].value,isValid:!0}:zt:Ht}return Ht};const $t={isValid:!1,value:null};var hs=e=>Array.isArray(e)?e.reduce((s,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:s,$t):$t;function Bt(e,s,t="validate"){if(Q(e)||Array.isArray(e)&&e.every(Q)||pe(e)&&!e)return{type:t,message:Q(e)?e:"",ref:s}}var Ce=e=>z(e)&&!Qe(e)?e:{value:e,message:""},qt=async(e,s,t,a,n,l)=>{const{ref:o,refs:u,required:x,maxLength:N,minLength:T,min:L,max:F,pattern:R,validate:k,name:f,valueAsNumber:S,mount:se}=e._f,A=b(t,f);if(!se||s.has(f))return{};const _=u?u[0]:o,P=C=>{if(n&&_.reportValidity){const V=pe(C)?"":C||"";u?u.forEach(I=>I.setCustomValidity(V)):_.setCustomValidity(V),_.reportValidity()}},E={},ie=vt(o),ae=He(o),ye=ie||ae,oe=(S||bt(o))&&U(o.value)&&U(A)||Ke(o)&&o.value===""||A===""||Array.isArray(A)&&!A.length,Y=St.bind(null,f,a,E),le=(C,V,I,q=de.maxLength,Z=de.minLength)=>{const j=C?V:I;E[f]={type:C?q:Z,message:j,ref:o,...Y(C?q:Z,j)}};if(l?!Array.isArray(A)||!A.length:x&&(!ye&&(oe||K(A))||pe(A)&&!A||ae&&!ps(u).isValid||ie&&!hs(u).isValid)){const{value:C,message:V}=Q(x)?{value:!!x,message:x}:Ce(x);if(C&&(E[f]={type:de.required,message:V,ref:_,...Y(de.required,V)},!a))return P(V),E}if(!oe&&(!K(L)||!K(F))){let C,V;const I=Ce(F),q=Ce(L);if(!K(A)&&!isNaN(A)){const Z=o.valueAsNumber||A&&+A;K(I.value)||(C=Z>I.value),K(q.value)||(V=Z<q.value)}else{const Z=o.valueAsDate||new Date(A),j=fe=>new Date(new Date().toDateString()+" "+fe),J=o.type=="time",W=o.type=="week";Q(I.value)&&A&&(C=J?j(A)>j(I.value):W?A>I.value:Z>new Date(I.value)),Q(q.value)&&A&&(V=J?j(A)<j(q.value):W?A<q.value:Z<new Date(q.value))}if((C||V)&&(le(!!C,I.message,q.message,de.max,de.min),!a))return P(E[f].message),E}if((N||T)&&!oe&&(Q(A)||l&&Array.isArray(A))){const C=Ce(N),V=Ce(T),I=!K(C.value)&&A.length>+C.value,q=!K(V.value)&&A.length<+V.value;if((I||q)&&(le(I,C.message,V.message),!a))return P(E[f].message),E}if(R&&!oe&&Q(A)){const{value:C,message:V}=Ce(R);if(Qe(C)&&!A.match(C)&&(E[f]={type:de.pattern,message:V,ref:o,...Y(de.pattern,V)},!a))return P(V),E}if(k){if(ne(k)){const C=await k(A,t),V=Bt(C,_);if(V&&(E[f]={...V,...Y(de.validate,V.message)},!a))return P(V.message),E}else if(z(k)){let C={};for(const V in k){if(!G(C)&&!a)break;const I=Bt(await k[V](A,t),_,V);I&&(C={...I,...Y(V,I.message)},P(I.message),a&&(E[f]=C))}if(!G(C)&&(E[f]={ref:_,...C},!a))return E}}return P(!0),E},Ge=e=>Array.isArray(e)?e:[e],gs=e=>Array.isArray(e)?e.filter(Boolean):[];function zr(e,s){const t=s.slice(0,-1).length;let a=0;for(;a<t;){if(K(e)){e=void 0;break}e=e[s[a]],a++}return e}function $r(e){for(const s in e)if(e.hasOwnProperty(s)&&!U(e[s]))return!1;return!0}function B(e,s){if(Q(s)&&Object.prototype.hasOwnProperty.call(e,s))return delete e[s],e;const t=Array.isArray(s)?s:ze(s)?[s]:Je(s);if(t.some(o=>xt.includes(String(o))))return e;const a=t.length===1?e:zr(e,t),n=t.length-1,l=t[n];return a&&delete a[l],n!==0&&(z(a)&&G(a)||Array.isArray(a)&&$r(a))&&B(e,t.slice(0,-1)),e}const ys=e=>{const s={};for(const t of Object.keys(e))if(yt(e[t])&&e[t]!==null&&!we(e[t])){const a=ys(e[t]);for(const n of Object.keys(a))s[`${t}.${n}`]=a[n]}else s[t]=e[t];return s},Br=ee.createContext(null);Br.displayName="HookFormContext";var Wt=()=>{let e=[];return{get observers(){return e},next:n=>{for(const l of e)l.next&&l.next(n)},subscribe:n=>(e.push(n),{unsubscribe:()=>{e=e.filter(l=>l!==n)}}),unsubscribe:()=>{e=[]}}};function xs(e,s){const t={};for(const a in e)if(e.hasOwnProperty(a)){const n=e[a],l=s[a];if(n&&z(n)&&l){const o=xs(n,l);z(o)&&(t[a]=o)}else e[a]&&(t[a]=l)}return t}var bs=e=>e.type==="select-multiple",qr=e=>vt(e)||He(e),it=e=>Ke(e)&&e.isConnected,Wr=e=>{for(const s in e)if(ne(e[s]))return!0;return!1};function vs(e){return Array.isArray(e)||z(e)&&!Wr(e)}function Ss(e){return!!(e&&"_f"in e)}function js(e){return Array.isArray(e)?!e.some(s=>!U(s)):!Object.keys(e).length}function dt(e,s){Array.isArray(e)?e[s]=void 0:delete e[s]}function ut(e,s={},t){for(const a in e){const n=e[a],l=t&&t[a];vs(n)&&(!Array.isArray(n)||!Ss(l))?(s[a]=Array.isArray(n)?[]:{},ut(n,s[a],l),js(s[a])&&dt(s,a)):U(n)||(s[a]=!0)}return s}function Te(e,s,t,a){t||(t=ut(s,{},a));for(const n in e){const l=e[n],o=a&&a[n];vs(l)&&(!Array.isArray(l)||!Ss(o))?(U(s)||ct(t[n])?t[n]=ut(l,Array.isArray(l)?[]:{},o):Te(l,K(s)?{}:s[n],t[n],o),js(t[n])&&dt(t,n)):he(l,s[n])?dt(t,n):t[n]=!0}return t}var ws=(e,{valueAsNumber:s,valueAsDate:t,setValueAs:a})=>U(e)?e:s?e===""?NaN:e&&+e:t&&Q(e)?new Date(e):a?a(e):e;function Gt(e){const s=e.ref;return bt(s)?s.files:vt(s)?hs(e.refs).value:bs(s)?[...s.selectedOptions].map(({value:t})=>t):He(s)?ps(e.refs).value:ws(U(s.value)?e.ref.value:s.value,e)}var Gr=(e,s,t,a)=>{const n={};for(const l of e){const o=b(s,l);o&&M(n,l,o._f)}return{criteriaMode:t,names:[...e],fields:n,shouldUseNativeValidation:a}},Le=e=>U(e)?e:Qe(e)?e.source:z(e)?Qe(e.value)?e.value.source:e.value:e;const Kt="AsyncFunction";var Kr=e=>{if(!e||!e.validate)return!1;if(ne(e.validate))return e.validate.constructor.name===Kt;if(z(e.validate)){for(const s in e.validate)if(e.validate[s].constructor.name===Kt)return!0}return!1},Qr=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function Qt(e,s,t){const a=b(e,t);if(a||ze(t))return{error:a,name:t};const n=t.split(".");for(;n.length;){const l=n.join("."),o=b(s,l),u=b(e,l);if(o&&!Array.isArray(o)&&t!==l)return{name:t};if(u&&u.type)return{name:l,error:u};if(u&&u.root&&u.root.type)return{name:`${l}.root`,error:u.root};n.pop()}return{name:t}}var Yr=(e,s,t,a)=>{t(e);const{name:n,...l}=e,o=Object.keys(l);return!o.length||a&&o.length>=Object.keys(s).length||o.find(u=>s[u]===(!a||ue.all))},Zr=(e,s,t)=>!e||!s||e===s||Ge(e).some(a=>a&&(t?a===s||a.startsWith(s+"."):a.startsWith(s)||s.startsWith(a))),Jr=(e,s,t,a,n)=>n.isOnAll?!1:!t&&n.isOnTouch?!(s||e):(t?a.isOnBlur:n.isOnBlur)?!e:(t?a.isOnChange:n.isOnChange)?e:!0,Xr=(e,s)=>!gs(b(e,s)).length&&B(e,s);const ei={mode:ue.onSubmit,reValidateMode:ue.onChange,shouldFocusError:!0},at="form",Ns={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function ti(e={}){let s={...ei,...e},t={...$(Ns),isLoading:ne(s.defaultValues),errors:s.errors||{},disabled:s.disabled||!1},a={},n=z(s.defaultValues)||z(s.values)?$(s.defaultValues||s.values)||{}:{},l=s.shouldUnregister?{}:$(n),o={action:!1,mount:!1,watch:!1,keepIsValid:!1},u={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set,registerName:new Set};const x={},N={};let T=0,L=qe(s.mode),F=qe(s.reValidateMode);const R={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},k={...R};let f={...k};const S={array:Wt(),state:Wt()};let se=0;const A=s.criteriaMode===ue.all,_=(i,c)=>d=>{clearTimeout(N[i]),N[i]=setTimeout(c,d)},P=async i=>{if(!o.keepIsValid&&!s.disabled&&(k.isValid||f.isValid||i)){const c=++se;let d;s.resolver?(d=G((await I()).errors),c===se&&E()):d=await j({fields:a,onlyCheckValid:!0,eventType:Pe.VALID}),c===se&&d!==t.isValid&&S.state.next({isValid:d})}},E=(i,c)=>{!s.disabled&&(k.isValidating||k.validatingFields||f.isValidating||f.validatingFields)&&((i||Array.from(u.mount)).forEach(d=>{d&&(c?M(t.validatingFields,d,c):B(t.validatingFields,d))}),S.state.next({validatingFields:t.validatingFields,isValidating:!G(t.validatingFields)}))},ie=()=>{t.dirtyFields=Te(n,l,void 0,a)},ae=(i,c=[],d,m,p=!0,y=!0)=>{if(m&&d&&!s.disabled){if(o.action=!0,y&&Array.isArray(b(a,i))){const g=d(b(a,i),m.argA,m.argB);p&&M(a,i,g)}if(y&&Array.isArray(b(t.errors,i))){const g=d(b(t.errors,i),m.argA,m.argB);p&&M(t.errors,i,g),Xr(t.errors,i)}if((k.touchedFields||f.touchedFields)&&y&&Array.isArray(b(t.touchedFields,i))){const g=d(b(t.touchedFields,i),m.argA,m.argB);p&&M(t.touchedFields,i,g)}(k.dirtyFields||f.dirtyFields)&&ie(),S.state.next({name:i,isDirty:W(i,c),dirtyFields:t.dirtyFields,errors:t.errors,isValid:t.isValid})}else M(l,i,c)},ye=(i,c)=>{M(t.errors,i,c),t.errors={...t.errors},S.state.next({errors:t.errors})},oe=i=>{t.errors=i,S.state.next({errors:t.errors,isValid:!1})},Y=i=>{const c=ze(i)?[i]:Je(i);let d=l,m=n;for(let p=0;p<c.length-1;p++){const y=c[p];if(d=K(d)?d:d[y],m=K(m)?m:m[y],d===null&&m!==null)return!0}return!1},le=(i,c,d,m)=>{const p=b(a,i);if(p){if(Y(i))return;const y=U(b(l,i)),g=b(l,i,U(d)?b(n,i):d);U(g)||m&&m.defaultChecked||c?M(l,i,c?g:Gt(p._f)):Ne(i,g),o.mount&&!o.action&&(P(),y&&t.isDirty&&(k.isDirty||f.isDirty)&&(W()||(t.isDirty=!1,S.state.next({...t}))),e.shouldUnregister&&y&&!U(b(l,i))&&rt(i,u)&&(o.watch=!0))}},C=(i,c,d,m,p)=>{let y=!1,g=!1;const v={name:i};if(!s.disabled||m===!0){if(!d||m){const w=he(b(n,i),c);(k.isDirty||f.isDirty)&&(g=t.isDirty,t.isDirty=v.isDirty=!w||W(),y=g!==v.isDirty),g=!!b(t.dirtyFields,i),w!==t.isDirty?t.dirtyFields=Te(n,l,void 0,a):w?B(t.dirtyFields,i):M(t.dirtyFields,i,!0),v.dirtyFields=t.dirtyFields,y=y||(k.dirtyFields||f.dirtyFields)&&g!==!w}if(d){const w=b(t.touchedFields,i);w||(M(t.touchedFields,i,d),v.touchedFields=t.touchedFields,y=y||(k.touchedFields||f.touchedFields)&&w!==d)}y&&p&&S.state.next(v)}return y?v:{}},V=(i,c,d,m)=>{const p=b(t.errors,i),y=(k.isValid||f.isValid)&&pe(c)&&t.isValid!==c;if(s.delayError&&d?(x[i]=_(i,()=>ye(i,d)),x[i](s.delayError)):(clearTimeout(N[i]),delete x[i],d?M(t.errors,i,d):B(t.errors,i),t.errors={...t.errors}),(d?!he(p,d):p)||!G(m)||y){const g={...m,...y&&pe(c)?{isValid:c}:{},errors:t.errors,name:i};t={...t,...g},S.state.next(g)}},I=async i=>(E(i,!0),await s.resolver(l,s.context,Gr(i||u.mount,a,s.criteriaMode,s.shouldUseNativeValidation))),q=async i=>{const{errors:c}=await I(i);if(E(i),i){for(const d of i){const m=b(c,d);m?u.array.has(d)&&z(m)&&!Object.keys(m).some(p=>!Number.isNaN(Number(p)))?Ut(t.errors,{[d]:m},d):M(t.errors,d,m):B(t.errors,d)}t.errors={...t.errors}}else t.errors=c;return c},Z=async({name:i,eventType:c})=>{if(e.validate){const d=await e.validate({formValues:l,formState:t,name:i,eventType:c});if(z(d))for(const m in d){const p=d[m];p&&$e(`${at}.${m}`,{message:Q(p.message)?p.message:"",type:p.type||de.validate})}else Q(d)||!d?$e(at,{message:d||"",type:de.validate}):_e(at);return d}return!0},j=async({fields:i,onlyCheckValid:c,name:d,eventType:m,context:p={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(p.runRootValidation=!0,!await Z({name:d,eventType:m})&&(p.valid=!1,c)))return p.valid;for(const y in i){const g=i[y];if(g){const{_f:v,...w}=g;if(v){const H=u.array.has(v.name),X=g._f&&Kr(g._f),xe=k.validatingFields||k.isValidating||f.validatingFields||f.isValidating;X&&xe&&E([v.name],!0);const be=await qt(g,u.disabled,l,A,s.shouldUseNativeValidation&&!c,H);if(X&&xe&&E([v.name]),be[v.name]&&(p.valid=!1,c)||(!c&&(b(be,v.name)?H?Ut(t.errors,be,v.name):M(t.errors,v.name,be[v.name]):B(t.errors,v.name)),e.shouldUseNativeValidation&&be[v.name]))break}!G(w)&&await j({context:p,onlyCheckValid:c,fields:w,name:y,eventType:m})}}return p.valid},J=()=>{for(const i of u.unMount){const c=b(a,i);c&&(c._f.refs?c._f.refs.every(d=>!it(d)):!it(c._f.ref))&&et(i)}u.unMount=new Set},W=(i,c)=>(i&&c&&M(l,i,c),!he(o.mount?l:n,n)),fe=(i,c,d)=>Hr(i,u,{...o.mount?l:U(c)?n:Q(i)?{[i]:c}:c},d,c),Ee=i=>gs(b(o.mount?l:n,i,s.shouldUnregister?b(n,i,[]):[])),Ne=(i,c,d={},m=!1,p=!1)=>{const y=b(a,i);let g=c;if(y){const v=y._f;v&&(!v.disabled&&M(l,i,ws(c,v)),g=Ke(v.ref)&&K(c)?"":c,bs(v.ref)?[...v.ref.options].forEach(w=>w.selected=g.includes(w.value)):v.refs?He(v.ref)?v.refs.forEach(w=>{(!w.defaultChecked||!w.disabled)&&(Array.isArray(g)?w.checked=!!g.find(H=>H===w.value):w.checked=g===w.value||!!g)}):v.refs.forEach(w=>w.checked=w.value===g):bt(v.ref)?v.ref.value="":(v.ref.value=g,!v.ref.type&&!p&&S.state.next({name:i,values:m?l:$(l)})))}(d.shouldDirty||d.shouldTouch)&&C(i,g,d.shouldTouch,d.shouldDirty,!p),d.shouldValidate&&me(i,{delayError:d.delayError})},ke=(i,c,d,m=!1,p=!1)=>{for(const y in c){if(!c.hasOwnProperty(y))return;const g=c[y],v=i+"."+y,w=b(a,v);(u.array.has(i)||z(g)||w&&!w._f)&&!we(g)?ke(v,g,d,m,p):Ne(v,g,d,m,p)}},Xe=(i,c,d,m,p=!1)=>{const y=b(a,i),g=u.array.has(i),v=m?c:$(c),w=b(l,i),H=he(w,v);if(H||M(l,i,v),g)S.array.next({name:i,values:m?l:$(l)}),(k.isDirty||k.dirtyFields||f.isDirty||f.dirtyFields)&&d.shouldDirty&&(ie(),p||S.state.next({name:i,dirtyFields:t.dirtyFields,isDirty:W(i,v)}));else{const X=Array.isArray(v)&&!v.length||G(v);!y||y._f||K(v)||X?Ne(i,v,d,m,p):ke(i,v,d,m,p)}if(!H&&!p){const X=rt(i,u),xe=m?l:$(l);S.state.next({...X&&t,name:o.mount||X?i:void 0,values:xe})}},h=(i,c,d={})=>Xe(i,c,d,!1),O=(i,c={})=>{const d=ne(i)?i(l):i;if(!he(l,d)){l={...l,...d};const m=ys(d);for(const p of u.mount)p in m&&Xe(p,m[p],c,!0,!0);S.state.next({...t,name:void 0,type:void 0,...T?{values:l}:{}}),c.shouldValidate&&P()}},ce=async i=>{o.mount=!0;const c=i.target;let d=c.name,m=!0;const p=b(a,d),y=g=>{m=Number.isNaN(g)||we(g)&&isNaN(g.getTime())||he(g,b(l,d,g))};if(p){let g,v;const w=c.type?Gt(p._f):Fr(i),H=i.type===Pe.BLUR||i.type===Pe.FOCUS_OUT,X=!Qr(p._f)&&!e.validate&&!s.resolver&&!b(t.errors,d)&&!p._f.deps,xe=X||Jr(H,b(t.touchedFields,d),t.isSubmitted,F,L),be=rt(d,u,H);if(M(l,d,w),H){if(!c||!c.readOnly){p._f.onBlur&&p._f.onBlur(i);const Ie=x[d];Ie&&Ie(0)}}else p._f.onChange&&p._f.onChange(i);const Re=C(d,w,H),Ms=!G(Re)||be;if(!H&&S.state.next({name:d,type:i.type,...T?{values:$(l)}:{}}),xe)return(!X||!t.isValid)&&(k.isValid||f.isValid)&&(s.mode==="onBlur"?H&&P():H||P()),Ms&&S.state.next({name:d,...be?{}:Re});if(!s.resolver&&e.validate&&await Z({name:d,eventType:i.type}),!H&&be&&S.state.next({...t}),s.resolver){const{errors:Ie}=await I([d]);if(E([d]),y(w),!m){!G(Re)&&S.state.next(Re);return}const Ls=Qt(t.errors,a,d),kt=Qt(Ie,a,Ls.name||d);g=kt.error,d=kt.name,v=G(Ie)}else E([d],!0),g=(await qt(p,u.disabled,l,A,s.shouldUseNativeValidation))[d],E([d]),y(w),m&&(g?v=!1:(k.isValid||f.isValid)&&(v=await j({fields:a,onlyCheckValid:!0,name:d,eventType:i.type})));m&&(p._f.deps&&(!Array.isArray(p._f.deps)||p._f.deps.length>0)&&me(p._f.deps),V(d,v,g,Re))}},re=(i,c)=>{if(b(t.errors,c)&&i.focus)return i.focus(),1},me=async(i,c={})=>{let d,m;const p=Ge(i);if(s.resolver){const y=await q(U(i)?i:p);d=G(y),m=i?!p.some(g=>b(y,g)):d}else i?(m=(await Promise.all(p.map(async y=>{const g=b(a,y);return await j({fields:g&&g._f?{[y]:g}:g,eventType:Pe.TRIGGER})}))).every(Boolean),!(!m&&!t.isValid)&&P()):m=d=await j({fields:a,name:i,eventType:Pe.TRIGGER});if(c.delayError&&s.delayError&&Q(i)){const y=b(t.errors,i);y?(B(t.errors,i),x[i]=_(i,()=>ye(i,y)),x[i](s.delayError)):(clearTimeout(N[i]),delete x[i])}return S.state.next({...!Q(i)||(k.isValid||f.isValid)&&d!==t.isValid?{}:{name:i},...s.resolver||!i?{isValid:d}:{},errors:t.errors}),c.shouldFocus&&!m&&Ue(a,re,i?p:u.mount),m},Ae=(i,c)=>{let d={...o.mount?l:n};return c&&(d=xs(c.dirtyFields?t.dirtyFields:t.touchedFields,d)),U(i)?d:Q(i)?b(d,i):i.map(m=>b(d,m))},Oe=(i,c)=>({invalid:!!b((c||t).errors,i),isDirty:!!b((c||t).dirtyFields,i),error:b((c||t).errors,i),isValidating:!!b(t.validatingFields,i),isTouched:!!b((c||t).touchedFields,i)}),_e=i=>{const c=i?Ge(i):void 0;c?.forEach(d=>B(t.errors,d)),c?c.forEach(d=>{S.state.next({name:d,errors:t.errors})}):S.state.next({errors:{}})},$e=(i,c,d)=>{const m=(b(a,i,{_f:{}})._f||{}).ref,p=b(t.errors,i)||{},{ref:y,message:g,type:v,...w}=p;M(t.errors,i,{...w,...c,ref:m}),S.state.next({name:i,errors:t.errors,isValid:!1}),d&&d.shouldFocus&&m&&m.focus&&m.focus()},Vs=(i,c)=>{if(ne(i)){T++;const{unsubscribe:d}=S.state.subscribe({next:p=>"values"in p&&i(p.values||fe(void 0,c),p)});let m=!1;return{unsubscribe:()=>{m||(m=!0,T--,d())}}}return fe(i,c,!0)},jt=i=>{var c;const d=!!(!((c=i.formState)===null||c===void 0)&&c.values);d&&T++;const{unsubscribe:m}=S.state.subscribe({next:y=>{if(Zr(i.name,y.name,i.exact)&&Yr(y,i.formState||k,Is,i.reRenderRoot)){const g={...l};i.callback({values:g,...t,...y,defaultValues:n})}}});if(!d)return m;let p=!1;return()=>{p||(p=!0,T--,m())}},Ds=i=>(o.mount=!0,f={...f,...i.formState},jt({...i,formState:{...R,...i.formState}})),et=(i,c={})=>{for(const d of i?Ge(i):u.mount)u.mount.delete(d),u.array.delete(d),c.keepValue||(B(a,d),B(l,d)),!c.keepError&&B(t.errors,d),!c.keepDirty&&B(t.dirtyFields,d),!c.keepTouched&&B(t.touchedFields,d),!c.keepIsValidating&&B(t.validatingFields,d),!s.shouldUnregister&&!c.keepDefaultValue&&B(n,d);S.state.next({values:$(l)}),S.state.next({...t,...c.keepDirty?{isDirty:W()}:{}}),!c.keepIsValid&&P()},wt=({disabled:i,name:c})=>{if(pe(i)&&o.mount||i||u.disabled.has(c)){const p=u.disabled.has(c)!==!!i;i?u.disabled.add(c):u.disabled.delete(c),p&&o.mount&&!o.action&&P()}},tt=(i,c={})=>{let d=b(a,i);const m=pe(c.disabled)||pe(s.disabled),p=!u.registerName.has(i)&&d&&d._f&&!d._f.mount;return M(a,i,{...d||{},_f:{...d&&d._f?d._f:{ref:{name:i}},name:i,mount:!0,...c}}),u.mount.add(i),d&&!p?wt({disabled:pe(c.disabled)?c.disabled:s.disabled,name:i}):le(i,!0,c.value),{...m?{disabled:c.disabled||s.disabled}:{},...s.progressive?{required:!!c.required,min:Le(c.min),max:Le(c.max),minLength:Le(c.minLength),maxLength:Le(c.maxLength),pattern:Le(c.pattern)}:{},name:i,onChange:ce,onBlur:ce,ref:y=>{if(y){u.registerName.add(i),tt(i,c),u.registerName.delete(i),d=b(a,i);const g=U(y.value)&&y.querySelectorAll&&y.querySelectorAll("input,select,textarea")[0]||y,v=qr(g),w=d._f.refs||[];if(v?w.find(H=>H===g):g===d._f.ref)return;M(a,i,{_f:{...d._f,...v?{refs:[...w.filter(it),g,...Array.isArray(b(n,i))?[{}]:[]],ref:{type:g.type,name:i}}:{ref:g}}}),le(i,!1,void 0,g)}else d=b(a,i,{}),d._f&&(d._f.mount=!1),(s.shouldUnregister||c.shouldUnregister)&&!(Or(u.array,i)&&o.action)&&u.unMount.add(i)}}},st=()=>s.shouldFocusError&&!s.shouldUseNativeValidation&&Ue(a,re,u.mount),Fs=i=>{pe(i)&&(S.state.next({disabled:i}),Ue(a,(c,d)=>{const m=b(a,d);m&&(c.disabled=m._f.disabled||i,Array.isArray(m._f.refs)&&m._f.refs.forEach(p=>{p.disabled=m._f.disabled||i}))},0,!1))},Nt=(i,c)=>async d=>{let m;d&&(d.preventDefault&&d.preventDefault(),d.persist&&d.persist());let p=$(l);if(S.state.next({isSubmitting:!0}),s.resolver){const{errors:y,values:g}=await I();E(),t.errors=y,p=$(g)}else await j({fields:a,eventType:Pe.SUBMIT});if(u.disabled.size)for(const y of u.disabled)B(p,y);if(B(t.errors,ms),G(t.errors)){S.state.next({errors:{}});try{await i(p,d)}catch(y){m=y}}else c&&await c({...t.errors},d),st(),setTimeout(st);if(S.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:G(t.errors)&&!m,submitCount:t.submitCount+1,errors:t.errors}),m)throw m},Os=(i,c={})=>{b(a,i)&&(U(c.defaultValue)?h(i,$(b(n,i))):(h(i,c.defaultValue),M(n,i,$(c.defaultValue))),c.keepTouched||B(t.touchedFields,i),c.keepDirty||(B(t.dirtyFields,i),t.isDirty=c.defaultValue?W(i,$(b(n,i))):W()),c.keepError||(B(t.errors,i),k.isValid&&P()),S.state.next({...t}))},At=(i,c={})=>{const d=i?$(i):n,m=$(d),p=G(i),y=m,g=a;if(c.keepDefaultValues||(n=d),!c.keepValues){if(c.keepDirtyValues){const v=new Set([...u.mount,...Object.keys(Te(n,l,void 0,g))]);for(const w of Array.from(v)){const H=b(t.dirtyFields,w),X=b(l,w),xe=b(y,w);H&&!U(X)?M(y,w,X):!H&&!U(xe)&&h(w,xe)}}else{if(Ze&&U(i))for(const v of u.mount){const w=b(a,v);if(w&&w._f){const H=Array.isArray(w._f.refs)?w._f.refs[0]:w._f.ref;if(Ke(H)){const X=H.closest("form");if(X){X.reset();break}}}}if(c.keepFieldsRef)for(const v of u.mount)h(v,b(y,v));else a={}}if(s.shouldUnregister){if(l=c.keepDefaultValues?$(n):{},c.keepFieldsRef)for(const v of u.mount)M(l,v,b(y,v))}else l=$(y);S.array.next({values:{...y}}),S.state.next({name:void 0,type:void 0,values:{...y}})}u={mount:c.keepDirtyValues?u.mount:new Set,unMount:new Set,array:new Set,registerName:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!k.isValid||!!c.keepIsValid||!!c.keepDirtyValues||!s.shouldUnregister&&!G(y),o.watch=!!s.shouldUnregister,o.keepIsValid=!!c.keepIsValid,o.action=!1,c.keepErrors||(t.errors={}),S.state.next({submitCount:c.keepSubmitCount?t.submitCount:0,isDirty:p?!1:c.keepDirty?t.isDirty:c.keepValues?W():!!(c.keepDefaultValues&&!he(i,n)),isSubmitted:c.keepIsSubmitted?t.isSubmitted:!1,dirtyFields:p?{}:c.keepDirtyValues?c.keepDefaultValues&&l?Te(n,l,void 0,g):t.dirtyFields:c.keepDefaultValues&&i?Te(n,i,void 0,g):c.keepDirty?t.dirtyFields:{},touchedFields:c.keepTouched?t.touchedFields:{},errors:c.keepErrors?t.errors:{},isSubmitSuccessful:c.keepIsSubmitSuccessful?t.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:n})},Tt=(i,c)=>At(ne(i)?i(l):i,{...s.resetOptions,...c}),Rs=(i,c={})=>{const d=b(a,i),m=d&&d._f;if(m){const p=m.refs?m.refs[0]:m.ref;p.focus&&setTimeout(()=>{p.focus(),c.shouldSelect&&ne(p.select)&&p.select()})}},Is=i=>{const{name:c,type:d,values:m,...p}=i;t={...t,...p}},Et={control:{register:tt,unregister:et,getFieldState:Oe,handleSubmit:Nt,setError:$e,_subscribe:jt,_runSchema:I,_updateIsValidating:E,_focusError:st,_getWatch:fe,_getDirty:W,_setValid:P,_setFieldArray:ae,_setDisabledField:wt,_setErrors:oe,_getFieldArray:Ee,_reset:At,_resetDefaultValues:()=>ne(s.defaultValues)&&s.defaultValues().then(i=>{Tt(i,s.resetOptions),S.state.next({isLoading:!1})}),_removeUnmounted:J,_disableForm:Fs,_subjects:S,_proxyFormState:k,get _fields(){return a},get _formValues(){return l},get _state(){return o},set _state(i){o=i},get _defaultValues(){return n},get _names(){return u},set _names(i){u=i},get _formState(){return t},get _options(){return s},set _options(i){s={...s,...i},L=qe(s.mode),F=qe(s.reValidateMode)}},subscribe:Ds,trigger:me,register:tt,handleSubmit:Nt,watch:Vs,setValue:h,setValues:O,getValues:Ae,reset:Tt,resetField:Os,resetDefaultValues:(i,c={})=>{if(n=$(i),!c.keepDirty){const d=Te(n,l,void 0,a);t.dirtyFields=d,t.isDirty=!G(d)}c.keepIsValid||P(),S.state.next({...t,defaultValues:n})},clearErrors:_e,unregister:et,setError:$e,setFocus:Rs,getFieldState:Oe};return{...Et,formControl:Et}}function si(e={}){const s=ee.useRef(void 0),t=ee.useRef(void 0),a=ee.useRef(e.formControl),[n,l]=ee.useState(()=>({...$(Ns),isLoading:ne(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1,defaultValues:ne(e.defaultValues)?void 0:e.defaultValues}));if(!s.current||e.formControl&&a.current!==e.formControl)if(a.current=e.formControl,e.formControl)s.current={...e.formControl,formState:n},e.defaultValues&&!ne(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:u,...x}=ti(e);s.current={...x,formState:n}}const o=s.current.control;return o._options=e,Ur(()=>{const u=o._subscribe({formState:o._proxyFormState,callback:()=>l({...o._formState,defaultValues:o._defaultValues}),reRenderRoot:!0});return l(x=>({...x,isReady:!0})),o._formState.isReady=!0,u},[o]),ee.useEffect(()=>o._disableForm(e.disabled),[o,e.disabled]),ee.useEffect(()=>{e.mode&&(o._options.mode=e.mode),e.reValidateMode&&(o._options.reValidateMode=e.reValidateMode)},[o,e.mode,e.reValidateMode]),ee.useEffect(()=>{e.errors&&(o._setErrors(e.errors),o._focusError())},[o,e.errors]),ee.useEffect(()=>{e.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,e.shouldUnregister]),ee.useEffect(()=>{if(o._proxyFormState.isDirty){const u=o._getDirty();u!==n.isDirty&&o._subjects.state.next({isDirty:u})}},[o,n.isDirty]),ee.useEffect(()=>{var u;e.values&&!he(e.values,t.current)?(o._reset(e.values,{keepFieldsRef:!0,...o._options.resetOptions}),!((u=o._options.resetOptions)===null||u===void 0)&&u.keepIsValid||o._setValid(),t.current=e.values,l(x=>({...x}))):o._resetDefaultValues()},[o,e.values]),ee.useEffect(()=>{o._state.mount||(o._setValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()}),s.current.formState=ee.useMemo(()=>Lr(n,o),[o,n]),s.current}const Yt=(e,s,t)=>{if(e&&"reportValidity"in e){const a=b(t,s);e.setCustomValidity(a&&a.message||""),e.reportValidity()}},ft=(e,s)=>{for(const t in s.fields){const a=s.fields[t];a&&a.ref&&"reportValidity"in a.ref?Yt(a.ref,t,e):a&&a.refs&&a.refs.forEach(n=>Yt(n,t,e))}},Zt=(e,s)=>{s.shouldUseNativeValidation&&ft(e,s);const t={};for(const a in e){const n=b(s.fields,a),l=Object.assign(e[a]||{},{ref:n&&n.ref});if(ri(s.names||Object.keys(e),a)){const o=Object.assign({},b(t,a));M(o,"root",l),M(t,a,o)}else M(t,a,l)}return t},ri=(e,s)=>{const t=Jt(s).replace(/[.*+?^${}()|\\]/g,"\\$&");return e.some(a=>Jt(a).match(`^${t}\\.\\d+`))};function Jt(e){return e.replace(/[\[\]]/g,"")}function As(e,s,t){function a(u,x){var N;Object.defineProperty(u,"_zod",{value:u._zod??{},enumerable:!1}),(N=u._zod).traits??(N.traits=new Set),u._zod.traits.add(e),s(u,x);for(const T in o.prototype)T in u||Object.defineProperty(u,T,{value:o.prototype[T].bind(u)});u._zod.constr=o,u._zod.def=x}const n=t?.Parent??Object;class l extends n{}Object.defineProperty(l,"name",{value:e});function o(u){var x;const N=t?.Parent?new l:this;a(N,u),(x=N._zod).deferred??(x.deferred=[]);for(const T of N._zod.deferred)T();return N}return Object.defineProperty(o,"init",{value:a}),Object.defineProperty(o,Symbol.hasInstance,{value:u=>t?.Parent&&u instanceof t.Parent?!0:u?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}class ii extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const ai={};function Ts(e){return ai}function ni(e,s){return typeof s=="bigint"?s.toString():s}const Es=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function We(e){return typeof e=="string"?e:e?.message}function ks(e,s,t){const a={...e,path:e.path??[]};if(!e.message){const n=We(e.inst?._zod.def?.error?.(e))??We(s?.error?.(e))??We(t.customError?.(e))??We(t.localeError?.(e))??"Invalid input";a.message=n}return delete a.inst,delete a.continue,s?.reportInput||delete a.input,a}const _s=(e,s)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:s,enumerable:!1}),Object.defineProperty(e,"message",{get(){return JSON.stringify(s,ni,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},oi=As("$ZodError",_s),Ps=As("$ZodError",_s,{Parent:Error}),li=e=>(s,t,a,n)=>{const l=a?Object.assign(a,{async:!1}):{async:!1},o=s._zod.run({value:t,issues:[]},l);if(o instanceof Promise)throw new ii;if(o.issues.length){const u=new(n?.Err??e)(o.issues.map(x=>ks(x,l,Ts())));throw Es(u,n?.callee),u}return o.value},ci=li(Ps),di=e=>async(s,t,a,n)=>{const l=a?Object.assign(a,{async:!0}):{async:!0};let o=s._zod.run({value:t,issues:[]},l);if(o instanceof Promise&&(o=await o),o.issues.length){const u=new(n?.Err??e)(o.issues.map(x=>ks(x,l,Ts())));throw Es(u,n?.callee),u}return o.value},ui=di(Ps);function mt(){return mt=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var t=arguments[s];for(var a in t)({}).hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e},mt.apply(null,arguments)}function Xt(e,s){try{var t=e()}catch(a){return s(a)}return t&&t.then?t.then(void 0,s):t}function fi(e,s){for(var t={};e.length;){var a=e[0],n=a.code,l=a.message,o=a.path.join(".");if(!t[o])if("unionErrors"in a){var u=a.unionErrors[0].errors[0];t[o]={message:u.message,type:u.code}}else t[o]={message:l,type:n};if("unionErrors"in a&&a.unionErrors.forEach(function(T){return T.errors.forEach(function(L){return e.push(L)})}),s){var x=t[o].types,N=x&&x[a.code];t[o]=St(o,s,t,n,N?[].concat(N,a.message):a.message)}e.shift()}return t}function mi(e,s){for(var t={},a=function(){var n=e[0],l=n.code,o=n.message,u=n.path.join(".");if(!t[u])if(n.code==="invalid_union"&&n.errors.length>0){var x=n.errors[0][0];t[u]={message:x.message,type:x.code}}else t[u]={message:o,type:l};if(n.code==="invalid_union"&&n.errors.forEach(function(L){return L.forEach(function(F){return e.push(mt({},F,{path:[].concat(n.path,F.path)}))})}),s){var N=t[u].types,T=N&&N[n.code];t[u]=St(u,s,t,l,T?[].concat(T,n.message):n.message)}e.shift()};e.length;)a();return t}function pi(e,s,t){if(t===void 0&&(t={}),(function(a){return"_def"in a&&typeof a._def=="object"&&"typeName"in a._def})(e))return function(a,n,l){try{return Promise.resolve(Xt(function(){return Promise.resolve(e[t.mode==="sync"?"parse":"parseAsync"](a,s)).then(function(o){return l.shouldUseNativeValidation&&ft({},l),{errors:{},values:t.raw?Object.assign({},a):o}})},function(o){if((function(u){return Array.isArray(u?.issues)})(o))return{values:{},errors:Zt(fi(o.errors,!l.shouldUseNativeValidation&&l.criteriaMode==="all"),l)};throw o}))}catch(o){return Promise.reject(o)}};if((function(a){return"_zod"in a&&typeof a._zod=="object"})(e))return function(a,n,l){try{return Promise.resolve(Xt(function(){return Promise.resolve((t.mode==="sync"?ci:ui)(e,a,s)).then(function(o){return l.shouldUseNativeValidation&&ft({},l),{errors:{},values:t.raw?Object.assign({},a):o}})},function(o){if((function(u){return u instanceof oi})(o))return{values:{},errors:Zt(mi(o.issues,!l.shouldUseNativeValidation&&l.criteriaMode==="all"),l)};throw o}))}catch(o){return Promise.reject(o)}};throw new Error("Invalid input: not a Zod schema")}const hi=e=>{const s=Ye(),{pushError:t}=qs(),{data:a}=ns({...os(),staleTime:1/0}),n=a?.accounts.find(x=>x.accountId===e)?.composeLanguages,l=D.useMemo(()=>n&&n.length>0?[...n]:Ws(navigator.languages),[n]),o=ge({...gt(),onSuccess:()=>{s.invalidateQueries({queryKey:je()})},onError:x=>{t(Gs("Couldn't save languages","The writing languages weren't saved.",x))}}),u=D.useCallback(x=>{e&&o.mutate({path:{accountId:e},body:{composeLanguages:x}})},[e,o]);return{languages:l,setLanguages:u,isSaving:o.isPending}},gi=e=>e.authType==="oauthMicrosoft",yi="••••••••••",xi=e=>{const s=e.smtpUsername?.trim();return s?s!==e.username:!1},bi=Zs({email:Se().email().min(1,"Email is required"),displayName:Se().optional(),username:Se().optional(),password:Se().optional(),imapHost:Se().min(1,"IMAP host is required"),imapPort:Ct.number().int().min(1).max(65535),imapTls:Me(),imapStartTls:Me(),smtpHost:Se().optional(),smtpPort:Ct.number().int().min(1).max(65535).optional(),smtpTls:Me().optional(),smtpStartTls:Me().optional(),smtpUsername:Se().optional(),smtpPassword:Se().optional(),useDifferentSmtpCreds:Me().optional()}),vi=({isOpen:e,onClose:s,account:t,focusSmtp:a})=>{const n=Ye(),l=!!t,[o,u]=D.useState(!1),[x,N]=D.useState(""),[T,L]=D.useState(!1),F=Ot(x),R=!!F&&!T,k=D.useRef(null),f=si({resolver:pi(bi),defaultValues:{email:"",displayName:"",username:"",password:"",imapHost:"",imapPort:993,imapTls:!0,imapStartTls:!1,smtpHost:"",smtpPort:587,smtpTls:!1,smtpStartTls:!0,useDifferentSmtpCreds:!1}});D.useEffect(()=>{if(t){const h=xi(t);f.reset({email:t.email,displayName:t.displayName||"",username:t.username||"",password:yi,imapHost:t.imapHost,imapPort:t.imapPort,imapTls:t.imapTls,imapStartTls:t.imapStartTls,smtpHost:t.smtpHost||"",smtpPort:t.smtpPort||587,smtpTls:t.smtpTls||!1,smtpStartTls:t.smtpStartTls||!0,smtpUsername:h&&t.smtpUsername||"",smtpPassword:"",useDifferentSmtpCreds:h}),u(!1)}else f.reset({email:"",displayName:"",username:"",password:"",imapHost:"",imapPort:993,imapTls:!0,imapStartTls:!1,smtpHost:"",smtpPort:587,smtpTls:!1,smtpStartTls:!0,useDifferentSmtpCreds:!1}),u(!1)},[t,f]);const S=ge({...Ks()}),se=ge({...Qs(),onSuccess:()=>{n.invalidateQueries({queryKey:je()}),s()}}),A=ge({...gt(),onSuccess:()=>{n.invalidateQueries({queryKey:je()}),s()}}),_=()=>{const h=f.getValues(),O=l&&!o;S.mutate({body:{accountId:O?t?.accountId:void 0,username:h.username||h.email,password:O?void 0:h.password||void 0,imapHost:h.imapHost,imapPort:Number(h.imapPort),imapTls:h.imapTls,imapStartTls:h.imapStartTls}})},P=()=>{const h=f.getValues(),O=l&&!o;S.mutate({body:{accountId:O?t?.accountId:void 0,username:h.username||h.email,password:O?void 0:h.password||void 0,imapHost:h.imapHost,imapPort:Number(h.imapPort),imapTls:h.imapTls,imapStartTls:h.imapStartTls,smtpHost:h.smtpHost||void 0,smtpPort:h.smtpPort?Number(h.smtpPort):void 0,smtpTls:h.smtpTls,smtpStartTls:h.smtpStartTls,smtpUsername:h.useDifferentSmtpCreds?h.smtpUsername:void 0,smtpPassword:h.useDifferentSmtpCreds?h.smtpPassword:void 0}})},E=f.handleSubmit(h=>{if(!l&&!h.password){f.setError("password",{message:"Password is required"});return}const O=yr({imapHost:h.imapHost,smtpHost:h.smtpHost,smtpPort:h.smtpPort,smtpTls:h.smtpTls,smtpStartTls:h.smtpStartTls});O&&(f.setValue("smtpHost",O.smtpHost),f.setValue("smtpPort",O.smtpPort),f.setValue("smtpTls",O.smtpTls),f.setValue("smtpStartTls",O.smtpStartTls));const ce=O?.smtpHost??h.smtpHost,re=O?.smtpPort??h.smtpPort,me=O?.smtpTls??h.smtpTls,Ae=O?.smtpStartTls??h.smtpStartTls,Oe={email:h.email,displayName:h.displayName?.trim()||void 0,username:h.username||void 0,imapHost:h.imapHost,imapPort:Number(h.imapPort),imapTls:h.imapTls,imapStartTls:h.imapStartTls,smtpHost:ce||void 0,smtpPort:re?Number(re):void 0,smtpTls:me,smtpStartTls:Ae,smtpUsername:h.useDifferentSmtpCreds&&h.smtpUsername||void 0,smtpPassword:h.useDifferentSmtpCreds&&h.smtpPassword||void 0};if(l&&t){const _e={...Oe,password:o?h.password:void 0};A.mutate({path:{accountId:t.accountId},body:_e})}else{const _e={...Oe,password:h.password};se.mutate({body:_e})}}),ie=se.isPending||A.isPending,{signature:ae,setSignature:ye,isSaving:oe}=gr(t?.accountId),[Y,le]=D.useState(ae.plainText),{languages:C,setLanguages:V,isSaving:I}=hi(t?.accountId),q=r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Writing languages"}),r.jsx(Vr,{value:C,onChange:V,busy:I})]});D.useEffect(()=>{le(ae.plainText)},[ae.plainText]),D.useEffect(()=>{if(!e||!a)return;const h=k.current;if(!h)return;const O=window.setTimeout(()=>{h.scrollIntoView({behavior:"smooth",block:"start"})},250);return()=>window.clearTimeout(O)},[e,a]);const Z=D.useCallback(()=>{Y!==ae.plainText&&ye(Y,Y)},[Y,ae.plainText,ye]),j=h=>{const{tls:O,startTls:ce}=Be(h);f.setValue("imapTls",O),f.setValue("imapStartTls",ce);const re=f.getValues("imapPort");(re===993||re===143)&&f.setValue("imapPort",h==="tls"?993:143)},J=h=>{const{tls:O,startTls:ce}=Be(h);f.setValue("smtpTls",O),f.setValue("smtpStartTls",ce);const re=f.getValues("smtpPort");if(re===465||re===587||re===25){const Ae=h==="tls"?465:h==="starttls"?587:25;f.setValue("smtpPort",Ae)}},W=()=>{const h=f.getValues("imapHost");f.setValue("smtpHost",xr(h)),f.setValue("smtpTls",!1),f.setValue("smtpStartTls",!0),f.setValue("smtpPort",587)},fe=h=>{N(h),L(!1);const O=Ot(h);if(!O)return;const ce=Be(O.imap.security);f.setValue("imapHost",O.imap.host),f.setValue("imapPort",O.imap.port),f.setValue("imapTls",ce.tls),f.setValue("imapStartTls",ce.startTls);const re=Be(O.smtp.security);f.setValue("smtpHost",O.smtp.host),f.setValue("smtpPort",O.smtp.port),f.setValue("smtpTls",re.tls),f.setValue("smtpStartTls",re.startTls);const me=f.getValues("email").trim(),Ae=f.getValues("username")?.trim();me&&!Ae&&f.setValue("username",me)},Ee=F?.passwordHelp.text,Ne=Rt(S.data?.imapError,Ee),ke=Rt(S.data?.smtpError,Ee);return(t?gi(t):!1)&&l?r.jsx(Mt,{isOpen:e,onClose:s,title:"Edit Account",footer:r.jsx(te,{type:"button",variant:"secondary",onClick:s,children:"Close"}),children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Microsoft 365 Account"}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"rounded-md border border-line bg-surface-sunken px-3 py-2.5 text-sm text-fg-muted",children:[r.jsx("span",{className:"block text-2xs font-medium uppercase tracking-wider text-fg-subtle mb-1",children:"Email"}),r.jsx("span",{className:"text-fg",children:t?.email})]}),r.jsxs("div",{className:"rounded-md border border-line bg-surface-sunken px-3 py-2.5 text-sm text-fg-muted",children:[r.jsx("span",{className:"block text-2xs font-medium uppercase tracking-wider text-fg-subtle mb-1",children:"Authentication"}),r.jsx("span",{className:"text-fg",children:"Microsoft OAuth (XOAUTH2)"})]}),r.jsx("p",{className:"text-xs text-fg-muted",children:"Server settings are managed automatically for Microsoft 365 accounts. To update credentials, use the Reconnect button."})]})]}),l&&r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Signature"}),r.jsx("div",{className:"space-y-3",children:r.jsxs("div",{children:[r.jsx("label",{htmlFor:"email-sig-view",className:"text-sm font-medium mb-1.5 block",children:"Email Signature"}),r.jsx("textarea",{id:"email-sig-view",value:Y,onChange:h=>le(h.target.value),onBlur:Z,rows:5,className:"w-full px-3 py-2 border border-line rounded-md bg-surface-sunken text-sm text-fg placeholder:text-fg-subtle focus-within:border-line-strong focus-within:ring-2 focus-within:ring-ring/30 transition-colors resize-y outline-none",placeholder:"Enter your email signature..."}),r.jsx("p",{className:"text-xs text-fg-muted mt-1",children:oe?"Saving signature...":"This signature will be appended to new emails."})]})})]}),l&&q]})}):r.jsx(Mt,{isOpen:e,onClose:s,title:l?"Edit Account":"Add Account",footer:r.jsxs(r.Fragment,{children:[r.jsx(te,{type:"button",variant:"secondary",onClick:s,children:"Cancel"}),r.jsx(te,{type:"submit",form:"account-form",variant:"primary",disabled:ie,children:ie?"Saving...":"Save Account"})]}),children:r.jsxs("form",{id:"account-form",onSubmit:E,className:"space-y-6",children:[r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Account Information"}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-provider",className:"text-sm font-medium mb-1.5 block",children:"Provider"}),r.jsxs(Ys,{id:"account-provider",value:x,onChange:h=>fe(h.target.value),children:[r.jsx("option",{value:"",children:"Custom / other"}),mr.map(h=>r.jsx("option",{value:h.id,children:h.label},h.id))]}),r.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Pick your email provider to fill in server settings automatically, or choose Custom to enter them by hand."})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-email",className:"text-sm font-medium mb-1.5 block",children:"Email Address"}),r.jsx(ve,{id:"account-email",...f.register("email"),placeholder:"alice@example.com"}),f.formState.errors.email&&r.jsx("p",{className:"text-sm text-danger mt-1",children:f.formState.errors.email.message})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-displayName",className:"text-sm font-medium mb-1.5 block",children:"Display name (optional)"}),r.jsx(ve,{id:"account-displayName",...f.register("displayName"),placeholder:"Alice"}),r.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"What to call this account in Remit. Leave blank to use a name derived from the address."})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-username",className:"text-sm font-medium mb-1.5 block",children:"Username"}),r.jsx(ve,{id:"account-username",...f.register("username"),placeholder:"Same as email if empty"})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-password",className:"text-sm font-medium mb-1.5 block",children:"Password"}),r.jsx(_t,{id:"account-password",...f.register("password",{onChange:()=>u(!0)}),onFocus:()=>{l&&!o&&(f.setValue("password",""),u(!0))},placeholder:l?"Leave empty to keep current":""}),f.formState.errors.password&&r.jsx("p",{className:"text-sm text-danger mt-1",children:f.formState.errors.password.message}),F&&r.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[F.passwordHelp.text," ",r.jsx("a",{href:F.passwordHelp.url,target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline",children:"Get an app password"})]})]})]})]}),r.jsxs("section",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider",children:"Incoming Mail (IMAP)"}),F&&r.jsx("button",{type:"button",onClick:()=>L(h=>!h),className:"text-xs text-fg-muted hover:text-fg transition-colors",children:T?"Use preset settings":"Advanced"})]}),R&&r.jsxs("p",{className:"text-xs text-fg-muted mb-3",children:["Server settings are pre-filled for ",F?.label," and locked. Choose Advanced to edit them by hand."]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"imap-host",className:"text-sm font-medium mb-1.5 block",children:"Server"}),r.jsx(ve,{id:"imap-host",...f.register("imapHost"),readOnly:R,placeholder:"imap.example.com"}),f.formState.errors.imapHost&&r.jsx("p",{className:"text-sm text-danger mt-1",children:f.formState.errors.imapHost.message})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"imap-port",className:"text-sm font-medium mb-1.5 block",children:"Port"}),r.jsx(ve,{id:"imap-port",...f.register("imapPort"),readOnly:R,type:"number"})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-sm font-medium mb-1.5 block",children:"Security"}),r.jsxs("div",{className:"space-y-1.5 mt-2",children:[r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:R,checked:f.watch("imapTls"),onChange:()=>j("tls")}),"TLS (Port 993)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:R,checked:!f.watch("imapTls")&&f.watch("imapStartTls"),onChange:()=>j("starttls")}),"STARTTLS (Port 143)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:R,checked:!f.watch("imapTls")&&!f.watch("imapStartTls"),onChange:()=>j("none")}),"None (Unencrypted)"]})]})]})]}),r.jsx(te,{type:"button",variant:"secondary",onClick:_,disabled:S.isPending,className:"w-full",icon:S.isPending?r.jsx(nt,{className:"size-4 animate-spin"}):void 0,children:S.isPending?"Testing...":"Test IMAP Connection"}),S.data&&r.jsxs("div",{className:De("p-2 rounded-md text-sm",S.data.imapSuccess?"bg-positive/10 text-positive":"bg-danger-soft text-danger"),children:[S.data.imapSuccess?r.jsx(Pt,{className:"inline size-4 mr-1"}):r.jsx(Fe,{className:"inline size-4 mr-1"}),S.data.imapSuccess?"IMAP Connected":Ne]})]})]}),r.jsxs("section",{ref:k,"data-testid":"smtp-section",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider",children:"Outgoing Mail (SMTP)"}),!R&&r.jsx("button",{type:"button",onClick:W,disabled:!f.watch("imapHost"),className:"text-xs text-fg-muted hover:text-fg transition-colors disabled:opacity-50",children:"Pre-fill from IMAP"})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"smtp-host",className:"text-sm font-medium mb-1.5 block",children:"Server"}),r.jsx(ve,{id:"smtp-host",...f.register("smtpHost"),readOnly:R,placeholder:"smtp.example.com"})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"smtp-port",className:"text-sm font-medium mb-1.5 block",children:"Port"}),r.jsx(ve,{id:"smtp-port",...f.register("smtpPort"),readOnly:R,type:"number"})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-sm font-medium mb-1.5 block",children:"Security"}),r.jsxs("div",{className:"space-y-1.5 mt-2",children:[r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:R,checked:f.watch("smtpTls")===!0,onChange:()=>J("tls")}),"TLS (Port 465)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:R,checked:!f.watch("smtpTls")&&f.watch("smtpStartTls")===!0,onChange:()=>J("starttls")}),"STARTTLS (Port 587)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:R,checked:!f.watch("smtpTls")&&!f.watch("smtpStartTls"),onChange:()=>J("none")}),"None (Unencrypted)"]})]})]})]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"checkbox",...f.register("useDifferentSmtpCreds")}),"Use different credentials for SMTP"]}),f.watch("useDifferentSmtpCreds")&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"smtp-username",className:"text-sm font-medium mb-1.5 block",children:"SMTP Username"}),r.jsx(ve,{id:"smtp-username",...f.register("smtpUsername")})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"smtp-password",className:"text-sm font-medium mb-1.5 block",children:"SMTP Password"}),r.jsx(_t,{id:"smtp-password",...f.register("smtpPassword")})]})]}),r.jsx(te,{type:"button",variant:"secondary",onClick:P,disabled:S.isPending||!f.watch("smtpHost"),className:"w-full",icon:S.isPending?r.jsx(nt,{className:"size-4 animate-spin"}):void 0,children:S.isPending?"Testing...":"Test SMTP Connection"}),S.data?.smtpSuccess!==void 0&&r.jsxs("div",{className:De("p-2 rounded-md text-sm",S.data.smtpSuccess?"bg-positive/10 text-positive":"bg-danger-soft text-danger"),children:[S.data.smtpSuccess?r.jsx(Pt,{className:"inline size-4 mr-1"}):r.jsx(Fe,{className:"inline size-4 mr-1"}),S.data.smtpSuccess?"SMTP Connected":ke]})]})]}),l&&r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Signature"}),r.jsx("div",{className:"space-y-3",children:r.jsxs("div",{children:[r.jsx("label",{htmlFor:"email-sig-edit",className:"text-sm font-medium mb-1.5 block",children:"Email Signature"}),r.jsx("textarea",{id:"email-sig-edit",value:Y,onChange:h=>le(h.target.value),onBlur:Z,rows:5,className:"w-full px-3 py-2 border border-line rounded-md bg-surface-sunken text-sm text-fg placeholder:text-fg-subtle focus-within:border-line-strong focus-within:ring-2 focus-within:ring-ring/30 transition-colors resize-y outline-none",placeholder:"Enter your email signature..."}),r.jsx("p",{className:"text-xs text-fg-muted mt-1",children:oe?"Saving signature...":"This signature will be appended to new emails."})]})})]}),l&&q]})})},Si="https://graph.microsoft.com/",ji={[ot.Mail]:["https://outlook.office.com/IMAP.AccessAsUser.All","https://outlook.office.com/SMTP.Send"],[ot.Calendar]:[`${Si}Calendars.Read`]},wi=e=>{const s=new Set(e.map(t=>t.toLowerCase()));return Object.values(ot).filter(t=>ji[t].every(a=>s.has(a.toLowerCase())))},pt=e=>`Couldn't turn ${e.service.toLowerCase()} ${e.intent}`,Ni=e=>Js(Xs({title:`Bug: ${pt(e)}`,errorMessage:`${pt(e)} — ${e.message}`}));function Ai({providerName:e,offered:s,enabled:t,consented:a,disabled:n,refusal:l,onRequestChange:o}){return s.length<2?null:r.jsxs("section",{className:"space-y-2 rounded-sm border border-line bg-surface px-row-inset py-3",children:[r.jsx(Pr,{providerName:e,offered:s,enabled:t,consented:a,disabled:n,onRequestChange:o}),l&&r.jsxs(lt,{tone:"danger",variant:"soft",children:[r.jsx("p",{className:"font-medium",children:pt(l)}),r.jsx("p",{className:"mt-0.5 break-words text-fg-muted",children:l.message}),r.jsx("a",{href:Ni(l),target:"_blank",rel:"noopener noreferrer",className:"mt-1 inline-block font-medium text-accent hover:underline",children:"Report an issue"})]})]})}const Cs=["Mail","Calendar"],es="Microsoft",ts=e=>e.authType==="oauthMicrosoft",ss=(e,s)=>Cs.filter(t=>t===s||e.includes(t));function Ti({account:e,onRemoveAccount:s}){const t=Ye(),[a,n]=D.useState(null),[l,o]=D.useState(null),[u,x]=D.useState(null),N=ge({...gt(),meta:Vt,onSuccess:()=>t.invalidateQueries({queryKey:je()})}),T=ge({...ls(),meta:Vt}),L=ds(_=>{const P=u;x(null),!(_!=="stalled"||P===null)&&o({service:P,intent:"on",message:us})}),F=N.isPending&&N.variables?.body.syncedServices?N.variables.body.syncedServices:e.syncedServices,R=ts(e)?Cs:["Mail"],k=ts(e)?wi(e.grantedScopes):R,f=(_,P,E)=>{o(null),N.mutate({path:{accountId:e.accountId},body:{syncedServices:_}},{onError:ie=>o({service:P,intent:E,message:It(ie)})})},S=_=>{o(null),T.mutate({body:{email:e.email,services:ss(F,_)}},{onSuccess:P=>{x(_),L(),window.location.assign(P.authorizationUrl)},onError:P=>o({service:_,intent:"on",message:It(P)})})},se=(_,P)=>{if(P==="off"){n({kind:F.length===1?"last":"disable",service:_});return}if(!k.includes(_)){n({kind:"enable",service:_});return}f(ss(F,_),_,"on")},A=()=>{const _=a;if(n(null),_!==null){if(_.kind==="last"){s();return}if(_.kind==="enable"){S(_.service);return}f(F.filter(P=>P!==_.service),_.service,"off")}};return r.jsxs(r.Fragment,{children:[r.jsx(Ai,{providerName:es,offered:R,enabled:F,consented:k,disabled:N.isPending||T.isPending||u!==null,refusal:l,onRequestChange:se}),r.jsx(Er,{change:a,providerName:es,onConfirm:A,onCancel:()=>n(null)})]})}function rs({open:e,onClose:s,accountEmail:t,signOut:a}){const[n,l]=D.useState(""),[o,u]=D.useState(!1),[x,N]=D.useState(!1),T=ge({...tr(),onSuccess:()=>{N(!0),setTimeout(()=>a(),2e3)}}),L=ge(sr()),F=()=>{T.isPending||(l(""),u(!1),N(!1),T.reset(),L.reset(),s())},R=()=>{if(n.trim().toLowerCase()!==t.toLowerCase()){u(!0);return}u(!1),T.mutate({body:{confirmEmail:n.trim()}})};return r.jsxs(cs,{open:e,onClose:F,title:"Delete your Remit account",children:[r.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[r.jsx(ht,{className:"size-4 shrink-0 text-danger"}),r.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:"Delete your Remit account"}),r.jsx(te,{variant:"ghost",size:"sm",icon:r.jsx(Fe,{className:"size-3.5"}),onClick:F,"aria-label":"Cancel"})]}),x?r.jsxs("div",{className:"px-5 py-6 text-sm text-fg-muted",children:[r.jsx("p",{className:"font-medium text-fg",children:"Account deletion scheduled."}),r.jsx("p",{className:"mt-1",children:"Your data will be erased shortly. Signing you out…"})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"space-y-4 px-5 py-4 text-sm text-fg-muted",children:[r.jsx("p",{children:"This permanently erases everything Remit holds for you:"}),r.jsxs("ul",{className:"space-y-1.5 text-xs",children:[r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"text-danger",children:"•"}),"All connected accounts disconnected and access tokens revoked."]}),r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"text-danger",children:"•"}),"Synced mail cache and search index."]}),r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"text-danger",children:"•"}),"AI history and insights."]}),r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"text-danger",children:"•"}),"Preferences and rules."]})]}),r.jsxs("div",{className:"rounded-sm border border-line bg-surface-sunken px-3 py-2 text-xs",children:[r.jsx("strong",{className:"text-fg",children:"Your mail at Gmail / IMAP is not deleted."})," ","This only removes Remit's copy and its access — the mail stays in your provider mailboxes."]}),r.jsxs("div",{className:"text-xs",children:[r.jsxs("button",{type:"button",onClick:()=>L.mutate({}),"aria-busy":L.isPending,className:"inline-flex items-center gap-1.5 font-medium text-accent hover:underline",children:[r.jsx(Sr,{className:"size-3.5"}),L.isPending?"Requesting export…":"Export my data first"]}),L.isSuccess&&r.jsx("p",{className:"mt-1.5 text-fg-muted",role:"status",children:"Export requested. We'll prepare a ZIP of your mail — find it under your data exports when it's ready."}),L.isError&&r.jsx("p",{className:"mt-1.5 text-danger",role:"alert",children:"Couldn't start the export. Please try again."})]}),r.jsxs("div",{children:[r.jsxs("label",{htmlFor:"confirm-remit-email",className:"mb-1 block text-xs font-medium text-fg",children:["Type"," ",r.jsx("span",{className:"font-mono text-fg-muted",children:t})," ","to confirm"]}),r.jsx(ve,{id:"confirm-remit-email",type:"email",placeholder:t,value:n,onChange:k=>{l(k.target.value),o&&u(!1),T.isError&&T.reset()},autoComplete:"off"}),o&&r.jsx("p",{className:"mt-1.5 text-xs text-danger",role:"alert",children:"That doesn't match your account email. Type it exactly to confirm."}),T.isError&&r.jsx("p",{className:"mt-1.5 text-xs text-danger",role:"alert",children:T.error instanceof Error?T.error.message:"Something went wrong. Please try again."})]})]}),r.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[r.jsx(te,{variant:"secondary",size:"sm",onClick:F,children:"Cancel"}),r.jsx(te,{variant:"danger",size:"sm",onClick:R,"aria-busy":T.isPending,children:T.isPending?"Deleting…":"Delete everything"})]})]})]})}function Ei(e){const{Account:s}=er();return r.jsx(s,{fallback:r.jsx(rs,{...e,accountEmail:"",signOut:()=>{}}),children:({email:t,signOut:a})=>r.jsx(rs,{...e,accountEmail:t??"",signOut:a})})}function ki(){const[e,s]=D.useState(!1);return r.jsxs("section",{className:"mt-8 border-t border-line pt-6",children:[r.jsx(Dr,{title:"Delete your Remit account",description:"Disconnects every account and erases Remit's copy of your mail, insights and preferences. Your mail at the providers is untouched.",action:r.jsx(te,{variant:"danger",size:"sm",onClick:()=>s(!0),children:"Delete your Remit account"})}),r.jsx(Ei,{open:e,onClose:()=>s(!1)})]})}function _i(e){const s=e.toLowerCase();return s==="access_denied"?"You cancelled the sign-in.":s==="scope_not_granted"?"Microsoft did not grant access to every service you picked. Sign in again and accept each permission Microsoft asks for.":s==="consent_required"||s.includes("admin_consent")||s.includes("interaction_required")?"Your organisation's admin needs to approve Remit. Ask your IT admin to grant the required permissions.":s.includes("imap_disabled")||s.includes("imap disabled")?"IMAP is disabled for this account. Ask your admin to enable IMAP access in the Microsoft 365 admin centre.":`Sign-in failed: ${e}. Please try again.`}function Pi(e){const s=e.split("@")[0]??"";return s?s.split(/[._-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" "):e}function Ci(e){const s=e.displayName?.trim();return s||Pi(e.email)}function Vi(e){if(!e.lastSyncAt)return"never synced";const s=cr(e.lastSyncAt);return s?`synced ${s}`:"never synced"}function is(e){return e.muted?.value?"muted":e.lastError?"error":e.connectionState==="authenticated"?"healthy":"error"}function as(e){return e.connectionState==="reauth_required"}function Di(e){return e.connectionState==="credentials_missing"}const Fi=()=>r.jsx("div",{className:"space-y-3",role:"status","aria-busy":"true","aria-label":"Loading accounts",children:["skeleton-0","skeleton-1"].map(e=>r.jsx("div",{className:"rounded-sm border border-line bg-surface animate-pulse p-4",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"size-10 rounded-full bg-surface-sunken"}),r.jsxs("div",{className:"flex-1 space-y-2",children:[r.jsx("div",{className:"h-4 bg-surface-sunken rounded w-1/3"}),r.jsx("div",{className:"h-3 bg-surface-sunken rounded w-2/3"})]})]})},e))});function sa(){const e=Dt.useSearch(),s=rr({from:Dt.fullPath}),[t,a]=D.useState(!0),[n,l]=D.useState(!1),[o,u]=D.useState(!1),[x,N]=D.useState(null),[T,L]=D.useState(!1),[F,R]=D.useState(null),[k,f]=D.useState(null),[S,se]=D.useState(null),[A,_]=D.useState(null),P=Ye(),{data:E,isPending:ie,isError:ae,error:ye,refetch:oe}=ns(os());D.useEffect(()=>{e.editAccountId&&(N(e.editAccountId),L(!!e.focusSmtp),s({search:{editAccountId:void 0,focusSmtp:void 0,connected:e.connected,oauthError:e.oauthError},replace:!0}))},[e.editAccountId,e.focusSmtp,s,e.connected,e.oauthError]),D.useEffect(()=>{e.connected&&(f("Account connected successfully."),N(e.connected),P.invalidateQueries({queryKey:je()}),s({search:{connected:void 0,oauthError:void 0,editAccountId:void 0,focusSmtp:void 0},replace:!0}))},[e.connected,s,P]),D.useEffect(()=>{e.oauthError&&(se(_i(e.oauthError)),_(null),s({search:{oauthError:void 0,connected:void 0,editAccountId:void 0,focusSmtp:void 0},replace:!0}))},[e.oauthError,s]),hr(A!==null,()=>{P.invalidateQueries({queryKey:je()})}),D.useEffect(()=>{if(!A||!E)return;const j=E.accounts.find(J=>J.accountId===A);(!j||!as(j))&&_(null)},[E,A]);const Y=ds(j=>{_(null),j==="stalled"&&se(us)}),le=ge({...ls(),onSuccess:j=>{Y(),window.location.assign(j.authorizationUrl)},onError:j=>{se(j instanceof Error?j.message:"Failed to start reconnect"),_(null)}}),C=ge({...ir(),onSuccess:()=>{P.invalidateQueries({queryKey:je()}),R(null)}}),V=E?.accounts.find(j=>j.accountId===F),I=E?.accounts.find(j=>j.accountId===x),q=()=>{l(!1),u(!1),N(null),L(!1)},Z=j=>{const J=or[j];J&&s({to:J})};return r.jsxs(ur,{items:ar,activeId:"accounts",title:"Accounts",description:"Every account keeps syncing — muted ones just stay out of unified views.",help:jr,helpOpen:t,onToggleHelp:()=>a(j=>!j),onSelect:Z,onBackToMail:()=>{s({to:"/mail"})},children:[k&&r.jsx(lt,{tone:"success",variant:"soft","data-testid":"oauth-success-banner",onDismiss:()=>f(null),children:k}),S&&r.jsx(lt,{tone:"danger",variant:"soft","data-testid":"oauth-error-banner",onDismiss:()=>se(null),children:S}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(nr,{tone:"neutral",children:ie||ae?"accounts":`${E.accounts.length} ${E.accounts.length===1?"account":"accounts"}`}),r.jsx(te,{variant:"primary",size:"sm",icon:r.jsx(Ft,{className:"size-3.5"}),onClick:()=>u(!0),children:"Add account"})]}),ie?r.jsx(Fi,{}):ae?r.jsx(vr,{title:"Couldn't load accounts",error:ye,onRetry:()=>{oe()}}):E.accounts.length===0?r.jsxs("div",{className:"py-12 text-sm text-fg-muted","data-testid":"accounts-empty",children:[r.jsx("p",{className:"mb-3",children:"No accounts configured."}),r.jsx(te,{variant:"primary",size:"sm",icon:r.jsx(Ft,{className:"size-3.5"}),onClick:()=>u(!0),children:"Add your first account"})]}):r.jsx("div",{className:"space-y-3",children:E.accounts.map(j=>{const J=as(j),W=Di(j),fe=j.authType==="oauthMicrosoft",Ee=A===j.accountId,Ne=J&&fe?{label:"Reconnect",variant:"secondary",busy:Ee,busyLabel:"Redirecting…",onClick:()=>{_(j.accountId),le.mutate({body:{email:j.email,services:j.syncedServices}})}}:W?{label:"Enter password",variant:"secondary",onClick:()=>N(j.accountId)}:is(j)==="error"?{label:"Reconnect",variant:"secondary",onClick:()=>N(j.accountId)}:{label:"Manage",variant:"ghost",onClick:()=>N(j.accountId)},ke=r.jsx(dr,{actions:[Ne],destructive:{label:"Delete account",iconOnly:!0,icon:r.jsx(lr,{className:"size-3.5"}),onClick:()=>R(j.accountId)}});return r.jsxs("div",{className:"space-y-2",children:[r.jsx(fr,{label:Ci(j),email:j.email,connector:fe?"Microsoft 365":"IMAP",syncLabel:Vi(j),state:is(j),errorDetail:J?j.lastError??"Re-authentication required":W?"Imported from a config file, which carries no password. Enter one to start syncing.":j.lastError,trailing:ke}),r.jsx(Ti,{account:j,onRemoveAccount:()=>R(j.accountId)})]},j.accountId)})}),o&&r.jsx("div",{className:"fixed inset-0 z-40 overflow-auto bg-canvas",children:r.jsx(pr,{skipWelcome:!0,onComplete:()=>{u(!1),P.invalidateQueries({queryKey:je()})},onCancel:()=>u(!1)})}),r.jsx(vi,{isOpen:n||!!x,account:I,focusSmtp:T,onClose:q}),r.jsxs(cs,{open:!!F,onClose:()=>R(null),title:"Delete account",children:[r.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[r.jsx(ht,{className:"size-4 shrink-0 text-danger"}),r.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:"Delete account"}),r.jsx(te,{variant:"ghost",size:"sm",icon:r.jsx(Fe,{className:"size-3.5"}),onClick:()=>R(null),"aria-label":"Cancel"})]}),r.jsxs("div",{className:"space-y-3 px-5 py-4 text-sm text-fg-muted",children:[r.jsx("p",{className:"text-center text-lg font-medium text-fg",children:"Are you sure?"}),V&&r.jsx("p",{className:"text-center",children:V.email}),r.jsxs("ul",{className:"list-inside list-disc space-y-1",children:[r.jsx("li",{children:"Remove the account from your settings"}),r.jsx("li",{children:"Stop syncing mail for this account"}),r.jsx("li",{children:"Delete all associated data (within 24 hours)"})]})]}),r.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[r.jsx(te,{variant:"secondary",size:"sm",onClick:()=>R(null),children:"Cancel"}),r.jsx(te,{variant:"danger",size:"sm","aria-busy":C.isPending,icon:C.isPending?r.jsx(nt,{className:"size-3.5 animate-spin"}):void 0,onClick:()=>{C.isPending||F&&C.mutate({path:{accountId:F}})},children:C.isPending?"Deleting…":"Delete account"})]})]}),r.jsx(ki,{})]})}export{sa as component,_i as mapOauthError};
@@ -1 +0,0 @@
1
- import{e as h,j as e,X as j,aB as b,t as o,r as f}from"./index-Dq0vpG8a.js";import{A as v}from"./avatar-C6rJXQ1w.js";import{C as y}from"./clock-DpXdz1Nu.js";const N=h("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]),g={accepted:"Coming",tentative:"Maybe",declined:"Not coming",noReply:"No reply"},k={accepted:"text-positive",tentative:"text-warning",declined:"text-danger",noReply:"text-fg-subtle"},w={accepted:b,tentative:y,declined:j,noReply:N};function R({rsvp:s,className:t}){const r=w[s];return e.jsxs("span",{className:o("inline-flex items-center gap-1 text-2xs font-medium",k[s],t),children:[e.jsx(r,{className:"size-3"}),g[s]]})}function I({attendee:s,active:t=!1,onActivate:r,contextId:l,touch:m=!1,className:a}){const c=e.jsxs(e.Fragment,{children:[e.jsx(v,{name:s.name,email:s.email,size:"sm"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-sm text-fg",children:s.name}),s.role==="organizer"&&e.jsx("span",{className:"block text-2xs text-fg-subtle",children:"Organiser"})]}),e.jsx(R,{rsvp:s.rsvp})]});return r?e.jsx("button",{type:"button","aria-expanded":t,"aria-controls":t&&l!==void 0?l:void 0,onClick:()=>r(t?"":s.email),onKeyDown:i=>{i.key==="Escape"&&r("")},onBlur:i=>{t&&i.relatedTarget!==null&&(i.currentTarget.parentElement?.contains(i.relatedTarget)||r(""))},className:o("flex w-full items-center gap-2.5 rounded-md px-1.5 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",m?"min-h-11":"min-h-9",t?"bg-accent-2-soft":"hover:bg-surface-sunken",a),children:c}):e.jsx("div",{className:o("flex min-h-9 items-center gap-2.5",a),children:c})}function E({attendees:s,activeEmail:t="",onActivate:r,renderContext:l,touch:m=!1,className:a}){const c=f.useId();if(s.length===0)return null;const i=["accepted","tentative","declined","noReply"].map(n=>({state:n,count:s.filter(p=>p.rsvp===n).length})).filter(n=>n.count>0).map(n=>`${n.count} ${g[n.state].toLowerCase()}`).join(" · ");return e.jsxs("div",{className:o("flex flex-col",a),children:[e.jsx("p",{className:"pb-1 text-2xs uppercase tracking-wider text-fg-subtle",children:`${s.length} guests · ${i}`}),s.map((n,p)=>{const u=n.email===t,x=`${c}-guest-${p}`,d=e.jsx(I,{attendee:n,active:u,onActivate:r,contextId:l?x:void 0,touch:m});return r?e.jsxs("div",{children:[d,u&&l&&e.jsx("div",{id:x,className:"py-1",children:l(n)})]},n.email):e.jsx(f.Fragment,{children:d},n.email)})]})}export{E as A,N as M,R};
@@ -1 +0,0 @@
1
- import{j as r,O as i}from"./index-Dq0vpG8a.js";import{a as m}from"./MailShell-CYnLaaio.js";import{B as o}from"./BriefPane-BYct_UtO.js";import{a as p}from"./search-token-index-DdA7BFEr.js";import{u as e}from"./search-mirror-Bl-Z8zrH.js";import"./FullCompose-D3rfYvQR.js";import"./ErrorState-DRZtXgYN.js";import"./index-B8TTkszh.js";import"./useMessageBodyContent-SaudvJ_f.js";import"./useSignature-DsTucVsn.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-BlQHSXzq.js";import"./sections-gAf5RAcd.js";import"./confirm-dialog-DOM1mbt4.js";import"./useSearchTokenContext-CwqK76g8.js";import"./kbd-DWOMKFVK.js";import"./search-scope-B5-OK3Cq.js";import"./MailListHeader-_GRJzk6x.js";import"./roving-focus-Cs6iWufr.js";import"./popover-menu-Dci8SQJT.js";import"./mail-CxDqKP0C.js";import"./avatar-C6rJXQ1w.js";import"./EmptyState-B3SKuNr0.js";import"./undo-2-EliG40fh.js";import"./download-D2-NUPGx.js";import"./calendar-suggestion-DwQe-DW4.js";import"./calendar-format-BCjw6Wdf.js";import"./useQueries-BLlTxIMR.js";import"./useCalendars-Dtgsk_ok.js";import"./calendar-report-CWyeC8kX.js";import"./attendee-row-lGaZ_txP.js";import"./clock-DpXdz1Nu.js";import"./calendar-clash-strip-I8NCaBf8.js";import"./bell-off-Cj-19EBu.js";import"./copy-CrcnK6wu.js";import"./shield-check-BbOZU-ha.js";import"./useFilters-BM8eI3xc.js";import"./useLayoutTier-DV_uk1qc.js";import"./menu-2BgPrZbs.js";import"./useRefreshControl-Dwjheutp.js";import"./circle-check-big-BfiUJz9g.js";import"./refresh-cw-BLxv_R1t.js";import"./useSemanticSearch-BmktGXpn.js";import"./useLabels-DCAn9Wiq.js";import"./search-query-Cr_ZXBCp.js";import"./wizard-selection-DxUM65kM.js";function $(){const t=p();return e({to:"/mail/brief"}),r.jsx(o,{thread:t,children:r.jsx(m,{phone:r.jsx(o.Phone,{}),list:r.jsx(o.List,{}),reading:r.jsx(i,{}),intelligence:r.jsx(o.Intelligence,{}),hasThread:!!t})})}export{$ as component};