@remit/web-client-dist 0.0.675 → 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 (181) hide show
  1. package/assets/{AppFrame-R9FR9SH9.js → AppFrame-DSPG81Mk.js} +1 -1
  2. package/assets/{BriefPane-BzlqkW4r.js → BriefPane-Cfl-uWfm.js} +1 -1
  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-dD_YhGMH.js → EmptyState-BUOSmldo.js} +1 -1
  9. package/assets/{ErrorState-nA0Ptq3g.js → ErrorState-KjDYblD5.js} +1 -1
  10. package/assets/{FlaggedPane-BwhUf1qN.js → FlaggedPane-Dw-wR4tp.js} +1 -1
  11. package/assets/{FullCompose-dJ4mfUrX.js → FullCompose-Djp_h4BT.js} +1 -1
  12. package/assets/{LabelApplyTrigger-BA7ANeDk.js → LabelApplyTrigger-oS5sxATE.js} +1 -1
  13. package/assets/{MailShell-0sTtK1xD.js → MailShell-LIuV2C3h.js} +1 -1
  14. package/assets/{MailViewChrome-BEx9Dr1Z.js → MailViewChrome-yffBJjbO.js} +1 -1
  15. package/assets/{MailboxPane-DYgnYeOy.js → MailboxPane-DUCZVAx6.js} +1 -1
  16. package/assets/{MessageBody-Deha778B.js → MessageBody-C89PSL_p.js} +1 -1
  17. package/assets/MessageToolbar-UJadqHyA.js +1 -0
  18. package/assets/{NavMenuButton-C-7-t18I.js → NavMenuButton-B-goW-G5.js} +1 -1
  19. package/assets/{OnboardingWizard-hfP07hpw.js → OnboardingWizard-Cvqq2aP_.js} +1 -1
  20. package/assets/{OutboxPane-gEXLW7BJ.js → OutboxPane-ce4uTAzW.js} +1 -1
  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-Kz9s3jOk.js → account-service-status-oYDwuPLn.js} +1 -1
  33. package/assets/{accounts-B5C8kCn6.js → accounts-DhSbRlEm.js} +1 -1
  34. package/assets/{advanced-CudHnY-7.js → advanced-B50NfkTy.js} +1 -1
  35. package/assets/{appearance-BTH52atO.js → appearance-CYNOlHLz.js} +1 -1
  36. package/assets/{avatar-vPm9XfmM.js → avatar-uWJajuSb.js} +1 -1
  37. package/assets/{bottom-sheet-BTdseD_6.js → bottom-sheet-Bc0vwv2J.js} +1 -1
  38. package/assets/brief-DPWE6nMF.js +1 -0
  39. package/assets/{brief-DuHUqR8b.js → brief-bdXCpAmW.js} +1 -1
  40. package/assets/{calendar-BQjH3OHS.js → calendar-7SdvLY_h.js} +1 -1
  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-BUFaaizf.js → calendar-failure-note-BtZLcaiZ.js} +1 -1
  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-865cdsJK.js → card-CPL-TrL1.js} +1 -1
  50. package/assets/{checkbox-Qon94b1C.js → checkbox-CGG1nAhQ.js} +1 -1
  51. package/assets/{circle-check-big-CyVG6r7N.js → circle-check-big-BsCwNdJZ.js} +1 -1
  52. package/assets/{circle-check-Db07NpOC.js → circle-check-i3jeyeTf.js} +1 -1
  53. package/assets/{circle-help-CVShnhWn.js → circle-help-CVWHf1ow.js} +1 -1
  54. package/assets/{clock-B9kFW89H.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-C2ovEkHy.js → config-import-DmOMXQ5W.js} +1 -1
  60. package/assets/{confirm-dialog-CgMAaLI3.js → confirm-dialog-q8tbS_22.js} +1 -1
  61. package/assets/{copy-CIKgpUwt.js → copy-LUCWJAE6.js} +1 -1
  62. package/assets/{credential-steps-BWguS0eW.js → credential-steps-DVglyUgf.js} +1 -1
  63. package/assets/{download-A4hq8dWf.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-DaKTW3eK.js → external-link-BDqA_mVy.js} +1 -1
  68. package/assets/{file-json-DiHW8YBd.js → file-json-DQGozYSr.js} +1 -1
  69. package/assets/{filters-1uKuLkQU.js → filters-DFLdTFEB.js} +1 -1
  70. package/assets/flagged-CCXBAY09.js +1 -0
  71. package/assets/{flagged-BIza20sq.js → flagged-CyMautVT.js} +1 -1
  72. package/assets/{folders-Bd16ltK4.js → folders-DtchKvEA.js} +1 -1
  73. package/assets/{help-copy-N4JgEUmu.js → help-copy-B2iT8EG_.js} +1 -1
  74. package/assets/{import-DJptfpxt.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-BzL5-pGT.js → index-CL_fwLHN.js} +88 -88
  79. package/assets/index-CZYy2P_j.js +1 -0
  80. package/assets/index-CqsCZrgd.js +1 -0
  81. package/assets/{index-C8VKP1dT.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-BWAq8iOl.js → index-DZb7rV9A.js} +4 -4
  85. package/assets/index-DoTwMLuw.js +1 -0
  86. package/assets/index-DrtbTKeC.js +1 -0
  87. package/assets/index-wVOTkeaF.js +1 -0
  88. package/assets/{kbd-B9MFmWVU.js → kbd-CDJCJUnp.js} +1 -1
  89. package/assets/{labels-DeCZEWet.js → labels-rv-5Xb0f.js} +1 -1
  90. package/assets/{mail-CSUpbRUP.js → mail-SW3rbFnq.js} +1 -1
  91. package/assets/{menu-CGw_RHKl.js → menu-CcLh9Whg.js} +1 -1
  92. package/assets/new-Zmtsd7wU.js +1 -0
  93. package/assets/onboarding-BbZUe6dp.js +1 -0
  94. package/assets/{onboarding-completion-DbgUYeRa.js → onboarding-completion-DoF3_MyG.js} +1 -1
  95. package/assets/outbox-ZJk7VidB.js +1 -0
  96. package/assets/{pencil-DOoqyGzC.js → pencil-LSmMSKiW.js} +1 -1
  97. package/assets/{popover-menu-CNiMANtf.js → popover-menu-fjlAfNO1.js} +1 -1
  98. package/assets/{refresh-cw-D1SQy8O7.js → refresh-cw-5OKnYRBy.js} +1 -1
  99. package/assets/{reply-CQarAZxU.js → reply-DvdgFS16.js} +1 -1
  100. package/assets/{rich-text-DgI7vzll.js → rich-text-BBwYPM6F.js} +1 -1
  101. package/assets/{rich-text-spellcheck-worker-provider-paPOw9As.js → rich-text-spellcheck-worker-provider-Bk8cqxyg.js} +1 -1
  102. package/assets/{rotate-ccw-DPB71584.js → rotate-ccw-CENCKp2Z.js} +1 -1
  103. package/assets/{roving-focus-Coea111y.js → roving-focus-FWOr5tBU.js} +1 -1
  104. package/assets/{row-actions-CiZruXil.js → row-actions-DA6zLLAB.js} +1 -1
  105. package/assets/{search-mirror-_Dap9COg.js → search-mirror-Dri4pWEq.js} +1 -1
  106. package/assets/{search-token-index-DQHE1g7A.js → search-token-index-B1HU1d2-.js} +1 -1
  107. package/assets/{sections-C6oVXjho.js → sections-Rf3k05-_.js} +1 -1
  108. package/assets/{senders-DIVpkzIq.js → senders-ikMjTlbx.js} +1 -1
  109. package/assets/settings-Bk7jziSO.js +1 -0
  110. package/assets/{settings-screen-4md2ibPl.js → settings-screen-DBP3ABLE.js} +1 -1
  111. package/assets/{shield-check-BcUXVpR8.js → shield-check-CdR23I2B.js} +1 -1
  112. package/assets/{sparkles-C1l6GCPT.js → sparkles-Bcn4ZRhZ.js} +1 -1
  113. package/assets/{suggested-vips-iEt-4yp9.js → suggested-vips-D-8cU8GT.js} +1 -1
  114. package/assets/suggestion._suggestionId-D6z0CuYD.js +1 -0
  115. package/assets/task._calendarTaskId-BYRN0yW3.js +1 -0
  116. package/assets/{undo-2-DHJ6nykB.js → undo-2-Bdx8L5xj.js} +1 -1
  117. package/assets/useCalendarData-DXhaM_NM.js +2 -0
  118. package/assets/useCalendarScheduling-BpjmrzdY.js +1 -0
  119. package/assets/useCalendarSuggestions-D3Jza1d7.js +1 -0
  120. package/assets/useCalendarTasks-D_NZ0GM6.js +1 -0
  121. package/assets/{useDebouncedValue-B7157ZPO.js → useDebouncedValue-BTZsNKEh.js} +1 -1
  122. package/assets/{useFilters-C3bLY42W.js → useFilters-CIuC8WLg.js} +1 -1
  123. package/assets/{useLabels-DYdHiHXI.js → useLabels-BZFMPVjT.js} +1 -1
  124. package/assets/useLayoutTier-DrLg7_rq.js +1 -0
  125. package/assets/{useMediaQuery-7Q3jBluO.js → useMediaQuery-DiQ0fGER.js} +1 -1
  126. package/assets/{useMessageBodyContent-CWGtiddz.js → useMessageBodyContent-D-LJBFh4.js} +1 -1
  127. package/assets/{useQueries-Sm8S3Cgh.js → useQueries-hChzM5ru.js} +1 -1
  128. package/assets/{useRefreshControl-bA8HK_j-.js → useRefreshControl-B6YIG0w2.js} +1 -1
  129. package/assets/{useResultFolderIndex-BaqajWHb.js → useResultFolderIndex-6TeGdWgp.js} +1 -1
  130. package/assets/{useSignature-sxHvGfKr.js → useSignature-BkzkUbjz.js} +1 -1
  131. package/assets/{warnings-ByqpxH4J.js → warnings-BdQvV6Kc.js} +1 -1
  132. package/index.html +2 -2
  133. package/package.json +1 -1
  134. package/assets/CalendarEventEditor-BpGmPZ2Z.js +0 -1
  135. package/assets/CalendarEventPopup-Brcgx7tV.js +0 -1
  136. package/assets/CalendarQuickCreate-CwkBXqAB.js +0 -1
  137. package/assets/CalendarSession--XFP5lXS.js +0 -1
  138. package/assets/MessageToolbar-5T47fDWC.js +0 -1
  139. package/assets/_calendarObjectId-Dbrtihva.js +0 -1
  140. package/assets/_mailboxId-B587Zr5T.js +0 -1
  141. package/assets/_messageId-BxlZMqGk.js +0 -1
  142. package/assets/_messageId-CRIBYDCW.js +0 -1
  143. package/assets/_messageId-DTs144Nv.js +0 -1
  144. package/assets/_outboxMessageId-BxdPyrXI.js +0 -1
  145. package/assets/_recurrenceId-QBmk5dbN.js +0 -1
  146. package/assets/_threadId-8Y3P5szz.js +0 -1
  147. package/assets/_threadId-AMQdO9xw.js +0 -1
  148. package/assets/_threadId-mpk_WkaQ.js +0 -1
  149. package/assets/_view._date-BfJq9sBQ.js +0 -1
  150. package/assets/brief-BC_KN7ph.js +0 -1
  151. package/assets/calendar-LLRgZQzl.js +0 -1
  152. package/assets/calendar-event-popup-Mft0N_sd.js +0 -1
  153. package/assets/calendar-event-sidebar-D5vjFGdS.js +0 -1
  154. package/assets/calendar-report-CzeBcU6C.js +0 -1
  155. package/assets/calendar-suggestion-ClsxDTZs.js +0 -1
  156. package/assets/calendars-zYfPB3b8.js +0 -1
  157. package/assets/compose._-_outboxMessageId_-BkKmzR39.js +0 -1
  158. package/assets/compose._-_outboxMessageId_-BnYGu6ez.js +0 -1
  159. package/assets/compose._-_outboxMessageId_-C5Aukg6m.js +0 -1
  160. package/assets/compose._-_outboxMessageId_-Ck-eEtzy.js +0 -1
  161. package/assets/edit-CxVYhmi5.js +0 -1
  162. package/assets/edit-DXN-G3Tu.js +0 -1
  163. package/assets/flagged-DmSptMzm.js +0 -1
  164. package/assets/index-B18BvpkW.js +0 -1
  165. package/assets/index-B4pYEqZI.js +0 -1
  166. package/assets/index-B77HnSA5.js +0 -1
  167. package/assets/index-BZdYp7ae.js +0 -1
  168. package/assets/index-BiCNOLIH.js +0 -1
  169. package/assets/index-CoCVPZ34.js +0 -1
  170. package/assets/index-CroyVnhC.js +0 -1
  171. package/assets/index-DTs144Nv.js +0 -1
  172. package/assets/index-DsgtllX4.js +0 -1
  173. package/assets/index-DupXMcS6.js +0 -1
  174. package/assets/new-DVwQ9Ia3.js +0 -1
  175. package/assets/onboarding-CDWqPDW8.js +0 -1
  176. package/assets/outbox-Ct7VdX2v.js +0 -1
  177. package/assets/settings-Cv257vpL.js +0 -1
  178. package/assets/suggestion._suggestionId-BQw9qGr-.js +0 -1
  179. package/assets/useCalendarData-Bz4EDHDO.js +0 -2
  180. package/assets/useCalendarSuggestions-DcYFtQhb.js +0 -1
  181. package/assets/useLayoutTier-5aJYrTut.js +0 -1
