@remit/web-client-dist 0.0.583 → 0.0.584

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 (149) hide show
  1. package/assets/BriefPane-BZEPUyJ2.js +1 -0
  2. package/assets/{CalendarComposePane-DPvfMx1d.js → CalendarComposePane-g8jg24dh.js} +1 -1
  3. package/assets/{CalendarComposeSeed-DAKFyT9U.js → CalendarComposeSeed-CW-0xIia.js} +1 -1
  4. package/assets/{CalendarShell-D_TStF2-.js → CalendarShell-B3JultCO.js} +1 -1
  5. package/assets/{EmptyState-DW05isg8.js → EmptyState-v8IldbXJ.js} +1 -1
  6. package/assets/{ErrorState-Brdqdjc0.js → ErrorState-DoP0L5mO.js} +1 -1
  7. package/assets/{FlaggedPane-Cp0Y2YHp.js → FlaggedPane-LkSgErc4.js} +1 -1
  8. package/assets/{FullCompose-CUw0TahW.js → FullCompose-Botg5UAg.js} +1 -1
  9. package/assets/MailListHeader-BVMj_BgB.js +7 -0
  10. package/assets/{MailNav-X1GxTZSw.js → MailNav-DMczUNyc.js} +1 -1
  11. package/assets/{MailShell-Dk7ZefSC.js → MailShell-CU_4OzDP.js} +1 -1
  12. package/assets/{MailViewChrome-DhwHyNOK.js → MailViewChrome-CygV35p5.js} +1 -1
  13. package/assets/{MailboxPane-B9ShmZ6d.js → MailboxPane-5jiN-HzZ.js} +1 -1
  14. package/assets/{NavMenuButton-WBZ4mdTb.js → NavMenuButton-BSQmvedG.js} +1 -1
  15. package/assets/{OnboardingWizard-CKdDMq8q.js → OnboardingWizard-BDvM-cK5.js} +1 -1
  16. package/assets/{OpenCalendarEvent-CTm8JYew.js → OpenCalendarEvent-D1Zjmyef.js} +2 -2
  17. package/assets/{OutboxPane-Dee-4d4Y.js → OutboxPane-BWnJPemK.js} +1 -1
  18. package/assets/_calendarObjectId-BgQNP97h.js +1 -0
  19. package/assets/_mailboxId-BvKTIX4s.js +1 -0
  20. package/assets/_messageId-Ba88d7wg.js +1 -0
  21. package/assets/_messageId-DJf4zGPC.js +1 -0
  22. package/assets/_messageId-D_-cp7H7.js +1 -0
  23. package/assets/_outboxMessageId-CoMRt-lg.js +1 -0
  24. package/assets/_recurrenceId-B880Ovwa.js +1 -0
  25. package/assets/_threadId-BIN23GJ5.js +1 -0
  26. package/assets/_threadId-DLq8B2d6.js +1 -0
  27. package/assets/_threadId-YDHF6N_6.js +1 -0
  28. package/assets/{_view._date-DOZ2M0Q8.js → _view._date-wWtZmMwV.js} +1 -1
  29. package/assets/{accounts-CboCJZO1.js → accounts-iDefP4Y_.js} +1 -1
  30. package/assets/{advanced-Dptrr6mC.js → advanced-BYh52Q-G.js} +1 -1
  31. package/assets/{appearance-Biy2PxBc.js → appearance--wqREK-V.js} +1 -1
  32. package/assets/{attachment-file-CMXfNfJn.js → attachment-file-DWEiGat9.js} +1 -1
  33. package/assets/{attendee-row-Dxb9LTNT.js → attendee-row-CS9Y6ArO.js} +1 -1
  34. package/assets/{avatar-DcQYncqX.js → avatar-DzRNl6M7.js} +1 -1
  35. package/assets/{bottom-sheet-0rVNywsT.js → bottom-sheet-BggkuSeI.js} +1 -1
  36. package/assets/brief-rNOY8GJc.js +1 -0
  37. package/assets/{brief-D5Zj3myE.js → brief-uIcU3yBA.js} +1 -1
  38. package/assets/{browser-ponyfill-BfT9TM1b.js → browser-ponyfill-DLp2PJIT.js} +1 -1
  39. package/assets/{bug-DyoRoy8a.js → bug-DBDWVZoa.js} +1 -1
  40. package/assets/{calendar-GLIkWqVi.js → calendar-Bj86R4l2.js} +1 -1
  41. package/assets/{calendar-color-gBA_HeUs.js → calendar-color-D8iiVcIS.js} +1 -1
  42. package/assets/{calendar-event-chip-B1KCBU39.js → calendar-event-chip-D9LKsN1T.js} +1 -1
  43. package/assets/{calendars-BhwEWE6u.js → calendars-CEH1WPfl.js} +1 -1
  44. package/assets/{card-B0Li1J-c.js → card-DdfokAjK.js} +1 -1
  45. package/assets/chevron-left-6yzScXZ_.js +1 -0
  46. package/assets/{circle-check-CW8ISmW6.js → circle-check-CqCqM246.js} +1 -1
  47. package/assets/{circle-check-big-B5miI5gF.js → circle-check-big-BWLwy6BP.js} +1 -1
  48. package/assets/{circle-help-tgWw5UEw.js → circle-help-Bv29pjeT.js} +1 -1
  49. package/assets/{clock-BLRfoCmj.js → clock-L_kb9cfg.js} +1 -1
  50. package/assets/compose._-_outboxMessageId_-BbfZyeMZ.js +1 -0
  51. package/assets/compose._-_outboxMessageId_-Cp5uxKBj.js +1 -0
  52. package/assets/compose._-_outboxMessageId_-Dtn5Y2Bj.js +1 -0
  53. package/assets/compose._-_outboxMessageId_-DucjAYL6.js +1 -0
  54. package/assets/{config-import-mbqbQ0Kv.js → config-import-F3rZeRs6.js} +1 -1
  55. package/assets/{confirm-dialog-BGO2L6eG.js → confirm-dialog-Bbol8p4q.js} +1 -1
  56. package/assets/{copy-XzKPSLKO.js → copy-DqyJAOcF.js} +1 -1
  57. package/assets/{credential-steps-ohZjWWsK.js → credential-steps-CoaJG0uV.js} +1 -1
  58. package/assets/{download-BCuLjuRU.js → download-BkiKj2Pu.js} +1 -1
  59. package/assets/{file-json-DbAdQ2iQ.js → file-json-C1KSqRrK.js} +1 -1
  60. package/assets/{filters-B3sq0tdN.js → filters-BIubskk0.js} +1 -1
  61. package/assets/{flagged-CQEbMrjf.js → flagged-CN8ARqwD.js} +1 -1
  62. package/assets/flagged-Mx45Lehu.js +1 -0
  63. package/assets/{folders-DAaQKesd.js → folders-dCTflPCM.js} +1 -1
  64. package/assets/{help-copy-CkzkBk5z.js → help-copy-FczmJroO.js} +1 -1
  65. package/assets/{import-B4ZBdsSR.js → import-ym67PQ7w.js} +1 -1
  66. package/assets/index-1Ejq9LnG.js +1 -0
  67. package/assets/index-B_bnGA_O.js +1 -0
  68. package/assets/index-Ba88d7wg.js +1 -0
  69. package/assets/index-BvfUq_lc.js +1 -0
  70. package/assets/{index-Cw9raKto.js → index-CK5_jciE.js} +1 -1
  71. package/assets/index-CZMsatxC.js +1 -0
  72. package/assets/index-Cajl-gpv.js +1 -0
  73. package/assets/index-DJf4zGPC.js +1 -0
  74. package/assets/{index-BaIsUUgP.js → index-DU93ZpU5.js} +4 -4
  75. package/assets/{index-Bi5u-0pF.js → index-DvUChk7j.js} +4 -4
  76. package/assets/index-DyvUiEgc.js +1 -0
  77. package/assets/index-LZphfBhh.js +1 -0
  78. package/assets/{kbd-B1FPHud4.js → kbd-UGlvLfzQ.js} +1 -1
  79. package/assets/{labels--BGx8tDh.js → labels-cuiQOF94.js} +1 -1
  80. package/assets/{mail-CAEg6Rz2.js → mail-C2qhf2Xg.js} +1 -1
  81. package/assets/{mail-DE2BeI2l.js → mail-DEHFRbMT.js} +1 -1
  82. package/assets/{map-pin-CSC6K2Yf.js → map-pin-DePWWPnP.js} +1 -1
  83. package/assets/{menu-BRwsmKu1.js → menu-DwL6wSy2.js} +1 -1
  84. package/assets/{new-DM6fHUQO.js → new-DUe1xR6A.js} +1 -1
  85. package/assets/onboarding-DbepRwfe.js +1 -0
  86. package/assets/{onboarding-completion-BHwBmMzB.js → onboarding-completion-MHwAJumU.js} +1 -1
  87. package/assets/outbox-_nzyRVhA.js +1 -0
  88. package/assets/{pencil-xEihGOsg.js → pencil-CFoM-0vk.js} +1 -1
  89. package/assets/{refresh-cw-BN8dsqdR.js → refresh-cw-Dl-tG_9M.js} +1 -1
  90. package/assets/{rich-text-DRoU9Pdt.js → rich-text-D92-CHLT.js} +15 -15
  91. package/assets/{rich-text-spellcheck-worker-provider-C3czbNlL.js → rich-text-spellcheck-worker-provider-CrncNjfj.js} +1 -1
  92. package/assets/{rotate-ccw-DjfLJMRi.js → rotate-ccw-BYz0MWuI.js} +1 -1
  93. package/assets/{roving-focus-mKC6iVzo.js → roving-focus-DHh3FjWJ.js} +1 -1
  94. package/assets/{row-actions-Dh_kRME-.js → row-actions-Dyl4iluw.js} +1 -1
  95. package/assets/{search-mirror-BdhSdehz.js → search-mirror-edUnrFth.js} +1 -1
  96. package/assets/{search-token-index-DbuV3Orb.js → search-token-index-sy91NMQe.js} +1 -1
  97. package/assets/{sections-B98ovYz8.js → sections-Bc_aHm2I.js} +1 -1
  98. package/assets/{senders-DEeOkAKY.js → senders-zvtBIGhA.js} +1 -1
  99. package/assets/settings-1qWeypM2.js +1 -0
  100. package/assets/{settings-screen-CaMBw9yx.js → settings-screen-DavxqwXN.js} +1 -1
  101. package/assets/{shield-check-JwTPT0jH.js → shield-check-VyvzmcFW.js} +1 -1
  102. package/assets/{suggested-vips-Cr5w1dkv.js → suggested-vips-DrKtencU.js} +1 -1
  103. package/assets/{useCalendarData-DDs4QiDV.js → useCalendarData-RLWmpLC_.js} +1 -1
  104. package/assets/{useCalendars-D1Ox3dSE.js → useCalendars-BQHiaXOr.js} +1 -1
  105. package/assets/{useDebouncedValue-Cp8nyFUU.js → useDebouncedValue-q2Msd07l.js} +1 -1
  106. package/assets/{useFilters-BRXbiG4b.js → useFilters-CwS7jGW2.js} +1 -1
  107. package/assets/{useLabels-B_9aXN4d.js → useLabels-DDx3QXUG.js} +1 -1
  108. package/assets/{useLayoutTier-rtRMZphL.js → useLayoutTier-BoxEF_W3.js} +1 -1
  109. package/assets/{useMessageBodyContent-BXu4YPnM.js → useMessageBodyContent-CQamaTRZ.js} +1 -1
  110. package/assets/{useQueries-Dg1KQOKp.js → useQueries-C5gwtd2q.js} +1 -1
  111. package/assets/{useRefreshControl-BUTXJkRF.js → useRefreshControl-CNRqhIsJ.js} +1 -1
  112. package/assets/{useResultFolderIndex-C0QcUuj7.js → useResultFolderIndex-D9TlM9GN.js} +1 -1
  113. package/assets/{useSearchTokenContext-CoDB8g3-.js → useSearchTokenContext-D5RrQjdu.js} +1 -1
  114. package/assets/{useSemanticSearch-C2us5P1h.js → useSemanticSearch-DNnXt79q.js} +1 -1
  115. package/assets/{useSignature-BySHd3ET.js → useSignature-DE2Ad6dB.js} +1 -1
  116. package/assets/{window-CSHsTkMc.js → window-Bcsh0g4u.js} +1 -1
  117. package/index.html +1 -1
  118. package/package.json +1 -1
  119. package/assets/BriefPane-BgMVbUxG.js +0 -1
  120. package/assets/MailListHeader-BMV1rvoO.js +0 -7
  121. package/assets/_calendarObjectId-D6IYcZIy.js +0 -1
  122. package/assets/_mailboxId-BqgCEvBY.js +0 -1
  123. package/assets/_messageId-B_B1MEV7.js +0 -1
  124. package/assets/_messageId-CPbIGtp8.js +0 -1
  125. package/assets/_messageId-Dq3n6oFU.js +0 -1
  126. package/assets/_outboxMessageId-Bw5CoAm-.js +0 -1
  127. package/assets/_recurrenceId-CFZ-zen1.js +0 -1
  128. package/assets/_threadId-CEU2zJXR.js +0 -1
  129. package/assets/_threadId-CI05vZKj.js +0 -1
  130. package/assets/_threadId-pXbyKl8_.js +0 -1
  131. package/assets/brief-BecJbMNq.js +0 -1
  132. package/assets/chevron-left-VQLzfpRJ.js +0 -1
  133. package/assets/compose._-_outboxMessageId_-B4DR4i4M.js +0 -1
  134. package/assets/compose._-_outboxMessageId_-C77p0Vro.js +0 -1
  135. package/assets/compose._-_outboxMessageId_-CbhAcx09.js +0 -1
  136. package/assets/compose._-_outboxMessageId_-CddHMBdg.js +0 -1
  137. package/assets/flagged-BdgOAZ9T.js +0 -1
  138. package/assets/index-BHzjTOL4.js +0 -1
  139. package/assets/index-BV5h-Zvb.js +0 -1
  140. package/assets/index-B_B1MEV7.js +0 -1
  141. package/assets/index-Bp9NK6EZ.js +0 -1
  142. package/assets/index-CZgxQQMn.js +0 -1
  143. package/assets/index-CZhttS4T.js +0 -1
  144. package/assets/index-CmocdEe2.js +0 -1
  145. package/assets/index-Dq3n6oFU.js +0 -1
  146. package/assets/index-Im0bHrjS.js +0 -1
  147. package/assets/onboarding-Dut8afrj.js +0 -1
  148. package/assets/outbox-BeeSg51u.js +0 -1
  149. package/assets/settings-CpUGcjGt.js +0 -1
