@remit/web-client-dist 0.0.674 → 0.0.676

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 (221) hide show
  1. package/assets/AppFrame-DSPG81Mk.js +1 -0
  2. package/assets/BriefPane-Cfl-uWfm.js +1 -0
  3. package/assets/CalendarEventEditor-COnJXvRd.js +1 -0
  4. package/assets/CalendarEventPopup-CqHE2vrc.js +1 -0
  5. package/assets/CalendarLoadFailed-CxL15r1A.js +1 -0
  6. package/assets/CalendarQuickCreate-DxgU3bNP.js +1 -0
  7. package/assets/CalendarSession-BKwK9s2o.js +1 -0
  8. package/assets/EmptyState-BUOSmldo.js +1 -0
  9. package/assets/{ErrorState-Bi4vrhhQ.js → ErrorState-KjDYblD5.js} +1 -1
  10. package/assets/FlaggedPane-Dw-wR4tp.js +1 -0
  11. package/assets/{FullCompose-D6Xef8Ur.js → FullCompose-Djp_h4BT.js} +1 -1
  12. package/assets/{LabelApplyTrigger-BnPNejnI.js → LabelApplyTrigger-oS5sxATE.js} +1 -1
  13. package/assets/MailShell-LIuV2C3h.js +1 -0
  14. package/assets/MailViewChrome-yffBJjbO.js +1 -0
  15. package/assets/MailboxPane-DUCZVAx6.js +1 -0
  16. package/assets/{MessageBody-AvWIklnv.js → MessageBody-C89PSL_p.js} +3 -3
  17. package/assets/MessageToolbar-UJadqHyA.js +1 -0
  18. package/assets/NavMenuButton-B-goW-G5.js +1 -0
  19. package/assets/OnboardingWizard-Cvqq2aP_.js +1 -0
  20. package/assets/OutboxPane-ce4uTAzW.js +1 -0
  21. package/assets/_calendarObjectId-lcrg9Fhc.js +1 -0
  22. package/assets/_mailboxId-BzKo-TnK.js +1 -0
  23. package/assets/_messageId-C7U0TsBv.js +1 -0
  24. package/assets/_messageId-CGB3gt7C.js +1 -0
  25. package/assets/_messageId-D2Qjacn6.js +1 -0
  26. package/assets/_outboxMessageId-FUbJ3RF8.js +1 -0
  27. package/assets/_recurrenceId-DpQOCGAd.js +1 -0
  28. package/assets/_threadId-BmZ2vl5z.js +1 -0
  29. package/assets/_threadId-Bs84eLjr.js +1 -0
  30. package/assets/_threadId-DySupNzi.js +1 -0
  31. package/assets/_view._date-DYujYKtx.js +1 -0
  32. package/assets/account-service-status-oYDwuPLn.js +1 -0
  33. package/assets/accounts-DhSbRlEm.js +1 -0
  34. package/assets/advanced-B50NfkTy.js +1 -0
  35. package/assets/appearance-CYNOlHLz.js +1 -0
  36. package/assets/{avatar-qD7fcqFf.js → avatar-uWJajuSb.js} +1 -1
  37. package/assets/{bottom-sheet-B_7iO-ln.js → bottom-sheet-Bc0vwv2J.js} +1 -1
  38. package/assets/brief-DPWE6nMF.js +1 -0
  39. package/assets/{brief-RK0pe25_.js → brief-bdXCpAmW.js} +1 -1
  40. package/assets/calendar-7SdvLY_h.js +1 -0
  41. package/assets/calendar-event-popup-DsPmxVye.js +1 -0
  42. package/assets/calendar-event-sidebar-soFGsDRR.js +1 -0
  43. package/assets/calendar-failure-note-BtZLcaiZ.js +1 -0
  44. package/assets/calendar-format-BwCpz-JZ.js +1 -0
  45. package/assets/calendar-guests-BR4hC59z.js +1 -0
  46. package/assets/calendar-suggestion-8jcpefeR.js +1 -0
  47. package/assets/calendar-tMekVEGW.js +1 -0
  48. package/assets/calendars-bLB0g-E-.js +1 -0
  49. package/assets/{card-C9cgHaft.js → card-CPL-TrL1.js} +1 -1
  50. package/assets/checkbox-CGG1nAhQ.js +1 -0
  51. package/assets/{circle-check-big-ZwVj0mbk.js → circle-check-big-BsCwNdJZ.js} +1 -1
  52. package/assets/{circle-check-CQPt1U9q.js → circle-check-i3jeyeTf.js} +1 -1
  53. package/assets/{circle-help-BtMu5xYr.js → circle-help-CVWHf1ow.js} +1 -1
  54. package/assets/{clock-B-eYdLBT.js → clock-NnulNCOv.js} +1 -1
  55. package/assets/compose._-_outboxMessageId_-Be8c22eR.js +1 -0
  56. package/assets/compose._-_outboxMessageId_-BuomqJqQ.js +1 -0
  57. package/assets/compose._-_outboxMessageId_-Bv9hyiuT.js +1 -0
  58. package/assets/compose._-_outboxMessageId_-CvUr9awX.js +1 -0
  59. package/assets/{config-import-DhLbROIb.js → config-import-DmOMXQ5W.js} +1 -1
  60. package/assets/{confirm-dialog-AppxcVfC.js → confirm-dialog-q8tbS_22.js} +1 -1
  61. package/assets/{copy-BCzZpML3.js → copy-LUCWJAE6.js} +1 -1
  62. package/assets/{credential-steps-DCjuFFo-.js → credential-steps-DVglyUgf.js} +1 -1
  63. package/assets/{download-C6M2pRs1.js → download-SQdHw0Vd.js} +1 -1
  64. package/assets/draft-Y5XWTm_J.js +1 -0
  65. package/assets/edit-DMorYaTV.js +1 -0
  66. package/assets/edit-Dr5FEVcd.js +1 -0
  67. package/assets/{external-link-tmwz3hf0.js → external-link-BDqA_mVy.js} +1 -1
  68. package/assets/{file-json-BgVPDajK.js → file-json-DQGozYSr.js} +1 -1
  69. package/assets/filters-DFLdTFEB.js +1 -0
  70. package/assets/flagged-CCXBAY09.js +1 -0
  71. package/assets/{flagged-IHM3vv4x.js → flagged-CyMautVT.js} +1 -1
  72. package/assets/folders-DtchKvEA.js +1 -0
  73. package/assets/{help-copy-BN4-5aIP.js → help-copy-B2iT8EG_.js} +1 -1
  74. package/assets/{import-BT72aUBc.js → import-DqNA5XIM.js} +1 -1
  75. package/assets/index-BaEsIFAV.js +1 -0
  76. package/assets/index-Biz6TlId.js +1 -0
  77. package/assets/index-BkMAx0hv.js +1 -0
  78. package/assets/index-CL_fwLHN.js +349 -0
  79. package/assets/index-CZYy2P_j.js +1 -0
  80. package/assets/index-CqsCZrgd.js +1 -0
  81. package/assets/{index-C2Hz4y-Q.css → index-Cr6oUxXl.css} +1 -1
  82. package/assets/index-CvDZvwnj.js +1 -0
  83. package/assets/index-D2Qjacn6.js +1 -0
  84. package/assets/{index-Cb2UJhnj.js → index-DZb7rV9A.js} +7 -7
  85. package/assets/index-DoTwMLuw.js +1 -0
  86. package/assets/index-DrtbTKeC.js +1 -0
  87. package/assets/index-DtqBFgK5.js +1 -0
  88. package/assets/index-wVOTkeaF.js +1 -0
  89. package/assets/{kbd-DxdiA2Fl.js → kbd-CDJCJUnp.js} +1 -1
  90. package/assets/labels-rv-5Xb0f.js +1 -0
  91. package/assets/mail-SW3rbFnq.js +1 -0
  92. package/assets/{menu-ouYQ8aI9.js → menu-CcLh9Whg.js} +1 -1
  93. package/assets/new-Zmtsd7wU.js +1 -0
  94. package/assets/onboarding-BbZUe6dp.js +1 -0
  95. package/assets/{onboarding-completion-h9meGJrm.js → onboarding-completion-DoF3_MyG.js} +1 -1
  96. package/assets/outbox-ZJk7VidB.js +1 -0
  97. package/assets/{pencil-D0Kwpd2W.js → pencil-LSmMSKiW.js} +1 -1
  98. package/assets/{popover-menu-CTiORP1p.js → popover-menu-fjlAfNO1.js} +1 -1
  99. package/assets/{refresh-cw-aweb7slK.js → refresh-cw-5OKnYRBy.js} +1 -1
  100. package/assets/reply-DvdgFS16.js +1 -0
  101. package/assets/{rich-text-BlpPNJ69.js → rich-text-BBwYPM6F.js} +14 -14
  102. package/assets/{rich-text-spellcheck-worker-provider-BVC2WqOs.js → rich-text-spellcheck-worker-provider-Bk8cqxyg.js} +1 -1
  103. package/assets/{rotate-ccw-cFCdZR4R.js → rotate-ccw-CENCKp2Z.js} +1 -1
  104. package/assets/{roving-focus-iNw1K_A-.js → roving-focus-FWOr5tBU.js} +1 -1
  105. package/assets/{row-actions-CsY_49bo.js → row-actions-DA6zLLAB.js} +1 -1
  106. package/assets/search-mirror-Dri4pWEq.js +1 -0
  107. package/assets/search-token-index-B1HU1d2-.js +1 -0
  108. package/assets/{sections-By63r1y_.js → sections-Rf3k05-_.js} +1 -1
  109. package/assets/senders-ikMjTlbx.js +1 -0
  110. package/assets/settings-Bk7jziSO.js +1 -0
  111. package/assets/settings-screen-DBP3ABLE.js +1 -0
  112. package/assets/{shield-check-C6K5BNfE.js → shield-check-CdR23I2B.js} +1 -1
  113. package/assets/sparkles-Bcn4ZRhZ.js +1 -0
  114. package/assets/{suggested-vips-DnRYIdD0.js → suggested-vips-D-8cU8GT.js} +1 -1
  115. package/assets/suggestion._suggestionId-D6z0CuYD.js +1 -0
  116. package/assets/task._calendarTaskId-BYRN0yW3.js +1 -0
  117. package/assets/{undo-2-BV0sKXdu.js → undo-2-Bdx8L5xj.js} +1 -1
  118. package/assets/useCalendarData-DXhaM_NM.js +2 -0
  119. package/assets/useCalendarScheduling-BpjmrzdY.js +1 -0
  120. package/assets/useCalendarSuggestions-D3Jza1d7.js +1 -0
  121. package/assets/useCalendarTasks-D_NZ0GM6.js +1 -0
  122. package/assets/{useDebouncedValue--u19KX6h.js → useDebouncedValue-BTZsNKEh.js} +1 -1
  123. package/assets/{useFilters-Cmf0Cndn.js → useFilters-CIuC8WLg.js} +1 -1
  124. package/assets/{useLabels-CN56tbCw.js → useLabels-BZFMPVjT.js} +1 -1
  125. package/assets/useLayoutTier-DrLg7_rq.js +1 -0
  126. package/assets/{useMediaQuery-DB2OdJvp.js → useMediaQuery-DiQ0fGER.js} +1 -1
  127. package/assets/useMessageBodyContent-D-LJBFh4.js +1 -0
  128. package/assets/useQueries-hChzM5ru.js +1 -0
  129. package/assets/useRefreshControl-B6YIG0w2.js +1 -0
  130. package/assets/useResultFolderIndex-6TeGdWgp.js +1 -0
  131. package/assets/{useSignature-37xUEwqG.js → useSignature-BkzkUbjz.js} +1 -1
  132. package/assets/warnings-BdQvV6Kc.js +5 -0
  133. package/index.html +2 -2
  134. package/package.json +1 -1
  135. package/assets/BriefPane-zWXuK_Pj.js +0 -1
  136. package/assets/CalendarComposePane-Bz_-lcWc.js +0 -1
  137. package/assets/CalendarComposeSeed-DrUkfGTc.js +0 -1
  138. package/assets/CalendarShell-BATnya1t.js +0 -1
  139. package/assets/EmptyState-DjcO1Fvj.js +0 -1
  140. package/assets/FlaggedPane-Doc9iLZn.js +0 -1
  141. package/assets/MailNav-C8EZGG4u.js +0 -1
  142. package/assets/MailShell-Dc5V-rLi.js +0 -1
  143. package/assets/MailViewChrome-CJkUbWPO.js +0 -1
  144. package/assets/MailboxPane-Bzn-4kym.js +0 -1
  145. package/assets/MessageToolbar-CvC2dLSg.js +0 -1
  146. package/assets/NavMenuButton-DSpTQKmQ.js +0 -1
  147. package/assets/OnboardingWizard-DzR2uArY.js +0 -1
  148. package/assets/OpenCalendarEvent-DuKGo-jF.js +0 -2
  149. package/assets/OutboxPane-Bf8T7dxW.js +0 -1
  150. package/assets/SignInAgain-CCZnH9Mt.js +0 -1
  151. package/assets/_calendarObjectId-BGZWGcp9.js +0 -1
  152. package/assets/_mailboxId-GGJA-jVS.js +0 -1
  153. package/assets/_messageId-C5LRx072.js +0 -1
  154. package/assets/_messageId-CCba-TdT.js +0 -1
  155. package/assets/_messageId-TW2iI02X.js +0 -1
  156. package/assets/_outboxMessageId-BwVgR2h4.js +0 -1
  157. package/assets/_recurrenceId-pJxBSSXe.js +0 -1
  158. package/assets/_threadId-B_SsLFXa.js +0 -1
  159. package/assets/_threadId-CL2HHRtw.js +0 -1
  160. package/assets/_threadId-DLvgcvlr.js +0 -1
  161. package/assets/_view._date-wBuxk5kG.js +0 -1
  162. package/assets/accounts-Dc5147aO.js +0 -1
  163. package/assets/advanced-C3zdMHK5.js +0 -1
  164. package/assets/appearance-Df1fh0eu.js +0 -1
  165. package/assets/attendee-row-r-oUgLyi.js +0 -1
  166. package/assets/bell-off-DNCJLc9z.js +0 -1
  167. package/assets/brief-ClYJePmh.js +0 -1
  168. package/assets/bug-D6xXLRSh.js +0 -1
  169. package/assets/calendar-Dg7vWWgr.js +0 -1
  170. package/assets/calendar-clash-strip-C9X1djbQ.js +0 -1
  171. package/assets/calendar-report-BRGottVJ.js +0 -1
  172. package/assets/calendar-subscription-B-aAc2Gy.js +0 -1
  173. package/assets/calendar-suggestion-qEC_UasM.js +0 -1
  174. package/assets/calendars-DBDN0ptk.js +0 -1
  175. package/assets/checkbox-CiQllE1Y.js +0 -1
  176. package/assets/chevron-left-Bt4eJ35K.js +0 -1
  177. package/assets/compose._-_outboxMessageId_-BMq7tjfo.js +0 -1
  178. package/assets/compose._-_outboxMessageId_-CbnOP01x.js +0 -1
  179. package/assets/compose._-_outboxMessageId_-CoBJDS24.js +0 -1
  180. package/assets/compose._-_outboxMessageId_-Cr5hBZLH.js +0 -1
  181. package/assets/filters-CwblOGNb.js +0 -1
  182. package/assets/flagged-DvOlELtX.js +0 -1
  183. package/assets/folders-lF0pnG5O.js +0 -1
  184. package/assets/index-BDcVKyir.js +0 -1
  185. package/assets/index-C5LRx072.js +0 -1
  186. package/assets/index-CCba-TdT.js +0 -1
  187. package/assets/index-CVKDJurZ.js +0 -1
  188. package/assets/index-CXrVnh7V.js +0 -1
  189. package/assets/index-CXzCthHG.js +0 -349
  190. package/assets/index-DRT_I4p4.js +0 -1
  191. package/assets/index-DSNc3rHB.js +0 -1
  192. package/assets/index-T04Kj7bC.js +0 -1
  193. package/assets/index-TW2iI02X.js +0 -1
  194. package/assets/index-u72ANhps.js +0 -1
  195. package/assets/labels-CTSVGM1M.js +0 -1
  196. package/assets/mail-BLRLmM-I.js +0 -1
  197. package/assets/mail-CHopLOA-.js +0 -1
  198. package/assets/map-pin-DbNUeHlR.js +0 -1
  199. package/assets/minus-COyPQ5q9.js +0 -1
  200. package/assets/new-DRfIDZVL.js +0 -1
  201. package/assets/onboarding-U6yiJPWH.js +0 -1
  202. package/assets/outbox-DFxDZsE8.js +0 -1
  203. package/assets/reply-B9-kr45N.js +0 -1
  204. package/assets/search-mirror-Bg0i4bJE.js +0 -1
  205. package/assets/search-query-Dq2--dgF.js +0 -1
  206. package/assets/search-token-index-JnwciDu0.js +0 -1
  207. package/assets/senders-BollE7le.js +0 -1
  208. package/assets/settings-aPDqsj-M.js +0 -1
  209. package/assets/settings-screen-DxN6mICP.js +0 -1
  210. package/assets/suggestion._suggestionId-m9OzQCaR.js +0 -1
  211. package/assets/useCalendarData-BQ_jLMR7.js +0 -1
  212. package/assets/useCalendarEvents-lDPF_B6_.js +0 -1
  213. package/assets/useCalendarFreeBusy-BFq23gzr.js +0 -1
  214. package/assets/useCalendarWrites-CIJUCBzo.js +0 -1
  215. package/assets/useCalendars-BgSJfw8G.js +0 -1
  216. package/assets/useLayoutTier-CUyuK30O.js +0 -1
  217. package/assets/useMessageBodyContent-Gq_pdN4f.js +0 -1
  218. package/assets/useQueries-gpmd3w5y.js +0 -1
  219. package/assets/useRefreshControl-DdZILsE1.js +0 -1
  220. package/assets/useResultFolderIndex-EOtkNq1e.js +0 -1
  221. package/assets/warnings-BYDfjgnx.js +0 -5