@@ -0,0 +1 @@
1
+ import{j as o}from"./index-CL_fwLHN.js";import{F as r}from"./FlaggedPane-Dw-wR4tp.js";import"./MessageBody-C89PSL_p.js";import"./kbd-CDJCJUnp.js";import"./search-scope-UI1H6AzA.js";import"./reply-DvdgFS16.js";import"./useMediaQuery-DiQ0fGER.js";import"./useMessageBodyContent-D-LJBFh4.js";import"./MessageToolbar-UJadqHyA.js";import"./roving-focus-FWOr5tBU.js";import"./search-token-index-B1HU1d2-.js";import"./useQueries-hChzM5ru.js";import"./EmptyState-BUOSmldo.js";import"./ErrorState-KjDYblD5.js";import"./popover-menu-fjlAfNO1.js";import"./avatar-uWJajuSb.js";import"./index-DZb7rV9A.js";import"./useSignature-BkzkUbjz.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-BTZsNKEh.js";import"./sections-Rf3k05-_.js";import"./undo-2-Bdx8L5xj.js";import"./download-SQdHw0Vd.js";import"./calendar-suggestion-8jcpefeR.js";import"./sparkles-Bcn4ZRhZ.js";import"./useCalendarSuggestions-D3Jza1d7.js";import"./calendar-format-BwCpz-JZ.js";import"./calendar-failure-note-BtZLcaiZ.js";import"./checkbox-CGG1nAhQ.js";import"./clock-NnulNCOv.js";import"./shield-check-CdR23I2B.js";import"./calendar-tMekVEGW.js";import"./useLayoutTier-DrLg7_rq.js";import"./menu-CcLh9Whg.js";import"./useFilters-CIuC8WLg.js";import"./confirm-dialog-q8tbS_22.js";import"./MailViewChrome-yffBJjbO.js";import"./refresh-cw-5OKnYRBy.js";import"./wizard-selection-zWa1qc6-.js";function M(){return o.jsx(r.Reading,{})}export{M as component};
@@ -0,0 +1 @@
1
+ import{j as o}from"./index-CL_fwLHN.js";import{M as r}from"./MailboxPane-DUCZVAx6.js";import"./MessageBody-C89PSL_p.js";import"./kbd-CDJCJUnp.js";import"./search-scope-UI1H6AzA.js";import"./reply-DvdgFS16.js";import"./useMediaQuery-DiQ0fGER.js";import"./useMessageBodyContent-D-LJBFh4.js";import"./useRefreshControl-B6YIG0w2.js";import"./circle-check-big-BsCwNdJZ.js";import"./refresh-cw-5OKnYRBy.js";import"./useQueries-hChzM5ru.js";import"./MessageToolbar-UJadqHyA.js";import"./roving-focus-FWOr5tBU.js";import"./search-token-index-B1HU1d2-.js";import"./EmptyState-BUOSmldo.js";import"./ErrorState-KjDYblD5.js";import"./popover-menu-fjlAfNO1.js";import"./avatar-uWJajuSb.js";import"./index-DZb7rV9A.js";import"./useSignature-BkzkUbjz.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-BTZsNKEh.js";import"./sections-Rf3k05-_.js";import"./undo-2-Bdx8L5xj.js";import"./download-SQdHw0Vd.js";import"./calendar-suggestion-8jcpefeR.js";import"./sparkles-Bcn4ZRhZ.js";import"./useCalendarSuggestions-D3Jza1d7.js";import"./calendar-format-BwCpz-JZ.js";import"./calendar-failure-note-BtZLcaiZ.js";import"./checkbox-CGG1nAhQ.js";import"./clock-NnulNCOv.js";import"./shield-check-CdR23I2B.js";import"./calendar-tMekVEGW.js";import"./useLayoutTier-DrLg7_rq.js";import"./menu-CcLh9Whg.js";import"./useFilters-CIuC8WLg.js";import"./confirm-dialog-q8tbS_22.js";import"./MailViewChrome-yffBJjbO.js";import"./LabelApplyTrigger-oS5sxATE.js";import"./useLabels-BZFMPVjT.js";import"./NavMenuButton-B-goW-G5.js";import"./bottom-sheet-Bc0vwv2J.js";import"./circle-help-CVWHf1ow.js";import"./circle-check-i3jeyeTf.js";function W(){return o.jsx(r.Reading,{})}export{W as component};
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/rich-text-spellcheck-worker-provider-paPOw9As.js","assets/index-BzL5-pGT.js","assets/index-C8VKP1dT.css","assets/rich-text-spellcheck-provider-J8m9wz6A.js","assets/rich-text-DgI7vzll.js","assets/roving-focus-Coea111y.js","assets/confirm-dialog-CgMAaLI3.js","assets/useMediaQuery-7Q3jBluO.js","assets/bottom-sheet-BTdseD_6.js","assets/popover-menu-CNiMANtf.js","assets/undo-2-DHJ6nykB.js","assets/useMessageBodyContent-CWGtiddz.js","assets/reply-CQarAZxU.js","assets/useSignature-sxHvGfKr.js","assets/account-form-helpers-DhckT_PN.js","assets/useDebouncedValue-B7157ZPO.js","assets/sections-C6oVXjho.js"])))=>i.map(i=>d[i]);
2
- import{b as jo,j as d,X as vr,o as ln,d as un,L as gr,x as Fo,T as $o,r as s,cK as Bo,cL as Uo,w as Ho,t as yr,B as wr,ah as Wo,cM as zo,v as Vo,cN as qo,cO as wn,c6 as br,cP as xe,cQ as Er,cR as Ko,cE as Yo,cS as Se,g as _e,aE as Me,cT as Go,cU as Xo,cV as xr,cW as Qo,aC as Sr,aD as Rr,N as Zo,f as Cr,cX as Jo,Z as ea,a as At,bH as ta,cY as Tr,cZ as na,c_ as ra,bJ as oa,c as Ar,c$ as aa,ao as sa,d0 as _n,b5 as Mn,d1 as ia,d2 as ca,aq as la,d3 as ua,ap as da,d4 as fa,ak as R}from"./index-BzL5-pGT.js";import{c as ma,b as ha}from"./useMessageBodyContent-CWGtiddz.js";import{u as pa}from"./useSignature-sxHvGfKr.js";import{b as va}from"./account-form-helpers-DhckT_PN.js";import{u as ga}from"./useDebouncedValue-B7157ZPO.js";import"./reply-CQarAZxU.js";import{a as ya}from"./sections-C6oVXjho.js";import{u as wa}from"./useMediaQuery-7Q3jBluO.js";const Dr=jo("Paperclip",[["path",{d:"M13.234 20.252 21 12.3",key:"1cbrk9"}],["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 0 2.828 2 2 0 0 0 2.828 0l8.414-8.586a4 4 0 0 0 0-5.656 4 4 0 0 0-5.656 0l-8.415 8.585a6 6 0 1 0 8.486 8.486",key:"1pkts6"}]]),ba=({email:e,displayName:t,onRemove:n,className:r})=>d.jsxs("span",{className:ln("inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-accent-2-soft text-sm max-w-[200px]",r),children:[d.jsx("span",{className:"truncate",children:t||e}),d.jsx("button",{type:"button",onClick:n,className:"shrink-0 p-0.5 rounded-full hover:bg-fg-muted/20 transition-colors","aria-label":`Remove ${e}`,children:d.jsx(vr,{className:"size-3"})})]}),Ea=/[\u0000-\u001f\u007f-\u009f\u061c\u200b-\u200f\u2028\u2029\u202a-\u202e\u2066-\u2069\ufeff]/g,xa=/[<>:"|?*]/g,Sa=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\.|$)/i,jn=120,Ra=12,Ca="attachment",Fn=e=>{const t=[...e];if(t.length<=jn)return e;const n=e.lastIndexOf("."),r=n>0&&[...e.slice(n)].length<=Ra?e.slice(n):"",o=jn-[...r].length;return t.slice(0,o).join("")+r},bl=(e,t=Ca)=>{const r=e.replace(Ea,"").split(/[/\\]/),a=(r[r.length-1]??"").replace(xa,"_").replace(/^[.\s]+/,"").replace(/[.\s]+$/,"");if(a.length===0)return Fn(t);const i=Sa.test(a)?`_${a}`:a;return Fn(i)},$n=["KB","MB","GB","TB"],Ta=e=>{if(!Number.isFinite(e)||e<0)return"unknown size";const t=Math.round(e);if(t<1024)return t===1?"1 byte":`${t} bytes`;const n=1023.95;let r=t/1024,o=0;for(;r>=n&&o<$n.length-1;)r/=1024,o+=1;return`${r.toFixed(1).replace(/\.0$/,"")} ${$n[o]}`},Aa=({disabled:e,onAttach:t})=>{const n=s.useRef(null);return d.jsxs(d.Fragment,{children:[d.jsx(un,{variant:"ghost",size:"md","aria-label":"Attach files",title:"Attach files","aria-busy":e,className:"min-h-11 min-w-11 px-2","data-testid":"compose-attach",icon:d.jsx(Dr,{className:"size-4"}),onClick:()=>{e||n.current?.click()}}),d.jsx("input",{ref:n,type:"file",multiple:!0,hidden:!0,"data-testid":"compose-attach-input",onChange:r=>{const o=Array.from(r.currentTarget.files??[]);r.currentTarget.value="",o.length>0&&t(o)}})]})},Da=({save:e})=>e.status==="saving"?d.jsx("output",{className:"animate-pulse text-xs text-fg-muted",children:"Saving..."}):e.status==="saved"?d.jsx("output",{className:"text-xs text-fg-muted",children:"Draft saved"}):e.status==="error"?d.jsx("output",{className:"text-xs text-danger",children:"Save failed"}):e.status==="unsaved"?d.jsx("output",{className:"truncate text-xs text-warning",children:e.reason}):null;function Na({send:e,onSend:t,onBlocked:n,onDiscard:r,save:o={status:"idle"},onAttach:a}){const i=e.status==="sending",c=e.status==="blocked"?e.reason:void 0;return d.jsxs("div",{className:"flex items-center justify-between border-t border-line px-3 py-2",children:[d.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[d.jsx(un,{variant:"primary",size:"md","aria-busy":i,title:c,className:"min-h-11 shrink-0 rounded-full px-4","data-testid":"compose-send",icon:i?d.jsx(gr,{className:"size-4 animate-spin"}):d.jsx(Fo,{className:"size-4"}),onClick:()=>{if(!i){if(c!==void 0){n(c);return}t()}},children:"Send"}),a&&d.jsx(Aa,{disabled:i,onAttach:a}),d.jsx(Da,{save:o})]}),d.jsx(un,{variant:"ghost",size:"md","aria-busy":i,"aria-label":"Discard",className:"min-h-11 min-w-11 px-2 hover:text-danger",icon:d.jsx($o,{className:"size-4"}),onClick:()=>{i||r()}})]})}const Bn=e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim()),Oa=e=>{const t=e.trim();if(!t)return;const n=t.match(/^(.+?)\s*<([^>]+)>$/);if(n){const r=n[1].trim().replace(/^"(.*)"$/,"$1"),o=n[2].trim();if(Bn(o))return{email:o,displayName:r}}if(Bn(t))return{email:t}},ka=e=>{const t=[];let n="",r=!1,o=!1;for(const a of e){if(a==='"'&&(r=!r),a==="<"&&(o=!0),a===">"&&(o=!1),(a===","||a===";")&&!r&&!o){t.push(n),n="";continue}n+=a}return t.push(n),t},Ia=e=>{const t=[],n=[];for(const r of ka(e)){const o=Oa(r);if(o){t.push(o);continue}r.trim()&&n.push(r.trim())}return{entries:t,unparsed:n.join(", ")}},La=["Tab",","],Pa=150,_a=({label:e,addresses:t,onChange:n,placeholder:r,suggestions:o=[],onQueryChange:a,onPendingChange:i,ref:c})=>{const[u,m]=s.useState(""),f=s.useRef(null),l=s.useMemo(()=>Ia(u),[u]);s.useEffect(()=>{i?.(l)},[l,i]);const h=s.useRef(void 0),g=s.useCallback(()=>{h.current!==void 0&&(clearTimeout(h.current),h.current=void 0)},[]);s.useEffect(()=>g,[g]);const x=new Set(t.map(b=>b.email.toLowerCase())),p=u.length>=2?o.filter(b=>!x.has(b.email.toLowerCase())):[],E=s.useCallback(b=>{m(b),a?.(b)},[a]),w=s.useCallback(b=>{g(),!x.has(b.email.toLowerCase())&&(n([...t,b]),E(""))},[t,x,n,E,g]),A=s.useCallback(b=>{n(t.filter((P,C)=>C!==b))},[t,n]),y=s.useCallback(b=>{w(b),f.current?.focus()},[w]),v=s.useCallback(()=>{if(g(),l.entries.length===0)return{addresses:t,unparsed:l.unparsed};const b=new Set(x),P=[...t];for(const C of l.entries){const q=C.email.toLowerCase();b.has(q)||(b.add(q),P.push(C))}return n(P),E(l.unparsed),{addresses:P,unparsed:l.unparsed}},[l,t,x,n,E,g]),D=s.useCallback(()=>{g(),E("")},[E,g]);s.useImperativeHandle(c,()=>({commitPending:v,clearPending:D}),[v,D]);const _=s.useRef(v);s.useEffect(()=>{_.current=v},[v]);const S=Bo({count:p.length,acceptKeys:La,onAccept:b=>y(p[b])}),k=s.useMemo(()=>p.map(b=>({value:b.email,label:b.displayName??b.email,...b.displayName?{hint:b.email}:{}})),[p]),N=s.useCallback(b=>{if(b.key==="Backspace"&&u===""&&t.length>0){A(t.length-1);return}S.handleKeyDown(b)||(b.key==="Enter"||b.key==="Tab"||b.key===",")&&u.trim()&&(b.preventDefault(),v())},[u,t.length,A,S.handleKeyDown,v]),F=s.useCallback(()=>{g(),h.current=setTimeout(()=>{h.current=void 0,_.current(),S.dismiss()},Pa)},[g,S.dismiss]);return d.jsxs("div",{className:"relative","data-address-field":e,children:[d.jsxs("div",{className:"flex items-start gap-2",children:[d.jsxs("label",{htmlFor:`address-field-${e}`,className:"text-sm text-fg-muted shrink-0 w-12 pt-1.5",children:[e,":"]}),d.jsxs("div",{className:"flex-1 flex flex-wrap items-center gap-1 min-h-[36px] px-2 py-1 border rounded-md bg-canvas cursor-text",onClick:()=>f.current?.focus(),onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&f.current?.focus()},children:[t.map((b,P)=>d.jsx(ba,{email:b.email,displayName:b.displayName,onRemove:()=>A(P)},b.email)),d.jsx("input",{ref:f,id:`address-field-${e}`,type:"text",value:u,onChange:b=>{S.reopen(),E(b.target.value)},onKeyDown:N,onBlur:F,placeholder:t.length===0?r:"",className:"flex-1 min-w-[120px] bg-transparent outline-none text-sm py-0.5",autoComplete:"off",...S.comboboxProps})]})]}),S.open&&d.jsx(Uo,{id:S.listId,suggestions:k,activeIndex:S.activeIndex,optionId:S.optionId,onPick:b=>{const P=p.find(C=>C.email===b.value);P&&y(P)},onHighlight:S.setActiveIndex,label:`${e} suggestions`,className:"absolute left-12 right-0 z-50 mt-1 max-h-[200px] shadow-lg"})]})},Ma=({state:e})=>e.status==="uploading"?d.jsx(gr,{className:"size-4 shrink-0 animate-spin text-fg-subtle","aria-hidden":!0}):e.status==="failed"?d.jsx(Ho,{className:"size-4 shrink-0 text-danger","aria-hidden":!0}):d.jsx(Dr,{className:"size-4 shrink-0 text-fg-subtle","aria-hidden":!0});function ja({items:e,onRemove:t,onRetry:n,className:r}){return e.length===0?null:d.jsx("ul",{"aria-label":"Attached files","data-testid":"compose-attachments",className:ln("flex flex-col gap-1 px-3 py-2",r),children:e.map(o=>d.jsxs("li",{"data-testid":"compose-attachment","data-state":o.state.status,className:ln("rounded-sm border bg-surface",o.state.status==="failed"?"border-danger/40":"border-line"),children:[d.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5",children:[d.jsx(Ma,{state:o.state}),d.jsxs("span",{className:"min-w-0 flex-1",children:[d.jsx("bdi",{className:"block truncate text-sm text-fg",title:o.filename,children:o.filename}),d.jsxs("span",{className:"block text-2xs text-fg-subtle",children:[Ta(o.sizeBytes),o.state.status==="uploading"?" · Uploading…":""]})]}),o.state.status==="failed"&&o.state.retryable&&d.jsx("button",{type:"button",onClick:()=>n(o.key),className:"text-xs font-medium text-accent hover:underline",children:"Try again"}),d.jsx("button",{type:"button","aria-label":`Remove ${o.filename}`,onClick:()=>t(o.key),className:"inline-flex size-8 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-sunken hover:text-fg",children:d.jsx(vr,{className:"size-4","aria-hidden":!0})})]}),o.state.status==="failed"&&d.jsx("p",{role:"alert","data-testid":"compose-attachment-error",className:"border-t border-danger/30 bg-danger-soft px-2 py-1.5 text-xs text-danger",children:o.state.reason})]},o.key))})}const Fa=()=>d.jsxs("div",{"aria-hidden":"true","data-testid":"compose-body-skeleton",className:"min-h-[120px] px-3 py-2",children:[d.jsx("div",{className:"mb-2 h-8 animate-pulse rounded bg-surface-sunken"}),d.jsx("div",{className:"min-h-[80px] animate-pulse rounded bg-surface-sunken/50"})]}),$a=e=>Array.from(e.dataTransfer?.types??[]).includes("Files");function Ba({banner:e,header:t,children:n,quoted:r,attachments:o,actionBar:a,layout:i="fill",onDropFiles:c}){const u=i==="fill",[m,f]=s.useState(!1),l=c?{onDragOver:h=>{$a(h)&&(h.preventDefault(),f(!0))},onDragLeave:h=>{h.relatedTarget instanceof Node&&h.currentTarget.contains(h.relatedTarget)||f(!1)},onDrop:h=>{f(!1);const g=Array.from(h.dataTransfer?.files??[]);g.length!==0&&(h.preventDefault(),c(g))}}:{};return d.jsxs("div",{className:[u?"flex h-full min-h-0 flex-col":"flex flex-col",m&&"outline-2 -outline-offset-2 outline-dashed outline-accent"].filter(Boolean).join(" "),"data-testid":"compose-drop-target","data-dropping":m||void 0,...l,children:[e,t,d.jsxs("div",{className:u?"flex min-h-0 flex-1 flex-col overflow-auto":"flex flex-col","data-testid":"compose-body-area",children:[n,r&&d.jsx("div",{className:"shrink-0 px-3 pb-2",children:r})]}),o&&d.jsx("div",{className:"shrink-0",children:o}),u?a:d.jsx("div",{className:"sticky bottom-0 z-10 bg-canvas",children:a})]})}const Kt=({label:e,onClick:t})=>d.jsx("button",{type:"button",onClick:t,className:"text-xs text-fg-muted hover:text-fg transition-colors",children:e}),Ua=({to:e,cc:t,bcc:n,subject:r})=>{const o=[];return e.length>0&&o.push(`To: ${e.map(a=>a.displayName??a.email).join(", ")}`),t.length>0&&o.push(`Cc: ${t.length}`),n.length>0&&o.push(`Bcc: ${n.length}`),r&&o.push(r),o.join(" · ")},Ha=({collapsed:e=!1,summary:t="",onExpand:n,from:r,to:o,cc:a,bcc:i,subject:c,onShowCc:u,onShowBcc:m})=>e?d.jsxs("button",{type:"button",onClick:n,"aria-label":"Show recipients and subject",className:"flex min-h-11 w-full items-center gap-2 overflow-hidden border-b border-line px-3 py-1.5 text-left transition-colors hover:bg-surface-sunken","data-testid":"compose-header-collapsed",children:[d.jsx("span",{className:"truncate text-xs text-fg-muted",children:t||"…"}),d.jsx(yr,{className:"ml-auto size-4 shrink-0 text-fg-muted","aria-hidden":"true"})]}):d.jsxs("div",{className:"space-y-1 px-3 py-2 border-b border-line",children:[r,o,a??d.jsxs("div",{className:"flex gap-2 pl-14",children:[d.jsx(Kt,{label:"Cc",onClick:u}),d.jsx(Kt,{label:"Bcc",onClick:m})]}),a&&!i&&d.jsx("div",{className:"pl-14",children:d.jsx(Kt,{label:"Bcc",onClick:m})}),i,c]}),Nr="This message is attachments only, and attachments aren't forwarded — a forward would arrive with nothing of the original in it.",Wa="This message is attachments only, so there's nothing to quote and your reply goes out without the original.",za=e=>e==="forward"?Nr:Wa,Va=({mode:e})=>d.jsx(wr,{tone:"warning","data-testid":"compose-quote-missing",children:d.jsx("span",{children:za(e)})}),dn="This account can't send mail until SMTP is configured.",qa=({onConfigure:e,configureRef:t})=>d.jsxs("div",{role:"alert","data-testid":"compose-smtp-missing-banner",className:"flex items-start gap-3 border-b border-warning/50 bg-warning/10 px-3 py-2",children:[d.jsx(Wo,{className:"size-5 shrink-0 mt-0.5 text-warning","aria-hidden":"true"}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsx("p",{className:"text-sm font-medium text-warning",children:dn}),d.jsxs("button",{ref:t,type:"button",onClick:e,"data-testid":"compose-smtp-configure",className:"mt-1 inline-flex items-center gap-1 text-xs font-medium text-warning hover:underline",children:["Configure SMTP",d.jsx(zo,{className:"size-3","aria-hidden":"true"})]})]})]}),Ka=({value:e,onChange:t})=>d.jsxs("div",{className:"flex items-start gap-2",children:[d.jsx("label",{className:"text-sm text-fg-muted shrink-0 w-12 pt-1.5",children:"Subj:"}),d.jsx("input",{type:"text",value:e,onChange:n=>t(n.target.value),className:"flex-1 px-2 py-1.5 border rounded-md bg-canvas text-sm",placeholder:"Subject","data-subject-field":!0})]}),Ya=({text:e,html:t,senderName:n,date:r})=>{const[o,a]=s.useState(!1);if(!e&&!t)return null;const i=[n,r].filter(Boolean).join(" on ");return d.jsxs("div",{className:"mt-2 px-3 pb-2",children:[d.jsxs("button",{type:"button",onClick:()=>a(!o),"aria-expanded":o,className:"flex items-center gap-1 text-xs text-fg-muted hover:text-fg transition-colors",children:[o?d.jsx(yr,{className:"size-3"}):d.jsx(Vo,{className:"size-3"}),i?`${i} wrote:`:"Show quoted text"]}),o&&d.jsx("blockquote",{className:"mt-2 pl-3 border-l-2 border-fg-subtle/30 text-sm text-fg-muted [&_a]:text-accent [&_a]:underline [&_blockquote]:pl-3 [&_blockquote]:border-l-2 [&_blockquote]:border-fg-subtle/30",children:t?d.jsx("div",{dangerouslySetInnerHTML:{__html:t}}):e.split(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/rich-text-spellcheck-worker-provider-Bk8cqxyg.js","assets/index-CL_fwLHN.js","assets/index-Cr6oUxXl.css","assets/rich-text-spellcheck-provider-J8m9wz6A.js","assets/rich-text-BBwYPM6F.js","assets/roving-focus-FWOr5tBU.js","assets/confirm-dialog-q8tbS_22.js","assets/useMediaQuery-DiQ0fGER.js","assets/bottom-sheet-Bc0vwv2J.js","assets/popover-menu-fjlAfNO1.js","assets/undo-2-Bdx8L5xj.js","assets/useMessageBodyContent-D-LJBFh4.js","assets/reply-DvdgFS16.js","assets/useSignature-BkzkUbjz.js","assets/account-form-helpers-DhckT_PN.js","assets/useDebouncedValue-BTZsNKEh.js","assets/sections-Rf3k05-_.js"])))=>i.map(i=>d[i]);
2
+ import{b as jo,j as d,X as vr,o as ln,d as un,L as gr,x as Fo,T as $o,r as s,cK as Bo,cL as Uo,w as Ho,t as yr,B as wr,ah as Wo,cM as zo,v as Vo,cN as qo,cO as wn,c6 as br,cP as xe,cQ as Er,cR as Ko,cE as Yo,cS as Se,g as _e,aE as Me,cT as Go,cU as Xo,cV as xr,cW as Qo,aC as Sr,aD as Rr,N as Zo,f as Cr,cX as Jo,Z as ea,a as At,bH as ta,cY as Tr,cZ as na,c_ as ra,bJ as oa,c as Ar,c$ as aa,ao as sa,d0 as _n,b5 as Mn,d1 as ia,d2 as ca,aq as la,d3 as ua,ap as da,d4 as fa,ak as R}from"./index-CL_fwLHN.js";import{c as ma,b as ha}from"./useMessageBodyContent-D-LJBFh4.js";import{u as pa}from"./useSignature-BkzkUbjz.js";import{b as va}from"./account-form-helpers-DhckT_PN.js";import{u as ga}from"./useDebouncedValue-BTZsNKEh.js";import"./reply-DvdgFS16.js";import{a as ya}from"./sections-Rf3k05-_.js";import{u as wa}from"./useMediaQuery-DiQ0fGER.js";const Dr=jo("Paperclip",[["path",{d:"M13.234 20.252 21 12.3",key:"1cbrk9"}],["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 0 2.828 2 2 0 0 0 2.828 0l8.414-8.586a4 4 0 0 0 0-5.656 4 4 0 0 0-5.656 0l-8.415 8.585a6 6 0 1 0 8.486 8.486",key:"1pkts6"}]]),ba=({email:e,displayName:t,onRemove:n,className:r})=>d.jsxs("span",{className:ln("inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-accent-2-soft text-sm max-w-[200px]",r),children:[d.jsx("span",{className:"truncate",children:t||e}),d.jsx("button",{type:"button",onClick:n,className:"shrink-0 p-0.5 rounded-full hover:bg-fg-muted/20 transition-colors","aria-label":`Remove ${e}`,children:d.jsx(vr,{className:"size-3"})})]}),Ea=/[\u0000-\u001f\u007f-\u009f\u061c\u200b-\u200f\u2028\u2029\u202a-\u202e\u2066-\u2069\ufeff]/g,xa=/[<>:"|?*]/g,Sa=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\.|$)/i,jn=120,Ra=12,Ca="attachment",Fn=e=>{const t=[...e];if(t.length<=jn)return e;const n=e.lastIndexOf("."),r=n>0&&[...e.slice(n)].length<=Ra?e.slice(n):"",o=jn-[...r].length;return t.slice(0,o).join("")+r},bl=(e,t=Ca)=>{const r=e.replace(Ea,"").split(/[/\\]/),a=(r[r.length-1]??"").replace(xa,"_").replace(/^[.\s]+/,"").replace(/[.\s]+$/,"");if(a.length===0)return Fn(t);const i=Sa.test(a)?`_${a}`:a;return Fn(i)},$n=["KB","MB","GB","TB"],Ta=e=>{if(!Number.isFinite(e)||e<0)return"unknown size";const t=Math.round(e);if(t<1024)return t===1?"1 byte":`${t} bytes`;const n=1023.95;let r=t/1024,o=0;for(;r>=n&&o<$n.length-1;)r/=1024,o+=1;return`${r.toFixed(1).replace(/\.0$/,"")} ${$n[o]}`},Aa=({disabled:e,onAttach:t})=>{const n=s.useRef(null);return d.jsxs(d.Fragment,{children:[d.jsx(un,{variant:"ghost",size:"md","aria-label":"Attach files",title:"Attach files","aria-busy":e,className:"min-h-11 min-w-11 px-2","data-testid":"compose-attach",icon:d.jsx(Dr,{className:"size-4"}),onClick:()=>{e||n.current?.click()}}),d.jsx("input",{ref:n,type:"file",multiple:!0,hidden:!0,"data-testid":"compose-attach-input",onChange:r=>{const o=Array.from(r.currentTarget.files??[]);r.currentTarget.value="",o.length>0&&t(o)}})]})},Da=({save:e})=>e.status==="saving"?d.jsx("output",{className:"animate-pulse text-xs text-fg-muted",children:"Saving..."}):e.status==="saved"?d.jsx("output",{className:"text-xs text-fg-muted",children:"Draft saved"}):e.status==="error"?d.jsx("output",{className:"text-xs text-danger",children:"Save failed"}):e.status==="unsaved"?d.jsx("output",{className:"truncate text-xs text-warning",children:e.reason}):null;function Na({send:e,onSend:t,onBlocked:n,onDiscard:r,save:o={status:"idle"},onAttach:a}){const i=e.status==="sending",c=e.status==="blocked"?e.reason:void 0;return d.jsxs("div",{className:"flex items-center justify-between border-t border-line px-3 py-2",children:[d.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[d.jsx(un,{variant:"primary",size:"md","aria-busy":i,title:c,className:"min-h-11 shrink-0 rounded-full px-4","data-testid":"compose-send",icon:i?d.jsx(gr,{className:"size-4 animate-spin"}):d.jsx(Fo,{className:"size-4"}),onClick:()=>{if(!i){if(c!==void 0){n(c);return}t()}},children:"Send"}),a&&d.jsx(Aa,{disabled:i,onAttach:a}),d.jsx(Da,{save:o})]}),d.jsx(un,{variant:"ghost",size:"md","aria-busy":i,"aria-label":"Discard",className:"min-h-11 min-w-11 px-2 hover:text-danger",icon:d.jsx($o,{className:"size-4"}),onClick:()=>{i||r()}})]})}const Bn=e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim()),Oa=e=>{const t=e.trim();if(!t)return;const n=t.match(/^(.+?)\s*<([^>]+)>$/);if(n){const r=n[1].trim().replace(/^"(.*)"$/,"$1"),o=n[2].trim();if(Bn(o))return{email:o,displayName:r}}if(Bn(t))return{email:t}},ka=e=>{const t=[];let n="",r=!1,o=!1;for(const a of e){if(a==='"'&&(r=!r),a==="<"&&(o=!0),a===">"&&(o=!1),(a===","||a===";")&&!r&&!o){t.push(n),n="";continue}n+=a}return t.push(n),t},Ia=e=>{const t=[],n=[];for(const r of ka(e)){const o=Oa(r);if(o){t.push(o);continue}r.trim()&&n.push(r.trim())}return{entries:t,unparsed:n.join(", ")}},La=["Tab",","],Pa=150,_a=({label:e,addresses:t,onChange:n,placeholder:r,suggestions:o=[],onQueryChange:a,onPendingChange:i,ref:c})=>{const[u,m]=s.useState(""),f=s.useRef(null),l=s.useMemo(()=>Ia(u),[u]);s.useEffect(()=>{i?.(l)},[l,i]);const h=s.useRef(void 0),g=s.useCallback(()=>{h.current!==void 0&&(clearTimeout(h.current),h.current=void 0)},[]);s.useEffect(()=>g,[g]);const x=new Set(t.map(b=>b.email.toLowerCase())),p=u.length>=2?o.filter(b=>!x.has(b.email.toLowerCase())):[],E=s.useCallback(b=>{m(b),a?.(b)},[a]),w=s.useCallback(b=>{g(),!x.has(b.email.toLowerCase())&&(n([...t,b]),E(""))},[t,x,n,E,g]),A=s.useCallback(b=>{n(t.filter((P,C)=>C!==b))},[t,n]),y=s.useCallback(b=>{w(b),f.current?.focus()},[w]),v=s.useCallback(()=>{if(g(),l.entries.length===0)return{addresses:t,unparsed:l.unparsed};const b=new Set(x),P=[...t];for(const C of l.entries){const q=C.email.toLowerCase();b.has(q)||(b.add(q),P.push(C))}return n(P),E(l.unparsed),{addresses:P,unparsed:l.unparsed}},[l,t,x,n,E,g]),D=s.useCallback(()=>{g(),E("")},[E,g]);s.useImperativeHandle(c,()=>({commitPending:v,clearPending:D}),[v,D]);const _=s.useRef(v);s.useEffect(()=>{_.current=v},[v]);const S=Bo({count:p.length,acceptKeys:La,onAccept:b=>y(p[b])}),k=s.useMemo(()=>p.map(b=>({value:b.email,label:b.displayName??b.email,...b.displayName?{hint:b.email}:{}})),[p]),N=s.useCallback(b=>{if(b.key==="Backspace"&&u===""&&t.length>0){A(t.length-1);return}S.handleKeyDown(b)||(b.key==="Enter"||b.key==="Tab"||b.key===",")&&u.trim()&&(b.preventDefault(),v())},[u,t.length,A,S.handleKeyDown,v]),F=s.useCallback(()=>{g(),h.current=setTimeout(()=>{h.current=void 0,_.current(),S.dismiss()},Pa)},[g,S.dismiss]);return d.jsxs("div",{className:"relative","data-address-field":e,children:[d.jsxs("div",{className:"flex items-start gap-2",children:[d.jsxs("label",{htmlFor:`address-field-${e}`,className:"text-sm text-fg-muted shrink-0 w-12 pt-1.5",children:[e,":"]}),d.jsxs("div",{className:"flex-1 flex flex-wrap items-center gap-1 min-h-[36px] px-2 py-1 border rounded-md bg-canvas cursor-text",onClick:()=>f.current?.focus(),onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&f.current?.focus()},children:[t.map((b,P)=>d.jsx(ba,{email:b.email,displayName:b.displayName,onRemove:()=>A(P)},b.email)),d.jsx("input",{ref:f,id:`address-field-${e}`,type:"text",value:u,onChange:b=>{S.reopen(),E(b.target.value)},onKeyDown:N,onBlur:F,placeholder:t.length===0?r:"",className:"flex-1 min-w-[120px] bg-transparent outline-none text-sm py-0.5",autoComplete:"off",...S.comboboxProps})]})]}),S.open&&d.jsx(Uo,{id:S.listId,suggestions:k,activeIndex:S.activeIndex,optionId:S.optionId,onPick:b=>{const P=p.find(C=>C.email===b.value);P&&y(P)},onHighlight:S.setActiveIndex,label:`${e} suggestions`,className:"absolute left-12 right-0 z-50 mt-1 max-h-[200px] shadow-lg"})]})},Ma=({state:e})=>e.status==="uploading"?d.jsx(gr,{className:"size-4 shrink-0 animate-spin text-fg-subtle","aria-hidden":!0}):e.status==="failed"?d.jsx(Ho,{className:"size-4 shrink-0 text-danger","aria-hidden":!0}):d.jsx(Dr,{className:"size-4 shrink-0 text-fg-subtle","aria-hidden":!0});function ja({items:e,onRemove:t,onRetry:n,className:r}){return e.length===0?null:d.jsx("ul",{"aria-label":"Attached files","data-testid":"compose-attachments",className:ln("flex flex-col gap-1 px-3 py-2",r),children:e.map(o=>d.jsxs("li",{"data-testid":"compose-attachment","data-state":o.state.status,className:ln("rounded-sm border bg-surface",o.state.status==="failed"?"border-danger/40":"border-line"),children:[d.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5",children:[d.jsx(Ma,{state:o.state}),d.jsxs("span",{className:"min-w-0 flex-1",children:[d.jsx("bdi",{className:"block truncate text-sm text-fg",title:o.filename,children:o.filename}),d.jsxs("span",{className:"block text-2xs text-fg-subtle",children:[Ta(o.sizeBytes),o.state.status==="uploading"?" · Uploading…":""]})]}),o.state.status==="failed"&&o.state.retryable&&d.jsx("button",{type:"button",onClick:()=>n(o.key),className:"text-xs font-medium text-accent hover:underline",children:"Try again"}),d.jsx("button",{type:"button","aria-label":`Remove ${o.filename}`,onClick:()=>t(o.key),className:"inline-flex size-8 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-sunken hover:text-fg",children:d.jsx(vr,{className:"size-4","aria-hidden":!0})})]}),o.state.status==="failed"&&d.jsx("p",{role:"alert","data-testid":"compose-attachment-error",className:"border-t border-danger/30 bg-danger-soft px-2 py-1.5 text-xs text-danger",children:o.state.reason})]},o.key))})}const Fa=()=>d.jsxs("div",{"aria-hidden":"true","data-testid":"compose-body-skeleton",className:"min-h-[120px] px-3 py-2",children:[d.jsx("div",{className:"mb-2 h-8 animate-pulse rounded bg-surface-sunken"}),d.jsx("div",{className:"min-h-[80px] animate-pulse rounded bg-surface-sunken/50"})]}),$a=e=>Array.from(e.dataTransfer?.types??[]).includes("Files");function Ba({banner:e,header:t,children:n,quoted:r,attachments:o,actionBar:a,layout:i="fill",onDropFiles:c}){const u=i==="fill",[m,f]=s.useState(!1),l=c?{onDragOver:h=>{$a(h)&&(h.preventDefault(),f(!0))},onDragLeave:h=>{h.relatedTarget instanceof Node&&h.currentTarget.contains(h.relatedTarget)||f(!1)},onDrop:h=>{f(!1);const g=Array.from(h.dataTransfer?.files??[]);g.length!==0&&(h.preventDefault(),c(g))}}:{};return d.jsxs("div",{className:[u?"flex h-full min-h-0 flex-col":"flex flex-col",m&&"outline-2 -outline-offset-2 outline-dashed outline-accent"].filter(Boolean).join(" "),"data-testid":"compose-drop-target","data-dropping":m||void 0,...l,children:[e,t,d.jsxs("div",{className:u?"flex min-h-0 flex-1 flex-col overflow-auto":"flex flex-col","data-testid":"compose-body-area",children:[n,r&&d.jsx("div",{className:"shrink-0 px-3 pb-2",children:r})]}),o&&d.jsx("div",{className:"shrink-0",children:o}),u?a:d.jsx("div",{className:"sticky bottom-0 z-10 bg-canvas",children:a})]})}const Kt=({label:e,onClick:t})=>d.jsx("button",{type:"button",onClick:t,className:"text-xs text-fg-muted hover:text-fg transition-colors",children:e}),Ua=({to:e,cc:t,bcc:n,subject:r})=>{const o=[];return e.length>0&&o.push(`To: ${e.map(a=>a.displayName??a.email).join(", ")}`),t.length>0&&o.push(`Cc: ${t.length}`),n.length>0&&o.push(`Bcc: ${n.length}`),r&&o.push(r),o.join(" · ")},Ha=({collapsed:e=!1,summary:t="",onExpand:n,from:r,to:o,cc:a,bcc:i,subject:c,onShowCc:u,onShowBcc:m})=>e?d.jsxs("button",{type:"button",onClick:n,"aria-label":"Show recipients and subject",className:"flex min-h-11 w-full items-center gap-2 overflow-hidden border-b border-line px-3 py-1.5 text-left transition-colors hover:bg-surface-sunken","data-testid":"compose-header-collapsed",children:[d.jsx("span",{className:"truncate text-xs text-fg-muted",children:t||"…"}),d.jsx(yr,{className:"ml-auto size-4 shrink-0 text-fg-muted","aria-hidden":"true"})]}):d.jsxs("div",{className:"space-y-1 px-3 py-2 border-b border-line",children:[r,o,a??d.jsxs("div",{className:"flex gap-2 pl-14",children:[d.jsx(Kt,{label:"Cc",onClick:u}),d.jsx(Kt,{label:"Bcc",onClick:m})]}),a&&!i&&d.jsx("div",{className:"pl-14",children:d.jsx(Kt,{label:"Bcc",onClick:m})}),i,c]}),Nr="This message is attachments only, and attachments aren't forwarded — a forward would arrive with nothing of the original in it.",Wa="This message is attachments only, so there's nothing to quote and your reply goes out without the original.",za=e=>e==="forward"?Nr:Wa,Va=({mode:e})=>d.jsx(wr,{tone:"warning","data-testid":"compose-quote-missing",children:d.jsx("span",{children:za(e)})}),dn="This account can't send mail until SMTP is configured.",qa=({onConfigure:e,configureRef:t})=>d.jsxs("div",{role:"alert","data-testid":"compose-smtp-missing-banner",className:"flex items-start gap-3 border-b border-warning/50 bg-warning/10 px-3 py-2",children:[d.jsx(Wo,{className:"size-5 shrink-0 mt-0.5 text-warning","aria-hidden":"true"}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsx("p",{className:"text-sm font-medium text-warning",children:dn}),d.jsxs("button",{ref:t,type:"button",onClick:e,"data-testid":"compose-smtp-configure",className:"mt-1 inline-flex items-center gap-1 text-xs font-medium text-warning hover:underline",children:["Configure SMTP",d.jsx(zo,{className:"size-3","aria-hidden":"true"})]})]})]}),Ka=({value:e,onChange:t})=>d.jsxs("div",{className:"flex items-start gap-2",children:[d.jsx("label",{className:"text-sm text-fg-muted shrink-0 w-12 pt-1.5",children:"Subj:"}),d.jsx("input",{type:"text",value:e,onChange:n=>t(n.target.value),className:"flex-1 px-2 py-1.5 border rounded-md bg-canvas text-sm",placeholder:"Subject","data-subject-field":!0})]}),Ya=({text:e,html:t,senderName:n,date:r})=>{const[o,a]=s.useState(!1);if(!e&&!t)return null;const i=[n,r].filter(Boolean).join(" on ");return d.jsxs("div",{className:"mt-2 px-3 pb-2",children:[d.jsxs("button",{type:"button",onClick:()=>a(!o),"aria-expanded":o,className:"flex items-center gap-1 text-xs text-fg-muted hover:text-fg transition-colors",children:[o?d.jsx(yr,{className:"size-3"}):d.jsx(Vo,{className:"size-3"}),i?`${i} wrote:`:"Show quoted text"]}),o&&d.jsx("blockquote",{className:"mt-2 pl-3 border-l-2 border-fg-subtle/30 text-sm text-fg-muted [&_a]:text-accent [&_a]:underline [&_blockquote]:pl-3 [&_blockquote]:border-l-2 [&_blockquote]:border-fg-subtle/30",children:t?d.jsx("div",{dangerouslySetInnerHTML:{__html:t}}):e.split(`
3
3
  `).map((c,u)=>d.jsx("p",{className:"min-h-[1.2em]",children:c},u))})]})},Ga=["p","br","div","h1","h2","h3","h4","h5","h6","strong","b","em","i","u","s","ul","ol","li","blockquote","pre","code","hr","table","thead","tbody","tr","th","td","a","img"],Xa=["href","src","alt","colspan","rowspan","lang","dir"],Qa=/^(?:https?:|mailto:)/i,Za=/^(?:https:|data:image\/)/i,Ja=/^cid:(.+)$/i,fn=()=>!1;let mn=fn;const es=e=>{const t=Ja.exec(e);return t?mn(t[1]):Za.test(e)},ts="max-width:100%;height:auto",ns=e=>{const t=qo();if(!t.isSupported)throw new Error("adopted HTML cannot be sanitized: no DOM is available");return t.addHook("afterSanitizeAttributes",n=>{if(n.tagName==="A"){Qa.test(n.getAttribute("href")??"")||n.removeAttribute("href"),e==="quoted"&&(n.setAttribute("target","_blank"),n.setAttribute("rel","noopener noreferrer nofollow"));return}if(n.tagName==="IMG"){if(e==="quoted"){n.remove();return}if(!es(n.getAttribute("src")??"")){n.remove();return}n.setAttribute("style",ts)}}),t},Un=new Map,rs=e=>{const t=Un.get(e);if(t)return t;const n=ns(e);return Un.set(e,n),n},Or=(e,t)=>rs(t).sanitize(e,{ALLOWED_TAGS:Ga,ALLOWED_ATTR:Xa,ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!1}),El=(e,t=fn)=>{mn=t;try{return Or(e,"outgoing")}finally{mn=fn}},os=e=>Or(e,"quoted"),as=e=>typeof e=="string"&&e.length>0?"rich":"plain",xl=(e,t)=>t.length>0,ss={plain:"Couldn't switch to plain text",rich:"Couldn't switch to rich text"},Sl=(e,t,n)=>t.trim()===""||n.trim()!==""?{outcome:"switch"}:{outcome:"blocked",title:ss[e],detail:"The conversion came back empty, so your message is unchanged."};function Re(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e?.(o),n===!1||!o||!o.defaultPrevented)return t?.(o)}}function Hn(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function is(...e){return t=>{let n=!1;const r=e.map(o=>{const a=Hn(o,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let o=0;o<r.length;o++){const a=r[o];typeof a=="function"?a():Hn(e[o],null)}}}}function je(...e){return s.useCallback(is(...e),e)}function cs(e,t=[]){let n=[];function r(a,i){const c=s.createContext(i);c.displayName=a+"Context";const u=n.length;n=[...n,i];const m=l=>{const{scope:h,children:g,...x}=l,p=h?.[e]?.[u]||c,E=s.useMemo(()=>x,Object.values(x));return d.jsx(p.Provider,{value:E,children:g})};m.displayName=a+"Provider";function f(l,h,g={}){const{optional:x=!1}=g,p=h?.[e]?.[u]||c,E=s.useContext(p);if(E)return E;if(i!==void 0)return i;if(!x)throw new Error(`\`${l}\` must be used within \`${a}\``)}return[m,f]}const o=()=>{const a=n.map(i=>s.createContext(i));return function(c){const u=c?.[e]||a;return s.useMemo(()=>({[`__scope${e}`]:{...c,[e]:u}}),[c,u])}};return o.scopeName=e,[r,ls(o,...t)]}function ls(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const i=r.reduce((c,{useScope:u,scopeName:m})=>{const l=u(a)[`__scope${m}`];return{...c,...l}},{});return s.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var nt=globalThis?.document?s.useLayoutEffect:()=>{},us=wn[" useInsertionEffect ".trim().toString()]||nt;function ds({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,a,i]=fs({defaultProp:t,onChange:n}),c=e!==void 0,u=c?e:o;{const f=s.useRef(e!==void 0);s.useEffect(()=>{const l=f.current;l!==c&&console.warn(`${r} is changing from ${l?"controlled":"uncontrolled"} to ${c?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=c},[c,r])}const m=s.useCallback(f=>{if(c){const l=ms(f)?f(e):f;l!==e&&i.current?.(l)}else a(f)},[c,e,a,i]);return[u,m]}function fs({defaultProp:e,onChange:t}){const[n,r]=s.useState(e),o=s.useRef(n),a=s.useRef(t);return us(()=>{a.current=t},[t]),s.useEffect(()=>{o.current!==n&&(a.current?.(n),o.current=n)},[n,o]),[n,r,a]}function ms(e){return typeof e=="function"}function kr(e){const t=s.forwardRef((n,r)=>{let{children:o,...a}=n,i=null,c=!1;const u=[];Wn(o)&&typeof pt=="function"&&(o=pt(o._payload)),s.Children.forEach(o,h=>{if(ys(h)){c=!0;const g=h;let x="child"in g.props?g.props.child:g.props.children;Wn(x)&&typeof pt=="function"&&(x=pt(x._payload)),i=ps(g,x),u.push(i?.props?.children)}else u.push(h)}),i?i=s.cloneElement(i,void 0,u):!c&&s.Children.count(o)===1&&s.isValidElement(o)&&(i=o);const m=i?gs(i):void 0,f=je(r,m);if(!i){if(o||o===0)throw new Error(c?xs(e):Es(e));return o}const l=vs(a,i.props??{});return i.type!==s.Fragment&&(l.ref=r?f:m),s.cloneElement(i,l)});return t.displayName=`${e}.Slot`,t}var hs=Symbol.for("radix.slottable"),ps=(e,t)=>{if("child"in e.props){const n=e.props.child;return s.isValidElement(n)?s.cloneElement(n,void 0,e.props.children(n.props.children)):null}return s.isValidElement(t)?t:null};function vs(e,t){const n={...t};for(const r in t){const o=e[r],a=t[r];/^on[A-Z]/.test(r)?o&&a?n[r]=(...c)=>{const u=a(...c);return o(...c),u}:o&&(n[r]=o):r==="style"?n[r]={...o,...a}:r==="className"&&(n[r]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function gs(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function ys(e){return s.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===hs}var ws=Symbol.for("react.lazy");function Wn(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===ws&&"_payload"in e&&bs(e._payload)}function bs(e){return typeof e=="object"&&e!==null&&"then"in e}var Es=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,xs=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,pt=wn[" use ".trim().toString()],Ss=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ge=Ss.reduce((e,t)=>{const n=kr(`Primitive.${t}`),r=s.forwardRef((o,a)=>{const{asChild:i,...c}=o,u=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(u,{...c,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Rs(e,t){e&&br.flushSync(()=>e.dispatchEvent(t))}function rt(e){const t=s.useRef(e);return s.useEffect(()=>{t.current=e}),s.useMemo(()=>((...n)=>t.current?.(...n)),[])}var Cs="DismissableLayer",hn="dismissableLayer.update",Ts="dismissableLayer.pointerDownOutside",As="dismissableLayer.focusOutside",zn,bn=s.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Ir=s.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:o,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:c,onDismiss:u,...m}=e,f=s.useContext(bn),[l,h]=s.useState(null),g=l?.ownerDocument??globalThis?.document,[,x]=s.useState({}),p=je(t,h),E=Array.from(f.layers),[w]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),A=w?E.indexOf(w):-1,y=l?E.indexOf(l):-1,v=f.layersWithOutsidePointerEventsDisabled.size>0,D=y>=A,_=s.useRef(!1),S=Is(b=>{a?.(b),c?.(b),b.defaultPrevented||u?.()},{ownerDocument:g,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:_,dismissableSurfaces:f.dismissableSurfaces,shouldHandlePointerDownOutside:s.useCallback(b=>{if(!(b instanceof Node))return!1;const P=[...f.branches].some(C=>C.contains(b));return D&&!P},[f.branches,D])}),k=Ls(b=>{if(r&&_.current)return;const P=b.target;[...f.branches].some(q=>q.contains(P))||(i?.(b),c?.(b),b.defaultPrevented||u?.())},g),N=l?y===E.length-1:!1,F=rt(b=>{b.key==="Escape"&&(o?.(b),!b.defaultPrevented&&u&&(b.preventDefault(),u()))});return s.useEffect(()=>{if(N)return g.addEventListener("keydown",F,{capture:!0}),()=>g.removeEventListener("keydown",F,{capture:!0})},[g,N,F]),s.useEffect(()=>{if(l)return n&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(zn=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(l)),f.layers.add(l),Vn(),()=>{n&&(f.layersWithOutsidePointerEventsDisabled.delete(l),f.layersWithOutsidePointerEventsDisabled.size===0&&(g.body.style.pointerEvents=zn))}},[l,g,n,f]),s.useEffect(()=>()=>{l&&(f.layers.delete(l),f.layersWithOutsidePointerEventsDisabled.delete(l),Vn())},[l,f]),s.useEffect(()=>{const b=()=>x({});return document.addEventListener(hn,b),()=>document.removeEventListener(hn,b)},[]),d.jsx(ge.div,{...m,ref:p,style:{pointerEvents:v?D?"auto":"none":void 0,...e.style},onFocusCapture:Re(e.onFocusCapture,k.onFocusCapture),onBlurCapture:Re(e.onBlurCapture,k.onBlurCapture),onPointerDownCapture:Re(e.onPointerDownCapture,S.onPointerDownCapture)})});Ir.displayName=Cs;var Ds="DismissableLayerBranch",Ns=s.forwardRef((e,t)=>{const n=s.useContext(bn),r=s.useRef(null),o=je(t,r);return s.useEffect(()=>{const a=r.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),d.jsx(ge.div,{...e,ref:o})});Ns.displayName=Ds;function Os(){const e=s.useContext(bn),[t,n]=s.useState(null);return s.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}var ks=()=>!0;function Is(e,t){const{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:o,dismissableSurfaces:a,shouldHandlePointerDownOutside:i=ks}=t,c=rt(e),u=s.useRef(!1),m=s.useRef(!1),f=s.useRef(new Map),l=s.useRef(()=>{});return s.useEffect(()=>{function h(){m.current=!1,o.current=!1,f.current.clear()}function g(){return Array.from(f.current.values()).some(Boolean)}function x(y){if(!m.current)return;const v=y.target;v instanceof Node&&[...a].some(_=>_.contains(v))||f.current.set(y.type,!0),y.type==="click"&&window.setTimeout(()=>{m.current&&l.current()},0)}function p(y){m.current&&f.current.set(y.type,!1)}const E=y=>{if(y.target&&!u.current){let v=function(){n.removeEventListener("click",l.current);const _=g();h(),_||Lr(Ts,c,D,{discrete:!0})};if(!i(y.target)){n.removeEventListener("click",l.current),h(),u.current=!1;return}const D={originalEvent:y};m.current=!0,o.current=r&&y.button===0,f.current.clear(),!r||y.button!==0?v():(n.removeEventListener("click",l.current),l.current=v,n.addEventListener("click",l.current,{once:!0}))}else n.removeEventListener("click",l.current),h();u.current=!1},w=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const y of w)n.addEventListener(y,x,!0),n.addEventListener(y,p);const A=window.setTimeout(()=>{n.addEventListener("pointerdown",E)},0);return()=>{window.clearTimeout(A),n.removeEventListener("pointerdown",E),n.removeEventListener("click",l.current);for(const y of w)n.removeEventListener(y,x,!0),n.removeEventListener(y,p)}},[n,c,r,o,a,i]),{onPointerDownCapture:()=>u.current=!0}}function Ls(e,t=globalThis?.document){const n=rt(e),r=s.useRef(!1);return s.useEffect(()=>{const o=a=>{a.target&&!r.current&&Lr(As,n,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Vn(){const e=new CustomEvent(hn);document.dispatchEvent(e)}function Lr(e,t,n,{discrete:r}){const o=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Rs(o,a):o.dispatchEvent(a)}var vt=0,Be=null;function Ps(){s.useEffect(()=>{Be||(Be={start:qn(),end:qn()});const{start:e,end:t}=Be;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),vt++,()=>{vt===1&&(Be?.start.remove(),Be?.end.remove(),Be=null),vt=Math.max(0,vt-1)}},[])}function qn(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Yt="focusScope.autoFocusOnMount",Gt="focusScope.autoFocusOnUnmount",Kn={bubbles:!1,cancelable:!0},_s="FocusScope",Pr=s.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...i}=e,[c,u]=s.useState(null),m=rt(o),f=rt(a),l=s.useRef(null),h=je(t,u),g=s.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;s.useEffect(()=>{if(r){let p=function(y){if(g.paused||!c)return;const v=y.target;c.contains(v)?l.current=v:Ee(l.current,{select:!0})},E=function(y){if(g.paused||!c)return;const v=y.relatedTarget;v!==null&&(c.contains(v)||Ee(l.current,{select:!0}))},w=function(y){if(document.activeElement===document.body)for(const D of y)D.removedNodes.length>0&&Ee(c)};document.addEventListener("focusin",p),document.addEventListener("focusout",E);const A=new MutationObserver(w);return c&&A.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",p),document.removeEventListener("focusout",E),A.disconnect()}}},[r,c,g.paused]),s.useEffect(()=>{if(c){Gn.add(g);const p=document.activeElement;if(!c.contains(p)){const w=new CustomEvent(Yt,Kn);c.addEventListener(Yt,m),c.dispatchEvent(w),w.defaultPrevented||(Ms(Us(_r(c)),{select:!0}),document.activeElement===p&&Ee(c))}return()=>{c.removeEventListener(Yt,m),setTimeout(()=>{const w=new CustomEvent(Gt,Kn);c.addEventListener(Gt,f),c.dispatchEvent(w),w.defaultPrevented||Ee(p??document.body,{select:!0}),c.removeEventListener(Gt,f),Gn.remove(g)},0)}}},[c,m,f,g]);const x=s.useCallback(p=>{if(!n&&!r||g.paused)return;const E=p.key==="Tab"&&!p.altKey&&!p.ctrlKey&&!p.metaKey,w=document.activeElement;if(E&&w){const A=p.currentTarget,[y,v]=js(A);y&&v?!p.shiftKey&&w===v?(p.preventDefault(),n&&Ee(y,{select:!0})):p.shiftKey&&w===y&&(p.preventDefault(),n&&Ee(v,{select:!0})):w===A&&p.preventDefault()}},[n,r,g.paused]);return d.jsx(ge.div,{tabIndex:-1,...i,ref:h,onKeyDown:x})});Pr.displayName=_s;function Ms(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Ee(r,{select:t}),document.activeElement!==n)return}function js(e){const t=_r(e),n=Yn(t,e),r=Yn(t.reverse(),e);return[n,r]}function _r(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Yn(e,t){const n=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):Fs(r,{upTo:t})))return r}function Fs(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function $s(e){return e instanceof HTMLInputElement&&"select"in e}function Ee(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&$s(e)&&t&&e.select()}}var Gn=Bs();function Bs(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=Xn(e,t),e.unshift(t)},remove(t){e=Xn(e,t),e[0]?.resume()}}}function Xn(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Us(e){return e.filter(t=>t.tagName!=="A")}var Hs=wn[" useId ".trim().toString()]||(()=>{}),Ws=0;function Xt(e){const[t,n]=s.useState(Hs());return nt(()=>{n(r=>r??String(Ws++))},[e]),e||(t?`radix-${t}`:"")}var zs="Portal",Mr=s.forwardRef((e,t)=>{const{container:n,...r}=e,[o,a]=s.useState(!1);nt(()=>a(!0),[]);const i=n||o&&globalThis?.document?.body;return i?br.createPortal(d.jsx(ge.div,{...r,ref:t}),i):null});Mr.displayName=zs;function Vs(e,t){return s.useReducer((n,r)=>t[n][r]??n,e)}var Ot=e=>{const{present:t,children:n}=e,r=qs(t),o=typeof n=="function"?n({present:r.isPresent}):s.Children.only(n),a=Ks(r.ref,Ys(o));return typeof n=="function"||r.isPresent?s.cloneElement(o,{ref:a}):null};Ot.displayName="Presence";function qs(e){const[t,n]=s.useState(),r=s.useRef(null),o=s.useRef(e),a=s.useRef("none"),i=s.useRef(void 0),c=e?"mounted":"unmounted",[u,m]=Vs(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return s.useEffect(()=>{u==="mounted"?(a.current=i.current??Je(r.current),i.current=void 0):a.current="none"},[u]),nt(()=>{const f=r.current,l=o.current;if(l!==e){const g=a.current,x=Je(f);e?(i.current=x,m("MOUNT")):x==="none"||f?.display==="none"?m("UNMOUNT"):m(l&&g!==x?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,m]),nt(()=>{if(t){let f;const l=t.ownerDocument.defaultView??window,h=x=>{const E=Je(r.current).includes(CSS.escape(x.animationName));if(x.target===t&&E&&(m("ANIMATION_END"),!o.current)){const w=t.style.animationFillMode;t.style.animationFillMode="forwards",f=l.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=w)})}},g=x=>{x.target===t&&(a.current=Je(r.current))};return t.addEventListener("animationstart",g),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{l.clearTimeout(f),t.removeEventListener("animationstart",g),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else m("ANIMATION_END")},[t,m]),{isPresent:["mounted","unmountSuspended"].includes(u),ref:s.useCallback(f=>{if(f){const l=getComputedStyle(f);r.current=l,i.current=Je(l)}else r.current=null;n(f)},[])}}function Qn(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Ks(...e){const t=s.useRef(e);return t.current=e,s.useCallback(n=>{const r=t.current;let o=!1;const a=r.map(i=>{const c=Qn(i,n);return!o&&typeof c=="function"&&(o=!0),c});if(o)return()=>{for(let i=0;i<a.length;i++){const c=a[i];typeof c=="function"?c():Qn(r[i],null)}}},[])}function Je(e){return e?.animationName||"none"}function Ys(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Gs=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Ue=new WeakMap,gt=new WeakMap,yt={},Qt=0,jr=function(e){return e&&(e.host||jr(e.parentNode))},Xs=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=jr(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},Qs=function(e,t,n,r){var o=Xs(t,Array.isArray(e)?e:[e]);yt[n]||(yt[n]=new WeakMap);var a=yt[n],i=[],c=new Set,u=new Set(o),m=function(l){!l||c.has(l)||(c.add(l),m(l.parentNode))};o.forEach(m);var f=function(l){!l||u.has(l)||Array.prototype.forEach.call(l.children,function(h){if(c.has(h))f(h);else try{var g=h.getAttribute(r),x=g!==null&&g!=="false",p=(Ue.get(h)||0)+1,E=(a.get(h)||0)+1;Ue.set(h,p),a.set(h,E),i.push(h),p===1&&x&&gt.set(h,!0),E===1&&h.setAttribute(n,"true"),x||h.setAttribute(r,"true")}catch(w){console.error("aria-hidden: cannot operate on ",h,w)}})};return f(t),c.clear(),Qt++,function(){i.forEach(function(l){var h=Ue.get(l)-1,g=a.get(l)-1;Ue.set(l,h),a.set(l,g),h||(gt.has(l)||l.removeAttribute(r),gt.delete(l)),g||l.removeAttribute(n)}),Qt--,Qt||(Ue=new WeakMap,Ue=new WeakMap,gt=new WeakMap,yt={})}},Zs=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Gs(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Qs(r,o,n,"aria-hidden")):function(){return null}},Rt="right-scroll-bar-position",Ct="width-before-scroll-bar",Js="with-scroll-bars-hidden",ei="--removed-body-scroll-bar-size";function Zt(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function ti(e,t){var n=s.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var ni=typeof window<"u"?s.useLayoutEffect:s.useEffect,Zn=new WeakMap;function ri(e,t){var n=ti(null,function(r){return e.forEach(function(o){return Zt(o,r)})});return ni(function(){var r=Zn.get(n);if(r){var o=new Set(r),a=new Set(e),i=n.current;o.forEach(function(c){a.has(c)||Zt(c,null)}),a.forEach(function(c){o.has(c)||Zt(c,i)})}Zn.set(n,e)},[e]),n}function oi(e){return e}function ai(e,t){t===void 0&&(t=oi);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(a){var i=t(a,r);return n.push(i),function(){n=n.filter(function(c){return c!==i})}},assignSyncMedium:function(a){for(r=!0;n.length;){var i=n;n=[],i.forEach(a)}n={push:function(c){return a(c)},filter:function(){return n}}},assignMedium:function(a){r=!0;var i=[];if(n.length){var c=n;n=[],c.forEach(a),i=n}var u=function(){var f=i;i=[],f.forEach(a)},m=function(){return Promise.resolve().then(u)};m(),n={push:function(f){i.push(f),m()},filter:function(f){return i=i.filter(f),n}}}};return o}function si(e){e===void 0&&(e={});var t=ai(null);return t.options=xe({async:!0,ssr:!1},e),t}var Fr=function(e){var t=e.sideCar,n=Er(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return s.createElement(r,xe({},n))};Fr.isSideCarExport=!0;function ii(e,t){return e.useMedium(t),Fr}var $r=si(),Jt=function(){},kt=s.forwardRef(function(e,t){var n=s.useRef(null),r=s.useState({onScrollCapture:Jt,onWheelCapture:Jt,onTouchMoveCapture:Jt}),o=r[0],a=r[1],i=e.forwardProps,c=e.children,u=e.className,m=e.removeScrollBar,f=e.enabled,l=e.shards,h=e.sideCar,g=e.noRelative,x=e.noIsolation,p=e.inert,E=e.allowPinchZoom,w=e.as,A=w===void 0?"div":w,y=e.gapMode,v=Er(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),D=h,_=ri([n,t]),S=xe(xe({},v),o);return s.createElement(s.Fragment,null,f&&s.createElement(D,{sideCar:$r,removeScrollBar:m,shards:l,noRelative:g,noIsolation:x,inert:p,setCallbacks:a,allowPinchZoom:!!E,lockRef:n,gapMode:y}),i?s.cloneElement(s.Children.only(c),xe(xe({},S),{ref:_})):s.createElement(A,xe({},S,{className:u,ref:_}),c))});kt.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};kt.classNames={fullWidth:Ct,zeroRight:Rt};var ci=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function li(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=ci();return t&&e.setAttribute("nonce",t),e}function ui(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function di(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var fi=function(){var e=0,t=null;return{add:function(n){e==0&&(t=li())&&(ui(t,n),di(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},mi=function(){var e=fi();return function(t,n){s.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Br=function(){var e=mi(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},hi={left:0,top:0,right:0,gap:0},en=function(e){return parseInt(e||"",10)||0},pi=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[en(n),en(r),en(o)]},vi=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return hi;var t=pi(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},gi=Br(),ze="data-scroll-locked",yi=function(e,t,n,r){var o=e.left,a=e.top,i=e.right,c=e.gap;return n===void 0&&(n="margin"),`
4
4
  .`.concat(Js,` {
5
5
  overflow: hidden `).concat(r,`;
@@ -40,7 +40,7 @@ import{b as jo,j as d,X as vr,o as ln,d as un,L as gr,x as Fo,T as $o,r as s,cK
40
40
  `)},Jn=function(){var e=parseInt(document.body.getAttribute(ze)||"0",10);return isFinite(e)?e:0},wi=function(){s.useEffect(function(){return document.body.setAttribute(ze,(Jn()+1).toString()),function(){var e=Jn()-1;e<=0?document.body.removeAttribute(ze):document.body.setAttribute(ze,e.toString())}},[])},bi=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;wi();var a=s.useMemo(function(){return vi(o)},[o]);return s.createElement(gi,{styles:yi(a,!t,o,n?"":"!important")})},pn=!1;if(typeof window<"u")try{var wt=Object.defineProperty({},"passive",{get:function(){return pn=!0,!0}});window.addEventListener("test",wt,wt),window.removeEventListener("test",wt,wt)}catch{pn=!1}var He=pn?{passive:!1}:!1,Ei=function(e){return e.tagName==="TEXTAREA"},Ur=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Ei(e)&&n[t]==="visible")},xi=function(e){return Ur(e,"overflowY")},Si=function(e){return Ur(e,"overflowX")},er=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Hr(e,r);if(o){var a=Wr(e,r),i=a[1],c=a[2];if(i>c)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Ri=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Ci=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Hr=function(e,t){return e==="v"?xi(t):Si(t)},Wr=function(e,t){return e==="v"?Ri(t):Ci(t)},Ti=function(e,t){return e==="h"&&t==="rtl"?-1:1},Ai=function(e,t,n,r,o){var a=Ti(e,window.getComputedStyle(t).direction),i=a*r,c=n.target,u=t.contains(c),m=!1,f=i>0,l=0,h=0;do{if(!c)break;var g=Wr(e,c),x=g[0],p=g[1],E=g[2],w=p-E-a*x;(x||w)&&Hr(e,c)&&(l+=w,h+=x);var A=c.parentNode;c=A&&A.nodeType===Node.DOCUMENT_FRAGMENT_NODE?A.host:A}while(!u&&c!==document.body||u&&(t.contains(c)||t===c));return(f&&Math.abs(l)<1||!f&&Math.abs(h)<1)&&(m=!0),m},bt=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},tr=function(e){return[e.deltaX,e.deltaY]},nr=function(e){return e&&"current"in e?e.current:e},Di=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Ni=function(e){return`
41
41
  .block-interactivity-`.concat(e,` {pointer-events: none;}
42
42
  .allow-interactivity-`).concat(e,` {pointer-events: all;}
43
- `)},Oi=0,We=[];function ki(e){var t=s.useRef([]),n=s.useRef([0,0]),r=s.useRef(),o=s.useState(Oi++)[0],a=s.useState(Br)[0],i=s.useRef(e);s.useEffect(function(){i.current=e},[e]),s.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var p=Ko([e.lockRef.current],(e.shards||[]).map(nr),!0).filter(Boolean);return p.forEach(function(E){return E.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),p.forEach(function(E){return E.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var c=s.useCallback(function(p,E){if("touches"in p&&p.touches.length===2||p.type==="wheel"&&p.ctrlKey)return!i.current.allowPinchZoom;var w=bt(p),A=n.current,y="deltaX"in p?p.deltaX:A[0]-w[0],v="deltaY"in p?p.deltaY:A[1]-w[1],D,_=p.target,S=Math.abs(y)>Math.abs(v)?"h":"v";if("touches"in p&&S==="h"&&_.type==="range")return!1;var k=window.getSelection(),N=k&&k.anchorNode,F=N?N===_||N.contains(_):!1;if(F)return!1;var b=er(S,_);if(!b)return!0;if(b?D=S:(D=S==="v"?"h":"v",b=er(S,_)),!b)return!1;if(!r.current&&"changedTouches"in p&&(y||v)&&(r.current=D),!D)return!0;var P=r.current||D;return Ai(P,E,p,P==="h"?y:v)},[]),u=s.useCallback(function(p){var E=p;if(!(!We.length||We[We.length-1]!==a)){var w="deltaY"in E?tr(E):bt(E),A=t.current.filter(function(D){return D.name===E.type&&(D.target===E.target||E.target===D.shadowParent)&&Di(D.delta,w)})[0];if(A&&A.should){E.cancelable&&E.preventDefault();return}if(!A){var y=(i.current.shards||[]).map(nr).filter(Boolean).filter(function(D){return D.contains(E.target)}),v=y.length>0?c(E,y[0]):!i.current.noIsolation;v&&E.cancelable&&E.preventDefault()}}},[]),m=s.useCallback(function(p,E,w,A){var y={name:p,delta:E,target:w,should:A,shadowParent:Ii(w)};t.current.push(y),setTimeout(function(){t.current=t.current.filter(function(v){return v!==y})},1)},[]),f=s.useCallback(function(p){n.current=bt(p),r.current=void 0},[]),l=s.useCallback(function(p){m(p.type,tr(p),p.target,c(p,e.lockRef.current))},[]),h=s.useCallback(function(p){m(p.type,bt(p),p.target,c(p,e.lockRef.current))},[]);s.useEffect(function(){return We.push(a),e.setCallbacks({onScrollCapture:l,onWheelCapture:l,onTouchMoveCapture:h}),document.addEventListener("wheel",u,He),document.addEventListener("touchmove",u,He),document.addEventListener("touchstart",f,He),function(){We=We.filter(function(p){return p!==a}),document.removeEventListener("wheel",u,He),document.removeEventListener("touchmove",u,He),document.removeEventListener("touchstart",f,He)}},[]);var g=e.removeScrollBar,x=e.inert;return s.createElement(s.Fragment,null,x?s.createElement(a,{styles:Ni(o)}):null,g?s.createElement(bi,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Ii(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Li=ii($r,ki);var zr=s.forwardRef(function(e,t){return s.createElement(kt,xe({},e,{ref:t,sideCar:Li}))});zr.classNames=kt.classNames;const Rl=({enabled:e=!0,bindings:t,capture:n=!1})=>{const r=s.useCallback(o=>{const a=o.target;if(!(a.tagName==="INPUT"||a.tagName==="TEXTAREA"||a.isContentEditable))for(const i of t){if(!(o.key.toLowerCase()===i.key.toLowerCase())||i.action&&Yo(i.action)||i.requireShift!==void 0&&i.requireShift!==o.shiftKey)continue;const u=o.ctrlKey||o.metaKey;if(i.requireMeta!==void 0){if(i.requireMeta!==u)continue}else{const m=i.noModifiers??!0,f=u||o.altKey||i.requireShift===void 0&&o.shiftKey;if(m&&f)continue}i.preventDefault&&o.preventDefault(),i.stopPropagation&&(o.stopPropagation(),o.stopImmediatePropagation()),i.handler(o);return}},[t]);s.useEffect(()=>{if(e)return window.addEventListener("keydown",r,n),()=>window.removeEventListener("keydown",r,n)},[e,r,n])},Pi=e=>typeof e=="object"&&e!==null&&"code"in e&&e.code==="attachment_rejected"&&"message"in e&&typeof e.message=="string",_i=new Set(["EmptyFile","UnusableFilename","FileTooLarge","TooManyAttachments"]),rr={status:"uploading"},Vr={status:"attached"},Pe=(e,t)=>({status:"failed",reason:e,retryable:t}),tn=(e,t)=>Pi(t)?Pe(t.message,!_i.has(t.reason)):Pe(`"${e}" could not be attached: ${Se(t)??"the request failed"}. Try again.`,!0),Mi=e=>({key:e.outboxAttachmentId,serverId:e.outboxAttachmentId,file:null,placement:null,contentId:e.contentId,contentType:e.contentType,contentUrl:e.contentUrl,filename:e.filename,sizeBytes:e.sizeBytes,state:e.state==="Stored"?Vr:Pe(`"${e.filename}" did not finish uploading. Remove it and attach it again.`,!1)});class ji{constructor(t){this.deps=t}deps;entries=[];snapshot=[];listeners=new Set;generation=0;draftId;nextKey=0;reservationsInFlight=new Set;inFlight=new Map;mintedAfterRemoval=new Map;removing=new Map;removedListeners=new Set;loaded=!1;subscribe=t=>(this.listeners.add(t),()=>this.listeners.delete(t));getSnapshot=()=>this.snapshot;owns=t=>this.entries.some(n=>n.contentId===t);storedContent=t=>{const n=this.entries.find(r=>r.contentId===t&&r.contentUrl!==null);return n?.contentUrl?{filename:n.filename,contentType:n.contentType,contentUrl:n.contentUrl}:null};isLoaded=()=>this.loaded;refreshLinks=t=>{const n=new Map(t.map(r=>[r.outboxAttachmentId,r.contentUrl]));this.set(this.entries.map(r=>{const o=r.serverId===null?void 0:n.get(r.serverId);return o===void 0?r:{...r,contentUrl:o}}))};onRemoved=t=>(this.removedListeners.add(t),()=>this.removedListeners.delete(t));blockingReason=()=>{const[t]=this.removing.values();if(t!==void 0)return`Removing "${t}"…`;const n=this.entries.find(o=>o.state.status==="uploading");if(n)return`"${n.filename}" is still uploading.`;const r=this.entries.find(o=>o.state.status==="failed");if(r)return`"${r.filename}" is not attached. Try it again or remove it before sending.`};set(t){this.entries=t,this.snapshot=t.map(({key:n,filename:r,sizeBytes:o,state:a})=>({key:n,filename:r,sizeBytes:o,state:a}));for(const n of this.listeners)n()}patch(t,n,r){t===this.generation&&this.entries.some(o=>o.key===n)&&this.set(this.entries.map(o=>o.key===n?{...o,...r}:o))}reserve(t,n){let r=()=>{};const o=new Promise(a=>{r=()=>{this.reservationsInFlight.delete(o),a()}});return this.reservationsInFlight.add(o),{minted:this.deps.transport().mint(t,n),settle:r}}upload=async(t,n,r,o,a)=>{if(a.aborted)return;const i=this.deps.transport(),{minted:c,settle:u}=this.reserve(o,r),m=await c.catch(h=>(this.patch(t,n,{state:tn(r.name,h)}),null));if(m!==null&&a.aborted&&this.mintedAfterRemoval.set(n,m.outboxAttachmentId),m!==null&&!a.aborted&&this.patch(t,n,{serverId:m.outboxAttachmentId,filename:m.filename,contentId:m.contentId,contentType:m.contentType}),u(),m===null||a.aborted)return;const f=await i.put(m.uploadUrl,r,a).then(()=>null,h=>Se(h)??"the connection dropped");if(a.aborted)return;if(f!==null){this.patch(t,n,{state:Pe(`"${m.filename}" did not finish uploading: ${f}. Try again.`,!0)});return}const l=await i.complete(o,m.outboxAttachmentId).catch(h=>(this.patch(t,n,{state:tn(m.filename,h)}),null));l===null||a.aborted||(this.patch(t,n,{state:Vr,contentUrl:l.contentUrl}),t===this.generation&&this.entries.find(h=>h.key===n)?.placement?.stored(r,m.contentId))};settleFailure(t,n,r){if(t!==this.generation)return;const o=this.entries.find(a=>a.key===n);o?.state.status==="failed"&&o.placement?.failed(r)}run=async(t,n,r,o,a)=>{await this.upload(t,n,r,o,a),this.inFlight.get(n)?.signal===a&&this.inFlight.delete(n),this.settleFailure(t,n,r)};syncKept=async t=>{for(;this.reservationsInFlight.size>0;)await Promise.all([...this.reservationsInFlight]);const n=this.draftId;return t!==this.generation||n===void 0?null:this.deps.transport().keep(n,this.entries.flatMap(r=>r.serverId===null?[]:[r.serverId])).then(()=>null,r=>r??new Error("the request failed"))};attach=async(t,n)=>{const r=this.generation,o=t.map(i=>{this.nextKey+=1;const c={key:`local-${this.nextKey}`,serverId:null,file:i,placement:n??null,contentId:null,contentType:i.type||"application/octet-stream",contentUrl:null,filename:i.name,sizeBytes:i.size,state:rr},u=new AbortController;return this.inFlight.set(c.key,u),{entry:c,file:i,signal:u.signal}});this.set([...this.entries,...o.map(({entry:i})=>i)]);const a=await this.deps.ensureDraft();if(a.outcome==="refused"){for(const{entry:i,file:c}of o)this.inFlight.delete(i.key),this.patch(r,i.key,{state:Pe(a.reason,!0)}),this.settleFailure(r,i.key,c);return}r===this.generation&&(this.draftId=a.outboxMessageId,await Promise.all(o.map(({entry:i,file:c,signal:u})=>this.run(r,i.key,c,a.outboxMessageId,u))))};retry=async t=>{const n=this.entries.find(c=>c.key===t);if(!n||n.file===null||this.inFlight.has(t))return;const r=n.file,o=this.generation,a=new AbortController;this.inFlight.set(t,a),this.patch(o,t,{state:rr,serverId:null});const i=await this.deps.ensureDraft();if(i.outcome==="refused"){this.inFlight.delete(t),this.patch(o,t,{state:Pe(i.reason,!0)});return}if(this.draftId=i.outboxMessageId,n.serverId!==null){const c=await this.syncKept(o);if(c!==null){this.inFlight.delete(t),this.patch(o,t,{serverId:n.serverId,state:tn(r.name,c)});return}}await this.run(o,t,r,i.outboxMessageId,a.signal)};remove=async t=>{const n=this.entries.find(c=>c.key===t);if(!n)return;const r=this.generation,o=this.inFlight.get(t);if(this.set(this.entries.filter(c=>c.key!==t)),o&&(this.inFlight.delete(t),o.abort()),n.serverId===null&&!o)return;this.removing.set(t,n.filename),this.set(this.entries);const a=await this.syncKept(r);this.removing.delete(t),this.set(this.entries);const i=n.serverId??this.mintedAfterRemoval.get(t)??null;if(this.mintedAfterRemoval.delete(t),r===this.generation){if(a===null){if(n.contentId===null)return;for(const c of this.removedListeners)c(n.contentId);return}i!==null&&this.set([...this.entries,{...n,serverId:i,file:null,state:Pe(`"${n.filename}" could not be removed: ${Se(a)??"the request failed"}. It is still on the draft — remove it again.`,!1)}])}};load=(t,n)=>{this.draftId=t,this.loaded=!0;const r=new Set(n.map(a=>a.outboxAttachmentId)),o=this.entries.filter(a=>a.file!==null&&(a.serverId===null||!r.has(a.serverId)));this.set([...n.map(Mi),...o])};reset=t=>{this.generation+=1;for(const n of this.inFlight.values())n.abort();this.inFlight.clear(),this.mintedAfterRemoval.clear(),this.removing.clear(),this.draftId=t,this.loaded=!1,this.set([])}}const Fi=(e,t,n)=>fetch(e,{method:"PUT",body:t,signal:n}).then(r=>{if(!r.ok)throw new Error(`the server answered ${r.status}`)}),$i=({ensureDraft:e})=>{const t=_e({...Go(),meta:Me}),n=_e({...Xo(),meta:Me}),r=_e({...xr(),meta:Me}),o=s.useRef(null);o.current={mint:(u,m)=>t.mutateAsync({path:{outboxMessageId:u},body:{filename:m.name,contentType:m.type||"application/octet-stream",sizeBytes:m.size}}),put:Fi,complete:(u,m)=>n.mutateAsync({path:{outboxMessageId:u,outboxAttachmentId:m}}).then(f=>({contentUrl:f.contentUrl})),keep:(u,m)=>r.mutateAsync({path:{outboxMessageId:u},body:{attachmentIds:m}}).then(()=>{})};const a=s.useRef(e);a.current=e;const[i]=s.useState(()=>new ji({transport:()=>{const u=o.current;if(!u)throw new Error("attachment transport not ready");return u},ensureDraft:()=>a.current()}));return{items:s.useSyncExternalStore(i.subscribe,i.getSnapshot,i.getSnapshot),attach:i.attach,retry:i.retry,remove:i.remove,load:i.load,reset:i.reset,owns:i.owns,isLoaded:i.isLoaded,refreshLinks:i.refreshLinks,storedContent:i.storedContent,onRemoved:i.onRemoved,blockingReason:i.blockingReason()}},Cl=e=>e==="link-expired"||e==="not-ready";class vn extends Error{reason;status;constructor(t,n,r){super(n),this.name="AttachmentFetchError",this.reason=t,this.status=r}}const Bi="x-remit-403-reason",Ui="expired",Hi=(e,t)=>{if(t?.trim()===Ui)return"link-expired";const n=ma(e,t);return n==="auth"?"auth":n==="body-missing"?"missing":"generic"},Wi=300*1e3,zi=async(e,t)=>{const n={},r=await t();r&&(n.Authorization=`Bearer ${r}`);const o=await Qo(e,{headers:n,signal:AbortSignal.timeout(Wi)});if(o.status===202)throw new vn("not-ready","Attachment is still being fetched from the mail server",202);if(!o.ok)throw new vn(Hi(o.status,o.headers.get(Bi)),`Failed to download attachment (${o.status} ${o.statusText})`,o.status);return o.blob()},Vi=(e,t,n)=>{switch(e){case"auth":return{title:"Your session expired",detail:`Sign in again, then download ${t} once more. Other parts of the app may also stop responding until you do.`};case"link-expired":return{title:"This download link expired and could not be renewed",detail:`Reload the page, then download ${t} again. If that keeps failing, this is worth reporting.`};case"missing":return{title:"This attachment is missing from storage",detail:"Remit has the message but not the file. Re-sync the account from Settings, then try again."};case"not-ready":return{title:"Still fetching this attachment",detail:"Remit is downloading it from the mail server now. Try again in a few seconds."};default:return{title:"Couldn't download this attachment",detail:n}}},or=e=>e instanceof vn?e.reason:"generic",qi=e=>e instanceof Error?e.message:typeof e=="string"?e:"An unexpected error occurred while downloading this attachment.",Tl=(e,t,n)=>{if(e!=="auth")return Sr(Rr({title:`Bug: attachment download failed (${e})`,errorMessage:`Downloading "${t}" failed: ${n}`}))},Al=(e,t)=>{const n=URL.createObjectURL(e),r=document.createElement("a");r.href=n,r.download=t,r.rel="noopener",document.body.append(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),0)},Ki=e=>{const{getToken:t}=Zo(),n=s.useRef({...e,getToken:t});return n.current={...e,getToken:t},s.useMemo(()=>{const r=c=>{const u=n.current;return u.isLoaded()?null:u.draftAttachments.find(m=>m.contentId===c)??null},o=c=>n.current.storedContent(c)??r(c),a=c=>zi(c.contentUrl,n.current.getToken).then(u=>URL.createObjectURL(new Blob([u],{type:c.contentType}))),i=c=>n.current.refreshLinks().then(()=>{const u=o(c);if(!u)throw new Error("the file is no longer on this draft");return a(u)});return{attach:(c,u)=>{n.current.attach(c,u)},owns:c=>n.current.owns(c)||r(c)!==null,onRemoved:c=>n.current.onRemoved(c),resolve:c=>{const u=o(c);return u?a(u).catch(m=>{if(or(m)!=="link-expired")throw m;return i(c)}).catch(m=>{const f=or(m);return n.current.pushError({...Vi(f,u.filename,qi(m)),error:f==="generic"?m:void 0}),null}):Promise.resolve(null)}}},[])},Yi=(e,t)=>e===void 0&&t.toAddresses.length===0,Gi={status:"unsaved",reason:"Not saved — add a To address to keep this draft."},ar={status:"idle"},Xi={status:"saving"},sr={status:"saved"},ir={status:"error"},Qi=e=>e.then(()=>{},()=>{}),Zi=({outboxMessageId:e,onDraftCreated:t})=>{const[n,r]=s.useState(ar),[o,a]=s.useState(null),i=s.useRef(void 0),c=s.useRef(new Set),u=Cr(),m=s.useRef(e),f=s.useRef(e);if(m.current!==e){const y=m.current!==void 0;m.current=e,f.current=e,y&&i.current&&clearTimeout(i.current)}const l=_e({...Jo(),meta:Me}),h=_e({...xr(),meta:Me}),g=s.useCallback(async y=>{r(Xi),a(null);const v=f.current;if(v){const _=await h.mutateAsync({path:{outboxMessageId:v},body:{toAddresses:y.toAddresses,ccAddresses:y.ccAddresses,bccAddresses:y.bccAddresses,subject:y.subject,textBody:y.textBody,htmlBody:y.htmlBody,inReplyTo:y.inReplyTo,references:y.references}});return r(sr),_}const D=await l.mutateAsync({body:{...y,sendImmediately:!1}});return f.current=D.outboxMessageId,t(D.outboxMessageId),r(sr),u.invalidateQueries({queryKey:ea().queryKey}),D},[l.mutateAsync,h.mutateAsync,t,u]),x=s.useRef(Promise.resolve()),p=s.useCallback(y=>{const v=x.current.then(()=>g(y));return x.current=Qi(v),v},[g]),E=s.useCallback(y=>{if(i.current&&clearTimeout(i.current),Yi(f.current,y)){r(Gi);return}r(v=>v.status==="unsaved"?ar:v),i.current=setTimeout(()=>{const v=f.current;v&&c.current.has(v)||p(y).catch(D=>{a(D),r(ir)})},2e3)},[p]),w=s.useCallback(y=>(i.current&&clearTimeout(i.current),p(y).then(v=>({outcome:"saved",outboxMessageId:v.outboxMessageId})).catch(v=>(r(ir),{outcome:"failed",error:v}))),[p]),A=s.useCallback(y=>{i.current&&clearTimeout(i.current),y&&c.current.add(y)},[]);return{saveState:n,saveError:o,saveDraft:E,saveImmediately:w,stopAutoSave:A}},Ji=e=>e.outboundCount>0||e.replyCount>0||e.flags?.vip?.value===!0||e.flags?.trusted?.value===!0,ec=e=>e.flags?.blocked?.value===!0?!1:e.flags?.junkOnly?.value!==!0?!0:Ji(e),nn=({label:e,addresses:t,onChange:n,placeholder:r,onPendingChange:o,ref:a})=>{const[i,c]=s.useState(""),u=ga(i,200),{data:m}=At({...ta({query:{q:u,limit:8}}),enabled:u.length>=2}),f=s.useMemo(()=>(m?.items??[]).filter(ec).map(l=>({email:l.normalizedEmail,displayName:l.displayName})),[m]);return d.jsx(_a,{label:e,addresses:t,onChange:n,placeholder:r,suggestions:f,onQueryChange:c,onPendingChange:o,ref:a})},tc=({accountId:e,configureRef:t})=>{const n=ya();return d.jsx(qa,{configureRef:t,onConfigure:()=>{n(e)}})},nc={download:"its dictionary could not be downloaded",engine:"the checker could not start",worker:"the checker stopped running"},rc=e=>{const t=`Spellcheck for ${e.language} is off: ${nc[e.reason]}.`;return{severity:"warning",title:"Spellcheck stopped",detail:`${t} Your browser is checking this message instead. ${e.detail}`,action:{label:"Report this",href:Sr(Rr({title:`Spellcheck stopped: ${e.reason} (${e.language})`,errorMessage:`${t} ${e.detail}`}))}}},oc=e=>({provider:async t=>{const{openSpellcheckWorker:n}=await Tr(async()=>{const{openSpellcheckWorker:r}=await import("./rich-text-spellcheck-worker-provider-paPOw9As.js");return{openSpellcheckWorker:r}},__vite__mapDeps([0,1,2,3]));return n(t)},onStatus:t=>{t.state==="failed"&&e(rc(t))}}),ac=e=>{if(na(e)?.code==="mail_sync_off")return Se(e)},qr=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),Dt=e=>e.split(`
43
+ `)},Oi=0,We=[];function ki(e){var t=s.useRef([]),n=s.useRef([0,0]),r=s.useRef(),o=s.useState(Oi++)[0],a=s.useState(Br)[0],i=s.useRef(e);s.useEffect(function(){i.current=e},[e]),s.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var p=Ko([e.lockRef.current],(e.shards||[]).map(nr),!0).filter(Boolean);return p.forEach(function(E){return E.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),p.forEach(function(E){return E.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var c=s.useCallback(function(p,E){if("touches"in p&&p.touches.length===2||p.type==="wheel"&&p.ctrlKey)return!i.current.allowPinchZoom;var w=bt(p),A=n.current,y="deltaX"in p?p.deltaX:A[0]-w[0],v="deltaY"in p?p.deltaY:A[1]-w[1],D,_=p.target,S=Math.abs(y)>Math.abs(v)?"h":"v";if("touches"in p&&S==="h"&&_.type==="range")return!1;var k=window.getSelection(),N=k&&k.anchorNode,F=N?N===_||N.contains(_):!1;if(F)return!1;var b=er(S,_);if(!b)return!0;if(b?D=S:(D=S==="v"?"h":"v",b=er(S,_)),!b)return!1;if(!r.current&&"changedTouches"in p&&(y||v)&&(r.current=D),!D)return!0;var P=r.current||D;return Ai(P,E,p,P==="h"?y:v)},[]),u=s.useCallback(function(p){var E=p;if(!(!We.length||We[We.length-1]!==a)){var w="deltaY"in E?tr(E):bt(E),A=t.current.filter(function(D){return D.name===E.type&&(D.target===E.target||E.target===D.shadowParent)&&Di(D.delta,w)})[0];if(A&&A.should){E.cancelable&&E.preventDefault();return}if(!A){var y=(i.current.shards||[]).map(nr).filter(Boolean).filter(function(D){return D.contains(E.target)}),v=y.length>0?c(E,y[0]):!i.current.noIsolation;v&&E.cancelable&&E.preventDefault()}}},[]),m=s.useCallback(function(p,E,w,A){var y={name:p,delta:E,target:w,should:A,shadowParent:Ii(w)};t.current.push(y),setTimeout(function(){t.current=t.current.filter(function(v){return v!==y})},1)},[]),f=s.useCallback(function(p){n.current=bt(p),r.current=void 0},[]),l=s.useCallback(function(p){m(p.type,tr(p),p.target,c(p,e.lockRef.current))},[]),h=s.useCallback(function(p){m(p.type,bt(p),p.target,c(p,e.lockRef.current))},[]);s.useEffect(function(){return We.push(a),e.setCallbacks({onScrollCapture:l,onWheelCapture:l,onTouchMoveCapture:h}),document.addEventListener("wheel",u,He),document.addEventListener("touchmove",u,He),document.addEventListener("touchstart",f,He),function(){We=We.filter(function(p){return p!==a}),document.removeEventListener("wheel",u,He),document.removeEventListener("touchmove",u,He),document.removeEventListener("touchstart",f,He)}},[]);var g=e.removeScrollBar,x=e.inert;return s.createElement(s.Fragment,null,x?s.createElement(a,{styles:Ni(o)}):null,g?s.createElement(bi,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Ii(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Li=ii($r,ki);var zr=s.forwardRef(function(e,t){return s.createElement(kt,xe({},e,{ref:t,sideCar:Li}))});zr.classNames=kt.classNames;const Rl=({enabled:e=!0,bindings:t,capture:n=!1})=>{const r=s.useCallback(o=>{const a=o.target;if(!(a.tagName==="INPUT"||a.tagName==="TEXTAREA"||a.isContentEditable))for(const i of t){if(!(o.key.toLowerCase()===i.key.toLowerCase())||i.action&&Yo(i.action)||i.requireShift!==void 0&&i.requireShift!==o.shiftKey)continue;const u=o.ctrlKey||o.metaKey;if(i.requireMeta!==void 0){if(i.requireMeta!==u)continue}else{const m=i.noModifiers??!0,f=u||o.altKey||i.requireShift===void 0&&o.shiftKey;if(m&&f)continue}i.preventDefault&&o.preventDefault(),i.stopPropagation&&(o.stopPropagation(),o.stopImmediatePropagation()),i.handler(o);return}},[t]);s.useEffect(()=>{if(e)return window.addEventListener("keydown",r,n),()=>window.removeEventListener("keydown",r,n)},[e,r,n])},Pi=e=>typeof e=="object"&&e!==null&&"code"in e&&e.code==="attachment_rejected"&&"message"in e&&typeof e.message=="string",_i=new Set(["EmptyFile","UnusableFilename","FileTooLarge","TooManyAttachments"]),rr={status:"uploading"},Vr={status:"attached"},Pe=(e,t)=>({status:"failed",reason:e,retryable:t}),tn=(e,t)=>Pi(t)?Pe(t.message,!_i.has(t.reason)):Pe(`"${e}" could not be attached: ${Se(t)??"the request failed"}. Try again.`,!0),Mi=e=>({key:e.outboxAttachmentId,serverId:e.outboxAttachmentId,file:null,placement:null,contentId:e.contentId,contentType:e.contentType,contentUrl:e.contentUrl,filename:e.filename,sizeBytes:e.sizeBytes,state:e.state==="Stored"?Vr:Pe(`"${e.filename}" did not finish uploading. Remove it and attach it again.`,!1)});class ji{constructor(t){this.deps=t}deps;entries=[];snapshot=[];listeners=new Set;generation=0;draftId;nextKey=0;reservationsInFlight=new Set;inFlight=new Map;mintedAfterRemoval=new Map;removing=new Map;removedListeners=new Set;loaded=!1;subscribe=t=>(this.listeners.add(t),()=>this.listeners.delete(t));getSnapshot=()=>this.snapshot;owns=t=>this.entries.some(n=>n.contentId===t);storedContent=t=>{const n=this.entries.find(r=>r.contentId===t&&r.contentUrl!==null);return n?.contentUrl?{filename:n.filename,contentType:n.contentType,contentUrl:n.contentUrl}:null};isLoaded=()=>this.loaded;refreshLinks=t=>{const n=new Map(t.map(r=>[r.outboxAttachmentId,r.contentUrl]));this.set(this.entries.map(r=>{const o=r.serverId===null?void 0:n.get(r.serverId);return o===void 0?r:{...r,contentUrl:o}}))};onRemoved=t=>(this.removedListeners.add(t),()=>this.removedListeners.delete(t));blockingReason=()=>{const[t]=this.removing.values();if(t!==void 0)return`Removing "${t}"…`;const n=this.entries.find(o=>o.state.status==="uploading");if(n)return`"${n.filename}" is still uploading.`;const r=this.entries.find(o=>o.state.status==="failed");if(r)return`"${r.filename}" is not attached. Try it again or remove it before sending.`};set(t){this.entries=t,this.snapshot=t.map(({key:n,filename:r,sizeBytes:o,state:a})=>({key:n,filename:r,sizeBytes:o,state:a}));for(const n of this.listeners)n()}patch(t,n,r){t===this.generation&&this.entries.some(o=>o.key===n)&&this.set(this.entries.map(o=>o.key===n?{...o,...r}:o))}reserve(t,n){let r=()=>{};const o=new Promise(a=>{r=()=>{this.reservationsInFlight.delete(o),a()}});return this.reservationsInFlight.add(o),{minted:this.deps.transport().mint(t,n),settle:r}}upload=async(t,n,r,o,a)=>{if(a.aborted)return;const i=this.deps.transport(),{minted:c,settle:u}=this.reserve(o,r),m=await c.catch(h=>(this.patch(t,n,{state:tn(r.name,h)}),null));if(m!==null&&a.aborted&&this.mintedAfterRemoval.set(n,m.outboxAttachmentId),m!==null&&!a.aborted&&this.patch(t,n,{serverId:m.outboxAttachmentId,filename:m.filename,contentId:m.contentId,contentType:m.contentType}),u(),m===null||a.aborted)return;const f=await i.put(m.uploadUrl,r,a).then(()=>null,h=>Se(h)??"the connection dropped");if(a.aborted)return;if(f!==null){this.patch(t,n,{state:Pe(`"${m.filename}" did not finish uploading: ${f}. Try again.`,!0)});return}const l=await i.complete(o,m.outboxAttachmentId).catch(h=>(this.patch(t,n,{state:tn(m.filename,h)}),null));l===null||a.aborted||(this.patch(t,n,{state:Vr,contentUrl:l.contentUrl}),t===this.generation&&this.entries.find(h=>h.key===n)?.placement?.stored(r,m.contentId))};settleFailure(t,n,r){if(t!==this.generation)return;const o=this.entries.find(a=>a.key===n);o?.state.status==="failed"&&o.placement?.failed(r)}run=async(t,n,r,o,a)=>{await this.upload(t,n,r,o,a),this.inFlight.get(n)?.signal===a&&this.inFlight.delete(n),this.settleFailure(t,n,r)};syncKept=async t=>{for(;this.reservationsInFlight.size>0;)await Promise.all([...this.reservationsInFlight]);const n=this.draftId;return t!==this.generation||n===void 0?null:this.deps.transport().keep(n,this.entries.flatMap(r=>r.serverId===null?[]:[r.serverId])).then(()=>null,r=>r??new Error("the request failed"))};attach=async(t,n)=>{const r=this.generation,o=t.map(i=>{this.nextKey+=1;const c={key:`local-${this.nextKey}`,serverId:null,file:i,placement:n??null,contentId:null,contentType:i.type||"application/octet-stream",contentUrl:null,filename:i.name,sizeBytes:i.size,state:rr},u=new AbortController;return this.inFlight.set(c.key,u),{entry:c,file:i,signal:u.signal}});this.set([...this.entries,...o.map(({entry:i})=>i)]);const a=await this.deps.ensureDraft();if(a.outcome==="refused"){for(const{entry:i,file:c}of o)this.inFlight.delete(i.key),this.patch(r,i.key,{state:Pe(a.reason,!0)}),this.settleFailure(r,i.key,c);return}r===this.generation&&(this.draftId=a.outboxMessageId,await Promise.all(o.map(({entry:i,file:c,signal:u})=>this.run(r,i.key,c,a.outboxMessageId,u))))};retry=async t=>{const n=this.entries.find(c=>c.key===t);if(!n||n.file===null||this.inFlight.has(t))return;const r=n.file,o=this.generation,a=new AbortController;this.inFlight.set(t,a),this.patch(o,t,{state:rr,serverId:null});const i=await this.deps.ensureDraft();if(i.outcome==="refused"){this.inFlight.delete(t),this.patch(o,t,{state:Pe(i.reason,!0)});return}if(this.draftId=i.outboxMessageId,n.serverId!==null){const c=await this.syncKept(o);if(c!==null){this.inFlight.delete(t),this.patch(o,t,{serverId:n.serverId,state:tn(r.name,c)});return}}await this.run(o,t,r,i.outboxMessageId,a.signal)};remove=async t=>{const n=this.entries.find(c=>c.key===t);if(!n)return;const r=this.generation,o=this.inFlight.get(t);if(this.set(this.entries.filter(c=>c.key!==t)),o&&(this.inFlight.delete(t),o.abort()),n.serverId===null&&!o)return;this.removing.set(t,n.filename),this.set(this.entries);const a=await this.syncKept(r);this.removing.delete(t),this.set(this.entries);const i=n.serverId??this.mintedAfterRemoval.get(t)??null;if(this.mintedAfterRemoval.delete(t),r===this.generation){if(a===null){if(n.contentId===null)return;for(const c of this.removedListeners)c(n.contentId);return}i!==null&&this.set([...this.entries,{...n,serverId:i,file:null,state:Pe(`"${n.filename}" could not be removed: ${Se(a)??"the request failed"}. It is still on the draft — remove it again.`,!1)}])}};load=(t,n)=>{this.draftId=t,this.loaded=!0;const r=new Set(n.map(a=>a.outboxAttachmentId)),o=this.entries.filter(a=>a.file!==null&&(a.serverId===null||!r.has(a.serverId)));this.set([...n.map(Mi),...o])};reset=t=>{this.generation+=1;for(const n of this.inFlight.values())n.abort();this.inFlight.clear(),this.mintedAfterRemoval.clear(),this.removing.clear(),this.draftId=t,this.loaded=!1,this.set([])}}const Fi=(e,t,n)=>fetch(e,{method:"PUT",body:t,signal:n}).then(r=>{if(!r.ok)throw new Error(`the server answered ${r.status}`)}),$i=({ensureDraft:e})=>{const t=_e({...Go(),meta:Me}),n=_e({...Xo(),meta:Me}),r=_e({...xr(),meta:Me}),o=s.useRef(null);o.current={mint:(u,m)=>t.mutateAsync({path:{outboxMessageId:u},body:{filename:m.name,contentType:m.type||"application/octet-stream",sizeBytes:m.size}}),put:Fi,complete:(u,m)=>n.mutateAsync({path:{outboxMessageId:u,outboxAttachmentId:m}}).then(f=>({contentUrl:f.contentUrl})),keep:(u,m)=>r.mutateAsync({path:{outboxMessageId:u},body:{attachmentIds:m}}).then(()=>{})};const a=s.useRef(e);a.current=e;const[i]=s.useState(()=>new ji({transport:()=>{const u=o.current;if(!u)throw new Error("attachment transport not ready");return u},ensureDraft:()=>a.current()}));return{items:s.useSyncExternalStore(i.subscribe,i.getSnapshot,i.getSnapshot),attach:i.attach,retry:i.retry,remove:i.remove,load:i.load,reset:i.reset,owns:i.owns,isLoaded:i.isLoaded,refreshLinks:i.refreshLinks,storedContent:i.storedContent,onRemoved:i.onRemoved,blockingReason:i.blockingReason()}},Cl=e=>e==="link-expired"||e==="not-ready";class vn extends Error{reason;status;constructor(t,n,r){super(n),this.name="AttachmentFetchError",this.reason=t,this.status=r}}const Bi="x-remit-403-reason",Ui="expired",Hi=(e,t)=>{if(t?.trim()===Ui)return"link-expired";const n=ma(e,t);return n==="auth"?"auth":n==="body-missing"?"missing":"generic"},Wi=300*1e3,zi=async(e,t)=>{const n={},r=await t();r&&(n.Authorization=`Bearer ${r}`);const o=await Qo(e,{headers:n,signal:AbortSignal.timeout(Wi)});if(o.status===202)throw new vn("not-ready","Attachment is still being fetched from the mail server",202);if(!o.ok)throw new vn(Hi(o.status,o.headers.get(Bi)),`Failed to download attachment (${o.status} ${o.statusText})`,o.status);return o.blob()},Vi=(e,t,n)=>{switch(e){case"auth":return{title:"Your session expired",detail:`Sign in again, then download ${t} once more. Other parts of the app may also stop responding until you do.`};case"link-expired":return{title:"This download link expired and could not be renewed",detail:`Reload the page, then download ${t} again. If that keeps failing, this is worth reporting.`};case"missing":return{title:"This attachment is missing from storage",detail:"Remit has the message but not the file. Re-sync the account from Settings, then try again."};case"not-ready":return{title:"Still fetching this attachment",detail:"Remit is downloading it from the mail server now. Try again in a few seconds."};default:return{title:"Couldn't download this attachment",detail:n}}},or=e=>e instanceof vn?e.reason:"generic",qi=e=>e instanceof Error?e.message:typeof e=="string"?e:"An unexpected error occurred while downloading this attachment.",Tl=(e,t,n)=>{if(e!=="auth")return Sr(Rr({title:`Bug: attachment download failed (${e})`,errorMessage:`Downloading "${t}" failed: ${n}`}))},Al=(e,t)=>{const n=URL.createObjectURL(e),r=document.createElement("a");r.href=n,r.download=t,r.rel="noopener",document.body.append(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),0)},Ki=e=>{const{getToken:t}=Zo(),n=s.useRef({...e,getToken:t});return n.current={...e,getToken:t},s.useMemo(()=>{const r=c=>{const u=n.current;return u.isLoaded()?null:u.draftAttachments.find(m=>m.contentId===c)??null},o=c=>n.current.storedContent(c)??r(c),a=c=>zi(c.contentUrl,n.current.getToken).then(u=>URL.createObjectURL(new Blob([u],{type:c.contentType}))),i=c=>n.current.refreshLinks().then(()=>{const u=o(c);if(!u)throw new Error("the file is no longer on this draft");return a(u)});return{attach:(c,u)=>{n.current.attach(c,u)},owns:c=>n.current.owns(c)||r(c)!==null,onRemoved:c=>n.current.onRemoved(c),resolve:c=>{const u=o(c);return u?a(u).catch(m=>{if(or(m)!=="link-expired")throw m;return i(c)}).catch(m=>{const f=or(m);return n.current.pushError({...Vi(f,u.filename,qi(m)),error:f==="generic"?m:void 0}),null}):Promise.resolve(null)}}},[])},Yi=(e,t)=>e===void 0&&t.toAddresses.length===0,Gi={status:"unsaved",reason:"Not saved — add a To address to keep this draft."},ar={status:"idle"},Xi={status:"saving"},sr={status:"saved"},ir={status:"error"},Qi=e=>e.then(()=>{},()=>{}),Zi=({outboxMessageId:e,onDraftCreated:t})=>{const[n,r]=s.useState(ar),[o,a]=s.useState(null),i=s.useRef(void 0),c=s.useRef(new Set),u=Cr(),m=s.useRef(e),f=s.useRef(e);if(m.current!==e){const y=m.current!==void 0;m.current=e,f.current=e,y&&i.current&&clearTimeout(i.current)}const l=_e({...Jo(),meta:Me}),h=_e({...xr(),meta:Me}),g=s.useCallback(async y=>{r(Xi),a(null);const v=f.current;if(v){const _=await h.mutateAsync({path:{outboxMessageId:v},body:{toAddresses:y.toAddresses,ccAddresses:y.ccAddresses,bccAddresses:y.bccAddresses,subject:y.subject,textBody:y.textBody,htmlBody:y.htmlBody,inReplyTo:y.inReplyTo,references:y.references}});return r(sr),_}const D=await l.mutateAsync({body:{...y,sendImmediately:!1}});return f.current=D.outboxMessageId,t(D.outboxMessageId),r(sr),u.invalidateQueries({queryKey:ea().queryKey}),D},[l.mutateAsync,h.mutateAsync,t,u]),x=s.useRef(Promise.resolve()),p=s.useCallback(y=>{const v=x.current.then(()=>g(y));return x.current=Qi(v),v},[g]),E=s.useCallback(y=>{if(i.current&&clearTimeout(i.current),Yi(f.current,y)){r(Gi);return}r(v=>v.status==="unsaved"?ar:v),i.current=setTimeout(()=>{const v=f.current;v&&c.current.has(v)||p(y).catch(D=>{a(D),r(ir)})},2e3)},[p]),w=s.useCallback(y=>(i.current&&clearTimeout(i.current),p(y).then(v=>({outcome:"saved",outboxMessageId:v.outboxMessageId})).catch(v=>(r(ir),{outcome:"failed",error:v}))),[p]),A=s.useCallback(y=>{i.current&&clearTimeout(i.current),y&&c.current.add(y)},[]);return{saveState:n,saveError:o,saveDraft:E,saveImmediately:w,stopAutoSave:A}},Ji=e=>e.outboundCount>0||e.replyCount>0||e.flags?.vip?.value===!0||e.flags?.trusted?.value===!0,ec=e=>e.flags?.blocked?.value===!0?!1:e.flags?.junkOnly?.value!==!0?!0:Ji(e),nn=({label:e,addresses:t,onChange:n,placeholder:r,onPendingChange:o,ref:a})=>{const[i,c]=s.useState(""),u=ga(i,200),{data:m}=At({...ta({query:{q:u,limit:8}}),enabled:u.length>=2}),f=s.useMemo(()=>(m?.items??[]).filter(ec).map(l=>({email:l.normalizedEmail,displayName:l.displayName})),[m]);return d.jsx(_a,{label:e,addresses:t,onChange:n,placeholder:r,suggestions:f,onQueryChange:c,onPendingChange:o,ref:a})},tc=({accountId:e,configureRef:t})=>{const n=ya();return d.jsx(qa,{configureRef:t,onConfigure:()=>{n(e)}})},nc={download:"its dictionary could not be downloaded",engine:"the checker could not start",worker:"the checker stopped running"},rc=e=>{const t=`Spellcheck for ${e.language} is off: ${nc[e.reason]}.`;return{severity:"warning",title:"Spellcheck stopped",detail:`${t} Your browser is checking this message instead. ${e.detail}`,action:{label:"Report this",href:Sr(Rr({title:`Spellcheck stopped: ${e.reason} (${e.language})`,errorMessage:`${t} ${e.detail}`}))}}},oc=e=>({provider:async t=>{const{openSpellcheckWorker:n}=await Tr(async()=>{const{openSpellcheckWorker:r}=await import("./rich-text-spellcheck-worker-provider-Bk8cqxyg.js");return{openSpellcheckWorker:r}},__vite__mapDeps([0,1,2,3]));return n(t)},onStatus:t=>{t.state==="failed"&&e(rc(t))}}),ac=e=>{if(na(e)?.code==="mail_sync_off")return Se(e)},qr=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),Dt=e=>e.split(`
44
44
  `).map(t=>`<p>${qr(t)}</p>`).join(""),sc=new Set(["ADDRESS","ARTICLE","BLOCKQUOTE","BR","DIV","H1","H2","H3","H4","H5","H6","HR","LI","OL","P","PRE","SECTION","TABLE","TR","UL"]),ic=e=>{const t=new DOMParser().parseFromString(e,"text/html"),n=[];let r="";const o=()=>{n.push(r.trim()),r=""},a=i=>{if(i.nodeType===i.TEXT_NODE){r+=(i.textContent??"").replace(/\s+/g," ");return}if(i.nodeType!==i.ELEMENT_NODE)return;const c=sc.has(i.tagName);c&&r!==""&&o();for(const u of i.childNodes)a(u);c&&o()};return a(t.body),r!==""&&o(),n.join(`
45
45
  `).replace(/\n{3,}/g,`
46
46
 
@@ -50,7 +50,7 @@ import{b as jo,j as d,X as vr,o as ln,d as un,L as gr,x as Fo,T as $o,r as s,cK
50
50
  `))}${o}`}}const a=lc(t);return{text:[a,...fc(r)].join(`
51
51
  `),html:`<p>${qr(a)}</p><blockquote type="cite">${o}</blockquote>`}},hc=(e,t)=>e===""?t:`${e}
52
52
 
53
- ${t}`,rn=(e,t,n,r)=>{const o=r?hc(t.text,r.text):t.text;if(e==="plain")return{textBody:o||void 0,htmlBody:""};const a=r?`${t.html}${r.html}`:t.html;return{textBody:o||void 0,htmlBody:a?ra(a,n):void 0}},cr=150,pc=()=>{const[e,t]=s.useState(()=>{if(typeof window>"u"||!window.visualViewport)return{viewportHeight:0,isKeyboardOpen:!1};const n=window.visualViewport.height;return{viewportHeight:n,isKeyboardOpen:window.innerHeight-n>cr}});return s.useEffect(()=>{if(typeof window>"u"||!window.visualViewport)return;const n=window.visualViewport,r=()=>{const o=n.height;t({viewportHeight:o,isKeyboardOpen:window.innerHeight-o>cr})};return r(),n.addEventListener("resize",r),()=>n.removeEventListener("resize",r)},[]),e},vc=({selectedAccountId:e,onSelect:t})=>{const{data:n}=At({...Ar(),staleTime:1/0}),r=n?.accounts??[];if(s.useEffect(()=>{!e&&r.length===1&&r[0]&&t(r[0])},[e,r,t]),r.length<=1){const a=r[0];return a?d.jsxs("div",{className:"flex items-start gap-2",children:[d.jsx("label",{className:"text-sm text-fg-muted shrink-0 w-12 pt-1.5",children:"From:"}),d.jsx("div",{className:"text-sm py-1.5",children:a.email})]}):null}const o=r.some(a=>a.accountId===e);return d.jsxs("div",{className:"flex items-start gap-2",children:[d.jsx("label",{htmlFor:"from-account-selector",className:"text-sm text-fg-muted shrink-0 w-12 pt-1.5",children:"From:"}),d.jsxs("select",{id:"from-account-selector",value:o?e:"",onChange:a=>{const i=r.find(c=>c.accountId===a.target.value);i&&t(i)},className:"flex-1 px-2 py-1.5 border rounded-md bg-canvas text-sm",children:[!o&&d.jsx("option",{value:"",disabled:!0,children:"Choose an account"}),r.map(a=>d.jsx("option",{value:a.accountId,children:a.email},a.accountId))]})]})},gc=s.lazy(()=>Tr(()=>import("./rich-text-DgI7vzll.js"),__vite__mapDeps([4,1,2,5,6,7,8,9,10,3,11,12,13,14,15,16])).then(e=>({default:e.ComposeBody}))),lr=e=>e?`<p></p><p>-- </p>${Dt(e)}`:"",Et=(e,t)=>t?{html:`${Dt(t.body)}${lr(e)}`,text:[t.body,e].filter(Boolean).join(`
53
+ ${t}`,rn=(e,t,n,r)=>{const o=r?hc(t.text,r.text):t.text;if(e==="plain")return{textBody:o||void 0,htmlBody:""};const a=r?`${t.html}${r.html}`:t.html;return{textBody:o||void 0,htmlBody:a?ra(a,n):void 0}},cr=150,pc=()=>{const[e,t]=s.useState(()=>{if(typeof window>"u"||!window.visualViewport)return{viewportHeight:0,isKeyboardOpen:!1};const n=window.visualViewport.height;return{viewportHeight:n,isKeyboardOpen:window.innerHeight-n>cr}});return s.useEffect(()=>{if(typeof window>"u"||!window.visualViewport)return;const n=window.visualViewport,r=()=>{const o=n.height;t({viewportHeight:o,isKeyboardOpen:window.innerHeight-o>cr})};return r(),n.addEventListener("resize",r),()=>n.removeEventListener("resize",r)},[]),e},vc=({selectedAccountId:e,onSelect:t})=>{const{data:n}=At({...Ar(),staleTime:1/0}),r=n?.accounts??[];if(s.useEffect(()=>{!e&&r.length===1&&r[0]&&t(r[0])},[e,r,t]),r.length<=1){const a=r[0];return a?d.jsxs("div",{className:"flex items-start gap-2",children:[d.jsx("label",{className:"text-sm text-fg-muted shrink-0 w-12 pt-1.5",children:"From:"}),d.jsx("div",{className:"text-sm py-1.5",children:a.email})]}):null}const o=r.some(a=>a.accountId===e);return d.jsxs("div",{className:"flex items-start gap-2",children:[d.jsx("label",{htmlFor:"from-account-selector",className:"text-sm text-fg-muted shrink-0 w-12 pt-1.5",children:"From:"}),d.jsxs("select",{id:"from-account-selector",value:o?e:"",onChange:a=>{const i=r.find(c=>c.accountId===a.target.value);i&&t(i)},className:"flex-1 px-2 py-1.5 border rounded-md bg-canvas text-sm",children:[!o&&d.jsx("option",{value:"",disabled:!0,children:"Choose an account"}),r.map(a=>d.jsx("option",{value:a.accountId,children:a.email},a.accountId))]})]})},gc=s.lazy(()=>Tr(()=>import("./rich-text-BBwYPM6F.js"),__vite__mapDeps([4,1,2,5,6,7,8,9,10,3,11,12,13,14,15,16])).then(e=>({default:e.ComposeBody}))),lr=e=>e?`<p></p><p>-- </p>${Dt(e)}`:"",Et=(e,t)=>t?{html:`${Dt(t.body)}${lr(e)}`,text:[t.body,e].filter(Boolean).join(`
54
54
 
55
55
  `)}:{html:lr(e),text:e},yc=e=>e?/^re:\s/i.test(e)?e:`Re: ${e}`:"Re: ",wc=e=>e?/^fwd?:\s/i.test(e)?e:`Fwd: ${e}`:"Fwd: ",bc=(e,t,n)=>{const{envelope:r}=e,a=(r.replyTo.length>0?r.replyTo:r.from).map(m=>({email:m.normalizedEmail,displayName:m.displayName}));if(t!=="reply-all")return{to:a,cc:[]};const i=n?.toLowerCase(),c=new Set(a.map(m=>m.email.toLowerCase())),u=[...r.to,...r.cc].filter(m=>m.normalizedEmail.toLowerCase()!==i&&!c.has(m.normalizedEmail.toLowerCase())).map(m=>({email:m.normalizedEmail,displayName:m.displayName}));return{to:a,cc:u}},ur=e=>{const t=e.envelope.messageIdValue,n=a=>e.references.filter(i=>i.referenceType===a).sort((i,c)=>i.referenceOrder-c.referenceOrder).map(i=>i.messageIdValue),r=n("references"),o=r.length>0?[...r]:n("in_reply_to");return t&&!o.includes(t)&&o.push(t),{inReplyTo:t,references:o}},Ec="Add a To address before sending.",xc="Loading the message you're quoting.",Sc="The message you're quoting couldn't be loaded, so it won't be included.",Rc="Add a To address before attaching a file — the draft the file is kept with is saved against it.",Cc=({label:e,text:t})=>`${e} holds "${t}", which is not an address.`,dr=e=>e.find(t=>t.text.trim()!==""),Tc={entries:[],unparsed:""},Ac=(e,t,n,r,o)=>e.length===0&&t.length===0&&n.length===0&&r.trim()===""&&o.text.trim()==="",Dc=({documentGeneration:e,selectedAccountId:t,onAccountChange:n,toAddresses:r,setToAddresses:o,ccAddresses:a,setCcAddresses:i,bccAddresses:c,setBccAddresses:u,showCc:m,setShowCc:f,showBcc:l,setShowBcc:h,subject:g,setSubject:x,fieldHandles:p,onToPendingChange:E})=>{const w=wa(),{isKeyboardOpen:A}=pc(),[y,v]=s.useState(void 0),D=y===e,[_,S]=s.useState(!1);return d.jsx("div",{className:"contents",onFocusCapture:()=>S(!0),onBlurCapture:k=>{k.currentTarget.contains(k.relatedTarget)||S(!1)},children:d.jsx(Ha,{collapsed:!w&&A&&!D&&!_,onExpand:()=>v(e),summary:Ua({to:r,cc:a,bcc:c,subject:g}),from:d.jsx(vc,{selectedAccountId:t,onSelect:n}),to:d.jsx(nn,{label:"To",addresses:r,onChange:o,placeholder:"Recipients",onPendingChange:E,ref:p.to}),cc:m?d.jsx(nn,{label:"Cc",addresses:a,onChange:i,ref:p.cc}):void 0,bcc:l?d.jsx(nn,{label:"Bcc",addresses:c,onChange:u,ref:p.bcc}):void 0,subject:d.jsx(Ka,{value:g,onChange:x}),onShowCc:()=>f(!0),onShowBcc:()=>h(!0)})})},Dl=({mode:e,account:t,sourceMessage:n,outboxMessageId:r,seed:o,insertion:a,onDraftCreated:i,onClose:c,onAccountChange:u,layout:m="fill"})=>{const{startSendPolling:f}=aa(),{pushError:l}=sa(),[h,g]=s.useState([]),[x,p]=s.useState([]),[E,w]=s.useState([]),[A,y]=s.useState(Tc),v=s.useRef(null),D=s.useRef(null),_=s.useRef(null),S=s.useMemo(()=>({to:v,cc:D,bcc:_}),[]),k=s.useCallback(()=>{v.current?.clearPending(),D.current?.clearPending(),_.current?.clearPending()},[]),[N,F]=s.useState(""),[b,P]=s.useState(!1),[C,q]=s.useState(!1),[$,Q]=s.useState(t?.accountId),[z,ee]=s.useState(!1),[ne,ye]=s.useState(r),Fe=s.useRef(void 0),Ce=s.useRef(!1),de=s.useRef(null),Te=s.useRef(r),Ae=s.useRef(r!==void 0),[De,Ne]=s.useState(r!==void 0),fe=s.useRef(r!==void 0?e:void 0),Oe=s.useRef(void 0),$e=s.useRef(e);$e.current=e;const me=s.useRef(t?.accountId);s.useEffect(()=>{const T=t?.accountId;!T||me.current===T||(me.current=T,!Ae.current&&Q(T))},[t?.accountId]),s.useEffect(()=>{const T=Te.current;if(T===r||(Te.current=r,T===void 0))return;Ae.current=r!==void 0,Ne(r!==void 0),fe.current=r!==void 0?$e.current:void 0,Oe.current=void 0;const U=r?{html:"",text:""}:Et(qe.current,I.current);g([]),p([]),w([]),k(),F(""),P(!1),q(!1),at(U.html),he(U.text),Xe("rich"),it(void 0),be({...U,formatting:[]}),Ye(Z=>Z+1),ee(!1),Fe.current=void 0,Ce.current=!1,ye(r)},[r,k]);const{signature:we}=pa($),qe=s.useRef(we.plainText);qe.current=we.plainText;const I=s.useRef(o);I.current=o;const[Ke,Ye]=s.useState(0),[Ge,at]=s.useState(()=>Et(we.plainText,o).html),[Lt,he]=s.useState(()=>Et(we.plainText,o).text),[ce,Xe]=s.useState("rich"),[re,Pt]=s.useState("en"),[st,it]=s.useState(),[pe,be]=s.useState(()=>({...Et(we.plainText,o),formatting:[]})),[_t,ct]=s.useState(()=>a?.version??0),Mt=a&&a.version>_t&&(r===void 0||z)?a:void 0,{data:j,error:Qe}=At({..._n({path:{outboxMessageId:r??""}}),enabled:!!r&&!z,meta:fa,retry:(T,U)=>!Mn(U)&&T<1});s.useEffect(()=>{Mn(Qe)&&c()},[Qe,c]),s.useEffect(()=>{if(!j||z)return;g(j.toAddresses.map(K=>({email:K,displayName:void 0}))),j.ccAddresses&&j.ccAddresses.length>0&&(p(j.ccAddresses.map(K=>({email:K,displayName:void 0}))),P(!0)),j.bccAddresses&&j.bccAddresses.length>0&&(w(j.bccAddresses.map(K=>({email:K,displayName:void 0}))),q(!0)),j.subject&&F(j.subject);const T=ia(j.htmlBody??""),U=T.html,Z=j.textBody??"";Xe(as(j.htmlBody)),it(T.language??void 0),at(U),he(Z),be({html:U,text:Z,formatting:[]}),Ye(K=>K+1),Q(j.accountId),ee(!0),Ce.current=!0},[j,z]),s.useEffect(()=>{if(n){if(Ae.current&&fe.current===e){const T=Oe.current;if(!T||T.myEmail===t?.email)return}if(fe.current=e,Oe.current={myEmail:t?.email},k(),e==="reply"||e==="reply-all"){const{to:T,cc:U}=bc(n,e,t?.email);g(T),p(U),U.length>0&&P(!0),F(yc(n.envelope.subject))}e==="forward"&&(g([]),p([]),w([]),F(wc(n.envelope.subject)))}},[e,n,t?.email,k]);const ke=e==="reply"||e==="reply-all"||e==="forward",{data:Ie,isLoading:lt,isError:jt,hasNoRenderablePart:Ft,refetch:O}=ha({messageId:n?.message.messageId,bodyParts:n?.bodyParts,enabled:ke&&!!n}),M=e==="forward"?"forward":"reply",B=ke&&!n,L=ke&&!De&&Ft,H=L&&M==="forward",W=s.useMemo(()=>{if(!ke||!n||De||!Ie)return;const T=Ie.kind==="html"?{kind:"html",content:os(Ie.body)}:{kind:"text",content:Ie.body};return mc(e==="forward"?"forward":"reply",n.envelope,T)},[ke,n,De,Ie,e]),X=n?.envelope.from[0]?.displayName??n?.envelope.from[0]?.normalizedEmail,le=s.useCallback(T=>{ee(!0),ye(T),i(T)},[i]),{saveState:te,saveError:oe,saveDraft:se,saveImmediately:J,stopAutoSave:ue}=Zi({outboxMessageId:r,onDraftCreated:le}),ut=s.useCallback(async()=>{if(r)return{outcome:"ready",outboxMessageId:r};if(!$)return{outcome:"refused",reason:"Choose an account to send from before attaching a file."};if(h.length===0)return{outcome:"refused",reason:Rc};const{htmlBody:T,textBody:U}=rn(ce,pe,re,W),Z=await J({accountId:$,toAddresses:h.map(K=>K.email),ccAddresses:x.length>0?x.map(K=>K.email):void 0,bccAddresses:E.length>0?E.map(K=>K.email):void 0,subject:N||void 0,textBody:U,htmlBody:T,...n&&(e==="reply"||e==="reply-all")?ur(n):{}});return Z.outcome==="failed"?{outcome:"refused",reason:`The draft could not be saved, so the file was not attached: ${Se(Z.error)??"the request failed"}.`}:{outcome:"ready",outboxMessageId:Z.outboxMessageId}},[r,$,h,x,E,N,pe,ce,re,W,n,e,J]),{items:wo,attach:$t,retry:bo,remove:Eo,load:Rn,reset:Cn,owns:xo,isLoaded:So,refreshLinks:Ro,storedContent:Co,onRemoved:To,blockingReason:Bt}=$i({ensureDraft:ut}),Ao=Cr(),Do=Ki({attach:$t,owns:xo,isLoaded:So,storedContent:Co,refreshLinks:()=>r?Ao.fetchQuery({..._n({path:{outboxMessageId:r}}),staleTime:0}).then(T=>Ro(T.attachments)):Promise.resolve(),onRemoved:To,draftAttachments:j&&j.outboxMessageId===r?j.attachments:[],pushError:l}),Tn=s.useRef(r);s.useEffect(()=>{const T=Tn.current;T!==r&&(Tn.current=r,T!==void 0&&Cn(r))},[r,Cn]);const An=s.useRef(void 0);s.useEffect(()=>{!j||j.outboxMessageId!==r||An.current!==j.outboxMessageId&&(An.current=j.outboxMessageId,Rn(j.outboxMessageId,j.attachments))},[j,r,Rn]),s.useEffect(()=>{oe&&l({title:"Couldn't save draft",detail:Se(oe)??"Saving the draft failed.",error:oe})},[oe,l]);const Dn=_e({...ca(),meta:Me}),Nn=_e({...ua(),meta:Me,onError:T=>{l(la("Couldn't discard draft","The draft wasn't discarded.",T))}}),{data:No}=At({...Ar(),staleTime:1/0}),Ze=No?.accounts.find(T=>T.accountId===$),Ut=Ze?va(Ze):!1,[Ht,Oo]=s.useState(),Wt=Ht&&Ht.accountId===$?Ht.reason:void 0,dt=Ze?.composeLanguages,ko=s.useMemo(()=>dt&&dt.length>0?dt:da(navigator.languages),[dt]),Io=s.useMemo(()=>oc(l),[l]),ft=s.useRef(!1),[On,kn]=s.useState(!1),mt=s.useCallback((T,U)=>On?{status:"sending"}:$?Wt?{status:"blocked",reason:Wt}:Ut?{status:"blocked",reason:dn}:lt||B?{status:"blocked",reason:xc}:Bt?{status:"blocked",reason:Bt}:U?{status:"blocked",reason:Cc(U)}:T===0?{status:"blocked",reason:Ec}:H?{status:"blocked",reason:Nr}:{status:"ready",accountId:$}:{status:"blocked",reason:"Choose an account to send from."},[On,$,Wt,Ut,lt,B,Bt,H]),zt=s.useMemo(()=>mt(h.length+A.entries.length,dr([{label:"To",text:A.unparsed}])),[mt,h.length,A]),Lo=zt;s.useEffect(()=>{if(!$||ft.current||ne!==void 0&&ne!==r||r&&!z||Ac(h,x,E,N,pe))return;const{htmlBody:T,textBody:U}=rn(ce,pe,re,W),Z={accountId:$,toAddresses:h.map(ae=>ae.email),ccAddresses:x.length>0?x.map(ae=>ae.email):void 0,bccAddresses:E.length>0?E.map(ae=>ae.email):void 0,subject:N||void 0,textBody:U,htmlBody:T},K=JSON.stringify(Z);if(Ce.current){Ce.current=!1,Fe.current=K;return}Fe.current!==K&&(Fe.current=void 0,se(Z))},[$,r,ne,z,h,x,E,N,pe,ce,re,W,se]);const In=s.useCallback(async(T,U)=>{if(!ft.current){ft.current=!0,kn(!0);try{ue();const Z=n&&(e==="reply"||e==="reply-all")?ur(n):{},{htmlBody:K,textBody:ae}=rn(ce,pe,re,W),Mo=!r,ht=await J({accountId:T,toAddresses:U.to.map(ve=>ve.email),ccAddresses:U.cc.length>0?U.cc.map(ve=>ve.email):void 0,bccAddresses:U.bcc.length>0?U.bcc.map(ve=>ve.email):void 0,subject:N||void 0,textBody:ae,htmlBody:K,...Z});if(ht.outcome==="failed"){l({title:"Couldn't send message",detail:Se(ht.error)??"Saving the message failed, so nothing was sent. Try again.",error:ht.error});return}const qt=ht.outboxMessageId;if(await Dn.mutateAsync({path:{outboxMessageId:qt}}).catch(ve=>{const Pn=ac(ve);return Pn&&Oo({accountId:T,reason:Pn}),l({title:"Couldn't send message",detail:Se(ve)??(Mo?"The draft was saved but the send request failed. Try again from the Outbox.":"The send request failed. Try again."),error:ve}),null})===null)return;ue(qt),f(qt),c()}finally{ft.current=!1,kn(!1)}}},[N,pe,ce,re,W,e,n,r,J,Dn,ue,f,l,c]),Po=s.useCallback(()=>{ue(r),r&&Nn.mutate({path:{outboxMessageId:r}}),c()},[ue,r,Nn,c]),Vt=s.useCallback(T=>{l({title:"Can't send yet",detail:T}),T===dn&&de.current?.focus()},[l]),Ln=s.useCallback(()=>{if(zt.status==="sending")return;const T=S.to.current?.commitPending(),U=S.cc.current?.commitPending(),Z=S.bcc.current?.commitPending(),K={to:T?.addresses??h,cc:U?.addresses??x,bcc:Z?.addresses??E},ae=mt(K.to.length,dr([{label:"To",text:T?.unparsed??""},{label:"Cc",text:U?.unparsed??""},{label:"Bcc",text:Z?.unparsed??""}]));if(ae.status!=="sending"){if(ae.status==="blocked"){Vt(ae.reason);return}In(ae.accountId,K)}},[zt.status,S,h,x,E,mt,Vt,In]),_o=s.useCallback(T=>{Q(T.accountId),u?.(T)},[u]);return d.jsx(Ba,{layout:m,onDropFiles:T=>{$t(T)},banner:d.jsxs(d.Fragment,{children:[Ze&&Ut?d.jsx(tc,{accountId:Ze.accountId,configureRef:de}):null,L?d.jsx(Va,{mode:M}):null,jt?d.jsxs(wr,{tone:"warning","data-testid":"compose-quote-failed",children:[d.jsx("span",{children:Sc})," ",d.jsx("button",{type:"button",className:"underline",onClick:()=>{O()},children:"Try again"})]}):null]}),header:d.jsx(Dc,{documentGeneration:Ke,selectedAccountId:$,onAccountChange:_o,toAddresses:h,setToAddresses:g,ccAddresses:x,setCcAddresses:p,bccAddresses:E,setBccAddresses:w,showCc:b,setShowCc:P,showBcc:C,setShowBcc:q,subject:N,setSubject:F,fieldHandles:S,onToPendingChange:y}),quoted:W?d.jsx(Ya,{text:W.text,html:W.html,senderName:X}):void 0,attachments:d.jsx(ja,{items:wo,onRemove:T=>{Eo(T)},onRetry:T=>{bo(T)}}),actionBar:d.jsx(Na,{send:Lo,onSend:Ln,onBlocked:Vt,onDiscard:Po,save:te,onAttach:T=>{$t(T)}}),children:d.jsx(s.Suspense,{fallback:d.jsx(Fa,{}),children:d.jsx(gc,{mode:ce,onModeChange:Xe,initialHtml:Ge,initialText:Lt,onChange:be,onSubmit:Ln,initialCaret:e==="new"?"start":void 0,onConversionError:l,languages:ko,initialLanguage:st,onLanguageChange:Pt,spellcheck:Io,insertion:Mt,onInserted:ct,inlineImages:Do},Ke)})})};var It="Dialog",[Yr]=cs(It),[Nc,ie]=Yr(It),Gr=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:a,modal:i=!0}=e,c=s.useRef(null),u=s.useRef(null),[m,f]=ds({prop:r,defaultProp:o??!1,onChange:a,caller:It});return d.jsx(Nc,{scope:t,triggerRef:c,contentRef:u,contentId:Xt(),titleId:Xt(),descriptionId:Xt(),open:m,onOpenChange:f,onOpenToggle:s.useCallback(()=>f(l=>!l),[f]),modal:i,children:n})};Gr.displayName=It;var Xr="DialogTrigger",Oc=s.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ie(Xr,n),a=je(t,o.triggerRef);return d.jsx(ge.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":xn(o.open),...r,ref:a,onClick:Re(e.onClick,o.onOpenToggle)})});Oc.displayName=Xr;var En="DialogPortal",[kc,Qr]=Yr(En,{forceMount:void 0}),Zr=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,a=ie(En,t);return d.jsx(kc,{scope:t,forceMount:n,children:s.Children.map(r,i=>d.jsx(Ot,{present:n||a.open,children:d.jsx(Mr,{asChild:!0,container:o,children:i})}))})};Zr.displayName=En;var Nt="DialogOverlay",Jr=s.forwardRef((e,t)=>{const n=Qr(Nt,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,a=ie(Nt,e.__scopeDialog);return a.modal?d.jsx(Ot,{present:r||a.open,children:d.jsx(Lc,{...o,ref:t})}):null});Jr.displayName=Nt;var Ic=kr("DialogOverlay.RemoveScroll"),Lc=s.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ie(Nt,n),a=Os(),i=je(t,a);return d.jsx(zr,{as:Ic,allowPinchZoom:!0,shards:[o.contentRef],children:d.jsx(ge.div,{"data-state":xn(o.open),...r,ref:i,style:{pointerEvents:"auto",...r.style}})})}),Ve="DialogContent",eo=s.forwardRef((e,t)=>{const n=Qr(Ve,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,a=ie(Ve,e.__scopeDialog);return d.jsx(Ot,{present:r||a.open,children:a.modal?d.jsx(Pc,{...o,ref:t}):d.jsx(_c,{...o,ref:t})})});eo.displayName=Ve;var Pc=s.forwardRef((e,t)=>{const n=ie(Ve,e.__scopeDialog),r=s.useRef(null),o=je(t,n.contentRef,r);return s.useEffect(()=>{const a=r.current;if(a)return Zs(a)},[]),d.jsx(to,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:Re(e.onCloseAutoFocus,a=>{a.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Re(e.onPointerDownOutside,a=>{const i=a.detail.originalEvent,c=i.button===0&&i.ctrlKey===!0;(i.button===2||c)&&a.preventDefault()}),onFocusOutside:Re(e.onFocusOutside,a=>a.preventDefault())})}),_c=s.forwardRef((e,t)=>{const n=ie(Ve,e.__scopeDialog),r=s.useRef(!1),o=s.useRef(!1);return d.jsx(to,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{e.onCloseAutoFocus?.(a),a.defaultPrevented||(r.current||n.triggerRef.current?.focus(),a.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:a=>{e.onInteractOutside?.(a),a.defaultPrevented||(r.current=!0,a.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=a.target;n.triggerRef.current?.contains(i)&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&o.current&&a.preventDefault()}})}),to=s.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:a,...i}=e,c=ie(Ve,n);return Ps(),d.jsx(d.Fragment,{children:d.jsx(Pr,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:a,children:d.jsx(Ir,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":xn(c.open),...i,ref:t,deferPointerDownOutside:!0,onDismiss:()=>c.onOpenChange(!1)})})})}),no="DialogTitle",ro=s.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ie(no,n);return d.jsx(ge.h2,{id:o.titleId,...r,ref:t})});ro.displayName=no;var oo="DialogDescription",Mc=s.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ie(oo,n);return d.jsx(ge.p,{id:o.descriptionId,...r,ref:t})});Mc.displayName=oo;var ao="DialogClose",jc=s.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ie(ao,n);return d.jsx(ge.button,{type:"button",...r,ref:t,onClick:Re(e.onClick,()=>o.onOpenChange(!1))})});jc.displayName=ao;function xn(e){return e?"open":"closed"}function Fc(e){if(typeof document>"u")return;let t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}const so=R.createContext({drawerRef:{current:null},overlayRef:{current:null},onPress:()=>{},onRelease:()=>{},onDrag:()=>{},onNestedDrag:()=>{},onNestedOpenChange:()=>{},onNestedRelease:()=>{},openProp:void 0,dismissible:!1,isOpen:!1,isDragging:!1,keyboardIsOpen:{current:!1},snapPointsOffset:null,snapPoints:null,handleOnly:!1,modal:!1,shouldFade:!1,activeSnapPoint:null,onOpenChange:()=>{},setActiveSnapPoint:()=>{},closeDrawer:()=>{},direction:"bottom",shouldAnimate:{current:!0},shouldScaleBackground:!1,setBackgroundColorOnScale:!0,noBodyStyles:!1,container:null,autoFocus:!1}),ot=()=>{const e=R.useContext(so);if(!e)throw new Error("useDrawerContext must be used within a Drawer.Root");return e};Fc(`[data-vaul-drawer]{touch-action:none;will-change:transform;transition:transform .5s cubic-bezier(.32, .72, 0, 1);animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=open]{animation-name:slideFromBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=closed]{animation-name:slideToBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=open]{animation-name:slideFromTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=closed]{animation-name:slideToTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=open]{animation-name:slideFromLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=closed]{animation-name:slideToLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=open]{animation-name:slideFromRight}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=closed]{animation-name:slideToRight}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--initial-transform,100%),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--initial-transform,100%),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-overlay][data-vaul-snap-points=false]{animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-overlay][data-vaul-snap-points=false][data-state=open]{animation-name:fadeIn}[data-vaul-overlay][data-state=closed]{animation-name:fadeOut}[data-vaul-animate=false]{animation:none!important}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:0;transition:opacity .5s cubic-bezier(.32, .72, 0, 1)}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:1}[data-vaul-drawer]:not([data-vaul-custom-container=true])::after{content:'';position:absolute;background:inherit;background-color:inherit}[data-vaul-drawer][data-vaul-drawer-direction=top]::after{top:initial;bottom:100%;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=bottom]::after{top:100%;bottom:initial;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=left]::after{left:initial;right:100%;top:0;bottom:0;width:200%}[data-vaul-drawer][data-vaul-drawer-direction=right]::after{left:100%;right:initial;top:0;bottom:0;width:200%}[data-vaul-overlay][data-vaul-snap-points=true]:not([data-vaul-snap-points-overlay=true]):not(
56
56
  [data-state=closed]
@@ -0,0 +1 @@
1
+ import{j as t,ad as o}from"./index-CL_fwLHN.js";const n=()=>t.jsx(o,{to:"/settings/accounts"});export{n as component};
@@ -0,0 +1 @@
1
+ import{j as o}from"./index-CL_fwLHN.js";import{F as r}from"./FlaggedPane-Dw-wR4tp.js";import"./MessageBody-C89PSL_p.js";import"./kbd-CDJCJUnp.js";import"./search-scope-UI1H6AzA.js";import"./reply-DvdgFS16.js";import"./useMediaQuery-DiQ0fGER.js";import"./useMessageBodyContent-D-LJBFh4.js";import"./MessageToolbar-UJadqHyA.js";import"./roving-focus-FWOr5tBU.js";import"./search-token-index-B1HU1d2-.js";import"./useQueries-hChzM5ru.js";import"./EmptyState-BUOSmldo.js";import"./ErrorState-KjDYblD5.js";import"./popover-menu-fjlAfNO1.js";import"./avatar-uWJajuSb.js";import"./index-DZb7rV9A.js";import"./useSignature-BkzkUbjz.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-BTZsNKEh.js";import"./sections-Rf3k05-_.js";import"./undo-2-Bdx8L5xj.js";import"./download-SQdHw0Vd.js";import"./calendar-suggestion-8jcpefeR.js";import"./sparkles-Bcn4ZRhZ.js";import"./useCalendarSuggestions-D3Jza1d7.js";import"./calendar-format-BwCpz-JZ.js";import"./calendar-failure-note-BtZLcaiZ.js";import"./checkbox-CGG1nAhQ.js";import"./clock-NnulNCOv.js";import"./shield-check-CdR23I2B.js";import"./calendar-tMekVEGW.js";import"./useLayoutTier-DrLg7_rq.js";import"./menu-CcLh9Whg.js";import"./useFilters-CIuC8WLg.js";import"./confirm-dialog-q8tbS_22.js";import"./MailViewChrome-yffBJjbO.js";import"./refresh-cw-5OKnYRBy.js";import"./wizard-selection-zWa1qc6-.js";function N(){return o.jsx(r.Reading,{})}export{N as component};
@@ -0,0 +1 @@
1
+ import{fP as o,j as r}from"./index-CL_fwLHN.js";import{C as m}from"./CalendarEventPopup-CqHE2vrc.js";import"./confirm-dialog-q8tbS_22.js";import"./calendar-event-popup-DsPmxVye.js";import"./pencil-LSmMSKiW.js";import"./useCalendarSuggestions-D3Jza1d7.js";import"./ErrorState-KjDYblD5.js";import"./useQueries-hChzM5ru.js";import"./calendar-guests-BR4hC59z.js";import"./circle-help-CVWHf1ow.js";import"./useCalendarTasks-D_NZ0GM6.js";import"./useCalendarData-DXhaM_NM.js";import"./calendar-format-BwCpz-JZ.js";import"./reply-DvdgFS16.js";import"./useMediaQuery-DiQ0fGER.js";import"./calendar-tMekVEGW.js";import"./CalendarSession-BKwK9s2o.js";function v(){const{calendarObjectId:t}=o.useParams();return r.jsx(m,{calendarObjectId:t})}export{v as component};
@@ -1 +1 @@
1
- import{j as s,o as t}from"./index-BzL5-pGT.js";function o({className:e,...n}){return s.jsx("kbd",{className:t("inline-flex h-4 min-w-4 items-center justify-center rounded-xs border border-line bg-surface-sunken px-1 font-sans text-2xs text-fg-muted",e),...n})}export{o as K};
1
+ import{j as s,o as t}from"./index-CL_fwLHN.js";function o({className:e,...n}){return s.jsx("kbd",{className:t("inline-flex h-4 min-w-4 items-center justify-center rounded-xs border border-line bg-surface-sunken px-1 font-sans text-2xs text-fg-muted",e),...n})}export{o as K};
@@ -1 +1 @@
1
- import{r as f,j as e,au as h,bf as y,at as b,bG as g,d as v,T as N,u as C,a as L,c as I,aK as D,aM as S,B as w}from"./index-BzL5-pGT.js";import{C as E}from"./confirm-dialog-CgMAaLI3.js";import{E as j}from"./ErrorState-nA0Ptq3g.js";import{S as $}from"./settings-screen-4md2ibPl.js";import{a as T,b as k,c as R,u as O}from"./useLabels-DYdHiHXI.js";import"./avatar-vPm9XfmM.js";import"./menu-CGw_RHKl.js";import"./circle-help-CVShnhWn.js";function B({labels:l,onRename:i,onRecolor:n,onDelete:m,deletingLabelId:c}){const[u,r]=f.useState(),[o,d]=f.useState("");if(l.length===0)return e.jsx("p",{className:"py-6 text-sm text-fg-muted",children:"No labels yet. Create one below, then use it in a filter or apply it to mail directly."});const t=a=>{const s=o.trim();s!==""&&i(a,s),r(void 0)};return e.jsx("ul",{className:"divide-y divide-line rounded-md border border-line",children:l.map(a=>e.jsxs("li",{className:"flex items-center gap-3 px-3 py-2.5",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[u===a.labelId?e.jsx(h,{autoFocus:!0,value:o,onChange:s=>d(s.target.value),onBlur:()=>t(a.labelId),onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),t(a.labelId)),s.key==="Escape"&&(s.preventDefault(),r(void 0))},"aria-label":`Rename label ${a.name}`}):e.jsx("button",{type:"button",onClick:()=>{r(a.labelId),d(a.name)},"aria-label":`Rename label ${a.name}`,className:"flex items-center gap-2 rounded-sm text-left hover:opacity-80",children:e.jsx(y,{label:a})}),e.jsx("p",{className:"mt-0.5 text-xs text-fg-subtle",children:a.filterCount===0?"Not used in any filter":`Used in ${a.filterCount} ${a.filterCount===1?"filter":"filters"}`})]}),e.jsx(b,{"aria-label":`Color for ${a.name}`,value:a.color,onChange:s=>n(a.labelId,s.target.value),className:"w-28 shrink-0",children:g.map(s=>e.jsx("option",{value:s,children:s},s))}),e.jsx(v,{variant:"ghost",size:"sm",icon:e.jsx(N,{className:"size-4 text-danger"}),onClick:()=>m(a),disabled:c===a.labelId,"aria-label":`Delete label ${a.name}`})]},a.labelId))})}const P=(l,i)=>{if(i===0)return{title:`Delete the "${l}" label?`};const n=i===1?"filter":"filters";return{title:`Delete the "${l}" label?`,description:`This also deletes ${i} ${n} that ${i===1?"applies":"apply"} it — they can't be recovered.`}},_=e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{children:"Labels mark mail without moving it — a message can carry any number of them alongside whichever folder it lives in."}),e.jsx("p",{children:"Use a label in a filter's action to have new (and existing) mail label itself automatically, or apply one to a selection directly from the mailbox."}),e.jsx("p",{children:"Deleting a label removes it from every message, and deletes every filter that applies it — the confirmation names how many."})]});function G({accountId:l}){const{createLabel:i,isPending:n,isError:m}=O(l),[c,u]=f.useState(""),[r,o]=f.useState("Default"),d=()=>{const t=c.trim();t!==""&&i(t,r).then(()=>{u(""),o("Default")})};return e.jsxs("div",{className:"space-y-2 rounded-sm border border-line bg-surface p-3",children:[e.jsx("p",{className:"text-sm font-medium text-fg",children:"New label"}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-end",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx("span",{className:"text-xs text-fg-muted",children:"Name"}),e.jsx(h,{value:c,onChange:t=>u(t.target.value),placeholder:"e.g. Receipts","aria-label":"Label name",onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),d())}})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-xs text-fg-muted",children:"Color"}),e.jsx(b,{value:r,onChange:t=>o(t.target.value),"aria-label":"Label color",className:"w-28",children:g.map(t=>e.jsx("option",{value:t,children:t},t))})]}),e.jsx(v,{variant:"primary",onClick:d,disabled:n||c.trim()==="",children:n?"Creating…":"Create label"})]}),m&&e.jsx(w,{tone:"danger",variant:"soft",children:"Couldn't create that label. Please try again."})]})}function H({account:l}){const i=l.accountId,{labels:n,isPending:m,isError:c,error:u,refetch:r}=T(i),{updateLabel:o}=k(i),{deleteLabel:d,deletingLabelId:t}=R(i),[a,s]=f.useState();return e.jsxs("section",{className:"space-y-2",children:[e.jsx("h2",{className:"text-sm font-semibold text-fg",children:l.email}),m?e.jsx("div",{className:"h-16 animate-pulse rounded-md border border-line bg-surface","aria-busy":"true","aria-label":`Loading labels for ${l.email}`}):c?e.jsx(j,{variant:"inline",title:`Couldn't load labels for ${l.email}`,error:u,onRetry:()=>{r()}}):e.jsx(B,{labels:n,onRename:(p,x)=>o(p,{name:x}),onRecolor:(p,x)=>o(p,{color:x}),onDelete:s,deletingLabelId:t}),e.jsx(G,{accountId:i}),a&&(()=>{const p=P(a.name,a.filterCount);return e.jsx(E,{isOpen:!0,title:p.title,description:p.description,confirmLabel:"Delete label",destructive:!0,isBusy:t===a.labelId,onConfirm:()=>{d(a.labelId),s(void 0)},onCancel:()=>s(void 0)})})()]})}function q(){const l=C(),[i,n]=f.useState(!0),{data:m,isPending:c,isError:u,error:r,refetch:o}=L(I()),d=t=>{const a=S[t];a&&l({to:a})};return e.jsx($,{items:D,activeId:"labels",title:"Labels",description:"Mark mail without moving it, per account.",help:_,helpOpen:i,onToggleHelp:()=>n(t=>!t),onSelect:d,onBackToMail:()=>{l({to:"/mail"})},children:c?e.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":"Loading accounts"}):u?e.jsx(j,{title:"Couldn't load accounts",error:r,onRetry:()=>{o()}}):m.accounts.length===0?e.jsx("p",{className:"py-12 text-sm text-fg-muted",children:"No accounts configured."}):e.jsx("div",{className:"space-y-8",children:m.accounts.map(t=>e.jsx(H,{account:t},t.accountId))})})}export{q as component};
1
+ import{r as f,j as e,au as h,bf as y,at as b,bG as g,d as v,T as N,u as C,a as L,c as I,aK as D,aM as S,B as w}from"./index-CL_fwLHN.js";import{C as E}from"./confirm-dialog-q8tbS_22.js";import{E as j}from"./ErrorState-KjDYblD5.js";import{S as $}from"./settings-screen-DBP3ABLE.js";import{a as T,b as k,c as R,u as O}from"./useLabels-BZFMPVjT.js";import"./avatar-uWJajuSb.js";import"./menu-CcLh9Whg.js";import"./circle-help-CVWHf1ow.js";function B({labels:l,onRename:i,onRecolor:n,onDelete:m,deletingLabelId:c}){const[u,r]=f.useState(),[o,d]=f.useState("");if(l.length===0)return e.jsx("p",{className:"py-6 text-sm text-fg-muted",children:"No labels yet. Create one below, then use it in a filter or apply it to mail directly."});const t=a=>{const s=o.trim();s!==""&&i(a,s),r(void 0)};return e.jsx("ul",{className:"divide-y divide-line rounded-md border border-line",children:l.map(a=>e.jsxs("li",{className:"flex items-center gap-3 px-3 py-2.5",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[u===a.labelId?e.jsx(h,{autoFocus:!0,value:o,onChange:s=>d(s.target.value),onBlur:()=>t(a.labelId),onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),t(a.labelId)),s.key==="Escape"&&(s.preventDefault(),r(void 0))},"aria-label":`Rename label ${a.name}`}):e.jsx("button",{type:"button",onClick:()=>{r(a.labelId),d(a.name)},"aria-label":`Rename label ${a.name}`,className:"flex items-center gap-2 rounded-sm text-left hover:opacity-80",children:e.jsx(y,{label:a})}),e.jsx("p",{className:"mt-0.5 text-xs text-fg-subtle",children:a.filterCount===0?"Not used in any filter":`Used in ${a.filterCount} ${a.filterCount===1?"filter":"filters"}`})]}),e.jsx(b,{"aria-label":`Color for ${a.name}`,value:a.color,onChange:s=>n(a.labelId,s.target.value),className:"w-28 shrink-0",children:g.map(s=>e.jsx("option",{value:s,children:s},s))}),e.jsx(v,{variant:"ghost",size:"sm",icon:e.jsx(N,{className:"size-4 text-danger"}),onClick:()=>m(a),disabled:c===a.labelId,"aria-label":`Delete label ${a.name}`})]},a.labelId))})}const P=(l,i)=>{if(i===0)return{title:`Delete the "${l}" label?`};const n=i===1?"filter":"filters";return{title:`Delete the "${l}" label?`,description:`This also deletes ${i} ${n} that ${i===1?"applies":"apply"} it — they can't be recovered.`}},_=e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{children:"Labels mark mail without moving it — a message can carry any number of them alongside whichever folder it lives in."}),e.jsx("p",{children:"Use a label in a filter's action to have new (and existing) mail label itself automatically, or apply one to a selection directly from the mailbox."}),e.jsx("p",{children:"Deleting a label removes it from every message, and deletes every filter that applies it — the confirmation names how many."})]});function G({accountId:l}){const{createLabel:i,isPending:n,isError:m}=O(l),[c,u]=f.useState(""),[r,o]=f.useState("Default"),d=()=>{const t=c.trim();t!==""&&i(t,r).then(()=>{u(""),o("Default")})};return e.jsxs("div",{className:"space-y-2 rounded-sm border border-line bg-surface p-3",children:[e.jsx("p",{className:"text-sm font-medium text-fg",children:"New label"}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-end",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx("span",{className:"text-xs text-fg-muted",children:"Name"}),e.jsx(h,{value:c,onChange:t=>u(t.target.value),placeholder:"e.g. Receipts","aria-label":"Label name",onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),d())}})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-xs text-fg-muted",children:"Color"}),e.jsx(b,{value:r,onChange:t=>o(t.target.value),"aria-label":"Label color",className:"w-28",children:g.map(t=>e.jsx("option",{value:t,children:t},t))})]}),e.jsx(v,{variant:"primary",onClick:d,disabled:n||c.trim()==="",children:n?"Creating…":"Create label"})]}),m&&e.jsx(w,{tone:"danger",variant:"soft",children:"Couldn't create that label. Please try again."})]})}function H({account:l}){const i=l.accountId,{labels:n,isPending:m,isError:c,error:u,refetch:r}=T(i),{updateLabel:o}=k(i),{deleteLabel:d,deletingLabelId:t}=R(i),[a,s]=f.useState();return e.jsxs("section",{className:"space-y-2",children:[e.jsx("h2",{className:"text-sm font-semibold text-fg",children:l.email}),m?e.jsx("div",{className:"h-16 animate-pulse rounded-md border border-line bg-surface","aria-busy":"true","aria-label":`Loading labels for ${l.email}`}):c?e.jsx(j,{variant:"inline",title:`Couldn't load labels for ${l.email}`,error:u,onRetry:()=>{r()}}):e.jsx(B,{labels:n,onRename:(p,x)=>o(p,{name:x}),onRecolor:(p,x)=>o(p,{color:x}),onDelete:s,deletingLabelId:t}),e.jsx(G,{accountId:i}),a&&(()=>{const p=P(a.name,a.filterCount);return e.jsx(E,{isOpen:!0,title:p.title,description:p.description,confirmLabel:"Delete label",destructive:!0,isBusy:t===a.labelId,onConfirm:()=>{d(a.labelId),s(void 0)},onCancel:()=>s(void 0)})})()]})}function q(){const l=C(),[i,n]=f.useState(!0),{data:m,isPending:c,isError:u,error:r,refetch:o}=L(I()),d=t=>{const a=S[t];a&&l({to:a})};return e.jsx($,{items:D,activeId:"labels",title:"Labels",description:"Mark mail without moving it, per account.",help:_,helpOpen:i,onToggleHelp:()=>n(t=>!t),onSelect:d,onBackToMail:()=>{l({to:"/mail"})},children:c?e.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":"Loading accounts"}):u?e.jsx(j,{title:"Couldn't load accounts",error:r,onRetry:()=>{o()}}):m.accounts.length===0?e.jsx("p",{className:"py-12 text-sm text-fg-muted",children:"No accounts configured."}):e.jsx("div",{className:"space-y-8",children:m.accounts.map(t=>e.jsx(H,{account:t},t.accountId))})})}export{q as component};
@@ -1 +1 @@
1
- import{b as B,r as f,j as e,o as C,p as Ee,q as Le,D as Ae,X as Fe,C as Te,S as oe,t as q,v as H,w as re,x as ie,F as ze,T as De,y as _e,M as Be,z as Ke,E as Qe,I as qe,G as le,d as P,H as ce,J as He,K as Ve,N as $e,P as ue,f as K,Q as de,R as me,U as Ue,V as We,W as Ge,Y as xe,a as fe,Z as Ye,_ as Je,$ as z,a0 as Xe,a1 as Ze,a2 as es,a3 as ss,a4 as ts,a5 as as,a6 as ns,a7 as os,a8 as rs,u as is,c as ls,a9 as cs,O as us}from"./index-BzL5-pGT.js";import{E as ds}from"./ErrorState-nA0Ptq3g.js";import{K as ms,B as xs,S as fs,u as ps,s as hs,b as gs,a as bs,c as vs,d as ys}from"./search-token-index-DQHE1g7A.js";import{K as V}from"./kbd-B9MFmWVU.js";import{u as js,l as O,a as D,m as $,b as Ns,c as Ss,N as w,d as Cs,e as ws,i as Is,f as Os}from"./reply-CQarAZxU.js";import{A as ks}from"./AppFrame-R9FR9SH9.js";import{P as Ms}from"./pencil-DOoqyGzC.js";import{u as Q,a as Rs}from"./useMessageBodyContent-CWGtiddz.js";import{c as Ps,s as Es,M as Ls}from"./MailShell-0sTtK1xD.js";import{u as As,a as Fs,R as Ts,s as zs,i as Ds,H as _s,M as Bs}from"./useRefreshControl-bA8HK_j-.js";import{M as Ks}from"./menu-CGw_RHKl.js";import{B as pe,u as Qs}from"./useResultFolderIndex-BaqajWHb.js";import{A as qs}from"./avatar-vPm9XfmM.js";import{u as Hs,P as Vs,a as $s,b as Us}from"./popover-menu-CNiMANtf.js";import{u as Ws}from"./sections-C6oVXjho.js";import{u as Gs}from"./roving-focus-Coea111y.js";import{C as Ys,A as Js}from"./account-service-status-Kz9s3jOk.js";import{S as Xs}from"./sparkles-C1l6GCPT.js";import{u as he}from"./useQueries-Sm8S3Cgh.js";import{f as Zs}from"./folder-failure-CqkVSsrb.js";import{i as et}from"./outbox-status-BlKn6P0x.js";import{u as st}from"./index-BWAq8iOl.js";import{u as ge,i as tt}from"./useLayoutTier-5aJYrTut.js";import{u as at}from"./useDebouncedValue-B7157ZPO.js";import"./search-scope-UI1H6AzA.js";import"./useMediaQuery-7Q3jBluO.js";import"./FullCompose-dJ4mfUrX.js";import"./confirm-dialog-CgMAaLI3.js";import"./circle-check-big-CyVG6r7N.js";import"./refresh-cw-D1SQy8O7.js";import"./useSignature-sxHvGfKr.js";import"./account-form-helpers-DhckT_PN.js";const be=B("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);const ve=B("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const nt=B("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]);function ot({email:s,onSignOut:t}){const a=f.useRef(null),{open:n,setOpen:o,containerRef:r,panelRef:i,getAnchor:u}=Hs("account-menu",()=>a.current?.focus());f.useEffect(()=>{if(!n)return;const d=requestAnimationFrame(()=>i.current?.querySelector('[role="menuitem"]')?.focus());return()=>cancelAnimationFrame(d)},[n,i]);const m=s??"Account";return e.jsxs("div",{ref:r,className:"relative",children:[e.jsx("button",{ref:a,type:"button","aria-label":"Account","aria-haspopup":"menu","aria-expanded":n,onClick:()=>o(d=>!d),className:"inline-flex min-h-11 min-w-11 items-center justify-center rounded-md p-1.5 text-fg-muted transition-colors hover:bg-surface-raised hover:text-fg",children:e.jsx(qs,{name:m,email:s??void 0,size:"sm"})}),e.jsx(Vs,{open:n,align:"end",panelRef:i,getAnchor:u,children:e.jsxs($s,{ref:i,label:m,children:[s&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"truncate px-4 py-2 text-xs text-fg-muted",title:s,"data-testid":"account-menu-email",children:s}),e.jsx("hr",{className:"my-1 h-px border-0 bg-line"})]}),e.jsx(Us,{label:"Sign out",icon:e.jsx(be,{className:"size-4"}),onSelect:()=>{o(!1),a.current?.focus(),t()}})]})})]})}function rt({leading:s,search:t,actions:a,className:n}){return e.jsxs("header",{className:C("flex min-h-pane-header w-full shrink-0 items-center gap-2 border-b border-line bg-canvas px-row-inset py-1",n),children:[s&&e.jsx("div",{className:"flex shrink-0 items-center gap-1",children:s}),e.jsx("div",{className:"flex min-w-0 flex-1 justify-start",children:e.jsx("div",{className:"w-full max-w-xs transition-[max-width] duration-150 ease-out focus-within:max-w-lg",children:t})}),a&&e.jsx("div",{className:"flex shrink-0 items-center gap-1",children:a})]})}function it({onCompose:s}){return e.jsx("button",{type:"button",onClick:s,"aria-label":"Compose new message",className:"lg:hidden fixed right-4 z-30 h-14 w-14 rounded-full bg-accent text-accent-fg shadow-lg flex items-center justify-center hover:opacity-90 active:scale-95 transition-all",style:{bottom:"calc(var(--app-tab-bar, 0px) + env(safe-area-inset-bottom, 0px) + 1rem)"},children:e.jsx(Ms,{className:"size-6"})})}const lt=({isOpen:s,onClose:t})=>{const a=f.useRef(null);return Ee({id:"shortcuts",open:s,answers:{back:t}}),Le(a,s),s?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx(Ae,{label:"Dismiss keyboard shortcuts",onDismiss:t,className:"backdrop-blur-sm"}),e.jsxs("div",{ref:a,role:"dialog","aria-modal":"true","aria-label":"Keyboard shortcuts",tabIndex:-1,className:C("relative z-10 max-h-[85vh] w-full max-w-2xl overflow-y-auto","rounded-lg border border-line bg-surface shadow-lg","p-6"),children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Keyboard shortcuts"}),e.jsx("button",{type:"button",onClick:t,className:"p-1 text-fg-muted transition-colors hover:text-fg","aria-label":"Close",children:e.jsx(Fe,{className:"size-5"})})]}),e.jsx("div",{className:"grid gap-x-8 gap-y-6 sm:grid-cols-2",children:ms.map(n=>e.jsxs("div",{children:[e.jsx("h3",{className:"mb-3 text-sm font-medium text-fg-muted",children:n.title}),e.jsx("div",{className:"space-y-2",children:n.hints.map(o=>e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{className:"text-sm",children:o.description}),e.jsx("span",{className:"flex shrink-0 items-center gap-1",children:o.keys.map((r,i)=>e.jsxs(f.Fragment,{children:[i>0&&o.keys[0]==="g"&&e.jsx("span",{className:"text-2xs text-fg-subtle",children:"then"}),e.jsx(V,{children:r})]},r))})]},`${o.action}-${o.keys.join("+")}`))})]},n.title))}),e.jsx("div",{className:"mt-6 border-t border-line pt-4",children:e.jsxs("p",{className:"text-center text-xs text-fg-muted",children:["Press ",e.jsx(V,{children:"Esc"})," to close"]})})]})]}):null},ct="button:not([disabled]), a[href]",E="outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-surface-sunken";function ut({active:s,dimmed:t,indent:a}){return C("flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-sm transition-colors",E,a&&"pl-7",s?"bg-accent-2-soft font-medium text-accent-2":"text-fg-muted hover:bg-surface hover:text-fg",t&&"opacity-55")}function dt({icon:s,label:t,count:a,active:n,failure:o}){return e.jsxs(e.Fragment,{children:[s&&e.jsx("span",{className:C("shrink-0",n?"text-accent-2":"text-fg-subtle"),children:s}),e.jsx("span",{className:"flex-1 truncate",children:t}),o&&e.jsx(re,{className:"size-3.5 shrink-0 text-danger","aria-hidden":"true"}),a!=null&&a>0&&e.jsx("span",{className:C("text-2xs tabular-nums",n?"text-accent-2":"text-fg-subtle"),children:a})]})}function I({icon:s,label:t,count:a,active:n,dimmed:o,indent:r,navId:i,linkComponent:u,ariaLabel:m,title:d,failure:h,onClick:y}){const g=ut({active:n,dimmed:o,indent:r}),c=e.jsx(dt,{icon:s,label:t,count:a,active:n,failure:h}),v=m??t,x=h?`${v} — ${h}`:v,p=h?`${d??t} — ${h}`:d;return i&&u?u({navId:i,className:g,ariaLabel:x,title:p,onClick:y,children:c}):e.jsx("button",{type:"button",onClick:y,className:g,"aria-label":h?x:m,title:p,children:c})}const U={inbox:0,flagged:1,drafts:2,sent:3,archive:4,all:5,junk:6,trash:7};function mt(s){switch(s){case"inbox":return e.jsx(qe,{className:"size-4"});case"flagged":return e.jsx(oe,{className:"size-4"});case"drafts":return e.jsx(Qe,{className:"size-4"});case"sent":return e.jsx(ie,{className:"size-4"});case"archive":return e.jsx(Ke,{className:"size-4"});case"all":return e.jsx(Be,{className:"size-4"});case"junk":return e.jsx(_e,{className:"size-4"});case"trash":return e.jsx(De,{className:"size-4"})}}const W=s=>s.role!=null,T=8,G="remit.nav.folders.open.",Y="remit.nav.account.open.";function J(s,t,a){if(typeof localStorage>"u")return a;const n=localStorage.getItem(s+t);return n===null?a:n!=="0"}function X(s,t,a){typeof localStorage>"u"||localStorage.setItem(s+t,a?"1":"0")}function xt({account:s,selectedNavId:t,onSelectNav:a,linkComponent:n}){const[o,r]=f.useState(()=>J(Y,s.id,!0)),[i,u]=f.useState(()=>J(G,s.id,!0)),[m,d]=f.useState(!1),h=()=>{r(l=>{const j=!l;return X(Y,s.id,j),j})},y=()=>{u(l=>{const j=!l;return X(G,s.id,j),j})},g=s.mailboxes.filter(W).sort((l,j)=>U[l.role]-U[j.role]),c=s.mailboxes.filter(l=>!W(l)),v=m||c.length<=T?c:c.slice(0,T),x=c.length-v.length,p=s.status??"ready",b=s.syncedServices!==void 0&&!s.syncedServices.includes("Mail"),N=p==="ready"&&g.length===0&&c.length===0;return e.jsxs("div",{className:"mt-3",children:[e.jsxs("button",{type:"button",onClick:h,"aria-expanded":o,className:C("flex w-full items-center gap-1.5 px-2 pb-1 text-left transition-colors hover:text-fg",E,s.muted&&"opacity-55"),children:[o?e.jsx(q,{className:"size-3 shrink-0 text-fg-subtle"}):e.jsx(H,{className:"size-3 shrink-0 text-fg-subtle"}),e.jsx("span",{className:"truncate text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:s.label}),s.muted&&e.jsxs(e.Fragment,{children:[e.jsx(xs,{className:"size-3 shrink-0 text-fg-subtle"}),e.jsx("span",{className:"text-2xs text-fg-subtle",children:"muted"})]}),b&&e.jsxs(e.Fragment,{children:[e.jsx(Ys,{className:"size-3 shrink-0 text-fg-subtle"}),e.jsx("span",{className:"text-2xs text-fg-subtle",children:Js.Mail})]})]}),o&&e.jsxs(e.Fragment,{children:[p==="loading"&&e.jsx("div",{className:"px-2 py-1 text-sm text-fg-muted",children:"Loading…"}),p==="error"&&e.jsxs("div",{role:"alert",className:"mx-2 my-1 flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-2 py-1.5 text-sm",children:[e.jsx(re,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":"true"}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("p",{className:"font-medium text-danger",children:"Couldn't load mailboxes"})}),s.onRetry&&e.jsx("button",{type:"button",onClick:s.onRetry,className:"shrink-0 text-sm font-medium text-accent hover:underline",children:"Retry"})]}),N&&e.jsx("div",{className:"px-2 py-1 text-sm text-fg-muted",children:"No mailboxes"}),p==="ready"&&e.jsxs(e.Fragment,{children:[g.map(l=>e.jsx(I,{navId:l.id,linkComponent:n,icon:mt(l.role),label:l.name,ariaLabel:l.name,title:l.fullPath??l.name,failure:l.failure,count:l.unseen,active:t===l.id,dimmed:s.muted,onClick:()=>a?.(l.id)},l.id)),s.outboxPending!==void 0&&e.jsx(I,{navId:"outbox",linkComponent:n,icon:e.jsx(ie,{className:"size-4"}),label:"Outbox",ariaLabel:"Outbox",count:s.outboxPending>0?s.outboxPending:void 0,active:t==="outbox",dimmed:s.muted,onClick:()=>a?.("outbox")}),c.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:y,"aria-expanded":i,className:C("mt-1 flex w-full items-center gap-1 px-2 py-1 text-left text-2xs font-semibold uppercase tracking-wider text-fg-subtle transition-colors hover:text-fg",E),children:[i?e.jsx(q,{className:"size-3 shrink-0"}):e.jsx(H,{className:"size-3 shrink-0"}),e.jsx("span",{className:"flex-1",children:"Folders"}),e.jsx("span",{className:"tabular-nums opacity-70",children:c.length})]}),i&&e.jsxs(e.Fragment,{children:[v.map(l=>e.jsx(I,{navId:l.id,linkComponent:n,icon:e.jsx(ze,{className:"size-4"}),label:l.name,ariaLabel:l.name,title:l.fullPath??l.name,failure:l.failure,count:l.unseen,active:t===l.id,dimmed:s.muted,onClick:()=>a?.(l.id)},l.id)),(x>0||m)&&c.length>T&&e.jsx("button",{type:"button",onClick:()=>d(l=>!l),className:C("ml-7 flex items-center px-2 py-1 text-2xs font-medium text-accent transition-colors hover:underline",E),children:m?"Show less":`Show all (${c.length})`})]})]})]})]})]})}function ft({accounts:s,selectedNavId:t,briefUnseen:a,onSelectNav:n,variant:o="desktop",linkComponent:r,calendarNav:i="hidden"}){const u=f.useRef(null);Gs({containerRef:u,itemSelector:ct});const m=o==="drawer",d=e.jsxs("nav",{ref:m?u:void 0,className:m?"px-2 py-2":"flex-1 overflow-y-auto px-2 py-2","aria-label":"Mailboxes",children:[e.jsx(I,{navId:"brief",linkComponent:r,icon:e.jsx(Xs,{className:"size-4"}),label:"Daily brief",ariaLabel:"Daily brief",count:a,active:t==="brief",onClick:()=>n?.("brief")}),i==="shown"&&e.jsx(I,{navId:"calendar",linkComponent:r,icon:e.jsx(Te,{className:"size-4"}),label:"Calendar",ariaLabel:"Calendar",active:t==="calendar",onClick:()=>n?.("calendar")}),e.jsx(I,{navId:"flagged",linkComponent:r,icon:e.jsx(oe,{className:"size-4"}),label:"Starred",ariaLabel:"Starred",active:t==="flagged",onClick:()=>n?.("flagged")}),s.length===0?e.jsx("div",{className:"px-2 py-4 text-center text-sm text-fg-muted",children:"No accounts configured"}):s.map(h=>e.jsx(xt,{account:h,selectedNavId:t,onSelectNav:n,linkComponent:r},h.id))]});return m?d:e.jsx("aside",{ref:u,className:"flex h-full w-full flex-col bg-surface-sunken",children:d})}function pt(){const s=le();if(!s)return null;const t=s.showNavPane?!s.navCollapsed:!1;return e.jsx(P,{variant:"ghost",size:"sm",icon:e.jsx(Ks,{className:"size-4"}),onClick:s.toggleNav,"aria-label":t?"Hide folders":"Show folders","aria-expanded":t,title:"Folders",className:"shrink-0"})}const ht={global:"Search all mail",pending:"Search mail",scoped:"Search this folder"};function gt({search:s,onCompose:t,onReportBug:a,onOpenSettings:n,settingsAttention:o,composeShortcut:r,refreshControl:i,account:u}){return e.jsx(rt,{leading:e.jsx(pt,{}),search:e.jsx(fs,{value:s.value,onChange:s.onChange,onClear:s.onClear,onClearQuery:s.onClearQuery,chips:s.chips,onRemoveChip:s.onRemoveChip,placeholder:ht[s.scope]}),actions:e.jsxs(e.Fragment,{children:[e.jsx(P,{variant:"ghost",size:"sm",icon:e.jsx(nt,{className:"size-4"}),title:r?`Compose (${r})`:"Compose","aria-label":"Compose",onClick:t}),e.jsx(P,{variant:"ghost",size:"sm",icon:e.jsx(pe,{className:"size-4"}),title:"Report a bug","aria-label":"Report a bug",onClick:a}),e.jsx(P,{variant:"ghost",size:"sm",icon:e.jsx(ce,{label:o,children:e.jsx(ve,{className:"size-4"})}),title:"Settings","aria-label":o?`Settings — ${o}`:"Settings",onClick:n}),i,u]})})}function bt(){const{pathname:s}=js(),t=He({from:"/mail/$mailboxId",shouldThrow:!1});return O(s,"/settings")?"settings":O(s,"/calendar")?"calendar":O(s,"/mail/outbox")?"outbox":O(s,"/mail/flagged")?"flagged":O(s,"/mail/brief")?"brief":t?.mailboxId??""}function vt(){const s=Ve(),t=D({select:d=>$(d.location.pathname)}),a=D({select:d=>Ns(d.location.search)}),[n,o]=f.useState(a),r=at(n,200),[i,u]=f.useState(t);if(i!==t){const d=Es(i,t,a);u(t),d!==void 0&&o(d)}const m=f.useCallback(d=>{u($(s.state.location.pathname)),o(d)},[s]);return{searchInput:n,committedQuery:Ps(n,r),viewKey:t,setSearchInput:m}}const yt=()=>{const s=Q();return Ss()?null:e.jsx(it,{onCompose:s})},ye=({children:s})=>{const{Account:t}=$e();return e.jsx(t,{children:s})},jt=()=>e.jsx(ye,{children:({email:s,signOut:t})=>e.jsx(ot,{email:s,onSignOut:t})});function Nt({accounts:s}){const{searchInput:t,onSearchChange:a,onSearchClear:n,onSearchClearQuery:o,resultFolderIndex:r}=ue(),i=K(),u=Ws(),m=Q(),{scope:d,clearScope:h}=ps(s),y=de(),g=d.kind==="scoped"?[{id:d.chip.id,label:d.chip.label,tone:"scope"}]:void 0,c=f.useMemo(()=>s.map(N=>N.accountId),[s]),{hasNewMail:v}=As(),{state:x,errorMessage:p,refresh:b}=Fs(c,{onSettled:()=>Ue(i,We(r.keys()))});return e.jsx(gt,{search:{value:t,scope:d.kind,chips:g,onChange:a,onClear:n,onClearQuery:o,onRemoveChip:h},onCompose:m,onReportBug:me,onOpenSettings:()=>u("accounts"),settingsAttention:y,composeShortcut:hs("compose"),refreshControl:e.jsx(Ts,{state:x,onRefresh:b,label:"Refresh all accounts",errorMessage:p,hasUpdate:v(c)}),account:e.jsx(jt,{})})}function St(){return e.jsxs("button",{type:"button",onClick:me,className:"flex w-full items-center gap-2 rounded-md px-2 py-1 text-sm text-fg-muted transition-colors hover:bg-surface hover:text-fg",children:[e.jsx(pe,{className:"size-4 shrink-0"}),e.jsx("span",{className:"flex-1 truncate text-left",children:"Report a bug"})]})}const Z=s=>/^\d/.test(s),Ct=(s,t)=>{const a=Z(s),n=Z(t);return a&&!n?-1:!a&&n?1:s.localeCompare(t,void 0,{sensitivity:"base",numeric:!0})};function wt(s,t,a){const n=[],o=[];for(const r of s)t.has(r.mailboxId)?n.push(r):o.push(r);return o.sort((r,i)=>Ct(z(r,void 0,a),z(i,void 0,a))),{system:n,labels:o}}function It(s,t,a){const n=Xe(t)&&s.unseenCount>0;return{id:s.mailboxId,name:z(s,t,a),unseen:n?s.unseenCount:void 0,role:t,fullPath:s.fullPath,failure:Zs(s)}}function ee({accounts:s,onMailboxSelect:t,variant:a="desktop"}){const n=K(),o=bt(),{onSearchChange:r}=ue(),{t:i}=Ge("mail",{useSuspense:!1}),u=f.useCallback((x,p)=>i(x,{defaultValue:p}),[i]),m=he({queries:s.map(x=>({...xe({path:{accountId:x.accountId}}),staleTime:1/0}))}),{data:d}=fe(Ye()),h=f.useMemo(()=>(d?.items??[]).filter(x=>et(x.status)).length,[d?.items]),y=f.useMemo(()=>s.map((x,p)=>{const b=m[p],N=b?.data?.items??[],l=Je(x.folderAppointments),{system:j,labels:L}=wt(N,l,u),A=b?.isError?"error":b?.isLoading?"loading":"ready";return{id:x.accountId,label:x.email,email:x.email,muted:!!x.muted,outboxPending:h,status:A,onRetry:()=>b?.refetch(),mailboxes:[...j,...L].map(k=>It(k,l.get(k.mailboxId),u))}}),[s,m,h,u]),g=x=>{n.invalidateQueries({queryKey:Ze({path:{mailboxId:x},query:{order:"desc"}})})},c=({navId:x,className:p,ariaLabel:b,title:N,children:l,onClick:j})=>x==="brief"?e.jsx(w,{to:"/mail/brief",search:{q:void 0},activeOptions:{includeSearch:!1},onClick:()=>j?.(),className:p,"aria-label":b,title:N,children:l}):x==="calendar"?e.jsx(w,{to:"/calendar",onClick:()=>j?.(),className:p,"aria-label":b,title:N,children:l}):x==="outbox"?e.jsx(w,{to:"/mail/outbox",search:{q:void 0},onClick:()=>j?.(),className:p,"aria-label":b,title:N,children:l}):x==="flagged"?e.jsx(w,{to:"/mail/flagged",search:{q:void 0},onClick:()=>j?.(),className:p,"aria-label":b,title:N,children:l}):x==="settings"?e.jsx(w,{to:"/settings/accounts",onClick:()=>j?.(),className:p,"aria-label":b,title:N,children:l}):e.jsx(w,{to:"/mail/$mailboxId",params:{mailboxId:x},search:{q:void 0},onClick:()=>{g(x),j?.()},className:p,"aria-label":b,title:N,children:l}),v=()=>{r(""),t?.()};return e.jsx(ft,{accounts:y,selectedNavId:o,onSelectNav:v,linkComponent:c,variant:a})}function Ot({accounts:s,onMailboxSelect:t}){const n=le()?.showNavPane??!0,o=de();return n?e.jsx(ee,{accounts:s}):e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsx(ee,{accounts:s,onMailboxSelect:t,variant:"drawer"})}),e.jsxs("div",{className:"border-t border-line px-2 py-2",children:[e.jsxs(w,{to:"/settings/accounts",onClick:t,children:[e.jsx(ce,{label:o,children:e.jsx(ve,{className:"size-4 shrink-0"})}),e.jsx("span",{className:"flex-1 truncate text-left",children:"Settings"})]}),e.jsx(St,{}),e.jsx(ye,{children:({signOut:r})=>e.jsxs("button",{type:"button",onClick:()=>{t?.(),r()},className:"flex min-h-11 w-full items-center gap-2 rounded-md px-2 py-1 text-sm text-fg-muted transition-colors hover:bg-surface hover:text-fg","data-testid":"sign-out-button",children:[e.jsx(be,{className:"size-4 shrink-0"}),e.jsx("span",{className:"flex-1 truncate text-left",children:"Sign out"})]})})]})]})}function kt(s){const t=he({queries:s.map(a=>({...xe({path:{accountId:a.accountId}}),staleTime:1/0}))});return f.useMemo(()=>gs(t.map(a=>a.data?.items??[])),[t])}const je="remit:intelligence-open";function Mt(){try{return localStorage.getItem(je)!=="closed"}catch{return!0}}function Rt(s){try{localStorage.setItem(je,s?"open":"closed")}catch{}}function se({panels:s,prefersOpen:t,isDesktop:a,hasThread:n,raisedFor:o,openMessage:r}){if(o!==null&&o===r)return!0;const i=s.filter(u=>u!=="sidebar");return i.length>0?i.includes("intelligence"):a&&n&&t}const Pt=()=>{const s=ge(),t=Cs(),a=ws(),n=t.find(Is),o=bs(),[r,i]=f.useState(Mt),u=o?`${o.threadId}/${o.messageId??""}`:null,[m,d]=f.useState(null),h={panels:t,prefersOpen:r,isDesktop:s==="desktop",hasThread:o!==void 0,openMessage:u},y=se({...h,raisedFor:m}),g=se({...h,raisedFor:null}),c=f.useCallback((b,N)=>{a([...b?["intelligence"]:[],...N?[N]:[]])},[a]),v=f.useCallback(b=>{c(g,b)},[g,c]),x=f.useCallback(()=>{if(y&&!g){d(null);return}const b=!y;Rt(b),i(b),d(null),c(b,n)},[g,y,n,c]),p=f.useCallback(()=>{d(u)},[u]);return{openOverlay:n,intelligenceOpen:y,showOverlay:v,toggleIntelligence:x,raiseIntelligence:p}};var M={exports:{}},te;function Et(){if(te)return M.exports;te=1;const s=(t,a,n)=>new Promise((o,r)=>{if(n=Object.assign({concurrency:1/0},n),typeof a!="function")throw new TypeError("Mapper function is required");const{concurrency:i}=n;if(!(typeof i=="number"&&i>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${i}\` (${typeof i})`);const u=[],m=t[Symbol.iterator]();let d=!1,h=!1,y=0,g=0;const c=()=>{if(d)return;const v=m.next(),x=g;if(g++,v.done){h=!0,y===0&&o(u);return}y++,Promise.resolve(v.value).then(p=>a(p,x)).then(p=>{u[x]=p,y--,c()},p=>{d=!0,r(p)})};for(let v=0;v<i&&(c(),!h);v++);});return M.exports=s,M.exports.default=s,M.exports}var Lt=Et();const At=es(Lt),Ft=900*1e3,Tt=30,zt=(s,t)=>{if(!s)return t;const a=Number.parseInt(s,10);return Number.isFinite(a)&&a>0?a:t},Dt=30*1e3,_t=s=>Math.max(zt(s,Tt)*1e3,Dt),Ne=_t(rs().mailboxPollIntervalSeconds),R=(s=Date.now(),t=Ne)=>Ds(s)?Math.min(_s,t):t,Bt=5,_=new Set,Kt=(s,t,a=Ft)=>s.filter(n=>{const o=n.lastSyncAt;return o==null?!0:t-o>a}).map(n=>n.accountId),Qt=(s,t,a=Ne)=>s-t>=a,qt=(s,t)=>s.filter(a=>!t.has(a)),ae=(s,t)=>{if(_.delete(s),as(t)||ns(t,{softError:!0})){os(t,{softError:!0});return}console.warn("[remit] background mailbox sync failed",{accountId:s,error:t})},ne=(s,t)=>ss({path:{accountId:s},throwOnError:!0}).then(()=>{t.invalidateQueries({queryKey:ts({path:{accountId:s}})})}),Ht=s=>{const t=K(),a=f.useRef(s);a.current=s;const n=s.map(o=>o.accountId).join(",");f.useEffect(()=>{const o=Date.now(),i=Kt(a.current,o).filter(u=>!_.has(u));if(i.length!==0)for(const u of i)_.add(u),ne(u,t).catch(m=>{ae(u,m)})},[n,t]),f.useEffect(()=>{let o=Date.now(),r;const i=new Set,u=()=>{o=Date.now();const g=qt(a.current.map(c=>c.accountId),i);for(const c of g)i.add(c);At(g,c=>ne(c,t).catch(v=>{ae(c,v)}).finally(()=>{i.delete(c)}),{concurrency:Bt})},m=()=>{if(document.visibilityState==="visible"){u(),r=setTimeout(m,R());return}},d=()=>{if(document.visibilityState!=="visible")return;r!==void 0&&clearTimeout(r);const g=Date.now(),c=R(g);if(Qt(g,o,c)){u(),r=setTimeout(m,c);return}r=setTimeout(m,o+c-g)},h=()=>{document.visibilityState==="visible"&&(r!==void 0&&clearTimeout(r),o=Date.now(),r=setTimeout(m,R()))};r=setTimeout(m,R()),document.addEventListener("visibilitychange",d);const y=zs(h);return()=>{r!==void 0&&clearTimeout(r),document.removeEventListener("visibilitychange",d),y()}},[n,t])};function Sa(){const s=is(),t=ge(),a=tt(t),{openOverlay:n,intelligenceOpen:o,showOverlay:r,toggleIntelligence:i,raiseIntelligence:u}=Pt(),m=n==="shortcuts",d=n==="nav",{searchInput:h,committedQuery:y,viewKey:g,setSearchInput:c}=vt(),{data:v,isLoading:x,isError:p,error:b,refetch:N}=fe({...ls(),staleTime:1/0}),l=!!(v&&(v.accounts?.length??0)===0);f.useEffect(()=>{l&&s({to:"/onboarding",replace:!0})},[l,s]),st({enabled:!m,bindings:[{key:"?",action:"help",handler:()=>r("shortcuts"),noModifiers:!1,preventDefault:!0}]});const j=Q(),L=Rs(),A=D({select:F=>Os(F.matches)?.list==="mailbox"}),k=f.useMemo(()=>({compose:j}),[j]);vs({enabled:!A&&!L,handlers:k});const Se=f.useCallback(()=>{c("")},[c]),Ce=f.useCallback(()=>{c("")},[c]),S=v?.accounts??[],we=f.useMemo(()=>S.map(F=>F.accountId),[S]),Ie=kt(S),Oe=Qs(S).index,ke=f.useMemo(()=>ys(S),[S]);Ht(S);const Me=f.useCallback(()=>{n==="nav"&&r(void 0)},[n,r]),Re={accounts:S,mailboxNameIndex:Ie,accountNameIndex:ke,resultFolderIndex:Oe,searchQuery:y,searchInput:h,searchViewKey:g,onSearchChange:c,onSearchClear:Se,onSearchClearQuery:Ce,intelligenceOpen:o,onToggleIntelligence:i,onRaiseIntelligence:u},Pe={isSinglePane:a,isLoading:x||l,intelligenceOpen:o,nav:e.jsx(Ot,{accounts:S,onMailboxSelect:Me}),topBar:a?void 0:e.jsx(Nt,{accounts:S}),overlay:a?e.jsx(yt,{}):void 0,navOpen:d,onOpenNav:()=>r("nav"),onCloseNav:()=>r(void 0)};return e.jsx(cs.Provider,{value:Re,children:e.jsxs(Bs,{accountIds:we,children:[e.jsx(ks,{children:p?e.jsx("div",{className:"flex h-full items-center justify-center bg-canvas p-4",children:e.jsx(ds,{title:"Couldn't load your account",error:b,onRetry:()=>{N()}})}):e.jsx(Ls,{chrome:Pe,children:e.jsx(us,{})})}),e.jsx(lt,{isOpen:m,onClose:()=>r(void 0)})]})})}export{Sa as component,ue as useMailContext};
1
+ import{b as B,r as f,j as e,o as C,p as Ee,q as Le,D as Ae,X as Fe,C as Te,S as oe,t as q,v as H,w as re,x as ie,F as ze,T as De,y as _e,M as Be,z as Ke,E as Qe,I as qe,G as le,d as P,H as ce,J as He,K as Ve,N as $e,P as ue,f as K,Q as de,R as me,U as Ue,V as We,W as Ge,Y as xe,a as fe,Z as Ye,_ as Je,$ as z,a0 as Xe,a1 as Ze,a2 as es,a3 as ss,a4 as ts,a5 as as,a6 as ns,a7 as os,a8 as rs,u as is,c as ls,a9 as cs,O as us}from"./index-CL_fwLHN.js";import{E as ds}from"./ErrorState-KjDYblD5.js";import{K as ms,B as xs,S as fs,u as ps,s as hs,b as gs,a as bs,c as vs,d as ys}from"./search-token-index-B1HU1d2-.js";import{K as V}from"./kbd-CDJCJUnp.js";import{u as js,l as O,a as D,m as $,b as Ns,c as Ss,N as w,d as Cs,e as ws,i as Is,f as Os}from"./reply-DvdgFS16.js";import{A as ks}from"./AppFrame-DSPG81Mk.js";import{P as Ms}from"./pencil-LSmMSKiW.js";import{u as Q,a as Rs}from"./useMessageBodyContent-D-LJBFh4.js";import{c as Ps,s as Es,M as Ls}from"./MailShell-LIuV2C3h.js";import{u as As,a as Fs,R as Ts,s as zs,i as Ds,H as _s,M as Bs}from"./useRefreshControl-B6YIG0w2.js";import{M as Ks}from"./menu-CcLh9Whg.js";import{B as pe,u as Qs}from"./useResultFolderIndex-6TeGdWgp.js";import{A as qs}from"./avatar-uWJajuSb.js";import{u as Hs,P as Vs,a as $s,b as Us}from"./popover-menu-fjlAfNO1.js";import{u as Ws}from"./sections-Rf3k05-_.js";import{u as Gs}from"./roving-focus-FWOr5tBU.js";import{C as Ys,A as Js}from"./account-service-status-oYDwuPLn.js";import{S as Xs}from"./sparkles-Bcn4ZRhZ.js";import{u as he}from"./useQueries-hChzM5ru.js";import{f as Zs}from"./folder-failure-CqkVSsrb.js";import{i as et}from"./outbox-status-BlKn6P0x.js";import{u as st}from"./index-DZb7rV9A.js";import{u as ge,i as tt}from"./useLayoutTier-DrLg7_rq.js";import{u as at}from"./useDebouncedValue-BTZsNKEh.js";import"./search-scope-UI1H6AzA.js";import"./useMediaQuery-DiQ0fGER.js";import"./FullCompose-Djp_h4BT.js";import"./confirm-dialog-q8tbS_22.js";import"./circle-check-big-BsCwNdJZ.js";import"./refresh-cw-5OKnYRBy.js";import"./useSignature-BkzkUbjz.js";import"./account-form-helpers-DhckT_PN.js";const be=B("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);const ve=B("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const nt=B("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]);function ot({email:s,onSignOut:t}){const a=f.useRef(null),{open:n,setOpen:o,containerRef:r,panelRef:i,getAnchor:u}=Hs("account-menu",()=>a.current?.focus());f.useEffect(()=>{if(!n)return;const d=requestAnimationFrame(()=>i.current?.querySelector('[role="menuitem"]')?.focus());return()=>cancelAnimationFrame(d)},[n,i]);const m=s??"Account";return e.jsxs("div",{ref:r,className:"relative",children:[e.jsx("button",{ref:a,type:"button","aria-label":"Account","aria-haspopup":"menu","aria-expanded":n,onClick:()=>o(d=>!d),className:"inline-flex min-h-11 min-w-11 items-center justify-center rounded-md p-1.5 text-fg-muted transition-colors hover:bg-surface-raised hover:text-fg",children:e.jsx(qs,{name:m,email:s??void 0,size:"sm"})}),e.jsx(Vs,{open:n,align:"end",panelRef:i,getAnchor:u,children:e.jsxs($s,{ref:i,label:m,children:[s&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"truncate px-4 py-2 text-xs text-fg-muted",title:s,"data-testid":"account-menu-email",children:s}),e.jsx("hr",{className:"my-1 h-px border-0 bg-line"})]}),e.jsx(Us,{label:"Sign out",icon:e.jsx(be,{className:"size-4"}),onSelect:()=>{o(!1),a.current?.focus(),t()}})]})})]})}function rt({leading:s,search:t,actions:a,className:n}){return e.jsxs("header",{className:C("flex min-h-pane-header w-full shrink-0 items-center gap-2 border-b border-line bg-canvas px-row-inset py-1",n),children:[s&&e.jsx("div",{className:"flex shrink-0 items-center gap-1",children:s}),e.jsx("div",{className:"flex min-w-0 flex-1 justify-start",children:e.jsx("div",{className:"w-full max-w-xs transition-[max-width] duration-150 ease-out focus-within:max-w-lg",children:t})}),a&&e.jsx("div",{className:"flex shrink-0 items-center gap-1",children:a})]})}function it({onCompose:s}){return e.jsx("button",{type:"button",onClick:s,"aria-label":"Compose new message",className:"lg:hidden fixed right-4 z-30 h-14 w-14 rounded-full bg-accent text-accent-fg shadow-lg flex items-center justify-center hover:opacity-90 active:scale-95 transition-all",style:{bottom:"calc(var(--app-tab-bar, 0px) + env(safe-area-inset-bottom, 0px) + 1rem)"},children:e.jsx(Ms,{className:"size-6"})})}const lt=({isOpen:s,onClose:t})=>{const a=f.useRef(null);return Ee({id:"shortcuts",open:s,answers:{back:t}}),Le(a,s),s?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx(Ae,{label:"Dismiss keyboard shortcuts",onDismiss:t,className:"backdrop-blur-sm"}),e.jsxs("div",{ref:a,role:"dialog","aria-modal":"true","aria-label":"Keyboard shortcuts",tabIndex:-1,className:C("relative z-10 max-h-[85vh] w-full max-w-2xl overflow-y-auto","rounded-lg border border-line bg-surface shadow-lg","p-6"),children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Keyboard shortcuts"}),e.jsx("button",{type:"button",onClick:t,className:"p-1 text-fg-muted transition-colors hover:text-fg","aria-label":"Close",children:e.jsx(Fe,{className:"size-5"})})]}),e.jsx("div",{className:"grid gap-x-8 gap-y-6 sm:grid-cols-2",children:ms.map(n=>e.jsxs("div",{children:[e.jsx("h3",{className:"mb-3 text-sm font-medium text-fg-muted",children:n.title}),e.jsx("div",{className:"space-y-2",children:n.hints.map(o=>e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{className:"text-sm",children:o.description}),e.jsx("span",{className:"flex shrink-0 items-center gap-1",children:o.keys.map((r,i)=>e.jsxs(f.Fragment,{children:[i>0&&o.keys[0]==="g"&&e.jsx("span",{className:"text-2xs text-fg-subtle",children:"then"}),e.jsx(V,{children:r})]},r))})]},`${o.action}-${o.keys.join("+")}`))})]},n.title))}),e.jsx("div",{className:"mt-6 border-t border-line pt-4",children:e.jsxs("p",{className:"text-center text-xs text-fg-muted",children:["Press ",e.jsx(V,{children:"Esc"})," to close"]})})]})]}):null},ct="button:not([disabled]), a[href]",E="outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-surface-sunken";function ut({active:s,dimmed:t,indent:a}){return C("flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-sm transition-colors",E,a&&"pl-7",s?"bg-accent-2-soft font-medium text-accent-2":"text-fg-muted hover:bg-surface hover:text-fg",t&&"opacity-55")}function dt({icon:s,label:t,count:a,active:n,failure:o}){return e.jsxs(e.Fragment,{children:[s&&e.jsx("span",{className:C("shrink-0",n?"text-accent-2":"text-fg-subtle"),children:s}),e.jsx("span",{className:"flex-1 truncate",children:t}),o&&e.jsx(re,{className:"size-3.5 shrink-0 text-danger","aria-hidden":"true"}),a!=null&&a>0&&e.jsx("span",{className:C("text-2xs tabular-nums",n?"text-accent-2":"text-fg-subtle"),children:a})]})}function I({icon:s,label:t,count:a,active:n,dimmed:o,indent:r,navId:i,linkComponent:u,ariaLabel:m,title:d,failure:h,onClick:y}){const g=ut({active:n,dimmed:o,indent:r}),c=e.jsx(dt,{icon:s,label:t,count:a,active:n,failure:h}),v=m??t,x=h?`${v} — ${h}`:v,p=h?`${d??t} — ${h}`:d;return i&&u?u({navId:i,className:g,ariaLabel:x,title:p,onClick:y,children:c}):e.jsx("button",{type:"button",onClick:y,className:g,"aria-label":h?x:m,title:p,children:c})}const U={inbox:0,flagged:1,drafts:2,sent:3,archive:4,all:5,junk:6,trash:7};function mt(s){switch(s){case"inbox":return e.jsx(qe,{className:"size-4"});case"flagged":return e.jsx(oe,{className:"size-4"});case"drafts":return e.jsx(Qe,{className:"size-4"});case"sent":return e.jsx(ie,{className:"size-4"});case"archive":return e.jsx(Ke,{className:"size-4"});case"all":return e.jsx(Be,{className:"size-4"});case"junk":return e.jsx(_e,{className:"size-4"});case"trash":return e.jsx(De,{className:"size-4"})}}const W=s=>s.role!=null,T=8,G="remit.nav.folders.open.",Y="remit.nav.account.open.";function J(s,t,a){if(typeof localStorage>"u")return a;const n=localStorage.getItem(s+t);return n===null?a:n!=="0"}function X(s,t,a){typeof localStorage>"u"||localStorage.setItem(s+t,a?"1":"0")}function xt({account:s,selectedNavId:t,onSelectNav:a,linkComponent:n}){const[o,r]=f.useState(()=>J(Y,s.id,!0)),[i,u]=f.useState(()=>J(G,s.id,!0)),[m,d]=f.useState(!1),h=()=>{r(l=>{const j=!l;return X(Y,s.id,j),j})},y=()=>{u(l=>{const j=!l;return X(G,s.id,j),j})},g=s.mailboxes.filter(W).sort((l,j)=>U[l.role]-U[j.role]),c=s.mailboxes.filter(l=>!W(l)),v=m||c.length<=T?c:c.slice(0,T),x=c.length-v.length,p=s.status??"ready",b=s.syncedServices!==void 0&&!s.syncedServices.includes("Mail"),N=p==="ready"&&g.length===0&&c.length===0;return e.jsxs("div",{className:"mt-3",children:[e.jsxs("button",{type:"button",onClick:h,"aria-expanded":o,className:C("flex w-full items-center gap-1.5 px-2 pb-1 text-left transition-colors hover:text-fg",E,s.muted&&"opacity-55"),children:[o?e.jsx(q,{className:"size-3 shrink-0 text-fg-subtle"}):e.jsx(H,{className:"size-3 shrink-0 text-fg-subtle"}),e.jsx("span",{className:"truncate text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:s.label}),s.muted&&e.jsxs(e.Fragment,{children:[e.jsx(xs,{className:"size-3 shrink-0 text-fg-subtle"}),e.jsx("span",{className:"text-2xs text-fg-subtle",children:"muted"})]}),b&&e.jsxs(e.Fragment,{children:[e.jsx(Ys,{className:"size-3 shrink-0 text-fg-subtle"}),e.jsx("span",{className:"text-2xs text-fg-subtle",children:Js.Mail})]})]}),o&&e.jsxs(e.Fragment,{children:[p==="loading"&&e.jsx("div",{className:"px-2 py-1 text-sm text-fg-muted",children:"Loading…"}),p==="error"&&e.jsxs("div",{role:"alert",className:"mx-2 my-1 flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-2 py-1.5 text-sm",children:[e.jsx(re,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":"true"}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("p",{className:"font-medium text-danger",children:"Couldn't load mailboxes"})}),s.onRetry&&e.jsx("button",{type:"button",onClick:s.onRetry,className:"shrink-0 text-sm font-medium text-accent hover:underline",children:"Retry"})]}),N&&e.jsx("div",{className:"px-2 py-1 text-sm text-fg-muted",children:"No mailboxes"}),p==="ready"&&e.jsxs(e.Fragment,{children:[g.map(l=>e.jsx(I,{navId:l.id,linkComponent:n,icon:mt(l.role),label:l.name,ariaLabel:l.name,title:l.fullPath??l.name,failure:l.failure,count:l.unseen,active:t===l.id,dimmed:s.muted,onClick:()=>a?.(l.id)},l.id)),s.outboxPending!==void 0&&e.jsx(I,{navId:"outbox",linkComponent:n,icon:e.jsx(ie,{className:"size-4"}),label:"Outbox",ariaLabel:"Outbox",count:s.outboxPending>0?s.outboxPending:void 0,active:t==="outbox",dimmed:s.muted,onClick:()=>a?.("outbox")}),c.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:y,"aria-expanded":i,className:C("mt-1 flex w-full items-center gap-1 px-2 py-1 text-left text-2xs font-semibold uppercase tracking-wider text-fg-subtle transition-colors hover:text-fg",E),children:[i?e.jsx(q,{className:"size-3 shrink-0"}):e.jsx(H,{className:"size-3 shrink-0"}),e.jsx("span",{className:"flex-1",children:"Folders"}),e.jsx("span",{className:"tabular-nums opacity-70",children:c.length})]}),i&&e.jsxs(e.Fragment,{children:[v.map(l=>e.jsx(I,{navId:l.id,linkComponent:n,icon:e.jsx(ze,{className:"size-4"}),label:l.name,ariaLabel:l.name,title:l.fullPath??l.name,failure:l.failure,count:l.unseen,active:t===l.id,dimmed:s.muted,onClick:()=>a?.(l.id)},l.id)),(x>0||m)&&c.length>T&&e.jsx("button",{type:"button",onClick:()=>d(l=>!l),className:C("ml-7 flex items-center px-2 py-1 text-2xs font-medium text-accent transition-colors hover:underline",E),children:m?"Show less":`Show all (${c.length})`})]})]})]})]})]})}function ft({accounts:s,selectedNavId:t,briefUnseen:a,onSelectNav:n,variant:o="desktop",linkComponent:r,calendarNav:i="hidden"}){const u=f.useRef(null);Gs({containerRef:u,itemSelector:ct});const m=o==="drawer",d=e.jsxs("nav",{ref:m?u:void 0,className:m?"px-2 py-2":"flex-1 overflow-y-auto px-2 py-2","aria-label":"Mailboxes",children:[e.jsx(I,{navId:"brief",linkComponent:r,icon:e.jsx(Xs,{className:"size-4"}),label:"Daily brief",ariaLabel:"Daily brief",count:a,active:t==="brief",onClick:()=>n?.("brief")}),i==="shown"&&e.jsx(I,{navId:"calendar",linkComponent:r,icon:e.jsx(Te,{className:"size-4"}),label:"Calendar",ariaLabel:"Calendar",active:t==="calendar",onClick:()=>n?.("calendar")}),e.jsx(I,{navId:"flagged",linkComponent:r,icon:e.jsx(oe,{className:"size-4"}),label:"Starred",ariaLabel:"Starred",active:t==="flagged",onClick:()=>n?.("flagged")}),s.length===0?e.jsx("div",{className:"px-2 py-4 text-center text-sm text-fg-muted",children:"No accounts configured"}):s.map(h=>e.jsx(xt,{account:h,selectedNavId:t,onSelectNav:n,linkComponent:r},h.id))]});return m?d:e.jsx("aside",{ref:u,className:"flex h-full w-full flex-col bg-surface-sunken",children:d})}function pt(){const s=le();if(!s)return null;const t=s.showNavPane?!s.navCollapsed:!1;return e.jsx(P,{variant:"ghost",size:"sm",icon:e.jsx(Ks,{className:"size-4"}),onClick:s.toggleNav,"aria-label":t?"Hide folders":"Show folders","aria-expanded":t,title:"Folders",className:"shrink-0"})}const ht={global:"Search all mail",pending:"Search mail",scoped:"Search this folder"};function gt({search:s,onCompose:t,onReportBug:a,onOpenSettings:n,settingsAttention:o,composeShortcut:r,refreshControl:i,account:u}){return e.jsx(rt,{leading:e.jsx(pt,{}),search:e.jsx(fs,{value:s.value,onChange:s.onChange,onClear:s.onClear,onClearQuery:s.onClearQuery,chips:s.chips,onRemoveChip:s.onRemoveChip,placeholder:ht[s.scope]}),actions:e.jsxs(e.Fragment,{children:[e.jsx(P,{variant:"ghost",size:"sm",icon:e.jsx(nt,{className:"size-4"}),title:r?`Compose (${r})`:"Compose","aria-label":"Compose",onClick:t}),e.jsx(P,{variant:"ghost",size:"sm",icon:e.jsx(pe,{className:"size-4"}),title:"Report a bug","aria-label":"Report a bug",onClick:a}),e.jsx(P,{variant:"ghost",size:"sm",icon:e.jsx(ce,{label:o,children:e.jsx(ve,{className:"size-4"})}),title:"Settings","aria-label":o?`Settings — ${o}`:"Settings",onClick:n}),i,u]})})}function bt(){const{pathname:s}=js(),t=He({from:"/mail/$mailboxId",shouldThrow:!1});return O(s,"/settings")?"settings":O(s,"/calendar")?"calendar":O(s,"/mail/outbox")?"outbox":O(s,"/mail/flagged")?"flagged":O(s,"/mail/brief")?"brief":t?.mailboxId??""}function vt(){const s=Ve(),t=D({select:d=>$(d.location.pathname)}),a=D({select:d=>Ns(d.location.search)}),[n,o]=f.useState(a),r=at(n,200),[i,u]=f.useState(t);if(i!==t){const d=Es(i,t,a);u(t),d!==void 0&&o(d)}const m=f.useCallback(d=>{u($(s.state.location.pathname)),o(d)},[s]);return{searchInput:n,committedQuery:Ps(n,r),viewKey:t,setSearchInput:m}}const yt=()=>{const s=Q();return Ss()?null:e.jsx(it,{onCompose:s})},ye=({children:s})=>{const{Account:t}=$e();return e.jsx(t,{children:s})},jt=()=>e.jsx(ye,{children:({email:s,signOut:t})=>e.jsx(ot,{email:s,onSignOut:t})});function Nt({accounts:s}){const{searchInput:t,onSearchChange:a,onSearchClear:n,onSearchClearQuery:o,resultFolderIndex:r}=ue(),i=K(),u=Ws(),m=Q(),{scope:d,clearScope:h}=ps(s),y=de(),g=d.kind==="scoped"?[{id:d.chip.id,label:d.chip.label,tone:"scope"}]:void 0,c=f.useMemo(()=>s.map(N=>N.accountId),[s]),{hasNewMail:v}=As(),{state:x,errorMessage:p,refresh:b}=Fs(c,{onSettled:()=>Ue(i,We(r.keys()))});return e.jsx(gt,{search:{value:t,scope:d.kind,chips:g,onChange:a,onClear:n,onClearQuery:o,onRemoveChip:h},onCompose:m,onReportBug:me,onOpenSettings:()=>u("accounts"),settingsAttention:y,composeShortcut:hs("compose"),refreshControl:e.jsx(Ts,{state:x,onRefresh:b,label:"Refresh all accounts",errorMessage:p,hasUpdate:v(c)}),account:e.jsx(jt,{})})}function St(){return e.jsxs("button",{type:"button",onClick:me,className:"flex w-full items-center gap-2 rounded-md px-2 py-1 text-sm text-fg-muted transition-colors hover:bg-surface hover:text-fg",children:[e.jsx(pe,{className:"size-4 shrink-0"}),e.jsx("span",{className:"flex-1 truncate text-left",children:"Report a bug"})]})}const Z=s=>/^\d/.test(s),Ct=(s,t)=>{const a=Z(s),n=Z(t);return a&&!n?-1:!a&&n?1:s.localeCompare(t,void 0,{sensitivity:"base",numeric:!0})};function wt(s,t,a){const n=[],o=[];for(const r of s)t.has(r.mailboxId)?n.push(r):o.push(r);return o.sort((r,i)=>Ct(z(r,void 0,a),z(i,void 0,a))),{system:n,labels:o}}function It(s,t,a){const n=Xe(t)&&s.unseenCount>0;return{id:s.mailboxId,name:z(s,t,a),unseen:n?s.unseenCount:void 0,role:t,fullPath:s.fullPath,failure:Zs(s)}}function ee({accounts:s,onMailboxSelect:t,variant:a="desktop"}){const n=K(),o=bt(),{onSearchChange:r}=ue(),{t:i}=Ge("mail",{useSuspense:!1}),u=f.useCallback((x,p)=>i(x,{defaultValue:p}),[i]),m=he({queries:s.map(x=>({...xe({path:{accountId:x.accountId}}),staleTime:1/0}))}),{data:d}=fe(Ye()),h=f.useMemo(()=>(d?.items??[]).filter(x=>et(x.status)).length,[d?.items]),y=f.useMemo(()=>s.map((x,p)=>{const b=m[p],N=b?.data?.items??[],l=Je(x.folderAppointments),{system:j,labels:L}=wt(N,l,u),A=b?.isError?"error":b?.isLoading?"loading":"ready";return{id:x.accountId,label:x.email,email:x.email,muted:!!x.muted,outboxPending:h,status:A,onRetry:()=>b?.refetch(),mailboxes:[...j,...L].map(k=>It(k,l.get(k.mailboxId),u))}}),[s,m,h,u]),g=x=>{n.invalidateQueries({queryKey:Ze({path:{mailboxId:x},query:{order:"desc"}})})},c=({navId:x,className:p,ariaLabel:b,title:N,children:l,onClick:j})=>x==="brief"?e.jsx(w,{to:"/mail/brief",search:{q:void 0},activeOptions:{includeSearch:!1},onClick:()=>j?.(),className:p,"aria-label":b,title:N,children:l}):x==="calendar"?e.jsx(w,{to:"/calendar",onClick:()=>j?.(),className:p,"aria-label":b,title:N,children:l}):x==="outbox"?e.jsx(w,{to:"/mail/outbox",search:{q:void 0},onClick:()=>j?.(),className:p,"aria-label":b,title:N,children:l}):x==="flagged"?e.jsx(w,{to:"/mail/flagged",search:{q:void 0},onClick:()=>j?.(),className:p,"aria-label":b,title:N,children:l}):x==="settings"?e.jsx(w,{to:"/settings/accounts",onClick:()=>j?.(),className:p,"aria-label":b,title:N,children:l}):e.jsx(w,{to:"/mail/$mailboxId",params:{mailboxId:x},search:{q:void 0},onClick:()=>{g(x),j?.()},className:p,"aria-label":b,title:N,children:l}),v=()=>{r(""),t?.()};return e.jsx(ft,{accounts:y,selectedNavId:o,onSelectNav:v,linkComponent:c,variant:a})}function Ot({accounts:s,onMailboxSelect:t}){const n=le()?.showNavPane??!0,o=de();return n?e.jsx(ee,{accounts:s}):e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsx(ee,{accounts:s,onMailboxSelect:t,variant:"drawer"})}),e.jsxs("div",{className:"border-t border-line px-2 py-2",children:[e.jsxs(w,{to:"/settings/accounts",onClick:t,children:[e.jsx(ce,{label:o,children:e.jsx(ve,{className:"size-4 shrink-0"})}),e.jsx("span",{className:"flex-1 truncate text-left",children:"Settings"})]}),e.jsx(St,{}),e.jsx(ye,{children:({signOut:r})=>e.jsxs("button",{type:"button",onClick:()=>{t?.(),r()},className:"flex min-h-11 w-full items-center gap-2 rounded-md px-2 py-1 text-sm text-fg-muted transition-colors hover:bg-surface hover:text-fg","data-testid":"sign-out-button",children:[e.jsx(be,{className:"size-4 shrink-0"}),e.jsx("span",{className:"flex-1 truncate text-left",children:"Sign out"})]})})]})]})}function kt(s){const t=he({queries:s.map(a=>({...xe({path:{accountId:a.accountId}}),staleTime:1/0}))});return f.useMemo(()=>gs(t.map(a=>a.data?.items??[])),[t])}const je="remit:intelligence-open";function Mt(){try{return localStorage.getItem(je)!=="closed"}catch{return!0}}function Rt(s){try{localStorage.setItem(je,s?"open":"closed")}catch{}}function se({panels:s,prefersOpen:t,isDesktop:a,hasThread:n,raisedFor:o,openMessage:r}){if(o!==null&&o===r)return!0;const i=s.filter(u=>u!=="sidebar");return i.length>0?i.includes("intelligence"):a&&n&&t}const Pt=()=>{const s=ge(),t=Cs(),a=ws(),n=t.find(Is),o=bs(),[r,i]=f.useState(Mt),u=o?`${o.threadId}/${o.messageId??""}`:null,[m,d]=f.useState(null),h={panels:t,prefersOpen:r,isDesktop:s==="desktop",hasThread:o!==void 0,openMessage:u},y=se({...h,raisedFor:m}),g=se({...h,raisedFor:null}),c=f.useCallback((b,N)=>{a([...b?["intelligence"]:[],...N?[N]:[]])},[a]),v=f.useCallback(b=>{c(g,b)},[g,c]),x=f.useCallback(()=>{if(y&&!g){d(null);return}const b=!y;Rt(b),i(b),d(null),c(b,n)},[g,y,n,c]),p=f.useCallback(()=>{d(u)},[u]);return{openOverlay:n,intelligenceOpen:y,showOverlay:v,toggleIntelligence:x,raiseIntelligence:p}};var M={exports:{}},te;function Et(){if(te)return M.exports;te=1;const s=(t,a,n)=>new Promise((o,r)=>{if(n=Object.assign({concurrency:1/0},n),typeof a!="function")throw new TypeError("Mapper function is required");const{concurrency:i}=n;if(!(typeof i=="number"&&i>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${i}\` (${typeof i})`);const u=[],m=t[Symbol.iterator]();let d=!1,h=!1,y=0,g=0;const c=()=>{if(d)return;const v=m.next(),x=g;if(g++,v.done){h=!0,y===0&&o(u);return}y++,Promise.resolve(v.value).then(p=>a(p,x)).then(p=>{u[x]=p,y--,c()},p=>{d=!0,r(p)})};for(let v=0;v<i&&(c(),!h);v++);});return M.exports=s,M.exports.default=s,M.exports}var Lt=Et();const At=es(Lt),Ft=900*1e3,Tt=30,zt=(s,t)=>{if(!s)return t;const a=Number.parseInt(s,10);return Number.isFinite(a)&&a>0?a:t},Dt=30*1e3,_t=s=>Math.max(zt(s,Tt)*1e3,Dt),Ne=_t(rs().mailboxPollIntervalSeconds),R=(s=Date.now(),t=Ne)=>Ds(s)?Math.min(_s,t):t,Bt=5,_=new Set,Kt=(s,t,a=Ft)=>s.filter(n=>{const o=n.lastSyncAt;return o==null?!0:t-o>a}).map(n=>n.accountId),Qt=(s,t,a=Ne)=>s-t>=a,qt=(s,t)=>s.filter(a=>!t.has(a)),ae=(s,t)=>{if(_.delete(s),as(t)||ns(t,{softError:!0})){os(t,{softError:!0});return}console.warn("[remit] background mailbox sync failed",{accountId:s,error:t})},ne=(s,t)=>ss({path:{accountId:s},throwOnError:!0}).then(()=>{t.invalidateQueries({queryKey:ts({path:{accountId:s}})})}),Ht=s=>{const t=K(),a=f.useRef(s);a.current=s;const n=s.map(o=>o.accountId).join(",");f.useEffect(()=>{const o=Date.now(),i=Kt(a.current,o).filter(u=>!_.has(u));if(i.length!==0)for(const u of i)_.add(u),ne(u,t).catch(m=>{ae(u,m)})},[n,t]),f.useEffect(()=>{let o=Date.now(),r;const i=new Set,u=()=>{o=Date.now();const g=qt(a.current.map(c=>c.accountId),i);for(const c of g)i.add(c);At(g,c=>ne(c,t).catch(v=>{ae(c,v)}).finally(()=>{i.delete(c)}),{concurrency:Bt})},m=()=>{if(document.visibilityState==="visible"){u(),r=setTimeout(m,R());return}},d=()=>{if(document.visibilityState!=="visible")return;r!==void 0&&clearTimeout(r);const g=Date.now(),c=R(g);if(Qt(g,o,c)){u(),r=setTimeout(m,c);return}r=setTimeout(m,o+c-g)},h=()=>{document.visibilityState==="visible"&&(r!==void 0&&clearTimeout(r),o=Date.now(),r=setTimeout(m,R()))};r=setTimeout(m,R()),document.addEventListener("visibilitychange",d);const y=zs(h);return()=>{r!==void 0&&clearTimeout(r),document.removeEventListener("visibilitychange",d),y()}},[n,t])};function Sa(){const s=is(),t=ge(),a=tt(t),{openOverlay:n,intelligenceOpen:o,showOverlay:r,toggleIntelligence:i,raiseIntelligence:u}=Pt(),m=n==="shortcuts",d=n==="nav",{searchInput:h,committedQuery:y,viewKey:g,setSearchInput:c}=vt(),{data:v,isLoading:x,isError:p,error:b,refetch:N}=fe({...ls(),staleTime:1/0}),l=!!(v&&(v.accounts?.length??0)===0);f.useEffect(()=>{l&&s({to:"/onboarding",replace:!0})},[l,s]),st({enabled:!m,bindings:[{key:"?",action:"help",handler:()=>r("shortcuts"),noModifiers:!1,preventDefault:!0}]});const j=Q(),L=Rs(),A=D({select:F=>Os(F.matches)?.list==="mailbox"}),k=f.useMemo(()=>({compose:j}),[j]);vs({enabled:!A&&!L,handlers:k});const Se=f.useCallback(()=>{c("")},[c]),Ce=f.useCallback(()=>{c("")},[c]),S=v?.accounts??[],we=f.useMemo(()=>S.map(F=>F.accountId),[S]),Ie=kt(S),Oe=Qs(S).index,ke=f.useMemo(()=>ys(S),[S]);Ht(S);const Me=f.useCallback(()=>{n==="nav"&&r(void 0)},[n,r]),Re={accounts:S,mailboxNameIndex:Ie,accountNameIndex:ke,resultFolderIndex:Oe,searchQuery:y,searchInput:h,searchViewKey:g,onSearchChange:c,onSearchClear:Se,onSearchClearQuery:Ce,intelligenceOpen:o,onToggleIntelligence:i,onRaiseIntelligence:u},Pe={isSinglePane:a,isLoading:x||l,intelligenceOpen:o,nav:e.jsx(Ot,{accounts:S,onMailboxSelect:Me}),topBar:a?void 0:e.jsx(Nt,{accounts:S}),overlay:a?e.jsx(yt,{}):void 0,navOpen:d,onOpenNav:()=>r("nav"),onCloseNav:()=>r(void 0)};return e.jsx(cs.Provider,{value:Re,children:e.jsxs(Bs,{accountIds:we,children:[e.jsx(ks,{children:p?e.jsx("div",{className:"flex h-full items-center justify-center bg-canvas p-4",children:e.jsx(ds,{title:"Couldn't load your account",error:b,onRetry:()=>{N()}})}):e.jsx(Ls,{chrome:Pe,children:e.jsx(us,{})})}),e.jsx(lt,{isOpen:m,onClose:()=>r(void 0)})]})})}export{Sa as component,ue as useMailContext};
@@ -1 +1 @@
1
- import{b as e}from"./index-BzL5-pGT.js";const n=e("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);export{n as M};
1
+ import{b as e}from"./index-CL_fwLHN.js";const n=e("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);export{n as M};
@@ -0,0 +1 @@
1
+ import{C as o}from"./CalendarEventEditor-COnJXvRd.js";import"./index-CL_fwLHN.js";import"./confirm-dialog-q8tbS_22.js";import"./calendar-event-popup-DsPmxVye.js";import"./pencil-LSmMSKiW.js";import"./useCalendarSuggestions-D3Jza1d7.js";import"./ErrorState-KjDYblD5.js";import"./useQueries-hChzM5ru.js";import"./calendar-event-sidebar-soFGsDRR.js";import"./calendar-guests-BR4hC59z.js";import"./circle-help-CVWHf1ow.js";import"./useCalendarData-DXhaM_NM.js";import"./useCalendarTasks-D_NZ0GM6.js";import"./draft-Y5XWTm_J.js";import"./useCalendarScheduling-BpjmrzdY.js";import"./useDebouncedValue-BTZsNKEh.js";import"./calendar-format-BwCpz-JZ.js";import"./reply-DvdgFS16.js";import"./useMediaQuery-DiQ0fGER.js";import"./calendar-tMekVEGW.js";import"./CalendarQuickCreate-DxgU3bNP.js";import"./CalendarSession-BKwK9s2o.js";const h=o;export{h as component};
@@ -0,0 +1 @@
1
+ import{n,f as i,u as a,r as m,j as s}from"./index-CL_fwLHN.js";import{O as p}from"./OnboardingWizard-Cvqq2aP_.js";import{c}from"./onboarding-completion-DoF3_MyG.js";import"./checkbox-CGG1nAhQ.js";import"./kbd-CDJCJUnp.js";import"./credential-steps-DVglyUgf.js";import"./card-CPL-TrL1.js";import"./account-form-helpers-DhckT_PN.js";import"./file-json-DQGozYSr.js";function O(){const o=n(),e=i(),t=a(),r=m.useCallback(l=>{c({queryClient:e,recordCompleted:()=>o.recordEvent("onboarding.completed"),navigateToInbox:()=>{window.location.assign("/mail")}})},[o,e]);return s.jsx(p,{skipWelcome:!1,onComplete:r,onImportConfig:()=>{t({to:"/import"})}})}export{O as component};
@@ -1 +1 @@
1
- import{l as o}from"./index-BzL5-pGT.js";async function n(e){e.recordCompleted(),await e.queryClient.refetchQueries({queryKey:o()}),e.navigateToInbox()}export{n as c};
1
+ import{l as o}from"./index-CL_fwLHN.js";async function n(e){e.recordCompleted(),await e.queryClient.refetchQueries({queryKey:o()}),e.navigateToInbox()}export{n as c};
@@ -0,0 +1 @@
1
+ import{j as o,O as i}from"./index-CL_fwLHN.js";import{a as m}from"./MailShell-LIuV2C3h.js";import{u as p,O as t}from"./OutboxPane-ce4uTAzW.js";import"./reply-DvdgFS16.js";import{u as s}from"./search-mirror-Dri4pWEq.js";import"./useMessageBodyContent-D-LJBFh4.js";import"./FullCompose-Djp_h4BT.js";import"./ErrorState-KjDYblD5.js";import"./index-DZb7rV9A.js";import"./useSignature-BkzkUbjz.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-BTZsNKEh.js";import"./sections-Rf3k05-_.js";import"./useMediaQuery-DiQ0fGER.js";import"./confirm-dialog-q8tbS_22.js";import"./roving-focus-FWOr5tBU.js";import"./MessageBody-C89PSL_p.js";import"./kbd-CDJCJUnp.js";import"./search-scope-UI1H6AzA.js";import"./circle-check-big-BsCwNdJZ.js";import"./clock-NnulNCOv.js";import"./row-actions-DA6zLLAB.js";import"./rotate-ccw-CENCKp2Z.js";import"./NavMenuButton-B-goW-G5.js";import"./menu-CcLh9Whg.js";import"./outbox-status-BlKn6P0x.js";function w(){const r=p();return s({to:"/mail/outbox"}),o.jsx(t,{outboxMessageId:r,children:o.jsx(m,{phone:o.jsx(t.Phone,{}),list:o.jsx(t.List,{}),reading:o.jsx(i,{})})})}export{w as component};
@@ -1 +1 @@
1
- import{b as a}from"./index-BzL5-pGT.js";const c=a("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);export{c as P};
1
+ import{b as a}from"./index-CL_fwLHN.js";const c=a("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);export{c as P};