@remit/web-client-dist 0.0.522 → 0.0.524

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 (151) hide show
  1. package/assets/{BriefPane-DnTuJaxi.js → BriefPane-BFt6V6kp.js} +1 -1
  2. package/assets/{CalendarComposePane-CNJBnGBB.js → CalendarComposePane-DAcupn2s.js} +1 -1
  3. package/assets/{CalendarComposeSeed-D7dfUK8g.js → CalendarComposeSeed-C1QkHXLM.js} +1 -1
  4. package/assets/{CalendarShell-Ci4c-odJ.js → CalendarShell-oqKF2eTp.js} +1 -1
  5. package/assets/{EmptyState-C3_Tj6_z.js → EmptyState-B5l4DUW4.js} +1 -1
  6. package/assets/{ErrorState-DW9hn0tP.js → ErrorState--2p5I6wj.js} +1 -1
  7. package/assets/FlaggedPane-DB-AxQh4.js +1 -0
  8. package/assets/{FullCompose-C5TvJ0sm.js → FullCompose-B4d9WZ6T.js} +1 -1
  9. package/assets/{MailListHeader-CqakXKgQ.js → MailListHeader-kD_OYiqE.js} +2 -2
  10. package/assets/{MailNav-CyHQPdWz.js → MailNav-CjAVXeIh.js} +1 -1
  11. package/assets/{MailShell-CIKDSwWM.js → MailShell-C6gzPUuw.js} +1 -1
  12. package/assets/MailViewChrome-B6yFR2VU.js +1 -0
  13. package/assets/MailboxPane-DQb-w_Zk.js +1 -0
  14. package/assets/{NavMenuButton-BjchpdR5.js → NavMenuButton-xOndgihg.js} +1 -1
  15. package/assets/{OnboardingWizard-Bn3zHI5d.js → OnboardingWizard--zWbuuZO.js} +1 -1
  16. package/assets/{OpenCalendarEvent-BAAe4QSH.js → OpenCalendarEvent-hZfI9rcX.js} +1 -1
  17. package/assets/{OutboxPane-8vnQ0mH1.js → OutboxPane-CmsB8bhV.js} +1 -1
  18. package/assets/_calendarObjectId-CW7GoKo_.js +1 -0
  19. package/assets/_mailboxId-Bh6x_4Ta.js +1 -0
  20. package/assets/_messageId-BjdqRzNA.js +1 -0
  21. package/assets/_messageId-DYsODVAs.js +1 -0
  22. package/assets/_messageId-nZeew1Yi.js +1 -0
  23. package/assets/_outboxMessageId-BN-zHE9o.js +1 -0
  24. package/assets/_recurrenceId-Mxrcukbt.js +1 -0
  25. package/assets/_threadId-D4A-Ul62.js +1 -0
  26. package/assets/_threadId-DoPvTr-5.js +1 -0
  27. package/assets/_threadId-DrlECOd9.js +1 -0
  28. package/assets/{_view._date-BcN3Zrh4.js → _view._date-Dxjb8BoQ.js} +1 -1
  29. package/assets/{accounts-BHAB2yk4.js → accounts-DM22VN8r.js} +1 -1
  30. package/assets/{advanced-DwRWtCUJ.js → advanced-j3PIafmB.js} +1 -1
  31. package/assets/{appearance-BBkTkcNX.js → appearance-D4ZyQxSJ.js} +1 -1
  32. package/assets/{attachment-file-CHE67h17.js → attachment-file-BKW1LvYE.js} +1 -1
  33. package/assets/{attendee-row-CF94Zgm7.js → attendee-row-CaFcq0Dc.js} +1 -1
  34. package/assets/{avatar-Byj273WX.js → avatar-CMlohog8.js} +1 -1
  35. package/assets/{bottom-sheet-DoDgnwLt.js → bottom-sheet-FUNFJG28.js} +1 -1
  36. package/assets/brief-iiiTsECw.js +1 -0
  37. package/assets/{brief-2KMLMaok.js → brief-oohldKpq.js} +1 -1
  38. package/assets/{browser-ponyfill-CPEPqrdG.js → browser-ponyfill-RH8G0PY5.js} +1 -1
  39. package/assets/{bug-CxCMTWPo.js → bug-BOAkHOob.js} +1 -1
  40. package/assets/{calendar-BITFDzqH.js → calendar-BCz_kEKP.js} +1 -1
  41. package/assets/{calendar-color-B1y21BSV.js → calendar-color-BjjneYsQ.js} +1 -1
  42. package/assets/{calendar-event-chip-C8Rq1jnl.js → calendar-event-chip-MdQdmgJv.js} +1 -1
  43. package/assets/{calendars-Bu2QH0Je.js → calendars-k1Woz5Nm.js} +1 -1
  44. package/assets/{card-Qb0JuBjA.js → card-IQFeqGVt.js} +1 -1
  45. package/assets/chevron-left-BuHbO0ZQ.js +1 -0
  46. package/assets/{circle-check-Cofxz4Z8.js → circle-check-B73TBv-p.js} +1 -1
  47. package/assets/{circle-check-big-BEE1r-iG.js → circle-check-big-PApHOS4Q.js} +1 -1
  48. package/assets/{circle-help-CiqAy6xr.js → circle-help-W-bok798.js} +1 -1
  49. package/assets/{clock-BIp_lRT7.js → clock-C5E9t_wY.js} +1 -1
  50. package/assets/compose._-_outboxMessageId_-BCv8oXYc.js +1 -0
  51. package/assets/compose._-_outboxMessageId_-BWWPKba4.js +1 -0
  52. package/assets/compose._-_outboxMessageId_-D8GfOivD.js +1 -0
  53. package/assets/compose._-_outboxMessageId_-rF2ebCVH.js +1 -0
  54. package/assets/config-import-j6Ex6rUg.js +1 -0
  55. package/assets/{confirm-dialog-Dqem_dYa.js → confirm-dialog-BTkV4N2t.js} +1 -1
  56. package/assets/{copy-lcDBDrVg.js → copy-htJcDYRm.js} +1 -1
  57. package/assets/{credential-steps-TeG9x_rG.js → credential-steps-SdAyOxLX.js} +1 -1
  58. package/assets/{download-C2IRMv25.js → download-iYbfvVSU.js} +1 -1
  59. package/assets/{file-json-DU5nTxTP.js → file-json-C19C1p7d.js} +1 -1
  60. package/assets/{filters-BiGgpGQr.js → filters-DGbq9Iiw.js} +1 -1
  61. package/assets/{flagged-BkXUseVD.js → flagged-1F2_cRcu.js} +1 -1
  62. package/assets/flagged-CMInazao.js +1 -0
  63. package/assets/{folders-DI0oSGCV.js → folders-BnesYLu2.js} +1 -1
  64. package/assets/{format-BMecNlt-.js → format-Cc3aS3ot.js} +1 -1
  65. package/assets/{help-copy-Zqo9E9DL.js → help-copy-qqkMLJGu.js} +1 -1
  66. package/assets/{import-BV1_qTVp.js → import-Az3vjKU0.js} +1 -1
  67. package/assets/{index-Gkx4jre7.js → index-86n4-j8G.js} +4 -4
  68. package/assets/index-BbRtyPkp.js +1 -0
  69. package/assets/index-BiVNUJYH.js +1 -0
  70. package/assets/{index-DxZtMOQf.js → index-CCWDwdgT.js} +1 -1
  71. package/assets/index-CLF7GeDo.js +1 -0
  72. package/assets/{index-DFOeerF8.js → index-D855R0Fw.js} +4 -4
  73. package/assets/index-DXNSFZn6.js +1 -0
  74. package/assets/index-DYsODVAs.js +1 -0
  75. package/assets/index-X31FqCoN.js +1 -0
  76. package/assets/index-hhDrR9zg.js +1 -0
  77. package/assets/index-lIM5lIlU.js +1 -0
  78. package/assets/index-nZeew1Yi.js +1 -0
  79. package/assets/{kbd-Bnp5umFa.js → kbd-Cfms0Oys.js} +1 -1
  80. package/assets/{labels-CocmTbVh.js → labels-CN0UpXfN.js} +1 -1
  81. package/assets/{mail-yqKLCIo8.js → mail-CvvXmucI.js} +1 -1
  82. package/assets/{mail-DsDWCtRo.js → mail-D8ExCCOr.js} +1 -1
  83. package/assets/{map-pin-3g2fqkw3.js → map-pin-BqQOdN8M.js} +1 -1
  84. package/assets/{menu-Bw1ZQNFp.js → menu-BHyCi7rW.js} +1 -1
  85. package/assets/{new-DZjHnlH0.js → new-vVhGLr7X.js} +1 -1
  86. package/assets/onboarding-BZef3Ejq.js +1 -0
  87. package/assets/{onboarding-completion-DgzzVQMS.js → onboarding-completion-CZcSJIaU.js} +1 -1
  88. package/assets/outbox-BJKNqc37.js +1 -0
  89. package/assets/{pencil-DFAlp614.js → pencil-BcFzbpXu.js} +1 -1
  90. package/assets/{refresh-cw-DGtjV-Yn.js → refresh-cw-BzxgnCmO.js} +1 -1
  91. package/assets/{rich-text-nj1HJ8n0.js → rich-text-BwW7zU6h.js} +1 -1
  92. package/assets/{rich-text-spellcheck-worker-provider-jdQEKFxj.js → rich-text-spellcheck-worker-provider-BQcgIDy1.js} +1 -1
  93. package/assets/{rotate-ccw-Cf-ERrQd.js → rotate-ccw-CShnXVol.js} +1 -1
  94. package/assets/{row-actions-Dz4qjZPy.js → row-actions-9TTs03mH.js} +1 -1
  95. package/assets/{search-mirror-C5COgo7J.js → search-mirror-CFC1hqWp.js} +1 -1
  96. package/assets/{search-token-index-BDWCdrDr.js → search-token-index-CXxBVdX5.js} +1 -1
  97. package/assets/{sections-Dp5ObH0B.js → sections-BKWo2Deh.js} +1 -1
  98. package/assets/{senders-CGi63VSl.js → senders-CyD_tWBm.js} +1 -1
  99. package/assets/settings-2lNX20rB.js +1 -0
  100. package/assets/{settings-screen-Ci3wkg10.js → settings-screen-BgUjgGfb.js} +1 -1
  101. package/assets/{shield-check-6fRO4KAO.js → shield-check-D_NOwpHN.js} +1 -1
  102. package/assets/{suggested-vips-CltoywuA.js → suggested-vips-BRv9v-4q.js} +1 -1
  103. package/assets/{useCalendarData-BWoVfpR0.js → useCalendarData-CfZbbmWc.js} +1 -1
  104. package/assets/{useCalendars-Bc1XufFR.js → useCalendars-CgIo_kEf.js} +1 -1
  105. package/assets/{useDebouncedValue-DdkXWYbv.js → useDebouncedValue-tudCfT8G.js} +1 -1
  106. package/assets/{useFilters-Ck2Pjjio.js → useFilters-D55evI_2.js} +1 -1
  107. package/assets/{useLabels-aSL1iqHo.js → useLabels-BS3G7NVR.js} +1 -1
  108. package/assets/{useLayoutTier-B7hLuv2u.js → useLayoutTier-BHxPbufX.js} +1 -1
  109. package/assets/{useMessageBodyContent-DKDt9OB3.js → useMessageBodyContent-I6J6WaYN.js} +1 -1
  110. package/assets/{useQueries-CEYkNMRl.js → useQueries-3Ta-bqMs.js} +1 -1
  111. package/assets/{useRefreshControl-BJ7UQujJ.js → useRefreshControl-9O_O25oC.js} +1 -1
  112. package/assets/{useResultFolderIndex-DyB8qnuW.js → useResultFolderIndex-CURSMky8.js} +1 -1
  113. package/assets/{useSearchTokenContext-Dm2n0VLM.js → useSearchTokenContext-D1NKXhM6.js} +3 -3
  114. package/assets/{useSemanticSearch-CdjzwsfH.js → useSemanticSearch-F_a8SnAV.js} +1 -1
  115. package/assets/{useSignature-XrbdPyt4.js → useSignature-g4RGAb59.js} +1 -1
  116. package/assets/{window-C7e0XMZy.js → window-BqaZu6ux.js} +1 -1
  117. package/index.html +1 -1
  118. package/package.json +1 -1
  119. package/assets/FlaggedPane-0vgtNSt6.js +0 -1
  120. package/assets/MailViewChrome-DwQQu8KH.js +0 -1
  121. package/assets/MailboxPane-BjayEYwx.js +0 -1
  122. package/assets/_calendarObjectId-BAAfghhN.js +0 -1
  123. package/assets/_mailboxId-B0BxP5HR.js +0 -1
  124. package/assets/_messageId-BKkr1iAN.js +0 -1
  125. package/assets/_messageId-DUM7dQGx.js +0 -1
  126. package/assets/_messageId-jDiDSHlZ.js +0 -1
  127. package/assets/_outboxMessageId-RoQwzjWh.js +0 -1
  128. package/assets/_recurrenceId-BZhRYQzP.js +0 -1
  129. package/assets/_threadId-BC8g_CXk.js +0 -1
  130. package/assets/_threadId-CA5hY61z.js +0 -1
  131. package/assets/_threadId-DNAbTUro.js +0 -1
  132. package/assets/brief-DSUqmJxl.js +0 -1
  133. package/assets/chevron-left-BuRKvZzj.js +0 -1
  134. package/assets/compose._-_outboxMessageId_-Bd3JXfwQ.js +0 -1
  135. package/assets/compose._-_outboxMessageId_-CgCpZ1_k.js +0 -1
  136. package/assets/compose._-_outboxMessageId_-OZeMdMx-.js +0 -1
  137. package/assets/compose._-_outboxMessageId_-ywj1OM9M.js +0 -1
  138. package/assets/config-import-Bzwkb0t8.js +0 -1
  139. package/assets/flagged-p7xi86g6.js +0 -1
  140. package/assets/index-BMoDGBdN.js +0 -1
  141. package/assets/index-Bk57FPbZ.js +0 -1
  142. package/assets/index-BkI08ywk.js +0 -1
  143. package/assets/index-C8EZD0G2.js +0 -1
  144. package/assets/index-D3X9YpmG.js +0 -1
  145. package/assets/index-DUM7dQGx.js +0 -1
  146. package/assets/index-DjSI_TP5.js +0 -1
  147. package/assets/index-jDiDSHlZ.js +0 -1
  148. package/assets/index-q0cFt_Cw.js +0 -1
  149. package/assets/onboarding-aVNO8ho8.js +0 -1
  150. package/assets/outbox-D4xFVek3.js +0 -1
  151. package/assets/settings-BlkUa0he.js +0 -1
