@remit/web-client-dist 0.0.321 → 0.0.323

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 (86) hide show
  1. package/assets/{BriefPane-BvS6OY3_.js → BriefPane-BJxOwp8m.js} +1 -1
  2. package/assets/{ErrorState-By22X09V.js → ErrorState-DZM_kyxb.js} +1 -1
  3. package/assets/{FlaggedPane-COtoIxw_.js → FlaggedPane-CT_N453X.js} +1 -1
  4. package/assets/{MailListHeader-CzkFVHra.js → MailListHeader-CaZUuANM.js} +6 -6
  5. package/assets/{MailViewChrome-_M0MZo3I.js → MailViewChrome-ClVgpPFO.js} +1 -1
  6. package/assets/{MailboxPane-DxXhzeri.js → MailboxPane-Cpo0ICDX.js} +1 -1
  7. package/assets/{NavMenuButton-DmFeFE-H.js → NavMenuButton-D-esVAha.js} +1 -1
  8. package/assets/{OnboardingWizard-KL6He6rZ.js → OnboardingWizard-Dv0CNLJu.js} +1 -1
  9. package/assets/OutboxPane-HUY9JhOn.js +1 -0
  10. package/assets/_mailboxId-BHSTiA2e.js +1 -0
  11. package/assets/_messageId-BNu6TlV_.js +1 -0
  12. package/assets/_outboxMessageId-D2tWCsPG.js +1 -0
  13. package/assets/_threadId-JHkXbYFV.js +1 -0
  14. package/assets/{account-form-helpers-DgsG82nf.js → account-form-helpers-Bsx48lx1.js} +1 -1
  15. package/assets/{accounts-DPg0TXKK.js → accounts-CBdVBnhy.js} +1 -1
  16. package/assets/{advanced-BcHKt9Ee.js → advanced-BuaLHou0.js} +1 -1
  17. package/assets/{appearance-BTcWKzSp.js → appearance-BQ0Dg1ei.js} +1 -1
  18. package/assets/{avatar-B5Xfa_Aj.js → avatar-DdSaEl5o.js} +1 -1
  19. package/assets/{bottom-sheet-CWKDKUBi.js → bottom-sheet-DmAG_FCk.js} +1 -1
  20. package/assets/{brief-B121wlDA.js → brief-D_aKiQy5.js} +1 -1
  21. package/assets/brief-IOLPzmXc.js +1 -0
  22. package/assets/{browser-ponyfill-Dnwm2Nul.js → browser-ponyfill-DZK7BleO.js} +1 -1
  23. package/assets/{circle-check-D_nZdueG.js → circle-check-DZneB6gk.js} +1 -1
  24. package/assets/{circle-check-big-Dm9DZK8n.js → circle-check-big-DT6yugdt.js} +1 -1
  25. package/assets/{circle-help-BGR1fVqk.js → circle-help-BJ-e95sd.js} +1 -1
  26. package/assets/{clock-LgAy7KhC.js → clock-CQOmlok1.js} +1 -1
  27. package/assets/{confirm-dialog-d8zs8D-F.js → confirm-dialog-DKl9zp18.js} +1 -1
  28. package/assets/{download-FAYYcvQP.js → download-LYnnm2y0.js} +1 -1
  29. package/assets/{filters-DTju1R14.js → filters-Df3eZiR5.js} +1 -1
  30. package/assets/{flagged-BoYv9IB6.js → flagged-Czys2fpG.js} +1 -1
  31. package/assets/flagged-Nt9qilw4.js +1 -0
  32. package/assets/{folders-BfrtWUpW.js → folders-CPk7FXDY.js} +1 -1
  33. package/assets/index-BNu6TlV_.js +1 -0
  34. package/assets/index-BXK1iByh.js +1 -0
  35. package/assets/index-Bd4SvJ27.js +1 -0
  36. package/assets/index-ByG6CDPW.js +1 -0
  37. package/assets/{index-3eAE16lF.js → index-CNoNYU4b.js} +58 -58
  38. package/assets/index-D4cNcmeL.js +1 -0
  39. package/assets/index-DtQuG32K.js +1 -0
  40. package/assets/{kbd-BVVVI8MK.js → kbd-BrhLdlau.js} +1 -1
  41. package/assets/{labels-BjFJ4XU1.js → labels-CaG9l1EM.js} +1 -1
  42. package/assets/mail-CUfL3Goi.js +1 -0
  43. package/assets/{menu-B3HPQBVa.js → menu-Bo_ZQ3dZ.js} +1 -1
  44. package/assets/{move-options-s_k2CE-Q.js → move-options-Cg4YrriV.js} +1 -1
  45. package/assets/nav-link-BCGmsThK.js +1 -0
  46. package/assets/{onboarding-BxbMIMO7.js → onboarding-BPGOK63U.js} +1 -1
  47. package/assets/outbox-pF0wQVQO.js +1 -0
  48. package/assets/{pencil-6AbAHB79.js → pencil-CPDJ8KvT.js} +1 -1
  49. package/assets/{rich-text-BA11pr6t.js → rich-text-DMA7APe6.js} +2 -2
  50. package/assets/{rotate-ccw-CgMVBPU0.js → rotate-ccw-Dc0Ronfg.js} +1 -1
  51. package/assets/{row-actions-Cfzm03L2.js → row-actions-ExiBwpBF.js} +1 -1
  52. package/assets/{search-scope-Bcn1kzwd.js → search-scope-Ds_ghZOi.js} +1 -1
  53. package/assets/search-token-index-BTQUgi2G.js +1 -0
  54. package/assets/{search-view-BtUa3wf0.js → search-view-CXPbecDB.js} +1 -1
  55. package/assets/{senders-DsoPkIii.js → senders-MC2FrOMF.js} +1 -1
  56. package/assets/settings-B8a8GsFB.js +1 -0
  57. package/assets/{settings-screen-jzEUDPFx.js → settings-screen-x0E-yYQb.js} +1 -1
  58. package/assets/{shield-check-Dq-7lUbt.js → shield-check-CA34sFyn.js} +1 -1
  59. package/assets/{suggested-vips-9VOMpahq.js → suggested-vips-DWT9IWLZ.js} +1 -1
  60. package/assets/{useDebouncedValue-nan84ZZT.js → useDebouncedValue-CQf4QpzS.js} +1 -1
  61. package/assets/{useFilters-laocR3nD.js → useFilters-CaSSUNWE.js} +1 -1
  62. package/assets/{useLabels-Bzefby_I.js → useLabels-DKpzozgD.js} +1 -1
  63. package/assets/{useMediaQuery-vS62WMhd.js → useMediaQuery-CAv9qAps.js} +1 -1
  64. package/assets/{useRefreshControl-DivGdE-V.js → useRefreshControl-B41i_Tqe.js} +1 -1
  65. package/assets/{useSearchMirror-BJ2isjrf.js → useSearchMirror--YnVEyRo.js} +1 -1
  66. package/assets/{useSearchTokenContext-DKU_0B8G.js → useSearchTokenContext-DIryp5er.js} +2 -2
  67. package/assets/{useSemanticSearch-Br2klJqm.js → useSemanticSearch-DDwHlaH_.js} +1 -1
  68. package/assets/{useSignature-DEHQxXCm.js → useSignature-C0EjJ_Wk.js} +1 -1
  69. package/index.html +1 -1
  70. package/package.json +1 -1
  71. package/assets/OutboxPane-BTeGPBk1.js +0 -1
  72. package/assets/_mailboxId-CNHu38xX.js +0 -1
  73. package/assets/_messageId-D_A2HKiL.js +0 -1
  74. package/assets/_threadId-BVUvwFWI.js +0 -1
  75. package/assets/brief-BaArslj1.js +0 -1
  76. package/assets/flagged-BU2-QoPm.js +0 -1
  77. package/assets/index-BJYlc6-u.js +0 -1
  78. package/assets/index-BLqvw8Q9.js +0 -1
  79. package/assets/index-C-5LrpJf.js +0 -1
  80. package/assets/index-C6qTCMjJ.js +0 -1
  81. package/assets/index-CLxW3Goq.js +0 -1
  82. package/assets/index-D_A2HKiL.js +0 -1
  83. package/assets/mail-C8sEJWa1.js +0 -1
  84. package/assets/outbox-D7_yfM4h.js +0 -1
  85. package/assets/search-token-index-XT09xk5-.js +0 -1
  86. package/assets/settings-6lKvObGd.js +0 -1
