@remit/web-client-dist 0.0.685 → 0.0.686

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 (186) hide show
  1. package/assets/{BriefPane-BfKwBxLe.js → BriefPane-DbPnsOco.js} +1 -1
  2. package/assets/{CalendarEventEditor-Bsugk6rT.js → CalendarEventEditor-CGrl9NkK.js} +1 -1
  3. package/assets/{CalendarEventPopup-C-BVvxfV.js → CalendarEventPopup-DSoQ-1wk.js} +1 -1
  4. package/assets/{CalendarLoadFailed-DcrF_lyr.js → CalendarLoadFailed-ClpqypbH.js} +1 -1
  5. package/assets/{CalendarQuickCreate-_ki0X3rq.js → CalendarQuickCreate-CaYUiVR8.js} +1 -1
  6. package/assets/{CalendarSession-CK-EC1yK.js → CalendarSession-Ql7K56YK.js} +1 -1
  7. package/assets/{DesktopChrome-BfOVbUXt.js → DesktopChrome-e0x9SkC0.js} +1 -1
  8. package/assets/{DropdownMenu-B4qvRStt.js → DropdownMenu-DusMkzz6.js} +1 -1
  9. package/assets/{EmptyState-BYR2eIr2.js → EmptyState-BjhPv2hS.js} +1 -1
  10. package/assets/{ErrorState-BXxvOnci.js → ErrorState-nIG-x-Zh.js} +1 -1
  11. package/assets/FlaggedPane-CcaZOeS-.js +1 -0
  12. package/assets/{FullCompose-DEhDpjci.js → FullCompose-D5JLo7Rb.js} +1 -1
  13. package/assets/{LabelApplyTrigger-C4ode0Y9.js → LabelApplyTrigger-CUfdoyOX.js} +1 -1
  14. package/assets/{MailShell-DvQDMygz.js → MailShell-DIZSKkXP.js} +1 -1
  15. package/assets/{MailViewChrome-D66Dcy3c.js → MailViewChrome-B22GO2ZU.js} +1 -1
  16. package/assets/MailboxPane-ikbl6KSS.js +135 -0
  17. package/assets/{MessageBody-CDTfM1lc.js → MessageBody-DbkrLz4x.js} +1 -1
  18. package/assets/{MessageToolbar-BW852rJj.js → MessageToolbar-D-FLeer4.js} +1 -1
  19. package/assets/{NavMenuButton-BZWw6TBA.js → NavMenuButton-C78wt6tT.js} +1 -1
  20. package/assets/{OnboardingWizard-Bppp1CPR.js → OnboardingWizard-B7BpPMJF.js} +1 -1
  21. package/assets/{OutboxPane-B_ihIEGn.js → OutboxPane-Ch6JqV2D.js} +1 -1
  22. package/assets/{ReportLink-CwxUgr_7.js → ReportLink-BTuMtEGU.js} +1 -1
  23. package/assets/_calendarObjectId-CNeye1nX.js +1 -0
  24. package/assets/_mailboxId-CINQfps_.js +1 -0
  25. package/assets/_messageId-D0UOksYx.js +1 -0
  26. package/assets/_messageId-OM56_7mN.js +1 -0
  27. package/assets/_messageId-VtS9XL2y.js +1 -0
  28. package/assets/_outboxMessageId-B0eJRNrJ.js +1 -0
  29. package/assets/_recurrenceId-CwEJEhKM.js +1 -0
  30. package/assets/{_slotId-D9HVYRDd.js → _slotId-CukLHO14.js} +1 -1
  31. package/assets/_threadId-BvpkdG2H.js +1 -0
  32. package/assets/_threadId-CEIXKQzn.js +1 -0
  33. package/assets/_threadId-H3F-Cx53.js +1 -0
  34. package/assets/{_view._date-DCmCYHjG.js → _view._date-BhRGXGQG.js} +1 -1
  35. package/assets/{account-service-status-D-hGpg9e.js → account-service-status-2nmShluv.js} +1 -1
  36. package/assets/{accounts-BcJ04H8d.js → accounts-B_pt4l15.js} +1 -1
  37. package/assets/{advanced-DnA-3VCS.js → advanced-DzS_Bhbq.js} +1 -1
  38. package/assets/{agenda-time-O7rJVIvd.js → agenda-time-Bt4BEp3g.js} +1 -1
  39. package/assets/{app-chrome-DvUymvcE.js → app-chrome-CbZgCDW_.js} +1 -1
  40. package/assets/{appearance-CypE55tV.js → appearance-D6Q4ETnm.js} +1 -1
  41. package/assets/{avatar-BgqBWztU.js → avatar-CQq2GZz9.js} +1 -1
  42. package/assets/{badge-CfQoDkmE.js → badge-BVw5vgFN.js} +1 -1
  43. package/assets/{bottom-sheet-Dhk1Aqz2.js → bottom-sheet-C81CIc2R.js} +1 -1
  44. package/assets/{brief-DgC2R0u5.js → brief-CGFThfPb.js} +1 -1
  45. package/assets/brief-CGmiPbD7.js +1 -0
  46. package/assets/{calendar-Ix1rbLDg.js → calendar-Ddji3ram.js} +1 -1
  47. package/assets/{calendar-BJu4Vl-g.js → calendar-SMIdRsx9.js} +1 -1
  48. package/assets/{calendar-event-popup-B4-Dpgb6.js → calendar-event-popup-DqvJLPWt.js} +1 -1
  49. package/assets/{calendar-event-sidebar-DZum-8WN.js → calendar-event-sidebar-CGPuc517.js} +1 -1
  50. package/assets/{calendar-failure-note-DK-uzvky.js → calendar-failure-note-4qETx8lD.js} +1 -1
  51. package/assets/{calendar-guests-Diti9JO5.js → calendar-guests-Dt2cjTqc.js} +1 -1
  52. package/assets/{calendar-suggestion-C8kx9fKn.js → calendar-suggestion-BZ4IIHBe.js} +1 -1
  53. package/assets/{calendars-ne1Oj2RW.js → calendars-U4lDveGO.js} +1 -1
  54. package/assets/{card-B-YLocTg.js → card-kzE1rw9u.js} +1 -1
  55. package/assets/{checkbox-DL0pObJW.js → checkbox-BILwOn1g.js} +1 -1
  56. package/assets/chevron-down-TeH9o9Q-.js +1 -0
  57. package/assets/chevron-left-DUh7xA0y.js +1 -0
  58. package/assets/{circle-check-OUBTwy71.js → circle-check-CBDdVMl8.js} +1 -1
  59. package/assets/{circle-check-big-Czqmzl9y.js → circle-check-big-DlhpMe5P.js} +1 -1
  60. package/assets/{circle-help-DJ-Mtycd.js → circle-help-CP1s-Yi3.js} +1 -1
  61. package/assets/{classification-DLUltDdR.js → classification-DF13x4GV.js} +1 -1
  62. package/assets/{clock-Bw2dEIoB.js → clock-CLvsvjcH.js} +1 -1
  63. package/assets/compose._-_outboxMessageId_-3OLQ2cbN.js +1 -0
  64. package/assets/compose._-_outboxMessageId_-BYGqO75X.js +1 -0
  65. package/assets/compose._-_outboxMessageId_-Cc0PpaH6.js +1 -0
  66. package/assets/compose._-_outboxMessageId_-SAeViPeG.js +1 -0
  67. package/assets/{config-import-B6tjROvg.js → config-import-BRacJ1y6.js} +1 -1
  68. package/assets/{confirm-dialog-sa45Xnmn.js → confirm-dialog-B0MVMPmn.js} +1 -1
  69. package/assets/{copy-9W6V4dQI.js → copy-DMRh3Rb2.js} +1 -1
  70. package/assets/{credential-steps-P9fRg1pE.js → credential-steps-4YQ5eJjl.js} +1 -1
  71. package/assets/{download-O3cdl6IV.js → download-WnSzcn6T.js} +1 -1
  72. package/assets/{draft-QkjvtbSZ.js → draft-0DDwY2Pw.js} +1 -1
  73. package/assets/edit-B4dfxZaW.js +1 -0
  74. package/assets/edit-BU8CFYW0.js +1 -0
  75. package/assets/{external-link-BYIIFw9_.js → external-link-B_11YPnQ.js} +1 -1
  76. package/assets/{file-json-vVOzTp-u.js → file-json-D4Uv97RH.js} +1 -1
  77. package/assets/{filters-DohRSViK.js → filters-BWFo6zj7.js} +1 -1
  78. package/assets/flagged-BQl5KVuF.js +1 -0
  79. package/assets/{flagged-BHlMmpp_.js → flagged-C_307aIb.js} +1 -1
  80. package/assets/{folder-input-hVRteCio.js → folder-input-DjY4GpKG.js} +1 -1
  81. package/assets/{folders-BFfd-sur.js → folders-D7JFBgPP.js} +1 -1
  82. package/assets/{help-copy-_K3IfQdg.js → help-copy-bU0rZqtx.js} +1 -1
  83. package/assets/{import-ByOg30ul.js → import-CyBIMXQK.js} +1 -1
  84. package/assets/index-6cMF4pO8.js +1 -0
  85. package/assets/index-B0m7QGSS.js +1 -0
  86. package/assets/{index-Bn8n_AsE.js → index-BZ4sAts4.js} +3 -3
  87. package/assets/index-CH48-R4X.js +1 -0
  88. package/assets/index-CjLHI6va.js +1 -0
  89. package/assets/{index-k6LzEquX.js → index-CrUfJlwk.js} +4 -4
  90. package/assets/index-D-NR3LoA.js +1 -0
  91. package/assets/index-D0UOksYx.js +1 -0
  92. package/assets/index-D1_eaXw-.js +1 -0
  93. package/assets/index-OM56_7mN.js +1 -0
  94. package/assets/index-VtS9XL2y.js +1 -0
  95. package/assets/index-ksP05uVF.js +1 -0
  96. package/assets/{kbd-PiHV4odS.js → kbd-5V1_yqOW.js} +1 -1
  97. package/assets/{label-chip-BnNtXrWd.js → label-chip-BBPaslky.js} +1 -1
  98. package/assets/{labels-BQe-BkCj.js → labels-xO9yj2bw.js} +1 -1
  99. package/assets/{mail-CPplAOgE.js → mail-CRvRtCed.js} +1 -1
  100. package/assets/{mail-BFIBAL7w.js → mail-DcTEJ5uO.js} +1 -1
  101. package/assets/{menu-znX-3dzE.js → menu-DXmZUEBa.js} +1 -1
  102. package/assets/{nav-link-CtuHya9S.js → nav-link-BvBkmH1H.js} +1 -1
  103. package/assets/new-kYNP_cv-.js +1 -0
  104. package/assets/onboarding-CFIwco02.js +1 -0
  105. package/assets/{onboarding-completion-CKAiaYkS.js → onboarding-completion-CK2mHfmP.js} +1 -1
  106. package/assets/outbox-DgFmUFU6.js +1 -0
  107. package/assets/{pencil-DA21sF5f.js → pencil-Py3MXttE.js} +1 -1
  108. package/assets/{people-BQjKSotc.js → people-CxpFEQpi.js} +1 -1
  109. package/assets/{plus-6ss9YFRF.js → plus-5sFyaPZh.js} +1 -1
  110. package/assets/{popover-menu-iCbmrU-E.js → popover-menu-uIVgxYG_.js} +1 -1
  111. package/assets/{refresh-cw-CUyjBEl4.js → refresh-cw-Dar0XAdp.js} +1 -1
  112. package/assets/{reply-DmpF7cgR.js → reply-D8bLYzum.js} +1 -1
  113. package/assets/{rich-text-Cppy56p_.js → rich-text-B2jeK_lt.js} +1 -1
  114. package/assets/{rich-text-spellcheck-worker-provider-Bk2_kAe9.js → rich-text-spellcheck-worker-provider-D1J3yZU8.js} +1 -1
  115. package/assets/{rotate-ccw-Dtkxt0CH.js → rotate-ccw-CSByuoeY.js} +1 -1
  116. package/assets/{roving-focus-CzX6YmR4.js → roving-focus-1m_wY9_4.js} +1 -1
  117. package/assets/{row-actions-Cn7bQ_Ks.js → row-actions-CB2wYT6g.js} +1 -1
  118. package/assets/{search-mirror-BSzHMUcd.js → search-mirror-CFL35Bis.js} +1 -1
  119. package/assets/{search-scope-Cl87snrn.js → search-scope-BR87UqJt.js} +1 -1
  120. package/assets/{search-token-index-BSaB7qLo.js → search-token-index-CoqsoQJZ.js} +1 -1
  121. package/assets/{sections-DwdsQ0ad.js → sections-B9pteMHc.js} +1 -1
  122. package/assets/{segmented-control-68-bWTGV.js → segmented-control-CVMDr-Je.js} +1 -1
  123. package/assets/{select-Cc2Vc4qL.js → select-DXHN14lo.js} +1 -1
  124. package/assets/{senders-DwOfiVHu.js → senders-CXpJyu9L.js} +1 -1
  125. package/assets/settings-B2MbfPot.js +1 -0
  126. package/assets/{settings-screen-IjQOks0s.js → settings-screen-C8kBB2kR.js} +1 -1
  127. package/assets/{shield-check-jkVgxi6o.js → shield-check-Fest6_gL.js} +1 -1
  128. package/assets/{suggest-list-FaY4DThZ.js → suggest-list-CUEgGZt_.js} +1 -1
  129. package/assets/{suggested-vips-BLlvjvH5.js → suggested-vips-CiTGLmJd.js} +1 -1
  130. package/assets/{suggestion._suggestionId-CL7hLrk-.js → suggestion._suggestionId-BMRKFgLt.js} +1 -1
  131. package/assets/{switch-a7x-CFTd.js → switch-xqSp-gFV.js} +1 -1
  132. package/assets/{task._calendarTaskId-CkPsJj-a.js → task._calendarTaskId-AbdgpKo5.js} +1 -1
  133. package/assets/{undo-2-CnxBm8gd.js → undo-2-IdsgUvVv.js} +1 -1
  134. package/assets/{useCalendarData-RUYA8D_t.js → useCalendarData-BKkQY_vQ.js} +1 -1
  135. package/assets/{useCalendarScheduling-CO3VOpcB.js → useCalendarScheduling-D_qd-mRK.js} +1 -1
  136. package/assets/{useCalendarSuggestions-Bb4PGHae.js → useCalendarSuggestions-D58tKJtx.js} +1 -1
  137. package/assets/{useCalendarTasks-RmI_Ij1j.js → useCalendarTasks-DLNYnUeu.js} +1 -1
  138. package/assets/{useDebouncedValue-I0sDLoIF.js → useDebouncedValue-CMBraotV.js} +1 -1
  139. package/assets/{useFilters-DT8SxgF4.js → useFilters-28pRmQGT.js} +1 -1
  140. package/assets/{useLabels-DO4UWjpG.js → useLabels-CGCEGKuz.js} +1 -1
  141. package/assets/{useLayoutTier-Cn3SwiV2.js → useLayoutTier-CnmLTkLg.js} +1 -1
  142. package/assets/{useMediaQuery-C00TiD5k.js → useMediaQuery-D3m_n689.js} +1 -1
  143. package/assets/{useMessageBodyContent-lqVkO1fM.js → useMessageBodyContent-dd-lowbx.js} +1 -1
  144. package/assets/{useQueries-Bs7-L_2j.js → useQueries-B-X1sW9_.js} +1 -1
  145. package/assets/{useRefreshControl-Bt-oDRnY.js → useRefreshControl-DbHCcSXX.js} +1 -1
  146. package/assets/{useResultFolderIndex-CALTzfWS.js → useResultFolderIndex-BvBtm4F3.js} +1 -1
  147. package/assets/{useSignature-DRFIcifS.js → useSignature-CQZ_Ke3T.js} +1 -1
  148. package/assets/{warnings-ClaUoDQx.js → warnings-bjC-sL2O.js} +1 -1
  149. package/index.html +1 -1
  150. package/package.json +1 -1
  151. package/assets/FlaggedPane-F0FM2UJN.js +0 -1
  152. package/assets/MailboxPane-BDYnlpr2.js +0 -135
  153. package/assets/_calendarObjectId-CSwodc6y.js +0 -1
  154. package/assets/_mailboxId-BlTWUSb1.js +0 -1
  155. package/assets/_messageId-BaqNxGqi.js +0 -1
  156. package/assets/_messageId-DNtVsPPW.js +0 -1
  157. package/assets/_messageId-ciVFKEzn.js +0 -1
  158. package/assets/_outboxMessageId-LLqtF8cH.js +0 -1
  159. package/assets/_recurrenceId-G4qPwsrp.js +0 -1
  160. package/assets/_threadId-BAVZ7S8M.js +0 -1
  161. package/assets/_threadId-DL34NZT4.js +0 -1
  162. package/assets/_threadId-qmAQ7RKu.js +0 -1
  163. package/assets/brief-DcbZ7jHO.js +0 -1
  164. package/assets/chevron-down-BWbeCM3N.js +0 -1
  165. package/assets/chevron-left-CliOUq1O.js +0 -1
  166. package/assets/compose._-_outboxMessageId_-CAx_e1OV.js +0 -1
  167. package/assets/compose._-_outboxMessageId_-CnWaV_IX.js +0 -1
  168. package/assets/compose._-_outboxMessageId_-Dmj8hyvT.js +0 -1
  169. package/assets/compose._-_outboxMessageId_-z980Xa6X.js +0 -1
  170. package/assets/edit-B31QMGS3.js +0 -1
  171. package/assets/edit-DjkZZFBG.js +0 -1
  172. package/assets/flagged-DIi4rqg8.js +0 -1
  173. package/assets/index-BIhlBhBD.js +0 -1
  174. package/assets/index-BaqNxGqi.js +0 -1
  175. package/assets/index-C53Z5hF_.js +0 -1
  176. package/assets/index-CRnDeQMw.js +0 -1
  177. package/assets/index-CzbtDE1H.js +0 -1
  178. package/assets/index-DNtVsPPW.js +0 -1
  179. package/assets/index-DR2Joq7n.js +0 -1
  180. package/assets/index-DbyBl7Lq.js +0 -1
  181. package/assets/index-cVALleyU.js +0 -1
  182. package/assets/index-ciVFKEzn.js +0 -1
  183. package/assets/new-psckzAFd.js +0 -1
  184. package/assets/onboarding-B_l5ow67.js +0 -1
  185. package/assets/outbox-BTiQbMrW.js +0 -1
  186. package/assets/settings-BdeAbD2h.js +0 -1