@@ -1 +1 @@
1
- import{j as o,L as Ze,U as Xe,e9 as et,C as Y,bi as tt,cM as st,r as a,c as oe,ea as ne,G as ot,dw as nt,eb as at,dQ as rt,_ as Te,dU as it,aj as ct,cT as lt,cU as dt}from"./index-DFOeerF8.js";import{g as je,e as ut,f as Re,u as mt,p as ft,R as ht}from"./useSearchTokenContext-Dm2n0VLM.js";import{ai as be,F as ve,aj as gt,ak as xt,G as pt,al as ye,am as It,an as bt,ao as vt,a7 as yt,ap as St,aq as Ct,ar as Tt,M as jt,as as Rt,ae as wt,at as Mt,e as kt,v as Ft,af as Ot,q as At,S as Nt,J as Bt,O as Se,N as Lt,K as Dt,d as Et,Y as Pt,Z as qt,$ as we,a0 as Me,a1 as zt,a2 as Qt,a3 as _t}from"./MailListHeader-CqakXKgQ.js";import{u as Ht,a as Ut,R as Gt,b as $t,c as Wt}from"./useRefreshControl-BJ7UQujJ.js";import{u as Vt}from"./useQueries-CEYkNMRl.js";import{a as Yt}from"./useLabels-aSL1iqHo.js";import{u as Jt,b as Kt}from"./useLayoutTier-B7hLuv2u.js";import{u as Zt,r as Xt,L as es}from"./useSemanticSearch-CdjzwsfH.js";import{w as ts}from"./wizard-selection-B1bng5Jq.js";import{u as ke}from"./sections-Dp5ObH0B.js";import{R as ss}from"./refresh-cw-DGtjV-Yn.js";import{a as os}from"./useMessageBodyContent-DKDt9OB3.js";import{g as ns,h as as}from"./search-token-index-BDWCdrDr.js";function rs({sync:e}){return e?o.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:[o.jsx(Ze,{className:"size-8 animate-spin text-fg-subtle","aria-hidden":"true"}),o.jsx("p",{className:"text-sm font-medium text-fg",children:"Still syncing your mail"}),o.jsx("p",{className:"text-xs text-fg-subtle",children:is(e)})]}):o.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 py-12 text-center px-4",children:[o.jsx(Xe,{className:"size-8 text-fg-subtle","aria-hidden":"true"}),o.jsx("p",{className:"text-sm font-medium text-fg",children:"You're caught up"}),o.jsx("p",{className:"text-xs text-fg-subtle",children:"Nothing needs attention."})]})}function is({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 Fe=[{id:"unread",name:"is",value:"unread"},{id:"attachment",name:"has",value:"attachment"}],Oe="category",cs={unclassified:"uncategorized"},U=e=>ut(e).map(t=>t.raw),H=e=>e.join(" "),ae=e=>{const t=Re(e);if(t)return Fe.find(n=>n.name===t.name&&n.value===t.value.toLowerCase())?.id},re=e=>{const t=Re(e);if(!t||t.name!==Oe)return;const n=t.value.toLowerCase(),r=cs[n];if(r)return r;if(!(!et(n)||n==="all"))return n},Ae=e=>Fe.find(t=>t.id===e),Ne=e=>Ae(e)!==void 0,ls=e=>{const t=new Set;for(const n of U(e)){const r=ae(n);r&&t.add(r)}return t},ds=e=>{let t="all";for(const n of U(e)){const r=re(n);r&&(t=r)}return t},us=(e,t)=>{const n=Ae(t);if(!n)return;const r=U(e),l=r.filter(d=>ae(d)!==t);return l.length<r.length?H(l):H([...r,je(n.name,n.value)])},ms=(e,t)=>{const n=U(e).filter(r=>!re(r));return H(t==="all"?n:[...n,je(Oe,t)])},fs=e=>H(U(e).filter(t=>!ae(t)&&!re(t))),Be=e=>e.trim().length>0,hs=e=>{if(!Be(e.query))return e.ownFilters;const t=new Set(ls(e.query));for(const n of e.ownFilters)Ne(n)||t.add(n);return t},gs=e=>Be(e.query)?ds(e.query):e.ownCategory,xs=(e,t)=>e.createdAt!==t.createdAt?e.createdAt-t.createdAt:e.accountId.localeCompare(t.accountId),ps=e=>[...e].sort(xs),Is=200,Ce=()=>o.jsx("div",{className:"animate-pulse",children:Array.from({length:3}).map((e,t)=>o.jsxs("div",{className:"flex items-start gap-3 py-2 pl-5 pr-4 border-b border-line",children:[o.jsx("div",{className:"size-7 rounded-full bg-surface-sunken shrink-0 mt-0.5"}),o.jsxs("div",{className:"flex-1 space-y-1.5",children:[o.jsxs("div",{className:"flex justify-between gap-2",children:[o.jsx("div",{className:"h-3.5 bg-surface-sunken rounded w-28"}),o.jsx("div",{className:"h-3 bg-surface-sunken rounded w-12"})]}),o.jsx("div",{className:"h-3.5 bg-surface-sunken rounded w-48"}),o.jsx("div",{className:"h-3 bg-surface-sunken rounded w-full"})]})]},t))}),bs=({accountEmail:e})=>{const t=ke();return o.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:[o.jsx(Te,{className:"size-3.5 shrink-0"}),o.jsxs("span",{className:"flex-1 truncate",children:[e," can't connect"]}),o.jsx("button",{type:"button",onClick:()=>t("accounts"),className:"shrink-0 underline text-danger hover:opacity-80",children:"Reconnect"})]})},vs=(e,t)=>{if(t.size===0)return{};const n=e.filter(d=>t.has(d.id)),r=Xt(n.map(d=>d.accountId));if(r.restriction)return r;const l=new Set;for(const d of n)d.mailboxId&&l.add(d.mailboxId);return l.size>1?{accountId:r.accountId,restriction:"spansFolders",moveDisabledHint:`Move only works within one folder — this selection spans ${l.size} folders`}:{accountId:r.accountId,mailboxId:l.size===1?[...l][0]:void 0}};function ys({header:e,rows:t,wizard:n,children:r}){const{selectedIds:l,selectedCount:d,exitSelection:u,orderedIds:m,allSelected:b,toggleAllLoaded:f}=Mt(),x=a.useMemo(()=>vs(t,l),[t,l]),{junkMailboxId:L}=kt(x.accountId),{labels:I}=Yt(x.accountId),p=a.useMemo(()=>Array.from(l),[l]),D=a.useMemo(()=>ts(t,l),[t,l]),h=Ft(L,x.mailboxId),v=a.useMemo(()=>m.length>0?{checked:b,indeterminate:d>0&&!b,onChange:f}:void 0,[m.length,b,d,f]),F=x.moveDisabledHint?{tone:"warning",text:x.moveDisabledHint}:void 0,S=C=>o.jsx(Nt,{title:C.title,navSlot:C.navSlot,titleMeta:C.titleMeta,searchSlot:C.searchSlot,searchField:C.searchField,idleSlot:C.makeFilterSlot,count:d,onCancel:u,onDelete:()=>n.start("delete"),onMove:()=>n.start("move"),onOrganize:()=>n.start("organize"),onJunk:h?()=>n.start("junk"):void 0,onMarkRead:()=>n.start("markRead"),overflowSlot:x.accountId&&x.mailboxId&&d>0&&I.length>0?o.jsx(es,{accountId:x.accountId,mailboxId:x.mailboxId,messageIds:p}):void 0,selectAll:v,notice:F});return o.jsx(Ot,{...e,selectionBar:S,paneOverlay:o.jsx(At,{verb:n.verb,accountId:x.accountId,mailboxId:x.mailboxId,selection:D,selectionRestriction:x.restriction,onFinished:u}),children:r})}function Ss({accounts:e,selectedMessageId:t,onOpenThread:n,commandsRef:r,onTriageContextChange:l,onDeleteMessages:d}){const{searchQuery:u,searchInput:m,resultFolderIndex:b,onSearchChange:f}=Y(),x=mt(),L=tt(),I=Jt(),p=st(),D=Kt(),h=a.useMemo(()=>ps(e.filter(s=>!s.muted?.value)),[e]),[v,F]=a.useState("all"),[S,C]=a.useState("all"),[G,E]=a.useState(new Set),[K,T]=a.useState(!1),P=a.useCallback(s=>{E(i=>{const c=new Set(i);return c.has(s)?c.delete(s):c.add(s),c})},[]),$=a.useCallback(()=>E(new Set),[]),R=m.trim().length>0,j=a.useMemo(()=>hs({query:m,ownFilters:G}),[m,G]),w=a.useMemo(()=>gs({query:m,ownCategory:S}),[m,S]),O=a.useCallback(s=>{if(!R||!Ne(s)){P(s);return}const i=us(m,s);i!==void 0&&f(i)},[R,m,f,P]),q=a.useCallback(s=>{if(!R){C(s);return}f(ms(m,s))},[R,m,f]),z=a.useCallback(()=>{C("all"),F("all"),$(),R&&f(fs(m))},[R,m,f,$]),{data:A,isLoading:Q,isError:g,refetch:N}=oe({...ne(),staleTime:6e4}),B=Vt({queries:h.map(s=>({...ot({path:{accountId:s.accountId}}),staleTime:1/0,meta:{softError:!0}}))}),W=a.useMemo(()=>{const s=new Map;for(let i=0;i<h.length;i++){const c=h[i].accountId,Ye=(B[i]?.data?.items??[]).reduce((Je,Ke)=>Je+(Ke.unseenCount??0),0);s.set(c,Ye)}return s},[h,B]),Ee=a.useMemo(()=>h.filter((s,i)=>{const c=B[i];return c?.isError?!nt(c.error):!1}),[h,B]),{freeText:M,tokens:Z}=ft(u.trim().toLowerCase(),x),{data:ie,isFetching:Pe}=oe({...ne({query:{query:M,limit:Is}}),enabled:M.length>0,staleTime:3e4}),y=a.useMemo(()=>{const s=be(A?.items??[]).map(ve);return(M?gt(s.filter(c=>xt(c,M)),be(ie?.items??[]).map(ve)):s).filter(c=>(v==="all"||c.accountId===v)&&pt(c,Z))},[A,ie,v,M,Z]),{bodyRows:ce,briefSpamOffer:X}=a.useMemo(()=>{if(!M)return{bodyRows:y,briefSpamOffer:void 0};const s=y.map(k=>ye(k,b)),{spam:i}=It(s);if(i.length===0)return{bodyRows:y,briefSpamOffer:void 0};const c=new Set(i.map(k=>k.id));return{bodyRows:y.filter(k=>!c.has(k.id)),briefSpamOffer:bt(s)}},[y,M,b]),le=a.useMemo(()=>vt(ce),[ce]),de=a.useCallback((s,i)=>{const c=y.find(k=>k.id===s)?.threadId;c&&n?.({threadId:c,messageId:s},i)},[y,n]),qe=a.useCallback(s=>{const i=s.threadId??y.find(c=>c.id===s.id)?.threadId;i&&n?.({threadId:i,messageId:s.id})},[y,n]),ee=a.useMemo(()=>h.length<=1?[]:[{id:"all",label:"All",active:v==="all"},...h.map(s=>({id:s.accountId,label:s.email.split("@")[0]??s.email,count:W.get(s.accountId),active:v===s.accountId}))],[h,W,v]),_=a.useMemo(()=>e.filter(s=>s.muted?.value).length,[e]),ze=a.useMemo(()=>Array.from(W.values()).reduce((s,i)=>s+i,0),[W]),te=a.useMemo(()=>h.map(s=>s.accountId),[h]),{hasNewMail:ue}=Ht(),{state:me,errorMessage:fe,refresh:he}=Ut(te,{onSettled:()=>N()}),Qe=a.useMemo(()=>o.jsx(Gt,{state:me,onRefresh:he,label:"Refresh daily brief",errorMessage:fe,hasUpdate:ue(te)}),[me,he,fe,ue,te]),se=a.useMemo(()=>y.filter(s=>(w==="all"||s.category===w)&&at(s,j)).map(s=>ye(s,b)),[y,w,j,b]),{hits:ge,isLoading:_e}=Zt(),He=a.useMemo(()=>{const s=new Map;for(const c of A?.items??[])s.set(c.messageId,c.threadId);const i=se.map(c=>s.get(c.id)).filter(c=>c!=null);return yt(ge,i,b)},[ge,se,A,b]),Ue=a.useMemo(()=>{const s=St(ee.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:_>0?`+${_} muted`:void 0,selectedCategory:w,activeFilters:j,expanded:K,onExpandedChange:T,onSelectCategory:i=>q(i),onSelectSource:F,onToggleFilter:i=>O(i),onClear:z}},[ee,_,w,j,K,O,q,z]),xe=le.length===0&&v==="all"&&M.length===0&&Z.length===0,Ge=a.useMemo(()=>h.map(s=>s.accountId),[h]),$e=a.useMemo(()=>h.some(s=>$t(s.syncPhase)),[h]),V=Wt(Ge,xe||$e),pe=o.jsxs("div",{className:"h-full overflow-y-auto",children:[o.jsx(Ce,{}),o.jsx(Ce,{})]}),Ie=!Q&&!g&&!xe,We=Ct({tier:I,hasLiveInput:R,hasCommittedQuery:u.trim().length>0,bodyRendersCommittedResults:!0}),Ve=Ie?o.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[X&&o.jsx(Tt,{count:X.count,onScopeToSpam:()=>D(X.mailboxId,u)}),o.jsx("div",{className:"min-h-0 flex-1",children:o.jsx(rt,{sections:le,briefCategory:w,Row:jt,selectedThreadId:t,onSelectThread:de,onSelectBriefCategory:q,sources:ee,sourcesNote:_>0?`+${_} muted`:void 0,onSelectSource:F,activeFilters:j,onToggleFilter:O,onClearFilters:z})})]}):Q?pe:g?o.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 py-12 text-sm text-fg-muted",children:[o.jsx(Te,{className:"size-8 text-danger"}),o.jsx("p",{children:"Couldn't load your messages"}),o.jsxs("button",{type:"button",onClick:()=>N(),className:"flex items-center gap-1 text-accent underline text-xs",children:[o.jsx(ss,{className:"size-3.5"}),"Try again"]})]}):V.resolved?o.jsx(rs,{sync:V.syncing?{synced:V.synced,total:V.total}:void 0}):pe;return o.jsx(it,{hasSheet:Ie&&!We,children:o.jsx(Rt,{selectedMessageId:t,rows:y,onOpen:de,onDeleteMessages:d,onSelectionVerb:p.start,commandsRef:r,onTriageContextChange:l,children:o.jsx(ys,{wizard:p,header:{title:"Daily brief",unreadCount:ze,footer:L?o.jsx(wt,{}):void 0,searchFilter:Ue,searchResults:se,searchLoading:Q||Pe,relatedResults:He,relatedLoading:_e,onSelectSearchResult:qe,searchResultsInBody:!0,refreshControl:Qe},rows:y,children:o.jsxs("div",{className:"flex h-full flex-col",children:[Ee.map(s=>o.jsx(bs,{accountEmail:s.email,accountId:s.accountId},s.accountId)),o.jsx("div",{className:"min-h-0 flex-1",children:Ve})]})})})})}const Le=a.createContext(null);function J(){const e=a.useContext(Le);if(!e)throw new Error("BriefPane.* must be used inside <BriefPane>");return e}function Cs({thread:e,children:t}){const n=ns(),r=as(),l=ke(),{searchInput:d}=Y(),u=e?.threadId,m=e?.messageId,{data:b}=oe({...ne(),staleTime:6e4}),f=a.useMemo(()=>b?.items??[],[b]),x=a.useMemo(()=>{if(u)return f.find(g=>g.messageId===m)??f.find(g=>g.threadId===u)},[f,u,m]),L=Bt(u,m),I=x??L,p=m??I?.messageId,D=a.useMemo(()=>{if(u)return{threadId:u,mailboxId:I?.mailboxId??"",subject:I?.subject,messageId:p,authenticity:I?.authenticity}},[u,I,p]),h=a.useCallback((g,N)=>{n(g,{replace:N?.replace,query:d})},[n,d]),v=a.useCallback(g=>{p&&g.includes(p)&&r()},[p,r]),F=Se({thread:I,isOpen:!0,onAfterOptimisticRemove:v}),S=Lt(),{deleteMessages:C}=Dt({mailboxId:I?.mailboxId??"",messages:f,onAfterOptimisticRemove:v}),{toggleReadFor:G}=Et({mailboxId:I?.mailboxId??"",messages:f}),E=S.focusedMessageId,T=a.useMemo(()=>f.find(g=>g.messageId===E),[f,E])??I,P=Se({thread:T,isOpen:T?.messageId===p}),$=os(),R=ct(),j=lt(),w=a.useMemo(()=>dt(j,u,p),[j,u,p]),O=a.useMemo(()=>{if(T)return g=>j({threadId:T.threadId,messageId:T.messageId,mode:g})},[j,T]),{nextMessageId:q,previousMessageId:z}=Pt({context:S,orderedIds:S.orderedIds,selectedMessageId:p,enabled:!$&&!R,hasOpenThread:u!==void 0,onClose:r,handlers:{reply:()=>O?.("reply"),replyAll:()=>O?.("reply-all"),forward:()=>O?.("forward"),delete:()=>{S.listCommandsRef.current?.requestVerb("delete")||P.deleteThread()},toggleStar:P.toggleStar,toggleRead:()=>{S.listCommandsRef.current?.requestVerb("markRead")||T&&G([T.messageId],!T.isRead)},goFlagged:()=>l("flagged"),goSettings:()=>l("settings")}}),A=a.useCallback(g=>{if(!g)return;const N=f.find(B=>B.messageId===g);return N?{threadId:N.threadId,messageId:g}:void 0},[f]),Q={selectedMessageId:p,selectedThread:I,conversation:D,onOpenThread:h,onCloseThread:r,nextThread:A(q),previousThread:A(z),actions:F,onReply:w,triage:S,onDeleteMessages:C,handleDeselectIfRemoved:v};return o.jsx(Le.Provider,{value:Q,children:t})}function De(){const{selectedMessageId:e,onOpenThread:t,triage:n,onDeleteMessages:r}=J(),{accounts:l}=Y();return o.jsx(Ss,{accounts:l,selectedMessageId:e,onOpenThread:t,commandsRef:n.listCommandsRef,onTriageContextChange:n.onTriageContextChange,onDeleteMessages:r})}function Ts(){const{conversation:e,selectedThread:t,actions:n,onReply:r,handleDeselectIfRemoved:l}=J(),d=!!e,u=Qt(e?.threadId);return o.jsxs(o.Fragment,{children:[o.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[o.jsx(_t,{hasThread:d,intelligenceOpen:u.isShowing,canToggleIntelligence:u.canToggle,onToggleIntelligence:u.toggle,onReply:r?()=>r("reply"):void 0,onReplyAll:r?()=>r("reply-all"):void 0,onForward:r?()=>r("forward"):void 0,onDelete:d?n.deleteThread:void 0,onToggleStar:d?n.toggleStar:void 0,isStarred:n.isStarred,moveContext:d&&n.accountId&&n.mailboxId?{accountId:n.accountId,currentMailboxId:n.mailboxId,onMove:n.moveThread}:void 0}),o.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e?o.jsx(we,{threadId:e.threadId,mailboxId:e.mailboxId,subject:e.subject,selectedMessageId:e.messageId,authenticity:e.authenticity,onOpenIntelligence:u.open,listOnScreen:!0}):o.jsx(ht,{})})]}),o.jsx(Me,{isOpen:u.drawerOpen,onClose:u.closeDrawer,thread:t,mailboxId:t?.mailboxId,accountId:t?.accountId,onAfterOptimisticRemove:l})]})}function js(){const{selectedThread:e,handleDeselectIfRemoved:t}=J(),{onToggleIntelligence:n}=Y();return o.jsx(zt,{onClose:n,thread:e,mailboxId:e?.mailboxId,accountId:e?.accountId,onAfterOptimisticRemove:t})}function Rs(){const{selectedThread:e,conversation:t,onOpenThread:n,onCloseThread:r,nextThread:l,previousThread:d,handleDeselectIfRemoved:u}=J(),m=qt(t?.threadId??null);return t?o.jsxs(o.Fragment,{children:[o.jsx(we,{threadId:t.threadId,mailboxId:t.mailboxId,subject:t.subject,selectedMessageId:t.messageId,authenticity:t.authenticity,onBack:r,onOpenIntelligence:m.toggle,onSwipeNext:l?()=>n(l):void 0,onSwipePrevious:d?()=>n(d):void 0,mobileIntelligenceOpen:m.isOpen}),o.jsx(Me,{isOpen:m.isOpen,onClose:m.close,thread:e,mailboxId:e?.mailboxId,accountId:e?.accountId,onAfterOptimisticRemove:u})]}):o.jsx("div",{className:"h-full",children:o.jsx(De,{})})}const zs=Object.assign(Cs,{List:De,Reading:Ts,Intelligence:js,Phone:Rs});export{zs as B};
1
+ import{j as o,L as Ze,U as Xe,e9 as et,C as Y,bi as tt,cM as st,r as a,c as oe,ea as ne,G as ot,dw as nt,eb as at,dQ as rt,_ as Te,dU as it,aj as ct,cS as lt,cT as dt}from"./index-D855R0Fw.js";import{g as je,e as ut,f as Re,u as mt,p as ft,R as ht}from"./useSearchTokenContext-D1NKXhM6.js";import{ai as be,ad as ve,aj as gt,ak as xt,ae as pt,al as ye,am as It,an as bt,ao as vt,a5 as yt,ap as St,aq as Ct,ar as Tt,M as jt,as as Rt,ac as wt,at as Mt,e as kt,v as Ft,af as At,q as Ot,S as Nt,H as Bt,L as Se,K as Lt,I as Dt,d as Et,W as Pt,X as qt,Z as we,_ as Me,$ as zt,a0 as Qt,a1 as _t}from"./MailListHeader-kD_OYiqE.js";import{u as Ht,a as Ut,R as Wt,b as $t,c as Gt}from"./useRefreshControl-9O_O25oC.js";import{u as Vt}from"./useQueries-3Ta-bqMs.js";import{a as Yt}from"./useLabels-BS3G7NVR.js";import{u as Jt,b as Kt}from"./useLayoutTier-BHxPbufX.js";import{u as Zt,r as Xt,L as es}from"./useSemanticSearch-F_a8SnAV.js";import{w as ts}from"./wizard-selection-B1bng5Jq.js";import{u as ke}from"./sections-BKWo2Deh.js";import{R as ss}from"./refresh-cw-BzxgnCmO.js";import{a as os}from"./useMessageBodyContent-I6J6WaYN.js";import{g as ns,h as as}from"./search-token-index-CXxBVdX5.js";function rs({sync:e}){return e?o.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:[o.jsx(Ze,{className:"size-8 animate-spin text-fg-subtle","aria-hidden":"true"}),o.jsx("p",{className:"text-sm font-medium text-fg",children:"Still syncing your mail"}),o.jsx("p",{className:"text-xs text-fg-subtle",children:is(e)})]}):o.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 py-12 text-center px-4",children:[o.jsx(Xe,{className:"size-8 text-fg-subtle","aria-hidden":"true"}),o.jsx("p",{className:"text-sm font-medium text-fg",children:"You're caught up"}),o.jsx("p",{className:"text-xs text-fg-subtle",children:"Nothing needs attention."})]})}function is({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 Fe=[{id:"unread",name:"is",value:"unread"},{id:"attachment",name:"has",value:"attachment"}],Ae="category",cs={unclassified:"uncategorized"},U=e=>ut(e).map(t=>t.raw),H=e=>e.join(" "),ae=e=>{const t=Re(e);if(t)return Fe.find(n=>n.name===t.name&&n.value===t.value.toLowerCase())?.id},re=e=>{const t=Re(e);if(!t||t.name!==Ae)return;const n=t.value.toLowerCase(),r=cs[n];if(r)return r;if(!(!et(n)||n==="all"))return n},Oe=e=>Fe.find(t=>t.id===e),Ne=e=>Oe(e)!==void 0,ls=e=>{const t=new Set;for(const n of U(e)){const r=ae(n);r&&t.add(r)}return t},ds=e=>{let t="all";for(const n of U(e)){const r=re(n);r&&(t=r)}return t},us=(e,t)=>{const n=Oe(t);if(!n)return;const r=U(e),l=r.filter(d=>ae(d)!==t);return l.length<r.length?H(l):H([...r,je(n.name,n.value)])},ms=(e,t)=>{const n=U(e).filter(r=>!re(r));return H(t==="all"?n:[...n,je(Ae,t)])},fs=e=>H(U(e).filter(t=>!ae(t)&&!re(t))),Be=e=>e.trim().length>0,hs=e=>{if(!Be(e.query))return e.ownFilters;const t=new Set(ls(e.query));for(const n of e.ownFilters)Ne(n)||t.add(n);return t},gs=e=>Be(e.query)?ds(e.query):e.ownCategory,xs=(e,t)=>e.createdAt!==t.createdAt?e.createdAt-t.createdAt:e.accountId.localeCompare(t.accountId),ps=e=>[...e].sort(xs),Is=200,Ce=()=>o.jsx("div",{className:"animate-pulse",children:Array.from({length:3}).map((e,t)=>o.jsxs("div",{className:"flex items-start gap-3 py-2 pl-5 pr-4 border-b border-line",children:[o.jsx("div",{className:"size-7 rounded-full bg-surface-sunken shrink-0 mt-0.5"}),o.jsxs("div",{className:"flex-1 space-y-1.5",children:[o.jsxs("div",{className:"flex justify-between gap-2",children:[o.jsx("div",{className:"h-3.5 bg-surface-sunken rounded w-28"}),o.jsx("div",{className:"h-3 bg-surface-sunken rounded w-12"})]}),o.jsx("div",{className:"h-3.5 bg-surface-sunken rounded w-48"}),o.jsx("div",{className:"h-3 bg-surface-sunken rounded w-full"})]})]},t))}),bs=({accountEmail:e})=>{const t=ke();return o.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:[o.jsx(Te,{className:"size-3.5 shrink-0"}),o.jsxs("span",{className:"flex-1 truncate",children:[e," can't connect"]}),o.jsx("button",{type:"button",onClick:()=>t("accounts"),className:"shrink-0 underline text-danger hover:opacity-80",children:"Reconnect"})]})},vs=(e,t)=>{if(t.size===0)return{};const n=e.filter(d=>t.has(d.id)),r=Xt(n.map(d=>d.accountId));if(r.restriction)return r;const l=new Set;for(const d of n)d.mailboxId&&l.add(d.mailboxId);return l.size>1?{accountId:r.accountId,restriction:"spansFolders",moveDisabledHint:`Move only works within one folder — this selection spans ${l.size} folders`}:{accountId:r.accountId,mailboxId:l.size===1?[...l][0]:void 0}};function ys({header:e,rows:t,wizard:n,children:r}){const{selectedIds:l,selectedCount:d,exitSelection:u,orderedIds:m,allSelected:b,toggleAllLoaded:f}=Mt(),x=a.useMemo(()=>vs(t,l),[t,l]),{junkMailboxId:L}=kt(x.accountId),{labels:I}=Yt(x.accountId),p=a.useMemo(()=>Array.from(l),[l]),D=a.useMemo(()=>ts(t,l),[t,l]),h=Ft(L,x.mailboxId),v=a.useMemo(()=>m.length>0?{checked:b,indeterminate:d>0&&!b,onChange:f}:void 0,[m.length,b,d,f]),F=x.moveDisabledHint?{tone:"warning",text:x.moveDisabledHint}:void 0,S=C=>o.jsx(Nt,{title:C.title,navSlot:C.navSlot,titleMeta:C.titleMeta,searchSlot:C.searchSlot,searchField:C.searchField,idleSlot:C.makeFilterSlot,count:d,onCancel:u,onDelete:()=>n.start("delete"),onMove:()=>n.start("move"),onOrganize:()=>n.start("organize"),onJunk:h?()=>n.start("junk"):void 0,onMarkRead:()=>n.start("markRead"),overflowSlot:x.accountId&&x.mailboxId&&d>0&&I.length>0?o.jsx(es,{accountId:x.accountId,mailboxId:x.mailboxId,messageIds:p}):void 0,selectAll:v,notice:F});return o.jsx(At,{...e,selectionBar:S,paneOverlay:o.jsx(Ot,{verb:n.verb,accountId:x.accountId,mailboxId:x.mailboxId,selection:D,selectionRestriction:x.restriction,onFinished:u}),children:r})}function Ss({accounts:e,selectedMessageId:t,onOpenThread:n,commandsRef:r,onTriageContextChange:l,onDeleteMessages:d}){const{searchQuery:u,searchInput:m,resultFolderIndex:b,onSearchChange:f}=Y(),x=mt(),L=tt(),I=Jt(),p=st(),D=Kt(),h=a.useMemo(()=>ps(e.filter(s=>!s.muted?.value)),[e]),[v,F]=a.useState("all"),[S,C]=a.useState("all"),[W,E]=a.useState(new Set),[K,T]=a.useState(!1),P=a.useCallback(s=>{E(i=>{const c=new Set(i);return c.has(s)?c.delete(s):c.add(s),c})},[]),$=a.useCallback(()=>E(new Set),[]),R=m.trim().length>0,j=a.useMemo(()=>hs({query:m,ownFilters:W}),[m,W]),w=a.useMemo(()=>gs({query:m,ownCategory:S}),[m,S]),A=a.useCallback(s=>{if(!R||!Ne(s)){P(s);return}const i=us(m,s);i!==void 0&&f(i)},[R,m,f,P]),q=a.useCallback(s=>{if(!R){C(s);return}f(ms(m,s))},[R,m,f]),z=a.useCallback(()=>{C("all"),F("all"),$(),R&&f(fs(m))},[R,m,f,$]),{data:O,isLoading:Q,isError:g,refetch:N}=oe({...ne(),staleTime:6e4}),B=Vt({queries:h.map(s=>({...ot({path:{accountId:s.accountId}}),staleTime:1/0,meta:{softError:!0}}))}),G=a.useMemo(()=>{const s=new Map;for(let i=0;i<h.length;i++){const c=h[i].accountId,Ye=(B[i]?.data?.items??[]).reduce((Je,Ke)=>Je+(Ke.unseenCount??0),0);s.set(c,Ye)}return s},[h,B]),Ee=a.useMemo(()=>h.filter((s,i)=>{const c=B[i];return c?.isError?!nt(c.error):!1}),[h,B]),{freeText:M,tokens:Z}=ft(u.trim().toLowerCase(),x),{data:ie,isFetching:Pe}=oe({...ne({query:{query:M,limit:Is}}),enabled:M.length>0,staleTime:3e4}),y=a.useMemo(()=>{const s=be(O?.items??[]).map(ve);return(M?gt(s.filter(c=>xt(c,M)),be(ie?.items??[]).map(ve)):s).filter(c=>(v==="all"||c.accountId===v)&&pt(c,Z))},[O,ie,v,M,Z]),{bodyRows:ce,briefSpamOffer:X}=a.useMemo(()=>{if(!M)return{bodyRows:y,briefSpamOffer:void 0};const s=y.map(k=>ye(k,b)),{spam:i}=It(s);if(i.length===0)return{bodyRows:y,briefSpamOffer:void 0};const c=new Set(i.map(k=>k.id));return{bodyRows:y.filter(k=>!c.has(k.id)),briefSpamOffer:bt(s)}},[y,M,b]),le=a.useMemo(()=>vt(ce),[ce]),de=a.useCallback((s,i)=>{const c=y.find(k=>k.id===s)?.threadId;c&&n?.({threadId:c,messageId:s},i)},[y,n]),qe=a.useCallback(s=>{const i=s.threadId??y.find(c=>c.id===s.id)?.threadId;i&&n?.({threadId:i,messageId:s.id})},[y,n]),ee=a.useMemo(()=>h.length<=1?[]:[{id:"all",label:"All",active:v==="all"},...h.map(s=>({id:s.accountId,label:s.email.split("@")[0]??s.email,count:G.get(s.accountId),active:v===s.accountId}))],[h,G,v]),_=a.useMemo(()=>e.filter(s=>s.muted?.value).length,[e]),ze=a.useMemo(()=>Array.from(G.values()).reduce((s,i)=>s+i,0),[G]),te=a.useMemo(()=>h.map(s=>s.accountId),[h]),{hasNewMail:ue}=Ht(),{state:me,errorMessage:fe,refresh:he}=Ut(te,{onSettled:()=>N()}),Qe=a.useMemo(()=>o.jsx(Wt,{state:me,onRefresh:he,label:"Refresh daily brief",errorMessage:fe,hasUpdate:ue(te)}),[me,he,fe,ue,te]),se=a.useMemo(()=>y.filter(s=>(w==="all"||s.category===w)&&at(s,j)).map(s=>ye(s,b)),[y,w,j,b]),{hits:ge,isLoading:_e}=Zt(),He=a.useMemo(()=>{const s=new Map;for(const c of O?.items??[])s.set(c.messageId,c.threadId);const i=se.map(c=>s.get(c.id)).filter(c=>c!=null);return yt(ge,i,b)},[ge,se,O,b]),Ue=a.useMemo(()=>{const s=St(ee.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:_>0?`+${_} muted`:void 0,selectedCategory:w,activeFilters:j,expanded:K,onExpandedChange:T,onSelectCategory:i=>q(i),onSelectSource:F,onToggleFilter:i=>A(i),onClear:z}},[ee,_,w,j,K,A,q,z]),xe=le.length===0&&v==="all"&&M.length===0&&Z.length===0,We=a.useMemo(()=>h.map(s=>s.accountId),[h]),$e=a.useMemo(()=>h.some(s=>$t(s.syncPhase)),[h]),V=Gt(We,xe||$e),pe=o.jsxs("div",{className:"h-full overflow-y-auto",children:[o.jsx(Ce,{}),o.jsx(Ce,{})]}),Ie=!Q&&!g&&!xe,Ge=Ct({tier:I,hasLiveInput:R,hasCommittedQuery:u.trim().length>0,bodyRendersCommittedResults:!0}),Ve=Ie?o.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[X&&o.jsx(Tt,{count:X.count,onScopeToSpam:()=>D(X.mailboxId,u)}),o.jsx("div",{className:"min-h-0 flex-1",children:o.jsx(rt,{sections:le,briefCategory:w,Row:jt,selectedThreadId:t,onSelectThread:de,onSelectBriefCategory:q,sources:ee,sourcesNote:_>0?`+${_} muted`:void 0,onSelectSource:F,activeFilters:j,onToggleFilter:A,onClearFilters:z})})]}):Q?pe:g?o.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 py-12 text-sm text-fg-muted",children:[o.jsx(Te,{className:"size-8 text-danger"}),o.jsx("p",{children:"Couldn't load your messages"}),o.jsxs("button",{type:"button",onClick:()=>N(),className:"flex items-center gap-1 text-accent underline text-xs",children:[o.jsx(ss,{className:"size-3.5"}),"Try again"]})]}):V.resolved?o.jsx(rs,{sync:V.syncing?{synced:V.synced,total:V.total}:void 0}):pe;return o.jsx(it,{hasSheet:Ie&&!Ge,children:o.jsx(Rt,{selectedMessageId:t,rows:y,onOpen:de,onDeleteMessages:d,onSelectionVerb:p.start,commandsRef:r,onTriageContextChange:l,children:o.jsx(ys,{wizard:p,header:{title:"Daily brief",unreadCount:ze,footer:L?o.jsx(wt,{}):void 0,searchFilter:Ue,searchResults:se,searchLoading:Q||Pe,relatedResults:He,relatedLoading:_e,onSelectSearchResult:qe,searchResultsInBody:!0,refreshControl:Qe},rows:y,children:o.jsxs("div",{className:"flex h-full flex-col",children:[Ee.map(s=>o.jsx(bs,{accountEmail:s.email,accountId:s.accountId},s.accountId)),o.jsx("div",{className:"min-h-0 flex-1",children:Ve})]})})})})}const Le=a.createContext(null);function J(){const e=a.useContext(Le);if(!e)throw new Error("BriefPane.* must be used inside <BriefPane>");return e}function Cs({thread:e,children:t}){const n=ns(),r=as(),l=ke(),{searchInput:d}=Y(),u=e?.threadId,m=e?.messageId,{data:b}=oe({...ne(),staleTime:6e4}),f=a.useMemo(()=>b?.items??[],[b]),x=a.useMemo(()=>{if(u)return f.find(g=>g.messageId===m)??f.find(g=>g.threadId===u)},[f,u,m]),L=Bt(u,m),I=x??L,p=m??I?.messageId,D=a.useMemo(()=>{if(u)return{threadId:u,mailboxId:I?.mailboxId??"",subject:I?.subject,messageId:p,authenticity:I?.authenticity}},[u,I,p]),h=a.useCallback((g,N)=>{n(g,{replace:N?.replace,query:d})},[n,d]),v=a.useCallback(g=>{p&&g.includes(p)&&r()},[p,r]),F=Se({thread:I,isOpen:!0,onAfterOptimisticRemove:v}),S=Lt(),{deleteMessages:C}=Dt({mailboxId:I?.mailboxId??"",messages:f,onAfterOptimisticRemove:v}),{toggleReadFor:W}=Et({mailboxId:I?.mailboxId??"",messages:f}),E=S.focusedMessageId,T=a.useMemo(()=>f.find(g=>g.messageId===E),[f,E])??I,P=Se({thread:T,isOpen:T?.messageId===p}),$=os(),R=ct(),j=lt(),w=a.useMemo(()=>dt(j,u,p),[j,u,p]),A=a.useMemo(()=>{if(T)return g=>j({threadId:T.threadId,messageId:T.messageId,mode:g})},[j,T]),{nextMessageId:q,previousMessageId:z}=Pt({context:S,orderedIds:S.orderedIds,selectedMessageId:p,enabled:!$&&!R,hasOpenThread:u!==void 0,onClose:r,handlers:{reply:()=>A?.("reply"),replyAll:()=>A?.("reply-all"),forward:()=>A?.("forward"),delete:()=>{S.listCommandsRef.current?.requestVerb("delete")||P.deleteThread()},toggleStar:P.toggleStar,toggleRead:()=>{S.listCommandsRef.current?.requestVerb("markRead")||T&&W([T.messageId],!T.isRead)},goFlagged:()=>l("flagged"),goSettings:()=>l("settings")}}),O=a.useCallback(g=>{if(!g)return;const N=f.find(B=>B.messageId===g);return N?{threadId:N.threadId,messageId:g}:void 0},[f]),Q={selectedMessageId:p,selectedThread:I,conversation:D,onOpenThread:h,onCloseThread:r,nextThread:O(q),previousThread:O(z),actions:F,onReply:w,triage:S,onDeleteMessages:C,handleDeselectIfRemoved:v};return o.jsx(Le.Provider,{value:Q,children:t})}function De(){const{selectedMessageId:e,onOpenThread:t,triage:n,onDeleteMessages:r}=J(),{accounts:l}=Y();return o.jsx(Ss,{accounts:l,selectedMessageId:e,onOpenThread:t,commandsRef:n.listCommandsRef,onTriageContextChange:n.onTriageContextChange,onDeleteMessages:r})}function Ts(){const{conversation:e,selectedThread:t,actions:n,onReply:r,handleDeselectIfRemoved:l}=J(),d=!!e,u=Qt(e?.threadId);return o.jsxs(o.Fragment,{children:[o.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[o.jsx(_t,{hasThread:d,intelligenceOpen:u.isShowing,canToggleIntelligence:u.canToggle,onToggleIntelligence:u.toggle,onReply:r?()=>r("reply"):void 0,onReplyAll:r?()=>r("reply-all"):void 0,onForward:r?()=>r("forward"):void 0,onDelete:d?n.deleteThread:void 0,onToggleStar:d?n.toggleStar:void 0,isStarred:n.isStarred,moveContext:d&&n.accountId&&n.mailboxId?{accountId:n.accountId,currentMailboxId:n.mailboxId,onMove:n.moveThread}:void 0}),o.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e?o.jsx(we,{threadId:e.threadId,mailboxId:e.mailboxId,subject:e.subject,selectedMessageId:e.messageId,authenticity:e.authenticity,onOpenIntelligence:u.open,listOnScreen:!0}):o.jsx(ht,{})})]}),o.jsx(Me,{isOpen:u.drawerOpen,onClose:u.closeDrawer,thread:t,mailboxId:t?.mailboxId,accountId:t?.accountId,onAfterOptimisticRemove:l})]})}function js(){const{selectedThread:e,handleDeselectIfRemoved:t}=J(),{onToggleIntelligence:n}=Y();return o.jsx(zt,{onClose:n,thread:e,mailboxId:e?.mailboxId,accountId:e?.accountId,onAfterOptimisticRemove:t})}function Rs(){const{selectedThread:e,conversation:t,onOpenThread:n,onCloseThread:r,nextThread:l,previousThread:d,handleDeselectIfRemoved:u}=J(),m=qt(t?.threadId??null);return t?o.jsxs(o.Fragment,{children:[o.jsx(we,{threadId:t.threadId,mailboxId:t.mailboxId,subject:t.subject,selectedMessageId:t.messageId,authenticity:t.authenticity,onBack:r,onOpenIntelligence:m.toggle,onSwipeNext:l?()=>n(l):void 0,onSwipePrevious:d?()=>n(d):void 0,mobileIntelligenceOpen:m.isOpen}),o.jsx(Me,{isOpen:m.isOpen,onClose:m.close,thread:e,mailboxId:e?.mailboxId,accountId:e?.accountId,onAfterOptimisticRemove:u})]}):o.jsx("div",{className:"h-full",children:o.jsx(De,{})})}const zs=Object.assign(Cs,{List:De,Reading:Ts,Intelligence:js,Phone:Rs});export{zs as B};
@@ -1 +1 @@
1
- import{a as ee,i as _}from"./window-C7e0XMZy.js";import{j as n,f as j,t as d,Y as te,Z as ne,ay as f,r as p,ax as ae,X as se,i as T,ei as re,ej as ie,ek as le,h as oe,s as ce,b1 as de,_ as ue}from"./index-DFOeerF8.js";import{f as me}from"./ErrorState-DW9hn0tP.js";import{R as z,c as he}from"./calendar-color-B1y21BSV.js";const xe=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],pe=["January","February","March","April","May","June","July","August","September","October","November","December"],fe=["first","second","third","fourth","last"],A="";function ye(e,t){if(!/^\d{4}-\d{2}-\d{2}$/.test(e))return[];const[a,s,i]=e.split("-").map(Number),r=new Date(Date.UTC(a,s-1,i)),l=xe[r.getUTCDay()],o=fe[Math.min(Math.floor((i-1)/7),4)],c=t===""?"":`, ${t}`,y=r.getUTCDay()>=1&&r.getUTCDay()<=5;return[`Every day${c}`,...y?[`Every weekday${c}`]:[],`Every week on ${l}${c}`,`Every month on the ${o} ${l}${c}`,`Every year on ${i} ${pe[s-1]}${c}`]}const ve="w-full rounded-md border border-line bg-surface-sunken px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus-visible:border-line-strong focus-visible:ring-2 focus-visible:ring-ring/30",u=({draft:e,onChange:t},a,s)=>t({...e,[a]:s});function x({label:e,children:t}){return n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:e}),t]})}function ge({draft:e,onChange:t,layout:a="compact",touch:s}){const i=a==="pane";return n.jsx(f,{value:e.title,placeholder:"Title","aria-label":"Title",onChange:r=>u({draft:e,onChange:t},"title",r.target.value),className:d(i?"text-lg font-medium":"text-md font-medium",i?"h-11":s?"min-h-11":"")})}function H(e){return e.allDay||e.startTime===""||e.endTime===""?!1:e.endTime<e.startTime}function be({draft:e,onChange:t,touch:a}){const s=a?"min-h-11":"",i=H(e),r=p.useId();return n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx(f,{type:"date",value:e.date,"aria-label":"Date",onChange:l=>u({draft:e,onChange:t},"date",l.target.value),className:d("w-40",s)}),e.allDay?n.jsx("span",{className:"text-sm text-fg-muted",children:"All day"}):n.jsxs(n.Fragment,{children:[n.jsx(f,{type:"time",value:e.startTime,"aria-label":"Start time",max:e.endTime===""?void 0:e.endTime,"aria-invalid":i,"aria-describedby":i?r:void 0,onChange:l=>u({draft:e,onChange:t},"startTime",l.target.value),className:d("w-28",s,i&&"border-danger/60")}),n.jsx("span",{className:"text-sm text-fg-subtle",children:"to"}),n.jsx(f,{type:"time",value:e.endTime,"aria-label":"End time",min:e.startTime===""?void 0:e.startTime,"aria-invalid":i,"aria-describedby":i?r:void 0,onChange:l=>u({draft:e,onChange:t},"endTime",l.target.value),className:d("w-28",s,i&&"border-danger/60")})]}),n.jsxs("label",{className:"flex items-center gap-2 text-sm text-fg-muted",children:[n.jsx("input",{type:"checkbox",checked:e.allDay,onChange:l=>u({draft:e,onChange:t},"allDay",l.target.checked),className:"size-4 accent-current"}),"All day"]})]}),i&&n.jsxs("p",{id:r,className:"text-xs text-danger",role:"alert",children:["Ends before it starts. Move the end past ",e.startTime,", or start earlier."]})]})}function Ee({draft:e,onChange:t,calendars:a,touch:s}){return n.jsx(Ae,{calendars:a,value:e.calendarId,onChange:i=>u({draft:e,onChange:t},"calendarId",i),touch:s})}function Ne({draft:e,onChange:t,touch:a,repeatEditable:s=!0,onCustom:i}){return s?n.jsx(ke,{value:e.repeat,date:e.date,startTime:e.startTime,onChange:r=>u({draft:e,onChange:t},"repeat",r),onCustom:i,className:a?"min-h-11":""}):n.jsxs("p",{className:"flex items-center gap-2 text-sm text-fg-muted",children:[n.jsx(z,{className:"size-4 shrink-0 text-fg-subtle","aria-hidden":!0}),e.repeat===A?"Does not repeat":e.repeat]})}function je({draft:e,onChange:t,touch:a}){return n.jsx(f,{value:e.location,placeholder:"Location","aria-label":"Location",onChange:s=>u({draft:e,onChange:t},"location",s.target.value),className:a?"min-h-11":""})}function Te({draft:e,onChange:t,touch:a}){return n.jsx(f,{value:e.guests,placeholder:"Guests, comma separated","aria-label":"Guests",onChange:s=>u({draft:e,onChange:t},"guests",s.target.value),className:a?"min-h-11":""})}function Ce({draft:e,onChange:t,layout:a="compact"}){return n.jsx("textarea",{value:e.notes,placeholder:"Notes","aria-label":"Notes",onChange:s=>u({draft:e,onChange:t},"notes",s.target.value),rows:a==="pane"?6:3,className:ve})}function De({draft:e,onChange:t,calendars:a,layout:s="compact",expanded:i=!1,onToggleExpanded:r,onSave:l,onCancel:o,onDelete:c,saveLabel:y="Add",header:g,repeatEditable:b=!0,guestsEditable:I=!1,calendarEditable:M=!0,onCustomRepeat:X,touch:m,className:w}){const v=s==="pane",h={draft:e,onChange:t,layout:s,touch:m},S=n.jsx(ge,{...h}),$=n.jsx(be,{...h}),R=n.jsx(Ee,{...h,calendars:a}),F=n.jsx(Ne,{...h,repeatEditable:b,onCustom:X}),Y=n.jsx(je,{...h}),L=n.jsx(Te,{...h}),P=n.jsx(Ce,{...h}),W=n.jsxs("div",{className:d("flex items-center gap-2",v?"pt-2":"pt-1"),children:[n.jsx(j,{variant:"primary",size:m||v?"md":"sm",onClick:l,disabled:H(e),className:m?"min-h-11 flex-1":"",children:y}),n.jsx(j,{variant:"ghost",size:m||v?"md":"sm",onClick:o,className:m?"min-h-11":"",children:"Cancel"}),c&&n.jsx(j,{variant:"ghost",size:m||v?"md":"sm",onClick:c,className:d("ml-auto text-danger",m&&"min-h-11"),children:"Delete"})]});if(v)return n.jsxs("div",{className:d("flex flex-col gap-5",w),children:[g,n.jsx(x,{label:"Title",children:S}),n.jsx(x,{label:"When",children:$}),M&&n.jsx(x,{label:"Calendar",children:R}),n.jsx(x,{label:"Repeat",children:F}),n.jsx(x,{label:"Location",children:Y}),I&&n.jsx(x,{label:"Guests",children:L}),n.jsx(x,{label:"Notes",children:P}),W]});const Z=r!==void 0&&!i;return n.jsxs("div",{className:d("flex flex-col gap-3",w),children:[g,S,$,M&&R,r&&n.jsxs("button",{type:"button",onClick:r,"aria-expanded":i,className:d("flex items-center gap-1 self-start rounded-sm text-xs font-medium text-fg-muted outline-none hover:text-fg focus-visible:ring-2 focus-visible:ring-ring",m&&"min-h-11"),children:[i?n.jsx(te,{className:"size-3.5"}):n.jsx(ne,{className:"size-3.5"}),i?"Fewer details":"More details"]}),!Z&&n.jsxs("div",{className:"flex flex-col gap-2 border-t border-line pt-3",children:[Y,I&&L,F,P]}),W]})}const U="__custom__";function ke({value:e,date:t,startTime:a,onChange:s,onCustom:i,className:r}){const l=ye(t,a),o=e===A||l.includes(e)?l:[e,...l];return n.jsxs(ae,{icon:n.jsx(z,{className:"size-4"}),"aria-label":"Repeat",value:e,onChange:c=>{if(c.target.value===U){i?.();return}s(c.target.value)},className:r,children:[n.jsx("option",{value:A,children:"Does not repeat"}),o.map(c=>n.jsx("option",{value:c,children:c},c)),i&&n.jsx("option",{value:U,children:"Custom…"})]})}function Ae({calendars:e,value:t,onChange:a,touch:s}){const i=p.useId();return n.jsxs("fieldset",{className:"flex flex-wrap gap-1.5",children:[n.jsx("legend",{className:"sr-only",children:"Calendar"}),e.map(r=>{const l=he(r.color),o=r.id===t;return n.jsxs("label",{className:d("inline-flex cursor-pointer items-center gap-1.5 rounded-full border px-2.5 text-xs transition-colors","has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-ring",s?"min-h-11":"h-7",o?d(l.soft,l.text,l.border):"border-line text-fg-muted hover:bg-surface-sunken"),children:[n.jsx("input",{type:"radio",name:i,value:r.id,checked:o,onChange:()=>a(r.id),className:"sr-only"}),n.jsx("span",{className:d("size-2 rounded-full",l.solid)}),r.name]},r.id)})]})}function Oe({title:e,subtitle:t,onClose:a,children:s,className:i}){return n.jsxs("section",{className:d("flex h-full w-full flex-col bg-surface",i),children:[n.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[n.jsx("h2",{className:"shrink-0 text-xs font-medium text-fg",children:e}),t!==void 0&&t!==""&&n.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-fg-muted",children:t}),n.jsx("button",{type:"button","aria-label":"Close editor",onClick:a,className:"ml-auto flex size-7 shrink-0 items-center justify-center rounded-md text-fg-subtle outline-none hover:bg-surface-sunken hover:text-fg focus-visible:ring-2 focus-visible:ring-ring",children:n.jsx(se,{className:"size-4"})})]}),n.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-row-inset py-5",children:n.jsx("div",{className:"mx-auto w-full max-w-2xl",children:s})})]})}const E=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],N=["SU","MO","TU","WE","TH","FR","SA"],Q=["January","February","March","April","May","June","July","August","September","October","November","December"],K=["first","second","third","fourth","last"],G=[1,2,3,4,-1],J="MO,TU,WE,TH,FR",Ie=e=>e.replace(/,\s*\d{2}:\d{2}$/,"").trim();function O(e){const t=Ie(e);if(t==="")return"";if(t==="Every day")return"FREQ=DAILY";if(t==="Every weekday")return`FREQ=WEEKLY;BYDAY=${J}`;const a=t.match(/^Every week on (\w+)$/);if(a){const r=E.indexOf(a[1]);return r===-1?void 0:`FREQ=WEEKLY;BYDAY=${N[r]}`}const s=t.match(/^Every month on the (\w+) (\w+)$/);if(s){const r=K.indexOf(s[1]),l=E.indexOf(s[2]);return r===-1||l===-1?void 0:`FREQ=MONTHLY;BYDAY=${G[r]}${N[l]}`}const i=t.match(/^Every year on (\d{1,2}) (\w+)$/);if(i){const r=Q.indexOf(i[2]);return r===-1?void 0:`FREQ=YEARLY;BYMONTH=${r+1};BYMONTHDAY=${Number(i[1])}`}}const Me=e=>e===""?"":`, ${e}`;function Pe(e,t){const a=new Map(e.split(";").map(l=>l.split("=")).filter(l=>l.length===2).map(([l,o])=>[l.toUpperCase(),o.toUpperCase()])),s=Me(t),i=a.get("FREQ"),r=a.get("BYDAY");if(!(a.has("INTERVAL")&&a.get("INTERVAL")!=="1")&&!(a.has("UNTIL")||a.has("COUNT"))){if(i==="DAILY")return`Every day${s}`;if(i==="WEEKLY"){if(r===void 0)return;if(r===J)return`Every weekday${s}`;const l=N.indexOf(r);return l===-1?void 0:`Every week on ${E[l]}${s}`}if(i==="MONTHLY"){const l=r?.match(/^(-?\d)([A-Z]{2})$/);if(!l)return;const o=G.indexOf(Number(l[1])),c=N.indexOf(l[2]);return o===-1||c===-1?void 0:`Every month on the ${K[o]} ${E[c]}${s}`}if(i==="YEARLY"){const l=Number(a.get("BYMONTH")),o=Number(a.get("BYMONTHDAY"));return!l||!o||l>12?void 0:`Every year on ${o} ${Q[l-1]}${s}`}}}function We(e,t){return{title:"",date:e,startTime:"09:00",endTime:"10:00",allDay:!1,calendarId:t,location:"",guests:"",notes:"",repeat:""}}function _e(e,t){return{title:e.title,date:e.start.slice(0,10),startTime:e.allDay?"":e.start.slice(11,16),endTime:e.allDay?"":e.end.slice(11,16),allDay:e.allDay,calendarId:e.calendarId,location:t.location,guests:"",notes:t.notes,repeat:t.repeat}}function q(e,t){return e.allDay?{start:e.date,end:ee(e.date,1)}:{start:_(e.date,e.startTime,t),end:_(e.date,e.endTime,t)}}function V(e,t){return e.title.trim()===""?"Give the event a title before saving it.":e.date===""?"Pick the day the event is on.":e.calendarId===""?"Pick the calendar to save the event in.":!e.allDay&&(e.startTime===""||e.endTime==="")?"Set a start and an end time, or mark the event all day.":!e.allDay&&e.endTime<=e.startTime?"The end time is not after the start time. Move one of them.":t&&O(e.repeat)===void 0?"This calendar can't store that repeat rule. Pick one of the offered rules, or turn the repeat off.":""}function Ue(e,t){const a=V(e,!0);if(a!=="")return{ok:!1,problem:a};const{start:s,end:i}=q(e,t);return{ok:!0,input:{calendarId:e.calendarId,summary:e.title.trim(),description:e.notes,location:e.location,start:s,end:i,allDay:e.allDay,...t===""?{}:{timeZone:t},recurrenceRule:O(e.repeat)??""}}}function Be(e,t,a){const s=t.repeat!==e.repeat,i=V(t,s);if(i!=="")return{ok:!1,problem:i};const r={};if(t.title.trim()!==e.title.trim()&&(r.summary=t.title.trim()),t.location!==e.location&&(r.location=t.location),t.notes!==e.notes&&(r.description=t.notes),t.date!==e.date||t.startTime!==e.startTime||t.endTime!==e.endTime||t.allDay!==e.allDay){const{start:o,end:c}=q(t,a);r.start=o,r.end=c,r.allDay=t.allDay,a!==""&&(r.timeZone=a)}return s&&(r.recurrenceRule=O(t.repeat)??""),{ok:!0,patch:r}}const C=ce(400,404,412),we=new Set(["calendarEventOperationsListCalendarEvents","calendarEventDetailOperationsGetCalendarEvent","calendarFreeBusyOperationsListCalendarFreeBusy"]),D={kind:"written"},k=e=>de(e)===412?{kind:"conflict"}:{kind:"refused",message:me(e)},Se={this:"This",following:"Following",all:"All"};function $e(){const e=oe();return p.useCallback(()=>{e.invalidateQueries({predicate:t=>{const a=t.queryKey[0];if(typeof a!="object"||a===null)return!1;const s=a._id;return typeof s=="string"&&we.has(s)}})},[e])}const B=({scope:e,recurrenceId:t})=>e===void 0||e==="all"?{}:{scope:Se[e],recurrenceId:t};function ze(){const e=$e(),t=T({...re(),meta:C,onSuccess:e}),a=T({...ie(),meta:C,onSuccess:e}),s=T({...le(),meta:C,onSuccess:e}),i=p.useCallback(o=>t.mutateAsync({body:o}).then(()=>D).catch(k),[t]),r=p.useCallback((o,c)=>a.mutateAsync({path:{calendarObjectId:o.calendarObjectId},query:{calendarId:o.calendarId,...B(o)},headers:{"If-Match":o.etag},body:c}).then(()=>D).catch(k),[a]),l=p.useCallback(o=>s.mutateAsync({path:{calendarObjectId:o.calendarObjectId},query:{calendarId:o.calendarId,...B(o)},headers:{"If-Match":o.etag}}).then(()=>D).catch(k),[s]);return p.useMemo(()=>({createEvent:i,updateEvent:r,deleteEvent:l,isWriting:t.isPending||a.isPending||s.isPending}),[i,r,l,t.isPending,a.isPending,s.isPending])}function He({title:e,subtitle:t,calendars:a,draft:s,onChange:i,problem:r,saveLabel:l,isSaving:o,repeatEditable:c=!0,calendarEditable:y=!0,onSave:g,onCancel:b}){return n.jsx(Oe,{title:e,subtitle:t,onClose:b,children:n.jsx(De,{draft:s,onChange:i,calendars:a,layout:"pane",repeatEditable:c,calendarEditable:y,saveLabel:o?"Saving…":l,onSave:g,onCancel:b,header:r===""?void 0:n.jsxs("div",{role:"alert",className:"flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-sm",children:[n.jsx(ue,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":"true"}),n.jsx("p",{className:"min-w-0 flex-1 break-words text-fg",children:r})]})})})}export{He as C,Ue as c,_e as d,We as e,Be as p,Pe as t,ze as u};
1
+ import{a as ee,i as _}from"./window-BqaZu6ux.js";import{j as n,f as j,t as d,Y as te,Z as ne,ay as f,r as p,ax as ae,X as se,i as T,ei as re,ej as ie,ek as le,h as oe,s as ce,b1 as de,_ as ue}from"./index-D855R0Fw.js";import{f as me}from"./ErrorState--2p5I6wj.js";import{R as z,c as he}from"./calendar-color-BjjneYsQ.js";const xe=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],pe=["January","February","March","April","May","June","July","August","September","October","November","December"],fe=["first","second","third","fourth","last"],A="";function ye(e,t){if(!/^\d{4}-\d{2}-\d{2}$/.test(e))return[];const[a,s,i]=e.split("-").map(Number),r=new Date(Date.UTC(a,s-1,i)),l=xe[r.getUTCDay()],o=fe[Math.min(Math.floor((i-1)/7),4)],c=t===""?"":`, ${t}`,y=r.getUTCDay()>=1&&r.getUTCDay()<=5;return[`Every day${c}`,...y?[`Every weekday${c}`]:[],`Every week on ${l}${c}`,`Every month on the ${o} ${l}${c}`,`Every year on ${i} ${pe[s-1]}${c}`]}const ve="w-full rounded-md border border-line bg-surface-sunken px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus-visible:border-line-strong focus-visible:ring-2 focus-visible:ring-ring/30",u=({draft:e,onChange:t},a,s)=>t({...e,[a]:s});function x({label:e,children:t}){return n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:e}),t]})}function ge({draft:e,onChange:t,layout:a="compact",touch:s}){const i=a==="pane";return n.jsx(f,{value:e.title,placeholder:"Title","aria-label":"Title",onChange:r=>u({draft:e,onChange:t},"title",r.target.value),className:d(i?"text-lg font-medium":"text-md font-medium",i?"h-11":s?"min-h-11":"")})}function H(e){return e.allDay||e.startTime===""||e.endTime===""?!1:e.endTime<e.startTime}function be({draft:e,onChange:t,touch:a}){const s=a?"min-h-11":"",i=H(e),r=p.useId();return n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx(f,{type:"date",value:e.date,"aria-label":"Date",onChange:l=>u({draft:e,onChange:t},"date",l.target.value),className:d("w-40",s)}),e.allDay?n.jsx("span",{className:"text-sm text-fg-muted",children:"All day"}):n.jsxs(n.Fragment,{children:[n.jsx(f,{type:"time",value:e.startTime,"aria-label":"Start time",max:e.endTime===""?void 0:e.endTime,"aria-invalid":i,"aria-describedby":i?r:void 0,onChange:l=>u({draft:e,onChange:t},"startTime",l.target.value),className:d("w-28",s,i&&"border-danger/60")}),n.jsx("span",{className:"text-sm text-fg-subtle",children:"to"}),n.jsx(f,{type:"time",value:e.endTime,"aria-label":"End time",min:e.startTime===""?void 0:e.startTime,"aria-invalid":i,"aria-describedby":i?r:void 0,onChange:l=>u({draft:e,onChange:t},"endTime",l.target.value),className:d("w-28",s,i&&"border-danger/60")})]}),n.jsxs("label",{className:"flex items-center gap-2 text-sm text-fg-muted",children:[n.jsx("input",{type:"checkbox",checked:e.allDay,onChange:l=>u({draft:e,onChange:t},"allDay",l.target.checked),className:"size-4 accent-current"}),"All day"]})]}),i&&n.jsxs("p",{id:r,className:"text-xs text-danger",role:"alert",children:["Ends before it starts. Move the end past ",e.startTime,", or start earlier."]})]})}function Ee({draft:e,onChange:t,calendars:a,touch:s}){return n.jsx(Ae,{calendars:a,value:e.calendarId,onChange:i=>u({draft:e,onChange:t},"calendarId",i),touch:s})}function Ne({draft:e,onChange:t,touch:a,repeatEditable:s=!0,onCustom:i}){return s?n.jsx(ke,{value:e.repeat,date:e.date,startTime:e.startTime,onChange:r=>u({draft:e,onChange:t},"repeat",r),onCustom:i,className:a?"min-h-11":""}):n.jsxs("p",{className:"flex items-center gap-2 text-sm text-fg-muted",children:[n.jsx(z,{className:"size-4 shrink-0 text-fg-subtle","aria-hidden":!0}),e.repeat===A?"Does not repeat":e.repeat]})}function je({draft:e,onChange:t,touch:a}){return n.jsx(f,{value:e.location,placeholder:"Location","aria-label":"Location",onChange:s=>u({draft:e,onChange:t},"location",s.target.value),className:a?"min-h-11":""})}function Te({draft:e,onChange:t,touch:a}){return n.jsx(f,{value:e.guests,placeholder:"Guests, comma separated","aria-label":"Guests",onChange:s=>u({draft:e,onChange:t},"guests",s.target.value),className:a?"min-h-11":""})}function Ce({draft:e,onChange:t,layout:a="compact"}){return n.jsx("textarea",{value:e.notes,placeholder:"Notes","aria-label":"Notes",onChange:s=>u({draft:e,onChange:t},"notes",s.target.value),rows:a==="pane"?6:3,className:ve})}function De({draft:e,onChange:t,calendars:a,layout:s="compact",expanded:i=!1,onToggleExpanded:r,onSave:l,onCancel:o,onDelete:c,saveLabel:y="Add",header:g,repeatEditable:b=!0,guestsEditable:I=!1,calendarEditable:M=!0,onCustomRepeat:X,touch:m,className:w}){const v=s==="pane",h={draft:e,onChange:t,layout:s,touch:m},S=n.jsx(ge,{...h}),$=n.jsx(be,{...h}),R=n.jsx(Ee,{...h,calendars:a}),F=n.jsx(Ne,{...h,repeatEditable:b,onCustom:X}),Y=n.jsx(je,{...h}),L=n.jsx(Te,{...h}),P=n.jsx(Ce,{...h}),W=n.jsxs("div",{className:d("flex items-center gap-2",v?"pt-2":"pt-1"),children:[n.jsx(j,{variant:"primary",size:m||v?"md":"sm",onClick:l,disabled:H(e),className:m?"min-h-11 flex-1":"",children:y}),n.jsx(j,{variant:"ghost",size:m||v?"md":"sm",onClick:o,className:m?"min-h-11":"",children:"Cancel"}),c&&n.jsx(j,{variant:"ghost",size:m||v?"md":"sm",onClick:c,className:d("ml-auto text-danger",m&&"min-h-11"),children:"Delete"})]});if(v)return n.jsxs("div",{className:d("flex flex-col gap-5",w),children:[g,n.jsx(x,{label:"Title",children:S}),n.jsx(x,{label:"When",children:$}),M&&n.jsx(x,{label:"Calendar",children:R}),n.jsx(x,{label:"Repeat",children:F}),n.jsx(x,{label:"Location",children:Y}),I&&n.jsx(x,{label:"Guests",children:L}),n.jsx(x,{label:"Notes",children:P}),W]});const Z=r!==void 0&&!i;return n.jsxs("div",{className:d("flex flex-col gap-3",w),children:[g,S,$,M&&R,r&&n.jsxs("button",{type:"button",onClick:r,"aria-expanded":i,className:d("flex items-center gap-1 self-start rounded-sm text-xs font-medium text-fg-muted outline-none hover:text-fg focus-visible:ring-2 focus-visible:ring-ring",m&&"min-h-11"),children:[i?n.jsx(te,{className:"size-3.5"}):n.jsx(ne,{className:"size-3.5"}),i?"Fewer details":"More details"]}),!Z&&n.jsxs("div",{className:"flex flex-col gap-2 border-t border-line pt-3",children:[Y,I&&L,F,P]}),W]})}const U="__custom__";function ke({value:e,date:t,startTime:a,onChange:s,onCustom:i,className:r}){const l=ye(t,a),o=e===A||l.includes(e)?l:[e,...l];return n.jsxs(ae,{icon:n.jsx(z,{className:"size-4"}),"aria-label":"Repeat",value:e,onChange:c=>{if(c.target.value===U){i?.();return}s(c.target.value)},className:r,children:[n.jsx("option",{value:A,children:"Does not repeat"}),o.map(c=>n.jsx("option",{value:c,children:c},c)),i&&n.jsx("option",{value:U,children:"Custom…"})]})}function Ae({calendars:e,value:t,onChange:a,touch:s}){const i=p.useId();return n.jsxs("fieldset",{className:"flex flex-wrap gap-1.5",children:[n.jsx("legend",{className:"sr-only",children:"Calendar"}),e.map(r=>{const l=he(r.color),o=r.id===t;return n.jsxs("label",{className:d("inline-flex cursor-pointer items-center gap-1.5 rounded-full border px-2.5 text-xs transition-colors","has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-ring",s?"min-h-11":"h-7",o?d(l.soft,l.text,l.border):"border-line text-fg-muted hover:bg-surface-sunken"),children:[n.jsx("input",{type:"radio",name:i,value:r.id,checked:o,onChange:()=>a(r.id),className:"sr-only"}),n.jsx("span",{className:d("size-2 rounded-full",l.solid)}),r.name]},r.id)})]})}function Oe({title:e,subtitle:t,onClose:a,children:s,className:i}){return n.jsxs("section",{className:d("flex h-full w-full flex-col bg-surface",i),children:[n.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[n.jsx("h2",{className:"shrink-0 text-xs font-medium text-fg",children:e}),t!==void 0&&t!==""&&n.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-fg-muted",children:t}),n.jsx("button",{type:"button","aria-label":"Close editor",onClick:a,className:"ml-auto flex size-7 shrink-0 items-center justify-center rounded-md text-fg-subtle outline-none hover:bg-surface-sunken hover:text-fg focus-visible:ring-2 focus-visible:ring-ring",children:n.jsx(se,{className:"size-4"})})]}),n.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-row-inset py-5",children:n.jsx("div",{className:"mx-auto w-full max-w-2xl",children:s})})]})}const E=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],N=["SU","MO","TU","WE","TH","FR","SA"],Q=["January","February","March","April","May","June","July","August","September","October","November","December"],K=["first","second","third","fourth","last"],G=[1,2,3,4,-1],J="MO,TU,WE,TH,FR",Ie=e=>e.replace(/,\s*\d{2}:\d{2}$/,"").trim();function O(e){const t=Ie(e);if(t==="")return"";if(t==="Every day")return"FREQ=DAILY";if(t==="Every weekday")return`FREQ=WEEKLY;BYDAY=${J}`;const a=t.match(/^Every week on (\w+)$/);if(a){const r=E.indexOf(a[1]);return r===-1?void 0:`FREQ=WEEKLY;BYDAY=${N[r]}`}const s=t.match(/^Every month on the (\w+) (\w+)$/);if(s){const r=K.indexOf(s[1]),l=E.indexOf(s[2]);return r===-1||l===-1?void 0:`FREQ=MONTHLY;BYDAY=${G[r]}${N[l]}`}const i=t.match(/^Every year on (\d{1,2}) (\w+)$/);if(i){const r=Q.indexOf(i[2]);return r===-1?void 0:`FREQ=YEARLY;BYMONTH=${r+1};BYMONTHDAY=${Number(i[1])}`}}const Me=e=>e===""?"":`, ${e}`;function Pe(e,t){const a=new Map(e.split(";").map(l=>l.split("=")).filter(l=>l.length===2).map(([l,o])=>[l.toUpperCase(),o.toUpperCase()])),s=Me(t),i=a.get("FREQ"),r=a.get("BYDAY");if(!(a.has("INTERVAL")&&a.get("INTERVAL")!=="1")&&!(a.has("UNTIL")||a.has("COUNT"))){if(i==="DAILY")return`Every day${s}`;if(i==="WEEKLY"){if(r===void 0)return;if(r===J)return`Every weekday${s}`;const l=N.indexOf(r);return l===-1?void 0:`Every week on ${E[l]}${s}`}if(i==="MONTHLY"){const l=r?.match(/^(-?\d)([A-Z]{2})$/);if(!l)return;const o=G.indexOf(Number(l[1])),c=N.indexOf(l[2]);return o===-1||c===-1?void 0:`Every month on the ${K[o]} ${E[c]}${s}`}if(i==="YEARLY"){const l=Number(a.get("BYMONTH")),o=Number(a.get("BYMONTHDAY"));return!l||!o||l>12?void 0:`Every year on ${o} ${Q[l-1]}${s}`}}}function We(e,t){return{title:"",date:e,startTime:"09:00",endTime:"10:00",allDay:!1,calendarId:t,location:"",guests:"",notes:"",repeat:""}}function _e(e,t){return{title:e.title,date:e.start.slice(0,10),startTime:e.allDay?"":e.start.slice(11,16),endTime:e.allDay?"":e.end.slice(11,16),allDay:e.allDay,calendarId:e.calendarId,location:t.location,guests:"",notes:t.notes,repeat:t.repeat}}function q(e,t){return e.allDay?{start:e.date,end:ee(e.date,1)}:{start:_(e.date,e.startTime,t),end:_(e.date,e.endTime,t)}}function V(e,t){return e.title.trim()===""?"Give the event a title before saving it.":e.date===""?"Pick the day the event is on.":e.calendarId===""?"Pick the calendar to save the event in.":!e.allDay&&(e.startTime===""||e.endTime==="")?"Set a start and an end time, or mark the event all day.":!e.allDay&&e.endTime<=e.startTime?"The end time is not after the start time. Move one of them.":t&&O(e.repeat)===void 0?"This calendar can't store that repeat rule. Pick one of the offered rules, or turn the repeat off.":""}function Ue(e,t){const a=V(e,!0);if(a!=="")return{ok:!1,problem:a};const{start:s,end:i}=q(e,t);return{ok:!0,input:{calendarId:e.calendarId,summary:e.title.trim(),description:e.notes,location:e.location,start:s,end:i,allDay:e.allDay,...t===""?{}:{timeZone:t},recurrenceRule:O(e.repeat)??""}}}function Be(e,t,a){const s=t.repeat!==e.repeat,i=V(t,s);if(i!=="")return{ok:!1,problem:i};const r={};if(t.title.trim()!==e.title.trim()&&(r.summary=t.title.trim()),t.location!==e.location&&(r.location=t.location),t.notes!==e.notes&&(r.description=t.notes),t.date!==e.date||t.startTime!==e.startTime||t.endTime!==e.endTime||t.allDay!==e.allDay){const{start:o,end:c}=q(t,a);r.start=o,r.end=c,r.allDay=t.allDay,a!==""&&(r.timeZone=a)}return s&&(r.recurrenceRule=O(t.repeat)??""),{ok:!0,patch:r}}const C=ce(400,404,412),we=new Set(["calendarEventOperationsListCalendarEvents","calendarEventDetailOperationsGetCalendarEvent","calendarFreeBusyOperationsListCalendarFreeBusy"]),D={kind:"written"},k=e=>de(e)===412?{kind:"conflict"}:{kind:"refused",message:me(e)},Se={this:"This",following:"Following",all:"All"};function $e(){const e=oe();return p.useCallback(()=>{e.invalidateQueries({predicate:t=>{const a=t.queryKey[0];if(typeof a!="object"||a===null)return!1;const s=a._id;return typeof s=="string"&&we.has(s)}})},[e])}const B=({scope:e,recurrenceId:t})=>e===void 0||e==="all"?{}:{scope:Se[e],recurrenceId:t};function ze(){const e=$e(),t=T({...re(),meta:C,onSuccess:e}),a=T({...ie(),meta:C,onSuccess:e}),s=T({...le(),meta:C,onSuccess:e}),i=p.useCallback(o=>t.mutateAsync({body:o}).then(()=>D).catch(k),[t]),r=p.useCallback((o,c)=>a.mutateAsync({path:{calendarObjectId:o.calendarObjectId},query:{calendarId:o.calendarId,...B(o)},headers:{"If-Match":o.etag},body:c}).then(()=>D).catch(k),[a]),l=p.useCallback(o=>s.mutateAsync({path:{calendarObjectId:o.calendarObjectId},query:{calendarId:o.calendarId,...B(o)},headers:{"If-Match":o.etag}}).then(()=>D).catch(k),[s]);return p.useMemo(()=>({createEvent:i,updateEvent:r,deleteEvent:l,isWriting:t.isPending||a.isPending||s.isPending}),[i,r,l,t.isPending,a.isPending,s.isPending])}function He({title:e,subtitle:t,calendars:a,draft:s,onChange:i,problem:r,saveLabel:l,isSaving:o,repeatEditable:c=!0,calendarEditable:y=!0,onSave:g,onCancel:b}){return n.jsx(Oe,{title:e,subtitle:t,onClose:b,children:n.jsx(De,{draft:s,onChange:i,calendars:a,layout:"pane",repeatEditable:c,calendarEditable:y,saveLabel:o?"Saving…":l,onSave:g,onCancel:b,header:r===""?void 0:n.jsxs("div",{role:"alert",className:"flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-sm",children:[n.jsx(ue,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":"true"}),n.jsx("p",{className:"min-w-0 flex-1 break-words text-fg",children:r})]})})})}export{He as C,Ue as c,_e as d,We as e,Be as p,Pe as t,ze as u};
@@ -1 +1 @@
1
- import{j as t,r as e}from"./index-DFOeerF8.js";const o=e.createContext(void 0),C=({pick:s,children:r})=>t.jsx(o.Provider,{value:s,children:r}),d=()=>e.useContext(o);export{C,d as u};
1
+ import{j as t,r as e}from"./index-D855R0Fw.js";const o=e.createContext(void 0),C=({pick:s,children:r})=>t.jsx(o.Provider,{value:s,children:r}),d=()=>e.useContext(o);export{C,d as u};
@@ -1 +1 @@
1
- import{r,j as n,ak as l,al as o}from"./index-DFOeerF8.js";const i=r.createContext(null),v=({chrome:s,children:a})=>n.jsx(i.Provider,{value:s,children:a});function C({workspace:s,reading:a,hasOpenEvent:x}){const e=r.useContext(i);if(!e)return n.jsx(l,{});const t={nav:e.nav,skeleton:n.jsx(l,{}),isLoading:e.isLoading,navOpen:e.navOpen,onOpenNav:e.onOpenNav,onCloseNav:e.onCloseNav,listBias:"list"};return e.isSinglePane?n.jsx(o,{...t,list:x?a:s}):n.jsx(o,{...t,list:s,reading:a})}export{v as C,C as a};
1
+ import{r,j as n,ak as l,al as o}from"./index-D855R0Fw.js";const i=r.createContext(null),v=({chrome:s,children:a})=>n.jsx(i.Provider,{value:s,children:a});function C({workspace:s,reading:a,hasOpenEvent:x}){const e=r.useContext(i);if(!e)return n.jsx(l,{});const t={nav:e.nav,skeleton:n.jsx(l,{}),isLoading:e.isLoading,navOpen:e.navOpen,onOpenNav:e.onOpenNav,onCloseNav:e.onCloseNav,listBias:"list"};return e.isSinglePane?n.jsx(o,{...t,list:x?a:s}):n.jsx(o,{...t,list:s,reading:a})}export{v as C,C as a};
@@ -1 +1 @@
1
- import{j as e}from"./index-DFOeerF8.js";const x=({message:s,icon:t})=>e.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:[t&&e.jsx("div",{className:"mb-4 text-fg-muted",children:t}),e.jsx("p",{className:"text-fg-muted",children:s})]});export{x as E};
1
+ import{j as e}from"./index-D855R0Fw.js";const x=({message:s,icon:t})=>e.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:[t&&e.jsx("div",{className:"mb-4 text-fg-muted",children:t}),e.jsx("p",{className:"text-fg-muted",children:s})]});export{x as E};
@@ -1 +1 @@
1
- import{j as t,_ as r}from"./index-DFOeerF8.js";const d=e=>e instanceof Error?e.message:typeof e=="string"?e:typeof e=="object"&&e!==null&&"message"in e&&typeof e.message=="string"?e.message:"An unexpected error occurred",l=({title:e="Couldn't load content",error:a,onRetry:s,variant:i="block"})=>{const n=d(a);return i==="inline"?t.jsxs("div",{role:"alert",className:"flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-sm",children:[t.jsx(r,{className:"size-4 shrink-0 text-danger mt-0.5","aria-hidden":"true"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"font-medium text-danger",children:e}),t.jsx("p",{className:"text-fg-muted mt-0.5 break-words",children:n})]}),s&&t.jsx("button",{type:"button",onClick:s,className:"shrink-0 text-sm font-medium text-accent hover:underline",children:"Retry"})]}):t.jsxs("div",{role:"alert",className:"flex flex-col items-center justify-center gap-3 p-8 text-center",children:[t.jsx(r,{className:"size-8 text-danger","aria-hidden":"true"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium text-danger",children:e}),t.jsx("p",{className:"text-sm text-fg-muted mt-1 break-words",children:n})]}),s&&t.jsx("button",{type:"button",onClick:s,className:"inline-flex items-center rounded-md border border-line bg-canvas px-4 py-2 text-sm font-medium hover:bg-surface-raised transition-colors",children:"Retry"})]})};export{l as E,d as f};
1
+ import{j as t,_ as r}from"./index-D855R0Fw.js";const d=e=>e instanceof Error?e.message:typeof e=="string"?e:typeof e=="object"&&e!==null&&"message"in e&&typeof e.message=="string"?e.message:"An unexpected error occurred",l=({title:e="Couldn't load content",error:a,onRetry:s,variant:i="block"})=>{const n=d(a);return i==="inline"?t.jsxs("div",{role:"alert",className:"flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-sm",children:[t.jsx(r,{className:"size-4 shrink-0 text-danger mt-0.5","aria-hidden":"true"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"font-medium text-danger",children:e}),t.jsx("p",{className:"text-fg-muted mt-0.5 break-words",children:n})]}),s&&t.jsx("button",{type:"button",onClick:s,className:"shrink-0 text-sm font-medium text-accent hover:underline",children:"Retry"})]}):t.jsxs("div",{role:"alert",className:"flex flex-col items-center justify-center gap-3 p-8 text-center",children:[t.jsx(r,{className:"size-8 text-danger","aria-hidden":"true"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium text-danger",children:e}),t.jsx("p",{className:"text-sm text-fg-muted mt-1 break-words",children:n})]}),s&&t.jsx("button",{type:"button",onClick:s,className:"inline-flex items-center rounded-md border border-line bg-canvas px-4 py-2 text-sm font-medium hover:bg-surface-raised transition-colors",children:"Retry"})]})};export{l as E,d as f};
@@ -0,0 +1 @@
1
+ import{ec as z,r as o,ci as G,c as $,C as V,bi as ie,cM as le,aX as ce,aY as ue,j as r,aj as ge,cS as he,cT as me}from"./index-D855R0Fw.js";import{u as fe,p as pe,R as Ie}from"./useSearchTokenContext-D1NKXhM6.js";import{ad as Z,aj as xe,ak as Te,ae as ye,au as be,al as ve,b as Se,M as Ce,as as Re,av as we,at as je,q as Me,H as Fe,L as Y,K as Oe,I as Pe,d as ke,W as Le,X as Ae,Z as J,_ as ee,$ as qe,a0 as Ee,a1 as Ne}from"./MailListHeader-kD_OYiqE.js";import{u as De,i as Be,t as He,c as Ke,d as Qe,a as _e}from"./MailViewChrome-B6yFR2VU.js";import{f as ze}from"./ErrorState--2p5I6wj.js";import{w as Ge}from"./wizard-selection-B1bng5Jq.js";import{a as Ve}from"./useMessageBodyContent-I6J6WaYN.js";import{g as We,h as Xe}from"./search-token-index-CXxBVdX5.js";import{u as Ue}from"./sections-BKWo2Deh.js";const A=e=>({...e,starred:!0,order:"desc"}),Ze=(e={})=>G({query:A(e)});function te(e={}){const{data:t,isLoading:s,isError:a,error:i,refetch:l,fetchNextPage:n,hasNextPage:h,isFetchingNextPage:m}=De({queryKey:Ze(e),queryFn:async({pageParam:I})=>{const{data:u}=await z({query:{...A(e),continuationToken:I},throwOnError:!0});return u},initialPageParam:void 0,getNextPageParam:I=>I.continuationToken,staleTime:6e4});return{threads:o.useMemo(()=>(t?.pages??[]).flatMap(I=>I.items??[]),[t]),isLoading:s,isError:a,error:i,refetch:l,fetchNextPage:n,hasNextPage:h,isFetchingNextPage:m}}function Ye(e,t){const s=e.query??"",a={...A(e),limit:t},{data:i}=$({queryKey:G({query:a}),queryFn:async()=>{const{data:l}=await z({query:a,throwOnError:!0});return l},enabled:s.length>0,staleTime:3e4});return o.useMemo(()=>i?.items??[],[i])}function $e(e={}){const t={...A(e),unread:!0,count:!0,results:!1},{data:s}=$({queryKey:G({query:t}),queryFn:async()=>{const{data:a}=await z({query:t,throwOnError:!0});return a},staleTime:6e4});return s?.count}const Je=["category","unread","starred","attachments"],et=(e,t)=>{const s=Be(e),{params:a,residual:i}=He(t,{...s,starred:!0},Je);return{criteria:{...a,...s},residual:i}},_=e=>{const t=new Set;return e.filter(s=>s.threadId===void 0?!0:t.has(s.threadId)?!1:(t.add(s.threadId),!0))},tt=200;function st({rows:e,verb:t}){const{selectedIds:s,exitSelection:a}=je(),i=o.useMemo(()=>Ge(e,s),[e,s]);return r.jsx(Me,{verb:t,selection:i,selectionRestriction:"spansAccounts",onFinished:a})}function at({selectedMessageId:e,onOpenThread:t,commandsRef:s,onTriageContextChange:a,onDeleteMessages:i}){const{searchQuery:l,resultFolderIndex:n}=V(),h=fe(),m=ie(),M=le(),[I,u]=o.useState("all"),[g,k]=o.useState(new Set),E=o.useCallback(d=>{k(b=>{const p=new Set(b);return p.has(d)?p.delete(d):p.add(d),p})},[]),v=o.useCallback(()=>{u("all"),k(new Set)},[]),{freeText:T,tokens:y}=pe(l.trim().toLowerCase(),h),{criteria:S,residual:F}=o.useMemo(()=>et({category:I,attributes:g},y),[I,g,y]),O=o.useMemo(()=>T?{...S,query:T}:S,[S,T]),{threads:N,isLoading:x,isError:P,error:D,refetch:B,fetchNextPage:C,hasNextPage:H,isFetchingNextPage:R}=te(S),L=Ye(O,tt),f=o.useMemo(()=>{const d=_(N).map(Z),b=T?xe(d.filter(p=>Te(p,T)),_(L).map(Z)):d;return _(b).filter(p=>ye(p,F))},[N,L,T,F]),w=o.useCallback((d,b)=>{const p=f.find(de=>de.id===d)?.threadId;p&&t?.({threadId:p,messageId:d},b)},[f,t]),K=o.useCallback(d=>{const b=d.threadId??f.find(p=>p.id===d.id)?.threadId;b&&t?.({threadId:b,messageId:d.id})},[f,t]),c=o.useMemo(()=>be(),[]),j=o.useMemo(()=>f.map(d=>ve(d,n)),[f,n]),Q=$e(O)??null,W=Ke(I),re=W?{label:W,reach:F.length>0||T?"loaded-pages":"whole-folder",onClear:v}:void 0,X=x?"loading":P?"error":f.length===0?"empty":"ready",oe=o.useCallback(()=>{const d=ce(ue());window.open(d,"_blank","noopener,noreferrer")},[]),U=Se(),ne=r.jsx("div",{className:"flex h-full min-h-0 flex-col",children:r.jsxs("div",{className:"flex-1 overflow-y-auto",children:[r.jsx("div",{className:"divide-y divide-line",children:f.map(d=>r.jsx(Ce,{thread:d,active:d.id===e,onClick:()=>w(d.id)},d.id))}),H?r.jsx("button",{type:"button",className:"w-full py-3 text-sm text-muted hover:text-fg disabled:opacity-50",onClick:()=>C(),disabled:R,children:R?"Loading…":"Load more"}):null]})});return r.jsx(Qe,{title:"Starred",unreadCount:Q,preset:c,selectedCategory:I,activeFilters:g,onSelectCategory:u,onToggleFilter:E,onClearFilters:v,searchResults:j,searchLoading:x,onSelectSearchResult:K,searchResultsInBody:!0,children:r.jsxs(Re,{selectedMessageId:e,rows:f,onOpen:w,onDeleteMessages:i,onSelectionVerb:M.start,commandsRef:s,onTriageContextChange:a,children:[r.jsx(_e,{listTitle:"Starred",sections:[{id:"flagged",threads:f}],flatList:!0,hideHeader:!0,listState:U.searchResults?"ready":X,listFilter:re,listScopeLabel:"Starred",searchQuery:T?l:void 0,errorMessage:P?ze(D):void 0,onRetry:()=>B(),onReportError:oe,selectedThreadId:e,onSelectThread:w,isDesktop:m,selectionBar:r.jsx(we,{title:"Starred"}),listBody:U.searchResults??(X==="ready"?ne:void 0)}),r.jsx(st,{rows:f,verb:M.verb})]})})}const se=o.createContext(null);function q(){const e=o.useContext(se);if(!e)throw new Error("FlaggedPane.* must be used inside <FlaggedPane>");return e}function rt({thread:e,children:t}){const s=We(),a=Xe(),i=Ue(),{searchInput:l}=V(),n=e?.threadId,h=e?.messageId,{threads:m}=te(),M=o.useMemo(()=>{if(n)return m.find(c=>c.messageId===h)??m.find(c=>c.threadId===n)},[m,n,h]),I=Fe(n,h),u=M??I,g=h??u?.messageId,k=o.useMemo(()=>{if(n)return{threadId:n,mailboxId:u?.mailboxId??"",subject:u?.subject,messageId:g,authenticity:u?.authenticity}},[n,u,g]),E=o.useCallback((c,j)=>{s(c,{replace:j?.replace,query:l})},[s,l]),v=o.useCallback(c=>{g&&c.includes(g)&&a()},[g,a]),T=Y({thread:u,isOpen:!0,onAfterOptimisticRemove:v}),y=Oe(),{deleteMessages:S}=Pe({mailboxId:u?.mailboxId??"",messages:m,onAfterOptimisticRemove:v}),{toggleReadFor:F}=ke({mailboxId:u?.mailboxId??"",messages:m}),O=y.focusedMessageId,x=o.useMemo(()=>m.find(c=>c.messageId===O),[m,O])??u,P=Y({thread:x,isOpen:x?.messageId===g}),D=Ve(),B=ge(),C=he(),H=o.useMemo(()=>me(C,n,g),[C,n,g]),R=o.useMemo(()=>{if(x)return c=>C({threadId:x.threadId,messageId:x.messageId,mode:c})},[C,x]),{nextMessageId:L,previousMessageId:f}=Le({context:y,orderedIds:y.orderedIds,selectedMessageId:g,enabled:!D&&!B,hasOpenThread:n!==void 0,onClose:a,handlers:{reply:()=>R?.("reply"),replyAll:()=>R?.("reply-all"),forward:()=>R?.("forward"),delete:()=>{y.listCommandsRef.current?.requestVerb("delete")||P.deleteThread()},toggleStar:P.toggleStar,toggleRead:()=>{y.listCommandsRef.current?.requestVerb("markRead")||x&&F([x.messageId],!x.isRead)},goBrief:()=>i("brief"),goSettings:()=>i("settings")}}),w=o.useCallback(c=>{if(!c)return;const j=m.find(Q=>Q.messageId===c);return j?{threadId:j.threadId,messageId:c}:void 0},[m]),K={selectedMessageId:g,selectedThread:u,conversation:k,onOpenThread:E,onCloseThread:a,nextThread:w(L),previousThread:w(f),actions:T,onReply:H,triage:y,onDeleteMessages:S,handleDeselectIfRemoved:v};return r.jsx(se.Provider,{value:K,children:t})}function ae(){const{selectedMessageId:e,onOpenThread:t,triage:s,onDeleteMessages:a}=q();return r.jsx(at,{selectedMessageId:e,onOpenThread:t,commandsRef:s.listCommandsRef,onTriageContextChange:s.onTriageContextChange,onDeleteMessages:a})}function ot(){const{conversation:e,selectedThread:t,actions:s,onReply:a,handleDeselectIfRemoved:i}=q(),l=!!e,n=Ee(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(Ne,{hasThread:l,intelligenceOpen:n.isShowing,canToggleIntelligence:n.canToggle,onToggleIntelligence:n.toggle,onReply:a?()=>a("reply"):void 0,onReplyAll:a?()=>a("reply-all"):void 0,onForward:a?()=>a("forward"):void 0,onDelete:l?s.deleteThread:void 0,onToggleStar:l?s.toggleStar:void 0,isStarred:s.isStarred,moveContext:l&&s.accountId&&s.mailboxId?{accountId:s.accountId,currentMailboxId:s.mailboxId,onMove:s.moveThread}:void 0}),r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e?r.jsx(J,{threadId:e.threadId,mailboxId:e.mailboxId,subject:e.subject,selectedMessageId:e.messageId,authenticity:e.authenticity,onOpenIntelligence:n.open,listOnScreen:!0}):r.jsx(Ie,{})})]}),r.jsx(ee,{isOpen:n.drawerOpen,onClose:n.closeDrawer,thread:t,mailboxId:t?.mailboxId,accountId:t?.accountId,onAfterOptimisticRemove:i})]})}function nt(){const{selectedThread:e,handleDeselectIfRemoved:t}=q(),{onToggleIntelligence:s}=V();return r.jsx(qe,{onClose:s,thread:e,mailboxId:e?.mailboxId,accountId:e?.accountId,onAfterOptimisticRemove:t})}function dt(){const{selectedThread:e,conversation:t,onCloseThread:s,onOpenThread:a,nextThread:i,previousThread:l,handleDeselectIfRemoved:n}=q(),h=Ae(t?.threadId??null);return t?r.jsxs(r.Fragment,{children:[r.jsx(J,{threadId:t.threadId,mailboxId:t.mailboxId,subject:t.subject,selectedMessageId:t.messageId,authenticity:t.authenticity,onBack:s,onOpenIntelligence:h.toggle,onSwipeNext:i?()=>a(i):void 0,onSwipePrevious:l?()=>a(l):void 0,mobileIntelligenceOpen:h.isOpen}),r.jsx(ee,{isOpen:h.isOpen,onClose:h.close,thread:e,mailboxId:e?.mailboxId,accountId:e?.accountId,onAfterOptimisticRemove:n})]}):r.jsx("div",{className:"h-full",children:r.jsx(ae,{})})}const It=Object.assign(rt,{List:ae,Reading:ot,Intelligence:nt,Phone:dt});export{It as F};
@@ -1 +1 @@
1
- import{r as n,c as f,d as m,E as N,j as e,bi as E,X as w}from"./index-DFOeerF8.js";import{E as u}from"./ErrorState-DW9hn0tP.js";import{D as r,C as x,u as k}from"./index-Gkx4jre7.js";import{c as p,d as h,e as b}from"./useMessageBodyContent-DKDt9OB3.js";import{C as S}from"./confirm-dialog-Dqem_dYa.js";const C=t=>t?"Draft":"New Message",I=()=>{const t=n.useRef(!1);return n.useCallback(()=>{const s=document.querySelector("[data-subject-field]")?.value??"",o=(document.querySelector('[data-testid="compose-body"]')?.textContent??"").replace(/--\s*/g,"").trim();return t.current=s.trim().length>0||o.length>0,t.current},[])},O=()=>{const t=p(),i=h(),s=b(),a=I(),[l,o]=n.useState(!1),{isError:d,error:c,refetch:g}=f({...m(),staleTime:1/0}),j=n.useCallback(D=>{D||(a()?o(!0):s())},[s,a]),y=n.useCallback(()=>{o(!1),s()},[s]),v=n.useCallback(()=>{o(!1)},[]);return N({id:"mobile-compose",open:!0}),e.jsxs(r.Root,{open:!0,onOpenChange:j,children:[e.jsxs(r.Portal,{children:[e.jsx(r.Overlay,{className:"fixed inset-0 z-40 bg-black/40"}),e.jsxs(r.Content,{className:"fixed inset-x-0 bottom-0 z-50 flex flex-col rounded-t-lg bg-canvas pb-[env(safe-area-inset-bottom,0px)]",style:{height:"95dvh"},children:[e.jsx(r.Handle,{className:"mx-auto mt-2 mb-1 h-1.5 w-12 rounded-full bg-fg-muted/30"}),e.jsx(r.Title,{className:"px-4 py-2 text-base font-semibold border-b border-line",children:C(t)}),d?e.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:e.jsx(u,{title:"Couldn't load compose",error:c,onRetry:()=>{g()}})}):e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(x,{mode:"new",outboxMessageId:t,onDraftCreated:i,onClose:s})})]})]}),e.jsx(S,{isOpen:l,title:"Discard draft?",description:"Your message has unsaved content. Are you sure you want to discard it?",confirmLabel:"Discard",cancelLabel:"Keep editing",destructive:!0,onConfirm:y,onCancel:v})]})},q=()=>{const t=p(),i=h(),s=b(),a=E(),{isError:l,error:o,refetch:d}=f({...m(),staleTime:1/0});if(k({bindings:[{key:"Escape",handler:s,preventDefault:!0}]}),!a)return e.jsx(O,{});const c=e.jsxs("header",{className:"flex items-center justify-between gap-2 px-4 py-3 border-b border-line shrink-0",children:[e.jsx("div",{className:"flex items-center gap-2 min-w-0",children:e.jsx("h2",{className:"text-lg font-semibold truncate",children:C(t)})}),e.jsx("button",{type:"button",onClick:s,className:"p-2 rounded-md hover:bg-surface-raised transition-colors min-h-11 min-w-11 inline-flex items-center justify-center","aria-label":"Close",children:e.jsx(w,{className:"size-5"})})]});return l?e.jsxs("div",{className:"h-full flex flex-col bg-canvas",children:[c,e.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:e.jsx(u,{title:"Couldn't load compose",error:o,onRetry:()=>{d()}})})]}):e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-canvas",children:[c,e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(x,{mode:"new",outboxMessageId:t,onDraftCreated:i,onClose:s})})]})};export{q as F};
1
+ import{r as n,c as f,d as m,E as N,j as e,bi as E,X as w}from"./index-D855R0Fw.js";import{E as u}from"./ErrorState--2p5I6wj.js";import{D as r,C as x,u as k}from"./index-86n4-j8G.js";import{c as p,d as h,e as b}from"./useMessageBodyContent-I6J6WaYN.js";import{C as S}from"./confirm-dialog-BTkV4N2t.js";const C=t=>t?"Draft":"New Message",I=()=>{const t=n.useRef(!1);return n.useCallback(()=>{const s=document.querySelector("[data-subject-field]")?.value??"",o=(document.querySelector('[data-testid="compose-body"]')?.textContent??"").replace(/--\s*/g,"").trim();return t.current=s.trim().length>0||o.length>0,t.current},[])},O=()=>{const t=p(),i=h(),s=b(),a=I(),[l,o]=n.useState(!1),{isError:d,error:c,refetch:g}=f({...m(),staleTime:1/0}),j=n.useCallback(D=>{D||(a()?o(!0):s())},[s,a]),y=n.useCallback(()=>{o(!1),s()},[s]),v=n.useCallback(()=>{o(!1)},[]);return N({id:"mobile-compose",open:!0}),e.jsxs(r.Root,{open:!0,onOpenChange:j,children:[e.jsxs(r.Portal,{children:[e.jsx(r.Overlay,{className:"fixed inset-0 z-40 bg-black/40"}),e.jsxs(r.Content,{className:"fixed inset-x-0 bottom-0 z-50 flex flex-col rounded-t-lg bg-canvas pb-[env(safe-area-inset-bottom,0px)]",style:{height:"95dvh"},children:[e.jsx(r.Handle,{className:"mx-auto mt-2 mb-1 h-1.5 w-12 rounded-full bg-fg-muted/30"}),e.jsx(r.Title,{className:"px-4 py-2 text-base font-semibold border-b border-line",children:C(t)}),d?e.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:e.jsx(u,{title:"Couldn't load compose",error:c,onRetry:()=>{g()}})}):e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(x,{mode:"new",outboxMessageId:t,onDraftCreated:i,onClose:s})})]})]}),e.jsx(S,{isOpen:l,title:"Discard draft?",description:"Your message has unsaved content. Are you sure you want to discard it?",confirmLabel:"Discard",cancelLabel:"Keep editing",destructive:!0,onConfirm:y,onCancel:v})]})},q=()=>{const t=p(),i=h(),s=b(),a=E(),{isError:l,error:o,refetch:d}=f({...m(),staleTime:1/0});if(k({bindings:[{key:"Escape",handler:s,preventDefault:!0}]}),!a)return e.jsx(O,{});const c=e.jsxs("header",{className:"flex items-center justify-between gap-2 px-4 py-3 border-b border-line shrink-0",children:[e.jsx("div",{className:"flex items-center gap-2 min-w-0",children:e.jsx("h2",{className:"text-lg font-semibold truncate",children:C(t)})}),e.jsx("button",{type:"button",onClick:s,className:"p-2 rounded-md hover:bg-surface-raised transition-colors min-h-11 min-w-11 inline-flex items-center justify-center","aria-label":"Close",children:e.jsx(w,{className:"size-5"})})]});return l?e.jsxs("div",{className:"h-full flex flex-col bg-canvas",children:[c,e.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:e.jsx(u,{title:"Couldn't load compose",error:o,onRetry:()=>{d()}})})]}):e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-canvas",children:[c,e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(x,{mode:"new",outboxMessageId:t,onDraftCreated:i,onClose:s})})]})};export{q as F};