@@ -1 +1 @@
1
- import{c as t}from"./index-3eAE16lF.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-CNoNYU4b.js";const e=t("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);export{e as R};
@@ -1 +1 @@
1
- import{r as e,j as l,B as b,b as y,al as x}from"./index-3eAE16lF.js";const i=()=>l.jsx(x,{className:"size-3.5 animate-spin"}),m=(s,n)=>n?l.jsx("span",{className:"sr-only",children:s}):s;function p({actions:s=[],destructive:n,className:o}){const[f,r]=e.useState(!1);return f&&n?.confirm?l.jsxs("div",{className:y("flex items-center gap-2",o),children:[l.jsx("span",{className:"text-xs text-fg-muted",children:n.confirm.prompt}),l.jsx(b,{variant:"secondary",size:"sm",onClick:()=>r(!1),children:n.confirm.cancelLabel??"Cancel"}),l.jsx(b,{variant:"danger",size:"sm","aria-busy":n.busy,icon:n.busy?i():void 0,onClick:()=>{n.busy||n.onClick()},children:n.busy?n.busyLabel??"Working…":n.confirm.confirmLabel??n.label})]}):l.jsxs("div",{className:y("flex items-center gap-2",o),children:[s.map(a=>l.jsx(b,{variant:a.variant??"ghost",size:"sm","aria-busy":a.busy,"aria-label":a.iconOnly?a.label:void 0,icon:a.busy?i():a.icon,onClick:()=>{a.busy||a.onClick()},children:a.busy&&a.busyLabel?a.busyLabel:m(a.label,a.iconOnly)},a.label)),n&&l.jsx(b,{variant:"ghost",size:"sm","aria-busy":n.busy,"aria-label":n.iconOnly?n.label:void 0,icon:n.busy?i():n.icon,onClick:()=>{if(!n.busy){if(n.confirm){r(!0);return}n.onClick()}},children:n.busy&&n.busyLabel?n.busyLabel:m(n.label,n.iconOnly)})]})}export{p as R};
1
+ import{r as e,j as l,B as b,b as y,al as x}from"./index-CNoNYU4b.js";const i=()=>l.jsx(x,{className:"size-3.5 animate-spin"}),m=(s,n)=>n?l.jsx("span",{className:"sr-only",children:s}):s;function p({actions:s=[],destructive:n,className:o}){const[f,r]=e.useState(!1);return f&&n?.confirm?l.jsxs("div",{className:y("flex items-center gap-2",o),children:[l.jsx("span",{className:"text-xs text-fg-muted",children:n.confirm.prompt}),l.jsx(b,{variant:"secondary",size:"sm",onClick:()=>r(!1),children:n.confirm.cancelLabel??"Cancel"}),l.jsx(b,{variant:"danger",size:"sm","aria-busy":n.busy,icon:n.busy?i():void 0,onClick:()=>{n.busy||n.onClick()},children:n.busy?n.busyLabel??"Working…":n.confirm.confirmLabel??n.label})]}):l.jsxs("div",{className:y("flex items-center gap-2",o),children:[s.map(a=>l.jsx(b,{variant:a.variant??"ghost",size:"sm","aria-busy":a.busy,"aria-label":a.iconOnly?a.label:void 0,icon:a.busy?i():a.icon,onClick:()=>{a.busy||a.onClick()},children:a.busy&&a.busyLabel?a.busyLabel:m(a.label,a.iconOnly)},a.label)),n&&l.jsx(b,{variant:"ghost",size:"sm","aria-busy":n.busy,"aria-label":n.iconOnly?n.label:void 0,icon:n.busy?i():n.icon,onClick:()=>{if(!n.busy){if(n.confirm){r(!0);return}n.onClick()}},children:n.busy&&n.busyLabel?n.busyLabel:m(n.label,n.iconOnly)})]})}export{p as R};
@@ -1 +1 @@
1
- import{c8 as a,cX as c,cY as d}from"./index-3eAE16lF.js";function p(e){const t=a({warn:e?.router===void 0}),o=e?.router||t;return c(o.stores.__store,d(e,o))}const n="/mail/brief",s="/mail/$mailboxId",u="/mail/outbox",l="/mail/flagged";function i(e){for(const t of e){if(t.routeId===n)return{list:"brief"};if(t.routeId===l)return{list:"flagged"};if(t.routeId===u)return{list:"outbox"};if(t.routeId===s)return{list:"mailbox",mailboxId:t.params?.mailboxId}}}function _(e){const t=i(e);if(!t)return"";switch(t.list){case"mailbox":return t.mailboxId?f(t.mailboxId):"";case"flagged":return l;case"outbox":return u;case"brief":return n}}function f(e){return`${s}:${e}`}function g(e,t){return e===t?!0:e.startsWith(`${t}/`)}function R(e){const t=e.split(/[?#]/)[0].split("/").filter(Boolean);return t[0]==="mail"&&t.length>2}const r="search-scope";function b(e){const t=e.trim().replace(/\s+/g," ").toLowerCase();return/\s/.test(t)?`in:"${t}"`:`in:${t}`}function m(e){const t=i(e);return t!==void 0&&t.list!=="brief"}function I(e){const t=i(e);return t?.list==="mailbox"?t.mailboxId:void 0}function M(e){const t=I(e.matches);return t||(m(e.matches)?e.callerMailboxId:e.callerMailboxId??e.inTokenMailboxId)}function S(e,t){const o=i(e);return o?.list==="flagged"?{kind:"scoped",chip:{id:r,label:"is:starred"}}:o?.list==="outbox"?{kind:"scoped",chip:{id:r,label:"in:outbox"}}:o?.list==="mailbox"?t?{kind:"scoped",chip:{id:r,label:b(t)}}:{kind:"pending"}:{kind:"global"}}function h(e,t,o){return t.kind==="global"?{kind:"global"}:i(e)?.list==="flagged"?{kind:"collection"}:{kind:"folder",...o?{role:o}:{}}}export{r as S,g as a,h as b,S as c,m as i,R as l,_ as m,I as r,M as s,p as u};
1
+ import{c7 as a,cX as c,cY as d}from"./index-CNoNYU4b.js";function p(e){const t=a({warn:e?.router===void 0}),o=e?.router||t;return c(o.stores.__store,d(e,o))}const n="/mail/brief",s="/mail/$mailboxId",u="/mail/outbox",l="/mail/flagged";function i(e){for(const t of e){if(t.routeId===n)return{list:"brief"};if(t.routeId===l)return{list:"flagged"};if(t.routeId===u)return{list:"outbox"};if(t.routeId===s)return{list:"mailbox",mailboxId:t.params?.mailboxId}}}function _(e){const t=i(e);if(!t)return"";switch(t.list){case"mailbox":return t.mailboxId?f(t.mailboxId):"";case"flagged":return l;case"outbox":return u;case"brief":return n}}function f(e){return`${s}:${e}`}function g(e,t){return e===t?!0:e.startsWith(`${t}/`)}function R(e){const t=e.split(/[?#]/)[0].split("/").filter(Boolean);return t[0]==="mail"&&t.length>2}const r="search-scope";function b(e){const t=e.trim().replace(/\s+/g," ").toLowerCase();return/\s/.test(t)?`in:"${t}"`:`in:${t}`}function m(e){const t=i(e);return t!==void 0&&t.list!=="brief"}function I(e){const t=i(e);return t?.list==="mailbox"?t.mailboxId:void 0}function M(e){const t=I(e.matches);return t||(m(e.matches)?e.callerMailboxId:e.callerMailboxId??e.inTokenMailboxId)}function S(e,t){const o=i(e);return o?.list==="flagged"?{kind:"scoped",chip:{id:r,label:"is:starred"}}:o?.list==="outbox"?{kind:"scoped",chip:{id:r,label:"in:outbox"}}:o?.list==="mailbox"?t?{kind:"scoped",chip:{id:r,label:b(t)}}:{kind:"pending"}:{kind:"global"}}function h(e,t,o){return t.kind==="global"?{kind:"global"}:i(e)?.list==="flagged"?{kind:"collection"}:{kind:"folder",...o?{role:o}:{}}}export{r as S,g as a,h as b,S as c,m as i,R as l,_ as m,I as r,M as s,p as u};
@@ -0,0 +1 @@
1
+ import{c as A,r as u,j as m,g as V,b as I,cK as z,X as G,J as N,z as j,l as $,s as X,t as F,v as q,y as J,D as W,o as Y,n as Z,cm as R}from"./index-CNoNYU4b.js";import{u as ee,c as te,S as ne}from"./search-scope-Ds_ghZOi.js";import{a as L,D as oe}from"./useMediaQuery-CAv9qAps.js";const Ee=A("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 Ie=A("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"}]]),re=[{action:"focusNext",keys:["j","k"],label:"navigate"},{action:"muteSender",keys:["m"],label:"mute"},{action:"help",keys:["?"],label:"all shortcuts"}];function Ne(e){return re.filter(t=>e[t.action]!==void 0)}const se=[{title:"Navigation",hints:[{action:"focusNext",keys:["j"],description:"Focus next message"},{action:"focusPrevious",keys:["k"],description:"Focus previous message"},{action:"focusNext",keys:["↓"],description:"Focus next message"},{action:"focusPrevious",keys:["↑"],description:"Focus previous message"},{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 ie(e){for(const t of se){const n=t.hints.find(r=>r.action===e);if(n)return n.keys}}function ae(e){const t=ie(e);return!t||t.length===0?"":t.length===1?t[0]??"":t[0]==="g"?t.join(" then "):t.join("")}function Te(e){const t=ae(e);return t===""?"":`(${t})`}const b={action:null,nextPrefix:null,preventDefault:!1},ce={b:"goBrief",i:"goInbox",s:"goSent",f:"goFlagged",",":"goSettings"},le={j:{action:"focusNext"},k:{action:"focusPrevious"},arrowdown:{action:"focusNext"},arrowup:{action:"focusPrevious"},home:{action:"focusFirst"},end:{action:"focusLast"},enter:{action:"openFocused"}," ":{action:"toggleSelect"},delete:{action:"delete"},backspace:{action:"delete"},u:{action:"toggleRead"},x:{action:"toggleSelect"},r:{action:"reply"},a:{action:"replyAll"},f:{action:"forward"},"#":{action:"delete"},s:{action:"toggleStar"},m:{action:"muteSender"},b:{action:"blockSender"},v:{action:"vipSender"},"!":{action:"markJunk"},i:{action:"toggleIntelligence"},d:{action:"toggleDensity"},"/":{action:"focusSearch"},c:{action:"compose"},"?":{action:"help"}};function ue(e,t){const n=e.key.toLowerCase(),r=e.metaKey||e.ctrlKey;if(e.inEditable)return{...b,nextPrefix:t==="g"?null:t};if(e.onControl&&(n==="enter"||n===" "))return{...b,nextPrefix:t==="g"?null:t};if(r&&n==="n")return{action:"compose",nextPrefix:null,preventDefault:!0};if(r&&n==="a")return{action:"selectAll",nextPrefix:null,preventDefault:!0};if(r)return{...b,nextPrefix:t==="g"?null:t};if(n==="escape")return{action:"back",nextPrefix:null,preventDefault:!1};if(t==="g"){const a=ce[n===","?",":n]??null;return{action:a,nextPrefix:null,preventDefault:a!==null}}if(n==="g"&&!e.shiftKey)return{action:null,nextPrefix:"g",preventDefault:!0};if(e.shiftKey){const s=n==="j"||n==="arrowdown";if(s||(n==="k"||n==="arrowup"))return{action:s?"extendSelectDown":"extendSelectUp",nextPrefix:null,preventDefault:!0}}const o=le[n];if(o){const s=o.requireShift===!0,a=n.length===1&&!/[a-z0-9]/.test(n);return!s&&e.shiftKey&&!a?b:{action:o.action,nextPrefix:null,preventDefault:!0}}return b}function fe(e){if(!(e instanceof HTMLElement))return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable}const de="data-message-row",pe='button, a[href], summary, [role="button"], [role="menuitem"], [role="tab"], [role="switch"], [role="checkbox"]';function me(e){if(!(e instanceof HTMLElement))return!1;const t=e.closest(pe);return t?!t.hasAttribute(de):!1}function he({key:e,shiftKey:t=!1,repeat:n=!1,caretAtStart:r,hasValue:o,chipCount:s}){const a=s-1;return e==="Escape"?o?{type:"clearQuery"}:{type:"blur"}:e==="Tab"&&t?s===0?{type:"none"}:{type:"focusChip",index:a}:e==="Backspace"||e==="ArrowLeft"?!r||s===0?{type:"none"}:n?{type:"none"}:{type:"focusChip",index:a}:{type:"none"}}function ye({key:e,repeat:t=!1,index:n,chipCount:r}){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>=r-1?{type:"focusInput"}:{type:"focusChip",index:n+1}:e==="Enter"||e===" "?{type:"activateChip",index:n}:e==="Escape"?{type:"focusInput"}:{type:"none"}}function ge(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,be=({chips:e=[],onRemoveChip:t,value:n,onChange:r,onClear:o,onClearQuery:s,placeholder:a="Search mail...",globalFocusKey:c=!0,showClearButton:f=!0,size:h="sm",inputId:p,suggest:d,className:x})=>{const O=u.useId(),T=p??O,k=u.useRef(null),D=u.useRef([]),P=s??o,[K,w]=u.useState(null),C=u.useRef(void 0),[B,H]=u.useState(""),v=e.length>0;u.useEffect(()=>{w(i=>i!==null&&i>=e.length?null:i)},[e.length]),u.useEffect(()=>{const i=C.current;if(i!==void 0){if(C.current=void 0,i===null){k.current?.focus();return}D.current[i]?.focus()}});const M=u.useRef(void 0);u.useEffect(()=>{const i=d?.caret;if(!i||i===M.current)return;M.current=i;const l=k.current;!l||l.ownerDocument.activeElement!==l||(l.setSelectionRange(i.cursor,i.cursor),d?.onCaretChange(i.cursor))});const S=i=>{d?.onCaretChange(i.selectionStart??i.value.length)},y=u.useCallback(i=>{w(i),C.current=i},[]),E=u.useCallback(i=>{const l=e[i];l&&t&&(y(ge(i,e.length)),H(`${l.label} removed`),t(l.id))},[e,t,y]),_=u.useCallback(()=>{y(null),o()},[o,y]),U=u.useCallback(i=>{const l=i.currentTarget;if(d?.onKeyDown(i))return;const g=he({key:i.key,shiftKey:i.shiftKey,repeat:i.repeat,caretAtStart:l.selectionStart===0&&l.selectionEnd===0,hasValue:n.length>0,chipCount:e.length});switch(g.type){case"focusChip":i.preventDefault(),y(g.index);return;case"clearQuery":P();return;case"blur":l.blur();return;case"none":return}},[e.length,n,P,y,d]),Q=u.useCallback(i=>l=>{const g=ye({key:l.key,repeat:l.repeat,index:i,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 u.useEffect(()=>{if(!c)return;const i=l=>{l.key!=="/"||l.metaKey||l.ctrlKey||l.altKey||xe(l.target)||(l.preventDefault(),k.current?.focus())};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[c]),m.jsxs("label",{htmlFor:T,className:I("flex w-full items-center gap-1.5 text-sm","bg-surface-sunken/50 border border-transparent","focus-within:bg-canvas focus-within:border-line focus-within:ring-2 focus-within:ring-ring","transition-colors",h==="lg"?"rounded-xl px-4 py-2":"rounded-md px-2.5 py-1",x),children:[m.jsx(V,{className:I("shrink-0 text-fg-muted pointer-events-none",h==="lg"?"size-5":"size-4")}),m.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1",children:[v&&m.jsx("div",{role:"grid","aria-label":"Search filters",className:"flex min-w-0 flex-wrap items-center gap-1",children:e.map((i,l)=>m.jsx(z,{ref:g=>{D.current[l]=g},label:i.label,tone:i.tone,focused:K===l,onFocusLabel:()=>w(l),onKeyDown:Q(l),onRemove:()=>E(l)},i.id))}),m.jsx("input",{ref:k,id:T,name:"q",type:"text","aria-label":"Search mail",autoComplete:"off",value:n,tabIndex:K===null?0:-1,onChange:i=>{r(i.target.value),S(i.target)},onKeyDown:U,onKeyUp:i=>S(i.currentTarget),onClick:i=>S(i.currentTarget),onFocus:i=>{w(null),d?.onFocusChange?.(!0),S(i.currentTarget)},onBlur:()=>d?.onFocusChange?.(!1),...d?.comboboxProps,placeholder:v?void 0:a,className:"min-w-24 flex-1 bg-transparent text-fg outline-none placeholder:text-fg-muted"})]}),(n||v)&&f&&m.jsx("button",{type:"button",onClick:_,className:"shrink-0 rounded p-0.5 hover:bg-surface-raised transition-colors","aria-label":"Clear search",children:m.jsx(G,{className:I("text-fg-muted",h==="lg"?"size-5":"size-4")})}),m.jsx("span",{role:"status","aria-live":"polite",className:"sr-only",children:B})]})},De=({value:e,onChange:t,onClear:n,onClearQuery:r,chips:o,onRemoveChip:s,placeholder:a="Search mail...",globalFocusKey:c=!0,showClearButton:f=!0,size:h,inputId:p,suggest:d,className:x})=>m.jsx(be,{value:e,onChange:t,onClear:n,onClearQuery:r,chips:o,onRemoveChip:s,placeholder:a,globalFocusKey:c,showClearButton:f,size:h,inputId:p,suggest:d,className:x});function Pe({handlers:e,enabled:t=!0,target:n,sequenceTimeoutMs:r=1e3}){const o=u.useRef(e);o.current=e;const s=u.useRef(null),a=u.useRef(null);u.useEffect(()=>{if(!t)return;const c=()=>{a.current!==null&&(clearTimeout(a.current),a.current=null)},f=p=>{const d=ue({key:p.key,shiftKey:p.shiftKey,metaKey:p.metaKey,ctrlKey:p.ctrlKey,altKey:p.altKey,inEditable:fe(p.target),onControl:me(p.target)},s.current);if(c(),s.current=d.nextPrefix,d.nextPrefix!==null&&(a.current=setTimeout(()=>{s.current=null,a.current=null},r)),d.action===null)return;const x=o.current[d.action];x&&(d.preventDefault&&p.preventDefault(),x())},h=n===void 0?window:n;if(h!==null)return h.addEventListener("keydown",f),()=>{h.removeEventListener("keydown",f),c(),s.current=null}},[t,r,n])}const Ke=({trigger:e,children:t,align:n="right"})=>{const[r,o]=u.useState(!1),s=u.useRef(null),a=u.useCallback(f=>{s.current&&!s.current.contains(f.target)&&o(!1)},[]),c=u.useCallback(f=>{f.key==="Escape"&&o(!1)},[]);return u.useEffect(()=>(r&&(document.addEventListener("mousedown",a),document.addEventListener("keydown",c)),()=>{document.removeEventListener("mousedown",a),document.removeEventListener("keydown",c)}),[r,a,c]),m.jsxs("div",{ref:s,className:"relative",children:[m.jsx("button",{type:"button",onClick:f=>{f.stopPropagation(),o(!r)},className:N("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}),r&&m.jsx("div",{className:N("absolute z-50 mt-1 min-w-[180px] py-1","bg-surface border border-line rounded-md shadow-lg",n==="right"?"right-0":"left-0"),children:t})]})},Me=({onClick:e,disabled:t,destructive:n,children:r})=>m.jsx("button",{type:"button",onClick:o=>{o.stopPropagation(),t||e()},disabled:t,className:N("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:r}),Re=()=>m.jsx("div",{className:"my-1 h-px bg-line"}),ke=({accounts:e})=>{const t=j({strict:!1}),n=$(),r=t.mailboxId,{t:o}=X("mail",{useSuspense:!1}),s=u.useCallback((c,f)=>o(c,{defaultValue:f}),[o]),a=F({queries:e.map(c=>({...q({path:{accountId:c.accountId}}),staleTime:1/0}))});if(n.pathname.startsWith("/mail/outbox"))return"Outbox";if(!r)return null;for(let c=0;c<e.length;c++){const f=a[c]?.data?.items;if(!f)continue;const h=f.find(d=>d.mailboxId===r);if(!h)continue;const p=J(e[c].folderAppointments);return W(h,p.get(r),s)}return null},Le=({accounts:e})=>{const n=j({strict:!1}).mailboxId,r=F({queries:e.map(o=>({...q({path:{accountId:o.accountId}}),staleTime:1/0}))});if(!n)return null;for(const o of r){const s=o.data?.items;if(!s)continue;const a=s.find(c=>c.mailboxId===n);if(a)return a.unseenCount}return null};function Ae(e){const t=Y(),{searchInput:n}=Z(),r=ke({accounts:e}),o=ee({select:c=>c.matches}),s=te(o,r),a=u.useCallback(c=>{c===ne&&t({to:"/mail/brief",search:{q:n||void 0}})},[t,n]);return{scope:s,clearScope:a}}const je=({enabled:e=!0,bindings:t,capture:n=!1})=>{const r=u.useCallback(o=>{const s=o.target;if(!(s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.isContentEditable))for(const a of t){if(!(o.key.toLowerCase()===a.key.toLowerCase())||a.requireShift!==void 0&&a.requireShift!==o.shiftKey)continue;const f=o.ctrlKey||o.metaKey;if(a.requireMeta!==void 0){if(a.requireMeta!==f)continue}else{const h=a.noModifiers??!0,p=f||o.altKey||a.requireShift===void 0&&o.shiftKey;if(h&&p)continue}a.preventDefault&&o.preventDefault(),a.stopPropagation&&(o.stopPropagation(),o.stopImmediatePropagation()),a.handler(o);return}},[t]);u.useEffect(()=>{if(e)return window.addEventListener("keydown",r,n),()=>window.removeEventListener("keydown",r,n)},[e,r,n])},we=768,Fe=e=>e!=="desktop",qe=()=>{const e=L(`(min-width: ${we}px)`);return L(oe)?"desktop":e?"tablet":"phone"};function Oe(e){const t=new Map;for(const n of e){const r=n.email.toLowerCase(),o=r.split("@")[0];o&&!t.has(o)&&t.set(o,n.accountId),t.has(r)||t.set(r,n.accountId)}return t}function Be(e){const t=new Map;for(const n of e)for(const r of n){const o=r.fullPath?.toLowerCase();if(!o)continue;const s=o.split("/").pop();t.has(o)||t.set(o,r.mailboxId),s&&!t.has(s)&&t.set(s,r.mailboxId)}return t}function He(e,t=[]){const n=e.flat().filter(s=>s.fullPath),r=new Map;for(const s of n){const a=R(s.fullPath).toLowerCase();r.set(a,(r.get(a)??0)+1)}const o=new Map(t.map(s=>[s.accountId,s.email]));return n.map(s=>{const a=R(s.fullPath),c=r.get(a.toLowerCase())===1,f=t.length>1?o.get(s.accountId):void 0;return{value:c?a:s.fullPath,label:s.displayNameOverride?.trim()||a,...f?{hint:f}:{}}})}function _e(e){const t=new Map;for(const n of e){const r=n.email.toLowerCase().split("@")[0]??"";t.set(r,(t.get(r)??0)+1)}return e.map(n=>{const r=n.email.split("@")[0]??n.email,o=t.get(r.toLowerCase())===1,s=n.displayName?.trim();return{value:o?r:n.email,label:s||n.email,...s?{hint:n.email}:{}}})}export{Ee as B,Ke as D,se as K,Ie as R,De as S,Re as a,Me as b,Be as c,qe as d,je as e,Pe as f,Oe as g,ke as h,Fe as i,Le as j,re as k,Ne as l,de as m,He as n,_e as o,ae as s,Te as t,Ae as u};
@@ -1 +1 @@
1
- import{r as u,j as a,a3 as i,a4 as p}from"./index-3eAE16lF.js";import{a as f}from"./search-scope-Bcn1kzwd.js";const c=u.createContext(null),h=({chrome:r,children:n})=>a.jsx(c.Provider,{value:r,children:n});function O({phone:r,list:n,reading:t,intelligence:o,hasThread:s=!1}){const e=u.useContext(c);if(!e)return a.jsx(i,{});const l={nav:e.nav,overlay:e.overlay,skeleton:a.jsx(i,{}),isLoading:e.isLoading,navOpen:e.navOpen,onOpenNav:e.onOpenNav,onCloseNav:e.onCloseNav};return e.isSinglePane?a.jsx(p,{...l,list:r,intelligenceOpen:e.intelligenceOpen}):a.jsx(p,{...l,topBar:e.topBar,list:n,reading:t,intelligence:o,intelligenceOpen:e.intelligenceOpen,hasThread:s})}function S(r,n,t){if(r!==n)return t}function d(r,n){return r===""?"":n}function g({searchInput:r,committedQuery:n,urlQuery:t,pathname:o,listPath:s}){return!f(o,s)||n!==r?!1:n!==t}export{h as M,O as a,g as b,d as c,S as s};
1
+ import{r as u,j as a,a3 as i,a4 as p}from"./index-CNoNYU4b.js";import{a as f}from"./search-scope-Ds_ghZOi.js";const c=u.createContext(null),h=({chrome:r,children:n})=>a.jsx(c.Provider,{value:r,children:n});function O({phone:r,list:n,reading:t,intelligence:o,hasThread:s=!1}){const e=u.useContext(c);if(!e)return a.jsx(i,{});const l={nav:e.nav,overlay:e.overlay,skeleton:a.jsx(i,{}),isLoading:e.isLoading,navOpen:e.navOpen,onOpenNav:e.onOpenNav,onCloseNav:e.onCloseNav};return e.isSinglePane?a.jsx(p,{...l,list:r,intelligenceOpen:e.intelligenceOpen}):a.jsx(p,{...l,topBar:e.topBar,list:n,reading:t,intelligence:o,intelligenceOpen:e.intelligenceOpen,hasThread:s})}function S(r,n,t){if(r!==n)return t}function d(r,n){return r===""?"":n}function g({searchInput:r,committedQuery:n,urlQuery:t,pathname:o,listPath:s}){return!f(o,s)||n!==r?!1:n!==t}export{h as M,O as a,g as b,d as c,S as s};
@@ -1 +1 @@
1
- import{j as e,b as N,o as z,r as c,ax as q,aj as L,g as O,aB as $,w as I,b6 as A,q as k,ad as C,b7 as M,b8 as P,B as S,a as B,b9 as R,X as G}from"./index-3eAE16lF.js";import{K as m}from"./kbd-BVVVI8MK.js";import{S as Q,a as E}from"./settings-screen-jzEUDPFx.js";import{E as V}from"./ErrorState-By22X09V.js";import{u as K}from"./useDebouncedValue-nan84ZZT.js";import{a as _}from"./format-De9HZKjg.js";import"./avatar-B5Xfa_Aj.js";import"./menu-B3HPQBVa.js";import"./circle-help-BGR1fVqk.js";function D({options:t,active:r,onSelect:x}){return e.jsx("div",{role:"tablist",className:N("flex shrink-0 gap-1 overflow-x-auto border-b border-line p-2","lg:w-44 lg:flex-col lg:gap-0 lg:overflow-visible lg:border-r lg:border-b-0 lg:py-2 lg:pr-2 lg:pl-3"),children:t.map(a=>{const d=a.id===r;return e.jsxs("button",{type:"button",role:"tab","aria-selected":d,onClick:()=>x(a.id),className:N("flex min-h-11 shrink-0 items-center gap-2 rounded-md px-3 text-left text-sm transition-colors lg:min-h-0 lg:px-2 lg:py-1",d?"bg-accent-2-soft font-medium text-accent-2":"text-fg-muted hover:bg-surface-sunken hover:text-fg"),children:[e.jsx("span",{className:"flex-1 truncate",children:a.label}),e.jsx("span",{className:N("text-2xs tabular-nums",d?"text-accent-2":"text-fg-subtle"),children:a.count??"—"})]},a.id)})})}const v={vip:"VIPs",muted:"Muted",blocked:"Blocked"},F=e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"VIP"})," senders get priority surface in the daily brief and notification escalation, even when an account is quiet."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Muted"})," senders never notify and stay out of the brief. Their mail still syncs and stays searchable."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Blocked"})," senders never load images and go straight to junk."]}),e.jsxs("p",{children:["Tip: flag from the keyboard on any message — ",e.jsx(m,{children:"v"})," VIP,"," ",e.jsx(m,{children:"m"})," mute, ",e.jsx(m,{children:"b"})," block. Every rule an automation creates shows up here and can be removed."]})]});function H({query:t,onCount:r}){const{data:x,isPending:a,isError:d,error:b}=I(A()),h=k(),i=C({...P(),onSettled:()=>{h.invalidateQueries({queryKey:M()})}}),l=x?.suggestions??[],p=t.trim().toLowerCase(),u=p?l.filter(n=>(n.displayName??"").toLowerCase().includes(p)||n.normalizedEmail.toLowerCase().includes(p)):l;return c.useEffect(()=>{r?.(u.length,l.length)},[r,u.length,l.length]),a?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(m,{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(n=>e.jsx(E,{name:n.displayName??n.normalizedEmail,email:n.normalizedEmail,meta:n.replyCount>0?`${n.inboundCount} received · you replied ${n.replyCount}×`:`${n.inboundCount} received · you've never replied`,trailing:e.jsx(S,{variant:"ghost",size:"sm",icon:e.jsx(B,{className:"size-3.5"}),"aria-busy":i.isPending,onClick:()=>{i.isPending||i.mutate({path:{addressId:n.addressId},body:{flags:{vip:{value:!0,setAt:Date.now(),setBy:"user"}}}})},children:"Add VIP"})},n.addressId))]})}function U({group:t,query:r,onCount:x}){const a=K(r.trim(),300),d=k(),[b,h]=c.useState(null),i=a.length>=2,l=R({query:{q:a,limit:50}}),{data:p,isPending:u,isError:n,error:j}=I({...l,enabled:i}),g=C({...P(),onSuccess:()=>{d.invalidateQueries({queryKey:l.queryKey})}}),f=(p?.items??[]).filter(s=>t==="muted"?s.flags?.muted?.value??!1:s.flags?.blocked?.value??!1);return c.useEffect(()=>{x?.(i?f.length:0,null)},[x,i,f.length]),i?u?e.jsx("div",{className:"px-row-inset py-3 text-sm text-fg-subtle animate-pulse",children:"Searching…"}):n?e.jsx("div",{className:"px-row-inset py-3",children:e.jsx(V,{variant:"inline",title:"Search failed",error:j})}):f.length===0?e.jsxs("p",{className:"px-row-inset py-5 text-sm text-fg-subtle",children:["No ",v[t].toLowerCase()," senders matching “",a,"”."]}):e.jsx(e.Fragment,{children:f.map(s=>{const o=t==="muted"?s.flags?.muted:s.flags?.blocked,y=o?[`${t}`,o.setAt&&_(o.setAt,{month:"short",year:"numeric"})||null,o.reason?`— ${o.reason}`:null].filter(Boolean).join(" "):t,w=g.isPending&&g.variables?.path.addressId===s.addressId,T=g.isError&&b===s.addressId;return e.jsx(E,{name:s.displayName??s.normalizedEmail,email:s.normalizedEmail,danger:t==="blocked",meta:y,trailing:T?e.jsx(S,{variant:"secondary",size:"sm",onClick:()=>{h(s.addressId),g.mutate({path:{addressId:s.addressId},body:{flags:{[t]:null}}})},children:"Retry"}):e.jsx(S,{variant:"ghost",size:"sm",icon:e.jsx(G,{className:"size-3.5"}),"aria-busy":w,"aria-label":`Remove ${t} flag`,onClick:()=>{w||(h(s.addressId),g.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(m,{children:"m"})," on any message to mute its sender; ",e.jsx(m,{children:"b"})," to block."]})]})}function ae(){const t=z(),[r,x]=c.useState("vip"),[a,d]=c.useState(""),[b,h]=c.useState(!0),[i,l]=c.useState(0),[p,u]=c.useState({vip:0,muted:null,blocked:null}),n=c.useCallback((s,o)=>{l(s),u(y=>({...y,vip:o}))},[]),j=c.useCallback((s,o)=>{l(s),u(y=>({...y,[r]:s}))},[r]),g=p[r],f=s=>{const o=$[s];o&&t({to:o})};return e.jsx(Q,{items:q,activeId:"senders",title:"Senders & Rules",description:"Per-sender preferences — set with one key from any message, managed here.",flush:!0,help:F,helpOpen:b,onToggleHelp:()=>h(s=>!s),onSelect:f,onBackToMail:()=>{t({to:"/mail"})},children:e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col lg:flex-row",children:[e.jsx(D,{active:r,onSelect:s=>{x(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(L,{icon:e.jsx(O,{className:"size-4"}),placeholder:`Filter ${v[r].toLowerCase()} by name or address`,className:"h-8 max-w-sm",value:a,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:a,onCount:n}):e.jsx(U,{group:r,query:a,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:g!=null?`${i} of ${g} flagged senders`:`${i} flagged senders`}),e.jsxs("span",{children:[e.jsx(m,{children:"j"})," ",e.jsx(m,{children:"k"})," navigate · ",e.jsx(m,{children:"⌫"})," remove flag"]})]})]})]})})}export{ae as component};
1
+ import{j as e,b as N,o as z,r as c,ax as q,aj as L,g as O,aB as $,w as I,b6 as A,q as k,ad as C,b7 as M,b8 as P,B as S,a as B,b9 as R,X as G}from"./index-CNoNYU4b.js";import{K as m}from"./kbd-BrhLdlau.js";import{S as Q,a as E}from"./settings-screen-x0E-yYQb.js";import{E as V}from"./ErrorState-DZM_kyxb.js";import{u as K}from"./useDebouncedValue-CQf4QpzS.js";import{a as _}from"./format-De9HZKjg.js";import"./avatar-DdSaEl5o.js";import"./menu-Bo_ZQ3dZ.js";import"./circle-help-BJ-e95sd.js";function D({options:t,active:r,onSelect:x}){return e.jsx("div",{role:"tablist",className:N("flex shrink-0 gap-1 overflow-x-auto border-b border-line p-2","lg:w-44 lg:flex-col lg:gap-0 lg:overflow-visible lg:border-r lg:border-b-0 lg:py-2 lg:pr-2 lg:pl-3"),children:t.map(a=>{const d=a.id===r;return e.jsxs("button",{type:"button",role:"tab","aria-selected":d,onClick:()=>x(a.id),className:N("flex min-h-11 shrink-0 items-center gap-2 rounded-md px-3 text-left text-sm transition-colors lg:min-h-0 lg:px-2 lg:py-1",d?"bg-accent-2-soft font-medium text-accent-2":"text-fg-muted hover:bg-surface-sunken hover:text-fg"),children:[e.jsx("span",{className:"flex-1 truncate",children:a.label}),e.jsx("span",{className:N("text-2xs tabular-nums",d?"text-accent-2":"text-fg-subtle"),children:a.count??"—"})]},a.id)})})}const v={vip:"VIPs",muted:"Muted",blocked:"Blocked"},F=e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"VIP"})," senders get priority surface in the daily brief and notification escalation, even when an account is quiet."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Muted"})," senders never notify and stay out of the brief. Their mail still syncs and stays searchable."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Blocked"})," senders never load images and go straight to junk."]}),e.jsxs("p",{children:["Tip: flag from the keyboard on any message — ",e.jsx(m,{children:"v"})," VIP,"," ",e.jsx(m,{children:"m"})," mute, ",e.jsx(m,{children:"b"})," block. Every rule an automation creates shows up here and can be removed."]})]});function H({query:t,onCount:r}){const{data:x,isPending:a,isError:d,error:b}=I(A()),h=k(),i=C({...P(),onSettled:()=>{h.invalidateQueries({queryKey:M()})}}),l=x?.suggestions??[],p=t.trim().toLowerCase(),u=p?l.filter(n=>(n.displayName??"").toLowerCase().includes(p)||n.normalizedEmail.toLowerCase().includes(p)):l;return c.useEffect(()=>{r?.(u.length,l.length)},[r,u.length,l.length]),a?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(m,{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(n=>e.jsx(E,{name:n.displayName??n.normalizedEmail,email:n.normalizedEmail,meta:n.replyCount>0?`${n.inboundCount} received · you replied ${n.replyCount}×`:`${n.inboundCount} received · you've never replied`,trailing:e.jsx(S,{variant:"ghost",size:"sm",icon:e.jsx(B,{className:"size-3.5"}),"aria-busy":i.isPending,onClick:()=>{i.isPending||i.mutate({path:{addressId:n.addressId},body:{flags:{vip:{value:!0,setAt:Date.now(),setBy:"user"}}}})},children:"Add VIP"})},n.addressId))]})}function U({group:t,query:r,onCount:x}){const a=K(r.trim(),300),d=k(),[b,h]=c.useState(null),i=a.length>=2,l=R({query:{q:a,limit:50}}),{data:p,isPending:u,isError:n,error:j}=I({...l,enabled:i}),g=C({...P(),onSuccess:()=>{d.invalidateQueries({queryKey:l.queryKey})}}),f=(p?.items??[]).filter(s=>t==="muted"?s.flags?.muted?.value??!1:s.flags?.blocked?.value??!1);return c.useEffect(()=>{x?.(i?f.length:0,null)},[x,i,f.length]),i?u?e.jsx("div",{className:"px-row-inset py-3 text-sm text-fg-subtle animate-pulse",children:"Searching…"}):n?e.jsx("div",{className:"px-row-inset py-3",children:e.jsx(V,{variant:"inline",title:"Search failed",error:j})}):f.length===0?e.jsxs("p",{className:"px-row-inset py-5 text-sm text-fg-subtle",children:["No ",v[t].toLowerCase()," senders matching “",a,"”."]}):e.jsx(e.Fragment,{children:f.map(s=>{const o=t==="muted"?s.flags?.muted:s.flags?.blocked,y=o?[`${t}`,o.setAt&&_(o.setAt,{month:"short",year:"numeric"})||null,o.reason?`— ${o.reason}`:null].filter(Boolean).join(" "):t,w=g.isPending&&g.variables?.path.addressId===s.addressId,T=g.isError&&b===s.addressId;return e.jsx(E,{name:s.displayName??s.normalizedEmail,email:s.normalizedEmail,danger:t==="blocked",meta:y,trailing:T?e.jsx(S,{variant:"secondary",size:"sm",onClick:()=>{h(s.addressId),g.mutate({path:{addressId:s.addressId},body:{flags:{[t]:null}}})},children:"Retry"}):e.jsx(S,{variant:"ghost",size:"sm",icon:e.jsx(G,{className:"size-3.5"}),"aria-busy":w,"aria-label":`Remove ${t} flag`,onClick:()=>{w||(h(s.addressId),g.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(m,{children:"m"})," on any message to mute its sender; ",e.jsx(m,{children:"b"})," to block."]})]})}function ae(){const t=z(),[r,x]=c.useState("vip"),[a,d]=c.useState(""),[b,h]=c.useState(!0),[i,l]=c.useState(0),[p,u]=c.useState({vip:0,muted:null,blocked:null}),n=c.useCallback((s,o)=>{l(s),u(y=>({...y,vip:o}))},[]),j=c.useCallback((s,o)=>{l(s),u(y=>({...y,[r]:s}))},[r]),g=p[r],f=s=>{const o=$[s];o&&t({to:o})};return e.jsx(Q,{items:q,activeId:"senders",title:"Senders & Rules",description:"Per-sender preferences — set with one key from any message, managed here.",flush:!0,help:F,helpOpen:b,onToggleHelp:()=>h(s=>!s),onSelect:f,onBackToMail:()=>{t({to:"/mail"})},children:e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col lg:flex-row",children:[e.jsx(D,{active:r,onSelect:s=>{x(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(L,{icon:e.jsx(O,{className:"size-4"}),placeholder:`Filter ${v[r].toLowerCase()} by name or address`,className:"h-8 max-w-sm",value:a,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:a,onCount:n}):e.jsx(U,{group:r,query:a,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:g!=null?`${i} of ${g} flagged senders`:`${i} flagged senders`}),e.jsxs("span",{children:[e.jsx(m,{children:"j"})," ",e.jsx(m,{children:"k"})," navigate · ",e.jsx(m,{children:"⌫"})," remove flag"]})]})]})]})})}export{ae as component};
@@ -0,0 +1 @@
1
+ import{j as t,_ as o}from"./index-CNoNYU4b.js";const n=()=>t.jsx(o,{});export{n as component};
@@ -1 +1 @@
1
- import{c as C,r as j,j as e,b as f,B as i,X as N,az as S}from"./index-3eAE16lF.js";import{A as w}from"./avatar-B5Xfa_Aj.js";import{M as B}from"./menu-B3HPQBVa.js";import{C as v}from"./circle-help-BGR1fVqk.js";const h=C("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,z]=j.useState(!1),p=!!s&&d,g=e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 pt-3 pb-1 text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Settings"}),e.jsx("nav",{className:"flex-1 overflow-y-auto px-2 py-1",children:l.map(a=>e.jsxs("button",{type:"button",onClick:()=>{k?.(a.id),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(B,{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:()=>z(a=>!a),"aria-label":"Tips","aria-expanded":b}),s&&!p&&e.jsx(i,{variant:"ghost",size:"sm",icon:e.jsx(v,{className:"size-4"}),className:"hidden ml-auto lg:inline-flex",onClick:u,"aria-label":"Show tips"})]}),s&&b&&e.jsx("div",{className:"border-b border-line bg-surface-sunken px-row-inset py-3 text-xs leading-relaxed text-fg-muted lg:hidden",children:s}),o?e.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:r}):e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:e.jsx("div",{className:"max-w-2xl px-3 py-5 lg:px-5",children:e.jsx("div",{className:"space-y-5",children:r})})})]}),p&&e.jsxs("aside",{className:"hidden w-64 shrink-0 flex-col border-l border-line bg-surface-sunken lg:flex",children:[e.jsxs("header",{className:"flex h-pane-header shrink-0 items-center justify-between border-b border-line px-row-inset",children:[e.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Tips & tricks"}),e.jsx(i,{variant:"ghost",size:"sm",icon:e.jsx(N,{className:"size-3.5"}),onClick:u,"aria-label":"Collapse tips"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-row-inset py-3 text-xs leading-relaxed text-fg-muted",children:s})]})]})}function R({name:l,email:t,meta: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 O={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=O[r];return e.jsxs("div",{className:f("rounded-sm border border-line bg-surface",r==="muted"&&"opacity-65"),children:[e.jsxs("div",{className:"flex flex-col gap-3 px-row-inset py-3 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx(w,{name:l,email:t,size:"md"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-semibold text-fg",children:l}),e.jsx(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
+ import{c as C,r as j,j as e,b as f,B as i,X as N,az as S}from"./index-CNoNYU4b.js";import{A as w}from"./avatar-DdSaEl5o.js";import{M as B}from"./menu-Bo_ZQ3dZ.js";import{C as v}from"./circle-help-BJ-e95sd.js";const h=C("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,z]=j.useState(!1),p=!!s&&d,g=e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 pt-3 pb-1 text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Settings"}),e.jsx("nav",{className:"flex-1 overflow-y-auto px-2 py-1",children:l.map(a=>e.jsxs("button",{type:"button",onClick:()=>{k?.(a.id),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(B,{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:()=>z(a=>!a),"aria-label":"Tips","aria-expanded":b}),s&&!p&&e.jsx(i,{variant:"ghost",size:"sm",icon:e.jsx(v,{className:"size-4"}),className:"hidden ml-auto lg:inline-flex",onClick:u,"aria-label":"Show tips"})]}),s&&b&&e.jsx("div",{className:"border-b border-line bg-surface-sunken px-row-inset py-3 text-xs leading-relaxed text-fg-muted lg:hidden",children:s}),o?e.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:r}):e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:e.jsx("div",{className:"max-w-2xl px-3 py-5 lg:px-5",children:e.jsx("div",{className:"space-y-5",children:r})})})]}),p&&e.jsxs("aside",{className:"hidden w-64 shrink-0 flex-col border-l border-line bg-surface-sunken lg:flex",children:[e.jsxs("header",{className:"flex h-pane-header shrink-0 items-center justify-between border-b border-line px-row-inset",children:[e.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Tips & tricks"}),e.jsx(i,{variant:"ghost",size:"sm",icon:e.jsx(N,{className:"size-3.5"}),onClick:u,"aria-label":"Collapse tips"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-row-inset py-3 text-xs leading-relaxed text-fg-muted",children:s})]})]})}function R({name:l,email:t,meta: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 O={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=O[r];return e.jsxs("div",{className:f("rounded-sm border border-line bg-surface",r==="muted"&&"opacity-65"),children:[e.jsxs("div",{className:"flex flex-col gap-3 px-row-inset py-3 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx(w,{name:l,email:t,size:"md"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-semibold text-fg",children:l}),e.jsx(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-3eAE16lF.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-CNoNYU4b.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,a5 as e}from"./index-3eAE16lF.js";const o=()=>t.jsx(e,{to:"/settings/senders",replace:!0});export{o as component};
1
+ import{j as t,a5 as e}from"./index-CNoNYU4b.js";const o=()=>t.jsx(e,{to:"/settings/senders",replace:!0});export{o as component};
@@ -1 +1 @@
1
- import{r as o}from"./index-3eAE16lF.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-CNoNYU4b.js";const n=(e,t)=>{const[r,u]=o.useState(e);return o.useEffect(()=>{const s=setTimeout(()=>u(e),t);return()=>clearTimeout(s)},[e,t]),r};export{n as u};
@@ -1 +1 @@
1
- import{r as m,ad as b,cO as E,w as C,cP as x,cx as F,cQ as P,q as O,cR as D,cS as N,cT as L,cU as z}from"./index-3eAE16lF.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"})},M=(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}),G=({mode:e,ruleScope:t})=>t==="standing"?"standing":t==="until"?"temporary":e==="selected"?"just-these":"all-like-these",X=({mode:e,ruleScope:t,anchorMessageId:r,clauses:a,matchOperator:i,moveMailboxId:n,until:s})=>({...e==="similar"&&r?{anchorMessageId:r}:{},matchOperator:i==="all"?"And":"Or",literalClauses:a.map(o=>({field:o.field,value:o.value})),moveMailboxId:n,expiresAt:t==="until"?M(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"),q=e=>JSON.stringify({anchor:e.anchorMessageId??null,operator:e.matchOperator,clauses:e.literalClauses.map(t=>`${t.field} ${t.value}`)}),te=(e,t)=>{const r=U(e,t);return{...r.anchorMessageId?{anchorMessageId:r.anchorMessageId}:{},matchOperator:r.matchOperator,literalClauses:r.literalClauses,moveMailboxId:e.moveMailboxId,labelId:e.labelId,expiresAt:e.scope==="until"?M(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},H=350,re=(e,t,r)=>{const a=b(F()),{mutateAsync:i}=a,n=q(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}))})},H);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:P},matchedIds:[]}},A=e=>N({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=O(),r=b({...D(),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=O(),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,X as j,V as k,ee as n,G as o,M as p,U as r,re as u};
1
+ import{r as m,ad as b,cO as E,w as C,cP as x,cx as F,cQ as P,q as O,cR as D,cS as N,cT as L,cU as z}from"./index-CNoNYU4b.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"})},M=(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}),G=({mode:e,ruleScope:t})=>t==="standing"?"standing":t==="until"?"temporary":e==="selected"?"just-these":"all-like-these",X=({mode:e,ruleScope:t,anchorMessageId:r,clauses:a,matchOperator:i,moveMailboxId:n,until:s})=>({...e==="similar"&&r?{anchorMessageId:r}:{},matchOperator:i==="all"?"And":"Or",literalClauses:a.map(o=>({field:o.field,value:o.value})),moveMailboxId:n,expiresAt:t==="until"?M(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"),q=e=>JSON.stringify({anchor:e.anchorMessageId??null,operator:e.matchOperator,clauses:e.literalClauses.map(t=>`${t.field} ${t.value}`)}),te=(e,t)=>{const r=U(e,t);return{...r.anchorMessageId?{anchorMessageId:r.anchorMessageId}:{},matchOperator:r.matchOperator,literalClauses:r.literalClauses,moveMailboxId:e.moveMailboxId,labelId:e.labelId,expiresAt:e.scope==="until"?M(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},H=350,re=(e,t,r)=>{const a=b(F()),{mutateAsync:i}=a,n=q(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}))})},H);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:P},matchedIds:[]}},A=e=>N({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=O(),r=b({...D(),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=O(),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,X as j,V as k,ee as n,G as o,M as p,U as r,re as u};
@@ -1 +1 @@
1
- import{w as L,bL as d,q as n,ad as l,bM as p,r as o,bN as y,bO as c,bP as g}from"./index-3eAE16lF.js";const u=e=>y({path:{accountId:e}}),f=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:u(e)})}}),{mutateAsync:s}=t;return{createLabel:o.useCallback((a,i="Default")=>e?s({path:{accountId:e},body:{name:a,color:i}}):Promise.reject(new Error("No account")),[e,s]),isPending:t.isPending,isError:t.isError,error:t.error,reset:t.reset}},h=e=>{const r=n(),t=l({...c(),onSuccess:()=>{e&&r.invalidateQueries({queryKey:u(e)})}}),{mutate:s}=t;return{updateLabel:o.useCallback((a,i)=>{e&&s({path:{accountId:e,labelId:a},body:i})},[e,s]),isPending:t.isPending,updatingLabelId:t.isPending?t.variables?.path.labelId:void 0}},C=e=>{const r=n(),t=l({...g(),onSuccess:()=>{e&&r.invalidateQueries({queryKey:u(e)})}}),{mutate:s}=t;return{deleteLabel:o.useCallback(a=>{e&&s({path:{accountId:e,labelId:a}})},[e,s]),isPending:t.isPending,deletingLabelId:t.isPending?t.variables?.path.labelId:void 0}};export{f as a,h as b,C as c,m as u};
1
+ import{w as L,bI as d,q as n,ad as l,bJ as p,r as o,bK as y,bL as c,bM as g}from"./index-CNoNYU4b.js";const u=e=>y({path:{accountId:e}}),f=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:u(e)})}}),{mutateAsync:s}=t;return{createLabel:o.useCallback((a,i="Default")=>e?s({path:{accountId:e},body:{name:a,color:i}}):Promise.reject(new Error("No account")),[e,s]),isPending:t.isPending,isError:t.isError,error:t.error,reset:t.reset}},h=e=>{const r=n(),t=l({...c(),onSuccess:()=>{e&&r.invalidateQueries({queryKey:u(e)})}}),{mutate:s}=t;return{updateLabel:o.useCallback((a,i)=>{e&&s({path:{accountId:e,labelId:a},body:i})},[e,s]),isPending:t.isPending,updatingLabelId:t.isPending?t.variables?.path.labelId:void 0}},C=e=>{const r=n(),t=l({...g(),onSuccess:()=>{e&&r.invalidateQueries({queryKey:u(e)})}}),{mutate:s}=t;return{deleteLabel:o.useCallback(a=>{e&&s({path:{accountId:e,labelId:a}})},[e,s]),isPending:t.isPending,deletingLabelId:t.isPending?t.variables?.path.labelId:void 0}};export{f as a,h as b,C as c,m as u};
@@ -1 +1 @@
1
- import{r as s}from"./index-3eAE16lF.js";const r=1024,c=`(min-width: ${r}px) and (not ((orientation: portrait) and (pointer: coarse)))`,d=e=>{const[o,n]=s.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(e).matches);return s.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const t=window.matchMedia(e),a=i=>n(i.matches);return n(t.matches),t.addEventListener("change",a),()=>t.removeEventListener("change",a)},[e]),o},m=()=>d(c);export{c as D,d as a,m as u};
1
+ import{r as s}from"./index-CNoNYU4b.js";const r=1024,c=`(min-width: ${r}px) and (not ((orientation: portrait) and (pointer: coarse)))`,d=e=>{const[o,n]=s.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(e).matches);return s.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const t=window.matchMedia(e),a=i=>n(i.matches);return n(t.matches),t.addEventListener("change",a),()=>t.removeEventListener("change",a)},[e]),o},m=()=>d(c);export{c as D,d as a,m as u};
@@ -1 +1 @@
1
- import{j as E,e as T,b as j,B as D,r as i,t as C,aD as R,q as P,n as K,a0 as Q,P as A,N as $,Q as z,R as B}from"./index-3eAE16lF.js";import{C as G}from"./circle-check-big-Dm9DZK8n.js";import{R as H}from"./search-token-index-XT09xk5-.js";function oe({state:e,onRefresh:t,label:s,errorMessage:a,hasUpdate:n,size:u="sm",className:c}){const o=e==="refreshing",f=e==="error",h=e==="success",g=f?E.jsx(T,{className:"size-4 text-danger"}):h?E.jsx(G,{className:"size-4 text-positive"}):E.jsx(H,{className:j("size-4",o&&"animate-spin")}),y=f?`${s} — failed: ${a??"try again"}`:o?`${s} — refreshing`:h?`${s} — up to date`:n?`${s} — new mail`:s;return E.jsxs("div",{className:"relative inline-flex",children:[E.jsx(D,{variant:"ghost",size:u,icon:g,onClick:t,disabled:o,"aria-label":y,"aria-busy":o||void 0,title:f?a:s,className:c}),e==="idle"&&n&&E.jsx("span",{"aria-hidden":"true",className:"absolute right-1 top-1 size-1.5 rounded-full bg-accent-2"})]})}const U=new Set(["discovering_mailboxes","syncing_inbox","syncing_others"]);function N(e){return!!e&&U.has(e)}const _=3e3,W=_*2,M={syncing:!1,resolved:!1,synced:0,total:0};function ie(e,t){const s=e.join(","),[a,n]=i.useState(!1),[u,c]=i.useState(!1);i.useEffect(()=>{n(!1),c(!1)},[s,t]),i.useEffect(()=>{if(!t)return;const r=setTimeout(()=>c(!0),W);return()=>clearTimeout(r)},[s,t]);const o=C({queries:e.map(r=>({...R({path:{accountId:r}}),enabled:t&&!a,refetchInterval:_,meta:{softError:!0}}))}),f=o.every(r=>r.isSuccess||r.isError),h=o.length===0||f||u;let g=!1,y=0,w=0;for(const r of o)if(N(r.data?.syncPhase)){g=!0;for(const l of r.data?.mailboxes??[])y+=l.messagesSynced,w+=l.messagesTotal}const S=t&&h&&!g;return i.useEffect(()=>{S&&n(!0)},[S]),!t||!h?M:{syncing:g,resolved:!0,synced:y,total:w}}const k=6e4,I=new Set(["sent","drafts","trash","archive"]),v=(e,t)=>{const s=new Map;for(const a of e){const n=t.get(a.mailboxId)?.role;n&&I.has(n)||s.set(a.mailboxId,a.messagesTotal)}return s},X=(e,t)=>{for(const[s,a]of t)if(a>(e.get(s)??0))return!0;return!1},q=i.createContext(null),J=()=>{const e=i.useContext(q);if(!e)throw new Error("useMailFreshness must be used inside <MailFreshnessProvider>");return e};function ce({accountIds:e,children:t}){const s=P(),{resultFolderIndex:a}=K(),n=i.useRef(new Map),u=i.useRef(new Set),[c,o]=i.useState(new Set),f=C({queries:e.map(r=>({...R({path:{accountId:r}}),refetchInterval:k,staleTime:k,meta:{softError:!0}}))}),h=f.map(r=>r.dataUpdatedAt).join(","),g=e.join(",");i.useEffect(()=>{let r=!1;const l=new Set(c);e.forEach((d,x)=>{const p=f[x]?.data;if(!p)return;const m=v(p.mailboxes??[],a);if(!u.current.has(d)){u.current.add(d),n.current.set(d,m);return}if(l.has(d))return;const O=n.current.get(d)??new Map;X(O,m)&&(l.add(d),r=!0)}),r&&o(l)},[g,h]);const y=i.useCallback(r=>r.some(l=>c.has(l)),[c]),w=i.useCallback(r=>{o(l=>{if(r.every(x=>!l.has(x)))return l;const d=new Set(l);for(const x of r)d.delete(x);return d});for(const l of r){const d=s.getQueryData(R({path:{accountId:l}}).queryKey);n.current.set(l,v(d?.mailboxes??[],a)),u.current.add(l)}},[s,a]),S=i.useMemo(()=>({hasNewMail:y,acknowledge:w}),[y,w]);return E.jsx(q.Provider,{value:S,children:t})}const V=2e3,Y=45e3,Z=e=>new Promise(t=>setTimeout(t,e)),b=e=>e instanceof Error&&e.message?e.message:"Something went wrong",ee=e=>{z(e,{softError:!0})&&B(e)},F=e=>e.reduce((t,s)=>Math.max(t,s.lastSyncedAt??0),0),L=(e,t)=>e.fetchQuery({...R({path:{accountId:t}}),staleTime:0}),se=async(e,t,s,a)=>{let n=!1;for(;;){const u=await L(e,t).then(f=>({ok:!0,data:f})).catch(f=>({ok:!1,error:f}));if(!u.ok)return{accountId:t,message:b(u.error)};const{syncPhase:c,mailboxes:o}=u.data;if(N(c))n=!0;else if(n||F(o??[])>s)return c==="error"?{accountId:t,message:"Sync failed for this account"}:void 0;if(Date.now()>=a)return{accountId:t,message:"Refresh is taking longer than usual"};await Z(V)}},te=async(e,t,s,a)=>{const n=await L(e,s).then(o=>({ok:!0,maxLastSynced:F(o.mailboxes??[])})).catch(o=>({ok:!1,error:o}));if(!n.ok)return{accountId:s,enqueued:!1,ok:!1,message:b(n.error)};const u=await $({path:{accountId:s},throwOnError:!0}).then(()=>({ok:!0})).catch(o=>({ok:!1,error:o}));if(!u.ok)return ee(u.error),{accountId:s,enqueued:!1,ok:!1,message:b(u.error)};t.recordEvent("sync.triggered");const c=await se(e,s,n.maxLastSynced,a);return c?{accountId:s,enqueued:!0,ok:!1,message:c.message}:{accountId:s,enqueued:!0,ok:!0}},ue=(e,t={})=>{const s=P(),a=Q(),{acknowledge:n}=J(),[u,c]=i.useState("idle"),[o,f]=i.useState(),h=i.useRef(0),g=i.useRef(e);g.current=e;const y=i.useRef(t);y.current=t,i.useEffect(()=>{if(u!=="success")return;const S=setTimeout(()=>c("idle"),2e3);return()=>clearTimeout(S)},[u]);const w=i.useCallback(()=>{const S=g.current;if(S.length===0){c("error"),f("Nothing to refresh yet");return}const r=++h.current;c("refreshing"),f(void 0),(async()=>{const l=Date.now()+Y,d=await Promise.all(S.map(m=>te(s,a,m,l)));if(h.current!==r)return;const x=d.filter(m=>m.enqueued).map(m=>m.accountId);for(const m of x)s.invalidateQueries({queryKey:A({path:{accountId:m}})});x.length>0&&(y.current.onSettled?.(),n(x));const p=d.filter(m=>!m.ok);p.length===0?c("success"):(c("error"),f(p[0]?.message))})()},[n,s,a]);return{state:u,errorMessage:o,refresh:w}};export{ce as M,oe as R,ue as a,ie as b,N as i,J as u};
1
+ import{j as E,e as T,b as j,B as D,r as i,t as C,aD as R,q as P,n as K,a0 as Q,P as A,N as $,Q as z,R as B}from"./index-CNoNYU4b.js";import{C as G}from"./circle-check-big-DT6yugdt.js";import{R as H}from"./search-token-index-BTQUgi2G.js";function oe({state:e,onRefresh:t,label:s,errorMessage:a,hasUpdate:n,size:u="sm",className:c}){const o=e==="refreshing",f=e==="error",h=e==="success",g=f?E.jsx(T,{className:"size-4 text-danger"}):h?E.jsx(G,{className:"size-4 text-positive"}):E.jsx(H,{className:j("size-4",o&&"animate-spin")}),y=f?`${s} — failed: ${a??"try again"}`:o?`${s} — refreshing`:h?`${s} — up to date`:n?`${s} — new mail`:s;return E.jsxs("div",{className:"relative inline-flex",children:[E.jsx(D,{variant:"ghost",size:u,icon:g,onClick:t,disabled:o,"aria-label":y,"aria-busy":o||void 0,title:f?a:s,className:c}),e==="idle"&&n&&E.jsx("span",{"aria-hidden":"true",className:"absolute right-1 top-1 size-1.5 rounded-full bg-accent-2"})]})}const U=new Set(["discovering_mailboxes","syncing_inbox","syncing_others"]);function N(e){return!!e&&U.has(e)}const _=3e3,W=_*2,M={syncing:!1,resolved:!1,synced:0,total:0};function ie(e,t){const s=e.join(","),[a,n]=i.useState(!1),[u,c]=i.useState(!1);i.useEffect(()=>{n(!1),c(!1)},[s,t]),i.useEffect(()=>{if(!t)return;const r=setTimeout(()=>c(!0),W);return()=>clearTimeout(r)},[s,t]);const o=C({queries:e.map(r=>({...R({path:{accountId:r}}),enabled:t&&!a,refetchInterval:_,meta:{softError:!0}}))}),f=o.every(r=>r.isSuccess||r.isError),h=o.length===0||f||u;let g=!1,y=0,w=0;for(const r of o)if(N(r.data?.syncPhase)){g=!0;for(const l of r.data?.mailboxes??[])y+=l.messagesSynced,w+=l.messagesTotal}const S=t&&h&&!g;return i.useEffect(()=>{S&&n(!0)},[S]),!t||!h?M:{syncing:g,resolved:!0,synced:y,total:w}}const k=6e4,I=new Set(["sent","drafts","trash","archive"]),v=(e,t)=>{const s=new Map;for(const a of e){const n=t.get(a.mailboxId)?.role;n&&I.has(n)||s.set(a.mailboxId,a.messagesTotal)}return s},X=(e,t)=>{for(const[s,a]of t)if(a>(e.get(s)??0))return!0;return!1},q=i.createContext(null),J=()=>{const e=i.useContext(q);if(!e)throw new Error("useMailFreshness must be used inside <MailFreshnessProvider>");return e};function ce({accountIds:e,children:t}){const s=P(),{resultFolderIndex:a}=K(),n=i.useRef(new Map),u=i.useRef(new Set),[c,o]=i.useState(new Set),f=C({queries:e.map(r=>({...R({path:{accountId:r}}),refetchInterval:k,staleTime:k,meta:{softError:!0}}))}),h=f.map(r=>r.dataUpdatedAt).join(","),g=e.join(",");i.useEffect(()=>{let r=!1;const l=new Set(c);e.forEach((d,x)=>{const p=f[x]?.data;if(!p)return;const m=v(p.mailboxes??[],a);if(!u.current.has(d)){u.current.add(d),n.current.set(d,m);return}if(l.has(d))return;const O=n.current.get(d)??new Map;X(O,m)&&(l.add(d),r=!0)}),r&&o(l)},[g,h]);const y=i.useCallback(r=>r.some(l=>c.has(l)),[c]),w=i.useCallback(r=>{o(l=>{if(r.every(x=>!l.has(x)))return l;const d=new Set(l);for(const x of r)d.delete(x);return d});for(const l of r){const d=s.getQueryData(R({path:{accountId:l}}).queryKey);n.current.set(l,v(d?.mailboxes??[],a)),u.current.add(l)}},[s,a]),S=i.useMemo(()=>({hasNewMail:y,acknowledge:w}),[y,w]);return E.jsx(q.Provider,{value:S,children:t})}const V=2e3,Y=45e3,Z=e=>new Promise(t=>setTimeout(t,e)),b=e=>e instanceof Error&&e.message?e.message:"Something went wrong",ee=e=>{z(e,{softError:!0})&&B(e)},F=e=>e.reduce((t,s)=>Math.max(t,s.lastSyncedAt??0),0),L=(e,t)=>e.fetchQuery({...R({path:{accountId:t}}),staleTime:0}),se=async(e,t,s,a)=>{let n=!1;for(;;){const u=await L(e,t).then(f=>({ok:!0,data:f})).catch(f=>({ok:!1,error:f}));if(!u.ok)return{accountId:t,message:b(u.error)};const{syncPhase:c,mailboxes:o}=u.data;if(N(c))n=!0;else if(n||F(o??[])>s)return c==="error"?{accountId:t,message:"Sync failed for this account"}:void 0;if(Date.now()>=a)return{accountId:t,message:"Refresh is taking longer than usual"};await Z(V)}},te=async(e,t,s,a)=>{const n=await L(e,s).then(o=>({ok:!0,maxLastSynced:F(o.mailboxes??[])})).catch(o=>({ok:!1,error:o}));if(!n.ok)return{accountId:s,enqueued:!1,ok:!1,message:b(n.error)};const u=await $({path:{accountId:s},throwOnError:!0}).then(()=>({ok:!0})).catch(o=>({ok:!1,error:o}));if(!u.ok)return ee(u.error),{accountId:s,enqueued:!1,ok:!1,message:b(u.error)};t.recordEvent("sync.triggered");const c=await se(e,s,n.maxLastSynced,a);return c?{accountId:s,enqueued:!0,ok:!1,message:c.message}:{accountId:s,enqueued:!0,ok:!0}},ue=(e,t={})=>{const s=P(),a=Q(),{acknowledge:n}=J(),[u,c]=i.useState("idle"),[o,f]=i.useState(),h=i.useRef(0),g=i.useRef(e);g.current=e;const y=i.useRef(t);y.current=t,i.useEffect(()=>{if(u!=="success")return;const S=setTimeout(()=>c("idle"),2e3);return()=>clearTimeout(S)},[u]);const w=i.useCallback(()=>{const S=g.current;if(S.length===0){c("error"),f("Nothing to refresh yet");return}const r=++h.current;c("refreshing"),f(void 0),(async()=>{const l=Date.now()+Y,d=await Promise.all(S.map(m=>te(s,a,m,l)));if(h.current!==r)return;const x=d.filter(m=>m.enqueued).map(m=>m.accountId);for(const m of x)s.invalidateQueries({queryKey:A({path:{accountId:m}})});x.length>0&&(y.current.onSettled?.(),n(x));const p=d.filter(m=>!m.ok);p.length===0?c("success"):(c("error"),f(p[0]?.message))})()},[n,s,a]);return{state:u,errorMessage:o,refresh:w}};export{ce as M,oe as R,ue as a,ie as b,N as i,J as u};
@@ -1 +1 @@
1
- import{o as h,n as y,V as v,r as p}from"./index-3eAE16lF.js";import{u as x}from"./search-scope-Bcn1kzwd.js";import{b as I}from"./search-view-BtUa3wf0.js";function q(o){const a=h(),{searchInput:c,searchQuery:e}=y(),{q:i=""}=v({from:"/mail"}),n=x({select:m=>m.location.pathname}),s=p.useRef(i);s.current=i;const{to:r}=o,t="params"in o?o.params.mailboxId:void 0,l=t?`/mail/${t}`:r;p.useEffect(()=>{if(!I({searchInput:c,committedQuery:e,urlQuery:s.current,pathname:n,listPath:l}))return;const d=!!e&&s.current!==e,u=f=>({...f,q:e||void 0,...d?{selectedMessageId:void 0,selectedThreadId:void 0,selectedMailboxId:void 0}:{}});if(!d){a({to:".",search:u,replace:!0});return}if(r==="/mail/$mailboxId"){if(!t)return;a({to:r,params:{mailboxId:t},search:u,replace:!0});return}a({to:r,search:u,replace:!0})},[c,e,a,r,t,l,n])}export{q as u};
1
+ import{o as h,n as y,V as v,r as p}from"./index-CNoNYU4b.js";import{u as x}from"./search-scope-Ds_ghZOi.js";import{b as I}from"./search-view-CXPbecDB.js";function q(o){const a=h(),{searchInput:c,searchQuery:e}=y(),{q:i=""}=v({from:"/mail"}),n=x({select:m=>m.location.pathname}),s=p.useRef(i);s.current=i;const{to:r}=o,t="params"in o?o.params.mailboxId:void 0,l=t?`/mail/${t}`:r;p.useEffect(()=>{if(!I({searchInput:c,committedQuery:e,urlQuery:s.current,pathname:n,listPath:l}))return;const d=!!e&&s.current!==e,u=f=>({...f,q:e||void 0,...d?{selectedMessageId:void 0,selectedThreadId:void 0,selectedMailboxId:void 0}:{}});if(!d){a({to:".",search:u,replace:!0});return}if(r==="/mail/$mailboxId"){if(!t)return;a({to:r,params:{mailboxId:t},search:u,replace:!0});return}a({to:r,search:u,replace:!0})},[c,e,a,r,t,l,n])}export{q as u};
@@ -1,4 +1,4 @@
1
- import{c2 as X,r as f,j as a,b as B,I as Y,a0 as Z,m as P,q as W,w as J,cp as H,co as ee,ab as te,ad as se,ae as re,b8 as ne,e as ae,X as oe,J as C,n as ie}from"./index-3eAE16lF.js";import{K as L}from"./kbd-BVVVI8MK.js";import{M as Q}from"./enums-CCxx0t2v.js";import{u as ce,i as le}from"./search-scope-Bcn1kzwd.js";const de=(e,t)=>{const r=e==="newsletter"||e==="marketing"||t;return{framed:r,isPlain:!r}},ue=()=>`
1
+ import{c1 as X,r as f,j as a,b as B,I as Y,a0 as Z,m as P,q as W,w as J,cp as H,co as ee,ab as te,ad as se,ae as re,b8 as ne,e as ae,X as oe,J as C,n as ie}from"./index-CNoNYU4b.js";import{K as L}from"./kbd-BrhLdlau.js";import{M as Q}from"./enums-CCxx0t2v.js";import{u as ce,i as le}from"./search-scope-Ds_ghZOi.js";const de=(e,t)=>{const r=e==="newsletter"||e==="marketing"||t;return{framed:r,isPlain:!r}},ue=()=>`
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 {
@@ -64,4 +64,4 @@ a, a:visited {
64
64
  color: ${t.accent} !important;
65
65
  text-decoration: underline;
66
66
  }
67
- `},Te=(e,t)=>e?t?"html,body{margin:0;color-scheme:dark light}":"html{margin:0;background-color:#ffffff;filter:invert(0.92) hue-rotate(180deg)}body{margin:0}img,picture,video,svg,canvas,[style*='background-image'],[background]{filter:invert(0.92) hue-rotate(180deg)}":"html,body{margin:0;background-color:#ffffff;color-scheme:light}",Ne=(e,t,s)=>{if(t==="plain")return`${O}<style>${Se(s)}</style>${e}`;const r=Ae.test(e);return`${O}<style>${Te(s,r)}</style>${e}`},je=5e4,Re=1e4,Ce="(max-width: 640px)",Me=.4,Le="allow-same-origin allow-popups allow-popups-to-escape-sandbox",I=(e,t,s)=>Math.min(Math.ceil(Math.max(e,t)),s),Be=(e,t)=>e<=0||t<=0||e<=t?1:Math.max(Me,t/e),De=e=>{const[t,s]=f.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(e).matches);return f.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const r=window.matchMedia(e);s(r.matches);const n=o=>s(o.matches);return r.addEventListener("change",n),()=>r.removeEventListener("change",n)},[e]),t},$e=new Set(["Enter","Escape","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End"]),_e=e=>e===" "?!1:e.length===1?!0:$e.has(e),U=e=>{if(e.metaKey||e.ctrlKey||e.altKey||!_e(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}))},K=({html:e,variant:t="framed",isDark:s=!1,className:r})=>{const n=f.useRef(null),o=f.useRef(null),[c,m]=f.useState(0),[i,l]=f.useState(0),[p,d]=f.useState(0),g=De(Ce),x=f.useMemo(()=>Ne(e,t,s),[e,t,s]);f.useEffect(()=>{const b=n.current;if(!b)return;const k=()=>d(E=>E===b.clientWidth?E:b.clientWidth);k();const w=new ResizeObserver(k);return w.observe(b),()=>w.disconnect()},[]),f.useEffect(()=>{const b=o.current;if(!b)return;const k=()=>{const y=b.contentDocument;if(!y?.body)return;const j=y.documentElement,R=I(y.body.scrollHeight,j?.scrollHeight??0,je);m(S=>S===R?S:R);const $=I(y.body.scrollWidth,j?.scrollWidth??0,Re);l(S=>S===$?S:$)};let w,E;const N=()=>{k();const y=b.contentDocument;y?.body&&(w=new ResizeObserver(k),w.observe(y.body),y.documentElement&&w.observe(y.documentElement),y.addEventListener("keydown",U),E=y)};return b.addEventListener("load",N),()=>{b.removeEventListener("load",N),E?.removeEventListener("keydown",U),w?.disconnect()}},[]);const u=g?Be(i,p):1,h=u<1,v=h?`${i}px`:g?"100%":t==="framed"&&i>0?`max(100%, ${i}px)`:i===0?"100%":`${i}px`,M=c===0?"1px":`${c}px`,T=a.jsx("iframe",{ref:o,title:"Email content",sandbox:Le,srcDoc:x,className:h?void 0:r,scrolling:"no",style:{width:v,maxWidth:h?"none":void 0,border:"none",display:"block",height:M,overflow:"hidden",transform:h?`scale(${u})`:void 0,transformOrigin:h?"top left":void 0,colorScheme:"normal"}});return a.jsx("div",{ref:n,className:h?r:void 0,children:h?a.jsx("div",{style:{width:"100%",height:`${Math.ceil(c*u)}px`,overflow:"hidden"},children:T}):T})},F=()=>a.jsx("p",{className:"text-fg-muted text-sm italic",children:"This message has no body content."}),Oe=({html:e,text:t,isDark:s=!1,category:r,allowImages:n=!1,resolveCid:o,className:c,renderBlockedNotice:m})=>{const i=f.useMemo(()=>!e||typeof document>"u"?null:ke({allowExternalImages:n,resolveCid:o})(e),[e,n,o]),l=i?.html??null,{framed:p,isPlain:d}=de(r,i?.hasAuthorBackground??!1),g=f.useMemo(()=>!l||n?0:(l.match(/data-blocked-src/g)||[]).length,[l,n]);return!l&&!t?a.jsx("div",{className:B("message-body",c),children:a.jsx(F,{})}):a.jsxs("div",{className:B("message-body",c),children:[g>0&&a.jsx("div",{className:"message-body-notice",children:m?.(g)}),l?p?a.jsx("div",{className:"w-full max-w-full overflow-x-auto",children:a.jsx(K,{html:l,variant:"framed",isDark:s})}):a.jsx("div",{className:"max-w-full overflow-x-auto lg:max-w-2xl",children:a.jsx(K,{html:l,variant:d?"plain":"framed",isDark:s})}):t?a.jsx("pre",{className:"email-text whitespace-pre-wrap text-sm leading-relaxed",children:t}):a.jsx(F,{})]})};function vt({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(Y,{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(L,{children:"j"})," / ",a.jsx(L,{children:"k"})," to move, ",a.jsx(L,{children:"Enter"})," to open"]})]})}function G(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 Ie=e=>{if(!e.startsWith('"'))return e;const t=e.slice(1);return t.endsWith('"')?t.slice(0,-1):t};function Ue(e){const t=e.indexOf(":");if(t<=0)return;const s=e.slice(t+1);return{name:e.slice(0,t).toLowerCase(),value:Ie(s),rawValue:s}}const Ke=e=>/[\s"]/.test(e),Fe=e=>Ke(e)?`"${e.replace(/"/g,"")}"`:e,kt=(e,t)=>`${e}:${Fe(t)}`,ze=e=>{const t=e.filter(n=>!n.isMultipart&&n.disposition!=="attachment"&&n.mediaType==="TEXT"&&n.contentUrl.length>0),s=t.find(n=>n.mediaSubtype.toUpperCase()==="HTML");if(s)return{kind:"html",contentUrl:s.contentUrl};const r=t.find(n=>n.mediaSubtype.toUpperCase()==="PLAIN");return r?{kind:"text",contentUrl:r.contentUrl}:null},D={all:["messages"],detail:e=>[...D.all,"detail",e],body:e=>[...D.detail(e),"body"]};class A extends Error{reason;status;retryAfterSeconds;constructor(t,s,r,n){super(s),this.name="BodyFetchError",this.reason=t,this.status=r,this.retryAfterSeconds=n}}const Pe=e=>{const t=Number.parseInt(e??"",10);return!Number.isFinite(t)||t<=0?1:Math.min(t,30)},We=8,He="x-remit-403-reason",Qe=(e,t)=>{const s=t?.trim()??"";return e===401?"auth":e===403?s.length>0?"auth":"body-missing":e===404?"body-missing":"generic"},Ge=(e,t)=>(t??"").toLowerCase().startsWith("text/html")?/<div\s+id=["']root["']/i.test(e):!1,qe=(e,t)=>{const s=(t??"").toLowerCase();return!!(e==="text"&&s.startsWith("text/html"))},Ve=async(e,t,s=async()=>null)=>{const r={},n=await s();n&&(r.Authorization=`Bearer ${n}`);const o=await ee(e,{headers:r});if(o.status===202)throw new A("not-ready","Message body is still syncing",202,Pe(o.headers.get("Retry-After")));if(!o.ok){const i=o.headers.get(He),l=Qe(o.status,i);throw new A(l,`Failed to load message body (${o.status} ${o.statusText})`,o.status)}const c=o.headers.get("content-type");if(qe(t,c))throw new A("content-type-mismatch",`Refusing to render message body — expected ${t}, got Content-Type ${c}`);const m=await o.text();if(Ge(m,c))throw new A("spa-shell-leak","Refusing to render message body — response looks like the SPA shell (CloudFront 403/404 fallback leaked through to /content/*)");return m},Xe=async(e,t)=>(t.isRetryAfterNotReady&&await e.refetchDescribeMessage(),e.fetchContent(t.contentUrl,t.kind)),Ye=({messageId:e,bodyParts:t,enabled:s=!0})=>{const r=t?ze(t):null,n=Z(),{getToken:o}=P(),c=f.useRef(null),m=W(),i=f.useRef(!1),l=f.useRef(null),p=e&&r?`${e}:${r.contentUrl}`:null;l.current!==p&&(l.current=p,i.current=!1);const d=J({queryKey:e?[...D.body(e),r?.contentUrl??null]:["messages","body","noop"],queryFn:()=>{if(!r)throw new Error("No renderable body part");if(!e)throw new Error("No messageId");const u=i.current;return i.current=!1,Xe({fetchContent:(h,v)=>Ve(h,v,o),refetchDescribeMessage:()=>m.refetchQueries({queryKey:H({path:{messageId:e}})})},{contentUrl:r.contentUrl,kind:r.kind,isRetryAfterNotReady:u})},enabled:s&&!!e&&!!r,staleTime:300*1e3,gcTime:1800*1e3,retry:(u,h)=>h instanceof A&&h.reason==="not-ready"?u<We:u<1,retryDelay:(u,h)=>h instanceof A&&h.reason==="not-ready"?(i.current=!0,(h.retryAfterSeconds??1)*1e3):1e3,meta:{softError:!0}}),g=d.isLoading&&!!r;f.useEffect(()=>{g&&(c.current=performance.now())},[g]),f.useEffect(()=>{d.isSuccess&&c.current!==null&&(n.recordTiming("message.body.load",Math.round(performance.now()-c.current)),c.current=null)},[d.isSuccess,n]);const x=d.data&&r?{kind:r.kind,body:d.data}:void 0;return{picked:r,data:x,isLoading:g,isError:d.isError,error:d.error,refetch:d.refetch}},q=(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=q(!0,r):delete n.trusted,{...e,flags:n}},Je=(e,t,s,r)=>{const n=o=>o.map(c=>Ze(c,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=W(),{pushError:s}=te(),{mutate:r,isPending:n,error:o,reset:c}=se({...ne(),onMutate:async i=>{const l=i.path.addressId,d=i.body.flags?.trusted?.value===!0,g=H({path:{messageId:e}});await t.cancelQueries({queryKey:g});const x=t.getQueriesData({queryKey:g}).filter(u=>u[1]!==void 0).map(([u,h])=>({queryKey:u,data:h}));return t.setQueriesData({queryKey:g},u=>u&&Je(u,l,d)),{describePrefix:g,previous:x}},onError:(i,l,p)=>{if(p)for(const d of p.previous)t.setQueryData(d.queryKey,d.data);s(re("Couldn't trust sender","The change wasn't saved.",i))},onSettled:(i,l,p,d)=>{d&&t.invalidateQueries({queryKey:d.describePrefix})}});return{toggleTrusted:(i,l)=>{r({path:{addressId:i},body:{flags:{trusted:q(!l)}}})},isPending:n,error:o,reset:c}},tt=()=>{const[e,t]=f.useState(()=>typeof document<"u"&&document.documentElement.classList.contains("dark"));return f.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 A?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),[c,m]=f.useState(!1),{Account:i}=P();return c?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(ae,{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(i,{children:({signOut:l})=>a.jsx("button",{type:"button",onClick:()=>l(),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(oe,{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"})]}),z=()=>a.jsx("p",{className:"text-fg-muted text-sm italic",children:"This message has no body content."}),Et=({bodyParts:e,html:t,text:s,isTrusted:r=!1,messageId:n,fromAddressId:o,category:c,className:m})=>{const[i,l]=f.useState(!1),p=r||i,d=tt(),{toggleTrusted:g,isPending:x}=et({messageId:n??""}),u=!!e&&e.length>0,{picked:h,data:v,isLoading:M,isError:T,error:b,refetch:k}=Ye({messageId:n,bodyParts:e,enabled:u}),w=f.useMemo(()=>fe(e??[]),[e]),E=u&&v?.kind==="html"?v.body:t,N=u&&v?.kind==="text"?v.body:s;if(u){if(M)return a.jsx("div",{className:C("message-body",m),children:a.jsx(it,{})});if(T)return a.jsx("div",{className:C("message-body",m),children:a.jsx(ot,{error:b,onRetry:()=>k()})});if(!h)return a.jsx("div",{className:C("message-body",m),children:a.jsx(z,{})})}else if(!t&&!s)return a.jsx("div",{className:C("message-body",m),children:a.jsx(z,{})});const y=!!(o&&n),j=()=>{!o||x||(l(!0),g(o,!1))};return a.jsx(Oe,{className:m,html:E,text:N,isDark:d,category:c,allowImages:p,resolveCid:w,renderBlockedNotice:R=>a.jsx(st,{blockedImageCount:R,canAlwaysTrust:y,isTrustPending:x,onLoadOnce:()=>l(!0),onAlwaysTrust:j})})},V={personal:"Personal",uncategorized:"Unclassified",transactional:"Transactional",newsletter:"Newsletter",marketing:"Marketing",social:"Social",automated:"Automated"},ct=Object.values(Q).map(e=>({value:e,label:V[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])),At=e=>ut.get(e.toLowerCase()),ft=/^\d{4}-\d{2}-\d{2}$/;function mt(e,t,s){if(!ft.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(Q).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=Ue(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 mt(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 St(e,t={}){const s=[],r=[];for(const n of G(e)){const o=pt(n.raw,t);o?s.push(o):r.push(n.raw)}return{freeText:r.join(" "),tokens:s}}function Tt(e,t){return G(e).filter(s=>s.raw!==t.raw).map(s=>s.raw).join(" ")}function Nt(e){switch(e.type){case"from":return`From: ${e.value}`;case"subject":return`Subject: ${e.value}`;case"category":return`Category: ${V[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}=ie();return{...ce({select:r=>le(r.matches)})?{}:{mailboxesByName:e},accountsByName:t}}export{Et as M,vt as R,dt as S,G as a,Ue as b,Oe as c,Ye as d,et as e,Qe as f,Nt as g,At as h,St as p,Tt as r,kt as s,jt as u};
67
+ `},Te=(e,t)=>e?t?"html,body{margin:0;color-scheme:dark light}":"html{margin:0;background-color:#ffffff;filter:invert(0.92) hue-rotate(180deg)}body{margin:0}img,picture,video,svg,canvas,[style*='background-image'],[background]{filter:invert(0.92) hue-rotate(180deg)}":"html,body{margin:0;background-color:#ffffff;color-scheme:light}",Ne=(e,t,s)=>{if(t==="plain")return`${O}<style>${Se(s)}</style>${e}`;const r=Ae.test(e);return`${O}<style>${Te(s,r)}</style>${e}`},je=5e4,Re=1e4,Ce="(max-width: 640px)",Me=.4,Le="allow-same-origin allow-popups allow-popups-to-escape-sandbox",I=(e,t,s)=>Math.min(Math.ceil(Math.max(e,t)),s),Be=(e,t)=>e<=0||t<=0||e<=t?1:Math.max(Me,t/e),De=e=>{const[t,s]=f.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(e).matches);return f.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const r=window.matchMedia(e);s(r.matches);const n=o=>s(o.matches);return r.addEventListener("change",n),()=>r.removeEventListener("change",n)},[e]),t},$e=new Set(["Enter","Escape","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End"]),_e=e=>e===" "?!1:e.length===1?!0:$e.has(e),U=e=>{if(e.metaKey||e.ctrlKey||e.altKey||!_e(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}))},K=({html:e,variant:t="framed",isDark:s=!1,className:r})=>{const n=f.useRef(null),o=f.useRef(null),[c,m]=f.useState(0),[i,l]=f.useState(0),[p,d]=f.useState(0),g=De(Ce),x=f.useMemo(()=>Ne(e,t,s),[e,t,s]);f.useEffect(()=>{const b=n.current;if(!b)return;const k=()=>d(E=>E===b.clientWidth?E:b.clientWidth);k();const w=new ResizeObserver(k);return w.observe(b),()=>w.disconnect()},[]),f.useEffect(()=>{const b=o.current;if(!b)return;const k=()=>{const y=b.contentDocument;if(!y?.body)return;const j=y.documentElement,R=I(y.body.scrollHeight,j?.scrollHeight??0,je);m(S=>S===R?S:R);const $=I(y.body.scrollWidth,j?.scrollWidth??0,Re);l(S=>S===$?S:$)};let w,E;const N=()=>{k();const y=b.contentDocument;y?.body&&(w=new ResizeObserver(k),w.observe(y.body),y.documentElement&&w.observe(y.documentElement),y.addEventListener("keydown",U),E=y)};return b.addEventListener("load",N),()=>{b.removeEventListener("load",N),E?.removeEventListener("keydown",U),w?.disconnect()}},[]);const u=g?Be(i,p):1,h=u<1,v=h?`${i}px`:g?"100%":t==="framed"&&i>0?`max(100%, ${i}px)`:i===0?"100%":`${i}px`,M=c===0?"1px":`${c}px`,T=a.jsx("iframe",{ref:o,title:"Email content",sandbox:Le,srcDoc:x,className:h?void 0:r,scrolling:"no",style:{width:v,maxWidth:h?"none":void 0,border:"none",display:"block",height:M,overflow:"hidden",transform:h?`scale(${u})`:void 0,transformOrigin:h?"top left":void 0,colorScheme:"normal"}});return a.jsx("div",{ref:n,className:h?r:void 0,children:h?a.jsx("div",{style:{width:"100%",height:`${Math.ceil(c*u)}px`,overflow:"hidden"},children:T}):T})},F=()=>a.jsx("p",{className:"text-fg-muted text-sm italic",children:"This message has no body content."}),Oe=({html:e,text:t,isDark:s=!1,category:r,allowImages:n=!1,resolveCid:o,className:c,renderBlockedNotice:m})=>{const i=f.useMemo(()=>!e||typeof document>"u"?null:ke({allowExternalImages:n,resolveCid:o})(e),[e,n,o]),l=i?.html??null,{framed:p,isPlain:d}=de(r,i?.hasAuthorBackground??!1),g=f.useMemo(()=>!l||n?0:(l.match(/data-blocked-src/g)||[]).length,[l,n]);return!l&&!t?a.jsx("div",{className:B("message-body",c),children:a.jsx(F,{})}):a.jsxs("div",{className:B("message-body",c),children:[g>0&&a.jsx("div",{className:"message-body-notice",children:m?.(g)}),l?p?a.jsx("div",{className:"w-full max-w-full overflow-x-auto",children:a.jsx(K,{html:l,variant:"framed",isDark:s})}):a.jsx("div",{className:"max-w-full overflow-x-auto lg:max-w-2xl",children:a.jsx(K,{html:l,variant:d?"plain":"framed",isDark:s})}):t?a.jsx("pre",{className:"email-text whitespace-pre-wrap text-sm leading-relaxed",children:t}):a.jsx(F,{})]})};function vt({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(Y,{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(L,{children:"j"})," / ",a.jsx(L,{children:"k"})," to move, ",a.jsx(L,{children:"Enter"})," to open"]})]})}function G(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 Ie=e=>{if(!e.startsWith('"'))return e;const t=e.slice(1);return t.endsWith('"')?t.slice(0,-1):t};function Ue(e){const t=e.indexOf(":");if(t<=0)return;const s=e.slice(t+1);return{name:e.slice(0,t).toLowerCase(),value:Ie(s),rawValue:s}}const Ke=e=>/[\s"]/.test(e),Fe=e=>Ke(e)?`"${e.replace(/"/g,"")}"`:e,kt=(e,t)=>`${e}:${Fe(t)}`,ze=e=>{const t=e.filter(n=>!n.isMultipart&&n.disposition!=="attachment"&&n.mediaType==="TEXT"&&n.contentUrl.length>0),s=t.find(n=>n.mediaSubtype.toUpperCase()==="HTML");if(s)return{kind:"html",contentUrl:s.contentUrl};const r=t.find(n=>n.mediaSubtype.toUpperCase()==="PLAIN");return r?{kind:"text",contentUrl:r.contentUrl}:null},D={all:["messages"],detail:e=>[...D.all,"detail",e],body:e=>[...D.detail(e),"body"]};class A extends Error{reason;status;retryAfterSeconds;constructor(t,s,r,n){super(s),this.name="BodyFetchError",this.reason=t,this.status=r,this.retryAfterSeconds=n}}const Pe=e=>{const t=Number.parseInt(e??"",10);return!Number.isFinite(t)||t<=0?1:Math.min(t,30)},We=8,He="x-remit-403-reason",Qe=(e,t)=>{const s=t?.trim()??"";return e===401?"auth":e===403?s.length>0?"auth":"body-missing":e===404?"body-missing":"generic"},Ge=(e,t)=>(t??"").toLowerCase().startsWith("text/html")?/<div\s+id=["']root["']/i.test(e):!1,qe=(e,t)=>{const s=(t??"").toLowerCase();return!!(e==="text"&&s.startsWith("text/html"))},Ve=async(e,t,s=async()=>null)=>{const r={},n=await s();n&&(r.Authorization=`Bearer ${n}`);const o=await ee(e,{headers:r});if(o.status===202)throw new A("not-ready","Message body is still syncing",202,Pe(o.headers.get("Retry-After")));if(!o.ok){const i=o.headers.get(He),l=Qe(o.status,i);throw new A(l,`Failed to load message body (${o.status} ${o.statusText})`,o.status)}const c=o.headers.get("content-type");if(qe(t,c))throw new A("content-type-mismatch",`Refusing to render message body — expected ${t}, got Content-Type ${c}`);const m=await o.text();if(Ge(m,c))throw new A("spa-shell-leak","Refusing to render message body — response looks like the SPA shell (CloudFront 403/404 fallback leaked through to /content/*)");return m},Xe=async(e,t)=>(t.isRetryAfterNotReady&&await e.refetchDescribeMessage(),e.fetchContent(t.contentUrl,t.kind)),Ye=({messageId:e,bodyParts:t,enabled:s=!0})=>{const r=t?ze(t):null,n=Z(),{getToken:o}=P(),c=f.useRef(null),m=W(),i=f.useRef(!1),l=f.useRef(null),p=e&&r?`${e}:${r.contentUrl}`:null;l.current!==p&&(l.current=p,i.current=!1);const d=J({queryKey:e?[...D.body(e),r?.contentUrl??null]:["messages","body","noop"],queryFn:()=>{if(!r)throw new Error("No renderable body part");if(!e)throw new Error("No messageId");const u=i.current;return i.current=!1,Xe({fetchContent:(h,v)=>Ve(h,v,o),refetchDescribeMessage:()=>m.refetchQueries({queryKey:H({path:{messageId:e}})})},{contentUrl:r.contentUrl,kind:r.kind,isRetryAfterNotReady:u})},enabled:s&&!!e&&!!r,staleTime:300*1e3,gcTime:1800*1e3,retry:(u,h)=>h instanceof A&&h.reason==="not-ready"?u<We:u<1,retryDelay:(u,h)=>h instanceof A&&h.reason==="not-ready"?(i.current=!0,(h.retryAfterSeconds??1)*1e3):1e3,meta:{softError:!0}}),g=d.isLoading&&!!r;f.useEffect(()=>{g&&(c.current=performance.now())},[g]),f.useEffect(()=>{d.isSuccess&&c.current!==null&&(n.recordTiming("message.body.load",Math.round(performance.now()-c.current)),c.current=null)},[d.isSuccess,n]);const x=d.data&&r?{kind:r.kind,body:d.data}:void 0;return{picked:r,data:x,isLoading:g,isError:d.isError,error:d.error,refetch:d.refetch}},q=(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=q(!0,r):delete n.trusted,{...e,flags:n}},Je=(e,t,s,r)=>{const n=o=>o.map(c=>Ze(c,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=W(),{pushError:s}=te(),{mutate:r,isPending:n,error:o,reset:c}=se({...ne(),onMutate:async i=>{const l=i.path.addressId,d=i.body.flags?.trusted?.value===!0,g=H({path:{messageId:e}});await t.cancelQueries({queryKey:g});const x=t.getQueriesData({queryKey:g}).filter(u=>u[1]!==void 0).map(([u,h])=>({queryKey:u,data:h}));return t.setQueriesData({queryKey:g},u=>u&&Je(u,l,d)),{describePrefix:g,previous:x}},onError:(i,l,p)=>{if(p)for(const d of p.previous)t.setQueryData(d.queryKey,d.data);s(re("Couldn't trust sender","The change wasn't saved.",i))},onSettled:(i,l,p,d)=>{d&&t.invalidateQueries({queryKey:d.describePrefix})}});return{toggleTrusted:(i,l)=>{r({path:{addressId:i},body:{flags:{trusted:q(!l)}}})},isPending:n,error:o,reset:c}},tt=()=>{const[e,t]=f.useState(()=>typeof document<"u"&&document.documentElement.classList.contains("dark"));return f.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 A?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),[c,m]=f.useState(!1),{Account:i}=P();return c?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(ae,{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(i,{children:({signOut:l})=>a.jsx("button",{type:"button",onClick:()=>l(),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(oe,{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"})]}),z=()=>a.jsx("p",{className:"text-fg-muted text-sm italic",children:"This message has no body content."}),Et=({bodyParts:e,html:t,text:s,isTrusted:r=!1,messageId:n,fromAddressId:o,category:c,className:m})=>{const[i,l]=f.useState(!1),p=r||i,d=tt(),{toggleTrusted:g,isPending:x}=et({messageId:n??""}),u=!!e&&e.length>0,{picked:h,data:v,isLoading:M,isError:T,error:b,refetch:k}=Ye({messageId:n,bodyParts:e,enabled:u}),w=f.useMemo(()=>fe(e??[]),[e]),E=u&&v?.kind==="html"?v.body:t,N=u&&v?.kind==="text"?v.body:s;if(u){if(M)return a.jsx("div",{className:C("message-body",m),children:a.jsx(it,{})});if(T)return a.jsx("div",{className:C("message-body",m),children:a.jsx(ot,{error:b,onRetry:()=>k()})});if(!h)return a.jsx("div",{className:C("message-body",m),children:a.jsx(z,{})})}else if(!t&&!s)return a.jsx("div",{className:C("message-body",m),children:a.jsx(z,{})});const y=!!(o&&n),j=()=>{!o||x||(l(!0),g(o,!1))};return a.jsx(Oe,{className:m,html:E,text:N,isDark:d,category:c,allowImages:p,resolveCid:w,renderBlockedNotice:R=>a.jsx(st,{blockedImageCount:R,canAlwaysTrust:y,isTrustPending:x,onLoadOnce:()=>l(!0),onAlwaysTrust:j})})},V={personal:"Personal",uncategorized:"Unclassified",transactional:"Transactional",newsletter:"Newsletter",marketing:"Marketing",social:"Social",automated:"Automated"},ct=Object.values(Q).map(e=>({value:e,label:V[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])),At=e=>ut.get(e.toLowerCase()),ft=/^\d{4}-\d{2}-\d{2}$/;function mt(e,t,s){if(!ft.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(Q).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=Ue(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 mt(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 St(e,t={}){const s=[],r=[];for(const n of G(e)){const o=pt(n.raw,t);o?s.push(o):r.push(n.raw)}return{freeText:r.join(" "),tokens:s}}function Tt(e,t){return G(e).filter(s=>s.raw!==t.raw).map(s=>s.raw).join(" ")}function Nt(e){switch(e.type){case"from":return`From: ${e.value}`;case"subject":return`Subject: ${e.value}`;case"category":return`Category: ${V[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}=ie();return{...ce({select:r=>le(r.matches)})?{}:{mailboxesByName:e},accountsByName:t}}export{Oe as M,vt as R,dt as S,G as a,Ue as b,Ye as c,et as d,Qe as e,Et as f,Nt as g,At as h,St as p,Tt as r,kt as s,jt as u};
@@ -1 +1 @@
1
- import{q as L,ab as C,ad as I,bF as k,bG as E,r as x,j as p,bH as h,bI as A,bJ as j,n as R,w as Q,bK as q}from"./index-3eAE16lF.js";import{ap as D,aq as O,ar as _,as as z,at as N}from"./MailListHeader-CzkFVHra.js";import{a as P}from"./useLabels-Bzefby_I.js";import{M as w}from"./enums-CCxx0t2v.js";import{u as F,s as G}from"./search-scope-Bcn1kzwd.js";import{n as U}from"./search-query-Cr_ZXBCp.js";import{u as B,p as K}from"./useSearchTokenContext-DKU_0B8G.js";const H=t=>{const{mailboxId:s,messages:i}=t,l=L(),{pushError:c}=C(),{mutateAsync:r,isPending:a}=I({...E(),onError:(o,u)=>{c({title:u.body.action==="Remove"?"Couldn't remove label":"Couldn't apply label",detail:k(o),error:o})},onSettled:(o,u,m)=>{D(l,O(_(m.body.messageIds??[],i??[],s)))}});return{applyLabel:x.useCallback((o,u,m)=>{o.length!==0&&z(o,d=>r({body:{messageIds:d,labelId:u,action:m}}))},[r]),isPending:a}};function oe({accountId:t,mailboxId:s,messageIds:i}){const{labels:l}=P(t),{applyLabel:c}=H({mailboxId:s}),r=x.useMemo(()=>l.map(a=>({key:a.labelId,label:a.name,icon:p.jsx("span",{className:`size-2.5 rounded-full ${A(a.color)?h[a.color]:h.Default}`}),onSelect:()=>c(i,a.labelId,"Apply")})),[l,i,c]);return r.length===0?null:p.jsx(N,{triggerLabel:"Apply label to selected messages",triggerIcon:p.jsx(j,{className:"size-4 text-fg-subtle"}),triggerText:"Apply label",items:r,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 J=20,V=new Set(Object.values(w)),$=t=>t!==void 0&&V.has(t)?t:void 0,W=t=>{if(t.some(s=>s.type==="isUnread"))return!1;if(t.some(s=>s.type==="isRead"))return!0};function ne({mailboxId:t,filterCategory:s}={}){const{searchQuery:i}=R(),l=B(),c=F({select:e=>e.matches}),r=U(i),{freeText:a,tokens:n}=K(r,l),o=a.length>0,u=n.find(e=>e.type==="category"),m=$(s)??u?.category,d=n.some(e=>e.type==="hasAttachment")?!0:void 0,b=n.some(e=>e.type==="isStarred")?!0:void 0,y=W(n),f=n.find(e=>e.type==="after"),g=n.find(e=>e.type==="before"),S=n.find(e=>e.type==="in"),M=G({matches:c,callerMailboxId:t,inTokenMailboxId:S?.mailboxId}),{data:T,isLoading:v}=Q({...q({query:{query:a,mailboxId:M,limit:J,...m!==void 0?{category:m}:{},...d!==void 0?{hasAttachment:d}:{},...b!==void 0?{hasStars:b}:{},...y!==void 0?{isRead:y}:{},...f?{sentDateFrom:f.epochSeconds}:{},...g?{sentDateTo:g.epochSeconds}:{}}}),enabled:o,staleTime:6e4});return{hits:T?.items??[],isLoading:o&&v}}export{oe as L,ne as u};
1
+ import{q as L,ab as C,ad as E,bC as I,bD as k,r as x,j as p,bE as h,bF as A,bG as j,n as R,w as D,bH as Q}from"./index-CNoNYU4b.js";import{ap as q,aq as O,ar as _,as as z,at as N}from"./MailListHeader-CaZUuANM.js";import{a as P}from"./useLabels-DKpzozgD.js";import{M as w}from"./enums-CCxx0t2v.js";import{u as F,s as G}from"./search-scope-Ds_ghZOi.js";import{n as U}from"./search-query-Cr_ZXBCp.js";import{u as B,p as H}from"./useSearchTokenContext-DIryp5er.js";const K=t=>{const{mailboxId:s,messages:i}=t,l=L(),{pushError:c}=C(),{mutateAsync:r,isPending:a}=E({...k(),onError:(o,u)=>{c({title:u.body.action==="Remove"?"Couldn't remove label":"Couldn't apply label",detail:I(o),error:o})},onSettled:(o,u,m)=>{q(l,O(_(m.body.messageIds??[],i??[],s)))}});return{applyLabel:x.useCallback((o,u,m)=>{o.length!==0&&z(o,d=>r({body:{messageIds:d,labelId:u,action:m}}))},[r]),isPending:a}};function oe({accountId:t,mailboxId:s,messageIds:i}){const{labels:l}=P(t),{applyLabel:c}=K({mailboxId:s}),r=x.useMemo(()=>l.map(a=>({key:a.labelId,label:a.name,icon:p.jsx("span",{className:`size-2.5 rounded-full ${A(a.color)?h[a.color]:h.Default}`}),onSelect:()=>c(i,a.labelId,"Apply")})),[l,i,c]);return r.length===0?null:p.jsx(N,{triggerLabel:"Apply label to selected messages",triggerIcon:p.jsx(j,{className:"size-4 text-fg-subtle"}),triggerText:"Apply label",items:r,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(w)),J=t=>t!==void 0&&$.has(t)?t:void 0,W=t=>{if(t.some(s=>s.type==="isUnread"))return!1;if(t.some(s=>s.type==="isRead"))return!0};function ne({mailboxId:t,filterCategory:s}={}){const{searchQuery:i}=R(),l=B(),c=F({select:e=>e.matches}),r=U(i),{freeText:a,tokens:n}=H(r,l),o=a.length>0,u=n.find(e=>e.type==="category"),m=J(s)??u?.category,d=n.some(e=>e.type==="hasAttachment")?!0:void 0,b=n.some(e=>e.type==="isStarred")?!0:void 0,y=W(n),f=n.find(e=>e.type==="after"),g=n.find(e=>e.type==="before"),S=n.find(e=>e.type==="in"),M=G({matches:c,callerMailboxId:t,inTokenMailboxId:S?.mailboxId}),{data:T,isLoading:v}=D({...Q({query:{query:a,mailboxId:M,limit:V,...m!==void 0?{category:m}:{},...d!==void 0?{hasAttachment:d}:{},...b!==void 0?{hasStars:b}:{},...y!==void 0?{isRead:y}:{},...f?{sentDateFrom:f.epochSeconds}:{},...g?{sentDateTo:g.epochSeconds}:{}}}),enabled:o,staleTime:6e4});return{hits:T?.items??[],isLoading:o&&v}}export{oe as L,ne as u};
@@ -1 +1 @@
1
- import{q as g,ab as f,w as p,W as m,r,ad as y,ae as T,$ as E,af as d}from"./index-3eAE16lF.js";const i={html:"",plainText:""},C=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(s=>s.accountId===e);return t?{html:t.signatureHtml??"",plainText:t.signaturePlainText??""}:i},[e,n]),a=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,s)=>{e&&a.mutate({path:{accountId:e},body:{signatureHtml:t,signaturePlainText:s}})},[e,a]);return{signature:l,setSignature:c,isSaving:a.isPending}};export{C as u};
1
+ import{q as g,ab as f,w as p,W as m,r,ad as y,ae as T,$ as E,af as d}from"./index-CNoNYU4b.js";const i={html:"",plainText:""},C=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(s=>s.accountId===e);return t?{html:t.signatureHtml??"",plainText:t.signaturePlainText??""}:i},[e,n]),a=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,s)=>{e&&a.mutate({path:{accountId:e},body:{signatureHtml:t,signaturePlainText:s}})},[e,a]);return{signature:l,setSignature:c,isSaving:a.isPending}};export{C as u};
package/index.html CHANGED
@@ -38,7 +38,7 @@
38
38
  } catch (_) {}
39
39
  })();
40
40
  </script>
41
- <script type="module" crossorigin src="/assets/index-3eAE16lF.js"></script>
41
+ <script type="module" crossorigin src="/assets/index-CNoNYU4b.js"></script>
42
42
  <link rel="stylesheet" crossorigin href="/assets/index-B9v7X7iy.css">
43
43
  </head>
44
44
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/web-client-dist",
3
- "version": "0.0.321",
3
+ "version": "0.0.323",
4
4
  "description": "Built Remit web client — static assets and the default runtime config.",
5
5
  "files": [
6
6
  "**/*"
@@ -1 +0,0 @@
1
- import{a9 as S,e as w,al as k,j as e,b,bx as _,T as U,f as C,o as H,V as K,w as W,x as G,n as J,r as u,u as R,bp as I,by as V,J as N,q as X,k as Y,ab as Z,bb as ee,ad as v,ae as y,bz as se,bc as te}from"./index-3eAE16lF.js";import{u as ne,p as ae,R as p,M as oe}from"./useSearchTokenContext-DKU_0B8G.js";import{C as A}from"./circle-check-big-Dm9DZK8n.js";import{C as T}from"./clock-LgAy7KhC.js";import{R as re}from"./row-actions-Cfzm03L2.js";import{R as ie}from"./rotate-ccw-CgMVBPU0.js";import{N as E}from"./NavMenuButton-DmFeFE-H.js";import{a as g,t as le}from"./format-De9HZKjg.js";import{i as ce,a as L}from"./outbox-status-CPfNHfUQ.js";import{n as de}from"./search-query-Cr_ZXBCp.js";const ue={queued:{icon:T,label:"Queued",className:"text-warning"},sending:{icon:k,label:"Sending…",className:"text-accent-2",spin:!0},sent:{icon:A,label:"Sent",className:"text-positive"},failed:{icon:w,label:"Failed",className:"text-danger"},blocked:{icon:S,label:"Blocked",className:"text-warning"}};function M({status:s,iconOnly:n,className:a}){const t=ue[s],o=t.icon;return e.jsxs("span",{className:b("inline-flex items-center gap-1.5 text-xs font-medium",t.className,a),children:[e.jsx(o,{className:b("size-4",t.spin&&"animate-spin")}),!n&&t.label]})}const xe=(s,n)=>n?"bg-accent-2-soft":s==="failed"?"bg-danger-soft":s==="blocked"?"bg-warning/10":"";function me({recipients:s,subject:n,time:a,status:t,error:o,selected:i,onSelect:c,onRetry:r,retrying:l,onEdit:x,onDelete:m,deleting:d}){const h=t==="failed"||t==="blocked";return e.jsxs("div",{className:b("flex items-start gap-3 border-b border-line px-4 py-3 transition-colors hover:bg-surface-raised",xe(t,i)),children:[e.jsxs("button",{type:"button",..._,onClick:c,className:"flex flex-1 min-w-0 items-start gap-3 text-left",children:[e.jsx("div",{className:"mt-0.5 shrink-0",children:e.jsx(M,{status:t,iconOnly:!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:s}),e.jsx("span",{className:"shrink-0 text-xs text-fg-muted",children:a})]}),e.jsx("div",{className:"truncate text-sm",children:n||"No subject"}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx(M,{status:t}),o&&e.jsxs("span",{className:"truncate text-xs text-fg-muted",children:["— ",o]})]})]})]}),h&&e.jsx("div",{className:"shrink-0",children:e.jsx(re,{actions:[...t==="failed"&&r?[{label:"Retry sending",iconOnly:!0,icon:e.jsx(ie,{className:"size-3.5"}),busy:l,onClick:r}]:[],{label:"Edit as draft",iconOnly:!0,icon:e.jsx(C,{className:"size-3.5"}),onClick:x}],destructive:{label:"Delete message",iconOnly:!0,icon:e.jsx(U,{className:"size-3.5"}),busy:d,confirm:{prompt:"Delete this message?",confirmLabel:"Delete"},onClick:m}})})]})}function fe(s,n){const a=n.trim().toLowerCase();if(a.length===0)return!0;const t=[s.subject,s.fromAddress,s.fromName,...s.toAddresses??[],...s.ccAddresses??[]].filter(o=>typeof o=="string").join(" ").toLowerCase();return a.split(/\s+/).every(o=>o.length===0||t.includes(o))}function he(s){return s.tokens.length>0&&s.freeText.trim().length===0}const Q={queued:{icon:T,label:"Queued",className:"text-warning"},sending:{icon:k,label:"Sending…",className:"text-accent-2"},sent:{icon:A,label:"Sent",className:"text-positive"},failed:{icon:w,label:"Failed",className:"text-danger"},blocked:{icon:S,label:"Blocked",className:"text-warning"}},be=s=>le(s).toDateString()===new Date().toDateString()?g(s,{hour:"numeric",minute:"2-digit"}):g(s,{month:"short",day:"numeric"}),O=s=>g(s,{dateStyle:"medium",timeStyle:"short"}),ge=s=>{const n=s.toAddresses??[];return n.length===0?"No recipients":n.length===1?n[0]:`${n[0]} +${n.length-1}`},D=(s,n)=>n?"The outbox cannot filter on those terms":s?"No matching outbox messages":"No outbox messages",P=u.createContext(null);function j(){const s=u.useContext(P);if(!s)throw new Error("OutboxPane.* must be used inside <OutboxPane>");return s}function pe({children:s}){const n=H(),{selectedOutboxMessageId:a}=K({strict:!1}),{data:t,isLoading:o}=W(G()),{searchQuery:i}=J(),c=ne(),r=de(i),l=ae(r,c),x=r.length>0,m=he(l),d=u.useMemo(()=>m?[]:(t?.items??[]).filter(f=>ce(f.status)).filter(f=>fe(f,l.freeText)),[t,l.freeText,m]),h=u.useMemo(()=>d.find(f=>f.outboxMessageId===a),[d,a]),F=u.useCallback(f=>{n({to:"/mail/outbox",search:q=>({...q,selectedOutboxMessageId:f})})},[n]),$={messages:d,hasQuery:x,unsupportedQuery:m,isLoading:o,selectedMessageId:a,selectedMessage:h,onSelectMessage:F};return e.jsx(P.Provider,{value:$,children:s})}function B({message:s,isSelected:n,onSelect:a}){const t=X(),{openCompose:o}=Y(),{pushError:i}=Z(),c=u.useCallback(()=>{t.invalidateQueries({queryKey:ee()})},[t]),r=v({...se(),onSuccess:c,onError:d=>{i(y("Couldn't resend message","The message wasn't sent.",d))}}),l=v({...te(),onSuccess:c,onError:d=>{i(y("Couldn't delete message","The message wasn't deleted.",d))}}),x=s.status;if(!Q[x])return null;const m=L(s.status);return e.jsx(me,{recipients:ge(s),subject:s.subject||"",time:be(s.sentAt??s.updatedAt),status:x,error:m?s.lastError??void 0:void 0,selected:n,onSelect:a,onRetry:x==="failed"?()=>r.mutate({path:{outboxMessageId:s.outboxMessageId}}):void 0,retrying:r.isPending,onEdit:()=>o({mode:"new",outboxMessageId:s.outboxMessageId}),onDelete:()=>l.mutate({path:{outboxMessageId:s.outboxMessageId}}),deleting:l.isPending})}function z({message:s,onBack:n}){const a=s.status,t=Q[a],o=t?.icon??C,i=s.sentAt?O(s.sentAt):O(s.updatedAt);return e.jsxs("div",{className:"h-full overflow-y-auto bg-canvas",children:[e.jsxs("div",{className:"border-b border-line p-4",children:[n&&e.jsxs("button",{type:"button",onClick:n,className:"mb-3 inline-flex items-center gap-1 text-sm text-fg-muted hover:text-fg",children:[e.jsx(V,{className:"size-4"}),e.jsx("span",{children:"Back"})]}),e.jsx("h1",{className:"text-xl font-semibold mb-3",children:s.subject||"(No subject)"}),e.jsxs("div",{className:"space-y-1 text-sm",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"text-fg-muted shrink-0 w-12",children:"From:"}),e.jsx("span",{className:"text-fg",children:s.fromName?`${s.fromName} <${s.fromAddress}>`:s.fromAddress})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"text-fg-muted shrink-0 w-12",children:"To:"}),e.jsx("span",{className:"text-fg",children:(s.toAddresses??[]).join(", ")})]}),s.ccAddresses&&s.ccAddresses.length>0&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"text-fg-muted shrink-0 w-12",children:"Cc:"}),e.jsx("span",{className:"text-fg",children:s.ccAddresses.join(", ")})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"text-fg-muted shrink-0 w-12",children:"Date:"}),e.jsx("span",{className:"text-fg",children:i})]}),t&&e.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[e.jsx(o,{className:N("size-4",t.className,a==="sending"&&"animate-spin")}),e.jsx("span",{className:N("text-xs font-medium",t.className),children:t.label}),L(s.status)&&s.lastError&&e.jsxs("span",{className:"text-xs text-fg-muted",children:["— ",s.lastError]})]})]})]}),e.jsx("div",{className:"p-4",children:e.jsx(oe,{html:s.htmlBody,text:s.textBody})})]})}function je(){const{messages:s,hasQuery:n,unsupportedQuery:a,isLoading:t,selectedMessageId:o,onSelectMessage:i}=j(),c=u.useRef(null);return R({containerRef:c,itemSelector:I}),t?e.jsx("div",{className:"flex h-full items-center justify-center bg-canvas",children:e.jsx("span",{className:"text-fg-muted",children:"Loading..."})}):s.length===0?e.jsx("div",{className:"flex h-full bg-surface",children:e.jsx(p,{message:D(n,a),showHints:!1})}):e.jsxs("div",{className:"h-full flex flex-col bg-canvas",children:[e.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[e.jsx(E,{}),e.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:"Outbox"}),e.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle",children:[s.length," ",s.length===1?"message":"messages"]})]}),e.jsx("div",{ref:c,className:"flex-1 overflow-y-auto",children:s.map(r=>e.jsx(B,{message:r,isSelected:o===r.outboxMessageId,onSelect:()=>i(r.outboxMessageId)},r.outboxMessageId))})]})}function Ne(){const{selectedMessage:s}=j();return e.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[e.jsx("header",{className:"flex h-pane-header shrink-0 items-center border-b border-line px-3"}),e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:s?e.jsx(z,{message:s}):e.jsx(p,{message:"Select a message to read",showHints:!1})})]})}function ve(){const{messages:s,hasQuery:n,unsupportedQuery:a,isLoading:t,selectedMessageId:o,selectedMessage:i,onSelectMessage:c}=j(),r=u.useRef(null);return R({containerRef:r,itemSelector:I}),t?e.jsx("div",{className:"flex h-full items-center justify-center bg-canvas",children:e.jsx("span",{className:"text-fg-muted",children:"Loading..."})}):i?e.jsx(z,{message:i,onBack:()=>c(void 0)}):s.length===0?e.jsx("div",{className:"flex h-full bg-surface",children:e.jsx(p,{message:D(n,a),showHints:!1})}):e.jsxs("div",{className:"h-full flex flex-col bg-canvas",children:[e.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[e.jsx(E,{}),e.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:"Outbox"}),e.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle",children:[s.length," ",s.length===1?"message":"messages"]})]}),e.jsx("div",{ref:r,className:"flex-1 overflow-y-auto",children:s.map(l=>e.jsx(B,{message:l,isSelected:o===l.outboxMessageId,onSelect:()=>c(l.outboxMessageId)},l.outboxMessageId))})]})}const Te=Object.assign(pe,{List:je,Reading:Ne,Phone:ve});export{Te as O};
@@ -1 +0,0 @@
1
- import{a1 as m,j as o,_ as p}from"./index-3eAE16lF.js";import{a as e}from"./search-view-BtUa3wf0.js";import{M as r}from"./MailboxPane-DxXhzeri.js";import{u as a}from"./useSearchMirror-BJ2isjrf.js";import"./search-scope-Bcn1kzwd.js";import"./useSearchTokenContext-DKU_0B8G.js";import"./kbd-BVVVI8MK.js";import"./enums-CCxx0t2v.js";import"./useRefreshControl-DivGdE-V.js";import"./circle-check-big-Dm9DZK8n.js";import"./search-token-index-XT09xk5-.js";import"./useMediaQuery-vS62WMhd.js";import"./MailListHeader-CzkFVHra.js";import"./account-form-helpers-DgsG82nf.js";import"./avatar-B5Xfa_Aj.js";import"./useSignature-DEHQxXCm.js";import"./useDebouncedValue-nan84ZZT.js";import"./ErrorState-By22X09V.js";import"./format-De9HZKjg.js";import"./download-FAYYcvQP.js";import"./shield-check-Dq-7lUbt.js";import"./move-options-s_k2CE-Q.js";import"./useFilters-laocR3nD.js";import"./confirm-dialog-d8zs8D-F.js";import"./clock-LgAy7KhC.js";import"./menu-B3HPQBVa.js";import"./MailViewChrome-_M0MZo3I.js";import"./NavMenuButton-DmFeFE-H.js";import"./useLabels-Bzefby_I.js";import"./useSemanticSearch-Br2klJqm.js";import"./search-query-Cr_ZXBCp.js";import"./bottom-sheet-CWKDKUBi.js";import"./circle-help-BGR1fVqk.js";import"./circle-check-D_nZdueG.js";import"./intelligence-pref-C6lFpj6U.js";function H(){const{mailboxId:t}=m.useParams(),{selectedMessageId:i}=m.useSearch();return a({to:"/mail/$mailboxId",params:{mailboxId:t}}),o.jsx(r,{mailboxId:t,selectedMessageId:i,children:o.jsx(e,{phone:o.jsx(r.Phone,{}),list:o.jsx(r.List,{}),reading:o.jsx(p,{}),intelligence:o.jsx(r.Intelligence,{}),hasThread:!!i})})}export{H as component};
@@ -1 +0,0 @@
1
- import{j as r}from"./index-3eAE16lF.js";import{B as o}from"./BriefPane-BvS6OY3_.js";import"./useSearchTokenContext-DKU_0B8G.js";import"./kbd-BVVVI8MK.js";import"./enums-CCxx0t2v.js";import"./search-scope-Bcn1kzwd.js";import"./MailListHeader-CzkFVHra.js";import"./search-token-index-XT09xk5-.js";import"./useMediaQuery-vS62WMhd.js";import"./account-form-helpers-DgsG82nf.js";import"./avatar-B5Xfa_Aj.js";import"./useSignature-DEHQxXCm.js";import"./useDebouncedValue-nan84ZZT.js";import"./ErrorState-By22X09V.js";import"./format-De9HZKjg.js";import"./download-FAYYcvQP.js";import"./shield-check-Dq-7lUbt.js";import"./move-options-s_k2CE-Q.js";import"./useFilters-laocR3nD.js";import"./confirm-dialog-d8zs8D-F.js";import"./clock-LgAy7KhC.js";import"./menu-B3HPQBVa.js";import"./useRefreshControl-DivGdE-V.js";import"./circle-check-big-Dm9DZK8n.js";import"./useLabels-Bzefby_I.js";import"./useSemanticSearch-Br2klJqm.js";import"./search-query-Cr_ZXBCp.js";function y(){return r.jsx(o.Reading,{})}export{y as component};
@@ -1 +0,0 @@
1
- import{_ as o}from"./index-3eAE16lF.js";const n=o;export{n as component};
@@ -1 +0,0 @@
1
- import{z as m,r as a,j as r,_ as p}from"./index-3eAE16lF.js";import{a as n}from"./search-view-BtUa3wf0.js";import{B as t}from"./BriefPane-BvS6OY3_.js";import{u as d}from"./useSearchMirror-BJ2isjrf.js";import"./search-token-index-XT09xk5-.js";import"./search-scope-Bcn1kzwd.js";import"./useSearchTokenContext-DKU_0B8G.js";import"./kbd-BVVVI8MK.js";import"./enums-CCxx0t2v.js";import"./MailListHeader-CzkFVHra.js";import"./account-form-helpers-DgsG82nf.js";import"./avatar-B5Xfa_Aj.js";import"./useSignature-DEHQxXCm.js";import"./useDebouncedValue-nan84ZZT.js";import"./useMediaQuery-vS62WMhd.js";import"./ErrorState-By22X09V.js";import"./format-De9HZKjg.js";import"./download-FAYYcvQP.js";import"./shield-check-Dq-7lUbt.js";import"./move-options-s_k2CE-Q.js";import"./useFilters-laocR3nD.js";import"./confirm-dialog-d8zs8D-F.js";import"./clock-LgAy7KhC.js";import"./menu-B3HPQBVa.js";import"./useRefreshControl-DivGdE-V.js";import"./circle-check-big-Dm9DZK8n.js";import"./useLabels-Bzefby_I.js";import"./useSemanticSearch-Br2klJqm.js";import"./search-query-Cr_ZXBCp.js";function h(){const o=m({from:"/mail/brief/$threadId",shouldThrow:!1}),s=m({from:"/mail/brief/$threadId/$messageId",shouldThrow:!1}),i=o?.threadId,e=s?.messageId;return a.useMemo(()=>i?{threadId:i,messageId:e}:void 0,[i,e])}function F(){const o=h();return d({to:"/mail/brief"}),r.jsx(t,{thread:o,children:r.jsx(n,{phone:r.jsx(t.Phone,{}),list:r.jsx(t.List,{}),reading:r.jsx(p,{}),intelligence:r.jsx(t.Intelligence,{}),hasThread:!!o})})}export{F as component};
@@ -1 +0,0 @@
1
- import{a2 as i,j as o,_ as e}from"./index-3eAE16lF.js";import{a as m}from"./search-view-BtUa3wf0.js";import{F as t}from"./FlaggedPane-COtoIxw_.js";import{u as p}from"./useSearchMirror-BJ2isjrf.js";import"./search-scope-Bcn1kzwd.js";import"./useSearchTokenContext-DKU_0B8G.js";import"./kbd-BVVVI8MK.js";import"./enums-CCxx0t2v.js";import"./MailListHeader-CzkFVHra.js";import"./search-token-index-XT09xk5-.js";import"./useMediaQuery-vS62WMhd.js";import"./account-form-helpers-DgsG82nf.js";import"./avatar-B5Xfa_Aj.js";import"./useSignature-DEHQxXCm.js";import"./useDebouncedValue-nan84ZZT.js";import"./ErrorState-By22X09V.js";import"./format-De9HZKjg.js";import"./download-FAYYcvQP.js";import"./shield-check-Dq-7lUbt.js";import"./move-options-s_k2CE-Q.js";import"./useFilters-laocR3nD.js";import"./confirm-dialog-d8zs8D-F.js";import"./clock-LgAy7KhC.js";import"./menu-B3HPQBVa.js";import"./MailViewChrome-_M0MZo3I.js";function b(){const{selectedMessageId:r}=i.useSearch();return p({to:"/mail/flagged"}),o.jsx(t,{selectedMessageId:r,children:o.jsx(m,{phone:o.jsx(t.Phone,{}),list:o.jsx(t.List,{}),reading:o.jsx(e,{}),intelligence:o.jsx(t.Intelligence,{}),hasThread:!!r})})}export{b as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-3eAE16lF.js";import{F as r}from"./FlaggedPane-COtoIxw_.js";import"./useSearchTokenContext-DKU_0B8G.js";import"./kbd-BVVVI8MK.js";import"./enums-CCxx0t2v.js";import"./search-scope-Bcn1kzwd.js";import"./MailListHeader-CzkFVHra.js";import"./search-token-index-XT09xk5-.js";import"./useMediaQuery-vS62WMhd.js";import"./account-form-helpers-DgsG82nf.js";import"./avatar-B5Xfa_Aj.js";import"./useSignature-DEHQxXCm.js";import"./useDebouncedValue-nan84ZZT.js";import"./ErrorState-By22X09V.js";import"./format-De9HZKjg.js";import"./download-FAYYcvQP.js";import"./shield-check-Dq-7lUbt.js";import"./move-options-s_k2CE-Q.js";import"./useFilters-laocR3nD.js";import"./confirm-dialog-d8zs8D-F.js";import"./clock-LgAy7KhC.js";import"./menu-B3HPQBVa.js";import"./MailViewChrome-_M0MZo3I.js";function q(){return o.jsx(r.Reading,{})}export{q as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-3eAE16lF.js";import{M as i}from"./MailboxPane-DxXhzeri.js";import"./useSearchTokenContext-DKU_0B8G.js";import"./kbd-BVVVI8MK.js";import"./enums-CCxx0t2v.js";import"./search-scope-Bcn1kzwd.js";import"./useRefreshControl-DivGdE-V.js";import"./circle-check-big-Dm9DZK8n.js";import"./search-token-index-XT09xk5-.js";import"./useMediaQuery-vS62WMhd.js";import"./MailListHeader-CzkFVHra.js";import"./account-form-helpers-DgsG82nf.js";import"./avatar-B5Xfa_Aj.js";import"./useSignature-DEHQxXCm.js";import"./useDebouncedValue-nan84ZZT.js";import"./ErrorState-By22X09V.js";import"./format-De9HZKjg.js";import"./download-FAYYcvQP.js";import"./shield-check-Dq-7lUbt.js";import"./move-options-s_k2CE-Q.js";import"./useFilters-laocR3nD.js";import"./confirm-dialog-d8zs8D-F.js";import"./clock-LgAy7KhC.js";import"./menu-B3HPQBVa.js";import"./MailViewChrome-_M0MZo3I.js";import"./NavMenuButton-DmFeFE-H.js";import"./useLabels-Bzefby_I.js";import"./useSemanticSearch-Br2klJqm.js";import"./search-query-Cr_ZXBCp.js";import"./bottom-sheet-CWKDKUBi.js";import"./circle-help-BGR1fVqk.js";import"./circle-check-D_nZdueG.js";import"./intelligence-pref-C6lFpj6U.js";function G(){return o.jsx(i.Reading,{})}export{G as component};
@@ -1 +0,0 @@
1
- import{j as r}from"./index-3eAE16lF.js";import{B as o}from"./BriefPane-BvS6OY3_.js";import"./useSearchTokenContext-DKU_0B8G.js";import"./kbd-BVVVI8MK.js";import"./enums-CCxx0t2v.js";import"./search-scope-Bcn1kzwd.js";import"./MailListHeader-CzkFVHra.js";import"./search-token-index-XT09xk5-.js";import"./useMediaQuery-vS62WMhd.js";import"./account-form-helpers-DgsG82nf.js";import"./avatar-B5Xfa_Aj.js";import"./useSignature-DEHQxXCm.js";import"./useDebouncedValue-nan84ZZT.js";import"./ErrorState-By22X09V.js";import"./format-De9HZKjg.js";import"./download-FAYYcvQP.js";import"./shield-check-Dq-7lUbt.js";import"./move-options-s_k2CE-Q.js";import"./useFilters-laocR3nD.js";import"./confirm-dialog-d8zs8D-F.js";import"./clock-LgAy7KhC.js";import"./menu-B3HPQBVa.js";import"./useRefreshControl-DivGdE-V.js";import"./circle-check-big-Dm9DZK8n.js";import"./useLabels-Bzefby_I.js";import"./useSemanticSearch-Br2klJqm.js";import"./search-query-Cr_ZXBCp.js";function z(){return r.jsx(o.Reading,{})}export{z as component};
@@ -1 +0,0 @@
1
- import{j as t,a5 as o}from"./index-3eAE16lF.js";const n=()=>t.jsx(o,{to:"/settings/accounts"});export{n as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-3eAE16lF.js";import{O as t}from"./OutboxPane-BTeGPBk1.js";import"./useSearchTokenContext-DKU_0B8G.js";import"./kbd-BVVVI8MK.js";import"./enums-CCxx0t2v.js";import"./search-scope-Bcn1kzwd.js";import"./circle-check-big-Dm9DZK8n.js";import"./clock-LgAy7KhC.js";import"./row-actions-Cfzm03L2.js";import"./rotate-ccw-CgMVBPU0.js";import"./NavMenuButton-DmFeFE-H.js";import"./menu-B3HPQBVa.js";import"./format-De9HZKjg.js";import"./outbox-status-CPfNHfUQ.js";import"./search-query-Cr_ZXBCp.js";function c(){return o.jsx(t.Reading,{})}export{c as component};
@@ -1 +0,0 @@
1
- import{j as r}from"./index-3eAE16lF.js";import{B as o}from"./BriefPane-BvS6OY3_.js";import"./useSearchTokenContext-DKU_0B8G.js";import"./kbd-BVVVI8MK.js";import"./enums-CCxx0t2v.js";import"./search-scope-Bcn1kzwd.js";import"./MailListHeader-CzkFVHra.js";import"./search-token-index-XT09xk5-.js";import"./useMediaQuery-vS62WMhd.js";import"./account-form-helpers-DgsG82nf.js";import"./avatar-B5Xfa_Aj.js";import"./useSignature-DEHQxXCm.js";import"./useDebouncedValue-nan84ZZT.js";import"./ErrorState-By22X09V.js";import"./format-De9HZKjg.js";import"./download-FAYYcvQP.js";import"./shield-check-Dq-7lUbt.js";import"./move-options-s_k2CE-Q.js";import"./useFilters-laocR3nD.js";import"./confirm-dialog-d8zs8D-F.js";import"./clock-LgAy7KhC.js";import"./menu-B3HPQBVa.js";import"./useRefreshControl-DivGdE-V.js";import"./circle-check-big-Dm9DZK8n.js";import"./useLabels-Bzefby_I.js";import"./useSemanticSearch-Br2klJqm.js";import"./search-query-Cr_ZXBCp.js";function y(){return r.jsx(o.Reading,{})}export{y as component};