@@ -1 +1 @@
1
- import{j as r,L as Mt,S as jt,eM as ne,e4 as re,r as a,a as Ge,J as ie,c$ as kt,U as Et,dF as Ot,eN as Ft,v as Ke,eO as At}from"./index-Bn8n_AsE.js";import{a5 as Nt,y as Bt,A as Lt,an as qt,ao as _t,ap as Dt,aq as Pt,ar as _e,as as Qt,at as zt,au as Wt,av as Ht,aw as Ut,ag as Gt,M as Kt,aj as $t,ax as Vt,ah as Yt,ay as Jt,az as Zt,f as Xt,p as es,ak as ts,m as ss,S as os,G as ns,K as De,J as rs,H as as,e as is,V as cs,W as xe,X as ls,Z as $e,_ as Ve,$ as ds,a0 as us,a1 as fs}from"./MessageToolbar-BW852rJj.js";import"./nav-link-CtuHya9S.js";import{a as ms}from"./useMessageBodyContent-lqVkO1fM.js";import{o as hs,e as gs,f as ps}from"./search-token-index-BSaB7qLo.js";import{d as xs,g as Is,r as ys}from"./reply-DmpF7cgR.js";import{u as Ye}from"./sections-DwdsQ0ad.js";import{u as ae}from"./useQueries-Bs7-L_2j.js";import{t as Je,s as vs,r as bs,L as Ss}from"./LabelApplyTrigger-C4ode0Y9.js";import{u as Ts,a as Cs,R as ws,b as Rs,c as Ms}from"./useRefreshControl-Bt-oDRnY.js";import{a as js}from"./useLabels-DO4UWjpG.js";import{u as ks}from"./useLayoutTier-Cn3SwiV2.js";import{u as Es}from"./useMediaQuery-C00TiD5k.js";import{r as Ze,n as Os,o as Xe,w as et,u as Fs,p as As,R as Ns}from"./MessageBody-CDTfM1lc.js";import{d as Bs,w as Ls}from"./wizard-selection-zWa1qc6-.js";import{R as qs}from"./refresh-cw-CUyjBEl4.js";function _s({sync:e}){return e?r.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 py-12 text-center px-4",role:"status","aria-live":"polite",children:[r.jsx(Mt,{className:"size-8 animate-spin text-fg-subtle","aria-hidden":"true"}),r.jsx("p",{className:"text-sm font-medium text-fg",children:"Still syncing your mail"}),r.jsx("p",{className:"text-xs text-fg-subtle",children:Ds(e)})]}):r.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 py-12 text-center px-4",children:[r.jsx(jt,{className:"size-8 text-fg-subtle","aria-hidden":"true"}),r.jsx("p",{className:"text-sm font-medium text-fg",children:"You're caught up"}),r.jsx("p",{className:"text-xs text-fg-subtle",children:"Nothing needs attention."})]})}function Ds({synced:e,total:t}){return t>0?`${e.toLocaleString()} of ${t.toLocaleString()} messages downloaded. This list fills in as they arrive.`:"Downloading your messages. This list fills in as they arrive."}const tt=[{id:"unread",name:"is",value:"unread"},{id:"attachment",name:"has",value:"attachment"}],st="category",Ps={unclassified:"uncategorized"},H=e=>Os(e).map(t=>t.raw),W=e=>e.join(" "),Ie=e=>{const t=Xe(e);if(t)return tt.find(s=>s.name===t.name&&s.value===t.value.toLowerCase())?.id},ye=e=>{const t=Xe(e);if(!t||t.name!==st)return;const s=t.value.toLowerCase(),n=Ps[s];if(n)return n;if(!(!et(s)||s==="all"))return s},ot=e=>tt.find(t=>t.id===e),nt=e=>ot(e)!==void 0,Qs=e=>{const t=new Set;for(const s of H(e)){const n=Ie(s);n&&t.add(n)}return t},zs=e=>{let t="all";for(const s of H(e)){const n=ye(s);n&&(t=n)}return t},Ws=(e,t)=>{const s=ot(t);if(!s)return;const n=H(e),i=n.filter(d=>Ie(d)!==t);return i.length<n.length?W(i):W([...n,Ze(s.name,s.value)])},Hs=(e,t)=>{const s=H(e).filter(n=>!ye(n));return W(t==="all"?s:[...s,Ze(st,t)])},Us=e=>W(H(e).filter(t=>!Ie(t)&&!ye(t))),rt=e=>e.trim().length>0,Pe=e=>{if(!rt(e.query))return e.ownFilters;const t=new Set(Qs(e.query));for(const s of e.ownFilters)nt(s)||t.add(s);return t},Qe=e=>rt(e.query)?zs(e.query):e.ownCategory,ze=6e4,Gs=3e4,Ks={kind:"unknown"},We=e=>(t,s)=>Nt(s?.queryKey,e)?t:void 0,$s=(e,t,s)=>({...e,category:[t],limit:s,order:"desc"}),Vs=(e,t)=>({...e,category:[t],order:"desc",count:!0,results:!1}),He=(e,t)=>({category:[t],...e.unread!==void 0?{unread:e.unread}:{},...e.starred!==void 0?{starred:e.starred}:{},...e.attachments!==void 0?{attachments:e.attachments}:{},...e.accountId!==void 0?{accountId:e.accountId}:{},...e.muted!==void 0?{muted:e.muted}:{}});function Ys({categories:e,criteria:t,limit:s,counted:n}){const i=ae({queries:e.map(c=>{const h=$s(t,c,s),u=He(t,c);return{queryKey:re({query:h}),queryFn:async()=>{const{data:v}=await ne({query:h,throwOnError:!0});return v},placeholderData:We(u),staleTime:ze}})}),d=ae({queries:e.map(c=>{const h=Vs(t,c),u=He(t,c);return{queryKey:re({query:h}),queryFn:async()=>{const{data:v}=await ne({query:h,throwOnError:!0});return v},enabled:n,placeholderData:We(u),staleTime:ze}})}),m=a.useMemo(()=>e.map((c,h)=>{const u=i[h],v=d[h],p=u?.data?.items??[];return{category:c,rows:p,atCap:p.length>=s,total:n?Je(v?.data?.count):Ks,loading:u?.isPending??!0,failed:u?.isError??!1,retry:()=>{u?.refetch(),n&&v?.refetch()}}}),[e,i,d,n,s]),l=a.useCallback(()=>{for(const c of i)c.refetch();for(const c of d)c.refetch()},[i,d]);return{sections:m,isLoading:i.length>0&&i.every(c=>c.isPending),isError:i.length>0&&i.every(c=>c.isError),refetch:l}}function Js(e,t,s){const n={...e,limit:t,order:"desc"},{data:i,isLoading:d,isError:m,refetch:l}=Ge({queryKey:re({query:n}),queryFn:async()=>{const{data:h}=await ne({query:n,throwOnError:!0});return h},enabled:s,staleTime:Gs});return{rows:a.useMemo(()=>s?i?.items??[]:[],[i,s]),isLoading:s&&d,isError:s&&m,refetch:a.useCallback(()=>{l()},[l])}}const Zs=3e4,Xs={kind:"unknown"},eo=(e,t)=>({...e,mailboxId:t,order:"desc",count:!0,results:!1});function to({criteria:e,junkMailboxIds:t,enabled:s}){const n=ae({queries:t.map(i=>{const d=eo(e,i);return{queryKey:re({query:d}),queryFn:async()=>{const{data:m}=await ne({query:d,throwOnError:!0});return m},enabled:s,staleTime:Zs}})});return a.useMemo(()=>t.map((i,d)=>({mailboxId:i,count:s?Je(n[d]?.data?.count):Xs,failed:s?n[d]?.isError??!1:!1})),[t,n,s])}const so=(e,t)=>e.createdAt!==t.createdAt?e.createdAt-t.createdAt:e.accountId.localeCompare(t.accountId),oo=e=>[...e].sort(so),no=["from","subject","category","unread","starred","attachments"],at=["contacts","today"],ro=e=>new Set(at.filter(t=>e.has(t))),ao=(e,t,s,n)=>{const i=Bt({category:e,attributes:t}),{params:d,residual:m}=Lt(s,i,no),l={...d,...i},c={muted:!1};return l.from!==void 0&&(c.from=l.from),l.subject!==void 0&&(c.subject=l.subject),l.unread!==void 0&&(c.unread=l.unread),l.starred!==void 0&&(c.starred=l.starred),l.attachments!==void 0&&(c.attachments=l.attachments),n!==void 0&&(c.accountId=n),{criteria:c,residual:m}},io=({residual:e,attributes:t})=>e.length===0&&!at.some(s=>t.has(s)),se=e=>e.count.kind==="exact"&&e.count.value>0?3:e.pageRows>0?2:e.count.kind==="unknown"?1:0,oe=e=>e.count.kind==="exact"?e.count.value:0,co=(e,t)=>se(e)!==se(t)?se(e)>se(t):oe(e)!==oe(t)?oe(e)>oe(t):e.pageRows>t.pageRows;function lo(e,{pageRowsByMailbox:t}){const s=e.map(u=>({...u,pageRows:t.get(u.mailboxId)??0}));for(const[u,v]of t)v<=0||s.some(p=>p.mailboxId===u)||s.push({mailboxId:u,count:{kind:"unknown"},failed:!1,pageRows:v});const n=s[0];if(!n)return;let i=0,d=!0,m=n;for(const u of s)u.count.kind==="unknown"?d=!1:i+=u.count.value,co(u,m)&&(m=u);const l=s.some(u=>u.pageRows>0),c=s.some(u=>u.failed);if(i===0&&!l&&(d||!c))return;const h=d&&i===0&&l;return{mailboxId:m.mailboxId,count:d&&!h?{kind:"exact",value:i}:{kind:"unknown"}}}const uo=50,fo=200,mo=[],Ue=()=>r.jsx("div",{className:"animate-pulse",children:Array.from({length:3}).map((e,t)=>r.jsxs("div",{className:"flex items-start gap-3 py-2 pl-5 pr-4 border-b border-line",children:[r.jsx("div",{className:"size-7 rounded-full bg-surface-sunken shrink-0 mt-0.5"}),r.jsxs("div",{className:"flex-1 space-y-1.5",children:[r.jsxs("div",{className:"flex justify-between gap-2",children:[r.jsx("div",{className:"h-3.5 bg-surface-sunken rounded w-28"}),r.jsx("div",{className:"h-3 bg-surface-sunken rounded w-12"})]}),r.jsx("div",{className:"h-3.5 bg-surface-sunken rounded w-48"}),r.jsx("div",{className:"h-3 bg-surface-sunken rounded w-full"})]})]},t))}),ho=({accountEmail:e})=>{const t=Ye();return r.jsxs("div",{className:"flex items-center gap-2 px-row-inset py-2 border-b border-line bg-danger-soft/40 text-xs text-danger",children:[r.jsx(Ke,{className:"size-3.5 shrink-0"}),r.jsxs("span",{className:"flex-1 truncate",children:[e," can't connect"]}),r.jsx("button",{type:"button",onClick:()=>t("accounts"),className:"shrink-0 underline text-danger hover:opacity-80",children:"Reconnect"})]})},go=(e,t)=>{if(t.size===0)return{};const s=e.filter(d=>t.has(d.id)),n=bs(s.map(d=>d.accountId));if(n.restriction)return n;const i=new Set;for(const d of s)d.mailboxId&&i.add(d.mailboxId);return i.size>1?{accountId:n.accountId,restriction:"spansFolders",moveDisabledHint:`Move only works within one folder — this selection spans ${i.size} folders`}:{accountId:n.accountId,mailboxId:i.size===1?[...i][0]:void 0}};function po({header:e,rows:t,wizard:s,children:n}){const{selectedIds:i,selectedCount:d,exitSelection:m,orderedIds:l,allSelected:c,toggleAllLoaded:h}=Zt(),u=a.useMemo(()=>go(t,i),[t,i]),{junkMailboxId:v}=Xt(u.accountId),{labels:p}=js(u.accountId),b=a.useMemo(()=>Array.from(i),[i]),L=a.useMemo(()=>Ls(t,i),[t,i]),x=es(v,u.mailboxId),S=a.useMemo(()=>l.length>0?{checked:c,indeterminate:d>0&&!c,onChange:h}:void 0,[l.length,c,d,h]),A=u.moveDisabledHint?{tone:"warning",text:u.moveDisabledHint}:void 0,T=R=>r.jsx(os,{title:R.title,navSlot:R.navSlot,titleMeta:R.titleMeta,searchSlot:R.searchSlot,searchField:R.searchField,idleSlot:R.makeFilterSlot,count:d,onCancel:m,onDelete:()=>s.start("delete"),onMove:()=>s.start("move"),onOrganize:()=>s.start("organize"),onJunk:x?()=>s.start("junk"):void 0,onMarkRead:()=>s.start("markRead"),overflowSlot:u.accountId&&u.mailboxId&&d>0&&p.length>0?r.jsx(Ss,{accountId:u.accountId,mailboxId:u.mailboxId,messageIds:b}):void 0,selectAll:S,notice:A});return r.jsx(ts,{...e,selectionBar:T,paneOverlay:r.jsx(ss,{verb:s.verb,accountId:u.accountId,mailboxId:u.mailboxId,selection:L,selectionRestriction:u.restriction,onFinished:m}),children:n})}function xo({accounts:e,selectedMessageId:t,onOpenThread:s,commandsRef:n,onTriageContextChange:i,onDeleteMessages:d}){const{searchQuery:m,searchInput:l,resultFolderIndex:c,onSearchChange:h}=ie(),u=Fs(),v=Es(),p=ks(),b=kt(),L=hs(),x=a.useMemo(()=>oo(e.filter(o=>!o.muted?.value)),[e]),[S,A]=a.useState("all"),[T,R]=a.useState("all"),[N,q]=a.useState(new Set),[le,M]=a.useState(!1),_=a.useCallback(o=>{q(f=>{const g=new Set(f);return g.has(o)?g.delete(o):g.add(o),g})},[]),U=a.useCallback(()=>q(new Set),[]),E=l.trim().length>0,{freeText:w,tokens:D}=As(m.trim().toLowerCase(),u),y=w.length>0,P=a.useMemo(()=>Pe({query:l,ownFilters:N}),[l,N]),Q=a.useMemo(()=>Qe({query:l,ownCategory:T}),[l,T]),F=a.useMemo(()=>Pe({query:m,ownFilters:N}),[m,N]),C=a.useMemo(()=>Qe({query:m,ownCategory:T}),[m,T]),I=a.useCallback(o=>{if(!E||!nt(o)){_(o);return}const f=Ws(l,o);f!==void 0&&h(f)},[E,l,h,_]),j=a.useCallback(o=>{if(!E){R(o);return}h(Hs(l,o))},[E,l,h]),de=a.useMemo(()=>C==="all"&&!y?o=>{et(o)&&j(o)}:void 0,[C,y,j]),ue=a.useCallback(()=>{R("all"),A("all"),U(),E&&h(Us(l))},[E,l,h,U]),G=ae({queries:x.map(o=>({...Et({path:{accountId:o.accountId}}),staleTime:1/0,meta:{softError:!0}}))}),K=a.useMemo(()=>{const o=new Map;for(let f=0;f<x.length;f++){const g=x[f].accountId,te=(G[f]?.data?.items??[]).reduce((O,Rt)=>O+(Rt.unseenCount??0),0);o.set(g,te)}return o},[x,G]),lt=a.useMemo(()=>x.filter((o,f)=>{const g=G[f];return g?.isError?!Ot(g.error):!1}),[x,G]),{criteria:fe,residual:$}=a.useMemo(()=>ao(C,F,D,S==="all"?void 0:S),[C,F,D,S]),dt=a.useMemo(()=>C==="all"?[...qt]:[C],[C]),ve=a.useMemo(()=>({...fe,query:w,...C==="all"?{}:{category:[C]}}),[fe,w,C]),be=io({residual:$,attributes:F}),{sections:V,isLoading:ut,isError:ft,refetch:Se}=Ys({categories:y?mo:dt,criteria:fe,limit:C==="all"?Jt:uo,counted:be}),{rows:Te,isLoading:mt,isError:ht,refetch:Ce}=Js(ve,fo,y),me=y?mt:ut,we=y?ht:ft,Re=a.useCallback(()=>{if(y){Ce();return}Se()},[y,Ce,Se]),Me=a.useMemo(()=>ro(F),[F]),Y=a.useCallback(o=>Bs(o).map(_t).filter(f=>Dt(f,Me)&&Pt(f,$)),[Me,$]),J=a.useMemo(()=>V.map(o=>({category:o.category,total:o.total,atCap:o.atCap,loading:o.loading,failed:o.failed,rows:Y(o.rows)})),[V,Y]),Z=a.useMemo(()=>Y(Te),[Te,Y]),gt=a.useCallback(o=>{V.find(f=>f.category===o)?.retry()},[V]),k=a.useMemo(()=>y?Z:J.flatMap(o=>o.rows),[y,Z,J]),pt=a.useMemo(()=>Ft(c),[c]),je=to({criteria:ve,junkMailboxIds:pt,enabled:be&&vs({hasSearchQuery:y,freeText:w,residualTokenCount:$.length})}),{spamIds:he,briefSpamOffer:X}=a.useMemo(()=>{const o={spamIds:void 0,briefSpamOffer:void 0};if(!w)return o;const f=k.map(O=>_e(O,c)),{spam:g}=Qt(f),B=new Map;for(const O of g)O.mailboxId&&B.set(O.mailboxId,(B.get(O.mailboxId)??0)+1);const te=lo(je,{pageRowsByMailbox:B});return g.length===0&&!te?o:{spamIds:g.length>0?new Set(g.map(O=>O.id)):void 0,briefSpamOffer:te}},[k,w,c,je]),ke=a.useMemo(()=>{const o=f=>he===void 0?f:f.filter(g=>!he.has(g.id));return y?[{id:"matches",threads:o(Z)}]:zt(J.map(f=>({...f,rows:o(f.rows)})))},[y,Z,J,he]),Ee=a.useCallback((o,f)=>{const g=k.find(B=>B.id===o)?.threadId;g&&s?.({threadId:g,messageId:o},f)},[k,s]),xt=a.useCallback(o=>{const f=o.threadId??k.find(g=>g.id===o.id)?.threadId;f&&s?.({threadId:f,messageId:o.id})},[k,s]),ge=a.useMemo(()=>x.length<=1?[]:[{id:"all",label:"All",active:S==="all"},...x.map(o=>({id:o.accountId,label:o.email.split("@")[0]??o.email,count:K.get(o.accountId),active:S===o.accountId}))],[x,K,S]),z=a.useMemo(()=>e.filter(o=>o.muted?.value).length,[e]),It=a.useMemo(()=>Array.from(K.values()).reduce((o,f)=>o+f,0),[K]),pe=a.useMemo(()=>x.map(o=>o.accountId),[x]),{hasNewMail:Oe}=Ts(),{state:Fe,errorMessage:Ae,refresh:Ne}=Cs(pe,{onSettled:()=>Re()}),yt=a.useMemo(()=>r.jsx(ws,{state:Fe,onRefresh:Ne,label:"Refresh daily brief",errorMessage:Ae,hasUpdate:Oe(pe)}),[Fe,Ne,Ae,Oe,pe]),vt=a.useMemo(()=>k.map(o=>_e(o,c)),[k,c]),bt=a.useMemo(()=>{const o=Wt(ge.map(f=>({id:f.id,label:f.label,count:f.count,active:f.active})));return{categories:o.categories,filters:o.filters,sources:o.sources,sourcesNote:z>0?`+${z} muted`:void 0,selectedCategory:Q,activeFilters:P,expanded:le,onExpandedChange:M,onSelectCategory:f=>j(f),onSelectSource:A,onToggleFilter:f=>I(f),onClear:ue}},[ge,z,Q,P,le,I,j,ue]),Be=ke.length===0&&S==="all"&&w.length===0&&D.length===0,St=a.useMemo(()=>x.map(o=>o.accountId),[x]),Tt=a.useMemo(()=>x.some(o=>Rs(o.syncPhase)),[x]),ee=Ms(St,Be||Tt),Le=r.jsxs("div",{className:"h-full overflow-y-auto",children:[r.jsx(Ue,{}),r.jsx(Ue,{})]}),qe=!me&&!we&&!Be,Ct=Ht({tier:p,hasLiveInput:E,hasCommittedQuery:m.trim().length>0,bodyRendersCommittedResults:!0}),wt=qe?r.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[X&&r.jsx(Ut,{count:X.count,onScopeToSpam:()=>L(X.mailboxId,m)}),r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(Gt,{sections:ke,briefCategory:Q,Row:Kt,selectedThreadId:t,onSelectThread:Ee,onShowAllSection:de,onRetrySection:gt,flat:y,onSelectBriefCategory:j,sources:ge,sourcesNote:z>0?`+${z} muted`:void 0,onSelectSource:A,activeFilters:P,onToggleFilter:I,onClearFilters:ue})})]}):me?Le:we?r.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 py-12 text-sm text-fg-muted",children:[r.jsx(Ke,{className:"size-8 text-danger"}),r.jsx("p",{children:"Couldn't load your messages"}),r.jsxs("button",{type:"button",onClick:()=>Re(),className:"flex items-center gap-1 text-accent underline text-xs",children:[r.jsx(qs,{className:"size-3.5"}),"Try again"]})]}):ee.resolved?r.jsx(_s,{sync:ee.syncing?{synced:ee.synced,total:ee.total}:void 0}):Le;return r.jsx($t,{hasSheet:qe&&!Ct,children:r.jsx(Vt,{selectedMessageId:t,rows:k,onOpen:Ee,onDeleteMessages:d,onSelectionVerb:b.start,commandsRef:n,onTriageContextChange:i,children:r.jsx(po,{wizard:b,header:{title:"Daily brief",unreadCount:It,footer:v?r.jsx(Yt,{}):void 0,searchFilter:bt,searchResults:vt,searchLoading:me,onSelectSearchResult:xt,spamOffer:X,searchResultsInBody:!0,refreshControl:yt},rows:k,children:r.jsxs("div",{className:"flex h-full flex-col",children:[lt.map(o=>r.jsx(ho,{accountEmail:o.email,accountId:o.accountId},o.accountId)),r.jsx("div",{className:"min-h-0 flex-1",children:wt})]})})})})}const it=a.createContext(null);function ce(){const e=a.useContext(it);if(!e)throw new Error("BriefPane.* must be used inside <BriefPane>");return e}function Io({thread:e,children:t}){const s=gs(),n=ps(),i=Ye(),{searchInput:d}=ie(),m=e?.threadId,l=e?.messageId,{data:c}=Ge({...At(),staleTime:6e4}),h=a.useMemo(()=>c?.items??[],[c]),u=a.useMemo(()=>{if(m)return h.find(I=>I.messageId===l)??h.find(I=>I.threadId===m)},[h,m,l]),v=ns(m,l),p=u??v,b=l??p?.messageId,L=a.useMemo(()=>{if(m)return{threadId:m,mailboxId:p?.mailboxId??"",subject:p?.subject,messageId:b,authenticity:p?.authenticity}},[m,p,b]),x=a.useCallback((I,j)=>{s(I,{replace:j?.replace,query:d})},[s,d]),S=a.useCallback(I=>{b&&I.includes(b)&&n()},[b,n]),A=De({thread:p,isOpen:!0,onAfterOptimisticRemove:S}),T=rs(),{deleteMessages:R}=as({mailboxId:p?.mailboxId??"",messages:h,onAfterOptimisticRemove:S}),{toggleReadFor:N}=is({mailboxId:p?.mailboxId??"",messages:h}),q=T.focusedMessageId,M=a.useMemo(()=>h.find(I=>I.messageId===q),[h,q])??p,_=De({thread:M,isOpen:M?.messageId===b}),U=ms(),E=xs(),w=Is(),D=a.useMemo(()=>ys(w,m,b),[w,m,b]),y=a.useMemo(()=>{if(M)return I=>w({threadId:M.threadId,messageId:M.messageId,mode:I})},[w,M]),{nextMessageId:P,previousMessageId:Q}=cs({context:T,orderedIds:T.orderedIds,selectedMessageId:b,enabled:!U&&!E,hasOpenThread:m!==void 0,onClose:n,handlers:{reply:()=>y?.("reply"),replyAll:()=>y?.("reply-all"),forward:()=>y?.("forward"),delete:()=>{T.listCommandsRef.current?.requestVerb("delete")||_.deleteThread()},toggleStar:_.toggleStar,toggleRead:()=>{T.listCommandsRef.current?.requestVerb("markRead")||M&&N([M.messageId],!M.isRead)},goFlagged:()=>i("flagged"),goSettings:()=>i("settings")}}),F=a.useCallback(I=>{if(!I)return;const j=h.find(de=>de.messageId===I);return j?{threadId:j.threadId,messageId:I}:void 0},[h]),C={selectedMessageId:b,selectedThread:p,conversation:L,onOpenThread:x,onCloseThread:n,nextThread:F(P),previousThread:F(Q),actions:A,onReply:D,triage:T,onDeleteMessages:R,handleDeselectIfRemoved:S};return r.jsx(it.Provider,{value:C,children:t})}function ct(){const{selectedMessageId:e,onOpenThread:t,triage:s,onDeleteMessages:n}=ce(),{accounts:i}=ie();return r.jsx(xo,{accounts:i,selectedMessageId:e,onOpenThread:t,commandsRef:s.listCommandsRef,onTriageContextChange:s.onTriageContextChange,onDeleteMessages:n})}function yo(){const e=xe(),{conversation:t,selectedThread:s,actions:n,onReply:i,handleDeselectIfRemoved:d,onOpenThread:m}=ce(),l=!!t,c=us(t?.threadId);return r.jsxs(r.Fragment,{children:[r.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[r.jsx(fs,{hasThread:l,intelligenceOpen:c.isShowing,canToggleIntelligence:c.canToggle,onToggleIntelligence:c.toggle,onReply:i?()=>i("reply"):void 0,onReplyAll:i?()=>i("reply-all"):void 0,onForward:i?()=>i("forward"):void 0,onDelete:l?n.deleteThread:void 0,onToggleStar:l?n.toggleStar:void 0,isStarred:n.isStarred,moveContext:l&&n.accountId&&n.mailboxId?{accountId:n.accountId,currentMailboxId:n.mailboxId,onMove:n.moveThread}:void 0}),r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t?r.jsx($e,{threadId:t.threadId,mailboxId:t.mailboxId,subject:t.subject,selectedMessageId:t.messageId,authenticity:t.authenticity,onOpenIntelligence:c.open,listOnScreen:!0}):r.jsx(Ns,{})})]}),r.jsx(Ve,{isOpen:c.drawerOpen,onClose:c.closeDrawer,thread:s,accountId:s?.accountId,onAfterOptimisticRemove:d,onReplyWithText:e,onOpenThread:m})]})}function vo(){const e=xe(),{selectedThread:t,handleDeselectIfRemoved:s,onOpenThread:n}=ce(),{onToggleIntelligence:i}=ie();return r.jsx(ds,{onClose:i,thread:t,accountId:t?.accountId,onAfterOptimisticRemove:s,onReplyWithText:e,onOpenThread:n})}function bo(){const e=xe(),{selectedThread:t,conversation:s,onOpenThread:n,onCloseThread:i,nextThread:d,previousThread:m,handleDeselectIfRemoved:l}=ce(),c=ls(s?.threadId??null);return s?r.jsxs(r.Fragment,{children:[r.jsx($e,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onBack:i,onOpenIntelligence:c.toggle,onSwipeNext:d?()=>n(d):void 0,onSwipePrevious:m?()=>n(m):void 0,mobileIntelligenceOpen:c.isOpen}),r.jsx(Ve,{isOpen:c.isOpen,onClose:c.close,thread:t,accountId:t?.accountId,onAfterOptimisticRemove:l,onReplyWithText:e,onOpenThread:n})]}):r.jsx("div",{className:"h-full",children:r.jsx(ct,{})})}const _o=Object.assign(Io,{List:ct,Reading:yo,Intelligence:vo,Phone:bo});export{_o as B};
1
+ import{j as r,L as Mt,S as jt,eM as ne,e4 as re,r as a,a as Ge,J as ie,c_ as kt,U as Et,dE as Ot,eN as At,v as Ke,eO as Ft}from"./index-BZ4sAts4.js";import{a5 as Nt,y as Bt,A as Lt,an as qt,ao as _t,ap as Dt,aq as Pt,ar as _e,as as Qt,at as zt,au as Wt,av as Ht,aw as Ut,ag as Gt,M as Kt,aj as $t,ax as Vt,ah as Yt,ay as Jt,az as Zt,f as Xt,p as es,ak as ts,m as ss,S as os,G as ns,K as De,J as rs,H as as,e as is,V as cs,W as xe,X as ls,Z as $e,_ as Ve,$ as ds,a0 as us,a1 as fs}from"./MessageToolbar-D-FLeer4.js";import"./nav-link-BvBkmH1H.js";import{a as ms}from"./useMessageBodyContent-dd-lowbx.js";import{o as hs,e as gs,f as ps}from"./search-token-index-CoqsoQJZ.js";import{d as xs,g as Is,r as ys}from"./reply-D8bLYzum.js";import{u as Ye}from"./sections-B9pteMHc.js";import{u as ae}from"./useQueries-B-X1sW9_.js";import{t as Je,s as vs,r as bs,L as Ss}from"./LabelApplyTrigger-CUfdoyOX.js";import{u as Ts,a as Cs,R as ws,b as Rs,c as Ms}from"./useRefreshControl-DbHCcSXX.js";import{a as js}from"./useLabels-CGCEGKuz.js";import{u as ks}from"./useLayoutTier-CnmLTkLg.js";import{u as Es}from"./useMediaQuery-D3m_n689.js";import{r as Ze,n as Os,o as Xe,w as et,u as As,p as Fs,R as Ns}from"./MessageBody-DbkrLz4x.js";import{d as Bs,w as Ls}from"./wizard-selection-zWa1qc6-.js";import{R as qs}from"./refresh-cw-Dar0XAdp.js";function _s({sync:e}){return e?r.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 py-12 text-center px-4",role:"status","aria-live":"polite",children:[r.jsx(Mt,{className:"size-8 animate-spin text-fg-subtle","aria-hidden":"true"}),r.jsx("p",{className:"text-sm font-medium text-fg",children:"Still syncing your mail"}),r.jsx("p",{className:"text-xs text-fg-subtle",children:Ds(e)})]}):r.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 py-12 text-center px-4",children:[r.jsx(jt,{className:"size-8 text-fg-subtle","aria-hidden":"true"}),r.jsx("p",{className:"text-sm font-medium text-fg",children:"You're caught up"}),r.jsx("p",{className:"text-xs text-fg-subtle",children:"Nothing needs attention."})]})}function Ds({synced:e,total:t}){return t>0?`${e.toLocaleString()} of ${t.toLocaleString()} messages downloaded. This list fills in as they arrive.`:"Downloading your messages. This list fills in as they arrive."}const tt=[{id:"unread",name:"is",value:"unread"},{id:"attachment",name:"has",value:"attachment"}],st="category",Ps={unclassified:"uncategorized"},H=e=>Os(e).map(t=>t.raw),W=e=>e.join(" "),Ie=e=>{const t=Xe(e);if(t)return tt.find(s=>s.name===t.name&&s.value===t.value.toLowerCase())?.id},ye=e=>{const t=Xe(e);if(!t||t.name!==st)return;const s=t.value.toLowerCase(),n=Ps[s];if(n)return n;if(!(!et(s)||s==="all"))return s},ot=e=>tt.find(t=>t.id===e),nt=e=>ot(e)!==void 0,Qs=e=>{const t=new Set;for(const s of H(e)){const n=Ie(s);n&&t.add(n)}return t},zs=e=>{let t="all";for(const s of H(e)){const n=ye(s);n&&(t=n)}return t},Ws=(e,t)=>{const s=ot(t);if(!s)return;const n=H(e),i=n.filter(d=>Ie(d)!==t);return i.length<n.length?W(i):W([...n,Ze(s.name,s.value)])},Hs=(e,t)=>{const s=H(e).filter(n=>!ye(n));return W(t==="all"?s:[...s,Ze(st,t)])},Us=e=>W(H(e).filter(t=>!Ie(t)&&!ye(t))),rt=e=>e.trim().length>0,Pe=e=>{if(!rt(e.query))return e.ownFilters;const t=new Set(Qs(e.query));for(const s of e.ownFilters)nt(s)||t.add(s);return t},Qe=e=>rt(e.query)?zs(e.query):e.ownCategory,ze=6e4,Gs=3e4,Ks={kind:"unknown"},We=e=>(t,s)=>Nt(s?.queryKey,e)?t:void 0,$s=(e,t,s)=>({...e,category:[t],limit:s,order:"desc"}),Vs=(e,t)=>({...e,category:[t],order:"desc",count:!0,results:!1}),He=(e,t)=>({category:[t],...e.unread!==void 0?{unread:e.unread}:{},...e.starred!==void 0?{starred:e.starred}:{},...e.attachments!==void 0?{attachments:e.attachments}:{},...e.accountId!==void 0?{accountId:e.accountId}:{},...e.muted!==void 0?{muted:e.muted}:{}});function Ys({categories:e,criteria:t,limit:s,counted:n}){const i=ae({queries:e.map(c=>{const h=$s(t,c,s),u=He(t,c);return{queryKey:re({query:h}),queryFn:async()=>{const{data:v}=await ne({query:h,throwOnError:!0});return v},placeholderData:We(u),staleTime:ze}})}),d=ae({queries:e.map(c=>{const h=Vs(t,c),u=He(t,c);return{queryKey:re({query:h}),queryFn:async()=>{const{data:v}=await ne({query:h,throwOnError:!0});return v},enabled:n,placeholderData:We(u),staleTime:ze}})}),m=a.useMemo(()=>e.map((c,h)=>{const u=i[h],v=d[h],p=u?.data?.items??[];return{category:c,rows:p,atCap:p.length>=s,total:n?Je(v?.data?.count):Ks,loading:u?.isPending??!0,failed:u?.isError??!1,retry:()=>{u?.refetch(),n&&v?.refetch()}}}),[e,i,d,n,s]),l=a.useCallback(()=>{for(const c of i)c.refetch();for(const c of d)c.refetch()},[i,d]);return{sections:m,isLoading:i.length>0&&i.every(c=>c.isPending),isError:i.length>0&&i.every(c=>c.isError),refetch:l}}function Js(e,t,s){const n={...e,limit:t,order:"desc"},{data:i,isLoading:d,isError:m,refetch:l}=Ge({queryKey:re({query:n}),queryFn:async()=>{const{data:h}=await ne({query:n,throwOnError:!0});return h},enabled:s,staleTime:Gs});return{rows:a.useMemo(()=>s?i?.items??[]:[],[i,s]),isLoading:s&&d,isError:s&&m,refetch:a.useCallback(()=>{l()},[l])}}const Zs=3e4,Xs={kind:"unknown"},eo=(e,t)=>({...e,mailboxId:t,order:"desc",count:!0,results:!1});function to({criteria:e,junkMailboxIds:t,enabled:s}){const n=ae({queries:t.map(i=>{const d=eo(e,i);return{queryKey:re({query:d}),queryFn:async()=>{const{data:m}=await ne({query:d,throwOnError:!0});return m},enabled:s,staleTime:Zs}})});return a.useMemo(()=>t.map((i,d)=>({mailboxId:i,count:s?Je(n[d]?.data?.count):Xs,failed:s?n[d]?.isError??!1:!1})),[t,n,s])}const so=(e,t)=>e.createdAt!==t.createdAt?e.createdAt-t.createdAt:e.accountId.localeCompare(t.accountId),oo=e=>[...e].sort(so),no=["from","subject","category","unread","starred","attachments"],at=["contacts","today"],ro=e=>new Set(at.filter(t=>e.has(t))),ao=(e,t,s,n)=>{const i=Bt({category:e,attributes:t}),{params:d,residual:m}=Lt(s,i,no),l={...d,...i},c={muted:!1};return l.from!==void 0&&(c.from=l.from),l.subject!==void 0&&(c.subject=l.subject),l.unread!==void 0&&(c.unread=l.unread),l.starred!==void 0&&(c.starred=l.starred),l.attachments!==void 0&&(c.attachments=l.attachments),n!==void 0&&(c.accountId=n),{criteria:c,residual:m}},io=({residual:e,attributes:t})=>e.length===0&&!at.some(s=>t.has(s)),se=e=>e.count.kind==="exact"&&e.count.value>0?3:e.pageRows>0?2:e.count.kind==="unknown"?1:0,oe=e=>e.count.kind==="exact"?e.count.value:0,co=(e,t)=>se(e)!==se(t)?se(e)>se(t):oe(e)!==oe(t)?oe(e)>oe(t):e.pageRows>t.pageRows;function lo(e,{pageRowsByMailbox:t}){const s=e.map(u=>({...u,pageRows:t.get(u.mailboxId)??0}));for(const[u,v]of t)v<=0||s.some(p=>p.mailboxId===u)||s.push({mailboxId:u,count:{kind:"unknown"},failed:!1,pageRows:v});const n=s[0];if(!n)return;let i=0,d=!0,m=n;for(const u of s)u.count.kind==="unknown"?d=!1:i+=u.count.value,co(u,m)&&(m=u);const l=s.some(u=>u.pageRows>0),c=s.some(u=>u.failed);if(i===0&&!l&&(d||!c))return;const h=d&&i===0&&l;return{mailboxId:m.mailboxId,count:d&&!h?{kind:"exact",value:i}:{kind:"unknown"}}}const uo=50,fo=200,mo=[],Ue=()=>r.jsx("div",{className:"animate-pulse",children:Array.from({length:3}).map((e,t)=>r.jsxs("div",{className:"flex items-start gap-3 py-2 pl-5 pr-4 border-b border-line",children:[r.jsx("div",{className:"size-7 rounded-full bg-surface-sunken shrink-0 mt-0.5"}),r.jsxs("div",{className:"flex-1 space-y-1.5",children:[r.jsxs("div",{className:"flex justify-between gap-2",children:[r.jsx("div",{className:"h-3.5 bg-surface-sunken rounded w-28"}),r.jsx("div",{className:"h-3 bg-surface-sunken rounded w-12"})]}),r.jsx("div",{className:"h-3.5 bg-surface-sunken rounded w-48"}),r.jsx("div",{className:"h-3 bg-surface-sunken rounded w-full"})]})]},t))}),ho=({accountEmail:e})=>{const t=Ye();return r.jsxs("div",{className:"flex items-center gap-2 px-row-inset py-2 border-b border-line bg-danger-soft/40 text-xs text-danger",children:[r.jsx(Ke,{className:"size-3.5 shrink-0"}),r.jsxs("span",{className:"flex-1 truncate",children:[e," can't connect"]}),r.jsx("button",{type:"button",onClick:()=>t("accounts"),className:"shrink-0 underline text-danger hover:opacity-80",children:"Reconnect"})]})},go=(e,t)=>{if(t.size===0)return{};const s=e.filter(d=>t.has(d.id)),n=bs(s.map(d=>d.accountId));if(n.restriction)return n;const i=new Set;for(const d of s)d.mailboxId&&i.add(d.mailboxId);return i.size>1?{accountId:n.accountId,restriction:"spansFolders",moveDisabledHint:`Move only works within one folder — this selection spans ${i.size} folders`}:{accountId:n.accountId,mailboxId:i.size===1?[...i][0]:void 0}};function po({header:e,rows:t,wizard:s,children:n}){const{selectedIds:i,selectedCount:d,exitSelection:m,orderedIds:l,allSelected:c,toggleAllLoaded:h}=Zt(),u=a.useMemo(()=>go(t,i),[t,i]),{junkMailboxId:v}=Xt(u.accountId),{labels:p}=js(u.accountId),b=a.useMemo(()=>Array.from(i),[i]),L=a.useMemo(()=>Ls(t,i),[t,i]),x=es(v,u.mailboxId),S=a.useMemo(()=>l.length>0?{checked:c,indeterminate:d>0&&!c,onChange:h}:void 0,[l.length,c,d,h]),F=u.moveDisabledHint?{tone:"warning",text:u.moveDisabledHint}:void 0,T=R=>r.jsx(os,{title:R.title,navSlot:R.navSlot,titleMeta:R.titleMeta,searchSlot:R.searchSlot,searchField:R.searchField,idleSlot:R.makeFilterSlot,count:d,onCancel:m,onDelete:()=>s.start("delete"),onMove:()=>s.start("move"),onOrganize:()=>s.start("organize"),onJunk:x?()=>s.start("junk"):void 0,onMarkRead:()=>s.start("markRead"),overflowSlot:u.accountId&&u.mailboxId&&d>0&&p.length>0?r.jsx(Ss,{accountId:u.accountId,mailboxId:u.mailboxId,messageIds:b}):void 0,selectAll:S,notice:F});return r.jsx(ts,{...e,selectionBar:T,paneOverlay:r.jsx(ss,{verb:s.verb,accountId:u.accountId,mailboxId:u.mailboxId,selection:L,selectionRestriction:u.restriction,onFinished:m}),children:n})}function xo({accounts:e,selectedMessageId:t,onOpenThread:s,commandsRef:n,onTriageContextChange:i,onDeleteMessages:d}){const{searchQuery:m,searchInput:l,resultFolderIndex:c,onSearchChange:h}=ie(),u=As(),v=Es(),p=ks(),b=kt(),L=hs(),x=a.useMemo(()=>oo(e.filter(o=>!o.muted?.value)),[e]),[S,F]=a.useState("all"),[T,R]=a.useState("all"),[N,q]=a.useState(new Set),[le,M]=a.useState(!1),_=a.useCallback(o=>{q(f=>{const g=new Set(f);return g.has(o)?g.delete(o):g.add(o),g})},[]),U=a.useCallback(()=>q(new Set),[]),E=l.trim().length>0,{freeText:w,tokens:D}=Fs(m.trim().toLowerCase(),u),y=w.length>0,P=a.useMemo(()=>Pe({query:l,ownFilters:N}),[l,N]),Q=a.useMemo(()=>Qe({query:l,ownCategory:T}),[l,T]),A=a.useMemo(()=>Pe({query:m,ownFilters:N}),[m,N]),C=a.useMemo(()=>Qe({query:m,ownCategory:T}),[m,T]),I=a.useCallback(o=>{if(!E||!nt(o)){_(o);return}const f=Ws(l,o);f!==void 0&&h(f)},[E,l,h,_]),j=a.useCallback(o=>{if(!E){R(o);return}h(Hs(l,o))},[E,l,h]),de=a.useMemo(()=>C==="all"&&!y?o=>{et(o)&&j(o)}:void 0,[C,y,j]),ue=a.useCallback(()=>{R("all"),F("all"),U(),E&&h(Us(l))},[E,l,h,U]),G=ae({queries:x.map(o=>({...Et({path:{accountId:o.accountId}}),staleTime:1/0,meta:{softError:!0}}))}),K=a.useMemo(()=>{const o=new Map;for(let f=0;f<x.length;f++){const g=x[f].accountId,te=(G[f]?.data?.items??[]).reduce((O,Rt)=>O+(Rt.unseenCount??0),0);o.set(g,te)}return o},[x,G]),lt=a.useMemo(()=>x.filter((o,f)=>{const g=G[f];return g?.isError?!Ot(g.error):!1}),[x,G]),{criteria:fe,residual:$}=a.useMemo(()=>ao(C,A,D,S==="all"?void 0:S),[C,A,D,S]),dt=a.useMemo(()=>C==="all"?[...qt]:[C],[C]),ve=a.useMemo(()=>({...fe,query:w,...C==="all"?{}:{category:[C]}}),[fe,w,C]),be=io({residual:$,attributes:A}),{sections:V,isLoading:ut,isError:ft,refetch:Se}=Ys({categories:y?mo:dt,criteria:fe,limit:C==="all"?Jt:uo,counted:be}),{rows:Te,isLoading:mt,isError:ht,refetch:Ce}=Js(ve,fo,y),me=y?mt:ut,we=y?ht:ft,Re=a.useCallback(()=>{if(y){Ce();return}Se()},[y,Ce,Se]),Me=a.useMemo(()=>ro(A),[A]),Y=a.useCallback(o=>Bs(o).map(_t).filter(f=>Dt(f,Me)&&Pt(f,$)),[Me,$]),J=a.useMemo(()=>V.map(o=>({category:o.category,total:o.total,atCap:o.atCap,loading:o.loading,failed:o.failed,rows:Y(o.rows)})),[V,Y]),Z=a.useMemo(()=>Y(Te),[Te,Y]),gt=a.useCallback(o=>{V.find(f=>f.category===o)?.retry()},[V]),k=a.useMemo(()=>y?Z:J.flatMap(o=>o.rows),[y,Z,J]),pt=a.useMemo(()=>At(c),[c]),je=to({criteria:ve,junkMailboxIds:pt,enabled:be&&vs({hasSearchQuery:y,freeText:w,residualTokenCount:$.length})}),{spamIds:he,briefSpamOffer:X}=a.useMemo(()=>{const o={spamIds:void 0,briefSpamOffer:void 0};if(!w)return o;const f=k.map(O=>_e(O,c)),{spam:g}=Qt(f),B=new Map;for(const O of g)O.mailboxId&&B.set(O.mailboxId,(B.get(O.mailboxId)??0)+1);const te=lo(je,{pageRowsByMailbox:B});return g.length===0&&!te?o:{spamIds:g.length>0?new Set(g.map(O=>O.id)):void 0,briefSpamOffer:te}},[k,w,c,je]),ke=a.useMemo(()=>{const o=f=>he===void 0?f:f.filter(g=>!he.has(g.id));return y?[{id:"matches",threads:o(Z)}]:zt(J.map(f=>({...f,rows:o(f.rows)})))},[y,Z,J,he]),Ee=a.useCallback((o,f)=>{const g=k.find(B=>B.id===o)?.threadId;g&&s?.({threadId:g,messageId:o},f)},[k,s]),xt=a.useCallback(o=>{const f=o.threadId??k.find(g=>g.id===o.id)?.threadId;f&&s?.({threadId:f,messageId:o.id})},[k,s]),ge=a.useMemo(()=>x.length<=1?[]:[{id:"all",label:"All",active:S==="all"},...x.map(o=>({id:o.accountId,label:o.email.split("@")[0]??o.email,count:K.get(o.accountId),active:S===o.accountId}))],[x,K,S]),z=a.useMemo(()=>e.filter(o=>o.muted?.value).length,[e]),It=a.useMemo(()=>Array.from(K.values()).reduce((o,f)=>o+f,0),[K]),pe=a.useMemo(()=>x.map(o=>o.accountId),[x]),{hasNewMail:Oe}=Ts(),{state:Ae,errorMessage:Fe,refresh:Ne}=Cs(pe,{onSettled:()=>Re()}),yt=a.useMemo(()=>r.jsx(ws,{state:Ae,onRefresh:Ne,label:"Refresh daily brief",errorMessage:Fe,hasUpdate:Oe(pe)}),[Ae,Ne,Fe,Oe,pe]),vt=a.useMemo(()=>k.map(o=>_e(o,c)),[k,c]),bt=a.useMemo(()=>{const o=Wt(ge.map(f=>({id:f.id,label:f.label,count:f.count,active:f.active})));return{categories:o.categories,filters:o.filters,sources:o.sources,sourcesNote:z>0?`+${z} muted`:void 0,selectedCategory:Q,activeFilters:P,expanded:le,onExpandedChange:M,onSelectCategory:f=>j(f),onSelectSource:F,onToggleFilter:f=>I(f),onClear:ue}},[ge,z,Q,P,le,I,j,ue]),Be=ke.length===0&&S==="all"&&w.length===0&&D.length===0,St=a.useMemo(()=>x.map(o=>o.accountId),[x]),Tt=a.useMemo(()=>x.some(o=>Rs(o.syncPhase)),[x]),ee=Ms(St,Be||Tt),Le=r.jsxs("div",{className:"h-full overflow-y-auto",children:[r.jsx(Ue,{}),r.jsx(Ue,{})]}),qe=!me&&!we&&!Be,Ct=Ht({tier:p,hasLiveInput:E,hasCommittedQuery:m.trim().length>0,bodyRendersCommittedResults:!0}),wt=qe?r.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[X&&r.jsx(Ut,{count:X.count,onScopeToSpam:()=>L(X.mailboxId,m)}),r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(Gt,{sections:ke,briefCategory:Q,Row:Kt,selectedThreadId:t,onSelectThread:Ee,onShowAllSection:de,onRetrySection:gt,flat:y,onSelectBriefCategory:j,sources:ge,sourcesNote:z>0?`+${z} muted`:void 0,onSelectSource:F,activeFilters:P,onToggleFilter:I,onClearFilters:ue})})]}):me?Le:we?r.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 py-12 text-sm text-fg-muted",children:[r.jsx(Ke,{className:"size-8 text-danger"}),r.jsx("p",{children:"Couldn't load your messages"}),r.jsxs("button",{type:"button",onClick:()=>Re(),className:"flex items-center gap-1 text-accent underline text-xs",children:[r.jsx(qs,{className:"size-3.5"}),"Try again"]})]}):ee.resolved?r.jsx(_s,{sync:ee.syncing?{synced:ee.synced,total:ee.total}:void 0}):Le;return r.jsx($t,{hasSheet:qe&&!Ct,children:r.jsx(Vt,{selectedMessageId:t,rows:k,onOpen:Ee,onDeleteMessages:d,onSelectionVerb:b.start,commandsRef:n,onTriageContextChange:i,children:r.jsx(po,{wizard:b,header:{title:"Daily brief",unreadCount:It,footer:v?r.jsx(Yt,{}):void 0,searchFilter:bt,searchResults:vt,searchLoading:me,onSelectSearchResult:xt,spamOffer:X,searchResultsInBody:!0,refreshControl:yt},rows:k,children:r.jsxs("div",{className:"flex h-full flex-col",children:[lt.map(o=>r.jsx(ho,{accountEmail:o.email,accountId:o.accountId},o.accountId)),r.jsx("div",{className:"min-h-0 flex-1",children:wt})]})})})})}const it=a.createContext(null);function ce(){const e=a.useContext(it);if(!e)throw new Error("BriefPane.* must be used inside <BriefPane>");return e}function Io({thread:e,children:t}){const s=gs(),n=ps(),i=Ye(),{searchInput:d}=ie(),m=e?.threadId,l=e?.messageId,{data:c}=Ge({...Ft(),staleTime:6e4}),h=a.useMemo(()=>c?.items??[],[c]),u=a.useMemo(()=>{if(m)return h.find(I=>I.messageId===l)??h.find(I=>I.threadId===m)},[h,m,l]),v=ns(m,l),p=u??v,b=l??p?.messageId,L=a.useMemo(()=>{if(m)return{threadId:m,mailboxId:p?.mailboxId??"",subject:p?.subject,messageId:b,authenticity:p?.authenticity}},[m,p,b]),x=a.useCallback((I,j)=>{s(I,{replace:j?.replace,query:d})},[s,d]),S=a.useCallback(I=>{b&&I.includes(b)&&n()},[b,n]),F=De({thread:p,isOpen:!0,onAfterOptimisticRemove:S}),T=rs(),{deleteMessages:R}=as({mailboxId:p?.mailboxId??"",messages:h,onAfterOptimisticRemove:S}),{toggleReadFor:N}=is({mailboxId:p?.mailboxId??"",messages:h}),q=T.focusedMessageId,M=a.useMemo(()=>h.find(I=>I.messageId===q),[h,q])??p,_=De({thread:M,isOpen:M?.messageId===b}),U=ms(),E=xs(),w=Is(),D=a.useMemo(()=>ys(w,m,b),[w,m,b]),y=a.useMemo(()=>{if(M)return I=>w({threadId:M.threadId,messageId:M.messageId,mode:I})},[w,M]),{nextMessageId:P,previousMessageId:Q}=cs({context:T,orderedIds:T.orderedIds,selectedMessageId:b,enabled:!U&&!E,hasOpenThread:m!==void 0,onClose:n,handlers:{reply:()=>y?.("reply"),replyAll:()=>y?.("reply-all"),forward:()=>y?.("forward"),delete:()=>{T.listCommandsRef.current?.requestVerb("delete")||_.deleteThread()},toggleStar:_.toggleStar,toggleRead:()=>{T.listCommandsRef.current?.requestVerb("markRead")||M&&N([M.messageId],!M.isRead)},goFlagged:()=>i("flagged"),goSettings:()=>i("settings")}}),A=a.useCallback(I=>{if(!I)return;const j=h.find(de=>de.messageId===I);return j?{threadId:j.threadId,messageId:I}:void 0},[h]),C={selectedMessageId:b,selectedThread:p,conversation:L,onOpenThread:x,onCloseThread:n,nextThread:A(P),previousThread:A(Q),actions:F,onReply:D,triage:T,onDeleteMessages:R,handleDeselectIfRemoved:S};return r.jsx(it.Provider,{value:C,children:t})}function ct(){const{selectedMessageId:e,onOpenThread:t,triage:s,onDeleteMessages:n}=ce(),{accounts:i}=ie();return r.jsx(xo,{accounts:i,selectedMessageId:e,onOpenThread:t,commandsRef:s.listCommandsRef,onTriageContextChange:s.onTriageContextChange,onDeleteMessages:n})}function yo(){const e=xe(),{conversation:t,selectedThread:s,actions:n,onReply:i,handleDeselectIfRemoved:d,onOpenThread:m}=ce(),l=!!t,c=us(t?.threadId);return r.jsxs(r.Fragment,{children:[r.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[r.jsx(fs,{hasThread:l,intelligenceOpen:c.isShowing,canToggleIntelligence:c.canToggle,onToggleIntelligence:c.toggle,onReply:i?()=>i("reply"):void 0,onReplyAll:i?()=>i("reply-all"):void 0,onForward:i?()=>i("forward"):void 0,onDelete:l?n.deleteThread:void 0,onToggleStar:l?n.toggleStar:void 0,isStarred:n.isStarred,moveContext:l&&n.accountId&&n.mailboxId?{accountId:n.accountId,currentMailboxId:n.mailboxId,onMove:n.moveThread}:void 0}),r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t?r.jsx($e,{threadId:t.threadId,mailboxId:t.mailboxId,subject:t.subject,selectedMessageId:t.messageId,authenticity:t.authenticity,onOpenIntelligence:c.open,listOnScreen:!0}):r.jsx(Ns,{})})]}),r.jsx(Ve,{isOpen:c.drawerOpen,onClose:c.closeDrawer,thread:s,accountId:s?.accountId,onAfterOptimisticRemove:d,onReplyWithText:e,onOpenThread:m})]})}function vo(){const e=xe(),{selectedThread:t,handleDeselectIfRemoved:s,onOpenThread:n}=ce(),{onToggleIntelligence:i}=ie();return r.jsx(ds,{onClose:i,thread:t,accountId:t?.accountId,onAfterOptimisticRemove:s,onReplyWithText:e,onOpenThread:n})}function bo(){const e=xe(),{selectedThread:t,conversation:s,onOpenThread:n,onCloseThread:i,nextThread:d,previousThread:m,handleDeselectIfRemoved:l}=ce(),c=ls(s?.threadId??null);return s?r.jsxs(r.Fragment,{children:[r.jsx($e,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onBack:i,onOpenIntelligence:c.toggle,onSwipeNext:d?()=>n(d):void 0,onSwipePrevious:m?()=>n(m):void 0,mobileIntelligenceOpen:c.isOpen}),r.jsx(Ve,{isOpen:c.isOpen,onClose:c.close,thread:t,accountId:t?.accountId,onAfterOptimisticRemove:l,onReplyWithText:e,onOpenThread:n})]}):r.jsx("div",{className:"h-full",children:r.jsx(ct,{})})}const _o=Object.assign(Io,{List:ct,Reading:yo,Intelligence:vo,Phone:bo});export{_o as B};
@@ -1 +1 @@
1
- import{r as t,eV as Ze,c4 as Fe,j as v,em as we}from"./index-Bn8n_AsE.js";import{c as xe,m as Ne,d as Oe,t as Be,p as je}from"./draft-QkjvtbSZ.js";import{b as le,e as fe,f as oe,p as Ae,U as me,c as ge,s as ze,i as Ge}from"./useCalendarSuggestions-Bb4PGHae.js";import{c as Qe,r as Le,s as Pe,t as Ue,R as Ve}from"./useCalendarData-RUYA8D_t.js";import{u as pe,b as ve}from"./useCalendarScheduling-CO3VOpcB.js";import{f as We}from"./calendar-format-BwCpz-JZ.js";import"./nav-link-CtuHya9S.js";import{a as ye,j as qe,b as ie,i as He}from"./calendar-BJu4Vl-g.js";import"./reply-DmpF7cgR.js";import{e as $e}from"./CalendarQuickCreate-_ki0X3rq.js";import{u as x}from"./CalendarSession-CK-EC1yK.js";import{C as Se}from"./calendar-event-sidebar-DZum-8WN.js";import{C as Je}from"./confirm-dialog-sa45Xnmn.js";import{s as _e}from"./calendar-guests-Diti9JO5.js";import{a as Ke}from"./calendar-event-popup-B4-Dpgb6.js";const he="This calendar changed while you were writing. Close the form and try again.",be=Intl.supportedValuesOf("timeZone"),Me=(e,n)=>e.date===n.date&&e.endDate===n.endDate&&e.startTime===n.startTime&&e.endTime===n.endTime&&e.allDay===n.allDay,$=e=>({date:e.date,endDate:e.endDate,startTime:e.allDay?"":e.startTime,endTime:e.allDay?"":e.endTime,allDay:e.allDay}),Ce=e=>e?"Opaque":"Transparent";function Ye(e,n){const{carriedFocus:l}=x(),f=t.useRef(!1);t.useEffect(()=>{if(!n||f.current)return;f.current=!0;const o=l.current;l.current="",((o===""?null:document.querySelector(`[data-event-sidebar] [aria-label="${CSS.escape(o)}"]`))??e.current)?.focus()},[l,e,n])}function Ee(e){const{requestClose:n}=x(),{closeToView:l}=ie(),[f,o]=t.useState(!1),y=t.useRef(!1);He(e&&!f,()=>y.current?!1:(o(!0),!0));const b=()=>{if(e){o(!0);return}l()},R=t.useRef(b);return R.current=b,t.useEffect(()=>(n.current=()=>R.current(),()=>{n.current=null}),[n]),{close:b,confirm:v.jsx(Je,{isOpen:f,title:"Discard draft?",description:"Your event has unsaved changes. Are you sure you want to discard them?",confirmLabel:"Discard",cancelLabel:"Keep editing",destructive:!0,onConfirm:()=>{y.current=!0,o(!1),l()},onCancel:()=>o(!1)}),leave:()=>{y.current=!0,l()}}}function vt(){const{session:e,dispatch:n,focusSaved:l}=x(),{date:f}=ye(),o=qe(),{setNewEventBounds:y}=ie(),{calendars:b,defaultCalendarId:R,timeZoneByCalendarId:j}=le(),C=b.filter(s=>!s.readOnly),{createEvent:A,isWriting:J}=fe(),{senders:z,defaultSenderId:_}=pe(),[K,M]=t.useState(),[G,Y]=t.useState(""),X=ve(G),{trackSends:ee}=x(),Q=t.useRef(null),L=t.useRef(null),E=oe(),[g,T]=t.useState({notes:"",repeat:"",timeZone:E,busy:!0}),[P,N]=t.useState(""),[O,a]=t.useState(),[i]=t.useState(()=>e.mode==="sidebar"?e.draft:void 0),m=Ze(o?.start,o?.end,f,E);t.useEffect(()=>{e.mode!=="sidebar"&&n({type:"sidebar-range",range:m})},[e.mode,n,m]);const d=e.mode==="sidebar"?e.draft:void 0,r=d?.range;t.useEffect(()=>{if(!r)return;const s=Fe(r,E);s.start===o?.start&&s.end===o?.end||y(s)},[r,o,E,y]),Ye(Q,e.mode==="sidebar"),t.useEffect(()=>{O&&L.current?.focus()},[O]);const I=C.find(s=>s.id===R)?.id??C[0]?.id??"";t.useEffect(()=>{d?.calendarId!==""||I===""||n({type:"change",draft:{...d,calendarId:I}})},[d,I,n]);const k=d!==void 0&&(g.notes!==""||g.repeat!==""||!g.busy||d.title!==(i?.title??"")||d.location!==(i?.location??"")||d.guests.length!==(i?.guests.length??0)),{close:U,confirm:Z,leave:te}=Ee(k);if(!d)return null;const V=K??_??C.find(s=>s.id===d.calendarId)?.accountId??"",F={...$e(d),notes:g.notes,repeat:g.repeat},W=()=>{const s=g.timeZone,u=xe(F,{clock:s,anchor:s!==E?s:Ae(j[d.calendarId]??me)},V);if(!u.ok){N(u.problem);return}N(""),a(void 0),A({...u.input,transparency:Ce(g.busy)}).then(S=>{if(S.kind==="created"){n({type:"saved"}),ee(S.sends),l(S.calendarObjectId),te();return}const p=S.kind==="conflict"?he:`Couldn't save this event: ${S.message}`;a({text:p,reportHref:ge(p),onRetry:W})})};return v.jsxs(v.Fragment,{children:[v.jsx(Se,{heading:"New event",draft:F,onChange:s=>{n({type:"change",draft:{range:$(s),title:s.title,location:s.location,calendarId:s.calendarId,guests:s.guests}}),T(u=>({...u,notes:s.notes,repeat:s.repeat}))},calendars:C,calendarEditable:!0,repeatEditable:!0,timeZone:g.timeZone,timeZones:be,onTimeZone:s=>T(u=>({...u,timeZone:s})),busy:g.busy,onBusy:s=>T(u=>({...u,busy:s})),guests:{suggestions:X,onQuery:Y,senders:z,sender:V,onSender:M,senderEditable:!0},onSave:W,onCancel:U,saving:J,problem:P,failure:O,failureRef:L,titleRef:Q}),Z]})}function yt({calendarObjectId:e,recurrenceId:n}){const{session:l,dispatch:f,focusSaved:o}=x(),{view:y,date:b,calendarIds:R}=ye(),{events:j,isLoading:C,freeIds:A}=Qe({view:y,date:b,calendarIds:R}),{calendars:J,timeZoneByCalendarId:z}=le(),{closeToView:_}=ie(),{updateEvent:K,isWriting:M}=fe(),{senders:G,defaultSenderId:Y}=pe(),[X,ee]=t.useState(),[Q,L]=t.useState(""),E=ve(Q),{trackSends:g}=x(),T=t.useRef(null),P=t.useRef(null),N=t.useId(),O=Ge(e,n??""),a=j.find(c=>c.id===O),{resource:i}=ze(e,a?.calendarId??""),[m,d]=t.useState(),[r,I]=t.useState(),[k,U]=t.useState(!0),[Z,te]=t.useState(oe()),[V,F]=t.useState(!1),[W,s]=t.useState(""),[u,S]=t.useState();t.useEffect(()=>{if(m||!a||!i)return;const c=Le(i.icalData),h=Pe(i.icalData,z[a.calendarId]??me),B=a.allDay?"":a.start.slice(11,16),re=a.allDay?c:Ne(c,we(a.start,h===""?"UTC":h).slice(0,10),a.start.slice(0,10)),D=Ue(i.icalData),w=Oe(a,{repeat:c===""?"":Be(re,B)??"Repeats",location:D.location,notes:D.description,guests:i.attendees.filter(H=>H.role==="Guest").map(H=>_e(H.email,H.displayName))}),ue=!A.has(a.id);d({draft:w,busy:ue,anchor:h}),I(w),U(ue),f({type:"sidebar-range",range:$(w)})},[m,a,i,A,z,f]);const p=l.mode==="sidebar"?l.draft.range:void 0;t.useEffect(()=>{!p||!r||Me(p,$(r))||I({...r,date:p.date,endDate:p.endDate,startTime:p.startTime,endTime:p.endTime,allDay:p.allDay})},[p,r]);const ce=r!==void 0;t.useEffect(()=>{ce&&T.current?.focus()},[ce]),t.useEffect(()=>{u&&P.current?.focus()},[u]);const Ie=m!==void 0&&r!==void 0&&(JSON.stringify(m.draft)!==JSON.stringify(r)||k!==m.busy),{close:De,confirm:Re,leave:Te}=Ee(Ie);if(!C&&a===void 0)return v.jsx("section",{className:"flex h-full flex-col bg-surface","aria-labelledby":N,children:v.jsx(Ke,{headingId:N,onClose:_})});if(!a||!m||!r)return null;const se=J.find(c=>c.id===a.calendarId),de=a.seriesId!==""&&n!==void 0,q=i?.organizer??"",ke=i!==void 0&&(i.participation==="Organizer"||i.participation==="Unscheduled"&&q===""),ne=G.find(c=>c.email===q)?.accountId??X??Y??se?.accountId??"",ae=c=>{F(!1);const h=je(m.draft,r,{clock:Z,anchor:Z!==oe()?Z:m.anchor});if(!h.ok){s(h.problem);return}s(""),S(void 0);const B=k!==m.busy?{...h.patch,transparency:Ce(k)}:h.patch,re=B.attendees!==void 0&&q===""&&ne!==""?{...B,organizerAccountId:ne}:B;K({calendarObjectId:e,calendarId:a.calendarId,recurrenceId:n??"",scope:c,etag:i?.etag??""},re).then(D=>{if(D.kind==="written"){f({type:"saved"}),g(D.sends),o(e),Te();return}const w=D.kind==="conflict"?he:`Couldn't save this event: ${D.message}`;S({text:w,reportHref:ge(w),onRetry:()=>ae(c)})})};return v.jsxs(v.Fragment,{children:[v.jsx(Se,{heading:"Edit event",draft:r,onChange:c=>{I(c),f({type:"sidebar-range",range:$(c)})},calendars:se?[se]:[],calendarEditable:!1,repeatEditable:!de,timeZone:Z,timeZones:be,onTimeZone:te,busy:k,onBusy:U,guests:ke?{suggestions:E,onQuery:L,senders:G,sender:ne,onSender:ee,senderEditable:q===""}:void 0,onSave:()=>de?F(!0):ae(void 0),onCancel:De,saving:M,problem:W,failure:u,failureRef:P,titleRef:T,children:V&&v.jsx(Ve,{title:a.title,ruleText:r.repeat===""?"It repeats":r.repeat,instanceText:We(a),onChoose:ae,onCancel:()=>F(!1)})}),Re]})}export{vt as C,yt as a};
1
+ import{r as t,eV as Ze,c4 as Fe,j as v,em as we}from"./index-BZ4sAts4.js";import{c as xe,m as Ne,d as Oe,t as Be,p as je}from"./draft-0DDwY2Pw.js";import{b as le,e as fe,f as oe,p as Ae,U as me,c as ge,s as ze,i as Ge}from"./useCalendarSuggestions-D58tKJtx.js";import{c as Qe,r as Le,s as Pe,t as Ue,R as Ve}from"./useCalendarData-BKkQY_vQ.js";import{u as pe,b as ve}from"./useCalendarScheduling-D_qd-mRK.js";import{f as We}from"./calendar-format-BwCpz-JZ.js";import"./nav-link-BvBkmH1H.js";import{a as ye,j as qe,b as ie,i as He}from"./calendar-SMIdRsx9.js";import"./reply-D8bLYzum.js";import{e as $e}from"./CalendarQuickCreate-CaYUiVR8.js";import{u as x}from"./CalendarSession-Ql7K56YK.js";import{C as Se}from"./calendar-event-sidebar-CGPuc517.js";import{C as Je}from"./confirm-dialog-B0MVMPmn.js";import{s as _e}from"./calendar-guests-Dt2cjTqc.js";import{a as Ke}from"./calendar-event-popup-DqvJLPWt.js";const he="This calendar changed while you were writing. Close the form and try again.",be=Intl.supportedValuesOf("timeZone"),Me=(e,n)=>e.date===n.date&&e.endDate===n.endDate&&e.startTime===n.startTime&&e.endTime===n.endTime&&e.allDay===n.allDay,$=e=>({date:e.date,endDate:e.endDate,startTime:e.allDay?"":e.startTime,endTime:e.allDay?"":e.endTime,allDay:e.allDay}),Ce=e=>e?"Opaque":"Transparent";function Ye(e,n){const{carriedFocus:l}=x(),f=t.useRef(!1);t.useEffect(()=>{if(!n||f.current)return;f.current=!0;const o=l.current;l.current="",((o===""?null:document.querySelector(`[data-event-sidebar] [aria-label="${CSS.escape(o)}"]`))??e.current)?.focus()},[l,e,n])}function Ee(e){const{requestClose:n}=x(),{closeToView:l}=ie(),[f,o]=t.useState(!1),y=t.useRef(!1);He(e&&!f,()=>y.current?!1:(o(!0),!0));const b=()=>{if(e){o(!0);return}l()},R=t.useRef(b);return R.current=b,t.useEffect(()=>(n.current=()=>R.current(),()=>{n.current=null}),[n]),{close:b,confirm:v.jsx(Je,{isOpen:f,title:"Discard draft?",description:"Your event has unsaved changes. Are you sure you want to discard them?",confirmLabel:"Discard",cancelLabel:"Keep editing",destructive:!0,onConfirm:()=>{y.current=!0,o(!1),l()},onCancel:()=>o(!1)}),leave:()=>{y.current=!0,l()}}}function vt(){const{session:e,dispatch:n,focusSaved:l}=x(),{date:f}=ye(),o=qe(),{setNewEventBounds:y}=ie(),{calendars:b,defaultCalendarId:R,timeZoneByCalendarId:j}=le(),C=b.filter(s=>!s.readOnly),{createEvent:A,isWriting:J}=fe(),{senders:z,defaultSenderId:_}=pe(),[K,M]=t.useState(),[G,Y]=t.useState(""),X=ve(G),{trackSends:ee}=x(),Q=t.useRef(null),L=t.useRef(null),E=oe(),[g,T]=t.useState({notes:"",repeat:"",timeZone:E,busy:!0}),[P,N]=t.useState(""),[O,a]=t.useState(),[i]=t.useState(()=>e.mode==="sidebar"?e.draft:void 0),m=Ze(o?.start,o?.end,f,E);t.useEffect(()=>{e.mode!=="sidebar"&&n({type:"sidebar-range",range:m})},[e.mode,n,m]);const d=e.mode==="sidebar"?e.draft:void 0,r=d?.range;t.useEffect(()=>{if(!r)return;const s=Fe(r,E);s.start===o?.start&&s.end===o?.end||y(s)},[r,o,E,y]),Ye(Q,e.mode==="sidebar"),t.useEffect(()=>{O&&L.current?.focus()},[O]);const I=C.find(s=>s.id===R)?.id??C[0]?.id??"";t.useEffect(()=>{d?.calendarId!==""||I===""||n({type:"change",draft:{...d,calendarId:I}})},[d,I,n]);const k=d!==void 0&&(g.notes!==""||g.repeat!==""||!g.busy||d.title!==(i?.title??"")||d.location!==(i?.location??"")||d.guests.length!==(i?.guests.length??0)),{close:U,confirm:Z,leave:te}=Ee(k);if(!d)return null;const V=K??_??C.find(s=>s.id===d.calendarId)?.accountId??"",F={...$e(d),notes:g.notes,repeat:g.repeat},W=()=>{const s=g.timeZone,u=xe(F,{clock:s,anchor:s!==E?s:Ae(j[d.calendarId]??me)},V);if(!u.ok){N(u.problem);return}N(""),a(void 0),A({...u.input,transparency:Ce(g.busy)}).then(S=>{if(S.kind==="created"){n({type:"saved"}),ee(S.sends),l(S.calendarObjectId),te();return}const p=S.kind==="conflict"?he:`Couldn't save this event: ${S.message}`;a({text:p,reportHref:ge(p),onRetry:W})})};return v.jsxs(v.Fragment,{children:[v.jsx(Se,{heading:"New event",draft:F,onChange:s=>{n({type:"change",draft:{range:$(s),title:s.title,location:s.location,calendarId:s.calendarId,guests:s.guests}}),T(u=>({...u,notes:s.notes,repeat:s.repeat}))},calendars:C,calendarEditable:!0,repeatEditable:!0,timeZone:g.timeZone,timeZones:be,onTimeZone:s=>T(u=>({...u,timeZone:s})),busy:g.busy,onBusy:s=>T(u=>({...u,busy:s})),guests:{suggestions:X,onQuery:Y,senders:z,sender:V,onSender:M,senderEditable:!0},onSave:W,onCancel:U,saving:J,problem:P,failure:O,failureRef:L,titleRef:Q}),Z]})}function yt({calendarObjectId:e,recurrenceId:n}){const{session:l,dispatch:f,focusSaved:o}=x(),{view:y,date:b,calendarIds:R}=ye(),{events:j,isLoading:C,freeIds:A}=Qe({view:y,date:b,calendarIds:R}),{calendars:J,timeZoneByCalendarId:z}=le(),{closeToView:_}=ie(),{updateEvent:K,isWriting:M}=fe(),{senders:G,defaultSenderId:Y}=pe(),[X,ee]=t.useState(),[Q,L]=t.useState(""),E=ve(Q),{trackSends:g}=x(),T=t.useRef(null),P=t.useRef(null),N=t.useId(),O=Ge(e,n??""),a=j.find(c=>c.id===O),{resource:i}=ze(e,a?.calendarId??""),[m,d]=t.useState(),[r,I]=t.useState(),[k,U]=t.useState(!0),[Z,te]=t.useState(oe()),[V,F]=t.useState(!1),[W,s]=t.useState(""),[u,S]=t.useState();t.useEffect(()=>{if(m||!a||!i)return;const c=Le(i.icalData),h=Pe(i.icalData,z[a.calendarId]??me),B=a.allDay?"":a.start.slice(11,16),re=a.allDay?c:Ne(c,we(a.start,h===""?"UTC":h).slice(0,10),a.start.slice(0,10)),D=Ue(i.icalData),w=Oe(a,{repeat:c===""?"":Be(re,B)??"Repeats",location:D.location,notes:D.description,guests:i.attendees.filter(H=>H.role==="Guest").map(H=>_e(H.email,H.displayName))}),ue=!A.has(a.id);d({draft:w,busy:ue,anchor:h}),I(w),U(ue),f({type:"sidebar-range",range:$(w)})},[m,a,i,A,z,f]);const p=l.mode==="sidebar"?l.draft.range:void 0;t.useEffect(()=>{!p||!r||Me(p,$(r))||I({...r,date:p.date,endDate:p.endDate,startTime:p.startTime,endTime:p.endTime,allDay:p.allDay})},[p,r]);const ce=r!==void 0;t.useEffect(()=>{ce&&T.current?.focus()},[ce]),t.useEffect(()=>{u&&P.current?.focus()},[u]);const Ie=m!==void 0&&r!==void 0&&(JSON.stringify(m.draft)!==JSON.stringify(r)||k!==m.busy),{close:De,confirm:Re,leave:Te}=Ee(Ie);if(!C&&a===void 0)return v.jsx("section",{className:"flex h-full flex-col bg-surface","aria-labelledby":N,children:v.jsx(Ke,{headingId:N,onClose:_})});if(!a||!m||!r)return null;const se=J.find(c=>c.id===a.calendarId),de=a.seriesId!==""&&n!==void 0,q=i?.organizer??"",ke=i!==void 0&&(i.participation==="Organizer"||i.participation==="Unscheduled"&&q===""),ne=G.find(c=>c.email===q)?.accountId??X??Y??se?.accountId??"",ae=c=>{F(!1);const h=je(m.draft,r,{clock:Z,anchor:Z!==oe()?Z:m.anchor});if(!h.ok){s(h.problem);return}s(""),S(void 0);const B=k!==m.busy?{...h.patch,transparency:Ce(k)}:h.patch,re=B.attendees!==void 0&&q===""&&ne!==""?{...B,organizerAccountId:ne}:B;K({calendarObjectId:e,calendarId:a.calendarId,recurrenceId:n??"",scope:c,etag:i?.etag??""},re).then(D=>{if(D.kind==="written"){f({type:"saved"}),g(D.sends),o(e),Te();return}const w=D.kind==="conflict"?he:`Couldn't save this event: ${D.message}`;S({text:w,reportHref:ge(w),onRetry:()=>ae(c)})})};return v.jsxs(v.Fragment,{children:[v.jsx(Se,{heading:"Edit event",draft:r,onChange:c=>{I(c),f({type:"sidebar-range",range:$(c)})},calendars:se?[se]:[],calendarEditable:!1,repeatEditable:!de,timeZone:Z,timeZones:be,onTimeZone:te,busy:k,onBusy:U,guests:ke?{suggestions:E,onQuery:L,senders:G,sender:ne,onSender:ee,senderEditable:q===""}:void 0,onSave:()=>de?F(!0):ae(void 0),onCancel:De,saving:M,problem:W,failure:u,failureRef:P,titleRef:T,children:V&&v.jsx(Ve,{title:a.title,ruleText:r.repeat===""?"It repeats":r.repeat,instanceText:We(a),onChoose:ae,onCancel:()=>F(!1)})}),Re]})}export{vt as C,yt as a};
@@ -1 +1 @@
1
- import{r,j as n,aa as k}from"./index-Bn8n_AsE.js";import{b as ce,e as de,v as ue,w as pe,s as fe,c as D,x as me,i as ve}from"./useCalendarSuggestions-Bb4PGHae.js";import{c as he,t as Ce,R as V}from"./useCalendarData-RUYA8D_t.js";import{f as N}from"./calendar-format-BwCpz-JZ.js";import"./nav-link-CtuHya9S.js";import{a as xe,b as ge}from"./calendar-BJu4Vl-g.js";import"./reply-DmpF7cgR.js";import{u as ye}from"./CalendarSession-CK-EC1yK.js";import{C as T}from"./useCalendarTasks-RmI_Ij1j.js";import{a as Se,b as Ee}from"./calendar-event-popup-B4-Dpgb6.js";import{d as $e,e as we}from"./calendar-guests-Diti9JO5.js";import{C as Ie}from"./confirm-dialog-sa45Xnmn.js";const Re={Accepted:"accepted",Declined:"declined",Tentative:"tentative",NeedsAction:"noReply"},je=a=>({name:a.displayName,email:a.email,rsvp:Re[a.status],role:a.role==="Organizer"?"organizer":"attendee"}),ke={accepted:"Accepted",declined:"Declined",tentative:"Tentative"},J="This calendar changed while you were writing.",De=a=>a.kind==="conflict"?`${J} Close the popup and open the event again.`:a.kind==="refused"?`Couldn't delete this event: ${a.message}`:"";function He({calendarObjectId:a,recurrenceId:p}){const{view:f,date:g,calendarIds:m}=xe(),{events:A,isLoading:U,freeIds:M}=he({view:f,date:g,calendarIds:m}),{calendars:Q}=ce(),{closeToView:v,openEditor:X}=ge(),{deleteEvent:Y,updateEvent:Z,isWriting:F}=de(),b=ye(),[O,y]=r.useState(),[ee,P]=r.useState(),c=r.useId(),L=r.useRef(null),B=r.useRef(null),G=r.useRef(null),[te,h]=r.useState(!1),[ne,S]=r.useState(!1),[E,ae]=r.useState(void 0),[K,re]=r.useState(null),C=ve(a,p??""),t=A.find(e=>e.id===C),$=p===void 0&&t===void 0?ue(A,a,new Date().toISOString()):void 0,d=pe(a,t===void 0&&!U&&$===void 0),w=Q.find(e=>e.id===t?.calendarId),{resource:s}=fe(a,t?.calendarId??""),se=s?Ce(s.icalData):void 0,W=t!==void 0&&s!==void 0&&!w?.readOnly,I=t!==void 0&&t.seriesId!=="";r.useLayoutEffect(()=>{re(t?document.querySelector(`[data-event-id="${CSS.escape(t.id)}"]`):null)},[t]);const R=d.kind==="Deleted"||d.kind==="NoOccurrenceFound";r.useEffect(()=>{R?B.current?.focus():t&&L.current?.focus()},[R,t]),r.useEffect(()=>{E&&G.current?.focus()},[E]),r.useEffect(()=>{const e=`[data-event-id="${CSS.escape(C)}"]`;return()=>{document.querySelector(e)?.focus()}},[C]);const z=e=>({calendarObjectId:a,calendarId:t?.calendarId??"",recurrenceId:p??"",scope:e,etag:s?.etag??""}),H=(s?.attendees??[]).filter(e=>e.role==="Guest").map(e=>e.displayName===""?e.email:e.displayName),oe=()=>{if(H.length>0){S(!0);return}if(I){h(!0);return}x(void 0)},ie=()=>{if(S(!1),I){h(!0);return}x(void 0)},x=e=>{h(!1),Y(z(e)).then(i=>{if(i.kind==="written"){b.trackSends(i.sends),v();return}const l=De(i);ae({text:l,reportHref:D(l),onRetry:()=>x(e)})})},j=(e,i)=>{y(void 0),P(void 0),Z(z(i),{answer:ke[e]}).then(l=>{if(l.kind==="written"){b.trackSends(l.sends);return}const q=l.kind==="conflict"?`${J} Close the popup and open the event again.`:`Couldn't send your reply: ${l.message}`;P({text:q,reportHref:D(q),onRetry:()=>j(e,i)})})},u=s?.participation,le=u!==void 0&&u!=="Organizer"&&u!=="Unscheduled";if($)return n.jsx(k,{to:"/calendar/$view/$date/$calendarObjectId/$recurrenceId",params:{view:f,date:g,calendarObjectId:a,recurrenceId:$.recurrenceId},search:!0,hash:!0,replace:!0});const o=d.kind==="Found"?d.jump:void 0,_=o!==void 0&&m.length>0&&!m.includes(o.calendarId);if(o&&(o.date!==g||_)){const e=_?i=>({...i,calendarId:[...m,o.calendarId]}):!0;return o.recurrenceId===""?n.jsx(k,{to:"/calendar/$view/$date/$calendarObjectId",params:{view:f,date:o.date,calendarObjectId:a},search:e,hash:!0,replace:!0}):n.jsx(k,{to:"/calendar/$view/$date/$calendarObjectId/$recurrenceId",params:{view:f,date:o.date,calendarObjectId:a,recurrenceId:o.recurrenceId},search:e,hash:!0,replace:!0})}if(d.kind==="Failed"&&!t){const e=`Couldn't open this event: ${d.reason}`;return n.jsx(T,{anchor:null,anchorKey:"failed",labelledBy:c,children:n.jsxs("div",{className:"flex flex-col gap-3 p-4",id:c,children:[n.jsxs("p",{role:"alert",className:"text-sm text-danger",children:[e," ",n.jsx("a",{href:D(e),target:"_blank",rel:"noreferrer",className:"font-medium text-accent hover:underline",children:"Report an issue"})]}),n.jsx("button",{type:"button",onClick:v,className:"self-end rounded-md border border-line px-3 py-1.5 text-sm font-medium",children:"Close"})]})})}return R?n.jsx(T,{anchor:null,anchorKey:"gone",labelledBy:c,children:n.jsx(Se,{headingId:c,onClose:v,closeRef:B})}):t?n.jsxs(n.Fragment,{children:[n.jsx(T,{anchor:K,anchorKey:`${C}:${K?"chip":"none"}`,labelledBy:c,children:n.jsxs(Ee,{headingId:c,headingRef:L,title:t.title,color:w?.color??"cal-1",when:N(t).replace(", "," · "),location:se?.location??"",calendarName:w?.name??"",availability:M.has(t.id)?"Free":"Busy",onEdit:W?()=>X(a,p):void 0,onDelete:W?oe:void 0,deleting:F,onClose:v,failure:E,failureRef:G,children:[s&&n.jsx($e,{attendees:s.attendees.map(je),counts:s.attendeeCounts}),le&&u&&n.jsx(we,{current:me(u),onAnswer:e=>I?y(e):j(e,void 0),sending:F,failure:ee}),O&&n.jsx(V,{title:t.title,ruleText:"It repeats",instanceText:N(t),scopes:["this","all"],onChoose:e=>j(O,e),onCancel:()=>y(void 0)}),te&&n.jsx(V,{title:t.title,ruleText:"It repeats",instanceText:N(t),onChoose:x,onCancel:()=>h(!1)})]})}),n.jsx(Ie,{isOpen:ne,title:"Delete and tell the guests?",description:`${H.join(", ")} will get a cancellation.`,confirmLabel:"Delete and send",cancelLabel:"Keep event",destructive:!0,onConfirm:ie,onCancel:()=>S(!1)})]}):null}export{He as C};
1
+ import{r,j as n,aa as k}from"./index-BZ4sAts4.js";import{b as ce,e as de,v as ue,w as pe,s as fe,c as D,x as me,i as ve}from"./useCalendarSuggestions-D58tKJtx.js";import{c as he,t as Ce,R as V}from"./useCalendarData-BKkQY_vQ.js";import{f as N}from"./calendar-format-BwCpz-JZ.js";import"./nav-link-BvBkmH1H.js";import{a as xe,b as ge}from"./calendar-SMIdRsx9.js";import"./reply-D8bLYzum.js";import{u as ye}from"./CalendarSession-Ql7K56YK.js";import{C as T}from"./useCalendarTasks-DLNYnUeu.js";import{a as Se,b as Ee}from"./calendar-event-popup-DqvJLPWt.js";import{d as $e,e as we}from"./calendar-guests-Dt2cjTqc.js";import{C as Ie}from"./confirm-dialog-B0MVMPmn.js";const Re={Accepted:"accepted",Declined:"declined",Tentative:"tentative",NeedsAction:"noReply"},je=a=>({name:a.displayName,email:a.email,rsvp:Re[a.status],role:a.role==="Organizer"?"organizer":"attendee"}),ke={accepted:"Accepted",declined:"Declined",tentative:"Tentative"},J="This calendar changed while you were writing.",De=a=>a.kind==="conflict"?`${J} Close the popup and open the event again.`:a.kind==="refused"?`Couldn't delete this event: ${a.message}`:"";function He({calendarObjectId:a,recurrenceId:p}){const{view:f,date:g,calendarIds:m}=xe(),{events:A,isLoading:U,freeIds:M}=he({view:f,date:g,calendarIds:m}),{calendars:Q}=ce(),{closeToView:v,openEditor:X}=ge(),{deleteEvent:Y,updateEvent:Z,isWriting:F}=de(),b=ye(),[O,y]=r.useState(),[ee,P]=r.useState(),c=r.useId(),L=r.useRef(null),B=r.useRef(null),G=r.useRef(null),[te,h]=r.useState(!1),[ne,S]=r.useState(!1),[E,ae]=r.useState(void 0),[K,re]=r.useState(null),C=ve(a,p??""),t=A.find(e=>e.id===C),$=p===void 0&&t===void 0?ue(A,a,new Date().toISOString()):void 0,d=pe(a,t===void 0&&!U&&$===void 0),w=Q.find(e=>e.id===t?.calendarId),{resource:s}=fe(a,t?.calendarId??""),se=s?Ce(s.icalData):void 0,W=t!==void 0&&s!==void 0&&!w?.readOnly,I=t!==void 0&&t.seriesId!=="";r.useLayoutEffect(()=>{re(t?document.querySelector(`[data-event-id="${CSS.escape(t.id)}"]`):null)},[t]);const R=d.kind==="Deleted"||d.kind==="NoOccurrenceFound";r.useEffect(()=>{R?B.current?.focus():t&&L.current?.focus()},[R,t]),r.useEffect(()=>{E&&G.current?.focus()},[E]),r.useEffect(()=>{const e=`[data-event-id="${CSS.escape(C)}"]`;return()=>{document.querySelector(e)?.focus()}},[C]);const z=e=>({calendarObjectId:a,calendarId:t?.calendarId??"",recurrenceId:p??"",scope:e,etag:s?.etag??""}),H=(s?.attendees??[]).filter(e=>e.role==="Guest").map(e=>e.displayName===""?e.email:e.displayName),oe=()=>{if(H.length>0){S(!0);return}if(I){h(!0);return}x(void 0)},ie=()=>{if(S(!1),I){h(!0);return}x(void 0)},x=e=>{h(!1),Y(z(e)).then(i=>{if(i.kind==="written"){b.trackSends(i.sends),v();return}const l=De(i);ae({text:l,reportHref:D(l),onRetry:()=>x(e)})})},j=(e,i)=>{y(void 0),P(void 0),Z(z(i),{answer:ke[e]}).then(l=>{if(l.kind==="written"){b.trackSends(l.sends);return}const q=l.kind==="conflict"?`${J} Close the popup and open the event again.`:`Couldn't send your reply: ${l.message}`;P({text:q,reportHref:D(q),onRetry:()=>j(e,i)})})},u=s?.participation,le=u!==void 0&&u!=="Organizer"&&u!=="Unscheduled";if($)return n.jsx(k,{to:"/calendar/$view/$date/$calendarObjectId/$recurrenceId",params:{view:f,date:g,calendarObjectId:a,recurrenceId:$.recurrenceId},search:!0,hash:!0,replace:!0});const o=d.kind==="Found"?d.jump:void 0,_=o!==void 0&&m.length>0&&!m.includes(o.calendarId);if(o&&(o.date!==g||_)){const e=_?i=>({...i,calendarId:[...m,o.calendarId]}):!0;return o.recurrenceId===""?n.jsx(k,{to:"/calendar/$view/$date/$calendarObjectId",params:{view:f,date:o.date,calendarObjectId:a},search:e,hash:!0,replace:!0}):n.jsx(k,{to:"/calendar/$view/$date/$calendarObjectId/$recurrenceId",params:{view:f,date:o.date,calendarObjectId:a,recurrenceId:o.recurrenceId},search:e,hash:!0,replace:!0})}if(d.kind==="Failed"&&!t){const e=`Couldn't open this event: ${d.reason}`;return n.jsx(T,{anchor:null,anchorKey:"failed",labelledBy:c,children:n.jsxs("div",{className:"flex flex-col gap-3 p-4",id:c,children:[n.jsxs("p",{role:"alert",className:"text-sm text-danger",children:[e," ",n.jsx("a",{href:D(e),target:"_blank",rel:"noreferrer",className:"font-medium text-accent hover:underline",children:"Report an issue"})]}),n.jsx("button",{type:"button",onClick:v,className:"self-end rounded-md border border-line px-3 py-1.5 text-sm font-medium",children:"Close"})]})})}return R?n.jsx(T,{anchor:null,anchorKey:"gone",labelledBy:c,children:n.jsx(Se,{headingId:c,onClose:v,closeRef:B})}):t?n.jsxs(n.Fragment,{children:[n.jsx(T,{anchor:K,anchorKey:`${C}:${K?"chip":"none"}`,labelledBy:c,children:n.jsxs(Ee,{headingId:c,headingRef:L,title:t.title,color:w?.color??"cal-1",when:N(t).replace(", "," · "),location:se?.location??"",calendarName:w?.name??"",availability:M.has(t.id)?"Free":"Busy",onEdit:W?()=>X(a,p):void 0,onDelete:W?oe:void 0,deleting:F,onClose:v,failure:E,failureRef:G,children:[s&&n.jsx($e,{attendees:s.attendees.map(je),counts:s.attendeeCounts}),le&&u&&n.jsx(we,{current:me(u),onAnswer:e=>I?y(e):j(e,void 0),sending:F,failure:ee}),O&&n.jsx(V,{title:t.title,ruleText:"It repeats",instanceText:N(t),scopes:["this","all"],onChoose:e=>j(O,e),onCancel:()=>y(void 0)}),te&&n.jsx(V,{title:t.title,ruleText:"It repeats",instanceText:N(t),onChoose:x,onCancel:()=>h(!1)})]})}),n.jsx(Ie,{isOpen:ne,title:"Delete and tell the guests?",description:`${H.join(", ")} will get a cancellation.`,confirmLabel:"Delete and send",cancelLabel:"Keep event",destructive:!0,onConfirm:ie,onCancel:()=>S(!1)})]}):null}export{He as C};
@@ -1 +1 @@
1
- import{j as e,v as d}from"./index-Bn8n_AsE.js";import{c as l}from"./useCalendarSuggestions-Bb4PGHae.js";import{f as o}from"./ErrorState-BXxvOnci.js";function x({title:r,error:a,onRetry:n,compact:t=!1}){const s=o(a);return e.jsxs("div",{role:"alert",className:t?"flex flex-col gap-2 rounded-md border border-danger/40 bg-danger-soft p-3 text-sm":"flex h-full flex-col items-center justify-center gap-3 p-8 text-center",children:[!t&&e.jsx(d,{className:"size-8 text-danger","aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-danger",children:r}),e.jsx("p",{className:"mt-1 break-words text-sm text-fg-muted",children:s})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:n,className:"inline-flex items-center rounded-md border border-line bg-canvas px-3 py-1.5 text-sm font-medium hover:bg-surface-raised",children:"Retry"}),e.jsx("a",{href:l(`${r}: ${s}`),target:"_blank",rel:"noreferrer",className:"text-sm font-medium text-accent hover:underline",children:"Report an issue"})]})]})}export{x as C};
1
+ import{j as e,v as d}from"./index-BZ4sAts4.js";import{c as l}from"./useCalendarSuggestions-D58tKJtx.js";import{f as o}from"./ErrorState-nIG-x-Zh.js";function x({title:r,error:a,onRetry:n,compact:t=!1}){const s=o(a);return e.jsxs("div",{role:"alert",className:t?"flex flex-col gap-2 rounded-md border border-danger/40 bg-danger-soft p-3 text-sm":"flex h-full flex-col items-center justify-center gap-3 p-8 text-center",children:[!t&&e.jsx(d,{className:"size-8 text-danger","aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-danger",children:r}),e.jsx("p",{className:"mt-1 break-words text-sm text-fg-muted",children:s})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:n,className:"inline-flex items-center rounded-md border border-line bg-canvas px-3 py-1.5 text-sm font-medium hover:bg-surface-raised",children:"Retry"}),e.jsx("a",{href:l(`${r}: ${s}`),target:"_blank",rel:"noreferrer",className:"text-sm font-medium text-accent hover:underline",children:"Report an issue"})]})]})}export{x as C};
@@ -1 +1 @@
1
- import{b as _,p as j,j as e,X as q,r as c,c3 as X}from"./index-Bn8n_AsE.js";import{c as J}from"./draft-QkjvtbSZ.js";import{b as V,e as F,c as ee,p as K,U,f as W}from"./useCalendarSuggestions-Bb4PGHae.js";import{u as te,b as ae}from"./useCalendarScheduling-CO3VOpcB.js";import{u as ne,C as re}from"./useCalendarTasks-RmI_Ij1j.js";import"./nav-link-CtuHya9S.js";import{i as se}from"./calendar-BJu4Vl-g.js";import"./reply-DmpF7cgR.js";import{u as le}from"./CalendarSession-CK-EC1yK.js";import{i as ie,c as oe}from"./calendar-guests-Diti9JO5.js";import{C as ce}from"./calendar-event-popup-B4-Dpgb6.js";const ue=_("GripHorizontal",[["circle",{cx:"12",cy:"9",r:"1",key:"124mty"}],["circle",{cx:"19",cy:"9",r:"1",key:"1ruzo2"}],["circle",{cx:"5",cy:"9",r:"1",key:"1a8b28"}],["circle",{cx:"12",cy:"15",r:"1",key:"1e56xg"}],["circle",{cx:"19",cy:"15",r:"1",key:"1a92ep"}],["circle",{cx:"5",cy:"15",r:"1",key:"5r1jwy"}]]),de="h-9 rounded-md border border-line bg-surface-sunken px-2 text-sm text-fg outline-none focus-visible:border-line-strong focus-visible:ring-2 focus-visible:ring-ring/30",$=(s,r)=>{const m={...s.range,...r};return r.date!==void 0&&!m.allDay&&(m.endDate=r.date),r.date!==void 0&&m.allDay&&m.endDate<r.date&&(m.endDate=r.date),{...s,range:m}};function me({headingId:s,mode:r,onMode:m,fields:i,taskFields:o,onTaskChange:u,calendars:g,taskLists:N,guestSuggestions:T,onGuestQuery:v,onChange:f,onSave:x,onMoreOptions:R,onClose:A,saving:y=!1,problem:w="",failure:S,failureRef:M,titleRef:P,settingsHref:z,dragHandle:E,touch:h=!1}){const n=r==="task",C=n?N:g,D=C.length===0,d=!n&&ie(i.guests)!==void 0,p=j(de,h&&"h-11"),G=n?o.title:i.title,I=t=>n?u({...o,title:t}):f({...i,title:t});return e.jsxs("form",{className:"relative flex flex-col",onSubmit:t=>{t.preventDefault(),!D&&!y&&!d&&x()},children:[e.jsxs("div",{onPointerDown:E?.onPointerDown,className:j("flex items-center justify-between rounded-t-xl bg-surface-sunken px-2 py-1",E&&"cursor-grab"),children:[e.jsx(ue,{className:"size-4 text-fg-subtle","aria-hidden":"true"}),e.jsx("h2",{id:s,className:"sr-only",children:n?"New task":"New event"})]}),e.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[e.jsx("input",{ref:P,"aria-label":"Title",placeholder:"Add title",value:G,onChange:t=>I(t.target.value),className:j("border-b-2 border-line bg-transparent pb-1 text-xl text-fg outline-none placeholder:text-fg-subtle focus:border-accent")}),e.jsxs("fieldset",{className:"flex gap-1 self-start rounded-md bg-surface-sunken p-0.5 text-sm",children:[e.jsx("legend",{className:"sr-only",children:"Kind"}),["event","task"].map(t=>e.jsxs("label",{className:j("cursor-pointer rounded px-3 py-1 font-medium has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-ring",r===t?"bg-surface text-fg shadow-sm":"text-fg-muted",h&&"min-h-11"),children:[e.jsx("input",{type:"radio",name:`${s}-kind`,value:t,checked:r===t,onChange:()=>m(t),className:"sr-only"}),t==="event"?"Event":"Task"]},t))]}),n?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-fg-muted",children:"Due"}),e.jsx("input",{type:"date","aria-label":"Due date",value:o.dueDate,onChange:t=>t.target.value!==""&&u({...o,dueDate:t.target.value}),className:p}),o.dueTime===""?e.jsx("button",{type:"button",onClick:()=>u({...o,dueTime:"09:00"}),className:"rounded-md px-2 font-medium text-accent hover:bg-accent-soft",children:"Add time"}):e.jsx("input",{type:"time","aria-label":"Due time",step:900,value:o.dueTime,onChange:t=>u({...o,dueTime:t.target.value}),className:p})]}):e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[e.jsx("input",{type:"date","aria-label":"Date",value:i.range.date,onChange:t=>t.target.value!==""&&f($(i,{date:t.target.value})),className:p}),i.range.allDay?e.jsx("span",{className:"text-fg-muted",children:"All day"}):e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"time","aria-label":"Start time",step:900,value:i.range.startTime,onChange:t=>t.target.value!==""&&f($(i,{startTime:t.target.value})),className:p}),e.jsx("span",{"aria-hidden":"true",children:"–"}),e.jsx("input",{type:"time","aria-label":"End time",step:900,value:i.range.endTime,onChange:t=>t.target.value!==""&&f($(i,{endTime:t.target.value})),className:p})]})]}),!n&&e.jsx(oe,{value:i.guests,onChange:t=>f({...i,guests:t}),suggestions:T,onQuery:v,touch:h}),n?e.jsx("textarea",{"aria-label":"Description",placeholder:"Add description",rows:2,value:o.description,onChange:t=>u({...o,description:t.target.value}),className:"w-full rounded-md border border-line bg-surface-sunken px-2 py-1 text-sm text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring/30"}):e.jsx("input",{"aria-label":"Location",placeholder:"Add location",value:i.location,onChange:t=>f({...i,location:t.target.value}),className:p}),D?e.jsxs("p",{role:"status",tabIndex:-1,className:"text-sm text-fg-muted",children:["None of your calendars accepts new events."," ",e.jsx("a",{href:z,className:"font-medium text-accent hover:underline",children:"Calendar settings"})]}):e.jsx("select",{"aria-label":n?"Task list":"Calendar",value:n?o.calendarId:i.calendarId,onChange:t=>n?u({...o,calendarId:t.target.value}):f({...i,calendarId:t.target.value}),className:p,children:C.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))}),w!==""&&e.jsx("p",{className:"text-sm text-danger",role:"status",children:w}),S&&e.jsx(ce,{failure:S,focusRef:M})]}),e.jsxs("div",{className:"flex items-center justify-between px-4 pb-4",children:[n?e.jsx("span",{}):e.jsx("button",{type:"button",onClick:R,className:j("rounded-md px-3 text-sm font-medium text-accent outline-none hover:bg-accent-soft focus-visible:ring-2 focus-visible:ring-ring",h?"min-h-11":"h-9"),children:"More options"}),e.jsx("button",{type:"submit",disabled:D||y||d,className:j("rounded-md bg-accent px-5 text-sm font-medium text-accent-fg outline-none hover:bg-accent-hover focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50",h?"min-h-11":"h-9"),children:y?"Saving…":"Save"})]}),e.jsx("button",{type:"button","aria-label":"Close",onClick:A,className:j("absolute top-0 right-1 flex items-center justify-center rounded-full text-fg-muted outline-none hover:bg-surface hover:text-fg focus-visible:ring-2 focus-visible:ring-ring",h?"size-11":"size-8"),children:e.jsx(q,{className:"size-4"})})]})}const fe=80;function ge({labelledBy:s,onDismiss:r,children:m,sheetRef:i,className:o}){const u=c.useRef(null),[g,N]=c.useState(0),T=x=>{u.current=x.clientY,x.currentTarget.setPointerCapture(x.pointerId)},v=x=>{u.current!==null&&N(Math.max(0,x.clientY-u.current))},f=()=>{u.current!==null&&(u.current=null,g>fe&&r(),N(0))};return e.jsxs("div",{ref:i,role:"dialog","aria-modal":"false","aria-labelledby":s,"data-calendar-popover":"",className:j("fixed inset-x-0 bottom-0 z-50 max-h-[70dvh] overflow-y-auto rounded-t-2xl border-t border-line bg-surface-raised pb-[env(safe-area-inset-bottom,0px)] shadow-2xl shadow-black/30",o),style:{transform:`translateY(${g}px)`,transition:g===0?"transform 200ms ease-out":"none"},children:[e.jsx("div",{"aria-hidden":"true","data-sheet-grabber":"",onPointerDown:T,onPointerMove:v,onPointerUp:f,onPointerCancel:f,className:"flex h-6 cursor-grab touch-none items-center justify-center",children:e.jsx("span",{className:"h-1 w-10 rounded-full bg-line-strong"})}),m]})}const xe="/settings/calendars";function pe(s){return{title:s.title,date:s.range.date,startTime:s.range.startTime,endDate:s.range.endDate,endTime:s.range.endTime,allDay:s.range.allDay,calendarId:s.calendarId,location:s.location,guests:s.guests,notes:"",repeat:""}}function we({session:s,dispatch:r,onMoreOptions:m,onSaved:i,touch:o=!1}){const u=c.useId(),g=c.useRef(null),N=c.useRef(null),[T,v]=c.useState(""),{calendars:f,taskLists:x,defaultCalendarId:R,timeZoneByCalendarId:A}=V(),y=f.filter(a=>!a.readOnly),{createEvent:w}=F(),{createTask:S}=ne(),{defaultSenderId:M}=te(),[P,z]=c.useState(""),E=ae(P),h=le(),{draft:n}=s,[C,D]=c.useState("event"),[d,p]=c.useState({title:"",dueDate:"",dueTime:"",description:"",calendarId:""}),G=a=>{if(a!==C){if(D(a),a==="event"){r({type:"change",draft:{...n,title:d.title}});return}p(l=>({...l,title:n.title,dueDate:n.range.date,dueTime:n.range.allDay?"":n.range.startTime,calendarId:l.calendarId===""?x[0]?.id??"":l.calendarId}))}},I=y.find(a=>a.id===R)?.id??y[0]?.id??"",t=M??y.find(a=>a.id===n.calendarId)?.accountId??"";c.useEffect(()=>{g.current?.focus()},[]),c.useEffect(()=>{n.calendarId!==""||I===""||r({type:"change",draft:{...n,calendarId:I}})},[n,I,r]),c.useEffect(()=>{s.status==="failed"&&N.current?.focus()},[s.status]);const L=c.useRef(null),B=c.useRef(null);se(o,()=>(r({type:"outside"}),!0));const k=`${n.range.date}T${n.range.startTime}/${n.range.endDate}T${n.range.endTime}`;c.useEffect(()=>{const a=B.current;if(k==="")return;const l=document.querySelector("[data-draft-block]"),b=document.querySelector("[role='grid'][aria-label='Time grid']");if(!a||!l||!b)return;const Z=l.getBoundingClientRect().bottom-a.getBoundingClientRect().top+16;Z>0&&(b.scrollTop+=Z)},[k]);const H=c.useRef(null);c.useEffect(()=>{const a=H.current;if(!a)return;const l=b=>{(b.target instanceof HTMLInputElement||b.target instanceof HTMLSelectElement)&&(L.current=b.target)};return a.addEventListener("focusin",l),()=>a.removeEventListener("focusin",l)},[]),c.useEffect(()=>{const a=L.current;k===""||!a||document.activeElement===a||a.focus()},[k]);const Y=()=>{if(d.title.trim()===""){v("Give the task a title before saving it."),g.current?.focus();return}v(""),r({type:"save"});const a=W(),l=d.dueTime==="";S({calendarId:d.calendarId,summary:d.title.trim(),description:d.description,allDay:l,due:l?d.dueDate:X(d.dueDate,d.dueTime,a),...l?{}:{timeZone:K(U)}}).then(b=>{if(b.kind==="written"){r({type:"saved"});return}r({type:"save-failed",problem:`Couldn't save the task: ${b.message}`})})},O=()=>{if(C==="task"){Y();return}const a=J(pe(n),{clock:W(),anchor:K(A[n.calendarId]??U)},t);if(!a.ok){v(a.problem),g.current?.focus();return}v(""),r({type:"save"}),w(a.input).then(l=>{if(l.kind==="created"){r({type:"saved"}),h.trackSends(l.sends),i(l.calendarObjectId);return}r({type:"save-failed",problem:l.kind==="conflict"?"This calendar changed while you were writing. Close the form and try again.":`Couldn't save this event: ${l.message}`})})},Q=a=>e.jsx("div",{ref:H,children:e.jsx(me,{headingId:u,mode:C,onMode:G,fields:n,taskFields:d,onTaskChange:p,calendars:y,taskLists:x,guestSuggestions:E,onGuestQuery:z,onChange:l=>r({type:"change",draft:l}),onSave:O,onMoreOptions:()=>m(L.current?.getAttribute("aria-label")??""),onClose:()=>r({type:"outside"}),saving:s.status==="saving",problem:T,failure:s.status==="failed"?{text:s.problem,reportHref:ee(s.problem),onRetry:O}:void 0,failureRef:N,titleRef:g,settingsHref:xe,dragHandle:a,touch:o})});return o?e.jsx(ge,{labelledBy:u,onDismiss:()=>r({type:"outside"}),sheetRef:B,children:Q()}):e.jsx(re,{anchor:"[data-draft-block]",anchorKey:k,labelledBy:u,wrapTab:!0,header:a=>Q(a),children:null})}export{we as C,pe as e};
1
+ import{b as _,p as j,j as e,X as q,r as c,c3 as X}from"./index-BZ4sAts4.js";import{c as J}from"./draft-0DDwY2Pw.js";import{b as V,e as F,c as ee,p as K,U,f as W}from"./useCalendarSuggestions-D58tKJtx.js";import{u as te,b as ae}from"./useCalendarScheduling-D_qd-mRK.js";import{u as ne,C as re}from"./useCalendarTasks-DLNYnUeu.js";import"./nav-link-BvBkmH1H.js";import{i as se}from"./calendar-SMIdRsx9.js";import"./reply-D8bLYzum.js";import{u as le}from"./CalendarSession-Ql7K56YK.js";import{i as ie,c as oe}from"./calendar-guests-Dt2cjTqc.js";import{C as ce}from"./calendar-event-popup-DqvJLPWt.js";const ue=_("GripHorizontal",[["circle",{cx:"12",cy:"9",r:"1",key:"124mty"}],["circle",{cx:"19",cy:"9",r:"1",key:"1ruzo2"}],["circle",{cx:"5",cy:"9",r:"1",key:"1a8b28"}],["circle",{cx:"12",cy:"15",r:"1",key:"1e56xg"}],["circle",{cx:"19",cy:"15",r:"1",key:"1a92ep"}],["circle",{cx:"5",cy:"15",r:"1",key:"5r1jwy"}]]),de="h-9 rounded-md border border-line bg-surface-sunken px-2 text-sm text-fg outline-none focus-visible:border-line-strong focus-visible:ring-2 focus-visible:ring-ring/30",$=(s,r)=>{const m={...s.range,...r};return r.date!==void 0&&!m.allDay&&(m.endDate=r.date),r.date!==void 0&&m.allDay&&m.endDate<r.date&&(m.endDate=r.date),{...s,range:m}};function me({headingId:s,mode:r,onMode:m,fields:i,taskFields:o,onTaskChange:u,calendars:g,taskLists:N,guestSuggestions:T,onGuestQuery:v,onChange:f,onSave:x,onMoreOptions:R,onClose:A,saving:y=!1,problem:w="",failure:S,failureRef:M,titleRef:P,settingsHref:z,dragHandle:E,touch:h=!1}){const n=r==="task",C=n?N:g,D=C.length===0,d=!n&&ie(i.guests)!==void 0,p=j(de,h&&"h-11"),G=n?o.title:i.title,I=t=>n?u({...o,title:t}):f({...i,title:t});return e.jsxs("form",{className:"relative flex flex-col",onSubmit:t=>{t.preventDefault(),!D&&!y&&!d&&x()},children:[e.jsxs("div",{onPointerDown:E?.onPointerDown,className:j("flex items-center justify-between rounded-t-xl bg-surface-sunken px-2 py-1",E&&"cursor-grab"),children:[e.jsx(ue,{className:"size-4 text-fg-subtle","aria-hidden":"true"}),e.jsx("h2",{id:s,className:"sr-only",children:n?"New task":"New event"})]}),e.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[e.jsx("input",{ref:P,"aria-label":"Title",placeholder:"Add title",value:G,onChange:t=>I(t.target.value),className:j("border-b-2 border-line bg-transparent pb-1 text-xl text-fg outline-none placeholder:text-fg-subtle focus:border-accent")}),e.jsxs("fieldset",{className:"flex gap-1 self-start rounded-md bg-surface-sunken p-0.5 text-sm",children:[e.jsx("legend",{className:"sr-only",children:"Kind"}),["event","task"].map(t=>e.jsxs("label",{className:j("cursor-pointer rounded px-3 py-1 font-medium has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-ring",r===t?"bg-surface text-fg shadow-sm":"text-fg-muted",h&&"min-h-11"),children:[e.jsx("input",{type:"radio",name:`${s}-kind`,value:t,checked:r===t,onChange:()=>m(t),className:"sr-only"}),t==="event"?"Event":"Task"]},t))]}),n?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-fg-muted",children:"Due"}),e.jsx("input",{type:"date","aria-label":"Due date",value:o.dueDate,onChange:t=>t.target.value!==""&&u({...o,dueDate:t.target.value}),className:p}),o.dueTime===""?e.jsx("button",{type:"button",onClick:()=>u({...o,dueTime:"09:00"}),className:"rounded-md px-2 font-medium text-accent hover:bg-accent-soft",children:"Add time"}):e.jsx("input",{type:"time","aria-label":"Due time",step:900,value:o.dueTime,onChange:t=>u({...o,dueTime:t.target.value}),className:p})]}):e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[e.jsx("input",{type:"date","aria-label":"Date",value:i.range.date,onChange:t=>t.target.value!==""&&f($(i,{date:t.target.value})),className:p}),i.range.allDay?e.jsx("span",{className:"text-fg-muted",children:"All day"}):e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"time","aria-label":"Start time",step:900,value:i.range.startTime,onChange:t=>t.target.value!==""&&f($(i,{startTime:t.target.value})),className:p}),e.jsx("span",{"aria-hidden":"true",children:"–"}),e.jsx("input",{type:"time","aria-label":"End time",step:900,value:i.range.endTime,onChange:t=>t.target.value!==""&&f($(i,{endTime:t.target.value})),className:p})]})]}),!n&&e.jsx(oe,{value:i.guests,onChange:t=>f({...i,guests:t}),suggestions:T,onQuery:v,touch:h}),n?e.jsx("textarea",{"aria-label":"Description",placeholder:"Add description",rows:2,value:o.description,onChange:t=>u({...o,description:t.target.value}),className:"w-full rounded-md border border-line bg-surface-sunken px-2 py-1 text-sm text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring/30"}):e.jsx("input",{"aria-label":"Location",placeholder:"Add location",value:i.location,onChange:t=>f({...i,location:t.target.value}),className:p}),D?e.jsxs("p",{role:"status",tabIndex:-1,className:"text-sm text-fg-muted",children:["None of your calendars accepts new events."," ",e.jsx("a",{href:z,className:"font-medium text-accent hover:underline",children:"Calendar settings"})]}):e.jsx("select",{"aria-label":n?"Task list":"Calendar",value:n?o.calendarId:i.calendarId,onChange:t=>n?u({...o,calendarId:t.target.value}):f({...i,calendarId:t.target.value}),className:p,children:C.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))}),w!==""&&e.jsx("p",{className:"text-sm text-danger",role:"status",children:w}),S&&e.jsx(ce,{failure:S,focusRef:M})]}),e.jsxs("div",{className:"flex items-center justify-between px-4 pb-4",children:[n?e.jsx("span",{}):e.jsx("button",{type:"button",onClick:R,className:j("rounded-md px-3 text-sm font-medium text-accent outline-none hover:bg-accent-soft focus-visible:ring-2 focus-visible:ring-ring",h?"min-h-11":"h-9"),children:"More options"}),e.jsx("button",{type:"submit",disabled:D||y||d,className:j("rounded-md bg-accent px-5 text-sm font-medium text-accent-fg outline-none hover:bg-accent-hover focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50",h?"min-h-11":"h-9"),children:y?"Saving…":"Save"})]}),e.jsx("button",{type:"button","aria-label":"Close",onClick:A,className:j("absolute top-0 right-1 flex items-center justify-center rounded-full text-fg-muted outline-none hover:bg-surface hover:text-fg focus-visible:ring-2 focus-visible:ring-ring",h?"size-11":"size-8"),children:e.jsx(q,{className:"size-4"})})]})}const fe=80;function ge({labelledBy:s,onDismiss:r,children:m,sheetRef:i,className:o}){const u=c.useRef(null),[g,N]=c.useState(0),T=x=>{u.current=x.clientY,x.currentTarget.setPointerCapture(x.pointerId)},v=x=>{u.current!==null&&N(Math.max(0,x.clientY-u.current))},f=()=>{u.current!==null&&(u.current=null,g>fe&&r(),N(0))};return e.jsxs("div",{ref:i,role:"dialog","aria-modal":"false","aria-labelledby":s,"data-calendar-popover":"",className:j("fixed inset-x-0 bottom-0 z-50 max-h-[70dvh] overflow-y-auto rounded-t-2xl border-t border-line bg-surface-raised pb-[env(safe-area-inset-bottom,0px)] shadow-2xl shadow-black/30",o),style:{transform:`translateY(${g}px)`,transition:g===0?"transform 200ms ease-out":"none"},children:[e.jsx("div",{"aria-hidden":"true","data-sheet-grabber":"",onPointerDown:T,onPointerMove:v,onPointerUp:f,onPointerCancel:f,className:"flex h-6 cursor-grab touch-none items-center justify-center",children:e.jsx("span",{className:"h-1 w-10 rounded-full bg-line-strong"})}),m]})}const xe="/settings/calendars";function pe(s){return{title:s.title,date:s.range.date,startTime:s.range.startTime,endDate:s.range.endDate,endTime:s.range.endTime,allDay:s.range.allDay,calendarId:s.calendarId,location:s.location,guests:s.guests,notes:"",repeat:""}}function we({session:s,dispatch:r,onMoreOptions:m,onSaved:i,touch:o=!1}){const u=c.useId(),g=c.useRef(null),N=c.useRef(null),[T,v]=c.useState(""),{calendars:f,taskLists:x,defaultCalendarId:R,timeZoneByCalendarId:A}=V(),y=f.filter(a=>!a.readOnly),{createEvent:w}=F(),{createTask:S}=ne(),{defaultSenderId:M}=te(),[P,z]=c.useState(""),E=ae(P),h=le(),{draft:n}=s,[C,D]=c.useState("event"),[d,p]=c.useState({title:"",dueDate:"",dueTime:"",description:"",calendarId:""}),G=a=>{if(a!==C){if(D(a),a==="event"){r({type:"change",draft:{...n,title:d.title}});return}p(l=>({...l,title:n.title,dueDate:n.range.date,dueTime:n.range.allDay?"":n.range.startTime,calendarId:l.calendarId===""?x[0]?.id??"":l.calendarId}))}},I=y.find(a=>a.id===R)?.id??y[0]?.id??"",t=M??y.find(a=>a.id===n.calendarId)?.accountId??"";c.useEffect(()=>{g.current?.focus()},[]),c.useEffect(()=>{n.calendarId!==""||I===""||r({type:"change",draft:{...n,calendarId:I}})},[n,I,r]),c.useEffect(()=>{s.status==="failed"&&N.current?.focus()},[s.status]);const L=c.useRef(null),B=c.useRef(null);se(o,()=>(r({type:"outside"}),!0));const k=`${n.range.date}T${n.range.startTime}/${n.range.endDate}T${n.range.endTime}`;c.useEffect(()=>{const a=B.current;if(k==="")return;const l=document.querySelector("[data-draft-block]"),b=document.querySelector("[role='grid'][aria-label='Time grid']");if(!a||!l||!b)return;const Z=l.getBoundingClientRect().bottom-a.getBoundingClientRect().top+16;Z>0&&(b.scrollTop+=Z)},[k]);const H=c.useRef(null);c.useEffect(()=>{const a=H.current;if(!a)return;const l=b=>{(b.target instanceof HTMLInputElement||b.target instanceof HTMLSelectElement)&&(L.current=b.target)};return a.addEventListener("focusin",l),()=>a.removeEventListener("focusin",l)},[]),c.useEffect(()=>{const a=L.current;k===""||!a||document.activeElement===a||a.focus()},[k]);const Y=()=>{if(d.title.trim()===""){v("Give the task a title before saving it."),g.current?.focus();return}v(""),r({type:"save"});const a=W(),l=d.dueTime==="";S({calendarId:d.calendarId,summary:d.title.trim(),description:d.description,allDay:l,due:l?d.dueDate:X(d.dueDate,d.dueTime,a),...l?{}:{timeZone:K(U)}}).then(b=>{if(b.kind==="written"){r({type:"saved"});return}r({type:"save-failed",problem:`Couldn't save the task: ${b.message}`})})},O=()=>{if(C==="task"){Y();return}const a=J(pe(n),{clock:W(),anchor:K(A[n.calendarId]??U)},t);if(!a.ok){v(a.problem),g.current?.focus();return}v(""),r({type:"save"}),w(a.input).then(l=>{if(l.kind==="created"){r({type:"saved"}),h.trackSends(l.sends),i(l.calendarObjectId);return}r({type:"save-failed",problem:l.kind==="conflict"?"This calendar changed while you were writing. Close the form and try again.":`Couldn't save this event: ${l.message}`})})},Q=a=>e.jsx("div",{ref:H,children:e.jsx(me,{headingId:u,mode:C,onMode:G,fields:n,taskFields:d,onTaskChange:p,calendars:y,taskLists:x,guestSuggestions:E,onGuestQuery:z,onChange:l=>r({type:"change",draft:l}),onSave:O,onMoreOptions:()=>m(L.current?.getAttribute("aria-label")??""),onClose:()=>r({type:"outside"}),saving:s.status==="saving",problem:T,failure:s.status==="failed"?{text:s.problem,reportHref:ee(s.problem),onRetry:O}:void 0,failureRef:N,titleRef:g,settingsHref:xe,dragHandle:a,touch:o})});return o?e.jsx(ge,{labelledBy:u,onDismiss:()=>r({type:"outside"}),sheetRef:B,children:Q()}):e.jsx(re,{anchor:"[data-draft-block]",anchorKey:k,labelledBy:u,wrapTab:!0,header:a=>Q(a),children:null})}export{we as C,pe as e};
@@ -1 +1 @@
1
- import{r as e}from"./index-Bn8n_AsE.js";const t=e.createContext(null);function s(){const n=e.useContext(t);if(!n)throw new Error("the calendar session is not mounted");return n}function r(){return e.useContext(t)}export{t as C,r as a,s as u};
1
+ import{r as e}from"./index-BZ4sAts4.js";const t=e.createContext(null);function s(){const n=e.useContext(t);if(!n)throw new Error("the calendar session is not mounted");return n}function r(){return e.useContext(t)}export{t as C,r as a,s as u};
@@ -1 +1 @@
1
- import{b as x,r as u,j as a,p as f,C as j,u as y,H as N,a7 as A,a8 as S}from"./index-Bn8n_AsE.js";import{u as h}from"./useLayoutTier-Cn3SwiV2.js";import{c as w,u as P}from"./nav-link-CtuHya9S.js";import"./reply-DmpF7cgR.js";import{a as k}from"./sections-DwdsQ0ad.js";import{A as C}from"./avatar-BgqBWztU.js";import{u as M,P as R,a as L,b as d}from"./popover-menu-iCbmrU-E.js";import{u as O}from"./roving-focus-CzX6YmR4.js";import{M as z}from"./mail-CPplAOgE.js";import{A as F}from"./app-chrome-DvUymvcE.js";const T=x("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 ae=x("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"}]]);function E({email:e,sections:s=[],onOpenSection:n,onSignOut:i}){const t=u.useRef(null),{open:r,setOpen:o,containerRef:c,panelRef:m,getAnchor:b}=M("account-menu",()=>t.current?.focus());u.useEffect(()=>{if(!r)return;const l=requestAnimationFrame(()=>m.current?.querySelector('[role="menuitem"]')?.focus());return()=>cancelAnimationFrame(l)},[r,m]);const p=e??"Account";return a.jsxs("div",{ref:c,className:"relative",children:[a.jsx("button",{ref:t,type:"button","aria-label":"Account","aria-haspopup":"menu","aria-expanded":r,onClick:()=>o(l=>!l),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:a.jsx(C,{name:p,email:e??void 0,size:"sm"})}),a.jsx(R,{open:r,align:"end",panelRef:m,getAnchor:b,children:a.jsxs(L,{ref:m,label:p,children:[e&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"truncate px-4 py-2 text-xs text-fg-muted",title:e,"data-testid":"account-menu-email",children:e}),a.jsx("hr",{className:"my-1 h-px border-0 bg-line"})]}),s.map(l=>a.jsx(d,{label:l.label,icon:l.icon,onSelect:()=>{o(!1),n?.(l.id)}},l.id)),a.jsx(d,{label:"Sign out",icon:a.jsx(T,{className:"size-4"}),onSelect:()=>{o(!1),t.current?.focus(),i()}})]})})]})}const D={mail:z,calendar:j},B="[data-app-item]",I=e=>e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey;function v({item:e,active:s,onNavigate:n,className:i,iconClassName:t}){const r=D[e.id];return a.jsxs("a",{href:e.href,"data-app-item":"","aria-current":s?"page":void 0,onClick:o=>{I(o)&&(o.preventDefault(),n(e.id))},className:f("flex flex-col items-center justify-center gap-0.5 rounded-lg outline-none transition-colors","focus-visible:ring-2 focus-visible:ring-ring",s?"bg-accent-soft text-accent":"text-fg-muted hover:bg-surface-sunken hover:text-fg",i),children:[a.jsx(r,{className:t,"aria-hidden":"true"}),a.jsx("span",{className:"text-2xs font-medium",children:e.label})]})}function K({items:e,active:s,onNavigate:n,className:i}){const t=u.useRef(null);return O({containerRef:t,itemSelector:B}),a.jsx("nav",{ref:t,"aria-label":"Apps",className:f("flex w-16 shrink-0 flex-col items-center gap-1 border-r border-line bg-surface py-2",i),children:e.map(r=>a.jsx(v,{item:r,active:r.id===s,onNavigate:n,className:"size-14",iconClassName:"size-5"},r.id))})}function q({items:e,active:s,onNavigate:n,className:i}){return a.jsx("nav",{"aria-label":"Apps",className:f("flex shrink-0 items-stretch justify-around border-t border-line bg-surface px-2 pt-1 pb-[max(0.25rem,env(safe-area-inset-bottom))]",i),children:e.map(t=>a.jsx(v,{item:t,active:t.id===s,onNavigate:n,className:"min-h-12 min-w-16 flex-1",iconClassName:"size-5"},t.id))})}function se({leading:e,search:s,actions:n,className:i}){return a.jsxs("header",{className:f("flex min-h-pane-header w-full shrink-0 items-center gap-2 border-b border-line bg-canvas px-row-inset py-1",i),children:[e&&a.jsx("div",{className:"flex shrink-0 items-center gap-1",children:e}),a.jsx("div",{className:"flex min-w-0 flex-1 justify-start",children:a.jsx("div",{className:"w-full max-w-xs transition-[max-width] duration-150 ease-out focus-within:max-w-lg",children:s})}),n&&a.jsx("div",{className:"flex shrink-0 items-center gap-1",children:n})]})}const V=e=>e.startsWith("/calendar")?"calendar":"mail";function g(){const e=y(),s=N(),n=w(),i=P({select:c=>c.pathname}),t=V(i),r=u.useMemo(()=>[{id:"mail",label:"Mail",href:s.buildLocation({to:"/mail",hash:n}).href},{id:"calendar",label:"Calendar",href:s.buildLocation({to:"/calendar",hash:n}).href}],[s,n]),o=u.useCallback(c=>{e({to:c==="calendar"?"/calendar":"/mail",hash:n})},[e,n]);return{items:r,active:t,switchTo:o}}function ne({children:e,hideTabBar:s=!1}){const n=h()==="phone",{items:i,active:t,switchTo:r}=g();return n?a.jsxs("div",{className:"flex h-full w-full flex-col",style:s?void 0:{"--app-tab-bar":"3.5rem"},children:[a.jsx("div",{className:"min-h-0 flex-1",children:e}),!s&&a.jsx(q,{items:i,active:t,onNavigate:r})]}):a.jsx(a.Fragment,{children:e})}const H=({children:e})=>{const{Account:s}=A();return a.jsx(s,{children:e})},te=()=>{const e=k(),s=S();return a.jsx(H,{children:({email:n,signOut:i})=>a.jsx(E,{email:n,sections:s.map(({id:t,label:r,icon:o})=>({id:t,label:r,icon:o})),onOpenSection:e,onSignOut:i})})};function _(){const{items:e,active:s,switchTo:n}=g();return a.jsx(K,{items:e,active:s,onNavigate:n})}function re({topBar:e,children:s}){return h()==="phone"?a.jsx(a.Fragment,{children:s}):a.jsx("div",{className:"flex h-full w-full flex-col overflow-hidden bg-canvas",children:a.jsx(F,{topBar:e,appBar:a.jsx(_,{}),children:s})})}export{se as A,re as D,T as L,ae as S,te as a,ne as b,H as c,_ as d};
1
+ import{b as x,r as u,j as a,p as f,C as j,u as y,H as N,a7 as A,a8 as S}from"./index-BZ4sAts4.js";import{u as h}from"./useLayoutTier-CnmLTkLg.js";import{c as w,u as P}from"./nav-link-BvBkmH1H.js";import"./reply-D8bLYzum.js";import{a as k}from"./sections-B9pteMHc.js";import{A as C}from"./avatar-CQq2GZz9.js";import{u as M,P as R,a as L,b as d}from"./popover-menu-uIVgxYG_.js";import{u as O}from"./roving-focus-1m_wY9_4.js";import{M as z}from"./mail-CRvRtCed.js";import{A as F}from"./app-chrome-CbZgCDW_.js";const T=x("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 ae=x("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"}]]);function E({email:e,sections:s=[],onOpenSection:n,onSignOut:i}){const t=u.useRef(null),{open:r,setOpen:o,containerRef:c,panelRef:m,getAnchor:b}=M("account-menu",()=>t.current?.focus());u.useEffect(()=>{if(!r)return;const l=requestAnimationFrame(()=>m.current?.querySelector('[role="menuitem"]')?.focus());return()=>cancelAnimationFrame(l)},[r,m]);const p=e??"Account";return a.jsxs("div",{ref:c,className:"relative",children:[a.jsx("button",{ref:t,type:"button","aria-label":"Account","aria-haspopup":"menu","aria-expanded":r,onClick:()=>o(l=>!l),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:a.jsx(C,{name:p,email:e??void 0,size:"sm"})}),a.jsx(R,{open:r,align:"end",panelRef:m,getAnchor:b,children:a.jsxs(L,{ref:m,label:p,children:[e&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"truncate px-4 py-2 text-xs text-fg-muted",title:e,"data-testid":"account-menu-email",children:e}),a.jsx("hr",{className:"my-1 h-px border-0 bg-line"})]}),s.map(l=>a.jsx(d,{label:l.label,icon:l.icon,onSelect:()=>{o(!1),n?.(l.id)}},l.id)),a.jsx(d,{label:"Sign out",icon:a.jsx(T,{className:"size-4"}),onSelect:()=>{o(!1),t.current?.focus(),i()}})]})})]})}const D={mail:z,calendar:j},B="[data-app-item]",I=e=>e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey;function v({item:e,active:s,onNavigate:n,className:i,iconClassName:t}){const r=D[e.id];return a.jsxs("a",{href:e.href,"data-app-item":"","aria-current":s?"page":void 0,onClick:o=>{I(o)&&(o.preventDefault(),n(e.id))},className:f("flex flex-col items-center justify-center gap-0.5 rounded-lg outline-none transition-colors","focus-visible:ring-2 focus-visible:ring-ring",s?"bg-accent-soft text-accent":"text-fg-muted hover:bg-surface-sunken hover:text-fg",i),children:[a.jsx(r,{className:t,"aria-hidden":"true"}),a.jsx("span",{className:"text-2xs font-medium",children:e.label})]})}function K({items:e,active:s,onNavigate:n,className:i}){const t=u.useRef(null);return O({containerRef:t,itemSelector:B}),a.jsx("nav",{ref:t,"aria-label":"Apps",className:f("flex w-16 shrink-0 flex-col items-center gap-1 border-r border-line bg-surface py-2",i),children:e.map(r=>a.jsx(v,{item:r,active:r.id===s,onNavigate:n,className:"size-14",iconClassName:"size-5"},r.id))})}function q({items:e,active:s,onNavigate:n,className:i}){return a.jsx("nav",{"aria-label":"Apps",className:f("flex shrink-0 items-stretch justify-around border-t border-line bg-surface px-2 pt-1 pb-[max(0.25rem,env(safe-area-inset-bottom))]",i),children:e.map(t=>a.jsx(v,{item:t,active:t.id===s,onNavigate:n,className:"min-h-12 min-w-16 flex-1",iconClassName:"size-5"},t.id))})}function se({leading:e,search:s,actions:n,className:i}){return a.jsxs("header",{className:f("flex min-h-pane-header w-full shrink-0 items-center gap-2 border-b border-line bg-canvas px-row-inset py-1",i),children:[e&&a.jsx("div",{className:"flex shrink-0 items-center gap-1",children:e}),a.jsx("div",{className:"flex min-w-0 flex-1 justify-start",children:a.jsx("div",{className:"w-full max-w-xs transition-[max-width] duration-150 ease-out focus-within:max-w-lg",children:s})}),n&&a.jsx("div",{className:"flex shrink-0 items-center gap-1",children:n})]})}const V=e=>e.startsWith("/calendar")?"calendar":"mail";function g(){const e=y(),s=N(),n=w(),i=P({select:c=>c.pathname}),t=V(i),r=u.useMemo(()=>[{id:"mail",label:"Mail",href:s.buildLocation({to:"/mail",hash:n}).href},{id:"calendar",label:"Calendar",href:s.buildLocation({to:"/calendar",hash:n}).href}],[s,n]),o=u.useCallback(c=>{e({to:c==="calendar"?"/calendar":"/mail",hash:n})},[e,n]);return{items:r,active:t,switchTo:o}}function ne({children:e,hideTabBar:s=!1}){const n=h()==="phone",{items:i,active:t,switchTo:r}=g();return n?a.jsxs("div",{className:"flex h-full w-full flex-col",style:s?void 0:{"--app-tab-bar":"3.5rem"},children:[a.jsx("div",{className:"min-h-0 flex-1",children:e}),!s&&a.jsx(q,{items:i,active:t,onNavigate:r})]}):a.jsx(a.Fragment,{children:e})}const H=({children:e})=>{const{Account:s}=A();return a.jsx(s,{children:e})},te=()=>{const e=k(),s=S();return a.jsx(H,{children:({email:n,signOut:i})=>a.jsx(E,{email:n,sections:s.map(({id:t,label:r,icon:o})=>({id:t,label:r,icon:o})),onOpenSection:e,onSignOut:i})})};function _(){const{items:e,active:s,switchTo:n}=g();return a.jsx(K,{items:e,active:s,onNavigate:n})}function re({topBar:e,children:s}){return h()==="phone"?a.jsx(a.Fragment,{children:s}):a.jsx("div",{className:"flex h-full w-full flex-col overflow-hidden bg-canvas",children:a.jsx(F,{topBar:e,appBar:a.jsx(_,{}),children:s})})}export{se as A,re as D,T as L,ae as S,te as a,ne as b,H as c,_ as d};
@@ -1 +1 @@
1
- import{r as o,n as d,j as s,p as l}from"./index-Bn8n_AsE.js";const m=({trigger:r,children:t,align:a="right"})=>{const[e,n]=o.useState(!1),i=o.useRef(null),c=o.useCallback(u=>{i.current&&!i.current.contains(u.target)&&n(!1)},[]);return d({id:"dropdown-menu",open:e,answers:{back:()=>n(!1)}}),o.useEffect(()=>(e&&document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)),[e,c]),s.jsxs("div",{ref:i,className:"relative",children:[s.jsx("button",{type:"button",onClick:u=>{u.stopPropagation(),n(!e)},className:l("p-1.5 min-h-11 min-w-11 inline-flex items-center justify-center rounded-md transition-colors","hover:bg-surface-raised text-fg-muted hover:text-fg"),children:r}),e&&s.jsx("div",{className:l("absolute z-50 mt-1 min-w-[180px] py-1","bg-surface border border-line rounded-md shadow-lg",a==="right"?"right-0":"left-0"),children:t})]})},f=({onClick:r,disabled:t,destructive:a,children:e})=>s.jsx("button",{type:"button",onClick:n=>{n.stopPropagation(),t||r()},disabled:t,className:l("w-full px-3 py-2 text-left text-sm transition-colors","flex items-center gap-2",t&&"opacity-50 cursor-not-allowed",!t&&"hover:bg-surface-raised",a&&"text-danger hover:text-danger"),children:e}),x=()=>s.jsx("div",{className:"my-1 h-px bg-line"});export{m as D,f as a,x as b};
1
+ import{r as o,n as d,j as s,p as l}from"./index-BZ4sAts4.js";const m=({trigger:r,children:t,align:a="right"})=>{const[e,n]=o.useState(!1),i=o.useRef(null),c=o.useCallback(u=>{i.current&&!i.current.contains(u.target)&&n(!1)},[]);return d({id:"dropdown-menu",open:e,answers:{back:()=>n(!1)}}),o.useEffect(()=>(e&&document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)),[e,c]),s.jsxs("div",{ref:i,className:"relative",children:[s.jsx("button",{type:"button",onClick:u=>{u.stopPropagation(),n(!e)},className:l("p-1.5 min-h-11 min-w-11 inline-flex items-center justify-center rounded-md transition-colors","hover:bg-surface-raised text-fg-muted hover:text-fg"),children:r}),e&&s.jsx("div",{className:l("absolute z-50 mt-1 min-w-[180px] py-1","bg-surface border border-line rounded-md shadow-lg",a==="right"?"right-0":"left-0"),children:t})]})},f=({onClick:r,disabled:t,destructive:a,children:e})=>s.jsx("button",{type:"button",onClick:n=>{n.stopPropagation(),t||r()},disabled:t,className:l("w-full px-3 py-2 text-left text-sm transition-colors","flex items-center gap-2",t&&"opacity-50 cursor-not-allowed",!t&&"hover:bg-surface-raised",a&&"text-danger hover:text-danger"),children:e}),x=()=>s.jsx("div",{className:"my-1 h-px bg-line"});export{m as D,f as a,x as b};
@@ -1 +1 @@
1
- import{j as e,aq as d,p as i,ad as l}from"./index-Bn8n_AsE.js";function x({clashes:t,clearText:s="Nothing else is booked over it.",className:a}){return t.length===0?e.jsxs("p",{className:i("flex items-center gap-2 rounded-md border border-line bg-surface-sunken p-2 text-xs text-fg-muted",a),children:[e.jsx(d,{className:"size-3.5 shrink-0 text-positive","aria-hidden":!0}),s]}):e.jsxs("div",{className:i("flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft p-2",a),children:[e.jsx(l,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-xs font-semibold text-danger",children:t.length===1?"This clashes with something you have already agreed to.":`This clashes with ${t.length} things you have already agreed to.`}),e.jsx("ul",{className:"mt-1 flex flex-col gap-0.5",children:t.map(r=>e.jsx("li",{className:"text-xs text-fg",children:r.label},r.id))})]})]})}const m=({message:t,icon:s})=>e.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:[s&&e.jsx("div",{className:"mb-4 text-fg-muted",children:s}),e.jsx("p",{className:"text-fg-muted",children:t})]});export{x as C,m as E};
1
+ import{j as e,aq as d,p as i,ad as l}from"./index-BZ4sAts4.js";function x({clashes:t,clearText:s="Nothing else is booked over it.",className:a}){return t.length===0?e.jsxs("p",{className:i("flex items-center gap-2 rounded-md border border-line bg-surface-sunken p-2 text-xs text-fg-muted",a),children:[e.jsx(d,{className:"size-3.5 shrink-0 text-positive","aria-hidden":!0}),s]}):e.jsxs("div",{className:i("flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft p-2",a),children:[e.jsx(l,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-xs font-semibold text-danger",children:t.length===1?"This clashes with something you have already agreed to.":`This clashes with ${t.length} things you have already agreed to.`}),e.jsx("ul",{className:"mt-1 flex flex-col gap-0.5",children:t.map(r=>e.jsx("li",{className:"text-xs text-fg",children:r.label},r.id))})]})]})}const m=({message:t,icon:s})=>e.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:[s&&e.jsx("div",{className:"mb-4 text-fg-muted",children:s}),e.jsx("p",{className:"text-fg-muted",children:t})]});export{x as C,m as E};
@@ -1 +1 @@
1
- import{j as t,v as r}from"./index-Bn8n_AsE.js";const d=e=>e instanceof Error?e.message:typeof e=="string"?e:typeof e=="object"&&e!==null&&"message"in e&&typeof e.message=="string"?e.message:"An unexpected error occurred",l=({title:e="Couldn't load content",error:a,onRetry:s,variant:i="block"})=>{const n=d(a);return i==="inline"?t.jsxs("div",{role:"alert",className:"flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-sm",children:[t.jsx(r,{className:"size-4 shrink-0 text-danger mt-0.5","aria-hidden":"true"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"font-medium text-danger",children:e}),t.jsx("p",{className:"text-fg-muted mt-0.5 break-words",children:n})]}),s&&t.jsx("button",{type:"button",onClick:s,className:"shrink-0 text-sm font-medium text-accent hover:underline",children:"Retry"})]}):t.jsxs("div",{role:"alert",className:"flex flex-col items-center justify-center gap-3 p-8 text-center",children:[t.jsx(r,{className:"size-8 text-danger","aria-hidden":"true"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium text-danger",children:e}),t.jsx("p",{className:"text-sm text-fg-muted mt-1 break-words",children:n})]}),s&&t.jsx("button",{type:"button",onClick:s,className:"inline-flex items-center rounded-md border border-line bg-canvas px-4 py-2 text-sm font-medium hover:bg-surface-raised transition-colors",children:"Retry"})]})};export{l as E,d as f};
1
+ import{j as t,v as r}from"./index-BZ4sAts4.js";const d=e=>e instanceof Error?e.message:typeof e=="string"?e:typeof e=="object"&&e!==null&&"message"in e&&typeof e.message=="string"?e.message:"An unexpected error occurred",l=({title:e="Couldn't load content",error:a,onRetry:s,variant:i="block"})=>{const n=d(a);return i==="inline"?t.jsxs("div",{role:"alert",className:"flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-sm",children:[t.jsx(r,{className:"size-4 shrink-0 text-danger mt-0.5","aria-hidden":"true"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"font-medium text-danger",children:e}),t.jsx("p",{className:"text-fg-muted mt-0.5 break-words",children:n})]}),s&&t.jsx("button",{type:"button",onClick:s,className:"shrink-0 text-sm font-medium text-accent hover:underline",children:"Retry"})]}):t.jsxs("div",{role:"alert",className:"flex flex-col items-center justify-center gap-3 p-8 text-center",children:[t.jsx(r,{className:"size-8 text-danger","aria-hidden":"true"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium text-danger",children:e}),t.jsx("p",{className:"text-sm text-fg-muted mt-1 break-words",children:n})]}),s&&t.jsx("button",{type:"button",onClick:s,className:"inline-flex items-center rounded-md border border-line bg-canvas px-4 py-2 text-sm font-medium hover:bg-surface-raised transition-colors",children:"Retry"})]})};export{l as E,d as f};
@@ -0,0 +1 @@
1
+ import{eM as U,r as n,e4 as X,a as le,J as z,c_ as ce,aw as ue,ax as ge,j as r}from"./index-BZ4sAts4.js";import{y as he,A as me,ao as pe,aq as fe,aA as xe,ar as Ie,d as Te,M as ye,ax as ve,aB as be,az as Re,m as Ce,G as Se,K as _,J as we,H as je,e as Fe,V as Me,W as H,X as Oe,Z,_ as $,$ as ke,a0 as Pe,a1 as Le}from"./MessageToolbar-D-FLeer4.js";import{u as Ae,l as Ne,b as De,a as qe}from"./MailViewChrome-B22GO2ZU.js";import"./nav-link-BvBkmH1H.js";import{a as Ee}from"./useMessageBodyContent-dd-lowbx.js";import{e as Be,f as We}from"./search-token-index-CoqsoQJZ.js";import{d as Qe,g as ze,r as He}from"./reply-D8bLYzum.js";import{u as Ke}from"./sections-B9pteMHc.js";import{u as Ve}from"./useMediaQuery-D3m_n689.js";import{u as Ge,p as J,R as _e}from"./MessageBody-DbkrLz4x.js";import{d as Je,w as Ue}from"./wizard-selection-zWa1qc6-.js";import{f as Xe}from"./ErrorState-nIG-x-Zh.js";const K=t=>({...t,starred:!0,order:"desc"}),Ze=(t={})=>X({query:K(t)});function Y(t={}){const{data:e,isLoading:s,isError:a,error:i,refetch:f,fetchNextPage:l,hasNextPage:g,isFetchingNextPage:o}=Ae({queryKey:Ze(t),queryFn:async({pageParam:x})=>{const{data:u}=await U({query:{...K(t),continuationToken:x},throwOnError:!0});return u},initialPageParam:void 0,getNextPageParam:x=>x.continuationToken,staleTime:6e4});return{threads:n.useMemo(()=>(e?.pages??[]).flatMap(x=>x.items??[]),[e]),isLoading:s,isError:a,error:i,refetch:f,fetchNextPage:l,hasNextPage:g,isFetchingNextPage:o}}function $e(t={}){const e={...K(t),unread:!0,count:!0,results:!1},{data:s}=le({queryKey:X({query:e}),queryFn:async()=>{const{data:a}=await U({query:e,throwOnError:!0});return a},staleTime:6e4});return s?.count}const Ye=["from","subject","category","unread","starred","attachments"],et=(t,e)=>{const s=he(t),{params:a,residual:i}=me(e,{...s,starred:!0},Ye);return{criteria:{...a,...s},residual:i}};function tt({rows:t,verb:e}){const{selectedIds:s,exitSelection:a}=Re(),i=n.useMemo(()=>Ue(t,s),[t,s]);return r.jsx(Ce,{verb:e,selection:i,selectionRestriction:"spansAccounts",onFinished:a})}function st({selectedMessageId:t,onOpenThread:e,commandsRef:s,onTriageContextChange:a,onDeleteMessages:i}){const{searchQuery:f,resultFolderIndex:l,onSearchClearQuery:g}=z(),o=Ge(),k=Ve(),x=ce(),[u,h]=n.useState("all"),[v,P]=n.useState(new Set),S=n.useCallback(d=>{P(C=>{const I=new Set(C);return I.has(d)?I.delete(d):I.add(d),I})},[]),w=n.useCallback(()=>{h("all"),P(new Set)},[]),T=n.useCallback(()=>{w(),g()},[w,g]),{freeText:j,tokens:b}=J(f.trim().toLowerCase(),o),L=J(f.trim(),o).freeText,{criteria:A,residual:m}=n.useMemo(()=>et({category:u,attributes:v},b),[u,v,b]),F=n.useMemo(()=>j?{...A,query:j}:A,[A,j]),{threads:N,isLoading:D,isError:y,error:E,refetch:M,fetchNextPage:B,hasNextPage:W,isFetchingNextPage:O}=Y(F),p=n.useMemo(()=>Je(N).map(pe).filter(d=>fe(d,m)),[N,m]),c=n.useCallback((d,C)=>{const I=p.find(de=>de.id===d)?.threadId;I&&e?.({threadId:I,messageId:d},C)},[p,e]),R=n.useCallback(d=>{const C=d.threadId??p.find(I=>I.id===d.id)?.threadId;C&&e?.({threadId:C,messageId:d.id})},[p,e]),Q=n.useMemo(()=>xe(),[]),se=n.useMemo(()=>p.map(d=>Ie(d,l)),[p,l]),ae=$e(F)??null,re=n.useMemo(()=>b.filter(d=>d.type!=="isStarred"),[b]),oe=Ne({chips:{category:u,attributes:v},tokens:re,reach:m.length>0?"loaded-pages":"whole-folder",onClear:T}),V=D?"loading":y?"error":p.length===0?"empty":"ready",ne=n.useCallback(()=>{const d=ue(ge());window.open(d,"_blank","noopener,noreferrer")},[]),G=Te(),ie=r.jsx("div",{className:"flex h-full min-h-0 flex-col",children:r.jsxs("div",{className:"flex-1 overflow-y-auto",children:[r.jsx("div",{className:"divide-y divide-line",children:p.map(d=>r.jsx(ye,{thread:d,active:d.id===t,onClick:()=>c(d.id)},d.id))}),W?r.jsx("button",{type:"button",className:"w-full py-3 text-sm text-muted hover:text-fg disabled:opacity-50",onClick:()=>B(),disabled:O,children:O?"Loading…":"Load more"}):null]})});return r.jsx(De,{title:"Starred",unreadCount:ae,preset:Q,selectedCategory:u,activeFilters:v,onSelectCategory:h,onToggleFilter:S,onClearFilters:w,searchResults:se,searchLoading:D,onSelectSearchResult:R,searchResultsInBody:!0,children:r.jsxs(ve,{selectedMessageId:t,rows:p,onOpen:c,onDeleteMessages:i,onSelectionVerb:x.start,commandsRef:s,onTriageContextChange:a,children:[r.jsx(qe,{listTitle:"Starred",sections:[{id:"flagged",threads:p}],flatList:!0,hideHeader:!0,listState:G.searchResults?"ready":V,listFilter:oe,listScopeLabel:"Starred",searchQuery:L||void 0,errorMessage:y?Xe(E):void 0,onRetry:()=>M(),onReportError:ne,selectedThreadId:t,onSelectThread:c,isDesktop:k,selectionBar:r.jsx(be,{title:"Starred"}),listBody:G.searchResults??(V==="ready"?ie:void 0)}),r.jsx(tt,{rows:p,verb:x.verb})]})})}const ee=n.createContext(null);function q(){const t=n.useContext(ee);if(!t)throw new Error("FlaggedPane.* must be used inside <FlaggedPane>");return t}function at({thread:t,children:e}){const s=Be(),a=We(),i=Ke(),{searchInput:f}=z(),l=t?.threadId,g=t?.messageId,{threads:o}=Y(),k=n.useMemo(()=>{if(l)return o.find(c=>c.messageId===g)??o.find(c=>c.threadId===l)},[o,l,g]),x=Se(l,g),u=k??x,h=g??u?.messageId,v=n.useMemo(()=>{if(l)return{threadId:l,mailboxId:u?.mailboxId??"",subject:u?.subject,messageId:h,authenticity:u?.authenticity}},[l,u,h]),P=n.useCallback((c,R)=>{s(c,{replace:R?.replace,query:f})},[s,f]),S=n.useCallback(c=>{h&&c.includes(h)&&a()},[h,a]),w=_({thread:u,isOpen:!0,onAfterOptimisticRemove:S}),T=we(),{deleteMessages:j}=je({mailboxId:u?.mailboxId??"",messages:o,onAfterOptimisticRemove:S}),{toggleReadFor:b}=Fe({mailboxId:u?.mailboxId??"",messages:o}),L=T.focusedMessageId,m=n.useMemo(()=>o.find(c=>c.messageId===L),[o,L])??u,F=_({thread:m,isOpen:m?.messageId===h}),N=Ee(),D=Qe(),y=ze(),E=n.useMemo(()=>He(y,l,h),[y,l,h]),M=n.useMemo(()=>{if(m)return c=>y({threadId:m.threadId,messageId:m.messageId,mode:c})},[y,m]),{nextMessageId:B,previousMessageId:W}=Me({context:T,orderedIds:T.orderedIds,selectedMessageId:h,enabled:!N&&!D,hasOpenThread:l!==void 0,onClose:a,handlers:{reply:()=>M?.("reply"),replyAll:()=>M?.("reply-all"),forward:()=>M?.("forward"),delete:()=>{T.listCommandsRef.current?.requestVerb("delete")||F.deleteThread()},toggleStar:F.toggleStar,toggleRead:()=>{T.listCommandsRef.current?.requestVerb("markRead")||m&&b([m.messageId],!m.isRead)},goBrief:()=>i("brief"),goSettings:()=>i("settings")}}),O=n.useCallback(c=>{if(!c)return;const R=o.find(Q=>Q.messageId===c);return R?{threadId:R.threadId,messageId:c}:void 0},[o]),p={selectedMessageId:h,selectedThread:u,conversation:v,onOpenThread:P,onCloseThread:a,nextThread:O(B),previousThread:O(W),actions:w,onReply:E,triage:T,onDeleteMessages:j,handleDeselectIfRemoved:S};return r.jsx(ee.Provider,{value:p,children:e})}function te(){const{selectedMessageId:t,onOpenThread:e,triage:s,onDeleteMessages:a}=q();return r.jsx(st,{selectedMessageId:t,onOpenThread:e,commandsRef:s.listCommandsRef,onTriageContextChange:s.onTriageContextChange,onDeleteMessages:a})}function rt(){const t=H(),{conversation:e,selectedThread:s,actions:a,onReply:i,handleDeselectIfRemoved:f,onOpenThread:l}=q(),g=!!e,o=Pe(e?.threadId);return r.jsxs(r.Fragment,{children:[r.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[r.jsx(Le,{hasThread:g,intelligenceOpen:o.isShowing,canToggleIntelligence:o.canToggle,onToggleIntelligence:o.toggle,onReply:i?()=>i("reply"):void 0,onReplyAll:i?()=>i("reply-all"):void 0,onForward:i?()=>i("forward"):void 0,onDelete:g?a.deleteThread:void 0,onToggleStar:g?a.toggleStar:void 0,isStarred:a.isStarred,moveContext:g&&a.accountId&&a.mailboxId?{accountId:a.accountId,currentMailboxId:a.mailboxId,onMove:a.moveThread}:void 0}),r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e?r.jsx(Z,{threadId:e.threadId,mailboxId:e.mailboxId,subject:e.subject,selectedMessageId:e.messageId,authenticity:e.authenticity,onOpenIntelligence:o.open,listOnScreen:!0}):r.jsx(_e,{})})]}),r.jsx($,{isOpen:o.drawerOpen,onClose:o.closeDrawer,thread:s,accountId:s?.accountId,onAfterOptimisticRemove:f,onReplyWithText:t,onOpenThread:l})]})}function ot(){const t=H(),{selectedThread:e,handleDeselectIfRemoved:s,onOpenThread:a}=q(),{onToggleIntelligence:i}=z();return r.jsx(ke,{onClose:i,thread:e,accountId:e?.accountId,onAfterOptimisticRemove:s,onReplyWithText:t,onOpenThread:a})}function nt(){const t=H(),{selectedThread:e,conversation:s,onCloseThread:a,onOpenThread:i,nextThread:f,previousThread:l,handleDeselectIfRemoved:g}=q(),o=Oe(s?.threadId??null);return s?r.jsxs(r.Fragment,{children:[r.jsx(Z,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onBack:a,onOpenIntelligence:o.toggle,onSwipeNext:f?()=>i(f):void 0,onSwipePrevious:l?()=>i(l):void 0,mobileIntelligenceOpen:o.isOpen}),r.jsx($,{isOpen:o.isOpen,onClose:o.close,thread:e,accountId:e?.accountId,onAfterOptimisticRemove:g,onReplyWithText:t,onOpenThread:i})]}):r.jsx("div",{className:"h-full",children:r.jsx(te,{})})}const Tt=Object.assign(at,{List:te,Reading:rt,Intelligence:ot,Phone:nt});export{Tt as F};
@@ -1 +1 @@
1
- import{r as n,a as f,c as m,n as N,j as e,X as w}from"./index-Bn8n_AsE.js";import{D as r,C as u,u as E}from"./index-k6LzEquX.js";import{u as k}from"./useMediaQuery-C00TiD5k.js";import"./nav-link-CtuHya9S.js";import{d as x,e as p,f as h}from"./useMessageBodyContent-lqVkO1fM.js";import"./reply-DmpF7cgR.js";import{E as b}from"./ErrorState-BXxvOnci.js";import{C as S}from"./confirm-dialog-sa45Xnmn.js";const C=t=>t?"Draft":"New Message",I=()=>{const t=n.useRef(!1);return n.useCallback(()=>{const s=document.querySelector("[data-subject-field]")?.value??"",o=(document.querySelector('[data-testid="compose-body"]')?.textContent??"").replace(/--\s*/g,"").trim();return t.current=s.trim().length>0||o.length>0,t.current},[])},O=()=>{const t=x(),i=p(),s=h(),a=I(),[l,o]=n.useState(!1),{isError:d,error:c,refetch:g}=f({...m(),staleTime:1/0}),j=n.useCallback(D=>{D||(a()?o(!0):s())},[s,a]),y=n.useCallback(()=>{o(!1),s()},[s]),v=n.useCallback(()=>{o(!1)},[]);return N({id:"mobile-compose",open:!0}),e.jsxs(r.Root,{open:!0,onOpenChange:j,children:[e.jsxs(r.Portal,{children:[e.jsx(r.Overlay,{className:"fixed inset-0 z-40 bg-black/40"}),e.jsxs(r.Content,{className:"fixed inset-x-0 bottom-0 z-50 flex flex-col rounded-t-lg bg-canvas pb-[env(safe-area-inset-bottom,0px)]",style:{height:"95dvh"},children:[e.jsx(r.Handle,{className:"mx-auto mt-2 mb-1 h-1.5 w-12 rounded-full bg-fg-muted/30"}),e.jsx(r.Title,{className:"px-4 py-2 text-base font-semibold border-b border-line",children:C(t)}),d?e.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:e.jsx(b,{title:"Couldn't load compose",error:c,onRetry:()=>{g()}})}):e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(u,{mode:"new",outboxMessageId:t,onDraftCreated:i,onClose:s})})]})]}),e.jsx(S,{isOpen:l,title:"Discard draft?",description:"Your message has unsaved content. Are you sure you want to discard it?",confirmLabel:"Discard",cancelLabel:"Keep editing",destructive:!0,onConfirm:y,onCancel:v})]})},L=()=>{const t=x(),i=p(),s=h(),a=k(),{isError:l,error:o,refetch:d}=f({...m(),staleTime:1/0});if(E({bindings:[{key:"Escape",handler:s,preventDefault:!0}]}),!a)return e.jsx(O,{});const c=e.jsxs("header",{className:"flex items-center justify-between gap-2 px-4 py-3 border-b border-line shrink-0",children:[e.jsx("div",{className:"flex items-center gap-2 min-w-0",children:e.jsx("h2",{className:"text-lg font-semibold truncate",children:C(t)})}),e.jsx("button",{type:"button",onClick:s,className:"p-2 rounded-md hover:bg-surface-raised transition-colors min-h-11 min-w-11 inline-flex items-center justify-center","aria-label":"Close",children:e.jsx(w,{className:"size-5"})})]});return l?e.jsxs("div",{className:"h-full flex flex-col bg-canvas",children:[c,e.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:e.jsx(b,{title:"Couldn't load compose",error:o,onRetry:()=>{d()}})})]}):e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-canvas",children:[c,e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(u,{mode:"new",outboxMessageId:t,onDraftCreated:i,onClose:s})})]})};export{L as F};
1
+ import{r as n,a as f,c as m,n as N,j as e,X as w}from"./index-BZ4sAts4.js";import{D as r,C as u,u as E}from"./index-CrUfJlwk.js";import{u as k}from"./useMediaQuery-D3m_n689.js";import"./nav-link-BvBkmH1H.js";import{d as x,e as p,f as h}from"./useMessageBodyContent-dd-lowbx.js";import"./reply-D8bLYzum.js";import{E as b}from"./ErrorState-nIG-x-Zh.js";import{C as S}from"./confirm-dialog-B0MVMPmn.js";const C=t=>t?"Draft":"New Message",I=()=>{const t=n.useRef(!1);return n.useCallback(()=>{const s=document.querySelector("[data-subject-field]")?.value??"",o=(document.querySelector('[data-testid="compose-body"]')?.textContent??"").replace(/--\s*/g,"").trim();return t.current=s.trim().length>0||o.length>0,t.current},[])},O=()=>{const t=x(),i=p(),s=h(),a=I(),[l,o]=n.useState(!1),{isError:d,error:c,refetch:g}=f({...m(),staleTime:1/0}),j=n.useCallback(D=>{D||(a()?o(!0):s())},[s,a]),y=n.useCallback(()=>{o(!1),s()},[s]),v=n.useCallback(()=>{o(!1)},[]);return N({id:"mobile-compose",open:!0}),e.jsxs(r.Root,{open:!0,onOpenChange:j,children:[e.jsxs(r.Portal,{children:[e.jsx(r.Overlay,{className:"fixed inset-0 z-40 bg-black/40"}),e.jsxs(r.Content,{className:"fixed inset-x-0 bottom-0 z-50 flex flex-col rounded-t-lg bg-canvas pb-[env(safe-area-inset-bottom,0px)]",style:{height:"95dvh"},children:[e.jsx(r.Handle,{className:"mx-auto mt-2 mb-1 h-1.5 w-12 rounded-full bg-fg-muted/30"}),e.jsx(r.Title,{className:"px-4 py-2 text-base font-semibold border-b border-line",children:C(t)}),d?e.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:e.jsx(b,{title:"Couldn't load compose",error:c,onRetry:()=>{g()}})}):e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(u,{mode:"new",outboxMessageId:t,onDraftCreated:i,onClose:s})})]})]}),e.jsx(S,{isOpen:l,title:"Discard draft?",description:"Your message has unsaved content. Are you sure you want to discard it?",confirmLabel:"Discard",cancelLabel:"Keep editing",destructive:!0,onConfirm:y,onCancel:v})]})},L=()=>{const t=x(),i=p(),s=h(),a=k(),{isError:l,error:o,refetch:d}=f({...m(),staleTime:1/0});if(E({bindings:[{key:"Escape",handler:s,preventDefault:!0}]}),!a)return e.jsx(O,{});const c=e.jsxs("header",{className:"flex items-center justify-between gap-2 px-4 py-3 border-b border-line shrink-0",children:[e.jsx("div",{className:"flex items-center gap-2 min-w-0",children:e.jsx("h2",{className:"text-lg font-semibold truncate",children:C(t)})}),e.jsx("button",{type:"button",onClick:s,className:"p-2 rounded-md hover:bg-surface-raised transition-colors min-h-11 min-w-11 inline-flex items-center justify-center","aria-label":"Close",children:e.jsx(w,{className:"size-5"})})]});return l?e.jsxs("div",{className:"h-full flex flex-col bg-canvas",children:[c,e.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:e.jsx(b,{title:"Couldn't load compose",error:o,onRetry:()=>{d()}})})]}):e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-canvas",children:[c,e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(u,{mode:"new",outboxMessageId:t,onDraftCreated:i,onClose:s})})]})};export{L as F};
@@ -1 +1 @@
1
- import{e as f,ak as g,f as b,P as y,Q as v,ck as x,ed as L,r as p,dy as h,j as c,ee as C}from"./index-Bn8n_AsE.js";import{am as k}from"./MessageToolbar-BW852rJj.js";import{a as M}from"./useLabels-DO4UWjpG.js";import{a as d,i as E}from"./label-chip-BnNtXrWd.js";import{c as A}from"./popover-menu-iCbmrU-E.js";const I=3,_=({hasSearchQuery:e,freeText:t,residualTokenCount:s})=>{if(!e||s>0)return!1;const a=t.trim();return a.length===0||a.length>=I},z=e=>e===void 0?{kind:"unknown"}:{kind:"exact",value:e},Q=e=>{const t=new Set;for(const s of e)s&&t.add(s);return t.size>1?{accountId:void 0,restriction:"spansAccounts",moveDisabledHint:"Move only works within one account — clear selection or pick messages from a single account"}:{accountId:t.size===1?[...t][0]:void 0,restriction:void 0,moveDisabledHint:void 0}},j=e=>{const{mailboxId:t,messages:s}=e,a=f(),{pushError:l}=g(),{mutateAsync:r,isPending:o}=b({...L(),onError:(n,i)=>{l({title:i.body.action==="Remove"?"Couldn't remove label":"Couldn't apply label",detail:x(n),error:n})},onSettled:(n,i,u)=>{y(a,v(k(u.body.messageIds??[],s??[],t)))}});return{applyLabel:p.useCallback((n,i,u)=>{n.length!==0&&h(n,m=>r({body:{messageIds:m,labelId:i,action:u}}))},[r]),isPending:o}};function H({accountId:e,mailboxId:t,messageIds:s}){const{labels:a}=M(e),{applyLabel:l}=j({mailboxId:t}),r=p.useMemo(()=>a.map(o=>({key:o.labelId,label:o.name,icon:c.jsx("span",{className:`size-2.5 rounded-full ${E(o.color)?d[o.color]:d.Default}`}),onSelect:()=>l(s,o.labelId,"Apply")})),[a,s,l]);return r.length===0?null:c.jsx(A,{triggerLabel:"Apply label to selected messages",triggerIcon:c.jsx(C,{className:"size-4 text-fg-subtle"}),triggerText:"Apply label",items:r,align:"start",nested:!0,touch:!1,triggerClassName:"min-h-11 w-full justify-start gap-3 px-4 py-2.5 text-sm font-normal text-fg"})}export{H as L,Q as r,_ as s,z as t};
1
+ import{e as f,ak as g,f as b,P as y,Q as v,ck as x,ed as L,r as p,dx as h,j as c,ee as C}from"./index-BZ4sAts4.js";import{am as k}from"./MessageToolbar-D-FLeer4.js";import{a as M}from"./useLabels-CGCEGKuz.js";import{a as d,i as E}from"./label-chip-BBPaslky.js";import{c as A}from"./popover-menu-uIVgxYG_.js";const I=3,_=({hasSearchQuery:e,freeText:t,residualTokenCount:s})=>{if(!e||s>0)return!1;const a=t.trim();return a.length===0||a.length>=I},z=e=>e===void 0?{kind:"unknown"}:{kind:"exact",value:e},Q=e=>{const t=new Set;for(const s of e)s&&t.add(s);return t.size>1?{accountId:void 0,restriction:"spansAccounts",moveDisabledHint:"Move only works within one account — clear selection or pick messages from a single account"}:{accountId:t.size===1?[...t][0]:void 0,restriction:void 0,moveDisabledHint:void 0}},j=e=>{const{mailboxId:t,messages:s}=e,a=f(),{pushError:l}=g(),{mutateAsync:r,isPending:o}=b({...L(),onError:(n,i)=>{l({title:i.body.action==="Remove"?"Couldn't remove label":"Couldn't apply label",detail:x(n),error:n})},onSettled:(n,i,u)=>{y(a,v(k(u.body.messageIds??[],s??[],t)))}});return{applyLabel:p.useCallback((n,i,u)=>{n.length!==0&&h(n,m=>r({body:{messageIds:m,labelId:i,action:u}}))},[r]),isPending:o}};function H({accountId:e,mailboxId:t,messageIds:s}){const{labels:a}=M(e),{applyLabel:l}=j({mailboxId:t}),r=p.useMemo(()=>a.map(o=>({key:o.labelId,label:o.name,icon:c.jsx("span",{className:`size-2.5 rounded-full ${E(o.color)?d[o.color]:d.Default}`}),onSelect:()=>l(s,o.labelId,"Apply")})),[a,s,l]);return r.length===0?null:c.jsx(A,{triggerLabel:"Apply label to selected messages",triggerIcon:c.jsx(C,{className:"size-4 text-fg-subtle"}),triggerText:"Apply label",items:r,align:"start",nested:!0,touch:!1,triggerClassName:"min-h-11 w-full justify-start gap-3 px-4 py-2.5 text-sm font-normal text-fg"})}export{H as L,Q as r,_ as s,z as t};
@@ -1 +1 @@
1
- import{l as m}from"./reply-DmpF7cgR.js";import{j as r,r as u,A as l}from"./index-Bn8n_AsE.js";import"./nav-link-CtuHya9S.js";import{a as v}from"./useMessageBodyContent-lqVkO1fM.js";import{F as x}from"./FullCompose-DEhDpjci.js";import{A as p}from"./search-scope-Cl87snrn.js";function C(o,n,s){if(o!==n)return s}function M(o,n){return o===""?"":n}function A({searchInput:o,committedQuery:n,urlQuery:s,pathname:t,listPath:a}){return!m(t,a)||n!==o?!1:n!==s}const c=u.createContext(null),B=({chrome:o,children:n})=>r.jsx(c.Provider,{value:o,children:n});function N({phone:o,list:n,reading:s,intelligence:t,hasThread:a=!1}){const e=u.useContext(c),f=v();if(!e)return r.jsx(l,{});const i={nav:e.nav,appBar:e.appBar,overlay:e.overlay,skeleton:r.jsx(l,{}),isLoading:e.isLoading,navOpen:e.navOpen,onOpenNav:e.onOpenNav,onCloseNav:e.onCloseNav};return e.isSinglePane?r.jsx(p,{...i,list:f?r.jsx(x,{}):o,intelligenceOpen:e.intelligenceOpen}):r.jsx(p,{...i,topBar:e.topBar,list:n,reading:s,intelligence:t,intelligenceOpen:e.intelligenceOpen,hasThread:a})}export{B as M,N as a,A as b,M as c,C as s};
1
+ import{l as m}from"./reply-D8bLYzum.js";import{j as r,r as u,A as l}from"./index-BZ4sAts4.js";import"./nav-link-BvBkmH1H.js";import{a as v}from"./useMessageBodyContent-dd-lowbx.js";import{F as x}from"./FullCompose-D5JLo7Rb.js";import{A as p}from"./search-scope-BR87UqJt.js";function C(o,n,s){if(o!==n)return s}function M(o,n){return o===""?"":n}function A({searchInput:o,committedQuery:n,urlQuery:s,pathname:t,listPath:a}){return!m(t,a)||n!==o?!1:n!==s}const c=u.createContext(null),B=({chrome:o,children:n})=>r.jsx(c.Provider,{value:o,children:n});function N({phone:o,list:n,reading:s,intelligence:t,hasThread:a=!1}){const e=u.useContext(c),f=v();if(!e)return r.jsx(l,{});const i={nav:e.nav,appBar:e.appBar,overlay:e.overlay,skeleton:r.jsx(l,{}),isLoading:e.isLoading,navOpen:e.navOpen,onOpenNav:e.onOpenNav,onCloseNav:e.onCloseNav};return e.isSinglePane?r.jsx(p,{...i,list:f?r.jsx(x,{}):o,intelligenceOpen:e.intelligenceOpen}):r.jsx(p,{...i,topBar:e.topBar,list:n,reading:s,intelligence:t,intelligenceOpen:e.intelligenceOpen,hasThread:a})}export{B as M,N as a,A as b,M as c,C as s};
@@ -1 +1 @@
1
- import{j as s,L as oe,B as A,v as ce,r as f,p as K,aq as le,T as ue,cH as de,d5 as fe,d6 as me,d7 as xe,J as ge}from"./index-Bn8n_AsE.js";import{j as he,k as pe}from"./search-token-index-BSaB7qLo.js";import{u as be,L as Q}from"./roving-focus-CzX6YmR4.js";import{a6 as ve,c as je,C as U,a7 as we,a8 as Ne,a9 as ye,aa as Re,ab as Pe,ac as Ce,o as Se,ad as ke,ae as Ee,af as Me,ag as Te,ah as Ie,ai as Y,aj as Oe,ak as Le,al as De}from"./MessageToolbar-BW852rJj.js";import{k as Ae}from"./search-scope-Cl87snrn.js";import{a as $e,S as ze,b as _e}from"./MessageBody-CDTfM1lc.js";import{A as He}from"./avatar-BgqBWztU.js";import{M as Fe}from"./mail-CPplAOgE.js";import{R as Be}from"./refresh-cw-CUyjBEl4.js";import{M as We}from"./menu-znX-3dzE.js";function Ge(){return s.jsx("div",{className:"space-y-0",role:"status","aria-busy":"true","aria-label":"Loading messages",children:Array.from({length:8}).map((e,t)=>s.jsxs("div",{className:"animate-pulse border-b border-line px-3 py-2",children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[s.jsx("div",{className:"h-4 w-32 rounded bg-surface-sunken"}),s.jsx("div",{className:"h-3 w-16 rounded bg-surface-sunken"})]}),s.jsx("div",{className:"mb-2 h-4 w-48 rounded bg-surface-sunken"}),s.jsx("div",{className:"h-3 w-full rounded bg-surface-sunken"})]},t))})}function Ke({filter:e,scopeLabel:t,searchQuery:n}){const l=n?.trim();return e?s.jsxs(X,{children:[s.jsx("p",{className:"font-medium text-fg",children:Xe(e.label,t,l)}),s.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:Qe[e.reach]}),s.jsx(A,{variant:"secondary",size:"sm",className:"mt-4",onClick:e.onClear,children:"Clear filter"})]}):s.jsx(X,{children:s.jsx("p",{className:"text-fg-muted",children:Ue(l,t)})})}const Qe={"whole-folder":"Every message in this folder was checked.","loaded-pages":"Only the messages loaded so far were checked."};function Ue(e,t){return e?"No messages match your search":t?`No messages in ${t}`:"No messages in this mailbox"}function Xe(e,t,n){return n?`No results for “${n}” in ${e}`:t?`No ${e} in ${t}`:`No ${e}`}function X({children:e}){return s.jsx("div",{className:"flex h-full flex-1 items-center justify-center",children:s.jsx("div",{className:"flex max-w-sm flex-col items-center justify-center p-8 text-center",children:e})})}function hs(){return s.jsxs("div",{className:"flex items-center justify-center gap-2 py-4 text-sm text-fg-muted",role:"status","aria-live":"polite",children:[s.jsx(oe,{className:"size-4 animate-spin","aria-hidden":"true"}),s.jsx("span",{children:"Loading more…"})]})}function qe({message:e="Something went wrong loading this mailbox.",onRetry:t,onReport:n}){return s.jsx("div",{className:"flex h-full flex-1 items-center justify-center p-4",children:s.jsxs("div",{role:"alert",className:"flex max-w-sm flex-col items-center justify-center gap-3 text-center",children:[s.jsx(ce,{className:"size-8 text-danger","aria-hidden":"true"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium text-danger",children:"Couldn't load messages"}),s.jsx("p",{className:"mt-1 break-words text-sm text-fg-muted",children:e})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[t&&s.jsx(A,{variant:"secondary",size:"sm",onClick:t,children:"Retry"}),n&&s.jsx(A,{variant:"ghost",size:"sm",onClick:n,children:"Report a problem"})]})]})})}const I=72;function q(e){return e==="leading"?I:e==="trailing"?-I:0}function Ye(e){return e>=I/2?"leading":e<=-I/2?"trailing":"none"}function Je({thread:e,selectionMode:t,checked:n,active:l,peek:u,onPeek:o,onToggleCheck:x,onLongPress:w,onOpen:g,onAct:h}){const[p,N]=f.useState(null),b=f.useRef(null),m=f.useRef(!1),P=i=>{b.current=i,N(i)},v=i=>{const k=b.current,O=m.current;if(m.current=!1,P(null),!(i.event.type.endsWith("cancel")||O)){if(i.tap){if(t){x();return}if(u!=="none"){o("none");return}g();return}i.axis!=="x"||t||k===null||o(Ye(k))}},R=$e(i=>{if(!i.down){v(i);return}if(Pe(i)){if(t)return;m.current=!0,Ce(),w();return}if(!i.intentional||t||m.current||i.axis!=="x")return;const k=i.values[0]-i.initial[0];P(Math.max(-I,Math.min(I,q(u)+k)))},{...ye(Re),tapsThreshold:_e,axisThreshold:ze.axisThreshold}),y=ve(R(),Ne,{"aria-description":t?void 0:"Select message"}),j=p??q(u),a=j>0?"leading":j<0?"trailing":"none",d=K("relative touch-pan-y bg-surface","select-none",je({active:n||l})),C={transform:j!==0?`translateX(${j}px)`:void 0,transition:p===null?"transform 150ms ease":"none",minHeight:44},S=!e.isRead,M=i=>i.stopPropagation(),$=t?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:K("inline-flex size-7 shrink-0 items-center justify-center rounded-full border",n?"border-accent bg-accent text-accent-fg":"border-line-strong bg-canvas"),children:n&&s.jsx(le,{className:"size-3.5"})}),s.jsx(U,{thread:e})]}):s.jsxs(s.Fragment,{children:[S&&s.jsx("span",{className:"absolute left-1.5 top-1/2 size-1.5 -translate-y-1/2 rounded-full bg-accent"}),s.jsx("span",{role:"checkbox",tabIndex:0,"aria-checked":n,"aria-label":`Select message from ${e.fromName}`,onPointerDown:M,onPointerMove:M,onPointerUp:M,onClick:i=>{i.preventDefault(),i.stopPropagation(),w()},onKeyDown:i=>{i.key!=="Enter"&&i.key!==" "||(i.preventDefault(),i.stopPropagation(),w())},className:"-m-2 inline-flex size-11 shrink-0 items-center justify-center rounded-full",children:s.jsx(He,{name:e.fromName,email:e.fromEmail,size:"sm"})}),s.jsx(U,{thread:e})]});return s.jsxs("div",{className:"relative overflow-hidden",children:[a==="leading"&&s.jsx("button",{type:"button",onClick:()=>h("leading"),"aria-label":e.isRead?"Mark as unread":"Mark as read",className:"absolute inset-y-0 left-0 flex items-center justify-start bg-accent-2 px-6 text-accent-fg",children:e.isRead?s.jsx(Fe,{className:"size-6"}):s.jsx(we,{className:"size-6"})}),a==="trailing"&&s.jsx("button",{type:"button",onClick:()=>h("trailing"),"aria-label":"Delete message",className:"absolute inset-y-0 right-0 flex items-center justify-end bg-danger px-6 text-canvas",children:s.jsx(ue,{className:"size-6"})}),s.jsx("button",{type:"button",role:t?"checkbox":void 0,"aria-checked":t?n:void 0,"data-message-row":!0,"data-message-id":e.id,...y,className:d,style:C,children:$})]})}function Ve({sections:e,selectedThreadId:t,selectionMode:n,checkedIds:l,initialPeek:u,onToggleCheck:o,onEnterSelection:x,onOpenThread:w,onRefresh:g,refreshing:h,busy:p=!1}){const[N,b]=f.useState(new Set),[m,P]=f.useState(new Map),v=e.flatMap(a=>a.threads).filter(a=>!N.has(a.id)).map(a=>{const d=m.get(a.id);return d===void 0?a:{...a,isRead:d}}),[R,y]=f.useState(u&&u!=="none"&&v[1]?{id:v[1].id,side:u}:null),j=(a,d)=>{if(d==="trailing")b(C=>new Set(C).add(a));else{const C=v.find(S=>S.id===a);P(S=>new Map(S).set(a,!C?.isRead))}y(null)};return s.jsxs("div",{className:"flex-1 overflow-y-auto",children:[h&&s.jsxs("div",{className:"flex items-center justify-center gap-2 border-b border-line py-3 text-fg-muted",children:[s.jsx(Be,{className:"size-4 animate-spin"}),s.jsx("span",{className:"text-xs",children:"Checking for new mail…"})]}),s.jsx("div",{className:"divide-y divide-line",children:v.map(a=>s.jsx("div",{className:p?"pointer-events-none opacity-50":void 0,children:s.jsx(Je,{thread:a,selectionMode:n,checked:l.has(a.id),active:a.id===t,peek:R?.id===a.id?R.side:"none",onPeek:d=>y(d==="none"?null:{id:a.id,side:d}),onToggleCheck:()=>o(a.id),onLongPress:()=>x(a.id),onOpen:()=>w(a.id),onAct:d=>j(a.id,d)})},a.id))}),!n&&!h&&!p&&s.jsx("button",{type:"button",onClick:g,className:"w-full border-t border-line py-2 text-center text-2xs text-fg-subtle transition-colors hover:bg-surface-sunken",children:"Pull to refresh"})]})}const Ze=new Set;function ps({listTitle:e,listMeta:t,sections:n,briefFilters:l,flatList:u,listState:o="ready",searchQuery:x,listFilter:w,listScopeLabel:g,errorMessage:h,onRetry:p,onReportError:N,briefFilter:b,selectedThreadId:m,density:P="comfortable",onSelectThread:v,onOpenNav:R,isDesktop:y,initialTouchState:j,selection:a,keyboard:d,selectionBar:C,paneOverlay:S,listBody:M,hideHeader:$=!1}){const i=P==="compact"?Ee:Me,k=f.useRef(null),O=f.useRef(null),T=Ae(d);be({containerRef:k,itemSelector:Q,enabled:!T});const E=T?d.focusedId:void 0,z=T?E??n[0]?.threads[0]?.id:void 0,_=f.useCallback(r=>z===void 0?void 0:r===z?0:-1,[z]);f.useEffect(()=>{if(E===void 0)return;const r=O.current;if(!r)return;const c=r.querySelector(`${Q}[data-message-id="${E}"]`);!c||c===r.ownerDocument.activeElement||c.focus({preventScroll:!1})},[E]),f.useEffect(()=>{if(!T)return;const r=O.current;if(!r)return;const c=r.ownerDocument.activeElement;c!==null&&c!==r.ownerDocument.body||r.focus({preventScroll:!0})},[T]);const ee=!y&&!l&&o==="ready",[se,W]=f.useState(!1),te=j==="peek-trailing"?"trailing":j==="peek-leading"?"leading":void 0,ne=()=>{W(!0),setTimeout(()=>W(!1),1400)},D=a?.selectedIds??Ze,L=a?.onToggle,G=a?.onRowSelect,re=Se(D.size,y),H=f.useCallback(r=>{if(L)return{checked:D.has(r),onToggle:c=>{c.preventDefault(),c.stopPropagation(),L(r)}}},[D,L]),F=f.useCallback((r,c)=>G?.(r,ke(c))?(c.preventDefault(),c.shiftKey&&window.getSelection()?.removeAllRanges(),!0):!1,[G]),ae=f.useCallback(({thread:r,active:c,onClick:B})=>s.jsx(i,{thread:r,active:c,focused:r.id===E,tabIndex:_(r.id),selection:H(r.id),onClick:ie=>{F(r.id,ie)||B?.()}}),[i,H,F,E,_]);return s.jsxs("section",{ref:r=>{O.current=r,d?.ref(r)},tabIndex:T?-1:void 0,className:"relative flex h-full w-full flex-col bg-surface outline-none",children:[C??($?null:s.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[R&&s.jsx(A,{variant:"ghost",size:"sm",icon:s.jsx(We,{className:"size-4"}),onClick:R,"aria-label":"Open folders",className:"-ml-1 shrink-0"}),s.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:e}),t&&s.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle",children:t})]})),o==="loading"?s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsx(Ge,{})}):o==="empty"?s.jsx(Ke,{filter:w,scopeLabel:g,searchQuery:x}):o==="error"?s.jsx(qe,{message:h,onRetry:p,onReport:N}):l&&b?s.jsx(Te,{...b,sections:n,selectedThreadId:m,Row:ae,keyboard:d,onSelectThread:v}):M??(ee?s.jsx(Ve,{sections:n,selectedThreadId:m,selectionMode:re,checkedIds:D,initialPeek:te,onToggleCheck:r=>L?.(r),onEnterSelection:r=>L?.(r),onOpenThread:r=>v?.(r),onRefresh:ne,refreshing:se}):s.jsx("div",{ref:k,className:"flex-1 overflow-y-auto",children:n.map(r=>s.jsxs("div",{children:[!u&&r.label&&s.jsxs("div",{className:"sticky top-0 flex h-section-row items-center justify-between border-b border-line bg-surface-sunken px-row-inset",children:[s.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:r.label}),s.jsx("span",{className:"text-2xs text-fg-subtle tabular-nums",children:r.threads.length})]}),s.jsx("div",{className:"divide-y divide-line",children:r.threads.map(c=>s.jsx(i,{thread:c,active:c.id===m,focused:c.id===E,tabIndex:_(c.id),selection:H(c.id),onClick:B=>{F(c.id,B)||v?.(c.id)}},c.id))})]},r.id))})),y&&s.jsx(Ie,{hints:d?pe(d.handlers):he}),S]})}var es=class extends de{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type="infinite",super.setOptions(e)}getOptimisticResult(e){return e._type="infinite",super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){const{state:n}=e,l=super.createResult(e,t),{isFetching:u,isRefetching:o,isError:x,isRefetchError:w}=l,g=n.fetchMeta?.fetchMore?.direction,h=x&&g==="forward",p=u&&g==="forward",N=x&&g==="backward",b=u&&g==="backward";return{...l,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:me(t,n.data),hasPreviousPage:fe(t,n.data),isFetchNextPageError:h,isFetchingNextPage:p,isFetchPreviousPageError:N,isFetchingPreviousPage:b,isRefetchError:w&&!h&&!N,isRefetching:o&&!p&&!b}}};function bs(e,t){return xe(e,es)}const J={dimension:"read",position:"pre",text:"unread"},ss={dimension:"read",position:"pre",text:"read"},V={dimension:"starred",position:"pre",text:"starred"},Z={dimension:"attachment",position:"post",text:"with an attachment"},ts=[["unread",J],["flagged",V],["attachment",Z]],ns=e=>{switch(e.type){case"category":return{dimension:"category",position:"pre",text:Y(e.category)??e.value};case"isUnread":return J;case"isRead":return ss;case"isStarred":return V;case"hasAttachment":return Z;case"from":return{dimension:e.raw,position:"post",text:`from ${e.value}`};case"subject":return{dimension:e.raw,position:"post",text:`about “${e.value}”`};case"before":return{dimension:e.raw,position:"post",text:`sent before ${e.value}`};case"after":return{dimension:e.raw,position:"post",text:`sent on or after ${e.value}`};case"in":return{dimension:e.raw,position:"post",text:`in ${e.value}`};case"account":return{dimension:e.raw,position:"post",text:`in the ${e.value} account`}}},rs=(e,t)=>{const n=new Map,l=o=>{n.has(o.dimension)||n.set(o.dimension,o)},u=Y(e.category);u&&l({dimension:"category",position:"pre",text:u});for(const[o,x]of ts)e.attributes.has(o)&&l(x);for(const o of t)l(ns(o));return[...n.values()]},as=(e,t)=>{const n=rs(e,t);if(n.length===0)return;const l=u=>n.filter(o=>o.position===u).map(o=>o.text);return[...l("pre"),"mail",...l("post")].join(" ")},vs=({chips:e,tokens:t,reach:n,onClear:l})=>{const u=as(e,t);if(u)return{label:u,reach:n,onClear:l}};function js({title:e,unreadCount:t,preset:n,selectedCategory:l,activeFilters:u,onSelectCategory:o,onToggleFilter:x,onSelectSource:w,onClearFilters:g,children:h,footer:p,searchResults:N,searchLoading:b,onSelectSearchResult:m,searchResultsLabel:P,searchResultsInBody:v,refreshControl:R}){const{searchInput:y}=ge(),j=y.trim().length>0,a={categories:n.categories,filters:n.filters,sources:n.sources,selectedCategory:l,activeFilters:u,onSelectCategory:o,onSelectSource:w,onToggleFilter:x,onClear:g};return s.jsx(Oe,{hasSheet:!j,children:s.jsx(Le,{title:e,unreadCount:t,footer:p,searchFilter:a,searchResults:N,searchLoading:b,onSelectSearchResult:m,searchResultsLabel:P,searchResultsInBody:v,refreshControl:R,children:s.jsx(De,{...a,hideChrome:j,children:h})})})}export{hs as M,Je as S,ps as a,js as b,vs as l,bs as u};
1
+ import{j as s,L as oe,B as A,v as ce,r as f,p as K,aq as le,T as ue,cH as de,d4 as fe,d5 as me,d6 as xe,J as ge}from"./index-BZ4sAts4.js";import{j as he,k as pe}from"./search-token-index-CoqsoQJZ.js";import{u as be,L as Q}from"./roving-focus-1m_wY9_4.js";import{a6 as ve,c as je,C as U,a7 as we,a8 as Ne,a9 as ye,aa as Re,ab as Pe,ac as Ce,o as Se,ad as ke,ae as Ee,af as Me,ag as Te,ah as Ie,ai as Y,aj as Oe,ak as Le,al as De}from"./MessageToolbar-D-FLeer4.js";import{k as Ae}from"./search-scope-BR87UqJt.js";import{a as $e,S as ze,b as _e}from"./MessageBody-DbkrLz4x.js";import{A as He}from"./avatar-CQq2GZz9.js";import{M as Fe}from"./mail-CRvRtCed.js";import{R as Be}from"./refresh-cw-Dar0XAdp.js";import{M as We}from"./menu-DXmZUEBa.js";function Ge(){return s.jsx("div",{className:"space-y-0",role:"status","aria-busy":"true","aria-label":"Loading messages",children:Array.from({length:8}).map((e,t)=>s.jsxs("div",{className:"animate-pulse border-b border-line px-3 py-2",children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[s.jsx("div",{className:"h-4 w-32 rounded bg-surface-sunken"}),s.jsx("div",{className:"h-3 w-16 rounded bg-surface-sunken"})]}),s.jsx("div",{className:"mb-2 h-4 w-48 rounded bg-surface-sunken"}),s.jsx("div",{className:"h-3 w-full rounded bg-surface-sunken"})]},t))})}function Ke({filter:e,scopeLabel:t,searchQuery:n}){const l=n?.trim();return e?s.jsxs(X,{children:[s.jsx("p",{className:"font-medium text-fg",children:Xe(e.label,t,l)}),s.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:Qe[e.reach]}),s.jsx(A,{variant:"secondary",size:"sm",className:"mt-4",onClick:e.onClear,children:"Clear filter"})]}):s.jsx(X,{children:s.jsx("p",{className:"text-fg-muted",children:Ue(l,t)})})}const Qe={"whole-folder":"Every message in this folder was checked.","loaded-pages":"Only the messages loaded so far were checked."};function Ue(e,t){return e?"No messages match your search":t?`No messages in ${t}`:"No messages in this mailbox"}function Xe(e,t,n){return n?`No results for “${n}” in ${e}`:t?`No ${e} in ${t}`:`No ${e}`}function X({children:e}){return s.jsx("div",{className:"flex h-full flex-1 items-center justify-center",children:s.jsx("div",{className:"flex max-w-sm flex-col items-center justify-center p-8 text-center",children:e})})}function hs(){return s.jsxs("div",{className:"flex items-center justify-center gap-2 py-4 text-sm text-fg-muted",role:"status","aria-live":"polite",children:[s.jsx(oe,{className:"size-4 animate-spin","aria-hidden":"true"}),s.jsx("span",{children:"Loading more…"})]})}function qe({message:e="Something went wrong loading this mailbox.",onRetry:t,onReport:n}){return s.jsx("div",{className:"flex h-full flex-1 items-center justify-center p-4",children:s.jsxs("div",{role:"alert",className:"flex max-w-sm flex-col items-center justify-center gap-3 text-center",children:[s.jsx(ce,{className:"size-8 text-danger","aria-hidden":"true"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium text-danger",children:"Couldn't load messages"}),s.jsx("p",{className:"mt-1 break-words text-sm text-fg-muted",children:e})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[t&&s.jsx(A,{variant:"secondary",size:"sm",onClick:t,children:"Retry"}),n&&s.jsx(A,{variant:"ghost",size:"sm",onClick:n,children:"Report a problem"})]})]})})}const I=72;function q(e){return e==="leading"?I:e==="trailing"?-I:0}function Ye(e){return e>=I/2?"leading":e<=-I/2?"trailing":"none"}function Je({thread:e,selectionMode:t,checked:n,active:l,peek:u,onPeek:o,onToggleCheck:x,onLongPress:w,onOpen:g,onAct:h}){const[p,N]=f.useState(null),b=f.useRef(null),m=f.useRef(!1),P=i=>{b.current=i,N(i)},v=i=>{const k=b.current,O=m.current;if(m.current=!1,P(null),!(i.event.type.endsWith("cancel")||O)){if(i.tap){if(t){x();return}if(u!=="none"){o("none");return}g();return}i.axis!=="x"||t||k===null||o(Ye(k))}},R=$e(i=>{if(!i.down){v(i);return}if(Pe(i)){if(t)return;m.current=!0,Ce(),w();return}if(!i.intentional||t||m.current||i.axis!=="x")return;const k=i.values[0]-i.initial[0];P(Math.max(-I,Math.min(I,q(u)+k)))},{...ye(Re),tapsThreshold:_e,axisThreshold:ze.axisThreshold}),y=ve(R(),Ne,{"aria-description":t?void 0:"Select message"}),j=p??q(u),a=j>0?"leading":j<0?"trailing":"none",d=K("relative touch-pan-y bg-surface","select-none",je({active:n||l})),C={transform:j!==0?`translateX(${j}px)`:void 0,transition:p===null?"transform 150ms ease":"none",minHeight:44},S=!e.isRead,M=i=>i.stopPropagation(),$=t?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:K("inline-flex size-7 shrink-0 items-center justify-center rounded-full border",n?"border-accent bg-accent text-accent-fg":"border-line-strong bg-canvas"),children:n&&s.jsx(le,{className:"size-3.5"})}),s.jsx(U,{thread:e})]}):s.jsxs(s.Fragment,{children:[S&&s.jsx("span",{className:"absolute left-1.5 top-1/2 size-1.5 -translate-y-1/2 rounded-full bg-accent"}),s.jsx("span",{role:"checkbox",tabIndex:0,"aria-checked":n,"aria-label":`Select message from ${e.fromName}`,onPointerDown:M,onPointerMove:M,onPointerUp:M,onClick:i=>{i.preventDefault(),i.stopPropagation(),w()},onKeyDown:i=>{i.key!=="Enter"&&i.key!==" "||(i.preventDefault(),i.stopPropagation(),w())},className:"-m-2 inline-flex size-11 shrink-0 items-center justify-center rounded-full",children:s.jsx(He,{name:e.fromName,email:e.fromEmail,size:"sm"})}),s.jsx(U,{thread:e})]});return s.jsxs("div",{className:"relative overflow-hidden",children:[a==="leading"&&s.jsx("button",{type:"button",onClick:()=>h("leading"),"aria-label":e.isRead?"Mark as unread":"Mark as read",className:"absolute inset-y-0 left-0 flex items-center justify-start bg-accent-2 px-6 text-accent-fg",children:e.isRead?s.jsx(Fe,{className:"size-6"}):s.jsx(we,{className:"size-6"})}),a==="trailing"&&s.jsx("button",{type:"button",onClick:()=>h("trailing"),"aria-label":"Delete message",className:"absolute inset-y-0 right-0 flex items-center justify-end bg-danger px-6 text-canvas",children:s.jsx(ue,{className:"size-6"})}),s.jsx("button",{type:"button",role:t?"checkbox":void 0,"aria-checked":t?n:void 0,"data-message-row":!0,"data-message-id":e.id,...y,className:d,style:C,children:$})]})}function Ve({sections:e,selectedThreadId:t,selectionMode:n,checkedIds:l,initialPeek:u,onToggleCheck:o,onEnterSelection:x,onOpenThread:w,onRefresh:g,refreshing:h,busy:p=!1}){const[N,b]=f.useState(new Set),[m,P]=f.useState(new Map),v=e.flatMap(a=>a.threads).filter(a=>!N.has(a.id)).map(a=>{const d=m.get(a.id);return d===void 0?a:{...a,isRead:d}}),[R,y]=f.useState(u&&u!=="none"&&v[1]?{id:v[1].id,side:u}:null),j=(a,d)=>{if(d==="trailing")b(C=>new Set(C).add(a));else{const C=v.find(S=>S.id===a);P(S=>new Map(S).set(a,!C?.isRead))}y(null)};return s.jsxs("div",{className:"flex-1 overflow-y-auto",children:[h&&s.jsxs("div",{className:"flex items-center justify-center gap-2 border-b border-line py-3 text-fg-muted",children:[s.jsx(Be,{className:"size-4 animate-spin"}),s.jsx("span",{className:"text-xs",children:"Checking for new mail…"})]}),s.jsx("div",{className:"divide-y divide-line",children:v.map(a=>s.jsx("div",{className:p?"pointer-events-none opacity-50":void 0,children:s.jsx(Je,{thread:a,selectionMode:n,checked:l.has(a.id),active:a.id===t,peek:R?.id===a.id?R.side:"none",onPeek:d=>y(d==="none"?null:{id:a.id,side:d}),onToggleCheck:()=>o(a.id),onLongPress:()=>x(a.id),onOpen:()=>w(a.id),onAct:d=>j(a.id,d)})},a.id))}),!n&&!h&&!p&&s.jsx("button",{type:"button",onClick:g,className:"w-full border-t border-line py-2 text-center text-2xs text-fg-subtle transition-colors hover:bg-surface-sunken",children:"Pull to refresh"})]})}const Ze=new Set;function ps({listTitle:e,listMeta:t,sections:n,briefFilters:l,flatList:u,listState:o="ready",searchQuery:x,listFilter:w,listScopeLabel:g,errorMessage:h,onRetry:p,onReportError:N,briefFilter:b,selectedThreadId:m,density:P="comfortable",onSelectThread:v,onOpenNav:R,isDesktop:y,initialTouchState:j,selection:a,keyboard:d,selectionBar:C,paneOverlay:S,listBody:M,hideHeader:$=!1}){const i=P==="compact"?Ee:Me,k=f.useRef(null),O=f.useRef(null),T=Ae(d);be({containerRef:k,itemSelector:Q,enabled:!T});const E=T?d.focusedId:void 0,z=T?E??n[0]?.threads[0]?.id:void 0,_=f.useCallback(r=>z===void 0?void 0:r===z?0:-1,[z]);f.useEffect(()=>{if(E===void 0)return;const r=O.current;if(!r)return;const c=r.querySelector(`${Q}[data-message-id="${E}"]`);!c||c===r.ownerDocument.activeElement||c.focus({preventScroll:!1})},[E]),f.useEffect(()=>{if(!T)return;const r=O.current;if(!r)return;const c=r.ownerDocument.activeElement;c!==null&&c!==r.ownerDocument.body||r.focus({preventScroll:!0})},[T]);const ee=!y&&!l&&o==="ready",[se,W]=f.useState(!1),te=j==="peek-trailing"?"trailing":j==="peek-leading"?"leading":void 0,ne=()=>{W(!0),setTimeout(()=>W(!1),1400)},D=a?.selectedIds??Ze,L=a?.onToggle,G=a?.onRowSelect,re=Se(D.size,y),H=f.useCallback(r=>{if(L)return{checked:D.has(r),onToggle:c=>{c.preventDefault(),c.stopPropagation(),L(r)}}},[D,L]),F=f.useCallback((r,c)=>G?.(r,ke(c))?(c.preventDefault(),c.shiftKey&&window.getSelection()?.removeAllRanges(),!0):!1,[G]),ae=f.useCallback(({thread:r,active:c,onClick:B})=>s.jsx(i,{thread:r,active:c,focused:r.id===E,tabIndex:_(r.id),selection:H(r.id),onClick:ie=>{F(r.id,ie)||B?.()}}),[i,H,F,E,_]);return s.jsxs("section",{ref:r=>{O.current=r,d?.ref(r)},tabIndex:T?-1:void 0,className:"relative flex h-full w-full flex-col bg-surface outline-none",children:[C??($?null:s.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[R&&s.jsx(A,{variant:"ghost",size:"sm",icon:s.jsx(We,{className:"size-4"}),onClick:R,"aria-label":"Open folders",className:"-ml-1 shrink-0"}),s.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:e}),t&&s.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle",children:t})]})),o==="loading"?s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsx(Ge,{})}):o==="empty"?s.jsx(Ke,{filter:w,scopeLabel:g,searchQuery:x}):o==="error"?s.jsx(qe,{message:h,onRetry:p,onReport:N}):l&&b?s.jsx(Te,{...b,sections:n,selectedThreadId:m,Row:ae,keyboard:d,onSelectThread:v}):M??(ee?s.jsx(Ve,{sections:n,selectedThreadId:m,selectionMode:re,checkedIds:D,initialPeek:te,onToggleCheck:r=>L?.(r),onEnterSelection:r=>L?.(r),onOpenThread:r=>v?.(r),onRefresh:ne,refreshing:se}):s.jsx("div",{ref:k,className:"flex-1 overflow-y-auto",children:n.map(r=>s.jsxs("div",{children:[!u&&r.label&&s.jsxs("div",{className:"sticky top-0 flex h-section-row items-center justify-between border-b border-line bg-surface-sunken px-row-inset",children:[s.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:r.label}),s.jsx("span",{className:"text-2xs text-fg-subtle tabular-nums",children:r.threads.length})]}),s.jsx("div",{className:"divide-y divide-line",children:r.threads.map(c=>s.jsx(i,{thread:c,active:c.id===m,focused:c.id===E,tabIndex:_(c.id),selection:H(c.id),onClick:B=>{F(c.id,B)||v?.(c.id)}},c.id))})]},r.id))})),y&&s.jsx(Ie,{hints:d?pe(d.handlers):he}),S]})}var es=class extends de{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type="infinite",super.setOptions(e)}getOptimisticResult(e){return e._type="infinite",super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){const{state:n}=e,l=super.createResult(e,t),{isFetching:u,isRefetching:o,isError:x,isRefetchError:w}=l,g=n.fetchMeta?.fetchMore?.direction,h=x&&g==="forward",p=u&&g==="forward",N=x&&g==="backward",b=u&&g==="backward";return{...l,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:me(t,n.data),hasPreviousPage:fe(t,n.data),isFetchNextPageError:h,isFetchingNextPage:p,isFetchPreviousPageError:N,isFetchingPreviousPage:b,isRefetchError:w&&!h&&!N,isRefetching:o&&!p&&!b}}};function bs(e,t){return xe(e,es)}const J={dimension:"read",position:"pre",text:"unread"},ss={dimension:"read",position:"pre",text:"read"},V={dimension:"starred",position:"pre",text:"starred"},Z={dimension:"attachment",position:"post",text:"with an attachment"},ts=[["unread",J],["flagged",V],["attachment",Z]],ns=e=>{switch(e.type){case"category":return{dimension:"category",position:"pre",text:Y(e.category)??e.value};case"isUnread":return J;case"isRead":return ss;case"isStarred":return V;case"hasAttachment":return Z;case"from":return{dimension:e.raw,position:"post",text:`from ${e.value}`};case"subject":return{dimension:e.raw,position:"post",text:`about “${e.value}”`};case"before":return{dimension:e.raw,position:"post",text:`sent before ${e.value}`};case"after":return{dimension:e.raw,position:"post",text:`sent on or after ${e.value}`};case"in":return{dimension:e.raw,position:"post",text:`in ${e.value}`};case"account":return{dimension:e.raw,position:"post",text:`in the ${e.value} account`}}},rs=(e,t)=>{const n=new Map,l=o=>{n.has(o.dimension)||n.set(o.dimension,o)},u=Y(e.category);u&&l({dimension:"category",position:"pre",text:u});for(const[o,x]of ts)e.attributes.has(o)&&l(x);for(const o of t)l(ns(o));return[...n.values()]},as=(e,t)=>{const n=rs(e,t);if(n.length===0)return;const l=u=>n.filter(o=>o.position===u).map(o=>o.text);return[...l("pre"),"mail",...l("post")].join(" ")},vs=({chips:e,tokens:t,reach:n,onClear:l})=>{const u=as(e,t);if(u)return{label:u,reach:n,onClear:l}};function js({title:e,unreadCount:t,preset:n,selectedCategory:l,activeFilters:u,onSelectCategory:o,onToggleFilter:x,onSelectSource:w,onClearFilters:g,children:h,footer:p,searchResults:N,searchLoading:b,onSelectSearchResult:m,searchResultsLabel:P,searchResultsInBody:v,refreshControl:R}){const{searchInput:y}=ge(),j=y.trim().length>0,a={categories:n.categories,filters:n.filters,sources:n.sources,selectedCategory:l,activeFilters:u,onSelectCategory:o,onSelectSource:w,onToggleFilter:x,onClear:g};return s.jsx(Oe,{hasSheet:!j,children:s.jsx(Le,{title:e,unreadCount:t,footer:p,searchFilter:a,searchResults:N,searchLoading:b,onSelectSearchResult:m,searchResultsLabel:P,searchResultsInBody:v,refreshControl:R,children:s.jsx(De,{...a,hideChrome:j,children:h})})})}export{hs as M,Je as S,ps as a,js as b,vs as l,bs as u};