@remit/web-client-dist 0.0.480 → 0.0.482

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 (142) hide show
  1. package/assets/BriefPane-CfitNMEu.js +1 -0
  2. package/assets/{ErrorState-CTL91fuE.js → ErrorState-4TfgxGLk.js} +1 -1
  3. package/assets/FlaggedPane-B7mltHsE.js +1 -0
  4. package/assets/{FullCompose-Bms4BHPg.js → FullCompose-0DIPCtd6.js} +1 -1
  5. package/assets/{MailListHeader-C43KDg07.js → MailListHeader-Brjq4vBE.js} +1 -1
  6. package/assets/{MailShell-C4fIrI6z.js → MailShell-CvGuWCuj.js} +1 -1
  7. package/assets/MailViewChrome-C7sCKY-n.js +1 -0
  8. package/assets/MailboxPane-COHQn6Yb.js +1 -0
  9. package/assets/{NavMenuButton-DOvsxgZN.js → NavMenuButton-n2Am7T-q.js} +1 -1
  10. package/assets/OnboardingWizard-BtlDSuHk.js +1 -0
  11. package/assets/OutboxPane-C-_EQFRO.js +1 -0
  12. package/assets/_mailboxId-Bqbp7c9M.js +1 -0
  13. package/assets/_messageId-BAluf3UO.js +1 -0
  14. package/assets/_messageId-CHs89GPR.js +1 -0
  15. package/assets/_messageId-Ctd9_Bl1.js +1 -0
  16. package/assets/_outboxMessageId-_2jJC1Qb.js +1 -0
  17. package/assets/_threadId-BYyW8ujt.js +1 -0
  18. package/assets/_threadId-BrgLQ-Pl.js +1 -0
  19. package/assets/_threadId-C9FCiXzy.js +1 -0
  20. package/assets/{accounts-BBPhIw_K.js → accounts-D3L3nj2z.js} +1 -1
  21. package/assets/advanced-DtxZPECw.js +4 -0
  22. package/assets/{appearance-CP_hVZW-.js → appearance-OV39hcLF.js} +1 -1
  23. package/assets/attachment-file-ul58bxI4.js +1 -0
  24. package/assets/{avatar-D2QoGusZ.js → avatar-G7g9Uwvc.js} +1 -1
  25. package/assets/bottom-sheet-B6YVIwAN.js +1 -0
  26. package/assets/brief-Bc68FlBf.js +1 -0
  27. package/assets/{brief-BmtI16ta.js → brief-BcQPVd1X.js} +1 -1
  28. package/assets/browser-ponyfill-DXnwXxSp.js +2 -0
  29. package/assets/{bug-B7DVX1LH.js → bug-Dj9DPa4Y.js} +1 -1
  30. package/assets/card-B1IEp2-a.js +1 -0
  31. package/assets/{circle-check-CUFp0EuL.js → circle-check-CsnMhxDa.js} +1 -1
  32. package/assets/{circle-check-big-D3ITahtH.js → circle-check-big-SYJDr4tY.js} +1 -1
  33. package/assets/{circle-help-DZ6iiqLn.js → circle-help-BoGPc17x.js} +1 -1
  34. package/assets/{clock-7DhaUrXH.js → clock-C2olBfsH.js} +1 -1
  35. package/assets/compose._-_outboxMessageId_-C_qZJ56q.js +1 -0
  36. package/assets/compose._-_outboxMessageId_-DKWODs5S.js +1 -0
  37. package/assets/compose._-_outboxMessageId_-DwRvAUq2.js +1 -0
  38. package/assets/compose._-_outboxMessageId_-mWQ2SoXJ.js +1 -0
  39. package/assets/config-import-1pqti4UQ.js +1 -0
  40. package/assets/confirm-dialog-B4KJVTQx.js +1 -0
  41. package/assets/credential-steps-BNmmF6YJ.js +1 -0
  42. package/assets/{download-CaoEFcgo.js → download-vw3zYEkx.js} +1 -1
  43. package/assets/filters-BmW8kKxW.js +1 -0
  44. package/assets/flagged-R318UqUZ.js +1 -0
  45. package/assets/{flagged-bFbPg-JE.js → flagged-uZGUg7Dw.js} +1 -1
  46. package/assets/folders-CkYvGGkZ.js +1 -0
  47. package/assets/{format-DOYPebpW.js → format-BSk7Do06.js} +1 -1
  48. package/assets/{help-copy-DpxyOl08.js → help-copy-D6t16AP5.js} +1 -1
  49. package/assets/import-CNvHrBcn.js +1 -0
  50. package/assets/index-2Vc2Ycg0.js +1 -0
  51. package/assets/index-BBBVjIQK.js +1 -0
  52. package/assets/index-CAPjLYZ5.js +1 -0
  53. package/assets/index-CHs89GPR.js +1 -0
  54. package/assets/index-COugriit.js +1 -0
  55. package/assets/{index-D5iR33Kk.js → index-CYwsmjFx.js} +12 -12
  56. package/assets/index-Ctd9_Bl1.js +1 -0
  57. package/assets/index-D93knX1J.js +1 -0
  58. package/assets/{index-DNl2PEHq.css → index-DYO-sbPN.css} +1 -1
  59. package/assets/{index--jDmBhH5.js → index-FpwHnbdV.js} +32 -32
  60. package/assets/index-N1RMrj2-.js +1 -0
  61. package/assets/{kbd-faCJijM9.js → kbd-tXno4rYH.js} +1 -1
  62. package/assets/labels-D8dMllXL.js +1 -0
  63. package/assets/mail-CFC6XnIq.js +1 -0
  64. package/assets/{mail-DRJYwhBZ.js → mail-DmVe7n1g.js} +1 -1
  65. package/assets/{menu-CW3Mzpax.js → menu-B-aaGy7K.js} +1 -1
  66. package/assets/onboarding-completion-YE4GukFN.js +1 -0
  67. package/assets/onboarding-vJtatS1N.js +1 -0
  68. package/assets/outbox-C9Rxk-WO.js +1 -0
  69. package/assets/{pencil-DKKAE-bd.js → pencil-DSzm4tGc.js} +1 -1
  70. package/assets/{rich-text-Cj936CB8.js → rich-text-Bi1khhyl.js} +15 -15
  71. package/assets/{rich-text-spellcheck-worker-provider-_InIfkuv.js → rich-text-spellcheck-worker-provider-vLdWVTOw.js} +1 -1
  72. package/assets/{rotate-ccw-Dhr2W02W.js → rotate-ccw-CwLIBdgY.js} +1 -1
  73. package/assets/row-actions-DgziqjAx.js +1 -0
  74. package/assets/{search-mirror-BDwx47ks.js → search-mirror-B2LoSoNR.js} +1 -1
  75. package/assets/search-token-index-C9KNJC5_.js +1 -0
  76. package/assets/sections-DDQm-Sbc.js +1 -0
  77. package/assets/senders-BWTk7Fqx.js +1 -0
  78. package/assets/settings-B4qmCAFR.js +1 -0
  79. package/assets/settings-screen-m0Uy9zlo.js +1 -0
  80. package/assets/{shield-check-Cj8mYi62.js → shield-check-Cs0C_oxK.js} +1 -1
  81. package/assets/{suggested-vips-BtvoU3i0.js → suggested-vips-CtCLsdy6.js} +1 -1
  82. package/assets/{useDebouncedValue-CjmnuaOp.js → useDebouncedValue-DU11pzlc.js} +1 -1
  83. package/assets/useFilters-BBJu_93Q.js +1 -0
  84. package/assets/useLabels-GtiakPKP.js +1 -0
  85. package/assets/useMessageBodyContent-BOBb68Px.js +1 -0
  86. package/assets/{useQueries-DSOBb7ot.js → useQueries-Dx2PHSps.js} +1 -1
  87. package/assets/useRefreshControl-CWjutjgw.js +1 -0
  88. package/assets/{useSearchTokenContext-R8A5fR2H.js → useSearchTokenContext-DH5XswlU.js} +4 -4
  89. package/assets/useSemanticSearch-CZUtmciE.js +1 -0
  90. package/assets/useSignature-HAuR6_Ul.js +1 -0
  91. package/index.html +2 -2
  92. package/package.json +1 -1
  93. package/assets/BriefPane-BdEJNwsV.js +0 -1
  94. package/assets/FlaggedPane-BzZh6Wsv.js +0 -1
  95. package/assets/MailViewChrome-q-U1DZjL.js +0 -1
  96. package/assets/MailboxPane-CuD0jr-f.js +0 -1
  97. package/assets/OnboardingWizard-B2FfSB3u.js +0 -1
  98. package/assets/OutboxPane-D4OIAjU0.js +0 -1
  99. package/assets/_mailboxId-CGgM6mBc.js +0 -1
  100. package/assets/_messageId-BJjLs2Pn.js +0 -1
  101. package/assets/_messageId-CJPzxEBL.js +0 -1
  102. package/assets/_messageId-oldJdeMi.js +0 -1
  103. package/assets/_outboxMessageId-Dw64siEo.js +0 -1
  104. package/assets/_threadId-8mCoRk5S.js +0 -1
  105. package/assets/_threadId-BYjLDO0i.js +0 -1
  106. package/assets/_threadId-DKCfh1r1.js +0 -1
  107. package/assets/advanced-RxcOnjlG.js +0 -4
  108. package/assets/attachment-file-DdbHhRnT.js +0 -1
  109. package/assets/bottom-sheet-BfbE1fYC.js +0 -1
  110. package/assets/brief-Yjq6y5en.js +0 -1
  111. package/assets/browser-ponyfill-pt-5A_uQ.js +0 -2
  112. package/assets/compose._-_outboxMessageId_-B4LakFkh.js +0 -1
  113. package/assets/compose._-_outboxMessageId_-BDbqrjuz.js +0 -1
  114. package/assets/compose._-_outboxMessageId_-DHyEHb2d.js +0 -1
  115. package/assets/compose._-_outboxMessageId_-dFeZ1y61.js +0 -1
  116. package/assets/confirm-dialog-7y6SUiP7.js +0 -1
  117. package/assets/filters-B9cCiScu.js +0 -1
  118. package/assets/flagged-CHpBIWk4.js +0 -1
  119. package/assets/folders-D0K_eYip.js +0 -1
  120. package/assets/index-B1Nn5IhQ.js +0 -1
  121. package/assets/index-C6t9WhW9.js +0 -1
  122. package/assets/index-CIFoV-8J.js +0 -1
  123. package/assets/index-CJEAB-UH.js +0 -1
  124. package/assets/index-CJPzxEBL.js +0 -1
  125. package/assets/index-DTrDTcq8.js +0 -1
  126. package/assets/index-DvbCYnGX.js +0 -1
  127. package/assets/index-oldJdeMi.js +0 -1
  128. package/assets/labels-ao1q8Nf_.js +0 -1
  129. package/assets/mail-CVui7-1b.js +0 -1
  130. package/assets/onboarding-CziuxS3m.js +0 -1
  131. package/assets/outbox-CIYCDg-G.js +0 -1
  132. package/assets/row-actions-ClLhsNPW.js +0 -1
  133. package/assets/search-token-index-CFFpLJvA.js +0 -1
  134. package/assets/senders-Cssai4ku.js +0 -1
  135. package/assets/settings-DWzmbjx4.js +0 -1
  136. package/assets/settings-screen-C9UiB_xP.js +0 -1
  137. package/assets/useFilters-BqbHYPYY.js +0 -1
  138. package/assets/useLabels-BjdBxeXq.js +0 -1
  139. package/assets/useMessageBodyContent-C0DuC9W1.js +0 -1
  140. package/assets/useRefreshControl-CSvzy86_.js +0 -1
  141. package/assets/useSemanticSearch-CwlN7Eas.js +0 -1
  142. package/assets/useSignature-CgXgknZQ.js +0 -1
