@remit/web-client-dist 0.0.677 → 0.0.678

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 (182) hide show
  1. package/assets/{BriefPane-dae720lw.js → BriefPane-DZbE8ZNv.js} +1 -1
  2. package/assets/CalendarEventEditor-LUplTbrz.js +1 -0
  3. package/assets/{CalendarEventPopup-qgqMLo7x.js → CalendarEventPopup-CQaPJg2s.js} +1 -1
  4. package/assets/{CalendarLoadFailed-CZZrv3kl.js → CalendarLoadFailed-DGqiWK7A.js} +1 -1
  5. package/assets/{CalendarQuickCreate-BtDiOQnj.js → CalendarQuickCreate-DqIwACsh.js} +1 -1
  6. package/assets/{CalendarSession-BSPnENrr.js → CalendarSession-DGGQfwLi.js} +1 -1
  7. package/assets/DesktopChrome-Dl4YzJrV.js +1 -0
  8. package/assets/DropdownMenu-CowSyQUa.js +1 -0
  9. package/assets/{EmptyState-DaDveift.js → EmptyState-DcHnaG2R.js} +1 -1
  10. package/assets/{ErrorState-BjlNwjgd.js → ErrorState-DcP5ZTMN.js} +1 -1
  11. package/assets/{FlaggedPane-BMM1CFDP.js → FlaggedPane-CuevlxSV.js} +1 -1
  12. package/assets/{FullCompose-C6KtKdIN.js → FullCompose-BdpPcB8J.js} +1 -1
  13. package/assets/LabelApplyTrigger-c7ugtEyT.js +1 -0
  14. package/assets/{MailShell-B8hUSN5k.js → MailShell-C7RoeX76.js} +1 -1
  15. package/assets/{MailViewChrome-ByS8tz5h.js → MailViewChrome-CQnNS9Dt.js} +1 -1
  16. package/assets/{MailboxPane-CAAszcbD.js → MailboxPane-GqjbzfQ9.js} +1 -1
  17. package/assets/{MessageBody-0P-UxriZ.js → MessageBody-B3Z3zu18.js} +4 -4
  18. package/assets/MessageToolbar-DpBF7XWc.js +1 -0
  19. package/assets/{NavMenuButton-lXQswWUS.js → NavMenuButton-d1WErbNE.js} +1 -1
  20. package/assets/{OnboardingWizard-B9A2fDSa.js → OnboardingWizard-CPxEO5Gn.js} +1 -1
  21. package/assets/{OutboxPane-C-1N19Mm.js → OutboxPane-CnWjm3Kz.js} +1 -1
  22. package/assets/_calendarObjectId-BNxfdsFq.js +1 -0
  23. package/assets/_mailboxId-5uzJGGTA.js +1 -0
  24. package/assets/_messageId-CtUY7QaK.js +1 -0
  25. package/assets/_messageId-CyMtXqvK.js +1 -0
  26. package/assets/_messageId-jb0nvtAH.js +1 -0
  27. package/assets/_outboxMessageId-CRuHx4Az.js +1 -0
  28. package/assets/_recurrenceId-Dcdvy3HK.js +1 -0
  29. package/assets/_threadId-B17WzUu-.js +1 -0
  30. package/assets/_threadId-Djcejxjj.js +1 -0
  31. package/assets/_threadId-TLGn2UeF.js +1 -0
  32. package/assets/{_view._date-CQz1dtN-.js → _view._date-DLGnjbKh.js} +1 -1
  33. package/assets/{account-service-status-Cn_S-syP.js → account-service-status-BrL78Bwl.js} +1 -1
  34. package/assets/accounts-DKPcRgRU.js +1 -0
  35. package/assets/advanced-BjXiUDtl.js +1 -0
  36. package/assets/appearance-MzTWiLTR.js +1 -0
  37. package/assets/{avatar-_Iz-lpCN.js → avatar-B4KRzyzS.js} +1 -1
  38. package/assets/{bottom-sheet-zjs6jE40.js → bottom-sheet-B5OEKAh2.js} +1 -1
  39. package/assets/brief-C-5GXXj6.js +1 -0
  40. package/assets/{brief-SkDhbGUS.js → brief-ChnlqLdX.js} +1 -1
  41. package/assets/{calendar-event-popup-Eoorlfr8.js → calendar-event-popup-Dbcz3Zb_.js} +1 -1
  42. package/assets/{calendar-event-sidebar-Dy-5E4fW.js → calendar-event-sidebar-D_7uvmvT.js} +1 -1
  43. package/assets/{calendar-failure-note-DGOwCvAu.js → calendar-failure-note-BJCyTf1U.js} +1 -1
  44. package/assets/{calendar-guests-CGyi0Z1i.js → calendar-guests-BCC1uGzd.js} +1 -1
  45. package/assets/{calendar-TkJ4zEO8.js → calendar-miAZmlW9.js} +1 -1
  46. package/assets/calendar-mwWH-7s8.js +1 -0
  47. package/assets/{calendar-suggestion-CwP3NZgH.js → calendar-suggestion-BppH-3oL.js} +1 -1
  48. package/assets/{calendars-C-lW-6Ji.js → calendars-D9ZEiowB.js} +1 -1
  49. package/assets/{card-BPN5dp6F.js → card-WB75jB_w.js} +1 -1
  50. package/assets/{checkbox-CJ4cnZfk.js → checkbox-BXzuviQP.js} +1 -1
  51. package/assets/{circle-check-BLyY37Bq.js → circle-check-Bifl6wEJ.js} +1 -1
  52. package/assets/{circle-check-big-DtREikeq.js → circle-check-big-BrmrabN6.js} +1 -1
  53. package/assets/{circle-help-BT_Dohsy.js → circle-help-Cyj92MDS.js} +1 -1
  54. package/assets/{clock-rdLLgeDx.js → clock-A6ewTncv.js} +1 -1
  55. package/assets/cloud-off-CsGOr1Gn.js +1 -0
  56. package/assets/compose._-_outboxMessageId_-C6-fUwE2.js +1 -0
  57. package/assets/compose._-_outboxMessageId_-CSKV8YnZ.js +1 -0
  58. package/assets/compose._-_outboxMessageId_-Djp_aqSn.js +1 -0
  59. package/assets/compose._-_outboxMessageId_-DspXe17c.js +1 -0
  60. package/assets/{config-import-CkiEFeqC.js → config-import-DTjV5c_Y.js} +1 -1
  61. package/assets/{confirm-dialog-DtOnF5MV.js → confirm-dialog-9Q6aXOb5.js} +1 -1
  62. package/assets/{copy--8c5mY8r.js → copy-DjyWdtW5.js} +1 -1
  63. package/assets/{credential-steps-CtTCRP2k.js → credential-steps-BoiX5zy2.js} +1 -1
  64. package/assets/{download-BKDG5QA1.js → download-CtoLQ9Ox.js} +1 -1
  65. package/assets/{draft-BeV5oY-T.js → draft-CdiiJR8n.js} +1 -1
  66. package/assets/edit-D9g3EW1R.js +1 -0
  67. package/assets/edit-DkOWaaHs.js +1 -0
  68. package/assets/{external-link-C55BTLfs.js → external-link-Dn2gWGrg.js} +1 -1
  69. package/assets/{file-json-D8vlo3ob.js → file-json-B4YU26EQ.js} +1 -1
  70. package/assets/filters--HZZoQYr.js +1 -0
  71. package/assets/flagged-CVmpEd-z.js +1 -0
  72. package/assets/{flagged-BXI9KzeP.js → flagged-CjfnRBYq.js} +1 -1
  73. package/assets/{folders-CMN67g3r.js → folders-BEv1OKE6.js} +1 -1
  74. package/assets/{help-copy-z6sn-HSk.js → help-copy-CQIBCXJf.js} +1 -1
  75. package/assets/{import-CT3XcMFi.js → import-DhvqQyGM.js} +1 -1
  76. package/assets/{index-Q7BlLS9p.js → index-4XPoPWhu.js} +75 -75
  77. package/assets/index-B4YQCeZ5.js +1 -0
  78. package/assets/index-B8TxM1Ri.js +1 -0
  79. package/assets/{index-IYu0bmf1.js → index-BNUBjW43.js} +4 -4
  80. package/assets/index-BqN9osrB.js +1 -0
  81. package/assets/index-CA4e3svh.js +1 -0
  82. package/assets/{index-Cr6oUxXl.css → index-CNLnhDIy.css} +1 -1
  83. package/assets/index-ChXNLMBw.js +1 -0
  84. package/assets/index-Cm4__-V6.js +1 -0
  85. package/assets/index-CtUY7QaK.js +1 -0
  86. package/assets/index-CyMtXqvK.js +1 -0
  87. package/assets/index-DDMaQQcI.js +1 -0
  88. package/assets/index-aTwfTj57.js +1 -0
  89. package/assets/{kbd-Bxe2zQGe.js → kbd-D0eWE7Kp.js} +1 -1
  90. package/assets/labels-DlSg6Q8z.js +1 -0
  91. package/assets/mail-CmiK10Kq.js +1 -0
  92. package/assets/{menu-BzT426Ih.js → menu-D06KWsdQ.js} +1 -1
  93. package/assets/new-B_n0KCot.js +1 -0
  94. package/assets/onboarding-DVJYsyGv.js +1 -0
  95. package/assets/{onboarding-completion-BB19AMJ-.js → onboarding-completion-DnXMA7VE.js} +1 -1
  96. package/assets/outbox-_8AzSWX1.js +1 -0
  97. package/assets/{pencil-CPbJ6Tks.js → pencil-CA6DIP59.js} +1 -1
  98. package/assets/people-BAjwQQiz.js +1 -0
  99. package/assets/{popover-menu-O_sOnKG9.js → popover-menu-BT-fkOr5.js} +1 -1
  100. package/assets/{refresh-cw-CIoRjIJp.js → refresh-cw-BERt5E10.js} +1 -1
  101. package/assets/{reply-BRbg9_Ak.js → reply-FoVQqDdv.js} +1 -1
  102. package/assets/{rich-text-B5WZj9gV.js → rich-text-C9TR28N2.js} +14 -14
  103. package/assets/{rich-text-spellcheck-worker-provider-BR2Tfepe.js → rich-text-spellcheck-worker-provider-DjdTU9LK.js} +1 -1
  104. package/assets/{rotate-ccw-Yghgmp4e.js → rotate-ccw-C-agNTCI.js} +1 -1
  105. package/assets/{roving-focus-Cj5YFxIj.js → roving-focus-Cj3j6dFs.js} +1 -1
  106. package/assets/{row-actions-D3zwQA9I.js → row-actions-C7JJUiqN.js} +1 -1
  107. package/assets/{search-mirror-CkH8xzbq.js → search-mirror-B5Imt12Z.js} +1 -1
  108. package/assets/{search-token-index-Box28J2l.js → search-token-index-C7o7PQIx.js} +1 -1
  109. package/assets/{sections-Bz9kplXE.js → sections-DiFHIPo4.js} +1 -1
  110. package/assets/senders-BpChah6o.js +1 -0
  111. package/assets/settings-kL8Y1zKC.js +1 -0
  112. package/assets/{settings-screen-DlzqJ0HQ.js → settings-screen-ZYutaKzZ.js} +1 -1
  113. package/assets/shield-check-DDrlOAO3.js +1 -0
  114. package/assets/{sparkles-t4_3JyEx.js → sparkles-MrqvyWps.js} +1 -1
  115. package/assets/{suggested-vips-0F7iDlFJ.js → suggested-vips-ODDnv-D2.js} +1 -1
  116. package/assets/{suggestion._suggestionId-Bz7HzxP1.js → suggestion._suggestionId-DZhG3YlZ.js} +1 -1
  117. package/assets/{task._calendarTaskId-D7UXvB0Z.js → task._calendarTaskId-BfaZmOEn.js} +1 -1
  118. package/assets/{undo-2-Dw4FFZmo.js → undo-2-C6aYHE3s.js} +1 -1
  119. package/assets/{useCalendarData-4TkWGBli.js → useCalendarData-C3WbLJaC.js} +1 -1
  120. package/assets/{useCalendarScheduling-DSmz3E5d.js → useCalendarScheduling-CjI7T1o-.js} +1 -1
  121. package/assets/{useCalendarSuggestions-DHNLR9_9.js → useCalendarSuggestions-D6k1REyo.js} +1 -1
  122. package/assets/{useCalendarTasks-Ch-qSnN_.js → useCalendarTasks-DNBYBsvN.js} +1 -1
  123. package/assets/{useDebouncedValue-B6s52mZt.js → useDebouncedValue-B0BMCu3v.js} +1 -1
  124. package/assets/{useFilters-CYaLiKrQ.js → useFilters-C_nA08Aa.js} +1 -1
  125. package/assets/{useLabels-Ci_KO517.js → useLabels-Dn9qgr5w.js} +1 -1
  126. package/assets/useLayoutTier-DtUqYCCh.js +1 -0
  127. package/assets/{useMediaQuery-CXurPMbN.js → useMediaQuery-a7SamL-l.js} +1 -1
  128. package/assets/{useMessageBodyContent-DJ1-V3VF.js → useMessageBodyContent-ClVl7CBj.js} +1 -1
  129. package/assets/useQueries-XPiXhlQX.js +1 -0
  130. package/assets/{useRefreshControl-BVxIaWvo.js → useRefreshControl-C9tPndY1.js} +1 -1
  131. package/assets/{useResultFolderIndex-BGDx2gSv.js → useResultFolderIndex-koSvRw-H.js} +1 -1
  132. package/assets/{useSignature-BtR5UuiQ.js → useSignature-rM5axmpY.js} +1 -1
  133. package/assets/{warnings-C4WaZxJm.js → warnings-De2eUHBy.js} +3 -3
  134. package/index.html +2 -2
  135. package/package.json +1 -1
  136. package/assets/CalendarEventEditor-D8lJfjiB.js +0 -1
  137. package/assets/DesktopChrome-wrncK03X.js +0 -1
  138. package/assets/LabelApplyTrigger-BOo72opb.js +0 -1
  139. package/assets/MessageToolbar-CpGOUJZt.js +0 -1
  140. package/assets/_calendarObjectId-DZUruQVS.js +0 -1
  141. package/assets/_mailboxId-BJ_K1owi.js +0 -1
  142. package/assets/_messageId-Bv7rw2Ee.js +0 -1
  143. package/assets/_messageId-CxEtXKOV.js +0 -1
  144. package/assets/_messageId-Dn--s-1U.js +0 -1
  145. package/assets/_outboxMessageId-CtKRsjsP.js +0 -1
  146. package/assets/_recurrenceId-BmfvBHMQ.js +0 -1
  147. package/assets/_threadId-CYfh6U5z.js +0 -1
  148. package/assets/_threadId-DR-VADHf.js +0 -1
  149. package/assets/_threadId-_Tp38Jjp.js +0 -1
  150. package/assets/accounts-BBs1u3a9.js +0 -1
  151. package/assets/advanced-NdwM48ef.js +0 -1
  152. package/assets/appearance-CN3GLLqL.js +0 -1
  153. package/assets/brief-DxWizfDz.js +0 -1
  154. package/assets/calendar-089QTsHp.js +0 -1
  155. package/assets/compose._-_outboxMessageId_-BTbEyzkW.js +0 -1
  156. package/assets/compose._-_outboxMessageId_-BtcobB1K.js +0 -1
  157. package/assets/compose._-_outboxMessageId_-CfMr_J5t.js +0 -1
  158. package/assets/compose._-_outboxMessageId_-CqlGCna1.js +0 -1
  159. package/assets/edit-BTLe8Y0F.js +0 -1
  160. package/assets/edit-ByggXvS8.js +0 -1
  161. package/assets/filters-BQo3gMJ3.js +0 -1
  162. package/assets/flagged-DJ-TC-JA.js +0 -1
  163. package/assets/index-6I3CIFzv.js +0 -1
  164. package/assets/index-B03cLsmc.js +0 -1
  165. package/assets/index-B_Kp6tBV.js +0 -1
  166. package/assets/index-BqhbwSzu.js +0 -1
  167. package/assets/index-Cs95BuoI.js +0 -1
  168. package/assets/index-Cua4RHkF.js +0 -1
  169. package/assets/index-D_cEGMwi.js +0 -1
  170. package/assets/index-Dn--s-1U.js +0 -1
  171. package/assets/index-HzhXMggl.js +0 -1
  172. package/assets/index-_NrXWlZY.js +0 -1
  173. package/assets/labels-B030K3QL.js +0 -1
  174. package/assets/mail-BuB5wUpu.js +0 -1
  175. package/assets/new-CRVRIIK_.js +0 -1
  176. package/assets/onboarding-C65aa4Nh.js +0 -1
  177. package/assets/outbox-DAPK8OVn.js +0 -1
  178. package/assets/senders-DnVrQngr.js +0 -1
  179. package/assets/settings-emdtCHOi.js +0 -1
  180. package/assets/shield-check-BSecZw5t.js +0 -1
  181. package/assets/useLayoutTier-DPp2gD1F.js +0 -1
  182. package/assets/useQueries-BNgXdYau.js +0 -1