@@ -0,0 +1 @@
1
+ import{j as t,o as u,r as c,C as m,aa as p,u as d,K as h}from"./index-CL_fwLHN.js";import{u as x}from"./roving-focus-FWOr5tBU.js";import{u as b}from"./useLayoutTier-DrLg7_rq.js";import{g as v,u as g}from"./reply-DvdgFS16.js";const j={mail:p,calendar:m},N="[data-app-item]",y=e=>e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey;function f({item:e,active:a,onNavigate:s,className:r,iconClassName:n}){const i=j[e.id];return t.jsxs("a",{href:e.href,"data-app-item":"","aria-current":a?"page":void 0,onClick:l=>{y(l)&&(l.preventDefault(),s(e.id))},className:u("flex flex-col items-center justify-center gap-0.5 rounded-lg outline-none transition-colors","focus-visible:ring-2 focus-visible:ring-ring",a?"bg-accent-soft text-accent":"text-fg-muted hover:bg-surface-sunken hover:text-fg",r),children:[t.jsx(i,{className:n,"aria-hidden":"true"}),t.jsx("span",{className:"text-2xs font-medium",children:e.label})]})}function C({items:e,active:a,onNavigate:s,className:r}){const n=c.useRef(null);return x({containerRef:n,itemSelector:N}),t.jsx("nav",{ref:n,"aria-label":"Apps",className:u("flex w-16 shrink-0 flex-col items-center gap-1 border-r border-line bg-surface py-2",r),children:e.map(i=>t.jsx(f,{item:i,active:i.id===a,onNavigate:s,className:"size-14",iconClassName:"size-5"},i.id))})}function A({items:e,active:a,onNavigate:s,className:r}){return t.jsx("nav",{"aria-label":"Apps",className:u("flex shrink-0 items-stretch justify-around border-t border-line bg-surface px-2 pt-1 pb-[max(0.25rem,env(safe-area-inset-bottom))]",r),children:e.map(n=>t.jsx(f,{item:n,active:n.id===a,onNavigate:s,className:"min-h-12 min-w-16 flex-1",iconClassName:"size-5"},n.id))})}const w=e=>e.startsWith("/calendar")?"calendar":"mail";function R(){const e=d(),a=h(),s=v(),r=g({select:o=>o.pathname}),n=w(r),i=c.useMemo(()=>[{id:"mail",label:"Mail",href:a.buildLocation({to:"/mail",hash:s}).href},{id:"calendar",label:"Calendar",href:a.buildLocation({to:"/calendar",hash:s}).href}],[a,s]),l=c.useCallback(o=>{e({to:o==="calendar"?"/calendar":"/mail",hash:s})},[e,s]);return{items:i,active:n,switchTo:l}}function T({children:e,hideTabBar:a=!1}){const s=b()==="phone",{items:r,active:n,switchTo:i}=R();return s?t.jsxs("div",{className:"flex h-full w-full flex-col",style:a?void 0:{"--app-tab-bar":"3.5rem"},children:[t.jsx("div",{className:"min-h-0 flex-1",children:e}),!a&&t.jsx(A,{items:r,active:n,onNavigate:i})]}):t.jsxs("div",{className:"flex h-full w-full",children:[t.jsx(C,{items:r,active:n,onNavigate:i}),t.jsx("div",{className:"min-w-0 flex-1",children:e})]})}export{T as A};
@@ -0,0 +1 @@
1
+ import{j as r,L as Mt,fy as Ke,fz as ne,eI as re,r as a,a as Ue,P as ie,dw as jt,Y as kt,ed as Et,fA as Ot,fB as At,w as $e,eX as Ft,fC as Nt}from"./index-CL_fwLHN.js";import{f as Ve,d as Bt,e as Ye,u as Lt,p as qt,R as Pt}from"./MessageBody-C89PSL_p.js";import{a5 as _t,y as Dt,A as Qt,al as zt,am as Wt,an as Ht,ao as Pe,ap as Gt,aq as Kt,ar as Ut,as as $t,at as Vt,ag as Yt,M as Jt,au as Zt,ah as Xt,av as es,aw as ts,f as ss,p as os,aj as ns,m as rs,S as as,G as is,K as _e,J as cs,H as ls,e as ds,V as us,W as xe,X as fs,Z as Je,_ as Ze,$ as ms,a0 as hs,a1 as gs}from"./MessageToolbar-UJadqHyA.js";import{h as ps,n as xs,r as Is}from"./reply-DvdgFS16.js";import{a as ys}from"./useMessageBodyContent-D-LJBFh4.js";import{m as vs,e as bs,f as Ss}from"./search-token-index-B1HU1d2-.js";import{u as Xe}from"./sections-Rf3k05-_.js";import{S as Ts}from"./sparkles-Bcn4ZRhZ.js";import{u as Cs,a as ws,R as Rs,b as Ms,c as js}from"./useRefreshControl-B6YIG0w2.js";import{u as ae}from"./useQueries-hChzM5ru.js";import{t as et,s as ks,r as Es,L as Os}from"./LabelApplyTrigger-oS5sxATE.js";import{a as As}from"./useLabels-BZFMPVjT.js";import{u as Fs}from"./useLayoutTier-DrLg7_rq.js";import{u as Ns}from"./useMediaQuery-DiQ0fGER.js";import{d as Bs,w as Ls}from"./wizard-selection-zWa1qc6-.js";import{R as qs}from"./refresh-cw-5OKnYRBy.js";function Ps({sync:e}){return e?r.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 py-12 text-center px-4",role:"status","aria-live":"polite",children:[r.jsx(Mt,{className:"size-8 animate-spin text-fg-subtle","aria-hidden":"true"}),r.jsx("p",{className:"text-sm font-medium text-fg",children:"Still syncing your mail"}),r.jsx("p",{className:"text-xs text-fg-subtle",children:_s(e)})]}):r.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 py-12 text-center px-4",children:[r.jsx(Ts,{className:"size-8 text-fg-subtle","aria-hidden":"true"}),r.jsx("p",{className:"text-sm font-medium text-fg",children:"You're caught up"}),r.jsx("p",{className:"text-xs text-fg-subtle",children:"Nothing needs attention."})]})}function _s({synced:e,total:t}){return t>0?`${e.toLocaleString()} of ${t.toLocaleString()} messages downloaded. This list fills in as they arrive.`:"Downloading your messages. This list fills in as they arrive."}const tt=[{id:"unread",name:"is",value:"unread"},{id:"attachment",name:"has",value:"attachment"}],st="category",Ds={unclassified:"uncategorized"},H=e=>Bt(e).map(t=>t.raw),W=e=>e.join(" "),Ie=e=>{const t=Ye(e);if(t)return tt.find(s=>s.name===t.name&&s.value===t.value.toLowerCase())?.id},ye=e=>{const t=Ye(e);if(!t||t.name!==st)return;const s=t.value.toLowerCase(),n=Ds[s];if(n)return n;if(!(!Ke(s)||s==="all"))return s},ot=e=>tt.find(t=>t.id===e),nt=e=>ot(e)!==void 0,Qs=e=>{const t=new Set;for(const s of H(e)){const n=Ie(s);n&&t.add(n)}return t},zs=e=>{let t="all";for(const s of H(e)){const n=ye(s);n&&(t=n)}return t},Ws=(e,t)=>{const s=ot(t);if(!s)return;const n=H(e),i=n.filter(d=>Ie(d)!==t);return i.length<n.length?W(i):W([...n,Ve(s.name,s.value)])},Hs=(e,t)=>{const s=H(e).filter(n=>!ye(n));return W(t==="all"?s:[...s,Ve(st,t)])},Gs=e=>W(H(e).filter(t=>!Ie(t)&&!ye(t))),rt=e=>e.trim().length>0,De=e=>{if(!rt(e.query))return e.ownFilters;const t=new Set(Qs(e.query));for(const s of e.ownFilters)nt(s)||t.add(s);return t},Qe=e=>rt(e.query)?zs(e.query):e.ownCategory,ze=6e4,Ks=3e4,Us={kind:"unknown"},We=e=>(t,s)=>_t(s?.queryKey,e)?t:void 0,$s=(e,t,s)=>({...e,category:[t],limit:s,order:"desc"}),Vs=(e,t)=>({...e,category:[t],order:"desc",count:!0,results:!1}),He=(e,t)=>({category:[t],...e.unread!==void 0?{unread:e.unread}:{},...e.starred!==void 0?{starred:e.starred}:{},...e.attachments!==void 0?{attachments:e.attachments}:{},...e.accountId!==void 0?{accountId:e.accountId}:{},...e.muted!==void 0?{muted:e.muted}:{}});function Ys({categories:e,criteria:t,limit:s,counted:n}){const i=ae({queries:e.map(c=>{const h=$s(t,c,s),u=He(t,c);return{queryKey:re({query:h}),queryFn:async()=>{const{data:v}=await ne({query:h,throwOnError:!0});return v},placeholderData:We(u),staleTime:ze}})}),d=ae({queries:e.map(c=>{const h=Vs(t,c),u=He(t,c);return{queryKey:re({query:h}),queryFn:async()=>{const{data:v}=await ne({query:h,throwOnError:!0});return v},enabled:n,placeholderData:We(u),staleTime:ze}})}),m=a.useMemo(()=>e.map((c,h)=>{const u=i[h],v=d[h],p=u?.data?.items??[];return{category:c,rows:p,atCap:p.length>=s,total:n?et(v?.data?.count):Us,loading:u?.isPending??!0,failed:u?.isError??!1,retry:()=>{u?.refetch(),n&&v?.refetch()}}}),[e,i,d,n,s]),l=a.useCallback(()=>{for(const c of i)c.refetch();for(const c of d)c.refetch()},[i,d]);return{sections:m,isLoading:i.length>0&&i.every(c=>c.isPending),isError:i.length>0&&i.every(c=>c.isError),refetch:l}}function Js(e,t,s){const n={...e,limit:t,order:"desc"},{data:i,isLoading:d,isError:m,refetch:l}=Ue({queryKey:re({query:n}),queryFn:async()=>{const{data:h}=await ne({query:n,throwOnError:!0});return h},enabled:s,staleTime:Ks});return{rows:a.useMemo(()=>s?i?.items??[]:[],[i,s]),isLoading:s&&d,isError:s&&m,refetch:a.useCallback(()=>{l()},[l])}}const Zs=3e4,Xs={kind:"unknown"},eo=(e,t)=>({...e,mailboxId:t,order:"desc",count:!0,results:!1});function to({criteria:e,junkMailboxIds:t,enabled:s}){const n=ae({queries:t.map(i=>{const d=eo(e,i);return{queryKey:re({query:d}),queryFn:async()=>{const{data:m}=await ne({query:d,throwOnError:!0});return m},enabled:s,staleTime:Zs}})});return a.useMemo(()=>t.map((i,d)=>({mailboxId:i,count:s?et(n[d]?.data?.count):Xs,failed:s?n[d]?.isError??!1:!1})),[t,n,s])}const so=(e,t)=>e.createdAt!==t.createdAt?e.createdAt-t.createdAt:e.accountId.localeCompare(t.accountId),oo=e=>[...e].sort(so),no=["from","subject","category","unread","starred","attachments"],at=["contacts","today"],ro=e=>new Set(at.filter(t=>e.has(t))),ao=(e,t,s,n)=>{const i=Dt({category:e,attributes:t}),{params:d,residual:m}=Qt(s,i,no),l={...d,...i},c={muted:!1};return l.from!==void 0&&(c.from=l.from),l.subject!==void 0&&(c.subject=l.subject),l.unread!==void 0&&(c.unread=l.unread),l.starred!==void 0&&(c.starred=l.starred),l.attachments!==void 0&&(c.attachments=l.attachments),n!==void 0&&(c.accountId=n),{criteria:c,residual:m}},io=({residual:e,attributes:t})=>e.length===0&&!at.some(s=>t.has(s)),se=e=>e.count.kind==="exact"&&e.count.value>0?3:e.pageRows>0?2:e.count.kind==="unknown"?1:0,oe=e=>e.count.kind==="exact"?e.count.value:0,co=(e,t)=>se(e)!==se(t)?se(e)>se(t):oe(e)!==oe(t)?oe(e)>oe(t):e.pageRows>t.pageRows;function lo(e,{pageRowsByMailbox:t}){const s=e.map(u=>({...u,pageRows:t.get(u.mailboxId)??0}));for(const[u,v]of t)v<=0||s.some(p=>p.mailboxId===u)||s.push({mailboxId:u,count:{kind:"unknown"},failed:!1,pageRows:v});const n=s[0];if(!n)return;let i=0,d=!0,m=n;for(const u of s)u.count.kind==="unknown"?d=!1:i+=u.count.value,co(u,m)&&(m=u);const l=s.some(u=>u.pageRows>0),c=s.some(u=>u.failed);if(i===0&&!l&&(d||!c))return;const h=d&&i===0&&l;return{mailboxId:m.mailboxId,count:d&&!h?{kind:"exact",value:i}:{kind:"unknown"}}}const uo=50,fo=200,mo=[],Ge=()=>r.jsx("div",{className:"animate-pulse",children:Array.from({length:3}).map((e,t)=>r.jsxs("div",{className:"flex items-start gap-3 py-2 pl-5 pr-4 border-b border-line",children:[r.jsx("div",{className:"size-7 rounded-full bg-surface-sunken shrink-0 mt-0.5"}),r.jsxs("div",{className:"flex-1 space-y-1.5",children:[r.jsxs("div",{className:"flex justify-between gap-2",children:[r.jsx("div",{className:"h-3.5 bg-surface-sunken rounded w-28"}),r.jsx("div",{className:"h-3 bg-surface-sunken rounded w-12"})]}),r.jsx("div",{className:"h-3.5 bg-surface-sunken rounded w-48"}),r.jsx("div",{className:"h-3 bg-surface-sunken rounded w-full"})]})]},t))}),ho=({accountEmail:e})=>{const t=Xe();return r.jsxs("div",{className:"flex items-center gap-2 px-row-inset py-2 border-b border-line bg-danger-soft/40 text-xs text-danger",children:[r.jsx($e,{className:"size-3.5 shrink-0"}),r.jsxs("span",{className:"flex-1 truncate",children:[e," can't connect"]}),r.jsx("button",{type:"button",onClick:()=>t("accounts"),className:"shrink-0 underline text-danger hover:opacity-80",children:"Reconnect"})]})},go=(e,t)=>{if(t.size===0)return{};const s=e.filter(d=>t.has(d.id)),n=Es(s.map(d=>d.accountId));if(n.restriction)return n;const i=new Set;for(const d of s)d.mailboxId&&i.add(d.mailboxId);return i.size>1?{accountId:n.accountId,restriction:"spansFolders",moveDisabledHint:`Move only works within one folder — this selection spans ${i.size} folders`}:{accountId:n.accountId,mailboxId:i.size===1?[...i][0]:void 0}};function po({header:e,rows:t,wizard:s,children:n}){const{selectedIds:i,selectedCount:d,exitSelection:m,orderedIds:l,allSelected:c,toggleAllLoaded:h}=ts(),u=a.useMemo(()=>go(t,i),[t,i]),{junkMailboxId:v}=ss(u.accountId),{labels:p}=As(u.accountId),b=a.useMemo(()=>Array.from(i),[i]),L=a.useMemo(()=>Ls(t,i),[t,i]),x=os(v,u.mailboxId),S=a.useMemo(()=>l.length>0?{checked:c,indeterminate:d>0&&!c,onChange:h}:void 0,[l.length,c,d,h]),F=u.moveDisabledHint?{tone:"warning",text:u.moveDisabledHint}:void 0,T=R=>r.jsx(as,{title:R.title,navSlot:R.navSlot,titleMeta:R.titleMeta,searchSlot:R.searchSlot,searchField:R.searchField,idleSlot:R.makeFilterSlot,count:d,onCancel:m,onDelete:()=>s.start("delete"),onMove:()=>s.start("move"),onOrganize:()=>s.start("organize"),onJunk:x?()=>s.start("junk"):void 0,onMarkRead:()=>s.start("markRead"),overflowSlot:u.accountId&&u.mailboxId&&d>0&&p.length>0?r.jsx(Os,{accountId:u.accountId,mailboxId:u.mailboxId,messageIds:b}):void 0,selectAll:S,notice:F});return r.jsx(ns,{...e,selectionBar:T,paneOverlay:r.jsx(rs,{verb:s.verb,accountId:u.accountId,mailboxId:u.mailboxId,selection:L,selectionRestriction:u.restriction,onFinished:m}),children:n})}function xo({accounts:e,selectedMessageId:t,onOpenThread:s,commandsRef:n,onTriageContextChange:i,onDeleteMessages:d}){const{searchQuery:m,searchInput:l,resultFolderIndex:c,onSearchChange:h}=ie(),u=Lt(),v=Ns(),p=Fs(),b=jt(),L=vs(),x=a.useMemo(()=>oo(e.filter(o=>!o.muted?.value)),[e]),[S,F]=a.useState("all"),[T,R]=a.useState("all"),[N,q]=a.useState(new Set),[le,M]=a.useState(!1),P=a.useCallback(o=>{q(f=>{const g=new Set(f);return g.has(o)?g.delete(o):g.add(o),g})},[]),G=a.useCallback(()=>q(new Set),[]),E=l.trim().length>0,{freeText:w,tokens:_}=qt(m.trim().toLowerCase(),u),y=w.length>0,D=a.useMemo(()=>De({query:l,ownFilters:N}),[l,N]),Q=a.useMemo(()=>Qe({query:l,ownCategory:T}),[l,T]),A=a.useMemo(()=>De({query:m,ownFilters:N}),[m,N]),C=a.useMemo(()=>Qe({query:m,ownCategory:T}),[m,T]),I=a.useCallback(o=>{if(!E||!nt(o)){P(o);return}const f=Ws(l,o);f!==void 0&&h(f)},[E,l,h,P]),j=a.useCallback(o=>{if(!E){R(o);return}h(Hs(l,o))},[E,l,h]),de=a.useMemo(()=>C==="all"&&!y?o=>{Ke(o)&&j(o)}:void 0,[C,y,j]),ue=a.useCallback(()=>{R("all"),F("all"),G(),E&&h(Gs(l))},[E,l,h,G]),K=ae({queries:x.map(o=>({...kt({path:{accountId:o.accountId}}),staleTime:1/0,meta:{softError:!0}}))}),U=a.useMemo(()=>{const o=new Map;for(let f=0;f<x.length;f++){const g=x[f].accountId,te=(K[f]?.data?.items??[]).reduce((O,Rt)=>O+(Rt.unseenCount??0),0);o.set(g,te)}return o},[x,K]),lt=a.useMemo(()=>x.filter((o,f)=>{const g=K[f];return g?.isError?!Et(g.error):!1}),[x,K]),{criteria:fe,residual:$}=a.useMemo(()=>ao(C,A,_,S==="all"?void 0:S),[C,A,_,S]),dt=a.useMemo(()=>C==="all"?[...zt]:[C],[C]),ve=a.useMemo(()=>({...fe,query:w,...C==="all"?{}:{category:[C]}}),[fe,w,C]),be=io({residual:$,attributes:A}),{sections:V,isLoading:ut,isError:ft,refetch:Se}=Ys({categories:y?mo:dt,criteria:fe,limit:C==="all"?es:uo,counted:be}),{rows:Te,isLoading:mt,isError:ht,refetch:Ce}=Js(ve,fo,y),me=y?mt:ut,we=y?ht:ft,Re=a.useCallback(()=>{if(y){Ce();return}Se()},[y,Ce,Se]),Me=a.useMemo(()=>ro(A),[A]),Y=a.useCallback(o=>Bs(o).map(Wt).filter(f=>Ot(f,Me)&&Ht(f,$)),[Me,$]),J=a.useMemo(()=>V.map(o=>({category:o.category,total:o.total,atCap:o.atCap,loading:o.loading,failed:o.failed,rows:Y(o.rows)})),[V,Y]),Z=a.useMemo(()=>Y(Te),[Te,Y]),gt=a.useCallback(o=>{V.find(f=>f.category===o)?.retry()},[V]),k=a.useMemo(()=>y?Z:J.flatMap(o=>o.rows),[y,Z,J]),pt=a.useMemo(()=>At(c),[c]),je=to({criteria:ve,junkMailboxIds:pt,enabled:be&&ks({hasSearchQuery:y,freeText:w,residualTokenCount:$.length})}),{spamIds:he,briefSpamOffer:X}=a.useMemo(()=>{const o={spamIds:void 0,briefSpamOffer:void 0};if(!w)return o;const f=k.map(O=>Pe(O,c)),{spam:g}=Gt(f),B=new Map;for(const O of g)O.mailboxId&&B.set(O.mailboxId,(B.get(O.mailboxId)??0)+1);const te=lo(je,{pageRowsByMailbox:B});return g.length===0&&!te?o:{spamIds:g.length>0?new Set(g.map(O=>O.id)):void 0,briefSpamOffer:te}},[k,w,c,je]),ke=a.useMemo(()=>{const o=f=>he===void 0?f:f.filter(g=>!he.has(g.id));return y?[{id:"matches",threads:o(Z)}]:Kt(J.map(f=>({...f,rows:o(f.rows)})))},[y,Z,J,he]),Ee=a.useCallback((o,f)=>{const g=k.find(B=>B.id===o)?.threadId;g&&s?.({threadId:g,messageId:o},f)},[k,s]),xt=a.useCallback(o=>{const f=o.threadId??k.find(g=>g.id===o.id)?.threadId;f&&s?.({threadId:f,messageId:o.id})},[k,s]),ge=a.useMemo(()=>x.length<=1?[]:[{id:"all",label:"All",active:S==="all"},...x.map(o=>({id:o.accountId,label:o.email.split("@")[0]??o.email,count:U.get(o.accountId),active:S===o.accountId}))],[x,U,S]),z=a.useMemo(()=>e.filter(o=>o.muted?.value).length,[e]),It=a.useMemo(()=>Array.from(U.values()).reduce((o,f)=>o+f,0),[U]),pe=a.useMemo(()=>x.map(o=>o.accountId),[x]),{hasNewMail:Oe}=Cs(),{state:Ae,errorMessage:Fe,refresh:Ne}=ws(pe,{onSettled:()=>Re()}),yt=a.useMemo(()=>r.jsx(Rs,{state:Ae,onRefresh:Ne,label:"Refresh daily brief",errorMessage:Fe,hasUpdate:Oe(pe)}),[Ae,Ne,Fe,Oe,pe]),vt=a.useMemo(()=>k.map(o=>Pe(o,c)),[k,c]),bt=a.useMemo(()=>{const o=Ut(ge.map(f=>({id:f.id,label:f.label,count:f.count,active:f.active})));return{categories:o.categories,filters:o.filters,sources:o.sources,sourcesNote:z>0?`+${z} muted`:void 0,selectedCategory:Q,activeFilters:D,expanded:le,onExpandedChange:M,onSelectCategory:f=>j(f),onSelectSource:F,onToggleFilter:f=>I(f),onClear:ue}},[ge,z,Q,D,le,I,j,ue]),Be=ke.length===0&&S==="all"&&w.length===0&&_.length===0,St=a.useMemo(()=>x.map(o=>o.accountId),[x]),Tt=a.useMemo(()=>x.some(o=>Ms(o.syncPhase)),[x]),ee=js(St,Be||Tt),Le=r.jsxs("div",{className:"h-full overflow-y-auto",children:[r.jsx(Ge,{}),r.jsx(Ge,{})]}),qe=!me&&!we&&!Be,Ct=$t({tier:p,hasLiveInput:E,hasCommittedQuery:m.trim().length>0,bodyRendersCommittedResults:!0}),wt=qe?r.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[X&&r.jsx(Vt,{count:X.count,onScopeToSpam:()=>L(X.mailboxId,m)}),r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(Yt,{sections:ke,briefCategory:Q,Row:Jt,selectedThreadId:t,onSelectThread:Ee,onShowAllSection:de,onRetrySection:gt,flat:y,onSelectBriefCategory:j,sources:ge,sourcesNote:z>0?`+${z} muted`:void 0,onSelectSource:F,activeFilters:D,onToggleFilter:I,onClearFilters:ue})})]}):me?Le:we?r.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 py-12 text-sm text-fg-muted",children:[r.jsx($e,{className:"size-8 text-danger"}),r.jsx("p",{children:"Couldn't load your messages"}),r.jsxs("button",{type:"button",onClick:()=>Re(),className:"flex items-center gap-1 text-accent underline text-xs",children:[r.jsx(qs,{className:"size-3.5"}),"Try again"]})]}):ee.resolved?r.jsx(Ps,{sync:ee.syncing?{synced:ee.synced,total:ee.total}:void 0}):Le;return r.jsx(Ft,{hasSheet:qe&&!Ct,children:r.jsx(Zt,{selectedMessageId:t,rows:k,onOpen:Ee,onDeleteMessages:d,onSelectionVerb:b.start,commandsRef:n,onTriageContextChange:i,children:r.jsx(po,{wizard:b,header:{title:"Daily brief",unreadCount:It,footer:v?r.jsx(Xt,{}):void 0,searchFilter:bt,searchResults:vt,searchLoading:me,onSelectSearchResult:xt,spamOffer:X,searchResultsInBody:!0,refreshControl:yt},rows:k,children:r.jsxs("div",{className:"flex h-full flex-col",children:[lt.map(o=>r.jsx(ho,{accountEmail:o.email,accountId:o.accountId},o.accountId)),r.jsx("div",{className:"min-h-0 flex-1",children:wt})]})})})})}const it=a.createContext(null);function ce(){const e=a.useContext(it);if(!e)throw new Error("BriefPane.* must be used inside <BriefPane>");return e}function Io({thread:e,children:t}){const s=bs(),n=Ss(),i=Xe(),{searchInput:d}=ie(),m=e?.threadId,l=e?.messageId,{data:c}=Ue({...Nt(),staleTime:6e4}),h=a.useMemo(()=>c?.items??[],[c]),u=a.useMemo(()=>{if(m)return h.find(I=>I.messageId===l)??h.find(I=>I.threadId===m)},[h,m,l]),v=is(m,l),p=u??v,b=l??p?.messageId,L=a.useMemo(()=>{if(m)return{threadId:m,mailboxId:p?.mailboxId??"",subject:p?.subject,messageId:b,authenticity:p?.authenticity}},[m,p,b]),x=a.useCallback((I,j)=>{s(I,{replace:j?.replace,query:d})},[s,d]),S=a.useCallback(I=>{b&&I.includes(b)&&n()},[b,n]),F=_e({thread:p,isOpen:!0,onAfterOptimisticRemove:S}),T=cs(),{deleteMessages:R}=ls({mailboxId:p?.mailboxId??"",messages:h,onAfterOptimisticRemove:S}),{toggleReadFor:N}=ds({mailboxId:p?.mailboxId??"",messages:h}),q=T.focusedMessageId,M=a.useMemo(()=>h.find(I=>I.messageId===q),[h,q])??p,P=_e({thread:M,isOpen:M?.messageId===b}),G=ys(),E=ps(),w=xs(),_=a.useMemo(()=>Is(w,m,b),[w,m,b]),y=a.useMemo(()=>{if(M)return I=>w({threadId:M.threadId,messageId:M.messageId,mode:I})},[w,M]),{nextMessageId:D,previousMessageId:Q}=us({context:T,orderedIds:T.orderedIds,selectedMessageId:b,enabled:!G&&!E,hasOpenThread:m!==void 0,onClose:n,handlers:{reply:()=>y?.("reply"),replyAll:()=>y?.("reply-all"),forward:()=>y?.("forward"),delete:()=>{T.listCommandsRef.current?.requestVerb("delete")||P.deleteThread()},toggleStar:P.toggleStar,toggleRead:()=>{T.listCommandsRef.current?.requestVerb("markRead")||M&&N([M.messageId],!M.isRead)},goFlagged:()=>i("flagged"),goSettings:()=>i("settings")}}),A=a.useCallback(I=>{if(!I)return;const j=h.find(de=>de.messageId===I);return j?{threadId:j.threadId,messageId:I}:void 0},[h]),C={selectedMessageId:b,selectedThread:p,conversation:L,onOpenThread:x,onCloseThread:n,nextThread:A(D),previousThread:A(Q),actions:F,onReply:_,triage:T,onDeleteMessages:R,handleDeselectIfRemoved:S};return r.jsx(it.Provider,{value:C,children:t})}function ct(){const{selectedMessageId:e,onOpenThread:t,triage:s,onDeleteMessages:n}=ce(),{accounts:i}=ie();return r.jsx(xo,{accounts:i,selectedMessageId:e,onOpenThread:t,commandsRef:s.listCommandsRef,onTriageContextChange:s.onTriageContextChange,onDeleteMessages:n})}function yo(){const e=xe(),{conversation:t,selectedThread:s,actions:n,onReply:i,handleDeselectIfRemoved:d,onOpenThread:m}=ce(),l=!!t,c=hs(t?.threadId);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(gs,{hasThread:l,intelligenceOpen:c.isShowing,canToggleIntelligence:c.canToggle,onToggleIntelligence:c.toggle,onReply:i?()=>i("reply"):void 0,onReplyAll:i?()=>i("reply-all"):void 0,onForward:i?()=>i("forward"):void 0,onDelete:l?n.deleteThread:void 0,onToggleStar:l?n.toggleStar:void 0,isStarred:n.isStarred,moveContext:l&&n.accountId&&n.mailboxId?{accountId:n.accountId,currentMailboxId:n.mailboxId,onMove:n.moveThread}:void 0}),r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t?r.jsx(Je,{threadId:t.threadId,mailboxId:t.mailboxId,subject:t.subject,selectedMessageId:t.messageId,authenticity:t.authenticity,onOpenIntelligence:c.open,listOnScreen:!0}):r.jsx(Pt,{})})]}),r.jsx(Ze,{isOpen:c.drawerOpen,onClose:c.closeDrawer,thread:s,accountId:s?.accountId,onAfterOptimisticRemove:d,onReplyWithText:e,onOpenThread:m})]})}function vo(){const e=xe(),{selectedThread:t,handleDeselectIfRemoved:s,onOpenThread:n}=ce(),{onToggleIntelligence:i}=ie();return r.jsx(ms,{onClose:i,thread:t,accountId:t?.accountId,onAfterOptimisticRemove:s,onReplyWithText:e,onOpenThread:n})}function bo(){const e=xe(),{selectedThread:t,conversation:s,onOpenThread:n,onCloseThread:i,nextThread:d,previousThread:m,handleDeselectIfRemoved:l}=ce(),c=fs(s?.threadId??null);return s?r.jsxs(r.Fragment,{children:[r.jsx(Je,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onBack:i,onOpenIntelligence:c.toggle,onSwipeNext:d?()=>n(d):void 0,onSwipePrevious:m?()=>n(m):void 0,mobileIntelligenceOpen:c.isOpen}),r.jsx(Ze,{isOpen:c.isOpen,onClose:c.close,thread:t,accountId:t?.accountId,onAfterOptimisticRemove:l,onReplyWithText:e,onOpenThread:n})]}):r.jsx("div",{className:"h-full",children:r.jsx(ct,{})})}const Po=Object.assign(Io,{List:ct,Reading:yo,Intelligence:vo,Phone:bo});export{Po as B};
@@ -0,0 +1 @@
1
+ import{r as t,fM as Ze,ck as Fe,j as v,fb as we}from"./index-CL_fwLHN.js";import{C as xe}from"./confirm-dialog-q8tbS_22.js";import{a as Ne}from"./calendar-event-popup-DsPmxVye.js";import{C as le}from"./calendar-event-sidebar-soFGsDRR.js";import{s as Oe}from"./calendar-guests-BR4hC59z.js";import{c as Be,r as je,s as Ae,t as ze,R as Ge}from"./useCalendarData-DXhaM_NM.js";import{c as Qe,m as Le,d as Pe,t as qe,p as Ue}from"./draft-Y5XWTm_J.js";import{b as fe,d as me,e as oe,o as We,U as ge,c as pe,q as He,h as Ve}from"./useCalendarSuggestions-D3Jza1d7.js";import{u as ve,b as ye}from"./useCalendarScheduling-BpjmrzdY.js";import{f as $e}from"./calendar-format-BwCpz-JZ.js";import"./reply-DvdgFS16.js";import{a as Se,j as Je,b as ie,i as Me}from"./calendar-tMekVEGW.js";import{e as _e}from"./CalendarQuickCreate-DxgU3bNP.js";import{u as x}from"./CalendarSession-BKwK9s2o.js";const he="This calendar changed while you were writing. Close the form and try again.",be=Intl.supportedValuesOf("timeZone"),Ke=(e,n)=>e.date===n.date&&e.endDate===n.endDate&&e.startTime===n.startTime&&e.endTime===n.endTime&&e.allDay===n.allDay,$=e=>({date:e.date,endDate:e.endDate,startTime:e.allDay?"":e.startTime,endTime:e.allDay?"":e.endTime,allDay:e.allDay}),Ce=e=>e?"Opaque":"Transparent";function Ye(e,n){const{carriedFocus:l}=x(),f=t.useRef(!1);t.useEffect(()=>{if(!n||f.current)return;f.current=!0;const o=l.current;l.current="",((o===""?null:document.querySelector(`[data-event-sidebar] [aria-label="${CSS.escape(o)}"]`))??e.current)?.focus()},[l,e,n])}function Ee(e){const{requestClose:n}=x(),{closeToView:l}=ie(),[f,o]=t.useState(!1),y=t.useRef(!1);Me(e&&!f,()=>y.current?!1:(o(!0),!0));const b=()=>{if(e){o(!0);return}l()},R=t.useRef(b);return R.current=b,t.useEffect(()=>(n.current=()=>R.current(),()=>{n.current=null}),[n]),{close:b,confirm:v.jsx(xe,{isOpen:f,title:"Discard draft?",description:"Your event has unsaved changes. Are you sure you want to discard them?",confirmLabel:"Discard",cancelLabel:"Keep editing",destructive:!0,onConfirm:()=>{y.current=!0,o(!1),l()},onCancel:()=>o(!1)}),leave:()=>{y.current=!0,l()}}}function pt(){const{session:e,dispatch:n,focusSaved:l}=x(),{date:f}=Se(),o=Je(),{setNewEventBounds:y}=ie(),{calendars:b,defaultCalendarId:R,timeZoneByCalendarId:j}=fe(),C=b.filter(s=>!s.readOnly),{createEvent:A,isWriting:J}=me(),{senders:z,defaultSenderId:M}=ve(),[_,K]=t.useState(),[G,Y]=t.useState(""),X=ye(G),{trackSends:ee}=x(),Q=t.useRef(null),L=t.useRef(null),E=oe(),[g,T]=t.useState({notes:"",repeat:"",timeZone:E,busy:!0}),[P,N]=t.useState(""),[O,a]=t.useState(),[i]=t.useState(()=>e.mode==="sidebar"?e.draft:void 0),m=Ze(o?.start,o?.end,f,E);t.useEffect(()=>{e.mode!=="sidebar"&&n({type:"sidebar-range",range:m})},[e.mode,n,m]);const d=e.mode==="sidebar"?e.draft:void 0,r=d?.range;t.useEffect(()=>{if(!r)return;const s=Fe(r,E);s.start===o?.start&&s.end===o?.end||y(s)},[r,o,E,y]),Ye(Q,e.mode==="sidebar"),t.useEffect(()=>{O&&L.current?.focus()},[O]);const I=C.find(s=>s.id===R)?.id??C[0]?.id??"";t.useEffect(()=>{d?.calendarId!==""||I===""||n({type:"change",draft:{...d,calendarId:I}})},[d,I,n]);const k=d!==void 0&&(g.notes!==""||g.repeat!==""||!g.busy||d.title!==(i?.title??"")||d.location!==(i?.location??"")||d.guests.length!==(i?.guests.length??0)),{close:q,confirm:Z,leave:te}=Ee(k);if(!d)return null;const U=_??M??C.find(s=>s.id===d.calendarId)?.accountId??"",F={..._e(d),notes:g.notes,repeat:g.repeat},W=()=>{const s=g.timeZone,u=Qe(F,{clock:s,anchor:s!==E?s:We(j[d.calendarId]??ge)},U);if(!u.ok){N(u.problem);return}N(""),a(void 0),A({...u.input,transparency:Ce(g.busy)}).then(S=>{if(S.kind==="created"){n({type:"saved"}),ee(S.sends),l(S.calendarObjectId),te();return}const p=S.kind==="conflict"?he:`Couldn't save this event: ${S.message}`;a({text:p,reportHref:pe(p),onRetry:W})})};return v.jsxs(v.Fragment,{children:[v.jsx(le,{heading:"New event",draft:F,onChange:s=>{n({type:"change",draft:{range:$(s),title:s.title,location:s.location,calendarId:s.calendarId,guests:s.guests}}),T(u=>({...u,notes:s.notes,repeat:s.repeat}))},calendars:C,calendarEditable:!0,repeatEditable:!0,timeZone:g.timeZone,timeZones:be,onTimeZone:s=>T(u=>({...u,timeZone:s})),busy:g.busy,onBusy:s=>T(u=>({...u,busy:s})),guests:{suggestions:X,onQuery:Y,senders:z,sender:U,onSender:K,senderEditable:!0},onSave:W,onCancel:q,saving:J,problem:P,failure:O,failureRef:L,titleRef:Q}),Z]})}function vt({calendarObjectId:e,recurrenceId:n}){const{session:l,dispatch:f,focusSaved:o}=x(),{view:y,date:b,calendarIds:R}=Se(),{events:j,isLoading:C,freeIds:A}=Be({view:y,date:b,calendarIds:R}),{calendars:J,timeZoneByCalendarId:z}=fe(),{closeToView:M}=ie(),{updateEvent:_,isWriting:K}=me(),{senders:G,defaultSenderId:Y}=ve(),[X,ee]=t.useState(),[Q,L]=t.useState(""),E=ye(Q),{trackSends:g}=x(),T=t.useRef(null),P=t.useRef(null),N=t.useId(),O=Ve(e,n??""),a=j.find(c=>c.id===O),{resource:i}=He(e,a?.calendarId??""),[m,d]=t.useState(),[r,I]=t.useState(),[k,q]=t.useState(!0),[Z,te]=t.useState(oe()),[U,F]=t.useState(!1),[W,s]=t.useState(""),[u,S]=t.useState();t.useEffect(()=>{if(m||!a||!i)return;const c=je(i.icalData),h=Ae(i.icalData,z[a.calendarId]??ge),B=a.allDay?"":a.start.slice(11,16),re=a.allDay?c:Le(c,we(a.start,h===""?"UTC":h).slice(0,10),a.start.slice(0,10)),D=ze(i.icalData),w=Pe(a,{repeat:c===""?"":qe(re,B)??"Repeats",location:D.location,notes:D.description,guests:i.attendees.filter(V=>V.role==="Guest").map(V=>Oe(V.email,V.displayName))}),ue=!A.has(a.id);d({draft:w,busy:ue,anchor:h}),I(w),q(ue),f({type:"sidebar-range",range:$(w)})},[m,a,i,A,z,f]);const p=l.mode==="sidebar"?l.draft.range:void 0;t.useEffect(()=>{!p||!r||Ke(p,$(r))||I({...r,date:p.date,endDate:p.endDate,startTime:p.startTime,endTime:p.endTime,allDay:p.allDay})},[p,r]);const ce=r!==void 0;t.useEffect(()=>{ce&&T.current?.focus()},[ce]),t.useEffect(()=>{u&&P.current?.focus()},[u]);const Ie=m!==void 0&&r!==void 0&&(JSON.stringify(m.draft)!==JSON.stringify(r)||k!==m.busy),{close:De,confirm:Re,leave:Te}=Ee(Ie);if(!C&&a===void 0)return v.jsx("section",{className:"flex h-full flex-col bg-surface","aria-labelledby":N,children:v.jsx(Ne,{headingId:N,onClose:M})});if(!a||!m||!r)return null;const se=J.find(c=>c.id===a.calendarId),de=a.seriesId!==""&&n!==void 0,H=i?.organizer??"",ke=i!==void 0&&(i.participation==="Organizer"||i.participation==="Unscheduled"&&H===""),ne=G.find(c=>c.email===H)?.accountId??X??Y??se?.accountId??"",ae=c=>{F(!1);const h=Ue(m.draft,r,{clock:Z,anchor:Z!==oe()?Z:m.anchor});if(!h.ok){s(h.problem);return}s(""),S(void 0);const B=k!==m.busy?{...h.patch,transparency:Ce(k)}:h.patch,re=B.attendees!==void 0&&H===""&&ne!==""?{...B,organizerAccountId:ne}:B;_({calendarObjectId:e,calendarId:a.calendarId,recurrenceId:n??"",scope:c,etag:i?.etag??""},re).then(D=>{if(D.kind==="written"){f({type:"saved"}),g(D.sends),o(e),Te();return}const w=D.kind==="conflict"?he:`Couldn't save this event: ${D.message}`;S({text:w,reportHref:pe(w),onRetry:()=>ae(c)})})};return v.jsxs(v.Fragment,{children:[v.jsx(le,{heading:"Edit event",draft:r,onChange:c=>{I(c),f({type:"sidebar-range",range:$(c)})},calendars:se?[se]:[],calendarEditable:!1,repeatEditable:!de,timeZone:Z,timeZones:be,onTimeZone:te,busy:k,onBusy:q,guests:ke?{suggestions:E,onQuery:L,senders:G,sender:ne,onSender:ee,senderEditable:H===""}:void 0,onSave:()=>de?F(!0):ae(void 0),onCancel:De,saving:K,problem:W,failure:u,failureRef:P,titleRef:T,children:U&&v.jsx(Ge,{title:a.title,ruleText:r.repeat===""?"It repeats":r.repeat,instanceText:$e(a),onChoose:ae,onCancel:()=>F(!1)})}),Re]})}export{pt as C,vt as a};
@@ -0,0 +1 @@
1
+ import{r as s,j as n,ad as k}from"./index-CL_fwLHN.js";import{C as ce}from"./confirm-dialog-q8tbS_22.js";import{a as de,b as ue}from"./calendar-event-popup-DsPmxVye.js";import{d as pe,e as fe}from"./calendar-guests-BR4hC59z.js";import{C as D}from"./useCalendarTasks-D_NZ0GM6.js";import{c as ve,t as me,R as V}from"./useCalendarData-DXhaM_NM.js";import{b as he,d as Ce,s as ge,v as xe,q as ye,c as N,w as Se,h as Ee}from"./useCalendarSuggestions-D3Jza1d7.js";import{f as T}from"./calendar-format-BwCpz-JZ.js";import"./reply-DvdgFS16.js";import{a as $e,b as we}from"./calendar-tMekVEGW.js";import{u as Ie}from"./CalendarSession-BKwK9s2o.js";const Re={Accepted:"accepted",Declined:"declined",Tentative:"tentative",NeedsAction:"noReply"},je=a=>({name:a.displayName,email:a.email,rsvp:Re[a.status],role:a.role==="Organizer"?"organizer":"attendee"}),ke={accepted:"Accepted",declined:"Declined",tentative:"Tentative"},J="This calendar changed while you were writing.",De=a=>a.kind==="conflict"?`${J} Close the popup and open the event again.`:a.kind==="refused"?`Couldn't delete this event: ${a.message}`:"";function qe({calendarObjectId:a,recurrenceId:p}){const{view:f,date:x,calendarIds:v}=$e(),{events:A,isLoading:U,freeIds:M}=ve({view:f,date:x,calendarIds:v}),{calendars:Q}=he(),{closeToView:m,openEditor:X}=we(),{deleteEvent:Y,updateEvent:Z,isWriting:F}=Ce(),b=Ie(),[O,y]=s.useState(),[ee,P]=s.useState(),c=s.useId(),L=s.useRef(null),B=s.useRef(null),G=s.useRef(null),[te,h]=s.useState(!1),[ne,S]=s.useState(!1),[E,ae]=s.useState(void 0),[K,se]=s.useState(null),C=Ee(a,p??""),t=A.find(e=>e.id===C),$=p===void 0&&t===void 0?ge(A,a,new Date().toISOString()):void 0,d=xe(a,t===void 0&&!U&&$===void 0),w=Q.find(e=>e.id===t?.calendarId),{resource:r}=ye(a,t?.calendarId??""),re=r?me(r.icalData):void 0,W=t!==void 0&&r!==void 0&&!w?.readOnly,I=t!==void 0&&t.seriesId!=="";s.useLayoutEffect(()=>{se(t?document.querySelector(`[data-event-id="${CSS.escape(t.id)}"]`):null)},[t]);const R=d.kind==="Deleted"||d.kind==="NoOccurrenceFound";s.useEffect(()=>{R?B.current?.focus():t&&L.current?.focus()},[R,t]),s.useEffect(()=>{E&&G.current?.focus()},[E]),s.useEffect(()=>{const e=`[data-event-id="${CSS.escape(C)}"]`;return()=>{document.querySelector(e)?.focus()}},[C]);const q=e=>({calendarObjectId:a,calendarId:t?.calendarId??"",recurrenceId:p??"",scope:e,etag:r?.etag??""}),z=(r?.attendees??[]).filter(e=>e.role==="Guest").map(e=>e.displayName===""?e.email:e.displayName),oe=()=>{if(z.length>0){S(!0);return}if(I){h(!0);return}g(void 0)},ie=()=>{if(S(!1),I){h(!0);return}g(void 0)},g=e=>{h(!1),Y(q(e)).then(i=>{if(i.kind==="written"){b.trackSends(i.sends),m();return}const l=De(i);ae({text:l,reportHref:N(l),onRetry:()=>g(e)})})},j=(e,i)=>{y(void 0),P(void 0),Z(q(i),{answer:ke[e]}).then(l=>{if(l.kind==="written"){b.trackSends(l.sends);return}const _=l.kind==="conflict"?`${J} Close the popup and open the event again.`:`Couldn't send your reply: ${l.message}`;P({text:_,reportHref:N(_),onRetry:()=>j(e,i)})})},u=r?.participation,le=u!==void 0&&u!=="Organizer"&&u!=="Unscheduled";if($)return n.jsx(k,{to:"/calendar/$view/$date/$calendarObjectId/$recurrenceId",params:{view:f,date:x,calendarObjectId:a,recurrenceId:$.recurrenceId},search:!0,hash:!0,replace:!0});const o=d.kind==="Found"?d.jump:void 0,H=o!==void 0&&v.length>0&&!v.includes(o.calendarId);if(o&&(o.date!==x||H)){const e=H?i=>({...i,calendarId:[...v,o.calendarId]}):!0;return o.recurrenceId===""?n.jsx(k,{to:"/calendar/$view/$date/$calendarObjectId",params:{view:f,date:o.date,calendarObjectId:a},search:e,hash:!0,replace:!0}):n.jsx(k,{to:"/calendar/$view/$date/$calendarObjectId/$recurrenceId",params:{view:f,date:o.date,calendarObjectId:a,recurrenceId:o.recurrenceId},search:e,hash:!0,replace:!0})}if(d.kind==="Failed"&&!t){const e=`Couldn't open this event: ${d.reason}`;return n.jsx(D,{anchor:null,anchorKey:"failed",labelledBy:c,children:n.jsxs("div",{className:"flex flex-col gap-3 p-4",id:c,children:[n.jsxs("p",{role:"alert",className:"text-sm text-danger",children:[e," ",n.jsx("a",{href:N(e),target:"_blank",rel:"noreferrer",className:"font-medium text-accent hover:underline",children:"Report an issue"})]}),n.jsx("button",{type:"button",onClick:m,className:"self-end rounded-md border border-line px-3 py-1.5 text-sm font-medium",children:"Close"})]})})}return R?n.jsx(D,{anchor:null,anchorKey:"gone",labelledBy:c,children:n.jsx(de,{headingId:c,onClose:m,closeRef:B})}):t?n.jsxs(n.Fragment,{children:[n.jsx(D,{anchor:K,anchorKey:`${C}:${K?"chip":"none"}`,labelledBy:c,children:n.jsxs(ue,{headingId:c,headingRef:L,title:t.title,color:w?.color??"cal-1",when:T(t).replace(", "," · "),location:re?.location??"",calendarName:w?.name??"",availability:M.has(t.id)?"Free":"Busy",onEdit:W?()=>X(a,p):void 0,onDelete:W?oe:void 0,deleting:F,onClose:m,failure:E,failureRef:G,children:[r&&n.jsx(pe,{attendees:r.attendees.map(je),counts:r.attendeeCounts}),le&&u&&n.jsx(fe,{current:Se(u),onAnswer:e=>I?y(e):j(e,void 0),sending:F,failure:ee}),O&&n.jsx(V,{title:t.title,ruleText:"It repeats",instanceText:T(t),scopes:["this","all"],onChoose:e=>j(O,e),onCancel:()=>y(void 0)}),te&&n.jsx(V,{title:t.title,ruleText:"It repeats",instanceText:T(t),onChoose:g,onCancel:()=>h(!1)})]})}),n.jsx(ce,{isOpen:ne,title:"Delete and tell the guests?",description:`${z.join(", ")} will get a cancellation.`,confirmLabel:"Delete and send",cancelLabel:"Keep event",destructive:!0,onConfirm:ie,onCancel:()=>S(!1)})]}):null}export{qe as C};
@@ -0,0 +1 @@
1
+ import{j as e,w as d}from"./index-CL_fwLHN.js";import{f as l}from"./ErrorState-KjDYblD5.js";import{c as o}from"./useCalendarSuggestions-D3Jza1d7.js";function x({title:r,error:a,onRetry:n,compact:t=!1}){const s=l(a);return e.jsxs("div",{role:"alert",className:t?"flex flex-col gap-2 rounded-md border border-danger/40 bg-danger-soft p-3 text-sm":"flex h-full flex-col items-center justify-center gap-3 p-8 text-center",children:[!t&&e.jsx(d,{className:"size-8 text-danger","aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-danger",children:r}),e.jsx("p",{className:"mt-1 break-words text-sm text-fg-muted",children:s})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:n,className:"inline-flex items-center rounded-md border border-line bg-canvas px-3 py-1.5 text-sm font-medium hover:bg-surface-raised",children:"Retry"}),e.jsx("a",{href:o(`${r}: ${s}`),target:"_blank",rel:"noreferrer",className:"text-sm font-medium text-accent hover:underline",children:"Report an issue"})]})]})}export{x as C};
@@ -0,0 +1 @@
1
+ import{b as _,o as j,j as e,X as q,r as c,cj as X}from"./index-CL_fwLHN.js";import{u as J,C as V}from"./useCalendarTasks-D_NZ0GM6.js";import{i as F,c as ee}from"./calendar-guests-BR4hC59z.js";import{C as te}from"./calendar-event-popup-DsPmxVye.js";import{c as ae}from"./draft-Y5XWTm_J.js";import{b as ne,d as re,c as se,o as K,U,e as W}from"./useCalendarSuggestions-D3Jza1d7.js";import{u as le,b as ie}from"./useCalendarScheduling-BpjmrzdY.js";import"./reply-DvdgFS16.js";import{i as oe}from"./calendar-tMekVEGW.js";import{u as ce}from"./CalendarSession-BKwK9s2o.js";const ue=_("GripHorizontal",[["circle",{cx:"12",cy:"9",r:"1",key:"124mty"}],["circle",{cx:"19",cy:"9",r:"1",key:"1ruzo2"}],["circle",{cx:"5",cy:"9",r:"1",key:"1a8b28"}],["circle",{cx:"12",cy:"15",r:"1",key:"1e56xg"}],["circle",{cx:"19",cy:"15",r:"1",key:"1a92ep"}],["circle",{cx:"5",cy:"15",r:"1",key:"5r1jwy"}]]),de="h-9 rounded-md border border-line bg-surface-sunken px-2 text-sm text-fg outline-none focus-visible:border-line-strong focus-visible:ring-2 focus-visible:ring-ring/30",$=(s,r)=>{const m={...s.range,...r};return r.date!==void 0&&!m.allDay&&(m.endDate=r.date),r.date!==void 0&&m.allDay&&m.endDate<r.date&&(m.endDate=r.date),{...s,range:m}};function me({headingId:s,mode:r,onMode:m,fields:i,taskFields:o,onTaskChange:u,calendars:g,taskLists:N,guestSuggestions:T,onGuestQuery:v,onChange:f,onSave:x,onMoreOptions:R,onClose:A,saving:y=!1,problem:w="",failure:S,failureRef:M,titleRef:P,settingsHref:z,dragHandle:E,touch:h=!1}){const n=r==="task",C=n?N:g,D=C.length===0,d=!n&&F(i.guests)!==void 0,p=j(de,h&&"h-11"),G=n?o.title:i.title,I=t=>n?u({...o,title:t}):f({...i,title:t});return e.jsxs("form",{className:"relative flex flex-col",onSubmit:t=>{t.preventDefault(),!D&&!y&&!d&&x()},children:[e.jsxs("div",{onPointerDown:E?.onPointerDown,className:j("flex items-center justify-between rounded-t-xl bg-surface-sunken px-2 py-1",E&&"cursor-grab"),children:[e.jsx(ue,{className:"size-4 text-fg-subtle","aria-hidden":"true"}),e.jsx("h2",{id:s,className:"sr-only",children:n?"New task":"New event"})]}),e.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[e.jsx("input",{ref:P,"aria-label":"Title",placeholder:"Add title",value:G,onChange:t=>I(t.target.value),className:j("border-b-2 border-line bg-transparent pb-1 text-xl text-fg outline-none placeholder:text-fg-subtle focus:border-accent")}),e.jsxs("fieldset",{className:"flex gap-1 self-start rounded-md bg-surface-sunken p-0.5 text-sm",children:[e.jsx("legend",{className:"sr-only",children:"Kind"}),["event","task"].map(t=>e.jsxs("label",{className:j("cursor-pointer rounded px-3 py-1 font-medium has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-ring",r===t?"bg-surface text-fg shadow-sm":"text-fg-muted",h&&"min-h-11"),children:[e.jsx("input",{type:"radio",name:`${s}-kind`,value:t,checked:r===t,onChange:()=>m(t),className:"sr-only"}),t==="event"?"Event":"Task"]},t))]}),n?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-fg-muted",children:"Due"}),e.jsx("input",{type:"date","aria-label":"Due date",value:o.dueDate,onChange:t=>t.target.value!==""&&u({...o,dueDate:t.target.value}),className:p}),o.dueTime===""?e.jsx("button",{type:"button",onClick:()=>u({...o,dueTime:"09:00"}),className:"rounded-md px-2 font-medium text-accent hover:bg-accent-soft",children:"Add time"}):e.jsx("input",{type:"time","aria-label":"Due time",step:900,value:o.dueTime,onChange:t=>u({...o,dueTime:t.target.value}),className:p})]}):e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[e.jsx("input",{type:"date","aria-label":"Date",value:i.range.date,onChange:t=>t.target.value!==""&&f($(i,{date:t.target.value})),className:p}),i.range.allDay?e.jsx("span",{className:"text-fg-muted",children:"All day"}):e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"time","aria-label":"Start time",step:900,value:i.range.startTime,onChange:t=>t.target.value!==""&&f($(i,{startTime:t.target.value})),className:p}),e.jsx("span",{"aria-hidden":"true",children:"–"}),e.jsx("input",{type:"time","aria-label":"End time",step:900,value:i.range.endTime,onChange:t=>t.target.value!==""&&f($(i,{endTime:t.target.value})),className:p})]})]}),!n&&e.jsx(ee,{value:i.guests,onChange:t=>f({...i,guests:t}),suggestions:T,onQuery:v,touch:h}),n?e.jsx("textarea",{"aria-label":"Description",placeholder:"Add description",rows:2,value:o.description,onChange:t=>u({...o,description:t.target.value}),className:"w-full rounded-md border border-line bg-surface-sunken px-2 py-1 text-sm text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring/30"}):e.jsx("input",{"aria-label":"Location",placeholder:"Add location",value:i.location,onChange:t=>f({...i,location:t.target.value}),className:p}),D?e.jsxs("p",{role:"status",tabIndex:-1,className:"text-sm text-fg-muted",children:["None of your calendars accepts new events."," ",e.jsx("a",{href:z,className:"font-medium text-accent hover:underline",children:"Calendar settings"})]}):e.jsx("select",{"aria-label":n?"Task list":"Calendar",value:n?o.calendarId:i.calendarId,onChange:t=>n?u({...o,calendarId:t.target.value}):f({...i,calendarId:t.target.value}),className:p,children:C.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))}),w!==""&&e.jsx("p",{className:"text-sm text-danger",role:"status",children:w}),S&&e.jsx(te,{failure:S,focusRef:M})]}),e.jsxs("div",{className:"flex items-center justify-between px-4 pb-4",children:[n?e.jsx("span",{}):e.jsx("button",{type:"button",onClick:R,className:j("rounded-md px-3 text-sm font-medium text-accent outline-none hover:bg-accent-soft focus-visible:ring-2 focus-visible:ring-ring",h?"min-h-11":"h-9"),children:"More options"}),e.jsx("button",{type:"submit",disabled:D||y||d,className:j("rounded-md bg-accent px-5 text-sm font-medium text-accent-fg outline-none hover:bg-accent-hover focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50",h?"min-h-11":"h-9"),children:y?"Saving…":"Save"})]}),e.jsx("button",{type:"button","aria-label":"Close",onClick:A,className:j("absolute top-0 right-1 flex items-center justify-center rounded-full text-fg-muted outline-none hover:bg-surface hover:text-fg focus-visible:ring-2 focus-visible:ring-ring",h?"size-11":"size-8"),children:e.jsx(q,{className:"size-4"})})]})}const fe=80;function ge({labelledBy:s,onDismiss:r,children:m,sheetRef:i,className:o}){const u=c.useRef(null),[g,N]=c.useState(0),T=x=>{u.current=x.clientY,x.currentTarget.setPointerCapture(x.pointerId)},v=x=>{u.current!==null&&N(Math.max(0,x.clientY-u.current))},f=()=>{u.current!==null&&(u.current=null,g>fe&&r(),N(0))};return e.jsxs("div",{ref:i,role:"dialog","aria-modal":"false","aria-labelledby":s,"data-calendar-popover":"",className:j("fixed inset-x-0 bottom-0 z-50 max-h-[70dvh] overflow-y-auto rounded-t-2xl border-t border-line bg-surface-raised pb-[env(safe-area-inset-bottom,0px)] shadow-2xl shadow-black/30",o),style:{transform:`translateY(${g}px)`,transition:g===0?"transform 200ms ease-out":"none"},children:[e.jsx("div",{"aria-hidden":"true","data-sheet-grabber":"",onPointerDown:T,onPointerMove:v,onPointerUp:f,onPointerCancel:f,className:"flex h-6 cursor-grab touch-none items-center justify-center",children:e.jsx("span",{className:"h-1 w-10 rounded-full bg-line-strong"})}),m]})}const xe="/settings/calendars";function pe(s){return{title:s.title,date:s.range.date,startTime:s.range.startTime,endDate:s.range.endDate,endTime:s.range.endTime,allDay:s.range.allDay,calendarId:s.calendarId,location:s.location,guests:s.guests,notes:"",repeat:""}}function ke({session:s,dispatch:r,onMoreOptions:m,onSaved:i,touch:o=!1}){const u=c.useId(),g=c.useRef(null),N=c.useRef(null),[T,v]=c.useState(""),{calendars:f,taskLists:x,defaultCalendarId:R,timeZoneByCalendarId:A}=ne(),y=f.filter(a=>!a.readOnly),{createEvent:w}=re(),{createTask:S}=J(),{defaultSenderId:M}=le(),[P,z]=c.useState(""),E=ie(P),h=ce(),{draft:n}=s,[C,D]=c.useState("event"),[d,p]=c.useState({title:"",dueDate:"",dueTime:"",description:"",calendarId:""}),G=a=>{if(a!==C){if(D(a),a==="event"){r({type:"change",draft:{...n,title:d.title}});return}p(l=>({...l,title:n.title,dueDate:n.range.date,dueTime:n.range.allDay?"":n.range.startTime,calendarId:l.calendarId===""?x[0]?.id??"":l.calendarId}))}},I=y.find(a=>a.id===R)?.id??y[0]?.id??"",t=M??y.find(a=>a.id===n.calendarId)?.accountId??"";c.useEffect(()=>{g.current?.focus()},[]),c.useEffect(()=>{n.calendarId!==""||I===""||r({type:"change",draft:{...n,calendarId:I}})},[n,I,r]),c.useEffect(()=>{s.status==="failed"&&N.current?.focus()},[s.status]);const L=c.useRef(null),B=c.useRef(null);oe(o,()=>(r({type:"outside"}),!0));const k=`${n.range.date}T${n.range.startTime}/${n.range.endDate}T${n.range.endTime}`;c.useEffect(()=>{const a=B.current;if(k==="")return;const l=document.querySelector("[data-draft-block]"),b=document.querySelector("[role='grid'][aria-label='Time grid']");if(!a||!l||!b)return;const Z=l.getBoundingClientRect().bottom-a.getBoundingClientRect().top+16;Z>0&&(b.scrollTop+=Z)},[k]);const H=c.useRef(null);c.useEffect(()=>{const a=H.current;if(!a)return;const l=b=>{(b.target instanceof HTMLInputElement||b.target instanceof HTMLSelectElement)&&(L.current=b.target)};return a.addEventListener("focusin",l),()=>a.removeEventListener("focusin",l)},[]),c.useEffect(()=>{const a=L.current;k===""||!a||document.activeElement===a||a.focus()},[k]);const Y=()=>{if(d.title.trim()===""){v("Give the task a title before saving it."),g.current?.focus();return}v(""),r({type:"save"});const a=W(),l=d.dueTime==="";S({calendarId:d.calendarId,summary:d.title.trim(),description:d.description,allDay:l,due:l?d.dueDate:X(d.dueDate,d.dueTime,a),...l?{}:{timeZone:K(U)}}).then(b=>{if(b.kind==="written"){r({type:"saved"});return}r({type:"save-failed",problem:`Couldn't save the task: ${b.message}`})})},O=()=>{if(C==="task"){Y();return}const a=ae(pe(n),{clock:W(),anchor:K(A[n.calendarId]??U)},t);if(!a.ok){v(a.problem),g.current?.focus();return}v(""),r({type:"save"}),w(a.input).then(l=>{if(l.kind==="created"){r({type:"saved"}),h.trackSends(l.sends),i(l.calendarObjectId);return}r({type:"save-failed",problem:l.kind==="conflict"?"This calendar changed while you were writing. Close the form and try again.":`Couldn't save this event: ${l.message}`})})},Q=a=>e.jsx("div",{ref:H,children:e.jsx(me,{headingId:u,mode:C,onMode:G,fields:n,taskFields:d,onTaskChange:p,calendars:y,taskLists:x,guestSuggestions:E,onGuestQuery:z,onChange:l=>r({type:"change",draft:l}),onSave:O,onMoreOptions:()=>m(L.current?.getAttribute("aria-label")??""),onClose:()=>r({type:"outside"}),saving:s.status==="saving",problem:T,failure:s.status==="failed"?{text:s.problem,reportHref:se(s.problem),onRetry:O}:void 0,failureRef:N,titleRef:g,settingsHref:xe,dragHandle:a,touch:o})});return o?e.jsx(ge,{labelledBy:u,onDismiss:()=>r({type:"outside"}),sheetRef:B,children:Q()}):e.jsx(V,{anchor:"[data-draft-block]",anchorKey:k,labelledBy:u,wrapTab:!0,header:a=>Q(a),children:null})}export{ke as C,pe as e};
@@ -0,0 +1 @@
1
+ import{r as e}from"./index-CL_fwLHN.js";const t=e.createContext(null);function s(){const n=e.useContext(t);if(!n)throw new Error("the calendar session is not mounted");return n}function r(){return e.useContext(t)}export{t as C,r as a,s as u};
@@ -0,0 +1 @@
1
+ import{j as e,aw as d,o as i,ah as l}from"./index-CL_fwLHN.js";function x({clashes:t,clearText:s="Nothing else is booked over it.",className:a}){return t.length===0?e.jsxs("p",{className:i("flex items-center gap-2 rounded-md border border-line bg-surface-sunken p-2 text-xs text-fg-muted",a),children:[e.jsx(d,{className:"size-3.5 shrink-0 text-positive","aria-hidden":!0}),s]}):e.jsxs("div",{className:i("flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft p-2",a),children:[e.jsx(l,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-xs font-semibold text-danger",children:t.length===1?"This clashes with something you have already agreed to.":`This clashes with ${t.length} things you have already agreed to.`}),e.jsx("ul",{className:"mt-1 flex flex-col gap-0.5",children:t.map(r=>e.jsx("li",{className:"text-xs text-fg",children:r.label},r.id))})]})]})}const m=({message:t,icon:s})=>e.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:[s&&e.jsx("div",{className:"mb-4 text-fg-muted",children:s}),e.jsx("p",{className:"text-fg-muted",children:t})]});export{x as C,m as E};
@@ -1 +1 @@
1
- import{j as t,T as r}from"./index-CXzCthHG.js";const d=e=>e instanceof Error?e.message:typeof e=="string"?e:typeof e=="object"&&e!==null&&"message"in e&&typeof e.message=="string"?e.message:"An unexpected error occurred",l=({title:e="Couldn't load content",error:a,onRetry:s,variant:i="block"})=>{const n=d(a);return i==="inline"?t.jsxs("div",{role:"alert",className:"flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-sm",children:[t.jsx(r,{className:"size-4 shrink-0 text-danger mt-0.5","aria-hidden":"true"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"font-medium text-danger",children:e}),t.jsx("p",{className:"text-fg-muted mt-0.5 break-words",children:n})]}),s&&t.jsx("button",{type:"button",onClick:s,className:"shrink-0 text-sm font-medium text-accent hover:underline",children:"Retry"})]}):t.jsxs("div",{role:"alert",className:"flex flex-col items-center justify-center gap-3 p-8 text-center",children:[t.jsx(r,{className:"size-8 text-danger","aria-hidden":"true"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium text-danger",children:e}),t.jsx("p",{className:"text-sm text-fg-muted mt-1 break-words",children:n})]}),s&&t.jsx("button",{type:"button",onClick:s,className:"inline-flex items-center rounded-md border border-line bg-canvas px-4 py-2 text-sm font-medium hover:bg-surface-raised transition-colors",children:"Retry"})]})};export{l as E,d as f};
1
+ import{j as t,w as r}from"./index-CL_fwLHN.js";const d=e=>e instanceof Error?e.message:typeof e=="string"?e:typeof e=="object"&&e!==null&&"message"in e&&typeof e.message=="string"?e.message:"An unexpected error occurred",l=({title:e="Couldn't load content",error:a,onRetry:s,variant:i="block"})=>{const n=d(a);return i==="inline"?t.jsxs("div",{role:"alert",className:"flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-sm",children:[t.jsx(r,{className:"size-4 shrink-0 text-danger mt-0.5","aria-hidden":"true"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"font-medium text-danger",children:e}),t.jsx("p",{className:"text-fg-muted mt-0.5 break-words",children:n})]}),s&&t.jsx("button",{type:"button",onClick:s,className:"shrink-0 text-sm font-medium text-accent hover:underline",children:"Retry"})]}):t.jsxs("div",{role:"alert",className:"flex flex-col items-center justify-center gap-3 p-8 text-center",children:[t.jsx(r,{className:"size-8 text-danger","aria-hidden":"true"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium text-danger",children:e}),t.jsx("p",{className:"text-sm text-fg-muted mt-1 break-words",children:n})]}),s&&t.jsx("button",{type:"button",onClick:s,className:"inline-flex items-center rounded-md border border-line bg-canvas px-4 py-2 text-sm font-medium hover:bg-surface-raised transition-colors",children:"Retry"})]})};export{l as E,d as f};
@@ -0,0 +1 @@
1
+ import{fz as J,r as n,eI as X,a as le,P as z,dw as ce,aC as ue,aD as ge,j as r}from"./index-CL_fwLHN.js";import{u as he,p as _,R as me}from"./MessageBody-C89PSL_p.js";import{y as pe,A as fe,am as xe,an as Ie,ax as Te,ao as ye,d as ve,M as be,au as Re,ay as Ce,aw as Se,m as we,G as je,K as U,J as Fe,H as Me,e as Oe,V as ke,W as H,X as Pe,Z,_ as $,$ as Le,a0 as Ae,a1 as Ne}from"./MessageToolbar-UJadqHyA.js";import{u as De,l as qe,b as Ee,a as We}from"./MailViewChrome-yffBJjbO.js";import{h as Be,n as Qe,r as ze}from"./reply-DvdgFS16.js";import{a as He}from"./useMessageBodyContent-D-LJBFh4.js";import{e as Ke,f as Ve}from"./search-token-index-B1HU1d2-.js";import{u as Ge}from"./sections-Rf3k05-_.js";import{f as _e}from"./ErrorState-KjDYblD5.js";import{u as Ue}from"./useMediaQuery-DiQ0fGER.js";import{d as Je,w as Xe}from"./wizard-selection-zWa1qc6-.js";const K=t=>({...t,starred:!0,order:"desc"}),Ze=(t={})=>X({query:K(t)});function Y(t={}){const{data:e,isLoading:s,isError:a,error:i,refetch:f,fetchNextPage:l,hasNextPage:g,isFetchingNextPage:o}=De({queryKey:Ze(t),queryFn:async({pageParam:x})=>{const{data:u}=await J({query:{...K(t),continuationToken:x},throwOnError:!0});return u},initialPageParam:void 0,getNextPageParam:x=>x.continuationToken,staleTime:6e4});return{threads:n.useMemo(()=>(e?.pages??[]).flatMap(x=>x.items??[]),[e]),isLoading:s,isError:a,error:i,refetch:f,fetchNextPage:l,hasNextPage:g,isFetchingNextPage:o}}function $e(t={}){const e={...K(t),unread:!0,count:!0,results:!1},{data:s}=le({queryKey:X({query:e}),queryFn:async()=>{const{data:a}=await J({query:e,throwOnError:!0});return a},staleTime:6e4});return s?.count}const Ye=["from","subject","category","unread","starred","attachments"],et=(t,e)=>{const s=pe(t),{params:a,residual:i}=fe(e,{...s,starred:!0},Ye);return{criteria:{...a,...s},residual:i}};function tt({rows:t,verb:e}){const{selectedIds:s,exitSelection:a}=Se(),i=n.useMemo(()=>Xe(t,s),[t,s]);return r.jsx(we,{verb:e,selection:i,selectionRestriction:"spansAccounts",onFinished:a})}function st({selectedMessageId:t,onOpenThread:e,commandsRef:s,onTriageContextChange:a,onDeleteMessages:i}){const{searchQuery:f,resultFolderIndex:l,onSearchClearQuery:g}=z(),o=he(),k=Ue(),x=ce(),[u,h]=n.useState("all"),[v,P]=n.useState(new Set),S=n.useCallback(d=>{P(C=>{const I=new Set(C);return I.has(d)?I.delete(d):I.add(d),I})},[]),w=n.useCallback(()=>{h("all"),P(new Set)},[]),T=n.useCallback(()=>{w(),g()},[w,g]),{freeText:j,tokens:b}=_(f.trim().toLowerCase(),o),L=_(f.trim(),o).freeText,{criteria:A,residual:m}=n.useMemo(()=>et({category:u,attributes:v},b),[u,v,b]),F=n.useMemo(()=>j?{...A,query:j}:A,[A,j]),{threads:N,isLoading:D,isError:y,error:E,refetch:M,fetchNextPage:W,hasNextPage:B,isFetchingNextPage:O}=Y(F),p=n.useMemo(()=>Je(N).map(xe).filter(d=>Ie(d,m)),[N,m]),c=n.useCallback((d,C)=>{const I=p.find(de=>de.id===d)?.threadId;I&&e?.({threadId:I,messageId:d},C)},[p,e]),R=n.useCallback(d=>{const C=d.threadId??p.find(I=>I.id===d.id)?.threadId;C&&e?.({threadId:C,messageId:d.id})},[p,e]),Q=n.useMemo(()=>Te(),[]),se=n.useMemo(()=>p.map(d=>ye(d,l)),[p,l]),ae=$e(F)??null,re=n.useMemo(()=>b.filter(d=>d.type!=="isStarred"),[b]),oe=qe({chips:{category:u,attributes:v},tokens:re,reach:m.length>0?"loaded-pages":"whole-folder",onClear:T}),V=D?"loading":y?"error":p.length===0?"empty":"ready",ne=n.useCallback(()=>{const d=ue(ge());window.open(d,"_blank","noopener,noreferrer")},[]),G=ve(),ie=r.jsx("div",{className:"flex h-full min-h-0 flex-col",children:r.jsxs("div",{className:"flex-1 overflow-y-auto",children:[r.jsx("div",{className:"divide-y divide-line",children:p.map(d=>r.jsx(be,{thread:d,active:d.id===t,onClick:()=>c(d.id)},d.id))}),B?r.jsx("button",{type:"button",className:"w-full py-3 text-sm text-muted hover:text-fg disabled:opacity-50",onClick:()=>W(),disabled:O,children:O?"Loading…":"Load more"}):null]})});return r.jsx(Ee,{title:"Starred",unreadCount:ae,preset:Q,selectedCategory:u,activeFilters:v,onSelectCategory:h,onToggleFilter:S,onClearFilters:w,searchResults:se,searchLoading:D,onSelectSearchResult:R,searchResultsInBody:!0,children:r.jsxs(Re,{selectedMessageId:t,rows:p,onOpen:c,onDeleteMessages:i,onSelectionVerb:x.start,commandsRef:s,onTriageContextChange:a,children:[r.jsx(We,{listTitle:"Starred",sections:[{id:"flagged",threads:p}],flatList:!0,hideHeader:!0,listState:G.searchResults?"ready":V,listFilter:oe,listScopeLabel:"Starred",searchQuery:L||void 0,errorMessage:y?_e(E):void 0,onRetry:()=>M(),onReportError:ne,selectedThreadId:t,onSelectThread:c,isDesktop:k,selectionBar:r.jsx(Ce,{title:"Starred"}),listBody:G.searchResults??(V==="ready"?ie:void 0)}),r.jsx(tt,{rows:p,verb:x.verb})]})})}const ee=n.createContext(null);function q(){const t=n.useContext(ee);if(!t)throw new Error("FlaggedPane.* must be used inside <FlaggedPane>");return t}function at({thread:t,children:e}){const s=Ke(),a=Ve(),i=Ge(),{searchInput:f}=z(),l=t?.threadId,g=t?.messageId,{threads:o}=Y(),k=n.useMemo(()=>{if(l)return o.find(c=>c.messageId===g)??o.find(c=>c.threadId===l)},[o,l,g]),x=je(l,g),u=k??x,h=g??u?.messageId,v=n.useMemo(()=>{if(l)return{threadId:l,mailboxId:u?.mailboxId??"",subject:u?.subject,messageId:h,authenticity:u?.authenticity}},[l,u,h]),P=n.useCallback((c,R)=>{s(c,{replace:R?.replace,query:f})},[s,f]),S=n.useCallback(c=>{h&&c.includes(h)&&a()},[h,a]),w=U({thread:u,isOpen:!0,onAfterOptimisticRemove:S}),T=Fe(),{deleteMessages:j}=Me({mailboxId:u?.mailboxId??"",messages:o,onAfterOptimisticRemove:S}),{toggleReadFor:b}=Oe({mailboxId:u?.mailboxId??"",messages:o}),L=T.focusedMessageId,m=n.useMemo(()=>o.find(c=>c.messageId===L),[o,L])??u,F=U({thread:m,isOpen:m?.messageId===h}),N=He(),D=Be(),y=Qe(),E=n.useMemo(()=>ze(y,l,h),[y,l,h]),M=n.useMemo(()=>{if(m)return c=>y({threadId:m.threadId,messageId:m.messageId,mode:c})},[y,m]),{nextMessageId:W,previousMessageId:B}=ke({context:T,orderedIds:T.orderedIds,selectedMessageId:h,enabled:!N&&!D,hasOpenThread:l!==void 0,onClose:a,handlers:{reply:()=>M?.("reply"),replyAll:()=>M?.("reply-all"),forward:()=>M?.("forward"),delete:()=>{T.listCommandsRef.current?.requestVerb("delete")||F.deleteThread()},toggleStar:F.toggleStar,toggleRead:()=>{T.listCommandsRef.current?.requestVerb("markRead")||m&&b([m.messageId],!m.isRead)},goBrief:()=>i("brief"),goSettings:()=>i("settings")}}),O=n.useCallback(c=>{if(!c)return;const R=o.find(Q=>Q.messageId===c);return R?{threadId:R.threadId,messageId:c}:void 0},[o]),p={selectedMessageId:h,selectedThread:u,conversation:v,onOpenThread:P,onCloseThread:a,nextThread:O(W),previousThread:O(B),actions:w,onReply:E,triage:T,onDeleteMessages:j,handleDeselectIfRemoved:S};return r.jsx(ee.Provider,{value:p,children:e})}function te(){const{selectedMessageId:t,onOpenThread:e,triage:s,onDeleteMessages:a}=q();return r.jsx(st,{selectedMessageId:t,onOpenThread:e,commandsRef:s.listCommandsRef,onTriageContextChange:s.onTriageContextChange,onDeleteMessages:a})}function rt(){const t=H(),{conversation:e,selectedThread:s,actions:a,onReply:i,handleDeselectIfRemoved:f,onOpenThread:l}=q(),g=!!e,o=Ae(e?.threadId);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(Ne,{hasThread:g,intelligenceOpen:o.isShowing,canToggleIntelligence:o.canToggle,onToggleIntelligence:o.toggle,onReply:i?()=>i("reply"):void 0,onReplyAll:i?()=>i("reply-all"):void 0,onForward:i?()=>i("forward"):void 0,onDelete:g?a.deleteThread:void 0,onToggleStar:g?a.toggleStar:void 0,isStarred:a.isStarred,moveContext:g&&a.accountId&&a.mailboxId?{accountId:a.accountId,currentMailboxId:a.mailboxId,onMove:a.moveThread}:void 0}),r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e?r.jsx(Z,{threadId:e.threadId,mailboxId:e.mailboxId,subject:e.subject,selectedMessageId:e.messageId,authenticity:e.authenticity,onOpenIntelligence:o.open,listOnScreen:!0}):r.jsx(me,{})})]}),r.jsx($,{isOpen:o.drawerOpen,onClose:o.closeDrawer,thread:s,accountId:s?.accountId,onAfterOptimisticRemove:f,onReplyWithText:t,onOpenThread:l})]})}function ot(){const t=H(),{selectedThread:e,handleDeselectIfRemoved:s,onOpenThread:a}=q(),{onToggleIntelligence:i}=z();return r.jsx(Le,{onClose:i,thread:e,accountId:e?.accountId,onAfterOptimisticRemove:s,onReplyWithText:t,onOpenThread:a})}function nt(){const t=H(),{selectedThread:e,conversation:s,onCloseThread:a,onOpenThread:i,nextThread:f,previousThread:l,handleDeselectIfRemoved:g}=q(),o=Pe(s?.threadId??null);return s?r.jsxs(r.Fragment,{children:[r.jsx(Z,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onBack:a,onOpenIntelligence:o.toggle,onSwipeNext:f?()=>i(f):void 0,onSwipePrevious:l?()=>i(l):void 0,mobileIntelligenceOpen:o.isOpen}),r.jsx($,{isOpen:o.isOpen,onClose:o.close,thread:e,accountId:e?.accountId,onAfterOptimisticRemove:g,onReplyWithText:t,onOpenThread:i})]}):r.jsx("div",{className:"h-full",children:r.jsx(te,{})})}const It=Object.assign(at,{List:te,Reading:rt,Intelligence:ot,Phone:nt});export{It as F};
@@ -1 +1 @@
1
- import{r as n,a as f,c as m,p as N,j as e,X as w}from"./index-CXzCthHG.js";import{E as u}from"./ErrorState-Bi4vrhhQ.js";import{D as r,C as x,u as E}from"./index-Cb2UJhnj.js";import{u as k}from"./useMediaQuery-DB2OdJvp.js";import"./reply-B9-kr45N.js";import{d as p,e as h,f as b}from"./useMessageBodyContent-Gq_pdN4f.js";import{C as S}from"./confirm-dialog-AppxcVfC.js";const C=t=>t?"Draft":"New Message",I=()=>{const t=n.useRef(!1);return n.useCallback(()=>{const s=document.querySelector("[data-subject-field]")?.value??"",o=(document.querySelector('[data-testid="compose-body"]')?.textContent??"").replace(/--\s*/g,"").trim();return t.current=s.trim().length>0||o.length>0,t.current},[])},O=()=>{const t=p(),i=h(),s=b(),a=I(),[l,o]=n.useState(!1),{isError:d,error:c,refetch:g}=f({...m(),staleTime:1/0}),j=n.useCallback(D=>{D||(a()?o(!0):s())},[s,a]),y=n.useCallback(()=>{o(!1),s()},[s]),v=n.useCallback(()=>{o(!1)},[]);return N({id:"mobile-compose",open:!0}),e.jsxs(r.Root,{open:!0,onOpenChange:j,children:[e.jsxs(r.Portal,{children:[e.jsx(r.Overlay,{className:"fixed inset-0 z-40 bg-black/40"}),e.jsxs(r.Content,{className:"fixed inset-x-0 bottom-0 z-50 flex flex-col rounded-t-lg bg-canvas pb-[env(safe-area-inset-bottom,0px)]",style:{height:"95dvh"},children:[e.jsx(r.Handle,{className:"mx-auto mt-2 mb-1 h-1.5 w-12 rounded-full bg-fg-muted/30"}),e.jsx(r.Title,{className:"px-4 py-2 text-base font-semibold border-b border-line",children:C(t)}),d?e.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:e.jsx(u,{title:"Couldn't load compose",error:c,onRetry:()=>{g()}})}):e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(x,{mode:"new",outboxMessageId:t,onDraftCreated:i,onClose:s})})]})]}),e.jsx(S,{isOpen:l,title:"Discard draft?",description:"Your message has unsaved content. Are you sure you want to discard it?",confirmLabel:"Discard",cancelLabel:"Keep editing",destructive:!0,onConfirm:y,onCancel:v})]})},K=()=>{const t=p(),i=h(),s=b(),a=k(),{isError:l,error:o,refetch:d}=f({...m(),staleTime:1/0});if(E({bindings:[{key:"Escape",handler:s,preventDefault:!0}]}),!a)return e.jsx(O,{});const c=e.jsxs("header",{className:"flex items-center justify-between gap-2 px-4 py-3 border-b border-line shrink-0",children:[e.jsx("div",{className:"flex items-center gap-2 min-w-0",children:e.jsx("h2",{className:"text-lg font-semibold truncate",children:C(t)})}),e.jsx("button",{type:"button",onClick:s,className:"p-2 rounded-md hover:bg-surface-raised transition-colors min-h-11 min-w-11 inline-flex items-center justify-center","aria-label":"Close",children:e.jsx(w,{className:"size-5"})})]});return l?e.jsxs("div",{className:"h-full flex flex-col bg-canvas",children:[c,e.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:e.jsx(u,{title:"Couldn't load compose",error:o,onRetry:()=>{d()}})})]}):e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-canvas",children:[c,e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(x,{mode:"new",outboxMessageId:t,onDraftCreated:i,onClose:s})})]})};export{K as F};
1
+ import{r as n,a as f,c as m,p as N,j as e,X as w}from"./index-CL_fwLHN.js";import{E as u}from"./ErrorState-KjDYblD5.js";import{D as r,C as x,u as E}from"./index-DZb7rV9A.js";import{u as k}from"./useMediaQuery-DiQ0fGER.js";import"./reply-DvdgFS16.js";import{d as p,e as h,f as b}from"./useMessageBodyContent-D-LJBFh4.js";import{C as S}from"./confirm-dialog-q8tbS_22.js";const C=t=>t?"Draft":"New Message",I=()=>{const t=n.useRef(!1);return n.useCallback(()=>{const s=document.querySelector("[data-subject-field]")?.value??"",o=(document.querySelector('[data-testid="compose-body"]')?.textContent??"").replace(/--\s*/g,"").trim();return t.current=s.trim().length>0||o.length>0,t.current},[])},O=()=>{const t=p(),i=h(),s=b(),a=I(),[l,o]=n.useState(!1),{isError:d,error:c,refetch:g}=f({...m(),staleTime:1/0}),j=n.useCallback(D=>{D||(a()?o(!0):s())},[s,a]),y=n.useCallback(()=>{o(!1),s()},[s]),v=n.useCallback(()=>{o(!1)},[]);return N({id:"mobile-compose",open:!0}),e.jsxs(r.Root,{open:!0,onOpenChange:j,children:[e.jsxs(r.Portal,{children:[e.jsx(r.Overlay,{className:"fixed inset-0 z-40 bg-black/40"}),e.jsxs(r.Content,{className:"fixed inset-x-0 bottom-0 z-50 flex flex-col rounded-t-lg bg-canvas pb-[env(safe-area-inset-bottom,0px)]",style:{height:"95dvh"},children:[e.jsx(r.Handle,{className:"mx-auto mt-2 mb-1 h-1.5 w-12 rounded-full bg-fg-muted/30"}),e.jsx(r.Title,{className:"px-4 py-2 text-base font-semibold border-b border-line",children:C(t)}),d?e.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:e.jsx(u,{title:"Couldn't load compose",error:c,onRetry:()=>{g()}})}):e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(x,{mode:"new",outboxMessageId:t,onDraftCreated:i,onClose:s})})]})]}),e.jsx(S,{isOpen:l,title:"Discard draft?",description:"Your message has unsaved content. Are you sure you want to discard it?",confirmLabel:"Discard",cancelLabel:"Keep editing",destructive:!0,onConfirm:y,onCancel:v})]})},K=()=>{const t=p(),i=h(),s=b(),a=k(),{isError:l,error:o,refetch:d}=f({...m(),staleTime:1/0});if(E({bindings:[{key:"Escape",handler:s,preventDefault:!0}]}),!a)return e.jsx(O,{});const c=e.jsxs("header",{className:"flex items-center justify-between gap-2 px-4 py-3 border-b border-line shrink-0",children:[e.jsx("div",{className:"flex items-center gap-2 min-w-0",children:e.jsx("h2",{className:"text-lg font-semibold truncate",children:C(t)})}),e.jsx("button",{type:"button",onClick:s,className:"p-2 rounded-md hover:bg-surface-raised transition-colors min-h-11 min-w-11 inline-flex items-center justify-center","aria-label":"Close",children:e.jsx(w,{className:"size-5"})})]});return l?e.jsxs("div",{className:"h-full flex flex-col bg-canvas",children:[c,e.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:e.jsx(u,{title:"Couldn't load compose",error:o,onRetry:()=>{d()}})})]}):e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-canvas",children:[c,e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(x,{mode:"new",outboxMessageId:t,onDraftCreated:i,onClose:s})})]})};export{K as F};
@@ -1 +1 @@
1
- import{f as g,am as f,g as b,z as y,C as v,cu as x,ek as C,r as p,dw as L,j as c,el as d,em as h,en as k}from"./index-CXzCthHG.js";import{c as M}from"./popover-menu-CTiORP1p.js";import{al as E}from"./MessageToolbar-CvC2dLSg.js";import{a as A}from"./useLabels-CN56tbCw.js";const I=3,z=({hasSearchQuery:e,freeText:t,residualTokenCount:s})=>{if(!e||s>0)return!1;const a=t.trim();return a.length===0||a.length>=I},S=e=>e===void 0?{kind:"unknown"}:{kind:"exact",value:e},_=e=>{const t=new Set;for(const s of e)s&&t.add(s);return t.size>1?{accountId:void 0,restriction:"spansAccounts",moveDisabledHint:"Move only works within one account — clear selection or pick messages from a single account"}:{accountId:t.size===1?[...t][0]:void 0,restriction:void 0,moveDisabledHint:void 0}},j=e=>{const{mailboxId:t,messages:s}=e,a=g(),{pushError:l}=f(),{mutateAsync:r,isPending:o}=b({...C(),onError:(n,i)=>{l({title:i.body.action==="Remove"?"Couldn't remove label":"Couldn't apply label",detail:x(n),error:n})},onSettled:(n,i,u)=>{y(a,v(E(u.body.messageIds??[],s??[],t)))}});return{applyLabel:p.useCallback((n,i,u)=>{n.length!==0&&L(n,m=>r({body:{messageIds:m,labelId:i,action:u}}))},[r]),isPending:o}};function H({accountId:e,mailboxId:t,messageIds:s}){const{labels:a}=A(e),{applyLabel:l}=j({mailboxId:t}),r=p.useMemo(()=>a.map(o=>({key:o.labelId,label:o.name,icon:c.jsx("span",{className:`size-2.5 rounded-full ${h(o.color)?d[o.color]:d.Default}`}),onSelect:()=>l(s,o.labelId,"Apply")})),[a,s,l]);return r.length===0?null:c.jsx(M,{triggerLabel:"Apply label to selected messages",triggerIcon:c.jsx(k,{className:"size-4 text-fg-subtle"}),triggerText:"Apply label",items:r,align:"start",nested:!0,touch:!1,triggerClassName:"min-h-11 w-full justify-start gap-3 px-4 py-2.5 text-sm font-normal text-fg"})}export{H as L,_ as r,z as s,S as t};
1
+ import{f as g,ao as f,g as b,U as y,V as v,cS as x,eY as L,r as p,e6 as h,j as c,eZ as d,e_ as C,e$ as k}from"./index-CL_fwLHN.js";import{c as M}from"./popover-menu-fjlAfNO1.js";import{ak as E}from"./MessageToolbar-UJadqHyA.js";import{a as A}from"./useLabels-BZFMPVjT.js";const I=3,_=({hasSearchQuery:e,freeText:t,residualTokenCount:s})=>{if(!e||s>0)return!1;const a=t.trim();return a.length===0||a.length>=I},w=e=>e===void 0?{kind:"unknown"}:{kind:"exact",value:e},z=e=>{const t=new Set;for(const s of e)s&&t.add(s);return t.size>1?{accountId:void 0,restriction:"spansAccounts",moveDisabledHint:"Move only works within one account — clear selection or pick messages from a single account"}:{accountId:t.size===1?[...t][0]:void 0,restriction:void 0,moveDisabledHint:void 0}},j=e=>{const{mailboxId:t,messages:s}=e,a=g(),{pushError:l}=f(),{mutateAsync:r,isPending:o}=b({...L(),onError:(n,i)=>{l({title:i.body.action==="Remove"?"Couldn't remove label":"Couldn't apply label",detail:x(n),error:n})},onSettled:(n,i,u)=>{y(a,v(E(u.body.messageIds??[],s??[],t)))}});return{applyLabel:p.useCallback((n,i,u)=>{n.length!==0&&h(n,m=>r({body:{messageIds:m,labelId:i,action:u}}))},[r]),isPending:o}};function U({accountId:e,mailboxId:t,messageIds:s}){const{labels:a}=A(e),{applyLabel:l}=j({mailboxId:t}),r=p.useMemo(()=>a.map(o=>({key:o.labelId,label:o.name,icon:c.jsx("span",{className:`size-2.5 rounded-full ${C(o.color)?d[o.color]:d.Default}`}),onSelect:()=>l(s,o.labelId,"Apply")})),[a,s,l]);return r.length===0?null:c.jsx(M,{triggerLabel:"Apply label to selected messages",triggerIcon:c.jsx(k,{className:"size-4 text-fg-subtle"}),triggerText:"Apply label",items:r,align:"start",nested:!0,touch:!1,triggerClassName:"min-h-11 w-full justify-start gap-3 px-4 py-2.5 text-sm font-normal text-fg"})}export{U as L,z as r,_ as s,w as t};
@@ -0,0 +1 @@
1
+ import{l as v}from"./reply-DvdgFS16.js";import{j as r,r as u,A as l,ac as p}from"./index-CL_fwLHN.js";import{a as m}from"./useMessageBodyContent-D-LJBFh4.js";import{F as x}from"./FullCompose-Djp_h4BT.js";function d(o,n,s){if(o!==n)return s}function j(o,n){return o===""?"":n}function C({searchInput:o,committedQuery:n,urlQuery:s,pathname:t,listPath:a}){return!v(t,a)||n!==o?!1:n!==s}const c=u.createContext(null),M=({chrome:o,children:n})=>r.jsx(c.Provider,{value:o,children:n});function N({phone:o,list:n,reading:s,intelligence:t,hasThread:a=!1}){const e=u.useContext(c),f=m();if(!e)return r.jsx(l,{});const i={nav:e.nav,overlay:e.overlay,skeleton:r.jsx(l,{}),isLoading:e.isLoading,navOpen:e.navOpen,onOpenNav:e.onOpenNav,onCloseNav:e.onCloseNav};return e.isSinglePane?r.jsx(p,{...i,list:f?r.jsx(x,{}):o,intelligenceOpen:e.intelligenceOpen}):r.jsx(p,{...i,topBar:e.topBar,list:n,reading:s,intelligence:t,intelligenceOpen:e.intelligenceOpen,hasThread:a})}export{M,N as a,C as b,j as c,d as s};
@@ -0,0 +1 @@
1
+ import{j as s,L as oe,d as A,w as ce,r as f,dW as le,o as U,aw as de,aa as ue,T as fe,dK as me,eT as xe,dO as ge,da as he,eU as pe,eV as be,eW as ve,P as je,eX as we,dP as Ne}from"./index-CL_fwLHN.js";import{j as ye,n as Re}from"./search-token-index-B1HU1d2-.js";import{u as Pe,L as X}from"./roving-focus-FWOr5tBU.js";import{a6 as Ce,c as Se,C as G,a7 as Ee,a8 as ke,a9 as Me,aa as Te,ab as Oe,ac as Ie,o as Le,ad as De,ae as Ae,af as $e,ag as ze,ah as _e,ai as Y,aj as Fe}from"./MessageToolbar-UJadqHyA.js";import{A as He}from"./avatar-uWJajuSb.js";import{R as We}from"./refresh-cw-5OKnYRBy.js";import{M as Be}from"./menu-CcLh9Whg.js";function Ke(){return s.jsx("div",{className:"space-y-0",role:"status","aria-busy":"true","aria-label":"Loading messages",children:Array.from({length:8}).map((e,t)=>s.jsxs("div",{className:"animate-pulse border-b border-line px-3 py-2",children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[s.jsx("div",{className:"h-4 w-32 rounded bg-surface-sunken"}),s.jsx("div",{className:"h-3 w-16 rounded bg-surface-sunken"})]}),s.jsx("div",{className:"mb-2 h-4 w-48 rounded bg-surface-sunken"}),s.jsx("div",{className:"h-3 w-full rounded bg-surface-sunken"})]},t))})}function Ue({filter:e,scopeLabel:t,searchQuery:n}){const l=n?.trim();return e?s.jsxs(Q,{children:[s.jsx("p",{className:"font-medium text-fg",children:Qe(e.label,t,l)}),s.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:Xe[e.reach]}),s.jsx(A,{variant:"secondary",size:"sm",className:"mt-4",onClick:e.onClear,children:"Clear filter"})]}):s.jsx(Q,{children:s.jsx("p",{className:"text-fg-muted",children:Ge(l,t)})})}const Xe={"whole-folder":"Every message in this folder was checked.","loaded-pages":"Only the messages loaded so far were checked."};function Ge(e,t){return e?"No messages match your search":t?`No messages in ${t}`:"No messages in this mailbox"}function Qe(e,t,n){return n?`No results for “${n}” in ${e}`:t?`No ${e} in ${t}`:`No ${e}`}function Q({children:e}){return s.jsx("div",{className:"flex h-full flex-1 items-center justify-center",children:s.jsx("div",{className:"flex max-w-sm flex-col items-center justify-center p-8 text-center",children:e})})}function ms(){return s.jsxs("div",{className:"flex items-center justify-center gap-2 py-4 text-sm text-fg-muted",role:"status","aria-live":"polite",children:[s.jsx(oe,{className:"size-4 animate-spin","aria-hidden":"true"}),s.jsx("span",{children:"Loading more…"})]})}function Ve({message:e="Something went wrong loading this mailbox.",onRetry:t,onReport:n}){return s.jsx("div",{className:"flex h-full flex-1 items-center justify-center p-4",children:s.jsxs("div",{role:"alert",className:"flex max-w-sm flex-col items-center justify-center gap-3 text-center",children:[s.jsx(ce,{className:"size-8 text-danger","aria-hidden":"true"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium text-danger",children:"Couldn't load messages"}),s.jsx("p",{className:"mt-1 break-words text-sm text-fg-muted",children:e})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[t&&s.jsx(A,{variant:"secondary",size:"sm",onClick:t,children:"Retry"}),n&&s.jsx(A,{variant:"ghost",size:"sm",onClick:n,children:"Report a problem"})]})]})})}const O=72;function V(e){return e==="leading"?O:e==="trailing"?-O:0}function Ye(e){return e>=O/2?"leading":e<=-O/2?"trailing":"none"}function qe({thread:e,selectionMode:t,checked:n,active:l,peek:d,onPeek:o,onToggleCheck:x,onLongPress:w,onOpen:g,onAct:h}){const[p,N]=f.useState(null),b=f.useRef(null),m=f.useRef(!1),P=i=>{b.current=i,N(i)},v=i=>{const E=b.current,I=m.current;if(m.current=!1,P(null),!(i.event.type.endsWith("cancel")||I)){if(i.tap){if(t){x();return}if(d!=="none"){o("none");return}g();return}i.axis!=="x"||t||E===null||o(Ye(E))}},R=le(i=>{if(!i.down){v(i);return}if(Oe(i)){if(t)return;m.current=!0,Ie(),w();return}if(!i.intentional||t||m.current||i.axis!=="x")return;const E=i.values[0]-i.initial[0];P(Math.max(-O,Math.min(O,V(d)+E)))},{...Me(Te),tapsThreshold:xe,axisThreshold:me.axisThreshold}),y=Ce(R(),ke,{"aria-description":t?void 0:"Select message"}),j=p??V(d),a=j>0?"leading":j<0?"trailing":"none",u=U("relative touch-pan-y bg-surface","select-none",Se({active:n||l})),C={transform:j!==0?`translateX(${j}px)`:void 0,transition:p===null?"transform 150ms ease":"none",minHeight:44},S=!e.isRead,M=i=>i.stopPropagation(),$=t?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:U("inline-flex size-7 shrink-0 items-center justify-center rounded-full border",n?"border-accent bg-accent text-accent-fg":"border-line-strong bg-canvas"),children:n&&s.jsx(de,{className:"size-3.5"})}),s.jsx(G,{thread:e})]}):s.jsxs(s.Fragment,{children:[S&&s.jsx("span",{className:"absolute left-1.5 top-1/2 size-1.5 -translate-y-1/2 rounded-full bg-accent"}),s.jsx("span",{role:"checkbox",tabIndex:0,"aria-checked":n,"aria-label":`Select message from ${e.fromName}`,onPointerDown:M,onPointerMove:M,onPointerUp:M,onClick:i=>{i.preventDefault(),i.stopPropagation(),w()},onKeyDown:i=>{i.key!=="Enter"&&i.key!==" "||(i.preventDefault(),i.stopPropagation(),w())},className:"-m-2 inline-flex size-11 shrink-0 items-center justify-center rounded-full",children:s.jsx(He,{name:e.fromName,email:e.fromEmail,size:"sm"})}),s.jsx(G,{thread:e})]});return s.jsxs("div",{className:"relative overflow-hidden",children:[a==="leading"&&s.jsx("button",{type:"button",onClick:()=>h("leading"),"aria-label":e.isRead?"Mark as unread":"Mark as read",className:"absolute inset-y-0 left-0 flex items-center justify-start bg-accent-2 px-6 text-accent-fg",children:e.isRead?s.jsx(ue,{className:"size-6"}):s.jsx(Ee,{className:"size-6"})}),a==="trailing"&&s.jsx("button",{type:"button",onClick:()=>h("trailing"),"aria-label":"Delete message",className:"absolute inset-y-0 right-0 flex items-center justify-end bg-danger px-6 text-canvas",children:s.jsx(fe,{className:"size-6"})}),s.jsx("button",{type:"button",role:t?"checkbox":void 0,"aria-checked":t?n:void 0,"data-message-row":!0,"data-message-id":e.id,...y,className:u,style:C,children:$})]})}function Je({sections:e,selectedThreadId:t,selectionMode:n,checkedIds:l,initialPeek:d,onToggleCheck:o,onEnterSelection:x,onOpenThread:w,onRefresh:g,refreshing:h,busy:p=!1}){const[N,b]=f.useState(new Set),[m,P]=f.useState(new Map),v=e.flatMap(a=>a.threads).filter(a=>!N.has(a.id)).map(a=>{const u=m.get(a.id);return u===void 0?a:{...a,isRead:u}}),[R,y]=f.useState(d&&d!=="none"&&v[1]?{id:v[1].id,side:d}:null),j=(a,u)=>{if(u==="trailing")b(C=>new Set(C).add(a));else{const C=v.find(S=>S.id===a);P(S=>new Map(S).set(a,!C?.isRead))}y(null)};return s.jsxs("div",{className:"flex-1 overflow-y-auto",children:[h&&s.jsxs("div",{className:"flex items-center justify-center gap-2 border-b border-line py-3 text-fg-muted",children:[s.jsx(We,{className:"size-4 animate-spin"}),s.jsx("span",{className:"text-xs",children:"Checking for new mail…"})]}),s.jsx("div",{className:"divide-y divide-line",children:v.map(a=>s.jsx("div",{className:p?"pointer-events-none opacity-50":void 0,children:s.jsx(qe,{thread:a,selectionMode:n,checked:l.has(a.id),active:a.id===t,peek:R?.id===a.id?R.side:"none",onPeek:u=>y(u==="none"?null:{id:a.id,side:u}),onToggleCheck:()=>o(a.id),onLongPress:()=>x(a.id),onOpen:()=>w(a.id),onAct:u=>j(a.id,u)})},a.id))}),!n&&!h&&!p&&s.jsx("button",{type:"button",onClick:g,className:"w-full border-t border-line py-2 text-center text-2xs text-fg-subtle transition-colors hover:bg-surface-sunken",children:"Pull to refresh"})]})}const Ze=new Set;function xs({listTitle:e,listMeta:t,sections:n,briefFilters:l,flatList:d,listState:o="ready",searchQuery:x,listFilter:w,listScopeLabel:g,errorMessage:h,onRetry:p,onReportError:N,briefFilter:b,selectedThreadId:m,density:P="comfortable",onSelectThread:v,onOpenNav:R,isDesktop:y,initialTouchState:j,selection:a,keyboard:u,selectionBar:C,paneOverlay:S,listBody:M,hideHeader:$=!1}){const i=P==="compact"?Ae:$e,E=f.useRef(null),I=f.useRef(null),T=ge(u);Pe({containerRef:E,itemSelector:X,enabled:!T});const k=T?u.focusedId:void 0,z=T?k??n[0]?.threads[0]?.id:void 0,_=f.useCallback(r=>z===void 0?void 0:r===z?0:-1,[z]);f.useEffect(()=>{if(k===void 0)return;const r=I.current;if(!r)return;const c=r.querySelector(`${X}[data-message-id="${k}"]`);!c||c===r.ownerDocument.activeElement||c.focus({preventScroll:!1})},[k]),f.useEffect(()=>{if(!T)return;const r=I.current;if(!r)return;const c=r.ownerDocument.activeElement;c!==null&&c!==r.ownerDocument.body||r.focus({preventScroll:!0})},[T]);const ee=!y&&!l&&o==="ready",[se,B]=f.useState(!1),te=j==="peek-trailing"?"trailing":j==="peek-leading"?"leading":void 0,ne=()=>{B(!0),setTimeout(()=>B(!1),1400)},D=a?.selectedIds??Ze,L=a?.onToggle,K=a?.onRowSelect,re=Le(D.size,y),F=f.useCallback(r=>{if(L)return{checked:D.has(r),onToggle:c=>{c.preventDefault(),c.stopPropagation(),L(r)}}},[D,L]),H=f.useCallback((r,c)=>K?.(r,De(c))?(c.preventDefault(),c.shiftKey&&window.getSelection()?.removeAllRanges(),!0):!1,[K]),ae=f.useCallback(({thread:r,active:c,onClick:W})=>s.jsx(i,{thread:r,active:c,focused:r.id===k,tabIndex:_(r.id),selection:F(r.id),onClick:ie=>{H(r.id,ie)||W?.()}}),[i,F,H,k,_]);return s.jsxs("section",{ref:r=>{I.current=r,u?.ref(r)},tabIndex:T?-1:void 0,className:"relative flex h-full w-full flex-col bg-surface outline-none",children:[C??($?null:s.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[R&&s.jsx(A,{variant:"ghost",size:"sm",icon:s.jsx(Be,{className:"size-4"}),onClick:R,"aria-label":"Open folders",className:"-ml-1 shrink-0"}),s.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:e}),t&&s.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle",children:t})]})),o==="loading"?s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsx(Ke,{})}):o==="empty"?s.jsx(Ue,{filter:w,scopeLabel:g,searchQuery:x}):o==="error"?s.jsx(Ve,{message:h,onRetry:p,onReport:N}):l&&b?s.jsx(ze,{...b,sections:n,selectedThreadId:m,Row:ae,keyboard:u,onSelectThread:v}):M??(ee?s.jsx(Je,{sections:n,selectedThreadId:m,selectionMode:re,checkedIds:D,initialPeek:te,onToggleCheck:r=>L?.(r),onEnterSelection:r=>L?.(r),onOpenThread:r=>v?.(r),onRefresh:ne,refreshing:se}):s.jsx("div",{ref:E,className:"flex-1 overflow-y-auto",children:n.map(r=>s.jsxs("div",{children:[!d&&r.label&&s.jsxs("div",{className:"sticky top-0 flex h-section-row items-center justify-between border-b border-line bg-surface-sunken px-row-inset",children:[s.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:r.label}),s.jsx("span",{className:"text-2xs text-fg-subtle tabular-nums",children:r.threads.length})]}),s.jsx("div",{className:"divide-y divide-line",children:r.threads.map(c=>s.jsx(i,{thread:c,active:c.id===m,focused:c.id===k,tabIndex:_(c.id),selection:F(c.id),onClick:W=>{H(c.id,W)||v?.(c.id)}},c.id))})]},r.id))})),y&&s.jsx(_e,{hints:u?Re(u.handlers):ye}),S]})}var es=class extends he{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type="infinite",super.setOptions(e)}getOptimisticResult(e){return e._type="infinite",super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){const{state:n}=e,l=super.createResult(e,t),{isFetching:d,isRefetching:o,isError:x,isRefetchError:w}=l,g=n.fetchMeta?.fetchMore?.direction,h=x&&g==="forward",p=d&&g==="forward",N=x&&g==="backward",b=d&&g==="backward";return{...l,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:be(t,n.data),hasPreviousPage:pe(t,n.data),isFetchNextPageError:h,isFetchingNextPage:p,isFetchPreviousPageError:N,isFetchingPreviousPage:b,isRefetchError:w&&!h&&!N,isRefetching:o&&!p&&!b}}};function gs(e,t){return ve(e,es)}const q={dimension:"read",position:"pre",text:"unread"},ss={dimension:"read",position:"pre",text:"read"},J={dimension:"starred",position:"pre",text:"starred"},Z={dimension:"attachment",position:"post",text:"with an attachment"},ts=[["unread",q],["flagged",J],["attachment",Z]],ns=e=>{switch(e.type){case"category":return{dimension:"category",position:"pre",text:Y(e.category)??e.value};case"isUnread":return q;case"isRead":return ss;case"isStarred":return J;case"hasAttachment":return Z;case"from":return{dimension:e.raw,position:"post",text:`from ${e.value}`};case"subject":return{dimension:e.raw,position:"post",text:`about “${e.value}”`};case"before":return{dimension:e.raw,position:"post",text:`sent before ${e.value}`};case"after":return{dimension:e.raw,position:"post",text:`sent on or after ${e.value}`};case"in":return{dimension:e.raw,position:"post",text:`in ${e.value}`};case"account":return{dimension:e.raw,position:"post",text:`in the ${e.value} account`}}},rs=(e,t)=>{const n=new Map,l=o=>{n.has(o.dimension)||n.set(o.dimension,o)},d=Y(e.category);d&&l({dimension:"category",position:"pre",text:d});for(const[o,x]of ts)e.attributes.has(o)&&l(x);for(const o of t)l(ns(o));return[...n.values()]},as=(e,t)=>{const n=rs(e,t);if(n.length===0)return;const l=d=>n.filter(o=>o.position===d).map(o=>o.text);return[...l("pre"),"mail",...l("post")].join(" ")},hs=({chips:e,tokens:t,reach:n,onClear:l})=>{const d=as(e,t);if(d)return{label:d,reach:n,onClear:l}};function ps({title:e,unreadCount:t,preset:n,selectedCategory:l,activeFilters:d,onSelectCategory:o,onToggleFilter:x,onSelectSource:w,onClearFilters:g,children:h,footer:p,searchResults:N,searchLoading:b,onSelectSearchResult:m,searchResultsLabel:P,searchResultsInBody:v,refreshControl:R}){const{searchInput:y}=je(),j=y.trim().length>0,a={categories:n.categories,filters:n.filters,sources:n.sources,selectedCategory:l,activeFilters:d,onSelectCategory:o,onSelectSource:w,onToggleFilter:x,onClear:g};return s.jsx(we,{hasSheet:!j,children:s.jsx(Fe,{title:e,unreadCount:t,footer:p,searchFilter:a,searchResults:N,searchLoading:b,onSelectSearchResult:m,searchResultsLabel:P,searchResultsInBody:v,refreshControl:R,children:s.jsx(Ne,{...a,hideChrome:j,children:h})})})}export{ms as M,qe as S,xs as a,ps as b,hs as l,gs as u};
@@ -0,0 +1 @@
1
+ import{j as r,bK as Ms,dk as Rs,B as ft,d as G,o as je,e as Vt,r as c,t as Es,v as Os,bj as As,f as jt,ao as qt,dl as Ns,l as zs,g as Mt,U as Fs,V as Ds,a4 as Ht,dm as _s,cS as Ls,s as Ps,dn as $s,a as mt,dp as Bs,dq as Qt,dr as Ut,ds as Ye,Z as Ws,dt as Ks,d3 as Vs,I as qs,E as Hs,T as Jt,du as Qs,dv as Gt,c6 as Us,dw as Js,dx as Gs,dy as Ys,dz as Xs,aC as Zs,aD as en,dA as tn,dB as sn,n as Rt,k as nn,bg as on,Y as rn,bh as an,bi as ln,P as Yt,a1 as cn,bu as un}from"./index-CL_fwLHN.js";import{u as dn,p as Lt,R as hn}from"./MessageBody-C89PSL_p.js";import{u as fn,a as mn,R as gn}from"./useRefreshControl-B6YIG0w2.js";import{u as Xt,r as pn,a as Et,C as Zt,c as es,j as xn,M as bn,t as ts,b as vn,d as Sn,e as ss,f as ns,g as yn,h as Cn,i as In,n as Tn,k as kn,S as wn,l as jn,D as Mn,m as Rn,o as En,p as os,q as On,s as An,v as Nn,w as zn,x as Fn,y as Dn,z as _n,A as Ln,B as Pn,E as $n,F as Bn,G as Wn,H as Pt,I as $t,J as Kn,K as Vn,L as qn,N as Hn,O as Qn,P as Un,Q as Jn,R as Gn,T as Yn,U as Xn,V as Zn,W as Ot,X as eo,Y as is,Z as rs,_ as as,$ as to,a0 as so,a1 as no,a2 as oo,a3 as io,a4 as ro,a5 as ao}from"./MessageToolbar-UJadqHyA.js";import{S as lo,M as co,a as uo,u as ho,l as fo,b as mo}from"./MailViewChrome-yffBJjbO.js";import{e as Xe,f as go,g as po,h as xo,i as bo}from"./search-token-index-B1HU1d2-.js";import{u as vo}from"./useLayoutTier-DrLg7_rq.js";import{t as So,L as yo,r as Co,s as Io}from"./LabelApplyTrigger-oS5sxATE.js";import{P as To,N as ko,n as wo}from"./NavMenuButton-B-goW-G5.js";import{n as jo,r as Mo,h as Ro}from"./reply-DvdgFS16.js";import{d as Eo,g as Oo,a as Ao,u as No}from"./useMessageBodyContent-D-LJBFh4.js";import{u as zo}from"./sections-Rf3k05-_.js";import{A as At}from"./avatar-uWJajuSb.js";import{C as Fo}from"./confirm-dialog-q8tbS_22.js";import{f as Do}from"./ErrorState-KjDYblD5.js";import{f as _o}from"./calendar-tMekVEGW.js";import{a as Lo}from"./useLabels-BZFMPVjT.js";import{a as Po,D as $o,u as Bo}from"./useMediaQuery-DiQ0fGER.js";import{S as gt}from"./shield-check-CdR23I2B.js";import{B as Wo}from"./bottom-sheet-Bc0vwv2J.js";import{C as ls}from"./checkbox-CGG1nAhQ.js";import{S as Ko}from"./sparkles-Bcn4ZRhZ.js";import{C as Vo}from"./circle-help-CVWHf1ow.js";import{C as qo}from"./circle-check-i3jeyeTf.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(Ms,{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})=>Po($o)?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(G,{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",cs=({senderTrust:e,size:o="sm",className:t})=>{const s=Xo(e,o);return s==="vip"?r.jsx(Ko,{className:je("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:je("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:je("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(ls,{className:"mt-0.5",checked:o,onChange:t,"aria-label":`${o?"Deselect":"Select"} ${s?l:`message from ${n}`}`}),!s&&r.jsx(At,{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(cs,{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(Vt,{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"},Bt=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?Es:Os;return r.jsxs("div",{className:je(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(ls,{className:"mt-0.5",checked:l==="all",indeterminate:l==="some",onChange:()=>t(e,l!=="all"),"aria-label":`${l==="all"?"Deselect":"Select"} all ${a} ${Bt(a)} from ${e.senderName}`}),r.jsx(At,{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(cs,{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(Vt,{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} ${Bt(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 Nt=e=>e===1?"message":"messages",ni=(e,o)=>`Moves ${e===1?"this message":`these ${e} ${Nt(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(G,{variant:"ghost",size:"sm",icon:r.jsx(Vo,{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(G,{variant:"ghost",size:"sm",onClick:n,children:"Select all"}),r.jsx(G,{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(G,{variant:"primary",onClick:l,className:"h-11 w-full font-semibold",children:`Continue with ${h} ${Nt(h)}`}),r.jsx(G,{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(As,{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(G,{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(G,{variant:"primary",onClick:i,className:"h-11 w-full font-semibold",children:`Move ${e} out of Spam`}),r.jsx(G,{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(qo,{className:"size-10 text-positive","aria-hidden":!0}),r.jsx("p",{className:"text-base font-semibold text-fg",children:`Moved ${e} ${Nt(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(G,{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(T=>T.id)):new Set),[g,m]=c.useState(t),[b,y]=c.useState(0),v=c.useRef(!1);c.useEffect(()=>{e&&!v.current&&(u("review"),h(new Set(o.map(T=>T.id))),m(t),y(0)),v.current=e},[e,o,t]);const I=d.size,p=T=>{h(w=>{const O=new Set(w);return O.has(T)?O.delete(T):O.add(T),O})},x=(T,w)=>{h(O=>{const A=new Set(O);for(const $ of T.messages)w?A.add($.id):A.delete($.id);return A})},j=()=>{const T=Array.from(d);y(T.length),i(T,g),u("done")};return r.jsxs(Wo,{open:e,onClose:l,label:"Rescue from spam",dismissLabel:"Close rescue",children:[a==="review"&&r.jsx(ii,{candidates:o,selected:d,onToggle:p,onToggleGroup:x,onSelectAll:()=>h(new Set(o.map(T=>T.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:b,destinationLabel:wt(s,g),onClose:l})]})}const ci=(e,o,t,s)=>`${e??""}|${o}|${t??""}|${s??""}`,ui=({accountId:e,mailboxId:o})=>{const t=jt(),{pushError:s}=qt(),{requestAppointment:n}=Ns(),{trashByAccount:i}=Xt(),l=e?i.get(e):void 0,a=ci(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(zs())?.accounts.find(w=>w.accountId===e)?.folderAppointments.find(w=>w.role==="Trash")?.mailboxId??o,[t,e,o]),m=c.useRef(void 0),{mutateAsync:b,isPending:y}=Mt({...$s(),meta:Ps(409),onMutate:()=>(m.current=a,{scope:a,listMailboxId:g()}),onSuccess:(x,j,T)=>{T.scope===a&&d({scope:a,deletedCount:x.deletedCount})},onError:(x,j,T)=>{const w=_s(x);if(!w){s({title:"Couldn't empty Trash",detail:Ls(x),error:x});return}T?.scope===a&&d({scope:a,refusal:w})},onSettled:(x,j,T,w)=>{m.current===w?.scope&&(m.current=void 0),Fs(t,Ds([w?.listMailboxId??o])),e&&t.invalidateQueries({queryKey:Ht({path:{accountId:e}})})}}),v=c.useCallback(()=>e?(d({scope:a}),b({path:{accountId:e}}).then(()=>{},()=>{})):Promise.resolve(),[e,a,b]),I=c.useCallback(()=>{v()},[v]),p=c.useCallback(()=>{const x=h?.refusal;x&&n({accountId:x.accountId,role:x.role,reason:x.reason,action:{kind:"emptyTrash"},onAppointed:v})},[h,n,v]);return{emptyTrash:I,isEmptying:y&&m.current===a,deletedCount:h?.deletedCount,refusal:h?.refusal,repair:p}},di="We can verify this sender";function hi(e){const{data:o}=mt({...Bs({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:di,trustSubReason:pn(s.senderTrust),senderTrust:s.senderTrust}))}}const fi=6e4,mi=({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:fi});return t?So(n?.count):{kind:"unknown"}},gi=e=>{const o=new Set,t=[];for(const s of e)o.has(s.threadMessageId)||(o.add(s.threadMessageId),t.push(s));return t};function pi(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:Ye(e.updatedAt),isRead:!0}}function xi(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:Ye(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,...Et(e)}}function bi({outboxMessages:e,accountId:o,imapThreads:t}){const s=e.filter(l=>l.status==="draft"&&l.accountId===o).map(pi),n=t.map(xi),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 vi=({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})]}),Si=({row:e,isSelected:o,onOpen:t,onDelete:s,isDeleting:n})=>r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:je("group",es({active:o})),children:[r.jsx(Hs,{className:"size-7 shrink-0 text-fg-muted mt-0.5"}),r.jsx(Zt,{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(Jt,{className:"size-3.5"})})})]}),yi=({row:e,isSelected:o,onOpen:t})=>{const s=!e.isRead;return r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:je("group",es({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(At,{name:e.fromName,email:e.fromEmail,size:"sm"}),r.jsx(Zt,{thread:e})]})};function Ci({accountId:e,selectedMessageId:o,imapThreads:t,title:s,unreadCount:n}){const i=Eo(),l=Oo(),a=Xe(),u=jt(),{data:d}=mt(Ws()),h=c.useMemo(()=>bi({outboxMessages:d?.items??[],accountId:e,imapThreads:t}),[d?.items,e,t]),g=Mt({...Vs(),onSuccess:()=>{u.invalidateQueries({queryKey:Ks()})}}),m=v=>{g.mutate({path:{outboxMessageId:v}})},b=v=>{const I=t.find(p=>p.messageId===v)?.threadId;I&&a({threadId:I,messageId:v})},y=h.length===0;return r.jsxs("section",{className:"flex h-full w-full flex-col bg-surface",children:[r.jsx(To,{title:s,leading:r.jsx(ko,{}),children:(n??0)>0&&r.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:[n," unread"]})}),r.jsx("div",{className:"flex-1 overflow-y-auto",children:y?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 text-center px-4",children:[r.jsx(qs,{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(v=>r.jsxs("div",{children:[v.label&&r.jsx(vi,{label:v.label,count:v.threads.length}),r.jsx("div",{className:"divide-y divide-line",children:v.threads.map(I=>v.id==="remit-drafts"?r.jsx(Si,{row:I,isSelected:I.id===i,onOpen:l,onDelete:m,isDeleting:g.isPending},I.id):r.jsx(yi,{row:I,isSelected:I.id===o,onOpen:b},I.id))})]},v.id))})]})}const us=e=>e===1?"1 message":`${Gt(e)} messages`,Ii=e=>({title:"Empty Trash?",description:`${us(e)} ${e===1?"is":"are"} erased from the mail server and cannot be restored.`,confirmLabel:"Empty Trash"}),Ti=(e,o={})=>{const{trashFolderLabel:t,staleFolderLabel:s}=o;if(e==="unconfirmed"){const n=Qs(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 ki({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?Ti(s,{trashFolderLabel:n,staleFolderLabel:i}):void 0,m=Ii(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:`${us(t)} erased from the mail server.`}),r.jsx(G,{variant:"ghost",size:"sm",icon:r.jsx(Jt,{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(G,{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(Fo,{isOpen:d,title:m.title,description:m.description,confirmLabel:m.confirmLabel,destructive:!0,onConfirm:()=>{h(!1),l()},onCancel:()=>h(!1)})]})}function wi(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 _e(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 Wt(e,o){if(e===void 0)throw new Error("Unexpected undefined");return e}const ji=(e,o)=>Math.abs(e-o)<1.01,Mi=(e,o,t)=>{let s;return function(...n){e.clearTimeout(s),s=e.setTimeout(()=>o.apply(this,n),t)}};let Ge;const Tt=()=>{if(Ge!==void 0)return Ge;if(typeof navigator>"u")return Ge=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Ge=!0;const e=navigator.maxTouchPoints;return Ge=navigator.platform==="MacIntel"&&e!==void 0&&e>0},Kt=e=>{const{offsetWidth:o,offsetHeight:t}=e;return{width:o,height:t}},Ri=e=>e,Ei=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},Oi=(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(Kt(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(Kt(t))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return i.observe(t,{box:"border-box"}),()=>{i.unobserve(t)}},ht={passive:!0},Ai=typeof window>"u"?!0:"onscrollend"in window,Ni=(e,o,t)=>{const s=e.scrollElement;if(!s)return;const n=e.targetWindow;if(!n)return;const i=e.options.useScrollendEvent&&Ai;let l=0;const a=i?null:Mi(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)}},zi=(e,o)=>Ni(e,o,t=>{const{horizontal:s,isRtl:n}=e.options;return s?t.scrollLeft*(n&&-1||1):t.scrollTop}),Fi=(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"]},Di=(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})},_i=Di;class Li{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:Ri,rangeExtractor:Ei,onChange:()=>{},measureElement:Fi,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 b=t[m];b!==void 0&&(i[m]=b)}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,b=i.count,y=this.getMeasurements(),v=m>0?((s=y[0])==null?void 0:s.key)??l.getItemKey(0):null,I=m>0?((n=y[m-1])==null?void 0:n.key)??l.getItemKey(m-1):null;if(b!==m||m>0&&b>0&&(i.getItemKey(0)!==v||i.getItemKey(b-1)!==I)){d=!0;const j=m>0?this.getVirtualItemForOffset(this.getScrollOffset())??y[0]:null;j&&(a=[j.key,this.getScrollOffset()-j.start]);const T=i.followOnAppend===!0?"auto":i.followOnAppend||null;T&&b>m&&this.isAtEnd(l.scrollEndThreshold)&&(m===0||i.getItemKey(b-1)!==I)&&(u=T)}}this.options=i,d&&(this.pendingMin=0,this.itemSizeCacheVersion++);let h=!1,g=0;if(a&&this.scrollOffset!==null){const[m,b]=a,y=this.getMeasurements(),{count:v,getItemKey:I}=this.options;let p=0;for(;p<v&&I(p)!==m;)p++;if(p<v){const x=y[p];if(x){const j=x.start+b;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=_e(()=>(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,!(!Tt()||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&&(Tt()&&(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=_e(()=>[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=_e(()=>[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 p of this.laneAssignments.keys())p>=t&&this.laneAssignments.delete(p);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(p=>{this.itemSizeCache.set(p.key,p.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 p=t*2;let x=this._flatMeasurements;if(!x||x.length<p){const w=new Float64Array(p);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),$=typeof A=="number"?A:this.options.estimateSize(w);x[w*2]=j,x[w*2+1]=$,j+=$+d}const T=wi(t,x,i);return this.measurementsCache=T,T}const b=this.measurementsCache.slice(0,m),y=new Array(a).fill(void 0),v=new Float64Array(a);let I=0;for(let p=0;p<m;p++){const x=b[p];x&&(y[x.lane]===void 0&&I++,y[x.lane]=p,v[x.lane]=x.end)}for(let p=m;p<t;p++){const x=i(p),j=this.laneAssignments.get(p);let T,w;const O=u==="estimate"||g.has(x);if(j!==void 0&&this.options.lanes>1){T=j;const J=y[T],R=J!==void 0?b[J]:void 0;w=R?R.end+d:s+n}else if(I===a){let J=0,R=v[0],ne=y[0];for(let F=1;F<a;F++){const P=v[F];(P<R||P===R&&y[F]<ne)&&(J=F,R=P,ne=y[F])}T=J,w=R+d,O&&this.laneAssignments.set(p,T)}else T=p%this.options.lanes,w=s+n,O&&this.laneAssignments.set(p,T);const A=g.get(x),$=typeof A=="number"?A:this.options.estimateSize(p),U=w+$;b[p]={index:p,start:w,size:$,end:U,key:x,lane:T},y[T]===void 0&&I++,y[T]=p,v[T]=U}return this.measurementsCache=b,b},{key:!1,debug:()=>this.options.debug}),this.calculateRange=_e(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,s,n,i)=>t.length===0||s===0?(this.range=null,null):(this.range=$i(t,s,n,i,i===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=_e(()=>{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,b=m?this.getTotalSize():0,y=((i=this.scrollState)==null?void 0:i.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[t]??{index:t,key:u,start:a,size:l,end:a+l,lane:0},g,this):a<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(u)||this.scrollDirection!=="backward"));(this.pendingMin===null||t<this.pendingMin)&&(this.pendingMin=t),this.itemSizeCache.set(u,s),this.itemSizeCacheVersion++,m?this.applyScrollAdjustment(this.getTotalSize()-b):y&&this.applyScrollAdjustment(g),this.notify(!1)}},this.getVirtualItems=_e(()=>[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=ds(0,s.length-1,i?a=>n[a*2]:a=>Wt(s[a]).start,t);return Wt(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&&(Tt()&&(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&&ji(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 ds=(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 Pi(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 $i(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=Pi(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=ds(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 kt=typeof document<"u"?c.useLayoutEffect:c.useEffect;function Bi({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 p=d.options.horizontal?"width":"height";h.container.style[p]=`${g}px`}const m=!!d.options.horizontal,b=h.mode==="transform",y=m?"left":"top",v=d.options.scrollMargin,I=d.getVirtualItems();for(const p of I){const x=p.start-v,j=d.elementsCache.get(p.key);j&&h.lastPositions.get(j)!==x&&(h.lastPositions.set(j,x),b?j.style.transform=m?`translate3d(${x}px, 0, 0)`:`translate3d(0, ${x}px, 0)`:j.style[y]=`${x}px`)}},a={...s,onChange:(d,h)=>{var g;const m=i.current;let b=!0;if(m.enabled){l(d);const y=d.range,v=m.prevRange;b=!v||v.isScrolling!==d.isScrolling||v.startIndex!==y?.startIndex||v.endIndex!==y?.endIndex,b&&(m.prevRange=y?{startIndex:y.startIndex,endIndex:y.endIndex,isScrolling:d.isScrolling}:null)}b&&(e&&h?Us.flushSync(n):n()),(g=s.onChange)==null||g.call(s,d,h)}},[u]=c.useState(()=>{const d=new Li(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 b=d.options.horizontal?"width":"height";h.style[b]=`${m}px`}}})});return u.setOptions(a),kt(()=>u._didMount(),[]),kt(()=>u._willUpdate()),kt(()=>{l(u)}),u}function Wi(e){return Bi({observeElementRect:Oi,observeElementOffset:zi,scrollToFn:_i,...e})}const zt=e=>e.query?`matching "${e.query}"`:e.from?`from "${e.from}"`:"matching your search",Ki=e=>`Select all ${zt(e)}`,Vi=(e,o)=>`All ${Gt(o)} ${zt(e)} selected`,qi=({verb:e,confirmingDelete:o,hasSelection:t,junkMailboxId:s,currentMailboxId:n,deletableMessageId:i})=>{if(o)return{kind:"withheld"};if(e==="junk"){const l=xn(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}},Hi=(e,o,t)=>e==="BACK"&&o&&t===void 0,Qi=(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:Ye(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:ts(e.category),messageCount:o,suspicious:e.authenticity?.dkimMismatch===!0,labels:e.labels,...Et(e)}),Ui=({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:b})=>r.jsx(bn,{thread:Qi(e,d),link:{mailboxId:o,threadId:e.threadId},inListbox:!0,active:t,focused:s,isTabStop:n,density:b,isDesktop:m,onFocusRow:i,selection:{isChecked:l,onToggleCheck:a,onRowSelect:u,isMultiSelectMode:h,onLongPress:g}}),Ji=c.memo(Ui),Gi=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:Ye(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:ts(e.category),suspicious:o,...Et(e)}},Yi=({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:b,density:y})=>{const[v,I]=c.useState("none"),p=Xe(),x=c.useCallback(A=>{navigator.vibrate?.(10),A==="trailing"?m(e.messageId):b(e.messageId,e.isRead),I("none")},[m,b,e.messageId,e.isRead]),j=c.useCallback(()=>{h(e.messageId)},[h,e.messageId]),T=c.useCallback(()=>{a(e.messageId)},[a,e.messageId]),w=c.useCallback(()=>{p({threadId:e.threadId,messageId:e.messageId})},[p,e.threadId,e.messageId]),O=vn(e.messageId,u);return g||d?r.jsx(Ji,{thread:e,mailboxId:o,isSelected:t,isFocused:s,isTabStop:n,onFocusRow:i,isChecked:l,onToggleCheck:a,onRowSelect:u,isMultiSelectMode:d,onLongPress:h,isDesktop:g,density:y}):r.jsx("div",{role:"presentation",onPointerDownCapture:O.onMouseDown,onClickCapture:O.claimClick,onContextMenu:O.onContextMenu,children:r.jsx(lo,{thread:Gi(e),selectionMode:!1,checked:!1,active:t,peek:v,onPeek:I,onToggleCheck:T,onLongPress:j,onOpen:w,onAct:x})})},Xi=72,Zi=32,er=5,hs="remit:list-density",tr=()=>{try{const e=localStorage.getItem(hs);if(e==="compact"||e==="comfortable")return e}catch{}return"comfortable"},sr=(e,o,t)=>Co(e.filter(s=>o.has(s.messageId)).map(s=>s.accountId??t)).moveDisabledHint,nr=({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:b,hasMore:y=!1,isLoadingMore:v=!1,accountId:I,listTitle:p,listMeta:x,listFilter:j,listSearchText:T,listScopeLabel:w,onTriageContextChange:O,commandsRef:A,hideHeader:$=!1})=>{const U=c.useRef(null),J=Xe(),R=Bo(),ne=Js(),{verb:F,start:P,startFromSearch:Me}=ne,ve=Gs(),Se=!!a?.trim(),H=Sn(),{labels:Le}=Lo(I),{pushError:oe}=qt(),[M,ye]=c.useState(t),[Re,Ce]=c.useState(),N=c.useCallback(f=>{Ce(S=>S===f?S:void 0),ye(f)},[]),[Y,Pe]=c.useState(tr),B=c.useCallback(()=>{Pe(f=>{const S=f==="comfortable"?"compact":"comfortable";try{localStorage.setItem(hs,S)}catch{}return S})},[]),{toggleReadFor:Ie}=ss({mailboxId:e}),{junkMailboxId:fe}=ns(I),me=os(fe,e),Ee=c.useMemo(()=>[{accountId:I,mailboxId:e}],[I,e]),{outcome:ie,staleFolderLabel:$e,guessedMailboxId:Be}=yn(Ee),{selectedIds:z,selectedCount:D,hasSelection:X,isSelected:Z,toggle:ee,select:te,clearSelection:Te,selectRange:ge,setAnchor:Oe,selectAll:We,toggleAll:re,intersectWith:Ze}=Cn(),Ke=En(D,R),[pe,E]=c.useState(null),et=c.useCallback((f,S,he)=>{const q=Ys(f,S,he,ie);q&&oe(q)},[oe,ie]),ke=Se&&!!u,tt=`${e}|${JSON.stringify(u??{})}`,k=In({mailboxId:e,mailboxLabel:p,accountId:I,enabled:ke,predicateKey:tt,searchQuery:u??{},reportEnding:et}),st=k.phase.kind,Ve=k.clear,L=c.useCallback(()=>{st==="escalated"&&Ve(),Te()},[Te,Ve,st]),[nt,ae]=c.useState(null),xe=c.useRef(null),le=c.useRef(!1),Ae=c.useRef(null),we=!s&&o.length>0,ce=Wi({count:o.length,getScrollElement:()=>U.current,estimateSize:()=>Y==="compact"?Zi:Xi,overscan:er}),qe=t?o.findIndex(f=>f.messageId===t):-1,W=M?o.findIndex(f=>f.messageId===M):-1,se=c.useCallback(f=>{if(f<0||f>=o.length)return;const S=o[f];if(Ke){ee(S.messageId);return}xe.current=S.messageId,le.current=!1,Ce(S.messageId),ye(S.messageId)},[o,Ke,ee]),Ne=c.useCallback(()=>{if(o.length===0)return;const f=W<0?0:Math.min(W+1,o.length-1);se(f)},[o.length,W,se]),ot=c.useCallback(()=>{if(o.length===0)return;const f=W<=0?0:W-1;se(f)},[o.length,W,se]),He=c.useCallback(()=>se(0),[se]),Qe=c.useCallback(()=>se(o.length-1),[se,o.length]),be=c.useCallback(()=>{M&&ee(M)},[M,ee]),_=c.useMemo(()=>o.map(f=>f.messageId),[o]),ze=c.useMemo(()=>{const f=[];for(const S of o)z.has(S.messageId)&&f.push({id:S.messageId,sender:S.fromName??S.fromEmail??"Unknown",email:S.fromEmail??"",subject:S.subject??"(No subject)",date:Ye(S.sentDate),accountId:I,mailboxId:S.mailboxId});return f},[o,z,I]),xt=c.useCallback((f,S)=>S.shiftKey?(ge(_,f,M),!0):S.metaKey||S.ctrlKey?(ee(f),!0):(L(),Oe(f),!1),[_,M,ge,ee,L,Oe]),it=c.useCallback(f=>{!h||f.length===0||(Ae.current=M??null,E(f))},[h,M]),Fe=c.useCallback(f=>{const S=Tn(_,M,f);S!==void 0&&(ge(_,S),xe.current=S,le.current=!1,Ce(void 0),ye(S))},[_,M,ge]),ue=c.useCallback(()=>Fe(-1),[Fe]),rt=c.useCallback(()=>Fe(1),[Fe]),at=c.useCallback(()=>{_.length>0&&We(_)},[_,We]),lt=c.useCallback(f=>{const S=qi({verb:f,confirmingDelete:pe!==null,hasSelection:X,junkMailboxId:fe,currentMailboxId:e,deletableMessageId:h?M:void 0});return S.kind==="openWizard"?(P(f),!0):S.kind==="confirmDelete"?(it([S.messageId]),!0):S.kind==="unavailable"?(oe({severity:"warning",title:S.reason}),!0):S.kind==="withheld"},[pe,h,X,fe,e,P,M,it,oe]),de=c.useCallback((f,S)=>{const he=o.find(q=>q.messageId===f)?.threadId;he&&J({threadId:he,messageId:f},{replace:S?.replace})},[J,o]),ct=c.useCallback(()=>{M&&de(M)},[M,de]),Ue=c.useRef(void 0),bt=c.useCallback(f=>{Ue.current=f,de(f,{replace:!0})},[de]);kn({keyboardFocusedMessageId:Re,openMessageId:t,enabled:R&&D===0,open:bt});const De=k.phase.kind==="escalated"?{scope:zt(u??{}),total:k.phase.total,searchQuery:u??{},run:(f,S)=>k.runAction(f,void 0,S),stop:k.stop}:void 0,ut=c.useCallback(f=>{if(f.length===0){E(null);return}const S=new Set(f),he=o.findIndex(Q=>S.has(Q.messageId));let q;for(let Q=he+1;Q<o.length;Q++)if(!S.has(o[Q].messageId)){q=o[Q].messageId;break}if(q===void 0){for(let Q=he-1;Q>=0;Q--)if(!S.has(o[Q].messageId)){q=o[Q].messageId;break}}h?.(f),L(),Ae.current=null,E(null),q!==void 0&&(xe.current=q,le.current=!1,N(q),R&&de(q,{replace:!0})),R||ae(Xs("delete",f.length,ie))},[o,h,L,de,R,N,ie]),vt=c.useCallback(()=>{const f=Ae.current;Ae.current=null,E(null),f!==null&&(xe.current=f,le.current=!1,N(f))},[N]),Je=c.useMemo(()=>sr(o,z,I),[I,z,o]),St=c.useCallback(()=>{if(De){Me();return}P("organize")},[De,Me,P]),dt=c.useCallback(f=>{h?.([f])},[h]),yt=c.useCallback((f,S)=>{Ie([f],!S)},[Ie]),C=c.useCallback(f=>{R||te(f)},[R,te]),V=c.useCallback(()=>{if(k.isRunning||k.phase.kind==="counting"){k.stop();return}L()},[k,L]),K=c.useCallback(()=>{k.clear()},[k]);c.useEffect(()=>{if(le.current||!R&&t)return;const f=W>=0?W:qe;f>=0&&ce.scrollToIndex(f,{align:"auto"})},[W,qe,ce,R,t]),c.useEffect(()=>{if(!t)return;const f=Ue.current===t;Ue.current=void 0,!f&&(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:we})},[M,z,we,O]);const Ft=c.useRef(O);Ft.current=O,c.useEffect(()=>()=>Ft.current?.({focusedMessageId:void 0,selectedIds:[],hasList:!1}),[]),c.useEffect(()=>{k.phase.kind!=="idle"||k.isRunning||Ze(o.map(f=>f.messageId))},[o,Ze,k.phase,k.isRunning]);const Dt=c.useRef(e);c.useEffect(()=>{Dt.current!==e&&(Dt.current=e,L())},[e,L]),_o({shouldBlockFn:({action:f})=>Hi(f,X,ve)?(L(),!0):!1,enableBeforeUnload:!1,disabled:!X||ve!==void 0}),c.useEffect(()=>{const f=U.current;if(!f||!y||!b)return;const S=()=>{if(v)return;const{scrollTop:he,scrollHeight:q,clientHeight:Q}=f;he+Q>=q-200&&b()};return f.addEventListener("scroll",S,{passive:!0}),S(),()=>f.removeEventListener("scroll",S)},[y,v,b]),c.useEffect(()=>{const f=xe.current;if(!f)return;const S=U.current?.querySelector(`[data-message-id="${f}"]`);S&&(xe.current=null,S.focus({preventScroll:!0}))}),c.useEffect(()=>{if(A){if(!we){A.current=null;return}return A.current={focusNext:Ne,focusPrevious:ot,focusFirst:He,focusLast:Qe,openFocused:ct,toggleSelect:be,extendSelectDown:rt,extendSelectUp:ue,selectAll:at,clearSelection:()=>X?(L(),!0):!1,requestVerb:lt,toggleDensity:B},()=>{A.current=null}}},[A,we,Ne,ot,He,Qe,ct,be,rt,ue,at,X,L,lt,B]);const _t=s?"loading":n?"error":o.length===0?"empty":"ready",gs=n?Do(i):void 0,ps=c.useCallback(()=>{const f=Zs(en());window.open(f,"_blank","noopener,noreferrer")},[]),xs=[{id:"inbox",threads:[]}],Ct=_.length>0&&_.every(f=>z.has(f)),bs=ke&&y&&Ct&&!g&&!m&&k.phase.kind==="idle"&&!k.isRunning,vs=g||m||k.isRunning,It=k.phase.kind==="escalated"?k.phase.total:k.progress?k.progress.total:D,Ss=k.runningAction?tn(k.runningAction.kind,k.progress?.done??0,k.progress?.total??It):k.phase.kind==="counting"?"Counting matches…":k.phase.kind==="escalated"?Vi(u??{},k.phase.total):void 0,ys=k.phase.kind!=="escalated"&&_.length>0?{checked:Ct,indeterminate:D>0&&!Ct,onChange:()=>re(_)}:void 0,Cs=k.runningAction?{value:k.progress?.done??0,max:k.progress?.total??It,tone:sn(k.runningAction.kind)}:void 0,Is=(k.isRunning||k.phase.kind==="counting"?{tone:"info",text:"",action:{label:"Stop",onClick:k.stop}}:k.phase.kind==="escalated"?{tone:"info",text:"",action:{label:"Clear selection",onClick:K}}:bs?{tone:"info",text:"",action:{label:Ki(u??{}),onClick:k.escalate}}:void 0)??(Je?{tone:"warning",text:Je}:void 0),Ts=r.jsx(wn,{title:H.title||p,navSlot:H.navSlot,titleMeta:H.titleMeta,searchSlot:H.searchSlot,searchField:H.searchField,idleSlot:H.makeFilterSlot,count:It,onCancel:V,onDelete:()=>P("delete"),onMove:()=>P("move"),onOrganize:St,onJunk:me?()=>P("junk"):void 0,onMarkRead:()=>P("markRead"),overflowSlot:I&&e&&D>0&&Le.length>0?r.jsx(yo,{accountId:I,mailboxId:e,messageIds:Array.from(z)}):void 0,isBusy:vs,isCounting:k.phase.kind==="counting",selectAll:ys,statusLabel:Ss,progress:Cs,notice:Is}),ks=jn(_,M),ws=c.useCallback(f=>{le.current=!0,N(f)},[N]),js=r.jsxs(r.Fragment,{children:[Se&&a&&r.jsx(Uo,{query:a,count:d}),r.jsxs("div",{ref:U,role:"listbox","aria-multiselectable":!0,"aria-label":p,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 S=o[f.index];return r.jsx("div",{role:"presentation","data-index":f.index,ref:ce.measureElement,className:je("absolute left-0 top-0 w-full border-b border-line",k.isRunning&&"pointer-events-none opacity-50"),style:{transform:`translateY(${f.start}px)`},children:r.jsx(Yi,{thread:S,mailboxId:e,isSelected:t===S.messageId,isFocused:M===S.messageId,isTabStop:ks===S.messageId,onFocusRow:ws,isChecked:Z(S.messageId),onToggleCheck:ee,onRowSelect:xt,isMultiSelectMode:Ke,onLongPress:C,isDesktop:R,onDelete:dt,onToggleRead:yt,density:Y})},f.key)})}),v&&r.jsx(co,{})]})]});return r.jsxs(r.Fragment,{children:[nt&&!R&&r.jsx(ft,{tone:"success",variant:"soft",className:"m-2 rounded-md",onDismiss:()=>ae(null),children:nt}),r.jsx(uo,{listTitle:p,listMeta:x,sections:xs,flatList:!0,listState:H.searchResults?"ready":_t,searchQuery:T,listFilter:j,listScopeLabel:w,errorMessage:gs,onRetry:l,onReportError:ps,density:Y,selectedThreadId:t,onSelectThread:f=>de(f),isDesktop:R,hideHeader:$,selectionBar:Ts,listBody:H.searchResults??(_t==="ready"?js:void 0)}),r.jsx(Mn,{isOpen:pe!==null,messageIds:pe??[],outcome:ie,accountId:I,trashFolderLabel:p,staleFolderLabel:$e,guessedMailboxId:Be,isDeleting:g,onConfirm:ut,onCancel:vt}),r.jsx(Rn,{verb:F,accountId:I,mailboxId:e,mailboxLabel:p,selection:ze,selectionRestriction:Je?"spansAccounts":void 0,escalated:De,escalatedProgress:k.progress,onFinished:L,onRunEnded:et})]})},or=e=>Ht({path:{accountId:e}}),ir=e=>{const o=jt(),t=Rt(),s=Mt({...nn(),onSuccess:()=>{t.recordEvent("sync.triggered"),o.invalidateQueries({queryKey:or(e)})}});return{trigger:()=>{s.mutate({path:{accountId:e}})},triggerAsync:()=>s.mutateAsync({path:{accountId:e}}),isPending:s.isPending,error:s.error,reset:s.reset}},rr=({accountId:e,children:o})=>{const{triggerAsync:t,isPending:s}=ir(e);return r.jsx(Jo,{onRefresh:t,isRefreshing:s,children:o})};function ar({accountId:e,currentMailboxId:o,candidates:t,onMove:s,children:n}){const[i,l]=c.useState(!1),a=Rt(),u=on(),{inboxMailboxId:d}=On(e),h=An(e),{data:g}=mt({...rn({path:{accountId:e}}),staleTime:1/0}),m=c.useMemo(()=>an({mailboxes:g?.items??[],folderAppointments:h,currentMailboxId:o,translator:u}),[g?.items,h,o,u]),b=c.useMemo(()=>d||(m.find(x=>x.label.toLowerCase()==="inbox")?.id??m.find(x=>!x.isCurrent)?.id??""),[d,m]),y=c.useRef(!1);c.useEffect(()=>{y.current||(y.current=!0,Nn(a,t.length))},[a,t.length]);const v=c.useCallback(()=>{zn(a,t.length),l(!0)},[a,t.length]),I=c.useCallback((p,x)=>{Fn(a,{selected:p.length,total:t.length,toInbox:x===d}),s(p,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:v})}),r.jsx("div",{className:"min-h-0 flex-1",children:n}),r.jsx(li,{open:i,candidates:t,defaultDestinationId:b,availableFolders:m,delimiter:ln(g?.items??[]),onConfirmMove:I,onCancel:()=>l(!1)})]})}const lr=50,fs=c.createContext(null);function pt(){const e=c.useContext(fs);if(!e)throw new Error("MailboxPane.* must be used inside <MailboxPane>");return e}function cr({mailboxId:e,thread:o,children:t}){const s=Xe(),n=go(),i=zo(),l=o?.threadId,a=o?.messageId,u=Rt(),{accounts:d,searchQuery:h,onToggleIntelligence:g,onSearchClearQuery:m}=Yt(),b=dn(),y=wo(h),v=y.length>0,{freeText:I,tokens:p}=Lt(y,b),x=Lt(h.trim(),b).freeText,[j,T]=c.useState("all"),[w,O]=c.useState(new Set),A=c.useMemo(()=>({category:j,attributes:w}),[j,w]),$=c.useMemo(()=>Dn(A),[A]),U=v||_n(A),{params:J,residual:R}=Ln(p,$),ne={order:"desc",...I?{query:I}:{},...J,...$},F={...ne,limit:lr},P={category:F.category,unread:F.unread,starred:F.starred,attachments:F.attachments},Me=U?Qt({path:{mailboxId:e},query:F}):cn({path:{mailboxId:e},query:{order:"desc"}}),{data:ve,isLoading:Se,isError:H,error:Le,refetch:oe,fetchNextPage:M,hasNextPage:ye,isFetchingNextPage:Re}=ho({queryKey:Me,queryFn:async({pageParam:C})=>{if(U){const{data:K}=await Ut({path:{mailboxId:e},query:{...F,continuationToken:C},throwOnError:!0});return K}const{data:V}=await un({path:{mailboxId:e},query:{order:"desc",continuationToken:C},throwOnError:!0});return V},initialPageParam:void 0,getNextPageParam:C=>C.continuationToken,placeholderData:(C,V)=>ao(V?.queryKey,P)?C:void 0}),Ce=mi({mailboxId:e,criteria:ne,enabled:Io({hasSearchQuery:v,freeText:I,residualTokenCount:R.length})}),{accountId:N,isLoading:Y}=Pn(e),Pe=po({accounts:d}),B=$n(gi(ve?.pages.flatMap(C=>C.items??[])??[]),R,N),Ie=c.useCallback(C=>{T(C)},[]),fe=c.useCallback(C=>{O(V=>{const K=new Set(V);return K.has(C)?K.delete(C):K.add(C),K})},[]),me=c.useCallback(()=>{T("all"),O(new Set)},[]),Ee=c.useCallback(()=>{me(),m()},[me,m]),ie=fo({chips:A,tokens:p,reach:R.length>0?"loaded-pages":Bn(F),onClear:Ee}),$e=l?B.find(C=>C.messageId===a)??B.find(C=>C.threadId===l):void 0,Be=Wn(l,a),z=$e??Be,D=a??z?.messageId,X=c.useMemo(()=>{if(l)return{threadId:l,mailboxId:z?.mailboxId??e,subject:z?.subject,messageId:D,authenticity:z?.authenticity}},[l,z,D,e]),Z=c.useCallback(C=>{D&&C.includes(D)&&n()},[D,n]),{deleteMessages:ee,isPending:te}=Pt({mailboxId:e,onAfterOptimisticRemove:Z}),{moveMessages:Te,isPending:ge}=$t({mailboxId:e,accountId:N,onAfterOptimisticRemove:Z}),Oe=c.useRef(null),We=Kn(),{listCommandsRef:re,onTriageContextChange:Ze,focusedMessageId:Ke,selectedIds:pe}=We,E=B.find(C=>C.messageId===Ke)??z,et=xo({accounts:d})??null,ke=Vn({thread:z,isOpen:!0,mailboxId:e,accountId:N,onAfterOptimisticRemove:Z}),{draftsMailboxId:tt}=qn(N),k=tt!==void 0&&tt===e,{archiveMailboxId:st}=Hn(N),Ve=Qn(),L=jo(),nt=c.useMemo(()=>Mo(L,l,D),[L,l,D]),ae=c.useMemo(()=>{if(E)return C=>L({threadId:E.threadId,messageId:E.messageId,mode:C})},[L,E]),xe=Ao(),le=Ro(),Ae=No(),we=c.useCallback(C=>C?Ve(C):[],[Ve]),{toggleStar:ce}=Un({threadId:E?.threadId??"",mailboxId:e}),{toggleReadFor:qe}=ss({mailboxId:e,accountId:N}),{junkMailboxId:W}=ns(N),se=W!=null&&W===e,Ne=os(W,e),{candidates:ot}=hi(se?W:void 0),{moveMessages:He}=$t({mailboxId:e,threadId:E?.threadId,accountId:N,onAfterOptimisticRemove:Z}),{deleteMessages:Qe}=Pt({mailboxId:e,threadId:E?.threadId,onAfterOptimisticRemove:Z}),{addressId:be,address:_}=Jn(E),{updateFlags:ze}=Gn({addressId:be,senderEmail:E?.fromEmail??void 0}),xt=c.useCallback(()=>ae?.("reply"),[ae]),it=c.useCallback(()=>ae?.("reply-all"),[ae]),Fe=c.useCallback(()=>ae?.("forward"),[ae]),ue=c.useCallback(()=>we(E),[we,E]),rt=c.useCallback(()=>{if(re.current?.requestVerb("delete"))return;const C=ue();C.length>0&&Qe(C)},[re,ue,Qe]),at=c.useCallback(()=>{if(re.current?.requestVerb("junk")||!Ne)return;const C=ue();C.length!==0&&(Yn(u,{count:C.length,senderTrust:E?.senderTrust??"unknown",wasRescuable:E?Xn(E):!1}),He(C,Ne))},[re,Ne,ue,He,u,E]),lt=c.useCallback(()=>{if(pe.length>0){const C=!(E?.hasStars??!1),V=new Set(pe);for(const K of B)V.has(K.messageId)&&K.hasStars!==C&&ce(K.messageId,K.hasStars);return}E&&ce(E.messageId,E.hasStars)},[pe,B,E,ce]),de=c.useCallback(()=>{if(re.current?.requestVerb("markRead"))return;const C=ue();if(C.length===0)return;const V=!(E?.isRead??!1);qe(C,V)},[re,ue,E,qe]),ct=c.useCallback(()=>{if(!be)return;const C=_?.flags?.muted?.value!==!0;ze({muted:{value:C}})},[be,_,ze]),Ue=c.useCallback(()=>{if(!be)return;const C=_?.flags?.vip?.value!==!0;ze({vip:{value:C}})},[be,_,ze]),bt=c.useCallback(()=>{Oe.current?.open()},[]),De=k?"drafts":st===e?"archive":W===e?"junk":"inbox",ut=c.useRef("");c.useEffect(()=>{const C=ut.current;ut.current=y,y.length>0&&C.length===0&&u.recordEvent("search.submitted",{mailboxType:De})},[y,De,u]);const{goBack:vt,nextMessageId:Je,previousMessageId:St}=Zn({context:We,orderedIds:B.map(C=>C.messageId),selectedMessageId:D,enabled:!xe&&!le,hasOpenThread:l!==void 0,onClose:n,handlers:{reply:xt,replyAll:it,forward:Fe,delete:rt,toggleStar:lt,toggleRead:de,muteSender:ct,blockSender:z?bt:void 0,vipSender:Ue,markJunk:at,toggleIntelligence:z?()=>Oe.current?.toggle():void 0,compose:Ae,goBrief:()=>i("brief"),goInbox:()=>i("brief"),goSent:()=>i("brief"),goFlagged:()=>i("flagged"),goSettings:()=>i("settings")}}),dt=C=>{if(!C)return;const V=B.find(K=>K.messageId===C);return V?{threadId:V.threadId,messageId:C}:void 0},yt={mailboxId:e,selectedMessageId:D,selectedThread:z,conversation:X,onOpenThread:s,threads:B,isLoading:Se,isError:H,error:Le,mailboxAccountId:N,mailboxAccountLoading:Y,mailboxName:Pe,unreadCount:et,isDraftsMailbox:k,isSpamFolder:se,rescueCandidates:ot,filterCategory:j,filterAttributes:w,onSelectFilterCategory:Ie,onToggleFilterAttribute:fe,onClearFilters:me,listFilter:ie,listSearchText:x||void 0,onToggleIntelligence:g,intelligenceRef:Oe,handleDeselectIfRemoved:Z,searchPredicate:v&&R.length===0?F:void 0,resultCount:Ce,onDeleteMessages:ee,onMoveMessages:Te,isDeleting:te,isMoving:ge,onLoadMore:M,hasMore:ye,isLoadingMore:Re,onTriageContextChange:Ze,listCommandsRef:re,onRetry:()=>oe(),onReply:nt,onToolbarDelete:ke.deleteThread,onToolbarStar:ke.toggleStar,isStarred:ke.isStarred,onToolbarMove:ke.moveThread,onBack:vt,nextThread:dt(Je),previousThread:dt(St)};return r.jsx(fs.Provider,{value:yt,children:t})}function ms(){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:b,mailboxName:y,unreadCount:v,isDraftsMailbox:I,isSpamFolder:p,rescueCandidates:x,onTriageContextChange:j,listCommandsRef:T,onRetry:w,filterCategory:O,filterAttributes:A,onSelectFilterCategory:$,onToggleFilterAttribute:U,onClearFilters:J,listFilter:R,listSearchText:ne,searchPredicate:F,resultCount:P}=pt(),{searchQuery:Me,searchInput:ve,accounts:Se,resultFolderIndex:H}=Yt(),Le=vo(),oe=Xe(),M=y??"Inbox",ye=c.useMemo(()=>oo(),[]),{trashMailboxId:Re}=io(b),Ce=bo({accounts:Se}),{trashByAccount:N}=Xt(),Y=ui({accountId:b,mailboxId:e}),Pe=Re!=null&&Re===e,B=c.useMemo(()=>b?[b]:[],[b]),{hasNewMail:Ie}=fn(),{state:fe,errorMessage:me,refresh:Ee}=mn(B,{onSettled:w}),ie=c.useMemo(()=>r.jsx(gn,{state:fe,onRefresh:Ee,label:`Refresh ${M}`,errorMessage:me,hasUpdate:Ie(B)}),[fe,Ee,M,me,Ie,B]),$e=c.useMemo(()=>t.map(te=>ro(te,H)),[t,H]),Be=c.useCallback(te=>{const Te=te.threadId??t.find(ge=>ge.messageId===te.id)?.threadId;Te&&oe({threadId:Te,messageId:te.id},{mailboxId:te.mailboxId??e,query:ve})},[e,oe,ve,t]);if(I&&b)return r.jsx(Ci,{accountId:b,selectedMessageId:o,imapThreads:t,title:y??"Drafts",unreadCount:v??void 0});const z=r.jsx(nr,{mailboxId:e,threads:t,selectedMessageId:o,isLoading:s,isError:n,error:i,onRetry:w,searchQuery:Me,searchPredicate:F,resultCount:P,onDeleteMessages:l,isDeleting:u,isMoving:d,onLoadMore:h,hasMore:g,isLoadingMore:m,accountId:b,listTitle:M,listFilter:R,listSearchText:ne,listScopeLabel:M,hideHeader:!0,onTriageContextChange:j,commandsRef:T}),D=Se[0]?.accountId,X=Le==="phone"&&D?r.jsx(rr,{accountId:D,children:z}):z,Z=p&&x.length>0&&b?r.jsx(ar,{accountId:b,currentMailboxId:e,candidates:x,onMove:a,children:X}):X,ee=Pe?r.jsx(ki,{messageCount:Ce,isEmptying:Y.isEmptying,deletedCount:Y.deletedCount,refusalReason:Y.refusal?.reason,trashFolderLabel:y??void 0,staleFolderLabel:b?N.get(b)?.staleFolderPath:void 0,onEmpty:Y.emptyTrash,onRepair:Y.repair,children:Z}):Z;return r.jsx(mo,{title:M,unreadCount:v,preset:ye,selectedCategory:O,activeFilters:A,onSelectCategory:$,onToggleFilter:U,onClearFilters:J,searchResults:$e,searchLoading:s,onSelectSearchResult:Be,searchResultsInBody:!0,refreshControl:ie,children:ee})}function ur(){const e=Ot(),{mailboxId:o,mailboxAccountId:t,mailboxAccountLoading:s,selectedThread:n,conversation:i,onReply:l,onToolbarDelete:a,onToolbarStar:u,isStarred:d,onToolbarMove:h,handleDeselectIfRemoved:g,intelligenceRef:m,onOpenThread:b}=pt(),y=!!i,v=so(i?.threadId);is(m,v);const I=c.useRef(null),{railFits:p,openRail:x}=v;c.useEffect(()=>{if(!p)return;const T=n?.messageId??null;T&&I.current!==T&&n?.authenticity?.dkimMismatch&&(I.current=T,x())},[p,x,n?.messageId,n?.authenticity?.dkimMismatch]);const j=i?r.jsx(rs,{threadId:i.threadId,mailboxId:i.mailboxId,subject:i.subject,selectedMessageId:i.messageId,authenticity:i.authenticity,onOpenIntelligence:v.open,listOnScreen:!0}):r.jsx(hn,{});return r.jsxs(r.Fragment,{children:[r.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[r.jsx(no,{hasThread:y,messageId:i?.messageId,intelligenceOpen:v.isShowing,canToggleIntelligence:v.canToggle,onToggleIntelligence:v.toggle,onReply:l?()=>l("reply"):void 0,onReplyAll:l?()=>l("reply-all"):void 0,onForward:l?()=>l("forward"):void 0,onDelete:y?a:void 0,onToggleStar:y?u:void 0,isStarred:d,moveContext:y&&t?{accountId:t,currentMailboxId:o,onMove:h}:void 0,moveContextLoading:s}),r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:j})]}),r.jsx(as,{isOpen:v.drawerOpen,onClose:v.closeDrawer,thread:n,accountId:t,onAfterOptimisticRemove:g,onReplyWithText:e,onOpenThread:b})]})}function dr(){const e=Ot(),{mailboxAccountId:o,selectedThread:t,onToggleIntelligence:s,handleDeselectIfRemoved:n,onOpenThread:i}=pt();return r.jsx(to,{onClose:s,thread:t,accountId:o,onAfterOptimisticRemove:n,onReplyWithText:e,onOpenThread:i})}function hr(){const e=Ot(),{mailboxAccountId:o,selectedThread:t,conversation:s,onOpenThread:n,onBack:i,nextThread:l,previousThread:a,handleDeselectIfRemoved:u,intelligenceRef:d}=pt(),h=eo(s?.threadId??null);return is(d,h),s?r.jsxs(r.Fragment,{children:[r.jsx(rs,{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(as,{isOpen:h.isOpen,onClose:h.close,thread:t,accountId:o,onAfterOptimisticRemove:u,onReplyWithText:e,onOpenThread:n})]}):r.jsx(ms,{})}const Pr=Object.assign(cr,{List:ms,Reading:ur,Intelligence:dr,Phone:hr});export{Pr as M};