@@ -1 +1 @@
1
- import{d$ as r,e0 as o,e1 as a}from"./index--jDmBhH5.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{e3 as r,e4 as o,e5 as a}from"./index-FpwHnbdV.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{c as t}from"./index--jDmBhH5.js";const e=t("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);export{e as R};
1
+ import{c as t}from"./index-FpwHnbdV.js";const e=t("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);export{e as R};
@@ -0,0 +1 @@
1
+ import{r as e,j as l,a as b,p as y,L as x}from"./index-FpwHnbdV.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 c({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{c as R};
@@ -1 +1 @@
1
- import{a1 as v,v as x,o as p,a9 as I,r as g,q as Q}from"./index--jDmBhH5.js";import{b}from"./MailShell-C4fIrI6z.js";import{a as q}from"./useMessageBodyContent-C0DuC9W1.js";function W(o){const t=v(),{searchInput:c,searchQuery:e}=x(),i=p({select:a=>Q(a.location.search)}),u=p({select:a=>a.location.pathname}),h=q(),f=I(),m=h||f,{to:s}=o,r="params"in o?o.params.mailboxId:void 0,l=r?`/mail/${r}`:s;g.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{ad as v,Q as x,H as p,K as I,ai as Q,r as g}from"./index-FpwHnbdV.js";import{b}from"./MailShell-CvGuWCuj.js";import{a as q}from"./useMessageBodyContent-BOBb68Px.js";function W(o){const t=v(),{searchInput:c,searchQuery:e}=x(),i=p({select:a=>I(a.location.search)}),u=p({select:a=>a.location.pathname}),h=q(),f=Q(),m=h||f,{to:s}=o,r="params"in o?o.params.mailboxId:void 0,l=r?`/mail/${r}`:s;g.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};
@@ -0,0 +1 @@
1
+ import{c as $,r as c,j as h,w as V,p as k,cc as G,X as z,cd as q,ce as Y,cf as X,cg as J,ch as W,D as x,ad as L,ci as Z,c5 as w,cj as ee,a1 as te,a0 as ne,bT as se,ck as re,U as ae,V as K,Y as oe,Z as ie,Q as ce,bF as F,bG as le,cl as M}from"./index-FpwHnbdV.js";import{a as ue,S as de}from"./search-scope-DTcpOp3S.js";import{u as D}from"./useQueries-Dx2PHSps.js";const Ke=$("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"}]]);const De=$("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]),fe=[{action:"focusNext",keys:["j","k"],label:"navigate"},{action:"muteSender",keys:["m"],label:"mute"},{action:"help",keys:["?"],label:"all shortcuts"}];function Ne(e){return fe.filter(t=>e[t.action]!==void 0)}const pe=[{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 he(e){for(const t of pe){const n=t.hints.find(s=>s.action===e);if(n)return n.keys}}function me(e){const t=he(e);return!t||t.length===0?"":t.length===1?t[0]??"":t[0]==="g"?t.join(" then "):t.join("")}function Ae(e){const t=me(e);return t===""?"":`(${t})`}function ye({key:e,shiftKey:t=!1,repeat:n=!1,caretAtStart:s,hasValue:a,chipCount:r}){const i=r-1;return e==="Escape"?a?{type:"clearQuery"}:{type:"blur"}:e==="Tab"&&t?r===0?{type:"none"}:{type:"focusChip",index:i}:e==="Backspace"||e==="ArrowLeft"?!s||r===0?{type:"none"}:n?{type:"none"}:{type:"focusChip",index:i}:{type:"none"}}function ge({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 be(e,t){const n=t-1;return n<=0?null:e<n?e:n-1}const xe=e=>e instanceof HTMLElement?e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.isContentEditable:!1,ke=({chips:e=[],onRemoveChip:t,value:n,onChange:s,onClear:a,onClearQuery:r,placeholder:i="Search mail...",globalFocusKey:u=!0,showClearButton:p=!0,size:m="sm",inputId:d,suggest:f,className:b})=>{const O=c.useId(),N=d??O,I=c.useRef(null),A=c.useRef([]),R=r??a,[P,C]=c.useState(null),S=c.useRef(void 0),[Q,B]=c.useState(""),T=e.length>0;c.useEffect(()=>{C(o=>o!==null&&o>=e.length?null:o)},[e.length]),c.useEffect(()=>{const o=S.current;if(o!==void 0){if(S.current=void 0,o===null){I.current?.focus();return}A.current[o]?.focus()}});const j=c.useRef(void 0);c.useEffect(()=>{const o=f?.caret;if(!o||o===j.current)return;j.current=o;const l=I.current;!l||l.ownerDocument.activeElement!==l||(l.setSelectionRange(o.cursor,o.cursor),f?.onCaretChange(o.cursor))});const v=o=>{f?.onCaretChange(o.selectionStart??o.value.length)},y=c.useCallback(o=>{C(o),S.current=o},[]),E=c.useCallback(o=>{const l=e[o];l&&t&&(y(be(o,e.length)),B(`${l.label} removed`),t(l.id))},[e,t,y]),H=c.useCallback(()=>{y(null),a()},[a,y]),U=c.useCallback(o=>{const l=o.currentTarget;if(f?.onKeyDown(o))return;const g=ye({key:o.key,shiftKey:o.shiftKey,repeat:o.repeat,caretAtStart:l.selectionStart===0&&l.selectionEnd===0,hasValue:n.length>0,chipCount:e.length});switch(g.type){case"focusChip":o.preventDefault(),y(g.index);return;case"clearQuery":R();return;case"blur":l.blur();return;case"none":return}},[e.length,n,R,y,f]),_=c.useCallback(o=>l=>{const g=ge({key:l.key,repeat:l.repeat,index:o,chipCount:e.length});switch(g.type!=="none"&&l.preventDefault(),g.type){case"removeChip":E(g.index);return;case"focusChip":y(g.index);return;case"focusInput":y(null);return;case"activateChip":return;case"none":return}},[e,E,y]);return c.useEffect(()=>{if(!u)return;const o=l=>{l.key!=="/"||l.metaKey||l.ctrlKey||l.altKey||xe(l.target)||q("focusSearch")||(l.preventDefault(),I.current?.focus())};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[u]),h.jsxs("label",{htmlFor:N,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",m==="lg"?"rounded-xl px-4 py-2":"rounded-md px-2.5 py-1",b),children:[h.jsx(V,{className:k("shrink-0 text-fg-muted pointer-events-none",m==="lg"?"size-5":"size-4")}),h.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1",children:[T&&h.jsx("div",{role:"grid","aria-label":"Search filters",className:"flex min-w-0 flex-wrap items-center gap-1",children:e.map((o,l)=>h.jsx(G,{ref:g=>{A.current[l]=g},label:o.label,tone:o.tone,focused:P===l,onFocusLabel:()=>C(l),onKeyDown:_(l),onRemove:()=>E(l)},o.id))}),h.jsx("input",{ref:I,id:N,name:"q",type:"text","aria-label":"Search mail",autoComplete:"off",value:n,tabIndex:P===null?0:-1,onChange:o=>{s(o.target.value),v(o.target)},onKeyDown:U,onKeyUp:o=>v(o.currentTarget),onClick:o=>v(o.currentTarget),onFocus:o=>{C(null),f?.onFocusChange?.(!0),v(o.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&&h.jsx("button",{type:"button",onClick:H,className:"shrink-0 rounded p-0.5 hover:bg-surface-raised transition-colors","aria-label":"Clear search",children:h.jsx(z,{className:k("text-fg-muted",m==="lg"?"size-5":"size-4")})}),h.jsx("span",{role:"status","aria-live":"polite",className:"sr-only",children:Q})]})},Re=({value:e,onChange:t,onClear:n,onClearQuery:s,chips:a,onRemoveChip:r,placeholder:i="Search mail...",globalFocusKey:u=!0,showClearButton:p=!0,size:m,inputId:d,suggest:f,className:b})=>h.jsx(ke,{value:e,onChange:t,onClear:n,onClearQuery:s,chips:a,onRemoveChip:r,placeholder:i,globalFocusKey:u,showClearButton:p,size:m,inputId:d,suggest:f,className:b});function Pe({handlers:e,enabled:t=!0,target:n,sequenceTimeoutMs:s=1e3}){const a=c.useRef(e);a.current=e;const r=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=Y({key:d.key,shiftKey:d.shiftKey,metaKey:d.metaKey,ctrlKey:d.ctrlKey,altKey:d.altKey,inEditable:J(d.target),onControl:X(d.target)},r.current);if(W().length>0){u(),r.current=null;return}if(u(),r.current=f.nextPrefix,f.nextPrefix!==null&&(i.current=setTimeout(()=>{r.current=null,i.current=null},s)),f.action===null||q(f.action)!==null)return;const b=a.current[f.action];b&&(f.preventDefault&&d.preventDefault(),b())},m=n===void 0?window:n;if(m!==null)return m.addEventListener("keydown",p),()=>{m.removeEventListener("keydown",p),u(),r.current=null}},[t,s,n])}function je(){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}),r=x({from:"/mail/$mailboxId/$threadId/$messageId",shouldThrow:!1}),i=e?.threadId??n?.threadId??a?.threadId,u=t?.messageId??s?.messageId??r?.messageId;return c.useMemo(()=>i?{threadId:i,messageId:u}:void 0,[i,u])}function Fe(){const e=L(),t=Z(),{list:n,mailboxId:s}=w();return c.useCallback((a,r)=>{const i=r?.query,p={search:d=>i===void 0?d:{...d,q:i||void 0},hash:t,replace:r?.replace??!1};if(n==="flagged"){e({to:"/mail/flagged/$threadId/$messageId",params:a,...p});return}const m=r?.mailboxId??s;if(n==="mailbox"&&m){e({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:m,...a},...p});return}e({to:"/mail/brief/$threadId/$messageId",params:a,...p})},[e,t,n,s])}function $e(){return ee()}function we(){const e=L();return c.useCallback(t=>{e({to:"/mail/brief",search:{q:t||void 0}})},[e])}function qe(){const e=L();return c.useCallback((t,n)=>{e({to:"/mail/$mailboxId",params:{mailboxId:t},search:{q:n||void 0}})},[e])}const Oe=({trigger:e,children:t,align:n="right"})=>{const[s,a]=c.useState(!1),r=c.useRef(null),i=c.useCallback(u=>{r.current&&!r.current.contains(u.target)&&a(!1)},[]);return te({id:"dropdown-menu",open:s,answers:{back:()=>a(!1)}}),c.useEffect(()=>(s&&document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)),[s,i]),h.jsxs("div",{ref:r,className:"relative",children:[h.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&&h.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})]})},Qe=({onClick:e,disabled:t,destructive:n,children:s})=>h.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}),Be=()=>h.jsx("div",{className:"my-1 h-px bg-line"}),Ie=e=>typeof e=="object"&&e!==null&&Array.isArray(e.pages),Ce=e=>typeof e=="object"&&e!==null&&Array.isArray(e.items),ve=(e,t)=>e===void 0?e:Ie(e)?{...e,pages:e.pages.map(n=>({...n,items:t(n.items)}))}:Ce(e)?{...e,items:t(e.items)}:e,He=e=>{const t=[];for(const n of new Set(e))t.push(ne({path:{mailboxId:n}})),t.push(se({path:{mailboxId:n}}));return t.push(re()),t},Ue=(e,t)=>Promise.all(t.map(n=>e.cancelQueries({queryKey:n}))),_e=(e,t)=>t.flatMap(n=>e.getQueriesData({queryKey:n})).filter(n=>n[1]!==void 0).map(([n,s])=>({queryKey:n,data:s})),Ve=(e,t,n)=>{const s=a=>ve(a,n);for(const a of t)e.setQueriesData({queryKey:a},s)},Ge=(e,t)=>{for(const n of t)e.setQueryData(n.queryKey,n.data)},ze=(e,t)=>{for(const n of t)e.invalidateQueries({queryKey:n})},Se=({accounts:e})=>{const{list:t,mailboxId:n}=w(),{t:s}=ae("mail",{useSuspense:!1}),a=c.useCallback((i,u)=>s(i,{defaultValue:u}),[s]),r=D({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=r[i]?.data?.items;if(!u)continue;const p=u.find(d=>d.mailboxId===n);if(!p)continue;const m=oe(e[i].folderAppointments);return ie(p,m.get(n),a)}return null},Ye=({accounts:e})=>{const{mailboxId:t}=w(),n=D({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 r=a.find(i=>i.mailboxId===t);if(r)return r.unseenCount}return null},Xe=({accounts:e})=>{const{mailboxId:t}=w(),n=D({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 r=a.find(i=>i.mailboxId===t);if(r)return r.messageCount}return 0};function Je(e){const t=we(),{searchInput:n}=ce(),s=Se({accounts:e}),a=w(),r=ue(a,s),i=c.useCallback(u=>{u===de&&t(n)},[t,n]);return{scope:r,clearScope:i}}const Te=768,We=e=>e!=="desktop",Ze=()=>{const e=F(`(min-width: ${Te}px)`);return F(le)?"desktop":e?"tablet":"phone"};function et(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 tt(e){const t=new Map;for(const n of e)for(const s of n){const a=s.fullPath?.toLowerCase();if(!a)continue;const r=M(s).toLowerCase();t.has(a)||t.set(a,s.mailboxId),t.has(r)||t.set(r,s.mailboxId)}return t}function nt(e,t=[]){const n=e.flat().filter(r=>r.fullPath),s=new Map;for(const r of n){const i=M(r).toLowerCase();s.set(i,(s.get(i)??0)+1)}const a=new Map(t.map(r=>[r.accountId,r.email]));return n.map(r=>{const i=M(r),u=s.get(i.toLowerCase())===1,p=t.length>1?a.get(r.accountId):void 0;return{value:u?i:r.fullPath,label:r.displayNameOverride?.trim()||i,...p?{hint:p}:{}}})}function st(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,r=n.displayName?.trim();return{value:a?s:n.email,label:r||n.email,...r?{hint:n.email}:{}}})}export{Ce as A,Ke as B,Ae as C,Oe as D,nt as E,st as F,Ne as G,pe as K,De as R,Re as S,Be as a,Qe as b,we as c,tt as d,Ze as e,je as f,Pe as g,et as h,ze as i,We as j,Fe as k,$e as l,Se as m,Ye as n,Xe as o,qe as p,fe as q,Ge as r,me as s,He as t,Je as u,Ue as v,_e as w,Ve as x,ve as y,Ie as z};
@@ -0,0 +1 @@
1
+ import{ad as e,r as s}from"./index-FpwHnbdV.js";const a={brief:"/mail/brief",flagged:"/mail/flagged",outbox:"/mail/outbox",settings:"/settings",accounts:"/settings/accounts",importConfig:"/import"};function c(){const t=e();return s.useCallback(o=>{t({to:a[o]})},[t])}function i(){const t=e();return s.useCallback(o=>{t({to:"/settings/accounts",search:{editAccountId:o,focusSmtp:!0}})},[t])}export{i as a,c as u};
@@ -0,0 +1 @@
1
+ import{j as e,p as S,ad as L,r as c,aJ as O,ax as T,w as $,aL as A,d as I,bB as q,u as C,f as k,bC as M,bD as P,a as N,o as R,bE as G,X as Q}from"./index-FpwHnbdV.js";import{K as f}from"./kbd-tXno4rYH.js";import{S as B,a as E}from"./settings-screen-m0Uy9zlo.js";import{E as V}from"./ErrorState-4TfgxGLk.js";import{u as D}from"./useDebouncedValue-DU11pzlc.js";import{a as K}from"./format-BSk7Do06.js";import{s as _}from"./help-copy-D6t16AP5.js";import"./avatar-G7g9Uwvc.js";import"./menu-B-aaGy7K.js";import"./circle-help-BoGPc17x.js";function F({options:t,active:r,onSelect:m}){return e.jsx("div",{role:"tablist",className:S("flex shrink-0 gap-1 overflow-x-auto border-b border-line p-2","lg:w-44 lg:flex-col lg:gap-0 lg:overflow-visible lg:border-r lg:border-b-0 lg:py-2 lg:pr-2 lg:pl-3"),children:t.map(n=>{const d=n.id===r;return e.jsxs("button",{type:"button",role:"tab","aria-selected":d,onClick:()=>m(n.id),className:S("flex min-h-11 shrink-0 items-center gap-2 rounded-md px-3 text-left text-sm transition-colors lg:min-h-0 lg:px-2 lg:py-1",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:S("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}=I(q()),g=C(),i=k({...P(),onSettled:()=>{g.invalidateQueries({queryKey:M()})}}),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(N,{variant:"ghost",size:"sm",icon:e.jsx(R,{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 J({group:t,query:r,onCount:m}){const n=D(r.trim(),300),d=C(),[b,g]=c.useState(null),i=n.length>=2,l=G({query:{q:n,limit:50}}),{data:p,isPending:u,isError:a,error:j}=I({...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&&K(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(N,{variant:"secondary",size:"sm",onClick:()=>{g(s.addressId),x.mutate({path:{addressId:s.addressId},body:{flags:{[t]:null}}})},children:"Retry"}):e.jsx(N,{variant:"ghost",size:"sm",icon:e.jsx(Q,{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]:null}}}))}})},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=L(),[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=A[s];o&&t({to:o})};return e.jsx(B,{items:O,activeId:"senders",title:"Senders & Rules",description:"Per-sender preferences — set with one key from any message, managed here.",flush:!0,help:_,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(T,{icon:e.jsx($,{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(J,{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{re as component};
@@ -0,0 +1 @@
1
+ import{j as t,af as o}from"./index-FpwHnbdV.js";const n=()=>t.jsx(o,{});export{n as component};
@@ -0,0 +1 @@
1
+ import{c as z,r as j,j as e,p as f,a as i,X as N,b as S}from"./index-FpwHnbdV.js";import{A as w}from"./avatar-G7g9Uwvc.js";import{M as O}from"./menu-B-aaGy7K.js";import{C as v}from"./circle-help-BoGPc17x.js";const h=z("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);function F({items:l,activeId:t,title:c,description:n,children:r,help:s,helpOpen:d=!0,flush:o,onSelect:k,onToggleHelp:u,onBackToMail:m}){const[y,x]=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),x(!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:()=>x(!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?.(),x(!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:()=>x(!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(O,{className:"size-4"}),className:"lg:hidden",onClick:()=>x(!0),"aria-label":"Open settings menu"}),e.jsx("h1",{className:"text-md font-semibold text-fg",children:c}),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 R({name:l,email:t,meta:c,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:[c,n&&e.jsxs("span",{className:"text-fg-muted",children:[" · ",n]})]})]}),s&&e.jsx("div",{className:"shrink-0",children:s})]})}const A={healthy:{tone:"positive",label:"healthy"},error:{tone:"danger",label:"error"},muted:{tone:"neutral",label:"muted"}};function X({label:l,email:t,connector:c,syncLabel:n,state:r,errorDetail:s,trailing:d}){const o=A[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(S,{tone:o.tone,dot:!0,children:o.label})]}),e.jsxs("div",{className:"truncate text-xs text-fg-subtle",children:[t," · ",c," · ",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,F as S,R as a};
@@ -1 +1 @@
1
- import{c as e}from"./index--jDmBhH5.js";const c=e("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);export{c as S};
1
+ import{c as e}from"./index-FpwHnbdV.js";const c=e("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);export{c as S};
@@ -1 +1 @@
1
- import{j as t,ac as e}from"./index--jDmBhH5.js";const o=()=>t.jsx(e,{to:"/settings/senders",replace:!0});export{o as component};
1
+ import{j as t,al as e}from"./index-FpwHnbdV.js";const o=()=>t.jsx(e,{to:"/settings/senders",replace:!0});export{o as component};
@@ -1 +1 @@
1
- import{r as o}from"./index--jDmBhH5.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-FpwHnbdV.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};
@@ -0,0 +1 @@
1
+ import{r as m,f as b,dR as E,d as C,dS as x,dA as F,dT as D,u as M,dU as N,dV as P,dW as L,dX as z}from"./index-FpwHnbdV.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=p=>String(p).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}),X=({mode:e,ruleScope:t})=>t==="standing"?"standing":t==="until"?"temporary":e==="selected"?"just-these":"all-like-these",G=({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,R=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]=m.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:R(g.state.dataUpdateCount)}}),s=m.useCallback(g=>{e&&i({path:{accountId:e},body:y(g)})},[e,i]),{refetch:o}=n,d=m.useCallback(()=>{o()},[o]),l=n.data,c=a.isPending?void 0:l,f=c?.state??a.data?.state,u=v(c?.state),p={state:f,matchedCount:c?.matchedCount??0,appliedCount:c?.appliedCount??0,failedCount:c?.failedCount??0,errorMessage:c?.errorMessage??""};return{start:s,refreshStatus:d,progress:p,isStarting:a.isPending,isRunning:!!t&&!u,isDone:u,failure:_(a.error,n.error,!!l)}},Z=["From","Subject","HasWords","ListId","FromDomain"],$=e=>{const t=e.trim(),r=t.match(/<([^>]+)>/);return(r?r[1]:t).trim().toLowerCase()},ee=(e,t)=>e==="ListId"?$(t):t.trim(),k=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:k(e.matchOperator),literalClauses:a}},Q=e=>e.anchorMessageId!==void 0||!e.literalClauses.some(t=>t.field==="HasWords"),W=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}},j=(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},q=350,re=(e,t,r)=>{const a=b(F()),{mutateAsync:i}=a,n=W(t),[s,o]=m.useState(()=>({})),d=m.useRef(t);d.current=t;const l=m.useRef(n),c=Q(t);return m.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(p=>{l.current===u&&o({count:p.matchedCount,matchedIds:p.messageIds,previewedSignature:u})}).catch(p=>{l.current===u&&o(g=>({...g,error:p instanceof Error?p.message:"Couldn't count matches.",errorSignature:u}))})},q);return()=>clearTimeout(f)},[e,c,n,s.previewedSignature,s.errorSignature,i]),c?{count:j(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=m.useCallback((o,d,l)=>{e&&a({path:{accountId:e},body:S(o,d,l)})},[e,a]),s=m.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:m.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,G as j,V as k,ee as n,X as o,O as p,U as r,re as u};
@@ -0,0 +1 @@
1
+ import{d as L,c7 as d,u as n,f as l,c8 as p,r as u,c9 as c,ca as y,cb as g}from"./index-FpwHnbdV.js";const o=e=>c({path:{accountId:e}}),P=e=>{const r=L({...d({path:{accountId:e??""}}),enabled:!!e});return{labels:r.data?.items??[],isPending:r.isPending,isError:r.isError,error:r.error,refetch:r.refetch}},m=e=>{const r=n(),t=l({...p(),onSuccess:()=>{e&&r.invalidateQueries({queryKey:o(e)})}}),{mutateAsync:s}=t;return{createLabel:u.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({...y(),onSuccess:()=>{e&&r.invalidateQueries({queryKey:o(e)})}}),{mutate:s}=t;return{updateLabel:u.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:o(e)})}}),{mutate:s}=t;return{deleteLabel:u.useCallback(a=>{e&&s({path:{accountId:e,labelId:a}})},[e,s]),isPending:t.isPending,deletingLabelId:t.isPending?t.variables?.path.labelId:void 0}};export{P as a,h as b,C as c,m as u};
@@ -0,0 +1 @@
1
+ import{r as c,ad as M,ci as S,c5 as O,D as h,cj as P,l as B,P as U,u as D,d as F,cF as N,cG as $}from"./index-FpwHnbdV.js";const w="/mail/brief/compose/{-$outboxMessageId}",R="/mail/flagged/compose/{-$outboxMessageId}",E="/mail/outbox/compose/{-$outboxMessageId}",k="/mail/$mailboxId/compose/{-$outboxMessageId}";function T(){const e=h({from:w,shouldThrow:!1}),t=h({from:R,shouldThrow:!1}),r=h({from:E,shouldThrow:!1}),s=h({from:k,shouldThrow:!1});return e??t??r??s}function j(){return T()!==void 0}function z(){return T()?.outboxMessageId}function L(e,t,r){return e==="flagged"?{to:R,params:{outboxMessageId:r}}:e==="outbox"?{to:E,params:{outboxMessageId:r}}:e==="mailbox"&&t?{to:k,params:{mailboxId:t,outboxMessageId:r}}:{to:w,params:{outboxMessageId:r}}}function b(){const e=M(),t=S(),{list:r,mailboxId:s}=O();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 Y(){const e=b();return c.useCallback(()=>e(void 0),[e])}function J(){const e=b();return c.useCallback(t=>e(t),[e])}function V(){const e=b();return c.useCallback(t=>e(t,{replace:!0,keepPanels:!0}),[e])}function Z(){return P()}const v=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},g={all:["messages"],detail:e=>[...g.all,"detail",e],body:e=>[...g.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 _=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",q=(e,t)=>{const r=t?.trim()??"";return e===401?"auth":e===403?r.length>0?"auth":"body-missing":e===404?"body-missing":"generic"},I=(e,t)=>(t??"").toLowerCase().startsWith("text/html")?/<div\s+id=["']root["']/i.test(e):!1,X=(e,t)=>{const r=(t??"").toLowerCase();return!!(e==="text"&&r.startsWith("text/html"))},G=async(e,t,r=async()=>null)=>{const s={},n=await r();n&&(s.Authorization=`Bearer ${n}`);const o=await $(e,{headers:s});if(o.status===202)throw new f("not-ready","Message body is still syncing",202,_(o.headers.get("Retry-After")));if(!o.ok){const l=o.headers.get(Q),m=q(o.status,l);throw new f(m,`Failed to load message body (${o.status} ${o.statusText})`,o.status)}const a=o.headers.get("content-type");if(X(t,a))throw new f("content-type-mismatch",`Refusing to render message body — expected ${t}, got Content-Type ${a}`);const y=await o.text();if(I(y,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 y},H=async(e,t)=>(t.isRetryAfterNotReady&&await e.refetchDescribeMessage(),e.fetchContent(t.contentUrl,t.kind)),ee=({messageId:e,bodyParts:t,enabled:r=!0})=>{const s=t?v(t):null,n=B(),{getToken:o}=U(),a=c.useRef(null),y=D(),l=c.useRef(!1),m=c.useRef(null),C=e&&s?`${e}:${s.contentUrl}`:null;m.current!==C&&(m.current=C,l.current=!1);const i=F({queryKey:e?[...g.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,H({fetchContent:(u,A)=>G(u,A,o),refetchDescribeMessage:()=>y.refetchQueries({queryKey:N({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;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 x=i.data&&s?{kind:s.kind,body:i.data}:void 0;return{picked:s,data:x,isLoading:p,isError:i.isError,error:i.error,refetch:i.refetch}};export{f as B,j as a,z as b,J as c,ee as d,V as e,Z as f,q as g,Y as u};
@@ -1 +1 @@
1
- import{cC as Q,cD as y,cE as w,cF as S,cG as C,w as k,cH as M,cI as q,r as p,cJ as x,cK as H,cL as L,cM as P,cN as v,cO as B,cP as A}from"./index--jDmBhH5.js";function R(r,e){const s=new Set(e);return r.filter(t=>!s.has(t))}function I(r,e,s){const t=r.slice(0);return t[e]=s,t}var T=class extends Q{#i;#e;#n;#r;#s;#t;#o;#u;#h;#c=[];constructor(r,e,s){super(),this.#i=r,this.#r=s,this.#n=[],this.#s=[],this.#e=[],this.setQueries(e)}onSubscribe(){this.listeners.size===1&&this.#s.forEach(r=>{r.subscribe(e=>{this.#d(r,e)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#s.forEach(r=>{r.destroy()})}setQueries(r,e){this.#n=r,this.#r=e,y.batch(()=>{const s=this.#s,t=this.#f(this.#n);t.forEach(o=>o.observer.setOptions(o.defaultedQueryOptions));const i=t.map(o=>o.observer),n=i.map(o=>o.getCurrentResult()),u=s.length!==i.length,a=i.some((o,d)=>o!==s[d]),f=u||a,b=f?!0:n.some((o,d)=>{const g=this.#e[d];return!g||!w(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=S(this.#t,e(r))),this.#t}return r}#b(){return this.#r?.combine!==void 0&&this.#s.some((r,e)=>r.options.suspense&&this.#e[e]?.data===void 0)}#f(r){const e=new Map;this.#s.forEach(t=>{const i=t.options.queryHash;if(!i)return;const n=e.get(i);n?n.push(t):e.set(i,[t])});const s=[];return r.forEach(t=>{const i=this.#i.defaultQueryOptions(t),u=e.get(i.queryHash)?.shift()??new C(this.#i,i);s.push({defaultedQueryOptions:i,observer:u})}),s}#d(r,e){const s=this.#s.indexOf(r);s!==-1&&(this.#e=I(this.#e,s,e),this.#p())}#p(){if(this.hasListeners()){const r=this.#a(this.#e,this.#c),e=this.#b(),s=this.#t,t=e?s:this.#l(r,this.#r?.combine);(e||s!==t)&&y.batch(()=>{this.listeners.forEach(i=>{i(this.#e)})})}}};function D({queries:r,...e},s){const t=k(),i=M(),n=q(),u=p.useMemo(()=>r.map(h=>{const c=t.defaultQueryOptions(h);return c._optimisticResults=i?"isRestoring":"optimistic",c}),[r,t,i]);u.forEach(h=>{x(h);const c=t.getQueryCache().get(h.queryHash);H(h,n,c)}),L(n);const[a]=p.useState(()=>new T(t,u,e)),[f,b,o]=a.getOptimisticResult(u,e.combine),d=!i&&e.subscribed!==!1;p.useSyncExternalStore(p.useCallback(h=>d?a.subscribe(y.batchCalls(h)):P,[a,d]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),p.useEffect(()=>{a.setQueries(u,e)},[u,e,a]);const m=f.some((h,c)=>v(u[c],h))?f.flatMap((h,c)=>{const l=u[c];if(l&&v(l,h)){const E=new C(t,l);return B(l,E,n)}return[]}):[];if(m.length>0)throw Promise.all(m);const O=f.find((h,c)=>{const l=u[c];return l&&A({result:h,errorResetBoundary:n,throwOnError:l.throwOnError,query:t.getQueryCache().get(l.queryHash),suspense:l.suspense})});if(O?.error)throw O.error;return b(o())}export{D as u};
1
+ import{cH as E,cI as y,cJ as S,cK as w,cL as C,u as k,cM as M,cN as q,r as p,cO as x,cP as H,cQ as L,cR as P,cS as R,cT as B,cU as T}from"./index-FpwHnbdV.js";function v(r,e){const s=new Set(e);return r.filter(t=>!s.has(t))}function A(r,e,s){const t=r.slice(0);return t[e]=s,t}var I=class extends E{#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&&(v(s,i).forEach(o=>{o.destroy()}),v(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=A(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 z({queries:r,...e},s){const t=k(),i=M(),n=q(),u=p.useMemo(()=>r.map(h=>{const c=t.defaultQueryOptions(h);return c._optimisticResults=i?"isRestoring":"optimistic",c}),[r,t,i]);u.forEach(h=>{x(h);const c=t.getQueryCache().get(h.queryHash);H(h,n,c)}),L(n);const[a]=p.useState(()=>new I(t,u,e)),[f,b,o]=a.getOptimisticResult(u,e.combine),d=!i&&e.subscribed!==!1;p.useSyncExternalStore(p.useCallback(h=>d?a.subscribe(y.batchCalls(h)):P,[a,d]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),p.useEffect(()=>{a.setQueries(u,e)},[u,e,a]);const m=f.some((h,c)=>R(u[c],h))?f.flatMap((h,c)=>{const l=u[c];if(l&&R(l,h)){const Q=new C(t,l);return B(l,Q,n)}return[]}):[];if(m.length>0)throw Promise.all(m);const O=f.find((h,c)=>{const l=u[c];return l&&T({result:h,errorResetBoundary:n,throwOnError:l.throwOnError,query:t.getQueryCache().get(l.queryHash),suspense:l.suspense})});if(O?.error)throw O.error;return b(o())}export{z as u};
@@ -0,0 +1 @@
1
+ import{j as E,t as Q,p as W,a as U,r as o,aM as R,u as N,Q as $,l as z,a8 as B,a9 as G,aa as I,ab as X}from"./index-FpwHnbdV.js";import{C as V}from"./circle-check-big-SYJDr4tY.js";import{R as J,i as Y,t as Z}from"./search-token-index-C9KNJC5_.js";import{u as L}from"./useQueries-Dx2PHSps.js";function Se({state:e,onRefresh:s,label:t,errorMessage:r,hasUpdate:a,size:u="sm",className:c}){const i=e==="refreshing",n=e==="error",h=e==="success",y=n?E.jsx(Q,{className:"size-4 text-danger"}):h?E.jsx(V,{className:"size-4 text-positive"}):E.jsx(J,{className:W("size-4",i&&"animate-spin")}),w=n?`${t} — failed: ${r??"try again"}`:i?`${t} — refreshing`:h?`${t} — up to date`:a?`${t} — new mail`:t;return E.jsxs("div",{className:"relative inline-flex",children:[E.jsx(U,{variant:"ghost",size:u,icon:y,onClick:s,disabled:i,"aria-label":w,"aria-busy":i||void 0,title:n?r:t,className:c}),e==="idle"&&a&&E.jsx("span",{"aria-hidden":"true",className:"absolute right-1 top-1 size-1.5 rounded-full bg-accent-2"})]})}const ee=new Set(["discovering_mailboxes","syncing_inbox","syncing_others"]);function P(e){return!!e&&ee.has(e)}const F=3e3,te=F*2,T={syncing:!1,resolved:!1,synced:0,total:0};function we(e,s){const t=e.join(","),[r,a]=o.useState(!1),[u,c]=o.useState(!1);o.useEffect(()=>{a(!1),c(!1)},[t,s]),o.useEffect(()=>{if(!s)return;const m=setTimeout(()=>c(!0),te);return()=>clearTimeout(m)},[t,s]);const i=L({queries:e.map(m=>({...R({path:{accountId:m}}),enabled:s&&!r,refetchInterval:F,meta:{softError:!0}}))}),n=i.every(m=>m.isSuccess||m.isError),h=i.length===0||n||u;let y=!1,w=0,S=0;for(const m of i)if(P(m.data?.syncPhase)){y=!0;for(const l of m.data?.mailboxes??[])w+=l.messagesSynced,S+=l.messagesTotal}const x=s&&h&&!y;return o.useEffect(()=>{x&&a(!0)},[x]),!s||!h?T:{syncing:y,resolved:!0,synced:w,total:S}}const se=180*1e3,xe=30*1e3;let q=0;const M=new Set,ne=(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,re=new Set(["sent","drafts","trash","archive"]),C=(e,s)=>{const t=new Map;for(const r of e){const a=s.get(r.mailboxId)?.role;a&&re.has(a)||t.set(r.mailboxId,r.messagesTotal)}return t},j=(e,s)=>{const t=[];for(const[r,a]of s)a>(e.get(r)??0)&&t.push(r);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=N(),{resultFolderIndex:r}=$(),a=o.useRef(new Map),u=o.useRef(new Set),c=o.useRef(new Map),[i,n]=o.useState(new Set),h=L({queries:e.map(l=>({...R({path:{accountId:l}}),refetchInterval:_,staleTime:_,meta:{softError:!0}}))}),y=h.map(l=>l.dataUpdatedAt).join(","),w=e.join(",");o.useEffect(()=>{let l=!1;const f=new Set(i);e.forEach((d,p)=>{const b=h[p]?.data;if(!b)return;const g=C(b.mailboxes??[],r),k=c.current.get(d);if(c.current.set(d,g),k){const A=j(k,g);A.length>0&&Y(t,Z(A))}if(!u.current.has(d)){u.current.add(d),a.current.set(d,g);return}if(f.has(d))return;const K=a.current.get(d)??new Map;oe(K,g)&&(f.add(d),l=!0)}),l&&n(f)},[w,y]);const S=o.useCallback(l=>l.some(f=>i.has(f)),[i]),x=o.useCallback(l=>{n(f=>{if(l.every(p=>!f.has(p)))return f;const d=new Set(f);for(const p of l)d.delete(p);return d});for(const f of l){const d=t.getQueryData(R({path:{accountId:f}}).queryKey);a.current.set(f,C(d?.mailboxes??[],r)),u.current.add(f)}},[t,r]),m=o.useMemo(()=>({hasNewMail:S,acknowledge:x}),[S,x]);return E.jsx(D.Provider,{value:m,children:s})}const ie=2e3,ce=45e3,ue=e=>new Promise(s=>setTimeout(s,e)),v=e=>e instanceof Error&&e.message?e.message:"Something went wrong",le=e=>{I(e,{softError:!0},"user")&&X(e)},O=(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:r=0,onInboxSynced:a,deadline:u,pollMs:c=ie})=>{let i=!1;for(;;){const n=await s().then(S=>({ok:!0,data:S})).catch(S=>({ok:!1,error:S}));if(!n.ok)return{accountId:e,message:v(n.error)};const{syncPhase:h,lastSyncAt:y}=n.data;if((y??0)>t&&!P(h))return h==="error"?{accountId:e,message:"Sync failed for this account"}:void 0;if(!i&&H(n.data)>r&&(i=!0,a?.()),Date.now()>=u)return{accountId:e,message:"Refresh is taking longer than usual"};await ue(c)}},de=async(e,s,t,r,a)=>{const u=await O(e,t).then(n=>({ok:!0,lastSyncAt:n.lastSyncAt??0,inboxSyncedAt:H(n)})).catch(n=>({ok:!1,error:n}));if(!u.ok)return{accountId:t,enqueued:!1,ok:!1,message:v(u.error)};const c=await B({path:{accountId:t},throwOnError:!0}).then(()=>({ok:!0})).catch(n=>({ok:!1,error:n}));if(!c.ok)return le(c.error),{accountId:t,enqueued:!1,ok:!1,message:v(c.error)};s.recordEvent("sync.triggered");const i=await fe({accountId:t,readStatus:()=>O(e,t),baselineLastSyncAt:u.lastSyncAt,baselineInboxSyncedAt:u.inboxSyncedAt,onInboxSynced:()=>a(t),deadline:r});return i?{accountId:t,enqueued:!0,ok:!1,message:i.message}:{accountId:t,enqueued:!0,ok:!0}},Re=(e,s={})=>{const t=N(),r=z(),{acknowledge:a}=ae(),[u,c]=o.useState("idle"),[i,n]=o.useState(),h=o.useRef(0),y=o.useRef(e);y.current=e;const w=o.useRef(s);w.current=s,o.useEffect(()=>{if(u!=="success")return;const x=setTimeout(()=>c("idle"),2e3);return()=>clearTimeout(x)},[u]);const S=o.useCallback(()=>{const x=y.current;if(x.length===0){c("error"),n("Nothing to refresh yet");return}const m=++h.current;c("refreshing"),n(void 0),ne();const l=f=>{h.current===m&&(t.invalidateQueries({queryKey:G({path:{accountId:f}})}),w.current.onSettled?.())};(async()=>{const f=Date.now()+ce,d=await Promise.all(x.map(g=>de(t,r,g,f,l)));if(h.current!==m)return;const p=d.filter(g=>g.enqueued).map(g=>g.accountId);for(const g of p)l(g);p.length>0&&a(p);const b=d.filter(g=>!g.ok);b.length===0?c("success"):(c("error"),n(b[0]?.message))})()},[a,t,r]);return{state:u,errorMessage:i,refresh:S}};export{xe as H,be as M,Se as R,Re as a,P as b,we as c,pe as i,Ee as s,ae as u};
@@ -1,4 +1,4 @@
1
- import{ck as V,r as g,j as a,b,I as Q,w as Y,ai as q,ak as X,al as Z,cA as J,bx as ee,t as te,e as se,X as re,bN as R,v as ne,c0 as ae}from"./index--jDmBhH5.js";import{K as k}from"./kbd-faCJijM9.js";import{B as oe,d as ie}from"./useMessageBodyContent-C0DuC9W1.js";import{i as ce}from"./search-scope-DTcpOp3S.js";const le=(e,t)=>{const r=e==="newsletter"||e==="marketing"||t;return{framed:r,isPlain:!r}},de=()=>`
1
+ import{cp as V,r as g,j as a,p as b,I as Q,u as Y,ar as q,f as X,at as Z,cF as J,bD as ee,P as te,t as se,X as re,bS as R,Q as ne,c5 as ae}from"./index-FpwHnbdV.js";import{K as k}from"./kbd-tXno4rYH.js";import{B as oe,d as ie}from"./useMessageBodyContent-BOBb68Px.js";import{i as ce}from"./search-scope-DTcpOp3S.js";const le=(e,t)=>{const r=e==="newsletter"||e==="marketing"||t;return{framed:r,isPlain:!r}},de=()=>`
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 {
@@ -53,14 +53,14 @@ pre, code {
53
53
  :is(pre, code, pre *, code *):is([nowrap], [style*="nowrap" i]) {
54
54
  white-space: pre-wrap !important;
55
55
  }
56
- `,ue=e=>{const t=new Map;for(const s of e){if(!s.contentId||s.contentUrl.length===0)continue;const r=s.contentId.replace(/^<|>$/g,"");t.set(r,s.contentUrl)}return s=>t.get(s.replace(/^<|>$/g,""))},me=/^(none|transparent|inherit|initial|unset)\s*$/i,_=e=>{const t=[],s=/<style[^>]*>([\s\S]*?)<\/style>/gi;let r;for(r=s.exec(e);r!==null;)t.push(r[1]),r=s.exec(e);return t},fe=e=>{const t=/background(?:-color)?\s*:\s*([^;}\n]+)/gi;let s;for(s=t.exec(e);s!==null;){const r=s[1].trim();if(!me.test(r))return!0;s=t.exec(e)}return!1},he=e=>{if(/\bstyle\s*=\s*["'][^"']*background/i.test(e)||/\bbgcolor\s*=/i.test(e))return!0;for(const t of _(e))if(fe(t))return!0;return!1},ge=new Set(["auto","none","initial","inherit","unset","revert","revert-layer"]),pe=new RegExp(`(?<![-\\w])(?:padding|margin)(?:-(top|right|bottom|left|block|inline)(?:-(?:start|end))?)?\\s*:\\s*([^;}"']+)`,"gi"),be=new Set(["top","bottom","block"]),B=e=>e.replace(/\/\*[\s\S]*?\*\//g,""),E=e=>{const t=e.toLowerCase();if(!t||ge.has(t)||t.startsWith("-"))return!1;const s=/^\+?(\d*\.?\d+)[a-z%]*$/.exec(t);return s?Number.parseFloat(s[1])!==0:!0},ye=e=>{const t=e.split(/\s+/).filter(Boolean);return t.length<2?t:t.length<4?[t[1]]:[t[1],t[3]]},xe=(e,t)=>{if(e&&be.has(e))return!1;const s=t.replace(/!\s*important/gi,"").trim();return s?e?s.split(/\s+/).some(E):ye(s).some(E):!1},T=e=>{for(const t of B(e).matchAll(pe))if(xe(t[1],t[2]))return!0;return!1},I=new Set(["blockquote"]),we=e=>e.replace(/<!--[\s\S]*?-->/g,""),ve=e=>{const t=[],s=/<([a-zA-Z][\w:-]*)((?:"[^"]*"|'[^']*'|[^>"'])*)>/g,r=/\bstyle\s*=\s*(?:"([^"]*)"|'([^']*)')/gi;for(const[,n,o]of e.matchAll(s))for(const l of o.matchAll(r))t.push({tag:n.toLowerCase(),style:l[1]??l[2]??""});return t},ke=e=>[...B(e).matchAll(/([^{}]*)\{([^{}]*)\}/g)].map(t=>({selector:t[1].trim(),body:t[2]})),Ae=e=>{const t=e.trim().split(/[\s>+~]+/).pop()??"";return(/^[a-zA-Z][\w-]*/.exec(t)?.[0]??"").toLowerCase()},Se=e=>e.split(",").every(t=>I.has(Ae(t))),Ee=e=>{const t=_(e),s=we(e);if(/\bcellpadding\s*=\s*["']?(?!0["'\s>])\d/i.test(s))return!0;for(const{tag:r,style:n}of ve(s))if(!I.has(r)&&T(n))return!0;for(const r of t)for(const n of ke(r))if(!Se(n.selector)&&T(n.body))return!0;return!1},Te=["script","iframe","object","embed","form","input","button","textarea","select","meta","link","base"],Ne=["onerror","onload","onclick","onmouseover","onmouseout","onfocus","onblur","onsubmit","onkeydown","onkeyup","formaction","xlink:href","data-bind"],Ce="data:image/svg+xml,"+encodeURIComponent(`
56
+ `,ue=e=>{const t=new Map;for(const s of e){if(!s.contentId||s.contentUrl.length===0)continue;const r=s.contentId.replace(/^<|>$/g,"");t.set(r,s.contentUrl)}return s=>t.get(s.replace(/^<|>$/g,""))},me=/^(none|transparent|inherit|initial|unset)\s*$/i,_=e=>{const t=[],s=/<style[^>]*>([\s\S]*?)<\/style>/gi;let r;for(r=s.exec(e);r!==null;)t.push(r[1]),r=s.exec(e);return t},fe=e=>{const t=/background(?:-color)?\s*:\s*([^;}\n]+)/gi;let s;for(s=t.exec(e);s!==null;){const r=s[1].trim();if(!me.test(r))return!0;s=t.exec(e)}return!1},he=e=>{if(/\bstyle\s*=\s*["'][^"']*background/i.test(e)||/\bbgcolor\s*=/i.test(e))return!0;for(const t of _(e))if(fe(t))return!0;return!1},ge=new Set(["auto","none","initial","inherit","unset","revert","revert-layer"]),pe=new RegExp(`(?<![-\\w])(?:padding|margin)(?:-(top|right|bottom|left|block|inline)(?:-(?:start|end))?)?\\s*:\\s*([^;}"']+)`,"gi"),be=new Set(["top","bottom","block"]),B=e=>e.replace(/\/\*[\s\S]*?\*\//g,""),E=e=>{const t=e.toLowerCase();if(!t||ge.has(t)||t.startsWith("-"))return!1;const s=/^\+?(\d*\.?\d+)[a-z%]*$/.exec(t);return s?Number.parseFloat(s[1])!==0:!0},ye=e=>{const t=e.split(/\s+/).filter(Boolean);return t.length<2?t:t.length<4?[t[1]]:[t[1],t[3]]},xe=(e,t)=>{if(e&&be.has(e))return!1;const s=t.replace(/!\s*important/gi,"").trim();return s?e?s.split(/\s+/).some(E):ye(s).some(E):!1},T=e=>{for(const t of B(e).matchAll(pe))if(xe(t[1],t[2]))return!0;return!1},I=new Set(["blockquote"]),we=e=>e.replace(/<!--[\s\S]*?-->/g,""),ve=e=>{const t=[],s=/<([a-zA-Z][\w:-]*)((?:"[^"]*"|'[^']*'|[^>"'])*)>/g,r=/\bstyle\s*=\s*(?:"([^"]*)"|'([^']*)')/gi;for(const[,n,o]of e.matchAll(s))for(const l of o.matchAll(r))t.push({tag:n.toLowerCase(),style:l[1]??l[2]??""});return t},ke=e=>[...B(e).matchAll(/([^{}]*)\{([^{}]*)\}/g)].map(t=>({selector:t[1].trim(),body:t[2]})),Se=e=>{const t=e.trim().split(/[\s>+~]+/).pop()??"";return(/^[a-zA-Z][\w-]*/.exec(t)?.[0]??"").toLowerCase()},Ae=e=>e.split(",").every(t=>I.has(Se(t))),Ee=e=>{const t=_(e),s=we(e);if(/\bcellpadding\s*=\s*["']?(?!0["'\s>])\d/i.test(s))return!0;for(const{tag:r,style:n}of ve(s))if(!I.has(r)&&T(n))return!0;for(const r of t)for(const n of ke(r))if(!Ae(n.selector)&&T(n.body))return!0;return!1},Te=["script","iframe","object","embed","form","input","button","textarea","select","meta","link","base"],Ne=["onerror","onload","onclick","onmouseover","onmouseout","onfocus","onblur","onsubmit","onkeydown","onkeyup","formaction","xlink:href","data-bind"],Ce="data:image/svg+xml,"+encodeURIComponent(`
57
57
  <svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100">
58
58
  <rect fill="#f0f0f0" width="100" height="100"/>
59
59
  <text x="50" y="50" text-anchor="middle" dy=".3em" fill="#999" font-size="12">
60
60
  Image blocked
61
61
  </text>
62
62
  </svg>
63
- `),je=e=>e.replace(/url\s*\([^)]*\)/gi,"none").replace(/expression\s*\([^)]*\)/gi,"").replace(/-moz-binding\s*:[^;]*/gi,""),Le=e=>e.replace(/@import[^;]*;/gi,"/* @import blocked */").replace(/url\s*\([^)]*\)/gi,"none").replace(/expression\s*\([^)]*\)/gi,"").replace(/-moz-binding\s*:[^;]*/gi,""),Re=(e={})=>{const t=V(),s={FORBID_TAGS:Te,FORBID_ATTR:Ne,ALLOW_DATA_ATTR:!1,ALLOW_UNKNOWN_PROTOCOLS:!1};return t.addHook("afterSanitizeAttributes",r=>{if(r.tagName==="IMG"){const n=r.getAttribute("src")||"";if(n.startsWith("data:"))return;if(n.startsWith("cid:")){const l=n.slice(4).replace(/^<|>$/g,""),m=e.resolveCid?.(l);m&&(r.setAttribute("src",m),r.classList.add("inline-content"));return}e.allowExternalImages||(r.setAttribute("data-blocked-src",n),r.setAttribute("src",Ce),r.setAttribute("alt","[Blocked image]"),r.classList.add("blocked-image"))}if(r.tagName==="A"){const n=r.getAttribute("href")||"";if(/^(javascript|data):/i.test(n)){r.removeAttribute("href");return}r.setAttribute("target","_blank"),r.setAttribute("rel","noopener noreferrer nofollow"),r.classList.add("external-link")}if(r.hasAttribute("style")){const n=r.getAttribute("style")||"";r.setAttribute("style",je(n))}}),t.addHook("uponSanitizeElement",(r,n)=>{if(n.tagName==="style"){const o=r.textContent||"";r.textContent=Le(o)}}),r=>{const n=he(r),o=Ee(r),l=t.sanitize(r,s);return{html:`<style>${de()}</style>${l}`,hasAuthorBackground:n,hasAuthorSpacing:o}}},_e='"Geist Variable", "Geist", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',v={light:{fg:"oklch(0.3 0.025 235)",canvas:"oklch(0.96 0.015 90)",accent:"oklch(0.55 0.14 150)"},dark:{fg:"oklch(0.88 0.02 90)",canvas:"oklch(0.22 0.025 220)",accent:"oklch(0.78 0.16 150)"}},Be={background:!1,spacing:!1},Ie="16px",Me=()=>`html{padding:0}body{padding:${Ie};box-sizing:border-box}`,Oe=()=>"html{overflow:hidden}body{overflow-x:auto}",$e=/prefers-color-scheme\s*:\s*dark|color-scheme\s*:\s*[^;}"']*\bdark\b/i,De='<meta name="viewport" content="width=device-width, initial-scale=1">',ze=e=>{const t=e?v.dark:v.light;return`
63
+ `),je=e=>e.replace(/url\s*\([^)]*\)/gi,"none").replace(/expression\s*\([^)]*\)/gi,"").replace(/-moz-binding\s*:[^;]*/gi,""),Le=e=>e.replace(/@import[^;]*;/gi,"/* @import blocked */").replace(/url\s*\([^)]*\)/gi,"none").replace(/expression\s*\([^)]*\)/gi,"").replace(/-moz-binding\s*:[^;]*/gi,""),Re=(e={})=>{const t=V(),s={FORBID_TAGS:Te,FORBID_ATTR:Ne,ALLOW_DATA_ATTR:!1,ALLOW_UNKNOWN_PROTOCOLS:!1};return t.addHook("afterSanitizeAttributes",r=>{if(r.tagName==="IMG"){const n=r.getAttribute("src")||"";if(n.startsWith("data:"))return;if(n.startsWith("cid:")){const l=n.slice(4).replace(/^<|>$/g,""),m=e.resolveCid?.(l);m&&(r.setAttribute("src",m),r.classList.add("inline-content"));return}e.allowExternalImages||(r.setAttribute("data-blocked-src",n),r.setAttribute("src",Ce),r.setAttribute("alt","[Blocked image]"),r.classList.add("blocked-image"))}if(r.tagName==="A"){const n=r.getAttribute("href")||"";if(/^(javascript|data):/i.test(n)){r.removeAttribute("href");return}r.setAttribute("target","_blank"),r.setAttribute("rel","noopener noreferrer nofollow"),r.classList.add("external-link")}if(r.hasAttribute("style")){const n=r.getAttribute("style")||"";r.setAttribute("style",je(n))}}),t.addHook("uponSanitizeElement",(r,n)=>{if(n.tagName==="style"){const o=r.textContent||"";r.textContent=Le(o)}}),r=>{const n=he(r),o=Ee(r),l=t.sanitize(r,s);return{html:`<style>${de()}</style>${l}`,hasAuthorBackground:n,hasAuthorSpacing:o}}},_e='"Geist Variable", "Geist", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',v={light:{fg:"oklch(0.3 0.025 235)",canvas:"oklch(0.96 0.015 90)",accent:"oklch(0.55 0.14 150)"},dark:{fg:"oklch(0.88 0.02 90)",canvas:"oklch(0.22 0.025 220)",accent:"oklch(0.78 0.16 150)"}},Be={background:!1,spacing:!1},Ie="16px",Me=()=>`html{padding:0}body{padding:${Ie};box-sizing:border-box}`,Oe=()=>"html{overflow:hidden}body{overflow-x:auto}",De=/prefers-color-scheme\s*:\s*dark|color-scheme\s*:\s*[^;}"']*\bdark\b/i,$e='<meta name="viewport" content="width=device-width, initial-scale=1">',ze=e=>{const t=e?v.dark:v.light;return`
64
64
  /* Plain-email base: UI font-stack + theme-aware colors (#424) */
65
65
  html, body {
66
66
  font-family: ${_e};
@@ -81,4 +81,4 @@ a, a:visited {
81
81
  color: ${t.accent} !important;
82
82
  text-decoration: underline;
83
83
  }
84
- `},S="invert(0.92) hue-rotate(180deg)",N=`img,picture,video,svg,canvas,[style*='background-image'],[background]{filter:${S}}`,Pe=(e,t,s)=>{const r=e?v.dark.canvas:v.light.canvas;return s?e?t?`html,body{margin:0;background-color:${r};color-scheme:dark light}`:`html{margin:0;background-color:#ffffff;filter:${S}}body{margin:0}${N}`:"html,body{margin:0;background-color:#ffffff;color-scheme:light}":e?t?`html,body{margin:0;background-color:${r};color-scheme:dark light}`:`html{margin:0;background-color:${r}}body{margin:0;filter:${S}}${N}`:`html,body{margin:0;background-color:${r};color-scheme:light}`},Ke=(e,t,s,r=Be)=>{const n=t==="plain"?ze(s):Pe(s,$e.test(e),r.background),o=r.spacing?"":Me();return`${De}<style>${n}</style>${e}<style>${Oe()}${o}</style>`},Fe=5e4,He="allow-same-origin allow-popups allow-popups-to-escape-sandbox",Ue=(e,t,s)=>Math.min(Math.ceil(Math.max(e,t)),s),Ge=new Set(["Enter","Escape","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End"]),We=e=>e===" "?!1:e.length===1?!0:Ge.has(e),A=e=>{if(e.metaKey||e.ctrlKey||e.altKey||!We(e.key))return;const t=e.currentTarget??e.target,s=t?.defaultView?.parent;!s||s===t?.defaultView||s.dispatchEvent(new KeyboardEvent("keydown",{key:e.key,code:e.code,shiftKey:e.shiftKey,bubbles:!0,cancelable:!0}))},C=({html:e,variant:t="framed",isDark:s=!1,declares:r,className:n})=>{const o=g.useRef(null),[l,m]=g.useState(0),d=g.useMemo(()=>Ke(e,t,s,r),[e,t,s,r]);return g.useEffect(()=>{const c=o.current;if(!c)return;const f=()=>{const i=c.contentDocument;if(!i?.body)return;const x=i.documentElement,y=Ue(i.body.scrollHeight,x?.scrollHeight??0,Fe);m(w=>w===y?w:y)};let u,h;const p=()=>{f(),u?.disconnect(),u=void 0,h?.removeEventListener("keydown",A),h?.removeEventListener("load",f,!0),h=void 0;const i=c.contentDocument;i?.body&&(u=new ResizeObserver(f),u.observe(i.body),i.documentElement&&u.observe(i.documentElement),i.addEventListener("load",f,!0),i.fonts?.ready.then(f),i.addEventListener("keydown",A),h=i)};return c.addEventListener("load",p),()=>{c.removeEventListener("load",p),h?.removeEventListener("keydown",A),h?.removeEventListener("load",f,!0),u?.disconnect()}},[]),a.jsx("iframe",{ref:o,title:"Email content",sandbox:He,srcDoc:d,className:n,style:{width:"100%",border:"none",display:"block",height:l===0?"1px":`${l}px`,colorScheme:"normal"}})},j=()=>a.jsx("p",{className:"text-fg-muted text-sm italic",children:"This message has no body content."}),vt=({className:e,children:t})=>a.jsx("div",{className:b("[&_.message-body-frame]:-mx-2 lg:[&_.message-body-frame]:-mx-4",e),children:t}),Ve=({html:e,text:t,isDark:s=!1,category:r,allowImages:n=!1,resolveCid:o,className:l,renderBlockedNotice:m})=>{const d=g.useMemo(()=>!e||typeof document>"u"?null:Re({allowExternalImages:n,resolveCid:o})(e),[e,n,o]),c=d?.html??null,{framed:f,isPlain:u}=le(r,d?.hasAuthorBackground??!1),h=g.useMemo(()=>({background:d?.hasAuthorBackground??!1,spacing:d?.hasAuthorSpacing??!1}),[d?.hasAuthorBackground,d?.hasAuthorSpacing]),p=g.useMemo(()=>!c||n?0:(c.match(/data-blocked-src/g)||[]).length,[c,n]);return!c&&!t?a.jsx("div",{className:b("message-body",l),children:a.jsx(j,{})}):a.jsxs("div",{className:b("message-body",l),children:[p>0&&a.jsx("div",{children:m?.(p)}),c?a.jsx("div",{className:"message-body-frame",children:f?a.jsx("div",{className:"w-full max-w-full",children:a.jsx(C,{html:c,variant:"framed",isDark:s,declares:h})}):a.jsx("div",{className:"max-w-full lg:max-w-2xl",children:a.jsx(C,{html:c,variant:u?"plain":"framed",isDark:s,declares:h})})}):t?a.jsx("pre",{className:"email-text whitespace-pre-wrap text-sm leading-relaxed",children:t}):a.jsx(j,{})]})};function kt({message:e="Select a thread to read",icon:t,showHints:s=!0,className:r}){return a.jsxs("div",{className:b("flex flex-1 flex-col items-center justify-center text-center",r),children:[t??a.jsx(Q,{className:"size-10 text-fg-subtle"}),a.jsx("p",{className:"mt-3 text-sm text-fg-muted",children:e}),s&&a.jsxs("p",{className:"text-2xs text-fg-subtle",children:[a.jsx(k,{children:"j"})," / ",a.jsx(k,{children:"k"})," to move, ",a.jsx(k,{children:"Enter"})," to open"]})]})}function M(e){const t=[];let s=-1,r=!1;for(let n=0;n<e.length;n++){const o=e[n];if(o==='"'){r=!r,s<0&&(s=n);continue}if(!r&&/\s/.test(o)){s>=0&&t.push({raw:e.slice(s,n),start:s,end:n}),s=-1;continue}s<0&&(s=n)}return s>=0&&t.push({raw:e.slice(s),start:s,end:e.length}),t}const Qe=e=>{if(!e.startsWith('"'))return e;const t=e.slice(1);return t.endsWith('"')?t.slice(0,-1):t};function Ye(e){const t=e.indexOf(":");if(t<=0)return;const s=e.slice(t+1);return{name:e.slice(0,t).toLowerCase(),value:Qe(s),rawValue:s}}const qe=e=>/[\s"]/.test(e),Xe=e=>qe(e)?`"${e.replace(/"/g,"")}"`:e,At=(e,t)=>`${e}:${Xe(t)}`,O=(e,t=Date.now())=>({value:e,setAt:t}),Ze=(e,t,s,r)=>{if(e.addressId!==t)return e;const n={...e.flags??{}};return s?n.trusted=O(!0,r):delete n.trusted,{...e,flags:n}},Je=(e,t,s,r)=>{const n=o=>o.map(l=>Ze(l,t,s,r));return{...e,envelope:{...e.envelope,from:n(e.envelope.from),to:n(e.envelope.to),cc:n(e.envelope.cc),bcc:n(e.envelope.bcc),replyTo:n(e.envelope.replyTo)}}},et=({messageId:e})=>{const t=Y(),{pushError:s}=q(),{mutate:r,isPending:n,error:o,reset:l}=X({...ee(),onMutate:async d=>{const c=d.path.addressId,u=d.body.flags?.trusted?.value===!0,h=J({path:{messageId:e}});await t.cancelQueries({queryKey:h});const p=t.getQueriesData({queryKey:h}).filter(i=>i[1]!==void 0).map(([i,x])=>({queryKey:i,data:x}));return t.setQueriesData({queryKey:h},i=>i&&Je(i,c,u)),{describePrefix:h,previous:p}},onError:(d,c,f)=>{if(f)for(const u of f.previous)t.setQueryData(u.queryKey,u.data);s(Z("Couldn't trust sender","The change wasn't saved.",d))},onSettled:(d,c,f,u)=>{u&&t.invalidateQueries({queryKey:u.describePrefix})}});return{toggleTrusted:(d,c)=>{r({path:{addressId:d},body:{flags:{trusted:O(!c)}}})},isPending:n,error:o,reset:l}},tt=()=>{const[e,t]=g.useState(()=>typeof document<"u"&&document.documentElement.classList.contains("dark"));return g.useEffect(()=>{const s=document.documentElement,r=new MutationObserver(()=>{t(s.classList.contains("dark"))});return r.observe(s,{attributes:!0,attributeFilter:["class"]}),()=>r.disconnect()},[]),e},st=({blockedImageCount:e,canAlwaysTrust:t,isTrustPending:s,onLoadOnce:r,onAlwaysTrust:n})=>a.jsxs("div",{className:"mb-3 flex items-center justify-between rounded-md bg-surface-sunken/50 px-3 py-2 text-sm",children:[a.jsxs("span",{className:"text-fg-muted",children:[e," image",e>1?"s":""," blocked for privacy"]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("button",{type:"button",onClick:r,className:"text-accent hover:underline",children:"Load once"}),t&&a.jsx("button",{type:"button",onClick:n,"aria-busy":s,className:"text-accent hover:underline aria-busy:opacity-50",children:s?"Trusting…":"Always trust"})]})]}),rt=(e,t)=>{switch(e){case"auth":return{title:"Your session expired",detail:"Sign in again to reload the message body. Other parts of the app may also stop responding until you do."};case"body-missing":return{title:"Message body is missing in storage",detail:"A sync failure may have left this message without its body bytes. Contact support, or run the reconcile script to refetch from the upstream IMAP server."};case"content-type-mismatch":return{title:"Couldn't load message body",detail:"The server returned an unexpected content type for this part. The message body has not been rendered to keep you safe."};case"spa-shell-leak":return{title:"Couldn't load message body",detail:"The server returned the app shell instead of the message body. This is an infrastructure bug — please report it."};case"not-ready":return{title:"Message body is still syncing",detail:"This message's body hasn't finished downloading from the mail server yet. It should appear shortly — reopen the message to try again."};default:return{title:"Couldn't load message body",detail:t}}},nt=e=>e instanceof oe?e.reason:"generic",at=e=>e instanceof Error?e.message:typeof e=="string"?e:"An unexpected error occurred while loading the message body.",ot=({error:e,onRetry:t})=>{const s=nt(e),r=at(e),{title:n,detail:o}=rt(s,r),[l,m]=g.useState(!1),{Account:d}=te();return l?null:a.jsxs("div",{role:"alert","data-testid":"message-body-error-banner","data-reason":s,className:"flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-sm",children:[a.jsx(se,{className:"size-4 shrink-0 text-danger mt-0.5","aria-hidden":"true"}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"font-medium text-danger",children:n}),a.jsx("p",{className:"text-fg-muted mt-1 break-words",children:o})]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-3",children:[s==="auth"&&a.jsx(d,{children:({signOut:c})=>a.jsx("button",{type:"button",onClick:()=>c(),className:"text-sm font-medium text-accent hover:underline",children:"Sign in again"})}),t&&a.jsx("button",{type:"button",onClick:t,className:"text-sm font-medium text-accent hover:underline",children:"Retry"}),a.jsx("button",{type:"button",onClick:()=>m(!0),"aria-label":"Dismiss message body error",className:"rounded-md p-1 text-fg-muted hover:bg-surface-raised hover:text-fg transition-colors",children:a.jsx(re,{className:"size-4","aria-hidden":"true"})})]})]})},it=()=>a.jsxs("div",{className:"animate-pulse space-y-2",role:"status","aria-label":"Loading message body",children:[a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-full"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-11/12"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-3/4"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-5/6"})]}),L=()=>a.jsx("p",{className:"text-fg-muted text-sm italic",children:"This message has no body content."}),St=({bodyParts:e,html:t,text:s,isTrusted:r=!1,messageId:n,fromAddressId:o,category:l,className:m})=>{const[d,c]=g.useState(!1),f=r||d,u=tt(),{toggleTrusted:h,isPending:p}=et({messageId:n??""}),i=!!e&&e.length>0,{picked:x,data:y,isLoading:w,isError:D,error:z,refetch:P}=ie({messageId:n,bodyParts:e,enabled:i}),K=g.useMemo(()=>ue(e??[]),[e]),F=i&&y?.kind==="html"?y.body:t,H=i&&y?.kind==="text"?y.body:s;if(i){if(w)return a.jsx("div",{className:b("message-body",m),children:a.jsx(it,{})});if(D)return a.jsx("div",{className:b("message-body",m),children:a.jsx(ot,{error:z,onRetry:()=>P()})});if(!x)return a.jsx("div",{className:b("message-body",m),children:a.jsx(L,{})})}else if(!t&&!s)return a.jsx("div",{className:b("message-body",m),children:a.jsx(L,{})});const U=!!(o&&n),G=()=>{!o||p||(c(!0),h(o,!1))};return a.jsx(Ve,{className:m,html:F,text:H,isDark:u,category:l,allowImages:f,resolveCid:K,renderBlockedNotice:W=>a.jsx(st,{blockedImageCount:W,canAlwaysTrust:U,isTrustPending:p,onLoadOnce:()=>c(!0),onAlwaysTrust:G})})},$={personal:"Personal",uncategorized:"Unclassified",transactional:"Transactional",newsletter:"Newsletter",marketing:"Marketing",social:"Social",automated:"Automated"},ct=Object.values(R).map(e=>({value:e,label:$[e]})),lt={unclassified:"uncategorized"},dt=[{name:"from",label:"Sender",values:"contact"},{name:"subject",label:"Subject",values:"text"},{name:"category",label:"Category",values:"fixed",options:ct},{name:"is",label:"State",values:"fixed",options:[{value:"unread",label:"Unread"},{value:"read",label:"Read"},{value:"starred",label:"Starred"}]},{name:"has",label:"Contents",values:"fixed",options:[{value:"attachment",label:"Has attachment"}]},{name:"in",label:"Folder",values:"mailbox"},{name:"account",label:"Account",values:"account"},{name:"after",label:"Sent on or after",values:"date"},{name:"before",label:"Sent before",values:"date"}],ut=new Map(dt.map(e=>[e.name,e])),Et=e=>ut.get(e.toLowerCase()),mt=/^\d{4}-\d{2}-\d{2}$/;function ft(e,t,s){if(!mt.test(s))return;const r=Date.parse(`${s}T00:00:00Z`);if(!Number.isNaN(r))return{type:e,raw:t,value:s,epochSeconds:Math.floor(r/1e3)}}function ht(e){const t=e.toLowerCase(),s=lt[t];return s||Object.values(R).find(n=>n===t)}function gt(e,t){switch(t.toLowerCase()){case"unread":return{type:"isUnread",raw:e};case"read":return{type:"isRead",raw:e};case"starred":case"flagged":return{type:"isStarred",raw:e};default:return}}function pt(e,t){const s=Ye(e);if(!s||s.value.length===0)return;const{name:r,value:n}=s;switch(r){case"from":return{type:"from",raw:e,value:n};case"subject":return{type:"subject",raw:e,value:n};case"category":{const o=ht(n);return o?{type:"category",raw:e,value:n,category:o}:void 0}case"is":return gt(e,n);case"has":return n.toLowerCase()==="attachment"?{type:"hasAttachment",raw:e}:void 0;case"before":case"after":return ft(r,e,n);case"in":{const o=t.mailboxesByName?.get(n.toLowerCase());return o?{type:"in",raw:e,value:n,mailboxId:o}:void 0}case"account":{const o=t.accountsByName?.get(n.toLowerCase());return o?{type:"account",raw:e,value:n,accountId:o}:void 0}default:return}}function Tt(e,t={}){const s=[],r=[];for(const n of M(e)){const o=pt(n.raw,t);o?s.push(o):r.push(n.raw)}return{freeText:r.join(" "),tokens:s}}function Nt(e,t){return M(e).filter(s=>s.raw!==t.raw).map(s=>s.raw).join(" ")}function Ct(e){switch(e.type){case"from":return`From: ${e.value}`;case"subject":return`Subject: ${e.value}`;case"category":return`Category: ${$[e.category]}`;case"hasAttachment":return"Has attachment";case"isUnread":return"Unread";case"isRead":return"Read";case"isStarred":return"Starred";case"before":return`Before ${e.value}`;case"after":return`After ${e.value}`;case"in":return`In: ${e.value}`;case"account":return`Account: ${e.value}`}}function jt(){const{mailboxNameIndex:e,accountNameIndex:t}=ne(),s=ae();return{...ce(s)?{}:{mailboxesByName:e},accountsByName:t}}export{vt as M,kt as R,dt as S,M as a,Ye as b,Ve as c,et as d,St as e,Ct as f,Et as g,Tt as p,Nt as r,At as s,jt as u};
84
+ `},A="invert(0.92) hue-rotate(180deg)",N=`img,picture,video,svg,canvas,[style*='background-image'],[background]{filter:${A}}`,Pe=(e,t,s)=>{const r=e?v.dark.canvas:v.light.canvas;return s?e?t?`html,body{margin:0;background-color:${r};color-scheme:dark light}`:`html{margin:0;background-color:#ffffff;filter:${A}}body{margin:0}${N}`:"html,body{margin:0;background-color:#ffffff;color-scheme:light}":e?t?`html,body{margin:0;background-color:${r};color-scheme:dark light}`:`html{margin:0;background-color:${r}}body{margin:0;filter:${A}}${N}`:`html,body{margin:0;background-color:${r};color-scheme:light}`},Ke=(e,t,s,r=Be)=>{const n=t==="plain"?ze(s):Pe(s,De.test(e),r.background),o=r.spacing?"":Me();return`${$e}<style>${n}</style>${e}<style>${Oe()}${o}</style>`},Fe=5e4,He="allow-same-origin allow-popups allow-popups-to-escape-sandbox",Ue=(e,t,s)=>Math.min(Math.ceil(Math.max(e,t)),s),Ge=new Set(["Enter","Escape","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End"]),We=e=>e===" "?!1:e.length===1?!0:Ge.has(e),S=e=>{if(e.metaKey||e.ctrlKey||e.altKey||!We(e.key))return;const t=e.currentTarget??e.target,s=t?.defaultView?.parent;!s||s===t?.defaultView||s.dispatchEvent(new KeyboardEvent("keydown",{key:e.key,code:e.code,shiftKey:e.shiftKey,bubbles:!0,cancelable:!0}))},C=({html:e,variant:t="framed",isDark:s=!1,declares:r,className:n})=>{const o=g.useRef(null),[l,m]=g.useState(0),d=g.useMemo(()=>Ke(e,t,s,r),[e,t,s,r]);return g.useEffect(()=>{const c=o.current;if(!c)return;const f=()=>{const i=c.contentDocument;if(!i?.body)return;const x=i.documentElement,y=Ue(i.body.scrollHeight,x?.scrollHeight??0,Fe);m(w=>w===y?w:y)};let u,h;const p=()=>{f(),u?.disconnect(),u=void 0,h?.removeEventListener("keydown",S),h?.removeEventListener("load",f,!0),h=void 0;const i=c.contentDocument;i?.body&&(u=new ResizeObserver(f),u.observe(i.body),i.documentElement&&u.observe(i.documentElement),i.addEventListener("load",f,!0),i.fonts?.ready.then(f),i.addEventListener("keydown",S),h=i)};return c.addEventListener("load",p),()=>{c.removeEventListener("load",p),h?.removeEventListener("keydown",S),h?.removeEventListener("load",f,!0),u?.disconnect()}},[]),a.jsx("iframe",{ref:o,title:"Email content",sandbox:He,srcDoc:d,className:n,style:{width:"100%",border:"none",display:"block",height:l===0?"1px":`${l}px`,colorScheme:"normal"}})},j=()=>a.jsx("p",{className:"text-fg-muted text-sm italic",children:"This message has no body content."}),vt=({className:e,children:t})=>a.jsx("div",{className:b("[&_.message-body-frame]:-mx-2 lg:[&_.message-body-frame]:-mx-4",e),children:t}),Ve=({html:e,text:t,isDark:s=!1,category:r,allowImages:n=!1,resolveCid:o,className:l,renderBlockedNotice:m})=>{const d=g.useMemo(()=>!e||typeof document>"u"?null:Re({allowExternalImages:n,resolveCid:o})(e),[e,n,o]),c=d?.html??null,{framed:f,isPlain:u}=le(r,d?.hasAuthorBackground??!1),h=g.useMemo(()=>({background:d?.hasAuthorBackground??!1,spacing:d?.hasAuthorSpacing??!1}),[d?.hasAuthorBackground,d?.hasAuthorSpacing]),p=g.useMemo(()=>!c||n?0:(c.match(/data-blocked-src/g)||[]).length,[c,n]);return!c&&!t?a.jsx("div",{className:b("message-body",l),children:a.jsx(j,{})}):a.jsxs("div",{className:b("message-body",l),children:[p>0&&a.jsx("div",{children:m?.(p)}),c?a.jsx("div",{className:"message-body-frame",children:f?a.jsx("div",{className:"w-full max-w-full",children:a.jsx(C,{html:c,variant:"framed",isDark:s,declares:h})}):a.jsx("div",{className:"max-w-full lg:max-w-2xl",children:a.jsx(C,{html:c,variant:u?"plain":"framed",isDark:s,declares:h})})}):t?a.jsx("pre",{className:"email-text whitespace-pre-wrap text-sm leading-relaxed",children:t}):a.jsx(j,{})]})};function kt({message:e="Select a thread to read",icon:t,showHints:s=!0,className:r}){return a.jsxs("div",{className:b("flex flex-1 flex-col items-center justify-center text-center",r),children:[t??a.jsx(Q,{className:"size-10 text-fg-subtle"}),a.jsx("p",{className:"mt-3 text-sm text-fg-muted",children:e}),s&&a.jsxs("p",{className:"text-2xs text-fg-subtle",children:[a.jsx(k,{children:"j"})," / ",a.jsx(k,{children:"k"})," to move, ",a.jsx(k,{children:"Enter"})," to open"]})]})}function M(e){const t=[];let s=-1,r=!1;for(let n=0;n<e.length;n++){const o=e[n];if(o==='"'){r=!r,s<0&&(s=n);continue}if(!r&&/\s/.test(o)){s>=0&&t.push({raw:e.slice(s,n),start:s,end:n}),s=-1;continue}s<0&&(s=n)}return s>=0&&t.push({raw:e.slice(s),start:s,end:e.length}),t}const Qe=e=>{if(!e.startsWith('"'))return e;const t=e.slice(1);return t.endsWith('"')?t.slice(0,-1):t};function Ye(e){const t=e.indexOf(":");if(t<=0)return;const s=e.slice(t+1);return{name:e.slice(0,t).toLowerCase(),value:Qe(s),rawValue:s}}const qe=e=>/[\s"]/.test(e),Xe=e=>qe(e)?`"${e.replace(/"/g,"")}"`:e,St=(e,t)=>`${e}:${Xe(t)}`,O=(e,t=Date.now())=>({value:e,setAt:t}),Ze=(e,t,s,r)=>{if(e.addressId!==t)return e;const n={...e.flags??{}};return s?n.trusted=O(!0,r):delete n.trusted,{...e,flags:n}},Je=(e,t,s,r)=>{const n=o=>o.map(l=>Ze(l,t,s,r));return{...e,envelope:{...e.envelope,from:n(e.envelope.from),to:n(e.envelope.to),cc:n(e.envelope.cc),bcc:n(e.envelope.bcc),replyTo:n(e.envelope.replyTo)}}},et=({messageId:e})=>{const t=Y(),{pushError:s}=q(),{mutate:r,isPending:n,error:o,reset:l}=X({...ee(),onMutate:async d=>{const c=d.path.addressId,u=d.body.flags?.trusted?.value===!0,h=J({path:{messageId:e}});await t.cancelQueries({queryKey:h});const p=t.getQueriesData({queryKey:h}).filter(i=>i[1]!==void 0).map(([i,x])=>({queryKey:i,data:x}));return t.setQueriesData({queryKey:h},i=>i&&Je(i,c,u)),{describePrefix:h,previous:p}},onError:(d,c,f)=>{if(f)for(const u of f.previous)t.setQueryData(u.queryKey,u.data);s(Z("Couldn't trust sender","The change wasn't saved.",d))},onSettled:(d,c,f,u)=>{u&&t.invalidateQueries({queryKey:u.describePrefix})}});return{toggleTrusted:(d,c)=>{r({path:{addressId:d},body:{flags:{trusted:O(!c)}}})},isPending:n,error:o,reset:l}},tt=()=>{const[e,t]=g.useState(()=>typeof document<"u"&&document.documentElement.classList.contains("dark"));return g.useEffect(()=>{const s=document.documentElement,r=new MutationObserver(()=>{t(s.classList.contains("dark"))});return r.observe(s,{attributes:!0,attributeFilter:["class"]}),()=>r.disconnect()},[]),e},st=({blockedImageCount:e,canAlwaysTrust:t,isTrustPending:s,onLoadOnce:r,onAlwaysTrust:n})=>a.jsxs("div",{className:"mb-3 flex items-center justify-between rounded-md bg-surface-sunken/50 px-3 py-2 text-sm",children:[a.jsxs("span",{className:"text-fg-muted",children:[e," image",e>1?"s":""," blocked for privacy"]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("button",{type:"button",onClick:r,className:"text-accent hover:underline",children:"Load once"}),t&&a.jsx("button",{type:"button",onClick:n,"aria-busy":s,className:"text-accent hover:underline aria-busy:opacity-50",children:s?"Trusting…":"Always trust"})]})]}),rt=(e,t)=>{switch(e){case"auth":return{title:"Your session expired",detail:"Sign in again to reload the message body. Other parts of the app may also stop responding until you do."};case"body-missing":return{title:"Message body is missing in storage",detail:"A sync failure may have left this message without its body bytes. Contact support, or run the reconcile script to refetch from the upstream IMAP server."};case"content-type-mismatch":return{title:"Couldn't load message body",detail:"The server returned an unexpected content type for this part. The message body has not been rendered to keep you safe."};case"spa-shell-leak":return{title:"Couldn't load message body",detail:"The server returned the app shell instead of the message body. This is an infrastructure bug — please report it."};case"not-ready":return{title:"Message body is still syncing",detail:"This message's body hasn't finished downloading from the mail server yet. It should appear shortly — reopen the message to try again."};default:return{title:"Couldn't load message body",detail:t}}},nt=e=>e instanceof oe?e.reason:"generic",at=e=>e instanceof Error?e.message:typeof e=="string"?e:"An unexpected error occurred while loading the message body.",ot=({error:e,onRetry:t})=>{const s=nt(e),r=at(e),{title:n,detail:o}=rt(s,r),[l,m]=g.useState(!1),{Account:d}=te();return l?null:a.jsxs("div",{role:"alert","data-testid":"message-body-error-banner","data-reason":s,className:"flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-sm",children:[a.jsx(se,{className:"size-4 shrink-0 text-danger mt-0.5","aria-hidden":"true"}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"font-medium text-danger",children:n}),a.jsx("p",{className:"text-fg-muted mt-1 break-words",children:o})]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-3",children:[s==="auth"&&a.jsx(d,{children:({signOut:c})=>a.jsx("button",{type:"button",onClick:()=>c(),className:"text-sm font-medium text-accent hover:underline",children:"Sign in again"})}),t&&a.jsx("button",{type:"button",onClick:t,className:"text-sm font-medium text-accent hover:underline",children:"Retry"}),a.jsx("button",{type:"button",onClick:()=>m(!0),"aria-label":"Dismiss message body error",className:"rounded-md p-1 text-fg-muted hover:bg-surface-raised hover:text-fg transition-colors",children:a.jsx(re,{className:"size-4","aria-hidden":"true"})})]})]})},it=()=>a.jsxs("div",{className:"animate-pulse space-y-2",role:"status","aria-label":"Loading message body",children:[a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-full"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-11/12"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-3/4"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-5/6"})]}),L=()=>a.jsx("p",{className:"text-fg-muted text-sm italic",children:"This message has no body content."}),At=({bodyParts:e,html:t,text:s,isTrusted:r=!1,messageId:n,fromAddressId:o,category:l,className:m})=>{const[d,c]=g.useState(!1),f=r||d,u=tt(),{toggleTrusted:h,isPending:p}=et({messageId:n??""}),i=!!e&&e.length>0,{picked:x,data:y,isLoading:w,isError:$,error:z,refetch:P}=ie({messageId:n,bodyParts:e,enabled:i}),K=g.useMemo(()=>ue(e??[]),[e]),F=i&&y?.kind==="html"?y.body:t,H=i&&y?.kind==="text"?y.body:s;if(i){if(w)return a.jsx("div",{className:b("message-body",m),children:a.jsx(it,{})});if($)return a.jsx("div",{className:b("message-body",m),children:a.jsx(ot,{error:z,onRetry:()=>P()})});if(!x)return a.jsx("div",{className:b("message-body",m),children:a.jsx(L,{})})}else if(!t&&!s)return a.jsx("div",{className:b("message-body",m),children:a.jsx(L,{})});const U=!!(o&&n),G=()=>{!o||p||(c(!0),h(o,!1))};return a.jsx(Ve,{className:m,html:F,text:H,isDark:u,category:l,allowImages:f,resolveCid:K,renderBlockedNotice:W=>a.jsx(st,{blockedImageCount:W,canAlwaysTrust:U,isTrustPending:p,onLoadOnce:()=>c(!0),onAlwaysTrust:G})})},D={personal:"Personal",uncategorized:"Unclassified",transactional:"Transactional",newsletter:"Newsletter",marketing:"Marketing",social:"Social",automated:"Automated"},ct=Object.values(R).map(e=>({value:e,label:D[e]})),lt={unclassified:"uncategorized"},dt=[{name:"from",label:"Sender",values:"contact"},{name:"subject",label:"Subject",values:"text"},{name:"category",label:"Category",values:"fixed",options:ct},{name:"is",label:"State",values:"fixed",options:[{value:"unread",label:"Unread"},{value:"read",label:"Read"},{value:"starred",label:"Starred"}]},{name:"has",label:"Contents",values:"fixed",options:[{value:"attachment",label:"Has attachment"}]},{name:"in",label:"Folder",values:"mailbox"},{name:"account",label:"Account",values:"account"},{name:"after",label:"Sent on or after",values:"date"},{name:"before",label:"Sent before",values:"date"}],ut=new Map(dt.map(e=>[e.name,e])),Et=e=>ut.get(e.toLowerCase()),mt=/^\d{4}-\d{2}-\d{2}$/;function ft(e,t,s){if(!mt.test(s))return;const r=Date.parse(`${s}T00:00:00Z`);if(!Number.isNaN(r))return{type:e,raw:t,value:s,epochSeconds:Math.floor(r/1e3)}}function ht(e){const t=e.toLowerCase(),s=lt[t];return s||Object.values(R).find(n=>n===t)}function gt(e,t){switch(t.toLowerCase()){case"unread":return{type:"isUnread",raw:e};case"read":return{type:"isRead",raw:e};case"starred":case"flagged":return{type:"isStarred",raw:e};default:return}}function pt(e,t){const s=Ye(e);if(!s||s.value.length===0)return;const{name:r,value:n}=s;switch(r){case"from":return{type:"from",raw:e,value:n};case"subject":return{type:"subject",raw:e,value:n};case"category":{const o=ht(n);return o?{type:"category",raw:e,value:n,category:o}:void 0}case"is":return gt(e,n);case"has":return n.toLowerCase()==="attachment"?{type:"hasAttachment",raw:e}:void 0;case"before":case"after":return ft(r,e,n);case"in":{const o=t.mailboxesByName?.get(n.toLowerCase());return o?{type:"in",raw:e,value:n,mailboxId:o}:void 0}case"account":{const o=t.accountsByName?.get(n.toLowerCase());return o?{type:"account",raw:e,value:n,accountId:o}:void 0}default:return}}function Tt(e,t={}){const s=[],r=[];for(const n of M(e)){const o=pt(n.raw,t);o?s.push(o):r.push(n.raw)}return{freeText:r.join(" "),tokens:s}}function Nt(e,t){return M(e).filter(s=>s.raw!==t.raw).map(s=>s.raw).join(" ")}function Ct(e){switch(e.type){case"from":return`From: ${e.value}`;case"subject":return`Subject: ${e.value}`;case"category":return`Category: ${D[e.category]}`;case"hasAttachment":return"Has attachment";case"isUnread":return"Unread";case"isRead":return"Read";case"isStarred":return"Starred";case"before":return`Before ${e.value}`;case"after":return`After ${e.value}`;case"in":return`In: ${e.value}`;case"account":return`Account: ${e.value}`}}function jt(){const{mailboxNameIndex:e,accountNameIndex:t}=ne(),s=ae();return{...ce(s)?{}:{mailboxesByName:e},accountsByName:t}}export{vt as M,kt as R,dt as S,M as a,Ye as b,Ve as c,et as d,At as e,Ct as f,Et as g,Tt as p,Nt as r,St as s,jt as u};
@@ -0,0 +1 @@
1
+ import{u as T,ar as I,f as C,bP as k,c1 as A,r as S,j as p,c2 as h,c3 as E,c4 as j,Q as w,c5 as D,d as Q,c6 as z,bS as P}from"./index-FpwHnbdV.js";import{P as R}from"./attachment-file-ul58bxI4.js";import{am as O,an as _}from"./MailListHeader-Brjq4vBE.js";import{i as N,t as q}from"./search-token-index-C9KNJC5_.js";import{a as B}from"./useLabels-GtiakPKP.js";import{n as U}from"./search-query-Cr_ZXBCp.js";import{s as F}from"./search-scope-DTcpOp3S.js";import{u as G,p as H}from"./useSearchTokenContext-DH5XswlU.js";const ne=e=>{const t=new Set;for(const a of e)a&&t.add(a);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}},K=e=>{const{mailboxId:t,messages:a}=e,c=T(),{pushError:l}=I(),{mutateAsync:i,isPending:o}=C({...A(),onError:(n,u)=>{l({title:u.body.action==="Remove"?"Couldn't remove label":"Couldn't apply label",detail:k(n),error:n})},onSettled:(n,u,d)=>{N(c,q(O(d.body.messageIds??[],a??[],t)))}});return{applyLabel:S.useCallback((n,u,d)=>{n.length!==0&&_(n,m=>i({body:{messageIds:m,labelId:u,action:d}}))},[i]),isPending:o}};function re({accountId:e,mailboxId:t,messageIds:a}){const{labels:c}=B(e),{applyLabel:l}=K({mailboxId:t}),i=S.useMemo(()=>c.map(o=>({key:o.labelId,label:o.name,icon:p.jsx("span",{className:`size-2.5 rounded-full ${E(o.color)?h[o.color]:h.Default}`}),onSelect:()=>l(a,o.labelId,"Apply")})),[c,a,l]);return i.length===0?null:p.jsx(R,{triggerLabel:"Apply label to selected messages",triggerIcon:p.jsx(j,{className:"size-4 text-fg-subtle"}),triggerText:"Apply label",items:i,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 V=20,$=new Set(Object.values(P)),J=e=>e!==void 0&&$.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 ie({mailboxId:e,filterCategory:t}={}){const{searchQuery:a}=w(),c=G(),l=D(),i=U(a),{freeText:o,tokens:r}=H(i,c),n=o.length>0,u=r.find(s=>s.type==="category"),d=J(t)??u?.category,m=r.some(s=>s.type==="hasAttachment")?!0:void 0,f=r.some(s=>s.type==="isStarred")?!0:void 0,y=W(r),b=r.find(s=>s.type==="after"),g=r.find(s=>s.type==="before"),v=r.find(s=>s.type==="in"),x=F({browsed:l,callerMailboxId:e,inTokenMailboxId:v?.mailboxId}),{data:L,isLoading:M}=Q({...z({query:{query:o,mailboxId:x,limit:V,...d!==void 0?{category:d}:{},...m!==void 0?{hasAttachment:m}:{},...f!==void 0?{hasStars:f}:{},...y!==void 0?{isRead:y}:{},...b?{sentDateFrom:b.epochSeconds}:{},...g?{sentDateTo:g.epochSeconds}:{}}}),enabled:n,staleTime:6e4});return{hits:L?.items??[],isLoading:n&&M}}export{re as L,ne as r,ie as u};
@@ -0,0 +1 @@
1
+ import{u as g,ar as f,d as p,e as m,r,f as y,at as T,k as E,h as d}from"./index-FpwHnbdV.js";const i={html:"",plainText:""},x=e=>{const u=g(),{pushError:o}=f(),{data:n}=p({...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};
package/index.html CHANGED
@@ -38,8 +38,8 @@
38
38
  } catch (_) {}
39
39
  })();
40
40
  </script>
41
- <script type="module" crossorigin src="/assets/index--jDmBhH5.js"></script>
42
- <link rel="stylesheet" crossorigin href="/assets/index-DNl2PEHq.css">
41
+ <script type="module" crossorigin src="/assets/index-FpwHnbdV.js"></script>
42
+ <link rel="stylesheet" crossorigin href="/assets/index-DYO-sbPN.css">
43
43
  </head>
44
44
  <body>
45
45
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/web-client-dist",
3
- "version": "0.0.480",
3
+ "version": "0.0.482",
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 o,as as Ze,S as Xe,bS as es,v as Y,b5 as ss,bF as ts,r as a,D as oe,bT as ne,z as os,bU as ns,bV as as,bW as rs,e as Ce,bX as is,a9 as cs,bP as ls,bQ as ds}from"./index--jDmBhH5.js";import{s as je,a as us,b as Re,u as ms,p as fs,R as hs}from"./useSearchTokenContext-R8A5fR2H.js";import{a8 as be,F as ve,a9 as gs,aa as xs,G as ps,ab as ye,ac as Is,ad as bs,ae as vs,a7 as ys,af as Ss,ag as Ts,ah as Cs,M as js,ai as Rs,aj as ws,ak as Ms,e as ks,v as Fs,al as Os,q as As,S as Ns,J as Bs,O as Se,N as Ds,K as Ls,d as Es,Y as Ps,Z as qs,$ as we,a0 as Me,a1 as zs,a2 as Qs,a3 as Hs}from"./MailListHeader-C43KDg07.js";import{u as _s,a as Ws,R as $s,b as Gs,c as Us}from"./useRefreshControl-CSvzy86_.js";import{u as Vs}from"./useQueries-DSOBb7ot.js";import{a as Ys}from"./useLabels-BjdBxeXq.js";import{e as Js,p as Ks,R as Zs,k as Xs,l as et}from"./search-token-index-CFFpLJvA.js";import{u as st,r as tt,L as ot}from"./useSemanticSearch-CwlN7Eas.js";import{w as nt}from"./wizard-selection-B1bng5Jq.js";import{u as ke}from"./index-D5iR33Kk.js";import{a as at}from"./useMessageBodyContent-C0DuC9W1.js";function rt({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:it(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 it({synced:e,total:s}){return s>0?`${e.toLocaleString()} of ${s.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",ct={unclassified:"uncategorized"},W=e=>us(e).map(s=>s.raw),_=e=>e.join(" "),ae=e=>{const s=Re(e);if(s)return Fe.find(n=>n.name===s.name&&n.value===s.value.toLowerCase())?.id},re=e=>{const s=Re(e);if(!s||s.name!==Oe)return;const n=s.value.toLowerCase(),r=ct[n];if(r)return r;if(!(!es(n)||n==="all"))return n},Ae=e=>Fe.find(s=>s.id===e),Ne=e=>Ae(e)!==void 0,lt=e=>{const s=new Set;for(const n of W(e)){const r=ae(n);r&&s.add(r)}return s},dt=e=>{let s="all";for(const n of W(e)){const r=re(n);r&&(s=r)}return s},ut=(e,s)=>{const n=Ae(s);if(!n)return;const r=W(e),l=r.filter(d=>ae(d)!==s);return l.length<r.length?_(l):_([...r,je(n.name,n.value)])},mt=(e,s)=>{const n=W(e).filter(r=>!re(r));return _(s==="all"?n:[...n,je(Oe,s)])},ft=e=>_(W(e).filter(s=>!ae(s)&&!re(s))),Be=e=>e.trim().length>0,ht=e=>{if(!Be(e.query))return e.ownFilters;const s=new Set(lt(e.query));for(const n of e.ownFilters)Ne(n)||s.add(n);return s},gt=e=>Be(e.query)?dt(e.query):e.ownCategory,xt=(e,s)=>e.createdAt!==s.createdAt?e.createdAt-s.createdAt:e.accountId.localeCompare(s.accountId),pt=e=>[...e].sort(xt),It=200,Te=()=>o.jsx("div",{className:"animate-pulse",children:Array.from({length:3}).map((e,s)=>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"})]})]},s))}),bt=({accountEmail:e})=>{const s=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(Ce,{className:"size-3.5 shrink-0"}),o.jsxs("span",{className:"flex-1 truncate",children:[e," can't connect"]}),o.jsx("button",{type:"button",onClick:()=>s("accounts"),className:"shrink-0 underline text-danger hover:opacity-80",children:"Reconnect"})]})},vt=(e,s)=>{if(s.size===0)return{};const n=e.filter(d=>s.has(d.id)),r=tt(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 yt({header:e,rows:s,wizard:n,children:r}){const{selectedIds:l,selectedCount:d,exitSelection:u,orderedIds:m,allSelected:b,toggleAllLoaded:f}=Ms(),x=a.useMemo(()=>vt(s,l),[s,l]),{junkMailboxId:D}=ks(x.accountId),{labels:I}=Ys(x.accountId),p=a.useMemo(()=>Array.from(l),[l]),L=a.useMemo(()=>nt(s,l),[s,l]),h=Fs(D,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=T=>o.jsx(Ns,{title:T.title,navSlot:T.navSlot,titleMeta:T.titleMeta,searchSlot:T.searchSlot,searchField:T.searchField,idleSlot:T.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(ot,{accountId:x.accountId,mailboxId:x.mailboxId,messageIds:p}):void 0,selectAll:v,notice:F});return o.jsx(Os,{...e,selectionBar:S,paneOverlay:o.jsx(As,{verb:n.verb,accountId:x.accountId,mailboxId:x.mailboxId,selection:L,selectionRestriction:x.restriction,onFinished:u}),children:r})}function St({accounts:e,selectedMessageId:s,onOpenThread:n,commandsRef:r,onTriageContextChange:l,onDeleteMessages:d}){const{searchQuery:u,searchInput:m,resultFolderIndex:b,onSearchChange:f}=Y(),x=ms(),D=ss(),I=Js(),p=ts(),L=Ks(),h=a.useMemo(()=>pt(e.filter(t=>!t.muted?.value)),[e]),[v,F]=a.useState("all"),[S,T]=a.useState("all"),[$,E]=a.useState(new Set),[K,C]=a.useState(!1),P=a.useCallback(t=>{E(i=>{const c=new Set(i);return c.has(t)?c.delete(t):c.add(t),c})},[]),G=a.useCallback(()=>E(new Set),[]),R=m.trim().length>0,j=a.useMemo(()=>ht({query:m,ownFilters:$}),[m,$]),w=a.useMemo(()=>gt({query:m,ownCategory:S}),[m,S]),O=a.useCallback(t=>{if(!R||!Ne(t)){P(t);return}const i=ut(m,t);i!==void 0&&f(i)},[R,m,f,P]),q=a.useCallback(t=>{if(!R){T(t);return}f(mt(m,t))},[R,m,f]),z=a.useCallback(()=>{T("all"),F("all"),G(),R&&f(ft(m))},[R,m,f,G]),{data:A,isLoading:Q,isError:g,refetch:N}=oe({...ne(),staleTime:6e4}),B=Vs({queries:h.map(t=>({...os({path:{accountId:t.accountId}}),staleTime:1/0,meta:{softError:!0}}))}),U=a.useMemo(()=>{const t=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);t.set(c,Ye)}return t},[h,B]),Ee=a.useMemo(()=>h.filter((t,i)=>{const c=B[i];return c?.isError?!ns(c.error):!1}),[h,B]),{freeText:M,tokens:Z}=fs(u.trim().toLowerCase(),x),{data:ie,isFetching:Pe}=oe({...ne({query:{query:M,limit:It}}),enabled:M.length>0,staleTime:3e4}),y=a.useMemo(()=>{const t=be(A?.items??[]).map(ve);return(M?gs(t.filter(c=>xs(c,M)),be(ie?.items??[]).map(ve)):t).filter(c=>(v==="all"||c.accountId===v)&&ps(c,Z))},[A,ie,v,M,Z]),{bodyRows:ce,briefSpamOffer:X}=a.useMemo(()=>{if(!M)return{bodyRows:y,briefSpamOffer:void 0};const t=y.map(k=>ye(k,b)),{spam:i}=Is(t);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:bs(t)}},[y,M,b]),le=a.useMemo(()=>vs(ce),[ce]),de=a.useCallback((t,i)=>{const c=y.find(k=>k.id===t)?.threadId;c&&n?.({threadId:c,messageId:t},i)},[y,n]),qe=a.useCallback(t=>{const i=t.threadId??y.find(c=>c.id===t.id)?.threadId;i&&n?.({threadId:i,messageId:t.id})},[y,n]),ee=a.useMemo(()=>h.length<=1?[]:[{id:"all",label:"All",active:v==="all"},...h.map(t=>({id:t.accountId,label:t.email.split("@")[0]??t.email,count:U.get(t.accountId),active:v===t.accountId}))],[h,U,v]),H=a.useMemo(()=>e.filter(t=>t.muted?.value).length,[e]),ze=a.useMemo(()=>Array.from(U.values()).reduce((t,i)=>t+i,0),[U]),se=a.useMemo(()=>h.map(t=>t.accountId),[h]),{hasNewMail:ue}=_s(),{state:me,errorMessage:fe,refresh:he}=Ws(se,{onSettled:()=>N()}),Qe=a.useMemo(()=>o.jsx($s,{state:me,onRefresh:he,label:"Refresh daily brief",errorMessage:fe,hasUpdate:ue(se)}),[me,he,fe,ue,se]),te=a.useMemo(()=>y.filter(t=>(w==="all"||t.category===w)&&as(t,j)).map(t=>ye(t,b)),[y,w,j,b]),{hits:ge,isLoading:He}=st(),_e=a.useMemo(()=>{const t=new Map;for(const c of A?.items??[])t.set(c.messageId,c.threadId);const i=te.map(c=>t.get(c.id)).filter(c=>c!=null);return ys(ge,i,b)},[ge,te,A,b]),We=a.useMemo(()=>{const t=Ss(ee.map(i=>({id:i.id,label:i.label,count:i.count,active:i.active})));return{categories:t.categories,filters:t.filters,sources:t.sources,sourcesNote:H>0?`+${H} muted`:void 0,selectedCategory:w,activeFilters:j,expanded:K,onExpandedChange:C,onSelectCategory:i=>q(i),onSelectSource:F,onToggleFilter:i=>O(i),onClear:z}},[ee,H,w,j,K,O,q,z]),xe=le.length===0&&v==="all"&&M.length===0&&Z.length===0,$e=a.useMemo(()=>h.map(t=>t.accountId),[h]),Ge=a.useMemo(()=>h.some(t=>Gs(t.syncPhase)),[h]),V=Us($e,xe||Ge),pe=o.jsxs("div",{className:"h-full overflow-y-auto",children:[o.jsx(Te,{}),o.jsx(Te,{})]}),Ie=!Q&&!g&&!xe,Ue=Ts({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(Cs,{count:X.count,onScopeToSpam:()=>L(X.mailboxId,u)}),o.jsx("div",{className:"min-h-0 flex-1",children:o.jsx(rs,{sections:le,briefCategory:w,Row:js,selectedThreadId:s,onSelectThread:de,onSelectBriefCategory:q,sources:ee,sourcesNote:H>0?`+${H} 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(Ce,{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(Zs,{className:"size-3.5"}),"Try again"]})]}):V.resolved?o.jsx(rt,{sync:V.syncing?{synced:V.synced,total:V.total}:void 0}):pe;return o.jsx(is,{hasSheet:Ie&&!Ue,children:o.jsx(Rs,{selectedMessageId:s,rows:y,onOpen:de,onDeleteMessages:d,onSelectionVerb:p.start,commandsRef:r,onTriageContextChange:l,children:o.jsx(yt,{wizard:p,header:{title:"Daily brief",unreadCount:ze,footer:D?o.jsx(ws,{}):void 0,searchFilter:We,searchResults:te,searchLoading:Q||Pe,relatedResults:_e,relatedLoading:He,onSelectSearchResult:qe,searchResultsInBody:!0,refreshControl:Qe},rows:y,children:o.jsxs("div",{className:"flex h-full flex-col",children:[Ee.map(t=>o.jsx(bt,{accountEmail:t.email,accountId:t.accountId},t.accountId)),o.jsx("div",{className:"min-h-0 flex-1",children:Ve})]})})})})}const De=a.createContext(null);function J(){const e=a.useContext(De);if(!e)throw new Error("BriefPane.* must be used inside <BriefPane>");return e}function Tt({thread:e,children:s}){const n=Xs(),r=et(),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]),D=Bs(u,m),I=x??D,p=m??I?.messageId,L=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=Ds(),{deleteMessages:T}=Ls({mailboxId:I?.mailboxId??"",messages:f,onAfterOptimisticRemove:v}),{toggleReadFor:$}=Es({mailboxId:I?.mailboxId??"",messages:f}),E=S.focusedMessageId,C=a.useMemo(()=>f.find(g=>g.messageId===E),[f,E])??I,P=Se({thread:C,isOpen:C?.messageId===p}),G=at(),R=cs(),j=ls(),w=a.useMemo(()=>ds(j,u,p),[j,u,p]),O=a.useMemo(()=>{if(C)return g=>j({threadId:C.threadId,messageId:C.messageId,mode:g})},[j,C]),{nextMessageId:q,previousMessageId:z}=Ps({context:S,orderedIds:S.orderedIds,selectedMessageId:p,enabled:!G&&!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")||C&&$([C.messageId],!C.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:L,onOpenThread:h,onCloseThread:r,nextThread:A(q),previousThread:A(z),actions:F,onReply:w,triage:S,onDeleteMessages:T,handleDeselectIfRemoved:v};return o.jsx(De.Provider,{value:Q,children:s})}function Le(){const{selectedMessageId:e,onOpenThread:s,triage:n,onDeleteMessages:r}=J(),{accounts:l}=Y();return o.jsx(St,{accounts:l,selectedMessageId:e,onOpenThread:s,commandsRef:n.listCommandsRef,onTriageContextChange:n.onTriageContextChange,onDeleteMessages:r})}function Ct(){const{conversation:e,selectedThread:s,actions:n,onReply:r,handleDeselectIfRemoved:l}=J(),d=!!e,u=Qs(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(Hs,{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(hs,{})})]}),o.jsx(Me,{isOpen:u.drawerOpen,onClose:u.closeDrawer,thread:s,mailboxId:s?.mailboxId,accountId:s?.accountId,onAfterOptimisticRemove:l})]})}function jt(){const{selectedThread:e,handleDeselectIfRemoved:s}=J(),{onToggleIntelligence:n}=Y();return o.jsx(zs,{onClose:n,thread:e,mailboxId:e?.mailboxId,accountId:e?.accountId,onAfterOptimisticRemove:s})}function Rt(){const{selectedThread:e,conversation:s,onOpenThread:n,onCloseThread:r,nextThread:l,previousThread:d,handleDeselectIfRemoved:u}=J(),m=qs(s?.threadId??null);return s?o.jsxs(o.Fragment,{children:[o.jsx(we,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.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(Le,{})})}const Pt=Object.assign(Tt,{List:Le,Reading:Ct,Intelligence:jt,Phone:Rt});export{Pt as B};
@@ -1 +0,0 @@
1
- import{dU as Y,r as n,cf as Z,v as z,b5 as $,bF as X,aT as ee,aU as te,j as a,a9 as se,bP as ae,bQ as re}from"./index--jDmBhH5.js";import{u as oe,p as ne,R as de}from"./useSearchTokenContext-R8A5fR2H.js";import{F as ie,aa as le,G as ce,au as ue,ab as ge,b as he,M as me,ai as fe,av as Ie,ak as pe,q as xe,J as Te,O as V,N as be,K as ve,d as ye,Y as Re,Z as Ce,$ as K,a0 as G,a1 as Se,a2 as we,a3 as je}from"./MailListHeader-C43KDg07.js";import{u as Fe,b as Me,a as Oe}from"./MailViewChrome-q-U1DZjL.js";import{f as Pe}from"./ErrorState-CTL91fuE.js";import{w as ke}from"./wizard-selection-B1bng5Jq.js";import{a as Le}from"./useMessageBodyContent-C0DuC9W1.js";import{k as Ae,l as Ne}from"./search-token-index-CFFpLJvA.js";import{u as De}from"./index-D5iR33Kk.js";const Ee=()=>Z({query:{starred:!0,order:"desc"}});function U(){const{data:e,isLoading:t,isError:s,error:d,refetch:h,fetchNextPage:c,hasNextPage:r,isFetchingNextPage:m}=Fe({queryKey:Ee(),queryFn:async({pageParam:T})=>{const{data:v}=await Y({query:{starred:!0,order:"desc",continuationToken:T},throwOnError:!0});return v},initialPageParam:void 0,getNextPageParam:T=>T.continuationToken,staleTime:6e4});return{threads:n.useMemo(()=>(e?.pages??[]).flatMap(T=>T.items??[]),[e]),isLoading:t,isError:s,error:d,refetch:h,fetchNextPage:c,hasNextPage:r,isFetchingNextPage:m}}const Be=e=>{const t=new Set;return e.filter(s=>t.has(s.threadId)?!1:(t.add(s.threadId),!0))},qe={unread:e=>!e.isRead,attachment:e=>e.hasAttachment===!0};function Qe({rows:e,verb:t}){const{selectedIds:s,exitSelection:d}=pe(),h=n.useMemo(()=>ke(e,s),[e,s]);return a.jsx(xe,{verb:t,selection:h,selectionRestriction:"spansAccounts",onFinished:d})}function ze({selectedMessageId:e,onOpenThread:t,commandsRef:s,onTriageContextChange:d,onDeleteMessages:h}){const{searchQuery:c,resultFolderIndex:r}=z(),m=oe(),I=$(),T=X(),[v,f]=n.useState("all"),[g,F]=n.useState(new Set),D=n.useCallback(o=>{F(u=>{const x=new Set(u);return x.has(o)?x.delete(o):x.add(o),x})},[]),C=n.useCallback(()=>{f("all"),F(new Set)},[]),{threads:M,isLoading:b,isError:O,error:E,refetch:P,fetchNextPage:H,hasNextPage:p,isFetchingNextPage:S}=U(),{freeText:R,tokens:k}=ne(c.trim().toLowerCase(),m),i=n.useMemo(()=>{const o=Array.from(g).map(u=>qe[u]).filter(u=>u!=null);return Be(M).map(ie).filter(u=>(v==="all"||u.category===v)&&o.every(x=>x(u))&&(!R||le(u,R))&&ce(u,k))},[M,v,g,R,k]),w=n.useCallback((o,u)=>{const x=i.find(J=>J.id===o)?.threadId;x&&t?.({threadId:x,messageId:o},u)},[i,t]),j=n.useCallback(o=>{const u=o.threadId??i.find(x=>x.id===o.id)?.threadId;u&&t?.({threadId:u,messageId:o.id})},[i,t]),B=n.useMemo(()=>ue(),[]),q=n.useMemo(()=>i.map(o=>ge(o,r)),[i,r]),L=n.useMemo(()=>i.filter(o=>!o.isRead).length,[i]),A=b?"loading":O?"error":i.length===0?"empty":"ready",l=n.useCallback(()=>{const o=ee(te());window.open(o,"_blank","noopener,noreferrer")},[]),y=he(),Q=a.jsx("div",{className:"flex h-full min-h-0 flex-col",children:a.jsxs("div",{className:"flex-1 overflow-y-auto",children:[a.jsx("div",{className:"divide-y divide-line",children:i.map(o=>a.jsx(me,{thread:o,active:o.id===e,onClick:()=>w(o.id)},o.id))}),p?a.jsx("button",{type:"button",className:"w-full py-3 text-sm text-muted hover:text-fg disabled:opacity-50",onClick:()=>H(),disabled:S,children:S?"Loading…":"Load more"}):null]})});return a.jsx(Me,{title:"Starred",unreadCount:L,preset:B,selectedCategory:v,activeFilters:g,onSelectCategory:f,onToggleFilter:D,onClearFilters:C,searchResults:q,searchLoading:b,onSelectSearchResult:j,searchResultsInBody:!0,children:a.jsxs(fe,{selectedMessageId:e,rows:i,onOpen:w,onDeleteMessages:h,onSelectionVerb:T.start,commandsRef:s,onTriageContextChange:d,children:[a.jsx(Oe,{listTitle:"Starred",sections:[{id:"flagged",threads:i}],flatList:!0,hideHeader:!0,listState:y.searchResults?"ready":A,searchQuery:R?c:void 0,errorMessage:O?Pe(E):void 0,onRetry:()=>P(),onReportError:l,selectedThreadId:e,onSelectThread:w,isDesktop:I,selectionBar:a.jsx(Ie,{title:"Starred"}),listBody:y.searchResults??(A==="ready"?Q:void 0)}),a.jsx(Qe,{rows:i,verb:T.verb})]})})}const W=n.createContext(null);function N(){const e=n.useContext(W);if(!e)throw new Error("FlaggedPane.* must be used inside <FlaggedPane>");return e}function He({thread:e,children:t}){const s=Ae(),d=Ne(),h=De(),{searchInput:c}=z(),r=e?.threadId,m=e?.messageId,{threads:I}=U(),T=n.useMemo(()=>{if(r)return I.find(l=>l.messageId===m)??I.find(l=>l.threadId===r)},[I,r,m]),v=Te(r,m),f=T??v,g=m??f?.messageId,F=n.useMemo(()=>{if(r)return{threadId:r,mailboxId:f?.mailboxId??"",subject:f?.subject,messageId:g,authenticity:f?.authenticity}},[r,f,g]),D=n.useCallback((l,y)=>{s(l,{replace:y?.replace,query:c})},[s,c]),C=n.useCallback(l=>{g&&l.includes(g)&&d()},[g,d]),M=V({thread:f,isOpen:!0,onAfterOptimisticRemove:C}),b=be(),{deleteMessages:O}=ve({mailboxId:f?.mailboxId??"",messages:I,onAfterOptimisticRemove:C}),{toggleReadFor:E}=ye({mailboxId:f?.mailboxId??"",messages:I}),P=b.focusedMessageId,p=n.useMemo(()=>I.find(l=>l.messageId===P),[I,P])??f,S=V({thread:p,isOpen:p?.messageId===g}),R=Le(),k=se(),i=ae(),w=n.useMemo(()=>re(i,r,g),[i,r,g]),j=n.useMemo(()=>{if(p)return l=>i({threadId:p.threadId,messageId:p.messageId,mode:l})},[i,p]),{nextMessageId:B,previousMessageId:q}=Re({context:b,orderedIds:b.orderedIds,selectedMessageId:g,enabled:!R&&!k,hasOpenThread:r!==void 0,onClose:d,handlers:{reply:()=>j?.("reply"),replyAll:()=>j?.("reply-all"),forward:()=>j?.("forward"),delete:()=>{b.listCommandsRef.current?.requestVerb("delete")||S.deleteThread()},toggleStar:S.toggleStar,toggleRead:()=>{b.listCommandsRef.current?.requestVerb("markRead")||p&&E([p.messageId],!p.isRead)},goBrief:()=>h("brief"),goSettings:()=>h("settings")}}),L=n.useCallback(l=>{if(!l)return;const y=I.find(Q=>Q.messageId===l);return y?{threadId:y.threadId,messageId:l}:void 0},[I]),A={selectedMessageId:g,selectedThread:f,conversation:F,onOpenThread:D,onCloseThread:d,nextThread:L(B),previousThread:L(q),actions:M,onReply:w,triage:b,onDeleteMessages:O,handleDeselectIfRemoved:C};return a.jsx(W.Provider,{value:A,children:t})}function _(){const{selectedMessageId:e,onOpenThread:t,triage:s,onDeleteMessages:d}=N();return a.jsx(ze,{selectedMessageId:e,onOpenThread:t,commandsRef:s.listCommandsRef,onTriageContextChange:s.onTriageContextChange,onDeleteMessages:d})}function Ve(){const{conversation:e,selectedThread:t,actions:s,onReply:d,handleDeselectIfRemoved:h}=N(),c=!!e,r=we(e?.threadId);return a.jsxs(a.Fragment,{children:[a.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[a.jsx(je,{hasThread:c,intelligenceOpen:r.isShowing,canToggleIntelligence:r.canToggle,onToggleIntelligence:r.toggle,onReply:d?()=>d("reply"):void 0,onReplyAll:d?()=>d("reply-all"):void 0,onForward:d?()=>d("forward"):void 0,onDelete:c?s.deleteThread:void 0,onToggleStar:c?s.toggleStar:void 0,isStarred:s.isStarred,moveContext:c&&s.accountId&&s.mailboxId?{accountId:s.accountId,currentMailboxId:s.mailboxId,onMove:s.moveThread}:void 0}),a.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e?a.jsx(K,{threadId:e.threadId,mailboxId:e.mailboxId,subject:e.subject,selectedMessageId:e.messageId,authenticity:e.authenticity,onOpenIntelligence:r.open,listOnScreen:!0}):a.jsx(de,{})})]}),a.jsx(G,{isOpen:r.drawerOpen,onClose:r.closeDrawer,thread:t,mailboxId:t?.mailboxId,accountId:t?.accountId,onAfterOptimisticRemove:h})]})}function Ke(){const{selectedThread:e,handleDeselectIfRemoved:t}=N(),{onToggleIntelligence:s}=z();return a.jsx(Se,{onClose:s,thread:e,mailboxId:e?.mailboxId,accountId:e?.accountId,onAfterOptimisticRemove:t})}function Ge(){const{selectedThread:e,conversation:t,onCloseThread:s,onOpenThread:d,nextThread:h,previousThread:c,handleDeselectIfRemoved:r}=N(),m=Ce(t?.threadId??null);return t?a.jsxs(a.Fragment,{children:[a.jsx(K,{threadId:t.threadId,mailboxId:t.mailboxId,subject:t.subject,selectedMessageId:t.messageId,authenticity:t.authenticity,onBack:s,onOpenIntelligence:m.toggle,onSwipeNext:h?()=>d(h):void 0,onSwipePrevious:c?()=>d(c):void 0,mobileIntelligenceOpen:m.isOpen}),a.jsx(G,{isOpen:m.isOpen,onClose:m.close,thread:e,mailboxId:e?.mailboxId,accountId:e?.accountId,onAfterOptimisticRemove:r})]}):a.jsx("div",{className:"h-full",children:a.jsx(_,{})})}const tt=Object.assign(He,{List:_,Reading:Ve,Intelligence:Ke,Phone:Ge});export{tt as F};
@@ -1 +0,0 @@
1
- import{j as e,as as re,B as A,e as ie,r as x,b as G,at as oe,T as ce,dI as le,u as ue,dJ as Q,bW as de,cG as fe,dK as me,dL as xe,dM as ge,v as he,bX as pe,d5 as be}from"./index--jDmBhH5.js";import{R as ve,q as je,G as we}from"./search-token-index-CFFpLJvA.js";import{ao as Ne,ap as ye,c as Pe,a as q,aq as Ce,s as Re,ar as ke,as as Se,at as Me,aj as Ee,al as Ie}from"./MailListHeader-C43KDg07.js";import{A as ze}from"./avatar-D2QoGusZ.js";import{M as Oe}from"./mail-DRJYwhBZ.js";import{M as Le}from"./menu-CW3Mzpax.js";function De(){return e.jsx("div",{className:"space-y-0",role:"status","aria-busy":"true","aria-label":"Loading messages",children:Array.from({length:8}).map((s,n)=>e.jsxs("div",{className:"animate-pulse border-b border-line px-3 py-2",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("div",{className:"h-4 w-32 rounded bg-surface-sunken"}),e.jsx("div",{className:"h-3 w-16 rounded bg-surface-sunken"})]}),e.jsx("div",{className:"mb-2 h-4 w-48 rounded bg-surface-sunken"}),e.jsx("div",{className:"h-3 w-full rounded bg-surface-sunken"})]},n))})}function Te({filter:s,scopeLabel:n,searchQuery:r}){const f=r?.trim();return s?e.jsxs(U,{children:[e.jsx("p",{className:"font-medium text-fg",children:$e(s.label,n,f)}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:_e[s.reach]}),e.jsx(A,{variant:"secondary",size:"sm",className:"mt-4",onClick:s.onClear,children:"Clear filter"})]}):e.jsx(U,{children:e.jsx("p",{className:"text-fg-muted",children:Ae(f,n)})})}const _e={"whole-folder":"Every message in this folder was checked.","loaded-pages":"Only the messages loaded so far were checked."};function Ae(s,n){return s?"No messages match your search":n?`No messages in ${n}`:"No messages in this mailbox"}function $e(s,n,r){return r?`No results for “${r}” in ${s}`:n?`No ${s} mail in ${n}`:`No ${s} mail`}function U({children:s}){return e.jsx("div",{className:"flex h-full flex-1 items-center justify-center",children:e.jsx("div",{className:"flex max-w-sm flex-col items-center justify-center p-8 text-center",children:s})})}function Ze(){return e.jsxs("div",{className:"flex items-center justify-center gap-2 py-4 text-sm text-fg-muted",role:"status","aria-live":"polite",children:[e.jsx(re,{className:"size-4 animate-spin","aria-hidden":"true"}),e.jsx("span",{children:"Loading more…"})]})}function Fe({message:s="Something went wrong loading this mailbox.",onRetry:n,onReport:r}){return e.jsx("div",{className:"flex h-full flex-1 items-center justify-center p-4",children:e.jsxs("div",{role:"alert",className:"flex max-w-sm flex-col items-center justify-center gap-3 text-center",children:[e.jsx(ie,{className:"size-8 text-danger","aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-danger",children:"Couldn't load messages"}),e.jsx("p",{className:"mt-1 break-words text-sm text-fg-muted",children:s})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[n&&e.jsx(A,{variant:"secondary",size:"sm",onClick:n,children:"Retry"}),r&&e.jsx(A,{variant:"ghost",size:"sm",onClick:r,children:"Report a problem"})]})]})})}const z=72,J=10,Xe=z/2,V="__swipeableRowAxisCancel";function Z(s){return s==="leading"?z:s==="trailing"?-z:0}function He(s){return s>=z/2?"leading":s<=-z/2?"trailing":"none"}function Be({thread:s,selectionMode:n,checked:r,active:f,peek:m,onPeek:g,onToggleCheck:y,onLongPress:j,onOpen:h,onAct:p}){const d=x.useRef(null),[b,v]=x.useState(null),{longPressProps:P}=Ne({onLongPress:j,isDisabled:n,accessibilityDescription:"Select message"}),k=i=>{const o=new PointerEvent("pointercancel",{bubbles:!0});o[V]=!0,i.currentTarget.dispatchEvent(o)},a=ye(P,{onPointerDown:i=>{d.current={startX:i.clientX,startY:i.clientY,axis:"none",escaped:!1}},onPointerMove:i=>{if(n)return;const o=d.current;if(!o)return;const u=i.clientX-o.startX,M=i.clientY-o.startY;if(o.axis==="none"&&(Math.abs(M)>J&&Math.abs(M)>Math.abs(u)?o.axis="vertical":Math.abs(u)>J&&Math.abs(u)>Math.abs(M)&&(o.axis="horizontal",i.currentTarget.setPointerCapture(i.pointerId))),o.axis==="none")return;const O=o.axis==="horizontal"?Math.abs(u):Math.abs(M);if(!o.escaped&&O>Xe&&(o.escaped=!0,k(i)),o.axis!=="horizontal")return;const F=Z(m),X=Math.max(-z,Math.min(z,F+u));v(X)},onPointerUp:i=>{const o=d.current;d.current=null;const u=b;if(v(null),!!o){if(o.axis!=="none"&&!o.escaped&&k(i),o.axis==="horizontal"){u!==null&&g(He(u));return}if(o.axis!=="vertical"){if(n){y();return}if(m!=="none"){g("none");return}h()}}},onPointerCancel:i=>{i.nativeEvent[V]||(d.current=null,v(null))}}),l=b??Z(m),N=l>0?"leading":l<0?"trailing":"none",C=G("relative touch-pan-y bg-surface","select-none",Pe({active:r||f})),D={transform:l!==0?`translateX(${l}px)`:void 0,transition:b===null?"transform 150ms ease":"none",minHeight:44},$=!s.isRead,I=i=>i.stopPropagation(),T=n?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:G("inline-flex size-7 shrink-0 items-center justify-center rounded-full border",r?"border-accent bg-accent text-accent-fg":"border-line-strong bg-canvas"),children:r&&e.jsx(oe,{className:"size-3.5"})}),e.jsx(q,{thread:s})]}):e.jsxs(e.Fragment,{children:[$&&e.jsx("span",{className:"absolute left-1.5 top-1/2 size-1.5 -translate-y-1/2 rounded-full bg-accent"}),e.jsx("span",{role:"checkbox",tabIndex:0,"aria-checked":r,"aria-label":`Select message from ${s.fromName}`,onPointerDown:I,onPointerMove:I,onPointerUp:I,onClick:i=>{i.preventDefault(),i.stopPropagation(),j()},onKeyDown:i=>{i.key!=="Enter"&&i.key!==" "||(i.preventDefault(),i.stopPropagation(),j())},className:"-m-2 inline-flex size-11 shrink-0 items-center justify-center rounded-full",children:e.jsx(ze,{name:s.fromName,email:s.fromEmail,size:"sm"})}),e.jsx(q,{thread:s})]});return e.jsxs("div",{className:"relative overflow-hidden",children:[N==="leading"&&e.jsx("button",{type:"button",onClick:()=>p("leading"),"aria-label":s.isRead?"Mark as unread":"Mark as read",className:"absolute inset-y-0 left-0 flex items-center justify-start bg-accent-2 px-6 text-accent-fg",children:s.isRead?e.jsx(Oe,{className:"size-6"}):e.jsx(Ce,{className:"size-6"})}),N==="trailing"&&e.jsx("button",{type:"button",onClick:()=>p("trailing"),"aria-label":"Delete message",className:"absolute inset-y-0 right-0 flex items-center justify-end bg-danger px-6 text-canvas",children:e.jsx(ce,{className:"size-6"})}),e.jsx("button",{type:"button",role:n?"checkbox":void 0,"aria-checked":n?r:void 0,"data-message-row":!0,"data-message-id":s.id,...a,className:C,style:D,children:T})]})}function We({sections:s,selectedThreadId:n,selectionMode:r,checkedIds:f,initialPeek:m,onToggleCheck:g,onEnterSelection:y,onOpenThread:j,onRefresh:h,refreshing:p,busy:d=!1}){const[b,v]=x.useState(new Set),[P,k]=x.useState(new Map),w=s.flatMap(a=>a.threads).filter(a=>!b.has(a.id)).map(a=>{const l=P.get(a.id);return l===void 0?a:{...a,isRead:l}}),[S,R]=x.useState(m&&m!=="none"&&w[1]?{id:w[1].id,side:m}:null),E=(a,l)=>{if(l==="trailing")v(N=>new Set(N).add(a));else{const N=w.find(C=>C.id===a);k(C=>new Map(C).set(a,!N?.isRead))}R(null)};return e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[p&&e.jsxs("div",{className:"flex items-center justify-center gap-2 border-b border-line py-3 text-fg-muted",children:[e.jsx(ve,{className:"size-4 animate-spin"}),e.jsx("span",{className:"text-xs",children:"Checking for new mail…"})]}),e.jsx("div",{className:"divide-y divide-line",children:w.map(a=>e.jsx("div",{className:d?"pointer-events-none opacity-50":void 0,children:e.jsx(Be,{thread:a,selectionMode:r,checked:f.has(a.id),active:a.id===n,peek:S?.id===a.id?S.side:"none",onPeek:l=>R(l==="none"?null:{id:a.id,side:l}),onToggleCheck:()=>g(a.id),onLongPress:()=>y(a.id),onOpen:()=>j(a.id),onAct:l=>E(a.id,l)})},a.id))}),!r&&!p&&!d&&e.jsx("button",{type:"button",onClick:h,className:"w-full border-t border-line py-2 text-center text-2xs text-fg-subtle transition-colors hover:bg-surface-sunken",children:"Pull to refresh"})]})}const Ke=new Set;function es({listTitle:s,listMeta:n,sections:r,briefFilters:f,flatList:m,listState:g="ready",searchQuery:y,listFilter:j,listScopeLabel:h,errorMessage:p,onRetry:d,onReportError:b,briefFilter:v,selectedThreadId:P,density:k="comfortable",onSelectThread:w,onOpenNav:S,isDesktop:R,initialTouchState:E,selection:a,keyboard:l,selectionBar:N,paneOverlay:C,listBody:D,hideHeader:$=!1}){const I=k==="compact"?Se:Me,T=x.useRef(null),i=x.useRef(null),o=le(l);ue({containerRef:T,itemSelector:Q,enabled:!o});const u=o?l.focusedId:void 0,M=o?u??r[0]?.threads[0]?.id:void 0,O=x.useCallback(t=>M===void 0?void 0:t===M?0:-1,[M]);x.useEffect(()=>{if(u===void 0)return;const t=i.current;if(!t)return;const c=t.querySelector(`${Q}[data-message-id="${u}"]`);!c||c===t.ownerDocument.activeElement||c.focus({preventScroll:!1})},[u]),x.useEffect(()=>{if(!o)return;const t=i.current;if(!t)return;const c=t.ownerDocument.activeElement;c!==null&&c!==t.ownerDocument.body||t.focus({preventScroll:!0})},[o]);const F=!R&&!f&&g==="ready",[X,K]=x.useState(!1),ee=E==="peek-trailing"?"trailing":E==="peek-leading"?"leading":void 0,se=()=>{K(!0),setTimeout(()=>K(!1),1400)},_=a?.selectedIds??Ke,L=a?.onToggle,Y=a?.onRowSelect,te=Re(_.size,R),H=x.useCallback(t=>{if(L)return{checked:_.has(t),onToggle:c=>{c.preventDefault(),c.stopPropagation(),L(t)}}},[_,L]),B=x.useCallback((t,c)=>Y?.(t,ke(c))?(c.preventDefault(),c.shiftKey&&window.getSelection()?.removeAllRanges(),!0):!1,[Y]),ne=x.useCallback(({thread:t,active:c,onClick:W})=>e.jsx(I,{thread:t,active:c,focused:t.id===u,tabIndex:O(t.id),selection:H(t.id),onClick:ae=>{B(t.id,ae)||W?.()}}),[I,H,B,u,O]);return e.jsxs("section",{ref:t=>{i.current=t,l?.ref(t)},tabIndex:o?-1:void 0,className:"relative flex h-full w-full flex-col bg-surface outline-none",children:[N??($?null:e.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[S&&e.jsx(A,{variant:"ghost",size:"sm",icon:e.jsx(Le,{className:"size-4"}),onClick:S,"aria-label":"Open folders",className:"-ml-1 shrink-0"}),e.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:s}),n&&e.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle",children:n})]})),g==="loading"?e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsx(De,{})}):g==="empty"?e.jsx(Te,{filter:j,scopeLabel:h,searchQuery:y}):g==="error"?e.jsx(Fe,{message:p,onRetry:d,onReport:b}):f?e.jsx(de,{...v??{},sections:r,selectedThreadId:P,Row:ne,keyboard:l,onSelectThread:w}):D??(F?e.jsx(We,{sections:r,selectedThreadId:P,selectionMode:te,checkedIds:_,initialPeek:ee,onToggleCheck:t=>L?.(t),onEnterSelection:t=>L?.(t),onOpenThread:t=>w?.(t),onRefresh:se,refreshing:X}):e.jsx("div",{ref:T,className:"flex-1 overflow-y-auto",children:r.map(t=>e.jsxs("div",{children:[!m&&t.label&&e.jsxs("div",{className:"sticky top-0 flex h-section-row items-center justify-between border-b border-line bg-surface-sunken px-row-inset",children:[e.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:t.label}),e.jsx("span",{className:"text-2xs text-fg-subtle tabular-nums",children:t.threads.length})]}),e.jsx("div",{className:"divide-y divide-line",children:t.threads.map(c=>e.jsx(I,{thread:c,active:c.id===P,focused:c.id===u,tabIndex:O(c.id),selection:H(c.id),onClick:W=>{B(c.id,W)||w?.(c.id)}},c.id))})]},t.id))})),R&&e.jsx(Ee,{hints:l?we(l.handlers):je}),C]})}var Ye=class extends fe{constructor(s,n){super(s,n)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(s){s._type="infinite",super.setOptions(s)}getOptimisticResult(s){return s._type="infinite",super.getOptimisticResult(s)}fetchNextPage(s){return this.fetch({...s,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(s){return this.fetch({...s,meta:{fetchMore:{direction:"backward"}}})}createResult(s,n){const{state:r}=s,f=super.createResult(s,n),{isFetching:m,isRefetching:g,isError:y,isRefetchError:j}=f,h=r.fetchMeta?.fetchMore?.direction,p=y&&h==="forward",d=m&&h==="forward",b=y&&h==="backward",v=m&&h==="backward";return{...f,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:xe(n,r.data),hasPreviousPage:me(n,r.data),isFetchNextPageError:p,isFetchingNextPage:d,isFetchPreviousPageError:b,isFetchingPreviousPage:v,isRefetchError:j&&!p&&!b,isRefetching:g&&!d&&!v}}};function ss(s,n){return ge(s,Ye)}function ts({title:s,unreadCount:n,preset:r,selectedCategory:f,activeFilters:m,onSelectCategory:g,onToggleFilter:y,onSelectSource:j,onClearFilters:h,children:p,footer:d,searchResults:b,searchLoading:v,relatedResults:P,relatedLoading:k,onSelectSearchResult:w,searchResultsLabel:S,relatedResultsLabel:R,searchResultsInBody:E,refreshControl:a}){const{searchInput:l}=he(),N=l.trim().length>0,C={categories:r.categories,filters:r.filters,sources:r.sources,selectedCategory:f,activeFilters:m,onSelectCategory:g,onSelectSource:j,onToggleFilter:y,onClear:h};return e.jsx(pe,{hasSheet:!N,children:e.jsx(Ie,{title:s,unreadCount:n,footer:d,searchFilter:C,searchResults:b,searchLoading:v,relatedResults:P,relatedLoading:k,onSelectSearchResult:w,searchResultsLabel:S,relatedResultsLabel:R,searchResultsInBody:E,refreshControl:a,children:e.jsx(be,{...C,hideChrome:N,children:p})})})}export{Ze as M,Be as S,es as a,ts as b,ss as u};