@remit/web-client-dist 0.0.683 → 0.0.684

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 (200) hide show
  1. package/assets/BriefPane-DKV1iFiW.js +1 -0
  2. package/assets/{CalendarEventEditor-CorHNzvG.js → CalendarEventEditor-BVJVcn8c.js} +1 -1
  3. package/assets/{CalendarEventPopup-D-SdDSgQ.js → CalendarEventPopup-BY5hHIwf.js} +1 -1
  4. package/assets/{CalendarLoadFailed-fjYDcNBn.js → CalendarLoadFailed-CFhSME4B.js} +1 -1
  5. package/assets/{CalendarQuickCreate-BNdOcecP.js → CalendarQuickCreate-AsCrUcAa.js} +1 -1
  6. package/assets/{CalendarSession-DVmvDWU4.js → CalendarSession-DRZ92kL4.js} +1 -1
  7. package/assets/{DesktopChrome-BTELS57y.js → DesktopChrome-C8Sk2ut7.js} +1 -1
  8. package/assets/{DropdownMenu-CMRvH2nc.js → DropdownMenu-DB36Lfi7.js} +1 -1
  9. package/assets/{EmptyState-D9VF8IjN.js → EmptyState-DjjWzqfi.js} +1 -1
  10. package/assets/{ErrorState-94ifepAa.js → ErrorState-k3wt6L_r.js} +1 -1
  11. package/assets/FlaggedPane-BKSCs9yQ.js +1 -0
  12. package/assets/{FullCompose-D0r-tiQo.js → FullCompose-Um26w7lB.js} +1 -1
  13. package/assets/{LabelApplyTrigger-C03Hgfzy.js → LabelApplyTrigger-BYIdJG0t.js} +1 -1
  14. package/assets/{MailShell-CtmFFRYB.js → MailShell-Dy-TBL0C.js} +1 -1
  15. package/assets/{MailViewChrome-Dsvhd_KV.js → MailViewChrome-DbIMXxXm.js} +1 -1
  16. package/assets/{MailboxPane-CZB7l_UU.js → MailboxPane-DE0MG44k.js} +2 -2
  17. package/assets/{MessageBody-D3iuMLwF.js → MessageBody-CQSDERa-.js} +4 -4
  18. package/assets/MessageToolbar-DBu6zN25.js +1 -0
  19. package/assets/{NavMenuButton-DSOpFRST.js → NavMenuButton-DwbUNWYU.js} +1 -1
  20. package/assets/{OnboardingWizard-B59qf55_.js → OnboardingWizard-G419TXSu.js} +1 -1
  21. package/assets/OutboxPane-CijiwhdB.js +1 -0
  22. package/assets/ReportLink-By19dSP-.js +1 -0
  23. package/assets/_calendarObjectId-fr_DOSB5.js +1 -0
  24. package/assets/_mailboxId-rxS0aTPA.js +1 -0
  25. package/assets/_messageId-Dd8DtbFX.js +1 -0
  26. package/assets/_messageId-MltBMuB2.js +1 -0
  27. package/assets/_messageId-OX5-naZB.js +1 -0
  28. package/assets/_outboxMessageId-CR43Ykvj.js +1 -0
  29. package/assets/_recurrenceId-5xRvoQr3.js +1 -0
  30. package/assets/_slotId-B0VWha3i.js +1 -0
  31. package/assets/_threadId-PVllb6ST.js +1 -0
  32. package/assets/_threadId-QNe6ZU7G.js +1 -0
  33. package/assets/_threadId-kRDsdwV9.js +1 -0
  34. package/assets/_view._date-9VfJM2qY.js +1 -0
  35. package/assets/{account-service-status-DcgJfCAF.js → account-service-status-CADf5pX0.js} +1 -1
  36. package/assets/accounts-CrGdo3ni.js +1 -0
  37. package/assets/{advanced-BK0dqfFu.js → advanced-CHxdFeri.js} +1 -1
  38. package/assets/{agenda-time-BuLpxvQJ.js → agenda-time-0kHgN1IS.js} +1 -1
  39. package/assets/{app-chrome-Do6quK12.js → app-chrome-tFbuBSBl.js} +1 -1
  40. package/assets/{appearance-BLw-N7mB.js → appearance-CmzgZOVO.js} +1 -1
  41. package/assets/{avatar-LbufyW4K.js → avatar-BmY6XepY.js} +1 -1
  42. package/assets/{badge-C9PbkapD.js → badge-DNMAx4D3.js} +1 -1
  43. package/assets/{bottom-sheet-CGUsHUE9.js → bottom-sheet-C2SG5YmN.js} +1 -1
  44. package/assets/brief-CDD1sD46.js +1 -0
  45. package/assets/{brief-CcMmKq4G.js → brief-DJx3XIOx.js} +1 -1
  46. package/assets/{calendar-C-SC0LmB.js → calendar-DzAewYd3.js} +1 -1
  47. package/assets/{calendar-event-popup--BJKBvHu.js → calendar-event-popup-BX4yyqgU.js} +1 -1
  48. package/assets/{calendar-event-sidebar-s-VGamZ2.js → calendar-event-sidebar-DG9W-BJ-.js} +1 -1
  49. package/assets/{calendar-CZgZil9h.js → calendar-exLBND8p.js} +1 -1
  50. package/assets/{calendar-failure-note-CEYH2UEH.js → calendar-failure-note-4QbINaXF.js} +1 -1
  51. package/assets/{calendar-guests-BaqdXc5Z.js → calendar-guests-C7ZBcQWB.js} +1 -1
  52. package/assets/calendar-suggestion-wnuXxa-h.js +1 -0
  53. package/assets/{calendars-BB8BOIZF.js → calendars-XiQ85lmu.js} +1 -1
  54. package/assets/{card-D7vOetR8.js → card-C42r2UXP.js} +1 -1
  55. package/assets/{checkbox-BG_wsoD6.js → checkbox-CjhlhVd0.js} +1 -1
  56. package/assets/chevron-down-DCUrV3H_.js +1 -0
  57. package/assets/chevron-left-Br4HtAWp.js +1 -0
  58. package/assets/{circle-check-DTYzt_6O.js → circle-check-B9p7FADR.js} +1 -1
  59. package/assets/{circle-check-big-Bm7lzv-i.js → circle-check-big-BTaxDmjy.js} +1 -1
  60. package/assets/{circle-help-BbeOW2US.js → circle-help-B5aCQkW2.js} +1 -1
  61. package/assets/classification-BQpRhmik.js +1 -0
  62. package/assets/{clock-BzJ_fFzJ.js → clock-CqDLo2F2.js} +1 -1
  63. package/assets/compose._-_outboxMessageId_-0TViPHVJ.js +1 -0
  64. package/assets/compose._-_outboxMessageId_-12b-uBgV.js +1 -0
  65. package/assets/compose._-_outboxMessageId_-B3fhCxCx.js +1 -0
  66. package/assets/compose._-_outboxMessageId_-Bfz6_gPW.js +1 -0
  67. package/assets/{config-import-C8-amzAu.js → config-import-9beahVan.js} +1 -1
  68. package/assets/{confirm-dialog-CJxHNbgP.js → confirm-dialog-By4KyYtA.js} +1 -1
  69. package/assets/{copy-BXsMQRiH.js → copy-BYqJcNuv.js} +1 -1
  70. package/assets/{credential-steps-rbRE-sDX.js → credential-steps-ioVIFoHi.js} +1 -1
  71. package/assets/{download-BfBVKcRB.js → download-DHu_VILi.js} +1 -1
  72. package/assets/{draft-DNq8lw24.js → draft-DBSWcwcO.js} +1 -1
  73. package/assets/edit-CDsGkq55.js +1 -0
  74. package/assets/edit-J4rkAx6h.js +1 -0
  75. package/assets/{external-link-BJSinsZe.js → external-link-CbBMj0Z_.js} +1 -1
  76. package/assets/{file-json-BQnHw6MM.js → file-json-DbQ50vT6.js} +1 -1
  77. package/assets/{filters-PWUZK_ek.js → filters-CZ386C51.js} +1 -1
  78. package/assets/flagged-C-zdu9Ko.js +1 -0
  79. package/assets/{flagged-CKVThblv.js → flagged-DCJxt3_p.js} +1 -1
  80. package/assets/{folder-input-ByfaQaN_.js → folder-input-F5BBuwYo.js} +1 -1
  81. package/assets/folders-CboZBGx6.js +1 -0
  82. package/assets/{help-copy-CiMWKARn.js → help-copy-UAU_hrL0.js} +1 -1
  83. package/assets/{import-Bp-nuO1l.js → import-BsVMIlh9.js} +1 -1
  84. package/assets/index-BBSi34NI.js +1 -0
  85. package/assets/index-BXFzm6T3.js +1 -0
  86. package/assets/{index-Dd-3T--b.js → index-C8_kRlZw.js} +4 -4
  87. package/assets/{index-CKflMWYU.js → index-CjLIM85N.js} +55 -55
  88. package/assets/{index-CMNnsfzR.css → index-CqMlmBtY.css} +1 -1
  89. package/assets/index-DVR7EF8n.js +1 -0
  90. package/assets/index-DXkPJvhA.js +1 -0
  91. package/assets/index-DYGeUOj0.js +1 -0
  92. package/assets/index-Dd8DtbFX.js +1 -0
  93. package/assets/index-DfDT80hv.js +1 -0
  94. package/assets/index-MltBMuB2.js +1 -0
  95. package/assets/index-OX5-naZB.js +1 -0
  96. package/assets/index-vUwnX4dj.js +1 -0
  97. package/assets/{kbd-BncXAFDO.js → kbd-CMsSty4m.js} +1 -1
  98. package/assets/{label-chip-WqxiwOiU.js → label-chip-Dy8yMiFM.js} +1 -1
  99. package/assets/{labels-Dg7TTcGv.js → labels-Dn7EENvK.js} +1 -1
  100. package/assets/{mail-D6kMQxBk.js → mail-BYU-RvAA.js} +1 -1
  101. package/assets/mail-ERxPLc6T.js +1 -0
  102. package/assets/{menu-DoDMKB2j.js → menu-S5zj22BN.js} +1 -1
  103. package/assets/{nav-link-D4-gc9H1.js → nav-link-BJFBTF93.js} +1 -1
  104. package/assets/new-apNYVdcM.js +1 -0
  105. package/assets/onboarding-BuXQ-yrG.js +1 -0
  106. package/assets/{onboarding-completion-CidQapv1.js → onboarding-completion-BGw_CF3C.js} +1 -1
  107. package/assets/outbox-BZL_g_gu.js +1 -0
  108. package/assets/{pencil-DWPNxo1l.js → pencil-DhM7psiB.js} +1 -1
  109. package/assets/people-CJWst29Y.js +1 -0
  110. package/assets/{plus-BQ1_1L0j.js → plus-CWdC1Tqr.js} +1 -1
  111. package/assets/{popover-menu-CNRLhp3y.js → popover-menu-vk6Zc0z7.js} +1 -1
  112. package/assets/{refresh-cw-BmzOf0Tw.js → refresh-cw-B_uXAs1Z.js} +1 -1
  113. package/assets/{reply-CM_F5zLS.js → reply-jAIguvVh.js} +1 -1
  114. package/assets/{rich-text-DGbE9Son.js → rich-text-BNKeOthA.js} +1 -1
  115. package/assets/{rich-text-spellcheck-worker-provider-CIgyTxax.js → rich-text-spellcheck-worker-provider-Cpg7LbTE.js} +1 -1
  116. package/assets/{rotate-ccw-BGcFG-wN.js → rotate-ccw-BO87SEMT.js} +1 -1
  117. package/assets/{roving-focus-5GpSESqn.js → roving-focus-DxrxBKOA.js} +1 -1
  118. package/assets/{row-actions-Cj5ovPiM.js → row-actions-B2Y3De5s.js} +1 -1
  119. package/assets/{search-mirror-C3jFbnCg.js → search-mirror-aqcvRPsg.js} +1 -1
  120. package/assets/{search-scope-4mzoV4f2.js → search-scope-m65PO2OM.js} +1 -1
  121. package/assets/{search-token-index-CjZf08nc.js → search-token-index-BV0MxVc4.js} +1 -1
  122. package/assets/{sections-HylxNewe.js → sections-1CLsW1zC.js} +1 -1
  123. package/assets/{segmented-control-DIfCqJPe.js → segmented-control-D85OUPJd.js} +1 -1
  124. package/assets/{select-DBBB1VI8.js → select-BccK4I_R.js} +1 -1
  125. package/assets/{senders-CjRXvk8z.js → senders-NrVp71W0.js} +1 -1
  126. package/assets/settings-ohqabhz3.js +1 -0
  127. package/assets/{settings-screen-83hRChID.js → settings-screen-B0brDUWW.js} +1 -1
  128. package/assets/{shield-check-BtDXLNzB.js → shield-check-nCSxAGzG.js} +1 -1
  129. package/assets/{suggest-list-B3YTezx4.js → suggest-list-CGKa8tfA.js} +1 -1
  130. package/assets/{suggested-vips-DeXMjfai.js → suggested-vips-D9HP0DVS.js} +1 -1
  131. package/assets/suggestion._suggestionId-DYsuCqNh.js +1 -0
  132. package/assets/switch-BDBBnLpE.js +1 -0
  133. package/assets/{task._calendarTaskId--_XtqsMj.js → task._calendarTaskId-DXwhwAoI.js} +1 -1
  134. package/assets/{undo-2-CG4e15mN.js → undo-2-DzniM_WO.js} +1 -1
  135. package/assets/{useCalendarData-CjjJgU5o.js → useCalendarData-CiACY6bV.js} +2 -2
  136. package/assets/{useCalendarScheduling-BgRBx6lW.js → useCalendarScheduling-Brb1S1QL.js} +1 -1
  137. package/assets/{useCalendarSuggestions--U0GEAn1.js → useCalendarSuggestions-9OSR5bVj.js} +1 -1
  138. package/assets/{useCalendarTasks-vfDCVCeh.js → useCalendarTasks-DZa9ySo0.js} +1 -1
  139. package/assets/{useDebouncedValue-DjJaY9PG.js → useDebouncedValue-m2WIWKGa.js} +1 -1
  140. package/assets/{useFilters-CfG8A2Tp.js → useFilters-C1uvJ4Ho.js} +1 -1
  141. package/assets/useLabels-BvI8jwIJ.js +1 -0
  142. package/assets/{useLayoutTier-4MDmjdnr.js → useLayoutTier-CL2fFLId.js} +1 -1
  143. package/assets/{useMediaQuery-B1PJEoqh.js → useMediaQuery-Ct2USFCe.js} +1 -1
  144. package/assets/{useMessageBodyContent-B0iiI3OV.js → useMessageBodyContent-MKSJN2kk.js} +1 -1
  145. package/assets/{useQueries-DVcMuKhn.js → useQueries-DiYEl2LH.js} +1 -1
  146. package/assets/useRefreshControl-guVLGaLs.js +1 -0
  147. package/assets/{useResultFolderIndex-DkgVg9nE.js → useResultFolderIndex--Vh1kDTt.js} +1 -1
  148. package/assets/{useSignature-DR9rEETd.js → useSignature-Ck8XWicp.js} +1 -1
  149. package/assets/{warnings-BM1pwMF7.js → warnings-CC5t4Lye.js} +2 -2
  150. package/index.html +2 -2
  151. package/package.json +1 -1
  152. package/assets/BriefPane-B3D5-BM0.js +0 -1
  153. package/assets/FlaggedPane-CpXIW-t2.js +0 -1
  154. package/assets/MessageToolbar-BEI90gj6.js +0 -1
  155. package/assets/OutboxPane-BUI6ugaL.js +0 -1
  156. package/assets/_calendarObjectId-BY50J2hr.js +0 -1
  157. package/assets/_mailboxId-0i2eghj0.js +0 -1
  158. package/assets/_messageId-BQqk5gfw.js +0 -1
  159. package/assets/_messageId-BqO-NhQa.js +0 -1
  160. package/assets/_messageId-Cmg2GAfD.js +0 -1
  161. package/assets/_outboxMessageId-BDvXTrQM.js +0 -1
  162. package/assets/_recurrenceId-CMVJw-Ue.js +0 -1
  163. package/assets/_slotId-CFujBWsH.js +0 -1
  164. package/assets/_threadId-BSlijLpe.js +0 -1
  165. package/assets/_threadId-BiFfo-Au.js +0 -1
  166. package/assets/_threadId-CvKjrqYT.js +0 -1
  167. package/assets/_view._date-BZkjct9_.js +0 -1
  168. package/assets/accounts-CEI9HlTN.js +0 -1
  169. package/assets/brief-ZZJ3nfgH.js +0 -1
  170. package/assets/calendar-suggestion-hiP6smEM.js +0 -1
  171. package/assets/chevron-down-Np6EEMl-.js +0 -1
  172. package/assets/chevron-left-CpG9UDY6.js +0 -1
  173. package/assets/compose._-_outboxMessageId_-BqsxhT9K.js +0 -1
  174. package/assets/compose._-_outboxMessageId_-CproJqKO.js +0 -1
  175. package/assets/compose._-_outboxMessageId_-D4ti_AhM.js +0 -1
  176. package/assets/compose._-_outboxMessageId_-DUOU8Jn4.js +0 -1
  177. package/assets/edit-BHhIau_f.js +0 -1
  178. package/assets/edit-DgebsJae.js +0 -1
  179. package/assets/flagged-CXvEvVrc.js +0 -1
  180. package/assets/folders-CN4VErkf.js +0 -1
  181. package/assets/index-B9liPKRG.js +0 -1
  182. package/assets/index-BQqk5gfw.js +0 -1
  183. package/assets/index-BxeM8f0P.js +0 -1
  184. package/assets/index-C8IkDmiU.js +0 -1
  185. package/assets/index-CGpfssJ_.js +0 -1
  186. package/assets/index-Cmg2GAfD.js +0 -1
  187. package/assets/index-CnG5iabp.js +0 -1
  188. package/assets/index-CsYB5imQ.js +0 -1
  189. package/assets/index-Dzu-4vEF.js +0 -1
  190. package/assets/index-ddvd0V_o.js +0 -1
  191. package/assets/mail-BXR9_JRf.js +0 -1
  192. package/assets/new-cj3Hd_mI.js +0 -1
  193. package/assets/onboarding-DVmfGdcY.js +0 -1
  194. package/assets/outbox-FTmGdqfa.js +0 -1
  195. package/assets/people-aWk5_IT2.js +0 -1
  196. package/assets/settings-BLU5tEtD.js +0 -1
  197. package/assets/sparkles-DxQ7dXLC.js +0 -1
  198. package/assets/suggestion._suggestionId-BFy5c2Ae.js +0 -1
  199. package/assets/useLabels-QIv6Xivl.js +0 -1
  200. package/assets/useRefreshControl-CY786xTG.js +0 -1