@@ -1 +1 @@
1
- import{f_ as r,f$ as o,g0 as a}from"./index-Q7BlLS9p.js";import{o as n}from"./rich-text-spellcheck-provider-J8m9wz6A.js";const l=t=>({post:e=>t.postMessage(e),listen:e=>t.addEventListener("message",s=>e(s.data)),fail:e=>t.addEventListener("error",s=>e(s.message)),terminate:()=>t.terminate()}),i=async t=>{const e=r(t);if(!e)return null;const s=new Worker(new URL("/assets/rich-text-spellcheck-worker-pWkhC-WR.js",import.meta.url),{type:"module"});return n(e,o(),l(s),a(e))};export{i as openSpellcheckWorker};
1
+ import{gc as r,gd as o,ge as a}from"./index-4XPoPWhu.js";import{o as n}from"./rich-text-spellcheck-provider-J8m9wz6A.js";const c=t=>({post:e=>t.postMessage(e),listen:e=>t.addEventListener("message",s=>e(s.data)),fail:e=>t.addEventListener("error",s=>e(s.message)),terminate:()=>t.terminate()}),i=async t=>{const e=r(t);if(!e)return null;const s=new Worker(new URL("/assets/rich-text-spellcheck-worker-pWkhC-WR.js",import.meta.url),{type:"module"});return n(e,o(),c(s),a(e))};export{i as openSpellcheckWorker};
@@ -1 +1 @@
1
- import{b as t}from"./index-Q7BlLS9p.js";const e=t("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);export{e as R};
1
+ import{b as t}from"./index-4XPoPWhu.js";const e=t("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);export{e as R};
@@ -1 +1 @@
1
- import{r as d}from"./index-Q7BlLS9p.js";const E={"data-list-row":""},v="[data-list-row]";function m(e,r,s,i="vertical"){if(s===0)return null;const n=i==="vertical"?"ArrowDown":"ArrowRight",c=i==="vertical"?"ArrowUp":"ArrowLeft";return e===n?r<0?0:Math.min(r+1,s-1):e===c?r<=0?0:r-1:e==="Home"?0:e==="End"?s-1:null}function l(e,r){return Array.from(e.querySelectorAll(r))}function y({containerRef:e,itemSelector:r,orientation:s="vertical",enabled:i=!0}){d.useEffect(()=>{if(!i)return;const n=e.current;if(!n)return;const c=()=>{const t=l(n,r);if(t.length===0)return;const f=t.find(o=>o===document.activeElement)??t[0];for(const o of t)o.tabIndex=o===f?0:-1},u=t=>{if(t.shiftKey||t.metaKey||t.ctrlKey||t.altKey)return;const a=l(n,r),f=a.indexOf(document.activeElement),o=m(t.key,f,a.length,s);o===null||o===f||(t.preventDefault(),t.stopPropagation(),a[o]?.focus())};return c(),n.addEventListener("focusin",c),n.addEventListener("keydown",u),()=>{n.removeEventListener("focusin",c),n.removeEventListener("keydown",u)}})}export{v as L,E as a,m as r,y as u};
1
+ import{r as d}from"./index-4XPoPWhu.js";const E={"data-list-row":""},v="[data-list-row]";function m(e,r,s,i="vertical"){if(s===0)return null;const n=i==="vertical"?"ArrowDown":"ArrowRight",c=i==="vertical"?"ArrowUp":"ArrowLeft";return e===n?r<0?0:Math.min(r+1,s-1):e===c?r<=0?0:r-1:e==="Home"?0:e==="End"?s-1:null}function l(e,r){return Array.from(e.querySelectorAll(r))}function y({containerRef:e,itemSelector:r,orientation:s="vertical",enabled:i=!0}){d.useEffect(()=>{if(!i)return;const n=e.current;if(!n)return;const c=()=>{const t=l(n,r);if(t.length===0)return;const f=t.find(o=>o===document.activeElement)??t[0];for(const o of t)o.tabIndex=o===f?0:-1},u=t=>{if(t.shiftKey||t.metaKey||t.ctrlKey||t.altKey)return;const a=l(n,r),f=a.indexOf(document.activeElement),o=m(t.key,f,a.length,s);o===null||o===f||(t.preventDefault(),t.stopPropagation(),a[o]?.focus())};return c(),n.addEventListener("focusin",c),n.addEventListener("keydown",u),()=>{n.removeEventListener("focusin",c),n.removeEventListener("keydown",u)}})}export{v as L,E as a,m as r,y as u};
@@ -1 +1 @@
1
- import{r as e,j as l,B as b,q as y,L as x}from"./index-Q7BlLS9p.js";const i=()=>l.jsx(x,{className:"size-3.5 animate-spin"}),m=(s,n)=>n?l.jsx("span",{className:"sr-only",children:s}):s;function p({actions:s=[],destructive:n,className:o}){const[f,r]=e.useState(!1);return f&&n?.confirm?l.jsxs("div",{className:y("flex items-center gap-2",o),children:[l.jsx("span",{className:"text-xs text-fg-muted",children:n.confirm.prompt}),l.jsx(b,{variant:"secondary",size:"sm",onClick:()=>r(!1),children:n.confirm.cancelLabel??"Cancel"}),l.jsx(b,{variant:"danger",size:"sm","aria-busy":n.busy,icon:n.busy?i():void 0,onClick:()=>{n.busy||n.onClick()},children:n.busy?n.busyLabel??"Working…":n.confirm.confirmLabel??n.label})]}):l.jsxs("div",{className:y("flex items-center gap-2",o),children:[s.map(a=>l.jsx(b,{variant:a.variant??"ghost",size:"sm","aria-busy":a.busy,"aria-label":a.iconOnly?a.label:void 0,icon:a.busy?i():a.icon,onClick:()=>{a.busy||a.onClick()},children:a.busy&&a.busyLabel?a.busyLabel:m(a.label,a.iconOnly)},a.label)),n&&l.jsx(b,{variant:"ghost",size:"sm","aria-busy":n.busy,"aria-label":n.iconOnly?n.label:void 0,icon:n.busy?i():n.icon,onClick:()=>{if(!n.busy){if(n.confirm){r(!0);return}n.onClick()}},children:n.busy&&n.busyLabel?n.busyLabel:m(n.label,n.iconOnly)})]})}export{p as R};
1
+ import{r as e,j as l,B as b,q as y,L as x}from"./index-4XPoPWhu.js";const i=()=>l.jsx(x,{className:"size-3.5 animate-spin"}),m=(s,n)=>n?l.jsx("span",{className:"sr-only",children:s}):s;function p({actions:s=[],destructive:n,className:o}){const[f,r]=e.useState(!1);return f&&n?.confirm?l.jsxs("div",{className:y("flex items-center gap-2",o),children:[l.jsx("span",{className:"text-xs text-fg-muted",children:n.confirm.prompt}),l.jsx(b,{variant:"secondary",size:"sm",onClick:()=>r(!1),children:n.confirm.cancelLabel??"Cancel"}),l.jsx(b,{variant:"danger",size:"sm","aria-busy":n.busy,icon:n.busy?i():void 0,onClick:()=>{n.busy||n.onClick()},children:n.busy?n.busyLabel??"Working…":n.confirm.confirmLabel??n.label})]}):l.jsxs("div",{className:y("flex items-center gap-2",o),children:[s.map(a=>l.jsx(b,{variant:a.variant??"ghost",size:"sm","aria-busy":a.busy,"aria-label":a.iconOnly?a.label:void 0,icon:a.busy?i():a.icon,onClick:()=>{a.busy||a.onClick()},children:a.busy&&a.busyLabel?a.busyLabel:m(a.label,a.iconOnly)},a.label)),n&&l.jsx(b,{variant:"ghost",size:"sm","aria-busy":n.busy,"aria-label":n.iconOnly?n.label:void 0,icon:n.busy?i():n.icon,onClick:()=>{if(!n.busy){if(n.confirm){r(!0);return}n.onClick()}},children:n.busy&&n.busyLabel?n.busyLabel:m(n.label,n.iconOnly)})]})}export{p as R};
@@ -1 +1 @@
1
- import{u as v,N as x,r as I}from"./index-Q7BlLS9p.js";import{a as p,b,h as g}from"./reply-BRbg9_Ak.js";import{b as Q}from"./MailShell-B8hUSN5k.js";import{a as q}from"./useMessageBodyContent-DJ1-V3VF.js";function A(a){const t=v(),{searchInput:c,searchQuery:e}=x(),i=p({select:o=>b(o.location.search)}),u=p({select:o=>o.location.pathname}),h=q(),f=g(),m=h||f,{to:s}=a,r="params"in a?a.params.mailboxId:void 0,l=r?`/mail/${r}`:s;I.useEffect(()=>{if(!Q({searchInput:c,committedQuery:e,urlQuery:i,pathname:u,listPath:l}))return;const y=!!e&&i!==e&&!m,n=d=>({...d,q:e||void 0});if(!y){t({to:".",search:n,hash:!0,replace:!0});return}if(s==="/mail/$mailboxId"){if(!r)return;t({to:s,params:{mailboxId:r},search:n,hash:!0,replace:!0});return}t({to:s,search:n,hash:!0,replace:!0})},[c,e,i,t,s,r,l,u,m])}export{A as u};
1
+ import{u as v,N as x,r as I}from"./index-4XPoPWhu.js";import{a as p,b,h as g}from"./reply-FoVQqDdv.js";import{b as Q}from"./MailShell-C7RoeX76.js";import{a as q}from"./useMessageBodyContent-ClVl7CBj.js";function A(a){const t=v(),{searchInput:c,searchQuery:e}=x(),i=p({select:o=>b(o.location.search)}),u=p({select:o=>o.location.pathname}),h=q(),f=g(),m=h||f,{to:s}=a,r="params"in a?a.params.mailboxId:void 0,l=r?`/mail/${r}`:s;I.useEffect(()=>{if(!Q({searchInput:c,committedQuery:e,urlQuery:i,pathname:u,listPath:l}))return;const y=!!e&&i!==e&&!m,n=d=>({...d,q:e||void 0});if(!y){t({to:".",search:n,hash:!0,replace:!0});return}if(s==="/mail/$mailboxId"){if(!r)return;t({to:s,params:{mailboxId:r},search:n,hash:!0,replace:!0});return}t({to:s,search:n,hash:!0,replace:!0})},[c,e,i,t,s,r,l,u,m])}export{A as u};
@@ -1 +1 @@
1
- import{b as U,r as l,j as h,bL as _,q as E,cE as G,X as Q,cF as j,cG as J,cH as z,cI as X,cJ as W,J as x,u as N,V as Y,W as K,Z,_ as ee,N as te,cK as M}from"./index-Q7BlLS9p.js";import{g as ne,j as k,k as oe}from"./reply-BRbg9_Ak.js";import{s as se,S as re}from"./search-scope-UI1H6AzA.js";import{u as F}from"./useQueries-BNgXdYau.js";const Ie=U("BellOff",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742",key:"178tsu"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05",key:"1hqiys"}]]),ae=[{action:"focusNext",keys:["j","k"],label:"navigate"},{action:"muteSender",keys:["m"],label:"mute"},{action:"help",keys:["?"],label:"all shortcuts"}];function Ce(e){return ae.filter(t=>e[t.action]!==void 0)}const ie=[{title:"Navigation",hints:[{action:"focusNext",keys:["j"],description:"Focus the message below"},{action:"focusPrevious",keys:["k"],description:"Focus the message above"},{action:"focusNext",keys:["↓"],description:"Focus the message below"},{action:"focusPrevious",keys:["↑"],description:"Focus the message above"},{action:"focusFirst",keys:["Home"],description:"Focus first"},{action:"focusLast",keys:["End"],description:"Focus last"},{action:"openFocused",keys:["Enter"],description:"Open focused thread"},{action:"back",keys:["Esc"],description:"Back / close overlay"}]},{title:"Selection",hints:[{action:"toggleSelect",keys:["x"],description:"Toggle select"},{action:"toggleSelect",keys:["Space"],description:"Toggle select"},{action:"extendSelectDown",keys:["Shift","j"],description:"Extend selection down"},{action:"extendSelectUp",keys:["Shift","k"],description:"Extend selection up"},{action:"extendSelectDown",keys:["Shift","↓"],description:"Extend selection down"},{action:"extendSelectUp",keys:["Shift","↑"],description:"Extend selection up"},{action:"selectAll",keys:["⌘","A"],description:"Select all"}]},{title:"Actions",hints:[{action:"reply",keys:["r"],description:"Reply"},{action:"replyAll",keys:["a"],description:"Reply all"},{action:"forward",keys:["f"],description:"Forward"},{action:"delete",keys:["#"],description:"Delete"},{action:"toggleStar",keys:["s"],description:"Star / unstar"},{action:"toggleRead",keys:["u"],description:"Toggle read / unread"}]},{title:"Sender",hints:[{action:"muteSender",keys:["m"],description:"Mute sender"},{action:"blockSender",keys:["b"],description:"Block sender"},{action:"vipSender",keys:["v"],description:"VIP sender"},{action:"markJunk",keys:["!"],description:"Mark junk"}]},{title:"Go to",hints:[{action:"goBrief",keys:["g","b"],description:"Daily brief"},{action:"goInbox",keys:["g","i"],description:"Inbox"},{action:"goSent",keys:["g","s"],description:"Sent"},{action:"goFlagged",keys:["g","f"],description:"Starred"},{action:"goSettings",keys:["g",","],description:"Settings"}]},{title:"View & global",hints:[{action:"toggleIntelligence",keys:["i"],description:"Toggle intelligence"},{action:"toggleDensity",keys:["d"],description:"Toggle density"},{action:"focusSearch",keys:["/"],description:"Focus search"},{action:"compose",keys:["c"],description:"Compose"},{action:"compose",keys:["⌘","N"],description:"Compose"},{action:"help",keys:["?"],description:"Shortcut help"}]}];function ce(e){for(const t of ie){const n=t.hints.find(o=>o.action===e);if(n)return n.keys}}function le(e){const t=ce(e);return!t||t.length===0?"":t.length===1?t[0]??"":t[0]==="g"?t.join(" then "):t.join("")}function we(e){const t=le(e);return t===""?"":`(${t})`}function ue({key:e,shiftKey:t=!1,repeat:n=!1,caretAtStart:o,hasValue:i,chipCount:r}){const a=r-1;return e==="Escape"?i?{type:"clearQuery"}:{type:"blur"}:e==="Tab"&&t?r===0?{type:"none"}:{type:"focusChip",index:a}:e==="Backspace"||e==="ArrowLeft"?!o||r===0?{type:"none"}:n?{type:"none"}:{type:"focusChip",index:a}:{type:"none"}}function fe({key:e,repeat:t=!1,index:n,chipCount:o}){return e==="Backspace"||e==="Delete"?t?{type:"none"}:{type:"removeChip",index:n}:e==="ArrowLeft"?n===0?{type:"none"}:{type:"focusChip",index:n-1}:e==="ArrowRight"?n>=o-1?{type:"focusInput"}:{type:"focusChip",index:n+1}:e==="Enter"||e===" "?{type:"activateChip",index:n}:e==="Escape"?{type:"focusInput"}:{type:"none"}}function de(e,t){const n=t-1;return n<=0?null:e<n?e:n-1}const pe=e=>e instanceof HTMLElement?e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.isContentEditable:!1,me=({chips:e=[],onRemoveChip:t,value:n,onChange:o,onClear:i,onClearQuery:r,placeholder:a="Search mail...",globalFocusKey:u=!0,showClearButton:p=!0,size:m="sm",inputId:f,suggest:d,className:b})=>{const D=l.useId(),R=f??D,I=l.useRef(null),A=l.useRef([]),P=r??i,[L,C]=l.useState(null),S=l.useRef(void 0),[q,B]=l.useState(""),v=e.length>0;l.useEffect(()=>{C(s=>s!==null&&s>=e.length?null:s)},[e.length]),l.useEffect(()=>{const s=S.current;if(s!==void 0){if(S.current=void 0,s===null){I.current?.focus();return}A.current[s]?.focus()}});const $=l.useRef(void 0);l.useEffect(()=>{const s=d?.caret;if(!s||s===$.current)return;$.current=s;const c=I.current;!c||c.ownerDocument.activeElement!==c||(c.setSelectionRange(s.cursor,s.cursor),d?.onCaretChange(s.cursor))});const w=s=>{d?.onCaretChange(s.selectionStart??s.value.length)},g=l.useCallback(s=>{C(s),S.current=s},[]),T=l.useCallback(s=>{const c=e[s];c&&t&&(g(de(s,e.length)),B(`${c.label} removed`),t(c.id))},[e,t,g]),O=l.useCallback(()=>{g(null),i()},[i,g]),H=l.useCallback(s=>{const c=s.currentTarget;if(d?.onKeyDown(s))return;const y=ue({key:s.key,shiftKey:s.shiftKey,repeat:s.repeat,caretAtStart:c.selectionStart===0&&c.selectionEnd===0,hasValue:n.length>0,chipCount:e.length});switch(y.type){case"focusChip":s.preventDefault(),g(y.index);return;case"clearQuery":P();return;case"blur":c.blur();return;case"none":return}},[e.length,n,P,g,d]),V=l.useCallback(s=>c=>{const y=fe({key:c.key,repeat:c.repeat,index:s,chipCount:e.length});switch(y.type!=="none"&&c.preventDefault(),y.type){case"removeChip":T(y.index);return;case"focusChip":g(y.index);return;case"focusInput":g(null);return;case"activateChip":return;case"none":return}},[e,T,g]);return l.useEffect(()=>{if(!u)return;const s=c=>{c.key!=="/"||c.metaKey||c.ctrlKey||c.altKey||pe(c.target)||j("focusSearch")||(c.preventDefault(),I.current?.focus())};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[u]),h.jsxs("label",{htmlFor:R,className:E("flex w-full items-center gap-1.5 text-sm","bg-surface-sunken/50 border border-transparent","focus-within:bg-canvas focus-within:border-line focus-within:ring-2 focus-within:ring-ring","transition-colors",m==="lg"?"rounded-xl px-4 py-2":"rounded-md px-2.5 py-1",b),children:[h.jsx(_,{className:E("shrink-0 text-fg-muted pointer-events-none",m==="lg"?"size-5":"size-4")}),h.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1",children:[v&&h.jsx("div",{role:"grid","aria-label":"Search filters",className:"flex min-w-0 flex-wrap items-center gap-1",children:e.map((s,c)=>h.jsx(G,{ref:y=>{A.current[c]=y},label:s.label,tone:s.tone,focused:L===c,onFocusLabel:()=>C(c),onKeyDown:V(c),onRemove:()=>T(c)},s.id))}),h.jsx("input",{ref:I,id:R,name:"q",type:"text","aria-label":"Search mail",autoComplete:"off",value:n,tabIndex:L===null?0:-1,onChange:s=>{o(s.target.value),w(s.target)},onKeyDown:H,onKeyUp:s=>w(s.currentTarget),onClick:s=>w(s.currentTarget),onFocus:s=>{C(null),d?.onFocusChange?.(!0),w(s.currentTarget)},onBlur:()=>d?.onFocusChange?.(!1),...d?.comboboxProps,placeholder:v?void 0:a,className:"min-w-24 flex-1 bg-transparent text-fg outline-none placeholder:text-fg-muted"})]}),(n||v)&&p&&h.jsx("button",{type:"button",onClick:O,className:"shrink-0 rounded p-0.5 hover:bg-surface-raised transition-colors","aria-label":"Clear search",children:h.jsx(Q,{className:E("text-fg-muted",m==="lg"?"size-5":"size-4")})}),h.jsx("span",{role:"status","aria-live":"polite",className:"sr-only",children:q})]})},Se=({value:e,onChange:t,onClear:n,onClearQuery:o,chips:i,onRemoveChip:r,placeholder:a="Search mail...",globalFocusKey:u=!0,showClearButton:p=!0,size:m,inputId:f,suggest:d,className:b})=>h.jsx(me,{value:e,onChange:t,onClear:n,onClearQuery:o,chips:i,onRemoveChip:r,placeholder:a,globalFocusKey:u,showClearButton:p,size:m,inputId:f,suggest:d,className:b});function ve({handlers:e,enabled:t=!0,target:n,sequenceTimeoutMs:o=1e3}){const i=l.useRef(e);i.current=e;const r=l.useRef(null),a=l.useRef(null);l.useEffect(()=>{if(!t)return;const u=()=>{a.current!==null&&(clearTimeout(a.current),a.current=null)},p=f=>{const d=J({key:f.key,shiftKey:f.shiftKey,metaKey:f.metaKey,ctrlKey:f.ctrlKey,altKey:f.altKey,inEditable:X(f.target),onControl:z(f.target)},r.current);if(W().length>0){u(),r.current=null;return}if(u(),r.current=d.nextPrefix,d.nextPrefix!==null&&(a.current=setTimeout(()=>{r.current=null,a.current=null},o)),d.action===null||j(d.action)!==null)return;const b=i.current[d.action];b&&(d.preventDefault&&f.preventDefault(),b())},m=n===void 0?window:n;if(m!==null)return m.addEventListener("keydown",p),()=>{m.removeEventListener("keydown",p),u(),r.current=null}},[t,o,n])}function Te(){const e=x({from:"/mail/brief/$threadId",shouldThrow:!1}),t=x({from:"/mail/brief/$threadId/$messageId",shouldThrow:!1}),n=x({from:"/mail/flagged/$threadId",shouldThrow:!1}),o=x({from:"/mail/flagged/$threadId/$messageId",shouldThrow:!1}),i=x({from:"/mail/$mailboxId/$threadId",shouldThrow:!1}),r=x({from:"/mail/$mailboxId/$threadId/$messageId",shouldThrow:!1}),a=e?.threadId??n?.threadId??i?.threadId,u=t?.messageId??o?.messageId??r?.messageId;return l.useMemo(()=>a?{threadId:a,messageId:u}:void 0,[a,u])}function Ee(){const e=N(),t=ne(),{list:n,mailboxId:o}=k();return l.useCallback((i,r)=>{const a=r?.query,p={search:f=>a===void 0?f:{...f,q:a||void 0},hash:t,replace:r?.replace??!1};if(n==="flagged"){e({to:"/mail/flagged/$threadId/$messageId",params:i,...p});return}const m=r?.mailboxId??o;if(n==="mailbox"&&m){e({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:m,...i},...p});return}e({to:"/mail/brief/$threadId/$messageId",params:i,...p})},[e,t,n,o])}function Me(){return oe()}function he(){const e=N();return l.useCallback(t=>{e({to:"/mail/brief",search:{q:t||void 0}})},[e])}function Ne(){const e=N();return l.useCallback((t,n)=>{e({to:"/mail/$mailboxId",params:{mailboxId:t},search:{q:n||void 0}})},[e])}const ge=({accounts:e})=>{const{list:t,mailboxId:n}=k(),{t:o}=Y("mail",{useSuspense:!1}),i=l.useCallback((a,u)=>o(a,{defaultValue:u}),[o]),r=F({queries:e.map(a=>({...K({path:{accountId:a.accountId}}),staleTime:1/0}))});if(t==="outbox")return"Outbox";if(!n)return null;for(let a=0;a<e.length;a++){const u=r[a]?.data?.items;if(!u)continue;const p=u.find(f=>f.mailboxId===n);if(!p)continue;const m=Z(e[a].folderAppointments);return ee(p,m.get(n),i)}return null},Ke=({accounts:e})=>{const{mailboxId:t}=k(),n=F({queries:e.map(o=>({...K({path:{accountId:o.accountId}}),staleTime:1/0}))});if(!t)return null;for(const o of n){const i=o.data?.items;if(!i)continue;const r=i.find(a=>a.mailboxId===t);if(r)return r.unseenCount}return null},Fe=({accounts:e})=>{const{mailboxId:t}=k(),n=F({queries:e.map(o=>({...K({path:{accountId:o.accountId}}),staleTime:1/0}))});if(!t)return 0;for(const o of n){const i=o.data?.items;if(!i)continue;const r=i.find(a=>a.mailboxId===t);if(r)return r.messageCount}return 0};function Re(e){const t=he(),{searchInput:n}=te(),o=ge({accounts:e}),i=k(),r=l.useMemo(()=>se(i,o),[i,o]),a=l.useCallback(u=>{u===re&&t(n)},[t,n]);return{scope:r,clearScope:a}}function Ae(e){const t=new Map;for(const n of e){const o=n.email.toLowerCase(),i=o.split("@")[0];i&&!t.has(i)&&t.set(i,n.accountId),t.has(o)||t.set(o,n.accountId)}return t}function Pe(e){const t=new Map;for(const n of e)for(const o of n){const i=o.fullPath?.toLowerCase();if(!i)continue;const r=M(o).toLowerCase();t.has(i)||t.set(i,o.mailboxId),t.has(r)||t.set(r,o.mailboxId)}return t}function Le(e,t=[]){const n=e.flat().filter(r=>r.fullPath),o=new Map;for(const r of n){const a=M(r).toLowerCase();o.set(a,(o.get(a)??0)+1)}const i=new Map(t.map(r=>[r.accountId,r.email]));return n.map(r=>{const a=M(r),u=o.get(a.toLowerCase())===1,p=t.length>1?i.get(r.accountId):void 0;return{value:u?a:r.fullPath,label:r.displayNameOverride?.trim()||a,...p?{hint:p}:{}}})}function $e(e){const t=new Map;for(const n of e){const o=n.email.toLowerCase().split("@")[0]??"";t.set(o,(t.get(o)??0)+1)}return e.map(n=>{const o=n.email.split("@")[0]??n.email,i=t.get(o.toLowerCase())===1,r=n.displayName?.trim();return{value:i?o:n.email,label:r||n.email,...r?{hint:n.email}:{}}})}export{Ie as B,ie as K,Se as S,Te as a,Pe as b,ve as c,Ae as d,Ee as e,Me as f,ge as g,Ke as h,Fe as i,ae as j,Le as k,$e as l,Ne as m,Ce as n,le as s,we as t,Re as u};
1
+ import{b as U,r as l,j as h,bZ as _,q as E,cS as Q,X as G,cT as j,cU as X,cV as z,cW as J,cX as W,J as x,u as N,V as Y,W as K,Z,_ as ee,N as te,cY as M}from"./index-4XPoPWhu.js";import{g as ne,j as k,k as oe}from"./reply-FoVQqDdv.js";import{s as se,S as re}from"./search-scope-UI1H6AzA.js";import{u as R}from"./useQueries-XPiXhlQX.js";const Ie=U("BellOff",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742",key:"178tsu"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05",key:"1hqiys"}]]),ae=[{action:"focusNext",keys:["j","k"],label:"navigate"},{action:"muteSender",keys:["m"],label:"mute"},{action:"help",keys:["?"],label:"all shortcuts"}];function Ce(e){return ae.filter(t=>e[t.action]!==void 0)}const ie=[{title:"Navigation",hints:[{action:"focusNext",keys:["j"],description:"Focus the message below"},{action:"focusPrevious",keys:["k"],description:"Focus the message above"},{action:"focusNext",keys:["↓"],description:"Focus the message below"},{action:"focusPrevious",keys:["↑"],description:"Focus the message above"},{action:"focusFirst",keys:["Home"],description:"Focus first"},{action:"focusLast",keys:["End"],description:"Focus last"},{action:"openFocused",keys:["Enter"],description:"Open focused thread"},{action:"back",keys:["Esc"],description:"Back / close overlay"}]},{title:"Selection",hints:[{action:"toggleSelect",keys:["x"],description:"Toggle select"},{action:"toggleSelect",keys:["Space"],description:"Toggle select"},{action:"extendSelectDown",keys:["Shift","j"],description:"Extend selection down"},{action:"extendSelectUp",keys:["Shift","k"],description:"Extend selection up"},{action:"extendSelectDown",keys:["Shift","↓"],description:"Extend selection down"},{action:"extendSelectUp",keys:["Shift","↑"],description:"Extend selection up"},{action:"selectAll",keys:["⌘","A"],description:"Select all"}]},{title:"Actions",hints:[{action:"reply",keys:["r"],description:"Reply"},{action:"replyAll",keys:["a"],description:"Reply all"},{action:"forward",keys:["f"],description:"Forward"},{action:"delete",keys:["#"],description:"Delete"},{action:"toggleStar",keys:["s"],description:"Star / unstar"},{action:"toggleRead",keys:["u"],description:"Toggle read / unread"}]},{title:"Sender",hints:[{action:"muteSender",keys:["m"],description:"Mute sender"},{action:"blockSender",keys:["b"],description:"Block sender"},{action:"vipSender",keys:["v"],description:"VIP sender"},{action:"markJunk",keys:["!"],description:"Mark junk"}]},{title:"Go to",hints:[{action:"goBrief",keys:["g","b"],description:"Daily brief"},{action:"goInbox",keys:["g","i"],description:"Inbox"},{action:"goSent",keys:["g","s"],description:"Sent"},{action:"goFlagged",keys:["g","f"],description:"Starred"},{action:"goSettings",keys:["g",","],description:"Settings"}]},{title:"View & global",hints:[{action:"toggleIntelligence",keys:["i"],description:"Toggle intelligence"},{action:"toggleDensity",keys:["d"],description:"Toggle density"},{action:"focusSearch",keys:["/"],description:"Focus search"},{action:"compose",keys:["c"],description:"Compose"},{action:"compose",keys:["⌘","N"],description:"Compose"},{action:"help",keys:["?"],description:"Shortcut help"}]}];function ce(e){for(const t of ie){const n=t.hints.find(o=>o.action===e);if(n)return n.keys}}function le(e){const t=ce(e);return!t||t.length===0?"":t.length===1?t[0]??"":t[0]==="g"?t.join(" then "):t.join("")}function we(e){const t=le(e);return t===""?"":`(${t})`}function ue({key:e,shiftKey:t=!1,repeat:n=!1,caretAtStart:o,hasValue:i,chipCount:r}){const a=r-1;return e==="Escape"?i?{type:"clearQuery"}:{type:"blur"}:e==="Tab"&&t?r===0?{type:"none"}:{type:"focusChip",index:a}:e==="Backspace"||e==="ArrowLeft"?!o||r===0?{type:"none"}:n?{type:"none"}:{type:"focusChip",index:a}:{type:"none"}}function fe({key:e,repeat:t=!1,index:n,chipCount:o}){return e==="Backspace"||e==="Delete"?t?{type:"none"}:{type:"removeChip",index:n}:e==="ArrowLeft"?n===0?{type:"none"}:{type:"focusChip",index:n-1}:e==="ArrowRight"?n>=o-1?{type:"focusInput"}:{type:"focusChip",index:n+1}:e==="Enter"||e===" "?{type:"activateChip",index:n}:e==="Escape"?{type:"focusInput"}:{type:"none"}}function de(e,t){const n=t-1;return n<=0?null:e<n?e:n-1}const pe=e=>e instanceof HTMLElement?e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.isContentEditable:!1,me=({chips:e=[],onRemoveChip:t,value:n,onChange:o,onClear:i,onClearQuery:r,placeholder:a="Search mail...",globalFocusKey:u=!0,showClearButton:p=!0,size:m="sm",inputId:f,suggest:d,className:b})=>{const D=l.useId(),F=f??D,I=l.useRef(null),A=l.useRef([]),P=r??i,[$,C]=l.useState(null),S=l.useRef(void 0),[q,B]=l.useState(""),v=e.length>0;l.useEffect(()=>{C(s=>s!==null&&s>=e.length?null:s)},[e.length]),l.useEffect(()=>{const s=S.current;if(s!==void 0){if(S.current=void 0,s===null){I.current?.focus();return}A.current[s]?.focus()}});const L=l.useRef(void 0);l.useEffect(()=>{const s=d?.caret;if(!s||s===L.current)return;L.current=s;const c=I.current;!c||c.ownerDocument.activeElement!==c||(c.setSelectionRange(s.cursor,s.cursor),d?.onCaretChange(s.cursor))});const w=s=>{d?.onCaretChange(s.selectionStart??s.value.length)},g=l.useCallback(s=>{C(s),S.current=s},[]),T=l.useCallback(s=>{const c=e[s];c&&t&&(g(de(s,e.length)),B(`${c.label} removed`),t(c.id))},[e,t,g]),O=l.useCallback(()=>{g(null),i()},[i,g]),H=l.useCallback(s=>{const c=s.currentTarget;if(d?.onKeyDown(s))return;const y=ue({key:s.key,shiftKey:s.shiftKey,repeat:s.repeat,caretAtStart:c.selectionStart===0&&c.selectionEnd===0,hasValue:n.length>0,chipCount:e.length});switch(y.type){case"focusChip":s.preventDefault(),g(y.index);return;case"clearQuery":P();return;case"blur":c.blur();return;case"none":return}},[e.length,n,P,g,d]),V=l.useCallback(s=>c=>{const y=fe({key:c.key,repeat:c.repeat,index:s,chipCount:e.length});switch(y.type!=="none"&&c.preventDefault(),y.type){case"removeChip":T(y.index);return;case"focusChip":g(y.index);return;case"focusInput":g(null);return;case"activateChip":return;case"none":return}},[e,T,g]);return l.useEffect(()=>{if(!u)return;const s=c=>{c.key!=="/"||c.metaKey||c.ctrlKey||c.altKey||pe(c.target)||j("focusSearch")||(c.preventDefault(),I.current?.focus())};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[u]),h.jsxs("label",{htmlFor:F,className:E("flex w-full items-center gap-1.5 text-sm","bg-surface-sunken/50 border border-transparent","focus-within:bg-canvas focus-within:border-line focus-within:ring-2 focus-within:ring-ring","transition-colors",m==="lg"?"rounded-xl px-4 py-2":"rounded-md px-2.5 py-1",b),children:[h.jsx(_,{className:E("shrink-0 text-fg-muted pointer-events-none",m==="lg"?"size-5":"size-4")}),h.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1",children:[v&&h.jsx("div",{role:"grid","aria-label":"Search filters",className:"flex min-w-0 flex-wrap items-center gap-1",children:e.map((s,c)=>h.jsx(Q,{ref:y=>{A.current[c]=y},label:s.label,tone:s.tone,focused:$===c,onFocusLabel:()=>C(c),onKeyDown:V(c),onRemove:()=>T(c)},s.id))}),h.jsx("input",{ref:I,id:F,name:"q",type:"text","aria-label":"Search mail",autoComplete:"off",value:n,tabIndex:$===null?0:-1,onChange:s=>{o(s.target.value),w(s.target)},onKeyDown:H,onKeyUp:s=>w(s.currentTarget),onClick:s=>w(s.currentTarget),onFocus:s=>{C(null),d?.onFocusChange?.(!0),w(s.currentTarget)},onBlur:()=>d?.onFocusChange?.(!1),...d?.comboboxProps,placeholder:v?void 0:a,className:"min-w-24 flex-1 bg-transparent text-fg outline-none placeholder:text-fg-muted"})]}),(n||v)&&p&&h.jsx("button",{type:"button",onClick:O,className:"shrink-0 rounded p-0.5 hover:bg-surface-raised transition-colors","aria-label":"Clear search",children:h.jsx(G,{className:E("text-fg-muted",m==="lg"?"size-5":"size-4")})}),h.jsx("span",{role:"status","aria-live":"polite",className:"sr-only",children:q})]})},Se=({value:e,onChange:t,onClear:n,onClearQuery:o,chips:i,onRemoveChip:r,placeholder:a="Search mail...",globalFocusKey:u=!0,showClearButton:p=!0,size:m,inputId:f,suggest:d,className:b})=>h.jsx(me,{value:e,onChange:t,onClear:n,onClearQuery:o,chips:i,onRemoveChip:r,placeholder:a,globalFocusKey:u,showClearButton:p,size:m,inputId:f,suggest:d,className:b});function ve({handlers:e,enabled:t=!0,target:n,sequenceTimeoutMs:o=1e3}){const i=l.useRef(e);i.current=e;const r=l.useRef(null),a=l.useRef(null);l.useEffect(()=>{if(!t)return;const u=()=>{a.current!==null&&(clearTimeout(a.current),a.current=null)},p=f=>{const d=X({key:f.key,shiftKey:f.shiftKey,metaKey:f.metaKey,ctrlKey:f.ctrlKey,altKey:f.altKey,inEditable:J(f.target),onControl:z(f.target)},r.current);if(W().length>0){u(),r.current=null;return}if(u(),r.current=d.nextPrefix,d.nextPrefix!==null&&(a.current=setTimeout(()=>{r.current=null,a.current=null},o)),d.action===null||j(d.action)!==null)return;const b=i.current[d.action];b&&(d.preventDefault&&f.preventDefault(),b())},m=n===void 0?window:n;if(m!==null)return m.addEventListener("keydown",p),()=>{m.removeEventListener("keydown",p),u(),r.current=null}},[t,o,n])}function Te(){const e=x({from:"/mail/brief/$threadId",shouldThrow:!1}),t=x({from:"/mail/brief/$threadId/$messageId",shouldThrow:!1}),n=x({from:"/mail/flagged/$threadId",shouldThrow:!1}),o=x({from:"/mail/flagged/$threadId/$messageId",shouldThrow:!1}),i=x({from:"/mail/$mailboxId/$threadId",shouldThrow:!1}),r=x({from:"/mail/$mailboxId/$threadId/$messageId",shouldThrow:!1}),a=e?.threadId??n?.threadId??i?.threadId,u=t?.messageId??o?.messageId??r?.messageId;return l.useMemo(()=>a?{threadId:a,messageId:u}:void 0,[a,u])}function Ee(){const e=N(),t=ne(),{list:n,mailboxId:o}=k();return l.useCallback((i,r)=>{const a=r?.query,p={search:f=>a===void 0?f:{...f,q:a||void 0},hash:t,replace:r?.replace??!1};if(n==="flagged"){e({to:"/mail/flagged/$threadId/$messageId",params:i,...p});return}const m=r?.mailboxId??o;if(n==="mailbox"&&m){e({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:m,...i},...p});return}e({to:"/mail/brief/$threadId/$messageId",params:i,...p})},[e,t,n,o])}function Me(){return oe()}function he(){const e=N();return l.useCallback(t=>{e({to:"/mail/brief",search:{q:t||void 0}})},[e])}function Ne(){const e=N();return l.useCallback((t,n)=>{e({to:"/mail/$mailboxId",params:{mailboxId:t},search:{q:n||void 0}})},[e])}const ge=({accounts:e})=>{const{list:t,mailboxId:n}=k(),{t:o}=Y("mail",{useSuspense:!1}),i=l.useCallback((a,u)=>o(a,{defaultValue:u}),[o]),r=R({queries:e.map(a=>({...K({path:{accountId:a.accountId}}),staleTime:1/0}))});if(t==="outbox")return"Outbox";if(!n)return null;for(let a=0;a<e.length;a++){const u=r[a]?.data?.items;if(!u)continue;const p=u.find(f=>f.mailboxId===n);if(!p)continue;const m=Z(e[a].folderAppointments);return ee(p,m.get(n),i)}return null},Ke=({accounts:e})=>{const{mailboxId:t}=k(),n=R({queries:e.map(o=>({...K({path:{accountId:o.accountId}}),staleTime:1/0}))});if(!t)return null;for(const o of n){const i=o.data?.items;if(!i)continue;const r=i.find(a=>a.mailboxId===t);if(r)return r.unseenCount}return null},Re=({accounts:e})=>{const{mailboxId:t}=k(),n=R({queries:e.map(o=>({...K({path:{accountId:o.accountId}}),staleTime:1/0}))});if(!t)return 0;for(const o of n){const i=o.data?.items;if(!i)continue;const r=i.find(a=>a.mailboxId===t);if(r)return r.messageCount}return 0};function Fe(e){const t=he(),{searchInput:n}=te(),o=ge({accounts:e}),i=k(),r=l.useMemo(()=>se(i,o),[i,o]),a=l.useCallback(u=>{u===re&&t(n)},[t,n]);return{scope:r,clearScope:a}}function Ae(e){const t=new Map;for(const n of e){const o=n.email.toLowerCase(),i=o.split("@")[0];i&&!t.has(i)&&t.set(i,n.accountId),t.has(o)||t.set(o,n.accountId)}return t}function Pe(e){const t=new Map;for(const n of e)for(const o of n){const i=o.fullPath?.toLowerCase();if(!i)continue;const r=M(o).toLowerCase();t.has(i)||t.set(i,o.mailboxId),t.has(r)||t.set(r,o.mailboxId)}return t}function $e(e,t=[]){const n=e.flat().filter(r=>r.fullPath),o=new Map;for(const r of n){const a=M(r).toLowerCase();o.set(a,(o.get(a)??0)+1)}const i=new Map(t.map(r=>[r.accountId,r.email]));return n.map(r=>{const a=M(r),u=o.get(a.toLowerCase())===1,p=t.length>1?i.get(r.accountId):void 0;return{value:u?a:r.fullPath,label:r.displayNameOverride?.trim()||a,...p?{hint:p}:{}}})}function Le(e){const t=new Map;for(const n of e){const o=n.email.toLowerCase().split("@")[0]??"";t.set(o,(t.get(o)??0)+1)}return e.map(n=>{const o=n.email.split("@")[0]??n.email,i=t.get(o.toLowerCase())===1,r=n.displayName?.trim();return{value:i?o:n.email,label:r||n.email,...r?{hint:n.email}:{}}})}export{Ie as B,ie as K,Se as S,Te as a,Pe as b,ve as c,Ae as d,Ee as e,Me as f,ge as g,Ke as h,Re as i,ae as j,$e as k,Le as l,Ne as m,Ce as n,le as s,we as t,Fe as u};
@@ -1 +1 @@
1
- import{u as e,r as s}from"./index-Q7BlLS9p.js";const a={brief:"/mail/brief",flagged:"/mail/flagged",outbox:"/mail/outbox",settings:"/settings",accounts:"/settings/accounts",importConfig:"/import"};function c(){const t=e();return s.useCallback(o=>{t({to:a[o]})},[t])}function i(){const t=e();return s.useCallback(o=>{t({to:"/settings/accounts",search:{editAccountId:o,focusSmtp:!0}})},[t])}export{i as a,c as u};
1
+ import{u as e,r as s}from"./index-4XPoPWhu.js";const a={brief:"/mail/brief",flagged:"/mail/flagged",outbox:"/mail/outbox",settings:"/settings",accounts:"/settings/accounts",importConfig:"/import"};function c(){const t=e();return s.useCallback(o=>{t({to:a[o]})},[t])}function i(){const t=e();return s.useCallback(o=>{t({to:"/settings/accounts",search:{editAccountId:o,focusSmtp:!0}})},[t])}export{i as a,c as u};
@@ -0,0 +1 @@
1
+ import{j as e,q as S,f as I,r as c,bW as $,a as C,g as k,bX as P,bY as A,B as w,X as L,u as O,aK as q,av as R,bZ as D,aN as K,b_ as M,b$ as Q,S as T}from"./index-4XPoPWhu.js";import{E}from"./ErrorState-DcP5ZTMN.js";import{K as y}from"./kbd-D0eWE7Kp.js";import{a as V,S as B}from"./settings-screen-ZYutaKzZ.js";import{u as G}from"./useDebouncedValue-B0BMCu3v.js";import{s as F}from"./help-copy-CQIBCXJf.js";import"./avatar-B4KRzyzS.js";import"./menu-D06KWsdQ.js";import"./circle-help-Cyj92MDS.js";function _({options:t,active:m,onSelect:r}){return e.jsx("div",{role:"tablist",className:S("flex shrink-0 gap-1 overflow-x-auto border-b border-line p-2","lg:w-44 lg:flex-col lg:gap-0 lg:overflow-visible lg:border-r lg:border-b-0 lg:py-2 lg:pr-2 lg:pl-3"),children:t.map(i=>{const l=i.id===m;return e.jsxs("button",{type:"button",role:"tab","aria-selected":l,onClick:()=>r(i.id),className:S("flex min-h-11 shrink-0 items-center gap-2 rounded-md px-3 text-left text-sm transition-colors lg:min-h-0 lg:px-2 lg:py-1",l?"bg-accent-2-soft font-medium text-accent-2":"text-fg-muted hover:bg-surface-sunken hover:text-fg"),children:[e.jsx("span",{className:"flex-1 truncate",children:i.label}),e.jsx("span",{className:S("text-2xs tabular-nums",l?"text-accent-2":"text-fg-subtle"),children:i.count??"—"})]},i.id)})})}const j={vip:"VIPs",muted:"Muted",blocked:"Blocked"};function H({query:t,onCount:m}){const{data:r,isPending:i,isError:l,error:f}=C(M()),b=I(),d=k({...P(),onSettled:()=>{b.invalidateQueries({queryKey:Q()})}}),o=r?.suggestions??[],p=t.trim().toLowerCase(),u=p?o.filter(a=>(a.displayName??"").toLowerCase().includes(p)||a.normalizedEmail.toLowerCase().includes(p)):o;return c.useEffect(()=>{m?.(u.length,o.length)},[m,u.length,o.length]),i?e.jsx("div",{className:"px-row-inset py-3 text-sm text-fg-subtle animate-pulse",children:"Loading VIP suggestions…"}):l?e.jsx("div",{className:"px-row-inset py-3",children:e.jsx(E,{variant:"inline",title:"Couldn't load VIP suggestions",error:f})}):o.length===0?e.jsxs("div",{className:"px-row-inset py-5 text-sm text-fg-subtle",children:["No VIP suggestions yet. As you reply to senders, they'll appear here. Press ",e.jsx(y,{children:"v"})," on any message to promote a sender to VIP."]}):u.length===0?e.jsxs("p",{className:"px-row-inset py-5 text-sm text-fg-subtle",children:["No VIPs match “",t,"”."]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-row-inset py-1 text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Suggested — promote to VIP"}),u.map(a=>e.jsx(V,{name:a.displayName??a.normalizedEmail,email:a.normalizedEmail,meta:a.replyCount>0?`${a.inboundCount} received · you replied ${a.replyCount}×`:`${a.inboundCount} received · you've never replied`,trailing:e.jsx(w,{variant:"ghost",size:"sm",icon:e.jsx(T,{className:"size-3.5"}),"aria-busy":d.isPending,onClick:()=>{d.isPending||d.mutate({path:{addressId:a.addressId},body:{flags:{vip:{value:!0,setAt:Date.now(),setBy:"user"}}}})},children:"Add VIP"})},a.addressId))]})}function X({group:t,query:m,onCount:r}){const i=G(m.trim(),300),l=I(),[f,b]=c.useState(null),d=i.length>=2,o=$({query:{q:i,limit:50}}),{data:p,isPending:u,isError:a,error:N}=C({...o,enabled:d}),x=k({...P(),onSuccess:()=>{l.invalidateQueries({queryKey:o.queryKey})}}),g=(p?.items??[]).filter(n=>t==="muted"?n.flags?.muted?.value??!1:n.flags?.blocked?.value??!1);return c.useEffect(()=>{r?.(d?g.length:0,null)},[r,d,g.length]),d?u?e.jsx("div",{className:"px-row-inset py-3 text-sm text-fg-subtle animate-pulse",children:"Searching…"}):a?e.jsx("div",{className:"px-row-inset py-3",children:e.jsx(E,{variant:"inline",title:"Search failed",error:N})}):g.length===0?e.jsxs("p",{className:"px-row-inset py-5 text-sm text-fg-subtle",children:["No ",j[t].toLowerCase()," senders matching “",i,"”."]}):e.jsx(e.Fragment,{children:g.map(n=>{const s=t==="muted"?n.flags?.muted:n.flags?.blocked,h=s?[`${t}`,s.setAt&&A(s.setAt,{month:"short",year:"numeric"})||null,s.reason?`— ${s.reason}`:null].filter(Boolean).join(" "):t,v=x.isPending&&x.variables?.path.addressId===n.addressId,z=x.isError&&f===n.addressId;return e.jsx(V,{name:n.displayName??n.normalizedEmail,email:n.normalizedEmail,danger:t==="blocked",meta:h,trailing:z?e.jsx(w,{variant:"secondary",size:"sm",onClick:()=>{b(n.addressId),x.mutate({path:{addressId:n.addressId},body:{flags:{[t]:{value:!1,setAt:Date.now()}}}})},children:"Retry"}):e.jsx(w,{variant:"ghost",size:"sm",icon:e.jsx(L,{className:"size-3.5"}),"aria-busy":v,"aria-label":`Remove ${t} flag`,onClick:()=>{v||(b(n.addressId),x.mutate({path:{addressId:n.addressId},body:{flags:{[t]:{value:!1,setAt:Date.now()}}}}))}})},n.addressId)})}):e.jsxs("div",{className:"px-row-inset py-5 text-sm text-fg-subtle space-y-2",children:[e.jsxs("p",{children:["Type 2+ characters to search ",j[t].toLowerCase()," ","senders by name or address."]}),e.jsxs("p",{className:"text-2xs text-fg-subtle",children:["Note: a dedicated flagged-address list endpoint is in the backlog. Press ",e.jsx(y,{children:"m"})," on any message to mute its sender; ",e.jsx(y,{children:"b"})," to block."]})]})}function ne(){const t=O(),m=q(),[r,i]=c.useState("vip"),[l,f]=c.useState(""),[b,d]=c.useState(!0),[o,p]=c.useState(0),[u,a]=c.useState({vip:0,muted:null,blocked:null}),N=c.useCallback((s,h)=>{p(s),a(v=>({...v,vip:h}))},[]),x=c.useCallback((s,h)=>{p(s),a(v=>({...v,[r]:s}))},[r]),g=u[r],n=s=>{const h=K[s];h&&t({to:h})};return e.jsx(B,{items:m,activeId:"senders",title:"Senders & Rules",description:"Per-sender preferences — set with one key from any message, managed here.",flush:!0,help:F,helpOpen:b,onToggleHelp:()=>d(s=>!s),onSelect:n,onBackToMail:()=>{t({to:"/mail"})},children:e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col lg:flex-row",children:[e.jsx(_,{active:r,onSelect:s=>{i(s),f("")},options:["vip","muted","blocked"].map(s=>({id:s,label:j[s],count:u[s]}))}),e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[e.jsx("div",{className:"border-b border-line px-row-inset py-2",children:e.jsx(R,{icon:e.jsx(D,{className:"size-4"}),placeholder:`Filter ${j[r].toLowerCase()} by name or address`,className:"h-8 max-w-sm",value:l,onChange:s=>f(s.target.value)})}),e.jsx("div",{className:"min-h-0 flex-1 divide-y divide-line overflow-y-auto",children:r==="vip"?e.jsx(H,{query:l,onCount:N}):e.jsx(X,{group:r,query:l,onCount:x})}),e.jsxs("footer",{className:"flex items-center justify-between border-t border-line px-row-inset py-1 text-2xs text-fg-subtle",children:[e.jsx("span",{children:g!=null?`${o} of ${g} flagged senders`:`${o} flagged senders`}),e.jsxs("span",{children:[e.jsx(y,{children:"j"})," ",e.jsx(y,{children:"k"})," navigate · ",e.jsx(y,{children:"⌫"})," remove flag"]})]})]})]})})}export{X as SearchGroupPane,ne as component};
@@ -0,0 +1 @@
1
+ import{j as t,O as o}from"./index-4XPoPWhu.js";const n=()=>t.jsx(o,{});export{n as component};
@@ -1 +1 @@
1
- import{r as j,j as e,q as f,bS as h,B as i,X as N,e as C}from"./index-Q7BlLS9p.js";import{A as w}from"./avatar-_Iz-lpCN.js";import{M as S}from"./menu-BzT426Ih.js";import{C as v}from"./circle-help-BT_Dohsy.js";function F({items:l,activeId:t,title:x,description:n,children:r,help:s,helpOpen:d=!0,flush:o,onSelect:k,onToggleHelp:u,onBackToMail:m}){const[y,c]=j.useState(!1),[b,z]=j.useState(!1),p=!!s&&d,g=e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 pt-3 pb-1 text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Settings"}),e.jsx("nav",{className:"flex-1 overflow-y-auto px-2 py-1",children:l.map(a=>e.jsxs("button",{type:"button",onClick:()=>{k?.(a.id),c(!1)},className:f("flex min-h-11 w-full items-center gap-2 rounded-md px-2 py-1 text-left text-sm transition-colors lg:min-h-0",a.id===t?"bg-accent-2-soft font-medium text-accent-2":"text-fg-muted hover:bg-surface hover:text-fg"),children:[a.icon&&e.jsx("span",{className:f("shrink-0",a.id===t?"text-accent-2":"text-fg-subtle"),children:a.icon}),a.label]},a.id))})]});return e.jsxs("div",{className:"safe-area-frame flex h-dvh w-full overflow-hidden bg-canvas font-sans text-fg",children:[e.jsxs("aside",{className:"hidden w-60 shrink-0 flex-col border-r border-line bg-surface-sunken lg:flex",children:[e.jsx("div",{className:"flex h-pane-header shrink-0 items-center border-b border-line px-2",children:e.jsxs("button",{type:"button",onClick:m,className:"flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-sm text-fg-muted hover:bg-surface hover:text-fg",children:[e.jsx(h,{className:"size-4 text-fg-subtle"}),"Back to mail"]})}),g]}),y&&e.jsxs("div",{className:"fixed inset-0 z-50 flex lg:hidden",children:[e.jsx("button",{type:"button","aria-label":"Close menu",className:"absolute inset-0 bg-canvas/60",onClick:()=>c(!1)}),e.jsxs("aside",{className:"safe-area-frame relative flex w-72 max-w-[85%] flex-col border-r border-line bg-surface-sunken",children:[e.jsxs("div",{className:"flex h-pane-header shrink-0 items-center justify-between border-b border-line px-2",children:[e.jsxs("button",{type:"button",onClick:()=>{m?.(),c(!1)},className:"flex items-center gap-2 rounded-md px-2 py-1 text-left text-sm text-fg-muted hover:bg-surface hover:text-fg",children:[e.jsx(h,{className:"size-4 text-fg-subtle"}),"Back to mail"]}),e.jsx(i,{variant:"ghost",size:"sm",icon:e.jsx(N,{className:"size-4"}),onClick:()=>c(!1),"aria-label":"Close menu"})]}),g]})]}),e.jsxs("main",{className:"flex min-w-0 flex-1 flex-col",children:[e.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-3 border-b border-line px-3 lg:px-5",children:[m&&e.jsx(i,{variant:"ghost",size:"sm",icon:e.jsx(h,{className:"size-4"}),className:"-ml-1 lg:hidden",onClick:m,"aria-label":"Back to mail"}),e.jsx(i,{variant:"ghost",size:"sm",icon:e.jsx(S,{className:"size-4"}),className:"lg:hidden",onClick:()=>c(!0),"aria-label":"Open settings menu"}),e.jsx("h1",{className:"text-md font-semibold text-fg",children:x}),n&&e.jsx("p",{className:"hidden min-w-0 truncate text-xs text-fg-subtle lg:block",children:n}),s&&e.jsx(i,{variant:"ghost",size:"sm",icon:e.jsx(v,{className:"size-4"}),className:"ml-auto lg:hidden",onClick:()=>z(a=>!a),"aria-label":"Tips","aria-expanded":b}),s&&!p&&e.jsx(i,{variant:"ghost",size:"sm",icon:e.jsx(v,{className:"size-4"}),className:"hidden ml-auto lg:inline-flex",onClick:u,"aria-label":"Show tips"})]}),s&&b&&e.jsx("div",{className:"border-b border-line bg-surface-sunken px-row-inset py-3 text-xs leading-relaxed text-fg-muted lg:hidden",children:s}),o?e.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:r}):e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:e.jsx("div",{className:"max-w-2xl px-3 py-5 lg:px-5",children:e.jsx("div",{className:"space-y-5",children:r})})})]}),p&&e.jsxs("aside",{className:"hidden w-64 shrink-0 flex-col border-l border-line bg-surface-sunken lg:flex",children:[e.jsxs("header",{className:"flex h-pane-header shrink-0 items-center justify-between border-b border-line px-row-inset",children:[e.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Tips & tricks"}),e.jsx(i,{variant:"ghost",size:"sm",icon:e.jsx(N,{className:"size-3.5"}),onClick:u,"aria-label":"Collapse tips"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-row-inset py-3 text-xs leading-relaxed text-fg-muted",children:s})]})]})}function R({name:l,email:t,meta:x,caption:n,danger:r,trailing:s}){return e.jsxs("div",{className:"flex items-center gap-3 px-row-inset py-2 hover:bg-surface-sunken",children:[e.jsx("span",{className:f(r&&"rounded-full ring-2 ring-danger/40"),children:e.jsx(w,{name:l,email:t,size:"sm"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-col gap-0 sm:flex-row sm:items-baseline sm:gap-2",children:[e.jsx("span",{className:"truncate text-sm font-medium text-fg",children:l}),e.jsx("span",{className:"truncate text-2xs text-fg-subtle",children:t})]}),e.jsxs("div",{className:"text-xs text-fg-subtle",children:[x,n&&e.jsxs("span",{className:"text-fg-muted",children:[" · ",n]})]})]}),s&&e.jsx("div",{className:"shrink-0",children:s})]})}const B={healthy:{tone:"positive",label:"healthy"},error:{tone:"danger",label:"error"},muted:{tone:"neutral",label:"muted"}};function q({label:l,email:t,connector:x,syncLabel:n,state:r,errorDetail:s,trailing:d}){const o=B[r];return e.jsxs("div",{className:f("rounded-sm border border-line bg-surface",r==="muted"&&"opacity-65"),children:[e.jsxs("div",{className:"flex flex-col gap-3 px-row-inset py-3 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx(w,{name:l,email:t,size:"md"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-semibold text-fg",children:l}),e.jsx(C,{tone:o.tone,dot:!0,children:o.label})]}),e.jsxs("div",{className:"truncate text-xs text-fg-subtle",children:[t," · ",x," · ",n]})]})]}),d&&e.jsx("div",{className:"shrink-0",children:d})]}),s&&e.jsx("div",{className:"border-t border-line px-row-inset py-2",children:e.jsx("code",{className:"block rounded-xs bg-danger-soft px-2 py-1 text-2xs text-danger",children:s})})]})}export{q as A,F as S,R as a};
1
+ import{r as j,j as e,q as f,c4 as h,B as i,X as N,e as C}from"./index-4XPoPWhu.js";import{A as w}from"./avatar-B4KRzyzS.js";import{M as S}from"./menu-D06KWsdQ.js";import{C as v}from"./circle-help-Cyj92MDS.js";function F({items:l,activeId:t,title:x,description:n,children:r,help:s,helpOpen:d=!0,flush:o,onSelect:k,onToggleHelp:u,onBackToMail:m}){const[y,c]=j.useState(!1),[b,z]=j.useState(!1),p=!!s&&d,g=e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 pt-3 pb-1 text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Settings"}),e.jsx("nav",{className:"flex-1 overflow-y-auto px-2 py-1",children:l.map(a=>e.jsxs("button",{type:"button",onClick:()=>{k?.(a.id),c(!1)},className:f("flex min-h-11 w-full items-center gap-2 rounded-md px-2 py-1 text-left text-sm transition-colors lg:min-h-0",a.id===t?"bg-accent-2-soft font-medium text-accent-2":"text-fg-muted hover:bg-surface hover:text-fg"),children:[a.icon&&e.jsx("span",{className:f("shrink-0",a.id===t?"text-accent-2":"text-fg-subtle"),children:a.icon}),a.label]},a.id))})]});return e.jsxs("div",{className:"safe-area-frame flex h-dvh w-full overflow-hidden bg-canvas font-sans text-fg",children:[e.jsxs("aside",{className:"hidden w-60 shrink-0 flex-col border-r border-line bg-surface-sunken lg:flex",children:[e.jsx("div",{className:"flex h-pane-header shrink-0 items-center border-b border-line px-2",children:e.jsxs("button",{type:"button",onClick:m,className:"flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-sm text-fg-muted hover:bg-surface hover:text-fg",children:[e.jsx(h,{className:"size-4 text-fg-subtle"}),"Back to mail"]})}),g]}),y&&e.jsxs("div",{className:"fixed inset-0 z-50 flex lg:hidden",children:[e.jsx("button",{type:"button","aria-label":"Close menu",className:"absolute inset-0 bg-canvas/60",onClick:()=>c(!1)}),e.jsxs("aside",{className:"safe-area-frame relative flex w-72 max-w-[85%] flex-col border-r border-line bg-surface-sunken",children:[e.jsxs("div",{className:"flex h-pane-header shrink-0 items-center justify-between border-b border-line px-2",children:[e.jsxs("button",{type:"button",onClick:()=>{m?.(),c(!1)},className:"flex items-center gap-2 rounded-md px-2 py-1 text-left text-sm text-fg-muted hover:bg-surface hover:text-fg",children:[e.jsx(h,{className:"size-4 text-fg-subtle"}),"Back to mail"]}),e.jsx(i,{variant:"ghost",size:"sm",icon:e.jsx(N,{className:"size-4"}),onClick:()=>c(!1),"aria-label":"Close menu"})]}),g]})]}),e.jsxs("main",{className:"flex min-w-0 flex-1 flex-col",children:[e.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-3 border-b border-line px-3 lg:px-5",children:[m&&e.jsx(i,{variant:"ghost",size:"sm",icon:e.jsx(h,{className:"size-4"}),className:"-ml-1 lg:hidden",onClick:m,"aria-label":"Back to mail"}),e.jsx(i,{variant:"ghost",size:"sm",icon:e.jsx(S,{className:"size-4"}),className:"lg:hidden",onClick:()=>c(!0),"aria-label":"Open settings menu"}),e.jsx("h1",{className:"text-md font-semibold text-fg",children:x}),n&&e.jsx("p",{className:"hidden min-w-0 truncate text-xs text-fg-subtle lg:block",children:n}),s&&e.jsx(i,{variant:"ghost",size:"sm",icon:e.jsx(v,{className:"size-4"}),className:"ml-auto lg:hidden",onClick:()=>z(a=>!a),"aria-label":"Tips","aria-expanded":b}),s&&!p&&e.jsx(i,{variant:"ghost",size:"sm",icon:e.jsx(v,{className:"size-4"}),className:"hidden ml-auto lg:inline-flex",onClick:u,"aria-label":"Show tips"})]}),s&&b&&e.jsx("div",{className:"border-b border-line bg-surface-sunken px-row-inset py-3 text-xs leading-relaxed text-fg-muted lg:hidden",children:s}),o?e.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:r}):e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:e.jsx("div",{className:"max-w-2xl px-3 py-5 lg:px-5",children:e.jsx("div",{className:"space-y-5",children:r})})})]}),p&&e.jsxs("aside",{className:"hidden w-64 shrink-0 flex-col border-l border-line bg-surface-sunken lg:flex",children:[e.jsxs("header",{className:"flex h-pane-header shrink-0 items-center justify-between border-b border-line px-row-inset",children:[e.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Tips & tricks"}),e.jsx(i,{variant:"ghost",size:"sm",icon:e.jsx(N,{className:"size-3.5"}),onClick:u,"aria-label":"Collapse tips"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-row-inset py-3 text-xs leading-relaxed text-fg-muted",children:s})]})]})}function R({name:l,email:t,meta:x,caption:n,danger:r,trailing:s}){return e.jsxs("div",{className:"flex items-center gap-3 px-row-inset py-2 hover:bg-surface-sunken",children:[e.jsx("span",{className:f(r&&"rounded-full ring-2 ring-danger/40"),children:e.jsx(w,{name:l,email:t,size:"sm"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-col gap-0 sm:flex-row sm:items-baseline sm:gap-2",children:[e.jsx("span",{className:"truncate text-sm font-medium text-fg",children:l}),e.jsx("span",{className:"truncate text-2xs text-fg-subtle",children:t})]}),e.jsxs("div",{className:"text-xs text-fg-subtle",children:[x,n&&e.jsxs("span",{className:"text-fg-muted",children:[" · ",n]})]})]}),s&&e.jsx("div",{className:"shrink-0",children:s})]})}const B={healthy:{tone:"positive",label:"healthy"},error:{tone:"danger",label:"error"},muted:{tone:"neutral",label:"muted"}};function q({label:l,email:t,connector:x,syncLabel:n,state:r,errorDetail:s,trailing:d}){const o=B[r];return e.jsxs("div",{className:f("rounded-sm border border-line bg-surface",r==="muted"&&"opacity-65"),children:[e.jsxs("div",{className:"flex flex-col gap-3 px-row-inset py-3 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx(w,{name:l,email:t,size:"md"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-semibold text-fg",children:l}),e.jsx(C,{tone:o.tone,dot:!0,children:o.label})]}),e.jsxs("div",{className:"truncate text-xs text-fg-subtle",children:[t," · ",x," · ",n]})]})]}),d&&e.jsx("div",{className:"shrink-0",children:d})]}),s&&e.jsx("div",{className:"border-t border-line px-row-inset py-2",children:e.jsx("code",{className:"block rounded-xs bg-danger-soft px-2 py-1 text-2xs text-danger",children:s})})]})}export{q as A,F as S,R as a};
@@ -0,0 +1 @@
1
+ import{b as e}from"./index-4XPoPWhu.js";const c=e("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);export{c as S};
@@ -1 +1 @@
1
- import{b as a}from"./index-Q7BlLS9p.js";const p=a("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);export{p as S};
1
+ import{b as a}from"./index-4XPoPWhu.js";const p=a("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);export{p as S};
@@ -1 +1 @@
1
- import{j as t,ae as e}from"./index-Q7BlLS9p.js";const o=()=>t.jsx(e,{to:"/settings/senders",replace:!0});export{o as component};
1
+ import{j as t,ae as e}from"./index-4XPoPWhu.js";const o=()=>t.jsx(e,{to:"/settings/senders",replace:!0});export{o as component};
@@ -1 +1 @@
1
- import{j as i,X as Z,q as O,f7 as R,fc as $,fa as v,r as u,ck as E,fS as F}from"./index-Q7BlLS9p.js";import{E as L,C as W}from"./EmptyState-DaDveift.js";import{C as z}from"./calendar-event-sidebar-Dy-5E4fW.js";import{C as B}from"./calendar-failure-note-DGOwCvAu.js";import{b as S,m as H,e as h,n as U,t as _,U as j,x as P,k,j as M,o as V}from"./useCalendarSuggestions-DHNLR9_9.js";import{e as w,p as q,a as G}from"./draft-BeV5oY-T.js";import{f as X}from"./calendar-format-BwCpz-JZ.js";import{a as Y}from"./CalendarSession-BSPnENrr.js";import"./reply-BRbg9_Ak.js";import{k as J,b as K}from"./calendar-TkJ4zEO8.js";import"./calendar-guests-CGyi0Z1i.js";import"./calendar-event-popup-Eoorlfr8.js";import"./pencil-CPbJ6Tks.js";import"./circle-help-BT_Dohsy.js";import"./ErrorState-BjlNwjgd.js";import"./useQueries-BNgXdYau.js";import"./useMediaQuery-CXurPMbN.js";function I({title:e,subtitle:a,onClose:r,children:s,className:o}){return i.jsxs("section",{className:O("flex h-full w-full flex-col bg-surface",o),children:[i.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[i.jsx("h2",{className:"shrink-0 text-xs font-medium text-fg",children:e}),a!==void 0&&a!==""&&i.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-fg-muted",children:a}),i.jsx("button",{type:"button","aria-label":"Close editor",onClick:r,className:"ml-auto flex size-7 shrink-0 items-center justify-center rounded-md text-fg-subtle outline-none hover:bg-surface-sunken hover:text-fg focus-visible:ring-2 focus-visible:ring-ring",children:i.jsx(Z,{className:"size-4"})})]}),i.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-row-inset py-5",children:i.jsx("div",{className:"mx-auto w-full max-w-2xl",children:s})})]})}function Q(e,a,r){const s={title:e.summary,location:e.location};if(e.allDay){const t=e.dtStart.slice(0,10),c=e.dtEnd.slice(0,10);return{...w(t,a),...s,allDay:!0,startTime:"",endDate:c>t?R(c,-1):t,endTime:""}}const o=t=>e.zoneCertainty==="Ambiguous"?t:$(t,r),l=o(e.dtStart),d=o(e.dtEnd);return{...w(l.slice(0,10),a),...s,startTime:l.slice(11,16),endDate:d.slice(0,10),endTime:d.slice(11,16)}}function ee(e,a,r,s){const o=q(a,r,s);if(!o.ok)return o;const d=e.zoneCertainty==="Ambiguous"||o.patch.start!==void 0?{...o.patch,...G(r,s.clock),allDay:r.allDay,timeZone:s.anchor}:o.patch;return{ok:!0,input:{calendarId:r.calendarId,event:d}}}const te=[],ae={from:"",to:""};function ne(e,a=""){const{timeZoneByCalendarId:r}=S(),s=e.date!==""&&!e.allDay&&e.endDate!==""&&e.startTime!==""&&e.endTime!==""&&`${e.endDate}T${e.endTime}`>`${e.date}T${e.startTime}`,{instances:o,isLoading:l,error:d}=H({...s?{from:v("week",e.date).from,to:v("week",e.endDate).to}:ae,calendarIds:te,enabled:s}),t=h();return u.useMemo(()=>{if(!s||l||d)return;const c=E(e.date,e.startTime,t),p=E(e.endDate,e.endTime,t),f=o.filter(m=>U(m)&&m.calendarObjectId!==a).map(m=>_(m,r[m.calendarId]??j,t));return F({start:c,end:p},f).map(m=>({id:m.id,label:`${m.title}, ${X(m)}`}))},[s,l,d,e.date,e.endDate,e.startTime,e.endTime,t,o,a,r])}const x="Add from mail",se="The invitation named a time zone nothing could resolve. The time below is as the mail wrote it — check it before adding.";function oe({suggestionId:e,onClose:a}){const{suggestion:r,isLoading:s,error:o}=P(e),l=r??void 0,[d,t]=u.useState(void 0);l!==void 0&&d===void 0&&t(l);const c=d??l;if(c!==void 0)return i.jsx(ie,{suggestion:c,onClose:a},c.suggestionId);if(o!==null){const p="Couldn't read what your mail is waiting on.";return i.jsx(I,{title:x,onClose:a,children:i.jsx(B,{text:`${p} Close this and try again.`,reportHref:k(p),className:"m-row-inset"})})}return i.jsx(I,{title:x,onClose:a,children:i.jsx(L,{message:s?"Reading the suggestion…":"This suggestion is no longer waiting on you. It was answered, or a later message replaced it."})})}function ie({suggestion:e,onClose:a}){const{calendars:r,defaultCalendarId:s,timeZoneByCalendarId:o}=S(),l=r.filter(n=>!n.readOnly),d=M(),[t]=u.useState(()=>Q(e,"",h())),[c,p]=u.useState(t),f=Y()?.dispatch;u.useEffect(()=>{f?.({type:"sidebar-range",range:{date:t.date,endDate:t.endDate,startTime:t.allDay?"":t.startTime,endTime:t.allDay?"":t.endTime,allDay:t.allDay}})},[t,f]);const[m,y]=u.useState(""),[N,A]=u.useState(),D=ne(c),g=l.some(n=>n.id===s)?s:l[0]?.id??"";u.useEffect(()=>{g!==""&&p(n=>n.calendarId===""?{...n,calendarId:g}:n)},[g]);const C=()=>{const n=ee(e,t,c,{clock:h(),anchor:V(o[c.calendarId]??j)});if(!n.ok){y(n.problem);return}y(""),d.acceptEdited(e.suggestionId,n.input).then(b=>{if(b.kind==="answered"){a();return}const T=`Couldn't add this to your calendar: ${b.message}`;A({text:T,reportHref:k(T),onRetry:C})})};return i.jsx(z,{heading:x,draft:c,onChange:n=>{p(n),f?.({type:"sidebar-range",range:{date:n.date,endDate:n.endDate,startTime:n.allDay?"":n.startTime,endTime:n.allDay?"":n.endTime,allDay:n.allDay}})},calendars:l,calendarEditable:!0,repeatEditable:!1,timeZone:h(),timeZones:[h()],onTimeZone:()=>{},busy:!0,onBusy:()=>{},onSave:C,onCancel:a,saving:d.isAnswering,saveLabel:"Add",failure:N,problem:m!==""?m:e.zoneCertainty==="Ambiguous"?se:"",children:D&&i.jsx(W,{clashes:D})})}function Ee(){const e=J(),{closeToView:a}=K();return e===void 0?null:i.jsx(oe,{suggestionId:e,onClose:a})}export{Ee as component};
1
+ import{j as i,X as Z,q as O,fl as R,fq as $,fo as v,r as u,cy as E,g4 as F}from"./index-4XPoPWhu.js";import{E as L,C as W}from"./EmptyState-DcHnaG2R.js";import{C as z}from"./calendar-event-sidebar-D_7uvmvT.js";import{C as B}from"./calendar-failure-note-BJCyTf1U.js";import{b as j,m as H,e as h,n as U,t as _,U as S,x as P,k,j as q,o as M}from"./useCalendarSuggestions-D6k1REyo.js";import{e as w,p as V,a as G}from"./draft-CdiiJR8n.js";import{f as X}from"./calendar-format-BwCpz-JZ.js";import{a as Y}from"./CalendarSession-DGGQfwLi.js";import"./reply-FoVQqDdv.js";import{k as J,b as K}from"./calendar-miAZmlW9.js";import"./calendar-guests-BCC1uGzd.js";import"./calendar-event-popup-Dbcz3Zb_.js";import"./pencil-CA6DIP59.js";import"./circle-help-Cyj92MDS.js";import"./ErrorState-DcP5ZTMN.js";import"./useQueries-XPiXhlQX.js";import"./useMediaQuery-a7SamL-l.js";function I({title:e,subtitle:a,onClose:r,children:s,className:o}){return i.jsxs("section",{className:O("flex h-full w-full flex-col bg-surface",o),children:[i.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[i.jsx("h2",{className:"shrink-0 text-xs font-medium text-fg",children:e}),a!==void 0&&a!==""&&i.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-fg-muted",children:a}),i.jsx("button",{type:"button","aria-label":"Close editor",onClick:r,className:"ml-auto flex size-7 shrink-0 items-center justify-center rounded-md text-fg-subtle outline-none hover:bg-surface-sunken hover:text-fg focus-visible:ring-2 focus-visible:ring-ring",children:i.jsx(Z,{className:"size-4"})})]}),i.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-row-inset py-5",children:i.jsx("div",{className:"mx-auto w-full max-w-2xl",children:s})})]})}function Q(e,a,r){const s={title:e.summary,location:e.location};if(e.allDay){const t=e.dtStart.slice(0,10),c=e.dtEnd.slice(0,10);return{...w(t,a),...s,allDay:!0,startTime:"",endDate:c>t?R(c,-1):t,endTime:""}}const o=t=>e.zoneCertainty==="Ambiguous"?t:$(t,r),l=o(e.dtStart),d=o(e.dtEnd);return{...w(l.slice(0,10),a),...s,startTime:l.slice(11,16),endDate:d.slice(0,10),endTime:d.slice(11,16)}}function ee(e,a,r,s){const o=V(a,r,s);if(!o.ok)return o;const d=e.zoneCertainty==="Ambiguous"||o.patch.start!==void 0?{...o.patch,...G(r,s.clock),allDay:r.allDay,timeZone:s.anchor}:o.patch;return{ok:!0,input:{calendarId:r.calendarId,event:d}}}const te=[],ae={from:"",to:""};function ne(e,a=""){const{timeZoneByCalendarId:r}=j(),s=e.date!==""&&!e.allDay&&e.endDate!==""&&e.startTime!==""&&e.endTime!==""&&`${e.endDate}T${e.endTime}`>`${e.date}T${e.startTime}`,{instances:o,isLoading:l,error:d}=H({...s?{from:v("week",e.date).from,to:v("week",e.endDate).to}:ae,calendarIds:te,enabled:s}),t=h();return u.useMemo(()=>{if(!s||l||d)return;const c=E(e.date,e.startTime,t),p=E(e.endDate,e.endTime,t),f=o.filter(m=>U(m)&&m.calendarObjectId!==a).map(m=>_(m,r[m.calendarId]??S,t));return F({start:c,end:p},f).map(m=>({id:m.id,label:`${m.title}, ${X(m)}`}))},[s,l,d,e.date,e.endDate,e.startTime,e.endTime,t,o,a,r])}const y="Add from mail",se="The invitation named a time zone nothing could resolve. The time below is as the mail wrote it — check it before adding.";function oe({suggestionId:e,onClose:a}){const{suggestion:r,isLoading:s,error:o}=P(e),l=r??void 0,[d,t]=u.useState(void 0);l!==void 0&&d===void 0&&t(l);const c=d??l;if(c!==void 0)return i.jsx(ie,{suggestion:c,onClose:a},c.suggestionId);if(o!==null){const p="Couldn't read what your mail is waiting on.";return i.jsx(I,{title:y,onClose:a,children:i.jsx(B,{text:`${p} Close this and try again.`,reportHref:k(p),className:"m-row-inset"})})}return i.jsx(I,{title:y,onClose:a,children:i.jsx(L,{message:s?"Reading the suggestion…":"This suggestion is no longer waiting on you. It was answered, or a later message replaced it."})})}function ie({suggestion:e,onClose:a}){const{calendars:r,defaultCalendarId:s,timeZoneByCalendarId:o}=j(),l=r.filter(n=>!n.readOnly),d=q(),[t]=u.useState(()=>Q(e,"",h())),[c,p]=u.useState(t),f=Y()?.dispatch;u.useEffect(()=>{f?.({type:"sidebar-range",range:{date:t.date,endDate:t.endDate,startTime:t.allDay?"":t.startTime,endTime:t.allDay?"":t.endTime,allDay:t.allDay}})},[t,f]);const[m,x]=u.useState(""),[N,A]=u.useState(),D=ne(c),g=l.some(n=>n.id===s)?s:l[0]?.id??"";u.useEffect(()=>{g!==""&&p(n=>n.calendarId===""?{...n,calendarId:g}:n)},[g]);const C=()=>{const n=ee(e,t,c,{clock:h(),anchor:M(o[c.calendarId]??S)});if(!n.ok){x(n.problem);return}x(""),d.acceptEdited(e.suggestionId,n.input).then(b=>{if(b.kind==="answered"){a();return}const T=`Couldn't add this to your calendar: ${b.message}`;A({text:T,reportHref:k(T),onRetry:C})})};return i.jsx(z,{heading:y,draft:c,onChange:n=>{p(n),f?.({type:"sidebar-range",range:{date:n.date,endDate:n.endDate,startTime:n.allDay?"":n.startTime,endTime:n.allDay?"":n.endTime,allDay:n.allDay}})},calendars:l,calendarEditable:!0,repeatEditable:!1,timeZone:h(),timeZones:[h()],onTimeZone:()=>{},busy:!0,onBusy:()=>{},onSave:C,onCancel:a,saving:d.isAnswering,saveLabel:"Add",failure:N,problem:m!==""?m:e.zoneCertainty==="Ambiguous"?se:"",children:D&&i.jsx(W,{clashes:D})})}function Ee(){const e=J(),{closeToView:a}=K();return e===void 0?null:i.jsx(oe,{suggestionId:e,onClose:a})}export{Ee as component};
@@ -1 +1 @@
1
- import{b as w,r as d,j as e,T as R,X as E,q as z,C as $,fc as B,ck as q,fT as L}from"./index-Q7BlLS9p.js";import{b as F,C as j,u as P}from"./useCalendarTasks-Ch-qSnN_.js";import{C as V}from"./calendar-event-popup-Eoorlfr8.js";import{b as Z,e as H,c as K}from"./useCalendarSuggestions-DHNLR9_9.js";import"./reply-BRbg9_Ak.js";import{b as S}from"./calendar-TkJ4zEO8.js";import{C as M}from"./CalendarLoadFailed-CZZrv3kl.js";import"./ErrorState-BjlNwjgd.js";import"./pencil-CPbJ6Tks.js";import"./useQueries-BNgXdYau.js";import"./useMediaQuery-CXurPMbN.js";const A=w("SquareCheckBig",[["path",{d:"M21 10.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.5",key:"1uzm8b"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);const O=w("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]),D="flex size-9 items-center justify-center rounded-full text-fg-muted outline-none hover:bg-surface-sunken hover:text-fg focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-40",v="h-9 w-full rounded-md border border-line bg-surface-sunken px-2 text-sm text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring/30";function W({headingId:t,headingRef:i,fields:l,dueText:r,listName:u,completed:c,onToggle:f,onSave:x,onDelete:g,onClose:p,busy:m=!1,failure:h}){const[s,o]=d.useState(null);return e.jsxs("div",{className:"flex flex-col gap-3 p-3",children:[e.jsxs("div",{className:"flex justify-end gap-1",children:[s===null&&e.jsx("button",{type:"button",onClick:()=>o(l),className:"rounded-md px-3 text-sm font-medium text-accent hover:bg-accent-soft focus-visible:ring-2 focus-visible:ring-ring",children:"Edit"}),e.jsx("button",{type:"button","aria-label":"Delete",onClick:g,disabled:m,className:D,children:e.jsx(R,{className:"size-4"})}),e.jsx("button",{type:"button","aria-label":"Close",onClick:p,className:D,children:e.jsx(E,{className:"size-4"})})]}),s===null?e.jsxs("div",{className:"flex flex-col gap-2 px-2",children:[e.jsx("h2",{id:t,ref:i,tabIndex:-1,className:z("text-xl font-normal break-words text-fg outline-none",c&&"text-fg-muted line-through"),children:l.title===""?"(No title)":l.title}),e.jsx("p",{className:"text-sm text-fg-muted",children:r}),e.jsxs("p",{className:"flex items-center gap-2 text-sm",children:[e.jsx($,{className:"size-4 text-fg-subtle","aria-label":"List"}),u]}),l.description!==""&&e.jsx("p",{className:"text-sm whitespace-pre-wrap break-words",children:l.description})]}):e.jsxs("form",{className:"flex flex-col gap-2 px-2",onSubmit:n=>{n.preventDefault(),x(s),o(null)},children:[e.jsx("h2",{id:t,className:"sr-only",children:"Edit task"}),e.jsx("input",{"aria-label":"Title",value:s.title,onChange:n=>o({...s,title:n.target.value}),className:v}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"date","aria-label":"Due date",value:s.dueDate,onChange:n=>n.target.value!==""&&o({...s,dueDate:n.target.value}),className:v}),e.jsx("input",{type:"time","aria-label":"Due time",value:s.dueTime,onChange:n=>o({...s,dueTime:n.target.value}),className:v})]}),e.jsx("textarea",{"aria-label":"Description",rows:3,value:s.description,onChange:n=>o({...s,description:n.target.value}),className:"w-full rounded-md border border-line bg-surface-sunken px-2 py-1 text-sm"}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>o(null),className:"h-9 rounded-md border border-line px-3 text-sm font-medium",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:m,className:"h-9 rounded-md bg-accent px-4 text-sm font-medium text-accent-fg disabled:opacity-50",children:"Save"})]})]}),h&&e.jsx(V,{failure:h}),s===null&&e.jsx("div",{className:"flex justify-end px-2",children:e.jsxs("button",{type:"button",onClick:f,disabled:m,className:"inline-flex h-9 items-center gap-2 rounded-md border border-line px-3 text-sm font-medium hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50",children:[c?e.jsx(O,{className:"size-4","aria-hidden":"true"}):e.jsx(A,{className:"size-4","aria-hidden":"true"}),c?"Mark not done":"Mark done"]})})]})}const U=(t,i)=>{const l=new Date(`${t.slice(0,10)}T00:00:00Z`),r=new Intl.DateTimeFormat(void 0,{weekday:"long",day:"numeric",month:"long",timeZone:"UTC"}).format(l);return i?`Due ${r}`:`Due ${r} · ${t.slice(11,16)}`};function X({calendarTaskId:t}){const i=F(t),{closeToView:l}=S(),r=d.useId(),u=d.useRef(null),c=i.kind==="gone";return d.useEffect(()=>{c&&u.current?.focus()},[c]),i.kind==="loading"?null:i.kind==="found"?e.jsx(G,{task:i.task}):i.kind==="failed"?e.jsx(j,{anchor:null,anchorKey:"failed",labelledBy:r,children:e.jsx("div",{id:r,className:"p-4",children:e.jsx(M,{title:"Couldn't open this task",error:i.error,onRetry:i.retry,compact:!0})})}):e.jsx(j,{anchor:null,anchorKey:"gone",labelledBy:r,children:e.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[e.jsx("h2",{id:r,className:"text-base font-medium text-fg",children:"This task was deleted or moved"}),e.jsx("button",{ref:u,type:"button",onClick:l,className:"self-end rounded-md border border-line px-3 py-1.5 text-sm font-medium hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring",children:"Close"})]})})}function G({task:t}){const{taskLists:i}=Z(),{closeToView:l}=S(),{updateTask:r,deleteTask:u,isWriting:c}=P(),f=d.useId(),x=d.useRef(null),[g,p]=d.useState(),[m,h]=d.useState(null),{calendarTaskId:s}=t;d.useLayoutEffect(()=>{h(document.querySelector(`[data-task-id="${CSS.escape(s)}"]`))},[s]),d.useEffect(()=>{x.current?.focus()},[]);const o=H(),n=t.allDay?t.due:B(t.due,o),I={title:t.summary,dueDate:n.slice(0,10),dueTime:t.allDay?"":n.slice(11,16),description:t.description},b=a=>N=>{if(N.kind==="written"){p(void 0);return}const T=`Couldn't save the task: ${N.message}`;p({text:T,reportHref:K(T),onRetry:a})},y=()=>{r(t,{completed:!t.completed}).then(b(y))},k=a=>{r(t,{summary:a.title,description:a.description,allDay:a.dueTime==="",due:a.dueTime===""?a.dueDate:q(a.dueDate,a.dueTime,o)}).then(b(()=>k(a)))},C=()=>{u(t).then(a=>{if(a.kind==="written"){l();return}b(C)(a)})};return e.jsx(j,{anchor:m,anchorKey:`${s}:${m?"chip":"none"}`,labelledBy:f,children:e.jsx(W,{headingId:f,headingRef:x,fields:I,dueText:U(n,t.allDay),listName:i.find(a=>a.id===t.calendarId)?.name??"Tasks",completed:t.completed,onToggle:y,onSave:k,onDelete:C,onClose:l,busy:c,failure:g})})}function re(){const{calendarTaskId:t}=L.useParams();return e.jsx(X,{calendarTaskId:t})}export{re as component};
1
+ import{b as w,r as d,j as e,T as R,X as E,q as z,C as $,fq as q,cy as B,g5 as L}from"./index-4XPoPWhu.js";import{b as F,C as j,u as P}from"./useCalendarTasks-DNBYBsvN.js";import{C as V}from"./calendar-event-popup-Dbcz3Zb_.js";import{b as Z,e as H,c as K}from"./useCalendarSuggestions-D6k1REyo.js";import"./reply-FoVQqDdv.js";import{b as S}from"./calendar-miAZmlW9.js";import{C as M}from"./CalendarLoadFailed-DGqiWK7A.js";import"./ErrorState-DcP5ZTMN.js";import"./pencil-CA6DIP59.js";import"./useQueries-XPiXhlQX.js";import"./useMediaQuery-a7SamL-l.js";const A=w("SquareCheckBig",[["path",{d:"M21 10.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.5",key:"1uzm8b"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);const O=w("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]),D="flex size-9 items-center justify-center rounded-full text-fg-muted outline-none hover:bg-surface-sunken hover:text-fg focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-40",v="h-9 w-full rounded-md border border-line bg-surface-sunken px-2 text-sm text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring/30";function W({headingId:t,headingRef:i,fields:l,dueText:r,listName:u,completed:c,onToggle:f,onSave:x,onDelete:g,onClose:p,busy:m=!1,failure:h}){const[s,o]=d.useState(null);return e.jsxs("div",{className:"flex flex-col gap-3 p-3",children:[e.jsxs("div",{className:"flex justify-end gap-1",children:[s===null&&e.jsx("button",{type:"button",onClick:()=>o(l),className:"rounded-md px-3 text-sm font-medium text-accent hover:bg-accent-soft focus-visible:ring-2 focus-visible:ring-ring",children:"Edit"}),e.jsx("button",{type:"button","aria-label":"Delete",onClick:g,disabled:m,className:D,children:e.jsx(R,{className:"size-4"})}),e.jsx("button",{type:"button","aria-label":"Close",onClick:p,className:D,children:e.jsx(E,{className:"size-4"})})]}),s===null?e.jsxs("div",{className:"flex flex-col gap-2 px-2",children:[e.jsx("h2",{id:t,ref:i,tabIndex:-1,className:z("text-xl font-normal break-words text-fg outline-none",c&&"text-fg-muted line-through"),children:l.title===""?"(No title)":l.title}),e.jsx("p",{className:"text-sm text-fg-muted",children:r}),e.jsxs("p",{className:"flex items-center gap-2 text-sm",children:[e.jsx($,{className:"size-4 text-fg-subtle","aria-label":"List"}),u]}),l.description!==""&&e.jsx("p",{className:"text-sm whitespace-pre-wrap break-words",children:l.description})]}):e.jsxs("form",{className:"flex flex-col gap-2 px-2",onSubmit:n=>{n.preventDefault(),x(s),o(null)},children:[e.jsx("h2",{id:t,className:"sr-only",children:"Edit task"}),e.jsx("input",{"aria-label":"Title",value:s.title,onChange:n=>o({...s,title:n.target.value}),className:v}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"date","aria-label":"Due date",value:s.dueDate,onChange:n=>n.target.value!==""&&o({...s,dueDate:n.target.value}),className:v}),e.jsx("input",{type:"time","aria-label":"Due time",value:s.dueTime,onChange:n=>o({...s,dueTime:n.target.value}),className:v})]}),e.jsx("textarea",{"aria-label":"Description",rows:3,value:s.description,onChange:n=>o({...s,description:n.target.value}),className:"w-full rounded-md border border-line bg-surface-sunken px-2 py-1 text-sm"}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>o(null),className:"h-9 rounded-md border border-line px-3 text-sm font-medium",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:m,className:"h-9 rounded-md bg-accent px-4 text-sm font-medium text-accent-fg disabled:opacity-50",children:"Save"})]})]}),h&&e.jsx(V,{failure:h}),s===null&&e.jsx("div",{className:"flex justify-end px-2",children:e.jsxs("button",{type:"button",onClick:f,disabled:m,className:"inline-flex h-9 items-center gap-2 rounded-md border border-line px-3 text-sm font-medium hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50",children:[c?e.jsx(O,{className:"size-4","aria-hidden":"true"}):e.jsx(A,{className:"size-4","aria-hidden":"true"}),c?"Mark not done":"Mark done"]})})]})}const U=(t,i)=>{const l=new Date(`${t.slice(0,10)}T00:00:00Z`),r=new Intl.DateTimeFormat(void 0,{weekday:"long",day:"numeric",month:"long",timeZone:"UTC"}).format(l);return i?`Due ${r}`:`Due ${r} · ${t.slice(11,16)}`};function X({calendarTaskId:t}){const i=F(t),{closeToView:l}=S(),r=d.useId(),u=d.useRef(null),c=i.kind==="gone";return d.useEffect(()=>{c&&u.current?.focus()},[c]),i.kind==="loading"?null:i.kind==="found"?e.jsx(G,{task:i.task}):i.kind==="failed"?e.jsx(j,{anchor:null,anchorKey:"failed",labelledBy:r,children:e.jsx("div",{id:r,className:"p-4",children:e.jsx(M,{title:"Couldn't open this task",error:i.error,onRetry:i.retry,compact:!0})})}):e.jsx(j,{anchor:null,anchorKey:"gone",labelledBy:r,children:e.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[e.jsx("h2",{id:r,className:"text-base font-medium text-fg",children:"This task was deleted or moved"}),e.jsx("button",{ref:u,type:"button",onClick:l,className:"self-end rounded-md border border-line px-3 py-1.5 text-sm font-medium hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring",children:"Close"})]})})}function G({task:t}){const{taskLists:i}=Z(),{closeToView:l}=S(),{updateTask:r,deleteTask:u,isWriting:c}=P(),f=d.useId(),x=d.useRef(null),[g,p]=d.useState(),[m,h]=d.useState(null),{calendarTaskId:s}=t;d.useLayoutEffect(()=>{h(document.querySelector(`[data-task-id="${CSS.escape(s)}"]`))},[s]),d.useEffect(()=>{x.current?.focus()},[]);const o=H(),n=t.allDay?t.due:q(t.due,o),I={title:t.summary,dueDate:n.slice(0,10),dueTime:t.allDay?"":n.slice(11,16),description:t.description},b=a=>N=>{if(N.kind==="written"){p(void 0);return}const T=`Couldn't save the task: ${N.message}`;p({text:T,reportHref:K(T),onRetry:a})},y=()=>{r(t,{completed:!t.completed}).then(b(y))},C=a=>{r(t,{summary:a.title,description:a.description,allDay:a.dueTime==="",due:a.dueTime===""?a.dueDate:B(a.dueDate,a.dueTime,o)}).then(b(()=>C(a)))},k=()=>{u(t).then(a=>{if(a.kind==="written"){l();return}b(k)(a)})};return e.jsx(j,{anchor:m,anchorKey:`${s}:${m?"chip":"none"}`,labelledBy:f,children:e.jsx(W,{headingId:f,headingRef:x,fields:I,dueText:U(n,t.allDay),listName:i.find(a=>a.id===t.calendarId)?.name??"Tasks",completed:t.completed,onToggle:y,onSave:C,onDelete:k,onClose:l,busy:c,failure:g})})}function re(){const{calendarTaskId:t}=L.useParams();return e.jsx(X,{calendarTaskId:t})}export{re as component};
@@ -1 +1 @@
1
- import{b as a}from"./index-Q7BlLS9p.js";const d=a("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);export{d as U};
1
+ import{b as a}from"./index-4XPoPWhu.js";const d=a("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);export{d as U};
@@ -1,2 +1,2 @@
1
- import{j as c,q as x,B as E,r as f,fa as S}from"./index-Q7BlLS9p.js";import{o as A,b as L,e as O,n as W,t as Z,U as B,m as P,p as U,h as F,r as M}from"./useCalendarSuggestions-DHNLR9_9.js";import{a as q,t as z}from"./useCalendarTasks-Ch-qSnN_.js";const K=[{scope:"this",label:"This event",note:"Leaves the rest of the series alone"},{scope:"following",label:"This and everything after",note:"Splits the series here"},{scope:"all",label:"The whole series",note:"Rewrites the rule itself"}];function Q({title:e,ruleText:s,instanceText:n,onChoose:t,onCancel:r,scopes:a,touch:o,className:d}){return c.jsxs("div",{className:x("flex flex-col gap-3",d),children:[c.jsxs("div",{children:[c.jsxs("h2",{className:"text-md font-semibold text-fg",children:[e," repeats"]}),c.jsx("p",{className:"text-xs text-fg-muted",children:s}),c.jsxs("p",{className:"text-xs text-fg-subtle",children:["You clicked ",n,"."]})]}),c.jsx("p",{className:"text-sm text-fg",children:"What should the change apply to?"}),c.jsx("div",{className:"flex flex-col gap-1.5",children:K.filter(l=>a===void 0||a.includes(l.scope)).map(l=>c.jsxs("button",{type:"button",onClick:()=>t(l.scope),className:x("flex flex-col rounded-md border border-line bg-surface px-3 py-2 text-left outline-none transition-colors hover:border-line-strong hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring",o&&"min-h-11 justify-center"),children:[c.jsx("span",{className:"text-sm font-medium text-fg",children:l.label}),c.jsx("span",{className:"text-2xs text-fg-subtle",children:l.note})]},l.scope))}),c.jsx(E,{variant:"ghost",size:o?"md":"sm",onClick:r,className:x("self-start",o&&"min-h-11"),children:"Cancel"})]})}const C=e=>e.replace(/\r?\n[ \t]/g,""),I=e=>e.replace(/\\n/gi,`
1
+ import{j as c,q as x,B as E,r as f,fo as S}from"./index-4XPoPWhu.js";import{o as A,b as L,e as O,n as W,t as Z,U as B,m as P,p as U,h as F,r as M}from"./useCalendarSuggestions-D6k1REyo.js";import{a as q,t as z}from"./useCalendarTasks-DNBYBsvN.js";const K=[{scope:"this",label:"This event",note:"Leaves the rest of the series alone"},{scope:"following",label:"This and everything after",note:"Splits the series here"},{scope:"all",label:"The whole series",note:"Rewrites the rule itself"}];function Q({title:e,ruleText:s,instanceText:n,onChoose:t,onCancel:r,scopes:a,touch:o,className:d}){return c.jsxs("div",{className:x("flex flex-col gap-3",d),children:[c.jsxs("div",{children:[c.jsxs("h2",{className:"text-md font-semibold text-fg",children:[e," repeats"]}),c.jsx("p",{className:"text-xs text-fg-muted",children:s}),c.jsxs("p",{className:"text-xs text-fg-subtle",children:["You clicked ",n,"."]})]}),c.jsx("p",{className:"text-sm text-fg",children:"What should the change apply to?"}),c.jsx("div",{className:"flex flex-col gap-1.5",children:K.filter(l=>a===void 0||a.includes(l.scope)).map(l=>c.jsxs("button",{type:"button",onClick:()=>t(l.scope),className:x("flex flex-col rounded-md border border-line bg-surface px-3 py-2 text-left outline-none transition-colors hover:border-line-strong hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring",o&&"min-h-11 justify-center"),children:[c.jsx("span",{className:"text-sm font-medium text-fg",children:l.label}),c.jsx("span",{className:"text-2xs text-fg-subtle",children:l.note})]},l.scope))}),c.jsx(E,{variant:"ghost",size:o?"md":"sm",onClick:r,className:x("self-start",o&&"min-h-11"),children:"Cancel"})]})}const C=e=>e.replace(/\r?\n[ \t]/g,""),I=e=>e.replace(/\\n/gi,`
2
2
  `).replace(/\\,/g,",").replace(/\\;/g,";").replace(/\\\\/g,"\\");function g(e,s){let n=!1;for(let t=s.length;t<e.length;t+=1){const r=e[t];if(t===s.length&&r!==";"&&r!==":")return;if(r==='"'){n=!n;continue}if(!n&&r===":")return e.slice(t+1).trim()}}function v(e,s){for(const n of C(e).split(/\r?\n/)){if(!n.startsWith(s))continue;const t=g(n,s);if(t!==void 0)return t}return""}const X=e=>v(e,"RRULE"),$=e=>({location:I(v(e,"LOCATION")),description:I(v(e,"DESCRIPTION"))});function ee(e,s){const n=C(e).split(/\r?\n/).find(r=>r.startsWith("DTSTART")&&g(r,"DTSTART")!==void 0);if(n===void 0)return A(s);const t=/;TZID="?([^;:"]+)"?/i.exec(n)?.[1];return t!==void 0?Intl.supportedValuesOf("timeZone").includes(t)?t:s:g(n,"DTSTART")?.toUpperCase().endsWith("Z")?"":s}function V(e,s){const n=e.map(a=>a.id);if(s.length===0)return n;const t=new Set(s),r=n.filter(a=>t.has(a));return r.length===0?n:r}function Y(e){const{calendars:s,colorByCalendarId:n,timeZoneByCalendarId:t,isLoading:r}=L(),a=V(s,e),o=a.length===s.length?[]:a,d=e.length===0||s.length>0;return{calendars:s,colorByCalendarId:n,timeZoneByCalendarId:t,shown:a,narrowed:o,resolved:d,isLoading:r}}function _(e,s,n){const t=n.join(",");return f.useMemo(()=>{const r=O(),a=new Set(t===""?[]:t.split(","));return e.filter(o=>W(o)&&a.has(o.calendarId)).map(o=>Z(o,s[o.calendarId]??B,r))},[e,s,t])}function se({view:e,date:s,calendarIds:n,enabled:t=!0}){const{calendars:r,colorByCalendarId:a,timeZoneByCalendarId:o,shown:d,narrowed:l,resolved:j,isLoading:N}=Y(n),w=S(e,s),h=t&&j,i=P({...w,calendarIds:l,enabled:h});U(e,s,l,h);const k=_(i.instances,o,d),p=q(w,h),m=p.tasks,D=f.useMemo(()=>m.map(z),[m]),T=i.refetch,b=p.refetch,y=f.useCallback(()=>{T(),b()},[T,b]),R=f.useMemo(()=>new Set(i.instances.filter(u=>u.transparency==="Transparent").map(u=>F(u.calendarObjectId,u.recurrenceId))),[i.instances]);return{calendars:r,events:k,colorByCalendarId:a,timeZoneByCalendarId:o,isLoading:N||i.isLoading,error:i.error??p.error,retry:y,storedTasks:m,tasks:D,instanceOf:M,freeIds:R}}export{Q as R,_ as a,V as b,se as c,X as r,ee as s,$ as t,Y as u};
@@ -1 +1 @@
1
- import{f as y,a as f,c as g,fF as m,g as b,fG as S,r as d,d3 as I,d1 as p,aZ as M,bI as h}from"./index-Q7BlLS9p.js";import{u as x}from"./useQueries-BNgXdYau.js";import{u as O}from"./useDebouncedValue-B6s52mZt.js";function Q(){const s=y(),{data:a}=f({...g(),staleTime:6e4}),{data:o}=f(m()),r=b(S()),i=d.useMemo(()=>(a?.accounts??[]).filter(n=>n.syncedServices.includes("Mail")).map(n=>({accountId:n.accountId,email:n.email})),[a?.accounts]),l=o?.defaultInvitationSenderAccountId,c=d.useCallback(async n=>{await r.mutateAsync({body:{defaultInvitationSenderAccountId:n}}),await s.invalidateQueries({queryKey:m().queryKey})},[r,s]);return{senders:i,defaultSenderId:l,setDefaultSender:c}}const E=2;function w(s){const a=O(s.trim(),200),{data:o}=f({...h({query:{q:a,limit:8}}),enabled:a.length>=E});return d.useMemo(()=>(o?.items??[]).map(r=>({email:r.normalizedEmail,name:r.displayName??""})),[o?.items])}const q=["sent","unfiled","failed","blocked"],v=["failed","blocked"];function A(s){const a=y(),o=b(I()),r=x({queries:s.map(e=>({...p({path:{outboxMessageId:e.outboxMessageId}}),meta:{softErrorStatuses:[404]},retry:!1,refetchInterval:u=>{if(u.state.error)return!1;const t=u.state.data?.status;return t&&q.includes(t)?!1:1500}}))}),i=s.flatMap((e,u)=>{const t=r[u];return!t?.error||M(t.error)===404?[]:[{send:e,error:t.error,refetch:t.refetch}]}),l=()=>{for(const e of i)e.refetch()},c=s.filter((e,u)=>{const t=r[u]?.data?.status;return t!==void 0&&v.includes(t)}),n=d.useCallback(async()=>{for(const e of c)await o.mutateAsync({path:{outboxMessageId:e.outboxMessageId}}),await a.invalidateQueries({queryKey:p({path:{outboxMessageId:e.outboxMessageId}}).queryKey})},[c,o,a]);return{missed:c.map(e=>e.email),retry:n,checkError:i[0]?.error??null,unchecked:i.map(e=>e.send.email),recheck:l}}export{A as a,w as b,Q as u};
1
+ import{f as y,a as f,c as g,fT as m,g as b,fU as S,r as d,dh as M,df as p,aZ as I,bW as h}from"./index-4XPoPWhu.js";import{u as x}from"./useQueries-XPiXhlQX.js";import{u as O}from"./useDebouncedValue-B0BMCu3v.js";function Q(){const s=y(),{data:a}=f({...g(),staleTime:6e4}),{data:o}=f(m()),r=b(S()),i=d.useMemo(()=>(a?.accounts??[]).filter(n=>n.syncedServices.includes("Mail")).map(n=>({accountId:n.accountId,email:n.email})),[a?.accounts]),l=o?.defaultInvitationSenderAccountId,c=d.useCallback(async n=>{await r.mutateAsync({body:{defaultInvitationSenderAccountId:n}}),await s.invalidateQueries({queryKey:m().queryKey})},[r,s]);return{senders:i,defaultSenderId:l,setDefaultSender:c}}const E=2;function U(s){const a=O(s.trim(),200),{data:o}=f({...h({query:{q:a,limit:8}}),enabled:a.length>=E});return d.useMemo(()=>(o?.items??[]).map(r=>({email:r.normalizedEmail,name:r.displayName??""})),[o?.items])}const q=["sent","unfiled","failed","blocked"],v=["failed","blocked"];function w(s){const a=y(),o=b(M()),r=x({queries:s.map(e=>({...p({path:{outboxMessageId:e.outboxMessageId}}),meta:{softErrorStatuses:[404]},retry:!1,refetchInterval:u=>{if(u.state.error)return!1;const t=u.state.data?.status;return t&&q.includes(t)?!1:1500}}))}),i=s.flatMap((e,u)=>{const t=r[u];return!t?.error||I(t.error)===404?[]:[{send:e,error:t.error,refetch:t.refetch}]}),l=()=>{for(const e of i)e.refetch()},c=s.filter((e,u)=>{const t=r[u]?.data?.status;return t!==void 0&&v.includes(t)}),n=d.useCallback(async()=>{for(const e of c)await o.mutateAsync({path:{outboxMessageId:e.outboxMessageId}}),await a.invalidateQueries({queryKey:p({path:{outboxMessageId:e.outboxMessageId}}).queryKey})},[c,o,a]);return{missed:c.map(e=>e.email),retry:n,checkError:i[0]?.error??null,unchecked:i.map(e=>e.send.email),recheck:l}}export{w as a,U as b,Q as u};
@@ -1 +1 @@
1
- import{b as X,aD as Q,aE as B,fc as _,a as C,fd as ee,r as d,f as b,s as y,g as m,fe as te,ff as ne,fg as ae,aZ as A,ba as se,b8 as re,b9 as oe,fh as ie,cd as w,fi as S,fa as ce,ct as de,fj as le,fk as ue,fl as fe,fm as pe,fn as ge,fo as me,fp as Ce,fq as ye}from"./index-Q7BlLS9p.js";import{f as I}from"./ErrorState-BjlNwjgd.js";import{u as G}from"./useQueries-BNgXdYau.js";const Fe=X("MapPin",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]]);function je(e){return Q(B({title:`Calendar invitation: ${e}`,errorMessage:e}))}function We(e){return Q(B({title:`Calendar event: ${e}`,errorMessage:e}))}const K=()=>Intl.DateTimeFormat().resolvedOptions().timeZone,q="";function Ue(e){if(e!==q)return e;const t=K();return Intl.supportedValuesOf("timeZone").includes(t)?t:q}const Ee={Cal1:"cal-1",Cal2:"cal-2",Cal3:"cal-3",Cal4:"cal-4",Cal5:"cal-5",Cal6:"cal-6"},Z={Unscheduled:"accepted",Organizer:"accepted",Accepted:"accepted",Tentative:"tentative",Declined:"declined",NeedsAction:"noReply"},$e=e=>Z[e],Oe={Local:"local",Explicit:"explicit",Ambiguous:"ambiguous"},z="#";function he(e,t){return t===""?e:`${e}${z}${t}`}function R(e){const t=e.indexOf(z);return t===-1?{calendarObjectId:e,recurrenceId:""}:{calendarObjectId:e.slice(0,t),recurrenceId:e.slice(t+1)}}const H=(e,t)=>{const n=[...e].sort((a,r)=>Date.parse(a.start)-Date.parse(r.start));return n.find(a=>Date.parse(a.end)>Date.parse(t))??n[0]};function xe(e,t,n){const a=H(e.filter(r=>{const o=R(r.id);return o.calendarObjectId===t&&o.recurrenceId!==""}),n);return a?R(a.id):void 0}function F(e,t,n,a){const r=H(e.filter(o=>o.calendarObjectId===t&&ve(o)).map(o=>Se(o,"",a)),n);if(r)return{...R(r.id),calendarId:r.calendarId,date:r.start.slice(0,10)}}function j(e){return{id:e.calendarId,accountId:e.accountConfigId,accountLabel:"",name:e.displayName,color:Ee[e.color]??"cal-1",...e.source==="Subscribed"?{readOnly:!0,sync:e.subscriptionEnabled?"live":"paused",syncError:e.subscriptionError}:{}}}function Se(e,t,n){return{id:he(e.calendarObjectId,e.recurrenceId),calendarId:e.calendarId,title:e.summary,start:e.allDay?e.start.slice(0,10):_(e.start,n),end:e.allDay?e.end.slice(0,10):_(e.end,n),allDay:e.allDay,location:"",notes:"",attendees:[],myRsvp:Z[e.participation],threadId:"",threadSubject:"",timeZone:t,zoneCertainty:Oe[e.zoneCertainty]??"explicit",recurrenceRule:e.hasRecurrence?"Repeats":"",seriesId:e.hasRecurrence?e.icalUid:"",seriesException:!1,status:e.status==="Tentative"?"tentative":"confirmed"}}const ve=e=>e.status!=="Cancelled";function Qe(){const{data:e,isLoading:t,error:n,refetch:a}=C(ee());return d.useMemo(()=>{const r=e?.items??[],o=r.filter(i=>i.componentSet!=="VtodoOnly"),l=o.map(j),s=r.filter(i=>i.componentSet==="VtodoOnly").map(j);return{calendars:l,taskLists:s,collections:r,colorByCalendarId:Object.fromEntries(l.map(i=>[i.id,i.color])),timeZoneByCalendarId:Object.fromEntries(r.map(i=>[i.calendarId,i.timezone])),defaultCalendarId:(o.find(i=>i.source==="Default")??o[0])?.calendarId??"",isLoading:t,error:n??null,retry:()=>{a()}}},[e,t,n,a])}const D=y(400,404,412),be=new Set(["calendarEventOperationsListCalendarEvents","calendarEventDetailOperationsGetCalendarEvent","calendarFreeBusyOperationsListCalendarFreeBusy","calendarTaskOperationsListCalendarTasks","calendarTaskDetailOperationsGetCalendarTask"]),W=e=>A(e)===412?{kind:"conflict"}:{kind:"refused",message:I(e)},Ae={this:"This",following:"Following",all:"All"};function V(){const e=b();return d.useCallback(()=>{e.invalidateQueries({predicate:t=>{const n=t.queryKey[0];if(typeof n!="object"||n===null)return!1;const a=n._id;return typeof a=="string"&&be.has(a)}})},[e])}const U=({scope:e,recurrenceId:t})=>e===void 0?{}:{scope:Ae[e],recurrenceId:t};function Be(){const e=V(),t=m({...te(),meta:D,onSuccess:e}),n=m({...ne(),meta:D,onSuccess:e}),a=m({...ae(),meta:D,onSuccess:e}),r=d.useCallback(s=>t.mutateAsync({body:s}).then(i=>({kind:"created",calendarObjectId:i.calendarObjectId,sends:i.sends})).catch(i=>A(i)===412?{kind:"conflict"}:{kind:"refused",message:I(i)}),[t]),o=d.useCallback((s,i)=>n.mutateAsync({path:{calendarObjectId:s.calendarObjectId},query:{calendarId:s.calendarId,...U(s)},headers:{"If-Match":s.etag},body:i}).then(f=>({kind:"written",sends:f.sends})).catch(W),[n]),l=d.useCallback(s=>a.mutateAsync({path:{calendarObjectId:s.calendarObjectId},query:{calendarId:s.calendarId,...U(s)},headers:{"If-Match":s.etag}}).then(i=>({kind:"written",sends:i.sends})).catch(W),[a]);return d.useMemo(()=>({createEvent:r,updateEvent:o,deleteEvent:l,isWriting:t.isPending||n.isPending||a.isPending}),[r,o,l,t.isPending,n.isPending,a.isPending])}const M=y(400,404),L={kind:"written"},P=e=>({kind:"refused",message:I(e)});function we(){const e=b(),t=V(),n=d.useCallback(()=>e.invalidateQueries({queryKey:se()}),[e]),a=d.useCallback(()=>(t(),n()),[t,n]),r=m({...re(),meta:M,onSuccess:n}),o=m({...oe(),meta:M,onSuccess:a}),l=m({...ie(),meta:M,onSuccess:a}),s=d.useCallback(c=>r.mutateAsync({body:c}).then(()=>L).catch(P),[r]),i=d.useCallback((c,p)=>o.mutateAsync({path:{calendarId:c},body:p}).then(()=>L).catch(P),[o]),f=d.useCallback(c=>l.mutateAsync({path:{calendarId:c}}).then(()=>L).catch(P),[l]);return d.useMemo(()=>({createCalendar:s,updateCalendar:i,deleteCalendar:f,isWriting:r.isPending||o.isPending||l.isPending}),[s,i,f,r.isPending,o.isPending,l.isPending])}const Ie=y(404);function Ge(e,t){const{data:n,isLoading:a,error:r,refetch:o}=C({...w({path:{calendarObjectId:e},query:{calendarId:t}}),meta:Ie,enabled:e!==""&&t!==""});return{resource:n,isLoading:a,error:r,refetch:()=>{o()}}}const Y=y(400,404),k=5*6e4,T=({from:e,to:t,calendarIds:n})=>({query:n.length===0?{from:e,to:t}:{from:e,to:t,calendarId:[...n]}});function Ke(e){const{data:t,isLoading:n,error:a,refetch:r}=C({...S(T(e)),meta:Y,staleTime:k,enabled:e.enabled??!0});return{instances:t?.items??[],isLoading:n,error:a,refetch:()=>{r()}}}function Ze(e,t,n){const a=G({queries:e.map(c=>({...S(T({...c,calendarIds:t})),meta:Y,staleTime:k,enabled:n}))}),r=e.map(c=>c.from).join("|"),o=a.map(c=>c.data),l=a.map(c=>c.isPending).join("|"),s=a.find(c=>c.error)?.error??null,i=d.useMemo(()=>o.flatMap(c=>c?.items??[]),[r,l]),f=d.useMemo(()=>{const c=new Set;return e.forEach((p,u)=>{a[u]?.isPending&&c.add(p.from)}),c},[r,l]);return{instances:i,pendingWindows:f,error:s,refetch:()=>{for(const c of a)c.error&&c.refetch()}}}function ze(e,t,n,a){const r=b(),o=[...n].join(",");d.useEffect(()=>{if(!a)return;const l=o===""?[]:o.split(",");for(const s of[-1,1]){const i=ce(e,de(t,e,s));r.prefetchQuery({...S(T({...i,calendarIds:l})),staleTime:k})}},[r,e,t,o,a])}const ke=y(400,404);function He(e){const t=G({queries:e.map(s=>({...le({query:{from:s.from,to:s.to}}),meta:ke,staleTime:k}))}),n=e.map(s=>s.from).join("|"),a=t.map(s=>s.data),r=t.map(s=>s.isPending).join("|"),o=d.useMemo(()=>a.flatMap(s=>s?.items??[]),[n,r]),l=d.useMemo(()=>{const s=new Set;return e.forEach((i,f)=>{t[f]?.isPending&&s.add(i.from)}),s},[n,r]);return{spans:o,pendingWindows:l,error:t.find(s=>s.error)?.error??null,refetch:()=>{for(const s of t)s.error&&s.refetch()}}}const $=365*24*60*6e4,De=1440*6e4,x=y(),Me=y(404),v=e=>new Date(e).toISOString().replace(/\.\d{3}Z$/,"+00:00"),Le=e=>{const t=e instanceof Error&&e.message!==""?e.message:"no reason given",n=A(e);return n===void 0?t:`${t} (HTTP ${n})`};function Ve(e,t){const[n]=d.useState(()=>Date.now()),a=K(),r=new Date(n).toISOString(),o=C({...S({query:{from:v(n),to:v(n+$),calendarObjectId:e}}),meta:x,retry:!1,enabled:t}),l=o.data?F(o.data.items,e,r,a):void 0,s=C({...w({path:{calendarObjectId:e}}),meta:Me,retry:!1,enabled:t&&o.data!==void 0&&l===void 0}),i=Date.parse(s.data?.dtStart??""),f=s.data!==void 0&&Number.isNaN(i),c=Number.isNaN(i)?0:i-De,p=C({...S({query:{from:v(c),to:v(c+$),calendarObjectId:e}}),meta:x,retry:!1,enabled:t&&s.data!==void 0&&!f}),u=p.data?F(p.data.items,e,r,a):void 0;if(!t)return{kind:"Idle"};if(l)return{kind:"Found",jump:l};if(u)return{kind:"Found",jump:u};const g=A(s.error)===404,N=[o.error,g?null:s.error,p.error].find(J=>J!==null);return N!==void 0?{kind:"Failed",reason:Le(N)}:g?{kind:"Deleted"}:f?{kind:"Failed",reason:`the stored event names no readable start (${s.data?.dtStart??""})`}:p.data!==void 0?{kind:"NoOccurrenceFound"}:{kind:"Searching"}}const E=y(400,404),Pe=new Set(["calendarSuggestionOperationsListCalendarSuggestions","messageCalendarSuggestionOperationsListMessageCalendarSuggestions","calendarEventOperationsListCalendarEvents","calendarEventDetailOperationsGetCalendarEvent","calendarFreeBusyOperationsListCalendarFreeBusy","filterOperationsListFilters"]),Re=e=>e.invalidateQueries({predicate:t=>{const n=t.queryKey[0];if(typeof n!="object"||n===null)return!1;const a=n._id;return typeof a=="string"&&Pe.has(a)}});function Ye(e){const{data:t,isLoading:n,error:a}=C({...ue({path:{messageId:e}}),meta:E});return{suggestions:t?.items??[],isLoading:n,error:a??null}}function Je(){const{data:e,isLoading:t,error:n}=C({...Ce({query:{state:"Pending"}}),meta:E});return{suggestions:e?.items??[],isLoading:t,error:n??null}}const Te=async(e,t)=>{let n;do{const{data:a}=await ye({query:{state:"Pending",continuationToken:n},signal:t,throwOnError:!0}),r=a.items.find(o=>o.suggestionId===e);if(r)return r;n=a.continuationToken}while(n);return null};function Xe(e){const{data:t,isLoading:n,error:a}=C({queryKey:[{_id:"calendarSuggestionOperationsListCalendarSuggestions",suggestionId:e}],queryFn:({signal:r})=>Te(e,r),meta:E});return{suggestion:t,isLoading:n,error:a??null}}const O={kind:"answered"},h=e=>({kind:"refused",message:I(e)});function et(){const e=b(),t=d.useCallback(()=>Re(e),[e]),n=m({...fe(),meta:E,onSuccess:t}),a=m({...pe(),meta:E,onSuccess:t}),r=m({...ge(),meta:E,onSuccess:t}),o=m({...me(),meta:E,onSuccess:t}),l=d.useCallback((u,g)=>n.mutateAsync({path:{suggestionId:u},body:{calendarId:g}}).then(()=>O).catch(h),[n]),s=d.useCallback((u,g)=>n.mutateAsync({path:{suggestionId:u},body:{calendarId:g,answer:"Tentative"}}).then(()=>O).catch(h),[n]),i=d.useCallback((u,g)=>n.mutateAsync({path:{suggestionId:u},body:g}).then(()=>O).catch(h),[n]),f=d.useCallback(u=>a.mutateAsync({path:{suggestionId:u}}).then(()=>O).catch(h),[a]),c=d.useCallback((u,g)=>r.mutateAsync({path:{suggestionId:u},body:{muteSender:g}}).then(()=>O).catch(h),[r]),p=d.useCallback(u=>o.mutateAsync({path:{suggestionId:u}}).then(()=>O).catch(h),[o]);return d.useMemo(()=>({accept:l,tentative:s,acceptEdited:i,decline:f,dismiss:c,reopen:p,isAnswering:n.isPending||a.isPending||r.isPending||o.isPending}),[l,s,i,f,c,p,n.isPending,a.isPending,r.isPending,o.isPending])}export{D as C,Fe as M,q as U,V as a,Qe as b,We as c,Be as d,K as e,Ze as f,He as g,he as h,Je as i,et as j,je as k,Ye as l,Ke as m,ve as n,Ue as o,ze as p,Ge as q,R as r,xe as s,Se as t,we as u,Ve as v,$e as w,Xe as x};
1
+ import{b as X,aD as B,aE as Q,fq as _,a as C,fr as ee,r as d,f as b,s as y,g as m,fs as te,ft as ne,fu as ae,aZ as A,ba as se,b8 as re,b9 as oe,fv as ie,cr as w,fw as S,fo as ce,cH as de,fx as le,fy as ue,fz as fe,fA as pe,fB as ge,fC as me,fD as Ce,fE as ye}from"./index-4XPoPWhu.js";import{f as I}from"./ErrorState-DcP5ZTMN.js";import{u as G}from"./useQueries-XPiXhlQX.js";const Fe=X("MapPin",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]]);function We(e){return B(Q({title:`Calendar invitation: ${e}`,errorMessage:e}))}function je(e){return B(Q({title:`Calendar event: ${e}`,errorMessage:e}))}const K=()=>Intl.DateTimeFormat().resolvedOptions().timeZone,q="";function Ue(e){if(e!==q)return e;const t=K();return Intl.supportedValuesOf("timeZone").includes(t)?t:q}const Ee={Cal1:"cal-1",Cal2:"cal-2",Cal3:"cal-3",Cal4:"cal-4",Cal5:"cal-5",Cal6:"cal-6"},Z={Unscheduled:"accepted",Organizer:"accepted",Accepted:"accepted",Tentative:"tentative",Declined:"declined",NeedsAction:"noReply"},xe=e=>Z[e],Oe={Local:"local",Explicit:"explicit",Ambiguous:"ambiguous"},z="#";function he(e,t){return t===""?e:`${e}${z}${t}`}function R(e){const t=e.indexOf(z);return t===-1?{calendarObjectId:e,recurrenceId:""}:{calendarObjectId:e.slice(0,t),recurrenceId:e.slice(t+1)}}const H=(e,t)=>{const n=[...e].sort((a,r)=>Date.parse(a.start)-Date.parse(r.start));return n.find(a=>Date.parse(a.end)>Date.parse(t))??n[0]};function $e(e,t,n){const a=H(e.filter(r=>{const o=R(r.id);return o.calendarObjectId===t&&o.recurrenceId!==""}),n);return a?R(a.id):void 0}function F(e,t,n,a){const r=H(e.filter(o=>o.calendarObjectId===t&&ve(o)).map(o=>Se(o,"",a)),n);if(r)return{...R(r.id),calendarId:r.calendarId,date:r.start.slice(0,10)}}function W(e){return{id:e.calendarId,accountId:e.accountConfigId,accountLabel:"",name:e.displayName,color:Ee[e.color]??"cal-1",...e.source==="Subscribed"?{readOnly:!0,sync:e.subscriptionEnabled?"live":"paused",syncError:e.subscriptionError}:{}}}function Se(e,t,n){return{id:he(e.calendarObjectId,e.recurrenceId),calendarId:e.calendarId,title:e.summary,start:e.allDay?e.start.slice(0,10):_(e.start,n),end:e.allDay?e.end.slice(0,10):_(e.end,n),allDay:e.allDay,location:"",notes:"",attendees:[],myRsvp:Z[e.participation],threadId:"",threadSubject:"",timeZone:t,zoneCertainty:Oe[e.zoneCertainty]??"explicit",recurrenceRule:e.hasRecurrence?"Repeats":"",seriesId:e.hasRecurrence?e.icalUid:"",seriesException:!1,status:e.status==="Tentative"?"tentative":"confirmed"}}const ve=e=>e.status!=="Cancelled";function Be(){const{data:e,isLoading:t,error:n,refetch:a}=C(ee());return d.useMemo(()=>{const r=e?.items??[],o=r.filter(i=>i.componentSet!=="VtodoOnly"),l=o.map(W),s=r.filter(i=>i.componentSet==="VtodoOnly").map(W);return{calendars:l,taskLists:s,collections:r,colorByCalendarId:Object.fromEntries(l.map(i=>[i.id,i.color])),timeZoneByCalendarId:Object.fromEntries(r.map(i=>[i.calendarId,i.timezone])),defaultCalendarId:(o.find(i=>i.source==="Default")??o[0])?.calendarId??"",isLoading:t,error:n??null,retry:()=>{a()}}},[e,t,n,a])}const D=y(400,404,412),be=new Set(["calendarEventOperationsListCalendarEvents","calendarEventDetailOperationsGetCalendarEvent","calendarFreeBusyOperationsListCalendarFreeBusy","calendarTaskOperationsListCalendarTasks","calendarTaskDetailOperationsGetCalendarTask"]),j=e=>A(e)===412?{kind:"conflict"}:{kind:"refused",message:I(e)},Ae={this:"This",following:"Following",all:"All"};function V(){const e=b();return d.useCallback(()=>{e.invalidateQueries({predicate:t=>{const n=t.queryKey[0];if(typeof n!="object"||n===null)return!1;const a=n._id;return typeof a=="string"&&be.has(a)}})},[e])}const U=({scope:e,recurrenceId:t})=>e===void 0?{}:{scope:Ae[e],recurrenceId:t};function Qe(){const e=V(),t=m({...te(),meta:D,onSuccess:e}),n=m({...ne(),meta:D,onSuccess:e}),a=m({...ae(),meta:D,onSuccess:e}),r=d.useCallback(s=>t.mutateAsync({body:s}).then(i=>({kind:"created",calendarObjectId:i.calendarObjectId,sends:i.sends})).catch(i=>A(i)===412?{kind:"conflict"}:{kind:"refused",message:I(i)}),[t]),o=d.useCallback((s,i)=>n.mutateAsync({path:{calendarObjectId:s.calendarObjectId},query:{calendarId:s.calendarId,...U(s)},headers:{"If-Match":s.etag},body:i}).then(f=>({kind:"written",sends:f.sends})).catch(j),[n]),l=d.useCallback(s=>a.mutateAsync({path:{calendarObjectId:s.calendarObjectId},query:{calendarId:s.calendarId,...U(s)},headers:{"If-Match":s.etag}}).then(i=>({kind:"written",sends:i.sends})).catch(j),[a]);return d.useMemo(()=>({createEvent:r,updateEvent:o,deleteEvent:l,isWriting:t.isPending||n.isPending||a.isPending}),[r,o,l,t.isPending,n.isPending,a.isPending])}const M=y(400,404),L={kind:"written"},P=e=>({kind:"refused",message:I(e)});function we(){const e=b(),t=V(),n=d.useCallback(()=>e.invalidateQueries({queryKey:se()}),[e]),a=d.useCallback(()=>(t(),n()),[t,n]),r=m({...re(),meta:M,onSuccess:n}),o=m({...oe(),meta:M,onSuccess:a}),l=m({...ie(),meta:M,onSuccess:a}),s=d.useCallback(c=>r.mutateAsync({body:c}).then(()=>L).catch(P),[r]),i=d.useCallback((c,p)=>o.mutateAsync({path:{calendarId:c},body:p}).then(()=>L).catch(P),[o]),f=d.useCallback(c=>l.mutateAsync({path:{calendarId:c}}).then(()=>L).catch(P),[l]);return d.useMemo(()=>({createCalendar:s,updateCalendar:i,deleteCalendar:f,isWriting:r.isPending||o.isPending||l.isPending}),[s,i,f,r.isPending,o.isPending,l.isPending])}const Ie=y(404);function Ge(e,t){const{data:n,isLoading:a,error:r,refetch:o}=C({...w({path:{calendarObjectId:e},query:{calendarId:t}}),meta:Ie,enabled:e!==""&&t!==""});return{resource:n,isLoading:a,error:r,refetch:()=>{o()}}}const Y=y(400,404),k=5*6e4,T=({from:e,to:t,calendarIds:n})=>({query:n.length===0?{from:e,to:t}:{from:e,to:t,calendarId:[...n]}});function Ke(e){const{data:t,isLoading:n,error:a,refetch:r}=C({...S(T(e)),meta:Y,staleTime:k,enabled:e.enabled??!0});return{instances:t?.items??[],isLoading:n,error:a,refetch:()=>{r()}}}function Ze(e,t,n){const a=G({queries:e.map(c=>({...S(T({...c,calendarIds:t})),meta:Y,staleTime:k,enabled:n}))}),r=e.map(c=>c.from).join("|"),o=a.map(c=>c.data),l=a.map(c=>c.isPending).join("|"),s=a.find(c=>c.error)?.error??null,i=d.useMemo(()=>o.flatMap(c=>c?.items??[]),[r,l]),f=d.useMemo(()=>{const c=new Set;return e.forEach((p,u)=>{a[u]?.isPending&&c.add(p.from)}),c},[r,l]);return{instances:i,pendingWindows:f,error:s,refetch:()=>{for(const c of a)c.error&&c.refetch()}}}function ze(e,t,n,a){const r=b(),o=[...n].join(",");d.useEffect(()=>{if(!a)return;const l=o===""?[]:o.split(",");for(const s of[-1,1]){const i=ce(e,de(t,e,s));r.prefetchQuery({...S(T({...i,calendarIds:l})),staleTime:k})}},[r,e,t,o,a])}const ke=y(400,404);function He(e){const t=G({queries:e.map(s=>({...le({query:{from:s.from,to:s.to}}),meta:ke,staleTime:k}))}),n=e.map(s=>s.from).join("|"),a=t.map(s=>s.data),r=t.map(s=>s.isPending).join("|"),o=d.useMemo(()=>a.flatMap(s=>s?.items??[]),[n,r]),l=d.useMemo(()=>{const s=new Set;return e.forEach((i,f)=>{t[f]?.isPending&&s.add(i.from)}),s},[n,r]);return{spans:o,pendingWindows:l,error:t.find(s=>s.error)?.error??null,refetch:()=>{for(const s of t)s.error&&s.refetch()}}}const x=365*24*60*6e4,De=1440*6e4,$=y(),Me=y(404),v=e=>new Date(e).toISOString().replace(/\.\d{3}Z$/,"+00:00"),Le=e=>{const t=e instanceof Error&&e.message!==""?e.message:"no reason given",n=A(e);return n===void 0?t:`${t} (HTTP ${n})`};function Ve(e,t){const[n]=d.useState(()=>Date.now()),a=K(),r=new Date(n).toISOString(),o=C({...S({query:{from:v(n),to:v(n+x),calendarObjectId:e}}),meta:$,retry:!1,enabled:t}),l=o.data?F(o.data.items,e,r,a):void 0,s=C({...w({path:{calendarObjectId:e}}),meta:Me,retry:!1,enabled:t&&o.data!==void 0&&l===void 0}),i=Date.parse(s.data?.dtStart??""),f=s.data!==void 0&&Number.isNaN(i),c=Number.isNaN(i)?0:i-De,p=C({...S({query:{from:v(c),to:v(c+x),calendarObjectId:e}}),meta:$,retry:!1,enabled:t&&s.data!==void 0&&!f}),u=p.data?F(p.data.items,e,r,a):void 0;if(!t)return{kind:"Idle"};if(l)return{kind:"Found",jump:l};if(u)return{kind:"Found",jump:u};const g=A(s.error)===404,N=[o.error,g?null:s.error,p.error].find(J=>J!==null);return N!==void 0?{kind:"Failed",reason:Le(N)}:g?{kind:"Deleted"}:f?{kind:"Failed",reason:`the stored event names no readable start (${s.data?.dtStart??""})`}:p.data!==void 0?{kind:"NoOccurrenceFound"}:{kind:"Searching"}}const E=y(400,404),Pe=new Set(["calendarSuggestionOperationsListCalendarSuggestions","messageCalendarSuggestionOperationsListMessageCalendarSuggestions","calendarEventOperationsListCalendarEvents","calendarEventDetailOperationsGetCalendarEvent","calendarFreeBusyOperationsListCalendarFreeBusy","filterOperationsListFilters"]),Re=e=>e.invalidateQueries({predicate:t=>{const n=t.queryKey[0];if(typeof n!="object"||n===null)return!1;const a=n._id;return typeof a=="string"&&Pe.has(a)}});function Ye(e){const{data:t,isLoading:n,error:a}=C({...ue({path:{messageId:e}}),meta:E});return{suggestions:t?.items??[],isLoading:n,error:a??null}}function Je(){const{data:e,isLoading:t,error:n}=C({...Ce({query:{state:"Pending"}}),meta:E});return{suggestions:e?.items??[],isLoading:t,error:n??null}}const Te=async(e,t)=>{let n;do{const{data:a}=await ye({query:{state:"Pending",continuationToken:n},signal:t,throwOnError:!0}),r=a.items.find(o=>o.suggestionId===e);if(r)return r;n=a.continuationToken}while(n);return null};function Xe(e){const{data:t,isLoading:n,error:a}=C({queryKey:[{_id:"calendarSuggestionOperationsListCalendarSuggestions",suggestionId:e}],queryFn:({signal:r})=>Te(e,r),meta:E});return{suggestion:t,isLoading:n,error:a??null}}const O={kind:"answered"},h=e=>({kind:"refused",message:I(e)});function et(){const e=b(),t=d.useCallback(()=>Re(e),[e]),n=m({...fe(),meta:E,onSuccess:t}),a=m({...pe(),meta:E,onSuccess:t}),r=m({...ge(),meta:E,onSuccess:t}),o=m({...me(),meta:E,onSuccess:t}),l=d.useCallback((u,g)=>n.mutateAsync({path:{suggestionId:u},body:{calendarId:g}}).then(()=>O).catch(h),[n]),s=d.useCallback((u,g)=>n.mutateAsync({path:{suggestionId:u},body:{calendarId:g,answer:"Tentative"}}).then(()=>O).catch(h),[n]),i=d.useCallback((u,g)=>n.mutateAsync({path:{suggestionId:u},body:g}).then(()=>O).catch(h),[n]),f=d.useCallback(u=>a.mutateAsync({path:{suggestionId:u}}).then(()=>O).catch(h),[a]),c=d.useCallback((u,g)=>r.mutateAsync({path:{suggestionId:u},body:{muteSender:g}}).then(()=>O).catch(h),[r]),p=d.useCallback(u=>o.mutateAsync({path:{suggestionId:u}}).then(()=>O).catch(h),[o]);return d.useMemo(()=>({accept:l,tentative:s,acceptEdited:i,decline:f,dismiss:c,reopen:p,isAnswering:n.isPending||a.isPending||r.isPending||o.isPending}),[l,s,i,f,c,p,n.isPending,a.isPending,r.isPending,o.isPending])}export{D as C,Fe as M,q as U,V as a,Be as b,je as c,Qe as d,K as e,Ze as f,He as g,he as h,Je as i,et as j,We as k,Ye as l,Ke as m,ve as n,Ue as o,ze as p,Ge as q,R as r,$e as s,Se as t,we as u,Ve as v,xe as w,Xe as x};
@@ -1 +1 @@
1
- import{r as u,j as O,q as v,g as y,fH as P,fI as q,fJ as W,a as E,fK as R,aZ as I,fL as j,s as D}from"./index-Q7BlLS9p.js";import{f as z}from"./ErrorState-BjlNwjgd.js";import{a as H,C as k}from"./useCalendarSuggestions-DHNLR9_9.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 N='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function _({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 L=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)},S=n=>{if(!f||n.key!=="Tab")return;const d=Array.from(n.currentTarget.querySelectorAll(N));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:S,className:v("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:L}),r]})}const F=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 J(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 Q(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.":z(e)});function V(){const e=H(),t=y({...P(),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{_ as C,J as a,Q as b,F as t,V as u};
1
+ import{r as u,j as O,q as v,g as y,fV as P,fW as q,fX as W,a as E,fY as R,aZ as I,fZ as j,s as D}from"./index-4XPoPWhu.js";import{f as z}from"./ErrorState-DcP5ZTMN.js";import{a as X,C as k}from"./useCalendarSuggestions-D6k1REyo.js";const i=8,x=(e,t,a)=>Math.min(Math.max(e,t),Math.max(t,a)),Y=(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 B(e,t,a){if(!e||!Y(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 G='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function V({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(B(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 L=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)},S=n=>{if(!f||n.key!=="Tab")return;const d=Array.from(n.currentTarget.querySelectorAll(G));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:S,className:v("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:L}),r]})}const Z=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 _(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 F(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.":z(e)});function Q(){const e=X(),t=y({...P(),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{V as C,_ as a,F as b,Z as t,Q as u};
@@ -1 +1 @@
1
- import{r as o}from"./index-Q7BlLS9p.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-4XPoPWhu.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{r as d,g as h,fr as x,a as A,fs as P,ft as N,fu as L,f as S,fv as T,fw as I,fx as w,fy as z,bc as R}from"./index-Q7BlLS9p.js";const G=(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},O={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."},X=e=>e.disabledReason==="None"?void 0:(e.disabledReason==="AwaitingFolder"||e.disabledReason==="FolderCreateFailed")&&e.actionMailboxId!=="None"?O.UserDisabled:O[e.disabledReason],Z=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"})},M=(e,t=new Date)=>{if(!e)return;const r=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!r)return;const[,s,i,a]=r,n=new Date(Number(s),Number(i)-1,Number(a),23,59,59,0);if(Number.isNaN(n.getTime()))return;const o=-t.getTimezoneOffset(),l=o>=0?"+":"-",c=Math.abs(o),f=String(Math.floor(c/60)).padStart(2,"0"),p=String(c%60).padStart(2,"0"),u=m=>String(m).padStart(2,"0");return`${n.getFullYear()}-${u(n.getMonth()+1)}-${u(n.getDate())}T${u(n.getHours())}:${u(n.getMinutes())}:${u(n.getSeconds())}${l}${f}:${p}`},g="None",k=e=>({filterId:e,matchOperator:"And",literalClauses:[],actionLabelId:g,actionMailboxId:g}),D=e=>({matchOperator:e.matchOperator,literalClauses:e.literalClauses,actionLabelId:e.labelId??g,actionMailboxId:e.moveMailboxId??g}),ee=({mode:e,ruleScope:t})=>t==="standing"?"standing":t==="until"?"temporary":e==="selected"?"just-these":"all-like-these",te=({ruleScope:e,clauses:t,matchOperator:r,moveMailboxId:s,until:i})=>({matchOperator:r==="all"?"And":"Or",literalClauses:t.map(a=>({field:a.field,value:a.value})),moveMailboxId:s,expiresAt:e==="until"?M(i??""):void 0}),y=(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??g,actionMailboxId:e.moveMailboxId??g}),_=new Set(["Complete","Failed"]),F=e=>e!==void 0&&_.has(e),J=1e3,$=15e3,U=e=>{const t=Math.max(0,e),r=J*2**t;return Math.min(r,$)},q=(e,t,r)=>{if(e)return{kind:r?"restartFailed":"startFailed",error:e};if(t)return{kind:"statusUnreadable",error:t}},re=e=>{const[t,r]=d.useState(),s=h({...x(),onSuccess:b=>r(b.organizeJobId)}),{mutate:i}=s,a=A({...P({path:{accountId:e??"",organizeJobId:t??""}}),enabled:!!e&&!!t,refetchInterval:b=>{const E=b.state.data?.state;return F(E)?!1:U(b.state.dataUpdateCount)}}),n=d.useCallback(b=>{e&&i({path:{accountId:e},body:D(b)})},[e,i]),o=d.useCallback(b=>{e&&i({path:{accountId:e},body:k(b)})},[e,i]),{refetch:l}=a,c=d.useCallback(()=>{l()},[l]),f=a.data,p=s.isPending?void 0:f,u=p?.state??s.data?.state,m=F(p?.state),v={state:u,matchedCount:p?.matchedCount??0,appliedCount:p?.appliedCount??0,failedCount:p?.failedCount??0,errorMessage:p?.errorMessage??""};return{start:n,startForFilter:o,watch:r,refreshStatus:c,progress:v,isStarting:s.isPending,isRunning:!!t&&!m,isDone:m,failure:q(s.error,a.error,!!f)}},se=["From","Subject","HasWords","ListId","FromDomain"],Q=e=>{const t=e.trim(),r=t.match(/<([^>]+)>/);return(r?r[1]:t).trim().toLowerCase()},ae=(e,t)=>e==="ListId"?Q(t):t.trim(),j=e=>e==="all"?"And":"Or",K=e=>({matchOperator:j(e.matchOperator),literalClauses:e.clauses.map(t=>({field:t.field,value:t.value}))}),B=e=>!e.literalClauses.some(t=>t.field==="HasWords"),H=e=>JSON.stringify({operator:e.matchOperator,clauses:e.literalClauses.map(t=>`${t.field} ${t.value}`)}),ie=e=>{const t=K(e);return{matchOperator:t.matchOperator,literalClauses:t.literalClauses,moveMailboxId:e.moveMailboxId,labelId:e.labelId,expiresAt:e.scope==="until"?M(e.until??""):void 0}},W=(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},V=350,ne=(e,t,r)=>{const s=h(N()),{mutateAsync:i}=s,a=H(t),[n,o]=d.useState(()=>({})),l=d.useRef(t);l.current=t;const c=d.useRef(a),f=B(t);return d.useEffect(()=>{if(!e||!f||a===n.previewedSignature||a===n.errorSignature)return;const p=setTimeout(()=>{const u=a;c.current=u,i({path:{accountId:e},body:D({...l.current})}).then(m=>{c.current===u&&o({count:m.matchedCount,matchedIds:m.messageIds,previewedSignature:u})}).catch(m=>{c.current===u&&o(v=>({...v,error:m instanceof Error?m.message:"Couldn't count matches.",errorSignature:u}))})},V);return()=>clearTimeout(p)},[e,f,a,n.previewedSignature,n.errorSignature,i]),f?{count:W(n,a),matchedIds:n.previewedSignature===a?n.matchedIds??[]:[]}:{count:{status:"error",reason:L},matchedIds:[]}},C=e=>I({path:{accountId:e}}),oe=e=>{const t=A({...w({path:{accountId:e??""}}),enabled:!!e});return{filters:t.data?.items??[],isPending:t.isPending,isError:t.isError,error:t.error,refetch:t.refetch}},le=e=>{const t=S(),r=h({...T(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:C(e)})}}),{mutate:s,mutateAsync:i}=r,a=d.useCallback((o,l,c)=>{e&&s({path:{accountId:e},body:y(o,l,c)})},[e,s]),n=d.useCallback(async(o,l,c)=>{if(e)return i({path:{accountId:e},body:y(o,l,c)}).then(f=>f,()=>{})},[e,i]);return{createFilter:a,createFilterAsync:n,data:r.data,isPending:r.isPending,isSuccess:r.isSuccess,isError:r.isError,error:r.error,reset:r.reset}},ue=e=>{const t=S(),r=h({...z(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:C(e)})}}),{mutate:s}=r;return{deleteFilter:d.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=h({...R(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:C(e)})}}),{mutate:s,variables:i}=r,a=d.useCallback((o,l)=>{e&&s({path:{accountId:e,filterId:o},body:{state:l?"Active":"Disabled"}})},[e,s]),n=d.useCallback(()=>{i&&s(i)},[s,i]);return{toggleFilter:a,retry:n,togglingFilterId:r.isPending?i?.path.filterId:void 0,isError:r.isError,error:r.error,enabling:i?.body?.state==="Active"}};export{g as N,se as S,re as a,C as b,ie as c,X as d,Z as e,G as f,oe as g,ue as h,de as i,le as j,te as k,ae as n,ee as o,M as p,K as r,ne as u};
1
+ import{r as d,g as h,fF as x,a as M,fG as P,fH as N,fI as L,f as v,fJ as I,fK as T,fL as z,fM as R,bc as w}from"./index-4XPoPWhu.js";const Y=(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},O={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."},X=e=>e.disabledReason==="None"?void 0:(e.disabledReason==="AwaitingFolder"||e.disabledReason==="FolderCreateFailed")&&e.actionMailboxId!=="None"?O.UserDisabled:O[e.disabledReason],Z=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"})},A=(e,t=new Date)=>{if(!e)return;const r=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!r)return;const[,s,i,a]=r,n=new Date(Number(s),Number(i)-1,Number(a),23,59,59,0);if(Number.isNaN(n.getTime()))return;const o=-t.getTimezoneOffset(),l=o>=0?"+":"-",c=Math.abs(o),f=String(Math.floor(c/60)).padStart(2,"0"),p=String(c%60).padStart(2,"0"),u=m=>String(m).padStart(2,"0");return`${n.getFullYear()}-${u(n.getMonth()+1)}-${u(n.getDate())}T${u(n.getHours())}:${u(n.getMinutes())}:${u(n.getSeconds())}${l}${f}:${p}`},g="None",k=e=>({filterId:e,matchOperator:"And",literalClauses:[],actionLabelId:g,actionMailboxId:g}),D=e=>({matchOperator:e.matchOperator,literalClauses:e.literalClauses,actionLabelId:e.labelId??g,actionMailboxId:e.moveMailboxId??g}),ee=({mode:e,ruleScope:t})=>t==="standing"?"standing":t==="until"?"temporary":e==="selected"?"just-these":"all-like-these",te=({ruleScope:e,clauses:t,matchOperator:r,moveMailboxId:s,until:i})=>({matchOperator:r==="all"?"And":"Or",literalClauses:t.map(a=>({field:a.field,value:a.value})),moveMailboxId:s,expiresAt:e==="until"?A(i??""):void 0}),y=(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??g,actionMailboxId:e.moveMailboxId??g}),_=new Set(["Complete","Failed"]),F=e=>e!==void 0&&_.has(e),J=1e3,$=15e3,U=e=>{const t=Math.max(0,e),r=J*2**t;return Math.min(r,$)},q=(e,t,r)=>{if(e)return{kind:r?"restartFailed":"startFailed",error:e};if(t)return{kind:"statusUnreadable",error:t}},re=e=>{const[t,r]=d.useState(),s=h({...x(),onSuccess:b=>r(b.organizeJobId)}),{mutate:i}=s,a=M({...P({path:{accountId:e??"",organizeJobId:t??""}}),enabled:!!e&&!!t,refetchInterval:b=>{const E=b.state.data?.state;return F(E)?!1:U(b.state.dataUpdateCount)}}),n=d.useCallback(b=>{e&&i({path:{accountId:e},body:D(b)})},[e,i]),o=d.useCallback(b=>{e&&i({path:{accountId:e},body:k(b)})},[e,i]),{refetch:l}=a,c=d.useCallback(()=>{l()},[l]),f=a.data,p=s.isPending?void 0:f,u=p?.state??s.data?.state,m=F(p?.state),S={state:u,matchedCount:p?.matchedCount??0,appliedCount:p?.appliedCount??0,failedCount:p?.failedCount??0,errorMessage:p?.errorMessage??""};return{start:n,startForFilter:o,watch:r,refreshStatus:c,progress:S,isStarting:s.isPending,isRunning:!!t&&!m,isDone:m,failure:q(s.error,a.error,!!f)}},se=["From","Subject","HasWords","ListId","FromDomain"],Q=e=>{const t=e.trim(),r=t.match(/<([^>]+)>/);return(r?r[1]:t).trim().toLowerCase()},ae=(e,t)=>e==="ListId"?Q(t):t.trim(),K=e=>e==="all"?"And":"Or",j=e=>({matchOperator:K(e.matchOperator),literalClauses:e.clauses.map(t=>({field:t.field,value:t.value}))}),H=e=>!e.literalClauses.some(t=>t.field==="HasWords"),B=e=>JSON.stringify({operator:e.matchOperator,clauses:e.literalClauses.map(t=>`${t.field} ${t.value}`)}),ie=e=>{const t=j(e);return{matchOperator:t.matchOperator,literalClauses:t.literalClauses,moveMailboxId:e.moveMailboxId,labelId:e.labelId,expiresAt:e.scope==="until"?A(e.until??""):void 0}},W=(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},G=350,ne=(e,t,r)=>{const s=h(N()),{mutateAsync:i}=s,a=B(t),[n,o]=d.useState(()=>({})),l=d.useRef(t);l.current=t;const c=d.useRef(a),f=H(t);return d.useEffect(()=>{if(!e||!f||a===n.previewedSignature||a===n.errorSignature)return;const p=setTimeout(()=>{const u=a;c.current=u,i({path:{accountId:e},body:D({...l.current})}).then(m=>{c.current===u&&o({count:m.matchedCount,matchedIds:m.messageIds,previewedSignature:u})}).catch(m=>{c.current===u&&o(S=>({...S,error:m instanceof Error?m.message:"Couldn't count matches.",errorSignature:u}))})},G);return()=>clearTimeout(p)},[e,f,a,n.previewedSignature,n.errorSignature,i]),f?{count:W(n,a),matchedIds:n.previewedSignature===a?n.matchedIds??[]:[]}:{count:{status:"error",reason:L},matchedIds:[]}},C=e=>T({path:{accountId:e}}),oe=e=>{const t=M({...z({path:{accountId:e??""}}),enabled:!!e});return{filters:t.data?.items??[],isPending:t.isPending,isError:t.isError,error:t.error,refetch:t.refetch}},le=e=>{const t=v(),r=h({...I(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:C(e)})}}),{mutate:s,mutateAsync:i}=r,a=d.useCallback((o,l,c)=>{e&&s({path:{accountId:e},body:y(o,l,c)})},[e,s]),n=d.useCallback(async(o,l,c)=>{if(e)return i({path:{accountId:e},body:y(o,l,c)}).then(f=>f,()=>{})},[e,i]);return{createFilter:a,createFilterAsync:n,data:r.data,isPending:r.isPending,isSuccess:r.isSuccess,isError:r.isError,error:r.error,reset:r.reset}},ue=e=>{const t=v(),r=h({...R(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:C(e)})}}),{mutate:s}=r;return{deleteFilter:d.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=v(),r=h({...w(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:C(e)})}}),{mutate:s,variables:i}=r,a=d.useCallback((o,l)=>{e&&s({path:{accountId:e,filterId:o},body:{state:l?"Active":"Disabled"}})},[e,s]),n=d.useCallback(()=>{i&&s(i)},[s,i]);return{toggleFilter:a,retry:n,togglingFilterId:r.isPending?i?.path.filterId:void 0,isError:r.isError,error:r.error,enabling:i?.body?.state==="Active"}};export{g as N,se as S,re as a,C as b,ie as c,X as d,Z as e,Y as f,oe as g,ue as h,de as i,le as j,te as k,ae as n,ee as o,A as p,j as r,ne as u};
@@ -1 +1 @@
1
- import{a as L,f1 as p,f as n,g as l,f2 as d,r as o,f3 as y,f4 as f,f5 as c}from"./index-Q7BlLS9p.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}},m=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}},h=e=>{const r=n(),t=l({...f(),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({...c(),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,h as b,C as c,m as u};
1
+ import{a as L,ff as p,f as n,g as l,fg as d,r as o,fh as y,fi as f,fj as g}from"./index-4XPoPWhu.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({...f(),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};
@@ -0,0 +1 @@
1
+ import"./index-4XPoPWhu.js";import{a as s,D as e}from"./useMediaQuery-a7SamL-l.js";const i=768,a=t=>t!=="desktop",p=()=>{const t=s(`(min-width: ${i}px)`);return s(e)?"desktop":t?"tablet":"phone"};export{a as i,p as u};
@@ -1 +1 @@
1
- import{r as s}from"./index-Q7BlLS9p.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-4XPoPWhu.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 +1 @@
1
- import{r as a,u as P,cC as O,J as p,n as U,aa as B,f as N,a as $,d6 as D,cX as L}from"./index-Q7BlLS9p.js";import{g as F,j as _,k as v}from"./reply-BRbg9_Ak.js";const E="/mail/brief/compose/{-$outboxMessageId}",w="/mail/flagged/compose/{-$outboxMessageId}",S="/mail/outbox/compose/{-$outboxMessageId}",R="/mail/$mailboxId/compose/{-$outboxMessageId}";function T(){const e=p({from:E,shouldThrow:!1}),t=p({from:w,shouldThrow:!1}),s=p({from:S,shouldThrow:!1}),r=p({from:R,shouldThrow:!1});return e??t??s??r}function te(){return T()!==void 0}function se(){return T()?.outboxMessageId}function K(e,t,s){return e==="flagged"?{to:w,params:{outboxMessageId:s}}:e==="outbox"?{to:S,params:{outboxMessageId:s}}:e==="mailbox"&&t?{to:R,params:{mailboxId:t,outboxMessageId:s}}:{to:E,params:{outboxMessageId:s}}}function b(){const e=P(),t=F(),{list:s,mailboxId:r}=_();return a.useCallback((o,n)=>{e({...K(s,r,o),search:O,hash:n?.keepPanels?!0:t,replace:n?.replace??!1})},[e,t,s,r])}function re(){const e=b();return a.useCallback(()=>e(void 0),[e])}function oe(){const e=b();return a.useCallback(t=>e(t),[e])}function ne(){const e=b();return a.useCallback(t=>e(t,{replace:!0,keepPanels:!0}),[e])}function ae(){return v()}const Q=new Set(["rfc822","global"]),q=e=>e.mediaType.toUpperCase()==="MESSAGE"&&Q.has(e.mediaSubtype.toLowerCase()),k=(e,t)=>e.partPath.startsWith(`${t}.`),I=e=>{const t=e.filter(q);return e.filter(s=>!t.some(r=>k(s,r.partPath)))},ce=(e,t)=>e.filter(s=>k(s,t)),X=e=>{const t=I(e).filter(o=>!o.isMultipart&&o.disposition!=="attachment"&&o.mediaType==="TEXT"&&o.contentUrl.length>0),s=t.find(o=>o.mediaSubtype.toUpperCase()==="HTML");if(s)return{kind:"html",contentUrl:s.contentUrl};const r=t.find(o=>o.mediaSubtype.toUpperCase()==="PLAIN");return r?{kind:"text",contentUrl:r.contentUrl}:null},g={all:["messages"],detail:e=>[...g.all,"detail",e],body:e=>[...g.detail(e),"body"]};class f extends Error{reason;status;retryAfterSeconds;constructor(t,s,r,o){super(s),this.name="BodyFetchError",this.reason=t,this.status=r,this.retryAfterSeconds=o}}const G=e=>{const t=Number.parseInt(e??"",10);return!Number.isFinite(t)||t<=0?1:Math.min(t,30)},W=8,H="x-remit-403-reason",Y=(e,t)=>{const s=t?.trim()??"";return e===401?"auth":e===403?s.length>0?"auth":"body-missing":e===404?"body-missing":"generic"},j=(e,t)=>(t??"").toLowerCase().startsWith("text/html")?/<div\s+id=["']root["']/i.test(e):!1,z=(e,t)=>{const s=(t??"").toLowerCase();return!!(e==="text"&&s.startsWith("text/html"))},J=async(e,t,s=async()=>null)=>{const r={},o=await s();o&&(r.Authorization=`Bearer ${o}`);const n=await L(e,{headers:r});if(n.status===202)throw new f("not-ready","Message body is still syncing",202,G(n.headers.get("Retry-After")));if(!n.ok){const l=n.headers.get(H),h=Y(n.status,l);throw new f(h,`Failed to load message body (${n.status} ${n.statusText})`,n.status)}const c=n.headers.get("content-type");if(z(t,c))throw new f("content-type-mismatch",`Refusing to render message body — expected ${t}, got Content-Type ${c}`);const m=await n.text();if(j(m,c))throw new f("spa-shell-leak","Refusing to render message body — response looks like the SPA shell (CloudFront 403/404 fallback leaked through to /content/*)");return m},V=async(e,t)=>(t.isRetryAfterNotReady&&await e.refetchDescribeMessage(),e.fetchContent(t.contentUrl,t.kind)),ie=({messageId:e,bodyParts:t,enabled:s=!0})=>{const r=t?X(t):null,o=U(),{getToken:n}=B(),c=a.useRef(null),m=N(),l=a.useRef(!1),h=a.useRef(null),C=e&&r?`${e}:${r.contentUrl}`:null;h.current!==C&&(h.current=C,l.current=!1);const i=$({queryKey:e?[...g.body(e),r?.contentUrl??null]:["messages","body","noop"],queryFn:()=>{if(!r)throw new Error("No renderable body part");if(!e)throw new Error("No messageId");const d=l.current;return l.current=!1,V({fetchContent:(u,x)=>J(u,x,n),refetchDescribeMessage:()=>m.refetchQueries({queryKey:D({path:{messageId:e}})})},{contentUrl:r.contentUrl,kind:r.kind,isRetryAfterNotReady:d})},enabled:s&&!!e&&!!r,staleTime:300*1e3,gcTime:1800*1e3,retry:(d,u)=>u instanceof f&&u.reason==="not-ready"?d<W:d<1,retryDelay:(d,u)=>u instanceof f&&u.reason==="not-ready"?(l.current=!0,(u.retryAfterSeconds??1)*1e3):1e3,meta:{softError:!0}}),y=i.isLoading&&!!r,A=t!==void 0&&r===null;a.useEffect(()=>{y&&(c.current=performance.now())},[y]),a.useEffect(()=>{i.isSuccess&&c.current!==null&&(o.recordTiming("message.body.load",Math.round(performance.now()-c.current)),c.current=null)},[i.isSuccess,o]);const M=i.data&&r?{kind:r.kind,body:i.data}:void 0;return{picked:r,data:M,isLoading:y,hasNoRenderablePart:A,isError:i.isError,error:i.error,refetch:i.refetch}};export{f as B,te as a,ie as b,Y as c,se as d,ne as e,ae as f,oe as g,ce as h,q as i,I as o,re as u};
1
+ import{r as a,u as P,cQ as O,J as p,n as U,aa as B,f as N,a as $,dk as D,d9 as L}from"./index-4XPoPWhu.js";import{g as F,j as _,k as v}from"./reply-FoVQqDdv.js";const E="/mail/brief/compose/{-$outboxMessageId}",w="/mail/flagged/compose/{-$outboxMessageId}",S="/mail/outbox/compose/{-$outboxMessageId}",R="/mail/$mailboxId/compose/{-$outboxMessageId}";function k(){const e=p({from:E,shouldThrow:!1}),t=p({from:w,shouldThrow:!1}),s=p({from:S,shouldThrow:!1}),r=p({from:R,shouldThrow:!1});return e??t??s??r}function te(){return k()!==void 0}function se(){return k()?.outboxMessageId}function Q(e,t,s){return e==="flagged"?{to:w,params:{outboxMessageId:s}}:e==="outbox"?{to:S,params:{outboxMessageId:s}}:e==="mailbox"&&t?{to:R,params:{mailboxId:t,outboxMessageId:s}}:{to:E,params:{outboxMessageId:s}}}function b(){const e=P(),t=F(),{list:s,mailboxId:r}=_();return a.useCallback((o,n)=>{e({...Q(s,r,o),search:O,hash:n?.keepPanels?!0:t,replace:n?.replace??!1})},[e,t,s,r])}function re(){const e=b();return a.useCallback(()=>e(void 0),[e])}function oe(){const e=b();return a.useCallback(t=>e(t),[e])}function ne(){const e=b();return a.useCallback(t=>e(t,{replace:!0,keepPanels:!0}),[e])}function ae(){return v()}const K=new Set(["rfc822","global"]),q=e=>e.mediaType.toUpperCase()==="MESSAGE"&&K.has(e.mediaSubtype.toLowerCase()),T=(e,t)=>e.partPath.startsWith(`${t}.`),I=e=>{const t=e.filter(q);return e.filter(s=>!t.some(r=>T(s,r.partPath)))},ce=(e,t)=>e.filter(s=>T(s,t)),G=e=>{const t=I(e).filter(o=>!o.isMultipart&&o.disposition!=="attachment"&&o.mediaType==="TEXT"&&o.contentUrl.length>0),s=t.find(o=>o.mediaSubtype.toUpperCase()==="HTML");if(s)return{kind:"html",contentUrl:s.contentUrl};const r=t.find(o=>o.mediaSubtype.toUpperCase()==="PLAIN");return r?{kind:"text",contentUrl:r.contentUrl}:null},g={all:["messages"],detail:e=>[...g.all,"detail",e],body:e=>[...g.detail(e),"body"]};class f extends Error{reason;status;retryAfterSeconds;constructor(t,s,r,o){super(s),this.name="BodyFetchError",this.reason=t,this.status=r,this.retryAfterSeconds=o}}const W=e=>{const t=Number.parseInt(e??"",10);return!Number.isFinite(t)||t<=0?1:Math.min(t,30)},X=8,H="x-remit-403-reason",Y=(e,t)=>{const s=t?.trim()??"";return e===401?"auth":e===403?s.length>0?"auth":"body-missing":e===404?"body-missing":"generic"},j=(e,t)=>(t??"").toLowerCase().startsWith("text/html")?/<div\s+id=["']root["']/i.test(e):!1,z=(e,t)=>{const s=(t??"").toLowerCase();return!!(e==="text"&&s.startsWith("text/html"))},J=async(e,t,s=async()=>null)=>{const r={},o=await s();o&&(r.Authorization=`Bearer ${o}`);const n=await L(e,{headers:r});if(n.status===202)throw new f("not-ready","Message body is still syncing",202,W(n.headers.get("Retry-After")));if(!n.ok){const l=n.headers.get(H),h=Y(n.status,l);throw new f(h,`Failed to load message body (${n.status} ${n.statusText})`,n.status)}const c=n.headers.get("content-type");if(z(t,c))throw new f("content-type-mismatch",`Refusing to render message body — expected ${t}, got Content-Type ${c}`);const m=await n.text();if(j(m,c))throw new f("spa-shell-leak","Refusing to render message body — response looks like the SPA shell (CloudFront 403/404 fallback leaked through to /content/*)");return m},V=async(e,t)=>(t.isRetryAfterNotReady&&await e.refetchDescribeMessage(),e.fetchContent(t.contentUrl,t.kind)),ie=({messageId:e,bodyParts:t,enabled:s=!0})=>{const r=t?G(t):null,o=U(),{getToken:n}=B(),c=a.useRef(null),m=N(),l=a.useRef(!1),h=a.useRef(null),C=e&&r?`${e}:${r.contentUrl}`:null;h.current!==C&&(h.current=C,l.current=!1);const i=$({queryKey:e?[...g.body(e),r?.contentUrl??null]:["messages","body","noop"],queryFn:()=>{if(!r)throw new Error("No renderable body part");if(!e)throw new Error("No messageId");const d=l.current;return l.current=!1,V({fetchContent:(u,x)=>J(u,x,n),refetchDescribeMessage:()=>m.refetchQueries({queryKey:D({path:{messageId:e}})})},{contentUrl:r.contentUrl,kind:r.kind,isRetryAfterNotReady:d})},enabled:s&&!!e&&!!r,staleTime:300*1e3,gcTime:1800*1e3,retry:(d,u)=>u instanceof f&&u.reason==="not-ready"?d<X:d<1,retryDelay:(d,u)=>u instanceof f&&u.reason==="not-ready"?(l.current=!0,(u.retryAfterSeconds??1)*1e3):1e3,meta:{softError:!0}}),y=i.isLoading&&!!r,A=t!==void 0&&r===null;a.useEffect(()=>{y&&(c.current=performance.now())},[y]),a.useEffect(()=>{i.isSuccess&&c.current!==null&&(o.recordTiming("message.body.load",Math.round(performance.now()-c.current)),c.current=null)},[i.isSuccess,o]);const M=i.data&&r?{kind:r.kind,body:i.data}:void 0;return{picked:r,data:M,isLoading:y,hasNoRenderablePart:A,isError:i.isError,error:i.error,refetch:i.refetch}};export{f as B,te as a,ie as b,Y as c,se as d,ne as e,ae as f,oe as g,ce as h,q as i,I as o,re as u};
@@ -0,0 +1 @@
1
+ import{dl as Q,dm as y,dn as w,dp as S,dq as C,f as k,dr as q,ds as x,r as p,dt as M,du as H,dv as L,dw as P,dx as O,dy as B,dz as z}from"./index-4XPoPWhu.js";function R(r,s){const e=new Set(s);return r.filter(t=>!e.has(t))}function A(r,s,e){const t=r.slice(0);return t[s]=e,t}var T=class extends Q{#i;#s;#n;#r;#e;#t;#o;#u;#h;#a=[];constructor(r,s,e){super(),this.#i=r,this.#r=e,this.#n=[],this.#e=[],this.#s=[],this.setQueries(s)}onSubscribe(){this.listeners.size===1&&this.#e.forEach(r=>{r.subscribe(s=>{this.#f(r,s)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#e.forEach(r=>{r.destroy()})}setQueries(r,s){this.#n=r,this.#r=s,y.batch(()=>{const e=this.#e,t=this.#d(this.#n);t.forEach(o=>o.observer.setOptions(o.defaultedQueryOptions));const i=t.map(o=>o.observer),n=i.map(o=>o.getCurrentResult()),u=e.length!==i.length,c=i.some((o,f)=>o!==e[f]),d=u||c,b=d?!0:n.some((o,f)=>{const g=this.#s[f];return!g||!w(o,g)});!d&&!b||(d&&(this.#a=t,this.#e=i),this.#s=n,this.hasListeners()&&(d&&(R(e,i).forEach(o=>{o.destroy()}),R(i,e).forEach(o=>{o.subscribe(f=>{this.#f(o,f)})})),this.#p()))})}getCurrentResult(){return this.#s}getQueries(){return this.#e.map(r=>r.getCurrentQuery())}getObservers(){return this.#e}getOptimisticResult(r,s){const e=this.#d(r),t=e.map(n=>n.observer.getOptimisticResult(n.defaultedQueryOptions)),i=e.map(n=>n.defaultedQueryOptions.queryHash);return[t,n=>this.#l(n??t,s,i),()=>this.#c(t,e)]}#c(r,s){return s.map((e,t)=>{const i=r[t];return e.defaultedQueryOptions.notifyOnChangeProps?i:e.observer.trackResult(i,n=>{s.forEach(u=>{u.observer.trackProp(n)})})})}#l(r,s,e){if(s){const t=this.#h,i=e!==void 0&&t!==void 0&&(t.length!==e.length||e.some((n,u)=>n!==t[u]));return(!this.#t||this.#s!==this.#u||i||s!==this.#o)&&(this.#o=s,this.#u=this.#s,e!==void 0&&(this.#h=e),this.#t=S(this.#t,s(r))),this.#t}return r}#b(){return this.#r?.combine!==void 0&&this.#e.some((r,s)=>r.options.suspense&&this.#s[s]?.data===void 0)}#d(r){const s=new Map;this.#e.forEach(t=>{const i=t.options.queryHash;if(!i)return;const n=s.get(i);n?n.push(t):s.set(i,[t])});const e=[];return r.forEach(t=>{const i=this.#i.defaultQueryOptions(t),u=s.get(i.queryHash)?.shift()??new C(this.#i,i);e.push({defaultedQueryOptions:i,observer:u})}),e}#f(r,s){const e=this.#e.indexOf(r);e!==-1&&(this.#s=A(this.#s,e,s),this.#p())}#p(){if(this.hasListeners()){const r=this.#c(this.#s,this.#a),s=this.#b(),e=this.#t,t=s?e:this.#l(r,this.#r?.combine);(s||e!==t)&&y.batch(()=>{this.listeners.forEach(i=>{i(this.#s)})})}}};function U({queries:r,...s},e){const t=k(),i=q(),n=x(),u=p.useMemo(()=>r.map(h=>{const a=t.defaultQueryOptions(h);return a._optimisticResults=i?"isRestoring":"optimistic",a}),[r,t,i]);u.forEach(h=>{M(h);const a=t.getQueryCache().get(h.queryHash);H(h,n,a)}),L(n);const[c]=p.useState(()=>new T(t,u,s)),[d,b,o]=c.getOptimisticResult(u,s.combine),f=!i&&s.subscribed!==!1;p.useSyncExternalStore(p.useCallback(h=>f?c.subscribe(y.batchCalls(h)):P,[c,f]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),p.useEffect(()=>{c.setQueries(u,s)},[u,s,c]);const m=d.some((h,a)=>O(u[a],h))?d.flatMap((h,a)=>{const l=u[a];if(l&&O(l,h)){const E=new C(t,l);return B(l,E,n)}return[]}):[];if(m.length>0)throw Promise.all(m);const v=d.find((h,a)=>{const l=u[a];return l&&z({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{U as u};
@@ -1 +1 @@
1
- import{j as E,w as K,q as Q,B as U,f as T,N as B,r as o,aP as R,R as $,U as z,n as G,a2 as I,a3 as X,a6 as V}from"./index-Q7BlLS9p.js";import{C as J}from"./circle-check-big-DtREikeq.js";import{R as Y}from"./refresh-cw-CIoRjIJp.js";import{u as P}from"./useQueries-BNgXdYau.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(J,{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},q=(e,s)=>{const t=[];for(const[r,a]of s)a>(e.get(r)??0)&&t.push(r);return t},se=(e,s)=>q(e,s).length>0,F=o.createContext(null),ne=()=>{const e=o.useContext(F);if(!e)throw new Error("useMailFreshness must be used inside <MailFreshnessProvider>");return e};function pe({accountIds:e,children:s}){const t=T(),{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=q(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(F.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,N={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?N:{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=>{V(e,{softError:!0})},O=(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 O(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:()=>O(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=T(),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
+ import{j as E,w as K,q as Q,B as U,f as T,N as B,r as o,aP as R,R as $,U as z,n as G,a2 as I,a3 as X,a6 as V}from"./index-4XPoPWhu.js";import{C as J}from"./circle-check-big-BrmrabN6.js";import{R as Y}from"./refresh-cw-BERt5E10.js";import{u as P}from"./useQueries-XPiXhlQX.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(J,{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},q=(e,s)=>{const t=[];for(const[r,a]of s)a>(e.get(r)??0)&&t.push(r);return t},se=(e,s)=>q(e,s).length>0,F=o.createContext(null),ne=()=>{const e=o.useContext(F);if(!e)throw new Error("useMailFreshness must be used inside <MailFreshnessProvider>");return e};function pe({accountIds:e,children:s}){const t=T(),{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=q(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(F.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,N={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?N:{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=>{V(e,{softError:!0})},O=(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 O(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:()=>O(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=T(),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,W as o,r as n,bR as r}from"./index-Q7BlLS9p.js";import{u as d}from"./useQueries-BNgXdYau.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,W as o,r as n,c3 as r}from"./index-4XPoPWhu.js";import{u as d}from"./useQueries-XPiXhlQX.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{f as g,ap as p,a as f,c as m,r,g as y,ar as T,l as E,i as x}from"./index-Q7BlLS9p.js";const i={html:"",plainText:""},d=e=>{const u=g(),{pushError:o}=p(),{data:n}=f({...m(),staleTime:1/0}),l=r.useMemo(()=>{if(!e||!n)return i;const t=n.accounts.find(a=>a.accountId===e);return t?{html:t.signatureHtml??"",plainText:t.signaturePlainText??""}:i},[e,n]),s=y({...x(),onSuccess:()=>{u.invalidateQueries({queryKey:E()})},onError:t=>{o(T("Couldn't save signature","The signature wasn't saved.",t))}}),c=r.useCallback((t,a)=>{e&&s.mutate({path:{accountId:e},body:{signatureHtml:t,signaturePlainText:a}})},[e,s]);return{signature:l,setSignature:c,isSaving:s.isPending}};export{d as u};
1
+ import{f as g,ap as p,a as f,c as m,r,g as y,ar as T,l as E,i as x}from"./index-4XPoPWhu.js";const i={html:"",plainText:""},d=e=>{const u=g(),{pushError:o}=p(),{data:n}=f({...m(),staleTime:1/0}),l=r.useMemo(()=>{if(!e||!n)return i;const t=n.accounts.find(a=>a.accountId===e);return t?{html:t.signatureHtml??"",plainText:t.signaturePlainText??""}:i},[e,n]),s=y({...x(),onSuccess:()=>{u.invalidateQueries({queryKey:E()})},onError:t=>{o(T("Couldn't save signature","The signature wasn't saved.",t))}}),c=r.useCallback((t,a)=>{e&&s.mutate({path:{accountId:e},body:{signatureHtml:t,signaturePlainText:a}})},[e,s]);return{signature:l,setSignature:c,isSaving:s.isPending}};export{d as u};