@@ -1 +1 @@
1
- import{eQ as r,eR as o,eS as a}from"./index-Bi5u-0pF.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{eR as r,eS as o,eT as a}from"./index-DvUChk7j.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 +1 @@
1
- import{e}from"./index-Bi5u-0pF.js";const a=e("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{a as R};
1
+ import{e}from"./index-DvUChk7j.js";const a=e("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{a as R};
@@ -1 +1 @@
1
- import{r as d}from"./index-Bi5u-0pF.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-DvUChk7j.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,f as b,t as y,L as x}from"./index-Bi5u-0pF.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,f as b,t as y,L as x}from"./index-DvUChk7j.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 x,C as v,x as p,z as I,ak as g,r as Q}from"./index-Bi5u-0pF.js";import{b}from"./MailShell-Dk7ZefSC.js";import{a as C}from"./useMessageBodyContent-BXu4YPnM.js";function W(o){const t=x(),{searchInput:c,searchQuery:e}=v(),i=p({select:a=>I(a.location.search)}),u=p({select:a=>a.location.pathname}),h=C(),f=g(),m=h||f,{to:s}=o,r="params"in o?o.params.mailboxId:void 0,l=r?`/mail/${r}`:s;Q.useEffect(()=>{if(!b({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{W as u};
1
+ import{u as x,C as v,x as p,z as I,ak as g,r as Q}from"./index-DvUChk7j.js";import{b}from"./MailShell-CU_4OzDP.js";import{a as C}from"./useMessageBodyContent-CQamaTRZ.js";function W(o){const t=x(),{searchInput:c,searchQuery:e}=v(),i=p({select:a=>I(a.location.search)}),u=p({select:a=>a.location.pathname}),h=C(),f=g(),m=h||f,{to:s}=o,r="params"in o?o.params.mailboxId:void 0,l=r?`/mail/${r}`:s;Q.useEffect(()=>{if(!b({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{W as u};
@@ -1 +1 @@
1
- import{r as c,j as m,bP as V,t as k,cd as _,X as G,ce as L,cf as Q,cg as z,ch as X,ci as J,a9 as x,u as M,cj as Y,ck as w,cl as W,G as Z,ac as ee,K,ae as te,af as ne,C as se,cm as N}from"./index-Bi5u-0pF.js";import{s as oe,S as re}from"./search-scope-B5-OK3Cq.js";import{u as R}from"./useQueries-Dg1KQOKp.js";const ae=[{action:"focusNext",keys:["j","k"],label:"navigate"},{action:"muteSender",keys:["m"],label:"mute"},{action:"help",keys:["?"],label:"all shortcuts"}];function ke(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(s=>s.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:s,hasValue:a,chipCount:o}){const i=o-1;return e==="Escape"?a?{type:"clearQuery"}:{type:"blur"}:e==="Tab"&&t?o===0?{type:"none"}:{type:"focusChip",index:i}:e==="Backspace"||e==="ArrowLeft"?!s||o===0?{type:"none"}:n?{type:"none"}:{type:"focusChip",index:i}:{type:"none"}}function de({key:e,repeat:t=!1,index:n,chipCount:s}){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>=s-1?{type:"focusInput"}:{type:"focusChip",index:n+1}:e==="Enter"||e===" "?{type:"activateChip",index:n}:e==="Escape"?{type:"focusInput"}:{type:"none"}}function fe(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:s,onClear:a,onClearQuery:o,placeholder:i="Search mail...",globalFocusKey:u=!0,showClearButton:p=!0,size:h="sm",inputId:d,suggest:f,className:b})=>{const $=c.useId(),j=d??$,I=c.useRef(null),P=c.useRef([]),F=o??a,[D,C]=c.useState(null),v=c.useRef(void 0),[q,O]=c.useState(""),T=e.length>0;c.useEffect(()=>{C(r=>r!==null&&r>=e.length?null:r)},[e.length]),c.useEffect(()=>{const r=v.current;if(r!==void 0){if(v.current=void 0,r===null){I.current?.focus();return}P.current[r]?.focus()}});const A=c.useRef(void 0);c.useEffect(()=>{const r=f?.caret;if(!r||r===A.current)return;A.current=r;const l=I.current;!l||l.ownerDocument.activeElement!==l||(l.setSelectionRange(r.cursor,r.cursor),f?.onCaretChange(r.cursor))});const S=r=>{f?.onCaretChange(r.selectionStart??r.value.length)},g=c.useCallback(r=>{C(r),v.current=r},[]),E=c.useCallback(r=>{const l=e[r];l&&t&&(g(fe(r,e.length)),O(`${l.label} removed`),t(l.id))},[e,t,g]),B=c.useCallback(()=>{g(null),a()},[a,g]),H=c.useCallback(r=>{const l=r.currentTarget;if(f?.onKeyDown(r))return;const y=ue({key:r.key,shiftKey:r.shiftKey,repeat:r.repeat,caretAtStart:l.selectionStart===0&&l.selectionEnd===0,hasValue:n.length>0,chipCount:e.length});switch(y.type){case"focusChip":r.preventDefault(),g(y.index);return;case"clearQuery":F();return;case"blur":l.blur();return;case"none":return}},[e.length,n,F,g,f]),U=c.useCallback(r=>l=>{const y=de({key:l.key,repeat:l.repeat,index:r,chipCount:e.length});switch(y.type!=="none"&&l.preventDefault(),y.type){case"removeChip":E(y.index);return;case"focusChip":g(y.index);return;case"focusInput":g(null);return;case"activateChip":return;case"none":return}},[e,E,g]);return c.useEffect(()=>{if(!u)return;const r=l=>{l.key!=="/"||l.metaKey||l.ctrlKey||l.altKey||pe(l.target)||L("focusSearch")||(l.preventDefault(),I.current?.focus())};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[u]),m.jsxs("label",{htmlFor:j,className:k("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",h==="lg"?"rounded-xl px-4 py-2":"rounded-md px-2.5 py-1",b),children:[m.jsx(V,{className:k("shrink-0 text-fg-muted pointer-events-none",h==="lg"?"size-5":"size-4")}),m.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1",children:[T&&m.jsx("div",{role:"grid","aria-label":"Search filters",className:"flex min-w-0 flex-wrap items-center gap-1",children:e.map((r,l)=>m.jsx(_,{ref:y=>{P.current[l]=y},label:r.label,tone:r.tone,focused:D===l,onFocusLabel:()=>C(l),onKeyDown:U(l),onRemove:()=>E(l)},r.id))}),m.jsx("input",{ref:I,id:j,name:"q",type:"text","aria-label":"Search mail",autoComplete:"off",value:n,tabIndex:D===null?0:-1,onChange:r=>{s(r.target.value),S(r.target)},onKeyDown:H,onKeyUp:r=>S(r.currentTarget),onClick:r=>S(r.currentTarget),onFocus:r=>{C(null),f?.onFocusChange?.(!0),S(r.currentTarget)},onBlur:()=>f?.onFocusChange?.(!1),...f?.comboboxProps,placeholder:T?void 0:i,className:"min-w-24 flex-1 bg-transparent text-fg outline-none placeholder:text-fg-muted"})]}),(n||T)&&p&&m.jsx("button",{type:"button",onClick:B,className:"shrink-0 rounded p-0.5 hover:bg-surface-raised transition-colors","aria-label":"Clear search",children:m.jsx(G,{className:k("text-fg-muted",h==="lg"?"size-5":"size-4")})}),m.jsx("span",{role:"status","aria-live":"polite",className:"sr-only",children:q})]})},Ie=({value:e,onChange:t,onClear:n,onClearQuery:s,chips:a,onRemoveChip:o,placeholder:i="Search mail...",globalFocusKey:u=!0,showClearButton:p=!0,size:h,inputId:d,suggest:f,className:b})=>m.jsx(me,{value:e,onChange:t,onClear:n,onClearQuery:s,chips:a,onRemoveChip:o,placeholder:i,globalFocusKey:u,showClearButton:p,size:h,inputId:d,suggest:f,className:b});function Ce({handlers:e,enabled:t=!0,target:n,sequenceTimeoutMs:s=1e3}){const a=c.useRef(e);a.current=e;const o=c.useRef(null),i=c.useRef(null);c.useEffect(()=>{if(!t)return;const u=()=>{i.current!==null&&(clearTimeout(i.current),i.current=null)},p=d=>{const f=Q({key:d.key,shiftKey:d.shiftKey,metaKey:d.metaKey,ctrlKey:d.ctrlKey,altKey:d.altKey,inEditable:X(d.target),onControl:z(d.target)},o.current);if(J().length>0){u(),o.current=null;return}if(u(),o.current=f.nextPrefix,f.nextPrefix!==null&&(i.current=setTimeout(()=>{o.current=null,i.current=null},s)),f.action===null||L(f.action)!==null)return;const b=a.current[f.action];b&&(f.preventDefault&&d.preventDefault(),b())},h=n===void 0?window:n;if(h!==null)return h.addEventListener("keydown",p),()=>{h.removeEventListener("keydown",p),u(),o.current=null}},[t,s,n])}function Se(){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}),s=x({from:"/mail/flagged/$threadId/$messageId",shouldThrow:!1}),a=x({from:"/mail/$mailboxId/$threadId",shouldThrow:!1}),o=x({from:"/mail/$mailboxId/$threadId/$messageId",shouldThrow:!1}),i=e?.threadId??n?.threadId??a?.threadId,u=t?.messageId??s?.messageId??o?.messageId;return c.useMemo(()=>i?{threadId:i,messageId:u}:void 0,[i,u])}function ve(){const e=M(),t=Y(),{list:n,mailboxId:s}=w();return c.useCallback((a,o)=>{const i=o?.query,p={search:d=>i===void 0?d:{...d,q:i||void 0},hash:t,replace:o?.replace??!1};if(n==="flagged"){e({to:"/mail/flagged/$threadId/$messageId",params:a,...p});return}const h=o?.mailboxId??s;if(n==="mailbox"&&h){e({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:h,...a},...p});return}e({to:"/mail/brief/$threadId/$messageId",params:a,...p})},[e,t,n,s])}function Te(){return W()}function he(){const e=M();return c.useCallback(t=>{e({to:"/mail/brief",search:{q:t||void 0}})},[e])}function Ee(){const e=M();return c.useCallback((t,n)=>{e({to:"/mail/$mailboxId",params:{mailboxId:t},search:{q:n||void 0}})},[e])}const Ne=({trigger:e,children:t,align:n="right"})=>{const[s,a]=c.useState(!1),o=c.useRef(null),i=c.useCallback(u=>{o.current&&!o.current.contains(u.target)&&a(!1)},[]);return Z({id:"dropdown-menu",open:s,answers:{back:()=>a(!1)}}),c.useEffect(()=>(s&&document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)),[s,i]),m.jsxs("div",{ref:o,className:"relative",children:[m.jsx("button",{type:"button",onClick:u=>{u.stopPropagation(),a(!s)},className:k("p-1.5 min-h-11 min-w-11 inline-flex items-center justify-center rounded-md transition-colors","hover:bg-surface-raised text-fg-muted hover:text-fg"),children:e}),s&&m.jsx("div",{className:k("absolute z-50 mt-1 min-w-[180px] py-1","bg-surface border border-line rounded-md shadow-lg",n==="right"?"right-0":"left-0"),children:t})]})},Me=({onClick:e,disabled:t,destructive:n,children:s})=>m.jsx("button",{type:"button",onClick:a=>{a.stopPropagation(),t||e()},disabled:t,className:k("w-full px-3 py-2 text-left text-sm transition-colors","flex items-center gap-2",t&&"opacity-50 cursor-not-allowed",!t&&"hover:bg-surface-raised",n&&"text-danger hover:text-danger"),children:s}),Ke=()=>m.jsx("div",{className:"my-1 h-px bg-line"}),ge=({accounts:e})=>{const{list:t,mailboxId:n}=w(),{t:s}=ee("mail",{useSuspense:!1}),a=c.useCallback((i,u)=>s(i,{defaultValue:u}),[s]),o=R({queries:e.map(i=>({...K({path:{accountId:i.accountId}}),staleTime:1/0}))});if(t==="outbox")return"Outbox";if(!n)return null;for(let i=0;i<e.length;i++){const u=o[i]?.data?.items;if(!u)continue;const p=u.find(d=>d.mailboxId===n);if(!p)continue;const h=te(e[i].folderAppointments);return ne(p,h.get(n),a)}return null},Re=({accounts:e})=>{const{mailboxId:t}=w(),n=R({queries:e.map(s=>({...K({path:{accountId:s.accountId}}),staleTime:1/0}))});if(!t)return null;for(const s of n){const a=s.data?.items;if(!a)continue;const o=a.find(i=>i.mailboxId===t);if(o)return o.unseenCount}return null},je=({accounts:e})=>{const{mailboxId:t}=w(),n=R({queries:e.map(s=>({...K({path:{accountId:s.accountId}}),staleTime:1/0}))});if(!t)return 0;for(const s of n){const a=s.data?.items;if(!a)continue;const o=a.find(i=>i.mailboxId===t);if(o)return o.messageCount}return 0};function Pe(e){const t=he(),{searchInput:n}=se(),s=ge({accounts:e}),a=w(),o=c.useMemo(()=>oe(a,s),[a,s]),i=c.useCallback(u=>{u===re&&t(n)},[t,n]);return{scope:o,clearScope:i}}function Fe(e){const t=new Map;for(const n of e){const s=n.email.toLowerCase(),a=s.split("@")[0];a&&!t.has(a)&&t.set(a,n.accountId),t.has(s)||t.set(s,n.accountId)}return t}function De(e){const t=new Map;for(const n of e)for(const s of n){const a=s.fullPath?.toLowerCase();if(!a)continue;const o=N(s).toLowerCase();t.has(a)||t.set(a,s.mailboxId),t.has(o)||t.set(o,s.mailboxId)}return t}function Ae(e,t=[]){const n=e.flat().filter(o=>o.fullPath),s=new Map;for(const o of n){const i=N(o).toLowerCase();s.set(i,(s.get(i)??0)+1)}const a=new Map(t.map(o=>[o.accountId,o.email]));return n.map(o=>{const i=N(o),u=s.get(i.toLowerCase())===1,p=t.length>1?a.get(o.accountId):void 0;return{value:u?i:o.fullPath,label:o.displayNameOverride?.trim()||i,...p?{hint:p}:{}}})}function Le(e){const t=new Map;for(const n of e){const s=n.email.toLowerCase().split("@")[0]??"";t.set(s,(t.get(s)??0)+1)}return e.map(n=>{const s=n.email.split("@")[0]??n.email,a=t.get(s.toLowerCase())===1,o=n.displayName?.trim();return{value:a?s:n.email,label:o||n.email,...o?{hint:n.email}:{}}})}export{Ne as D,ie as K,Ie as S,Ke as a,Me as b,De as c,Se as d,Ce as e,Fe as f,ve as g,Te as h,ge as i,Re as j,je as k,ae as l,Ae as m,Le as n,Ee as o,ke as p,le as s,we as t,Pe as u};
1
+ import{r as c,j as m,bP as V,t as k,cd as _,X as G,ce as L,cf as Q,cg as z,ch as X,ci as J,a9 as x,u as M,cj as Y,ck as w,cl as W,G as Z,ac as ee,K,ae as te,af as ne,C as se,cm as N}from"./index-DvUChk7j.js";import{s as oe,S as re}from"./search-scope-B5-OK3Cq.js";import{u as R}from"./useQueries-C5gwtd2q.js";const ae=[{action:"focusNext",keys:["j","k"],label:"navigate"},{action:"muteSender",keys:["m"],label:"mute"},{action:"help",keys:["?"],label:"all shortcuts"}];function ke(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(s=>s.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:s,hasValue:a,chipCount:o}){const i=o-1;return e==="Escape"?a?{type:"clearQuery"}:{type:"blur"}:e==="Tab"&&t?o===0?{type:"none"}:{type:"focusChip",index:i}:e==="Backspace"||e==="ArrowLeft"?!s||o===0?{type:"none"}:n?{type:"none"}:{type:"focusChip",index:i}:{type:"none"}}function de({key:e,repeat:t=!1,index:n,chipCount:s}){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>=s-1?{type:"focusInput"}:{type:"focusChip",index:n+1}:e==="Enter"||e===" "?{type:"activateChip",index:n}:e==="Escape"?{type:"focusInput"}:{type:"none"}}function fe(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:s,onClear:a,onClearQuery:o,placeholder:i="Search mail...",globalFocusKey:u=!0,showClearButton:p=!0,size:h="sm",inputId:d,suggest:f,className:b})=>{const $=c.useId(),j=d??$,I=c.useRef(null),P=c.useRef([]),F=o??a,[D,C]=c.useState(null),v=c.useRef(void 0),[q,O]=c.useState(""),T=e.length>0;c.useEffect(()=>{C(r=>r!==null&&r>=e.length?null:r)},[e.length]),c.useEffect(()=>{const r=v.current;if(r!==void 0){if(v.current=void 0,r===null){I.current?.focus();return}P.current[r]?.focus()}});const A=c.useRef(void 0);c.useEffect(()=>{const r=f?.caret;if(!r||r===A.current)return;A.current=r;const l=I.current;!l||l.ownerDocument.activeElement!==l||(l.setSelectionRange(r.cursor,r.cursor),f?.onCaretChange(r.cursor))});const S=r=>{f?.onCaretChange(r.selectionStart??r.value.length)},g=c.useCallback(r=>{C(r),v.current=r},[]),E=c.useCallback(r=>{const l=e[r];l&&t&&(g(fe(r,e.length)),O(`${l.label} removed`),t(l.id))},[e,t,g]),B=c.useCallback(()=>{g(null),a()},[a,g]),H=c.useCallback(r=>{const l=r.currentTarget;if(f?.onKeyDown(r))return;const y=ue({key:r.key,shiftKey:r.shiftKey,repeat:r.repeat,caretAtStart:l.selectionStart===0&&l.selectionEnd===0,hasValue:n.length>0,chipCount:e.length});switch(y.type){case"focusChip":r.preventDefault(),g(y.index);return;case"clearQuery":F();return;case"blur":l.blur();return;case"none":return}},[e.length,n,F,g,f]),U=c.useCallback(r=>l=>{const y=de({key:l.key,repeat:l.repeat,index:r,chipCount:e.length});switch(y.type!=="none"&&l.preventDefault(),y.type){case"removeChip":E(y.index);return;case"focusChip":g(y.index);return;case"focusInput":g(null);return;case"activateChip":return;case"none":return}},[e,E,g]);return c.useEffect(()=>{if(!u)return;const r=l=>{l.key!=="/"||l.metaKey||l.ctrlKey||l.altKey||pe(l.target)||L("focusSearch")||(l.preventDefault(),I.current?.focus())};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[u]),m.jsxs("label",{htmlFor:j,className:k("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",h==="lg"?"rounded-xl px-4 py-2":"rounded-md px-2.5 py-1",b),children:[m.jsx(V,{className:k("shrink-0 text-fg-muted pointer-events-none",h==="lg"?"size-5":"size-4")}),m.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1",children:[T&&m.jsx("div",{role:"grid","aria-label":"Search filters",className:"flex min-w-0 flex-wrap items-center gap-1",children:e.map((r,l)=>m.jsx(_,{ref:y=>{P.current[l]=y},label:r.label,tone:r.tone,focused:D===l,onFocusLabel:()=>C(l),onKeyDown:U(l),onRemove:()=>E(l)},r.id))}),m.jsx("input",{ref:I,id:j,name:"q",type:"text","aria-label":"Search mail",autoComplete:"off",value:n,tabIndex:D===null?0:-1,onChange:r=>{s(r.target.value),S(r.target)},onKeyDown:H,onKeyUp:r=>S(r.currentTarget),onClick:r=>S(r.currentTarget),onFocus:r=>{C(null),f?.onFocusChange?.(!0),S(r.currentTarget)},onBlur:()=>f?.onFocusChange?.(!1),...f?.comboboxProps,placeholder:T?void 0:i,className:"min-w-24 flex-1 bg-transparent text-fg outline-none placeholder:text-fg-muted"})]}),(n||T)&&p&&m.jsx("button",{type:"button",onClick:B,className:"shrink-0 rounded p-0.5 hover:bg-surface-raised transition-colors","aria-label":"Clear search",children:m.jsx(G,{className:k("text-fg-muted",h==="lg"?"size-5":"size-4")})}),m.jsx("span",{role:"status","aria-live":"polite",className:"sr-only",children:q})]})},Ie=({value:e,onChange:t,onClear:n,onClearQuery:s,chips:a,onRemoveChip:o,placeholder:i="Search mail...",globalFocusKey:u=!0,showClearButton:p=!0,size:h,inputId:d,suggest:f,className:b})=>m.jsx(me,{value:e,onChange:t,onClear:n,onClearQuery:s,chips:a,onRemoveChip:o,placeholder:i,globalFocusKey:u,showClearButton:p,size:h,inputId:d,suggest:f,className:b});function Ce({handlers:e,enabled:t=!0,target:n,sequenceTimeoutMs:s=1e3}){const a=c.useRef(e);a.current=e;const o=c.useRef(null),i=c.useRef(null);c.useEffect(()=>{if(!t)return;const u=()=>{i.current!==null&&(clearTimeout(i.current),i.current=null)},p=d=>{const f=Q({key:d.key,shiftKey:d.shiftKey,metaKey:d.metaKey,ctrlKey:d.ctrlKey,altKey:d.altKey,inEditable:X(d.target),onControl:z(d.target)},o.current);if(J().length>0){u(),o.current=null;return}if(u(),o.current=f.nextPrefix,f.nextPrefix!==null&&(i.current=setTimeout(()=>{o.current=null,i.current=null},s)),f.action===null||L(f.action)!==null)return;const b=a.current[f.action];b&&(f.preventDefault&&d.preventDefault(),b())},h=n===void 0?window:n;if(h!==null)return h.addEventListener("keydown",p),()=>{h.removeEventListener("keydown",p),u(),o.current=null}},[t,s,n])}function Se(){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}),s=x({from:"/mail/flagged/$threadId/$messageId",shouldThrow:!1}),a=x({from:"/mail/$mailboxId/$threadId",shouldThrow:!1}),o=x({from:"/mail/$mailboxId/$threadId/$messageId",shouldThrow:!1}),i=e?.threadId??n?.threadId??a?.threadId,u=t?.messageId??s?.messageId??o?.messageId;return c.useMemo(()=>i?{threadId:i,messageId:u}:void 0,[i,u])}function ve(){const e=M(),t=Y(),{list:n,mailboxId:s}=w();return c.useCallback((a,o)=>{const i=o?.query,p={search:d=>i===void 0?d:{...d,q:i||void 0},hash:t,replace:o?.replace??!1};if(n==="flagged"){e({to:"/mail/flagged/$threadId/$messageId",params:a,...p});return}const h=o?.mailboxId??s;if(n==="mailbox"&&h){e({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:h,...a},...p});return}e({to:"/mail/brief/$threadId/$messageId",params:a,...p})},[e,t,n,s])}function Te(){return W()}function he(){const e=M();return c.useCallback(t=>{e({to:"/mail/brief",search:{q:t||void 0}})},[e])}function Ee(){const e=M();return c.useCallback((t,n)=>{e({to:"/mail/$mailboxId",params:{mailboxId:t},search:{q:n||void 0}})},[e])}const Ne=({trigger:e,children:t,align:n="right"})=>{const[s,a]=c.useState(!1),o=c.useRef(null),i=c.useCallback(u=>{o.current&&!o.current.contains(u.target)&&a(!1)},[]);return Z({id:"dropdown-menu",open:s,answers:{back:()=>a(!1)}}),c.useEffect(()=>(s&&document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)),[s,i]),m.jsxs("div",{ref:o,className:"relative",children:[m.jsx("button",{type:"button",onClick:u=>{u.stopPropagation(),a(!s)},className:k("p-1.5 min-h-11 min-w-11 inline-flex items-center justify-center rounded-md transition-colors","hover:bg-surface-raised text-fg-muted hover:text-fg"),children:e}),s&&m.jsx("div",{className:k("absolute z-50 mt-1 min-w-[180px] py-1","bg-surface border border-line rounded-md shadow-lg",n==="right"?"right-0":"left-0"),children:t})]})},Me=({onClick:e,disabled:t,destructive:n,children:s})=>m.jsx("button",{type:"button",onClick:a=>{a.stopPropagation(),t||e()},disabled:t,className:k("w-full px-3 py-2 text-left text-sm transition-colors","flex items-center gap-2",t&&"opacity-50 cursor-not-allowed",!t&&"hover:bg-surface-raised",n&&"text-danger hover:text-danger"),children:s}),Ke=()=>m.jsx("div",{className:"my-1 h-px bg-line"}),ge=({accounts:e})=>{const{list:t,mailboxId:n}=w(),{t:s}=ee("mail",{useSuspense:!1}),a=c.useCallback((i,u)=>s(i,{defaultValue:u}),[s]),o=R({queries:e.map(i=>({...K({path:{accountId:i.accountId}}),staleTime:1/0}))});if(t==="outbox")return"Outbox";if(!n)return null;for(let i=0;i<e.length;i++){const u=o[i]?.data?.items;if(!u)continue;const p=u.find(d=>d.mailboxId===n);if(!p)continue;const h=te(e[i].folderAppointments);return ne(p,h.get(n),a)}return null},Re=({accounts:e})=>{const{mailboxId:t}=w(),n=R({queries:e.map(s=>({...K({path:{accountId:s.accountId}}),staleTime:1/0}))});if(!t)return null;for(const s of n){const a=s.data?.items;if(!a)continue;const o=a.find(i=>i.mailboxId===t);if(o)return o.unseenCount}return null},je=({accounts:e})=>{const{mailboxId:t}=w(),n=R({queries:e.map(s=>({...K({path:{accountId:s.accountId}}),staleTime:1/0}))});if(!t)return 0;for(const s of n){const a=s.data?.items;if(!a)continue;const o=a.find(i=>i.mailboxId===t);if(o)return o.messageCount}return 0};function Pe(e){const t=he(),{searchInput:n}=se(),s=ge({accounts:e}),a=w(),o=c.useMemo(()=>oe(a,s),[a,s]),i=c.useCallback(u=>{u===re&&t(n)},[t,n]);return{scope:o,clearScope:i}}function Fe(e){const t=new Map;for(const n of e){const s=n.email.toLowerCase(),a=s.split("@")[0];a&&!t.has(a)&&t.set(a,n.accountId),t.has(s)||t.set(s,n.accountId)}return t}function De(e){const t=new Map;for(const n of e)for(const s of n){const a=s.fullPath?.toLowerCase();if(!a)continue;const o=N(s).toLowerCase();t.has(a)||t.set(a,s.mailboxId),t.has(o)||t.set(o,s.mailboxId)}return t}function Ae(e,t=[]){const n=e.flat().filter(o=>o.fullPath),s=new Map;for(const o of n){const i=N(o).toLowerCase();s.set(i,(s.get(i)??0)+1)}const a=new Map(t.map(o=>[o.accountId,o.email]));return n.map(o=>{const i=N(o),u=s.get(i.toLowerCase())===1,p=t.length>1?a.get(o.accountId):void 0;return{value:u?i:o.fullPath,label:o.displayNameOverride?.trim()||i,...p?{hint:p}:{}}})}function Le(e){const t=new Map;for(const n of e){const s=n.email.toLowerCase().split("@")[0]??"";t.set(s,(t.get(s)??0)+1)}return e.map(n=>{const s=n.email.split("@")[0]??n.email,a=t.get(s.toLowerCase())===1,o=n.displayName?.trim();return{value:a?s:n.email,label:o||n.email,...o?{hint:n.email}:{}}})}export{Ne as D,ie as K,Ie as S,Ke as a,Me as b,De as c,Se as d,Ce as e,Fe as f,ve as g,Te as h,ge as i,Re as j,je as k,ae as l,Ae as m,Le as n,Ee as o,ke as p,le as s,we as t,Pe as u};
@@ -1 +1 @@
1
- import{u as e,r as s}from"./index-Bi5u-0pF.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-DvUChk7j.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 +1 @@
1
- import{j as e,t as N,h as I,r as c,bM as A,c as C,i as k,bN as P,bO as L,f as S,X as O,u as T,aL as $,az as M,bP as R,aN as q,bQ as Q,bR as D,Z as G}from"./index-Bi5u-0pF.js";import{K as f}from"./kbd-B1FPHud4.js";import{a as E,S as K}from"./settings-screen-CaMBw9yx.js";import{E as V}from"./ErrorState-Brdqdjc0.js";import{u as _}from"./useDebouncedValue-Cp8nyFUU.js";import{s as B}from"./help-copy-CkzkBk5z.js";import"./avatar-DcQYncqX.js";import"./chevron-left-VQLzfpRJ.js";import"./menu-BRwsmKu1.js";import"./circle-help-tgWw5UEw.js";function F({options:t,active:r,onSelect:m}){return e.jsx("div",{role:"tablist",className:N("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(n=>{const d=n.id===r;return e.jsxs("button",{type:"button",role:"tab","aria-selected":d,onClick:()=>m(n.id),className:N("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",d?"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:n.label}),e.jsx("span",{className:N("text-2xs tabular-nums",d?"text-accent-2":"text-fg-subtle"),children:n.count??"—"})]},n.id)})})}const v={vip:"VIPs",muted:"Muted",blocked:"Blocked"};function H({query:t,onCount:r}){const{data:m,isPending:n,isError:d,error:b}=C(Q()),g=I(),i=k({...P(),onSettled:()=>{g.invalidateQueries({queryKey:D()})}}),l=m?.suggestions??[],p=t.trim().toLowerCase(),u=p?l.filter(a=>(a.displayName??"").toLowerCase().includes(p)||a.normalizedEmail.toLowerCase().includes(p)):l;return c.useEffect(()=>{r?.(u.length,l.length)},[r,u.length,l.length]),n?e.jsx("div",{className:"px-row-inset py-3 text-sm text-fg-subtle animate-pulse",children:"Loading VIP suggestions…"}):d?e.jsx("div",{className:"px-row-inset py-3",children:e.jsx(V,{variant:"inline",title:"Couldn't load VIP suggestions",error:b})}):l.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(f,{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(E,{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(S,{variant:"ghost",size:"sm",icon:e.jsx(G,{className:"size-3.5"}),"aria-busy":i.isPending,onClick:()=>{i.isPending||i.mutate({path:{addressId:a.addressId},body:{flags:{vip:{value:!0,setAt:Date.now(),setBy:"user"}}}})},children:"Add VIP"})},a.addressId))]})}function U({group:t,query:r,onCount:m}){const n=_(r.trim(),300),d=I(),[b,g]=c.useState(null),i=n.length>=2,l=A({query:{q:n,limit:50}}),{data:p,isPending:u,isError:a,error:j}=C({...l,enabled:i}),x=k({...P(),onSuccess:()=>{d.invalidateQueries({queryKey:l.queryKey})}}),h=(p?.items??[]).filter(s=>t==="muted"?s.flags?.muted?.value??!1:s.flags?.blocked?.value??!1);return c.useEffect(()=>{m?.(i?h.length:0,null)},[m,i,h.length]),i?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(V,{variant:"inline",title:"Search failed",error:j})}):h.length===0?e.jsxs("p",{className:"px-row-inset py-5 text-sm text-fg-subtle",children:["No ",v[t].toLowerCase()," senders matching “",n,"”."]}):e.jsx(e.Fragment,{children:h.map(s=>{const o=t==="muted"?s.flags?.muted:s.flags?.blocked,y=o?[`${t}`,o.setAt&&L(o.setAt,{month:"short",year:"numeric"})||null,o.reason?`— ${o.reason}`:null].filter(Boolean).join(" "):t,w=x.isPending&&x.variables?.path.addressId===s.addressId,z=x.isError&&b===s.addressId;return e.jsx(E,{name:s.displayName??s.normalizedEmail,email:s.normalizedEmail,danger:t==="blocked",meta:y,trailing:z?e.jsx(S,{variant:"secondary",size:"sm",onClick:()=>{g(s.addressId),x.mutate({path:{addressId:s.addressId},body:{flags:{[t]:{value:!1,setAt:Date.now()}}}})},children:"Retry"}):e.jsx(S,{variant:"ghost",size:"sm",icon:e.jsx(O,{className:"size-3.5"}),"aria-busy":w,"aria-label":`Remove ${t} flag`,onClick:()=>{w||(g(s.addressId),x.mutate({path:{addressId:s.addressId},body:{flags:{[t]:{value:!1,setAt:Date.now()}}}}))}})},s.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 ",v[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(f,{children:"m"})," on any message to mute its sender; ",e.jsx(f,{children:"b"})," to block."]})]})}function re(){const t=T(),[r,m]=c.useState("vip"),[n,d]=c.useState(""),[b,g]=c.useState(!0),[i,l]=c.useState(0),[p,u]=c.useState({vip:0,muted:null,blocked:null}),a=c.useCallback((s,o)=>{l(s),u(y=>({...y,vip:o}))},[]),j=c.useCallback((s,o)=>{l(s),u(y=>({...y,[r]:s}))},[r]),x=p[r],h=s=>{const o=q[s];o&&t({to:o})};return e.jsx(K,{items:$,activeId:"senders",title:"Senders & Rules",description:"Per-sender preferences — set with one key from any message, managed here.",flush:!0,help:B,helpOpen:b,onToggleHelp:()=>g(s=>!s),onSelect:h,onBackToMail:()=>{t({to:"/mail"})},children:e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col lg:flex-row",children:[e.jsx(F,{active:r,onSelect:s=>{m(s),d("")},options:["vip","muted","blocked"].map(s=>({id:s,label:v[s],count:p[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(M,{icon:e.jsx(R,{className:"size-4"}),placeholder:`Filter ${v[r].toLowerCase()} by name or address`,className:"h-8 max-w-sm",value:n,onChange:s=>d(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:n,onCount:a}):e.jsx(U,{group:r,query:n,onCount:j})}),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:x!=null?`${i} of ${x} flagged senders`:`${i} flagged senders`}),e.jsxs("span",{children:[e.jsx(f,{children:"j"})," ",e.jsx(f,{children:"k"})," navigate · ",e.jsx(f,{children:"⌫"})," remove flag"]})]})]})]})})}export{U as SearchGroupPane,re as component};
1
+ import{j as e,t as N,h as I,r as c,bM as A,c as C,i as k,bN as P,bO as L,f as S,X as O,u as T,aL as $,az as M,bP as R,aN as q,bQ as Q,bR as D,Z as G}from"./index-DvUChk7j.js";import{K as f}from"./kbd-UGlvLfzQ.js";import{a as E,S as K}from"./settings-screen-DavxqwXN.js";import{E as V}from"./ErrorState-DoP0L5mO.js";import{u as _}from"./useDebouncedValue-q2Msd07l.js";import{s as B}from"./help-copy-FczmJroO.js";import"./avatar-DzRNl6M7.js";import"./chevron-left-6yzScXZ_.js";import"./menu-DwL6wSy2.js";import"./circle-help-Bv29pjeT.js";function F({options:t,active:r,onSelect:m}){return e.jsx("div",{role:"tablist",className:N("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(n=>{const d=n.id===r;return e.jsxs("button",{type:"button",role:"tab","aria-selected":d,onClick:()=>m(n.id),className:N("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",d?"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:n.label}),e.jsx("span",{className:N("text-2xs tabular-nums",d?"text-accent-2":"text-fg-subtle"),children:n.count??"—"})]},n.id)})})}const v={vip:"VIPs",muted:"Muted",blocked:"Blocked"};function H({query:t,onCount:r}){const{data:m,isPending:n,isError:d,error:b}=C(Q()),g=I(),i=k({...P(),onSettled:()=>{g.invalidateQueries({queryKey:D()})}}),l=m?.suggestions??[],p=t.trim().toLowerCase(),u=p?l.filter(a=>(a.displayName??"").toLowerCase().includes(p)||a.normalizedEmail.toLowerCase().includes(p)):l;return c.useEffect(()=>{r?.(u.length,l.length)},[r,u.length,l.length]),n?e.jsx("div",{className:"px-row-inset py-3 text-sm text-fg-subtle animate-pulse",children:"Loading VIP suggestions…"}):d?e.jsx("div",{className:"px-row-inset py-3",children:e.jsx(V,{variant:"inline",title:"Couldn't load VIP suggestions",error:b})}):l.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(f,{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(E,{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(S,{variant:"ghost",size:"sm",icon:e.jsx(G,{className:"size-3.5"}),"aria-busy":i.isPending,onClick:()=>{i.isPending||i.mutate({path:{addressId:a.addressId},body:{flags:{vip:{value:!0,setAt:Date.now(),setBy:"user"}}}})},children:"Add VIP"})},a.addressId))]})}function U({group:t,query:r,onCount:m}){const n=_(r.trim(),300),d=I(),[b,g]=c.useState(null),i=n.length>=2,l=A({query:{q:n,limit:50}}),{data:p,isPending:u,isError:a,error:j}=C({...l,enabled:i}),x=k({...P(),onSuccess:()=>{d.invalidateQueries({queryKey:l.queryKey})}}),h=(p?.items??[]).filter(s=>t==="muted"?s.flags?.muted?.value??!1:s.flags?.blocked?.value??!1);return c.useEffect(()=>{m?.(i?h.length:0,null)},[m,i,h.length]),i?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(V,{variant:"inline",title:"Search failed",error:j})}):h.length===0?e.jsxs("p",{className:"px-row-inset py-5 text-sm text-fg-subtle",children:["No ",v[t].toLowerCase()," senders matching “",n,"”."]}):e.jsx(e.Fragment,{children:h.map(s=>{const o=t==="muted"?s.flags?.muted:s.flags?.blocked,y=o?[`${t}`,o.setAt&&L(o.setAt,{month:"short",year:"numeric"})||null,o.reason?`— ${o.reason}`:null].filter(Boolean).join(" "):t,w=x.isPending&&x.variables?.path.addressId===s.addressId,z=x.isError&&b===s.addressId;return e.jsx(E,{name:s.displayName??s.normalizedEmail,email:s.normalizedEmail,danger:t==="blocked",meta:y,trailing:z?e.jsx(S,{variant:"secondary",size:"sm",onClick:()=>{g(s.addressId),x.mutate({path:{addressId:s.addressId},body:{flags:{[t]:{value:!1,setAt:Date.now()}}}})},children:"Retry"}):e.jsx(S,{variant:"ghost",size:"sm",icon:e.jsx(O,{className:"size-3.5"}),"aria-busy":w,"aria-label":`Remove ${t} flag`,onClick:()=>{w||(g(s.addressId),x.mutate({path:{addressId:s.addressId},body:{flags:{[t]:{value:!1,setAt:Date.now()}}}}))}})},s.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 ",v[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(f,{children:"m"})," on any message to mute its sender; ",e.jsx(f,{children:"b"})," to block."]})]})}function re(){const t=T(),[r,m]=c.useState("vip"),[n,d]=c.useState(""),[b,g]=c.useState(!0),[i,l]=c.useState(0),[p,u]=c.useState({vip:0,muted:null,blocked:null}),a=c.useCallback((s,o)=>{l(s),u(y=>({...y,vip:o}))},[]),j=c.useCallback((s,o)=>{l(s),u(y=>({...y,[r]:s}))},[r]),x=p[r],h=s=>{const o=q[s];o&&t({to:o})};return e.jsx(K,{items:$,activeId:"senders",title:"Senders & Rules",description:"Per-sender preferences — set with one key from any message, managed here.",flush:!0,help:B,helpOpen:b,onToggleHelp:()=>g(s=>!s),onSelect:h,onBackToMail:()=>{t({to:"/mail"})},children:e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col lg:flex-row",children:[e.jsx(F,{active:r,onSelect:s=>{m(s),d("")},options:["vip","muted","blocked"].map(s=>({id:s,label:v[s],count:p[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(M,{icon:e.jsx(R,{className:"size-4"}),placeholder:`Filter ${v[r].toLowerCase()} by name or address`,className:"h-8 max-w-sm",value:n,onChange:s=>d(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:n,onCount:a}):e.jsx(U,{group:r,query:n,onCount:j})}),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:x!=null?`${i} of ${x} flagged senders`:`${i} flagged senders`}),e.jsxs("span",{children:[e.jsx(f,{children:"j"})," ",e.jsx(f,{children:"k"})," navigate · ",e.jsx(f,{children:"⌫"})," remove flag"]})]})]})]})})}export{U as SearchGroupPane,re as component};
@@ -0,0 +1 @@
1
+ import{j as t,O as o}from"./index-DvUChk7j.js";const n=()=>t.jsx(o,{});export{n as component};
@@ -1 +1 @@
1
- import{r as j,j as e,t as f,f as i,X as N,g as z}from"./index-Bi5u-0pF.js";import{A as w}from"./avatar-DcQYncqX.js";import{C as h}from"./chevron-left-VQLzfpRJ.js";import{M as S}from"./menu-BRwsmKu1.js";import{C as v}from"./circle-help-tgWw5UEw.js";function R({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,C]=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:()=>C(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 L({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 O={healthy:{tone:"positive",label:"healthy"},error:{tone:"danger",label:"error"},muted:{tone:"neutral",label:"muted"}};function X({label:l,email:t,connector:x,syncLabel:n,state:r,errorDetail:s,trailing:d}){const o=O[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(z,{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{X as A,R as S,L as a};
1
+ import{r as j,j as e,t as f,f as i,X as N,g as z}from"./index-DvUChk7j.js";import{A as w}from"./avatar-DzRNl6M7.js";import{C as h}from"./chevron-left-6yzScXZ_.js";import{M as S}from"./menu-DwL6wSy2.js";import{C as v}from"./circle-help-Bv29pjeT.js";function R({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,C]=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:()=>C(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 L({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 O={healthy:{tone:"positive",label:"healthy"},error:{tone:"danger",label:"error"},muted:{tone:"neutral",label:"muted"}};function X({label:l,email:t,connector:x,syncLabel:n,state:r,errorDetail:s,trailing:d}){const o=O[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(z,{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{X as A,R as S,L as a};
@@ -1 +1 @@
1
- import{e}from"./index-Bi5u-0pF.js";const d=e("CloudOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193",key:"yfwify"}],["path",{d:"M21.532 16.5A4.5 4.5 0 0 0 17.5 10h-1.79A7.008 7.008 0 0 0 10 5.07",key:"jlfiyv"}]]);const h=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{d as C,h as S};
1
+ import{e}from"./index-DvUChk7j.js";const d=e("CloudOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193",key:"yfwify"}],["path",{d:"M21.532 16.5A4.5 4.5 0 0 0 17.5 10h-1.79A7.008 7.008 0 0 0 10 5.07",key:"jlfiyv"}]]);const h=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{d as C,h as S};
@@ -1 +1 @@
1
- import{j as t,an as e}from"./index-Bi5u-0pF.js";const o=()=>t.jsx(e,{to:"/settings/senders",replace:!0});export{o as component};
1
+ import{j as t,an as e}from"./index-DvUChk7j.js";const o=()=>t.jsx(e,{to:"/settings/senders",replace:!0});export{o as component};
@@ -1 +1 @@
1
- import{r as f,c as D,eB as p,h as I,eC as v,s as A}from"./index-Bi5u-0pF.js";import{c as g}from"./window-CSHsTkMc.js";import{u as L,i as W,t as M,U as N,r as O}from"./useCalendars-D1Ox3dSE.js";import{u as S}from"./useQueries-Dg1KQOKp.js";function T(e,n){const a=e.map(t=>t.id);if(n.length===0)return a;const r=new Set(n),o=a.filter(t=>r.has(t));return o.length===0?a:o}function _(e){const{calendars:n,colorByCalendarId:a,timeZoneByCalendarId:r,isLoading:o}=L(),t=T(n,e),c=t.length===n.length?[]:t,i=e.length===0||n.length>0;return{calendars:n,colorByCalendarId:a,timeZoneByCalendarId:r,shown:t,narrowed:c,resolved:i,isLoading:o}}function j(e,n,a){const r=a.join(",");return f.useMemo(()=>{const o=new Set(r===""?[]:r.split(","));return e.filter(t=>W(t)&&o.has(t.calendarId)).map(t=>M(t,n[t.calendarId]??N))},[e,n,r])}const w=A(400,404),C=5*6e4,E=({from:e,to:n,calendarIds:a})=>({query:a.length===0?{from:e,to:n}:{from:e,to:n,calendarId:[...a]}});function b(e){const{data:n,isLoading:a,error:r,refetch:o}=D({...p(E(e)),meta:w,staleTime:C,enabled:e.enabled??!0});return{instances:n?.items??[],isLoading:a,error:r,refetch:()=>{o()}}}function k(e,n,a){const r=S({queries:e.map(s=>({...p(E({...s,calendarIds:n})),meta:w,staleTime:C,enabled:a}))}),o=e.map(s=>s.from).join("|"),t=r.map(s=>s.data),c=r.map(s=>s.isPending).join("|"),i=r.find(s=>s.error)?.error??null,d=f.useMemo(()=>t.flatMap(s=>s?.items??[]),[o,c]),m=f.useMemo(()=>{const s=new Set;return e.forEach((h,l)=>{r[l]?.isPending&&s.add(h.from)}),s},[o,c]);return{instances:d,pendingWindows:m,error:i,refetch:()=>{for(const s of r)s.error&&s.refetch()}}}function B(e,n,a,r){const o=I(),t=[...a].join(",");f.useEffect(()=>{if(!r)return;const c=t===""?[]:t.split(",");for(const i of[-1,1]){const d=g(e,v(n,e,i));o.prefetchQuery({...p(E({...d,calendarIds:c})),staleTime:C})}},[o,e,n,t,r])}function x({view:e,date:n,calendarIds:a,enabled:r=!0}){const{calendars:o,colorByCalendarId:t,timeZoneByCalendarId:c,shown:i,narrowed:d,resolved:m,isLoading:s}=_(a),h=g(e,n),l=r&&m,u=b({...h,calendarIds:d,enabled:l});B(e,n,d,l);const y=j(u.instances,c,i);return{calendars:o,events:y,colorByCalendarId:t,timeZoneByCalendarId:c,isLoading:s||u.isLoading,error:u.error,retry:u.refetch,instanceOf:O}}export{C,k as a,j as b,x as c,_ as u};
1
+ import{r as f,c as y,eC as p,h as I,eD as v,s as A}from"./index-DvUChk7j.js";import{c as g}from"./window-Bcsh0g4u.js";import{u as L,i as W,t as M,U as N,r as O}from"./useCalendars-BQHiaXOr.js";import{u as S}from"./useQueries-C5gwtd2q.js";function T(e,n){const a=e.map(t=>t.id);if(n.length===0)return a;const r=new Set(n),o=a.filter(t=>r.has(t));return o.length===0?a:o}function _(e){const{calendars:n,colorByCalendarId:a,timeZoneByCalendarId:r,isLoading:o}=L(),t=T(n,e),c=t.length===n.length?[]:t,i=e.length===0||n.length>0;return{calendars:n,colorByCalendarId:a,timeZoneByCalendarId:r,shown:t,narrowed:c,resolved:i,isLoading:o}}function j(e,n,a){const r=a.join(",");return f.useMemo(()=>{const o=new Set(r===""?[]:r.split(","));return e.filter(t=>W(t)&&o.has(t.calendarId)).map(t=>M(t,n[t.calendarId]??N))},[e,n,r])}const w=A(400,404),C=5*6e4,E=({from:e,to:n,calendarIds:a})=>({query:a.length===0?{from:e,to:n}:{from:e,to:n,calendarId:[...a]}});function b(e){const{data:n,isLoading:a,error:r,refetch:o}=y({...p(E(e)),meta:w,staleTime:C,enabled:e.enabled??!0});return{instances:n?.items??[],isLoading:a,error:r,refetch:()=>{o()}}}function k(e,n,a){const r=S({queries:e.map(s=>({...p(E({...s,calendarIds:n})),meta:w,staleTime:C,enabled:a}))}),o=e.map(s=>s.from).join("|"),t=r.map(s=>s.data),c=r.map(s=>s.isPending).join("|"),i=r.find(s=>s.error)?.error??null,d=f.useMemo(()=>t.flatMap(s=>s?.items??[]),[o,c]),m=f.useMemo(()=>{const s=new Set;return e.forEach((h,l)=>{r[l]?.isPending&&s.add(h.from)}),s},[o,c]);return{instances:d,pendingWindows:m,error:i,refetch:()=>{for(const s of r)s.error&&s.refetch()}}}function Q(e,n,a,r){const o=I(),t=[...a].join(",");f.useEffect(()=>{if(!r)return;const c=t===""?[]:t.split(",");for(const i of[-1,1]){const d=g(e,v(n,e,i));o.prefetchQuery({...p(E({...d,calendarIds:c})),staleTime:C})}},[o,e,n,t,r])}function x({view:e,date:n,calendarIds:a,enabled:r=!0}){const{calendars:o,colorByCalendarId:t,timeZoneByCalendarId:c,shown:i,narrowed:d,resolved:m,isLoading:s}=_(a),h=g(e,n),l=r&&m,u=b({...h,calendarIds:d,enabled:l});Q(e,n,d,l);const D=j(u.instances,c,i);return{calendars:o,events:D,colorByCalendarId:t,timeZoneByCalendarId:c,isLoading:s||u.isLoading,error:u.error,retry:u.refetch,instanceOf:O}}export{C,k as a,j as b,x as c,_ as u};
@@ -1 +1 @@
1
- import{c as o,eA as s,r as l}from"./index-Bi5u-0pF.js";const I=()=>Intl.DateTimeFormat().resolvedOptions().timeZone,p="",d={Cal1:"cal-1",Cal2:"cal-2",Cal3:"cal-3",Cal4:"cal-4",Cal5:"cal-5",Cal6:"cal-6"},i={Local:"local",Explicit:"explicit",Ambiguous:"ambiguous"},n="#";function u(e,a){return a===""?e:`${e}${n}${a}`}function O(e){const a=e.indexOf(n);return a===-1?{calendarObjectId:e,recurrenceId:""}:{calendarObjectId:e.slice(0,a),recurrenceId:e.slice(a+1)}}function m(e){return{id:e.calendarId,accountId:e.accountConfigId,accountLabel:"",name:e.displayName,color:d[e.color]??"cal-1"}}function f(e,a){return{id:u(e.calendarObjectId,e.recurrenceId),calendarId:e.calendarId,title:e.summary,start:e.start,end:e.end,allDay:e.allDay,location:"",notes:"",attendees:[],myRsvp:"accepted",threadId:"",threadSubject:"",timeZone:a,zoneCertainty:i[e.zoneCertainty]??"explicit",recurrenceRule:e.hasRecurrence?"Repeats":"",seriesId:e.hasRecurrence?e.icalUid:"",seriesException:!1,status:e.status==="Tentative"?"tentative":"confirmed"}}const E=e=>e.status!=="Cancelled";function R(){const{data:e,isLoading:a}=o(s());return l.useMemo(()=>{const r=e?.items??[],c=r.map(m);return{calendars:c,colorByCalendarId:Object.fromEntries(c.map(t=>[t.id,t.color])),timeZoneByCalendarId:Object.fromEntries(r.map(t=>[t.calendarId,t.timezone])),isLoading:a}},[e,a])}export{p as U,u as c,I as d,E as i,O as r,f as t,R as u};
1
+ import{c as o,eB as s,r as l}from"./index-DvUChk7j.js";const I=()=>Intl.DateTimeFormat().resolvedOptions().timeZone,p="",d={Cal1:"cal-1",Cal2:"cal-2",Cal3:"cal-3",Cal4:"cal-4",Cal5:"cal-5",Cal6:"cal-6"},i={Local:"local",Explicit:"explicit",Ambiguous:"ambiguous"},n="#";function u(e,a){return a===""?e:`${e}${n}${a}`}function O(e){const a=e.indexOf(n);return a===-1?{calendarObjectId:e,recurrenceId:""}:{calendarObjectId:e.slice(0,a),recurrenceId:e.slice(a+1)}}function m(e){return{id:e.calendarId,accountId:e.accountConfigId,accountLabel:"",name:e.displayName,color:d[e.color]??"cal-1"}}function f(e,a){return{id:u(e.calendarObjectId,e.recurrenceId),calendarId:e.calendarId,title:e.summary,start:e.start,end:e.end,allDay:e.allDay,location:"",notes:"",attendees:[],myRsvp:"accepted",threadId:"",threadSubject:"",timeZone:a,zoneCertainty:i[e.zoneCertainty]??"explicit",recurrenceRule:e.hasRecurrence?"Repeats":"",seriesId:e.hasRecurrence?e.icalUid:"",seriesException:!1,status:e.status==="Tentative"?"tentative":"confirmed"}}const E=e=>e.status!=="Cancelled";function R(){const{data:e,isLoading:a}=o(s());return l.useMemo(()=>{const r=e?.items??[],c=r.map(m);return{calendars:c,colorByCalendarId:Object.fromEntries(c.map(t=>[t.id,t.color])),timeZoneByCalendarId:Object.fromEntries(r.map(t=>[t.calendarId,t.timezone])),isLoading:a}},[e,a])}export{p as U,u as c,I as d,E as i,O as r,f as t,R as u};
@@ -1 +1 @@
1
- import{r as o}from"./index-Bi5u-0pF.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-DvUChk7j.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 p,i as b,eo as E,c as C,ep as x,dW as F,eq as D,h as M,er as N,es as P,et as L,eu as z}from"./index-Bi5u-0pF.js";const B=(e,t)=>{if(e.state==="Expired")return"Expired";if(e.scope!=="Temporary"||!e.expiresAt)return"Active";const r=Date.parse(e.expiresAt);return Number.isNaN(r)?"Active":r<=t?"Expired":"Active"},K=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"})},O=(e,t=new Date)=>{if(!e)return;const r=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!r)return;const[,a,i,n]=r,s=new Date(Number(a),Number(i)-1,Number(n),23,59,59,0);if(Number.isNaN(s.getTime()))return;const o=-t.getTimezoneOffset(),d=o>=0?"+":"-",l=Math.abs(o),c=String(Math.floor(l/60)).padStart(2,"0"),f=String(l%60).padStart(2,"0"),u=m=>String(m).padStart(2,"0");return`${s.getFullYear()}-${u(s.getMonth()+1)}-${u(s.getDate())}T${u(s.getHours())}:${u(s.getMinutes())}:${u(s.getSeconds())}${d}${c}:${f}`},h="None",V=e=>!e.literalClauses.some(t=>t.field==="HasWords"),y=e=>({...e.anchorMessageId?{anchorMessageId:e.anchorMessageId}:{},matchOperator:e.matchOperator,literalClauses:e.literalClauses,actionLabelId:e.labelId??h,actionMailboxId:e.moveMailboxId??h}),G=({mode:e,ruleScope:t})=>t==="standing"?"standing":t==="until"?"temporary":e==="selected"?"just-these":"all-like-these",X=({mode:e,ruleScope:t,anchorMessageId:r,clauses:a,matchOperator:i,moveMailboxId:n,until:s})=>({...e==="similar"&&r?{anchorMessageId:r}:{},matchOperator:i==="all"?"And":"Or",literalClauses:a.map(o=>({field:o.field,value:o.value})),moveMailboxId:n,expiresAt:t==="until"?O(s??""):void 0}),S=(e,t,r)=>({name:r,scope:t==="standing"?"Standing":"Temporary",...t==="temporary"&&e.expiresAt?{expiresAt:e.expiresAt}:{},matchOperator:e.matchOperator,literalClauses:e.literalClauses,actionLabelId:e.labelId??h,actionMailboxId:e.moveMailboxId??h,...e.anchorMessageId?{anchorMessageId:e.anchorMessageId}:{}}),T=new Set(["Complete","Failed"]),v=e=>e!==void 0&&T.has(e),w=1e3,J=15e3,_=e=>{const t=Math.max(0,e),r=w*2**t;return Math.min(r,J)},$=(e,t,r)=>{if(e)return{kind:r?"restartFailed":"startFailed",error:e};if(t)return{kind:"statusUnreadable",error:t}},Y=e=>{const[t,r]=p.useState(),a=b({...E(),onSuccess:g=>r(g.organizeJobId)}),{mutate:i}=a,n=C({...x({path:{accountId:e??"",organizeJobId:t??""}}),enabled:!!e&&!!t,refetchInterval:g=>{const I=g.state.data?.state;return v(I)?!1:_(g.state.dataUpdateCount)}}),s=p.useCallback(g=>{e&&i({path:{accountId:e},body:y(g)})},[e,i]),{refetch:o}=n,d=p.useCallback(()=>{o()},[o]),l=n.data,c=a.isPending?void 0:l,f=c?.state??a.data?.state,u=v(c?.state),m={state:f,matchedCount:c?.matchedCount??0,appliedCount:c?.appliedCount??0,failedCount:c?.failedCount??0,errorMessage:c?.errorMessage??""};return{start:s,refreshStatus:d,progress:m,isStarting:a.isPending,isRunning:!!t&&!u,isDone:u,failure:$(a.error,n.error,!!l)}},Z=["From","Subject","HasWords","ListId","FromDomain"],k=e=>{const t=e.trim(),r=t.match(/<([^>]+)>/);return(r?r[1]:t).trim().toLowerCase()},ee=(e,t)=>e==="ListId"?k(t):t.trim(),R=e=>e==="all"?"And":"Or",U=(e,t)=>{const r=e.widen!==void 0&&!e.widen.inactive,a=e.clauses.map(i=>({field:i.field,value:i.value}));return{...r&&t?{anchorMessageId:t}:{},matchOperator:R(e.matchOperator),literalClauses:a}},q=e=>e.anchorMessageId!==void 0||!e.literalClauses.some(t=>t.field==="HasWords"),Q=e=>JSON.stringify({anchor:e.anchorMessageId??null,operator:e.matchOperator,clauses:e.literalClauses.map(t=>`${t.field} ${t.value}`)}),te=(e,t)=>{const r=U(e,t);return{...r.anchorMessageId?{anchorMessageId:r.anchorMessageId}:{},matchOperator:r.matchOperator,literalClauses:r.literalClauses,moveMailboxId:e.moveMailboxId,labelId:e.labelId,expiresAt:e.scope==="until"?O(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},j=350,re=(e,t,r)=>{const a=b(F()),{mutateAsync:i}=a,n=Q(t),[s,o]=p.useState(()=>({})),d=p.useRef(t);d.current=t;const l=p.useRef(n),c=q(t);return p.useEffect(()=>{if(!e||!c||n===s.previewedSignature||n===s.errorSignature)return;const f=setTimeout(()=>{const u=n;l.current=u,i({path:{accountId:e},body:y({...d.current})}).then(m=>{l.current===u&&o({count:m.matchedCount,matchedIds:m.messageIds,previewedSignature:u})}).catch(m=>{l.current===u&&o(g=>({...g,error:m instanceof Error?m.message:"Couldn't count matches.",errorSignature:u}))})},j);return()=>clearTimeout(f)},[e,c,n,s.previewedSignature,s.errorSignature,i]),c?{count:W(s,n),matchedIds:s.previewedSignature===n?s.matchedIds??[]:[]}:{count:{status:"error",reason:D},matchedIds:[]}},A=e=>P({path:{accountId:e}}),se=e=>{const t=C({...L({path:{accountId:e??""}}),enabled:!!e});return{filters:t.data?.items??[],isPending:t.isPending,isError:t.isError,error:t.error,refetch:t.refetch}},ae=e=>{const t=M(),r=b({...N(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:A(e)})}}),{mutate:a,mutateAsync:i}=r,n=p.useCallback((o,d,l)=>{e&&a({path:{accountId:e},body:S(o,d,l)})},[e,a]),s=p.useCallback(async(o,d,l)=>e?i({path:{accountId:e},body:S(o,d,l)}).then(()=>!0,()=>!1):!1,[e,i]);return{createFilter:n,createFilterAsync:s,isPending:r.isPending,isSuccess:r.isSuccess,isError:r.isError,error:r.error,reset:r.reset}},ne=e=>{const t=M(),r=b({...z(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:A(e)})}}),{mutate:a}=r;return{deleteFilter:p.useCallback(n=>{e&&a({path:{accountId:e,filterId:n}})},[e,a]),isPending:r.isPending,deletingFilterId:r.isPending?r.variables?.path.filterId:void 0}};export{h as N,Z as S,Y as a,A as b,te as c,K as d,se as e,B as f,ne as g,y as h,ae as i,X as j,V as k,ee as n,G as o,O as p,U as r,re as u};
1
+ import{r as p,i as b,eo as E,c as C,ep as x,dW as F,eq as D,h as M,er as N,es as P,et as L,eu as z}from"./index-DvUChk7j.js";const B=(e,t)=>{if(e.state==="Expired")return"Expired";if(e.scope!=="Temporary"||!e.expiresAt)return"Active";const r=Date.parse(e.expiresAt);return Number.isNaN(r)?"Active":r<=t?"Expired":"Active"},K=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"})},O=(e,t=new Date)=>{if(!e)return;const r=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!r)return;const[,a,i,n]=r,s=new Date(Number(a),Number(i)-1,Number(n),23,59,59,0);if(Number.isNaN(s.getTime()))return;const o=-t.getTimezoneOffset(),d=o>=0?"+":"-",l=Math.abs(o),c=String(Math.floor(l/60)).padStart(2,"0"),f=String(l%60).padStart(2,"0"),u=m=>String(m).padStart(2,"0");return`${s.getFullYear()}-${u(s.getMonth()+1)}-${u(s.getDate())}T${u(s.getHours())}:${u(s.getMinutes())}:${u(s.getSeconds())}${d}${c}:${f}`},h="None",V=e=>!e.literalClauses.some(t=>t.field==="HasWords"),y=e=>({...e.anchorMessageId?{anchorMessageId:e.anchorMessageId}:{},matchOperator:e.matchOperator,literalClauses:e.literalClauses,actionLabelId:e.labelId??h,actionMailboxId:e.moveMailboxId??h}),G=({mode:e,ruleScope:t})=>t==="standing"?"standing":t==="until"?"temporary":e==="selected"?"just-these":"all-like-these",X=({mode:e,ruleScope:t,anchorMessageId:r,clauses:a,matchOperator:i,moveMailboxId:n,until:s})=>({...e==="similar"&&r?{anchorMessageId:r}:{},matchOperator:i==="all"?"And":"Or",literalClauses:a.map(o=>({field:o.field,value:o.value})),moveMailboxId:n,expiresAt:t==="until"?O(s??""):void 0}),S=(e,t,r)=>({name:r,scope:t==="standing"?"Standing":"Temporary",...t==="temporary"&&e.expiresAt?{expiresAt:e.expiresAt}:{},matchOperator:e.matchOperator,literalClauses:e.literalClauses,actionLabelId:e.labelId??h,actionMailboxId:e.moveMailboxId??h,...e.anchorMessageId?{anchorMessageId:e.anchorMessageId}:{}}),T=new Set(["Complete","Failed"]),v=e=>e!==void 0&&T.has(e),w=1e3,J=15e3,_=e=>{const t=Math.max(0,e),r=w*2**t;return Math.min(r,J)},$=(e,t,r)=>{if(e)return{kind:r?"restartFailed":"startFailed",error:e};if(t)return{kind:"statusUnreadable",error:t}},Y=e=>{const[t,r]=p.useState(),a=b({...E(),onSuccess:g=>r(g.organizeJobId)}),{mutate:i}=a,n=C({...x({path:{accountId:e??"",organizeJobId:t??""}}),enabled:!!e&&!!t,refetchInterval:g=>{const I=g.state.data?.state;return v(I)?!1:_(g.state.dataUpdateCount)}}),s=p.useCallback(g=>{e&&i({path:{accountId:e},body:y(g)})},[e,i]),{refetch:o}=n,d=p.useCallback(()=>{o()},[o]),l=n.data,c=a.isPending?void 0:l,f=c?.state??a.data?.state,u=v(c?.state),m={state:f,matchedCount:c?.matchedCount??0,appliedCount:c?.appliedCount??0,failedCount:c?.failedCount??0,errorMessage:c?.errorMessage??""};return{start:s,refreshStatus:d,progress:m,isStarting:a.isPending,isRunning:!!t&&!u,isDone:u,failure:$(a.error,n.error,!!l)}},Z=["From","Subject","HasWords","ListId","FromDomain"],k=e=>{const t=e.trim(),r=t.match(/<([^>]+)>/);return(r?r[1]:t).trim().toLowerCase()},ee=(e,t)=>e==="ListId"?k(t):t.trim(),R=e=>e==="all"?"And":"Or",U=(e,t)=>{const r=e.widen!==void 0&&!e.widen.inactive,a=e.clauses.map(i=>({field:i.field,value:i.value}));return{...r&&t?{anchorMessageId:t}:{},matchOperator:R(e.matchOperator),literalClauses:a}},q=e=>e.anchorMessageId!==void 0||!e.literalClauses.some(t=>t.field==="HasWords"),Q=e=>JSON.stringify({anchor:e.anchorMessageId??null,operator:e.matchOperator,clauses:e.literalClauses.map(t=>`${t.field} ${t.value}`)}),te=(e,t)=>{const r=U(e,t);return{...r.anchorMessageId?{anchorMessageId:r.anchorMessageId}:{},matchOperator:r.matchOperator,literalClauses:r.literalClauses,moveMailboxId:e.moveMailboxId,labelId:e.labelId,expiresAt:e.scope==="until"?O(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},j=350,re=(e,t,r)=>{const a=b(F()),{mutateAsync:i}=a,n=Q(t),[s,o]=p.useState(()=>({})),d=p.useRef(t);d.current=t;const l=p.useRef(n),c=q(t);return p.useEffect(()=>{if(!e||!c||n===s.previewedSignature||n===s.errorSignature)return;const f=setTimeout(()=>{const u=n;l.current=u,i({path:{accountId:e},body:y({...d.current})}).then(m=>{l.current===u&&o({count:m.matchedCount,matchedIds:m.messageIds,previewedSignature:u})}).catch(m=>{l.current===u&&o(g=>({...g,error:m instanceof Error?m.message:"Couldn't count matches.",errorSignature:u}))})},j);return()=>clearTimeout(f)},[e,c,n,s.previewedSignature,s.errorSignature,i]),c?{count:W(s,n),matchedIds:s.previewedSignature===n?s.matchedIds??[]:[]}:{count:{status:"error",reason:D},matchedIds:[]}},A=e=>P({path:{accountId:e}}),se=e=>{const t=C({...L({path:{accountId:e??""}}),enabled:!!e});return{filters:t.data?.items??[],isPending:t.isPending,isError:t.isError,error:t.error,refetch:t.refetch}},ae=e=>{const t=M(),r=b({...N(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:A(e)})}}),{mutate:a,mutateAsync:i}=r,n=p.useCallback((o,d,l)=>{e&&a({path:{accountId:e},body:S(o,d,l)})},[e,a]),s=p.useCallback(async(o,d,l)=>e?i({path:{accountId:e},body:S(o,d,l)}).then(()=>!0,()=>!1):!1,[e,i]);return{createFilter:n,createFilterAsync:s,isPending:r.isPending,isSuccess:r.isSuccess,isError:r.isError,error:r.error,reset:r.reset}},ne=e=>{const t=M(),r=b({...z(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:A(e)})}}),{mutate:a}=r;return{deleteFilter:p.useCallback(n=>{e&&a({path:{accountId:e,filterId:n}})},[e,a]),isPending:r.isPending,deletingFilterId:r.isPending?r.variables?.path.filterId:void 0}};export{h as N,Z as S,Y as a,A as b,te as c,K as d,se as e,B as f,ne as g,y as h,ae as i,X as j,V as k,ee as n,G as o,O as p,U as r,re as u};
@@ -1 +1 @@
1
- import{c as L,ej as p,h as n,i as l,ek as d,r as o,el as y,em as c,en as g}from"./index-Bi5u-0pF.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}},f=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({...c(),onSuccess:()=>{e&&r.invalidateQueries({queryKey:u(e)})}}),{mutate:s}=t;return{updateLabel:o.useCallback((a,i)=>{e&&s({path:{accountId:e,labelId:a},body:i})},[e,s]),isPending:t.isPending,updatingLabelId:t.isPending?t.variables?.path.labelId:void 0}},C=e=>{const r=n(),t=l({...g(),onSuccess:()=>{e&&r.invalidateQueries({queryKey:u(e)})}}),{mutate:s}=t;return{deleteLabel:o.useCallback(a=>{e&&s({path:{accountId:e,labelId:a}})},[e,s]),isPending:t.isPending,deletingLabelId:t.isPending?t.variables?.path.labelId:void 0}};export{P as a,h as b,C as c,f as u};
1
+ import{c as L,ej as p,h as n,i as l,ek as d,r as o,el as y,em as c,en as g}from"./index-DvUChk7j.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}},f=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({...c(),onSuccess:()=>{e&&r.invalidateQueries({queryKey:u(e)})}}),{mutate:s}=t;return{updateLabel:o.useCallback((a,i)=>{e&&s({path:{accountId:e,labelId:a},body:i})},[e,s]),isPending:t.isPending,updatingLabelId:t.isPending?t.variables?.path.labelId:void 0}},C=e=>{const r=n(),t=l({...g(),onSuccess:()=>{e&&r.invalidateQueries({queryKey:u(e)})}}),{mutate:s}=t;return{deleteLabel:o.useCallback(a=>{e&&s({path:{accountId:e,labelId:a}})},[e,s]),isPending:t.isPending,deletingLabelId:t.isPending?t.variables?.path.labelId:void 0}};export{P as a,h as b,C as c,f as u};
@@ -1 +1 @@
1
- import{e as s,bZ as t,b_ as a}from"./index-Bi5u-0pF.js";const p=s("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"}]]),o=768,r=e=>e!=="desktop",c=()=>{const e=t(`(min-width: ${o}px)`);return t(a)?"desktop":e?"tablet":"phone"};export{p as B,r as i,c as u};
1
+ import{e as s,bZ as t,b_ as a}from"./index-DvUChk7j.js";const p=s("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"}]]),o=768,r=e=>e!=="desktop",c=()=>{const e=t(`(min-width: ${o}px)`);return t(a)?"desktop":e?"tablet":"phone"};export{p as B,r as i,c as u};
@@ -1 +1 @@
1
- import{r as c,u as S,cj as O,ck as B,a9 as h,cl as N,q as P,ab as U,h as $,c as D,cG as F,cH as v}from"./index-Bi5u-0pF.js";const R="/mail/brief/compose/{-$outboxMessageId}",w="/mail/flagged/compose/{-$outboxMessageId}",E="/mail/outbox/compose/{-$outboxMessageId}",k="/mail/$mailboxId/compose/{-$outboxMessageId}";function T(){const e=h({from:R,shouldThrow:!1}),t=h({from:w,shouldThrow:!1}),r=h({from:E,shouldThrow:!1}),s=h({from:k,shouldThrow:!1});return e??t??r??s}function z(){return T()!==void 0}function Y(){return T()?.outboxMessageId}function L(e,t,r){return e==="flagged"?{to:w,params:{outboxMessageId:r}}:e==="outbox"?{to:E,params:{outboxMessageId:r}}:e==="mailbox"&&t?{to:k,params:{mailboxId:t,outboxMessageId:r}}:{to:R,params:{outboxMessageId:r}}}function g(){const e=S(),t=O(),{list:r,mailboxId:s}=B();return c.useCallback((n,o)=>{e({...L(r,s,n),search:a=>a,hash:o?.keepPanels?!0:t,replace:o?.replace??!1})},[e,t,r,s])}function J(){const e=g();return c.useCallback(()=>e(void 0),[e])}function V(){const e=g();return c.useCallback(t=>e(t),[e])}function Z(){const e=g();return c.useCallback(t=>e(t,{replace:!0,keepPanels:!0}),[e])}function ee(){return N()}const _=e=>{const t=e.filter(n=>!n.isMultipart&&n.disposition!=="attachment"&&n.mediaType==="TEXT"&&n.contentUrl.length>0),r=t.find(n=>n.mediaSubtype.toUpperCase()==="HTML");if(r)return{kind:"html",contentUrl:r.contentUrl};const s=t.find(n=>n.mediaSubtype.toUpperCase()==="PLAIN");return s?{kind:"text",contentUrl:s.contentUrl}:null},b={all:["messages"],detail:e=>[...b.all,"detail",e],body:e=>[...b.detail(e),"body"]};class f extends Error{reason;status;retryAfterSeconds;constructor(t,r,s,n){super(r),this.name="BodyFetchError",this.reason=t,this.status=s,this.retryAfterSeconds=n}}const q=e=>{const t=Number.parseInt(e??"",10);return!Number.isFinite(t)||t<=0?1:Math.min(t,30)},K=8,Q="x-remit-403-reason",I=(e,t)=>{const r=t?.trim()??"";return e===401?"auth":e===403?r.length>0?"auth":"body-missing":e===404?"body-missing":"generic"},X=(e,t)=>(t??"").toLowerCase().startsWith("text/html")?/<div\s+id=["']root["']/i.test(e):!1,G=(e,t)=>{const r=(t??"").toLowerCase();return!!(e==="text"&&r.startsWith("text/html"))},H=async(e,t,r=async()=>null)=>{const s={},n=await r();n&&(s.Authorization=`Bearer ${n}`);const o=await v(e,{headers:s});if(o.status===202)throw new f("not-ready","Message body is still syncing",202,q(o.headers.get("Retry-After")));if(!o.ok){const l=o.headers.get(Q),y=I(o.status,l);throw new f(y,`Failed to load message body (${o.status} ${o.statusText})`,o.status)}const a=o.headers.get("content-type");if(G(t,a))throw new f("content-type-mismatch",`Refusing to render message body — expected ${t}, got Content-Type ${a}`);const m=await o.text();if(X(m,a))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},W=async(e,t)=>(t.isRetryAfterNotReady&&await e.refetchDescribeMessage(),e.fetchContent(t.contentUrl,t.kind)),te=({messageId:e,bodyParts:t,enabled:r=!0})=>{const s=t?_(t):null,n=P(),{getToken:o}=U(),a=c.useRef(null),m=$(),l=c.useRef(!1),y=c.useRef(null),C=e&&s?`${e}:${s.contentUrl}`:null;y.current!==C&&(y.current=C,l.current=!1);const i=D({queryKey:e?[...b.body(e),s?.contentUrl??null]:["messages","body","noop"],queryFn:()=>{if(!s)throw new Error("No renderable body part");if(!e)throw new Error("No messageId");const d=l.current;return l.current=!1,W({fetchContent:(u,M)=>H(u,M,o),refetchDescribeMessage:()=>m.refetchQueries({queryKey:F({path:{messageId:e}})})},{contentUrl:s.contentUrl,kind:s.kind,isRetryAfterNotReady:d})},enabled:r&&!!e&&!!s,staleTime:300*1e3,gcTime:1800*1e3,retry:(d,u)=>u instanceof f&&u.reason==="not-ready"?d<K:d<1,retryDelay:(d,u)=>u instanceof f&&u.reason==="not-ready"?(l.current=!0,(u.retryAfterSeconds??1)*1e3):1e3,meta:{softError:!0}}),p=i.isLoading&&!!s,x=t!==void 0&&s===null;c.useEffect(()=>{p&&(a.current=performance.now())},[p]),c.useEffect(()=>{i.isSuccess&&a.current!==null&&(n.recordTiming("message.body.load",Math.round(performance.now()-a.current)),a.current=null)},[i.isSuccess,n]);const A=i.data&&s?{kind:s.kind,body:i.data}:void 0;return{picked:s,data:A,isLoading:p,hasNoRenderablePart:x,isError:i.isError,error:i.error,refetch:i.refetch}};export{f as B,z as a,te as b,Y as c,Z as d,ee as e,V as f,I as g,J as u};
1
+ import{r as c,u as S,cj as O,ck as B,a9 as h,cl as N,q as P,ab as U,h as $,c as D,cG as F,cH as v}from"./index-DvUChk7j.js";const R="/mail/brief/compose/{-$outboxMessageId}",w="/mail/flagged/compose/{-$outboxMessageId}",E="/mail/outbox/compose/{-$outboxMessageId}",k="/mail/$mailboxId/compose/{-$outboxMessageId}";function T(){const e=h({from:R,shouldThrow:!1}),t=h({from:w,shouldThrow:!1}),r=h({from:E,shouldThrow:!1}),s=h({from:k,shouldThrow:!1});return e??t??r??s}function z(){return T()!==void 0}function Y(){return T()?.outboxMessageId}function L(e,t,r){return e==="flagged"?{to:w,params:{outboxMessageId:r}}:e==="outbox"?{to:E,params:{outboxMessageId:r}}:e==="mailbox"&&t?{to:k,params:{mailboxId:t,outboxMessageId:r}}:{to:R,params:{outboxMessageId:r}}}function g(){const e=S(),t=O(),{list:r,mailboxId:s}=B();return c.useCallback((n,o)=>{e({...L(r,s,n),search:a=>a,hash:o?.keepPanels?!0:t,replace:o?.replace??!1})},[e,t,r,s])}function J(){const e=g();return c.useCallback(()=>e(void 0),[e])}function V(){const e=g();return c.useCallback(t=>e(t),[e])}function Z(){const e=g();return c.useCallback(t=>e(t,{replace:!0,keepPanels:!0}),[e])}function ee(){return N()}const _=e=>{const t=e.filter(n=>!n.isMultipart&&n.disposition!=="attachment"&&n.mediaType==="TEXT"&&n.contentUrl.length>0),r=t.find(n=>n.mediaSubtype.toUpperCase()==="HTML");if(r)return{kind:"html",contentUrl:r.contentUrl};const s=t.find(n=>n.mediaSubtype.toUpperCase()==="PLAIN");return s?{kind:"text",contentUrl:s.contentUrl}:null},b={all:["messages"],detail:e=>[...b.all,"detail",e],body:e=>[...b.detail(e),"body"]};class f extends Error{reason;status;retryAfterSeconds;constructor(t,r,s,n){super(r),this.name="BodyFetchError",this.reason=t,this.status=s,this.retryAfterSeconds=n}}const q=e=>{const t=Number.parseInt(e??"",10);return!Number.isFinite(t)||t<=0?1:Math.min(t,30)},K=8,Q="x-remit-403-reason",I=(e,t)=>{const r=t?.trim()??"";return e===401?"auth":e===403?r.length>0?"auth":"body-missing":e===404?"body-missing":"generic"},X=(e,t)=>(t??"").toLowerCase().startsWith("text/html")?/<div\s+id=["']root["']/i.test(e):!1,G=(e,t)=>{const r=(t??"").toLowerCase();return!!(e==="text"&&r.startsWith("text/html"))},H=async(e,t,r=async()=>null)=>{const s={},n=await r();n&&(s.Authorization=`Bearer ${n}`);const o=await v(e,{headers:s});if(o.status===202)throw new f("not-ready","Message body is still syncing",202,q(o.headers.get("Retry-After")));if(!o.ok){const l=o.headers.get(Q),y=I(o.status,l);throw new f(y,`Failed to load message body (${o.status} ${o.statusText})`,o.status)}const a=o.headers.get("content-type");if(G(t,a))throw new f("content-type-mismatch",`Refusing to render message body — expected ${t}, got Content-Type ${a}`);const m=await o.text();if(X(m,a))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},W=async(e,t)=>(t.isRetryAfterNotReady&&await e.refetchDescribeMessage(),e.fetchContent(t.contentUrl,t.kind)),te=({messageId:e,bodyParts:t,enabled:r=!0})=>{const s=t?_(t):null,n=P(),{getToken:o}=U(),a=c.useRef(null),m=$(),l=c.useRef(!1),y=c.useRef(null),C=e&&s?`${e}:${s.contentUrl}`:null;y.current!==C&&(y.current=C,l.current=!1);const i=D({queryKey:e?[...b.body(e),s?.contentUrl??null]:["messages","body","noop"],queryFn:()=>{if(!s)throw new Error("No renderable body part");if(!e)throw new Error("No messageId");const d=l.current;return l.current=!1,W({fetchContent:(u,M)=>H(u,M,o),refetchDescribeMessage:()=>m.refetchQueries({queryKey:F({path:{messageId:e}})})},{contentUrl:s.contentUrl,kind:s.kind,isRetryAfterNotReady:d})},enabled:r&&!!e&&!!s,staleTime:300*1e3,gcTime:1800*1e3,retry:(d,u)=>u instanceof f&&u.reason==="not-ready"?d<K:d<1,retryDelay:(d,u)=>u instanceof f&&u.reason==="not-ready"?(l.current=!0,(u.retryAfterSeconds??1)*1e3):1e3,meta:{softError:!0}}),p=i.isLoading&&!!s,x=t!==void 0&&s===null;c.useEffect(()=>{p&&(a.current=performance.now())},[p]),c.useEffect(()=>{i.isSuccess&&a.current!==null&&(n.recordTiming("message.body.load",Math.round(performance.now()-a.current)),a.current=null)},[i.isSuccess,n]);const A=i.data&&s?{kind:s.kind,body:i.data}:void 0;return{picked:s,data:A,isLoading:p,hasNoRenderablePart:x,isError:i.isError,error:i.error,refetch:i.refetch}};export{f as B,z as a,te as b,Y as c,Z as d,ee as e,V as f,I as g,J as u};
@@ -1 +1 @@
1
- import{b$ as Q,c0 as y,c1 as S,c2 as w,c3 as C,h as k,c4 as q,c5 as x,r as p,c6 as M,c7 as H,c8 as L,c9 as P,ca as O,cb as B,cc as A}from"./index-Bi5u-0pF.js";function R(r,e){const s=new Set(e);return r.filter(t=>!s.has(t))}function T(r,e,s){const t=r.slice(0);return t[e]=s,t}var z=class extends Q{#i;#e;#n;#r;#s;#t;#o;#u;#h;#c=[];constructor(r,e,s){super(),this.#i=r,this.#r=s,this.#n=[],this.#s=[],this.#e=[],this.setQueries(e)}onSubscribe(){this.listeners.size===1&&this.#s.forEach(r=>{r.subscribe(e=>{this.#d(r,e)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#s.forEach(r=>{r.destroy()})}setQueries(r,e){this.#n=r,this.#r=e,y.batch(()=>{const s=this.#s,t=this.#f(this.#n);t.forEach(o=>o.observer.setOptions(o.defaultedQueryOptions));const i=t.map(o=>o.observer),n=i.map(o=>o.getCurrentResult()),u=s.length!==i.length,a=i.some((o,d)=>o!==s[d]),f=u||a,b=f?!0:n.some((o,d)=>{const g=this.#e[d];return!g||!S(o,g)});!f&&!b||(f&&(this.#c=t,this.#s=i),this.#e=n,this.hasListeners()&&(f&&(R(s,i).forEach(o=>{o.destroy()}),R(i,s).forEach(o=>{o.subscribe(d=>{this.#d(o,d)})})),this.#p()))})}getCurrentResult(){return this.#e}getQueries(){return this.#s.map(r=>r.getCurrentQuery())}getObservers(){return this.#s}getOptimisticResult(r,e){const s=this.#f(r),t=s.map(n=>n.observer.getOptimisticResult(n.defaultedQueryOptions)),i=s.map(n=>n.defaultedQueryOptions.queryHash);return[t,n=>this.#l(n??t,e,i),()=>this.#a(t,s)]}#a(r,e){return e.map((s,t)=>{const i=r[t];return s.defaultedQueryOptions.notifyOnChangeProps?i:s.observer.trackResult(i,n=>{e.forEach(u=>{u.observer.trackProp(n)})})})}#l(r,e,s){if(e){const t=this.#h,i=s!==void 0&&t!==void 0&&(t.length!==s.length||s.some((n,u)=>n!==t[u]));return(!this.#t||this.#e!==this.#u||i||e!==this.#o)&&(this.#o=e,this.#u=this.#e,s!==void 0&&(this.#h=s),this.#t=w(this.#t,e(r))),this.#t}return r}#b(){return this.#r?.combine!==void 0&&this.#s.some((r,e)=>r.options.suspense&&this.#e[e]?.data===void 0)}#f(r){const e=new Map;this.#s.forEach(t=>{const i=t.options.queryHash;if(!i)return;const n=e.get(i);n?n.push(t):e.set(i,[t])});const s=[];return r.forEach(t=>{const i=this.#i.defaultQueryOptions(t),u=e.get(i.queryHash)?.shift()??new C(this.#i,i);s.push({defaultedQueryOptions:i,observer:u})}),s}#d(r,e){const s=this.#s.indexOf(r);s!==-1&&(this.#e=T(this.#e,s,e),this.#p())}#p(){if(this.hasListeners()){const r=this.#a(this.#e,this.#c),e=this.#b(),s=this.#t,t=e?s:this.#l(r,this.#r?.combine);(e||s!==t)&&y.batch(()=>{this.listeners.forEach(i=>{i(this.#e)})})}}};function U({queries:r,...e},s){const t=k(),i=q(),n=x(),u=p.useMemo(()=>r.map(h=>{const c=t.defaultQueryOptions(h);return c._optimisticResults=i?"isRestoring":"optimistic",c}),[r,t,i]);u.forEach(h=>{M(h);const c=t.getQueryCache().get(h.queryHash);H(h,n,c)}),L(n);const[a]=p.useState(()=>new z(t,u,e)),[f,b,o]=a.getOptimisticResult(u,e.combine),d=!i&&e.subscribed!==!1;p.useSyncExternalStore(p.useCallback(h=>d?a.subscribe(y.batchCalls(h)):P,[a,d]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),p.useEffect(()=>{a.setQueries(u,e)},[u,e,a]);const m=f.some((h,c)=>O(u[c],h))?f.flatMap((h,c)=>{const l=u[c];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=f.find((h,c)=>{const l=u[c];return l&&A({result:h,errorResetBoundary:n,throwOnError:l.throwOnError,query:t.getQueryCache().get(l.queryHash),suspense:l.suspense})});if(v?.error)throw v.error;return b(o())}export{U as u};
1
+ import{b$ as Q,c0 as y,c1 as S,c2 as w,c3 as C,h as k,c4 as q,c5 as x,r as p,c6 as M,c7 as H,c8 as L,c9 as P,ca as O,cb as B,cc as A}from"./index-DvUChk7j.js";function R(r,e){const s=new Set(e);return r.filter(t=>!s.has(t))}function T(r,e,s){const t=r.slice(0);return t[e]=s,t}var z=class extends Q{#i;#e;#n;#r;#s;#t;#o;#u;#h;#c=[];constructor(r,e,s){super(),this.#i=r,this.#r=s,this.#n=[],this.#s=[],this.#e=[],this.setQueries(e)}onSubscribe(){this.listeners.size===1&&this.#s.forEach(r=>{r.subscribe(e=>{this.#d(r,e)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#s.forEach(r=>{r.destroy()})}setQueries(r,e){this.#n=r,this.#r=e,y.batch(()=>{const s=this.#s,t=this.#f(this.#n);t.forEach(o=>o.observer.setOptions(o.defaultedQueryOptions));const i=t.map(o=>o.observer),n=i.map(o=>o.getCurrentResult()),u=s.length!==i.length,a=i.some((o,d)=>o!==s[d]),f=u||a,b=f?!0:n.some((o,d)=>{const g=this.#e[d];return!g||!S(o,g)});!f&&!b||(f&&(this.#c=t,this.#s=i),this.#e=n,this.hasListeners()&&(f&&(R(s,i).forEach(o=>{o.destroy()}),R(i,s).forEach(o=>{o.subscribe(d=>{this.#d(o,d)})})),this.#p()))})}getCurrentResult(){return this.#e}getQueries(){return this.#s.map(r=>r.getCurrentQuery())}getObservers(){return this.#s}getOptimisticResult(r,e){const s=this.#f(r),t=s.map(n=>n.observer.getOptimisticResult(n.defaultedQueryOptions)),i=s.map(n=>n.defaultedQueryOptions.queryHash);return[t,n=>this.#l(n??t,e,i),()=>this.#a(t,s)]}#a(r,e){return e.map((s,t)=>{const i=r[t];return s.defaultedQueryOptions.notifyOnChangeProps?i:s.observer.trackResult(i,n=>{e.forEach(u=>{u.observer.trackProp(n)})})})}#l(r,e,s){if(e){const t=this.#h,i=s!==void 0&&t!==void 0&&(t.length!==s.length||s.some((n,u)=>n!==t[u]));return(!this.#t||this.#e!==this.#u||i||e!==this.#o)&&(this.#o=e,this.#u=this.#e,s!==void 0&&(this.#h=s),this.#t=w(this.#t,e(r))),this.#t}return r}#b(){return this.#r?.combine!==void 0&&this.#s.some((r,e)=>r.options.suspense&&this.#e[e]?.data===void 0)}#f(r){const e=new Map;this.#s.forEach(t=>{const i=t.options.queryHash;if(!i)return;const n=e.get(i);n?n.push(t):e.set(i,[t])});const s=[];return r.forEach(t=>{const i=this.#i.defaultQueryOptions(t),u=e.get(i.queryHash)?.shift()??new C(this.#i,i);s.push({defaultedQueryOptions:i,observer:u})}),s}#d(r,e){const s=this.#s.indexOf(r);s!==-1&&(this.#e=T(this.#e,s,e),this.#p())}#p(){if(this.hasListeners()){const r=this.#a(this.#e,this.#c),e=this.#b(),s=this.#t,t=e?s:this.#l(r,this.#r?.combine);(e||s!==t)&&y.batch(()=>{this.listeners.forEach(i=>{i(this.#e)})})}}};function U({queries:r,...e},s){const t=k(),i=q(),n=x(),u=p.useMemo(()=>r.map(h=>{const c=t.defaultQueryOptions(h);return c._optimisticResults=i?"isRestoring":"optimistic",c}),[r,t,i]);u.forEach(h=>{M(h);const c=t.getQueryCache().get(h.queryHash);H(h,n,c)}),L(n);const[a]=p.useState(()=>new z(t,u,e)),[f,b,o]=a.getOptimisticResult(u,e.combine),d=!i&&e.subscribed!==!1;p.useSyncExternalStore(p.useCallback(h=>d?a.subscribe(y.batchCalls(h)):P,[a,d]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),p.useEffect(()=>{a.setQueries(u,e)},[u,e,a]);const m=f.some((h,c)=>O(u[c],h))?f.flatMap((h,c)=>{const l=u[c];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=f.find((h,c)=>{const l=u[c];return l&&A({result:h,errorResetBoundary:n,throwOnError:l.throwOnError,query:t.getQueryCache().get(l.queryHash),suspense:l.suspense})});if(v?.error)throw v.error;return b(o())}export{U as u};
@@ -1 +1 @@
1
- import{j as E,a0 as K,t as Q,f as U,r as o,aP as R,h as T,C as $,E as z,F as B,q as G,P as I,Q as X,R as V,S as J}from"./index-Bi5u-0pF.js";import{C as Y}from"./circle-check-big-B5miI5gF.js";import{R as Z}from"./refresh-cw-BN8dsqdR.js";import{u as N}from"./useQueries-Dg1KQOKp.js";function ye({state:e,onRefresh:s,label:t,errorMessage:n,hasUpdate:a,size:u="sm",className:c}){const i=e==="refreshing",r=e==="error",h=e==="success",S=r?E.jsx(K,{className:"size-4 text-danger"}):h?E.jsx(Y,{className:"size-4 text-positive"}):E.jsx(Z,{className:Q("size-4",i&&"animate-spin")}),w=r?`${t} — failed: ${n??"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:S,onClick:s,disabled:i,"aria-label":w,"aria-busy":i||void 0,title:r?n: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 ee=new Set(["discovering_mailboxes","syncing_inbox","syncing_others"]);function L(e){return!!e&&ee.has(e)}const F=3e3,te=F*2,C={syncing:!1,resolved:!1,synced:0,total:0};function we(e,s){const t=e.join(","),[n,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),te);return()=>clearTimeout(m)},[t,s]);const i=N({queries:e.map(m=>({...R({path:{accountId:m}}),enabled:s&&!n,refetchInterval:F,meta:{softError:!0}}))}),r=i.every(m=>m.isSuccess||m.isError),h=i.length===0||r||u;let S=!1,w=0,y=0;for(const m of i)if(L(m.data?.syncPhase)){S=!0;for(const l of m.data?.mailboxes??[])w+=l.messagesSynced,y+=l.messagesTotal}const x=s&&h&&!S;return o.useEffect(()=>{x&&a(!0)},[x]),!s||!h?C:{syncing:S,resolved:!0,synced:w,total:y}}const se=180*1e3,xe=30*1e3;let q=0;const M=new Set,re=(e=Date.now())=>{q=e+se;for(const s of M)s()},pe=(e=Date.now())=>e<q,Ee=e=>(M.add(e),()=>{M.delete(e)}),_=6e4,ne=new Set(["sent","drafts","trash","archive"]),O=(e,s)=>{const t=new Map;for(const n of e){const a=s.get(n.mailboxId)?.role;a&&ne.has(a)||t.set(n.mailboxId,n.highWaterMarkUid)}return t},j=(e,s)=>{const t=[];for(const[n,a]of s)a>(e.get(n)??0)&&t.push(n);return t},oe=(e,s)=>j(e,s).length>0,D=o.createContext(null),ae=()=>{const e=o.useContext(D);if(!e)throw new Error("useMailFreshness must be used inside <MailFreshnessProvider>");return e};function be({accountIds:e,children:s}){const t=T(),{resultFolderIndex:n}=$(),a=o.useRef(new Map),u=o.useRef(new Set),c=o.useRef(new Map),[i,r]=o.useState(new Set),h=N({queries:e.map(l=>({...R({path:{accountId:l}}),refetchInterval:_,staleTime:_,meta:{softError:!0}}))}),S=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=O(b.mailboxes??[],n),v=c.current.get(d);if(c.current.set(d,g),v){const A=j(v,g);A.length>0&&z(t,B(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;oe(W,g)&&(f.add(d),l=!0)}),l&&r(f)},[w,S]);const y=o.useCallback(l=>l.some(f=>i.has(f)),[i]),x=o.useCallback(l=>{r(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,O(d?.mailboxes??[],n)),u.current.add(f)}},[t,n]),m=o.useMemo(()=>({hasNewMail:y,acknowledge:x}),[y,x]);return E.jsx(D.Provider,{value:m,children:s})}const ie=2e3,ce=45e3,ue=e=>new Promise(s=>setTimeout(s,e)),k=e=>e instanceof Error&&e.message?e.message:"Something went wrong",le=e=>{V(e,{softError:!0},"user")&&J(e)},P=(e,s)=>e.fetchQuery({...R({path:{accountId:s}}),staleTime:0}),H=e=>e.mailboxes?.find(s=>s.fullPath?.toUpperCase()==="INBOX")?.lastSyncedAt??0,fe=async({accountId:e,readStatus:s,baselineLastSyncAt:t,baselineInboxSyncedAt:n=0,onInboxSynced:a,deadline:u,pollMs:c=ie})=>{let i=!1;for(;;){const r=await s().then(y=>({ok:!0,data:y})).catch(y=>({ok:!1,error:y}));if(!r.ok)return{accountId:e,message:k(r.error)};const{syncPhase:h,lastSyncAt:S}=r.data;if((S??0)>t&&!L(h))return h==="error"?{accountId:e,message:"Sync failed for this account"}:void 0;if(!i&&H(r.data)>n&&(i=!0,a?.()),Date.now()>=u)return{accountId:e,message:"Refresh is taking longer than usual"};await ue(c)}},de=async(e,s,t,n,a)=>{const u=await P(e,t).then(r=>({ok:!0,lastSyncAt:r.lastSyncAt??0,inboxSyncedAt:H(r)})).catch(r=>({ok:!1,error:r}));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(r=>({ok:!1,error:r}));if(!c.ok)return le(c.error),{accountId:t,enqueued:!1,ok:!1,message:k(c.error)};s.recordEvent("sync.triggered");const i=await fe({accountId:t,readStatus:()=>P(e,t),baselineLastSyncAt:u.lastSyncAt,baselineInboxSyncedAt:u.inboxSyncedAt,onInboxSynced:()=>a(t),deadline:n});return i?{accountId:t,enqueued:!0,ok:!1,message:i.message}:{accountId:t,enqueued:!0,ok:!0}},Re=(e,s={})=>{const t=T(),n=G(),{acknowledge:a}=ae(),[u,c]=o.useState("idle"),[i,r]=o.useState(),h=o.useRef(0),S=o.useRef(e);S.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 y=o.useCallback(()=>{const x=S.current;if(x.length===0){c("error"),r("Nothing to refresh yet");return}const m=++h.current;c("refreshing"),r(void 0),re();const l=f=>{h.current===m&&(t.invalidateQueries({queryKey:X({path:{accountId:f}})}),w.current.onSettled?.())};(async()=>{const f=Date.now()+ce,d=await Promise.all(x.map(g=>de(t,n,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"),r(b[0]?.message))})()},[a,t,n]);return{state:u,errorMessage:i,refresh:y}};export{xe as H,be as M,ye as R,Re as a,L as b,we as c,pe as i,Ee as s,ae as u};
1
+ import{j as E,a0 as K,t as Q,f as U,r as o,aP as R,h as T,C as $,E as z,F as B,q as G,P as I,Q as X,R as V,S as J}from"./index-DvUChk7j.js";import{C as Y}from"./circle-check-big-BWLwy6BP.js";import{R as Z}from"./refresh-cw-Dl-tG_9M.js";import{u as N}from"./useQueries-C5gwtd2q.js";function ye({state:e,onRefresh:s,label:t,errorMessage:n,hasUpdate:a,size:u="sm",className:c}){const i=e==="refreshing",r=e==="error",h=e==="success",S=r?E.jsx(K,{className:"size-4 text-danger"}):h?E.jsx(Y,{className:"size-4 text-positive"}):E.jsx(Z,{className:Q("size-4",i&&"animate-spin")}),w=r?`${t} — failed: ${n??"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:S,onClick:s,disabled:i,"aria-label":w,"aria-busy":i||void 0,title:r?n: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 ee=new Set(["discovering_mailboxes","syncing_inbox","syncing_others"]);function L(e){return!!e&&ee.has(e)}const F=3e3,te=F*2,C={syncing:!1,resolved:!1,synced:0,total:0};function we(e,s){const t=e.join(","),[n,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),te);return()=>clearTimeout(m)},[t,s]);const i=N({queries:e.map(m=>({...R({path:{accountId:m}}),enabled:s&&!n,refetchInterval:F,meta:{softError:!0}}))}),r=i.every(m=>m.isSuccess||m.isError),h=i.length===0||r||u;let S=!1,w=0,y=0;for(const m of i)if(L(m.data?.syncPhase)){S=!0;for(const l of m.data?.mailboxes??[])w+=l.messagesSynced,y+=l.messagesTotal}const x=s&&h&&!S;return o.useEffect(()=>{x&&a(!0)},[x]),!s||!h?C:{syncing:S,resolved:!0,synced:w,total:y}}const se=180*1e3,xe=30*1e3;let q=0;const M=new Set,re=(e=Date.now())=>{q=e+se;for(const s of M)s()},pe=(e=Date.now())=>e<q,Ee=e=>(M.add(e),()=>{M.delete(e)}),_=6e4,ne=new Set(["sent","drafts","trash","archive"]),O=(e,s)=>{const t=new Map;for(const n of e){const a=s.get(n.mailboxId)?.role;a&&ne.has(a)||t.set(n.mailboxId,n.highWaterMarkUid)}return t},j=(e,s)=>{const t=[];for(const[n,a]of s)a>(e.get(n)??0)&&t.push(n);return t},oe=(e,s)=>j(e,s).length>0,D=o.createContext(null),ae=()=>{const e=o.useContext(D);if(!e)throw new Error("useMailFreshness must be used inside <MailFreshnessProvider>");return e};function be({accountIds:e,children:s}){const t=T(),{resultFolderIndex:n}=$(),a=o.useRef(new Map),u=o.useRef(new Set),c=o.useRef(new Map),[i,r]=o.useState(new Set),h=N({queries:e.map(l=>({...R({path:{accountId:l}}),refetchInterval:_,staleTime:_,meta:{softError:!0}}))}),S=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=O(b.mailboxes??[],n),v=c.current.get(d);if(c.current.set(d,g),v){const A=j(v,g);A.length>0&&z(t,B(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;oe(W,g)&&(f.add(d),l=!0)}),l&&r(f)},[w,S]);const y=o.useCallback(l=>l.some(f=>i.has(f)),[i]),x=o.useCallback(l=>{r(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,O(d?.mailboxes??[],n)),u.current.add(f)}},[t,n]),m=o.useMemo(()=>({hasNewMail:y,acknowledge:x}),[y,x]);return E.jsx(D.Provider,{value:m,children:s})}const ie=2e3,ce=45e3,ue=e=>new Promise(s=>setTimeout(s,e)),k=e=>e instanceof Error&&e.message?e.message:"Something went wrong",le=e=>{V(e,{softError:!0},"user")&&J(e)},P=(e,s)=>e.fetchQuery({...R({path:{accountId:s}}),staleTime:0}),H=e=>e.mailboxes?.find(s=>s.fullPath?.toUpperCase()==="INBOX")?.lastSyncedAt??0,fe=async({accountId:e,readStatus:s,baselineLastSyncAt:t,baselineInboxSyncedAt:n=0,onInboxSynced:a,deadline:u,pollMs:c=ie})=>{let i=!1;for(;;){const r=await s().then(y=>({ok:!0,data:y})).catch(y=>({ok:!1,error:y}));if(!r.ok)return{accountId:e,message:k(r.error)};const{syncPhase:h,lastSyncAt:S}=r.data;if((S??0)>t&&!L(h))return h==="error"?{accountId:e,message:"Sync failed for this account"}:void 0;if(!i&&H(r.data)>n&&(i=!0,a?.()),Date.now()>=u)return{accountId:e,message:"Refresh is taking longer than usual"};await ue(c)}},de=async(e,s,t,n,a)=>{const u=await P(e,t).then(r=>({ok:!0,lastSyncAt:r.lastSyncAt??0,inboxSyncedAt:H(r)})).catch(r=>({ok:!1,error:r}));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(r=>({ok:!1,error:r}));if(!c.ok)return le(c.error),{accountId:t,enqueued:!1,ok:!1,message:k(c.error)};s.recordEvent("sync.triggered");const i=await fe({accountId:t,readStatus:()=>P(e,t),baselineLastSyncAt:u.lastSyncAt,baselineInboxSyncedAt:u.inboxSyncedAt,onInboxSynced:()=>a(t),deadline:n});return i?{accountId:t,enqueued:!0,ok:!1,message:i.message}:{accountId:t,enqueued:!0,ok:!0}},Re=(e,s={})=>{const t=T(),n=G(),{acknowledge:a}=ae(),[u,c]=o.useState("idle"),[i,r]=o.useState(),h=o.useRef(0),S=o.useRef(e);S.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 y=o.useCallback(()=>{const x=S.current;if(x.length===0){c("error"),r("Nothing to refresh yet");return}const m=++h.current;c("refreshing"),r(void 0),re();const l=f=>{h.current===m&&(t.invalidateQueries({queryKey:X({path:{accountId:f}})}),w.current.onSettled?.())};(async()=>{const f=Date.now()+ce,d=await Promise.all(x.map(g=>de(t,n,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"),r(b[0]?.message))})()},[a,t,n]);return{state:u,errorMessage:i,refresh:y}};export{xe as H,be as M,ye as R,Re as a,L as b,we as c,pe as i,Ee as s,ae as u};
@@ -1 +1 @@
1
- import{K as r,r as s,b5 as t}from"./index-Bi5u-0pF.js";import{u as m}from"./useQueries-Dg1KQOKp.js";const a=i=>({items:i.map(e=>e.data?.items??[]),isPending:i.some(e=>e.isPending),error:i.find(e=>e.error)?.error??null});function u(i){const e=m({queries:i.map(o=>({...r({path:{accountId:o.accountId}}),staleTime:1/0})),combine:a});return{index:s.useMemo(()=>t(i.map((o,n)=>({folderAppointments:o.folderAppointments,mailboxes:e.items[n]??[]}))),[i,e]),isPending:e.isPending,error:e.error}}export{u};
1
+ import{K as r,r as s,b5 as t}from"./index-DvUChk7j.js";import{u as m}from"./useQueries-C5gwtd2q.js";const a=i=>({items:i.map(e=>e.data?.items??[]),isPending:i.some(e=>e.isPending),error:i.find(e=>e.error)?.error??null});function u(i){const e=m({queries:i.map(o=>({...r({path:{accountId:o.accountId}}),staleTime:1/0})),combine:a});return{index:s.useMemo(()=>t(i.map((o,n)=>({folderAppointments:o.folderAppointments,mailboxes:e.items[n]??[]}))),[i,e]),isPending:e.isPending,error:e.error}}export{u};
@@ -1,4 +1,4 @@
1
- import{cq as Y,r as h,j as a,t as b,I as X,h as Z,at as J,i as ee,av as te,cG as se,bN as re,ab as ne,a0 as ae,X as oe,c$ as _,d0 as $,C as ie,ck as ce}from"./index-Bi5u-0pF.js";import{K as A}from"./kbd-B1FPHud4.js";import{B as le,b as de}from"./useMessageBodyContent-BXu4YPnM.js";import{i as ue}from"./search-scope-B5-OK3Cq.js";const me=(e,t)=>{const r=e==="newsletter"||e==="marketing"||t;return{framed:r,isPlain:!r}},fe=()=>`
1
+ import{cq as Y,r as h,j as a,t as b,I as X,h as Z,at as J,i as ee,av as te,cG as se,bN as re,ab as ne,a0 as ae,X as oe,c$ as _,d0 as $,C as ie,ck as ce}from"./index-DvUChk7j.js";import{K as A}from"./kbd-UGlvLfzQ.js";import{B as le,b as de}from"./useMessageBodyContent-CQamaTRZ.js";import{i as ue}from"./search-scope-B5-OK3Cq.js";const me=(e,t)=>{const r=e==="newsletter"||e==="marketing"||t;return{framed:r,isPlain:!r}},fe=()=>`
2
2
  /* Zero the UA default body margin and clamp the document to the iframe width so
3
3
  wide author markup can't push the body (and the page) past the viewport. */