@@ -1 +1 @@
1
- import{r as u,j as S,p as P,f as y,eM as v,eN as q,eO as W,a as E,eP as R,aO as I,eQ as j,s as D}from"./index-CKflMWYU.js";import{a as z,C as k}from"./useCalendarSuggestions--U0GEAn1.js";import{f as N}from"./ErrorState-94ifepAa.js";const i=8,x=(e,t,a)=>Math.min(Math.max(e,t),Math.max(t,a)),B=(e,t)=>e.width>0&&e.height>0&&e.left<t.width&&e.left+e.width>0&&e.top<t.height&&e.top+e.height>0;function C(e,t){return{left:Math.max(i,(t.width-e.width)/2),top:Math.max(i,(t.height-e.height)/2),side:"center"}}function G(e,t,a){if(!e||!B(e,a))return C(t,a);const r=x(e.top,i,a.height-t.height-i),c=e.left+e.width+i;if(c+t.width<=a.width-i)return{left:c,top:r,side:"right"};const f=e.left-i-t.width;if(f>=i)return{left:f,top:r,side:"left"};const l=x(e.left,i,a.width-t.width-i),s=e.top+e.height+i;if(s+t.height<=a.height-i)return{left:l,top:s,side:"below"};const h=e.top-i-t.height;return h>=i?{left:l,top:h,side:"above"}:C(t,a)}const H='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function Y({anchor:e,anchorKey:t,labelledBy:a,children:r,header:c,wrapTab:f=!1,panelRef:l,className:s}){const h=u.useRef(null),[w,M]=u.useState(null),[b,A]=u.useState({key:t,x:0,y:0}),g=b.key===t?b:{x:0,y:0};u.useLayoutEffect(()=>{const n=h.current;if(!n||t==="")return;const d=()=>{const o=(typeof e=="string"?document.querySelector(e):e)?.getBoundingClientRect();M(G(o?{left:o.left,top:o.top,width:o.width,height:o.height}:null,{width:n.offsetWidth,height:n.offsetHeight},{width:window.innerWidth,height:window.innerHeight}))};return d(),window.addEventListener("resize",d),()=>window.removeEventListener("resize",d)},[e,t]);const O=n=>{if(n.button!==0||n.target instanceof Element&&n.target.closest("button, input, select, a"))return;n.preventDefault();const d={x:n.clientX-g.x,y:n.clientY-g.y},m=p=>A({key:t,x:p.clientX-d.x,y:p.clientY-d.y}),o=()=>{window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",o)};window.addEventListener("pointermove",m),window.addEventListener("pointerup",o)},L=n=>{if(!f||n.key!=="Tab")return;const d=Array.from(n.currentTarget.querySelectorAll(H));if(d.length===0)return;const m=d[0],o=d[d.length-1];n.shiftKey&&document.activeElement===m?(n.preventDefault(),o.focus()):!n.shiftKey&&document.activeElement===o&&(n.preventDefault(),m.focus())};return S.jsxs("div",{ref:n=>{h.current=n,typeof l=="function"?l(n):l&&(l.current=n)},role:"dialog","aria-modal":"false","aria-labelledby":a,"data-calendar-popover":"",onKeyDown:L,className:P("fixed z-40 w-[26rem] max-w-[calc(100vw-1rem)] rounded-xl border border-line bg-surface-raised text-fg shadow-xl shadow-black/20",w===null&&"opacity-0",s),style:{left:(w?.left??0)+g.x,top:(w?.top??0)+g.y},children:[c?.({onPointerDown:O}),r]})}const _=e=>({calendarTaskId:e.calendarTaskId,calendarId:e.calendarId,title:e.summary,due:e.allDay?e.due.slice(0,10):e.dueAt,allDay:e.allDay,completed:e.completed});function F(e,t=!0){const{data:a,error:r,refetch:c}=E({...R({query:{from:e.from,to:e.to}}),meta:D(400,404),enabled:t});return{tasks:u.useMemo(()=>a?.items??[],[a?.items]),error:r,refetch:c}}function V(e){const{data:t,error:a,refetch:r}=E({...j({path:{calendarTaskId:e}}),meta:D(404),retry:!1});return t?{kind:"found",task:t}:a===null?{kind:"loading"}:I(a)===404?{kind:"gone"}:{kind:"failed",error:a,retry:()=>{r()}}}const T=e=>({kind:"refused",message:I(e)===412?"This task changed while you were looking at it. Close it and open it again.":N(e)});function J(){const e=z(),t=y({...v(),meta:k,onSuccess:e}),a=y({...q(),meta:k,onSuccess:e}),r=y({...W(),meta:k,onSuccess:e}),c=u.useCallback(s=>t.mutateAsync({body:s}).then(()=>({kind:"written"})).catch(T),[t]),f=u.useCallback((s,h)=>a.mutateAsync({path:{calendarTaskId:s.calendarTaskId},query:{calendarId:s.calendarId},headers:{"If-Match":s.etag},body:h}).then(()=>({kind:"written"})).catch(T),[a]),l=u.useCallback(s=>r.mutateAsync({path:{calendarTaskId:s.calendarTaskId},query:{calendarId:s.calendarId},headers:{"If-Match":s.etag}}).then(()=>({kind:"written"})).catch(T),[r]);return{createTask:c,updateTask:f,deleteTask:l,isWriting:t.isPending||a.isPending||r.isPending}}export{Y as C,F as a,V as b,_ as t,J as u};
1
+ import{r as u,j as O,p as P,f as y,eQ as v,eR as q,eS as R,a as E,eT as W,aP as I,eU as j,s as D}from"./index-CjLIM85N.js";import{a as z,C as k}from"./useCalendarSuggestions-9OSR5bVj.js";import{f as U}from"./ErrorState-k3wt6L_r.js";const i=8,x=(e,t,a)=>Math.min(Math.max(e,t),Math.max(t,a)),B=(e,t)=>e.width>0&&e.height>0&&e.left<t.width&&e.left+e.width>0&&e.top<t.height&&e.top+e.height>0;function C(e,t){return{left:Math.max(i,(t.width-e.width)/2),top:Math.max(i,(t.height-e.height)/2),side:"center"}}function G(e,t,a){if(!e||!B(e,a))return C(t,a);const r=x(e.top,i,a.height-t.height-i),c=e.left+e.width+i;if(c+t.width<=a.width-i)return{left:c,top:r,side:"right"};const f=e.left-i-t.width;if(f>=i)return{left:f,top:r,side:"left"};const l=x(e.left,i,a.width-t.width-i),s=e.top+e.height+i;if(s+t.height<=a.height-i)return{left:l,top:s,side:"below"};const h=e.top-i-t.height;return h>=i?{left:l,top:h,side:"above"}:C(t,a)}const H='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function Y({anchor:e,anchorKey:t,labelledBy:a,children:r,header:c,wrapTab:f=!1,panelRef:l,className:s}){const h=u.useRef(null),[w,M]=u.useState(null),[b,A]=u.useState({key:t,x:0,y:0}),g=b.key===t?b:{x:0,y:0};u.useLayoutEffect(()=>{const n=h.current;if(!n||t==="")return;const d=()=>{const o=(typeof e=="string"?document.querySelector(e):e)?.getBoundingClientRect();M(G(o?{left:o.left,top:o.top,width:o.width,height:o.height}:null,{width:n.offsetWidth,height:n.offsetHeight},{width:window.innerWidth,height:window.innerHeight}))};return d(),window.addEventListener("resize",d),()=>window.removeEventListener("resize",d)},[e,t]);const S=n=>{if(n.button!==0||n.target instanceof Element&&n.target.closest("button, input, select, a"))return;n.preventDefault();const d={x:n.clientX-g.x,y:n.clientY-g.y},m=p=>A({key:t,x:p.clientX-d.x,y:p.clientY-d.y}),o=()=>{window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",o)};window.addEventListener("pointermove",m),window.addEventListener("pointerup",o)},L=n=>{if(!f||n.key!=="Tab")return;const d=Array.from(n.currentTarget.querySelectorAll(H));if(d.length===0)return;const m=d[0],o=d[d.length-1];n.shiftKey&&document.activeElement===m?(n.preventDefault(),o.focus()):!n.shiftKey&&document.activeElement===o&&(n.preventDefault(),m.focus())};return O.jsxs("div",{ref:n=>{h.current=n,typeof l=="function"?l(n):l&&(l.current=n)},role:"dialog","aria-modal":"false","aria-labelledby":a,"data-calendar-popover":"",onKeyDown:L,className:P("fixed z-40 w-[26rem] max-w-[calc(100vw-1rem)] rounded-xl border border-line bg-surface-raised text-fg shadow-xl shadow-black/20",w===null&&"opacity-0",s),style:{left:(w?.left??0)+g.x,top:(w?.top??0)+g.y},children:[c?.({onPointerDown:S}),r]})}const _=e=>({calendarTaskId:e.calendarTaskId,calendarId:e.calendarId,title:e.summary,due:e.allDay?e.due.slice(0,10):e.dueAt,allDay:e.allDay,completed:e.completed});function F(e,t=!0){const{data:a,error:r,refetch:c}=E({...W({query:{from:e.from,to:e.to}}),meta:D(400,404),enabled:t});return{tasks:u.useMemo(()=>a?.items??[],[a?.items]),error:r,refetch:c}}function V(e){const{data:t,error:a,refetch:r}=E({...j({path:{calendarTaskId:e}}),meta:D(404),retry:!1});return t?{kind:"found",task:t}:a===null?{kind:"loading"}:I(a)===404?{kind:"gone"}:{kind:"failed",error:a,retry:()=>{r()}}}const T=e=>({kind:"refused",message:I(e)===412?"This task changed while you were looking at it. Close it and open it again.":U(e)});function J(){const e=z(),t=y({...v(),meta:k,onSuccess:e}),a=y({...q(),meta:k,onSuccess:e}),r=y({...R(),meta:k,onSuccess:e}),c=u.useCallback(s=>t.mutateAsync({body:s}).then(()=>({kind:"written"})).catch(T),[t]),f=u.useCallback((s,h)=>a.mutateAsync({path:{calendarTaskId:s.calendarTaskId},query:{calendarId:s.calendarId},headers:{"If-Match":s.etag},body:h}).then(()=>({kind:"written"})).catch(T),[a]),l=u.useCallback(s=>r.mutateAsync({path:{calendarTaskId:s.calendarTaskId},query:{calendarId:s.calendarId},headers:{"If-Match":s.etag}}).then(()=>({kind:"written"})).catch(T),[r]);return{createTask:c,updateTask:f,deleteTask:l,isWriting:t.isPending||a.isPending||r.isPending}}export{Y as C,F as a,V as b,_ as t,J as u};
@@ -1 +1 @@
1
- import{r as o}from"./index-CKflMWYU.js";const n=(e,t)=>{const[r,u]=o.useState(e);return o.useEffect(()=>{const s=setTimeout(()=>u(e),t);return()=>clearTimeout(s)},[e,t]),r};export{n as u};
1
+ import{r as o}from"./index-CjLIM85N.js";const n=(e,t)=>{const[r,u]=o.useState(e);return o.useEffect(()=>{const s=setTimeout(()=>u(e),t);return()=>clearTimeout(s)},[e,t]),r};export{n as u};
@@ -1 +1 @@
1
- import{j as u,ev as x,X as E,p as M,ew as z,ex as L,an as w,B as O,r as p,f as v,ey as T,a as D,ez as R,eA as $,eB as _,e as S,eC as J,eD as U,eE as B,eF as q,b7 as K}from"./index-CKflMWYU.js";import{u as Q,S as H}from"./suggest-list-B3YTezx4.js";import{S as W}from"./select-DBBB1VI8.js";import{P as X}from"./plus-BQ1_1L0j.js";const P="inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs";function pe({clause:e,onEdit:t,onRemove:r}){return u.jsxs("span",{className:M(P,e.derived?"border-dashed border-line-strong bg-surface-sunken":"border-line bg-surface"),children:[u.jsxs("button",{type:"button",onClick:t,"aria-label":`Edit ${x(e.field)} clause`,className:"flex items-center gap-1 text-left",children:[u.jsx("span",{className:"font-medium text-fg-muted",children:x(e.field)}),u.jsx("span",{className:"text-fg",children:e.value})]}),e.derived&&u.jsx("span",{className:"text-2xs text-fg-subtle",children:"from sender"}),r&&u.jsx("button",{type:"button",onClick:r,"aria-label":`Remove ${x(e.field)} clause`,className:"flex size-4 items-center justify-center rounded-full text-fg-subtle hover:bg-surface-sunken hover:text-fg-muted",children:u.jsx(E,{className:"size-3"})})]})}function fe({label:e,onClick:t}){return u.jsxs("button",{type:"button",onClick:t,className:M(P,"border-dashed border-line-strong text-fg-muted hover:border-accent-2 hover:text-accent-2"),children:[u.jsx(X,{className:"size-3","aria-hidden":"true"}),e]})}function be({draft:e,mode:t,fields:r=L,suggestions:s=[],onChangeField:o,onChangeValue:a,onSubmit:n,onCancel:c}){const d=z(e.field),l=Q({count:s.length,onAccept:i=>a?.(s[i].value)});return u.jsxs("div",{className:"space-y-1.5 rounded-lg border border-accent-2 bg-surface p-2",children:[u.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u.jsx(W,{"aria-label":"Clause field",value:e.field,onChange:i=>o?.(i.target.value),className:"h-8 w-32 shrink-0",children:r.map(i=>u.jsx("option",{value:i,children:x(i)},i))}),u.jsx(w,{"aria-label":"Clause value",value:e.value,placeholder:"value…",autoComplete:"off",onChange:i=>{l.reopen(),a?.(i.target.value)},onKeyDown:i=>{l.handleKeyDown(i)||i.key==="Enter"&&n?.()},className:"h-8 min-w-40 flex-1",...l.comboboxProps}),u.jsx(O,{variant:"primary",size:"sm",onClick:n,disabled:e.value.trim()==="",className:"shrink-0",children:t==="add"?"Add":"Save"}),u.jsx(O,{variant:"ghost",size:"sm",onClick:c,"aria-label":"Cancel clause edit",icon:u.jsx(E,{className:"size-4"}),className:"shrink-0 px-2"})]}),l.open&&u.jsx(H,{id:l.listId,suggestions:s,activeIndex:l.activeIndex,optionId:l.optionId,onPick:i=>{a?.(i.value),l.dismiss()},onHighlight:l.setActiveIndex,label:`${x(e.field)} suggestions`}),d&&u.jsx("p",{className:"px-0.5 text-2xs text-fg-subtle",children:d})]})}const ge=(e,t)=>{if(e.state==="Expired")return"Expired";const r=e.state==="Disabled"?"Disabled":"Active";if(e.scope!=="Temporary"||!e.expiresAt)return r;const s=Date.parse(e.expiresAt);return Number.isNaN(s)?r:s<=t?"Expired":r},N={UserDisabled:"Turned off. Turn it on to run it on new mail again.",AwaitingFolder:"Off until its folder exists on the mail server. It turns on by itself once the folder is created.",FolderCreateFailed:"Off: the mail server refused to create its folder. Pick another folder in the rule, then turn it on.",FolderMissing:"Off: the folder it moves mail into no longer exists. Pick another folder in the rule, then turn it on."},he=e=>e.disabledReason==="None"?void 0:(e.disabledReason==="AwaitingFolder"||e.disabledReason==="FolderCreateFailed")&&e.actionMailboxId!=="None"?N.UserDisabled:N[e.disabledReason],xe=e=>{if(!e)return;const t=Date.parse(e);if(!Number.isNaN(t))return new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})},j=(e,t=new Date)=>{if(!e)return;const r=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!r)return;const[,s,o,a]=r,n=new Date(Number(s),Number(o)-1,Number(a),23,59,59,0);if(Number.isNaN(n.getTime()))return;const c=-t.getTimezoneOffset(),d=c>=0?"+":"-",l=Math.abs(c),i=String(Math.floor(l/60)).padStart(2,"0"),f=String(l%60).padStart(2,"0"),m=b=>String(b).padStart(2,"0");return`${n.getFullYear()}-${m(n.getMonth()+1)}-${m(n.getDate())}T${m(n.getHours())}:${m(n.getMinutes())}:${m(n.getSeconds())}${d}${i}:${f}`},h="None",Y=e=>({filterId:e,matchOperator:"And",literalClauses:[],actionLabelId:h,actionMailboxId:h}),k=e=>({matchOperator:e.matchOperator,literalClauses:e.literalClauses,actionLabelId:e.labelId??h,actionMailboxId:e.moveMailboxId??h}),ve=({mode:e,ruleScope:t})=>t==="standing"?"standing":t==="until"?"temporary":e==="selected"?"just-these":"all-like-these",Ce=({ruleScope:e,clauses:t,matchOperator:r,moveMailboxId:s,until:o})=>({matchOperator:r==="all"?"And":"Or",literalClauses:t.map(a=>({field:a.field,value:a.value})),moveMailboxId:s,expiresAt:e==="until"?j(o??""):void 0}),F=(e,t,r)=>({name:r,scope:t==="standing"?"Standing":"Temporary",...t==="temporary"&&e.expiresAt?{expiresAt:e.expiresAt}:{},matchOperator:e.matchOperator,literalClauses:e.literalClauses,actionLabelId:e.labelId??h,actionMailboxId:e.moveMailboxId??h}),G=new Set(["Complete","Failed"]),A=e=>e!==void 0&&G.has(e),V=1e3,Z=15e3,ee=e=>{const t=Math.max(0,e),r=V*2**t;return Math.min(r,Z)},te=(e,t,r)=>{if(e)return{kind:r?"restartFailed":"startFailed",error:e};if(t)return{kind:"statusUnreadable",error:t}},Se=e=>{const[t,r]=p.useState(),s=v({...T(),onSuccess:g=>r(g.organizeJobId)}),{mutate:o}=s,a=D({...R({path:{accountId:e??"",organizeJobId:t??""}}),enabled:!!e&&!!t,refetchInterval:g=>{const I=g.state.data?.state;return A(I)?!1:ee(g.state.dataUpdateCount)}}),n=p.useCallback(g=>{e&&o({path:{accountId:e},body:k(g)})},[e,o]),c=p.useCallback(g=>{e&&o({path:{accountId:e},body:Y(g)})},[e,o]),{refetch:d}=a,l=p.useCallback(()=>{d()},[d]),i=a.data,f=s.isPending?void 0:i,m=f?.state??s.data?.state,b=A(f?.state),C={state:m,matchedCount:f?.matchedCount??0,appliedCount:f?.appliedCount??0,failedCount:f?.failedCount??0,errorMessage:f?.errorMessage??""};return{start:n,startForFilter:c,watch:r,refreshStatus:l,progress:C,isStarting:s.isPending,isRunning:!!t&&!b,isDone:b,failure:te(s.error,a.error,!!i)}},ye=["From","Subject","HasWords","ListId","FromDomain"],re=e=>{const t=e.trim(),r=t.match(/<([^>]+)>/);return(r?r[1]:t).trim().toLowerCase()},Oe=(e,t)=>e==="ListId"?re(t):t.trim(),se=e=>e==="all"?"And":"Or",ae=e=>({matchOperator:se(e.matchOperator),literalClauses:e.clauses.map(t=>({field:t.field,value:t.value}))}),ie=e=>!e.literalClauses.some(t=>t.field==="HasWords"),ne=e=>JSON.stringify({operator:e.matchOperator,clauses:e.literalClauses.map(t=>`${t.field} ${t.value}`)}),Ne=e=>{const t=ae(e);return{matchOperator:t.matchOperator,literalClauses:t.literalClauses,moveMailboxId:e.moveMailboxId,labelId:e.labelId,expiresAt:e.scope==="until"?j(e.until??""):void 0}},oe=(e,t)=>e.error!==void 0&&e.errorSignature===t?{status:"error",reason:e.error}:e.count===void 0?{status:"loading"}:e.previewedSignature===t?{status:"ready",count:e.count}:{status:"ready",count:e.count,stale:!0},le=350,Fe=(e,t,r)=>{const s=v($()),{mutateAsync:o}=s,a=ne(t),[n,c]=p.useState(()=>({})),d=p.useRef(t);d.current=t;const l=p.useRef(a),i=ie(t);return p.useEffect(()=>{if(!e||!i||a===n.previewedSignature||a===n.errorSignature)return;const f=setTimeout(()=>{const m=a;l.current=m,o({path:{accountId:e},body:k({...d.current})}).then(b=>{l.current===m&&c({count:b.matchedCount,matchedIds:b.messageIds,previewedSignature:m})}).catch(b=>{l.current===m&&c(C=>({...C,error:b instanceof Error?b.message:"Couldn't count matches.",errorSignature:m}))})},le);return()=>clearTimeout(f)},[e,i,a,n.previewedSignature,n.errorSignature,o]),i?{count:oe(n,a),matchedIds:n.previewedSignature===a?n.matchedIds??[]:[]}:{count:{status:"error",reason:_},matchedIds:[]}},y=e=>U({path:{accountId:e}}),Ae=e=>{const t=D({...B({path:{accountId:e??""}}),enabled:!!e});return{filters:t.data?.items??[],isPending:t.isPending,isError:t.isError,error:t.error,refetch:t.refetch}},Ee=e=>{const t=S(),r=v({...J(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:y(e)})}}),{mutate:s,mutateAsync:o}=r,a=p.useCallback((c,d,l)=>{e&&s({path:{accountId:e},body:F(c,d,l)})},[e,s]),n=p.useCallback(async(c,d,l)=>{if(e)return o({path:{accountId:e},body:F(c,d,l)}).then(i=>i,()=>{})},[e,o]);return{createFilter:a,createFilterAsync:n,data:r.data,isPending:r.isPending,isSuccess:r.isSuccess,isError:r.isError,error:r.error,reset:r.reset}},Me=e=>{const t=S(),r=v({...q(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:y(e)})}}),{mutate:s}=r;return{deleteFilter:p.useCallback(a=>{e&&s({path:{accountId:e,filterId:a}})},[e,s]),isPending:r.isPending,deletingFilterId:r.isPending?r.variables?.path.filterId:void 0}},De=e=>{const t=S(),r=v({...K(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:y(e)})}}),{mutate:s,variables:o}=r,a=p.useCallback((c,d)=>{e&&s({path:{accountId:e,filterId:c},body:{state:d?"Active":"Disabled"}})},[e,s]),n=p.useCallback(()=>{o&&s(o)},[s,o]);return{toggleFilter:a,retry:n,togglingFilterId:r.isPending?o?.path.filterId:void 0,isError:r.isError,error:r.error,enabling:o?.body?.state==="Active"}};export{fe as A,pe as C,h as N,ye as S,be as a,y as b,Se as c,Ne as d,he as e,ge as f,xe as g,Ae as h,Me as i,De as j,Ee as k,Ce as l,Oe as n,ve as o,j as p,ae as r,Fe as u};
1
+ import{j as u,eB as x,X as E,p as M,eC as L,eD as z,ao as w,B as O,r as p,f as v,eE as T,a as D,eF as R,eG as $,eH as _,e as S,eI as J,eJ as U,eK as B,eL as K,be as q}from"./index-CjLIM85N.js";import{u as H,S as Q}from"./suggest-list-CGKa8tfA.js";import{S as W}from"./select-BccK4I_R.js";import{P as G}from"./plus-CWdC1Tqr.js";const P="inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs";function pe({clause:e,onEdit:t,onRemove:r}){return u.jsxs("span",{className:M(P,e.derived?"border-dashed border-line-strong bg-surface-sunken":"border-line bg-surface"),children:[u.jsxs("button",{type:"button",onClick:t,"aria-label":`Edit ${x(e.field)} clause`,className:"flex items-center gap-1 text-left",children:[u.jsx("span",{className:"font-medium text-fg-muted",children:x(e.field)}),u.jsx("span",{className:"text-fg",children:e.value})]}),e.derived&&u.jsx("span",{className:"text-2xs text-fg-subtle",children:"from sender"}),r&&u.jsx("button",{type:"button",onClick:r,"aria-label":`Remove ${x(e.field)} clause`,className:"flex size-4 items-center justify-center rounded-full text-fg-subtle hover:bg-surface-sunken hover:text-fg-muted",children:u.jsx(E,{className:"size-3"})})]})}function fe({label:e,onClick:t}){return u.jsxs("button",{type:"button",onClick:t,className:M(P,"border-dashed border-line-strong text-fg-muted hover:border-accent-2 hover:text-accent-2"),children:[u.jsx(G,{className:"size-3","aria-hidden":"true"}),e]})}function be({draft:e,mode:t,fields:r=z,suggestions:s=[],onChangeField:o,onChangeValue:a,onSubmit:n,onCancel:c}){const d=L(e.field),l=H({count:s.length,onAccept:i=>a?.(s[i].value)});return u.jsxs("div",{className:"space-y-1.5 rounded-lg border border-accent-2 bg-surface p-2",children:[u.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u.jsx(W,{"aria-label":"Clause field",value:e.field,onChange:i=>o?.(i.target.value),className:"h-8 w-32 shrink-0",children:r.map(i=>u.jsx("option",{value:i,children:x(i)},i))}),u.jsx(w,{"aria-label":"Clause value",value:e.value,placeholder:"value…",autoComplete:"off",onChange:i=>{l.reopen(),a?.(i.target.value)},onKeyDown:i=>{l.handleKeyDown(i)||i.key==="Enter"&&n?.()},className:"h-8 min-w-40 flex-1",...l.comboboxProps}),u.jsx(O,{variant:"primary",size:"sm",onClick:n,disabled:e.value.trim()==="",className:"shrink-0",children:t==="add"?"Add":"Save"}),u.jsx(O,{variant:"ghost",size:"sm",onClick:c,"aria-label":"Cancel clause edit",icon:u.jsx(E,{className:"size-4"}),className:"shrink-0 px-2"})]}),l.open&&u.jsx(Q,{id:l.listId,suggestions:s,activeIndex:l.activeIndex,optionId:l.optionId,onPick:i=>{a?.(i.value),l.dismiss()},onHighlight:l.setActiveIndex,label:`${x(e.field)} suggestions`}),d&&u.jsx("p",{className:"px-0.5 text-2xs text-fg-subtle",children:d})]})}const ge=(e,t)=>{if(e.state==="Expired")return"Expired";const r=e.state==="Disabled"?"Disabled":"Active";if(e.scope!=="Temporary"||!e.expiresAt)return r;const s=Date.parse(e.expiresAt);return Number.isNaN(s)?r:s<=t?"Expired":r},N={UserDisabled:"Turned off. Turn it on to run it on new mail again.",AwaitingFolder:"Off until its folder exists on the mail server. It turns on by itself once the folder is created.",FolderCreateFailed:"Off: the mail server refused to create its folder. Pick another folder in the rule, then turn it on.",FolderMissing:"Off: the folder it moves mail into no longer exists. Pick another folder in the rule, then turn it on."},he=e=>e.disabledReason==="None"?void 0:(e.disabledReason==="AwaitingFolder"||e.disabledReason==="FolderCreateFailed")&&e.actionMailboxId!=="None"?N.UserDisabled:N[e.disabledReason],xe=e=>{if(!e)return;const t=Date.parse(e);if(!Number.isNaN(t))return new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})},j=(e,t=new Date)=>{if(!e)return;const r=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!r)return;const[,s,o,a]=r,n=new Date(Number(s),Number(o)-1,Number(a),23,59,59,0);if(Number.isNaN(n.getTime()))return;const c=-t.getTimezoneOffset(),d=c>=0?"+":"-",l=Math.abs(c),i=String(Math.floor(l/60)).padStart(2,"0"),f=String(l%60).padStart(2,"0"),m=b=>String(b).padStart(2,"0");return`${n.getFullYear()}-${m(n.getMonth()+1)}-${m(n.getDate())}T${m(n.getHours())}:${m(n.getMinutes())}:${m(n.getSeconds())}${d}${i}:${f}`},h="None",X=e=>({filterId:e,matchOperator:"And",literalClauses:[],actionLabelId:h,actionMailboxId:h}),I=e=>({matchOperator:e.matchOperator,literalClauses:e.literalClauses,actionLabelId:e.labelId??h,actionMailboxId:e.moveMailboxId??h}),ve=({mode:e,ruleScope:t})=>t==="standing"?"standing":t==="until"?"temporary":e==="selected"?"just-these":"all-like-these",Ce=({ruleScope:e,clauses:t,matchOperator:r,moveMailboxId:s,until:o})=>({matchOperator:r==="all"?"And":"Or",literalClauses:t.map(a=>({field:a.field,value:a.value})),moveMailboxId:s,expiresAt:e==="until"?j(o??""):void 0}),F=(e,t,r)=>({name:r,scope:t==="standing"?"Standing":"Temporary",...t==="temporary"&&e.expiresAt?{expiresAt:e.expiresAt}:{},matchOperator:e.matchOperator,literalClauses:e.literalClauses,actionLabelId:e.labelId??h,actionMailboxId:e.moveMailboxId??h}),Y=new Set(["Complete","Failed"]),A=e=>e!==void 0&&Y.has(e),V=1e3,Z=15e3,ee=e=>{const t=Math.max(0,e),r=V*2**t;return Math.min(r,Z)},te=(e,t,r)=>{if(e)return{kind:r?"restartFailed":"startFailed",error:e};if(t)return{kind:"statusUnreadable",error:t}},Se=e=>{const[t,r]=p.useState(),s=v({...T(),onSuccess:g=>r(g.organizeJobId)}),{mutate:o}=s,a=D({...R({path:{accountId:e??"",organizeJobId:t??""}}),enabled:!!e&&!!t,refetchInterval:g=>{const k=g.state.data?.state;return A(k)?!1:ee(g.state.dataUpdateCount)}}),n=p.useCallback(g=>{e&&o({path:{accountId:e},body:I(g)})},[e,o]),c=p.useCallback(g=>{e&&o({path:{accountId:e},body:X(g)})},[e,o]),{refetch:d}=a,l=p.useCallback(()=>{d()},[d]),i=a.data,f=s.isPending?void 0:i,m=f?.state??s.data?.state,b=A(f?.state),C={state:m,matchedCount:f?.matchedCount??0,appliedCount:f?.appliedCount??0,failedCount:f?.failedCount??0,errorMessage:f?.errorMessage??""};return{start:n,startForFilter:c,watch:r,refreshStatus:l,progress:C,isStarting:s.isPending,isRunning:!!t&&!b,isDone:b,failure:te(s.error,a.error,!!i)}},ye=["From","Subject","HasWords","ListId","FromDomain"],re=e=>{const t=e.trim(),r=t.match(/<([^>]+)>/);return(r?r[1]:t).trim().toLowerCase()},Oe=(e,t)=>e==="ListId"?re(t):t.trim(),se=e=>e==="all"?"And":"Or",ae=e=>({matchOperator:se(e.matchOperator),literalClauses:e.clauses.map(t=>({field:t.field,value:t.value}))}),ie=e=>!e.literalClauses.some(t=>t.field==="HasWords"),ne=e=>JSON.stringify({operator:e.matchOperator,clauses:e.literalClauses.map(t=>`${t.field} ${t.value}`)}),Ne=e=>{const t=ae(e);return{matchOperator:t.matchOperator,literalClauses:t.literalClauses,moveMailboxId:e.moveMailboxId,labelId:e.labelId,expiresAt:e.scope==="until"?j(e.until??""):void 0}},oe=(e,t)=>e.error!==void 0&&e.errorSignature===t?{status:"error",reason:e.error}:e.count===void 0?{status:"loading"}:e.previewedSignature===t?{status:"ready",count:e.count}:{status:"ready",count:e.count,stale:!0},le=350,Fe=(e,t,r)=>{const s=v($()),{mutateAsync:o}=s,a=ne(t),[n,c]=p.useState(()=>({})),d=p.useRef(t);d.current=t;const l=p.useRef(a),i=ie(t);return p.useEffect(()=>{if(!e||!i||a===n.previewedSignature||a===n.errorSignature)return;const f=setTimeout(()=>{const m=a;l.current=m,o({path:{accountId:e},body:I({...d.current})}).then(b=>{l.current===m&&c({count:b.matchedCount,matchedIds:b.messageIds,previewedSignature:m})}).catch(b=>{l.current===m&&c(C=>({...C,error:b instanceof Error?b.message:"Couldn't count matches.",errorSignature:m}))})},le);return()=>clearTimeout(f)},[e,i,a,n.previewedSignature,n.errorSignature,o]),i?{count:oe(n,a),matchedIds:n.previewedSignature===a?n.matchedIds??[]:[]}:{count:{status:"error",reason:_},matchedIds:[]}},y=e=>U({path:{accountId:e}}),Ae=e=>{const t=D({...B({path:{accountId:e??""}}),enabled:!!e});return{filters:t.data?.items??[],isPending:t.isPending,isError:t.isError,error:t.error,refetch:t.refetch}},Ee=e=>{const t=S(),r=v({...J(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:y(e)})}}),{mutate:s,mutateAsync:o}=r,a=p.useCallback((c,d,l)=>{e&&s({path:{accountId:e},body:F(c,d,l)})},[e,s]),n=p.useCallback(async(c,d,l)=>{if(e)return o({path:{accountId:e},body:F(c,d,l)}).then(i=>i,()=>{})},[e,o]);return{createFilter:a,createFilterAsync:n,data:r.data,isPending:r.isPending,isSuccess:r.isSuccess,isError:r.isError,error:r.error,reset:r.reset}},Me=e=>{const t=S(),r=v({...K(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:y(e)})}}),{mutate:s}=r;return{deleteFilter:p.useCallback(a=>{e&&s({path:{accountId:e,filterId:a}})},[e,s]),isPending:r.isPending,deletingFilterId:r.isPending?r.variables?.path.filterId:void 0}},De=e=>{const t=S(),r=v({...q(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:y(e)})}}),{mutate:s,variables:o}=r,a=p.useCallback((c,d)=>{e&&s({path:{accountId:e,filterId:c},body:{state:d?"Active":"Disabled"}})},[e,s]),n=p.useCallback(()=>{o&&s(o)},[s,o]);return{toggleFilter:a,retry:n,togglingFilterId:r.isPending?o?.path.filterId:void 0,isError:r.isError,error:r.error,enabling:o?.body?.state==="Active"}};export{fe as A,pe as C,h as N,ye as S,be as a,y as b,Se as c,Ne as d,he as e,ge as f,xe as g,Ae as h,Me as i,De as j,Ee as k,Ce as l,Oe as n,ve as o,j as p,ae as r,Fe as u};
@@ -0,0 +1 @@
1
+ import{a as L,ef as p,e as n,f as l,eg as d,r as o,eh as y,ei as c,ej as g}from"./index-CjLIM85N.js";const u=e=>y({path:{accountId:e}}),P=e=>{const r=L({...p({path:{accountId:e??""}}),enabled:!!e});return{labels:r.data?.items??[],isPending:r.isPending,isError:r.isError,error:r.error,refetch:r.refetch}},h=e=>{const r=n(),t=l({...d(),onSuccess:()=>{e&&r.invalidateQueries({queryKey:u(e)})}}),{mutateAsync:s}=t;return{createLabel:o.useCallback((a,i="Default")=>e?s({path:{accountId:e},body:{name:a,color:i}}):Promise.reject(new Error("No account")),[e,s]),isPending:t.isPending,isError:t.isError,error:t.error,reset:t.reset}},m=e=>{const r=n(),t=l({...c(),onSuccess:()=>{e&&r.invalidateQueries({queryKey:u(e)})}}),{mutate:s}=t;return{updateLabel:o.useCallback((a,i)=>{e&&s({path:{accountId:e,labelId:a},body:i})},[e,s]),isPending:t.isPending,updatingLabelId:t.isPending?t.variables?.path.labelId:void 0}},C=e=>{const r=n(),t=l({...g(),onSuccess:()=>{e&&r.invalidateQueries({queryKey:u(e)})}}),{mutate:s}=t;return{deleteLabel:o.useCallback(a=>{e&&s({path:{accountId:e,labelId:a}})},[e,s]),isPending:t.isPending,deletingLabelId:t.isPending?t.variables?.path.labelId:void 0}};export{P as a,m as b,C as c,h as u};
@@ -1 +1 @@
1
- import{a as s,D as e}from"./useMediaQuery-B1PJEoqh.js";const i=768,a=t=>t!=="desktop",r=()=>{const t=s(`(min-width: ${i}px)`);return s(e)?"desktop":t?"tablet":"phone"};export{a as i,r as u};
1
+ import{a as s,D as e}from"./useMediaQuery-Ct2USFCe.js";const i=768,a=t=>t!=="desktop",r=()=>{const t=s(`(min-width: ${i}px)`);return s(e)?"desktop":t?"tablet":"phone"};export{a as i,r as u};
@@ -1 +1 @@
1
- import{r as s}from"./index-CKflMWYU.js";const r=1024,c=`(min-width: ${r}px) and (not ((orientation: portrait) and (pointer: coarse)))`,d=e=>{const[o,n]=s.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(e).matches);return s.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const t=window.matchMedia(e);n(t.matches);const a=i=>n(i.matches);return t.addEventListener("change",a),()=>t.removeEventListener("change",a)},[e]),o},m=()=>d(c);export{c as D,d as a,m as u};
1
+ import{r as s}from"./index-CjLIM85N.js";const r=1024,c=`(min-width: ${r}px) and (not ((orientation: portrait) and (pointer: coarse)))`,d=e=>{const[o,n]=s.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(e).matches);return s.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const t=window.matchMedia(e);n(t.matches);const a=i=>n(i.matches);return t.addEventListener("change",a),()=>t.removeEventListener("change",a)},[e]),o},m=()=>d(c);export{c as D,d as a,m as u};
@@ -1,3 +1,3 @@
1
- import{r as V,u as go,c8 as _o,E as Wt,l as Eo,a6 as yo,e as Ao,a as bo,cw as So,ci as Ro}from"./index-CKflMWYU.js";import{e as Oo,f as wo}from"./reply-CM_F5zLS.js";import{c as Do}from"./nav-link-D4-gc9H1.js";function fn(n,o){(o==null||o>n.length)&&(o=n.length);for(var a=0,l=Array(o);a<o;a++)l[a]=n[a];return l}function Co(n){if(Array.isArray(n))return n}function Lo(n,o){var a=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(a!=null){var l,c,p,h,F=[],A=!0,G=!1;try{if(p=(a=a.call(n)).next,o!==0)for(;!(A=(l=p.call(a)).done)&&(F.push(l.value),F.length!==o);A=!0);}catch(W){G=!0,c=W}finally{try{if(!A&&a.return!=null&&(h=a.return(),Object(h)!==h))return}finally{if(G)throw c}}return F}}function No(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1
+ import{r as V,u as go,ce as _o,G as Wt,l as Eo,a7 as yo,e as Ao,a as bo,cC as So,co as Ro}from"./index-CjLIM85N.js";import{e as Oo,f as wo}from"./reply-jAIguvVh.js";import{c as Do}from"./nav-link-BJFBTF93.js";function fn(n,o){(o==null||o>n.length)&&(o=n.length);for(var a=0,l=Array(o);a<o;a++)l[a]=n[a];return l}function Co(n){if(Array.isArray(n))return n}function Lo(n,o){var a=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(a!=null){var l,c,p,h,F=[],A=!0,G=!1;try{if(p=(a=a.call(n)).next,o!==0)for(;!(A=(l=p.call(a)).done)&&(F.push(l.value),F.length!==o);A=!0);}catch(W){G=!0,c=W}finally{try{if(!A&&a.return!=null&&(h=a.return(),Object(h)!==h))return}finally{if(G)throw c}}return F}}function No(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Io(n,o){return Co(n)||Lo(n,o)||Mo(n,o)||No()}function Mo(n,o){if(n){if(typeof n=="string")return fn(n,o);var a={}.toString.call(n).slice(8,-1);return a==="Object"&&n.constructor&&(a=n.constructor.name),a==="Map"||a==="Set"?Array.from(n):a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?fn(n,o):void 0}}const wn=Object.entries,pn=Object.setPrototypeOf,Po=Object.isFrozen,Dn=Object.getPrototypeOf,Cn=Object.getOwnPropertyDescriptor;let O=Object.freeze,D=Object.seal,Tt=Object.create,Ln=typeof Reflect<"u"&&Reflect,De=Ln.apply,Ce=Ln.construct;O||(O=function(o){return o});D||(D=function(o){return o});De||(De=function(o,a){for(var l=arguments.length,c=new Array(l>2?l-2:0),p=2;p<l;p++)c[p-2]=arguments[p];return o.apply(a,c)});Ce||(Ce=function(o){for(var a=arguments.length,l=new Array(a>1?a-1:0),c=1;c<a;c++)l[c-1]=arguments[c];return new o(...l)});const $=E(Array.prototype.forEach),xo=E(Array.prototype.lastIndexOf),mn=E(Array.prototype.pop),Dt=E(Array.prototype.push),vo=E(Array.prototype.slice),ko=E(Array.prototype.splice),_t=Array.isArray,_e=Nn(Set),Ee=E(Set.prototype.add),Ct=E(Set.prototype.has),st=E(String.prototype.toLowerCase),ye=E(String.prototype.toString),dn=E(String.prototype.match),Lt=E(String.prototype.replace),hn=E(String.prototype.indexOf),Uo=E(String.prototype.trim),Fo=E(Number.prototype.toString),zo=E(Boolean.prototype.toString),Tn=typeof BigInt>"u"?null:E(BigInt.prototype.toString),gn=typeof Symbol>"u"?null:E(Symbol.prototype.toString),P=E(Object.prototype.hasOwnProperty),Nt=E(Object.prototype.toString),w=E(RegExp.prototype.test),j=Nn(TypeError);function E(n){return function(o){o instanceof RegExp&&(o.lastIndex=0);for(var a=arguments.length,l=new Array(a>1?a-1:0),c=1;c<a;c++)l[c-1]=arguments[c];return De(n,o,l)}}function Nn(n){return function(){for(var o=arguments.length,a=new Array(o),l=0;l<o;l++)a[l]=arguments[l];return Ce(n,a)}}function d(n,o){let a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:st;if(pn&&pn(n,null),!_t(o))return n;let l=o.length;for(;l--;){let c=o[l];if(typeof c=="string"){const p=a(c);p!==c&&(Po(o)||(o[l]=p),c=p)}n[c]=!0}return n}function Ho(n){for(let o=0;o<n.length;o++)P(n,o)||(n[o]=null);return n}function x(n){const o=Tt(null);for(const l of wn(n)){var a=Io(l,2);const c=a[0],p=a[1];P(n,c)&&(_t(p)?o[c]=Ho(p):p&&typeof p=="object"&&p.constructor===Object?o[c]=x(p):o[c]=p)}return o}function Bo(n){switch(typeof n){case"string":return n;case"number":return Fo(n);case"boolean":return zo(n);case"bigint":return Tn?Tn(n):"0";case"symbol":return gn?gn(n):"Symbol()";case"undefined":return Nt(n);case"function":case"object":{if(n===null)return Nt(n);const o=n,a=k(o,"toString");if(typeof a=="function"){const l=a(o);return typeof l=="string"?l:Nt(l)}return Nt(n)}default:return Nt(n)}}function k(n,o){for(;n!==null;){const l=Cn(n,o);if(l){if(l.get)return E(l.get);if(typeof l.value=="function")return E(l.value)}n=Dn(n)}function a(){return null}return a}function Go(n,o){for(;n!==null;){const a=Cn(n,o);if(a)return a.get?E(a.get):null;n=Dn(n)}return null}function Wo(n){try{return w(n,""),!0}catch{return!1}}const _n=O(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Ae=O(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),be=O(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Yo=O(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Se=O(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),$o=O(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),En=O(["#text"]),yn=O(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Re=O(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),An=O(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Yt=O(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),jo=D(/{{[\w\W]*|^[\w\W]*}}/g),Vo=D(/<%[\w\W]*|^[\w\W]*%>/g),Xo=D(/\${[\w\W]*/g),Ko=D(/^data-[\-\w.\u00B7-\uFFFF]+$/),qo=D(/^aria-[\-\w]+$/),bn=D(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Qo=D(/^(?:\w+script|data):/i),Zo=D(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Jo=D(/^html$/i),tr=D(/^[a-z][.\w]*(-[.\w]+)+$/i),Oe=D(/<[/\w!]/g),Sn=D(/<[/\w]/g),er=D(/<\/no(script|embed|frames)/i),Rn=D(/\/>/i),b={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},nr=O(d({},["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"])),or=function(){return typeof window>"u"?null:window},rr=function(o,a){if(typeof o!="object"||typeof o.createPolicy!="function")return null;let l=null;const c="data-tt-policy-suffix";a&&a.hasAttribute(c)&&(l=a.getAttribute(c));const p="dompurify"+(l?"#"+l:"");try{return o.createPolicy(p,{createHTML(h){return h},createScriptURL(h){return h}})}catch{return console.warn("TrustedTypes policy "+p+" could not be created."),null}},On=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Z=function(o,a,l,c){return P(o,a)&&_t(o[a])?d(c.base?x(c.base):{},o[a],c.transform):l},we=function(o,a,l){const c=P(o,a)?o[a]:void 0;return c&&typeof c=="object"?x(c):l()};function In(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:or();const o=s=>In(s);if(o.version="3.4.17",o.removed=[],!n||!n.document||n.document.nodeType!==b.document||!n.Element)return o.isSupported=!1,o;let a=n.document;const l=a,c=l.currentScript;n.DocumentFragment;const p=n.HTMLTemplateElement,h=n.Node,F=n.Element,A=n.NodeFilter;n.NamedNodeMap===void 0&&(n.NamedNodeMap||n.MozNamedAttrMap),n.HTMLFormElement;const G=n.DOMParser,W=n.trustedTypes,R=F.prototype,Et=k(R,"cloneNode"),yt=k(R,"remove"),It=k(R,"removeAttributeNode"),J=k(R,"nextSibling"),L=k(R,"childNodes"),X=k(R,"parentNode"),$t=k(R,"shadowRoot"),jt=k(R,"attributes"),tt=h&&h.prototype?k(h.prototype,"nodeType"):null,at=h&&h.prototype?k(h.prototype,"nodeName"):null,Mt=h&&h.prototype?k(h.prototype,"ownerDocument"):null,v=function(t){return tt?tt(t):t.nodeType},At=function(t){return at?at(t):t.nodeName},Ie=Go(R,"namespaceURI"),Vt=function(t){return Ie?Ie(t):t.namespaceURI};if(typeof p=="function"){const s=a.createElement("template");s.content&&s.content.ownerDocument&&(a=s.content.ownerDocument)}let N,et="",Xt,Me=!1,bt=0;const Pe=function(){if(bt>0)throw j('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},lt=function(t){Pe(),bt++;try{return N.createHTML(t)}finally{bt--}},Fn=function(t){Pe(),bt++;try{return N.createScriptURL(t)}finally{bt--}},zn=function(){return Me||(Xt=rr(W,c),Me=!0),Xt},Pt=a,Kt=Pt.implementation,xe=Pt.createNodeIterator,Hn=Pt.createDocumentFragment,Bn=Pt.getElementsByTagName,Gn=l.importNode;let T=On();o.isSupported=typeof wn=="function"&&typeof X=="function"&&Kt&&Kt.createHTMLDocument!==void 0;const Wn=jo,Yn=Vo,$n=Xo,jn=Ko,Vn=qo,Xn=Qo,ve=Zo,Kn=tr;let ke=bn,g=null;const qt=d({},[..._n,...Ae,...be,...Se,...En]);let _=null;const Qt=d({},[...yn,...Re,...An,...Yt]);let z=Object.seal(Tt(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),St=null,Ue=null;const K=Object.seal(Tt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Fe=!0,Zt=!0,ze=!1,Jt=!0,Y=!1,nt=!0,ot=!1,te=!1,xt=null,vt=null,ee=!1,ct=!1,kt=!1,Ut=!1,He=!0,Be=!1;const Ge="user-content-";let ne=!0,oe=!1,rt=null,ut={},it=null;const We=d({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let Ye=null;const $e=d({},["audio","video","img","source","image","track"]);let je=null;const Ve=d({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ft="http://www.w3.org/1998/Math/MathML",zt="http://www.w3.org/2000/svg",H="http://www.w3.org/1999/xhtml";let ft=H,re=!1,ie=null;const qn=d({},[Ft,zt,H],ye),Xe=O(["mi","mo","mn","ms","mtext"]);let se=d({},Xe);const Ke=O(["annotation-xml"]);let ae=d({},Ke);const Qn=d({},["title","style","font","a","script"]);let Rt=null;const Zn=["application/xhtml+xml","text/html"],Jn="text/html";let y=null,pt=null;const to=a.createElement("form"),qe=function(t){return t instanceof RegExp||t instanceof Function},le=function(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(pt&&pt===t)return;(!t||typeof t!="object")&&(t={}),t=x(t),Rt=Zn.indexOf(t.PARSER_MEDIA_TYPE)===-1?Jn:t.PARSER_MEDIA_TYPE,y=Rt==="application/xhtml+xml"?ye:st,g=Z(t,"ALLOWED_TAGS",qt,{transform:y}),_=Z(t,"ALLOWED_ATTR",Qt,{transform:y}),ie=Z(t,"ALLOWED_NAMESPACES",qn,{transform:ye}),je=Z(t,"ADD_URI_SAFE_ATTR",Ve,{transform:y,base:Ve}),Ye=Z(t,"ADD_DATA_URI_TAGS",$e,{transform:y,base:$e}),it=Z(t,"FORBID_CONTENTS",We,{transform:y}),St=Z(t,"FORBID_TAGS",x({}),{transform:y}),Ue=Z(t,"FORBID_ATTR",x({}),{transform:y}),ut=P(t,"USE_PROFILES")?t.USE_PROFILES&&typeof t.USE_PROFILES=="object"?x(t.USE_PROFILES):t.USE_PROFILES:!1,Fe=t.ALLOW_ARIA_ATTR!==!1,Zt=t.ALLOW_DATA_ATTR!==!1,ze=t.ALLOW_UNKNOWN_PROTOCOLS||!1,Jt=t.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Y=t.SAFE_FOR_TEMPLATES||!1,nt=t.SAFE_FOR_XML!==!1,ot=t.WHOLE_DOCUMENT||!1,ct=t.RETURN_DOM||!1,kt=t.RETURN_DOM_FRAGMENT||!1,Ut=t.RETURN_TRUSTED_TYPE||!1,ee=t.FORCE_BODY||!1,He=t.SANITIZE_DOM!==!1,Be=t.SANITIZE_NAMED_PROPS||!1,ne=t.KEEP_CONTENT!==!1,oe=t.IN_PLACE||!1,ke=Wo(t.ALLOWED_URI_REGEXP)?t.ALLOWED_URI_REGEXP:bn,ft=typeof t.NAMESPACE=="string"?t.NAMESPACE:H,se=we(t,"MATHML_TEXT_INTEGRATION_POINTS",()=>d({},Xe)),ae=we(t,"HTML_INTEGRATION_POINTS",()=>d({},Ke));const e=we(t,"CUSTOM_ELEMENT_HANDLING",()=>Tt(null));if(z=Tt(null),P(e,"tagNameCheck")&&qe(e.tagNameCheck)&&(z.tagNameCheck=e.tagNameCheck),P(e,"attributeNameCheck")&&qe(e.attributeNameCheck)&&(z.attributeNameCheck=e.attributeNameCheck),P(e,"allowCustomizedBuiltInElements")&&typeof e.allowCustomizedBuiltInElements=="boolean"&&(z.allowCustomizedBuiltInElements=e.allowCustomizedBuiltInElements),D(z),Y&&(Zt=!1),kt&&(ct=!0),ut&&(g=d({},En),_=Tt(null),ut.html===!0&&(d(g,_n),d(_,yn)),ut.svg===!0&&(d(g,Ae),d(_,Re),d(_,Yt)),ut.svgFilters===!0&&(d(g,be),d(_,Re),d(_,Yt)),ut.mathMl===!0&&(d(g,Se),d(_,An),d(_,Yt))),K.tagCheck=null,K.attributeCheck=null,P(t,"ADD_TAGS")&&(typeof t.ADD_TAGS=="function"?K.tagCheck=t.ADD_TAGS:_t(t.ADD_TAGS)&&(g===qt&&(g=x(g)),d(g,t.ADD_TAGS,y))),P(t,"ADD_ATTR")&&(typeof t.ADD_ATTR=="function"?K.attributeCheck=t.ADD_ATTR:_t(t.ADD_ATTR)&&(_===Qt&&(_=x(_)),d(_,t.ADD_ATTR,y))),P(t,"ADD_FORBID_CONTENTS")&&_t(t.ADD_FORBID_CONTENTS)&&(it===We&&(it=x(it)),d(it,t.ADD_FORBID_CONTENTS,y)),ne&&(g["#text"]=!0),ot&&d(g,["html","head","body"]),g.table&&(d(g,["tbody"]),delete St.tbody),t.TRUSTED_TYPES_POLICY){if(typeof t.TRUSTED_TYPES_POLICY.createHTML!="function")throw j('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof t.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw j('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const r=N;N=t.TRUSTED_TYPES_POLICY;try{et=lt("")}catch(i){throw N=r,i}}else t.TRUSTED_TYPES_POLICY===null?(N=void 0,et=""):(N===void 0&&(N=zn()),N&&typeof et=="string"&&(et=lt("")));O&&O(t),pt=t},Qe=d({},[...Ae,...be,...Yo]),Ze=d({},[...Se,...$o]),eo=function(t,e,r){return e.namespaceURI===H?t==="svg":e.namespaceURI===Ft?t==="svg"&&(r==="annotation-xml"||se[r]):!!Qe[t]},no=function(t,e,r){return e.namespaceURI===H?t==="math":e.namespaceURI===zt?t==="math"&&ae[r]:!!Ze[t]},oo=function(t,e,r){return e.namespaceURI===zt&&!ae[r]||e.namespaceURI===Ft&&!se[r]?!1:!Ze[t]&&(Qn[t]||!Qe[t])},ro=function(t){const e=Vt(t),r=st(At(t)),i=X(t);let u,f;return i&&v(i)===b.element?(u={namespaceURI:Vt(i)},f=st(At(i))):(u={namespaceURI:ft},f="template"),ie[e]?e===zt?eo(r,u,f):e===Ft?no(r,u,f):e===H?oo(r,u,f):!!(Rt==="application/xhtml+xml"&&ie[e]):!1},q=function(t){Dt(o.removed,{element:t});try{X(t).removeChild(t)}catch{if(yt(t),!X(t))throw j("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Je=function(t,e,r){try{It(t,e)}catch{try{t.removeAttribute(r)}catch{}}},ce=function(t){fe(t);const e=L(t);e&&$(vo(e),i=>{try{yt(i)}catch{}});const r=v(t)===b.element?jt(t):null;if(r)for(let i=r.length-1;i>=0;--i){const u=r[i],f=u&&u.name;typeof f=="string"&&Je(t,u,f)}},mt=function(t,e,r){if(!r)try{r=e.getAttributeNode(t)}catch{r=null}Dt(o.removed,{attribute:r||null,from:e});try{r?It(e,r):e.removeAttribute(t)}catch{try{e.removeAttribute(t)}catch{}}if(t==="is")if(ct||kt)try{q(e)}catch{}else try{e.setAttribute(t,"")}catch{}},tn=function(t){const e=jt(t);if(e)for(let r=e.length-1;r>=0;--r){const i=e[r],u=i&&i.name;typeof u!="string"||_[y(u)]||Je(t,i,u)}},ue=function(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;const i=[t];for(;i.length>0;){const u=i.pop();if(e(u)===!1)continue;if(r&&v(u)===b.element){const m=$t(u);Q(m)&&i.push(m)}const f=L(u);if(f)for(let m=f.length-1;m>=0;--m)i.push(f[m])}},fe=function(t){ue(t,e=>{v(e)===b.element&&tn(e)})},pe=function(t){const e=[];return ue(t,r=>{e.push(r)},!0),e},io=function(t,e){const r=_e();$(pe(t),i=>{v(i)===b.element&&Ee(r,i)}),$(e,i=>{v(i)===b.element&&!Ct(r,i)&&tn(i)})},en=function(t,e){let r=!1;return $(o.removed,i=>{i.element&&(r=r||i.element===t,fe(i.element))}),io(t,e),r},so=8,ao=function(t,e){const r=rt;let i=null;const u=()=>(i||(i=_e(),$(e,f=>{Ee(i,f)})),i);for(let f=0;;f++){const m=pe(t),S=[t];let B=!1;if($(m,C=>{v(C)===b.documentFragment?Dt(S,C):!B&&!Ct(r,C)&&(B=Ct(u(),C))}),!B)return;if(f>=so)throw j("the tree kept changing during in-place sanitization; refusing to return it");$(S,(C,I)=>{lo(C,I>0,t,u())})}},lo=function(t,e,r,i){const u=me(t);let f;for(;f=u.nextNode();)!Ct(i,f)||Ct(rt,f)||(e&&U(T.uponSanitizeShadowNode,f,null),he(f,r),Te(f,r),Q(f.content)&&wt(f.content))},co=function(t){rt&&Ee(rt,t)},nn=function(t,e){return nt?t==="patchsrc"?!0:t==="for"&&e!=="label"&&e!=="output":!1},uo=function(t){nt&&ue(t,e=>{const r=v(e);if(r===b.processingInstruction||r===b.comment&&w(Sn,e.data)){try{yt(e)}catch{}return!1}if(r===b.element){const i=e,u=y(At(e));try{i.hasAttribute&&i.hasAttribute("patchsrc")&&i.removeAttribute("patchsrc"),i.hasAttribute&&i.hasAttribute("for")&&nn("for",u)&&i.removeAttribute("for")}catch{}}return!0})},on=function(t){let e=null,r=null;if(ee)t="<remove></remove>"+t;else{const f=dn(t,/^[\r\n\t ]+/);r=f&&f[0]}Rt==="application/xhtml+xml"&&ft===H&&(t='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+t+"</body></html>");const i=N?lt(t):t;if(ft===H)try{e=new G().parseFromString(i,Rt)}catch{}if(!e||!e.documentElement){e=Kt.createDocument(ft,"template",null);try{e.documentElement.innerHTML=re?et:i}catch{}}const u=e.body||e.documentElement;return t&&r&&u.insertBefore(a.createTextNode(r),u.childNodes[0]||null),ft===H?Bn.call(e,ot?"html":"body")[0]:ot?e.documentElement:u},me=function(t){const e=Mt?Mt(t):t.ownerDocument;return xe.call(e||t,t,A.SHOW_ELEMENT|A.SHOW_COMMENT|A.SHOW_TEXT|A.SHOW_PROCESSING_INSTRUCTION|A.SHOW_CDATA_SECTION,null)},Ht=function(t){return t=Lt(t,Wn," "),t=Lt(t,Yn," "),t=Lt(t,$n," "),t},de=function(t){var e;rn(t);const r=(e=t.querySelectorAll)===null||e===void 0?void 0:e.call(t,"template");r&&$(r,i=>{Q(i.content)&&de(i.content)})},rn=function(t){t.normalize();const e=Mt?Mt(t):t.ownerDocument,r=xe.call(e||t,t,A.SHOW_TEXT|A.SHOW_COMMENT|A.SHOW_CDATA_SECTION|A.SHOW_PROCESSING_INSTRUCTION,null);let i=r.nextNode();for(;i;)i.data=Ht(i.data),i=r.nextNode()},Bt=function(t){const e=at?at(t):null;return typeof e!="string"||y(e)!=="form"?!1:typeof t.nodeName!="string"||typeof t.textContent!="string"||typeof t.removeChild!="function"||t.attributes!==jt(t)||typeof t.removeAttribute!="function"||typeof t.removeAttributeNode!="function"||typeof t.getAttributeNode!="function"||typeof t.setAttribute!="function"||typeof t.namespaceURI!="string"||typeof t.insertBefore!="function"||typeof t.hasChildNodes!="function"||t.nodeType!==tt(t)||t.childNodes!==L(t)},Q=function(t){if(!tt||typeof t!="object"||t===null)return!1;try{return tt(t)===b.documentFragment}catch{return!1}},Ot=function(t){if(!tt||typeof t!="object"||t===null)return!1;try{return typeof tt(t)=="number"}catch{return!1}};function U(s,t,e){s.length!==0&&$(s,r=>{r.call(o,t,e,pt)})}const fo=function(t,e){return!!(nt&&t.hasChildNodes()&&!Ot(t.firstElementChild)&&w(Oe,t.textContent)&&w(Oe,t.innerHTML)||nt&&nr[e]&&v(t)===b.element&&Vt(t)===H&&(Ot(t.firstElementChild)||typeof t.textContent=="string"&&w(Oe,t.textContent))||t.nodeType===b.processingInstruction||nt&&t.nodeType===b.comment&&w(Sn,t.data))},Gt=function(t,e){if(t instanceof RegExp)return w(t,e);if(t instanceof Function){for(var r=arguments.length,i=new Array(r>2?r-2:0),u=2;u<r;u++)i[u-2]=arguments[u];return!!t(e,...i)}return!1},po=function(t,e,r){if(!St[e]&&ln(e)&&Gt(z.tagNameCheck,e))return!1;if(ne&&!it[e]&&!it[st(e)]){const i=X(t),u=L(t);if(u&&i){const f=u.length;for(let m=f-1;m>=0;--m){const S=t===r?Et(u[m],!0):u[m];i.insertBefore(S,J(t))}}}return q(t),!0},sn=function(t,e,r,i){return t.length===0?e:e===r||e===i?x(e):e},dt=function(t,e){return t===e||X(t)!==null?!1:(oe&&fe(t),!0)},he=function(t,e){if(co(t),U(T.beforeSanitizeElements,t,null),dt(t,e))return!0;if(Bt(t))return q(t),!0;const r=y(At(t));if(g=sn(T.uponSanitizeElement,g,qt,xt),U(T.uponSanitizeElement,t,{tagName:r,allowedTags:g}),dt(t,e))return!0;if(fo(t,r))return q(t),!0;if(St[r]||!(K.tagCheck instanceof Function&&K.tagCheck(r))&&!g[r]){const i=po(t,r,e);return i===!1&&(U(T.afterSanitizeElements,t,null),dt(t,e))?!0:i}if(v(t)===b.element&&!ro(t)||(r==="noscript"||r==="noembed"||r==="noframes")&&w(er,t.innerHTML))return q(t),!0;if(Y&&t.nodeType===b.text){const i=Ht(t.textContent);t.textContent!==i&&(Dt(o.removed,{element:t.cloneNode()}),t.textContent=i)}return U(T.afterSanitizeElements,t,null),dt(t,e)},an=function(t,e,r){if(Ue[e]||nn(e,t)||He&&(e==="id"||e==="name")&&(r in a||r in to))return!1;const i=_[e]||K.attributeCheck instanceof Function&&K.attributeCheck(e,t);return Zt&&w(jn,e)||Fe&&w(Vn,e)?!0:i?je[e]||w(ke,Lt(r,ve,""))||(e==="src"||e==="xlink:href"||e==="href")&&t!=="script"&&hn(r,"data:")===0&&Ye[t]||ze&&!w(Xn,Lt(r,ve,""))?!0:!r:ln(t)&&Gt(z.tagNameCheck,t)&&Gt(z.attributeNameCheck,e,t)||e==="is"&&z.allowCustomizedBuiltInElements&&Gt(z.tagNameCheck,r)},mo=d({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),ln=function(t){return!mo[st(t)]&&w(Kn,t)},ho=function(t,e,r,i){if(N&&typeof W=="object"&&typeof W.getAttributeType=="function"&&!r)switch(W.getAttributeType(t,e)){case"TrustedHTML":return lt(i);case"TrustedScriptURL":return Fn(i)}return i},To=function(t,e,r,i){try{return r?t.setAttributeNS(r,e,i):t.setAttribute(e,i),Bt(t)?(q(t),!1):!0}catch{return mt(e,t),!1}},cn=function(t,e){return nt&&w(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,e)?!0:st(t)==="attributename"&&dn(e,"href")!==null},Te=function(t,e){if(U(T.beforeSanitizeAttributes,t,null),dt(t,e))return;const r=t.attributes;if(!r||Bt(t))return;_=sn(T.uponSanitizeAttribute,_,Qt,vt);const i={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:_,forceKeepAttr:void 0};let u=r.length;const f=y(t.nodeName);for(;u--;){const m=r[u],S=m.name,B=m.namespaceURI,C=m.value,I=y(S),ht=C;let M=S==="value"?ht:Uo(ht),un=!1;if(i.attrName=I,i.attrValue=M,i.keepAttr=!0,i.forceKeepAttr=void 0,U(T.uponSanitizeAttribute,t,i),M=i.attrValue,Be&&(I==="id"||I==="name")&&hn(M,Ge)!==0&&(mt(S,t,m),M=Ge+M,un=!0),cn(S,M)){mt(S,t,m);continue}if(!i.forceKeepAttr){if(!i.keepAttr){mt(S,t,m);continue}if(!Jt&&w(Rn,M)){mt(S,t,m);continue}if(Y&&(M=Ht(M)),!an(f,I,M)){mt(S,t,m);continue}M=ho(f,I,B,M),M!==ht&&To(t,S,B,M)&&un&&mn(o.removed)}}U(T.afterSanitizeAttributes,t,null),dt(t,e)},wt=function(t){let e=null;const r=me(t);for(U(T.beforeSanitizeShadowDOM,t,null);e=r.nextNode();)if(U(T.uponSanitizeShadowNode,e,null),he(e,t),Te(e,t),Q(e.content)&&wt(e.content),v(e)===b.element){const i=$t(e);Q(i)&&(ge(i),wt(i))}Y&&rn(t),U(T.afterSanitizeShadowDOM,t,null)},ge=function(t){const e=[{node:t,shadow:null}];for(;e.length>0;){const r=e.pop();if(r.shadow){wt(r.shadow);continue}const i=r.node,u=v(i)===b.element,f=L(i);if(f)for(let m=f.length-1;m>=0;--m)e.push({node:f[m],shadow:null});if(u){const m=at?at(i):null;if(typeof m=="string"&&y(m)==="template"){const S=i.content;Q(S)&&e.push({node:S,shadow:null})}}if(u){const m=$t(i);Q(m)&&e.push({node:null,shadow:m},{node:m,shadow:null})}}};return o.sanitize=function(s){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},e=null,r=null,i=null,u=null;if(re=!s,re&&(s="<!-->"),typeof s!="string"&&!Ot(s)&&(s=Bo(s),typeof s!="string"))throw j("dirty is not a string, aborting");if(!o.isSupported)return s;te?(g=xt,_=vt):le(t),(T.uponSanitizeElement.length>0||T.uponSanitizeAttribute.length>0)&&(g=x(g)),T.uponSanitizeAttribute.length>0&&(_=x(_)),o.removed=[];const f=oe&&typeof s!="string"&&Ot(s);let m=[];const S=rt;if(f){uo(s);const I=At(s);if(typeof I=="string"){const ht=y(I);if(!g[ht]||St[ht])throw ce(s),j("root node is forbidden and cannot be sanitized in-place")}if(Bt(s))throw ce(s),j("root node is clobbered and cannot be sanitized in-place");m=pe(s),rt=_e()}else if(Ot(s))e=on("<!---->"),r=e.ownerDocument.importNode(s,!0),r.nodeType===b.element&&r.nodeName==="BODY"||r.nodeName==="HTML"?e=r:e.appendChild(r),ge(e);else{if(!ct&&!Y&&!ot&&s.indexOf("<")===-1)return N&&Ut?lt(s):s;if(e=on(s),!e)return ct?null:Ut?et:""}e&&ee&&q(e.firstChild);const B=f?s:e;try{f&&ge(s);const I=me(B);for(;i=I.nextNode();)he(i,B),Te(i,B),Q(i.content)&&wt(i.content);f&&ao(s,m)}catch(I){throw f&&(ce(s),en(s,m)),I}finally{rt=S}if(f){if(en(s,m))throw j("a node selected for removal could not be safely returned; refusing to sanitize in place");return Y&&de(s),s}if(ct){if(Y&&de(e),kt)for(u=Hn.call(e.ownerDocument);e.firstChild;)u.appendChild(e.firstChild);else u=e;return(_.shadowroot||_.shadowrootmode)&&(u=Gn.call(l,u,!0)),u}let C=ot?e.outerHTML:e.innerHTML;return ot&&g["!doctype"]&&e.ownerDocument&&e.ownerDocument.doctype&&e.ownerDocument.doctype.name&&w(Jo,e.ownerDocument.doctype.name)&&(C="<!DOCTYPE "+e.ownerDocument.doctype.name+`>
3
3
  `+C),Y&&(C=Ht(C)),N&&Ut?lt(C):C},o.setConfig=function(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};le(s),te=!0,xt=g,vt=_},o.clearConfig=function(){pt=null,te=!1,xt=null,vt=null,N=Xt,et=""},o.isValidAttribute=function(s,t,e){pt||le({});const r=y(s),i=y(t);return typeof e=="string"&&(cn(t,e)||!Jt&&w(Rn,e))?!1:an(r,i,e)},o.addHook=function(s,t){typeof t=="function"&&P(T,s)&&Dt(T[s],t)},o.removeHook=function(s,t){if(P(T,s)){if(t!==void 0){const e=xo(T[s],t);return e===-1?void 0:ko(T[s],e,1)[0]}return mn(T[s])}},o.removeHooks=function(s){P(T,s)&&(T[s]=[])},o.removeAllHooks=function(){T=On()},o}var Ar=In();const Mn="/mail/brief/compose/{-$outboxMessageId}",Pn="/mail/flagged/compose/{-$outboxMessageId}",xn="/mail/outbox/compose/{-$outboxMessageId}",vn="/mail/$mailboxId/compose/{-$outboxMessageId}";function kn(){const n=Wt({from:Mn,shouldThrow:!1}),o=Wt({from:Pn,shouldThrow:!1}),a=Wt({from:xn,shouldThrow:!1}),l=Wt({from:vn,shouldThrow:!1});return n??o??a??l}function br(){return kn()!==void 0}function Sr(){return kn()?.outboxMessageId}function ir(n,o,a){return n==="flagged"?{to:Pn,params:{outboxMessageId:a}}:n==="outbox"?{to:xn,params:{outboxMessageId:a}}:n==="mailbox"&&o?{to:vn,params:{mailboxId:o,outboxMessageId:a}}:{to:Mn,params:{outboxMessageId:a}}}function Ne(){const n=go(),o=Do(),{list:a,mailboxId:l}=Oo();return V.useCallback((c,p)=>{n({...ir(a,l,c),search:_o,hash:p?.keepPanels?!0:o,replace:p?.replace??!1})},[n,o,a,l])}function Rr(){const n=Ne();return V.useCallback(()=>n(void 0),[n])}function Or(){const n=Ne();return V.useCallback(o=>n(o),[n])}function wr(){const n=Ne();return V.useCallback(o=>n(o,{replace:!0,keepPanels:!0}),[n])}function Dr(){return wo()}const sr=new Set(["rfc822","global"]),ar=n=>n.mediaType.toUpperCase()==="MESSAGE"&&sr.has(n.mediaSubtype.toLowerCase()),Un=(n,o)=>n.partPath.startsWith(`${o}.`),lr=n=>{const o=n.filter(ar);return n.filter(a=>!o.some(l=>Un(a,l.partPath)))},Cr=(n,o)=>n.filter(a=>Un(a,o)),cr=n=>{const o=lr(n).filter(c=>!c.isMultipart&&c.disposition!=="attachment"&&c.mediaType==="TEXT"&&c.contentUrl.length>0),a=o.find(c=>c.mediaSubtype.toUpperCase()==="HTML");if(a)return{kind:"html",contentUrl:a.contentUrl};const l=o.find(c=>c.mediaSubtype.toUpperCase()==="PLAIN");return l?{kind:"text",contentUrl:l.contentUrl}:null},Le={all:["messages"],detail:n=>[...Le.all,"detail",n],body:n=>[...Le.detail(n),"body"]};class gt extends Error{reason;status;retryAfterSeconds;constructor(o,a,l,c){super(a),this.name="BodyFetchError",this.reason=o,this.status=l,this.retryAfterSeconds=c}}const ur=n=>{const o=Number.parseInt(n??"",10);return!Number.isFinite(o)||o<=0?1:Math.min(o,30)},fr=8,pr="x-remit-403-reason",mr=(n,o)=>{const a=o?.trim()??"";return n===401?"auth":n===403?a.length>0?"auth":"body-missing":n===404?"body-missing":"generic"},dr=(n,o)=>(o??"").toLowerCase().startsWith("text/html")?/<div\s+id=["']root["']/i.test(n):!1,hr=(n,o)=>{const a=(o??"").toLowerCase();return!!(n==="text"&&a.startsWith("text/html"))},Tr=async(n,o,a=async()=>null)=>{const l={},c=await a();c&&(l.Authorization=`Bearer ${c}`);const p=await Ro(n,{headers:l});if(p.status===202)throw new gt("not-ready","Message body is still syncing",202,ur(p.headers.get("Retry-After")));if(!p.ok){const A=p.headers.get(pr),G=mr(p.status,A);throw new gt(G,`Failed to load message body (${p.status} ${p.statusText})`,p.status)}const h=p.headers.get("content-type");if(hr(o,h))throw new gt("content-type-mismatch",`Refusing to render message body — expected ${o}, got Content-Type ${h}`);const F=await p.text();if(dr(F,h))throw new gt("spa-shell-leak","Refusing to render message body — response looks like the SPA shell (CloudFront 403/404 fallback leaked through to /content/*)");return F},gr=async(n,o)=>(o.isRetryAfterNotReady&&await n.refetchDescribeMessage(),n.fetchContent(o.contentUrl,o.kind)),Lr=({messageId:n,bodyParts:o,enabled:a=!0})=>{const l=o?cr(o):null,c=Eo(),{getToken:p}=yo(),h=V.useRef(null),F=Ao(),A=V.useRef(!1),G=V.useRef(null),W=n&&l?`${n}:${l.contentUrl}`:null;G.current!==W&&(G.current=W,A.current=!1);const R=bo({queryKey:n?[...Le.body(n),l?.contentUrl??null]:["messages","body","noop"],queryFn:()=>{if(!l)throw new Error("No renderable body part");if(!n)throw new Error("No messageId");const J=A.current;return A.current=!1,gr({fetchContent:(L,X)=>Tr(L,X,p),refetchDescribeMessage:()=>F.refetchQueries({queryKey:So({path:{messageId:n}})})},{contentUrl:l.contentUrl,kind:l.kind,isRetryAfterNotReady:J})},enabled:a&&!!n&&!!l,staleTime:300*1e3,gcTime:1800*1e3,retry:(J,L)=>L instanceof gt&&L.reason==="not-ready"?J<fr:J<1,retryDelay:(J,L)=>L instanceof gt&&L.reason==="not-ready"?(A.current=!0,(L.retryAfterSeconds??1)*1e3):1e3,meta:{softError:!0}}),Et=R.isLoading&&!!l,yt=o!==void 0&&l===null;V.useEffect(()=>{Et&&(h.current=performance.now())},[Et]),V.useEffect(()=>{R.isSuccess&&h.current!==null&&(c.recordTiming("message.body.load",Math.round(performance.now()-h.current)),h.current=null)},[R.isSuccess,c]);const It=R.data&&l?{kind:l.kind,body:R.data}:void 0;return{picked:l,data:It,isLoading:Et,hasNoRenderablePart:yt,isError:R.isError,error:R.error,refetch:R.refetch}};export{gt as B,br as a,Lr as b,mr as c,Sr as d,wr as e,Dr as f,Or as g,Cr as h,ar as i,lr as o,Ar as p,Rr as u};
@@ -1 +1 @@
1
- import{cx as Q,cy as y,cz as S,cA as w,cB as C,e as k,cC as x,cD as q,r as p,cE as M,cF as H,cG as B,cH as L,cI as O,cJ as P,cK as A}from"./index-CKflMWYU.js";function R(r,e){const s=new Set(e);return r.filter(t=>!s.has(t))}function z(r,e,s){const t=r.slice(0);return t[e]=s,t}var I=class extends Q{#i;#e;#n;#r;#s;#t;#o;#u;#h;#c=[];constructor(r,e,s){super(),this.#i=r,this.#r=s,this.#n=[],this.#s=[],this.#e=[],this.setQueries(e)}onSubscribe(){this.listeners.size===1&&this.#s.forEach(r=>{r.subscribe(e=>{this.#d(r,e)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#s.forEach(r=>{r.destroy()})}setQueries(r,e){this.#n=r,this.#r=e,y.batch(()=>{const s=this.#s,t=this.#f(this.#n);t.forEach(o=>o.observer.setOptions(o.defaultedQueryOptions));const i=t.map(o=>o.observer),n=i.map(o=>o.getCurrentResult()),u=s.length!==i.length,a=i.some((o,d)=>o!==s[d]),f=u||a,b=f?!0:n.some((o,d)=>{const g=this.#e[d];return!g||!S(o,g)});!f&&!b||(f&&(this.#c=t,this.#s=i),this.#e=n,this.hasListeners()&&(f&&(R(s,i).forEach(o=>{o.destroy()}),R(i,s).forEach(o=>{o.subscribe(d=>{this.#d(o,d)})})),this.#p()))})}getCurrentResult(){return this.#e}getQueries(){return this.#s.map(r=>r.getCurrentQuery())}getObservers(){return this.#s}getOptimisticResult(r,e){const s=this.#f(r),t=s.map(n=>n.observer.getOptimisticResult(n.defaultedQueryOptions)),i=s.map(n=>n.defaultedQueryOptions.queryHash);return[t,n=>this.#l(n??t,e,i),()=>this.#a(t,s)]}#a(r,e){return e.map((s,t)=>{const i=r[t];return s.defaultedQueryOptions.notifyOnChangeProps?i:s.observer.trackResult(i,n=>{e.forEach(u=>{u.observer.trackProp(n)})})})}#l(r,e,s){if(e){const t=this.#h,i=s!==void 0&&t!==void 0&&(t.length!==s.length||s.some((n,u)=>n!==t[u]));return(!this.#t||this.#e!==this.#u||i||e!==this.#o)&&(this.#o=e,this.#u=this.#e,s!==void 0&&(this.#h=s),this.#t=w(this.#t,e(r))),this.#t}return r}#b(){return this.#r?.combine!==void 0&&this.#s.some((r,e)=>r.options.suspense&&this.#e[e]?.data===void 0)}#f(r){const e=new Map;this.#s.forEach(t=>{const i=t.options.queryHash;if(!i)return;const n=e.get(i);n?n.push(t):e.set(i,[t])});const s=[];return r.forEach(t=>{const i=this.#i.defaultQueryOptions(t),u=e.get(i.queryHash)?.shift()??new C(this.#i,i);s.push({defaultedQueryOptions:i,observer:u})}),s}#d(r,e){const s=this.#s.indexOf(r);s!==-1&&(this.#e=z(this.#e,s,e),this.#p())}#p(){if(this.hasListeners()){const r=this.#a(this.#e,this.#c),e=this.#b(),s=this.#t,t=e?s:this.#l(r,this.#r?.combine);(e||s!==t)&&y.batch(()=>{this.listeners.forEach(i=>{i(this.#e)})})}}};function D({queries:r,...e},s){const t=k(),i=x(),n=q(),u=p.useMemo(()=>r.map(h=>{const c=t.defaultQueryOptions(h);return c._optimisticResults=i?"isRestoring":"optimistic",c}),[r,t,i]);u.forEach(h=>{M(h);const c=t.getQueryCache().get(h.queryHash);H(h,n,c)}),B(n);const[a]=p.useState(()=>new I(t,u,e)),[f,b,o]=a.getOptimisticResult(u,e.combine),d=!i&&e.subscribed!==!1;p.useSyncExternalStore(p.useCallback(h=>d?a.subscribe(y.batchCalls(h)):L,[a,d]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),p.useEffect(()=>{a.setQueries(u,e)},[u,e,a]);const m=f.some((h,c)=>O(u[c],h))?f.flatMap((h,c)=>{const l=u[c];if(l&&O(l,h)){const E=new C(t,l);return P(l,E,n)}return[]}):[];if(m.length>0)throw Promise.all(m);const v=f.find((h,c)=>{const l=u[c];return l&&A({result:h,errorResetBoundary:n,throwOnError:l.throwOnError,query:t.getQueryCache().get(l.queryHash),suspense:l.suspense})});if(v?.error)throw v.error;return b(o())}export{D as u};
1
+ import{cD as Q,cE as y,cF as S,cG as w,cH as C,e as k,cI as M,cJ as q,r as p,cK as x,cL as H,cM as L,cN as P,cO as v,cP as B,cQ as A}from"./index-CjLIM85N.js";function R(r,e){const s=new Set(e);return r.filter(t=>!s.has(t))}function I(r,e,s){const t=r.slice(0);return t[e]=s,t}var T=class extends Q{#i;#e;#n;#r;#s;#t;#o;#u;#h;#c=[];constructor(r,e,s){super(),this.#i=r,this.#r=s,this.#n=[],this.#s=[],this.#e=[],this.setQueries(e)}onSubscribe(){this.listeners.size===1&&this.#s.forEach(r=>{r.subscribe(e=>{this.#d(r,e)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#s.forEach(r=>{r.destroy()})}setQueries(r,e){this.#n=r,this.#r=e,y.batch(()=>{const s=this.#s,t=this.#f(this.#n);t.forEach(o=>o.observer.setOptions(o.defaultedQueryOptions));const i=t.map(o=>o.observer),n=i.map(o=>o.getCurrentResult()),u=s.length!==i.length,a=i.some((o,d)=>o!==s[d]),f=u||a,b=f?!0:n.some((o,d)=>{const g=this.#e[d];return!g||!S(o,g)});!f&&!b||(f&&(this.#c=t,this.#s=i),this.#e=n,this.hasListeners()&&(f&&(R(s,i).forEach(o=>{o.destroy()}),R(i,s).forEach(o=>{o.subscribe(d=>{this.#d(o,d)})})),this.#p()))})}getCurrentResult(){return this.#e}getQueries(){return this.#s.map(r=>r.getCurrentQuery())}getObservers(){return this.#s}getOptimisticResult(r,e){const s=this.#f(r),t=s.map(n=>n.observer.getOptimisticResult(n.defaultedQueryOptions)),i=s.map(n=>n.defaultedQueryOptions.queryHash);return[t,n=>this.#l(n??t,e,i),()=>this.#a(t,s)]}#a(r,e){return e.map((s,t)=>{const i=r[t];return s.defaultedQueryOptions.notifyOnChangeProps?i:s.observer.trackResult(i,n=>{e.forEach(u=>{u.observer.trackProp(n)})})})}#l(r,e,s){if(e){const t=this.#h,i=s!==void 0&&t!==void 0&&(t.length!==s.length||s.some((n,u)=>n!==t[u]));return(!this.#t||this.#e!==this.#u||i||e!==this.#o)&&(this.#o=e,this.#u=this.#e,s!==void 0&&(this.#h=s),this.#t=w(this.#t,e(r))),this.#t}return r}#b(){return this.#r?.combine!==void 0&&this.#s.some((r,e)=>r.options.suspense&&this.#e[e]?.data===void 0)}#f(r){const e=new Map;this.#s.forEach(t=>{const i=t.options.queryHash;if(!i)return;const n=e.get(i);n?n.push(t):e.set(i,[t])});const s=[];return r.forEach(t=>{const i=this.#i.defaultQueryOptions(t),u=e.get(i.queryHash)?.shift()??new C(this.#i,i);s.push({defaultedQueryOptions:i,observer:u})}),s}#d(r,e){const s=this.#s.indexOf(r);s!==-1&&(this.#e=I(this.#e,s,e),this.#p())}#p(){if(this.hasListeners()){const r=this.#a(this.#e,this.#c),e=this.#b(),s=this.#t,t=e?s:this.#l(r,this.#r?.combine);(e||s!==t)&&y.batch(()=>{this.listeners.forEach(i=>{i(this.#e)})})}}};function D({queries:r,...e},s){const t=k(),i=M(),n=q(),u=p.useMemo(()=>r.map(h=>{const c=t.defaultQueryOptions(h);return c._optimisticResults=i?"isRestoring":"optimistic",c}),[r,t,i]);u.forEach(h=>{x(h);const c=t.getQueryCache().get(h.queryHash);H(h,n,c)}),L(n);const[a]=p.useState(()=>new T(t,u,e)),[f,b,o]=a.getOptimisticResult(u,e.combine),d=!i&&e.subscribed!==!1;p.useSyncExternalStore(p.useCallback(h=>d?a.subscribe(y.batchCalls(h)):P,[a,d]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),p.useEffect(()=>{a.setQueries(u,e)},[u,e,a]);const m=f.some((h,c)=>v(u[c],h))?f.flatMap((h,c)=>{const l=u[c];if(l&&v(l,h)){const E=new C(t,l);return B(l,E,n)}return[]}):[];if(m.length>0)throw Promise.all(m);const O=f.find((h,c)=>{const l=u[c];return l&&A({result:h,errorResetBoundary:n,throwOnError:l.throwOnError,query:t.getQueryCache().get(l.queryHash),suspense:l.suspense})});if(O?.error)throw O.error;return b(o())}export{D as u};
@@ -0,0 +1 @@
1
+ import{j as E,v as K,p as Q,B as U,e as N,J as B,r as o,aF as R,P as $,Q as z,l as G,a0 as I,a1 as X,a4 as J}from"./index-CjLIM85N.js";import{C as V}from"./circle-check-big-BTaxDmjy.js";import{R as Y}from"./refresh-cw-B_uXAs1Z.js";import{u as P}from"./useQueries-DiYEl2LH.js";function ye({state:e,onRefresh:s,label:t,errorMessage:r,hasUpdate:a,size:u="sm",className:c}){const i=e==="refreshing",n=e==="error",h=e==="success",y=n?E.jsx(K,{className:"size-4 text-danger"}):h?E.jsx(V,{className:"size-4 text-positive"}):E.jsx(Y,{className:Q("size-4",i&&"animate-spin")}),w=n?`${t} — failed: ${r??"try again"}`:i?`${t} — refreshing`:h?`${t} — up to date`:a?`${t} — new mail`:t;return E.jsxs("div",{className:"relative inline-flex",children:[E.jsx(U,{variant:"ghost",size:u,icon:y,onClick:s,disabled:i,"aria-label":w,"aria-busy":i||void 0,title:n?r:t,className:c}),e==="idle"&&a&&E.jsx("span",{"aria-hidden":"true",className:"absolute right-1 top-1 size-1.5 rounded-full bg-accent-2"})]})}const Z=180*1e3,Se=30*1e3;let L=0;const M=new Set,ee=(e=Date.now())=>{L=e+Z;for(const s of M)s()},we=(e=Date.now())=>e<L,xe=e=>(M.add(e),()=>{M.delete(e)}),_=6e4,te=new Set(["sent","drafts","trash","archive"]),C=(e,s)=>{const t=new Map;for(const r of e){const a=s.get(r.mailboxId)?.role;a&&te.has(a)||t.set(r.mailboxId,r.highWaterMarkUid)}return t},F=(e,s)=>{const t=[];for(const[r,a]of s)a>(e.get(r)??0)&&t.push(r);return t},se=(e,s)=>F(e,s).length>0,q=o.createContext(null),ne=()=>{const e=o.useContext(q);if(!e)throw new Error("useMailFreshness must be used inside <MailFreshnessProvider>");return e};function pe({accountIds:e,children:s}){const t=N(),{resultFolderIndex:r}=B(),a=o.useRef(new Map),u=o.useRef(new Set),c=o.useRef(new Map),[i,n]=o.useState(new Set),h=P({queries:e.map(l=>({...R({path:{accountId:l}}),refetchInterval:_,staleTime:_,meta:{softError:!0}}))}),y=h.map(l=>l.dataUpdatedAt).join(","),w=e.join(",");o.useEffect(()=>{let l=!1;const f=new Set(i);e.forEach((d,p)=>{const b=h[p]?.data;if(!b)return;const g=C(b.mailboxes??[],r),v=c.current.get(d);if(c.current.set(d,g),v){const A=F(v,g);A.length>0&&$(t,z(A))}if(!u.current.has(d)){u.current.add(d),a.current.set(d,g);return}if(f.has(d))return;const W=a.current.get(d)??new Map;se(W,g)&&(f.add(d),l=!0)}),l&&n(f)},[w,y]);const S=o.useCallback(l=>l.some(f=>i.has(f)),[i]),x=o.useCallback(l=>{n(f=>{if(l.every(p=>!f.has(p)))return f;const d=new Set(f);for(const p of l)d.delete(p);return d});for(const f of l){const d=t.getQueryData(R({path:{accountId:f}}).queryKey);a.current.set(f,C(d?.mailboxes??[],r)),u.current.add(f)}},[t,r]),m=o.useMemo(()=>({hasNewMail:S,acknowledge:x}),[S,x]);return E.jsx(q.Provider,{value:m,children:s})}const re=new Set(["discovering_mailboxes","syncing_inbox","syncing_others"]);function j(e){return!!e&&re.has(e)}const D=3e3,oe=D*2,O={syncing:!1,resolved:!1,synced:0,total:0};function Ee(e,s){const t=e.join(","),[r,a]=o.useState(!1),[u,c]=o.useState(!1);o.useEffect(()=>{a(!1),c(!1)},[t,s]),o.useEffect(()=>{if(!s)return;const m=setTimeout(()=>c(!0),oe);return()=>clearTimeout(m)},[t,s]);const i=P({queries:e.map(m=>({...R({path:{accountId:m}}),enabled:s&&!r,refetchInterval:D,meta:{softError:!0}}))}),n=i.every(m=>m.isSuccess||m.isError),h=i.length===0||n||u;let y=!1,w=0,S=0;for(const m of i)if(j(m.data?.syncPhase)){y=!0;for(const l of m.data?.mailboxes??[])w+=l.messagesSynced,S+=l.messagesTotal}const x=s&&h&&!y;return o.useEffect(()=>{x&&a(!0)},[x]),!s||!h?O:{syncing:y,resolved:!0,synced:w,total:S}}const ae=2e3,ie=45e3,ce=e=>new Promise(s=>setTimeout(s,e)),k=e=>e instanceof Error&&e.message?e.message:"Something went wrong",ue=e=>{J(e,{softError:!0})},T=(e,s)=>e.fetchQuery({...R({path:{accountId:s}}),staleTime:0}),H=e=>e.mailboxes?.find(s=>s.fullPath?.toUpperCase()==="INBOX")?.lastSyncedAt??0,le=async({accountId:e,readStatus:s,baselineLastSyncAt:t,baselineInboxSyncedAt:r=0,onInboxSynced:a,deadline:u,pollMs:c=ae})=>{let i=!1;for(;;){const n=await s().then(S=>({ok:!0,data:S})).catch(S=>({ok:!1,error:S}));if(!n.ok)return{accountId:e,message:k(n.error)};const{syncPhase:h,lastSyncAt:y}=n.data;if((y??0)>t&&!j(h))return h==="error"?{accountId:e,message:"Sync failed for this account"}:void 0;if(!i&&H(n.data)>r&&(i=!0,a?.()),Date.now()>=u)return{accountId:e,message:"Refresh is taking longer than usual"};await ce(c)}},fe=async(e,s,t,r,a)=>{const u=await T(e,t).then(n=>({ok:!0,lastSyncAt:n.lastSyncAt??0,inboxSyncedAt:H(n)})).catch(n=>({ok:!1,error:n}));if(!u.ok)return{accountId:t,enqueued:!1,ok:!1,message:k(u.error)};const c=await I({path:{accountId:t},throwOnError:!0}).then(()=>({ok:!0})).catch(n=>({ok:!1,error:n}));if(!c.ok)return ue(c.error),{accountId:t,enqueued:!1,ok:!1,message:k(c.error)};s.recordEvent("sync.triggered");const i=await le({accountId:t,readStatus:()=>T(e,t),baselineLastSyncAt:u.lastSyncAt,baselineInboxSyncedAt:u.inboxSyncedAt,onInboxSynced:()=>a(t),deadline:r});return i?{accountId:t,enqueued:!0,ok:!1,message:i.message}:{accountId:t,enqueued:!0,ok:!0}},be=(e,s={})=>{const t=N(),r=G(),{acknowledge:a}=ne(),[u,c]=o.useState("idle"),[i,n]=o.useState(),h=o.useRef(0),y=o.useRef(e);y.current=e;const w=o.useRef(s);w.current=s,o.useEffect(()=>{if(u!=="success")return;const x=setTimeout(()=>c("idle"),2e3);return()=>clearTimeout(x)},[u]);const S=o.useCallback(()=>{const x=y.current;if(x.length===0){c("error"),n("Nothing to refresh yet");return}const m=++h.current;c("refreshing"),n(void 0),ee();const l=f=>{h.current===m&&(t.invalidateQueries({queryKey:X({path:{accountId:f}})}),w.current.onSettled?.())};(async()=>{const f=Date.now()+ie,d=await Promise.all(x.map(g=>fe(t,r,g,f,l)));if(h.current!==m)return;const p=d.filter(g=>g.enqueued).map(g=>g.accountId);for(const g of p)l(g);p.length>0&&a(p);const b=d.filter(g=>!g.ok);b.length===0?c("success"):(c("error"),n(b[0]?.message))})()},[a,t,r]);return{state:u,errorMessage:i,refresh:S}};export{Se as H,pe as M,ye as R,be as a,j as b,Ee as c,we as i,xe as s,ne as u};
@@ -1 +1 @@
1
- import{b as s,R as o,r as n,bU as r}from"./index-CKflMWYU.js";import{u as d}from"./useQueries-DVcMuKhn.js";const h=s("Bug",[["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}],["path",{d:"M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",key:"xs1cw7"}],["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M17.2 17c2.1.1 3.8 1.9 3.8 4",key:"k3fwyw"}]]),p=t=>({items:t.map(e=>e.data?.items??[]),isPending:t.some(e=>e.isPending),error:t.find(e=>e.error)?.error??null});function u(t){const e=d({queries:t.map(i=>({...o({path:{accountId:i.accountId}}),staleTime:1/0})),combine:p});return{index:n.useMemo(()=>r(t.map((i,a)=>({folderAppointments:i.folderAppointments,mailboxes:e.items[a]??[]}))),[t,e]),isPending:e.isPending,error:e.error}}export{h as B,u};
1
+ import{b as s,U as o,r as n,b_ as r}from"./index-CjLIM85N.js";import{u as d}from"./useQueries-DiYEl2LH.js";const h=s("Bug",[["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}],["path",{d:"M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",key:"xs1cw7"}],["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M17.2 17c2.1.1 3.8 1.9 3.8 4",key:"k3fwyw"}]]),p=t=>({items:t.map(e=>e.data?.items??[]),isPending:t.some(e=>e.isPending),error:t.find(e=>e.error)?.error??null});function u(t){const e=d({queries:t.map(i=>({...o({path:{accountId:i.accountId}}),staleTime:1/0})),combine:p});return{index:n.useMemo(()=>r(t.map((i,a)=>({folderAppointments:i.folderAppointments,mailboxes:e.items[a]??[]}))),[t,e]),isPending:e.isPending,error:e.error}}export{h as B,u};
@@ -1 +1 @@
1
- import{e as m,aj as y,a as b,c as L,r as c,f as w,ak as S,k,h as E}from"./index-CKflMWYU.js";var u={en:1199414,"en-GB":1199758,nl:3180464},g=["en","en-GB","nl"];const C=()=>typeof g>"u"?[]:g,M=()=>{const e="/spellcheck/de99b00dc30674fd/";return typeof document>"u"?e:new URL(e,document.baseURI).href},_=e=>typeof u>"u"?0:u[e]??0,O=(e,n=C())=>{const t=e.toLowerCase(),a=n.find(i=>i.toLowerCase()===t);if(a)return a;const o=t.split("-")[0];return n.find(i=>i.toLowerCase().split("-")[0]===o)??null},T=[{tag:"ar",detectionCode:"arb"},{tag:"az",detectionCode:"azj"},{tag:"be",detectionCode:"bel"},{tag:"bg",detectionCode:"bul"},{tag:"bs",detectionCode:"bos"},{tag:"cs",detectionCode:"ces"},{tag:"de",detectionCode:"deu"},{tag:"en",detectionCode:"eng"},{tag:"es",detectionCode:"spa"},{tag:"fa",detectionCode:"pes"},{tag:"fr",detectionCode:"fra"},{tag:"ha",detectionCode:"hau"},{tag:"hi",detectionCode:"hin"},{tag:"hr",detectionCode:"hrv"},{tag:"hu",detectionCode:"hun"},{tag:"id",detectionCode:"ind"},{tag:"ig",detectionCode:"ibo"},{tag:"it",detectionCode:"ita"},{tag:"jv",detectionCode:"jav"},{tag:"kk",detectionCode:"kaz"},{tag:"mr",detectionCode:"mar"},{tag:"ms",detectionCode:"zlm"},{tag:"ne",detectionCode:"npi"},{tag:"nl",detectionCode:"nld"},{tag:"pl",detectionCode:"pol"},{tag:"ps",detectionCode:"pbu"},{tag:"pt",detectionCode:"por"},{tag:"ro",detectionCode:"ron"},{tag:"ru",detectionCode:"rus"},{tag:"so",detectionCode:"som"},{tag:"sr",detectionCode:"srp"},{tag:"su",detectionCode:"sun"},{tag:"sv",detectionCode:"swe"},{tag:"sw",detectionCode:"swh"},{tag:"tl",detectionCode:"tgl"},{tag:"tr",detectionCode:"tur"},{tag:"uk",detectionCode:"ukr"},{tag:"ur",detectionCode:"urd"},{tag:"vi",detectionCode:"vie"},{tag:"yo",detectionCode:"yor"},{tag:"zu",detectionCode:"zul"}],d=e=>(e.split("-")[0]??"").toLowerCase(),v=new Map(T.map(e=>[e.tag,e])),x=e=>v.get(d(e))?.detectionCode??null,P=/^[a-z]{2,3}(-[a-z0-9]{2,8})*$/i,G=e=>d(e).toUpperCase(),H=e=>{if(!P.test(e))return e;const t=new Intl.DisplayNames([e],{type:"language",fallback:"none"}).of(e);return t?t.charAt(0).toLocaleUpperCase(e)+t.slice(1):e},z=(e,n=C())=>{const t=[...e,...n].filter(o=>x(o)!==null),a=[...new Set(t.map(d))];return a.includes("en")||a.push("en"),a},N=e=>/iPhone|iPad|iPod/.test(e)?"On iPhone and iPad the keyboard decides this. Add the language under Settings, then General, then Keyboard.":/Edg\//.test(e)?"Edge checks every language you add under Settings, then Languages. Adding one there checks it alongside the others.":/Firefox\//.test(e)?"Firefox uses this setting. Right-click the message to add a dictionary for it.":/Chrome\/|Chromium\//.test(e)?"Chrome checks every language you add under Settings, then Languages. Adding one there checks it alongside the others.":/Safari\//.test(e)?"macOS decides this under Keyboard, then Text Input, then Spelling. Automatic by Language covers every language enabled there.":"Your browser decides which dictionaries it checks. Add this language in its own language settings to have it spellchecked.",h=e=>new DOMParser().parseFromString(e,"text/html"),p=e=>{const n=[...e.children];if(n.length!==1)return null;const t=n[0];return t?[...e.childNodes].some(o=>o!==t&&(o.textContent??"").trim()!=="")?null:t:null},R=(e,n)=>{if(e==="")return"";const t=h(e),a=p(t.body);if(a?.tagName==="DIV"&&a.hasAttribute("lang"))return a.setAttribute("lang",n),t.body.innerHTML;const o=t.createElement("div");for(o.setAttribute("lang",n);t.body.firstChild;)o.append(t.body.firstChild);return t.body.append(o),t.body.innerHTML},U=e=>{if(e==="")return{html:e,language:null};const n=h(e),t=p(n.body);return t?.tagName!=="DIV"||!t.hasAttribute("lang")?{html:e,language:null}:{html:t.innerHTML,language:t.getAttribute("lang")}},l={html:"",plainText:""},B=e=>{const n=m(),{pushError:t}=y(),{data:a}=b({...L(),staleTime:1/0}),o=c.useMemo(()=>{if(!e||!a)return l;const s=a.accounts.find(r=>r.accountId===e);return s?{html:s.signatureHtml??"",plainText:s.signaturePlainText??""}:l},[e,a]),i=w({...E(),onSuccess:()=>{n.invalidateQueries({queryKey:k()})},onError:s=>{t(S("Couldn't save signature","The signature wasn't saved.",s))}}),f=c.useCallback((s,r)=>{e&&i.mutate({path:{accountId:e},body:{signatureHtml:s,signaturePlainText:r}})},[e,i]);return{signature:o,setSignature:f,isSaving:i.isPending}};export{T as C,U as a,G as b,N as c,z as d,x as e,O as f,_ as g,H as l,d as p,M as s,B as u,R as w};
1
+ import{e as m,ak as y,a as b,c as L,r as c,f as w,al as S,k,h as E}from"./index-CjLIM85N.js";var u={en:1199414,"en-GB":1199758,nl:3180464},g=["en","en-GB","nl"];const C=()=>typeof g>"u"?[]:g,M=()=>{const e="/spellcheck/de99b00dc30674fd/";return typeof document>"u"?e:new URL(e,document.baseURI).href},_=e=>typeof u>"u"?0:u[e]??0,O=(e,n=C())=>{const t=e.toLowerCase(),a=n.find(i=>i.toLowerCase()===t);if(a)return a;const o=t.split("-")[0];return n.find(i=>i.toLowerCase().split("-")[0]===o)??null},T=[{tag:"ar",detectionCode:"arb"},{tag:"az",detectionCode:"azj"},{tag:"be",detectionCode:"bel"},{tag:"bg",detectionCode:"bul"},{tag:"bs",detectionCode:"bos"},{tag:"cs",detectionCode:"ces"},{tag:"de",detectionCode:"deu"},{tag:"en",detectionCode:"eng"},{tag:"es",detectionCode:"spa"},{tag:"fa",detectionCode:"pes"},{tag:"fr",detectionCode:"fra"},{tag:"ha",detectionCode:"hau"},{tag:"hi",detectionCode:"hin"},{tag:"hr",detectionCode:"hrv"},{tag:"hu",detectionCode:"hun"},{tag:"id",detectionCode:"ind"},{tag:"ig",detectionCode:"ibo"},{tag:"it",detectionCode:"ita"},{tag:"jv",detectionCode:"jav"},{tag:"kk",detectionCode:"kaz"},{tag:"mr",detectionCode:"mar"},{tag:"ms",detectionCode:"zlm"},{tag:"ne",detectionCode:"npi"},{tag:"nl",detectionCode:"nld"},{tag:"pl",detectionCode:"pol"},{tag:"ps",detectionCode:"pbu"},{tag:"pt",detectionCode:"por"},{tag:"ro",detectionCode:"ron"},{tag:"ru",detectionCode:"rus"},{tag:"so",detectionCode:"som"},{tag:"sr",detectionCode:"srp"},{tag:"su",detectionCode:"sun"},{tag:"sv",detectionCode:"swe"},{tag:"sw",detectionCode:"swh"},{tag:"tl",detectionCode:"tgl"},{tag:"tr",detectionCode:"tur"},{tag:"uk",detectionCode:"ukr"},{tag:"ur",detectionCode:"urd"},{tag:"vi",detectionCode:"vie"},{tag:"yo",detectionCode:"yor"},{tag:"zu",detectionCode:"zul"}],d=e=>(e.split("-")[0]??"").toLowerCase(),v=new Map(T.map(e=>[e.tag,e])),x=e=>v.get(d(e))?.detectionCode??null,P=/^[a-z]{2,3}(-[a-z0-9]{2,8})*$/i,G=e=>d(e).toUpperCase(),H=e=>{if(!P.test(e))return e;const t=new Intl.DisplayNames([e],{type:"language",fallback:"none"}).of(e);return t?t.charAt(0).toLocaleUpperCase(e)+t.slice(1):e},z=(e,n=C())=>{const t=[...e,...n].filter(o=>x(o)!==null),a=[...new Set(t.map(d))];return a.includes("en")||a.push("en"),a},N=e=>/iPhone|iPad|iPod/.test(e)?"On iPhone and iPad the keyboard decides this. Add the language under Settings, then General, then Keyboard.":/Edg\//.test(e)?"Edge checks every language you add under Settings, then Languages. Adding one there checks it alongside the others.":/Firefox\//.test(e)?"Firefox uses this setting. Right-click the message to add a dictionary for it.":/Chrome\/|Chromium\//.test(e)?"Chrome checks every language you add under Settings, then Languages. Adding one there checks it alongside the others.":/Safari\//.test(e)?"macOS decides this under Keyboard, then Text Input, then Spelling. Automatic by Language covers every language enabled there.":"Your browser decides which dictionaries it checks. Add this language in its own language settings to have it spellchecked.",h=e=>new DOMParser().parseFromString(e,"text/html"),p=e=>{const n=[...e.children];if(n.length!==1)return null;const t=n[0];return t?[...e.childNodes].some(o=>o!==t&&(o.textContent??"").trim()!=="")?null:t:null},R=(e,n)=>{if(e==="")return"";const t=h(e),a=p(t.body);if(a?.tagName==="DIV"&&a.hasAttribute("lang"))return a.setAttribute("lang",n),t.body.innerHTML;const o=t.createElement("div");for(o.setAttribute("lang",n);t.body.firstChild;)o.append(t.body.firstChild);return t.body.append(o),t.body.innerHTML},U=e=>{if(e==="")return{html:e,language:null};const n=h(e),t=p(n.body);return t?.tagName!=="DIV"||!t.hasAttribute("lang")?{html:e,language:null}:{html:t.innerHTML,language:t.getAttribute("lang")}},l={html:"",plainText:""},B=e=>{const n=m(),{pushError:t}=y(),{data:a}=b({...L(),staleTime:1/0}),o=c.useMemo(()=>{if(!e||!a)return l;const s=a.accounts.find(r=>r.accountId===e);return s?{html:s.signatureHtml??"",plainText:s.signaturePlainText??""}:l},[e,a]),i=w({...E(),onSuccess:()=>{n.invalidateQueries({queryKey:k()})},onError:s=>{t(S("Couldn't save signature","The signature wasn't saved.",s))}}),f=c.useCallback((s,r)=>{e&&i.mutate({path:{accountId:e},body:{signatureHtml:s,signaturePlainText:r}})},[e,i]);return{signature:o,setSignature:f,isSaving:i.isPending}};export{T as C,U as a,G as b,N as c,z as d,x as e,O as f,_ as g,H as l,d as p,M as s,B as u,R as w};
@@ -1,5 +1,5 @@
1
- import{j as s,aA as T,B as d,aH as C,be as j,bc as N,d as $,ac as A,a6 as k,bu as E,bR as f,bS as _,bT as M,a as P,c as W,r as l,a1 as z,av as p,aw as x,u as O,ab as B}from"./index-CKflMWYU.js";import{B as h,u as L}from"./useResultFolderIndex-DkgVg9nE.js";import{B as y}from"./badge-C9PbkapD.js";import{C as S}from"./circle-check-DTYzt_6O.js";import{C as q}from"./copy-BXsMQRiH.js";import{E as D}from"./external-link-BJSinsZe.js";import{f as U}from"./ErrorState-94ifepAa.js";import{a as F}from"./sections-HylxNewe.js";import{w as G}from"./help-copy-CiMWKARn.js";import{S as H}from"./settings-screen-83hRChID.js";import"./useQueries-DVcMuKhn.js";import"./kbd-BncXAFDO.js";import"./avatar-LbufyW4K.js";import"./chevron-left-CpG9UDY6.js";import"./menu-DoDMKB2j.js";import"./circle-help-BbeOW2US.js";function Q({report:e,onClose:t,issueUrl:n,onCopy:a}){return e===null?null:s.jsx(T,{open:!0,onClose:t,title:"Report this message",children:s.jsxs("div",{className:"flex max-h-[80vh] flex-col",children:[s.jsxs("header",{className:"space-y-1 border-b border-line px-4 py-3",children:[s.jsx("h3",{className:"text-sm font-semibold text-fg",children:"Report this message"}),s.jsx("p",{className:"text-xs text-fg-muted",children:"This is everything the report contains. It describes what went wrong with the message — never its contents, addresses, subject, attachment names, folder name, or the parser's own error text."})]}),s.jsx("pre",{className:"flex-1 overflow-auto bg-surface-sunken px-4 py-3 text-2xs leading-relaxed whitespace-pre-wrap text-fg-muted",children:e}),s.jsxs("footer",{className:"flex flex-wrap items-center justify-end gap-2 border-t border-line px-4 py-3",children:[s.jsx(d,{variant:"ghost",size:"sm",onClick:t,children:"Cancel"}),s.jsx(d,{variant:"secondary",size:"sm",icon:s.jsx(q,{className:"size-3.5"}),onClick:()=>a(e),children:"Copy report"}),s.jsx(C,{external:!0,size:"sm",href:n,icon:s.jsx(D,{className:"size-3.5"}),children:"Open on GitHub"})]})]})})}const V={BodyParse:"The message is built in a way Remit could not read."};function Y(e){return V[e]}function R(e){return e.split(";")[0].trim()}const b=/^[A-Za-z0-9!#$%&'*+._-]+$/,v=/^[A-Za-z0-9!#$%&'*+._-]+\/[A-Za-z0-9!#$%&'*+._-]+$/;function m(e,t){return t.test(e)?`\`${e}\``:`\`${JSON.stringify(e).replace(/`/g,"\\u0060")}\` (malformed)`}function Z(e){const t=R(e);return v.test(t)?t:JSON.stringify(t)}const g="_not read_";function J(e){return e.length===0?["(no MIME structure was read)"]:e.map(t=>`${" ".repeat(t.depth)}- ${Z(t.contentType)}`)}const K="_No message content, addresses, subject, attachment names or parser output are included._";function w(e){return{head:[`### Message quarantined at \`${e.failureStage}\``,"",`- **Failure**: \`${e.failureCode}\``,`- **Folder role**: ${e.mailboxRole??"_none appointed_"}`,`- **Failing part**: ${e.failurePartPath==null?"_whole message_":`\`${e.failurePartPath}\``}`,`- **Attempts before quarantine**: ${e.attempts}`,`- **Worker build**: ${e.workerVersion}`,`- **Message-ID hash**: ${e.messageIdHash==null?"_none declared_":`\`${e.messageIdHash}\``}`,"","#### Message shape","",`- **Content-Type**: ${e.contentType==null?g:m(R(e.contentType),v)}`,`- **Content-Transfer-Encoding**: ${e.transferEncoding==null?g:m(e.transferEncoding,b)}`,`- **Charset**: ${e.charset==null?"_not declared_":m(e.charset,b)}`,`- **Size**: ${e.sizeBytes==null?g:`${e.sizeBytes} bytes`}`,"","MIME structure:"].join(`
1
+ import{j as s,aB as T,B as d,aI as C,bl as j,bj as N,d as $,ad as A,a7 as k,bB as E,bX as f,bY as _,bZ as M,a as P,c as W,r as l,a2 as z,aw as x,ax as p,u as O,ac as B}from"./index-CjLIM85N.js";import{B as h,u as L}from"./useResultFolderIndex--Vh1kDTt.js";import{B as y}from"./badge-DNMAx4D3.js";import{C as S}from"./circle-check-B9p7FADR.js";import{C as q}from"./copy-BYqJcNuv.js";import{E as D}from"./external-link-CbBMj0Z_.js";import{f as U}from"./ErrorState-k3wt6L_r.js";import{a as F}from"./sections-1CLsW1zC.js";import{w as G}from"./help-copy-UAU_hrL0.js";import{S as H}from"./settings-screen-B0brDUWW.js";import"./useQueries-DiYEl2LH.js";import"./kbd-CMsSty4m.js";import"./avatar-BmY6XepY.js";import"./chevron-left-Br4HtAWp.js";import"./menu-S5zj22BN.js";import"./circle-help-B5aCQkW2.js";function Q({report:e,onClose:t,issueUrl:n,onCopy:a}){return e===null?null:s.jsx(T,{open:!0,onClose:t,title:"Report this message",children:s.jsxs("div",{className:"flex max-h-[80vh] flex-col",children:[s.jsxs("header",{className:"space-y-1 border-b border-line px-4 py-3",children:[s.jsx("h3",{className:"text-sm font-semibold text-fg",children:"Report this message"}),s.jsx("p",{className:"text-xs text-fg-muted",children:"This is everything the report contains. It describes what went wrong with the message — never its contents, addresses, subject, attachment names, folder name, or the parser's own error text."})]}),s.jsx("pre",{className:"flex-1 overflow-auto bg-surface-sunken px-4 py-3 text-2xs leading-relaxed whitespace-pre-wrap text-fg-muted",children:e}),s.jsxs("footer",{className:"flex flex-wrap items-center justify-end gap-2 border-t border-line px-4 py-3",children:[s.jsx(d,{variant:"ghost",size:"sm",onClick:t,children:"Cancel"}),s.jsx(d,{variant:"secondary",size:"sm",icon:s.jsx(q,{className:"size-3.5"}),onClick:()=>a(e),children:"Copy report"}),s.jsx(C,{external:!0,size:"sm",href:n,icon:s.jsx(D,{className:"size-3.5"}),children:"Open on GitHub"})]})]})})}const V={BodyParse:"The message is built in a way Remit could not read."};function Y(e){return V[e]}function R(e){return e.split(";")[0].trim()}const b=/^[A-Za-z0-9!#$%&'*+._-]+$/,v=/^[A-Za-z0-9!#$%&'*+._-]+\/[A-Za-z0-9!#$%&'*+._-]+$/;function m(e,t){return t.test(e)?`\`${e}\``:`\`${JSON.stringify(e).replace(/`/g,"\\u0060")}\` (malformed)`}function Z(e){const t=R(e);return v.test(t)?t:JSON.stringify(t)}const g="_not read_";function J(e){return e.length===0?["(no MIME structure was read)"]:e.map(t=>`${" ".repeat(t.depth)}- ${Z(t.contentType)}`)}const K="_No message content, addresses, subject, attachment names or parser output are included._";function w(e){return{head:[`### Message quarantined at \`${e.failureStage}\``,"",`- **Failure**: \`${e.failureCode}\``,`- **Folder role**: ${e.mailboxRole??"_none appointed_"}`,`- **Failing part**: ${e.failurePartPath==null?"_whole message_":`\`${e.failurePartPath}\``}`,`- **Attempts before quarantine**: ${e.attempts}`,`- **Worker build**: ${e.workerVersion}`,`- **Message-ID hash**: ${e.messageIdHash==null?"_none declared_":`\`${e.messageIdHash}\``}`,"","#### Message shape","",`- **Content-Type**: ${e.contentType==null?g:m(R(e.contentType),v)}`,`- **Content-Transfer-Encoding**: ${e.transferEncoding==null?g:m(e.transferEncoding,b)}`,`- **Charset**: ${e.charset==null?"_not declared_":m(e.charset,b)}`,`- **Size**: ${e.sizeBytes==null?g:`${e.sizeBytes} bytes`}`,"","MIME structure:"].join(`
2
2
  `),structure:J(e.structure).join(`
3
3
  `),disclaimer:K}}function X(e){const{head:t,structure:n,disclaimer:a}=w(e);return[t,"","```",n,"```","",a].join(`
4
4
  `)}function ee(e){return`Message quarantined: ${e.failureCode} at ${e.failureStage}`}function se(e){return new Date(e).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}function te({entry:e,onCutBug:t}){return s.jsxs("li",{className:"flex flex-col gap-2 border-b border-line px-row-inset py-3 last:border-b-0 sm:flex-row sm:items-start sm:justify-between",children:[s.jsxs("div",{className:"min-w-0 space-y-1",children:[s.jsx("p",{className:"text-sm text-fg",children:Y(e.failureStage)}),s.jsx("p",{className:"truncate text-xs text-fg-muted",title:e.failureMessage,children:e.failureMessage}),s.jsxs("p",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-2xs text-fg-subtle",children:[e.mailboxRole&&s.jsx(y,{tone:"warning",children:j(e.mailboxRole)}),s.jsx("span",{className:"truncate",title:e.mailboxPath,children:N(e.mailboxPath,e.mailboxDelimiter)}),s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx("span",{children:`uid ${e.uid}`}),s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx("span",{children:se(e.quarantinedAt)}),e.attempts>1&&s.jsxs(s.Fragment,{children:[s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx("span",{children:`${e.attempts} attempts`})]})]})]}),s.jsx(d,{variant:"secondary",size:"sm",className:"shrink-0",icon:s.jsx(h,{className:"size-3.5"}),onClick:()=>t(e),children:"Cut a bug"})]})}function ne({entries:e,onCutBug:t}){return s.jsxs("section",{className:"space-y-3",children:[s.jsxs("header",{className:"space-y-1",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Messages set aside"}),s.jsx("p",{className:"text-xs text-fg-muted",children:"Mail Remit could not read is set aside here instead of being skipped, so nothing goes missing quietly. The rest of the folder keeps syncing. Recovering a set-aside message is a re-sync, not a per-row action."})]}),e.length===0&&s.jsxs("div",{className:"flex items-center gap-2 rounded-sm border border-line bg-surface px-row-inset py-3",children:[s.jsx(S,{className:"size-4 shrink-0 text-positive","aria-hidden":!0}),s.jsx("p",{className:"text-sm text-fg-muted",children:"Every message has been read successfully. Nothing is set aside."})]}),e.length>1&&s.jsx($,{tone:"warning",children:s.jsxs("p",{className:"flex items-start gap-2",children:[s.jsx(A,{className:"mt-0.5 size-4 shrink-0","aria-hidden":!0}),s.jsxs("span",{children:[s.jsx("span",{className:"font-semibold",children:`${e.length} messages could not be read.`})," ","More than one means something is wrong with how Remit reads mail, not with the mail. Reporting one of these gets it fixed."]})]})}),e.length>0&&s.jsx("ul",{className:"rounded-sm border border-line bg-surface",children:e.map(n=>s.jsx(te,{entry:n,onCutBug:t},n.quarantineId))})]})}const ae={Retrying:"The message could not be synced. Remit tries again every sync.",GaveUp:"The message body could not be downloaded. Remit has stopped trying."};function re(e){return ae[e.state]}const ie="_No message content, addresses, subject, folder name or error text are included._";function oe(e){return[`### Message failed to sync at \`${e.stage}\``,"",`- **State**: \`${e.state}\``,`- **Attempts**: ${e.attempts}`,"",ie].join(`
5
- `)}function le(e){return`Message failed to sync: ${e.state} at ${e.stage}`}function ce(e){return new Date(e).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}function de({entry:e,onReport:t}){const n=e.state==="GaveUp";return s.jsxs("li",{className:"flex flex-col gap-2 border-b border-line px-row-inset py-3 last:border-b-0 sm:flex-row sm:items-start sm:justify-between",children:[s.jsxs("div",{className:"min-w-0 space-y-1",children:[s.jsx("p",{className:"text-sm text-fg",children:re(e)}),s.jsxs("p",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-2xs text-fg-subtle",children:[s.jsx(y,{tone:n?"danger":"warning",children:n?"Gave up":"Retrying"}),s.jsx("span",{className:"truncate",children:e.folderLabel}),s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx("span",{children:`uid ${e.uid}`}),s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx("span",{children:`since ${ce(e.createdAt)}`}),s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx("span",{children:`${e.attempts} attempts`})]})]}),s.jsx(d,{variant:"secondary",size:"sm",className:"shrink-0",icon:s.jsx(h,{className:"size-3.5"}),onClick:()=>t(e),children:"Cut a bug"})]})}function ue({entries:e,total:t,onReport:n}){return s.jsxs("section",{className:"space-y-3",children:[s.jsxs("header",{className:"space-y-1",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Messages that failed to sync"}),s.jsx("p",{className:"text-xs text-fg-muted",children:"A message shows here after three failed rounds and leaves on its own once it syncs. The rest of the folder keeps syncing."})]}),e.length===0&&s.jsxs("div",{className:"flex items-center gap-2 rounded-sm border border-line bg-surface px-row-inset py-3",children:[s.jsx(S,{className:"size-4 shrink-0 text-positive","aria-hidden":!0}),s.jsx("p",{className:"text-sm text-fg-muted",children:"Every message is syncing. Nothing has failed."})]}),t>e.length&&s.jsx("p",{className:"text-xs text-fg-muted",children:`Showing the ${e.length} newest of ${t} messages that failed to sync.`}),e.length>0&&s.jsx("ul",{className:"rounded-sm border border-line bg-surface",children:e.map(a=>s.jsx(de,{entry:a,onReport:n},a.syncWarningId))})]})}function me(){const{Account:e}=k();return s.jsx(e,{children:({signOut:t})=>s.jsx("button",{type:"button",onClick:()=>t(),className:"rounded-md border border-line px-2.5 py-1 text-sm font-medium text-fg outline-none hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring",children:"Sign in again"})})}function ge(e,t){return{quarantineId:e.quarantineId,accountId:e.accountId,mailboxId:e.mailboxId,uidValidity:e.uidValidity,uid:e.uid,mailboxRole:e.mailboxRole?E[e.mailboxRole]:void 0,mailboxPath:e.mailboxPath,mailboxDelimiter:t,failureStage:e.failureStage,failureCode:e.failureCode,failureMessage:e.failureMessage,failurePartPath:e.failurePartPath,quarantinedAt:e.quarantinedAt,attempts:e.attempts,sizeBytes:e.sizeBytes,contentType:e.contentType,transferEncoding:e.transferEncoding,charset:e.charset,structure:e.structure,messageIdHash:e.messageIdHash,workerVersion:e.workerVersion}}const pe=3,xe=(e,t)=>e===_.Body&&t>=pe?f.GaveUp:f.Retrying,he="A folder no longer listed";function fe(e){return e?.role?j(e.role):e?.providerPath?N(e.providerPath,e.hierarchyDelimiter):he}function be(e,t){return{syncWarningId:e.syncWarningId,uid:e.uid,stage:e.stage,state:xe(e.stage,e.attempts),attempts:e.attempts,createdAt:e.createdAt,folderLabel:fe(t)}}const je=[],Ne=[];function ye(e){window.open(e,"_blank","noopener,noreferrer")}function Se(e){return{report:X(e),issueUrl:p(x({quarantine:w(e),title:ee(e)}))}}function Re(e){const t=oe(e);return{report:t,issueUrl:p(x({syncWarning:t,title:le(e)}))}}function ve({signIn:e}){return s.jsx("section",{role:"alert",className:"space-y-3",children:s.jsxs("div",{className:"space-y-2 rounded-sm border border-danger/40 bg-danger-soft px-row-inset py-3",children:[s.jsx("p",{className:"text-sm font-medium text-danger",children:"Your session has ended."}),s.jsx("p",{className:"text-sm text-fg-muted",children:"Sign in again to see the messages that failed to sync or were set aside."}),e]})})}function we({error:e}){return s.jsx("section",{role:"alert",className:"space-y-3",children:s.jsxs("div",{className:"space-y-2 rounded-sm border border-danger/40 bg-danger-soft px-row-inset py-3",children:[s.jsx("p",{className:"text-sm font-medium text-danger",children:"The warnings could not be read."}),s.jsx("p",{className:"break-words text-sm text-fg-muted",children:U(e)}),s.jsx("p",{className:"text-xs text-fg-muted",children:"Mail may still be failing to sync or have been set aside — this page cannot say either way until it can read the list. Reporting this gets it fixed."}),s.jsx(d,{variant:"secondary",size:"sm",icon:s.jsx(h,{className:"size-3.5"}),onClick:()=>ye(p(x())),children:"Report this"})]})})}function Ie({read:e,signIn:t}){const[n,a]=l.useState(null),[o,r]=l.useState(!1);if(e.kind==="Pending")return s.jsx("p",{className:"animate-pulse text-sm text-fg-subtle",children:"Checking for warnings…"});if(e.kind==="SignedOut")return s.jsx(ve,{signIn:t});if(e.kind==="Failed")return s.jsx(we,{error:e.error});const u=i=>{navigator.clipboard.writeText(i).then(()=>{r(!1),a(null)},()=>{r(!0),a(null)})};return s.jsxs("div",{className:"space-y-6",children:[o&&s.jsx("p",{role:"alert",className:"text-sm text-danger",children:"The report was not copied — this browser refused clipboard access. Cut the bug again and use Open on GitHub, which needs no clipboard."}),s.jsx(ue,{entries:e.warnings,total:e.warningsTotal,onReport:i=>a(Re(i))}),s.jsx(ne,{entries:e.quarantine,onCutBug:i=>a(Se(i))}),s.jsx(Q,{report:n?.report??null,issueUrl:n?.issueUrl??"",onClose:()=>a(null),onCopy:u})]})}function Te(e,t){return e.get(t)?.hierarchyDelimiter??""}function Ce(){const e=M(),t=P(W()),n=l.useMemo(()=>t.data?.accounts??[],[t.data]),a=L(n),o=e.data?.entries??je,r=e.data?.warnings??Ne,u=l.useMemo(()=>o.map(c=>ge(c,Te(a.index,c.mailboxId))),[o,a.index]),i=l.useMemo(()=>r.map(c=>be(c,a.index.get(c.mailboxId))),[r,a.index]),I=$e(e.error??t.error??a.error,e.isPending||t.isPending||a.isPending,{kind:"Ready",quarantine:u,warnings:i,warningsTotal:e.data?.warningsTotal??0});return s.jsx(Ie,{read:I,signIn:s.jsx(me,{})})}function $e(e,t,n){return z(e)?{kind:"SignedOut"}:e?{kind:"Failed",error:e}:t?{kind:"Pending"}:n}function He(){const e=O(),t=B(),n=F(),[a,o]=l.useState(!0);return s.jsx(H,{items:t,activeId:"warnings",title:"Warnings",description:"Messages that failed to sync, and messages set aside.",help:G,helpOpen:a,onToggleHelp:()=>o(r=>!r),onSelect:n,onBackToMail:()=>{e({to:"/mail"})},children:s.jsx(Ce,{})})}export{He as component};
5
+ `)}function le(e){return`Message failed to sync: ${e.state} at ${e.stage}`}function ce(e){return new Date(e).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}function de({entry:e,onReport:t}){const n=e.state==="GaveUp";return s.jsxs("li",{className:"flex flex-col gap-2 border-b border-line px-row-inset py-3 last:border-b-0 sm:flex-row sm:items-start sm:justify-between",children:[s.jsxs("div",{className:"min-w-0 space-y-1",children:[s.jsx("p",{className:"text-sm text-fg",children:re(e)}),s.jsxs("p",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-2xs text-fg-subtle",children:[s.jsx(y,{tone:n?"danger":"warning",children:n?"Gave up":"Retrying"}),s.jsx("span",{className:"truncate",children:e.folderLabel}),s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx("span",{children:`uid ${e.uid}`}),s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx("span",{children:`since ${ce(e.createdAt)}`}),s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx("span",{children:`${e.attempts} attempts`})]})]}),s.jsx(d,{variant:"secondary",size:"sm",className:"shrink-0",icon:s.jsx(h,{className:"size-3.5"}),onClick:()=>t(e),children:"Cut a bug"})]})}function ue({entries:e,total:t,onReport:n}){return s.jsxs("section",{className:"space-y-3",children:[s.jsxs("header",{className:"space-y-1",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Messages that failed to sync"}),s.jsx("p",{className:"text-xs text-fg-muted",children:"A message shows here after three failed rounds and leaves on its own once it syncs. The rest of the folder keeps syncing."})]}),e.length===0&&s.jsxs("div",{className:"flex items-center gap-2 rounded-sm border border-line bg-surface px-row-inset py-3",children:[s.jsx(S,{className:"size-4 shrink-0 text-positive","aria-hidden":!0}),s.jsx("p",{className:"text-sm text-fg-muted",children:"Every message is syncing. Nothing has failed."})]}),t>e.length&&s.jsx("p",{className:"text-xs text-fg-muted",children:`Showing the ${e.length} newest of ${t} messages that failed to sync.`}),e.length>0&&s.jsx("ul",{className:"rounded-sm border border-line bg-surface",children:e.map(a=>s.jsx(de,{entry:a,onReport:n},a.syncWarningId))})]})}function me(){const{Account:e}=k();return s.jsx(e,{children:({signOut:t})=>s.jsx("button",{type:"button",onClick:()=>t(),className:"rounded-md border border-line px-2.5 py-1 text-sm font-medium text-fg outline-none hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring",children:"Sign in again"})})}function ge(e,t){return{quarantineId:e.quarantineId,accountId:e.accountId,mailboxId:e.mailboxId,uidValidity:e.uidValidity,uid:e.uid,mailboxRole:e.mailboxRole?E[e.mailboxRole]:void 0,mailboxPath:e.mailboxPath,mailboxDelimiter:t,failureStage:e.failureStage,failureCode:e.failureCode,failureMessage:e.failureMessage,failurePartPath:e.failurePartPath,quarantinedAt:e.quarantinedAt,attempts:e.attempts,sizeBytes:e.sizeBytes,contentType:e.contentType,transferEncoding:e.transferEncoding,charset:e.charset,structure:e.structure,messageIdHash:e.messageIdHash,workerVersion:e.workerVersion}}const xe=3,pe=(e,t)=>e===_.Body&&t>=xe?f.GaveUp:f.Retrying,he="A folder no longer listed";function fe(e){return e?.role?j(e.role):e?.providerPath?N(e.providerPath,e.hierarchyDelimiter):he}function be(e,t){return{syncWarningId:e.syncWarningId,uid:e.uid,stage:e.stage,state:pe(e.stage,e.attempts),attempts:e.attempts,createdAt:e.createdAt,folderLabel:fe(t)}}const je=[],Ne=[];function ye(e){window.open(e,"_blank","noopener,noreferrer")}function Se(e){return{report:X(e),issueUrl:x(p({quarantine:w(e),title:ee(e)}))}}function Re(e){const t=oe(e);return{report:t,issueUrl:x(p({syncWarning:t,title:le(e)}))}}function ve({signIn:e}){return s.jsx("section",{role:"alert",className:"space-y-3",children:s.jsxs("div",{className:"space-y-2 rounded-sm border border-danger/40 bg-danger-soft px-row-inset py-3",children:[s.jsx("p",{className:"text-sm font-medium text-danger",children:"Your session has ended."}),s.jsx("p",{className:"text-sm text-fg-muted",children:"Sign in again to see the messages that failed to sync or were set aside."}),e]})})}function we({error:e}){return s.jsx("section",{role:"alert",className:"space-y-3",children:s.jsxs("div",{className:"space-y-2 rounded-sm border border-danger/40 bg-danger-soft px-row-inset py-3",children:[s.jsx("p",{className:"text-sm font-medium text-danger",children:"The warnings could not be read."}),s.jsx("p",{className:"break-words text-sm text-fg-muted",children:U(e)}),s.jsx("p",{className:"text-xs text-fg-muted",children:"Mail may still be failing to sync or have been set aside — this page cannot say either way until it can read the list. Reporting this gets it fixed."}),s.jsx(d,{variant:"secondary",size:"sm",icon:s.jsx(h,{className:"size-3.5"}),onClick:()=>ye(x(p())),children:"Report this"})]})})}function Ie({read:e,signIn:t}){const[n,a]=l.useState(null),[o,r]=l.useState(!1);if(e.kind==="Pending")return s.jsx("p",{className:"animate-pulse text-sm text-fg-subtle",children:"Checking for warnings…"});if(e.kind==="SignedOut")return s.jsx(ve,{signIn:t});if(e.kind==="Failed")return s.jsx(we,{error:e.error});const u=i=>{navigator.clipboard.writeText(i).then(()=>{r(!1),a(null)},()=>{r(!0),a(null)})};return s.jsxs("div",{className:"space-y-6",children:[o&&s.jsx("p",{role:"alert",className:"text-sm text-danger",children:"The report was not copied — this browser refused clipboard access. Cut the bug again and use Open on GitHub, which needs no clipboard."}),s.jsx(ue,{entries:e.warnings,total:e.warningsTotal,onReport:i=>a(Re(i))}),s.jsx(ne,{entries:e.quarantine,onCutBug:i=>a(Se(i))}),s.jsx(Q,{report:n?.report??null,issueUrl:n?.issueUrl??"",onClose:()=>a(null),onCopy:u})]})}function Te(e,t){return e.get(t)?.hierarchyDelimiter??""}function Ce(){const e=M(),t=P(W()),n=l.useMemo(()=>t.data?.accounts??[],[t.data]),a=L(n),o=e.data?.entries??je,r=e.data?.warnings??Ne,u=l.useMemo(()=>o.map(c=>ge(c,Te(a.index,c.mailboxId))),[o,a.index]),i=l.useMemo(()=>r.map(c=>be(c,a.index.get(c.mailboxId))),[r,a.index]),I=$e(e.error??t.error??a.error,e.isPending||t.isPending||a.isPending,{kind:"Ready",quarantine:u,warnings:i,warningsTotal:e.data?.warningsTotal??0});return s.jsx(Ie,{read:I,signIn:s.jsx(me,{})})}function $e(e,t,n){return z(e)?{kind:"SignedOut"}:e?{kind:"Failed",error:e}:t?{kind:"Pending"}:n}function He(){const e=O(),t=B(),n=F(),[a,o]=l.useState(!0);return s.jsx(H,{items:t,activeId:"warnings",title:"Warnings",description:"Messages that failed to sync, and messages set aside.",help:G,helpOpen:a,onToggleHelp:()=>o(r=>!r),onSelect:n,onBackToMail:()=>{e({to:"/mail"})},children:s.jsx(Ce,{})})}export{He as component};
package/index.html CHANGED
@@ -35,8 +35,8 @@
35
35
  } catch (_) {}
36
36
  })();
37
37
  </script>
38
- <script type="module" crossorigin src="/assets/index-CKflMWYU.js"></script>
39
- <link rel="stylesheet" crossorigin href="/assets/index-CMNnsfzR.css">
38
+ <script type="module" crossorigin src="/assets/index-CjLIM85N.js"></script>
39
+ <link rel="stylesheet" crossorigin href="/assets/index-CqMlmBtY.css">
40
40
  </head>
41
41
  <body>
42
42
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/web-client-dist",
3
- "version": "0.0.683",
3
+ "version": "0.0.684",
4
4
  "description": "Built Remit web client — static assets and the default runtime config.",
5
5
  "files": [
6
6
  "**/*"
@@ -1 +0,0 @@
1
- import{j as r,L as Mt,eG as ne,d_ as re,r as a,a as Ke,H as ie,cV as jt,R as kt,dz as Et,eH as Ot,t as Ue,eI as At}from"./index-CKflMWYU.js";import{a5 as Ft,y as Nt,A as Bt,an as Lt,ao as qt,ap as _t,aq as Dt,ar as _e,as as Pt,at as Qt,au as zt,av as Wt,aw as Ht,ag as Gt,M as Kt,aj as Ut,ax as Vt,ah as $t,ay as Yt,az as Jt,f as Zt,p as Xt,ak as es,m as ts,S as ss,G as os,K as De,J as ns,H as rs,e as as,V as is,W as xe,X as cs,Z as Ve,_ as $e,$ as ls,a0 as ds,a1 as us}from"./MessageToolbar-BEI90gj6.js";import"./nav-link-D4-gc9H1.js";import{a as fs}from"./useMessageBodyContent-B0iiI3OV.js";import{o as ms,e as hs,f as gs}from"./search-token-index-CjZf08nc.js";import{d as ps,g as xs,r as Is}from"./reply-CM_F5zLS.js";import{u as Ye}from"./sections-HylxNewe.js";import{u as ae}from"./useQueries-DVcMuKhn.js";import{t as Je,s as ys,r as vs,L as bs}from"./LabelApplyTrigger-C03Hgfzy.js";import{u as Ss,a as Ts,R as Cs,b as ws,c as Rs}from"./useRefreshControl-CY786xTG.js";import{a as Ms}from"./useLabels-QIv6Xivl.js";import{u as js}from"./useLayoutTier-4MDmjdnr.js";import{u as ks}from"./useMediaQuery-B1PJEoqh.js";import{r as Ze,n as Es,o as Xe,w as et,u as Os,p as As,R as Fs}from"./MessageBody-D3iuMLwF.js";import{d as Ns,w as Bs}from"./wizard-selection-zWa1qc6-.js";import{R as Ls}from"./refresh-cw-BmzOf0Tw.js";import{S as qs}from"./sparkles-DxQ7dXLC.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(qs,{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=>Es(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)])},Gs=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,Ks=3e4,Us={kind:"unknown"},We=e=>(t,s)=>Ft(s?.queryKey,e)?t:void 0,Vs=(e,t,s)=>({...e,category:[t],limit:s,order:"desc"}),$s=(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=Vs(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=$s(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):Us,loading:u?.isPending??!0,failed:u?.isError??!1,retry:()=>{u?.refetch(),n&&v?.refetch()}}}),[e,i,d,n,s]),l=a.useCallback(()=>{for(const c of i)c.refetch();for(const c of d)c.refetch()},[i,d]);return{sections:m,isLoading:i.length>0&&i.every(c=>c.isPending),isError:i.length>0&&i.every(c=>c.isError),refetch:l}}function Js(e,t,s){const n={...e,limit:t,order:"desc"},{data:i,isLoading:d,isError:m,refetch:l}=Ke({queryKey:re({query:n}),queryFn:async()=>{const{data:h}=await ne({query:n,throwOnError:!0});return h},enabled:s,staleTime:Ks});return{rows:a.useMemo(()=>s?i?.items??[]:[],[i,s]),isLoading:s&&d,isError:s&&m,refetch:a.useCallback(()=>{l()},[l])}}const Zs=3e4,Xs={kind:"unknown"},eo=(e,t)=>({...e,mailboxId:t,order:"desc",count:!0,results:!1});function to({criteria:e,junkMailboxIds:t,enabled:s}){const n=ae({queries:t.map(i=>{const d=eo(e,i);return{queryKey:re({query:d}),queryFn:async()=>{const{data:m}=await ne({query:d,throwOnError:!0});return m},enabled:s,staleTime:Zs}})});return a.useMemo(()=>t.map((i,d)=>({mailboxId:i,count:s?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=Nt({category:e,attributes:t}),{params:d,residual:m}=Bt(s,i,no),l={...d,...i},c={muted:!1};return l.from!==void 0&&(c.from=l.from),l.subject!==void 0&&(c.subject=l.subject),l.unread!==void 0&&(c.unread=l.unread),l.starred!==void 0&&(c.starred=l.starred),l.attachments!==void 0&&(c.attachments=l.attachments),n!==void 0&&(c.accountId=n),{criteria:c,residual:m}},io=({residual:e,attributes:t})=>e.length===0&&!at.some(s=>t.has(s)),se=e=>e.count.kind==="exact"&&e.count.value>0?3:e.pageRows>0?2:e.count.kind==="unknown"?1:0,oe=e=>e.count.kind==="exact"?e.count.value:0,co=(e,t)=>se(e)!==se(t)?se(e)>se(t):oe(e)!==oe(t)?oe(e)>oe(t):e.pageRows>t.pageRows;function lo(e,{pageRowsByMailbox:t}){const s=e.map(u=>({...u,pageRows:t.get(u.mailboxId)??0}));for(const[u,v]of t)v<=0||s.some(p=>p.mailboxId===u)||s.push({mailboxId:u,count:{kind:"unknown"},failed:!1,pageRows:v});const n=s[0];if(!n)return;let i=0,d=!0,m=n;for(const u of s)u.count.kind==="unknown"?d=!1:i+=u.count.value,co(u,m)&&(m=u);const l=s.some(u=>u.pageRows>0),c=s.some(u=>u.failed);if(i===0&&!l&&(d||!c))return;const h=d&&i===0&&l;return{mailboxId:m.mailboxId,count:d&&!h?{kind:"exact",value:i}:{kind:"unknown"}}}const uo=50,fo=200,mo=[],Ge=()=>r.jsx("div",{className:"animate-pulse",children:Array.from({length:3}).map((e,t)=>r.jsxs("div",{className:"flex items-start gap-3 py-2 pl-5 pr-4 border-b border-line",children:[r.jsx("div",{className:"size-7 rounded-full bg-surface-sunken shrink-0 mt-0.5"}),r.jsxs("div",{className:"flex-1 space-y-1.5",children:[r.jsxs("div",{className:"flex justify-between gap-2",children:[r.jsx("div",{className:"h-3.5 bg-surface-sunken rounded w-28"}),r.jsx("div",{className:"h-3 bg-surface-sunken rounded w-12"})]}),r.jsx("div",{className:"h-3.5 bg-surface-sunken rounded w-48"}),r.jsx("div",{className:"h-3 bg-surface-sunken rounded w-full"})]})]},t))}),ho=({accountEmail:e})=>{const t=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(Ue,{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=vs(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}=Jt(),u=a.useMemo(()=>go(t,i),[t,i]),{junkMailboxId:v}=Zt(u.accountId),{labels:p}=Ms(u.accountId),b=a.useMemo(()=>Array.from(i),[i]),L=a.useMemo(()=>Bs(t,i),[t,i]),x=Xt(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(ss,{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(bs,{accountId:u.accountId,mailboxId:u.mailboxId,messageIds:b}):void 0,selectAll:S,notice:F});return r.jsx(es,{...e,selectionBar:T,paneOverlay:r.jsx(ts,{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=Os(),v=ks(),p=js(),b=jt(),L=ms(),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})},[]),G=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]),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"),G(),E&&h(Gs(l))},[E,l,h,G]),K=ae({queries:x.map(o=>({...kt({path:{accountId:o.accountId}}),staleTime:1/0,meta:{softError:!0}}))}),U=a.useMemo(()=>{const o=new Map;for(let f=0;f<x.length;f++){const g=x[f].accountId,te=(K[f]?.data?.items??[]).reduce((O,Rt)=>O+(Rt.unseenCount??0),0);o.set(g,te)}return o},[x,K]),lt=a.useMemo(()=>x.filter((o,f)=>{const g=K[f];return g?.isError?!Et(g.error):!1}),[x,K]),{criteria:fe,residual:V}=a.useMemo(()=>ao(C,A,D,S==="all"?void 0:S),[C,A,D,S]),dt=a.useMemo(()=>C==="all"?[...Lt]:[C],[C]),ve=a.useMemo(()=>({...fe,query:w,...C==="all"?{}:{category:[C]}}),[fe,w,C]),be=io({residual:V,attributes:A}),{sections:$,isLoading:ut,isError:ft,refetch:Se}=Ys({categories:y?mo:dt,criteria:fe,limit:C==="all"?Yt: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=>Ns(o).map(qt).filter(f=>_t(f,Me)&&Dt(f,V)),[Me,V]),J=a.useMemo(()=>$.map(o=>({category:o.category,total:o.total,atCap:o.atCap,loading:o.loading,failed:o.failed,rows:Y(o.rows)})),[$,Y]),Z=a.useMemo(()=>Y(Te),[Te,Y]),gt=a.useCallback(o=>{$.find(f=>f.category===o)?.retry()},[$]),k=a.useMemo(()=>y?Z:J.flatMap(o=>o.rows),[y,Z,J]),pt=a.useMemo(()=>Ot(c),[c]),je=to({criteria:ve,junkMailboxIds:pt,enabled:be&&ys({hasSearchQuery:y,freeText:w,residualTokenCount:V.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}=Pt(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)}]:Qt(J.map(f=>({...f,rows:o(f.rows)})))},[y,Z,J,he]),Ee=a.useCallback((o,f)=>{const g=k.find(B=>B.id===o)?.threadId;g&&s?.({threadId:g,messageId:o},f)},[k,s]),xt=a.useCallback(o=>{const f=o.threadId??k.find(g=>g.id===o.id)?.threadId;f&&s?.({threadId:f,messageId:o.id})},[k,s]),ge=a.useMemo(()=>x.length<=1?[]:[{id:"all",label:"All",active:S==="all"},...x.map(o=>({id:o.accountId,label:o.email.split("@")[0]??o.email,count:U.get(o.accountId),active:S===o.accountId}))],[x,U,S]),z=a.useMemo(()=>e.filter(o=>o.muted?.value).length,[e]),It=a.useMemo(()=>Array.from(U.values()).reduce((o,f)=>o+f,0),[U]),pe=a.useMemo(()=>x.map(o=>o.accountId),[x]),{hasNewMail:Oe}=Ss(),{state:Ae,errorMessage:Fe,refresh:Ne}=Ts(pe,{onSettled:()=>Re()}),yt=a.useMemo(()=>r.jsx(Cs,{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=zt(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=>ws(o.syncPhase)),[x]),ee=Rs(St,Be||Tt),Le=r.jsxs("div",{className:"h-full overflow-y-auto",children:[r.jsx(Ge,{}),r.jsx(Ge,{})]}),qe=!me&&!we&&!Be,Ct=Wt({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(Ht,{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(Ue,{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(Ls,{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(Ut,{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($t,{}):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=hs(),n=gs(),i=Ye(),{searchInput:d}=ie(),m=e?.threadId,l=e?.messageId,{data:c}=Ke({...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=os(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=ns(),{deleteMessages:R}=rs({mailboxId:p?.mailboxId??"",messages:h,onAfterOptimisticRemove:S}),{toggleReadFor:N}=as({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}),G=fs(),E=ps(),w=xs(),D=a.useMemo(()=>Is(w,m,b),[w,m,b]),y=a.useMemo(()=>{if(M)return I=>w({threadId:M.threadId,messageId:M.messageId,mode:I})},[w,M]),{nextMessageId:P,previousMessageId:Q}=is({context:T,orderedIds:T.orderedIds,selectedMessageId:b,enabled:!G&&!E,hasOpenThread:m!==void 0,onClose:n,handlers:{reply:()=>y?.("reply"),replyAll:()=>y?.("reply-all"),forward:()=>y?.("forward"),delete:()=>{T.listCommandsRef.current?.requestVerb("delete")||_.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=ds(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(us,{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(Ve,{threadId:t.threadId,mailboxId:t.mailboxId,subject:t.subject,selectedMessageId:t.messageId,authenticity:t.authenticity,onOpenIntelligence:c.open,listOnScreen:!0}):r.jsx(Fs,{})})]}),r.jsx($e,{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(ls,{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=cs(s?.threadId??null);return s?r.jsxs(r.Fragment,{children:[r.jsx(Ve,{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($e,{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 Do=Object.assign(Io,{List:ct,Reading:yo,Intelligence:vo,Phone:bo});export{Do as B};
@@ -1 +0,0 @@
1
- import{eG as J,r as n,d_ as X,a as le,H,cV as ce,av as ue,aw as ge,j as r}from"./index-CKflMWYU.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 V,X as Oe,Z,_ as $,$ as ke,a0 as Pe,a1 as Le}from"./MessageToolbar-BEI90gj6.js";import{u as Ae,l as Ne,b as De,a as qe}from"./MailViewChrome-Dsvhd_KV.js";import"./nav-link-D4-gc9H1.js";import{a as Ee}from"./useMessageBodyContent-B0iiI3OV.js";import{e as Be,f as We}from"./search-token-index-CjZf08nc.js";import{d as Qe,g as He,r as Ve}from"./reply-CM_F5zLS.js";import{u as ze}from"./sections-HylxNewe.js";import{u as Ge}from"./useMediaQuery-B1PJEoqh.js";import{u as Ke,p as U,R as _e}from"./MessageBody-D3iuMLwF.js";import{d as Ue,w as Je}from"./wizard-selection-zWa1qc6-.js";import{f as Xe}from"./ErrorState-94ifepAa.js";const z=t=>({...t,starred:!0,order:"desc"}),Ze=(t={})=>X({query:z(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 J({query:{...z(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={...z(t),unread:!0,count:!0,results:!1},{data:s}=le({queryKey:X({query:e}),queryFn:async()=>{const{data:a}=await J({query:e,throwOnError:!0});return a},staleTime:6e4});return s?.count}const Ye=["from","subject","category","unread","starred","attachments"],et=(t,e)=>{const s=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(()=>Je(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}=H(),o=Ke(),k=Ge(),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}=U(f.trim().toLowerCase(),o),L=U(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(()=>Ue(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}),G=D?"loading":y?"error":p.length===0?"empty":"ready",ne=n.useCallback(()=>{const d=ue(ge());window.open(d,"_blank","noopener,noreferrer")},[]),K=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:K.searchResults?"ready":G,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:K.searchResults??(G==="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=ze(),{searchInput:f}=H(),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=He(),E=n.useMemo(()=>Ve(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=V(),{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=V(),{selectedThread:e,handleDeselectIfRemoved:s,onOpenThread:a}=q(),{onToggleIntelligence:i}=H();return r.jsx(ke,{onClose:i,thread:e,accountId:e?.accountId,onAfterOptimisticRemove:s,onReplyWithText:t,onOpenThread:a})}function nt(){const t=V(),{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};