4
4
  html, body {
@@ -1 +1 @@
1
- import{h as T,at as L,i as k,E as I,F as E,cC as A,ef as R,r as v,dr as j,j as p,eg as h,eh as w,ei as D,C as _,ck as N,c as Q,dM as z,c$ as O}from"./index-Bi5u-0pF.js";import{P}from"./attachment-file-CMXfNfJn.js";import{aj as U}from"./MailListHeader-BMV1rvoO.js";import{a as q}from"./useLabels-B_9aXN4d.js";import{n as B}from"./search-query-Cr_ZXBCp.js";import{b as F}from"./search-scope-B5-OK3Cq.js";import{u as G,p as H}from"./useSearchTokenContext-CoDB8g3-.js";const ne=e=>{const t=new Set;for(const s of e)s&&t.add(s);return t.size>1?{accountId:void 0,restriction:"spansAccounts",moveDisabledHint:"Move only works within one account — clear selection or pick messages from a single account"}:{accountId:t.size===1?[...t][0]:void 0,restriction:void 0,moveDisabledHint:void 0}},$=e=>{const{mailboxId:t,messages:s}=e,n=T(),{pushError:l}=L(),{mutateAsync:c,isPending:a}=k({...R(),onError:(r,u)=>{l({title:u.body.action==="Remove"?"Couldn't remove label":"Couldn't apply label",detail:A(r),error:r})},onSettled:(r,u,d)=>{I(n,E(U(d.body.messageIds??[],s??[],t)))}});return{applyLabel:v.useCallback((r,u,d)=>{r.length!==0&&j(r,m=>c({body:{messageIds:m,labelId:u,action:d}}))},[c]),isPending:a}};function re({accountId:e,mailboxId:t,messageIds:s}){const{labels:n}=q(e),{applyLabel:l}=$({mailboxId:t}),c=v.useMemo(()=>n.map(a=>({key:a.labelId,label:a.name,icon:p.jsx("span",{className:`size-2.5 rounded-full ${w(a.color)?h[a.color]:h.Default}`}),onSelect:()=>l(s,a.labelId,"Apply")})),[n,s,l]);return c.length===0?null:p.jsx(P,{triggerLabel:"Apply label to selected messages",triggerIcon:p.jsx(D,{className:"size-4 text-fg-subtle"}),triggerText:"Apply label",items:c,align:"start",nested:!0,touch:!1,triggerClassName:"min-h-11 w-full justify-start gap-3 px-4 py-2.5 text-sm font-normal text-fg"})}const K=3,ie=({hasSearchQuery:e,freeText:t,residualTokenCount:s})=>{if(!e||s>0)return!1;const n=t.trim();return n.length===0||n.length>=K},ce=e=>e===void 0?{kind:"unknown"}:{kind:"exact",value:e},V=20,Y=new Set(Object.values(O)),J=e=>e!==void 0&&Y.has(e)?e:void 0,W=e=>{if(e.some(t=>t.type==="isUnread"))return!1;if(e.some(t=>t.type==="isRead"))return!0};function le({mailboxId:e,filterCategory:t}={}){const{searchQuery:s}=_(),n=G(),l=N(),c=B(s),{freeText:a,tokens:i}=H(c,n),r=a.length>0,u=i.find(o=>o.type==="category"),d=J(t)??u?.category,m=i.some(o=>o.type==="hasAttachment")?!0:void 0,f=i.some(o=>o.type==="isStarred")?!0:void 0,y=W(i),g=i.find(o=>o.type==="after"),b=i.find(o=>o.type==="before"),x=i.find(o=>o.type==="in"),S=F({browsed:l,callerMailboxId:e,inTokenMailboxId:x?.mailboxId}),{data:C,isLoading:M}=Q({...z({query:{query:a,mailboxId:S,limit:V,...d!==void 0?{category:d}:{},...m!==void 0?{hasAttachment:m}:{},...f!==void 0?{hasStars:f}:{},...y!==void 0?{isRead:y}:{},...g?{sentDateFrom:g.epochSeconds}:{},...b?{sentDateTo:b.epochSeconds}:{}}}),enabled:r,staleTime:6e4});return{hits:C?.items??[],isLoading:r&&M}}export{re as L,ne as r,ie as s,ce as t,le as u};
1
+ import{h as T,at as L,i as k,E as I,F as E,cC as A,ef as R,r as v,dr as j,j as p,eg as h,eh as w,ei as D,C as _,ck as N,c as Q,dM as z,c$ as O}from"./index-DvUChk7j.js";import{P}from"./attachment-file-DWEiGat9.js";import{aj as U}from"./MailListHeader-BVMj_BgB.js";import{a as q}from"./useLabels-DDx3QXUG.js";import{n as B}from"./search-query-Cr_ZXBCp.js";import{b as F}from"./search-scope-B5-OK3Cq.js";import{u as G,p as H}from"./useSearchTokenContext-D5RrQjdu.js";const ne=e=>{const t=new Set;for(const s of e)s&&t.add(s);return t.size>1?{accountId:void 0,restriction:"spansAccounts",moveDisabledHint:"Move only works within one account — clear selection or pick messages from a single account"}:{accountId:t.size===1?[...t][0]:void 0,restriction:void 0,moveDisabledHint:void 0}},$=e=>{const{mailboxId:t,messages:s}=e,n=T(),{pushError:l}=L(),{mutateAsync:c,isPending:a}=k({...R(),onError:(r,u)=>{l({title:u.body.action==="Remove"?"Couldn't remove label":"Couldn't apply label",detail:A(r),error:r})},onSettled:(r,u,d)=>{I(n,E(U(d.body.messageIds??[],s??[],t)))}});return{applyLabel:v.useCallback((r,u,d)=>{r.length!==0&&j(r,m=>c({body:{messageIds:m,labelId:u,action:d}}))},[c]),isPending:a}};function re({accountId:e,mailboxId:t,messageIds:s}){const{labels:n}=q(e),{applyLabel:l}=$({mailboxId:t}),c=v.useMemo(()=>n.map(a=>({key:a.labelId,label:a.name,icon:p.jsx("span",{className:`size-2.5 rounded-full ${w(a.color)?h[a.color]:h.Default}`}),onSelect:()=>l(s,a.labelId,"Apply")})),[n,s,l]);return c.length===0?null:p.jsx(P,{triggerLabel:"Apply label to selected messages",triggerIcon:p.jsx(D,{className:"size-4 text-fg-subtle"}),triggerText:"Apply label",items:c,align:"start",nested:!0,touch:!1,triggerClassName:"min-h-11 w-full justify-start gap-3 px-4 py-2.5 text-sm font-normal text-fg"})}const K=3,ie=({hasSearchQuery:e,freeText:t,residualTokenCount:s})=>{if(!e||s>0)return!1;const n=t.trim();return n.length===0||n.length>=K},ce=e=>e===void 0?{kind:"unknown"}:{kind:"exact",value:e},V=20,Y=new Set(Object.values(O)),J=e=>e!==void 0&&Y.has(e)?e:void 0,W=e=>{if(e.some(t=>t.type==="isUnread"))return!1;if(e.some(t=>t.type==="isRead"))return!0};function le({mailboxId:e,filterCategory:t}={}){const{searchQuery:s}=_(),n=G(),l=N(),c=B(s),{freeText:a,tokens:i}=H(c,n),r=a.length>0,u=i.find(o=>o.type==="category"),d=J(t)??u?.category,m=i.some(o=>o.type==="hasAttachment")?!0:void 0,f=i.some(o=>o.type==="isStarred")?!0:void 0,y=W(i),g=i.find(o=>o.type==="after"),b=i.find(o=>o.type==="before"),x=i.find(o=>o.type==="in"),S=F({browsed:l,callerMailboxId:e,inTokenMailboxId:x?.mailboxId}),{data:C,isLoading:M}=Q({...z({query:{query:a,mailboxId:S,limit:V,...d!==void 0?{category:d}:{},...m!==void 0?{hasAttachment:m}:{},...f!==void 0?{hasStars:f}:{},...y!==void 0?{isRead:y}:{},...g?{sentDateFrom:g.epochSeconds}:{},...b?{sentDateTo:b.epochSeconds}:{}}}),enabled:r,staleTime:6e4});return{hits:C?.items??[],isLoading:r&&M}}export{re as L,ne as r,ie as s,ce as t,le as u};
@@ -1 +1 @@
1
- import{h as g,at as p,c as f,d as m,r,i as y,av as T,o as E,l as d}from"./index-Bi5u-0pF.js";const i={html:"",plainText:""},x=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({...d(),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{x as u};
1
+ import{h as g,at as p,c as f,d as m,r,i as y,av as T,o as E,l as d}from"./index-DvUChk7j.js";const i={html:"",plainText:""},x=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({...d(),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{x as u};
@@ -1 +1 @@
1
- import{a9 as d,eD as g,r as u,eE as y,bV as m,u as D,cj as b,eC as C}from"./index-Bi5u-0pF.js";const i="/calendar/$view/$date";function I(){const e=d({from:i,shouldThrow:!1}),a=g({from:i,shouldThrow:!1}),t=e?.view??"",n=e?.date??"",r=a?.calendarId;return u.useMemo(()=>({...y({view:t,date:n},m(new Date)),calendarIds:r??[]}),[t,n,r])}function j(){const e=d({from:"/calendar/$view/$date/$calendarObjectId",shouldThrow:!1}),a=d({from:"/calendar/$view/$date/$calendarObjectId/$recurrenceId",shouldThrow:!1}),t=e?.calendarObjectId,n=a?.recurrenceId;return u.useMemo(()=>t?{calendarObjectId:t,recurrenceId:n}:void 0,[t,n])}function z(){return d({from:"/calendar/$view/$date/new",shouldThrow:!1})!==void 0}function A(){const e=D(),a=b(),{view:t,date:n}=I(),r=u.useCallback(s=>{e({to:i,params:s,search:!0,hash:a})},[e,a]);return u.useMemo(()=>({goToView:s=>r({view:s,date:n}),step:s=>r({view:t,date:C(n,t,s)}),goToToday:()=>r({view:t,date:m(new Date)}),setAnchorDate:s=>e({to:i,params:{view:t,date:s},search:!0,hash:a,replace:!0}),zoomToDay:s=>r({view:"day",date:s}),openEvent:(s,o)=>e(o===void 0||o===""?{to:"/calendar/$view/$date/$calendarObjectId",params:{view:t,date:n,calendarObjectId:s},search:!0,hash:a}:{to:"/calendar/$view/$date/$calendarObjectId/$recurrenceId",params:{view:t,date:n,calendarObjectId:s,recurrenceId:o},search:!0,hash:a}),closeEvent:()=>r({view:t,date:n}),openComposer:()=>e({to:"/calendar/$view/$date/new",params:{view:t,date:n},search:!0,hash:a})}),[r,e,a,t,n])}const c=e=>String(e).padStart(2,"0"),N=e=>`${e.getUTCFullYear()}-${c(e.getUTCMonth()+1)}-${c(e.getUTCDate())}`,p=e=>{const a=e<0?"-":"+",t=Math.abs(e);return`${a}${c(Math.floor(t/60))}:${c(t%60)}`};function w(e,a){const t=new Date(`${e}T${a}:00`);return`${e}T${a}:00${p(-t.getTimezoneOffset())}`}const l=new Map;function O(e){if(l.has(e))return l.get(e);let a;try{a=new Intl.DateTimeFormat("en-US",{timeZone:e,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{a=void 0}return l.set(e,a),a}function $(e,a){const t=O(e);if(!t)return Number.NaN;const n=t.formatToParts(new Date(a)),r=T=>Number(n.find(v=>v.type===T)?.value),s=r("hour")%24;return(Date.UTC(r("year"),r("month")-1,r("day"),s,r("minute"),r("second"))-a)/6e4}function P(e,a,t){if(t==="")return`${e}T${a}:00+00:00`;const n=Date.parse(`${e}T${a}:00Z`),r=$(t,n);if(Number.isNaN(r))return w(e,a);const s=$(t,n-r*6e4);return`${e}T${a}:00${p(Number.isNaN(s)?r:s)}`}const h=e=>w(e,"00:00");function f(e,a){const[t,n,r]=e.split("-").map(Number);return N(new Date(Date.UTC(t,n-1,r+a)))}function U(e){const[a,t,n]=e.split("-").map(Number),r=new Date(Date.UTC(a,t-1,n));return f(e,-((r.getUTCDay()+6)%7))}function E(e,a){const[t,n]=a.split("-").map(Number);if(e==="year")return[`${t}-01-01`,`${t+1}-01-01`];if(e==="month"){const s=`${t}-${c(n)}-01`,o=n===12?`${t+1}-01-01`:`${t}-${c(n+1)}-01`;return[s,o]}if(e==="day")return[a,f(a,1)];const r=U(a);return[r,f(r,7)]}function S(e,a){const[t,n]=E(e,a);return{from:h(t),to:h(n)}}export{f as a,A as b,S as c,j as d,z as e,P as i,I as u};
1
+ import{a9 as d,eE as g,r as u,eF as y,bV as m,u as D,cj as b,eD as C}from"./index-DvUChk7j.js";const i="/calendar/$view/$date";function I(){const e=d({from:i,shouldThrow:!1}),a=g({from:i,shouldThrow:!1}),t=e?.view??"",n=e?.date??"",r=a?.calendarId;return u.useMemo(()=>({...y({view:t,date:n},m(new Date)),calendarIds:r??[]}),[t,n,r])}function j(){const e=d({from:"/calendar/$view/$date/$calendarObjectId",shouldThrow:!1}),a=d({from:"/calendar/$view/$date/$calendarObjectId/$recurrenceId",shouldThrow:!1}),t=e?.calendarObjectId,n=a?.recurrenceId;return u.useMemo(()=>t?{calendarObjectId:t,recurrenceId:n}:void 0,[t,n])}function z(){return d({from:"/calendar/$view/$date/new",shouldThrow:!1})!==void 0}function A(){const e=D(),a=b(),{view:t,date:n}=I(),r=u.useCallback(s=>{e({to:i,params:s,search:!0,hash:a})},[e,a]);return u.useMemo(()=>({goToView:s=>r({view:s,date:n}),step:s=>r({view:t,date:C(n,t,s)}),goToToday:()=>r({view:t,date:m(new Date)}),setAnchorDate:s=>e({to:i,params:{view:t,date:s},search:!0,hash:a,replace:!0}),zoomToDay:s=>r({view:"day",date:s}),openEvent:(s,o)=>e(o===void 0||o===""?{to:"/calendar/$view/$date/$calendarObjectId",params:{view:t,date:n,calendarObjectId:s},search:!0,hash:a}:{to:"/calendar/$view/$date/$calendarObjectId/$recurrenceId",params:{view:t,date:n,calendarObjectId:s,recurrenceId:o},search:!0,hash:a}),closeEvent:()=>r({view:t,date:n}),openComposer:()=>e({to:"/calendar/$view/$date/new",params:{view:t,date:n},search:!0,hash:a})}),[r,e,a,t,n])}const c=e=>String(e).padStart(2,"0"),N=e=>`${e.getUTCFullYear()}-${c(e.getUTCMonth()+1)}-${c(e.getUTCDate())}`,p=e=>{const a=e<0?"-":"+",t=Math.abs(e);return`${a}${c(Math.floor(t/60))}:${c(t%60)}`};function w(e,a){const t=new Date(`${e}T${a}:00`);return`${e}T${a}:00${p(-t.getTimezoneOffset())}`}const l=new Map;function O(e){if(l.has(e))return l.get(e);let a;try{a=new Intl.DateTimeFormat("en-US",{timeZone:e,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{a=void 0}return l.set(e,a),a}function $(e,a){const t=O(e);if(!t)return Number.NaN;const n=t.formatToParts(new Date(a)),r=T=>Number(n.find(v=>v.type===T)?.value),s=r("hour")%24;return(Date.UTC(r("year"),r("month")-1,r("day"),s,r("minute"),r("second"))-a)/6e4}function P(e,a,t){if(t==="")return`${e}T${a}:00+00:00`;const n=Date.parse(`${e}T${a}:00Z`),r=$(t,n);if(Number.isNaN(r))return w(e,a);const s=$(t,n-r*6e4);return`${e}T${a}:00${p(Number.isNaN(s)?r:s)}`}const h=e=>w(e,"00:00");function f(e,a){const[t,n,r]=e.split("-").map(Number);return N(new Date(Date.UTC(t,n-1,r+a)))}function U(e){const[a,t,n]=e.split("-").map(Number),r=new Date(Date.UTC(a,t-1,n));return f(e,-((r.getUTCDay()+6)%7))}function E(e,a){const[t,n]=a.split("-").map(Number);if(e==="year")return[`${t}-01-01`,`${t+1}-01-01`];if(e==="month"){const s=`${t}-${c(n)}-01`,o=n===12?`${t+1}-01-01`:`${t}-${c(n+1)}-01`;return[s,o]}if(e==="day")return[a,f(a,1)];const r=U(a);return[r,f(r,7)]}function S(e,a){const[t,n]=E(e,a);return{from:h(t),to:h(n)}}export{f as a,A as b,S as c,j as d,z as e,P as i,I as u};
package/index.html CHANGED
@@ -38,7 +38,7 @@
38
38
  } catch (_) {}
39
39
  })();
40
40
  </script>
41
- <script type="module" crossorigin src="/assets/index-Bi5u-0pF.js"></script>
41
+ <script type="module" crossorigin src="/assets/index-DvUChk7j.js"></script>
42
42
  <link rel="stylesheet" crossorigin href="/assets/index-nHfgj6E6.css">
43
43
  </head>
44
44
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/web-client-dist",
3
- "version": "0.0.583",
3
+ "version": "0.0.584",
4
4
  "description": "Built Remit web client — static assets and the default runtime config.",
5
5
  "files": [
6
6
  "**/*"
@@ -1 +0,0 @@
1
- import{j as r,L as Tt,W as wt,ev as _e,ew as ue,dX as me,r as n,c as Qe,C as J,bl as Rt,cN as Mt,K as jt,dN as kt,ex as Et,a0 as ze,ee as At,ey as Ft,ak as Ot,cZ as Nt,c_ as Bt}from"./index-Bi5u-0pF.js";import{g as He,e as Lt,f as Ke,u as qt,p as Pt,R as Dt}from"./useSearchTokenContext-CoDB8g3-.js";import{a8 as _t,A as Qt,E as zt,ak as Ht,al as Kt,am as Gt,an as Fe,ao as Wt,ap as Ut,aq as Yt,a7 as $t,ar as Vt,as as Zt,at as Jt,af as Xt,M as es,au as ts,ag as ss,av as os,aw as rs,e as ns,p as as,ai as is,m as cs,S as ls,J as ds,O as Oe,N as us,K as ms,d as fs,Y as hs,Z as gs,$ as Ge,a0 as We,a1 as ps,a2 as xs,a3 as Is}from"./MailListHeader-BMV1rvoO.js";import{u as ys,a as vs,R as bs,b as Ss,c as Cs}from"./useRefreshControl-BUTXJkRF.js";import{u as fe}from"./useQueries-Dg1KQOKp.js";import{t as Ts,u as ws,r as Rs,L as Ms}from"./useSemanticSearch-C2us5P1h.js";import{a as js}from"./useLabels-B_9aXN4d.js";import{u as ks}from"./useLayoutTier-rtRMZphL.js";import{d as Es,w as As}from"./wizard-selection-DxUM65kM.js";import{o as Fs,g as Os,h as Ns}from"./search-token-index-DbuV3Orb.js";import{u as Ue}from"./sections-B98ovYz8.js";import{R as Bs}from"./refresh-cw-BN8dsqdR.js";import{a as Ls}from"./useMessageBodyContent-BXu4YPnM.js";function qs({sync:e}){return e?r.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 py-12 text-center px-4",role:"status","aria-live":"polite",children:[r.jsx(Tt,{className:"size-8 animate-spin text-fg-subtle","aria-hidden":"true"}),r.jsx("p",{className:"text-sm font-medium text-fg",children:"Still syncing your mail"}),r.jsx("p",{className:"text-xs text-fg-subtle",children:Ps(e)})]}):r.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 py-12 text-center px-4",children:[r.jsx(wt,{className:"size-8 text-fg-subtle","aria-hidden":"true"}),r.jsx("p",{className:"text-sm font-medium text-fg",children:"You're caught up"}),r.jsx("p",{className:"text-xs text-fg-subtle",children:"Nothing needs attention."})]})}function Ps({synced:e,total:t}){return t>0?`${e.toLocaleString()} of ${t.toLocaleString()} messages downloaded. This list fills in as they arrive.`:"Downloading your messages. This list fills in as they arrive."}const Ye=[{id:"unread",name:"is",value:"unread"},{id:"attachment",name:"has",value:"attachment"}],$e="category",Ds={unclassified:"uncategorized"},H=e=>Lt(e).map(t=>t.raw),z=e=>e.join(" "),he=e=>{const t=Ke(e);if(t)return Ye.find(o=>o.name===t.name&&o.value===t.value.toLowerCase())?.id},ge=e=>{const t=Ke(e);if(!t||t.name!==$e)return;const o=t.value.toLowerCase(),a=Ds[o];if(a)return a;if(!(!_e(o)||o==="all"))return o},Ve=e=>Ye.find(t=>t.id===e),Ze=e=>Ve(e)!==void 0,_s=e=>{const t=new Set;for(const o of H(e)){const a=he(o);a&&t.add(a)}return t},Qs=e=>{let t="all";for(const o of H(e)){const a=ge(o);a&&(t=a)}return t},zs=(e,t)=>{const o=Ve(t);if(!o)return;const a=H(e),c=a.filter(m=>he(m)!==t);return c.length<a.length?z(c):z([...a,He(o.name,o.value)])},Hs=(e,t)=>{const o=H(e).filter(a=>!ge(a));return z(t==="all"?o:[...o,He($e,t)])},Ks=e=>z(H(e).filter(t=>!he(t)&&!ge(t))),Je=e=>e.trim().length>0,Ne=e=>{if(!Je(e.query))return e.ownFilters;const t=new Set(_s(e.query));for(const o of e.ownFilters)Ze(o)||t.add(o);return t},Be=e=>Je(e.query)?Qs(e.query):e.ownCategory,Le=6e4,Gs=3e4,Ws={kind:"unknown"},qe=e=>(t,o)=>_t(o?.queryKey,e)?t:void 0,Us=(e,t,o)=>({...e,category:[t],limit:o,order:"desc"}),Ys=(e,t)=>({...e,category:[t],order:"desc",count:!0,results:!1}),Pe=(e,t)=>({category:[t],...e.unread!==void 0?{unread:e.unread}:{},...e.starred!==void 0?{starred:e.starred}:{},...e.attachments!==void 0?{attachments:e.attachments}:{},...e.accountId!==void 0?{accountId:e.accountId}:{},...e.muted!==void 0?{muted:e.muted}:{}});function $s({categories:e,criteria:t,limit:o,counted:a}){const c=fe({queries:e.map(d=>{const f=Us(t,d,o),g=Pe(t,d);return{queryKey:me({query:f}),queryFn:async()=>{const{data:T}=await ue({query:f,throwOnError:!0});return T},placeholderData:qe(g),staleTime:Le}})}),m=fe({queries:e.map(d=>{const f=Ys(t,d),g=Pe(t,d);return{queryKey:me({query:f}),queryFn:async()=>{const{data:T}=await ue({query:f,throwOnError:!0});return T},enabled:a,placeholderData:qe(g),staleTime:Le}})}),u=n.useMemo(()=>e.map((d,f)=>{const g=c[f],T=m[f],I=g?.data?.items??[];return{category:d,rows:I,atCap:I.length>=o,total:a?Ts(T?.data?.count):Ws,loading:g?.isPending??!0,failed:g?.isError??!1,retry:()=>{g?.refetch(),a&&T?.refetch()}}}),[e,c,m,a,o]),l=n.useCallback(()=>{for(const d of c)d.refetch();for(const d of m)d.refetch()},[c,m]);return{sections:u,isLoading:c.length>0&&c.every(d=>d.isPending),isError:c.length>0&&c.every(d=>d.isError),refetch:l}}function Vs(e,t,o){const a={...e,limit:t,order:"desc"},{data:c,isLoading:m,isError:u,refetch:l}=Qe({queryKey:me({query:a}),queryFn:async()=>{const{data:f}=await ue({query:a,throwOnError:!0});return f},enabled:o,staleTime:Gs});return{rows:n.useMemo(()=>o?c?.items??[]:[],[c,o]),isLoading:o&&m,isError:o&&u,refetch:n.useCallback(()=>{l()},[l])}}const Zs=(e,t)=>e.createdAt!==t.createdAt?e.createdAt-t.createdAt:e.accountId.localeCompare(t.accountId),Js=e=>[...e].sort(Zs),Xs=["from","subject","category","unread","starred","attachments"],Xe=["contacts","today"],eo=e=>new Set(Xe.filter(t=>e.has(t))),to=(e,t,o,a)=>{const c=Qt({category:e,attributes:t}),{params:m,residual:u}=zt(o,c,Xs),l={...m,...c},d={muted:!1};return l.from!==void 0&&(d.from=l.from),l.subject!==void 0&&(d.subject=l.subject),l.unread!==void 0&&(d.unread=l.unread),l.starred!==void 0&&(d.starred=l.starred),l.attachments!==void 0&&(d.attachments=l.attachments),a!==void 0&&(d.accountId=a),{criteria:d,residual:u}},so=({residual:e,attributes:t})=>e.length===0&&!Xe.some(o=>t.has(o)),oo=50,ro=200,no=[],De=()=>r.jsx("div",{className:"animate-pulse",children:Array.from({length:3}).map((e,t)=>r.jsxs("div",{className:"flex items-start gap-3 py-2 pl-5 pr-4 border-b border-line",children:[r.jsx("div",{className:"size-7 rounded-full bg-surface-sunken shrink-0 mt-0.5"}),r.jsxs("div",{className:"flex-1 space-y-1.5",children:[r.jsxs("div",{className:"flex justify-between gap-2",children:[r.jsx("div",{className:"h-3.5 bg-surface-sunken rounded w-28"}),r.jsx("div",{className:"h-3 bg-surface-sunken rounded w-12"})]}),r.jsx("div",{className:"h-3.5 bg-surface-sunken rounded w-48"}),r.jsx("div",{className:"h-3 bg-surface-sunken rounded w-full"})]})]},t))}),ao=({accountEmail:e})=>{const t=Ue();return r.jsxs("div",{className:"flex items-center gap-2 px-row-inset py-2 border-b border-line bg-danger-soft/40 text-xs text-danger",children:[r.jsx(ze,{className:"size-3.5 shrink-0"}),r.jsxs("span",{className:"flex-1 truncate",children:[e," can't connect"]}),r.jsx("button",{type:"button",onClick:()=>t("accounts"),className:"shrink-0 underline text-danger hover:opacity-80",children:"Reconnect"})]})},io=(e,t)=>{if(t.size===0)return{};const o=e.filter(m=>t.has(m.id)),a=Rs(o.map(m=>m.accountId));if(a.restriction)return a;const c=new Set;for(const m of o)m.mailboxId&&c.add(m.mailboxId);return c.size>1?{accountId:a.accountId,restriction:"spansFolders",moveDisabledHint:`Move only works within one folder — this selection spans ${c.size} folders`}:{accountId:a.accountId,mailboxId:c.size===1?[...c][0]:void 0}};function co({header:e,rows:t,wizard:o,children:a}){const{selectedIds:c,selectedCount:m,exitSelection:u,orderedIds:l,allSelected:d,toggleAllLoaded:f}=rs(),g=n.useMemo(()=>io(t,c),[t,c]),{junkMailboxId:T}=ns(g.accountId),{labels:I}=js(g.accountId),v=n.useMemo(()=>Array.from(c),[c]),B=n.useMemo(()=>As(t,c),[t,c]),p=as(T,g.mailboxId),b=n.useMemo(()=>l.length>0?{checked:d,indeterminate:m>0&&!d,onChange:f}:void 0,[l.length,d,m,f]),F=g.moveDisabledHint?{tone:"warning",text:g.moveDisabledHint}:void 0,S=R=>r.jsx(ls,{title:R.title,navSlot:R.navSlot,titleMeta:R.titleMeta,searchSlot:R.searchSlot,searchField:R.searchField,idleSlot:R.makeFilterSlot,count:m,onCancel:u,onDelete:()=>o.start("delete"),onMove:()=>o.start("move"),onOrganize:()=>o.start("organize"),onJunk:p?()=>o.start("junk"):void 0,onMarkRead:()=>o.start("markRead"),overflowSlot:g.accountId&&g.mailboxId&&m>0&&I.length>0?r.jsx(Ms,{accountId:g.accountId,mailboxId:g.mailboxId,messageIds:v}):void 0,selectAll:b,notice:F});return r.jsx(is,{...e,selectionBar:S,paneOverlay:r.jsx(cs,{verb:o.verb,accountId:g.accountId,mailboxId:g.mailboxId,selection:B,selectionRestriction:g.restriction,onFinished:u}),children:a})}function lo({accounts:e,selectedMessageId:t,onOpenThread:o,commandsRef:a,onTriageContextChange:c,onDeleteMessages:m}){const{searchQuery:u,searchInput:l,resultFolderIndex:d,onSearchChange:f}=J(),g=qt(),T=Rt(),I=ks(),v=Mt(),B=Fs(),p=n.useMemo(()=>Js(e.filter(s=>!s.muted?.value)),[e]),[b,F]=n.useState("all"),[S,R]=n.useState("all"),[O,L]=n.useState(new Set),[ee,M]=n.useState(!1),q=n.useCallback(s=>{L(i=>{const h=new Set(i);return h.has(s)?h.delete(s):h.add(s),h})},[]),K=n.useCallback(()=>L(new Set),[]),E=l.trim().length>0,{freeText:j,tokens:P}=Pt(u.trim().toLowerCase(),g),y=j.length>0,D=n.useMemo(()=>Ne({query:l,ownFilters:O}),[l,O]),_=n.useMemo(()=>Be({query:l,ownCategory:S}),[l,S]),A=n.useMemo(()=>Ne({query:u,ownFilters:O}),[u,O]),C=n.useMemo(()=>Be({query:u,ownCategory:S}),[u,S]),x=n.useCallback(s=>{if(!E||!Ze(s)){q(s);return}const i=zs(l,s);i!==void 0&&f(i)},[E,l,f,q]),k=n.useCallback(s=>{if(!E){R(s);return}f(Hs(l,s))},[E,l,f]),te=n.useMemo(()=>C==="all"&&!y?s=>{_e(s)&&k(s)}:void 0,[C,y,k]),se=n.useCallback(()=>{R("all"),F("all"),K(),E&&f(Ks(l))},[E,l,f,K]),G=fe({queries:p.map(s=>({...jt({path:{accountId:s.accountId}}),staleTime:1/0,meta:{softError:!0}}))}),W=n.useMemo(()=>{const s=new Map;for(let i=0;i<p.length;i++){const h=p[i].accountId,bt=(G[i]?.data?.items??[]).reduce((St,Ct)=>St+(Ct.unseenCount??0),0);s.set(h,bt)}return s},[p,G]),st=n.useMemo(()=>p.filter((s,i)=>{const h=G[i];return h?.isError?!kt(h.error):!1}),[p,G]),{criteria:oe,residual:re}=n.useMemo(()=>to(C,A,P,b==="all"?void 0:b),[C,A,P,b]),ot=n.useMemo(()=>C==="all"?[...Ht]:[C],[C]),rt=n.useMemo(()=>({...oe,query:j,...C==="all"?{}:{category:[C]}}),[oe,j,C]),nt=so({residual:re,attributes:A}),{sections:U,isLoading:at,isError:it,refetch:pe}=$s({categories:y?no:ot,criteria:oe,limit:C==="all"?os:oo,counted:nt}),{rows:xe,isLoading:ct,isError:lt,refetch:Ie}=Vs(rt,ro,y),ne=y?ct:at,ye=y?lt:it,ve=n.useCallback(()=>{if(y){Ie();return}pe()},[y,Ie,pe]),be=n.useMemo(()=>eo(A),[A]),Y=n.useCallback(s=>Es(s).map(Kt).filter(i=>Et(i,be)&&Gt(i,re)),[be,re]),$=n.useMemo(()=>U.map(s=>({category:s.category,total:s.total,atCap:s.atCap,loading:s.loading,failed:s.failed,rows:Y(s.rows)})),[U,Y]),V=n.useMemo(()=>Y(xe),[xe,Y]),dt=n.useCallback(s=>{U.find(i=>i.category===s)?.retry()},[U]),w=n.useMemo(()=>y?V:$.flatMap(s=>s.rows),[y,V,$]),{spamIds:ae,briefSpamOffer:ie}=n.useMemo(()=>{const s={spamIds:void 0,briefSpamOffer:void 0};if(!j)return s;const i=w.map(N=>Fe(N,d)),{spam:h}=Wt(i);return h.length===0?s:{spamIds:new Set(h.map(N=>N.id)),briefSpamOffer:Ut(i)}},[w,j,d]),Se=n.useMemo(()=>{const s=i=>ae===void 0?i:i.filter(h=>!ae.has(h.id));return y?[{id:"matches",threads:s(V)}]:Yt($.map(i=>({...i,rows:s(i.rows)})))},[y,V,$,ae]),Ce=n.useCallback((s,i)=>{const h=w.find(N=>N.id===s)?.threadId;h&&o?.({threadId:h,messageId:s},i)},[w,o]),ut=n.useCallback(s=>{const i=s.threadId??w.find(h=>h.id===s.id)?.threadId;i&&o?.({threadId:i,messageId:s.id})},[w,o]),ce=n.useMemo(()=>p.length<=1?[]:[{id:"all",label:"All",active:b==="all"},...p.map(s=>({id:s.accountId,label:s.email.split("@")[0]??s.email,count:W.get(s.accountId),active:b===s.accountId}))],[p,W,b]),Q=n.useMemo(()=>e.filter(s=>s.muted?.value).length,[e]),mt=n.useMemo(()=>Array.from(W.values()).reduce((s,i)=>s+i,0),[W]),le=n.useMemo(()=>p.map(s=>s.accountId),[p]),{hasNewMail:Te}=ys(),{state:we,errorMessage:Re,refresh:Me}=vs(le,{onSettled:()=>ve()}),ft=n.useMemo(()=>r.jsx(bs,{state:we,onRefresh:Me,label:"Refresh daily brief",errorMessage:Re,hasUpdate:Te(le)}),[we,Me,Re,Te,le]),de=n.useMemo(()=>w.map(s=>Fe(s,d)),[w,d]),{hits:je,isLoading:ht}=ws(),gt=n.useMemo(()=>{const s=new Map(w.map(h=>[h.id,h.threadId])),i=de.map(h=>s.get(h.id)).filter(h=>h!=null);return $t(je,i,d)},[je,de,w,d]),pt=n.useMemo(()=>{const s=Vt(ce.map(i=>({id:i.id,label:i.label,count:i.count,active:i.active})));return{categories:s.categories,filters:s.filters,sources:s.sources,sourcesNote:Q>0?`+${Q} muted`:void 0,selectedCategory:_,activeFilters:D,expanded:ee,onExpandedChange:M,onSelectCategory:i=>k(i),onSelectSource:F,onToggleFilter:i=>x(i),onClear:se}},[ce,Q,_,D,ee,x,k,se]),ke=Se.length===0&&b==="all"&&j.length===0&&P.length===0,xt=n.useMemo(()=>p.map(s=>s.accountId),[p]),It=n.useMemo(()=>p.some(s=>Ss(s.syncPhase)),[p]),Z=Cs(xt,ke||It),Ee=r.jsxs("div",{className:"h-full overflow-y-auto",children:[r.jsx(De,{}),r.jsx(De,{})]}),Ae=!ne&&!ye&&!ke,yt=Zt({tier:I,hasLiveInput:E,hasCommittedQuery:u.trim().length>0,bodyRendersCommittedResults:!0}),vt=Ae?r.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[ie&&r.jsx(Jt,{count:ie.count,onScopeToSpam:()=>B(ie.mailboxId,u)}),r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(Xt,{sections:Se,briefCategory:_,Row:es,selectedThreadId:t,onSelectThread:Ce,onShowAllSection:te,onRetrySection:dt,flat:y,onSelectBriefCategory:k,sources:ce,sourcesNote:Q>0?`+${Q} muted`:void 0,onSelectSource:F,activeFilters:D,onToggleFilter:x,onClearFilters:se})})]}):ne?Ee:ye?r.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 py-12 text-sm text-fg-muted",children:[r.jsx(ze,{className:"size-8 text-danger"}),r.jsx("p",{children:"Couldn't load your messages"}),r.jsxs("button",{type:"button",onClick:()=>ve(),className:"flex items-center gap-1 text-accent underline text-xs",children:[r.jsx(Bs,{className:"size-3.5"}),"Try again"]})]}):Z.resolved?r.jsx(qs,{sync:Z.syncing?{synced:Z.synced,total:Z.total}:void 0}):Ee;return r.jsx(At,{hasSheet:Ae&&!yt,children:r.jsx(ts,{selectedMessageId:t,rows:w,onOpen:Ce,onDeleteMessages:m,onSelectionVerb:v.start,commandsRef:a,onTriageContextChange:c,children:r.jsx(co,{wizard:v,header:{title:"Daily brief",unreadCount:mt,footer:T?r.jsx(ss,{}):void 0,searchFilter:pt,searchResults:de,searchLoading:ne,relatedResults:gt,relatedLoading:ht,onSelectSearchResult:ut,searchResultsInBody:!0,refreshControl:ft},rows:w,children:r.jsxs("div",{className:"flex h-full flex-col",children:[st.map(s=>r.jsx(ao,{accountEmail:s.email,accountId:s.accountId},s.accountId)),r.jsx("div",{className:"min-h-0 flex-1",children:vt})]})})})})}const et=n.createContext(null);function X(){const e=n.useContext(et);if(!e)throw new Error("BriefPane.* must be used inside <BriefPane>");return e}function uo({thread:e,children:t}){const o=Os(),a=Ns(),c=Ue(),{searchInput:m}=J(),u=e?.threadId,l=e?.messageId,{data:d}=Qe({...Ft(),staleTime:6e4}),f=n.useMemo(()=>d?.items??[],[d]),g=n.useMemo(()=>{if(u)return f.find(x=>x.messageId===l)??f.find(x=>x.threadId===u)},[f,u,l]),T=ds(u,l),I=g??T,v=l??I?.messageId,B=n.useMemo(()=>{if(u)return{threadId:u,mailboxId:I?.mailboxId??"",subject:I?.subject,messageId:v,authenticity:I?.authenticity}},[u,I,v]),p=n.useCallback((x,k)=>{o(x,{replace:k?.replace,query:m})},[o,m]),b=n.useCallback(x=>{v&&x.includes(v)&&a()},[v,a]),F=Oe({thread:I,isOpen:!0,onAfterOptimisticRemove:b}),S=us(),{deleteMessages:R}=ms({mailboxId:I?.mailboxId??"",messages:f,onAfterOptimisticRemove:b}),{toggleReadFor:O}=fs({mailboxId:I?.mailboxId??"",messages:f}),L=S.focusedMessageId,M=n.useMemo(()=>f.find(x=>x.messageId===L),[f,L])??I,q=Oe({thread:M,isOpen:M?.messageId===v}),K=Ls(),E=Ot(),j=Nt(),P=n.useMemo(()=>Bt(j,u,v),[j,u,v]),y=n.useMemo(()=>{if(M)return x=>j({threadId:M.threadId,messageId:M.messageId,mode:x})},[j,M]),{nextMessageId:D,previousMessageId:_}=hs({context:S,orderedIds:S.orderedIds,selectedMessageId:v,enabled:!K&&!E,hasOpenThread:u!==void 0,onClose:a,handlers:{reply:()=>y?.("reply"),replyAll:()=>y?.("reply-all"),forward:()=>y?.("forward"),delete:()=>{S.listCommandsRef.current?.requestVerb("delete")||q.deleteThread()},toggleStar:q.toggleStar,toggleRead:()=>{S.listCommandsRef.current?.requestVerb("markRead")||M&&O([M.messageId],!M.isRead)},goFlagged:()=>c("flagged"),goSettings:()=>c("settings")}}),A=n.useCallback(x=>{if(!x)return;const k=f.find(te=>te.messageId===x);return k?{threadId:k.threadId,messageId:x}:void 0},[f]),C={selectedMessageId:v,selectedThread:I,conversation:B,onOpenThread:p,onCloseThread:a,nextThread:A(D),previousThread:A(_),actions:F,onReply:P,triage:S,onDeleteMessages:R,handleDeselectIfRemoved:b};return r.jsx(et.Provider,{value:C,children:t})}function tt(){const{selectedMessageId:e,onOpenThread:t,triage:o,onDeleteMessages:a}=X(),{accounts:c}=J();return r.jsx(lo,{accounts:c,selectedMessageId:e,onOpenThread:t,commandsRef:o.listCommandsRef,onTriageContextChange:o.onTriageContextChange,onDeleteMessages:a})}function mo(){const{conversation:e,selectedThread:t,actions:o,onReply:a,handleDeselectIfRemoved:c}=X(),m=!!e,u=xs(e?.threadId);return r.jsxs(r.Fragment,{children:[r.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[r.jsx(Is,{hasThread:m,intelligenceOpen:u.isShowing,canToggleIntelligence:u.canToggle,onToggleIntelligence:u.toggle,onReply:a?()=>a("reply"):void 0,onReplyAll:a?()=>a("reply-all"):void 0,onForward:a?()=>a("forward"):void 0,onDelete:m?o.deleteThread:void 0,onToggleStar:m?o.toggleStar:void 0,isStarred:o.isStarred,moveContext:m&&o.accountId&&o.mailboxId?{accountId:o.accountId,currentMailboxId:o.mailboxId,onMove:o.moveThread}:void 0}),r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e?r.jsx(Ge,{threadId:e.threadId,mailboxId:e.mailboxId,subject:e.subject,selectedMessageId:e.messageId,authenticity:e.authenticity,onOpenIntelligence:u.open,listOnScreen:!0}):r.jsx(Dt,{})})]}),r.jsx(We,{isOpen:u.drawerOpen,onClose:u.closeDrawer,thread:t,mailboxId:t?.mailboxId,accountId:t?.accountId,onAfterOptimisticRemove:c})]})}function fo(){const{selectedThread:e,handleDeselectIfRemoved:t}=X(),{onToggleIntelligence:o}=J();return r.jsx(ps,{onClose:o,thread:e,mailboxId:e?.mailboxId,accountId:e?.accountId,onAfterOptimisticRemove:t})}function ho(){const{selectedThread:e,conversation:t,onOpenThread:o,onCloseThread:a,nextThread:c,previousThread:m,handleDeselectIfRemoved:u}=X(),l=gs(t?.threadId??null);return t?r.jsxs(r.Fragment,{children:[r.jsx(Ge,{threadId:t.threadId,mailboxId:t.mailboxId,subject:t.subject,selectedMessageId:t.messageId,authenticity:t.authenticity,onBack:a,onOpenIntelligence:l.toggle,onSwipeNext:c?()=>o(c):void 0,onSwipePrevious:m?()=>o(m):void 0,mobileIntelligenceOpen:l.isOpen}),r.jsx(We,{isOpen:l.isOpen,onClose:l.close,thread:e,mailboxId:e?.mailboxId,accountId:e?.accountId,onAfterOptimisticRemove:u})]}):r.jsx("div",{className:"h-full",children:r.jsx(tt,{})})}const jo=Object.assign(uo,{List:tt,Reading:mo,Intelligence:fo,Phone:ho});export{jo as B};