@remit/web-client-dist 0.0.466 → 0.0.468

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 (114) hide show
  1. package/assets/BriefPane-DLK5k99W.js +1 -0
  2. package/assets/{ErrorState-DahaLsPP.js → ErrorState-B1mR3jCT.js} +1 -1
  3. package/assets/{FlaggedPane-BnLZg3bX.js → FlaggedPane-DI6-ax2Z.js} +1 -1
  4. package/assets/{FullCompose-BRl0TTg1.js → FullCompose-Br0mcbGw.js} +1 -1
  5. package/assets/{MailListHeader-CE3fumXQ.js → MailListHeader-C9Ahbu_k.js} +2 -2
  6. package/assets/{MailShell-DM51bkst.js → MailShell-CUim8dj6.js} +1 -1
  7. package/assets/{MailViewChrome-rCAcUprL.js → MailViewChrome-D9aV_9be.js} +1 -1
  8. package/assets/{MailboxPane-CfEuGJke.js → MailboxPane-Dj528iUI.js} +1 -1
  9. package/assets/{NavMenuButton-D7OnVn0n.js → NavMenuButton-BQ9-rzur.js} +1 -1
  10. package/assets/{OnboardingWizard-D7n1FFgq.js → OnboardingWizard-5emWPpUT.js} +1 -1
  11. package/assets/{OutboxPane-CHY4zzPd.js → OutboxPane-32Q9m5ko.js} +1 -1
  12. package/assets/_mailboxId-BMhZ77qu.js +1 -0
  13. package/assets/_messageId-BCIXHmXz.js +1 -0
  14. package/assets/_messageId-H07H7Eex.js +1 -0
  15. package/assets/_messageId-mRH07OoH.js +1 -0
  16. package/assets/_outboxMessageId-9cyseXBF.js +1 -0
  17. package/assets/_threadId-DIaDNMTt.js +1 -0
  18. package/assets/_threadId-DV5G2S4v.js +1 -0
  19. package/assets/_threadId-DWlFkjM3.js +1 -0
  20. package/assets/{accounts-b7snCCud.js → accounts-BhVAc8yw.js} +1 -1
  21. package/assets/advanced-DUSGDBfK.js +4 -0
  22. package/assets/{appearance-BnKopIIl.js → appearance-BbkweWeP.js} +1 -1
  23. package/assets/{attachment-file-DdY-ZgnJ.js → attachment-file-DEH4WgYf.js} +1 -1
  24. package/assets/{avatar-CgRc9nHj.js → avatar-BBglc2I4.js} +1 -1
  25. package/assets/{bottom-sheet-Buif-5NL.js → bottom-sheet-OpVokgSv.js} +1 -1
  26. package/assets/{brief-t259xOxc.js → brief-CrRSkqlA.js} +1 -1
  27. package/assets/brief-cxgK-E6D.js +1 -0
  28. package/assets/{browser-ponyfill-CyCeay-8.js → browser-ponyfill-Df7n_1sC.js} +2 -2
  29. package/assets/{bug-DJcpDTib.js → bug-D_fNRScy.js} +1 -1
  30. package/assets/{circle-check-Cj5oazRb.js → circle-check-Baq2FWDe.js} +1 -1
  31. package/assets/{circle-check-big-LmiZ66Yc.js → circle-check-big-CXwm43TJ.js} +1 -1
  32. package/assets/{circle-help-C-uModsr.js → circle-help-CM8xpE1V.js} +1 -1
  33. package/assets/{clock-C7yqRbXe.js → clock-BQeXEzQF.js} +1 -1
  34. package/assets/compose._-_outboxMessageId_-3wpqxHI6.js +1 -0
  35. package/assets/compose._-_outboxMessageId_-CPMXxUi_.js +1 -0
  36. package/assets/compose._-_outboxMessageId_-DWeiwO6s.js +1 -0
  37. package/assets/compose._-_outboxMessageId_-DndQVaa2.js +1 -0
  38. package/assets/{confirm-dialog-BsxoJB1K.js → confirm-dialog-GmPoGhCn.js} +1 -1
  39. package/assets/{download-D8jdmJXi.js → download-EfcHBuh8.js} +1 -1
  40. package/assets/{filters-QOwHL3Ws.js → filters-DidFDGTV.js} +1 -1
  41. package/assets/flagged-BhTGWo0c.js +1 -0
  42. package/assets/{flagged-SOlEOghK.js → flagged-utTyqiq-.js} +1 -1
  43. package/assets/{folders-ClaskegL.js → folders-Cef6uriX.js} +1 -1
  44. package/assets/{format-Q6SH-IHD.js → format-3KE4u_Hd.js} +1 -1
  45. package/assets/{help-copy-CqGXlWWr.js → help-copy-CtXPXqHY.js} +1 -1
  46. package/assets/{index-C0YbF1L6.js → index-BWDUs3V6.js} +51 -51
  47. package/assets/{index-Xoco-tet.js → index-B_8e-R9R.js} +7 -7
  48. package/assets/index-BeNI6neR.js +1 -0
  49. package/assets/index-CLDF_4HA.js +1 -0
  50. package/assets/index-CzK-6vhR.js +1 -0
  51. package/assets/index-DEO1VWcT.js +1 -0
  52. package/assets/index-DyGkymdi.js +1 -0
  53. package/assets/index-H07H7Eex.js +1 -0
  54. package/assets/index-cMzfCNd2.js +1 -0
  55. package/assets/index-mRH07OoH.js +1 -0
  56. package/assets/{kbd-BroWJblw.js → kbd-B38YZfep.js} +1 -1
  57. package/assets/{labels-oVvqVPqX.js → labels-CCi4LQfv.js} +1 -1
  58. package/assets/{mail-Dk_5qV5Y.js → mail-BWE-pYx5.js} +1 -1
  59. package/assets/mail-Cg3Fw05o.js +1 -0
  60. package/assets/{menu-D9zjxEPa.js → menu-5hCLgFBH.js} +1 -1
  61. package/assets/{onboarding-BgPHzyar.js → onboarding-DDciFWNb.js} +1 -1
  62. package/assets/outbox-_x6GAjiP.js +1 -0
  63. package/assets/{pencil-lIIqlS7F.js → pencil-YuDLXsRQ.js} +1 -1
  64. package/assets/{rich-text-DrIBcneQ.js → rich-text-CfSZ-p4W.js} +1 -1
  65. package/assets/{rich-text-spellcheck-worker-provider-COaIbIz6.js → rich-text-spellcheck-worker-provider-CgGcVVZ7.js} +1 -1
  66. package/assets/{rotate-ccw-BhOBHPpy.js → rotate-ccw-XBZJu6qP.js} +1 -1
  67. package/assets/{row-actions-CgwuP_XL.js → row-actions-oBe5D2si.js} +1 -1
  68. package/assets/{search-mirror-BxxbguOQ.js → search-mirror-CykJ2cWs.js} +1 -1
  69. package/assets/search-token-index-CqhHYEC3.js +1 -0
  70. package/assets/{senders-BRrbMgxw.js → senders-DtECYsWd.js} +1 -1
  71. package/assets/settings-DhIrOkty.js +1 -0
  72. package/assets/{settings-screen-oaXSGTtC.js → settings-screen-DAIjg4OV.js} +1 -1
  73. package/assets/{shield-check-CcjA5zAM.js → shield-check-lGPCGnQJ.js} +1 -1
  74. package/assets/{suggested-vips-TrcvWL6P.js → suggested-vips-DxtB-62O.js} +1 -1
  75. package/assets/{useDebouncedValue-Nd03opjC.js → useDebouncedValue-s7snq_EM.js} +1 -1
  76. package/assets/{useFilters-CyHmS5pJ.js → useFilters-gaAKlbPF.js} +1 -1
  77. package/assets/{useLabels-1rNWGQyV.js → useLabels-B3A1qgdI.js} +1 -1
  78. package/assets/{useMessageBodyContent-DUyoMT7-.js → useMessageBodyContent-DS0NFpSx.js} +1 -1
  79. package/assets/useQueries-C3zqiHO-.js +1 -0
  80. package/assets/useRefreshControl-oC0K6m0h.js +1 -0
  81. package/assets/{useSearchTokenContext-9FUSRyq-.js → useSearchTokenContext-w53PxiHs.js} +3 -3
  82. package/assets/{useSemanticSearch-CndRDdLY.js → useSemanticSearch-BK6xhcs8.js} +1 -1
  83. package/assets/{useSignature-Dh1YfrLK.js → useSignature-DW3HxNEu.js} +1 -1
  84. package/index.html +1 -1
  85. package/package.json +1 -1
  86. package/assets/BriefPane-CccvxIPm.js +0 -1
  87. package/assets/_mailboxId-0KPLzSyc.js +0 -1
  88. package/assets/_messageId-CLzaKnpD.js +0 -1
  89. package/assets/_messageId-XN2qNpQ2.js +0 -1
  90. package/assets/_messageId-b0kzFKt3.js +0 -1
  91. package/assets/_outboxMessageId-CexeuSvn.js +0 -1
  92. package/assets/_threadId-B7_He_P1.js +0 -1
  93. package/assets/_threadId-B_hTqYxv.js +0 -1
  94. package/assets/_threadId-CdaFxlag.js +0 -1
  95. package/assets/advanced-BevmkfTc.js +0 -4
  96. package/assets/brief-CpItGQkI.js +0 -1
  97. package/assets/compose._-_outboxMessageId_-B6FztRTg.js +0 -1
  98. package/assets/compose._-_outboxMessageId_-BPwbuaFL.js +0 -1
  99. package/assets/compose._-_outboxMessageId_-CAWDoa8e.js +0 -1
  100. package/assets/compose._-_outboxMessageId_-DGgNutCU.js +0 -1
  101. package/assets/flagged-DqAOo1zz.js +0 -1
  102. package/assets/index-B5M8PwWY.js +0 -1
  103. package/assets/index-B7FCRaei.js +0 -1
  104. package/assets/index-BqVgmOq9.js +0 -1
  105. package/assets/index-C9sfLIJT.js +0 -1
  106. package/assets/index-CG6B9kNs.js +0 -1
  107. package/assets/index-XN2qNpQ2.js +0 -1
  108. package/assets/index-b0kzFKt3.js +0 -1
  109. package/assets/index-cBLQ-i9P.js +0 -1
  110. package/assets/mail-Y2G6r7YB.js +0 -1
  111. package/assets/outbox-7hty8V-r.js +0 -1
  112. package/assets/search-token-index-C2zFed-7.js +0 -1
  113. package/assets/settings-kfpDZaa6.js +0 -1
  114. package/assets/useRefreshControl-0RtlFTjR.js +0 -1
@@ -1,4 +1,4 @@
1
- import{cy as V,r as g,j as a,b,I as Q,x as Y,ai as q,ak as X,al as Z,cO as J,by as ee,t as te,e as se,X as re,bO as R,v as ne,c1 as ae}from"./index-C0YbF1L6.js";import{K as k}from"./kbd-BroWJblw.js";import{B as oe,d as ie}from"./useMessageBodyContent-DUyoMT7-.js";import{i as ce}from"./search-scope-DTcpOp3S.js";const le=(e,t)=>{const r=e==="newsletter"||e==="marketing"||t;return{framed:r,isPlain:!r}},de=()=>`
1
+ import{cj as V,r as g,j as a,b,I as Q,x as Y,ai as q,ak as X,al as Z,cz as J,bx as ee,t as te,e as se,X as re,bN as R,v as ne,c0 as ae}from"./index-BWDUs3V6.js";import{K as k}from"./kbd-B38YZfep.js";import{B as oe,d as ie}from"./useMessageBodyContent-DS0NFpSx.js";import{i as ce}from"./search-scope-DTcpOp3S.js";const le=(e,t)=>{const r=e==="newsletter"||e==="marketing"||t;return{framed:r,isPlain:!r}},de=()=>`
2
2
  /* Zero the UA default body margin and clamp the document to the iframe width so
3
3
  wide author markup can't push the body (and the page) past the viewport. */
4
4
  html, body {
@@ -60,7 +60,7 @@ pre, code {
60
60
  Image blocked
61
61
  </text>
62
62
  </svg>
63
- `),je=e=>e.replace(/url\s*\([^)]*\)/gi,"none").replace(/expression\s*\([^)]*\)/gi,"").replace(/-moz-binding\s*:[^;]*/gi,""),Le=e=>e.replace(/@import[^;]*;/gi,"/* @import blocked */").replace(/url\s*\([^)]*\)/gi,"none").replace(/expression\s*\([^)]*\)/gi,"").replace(/-moz-binding\s*:[^;]*/gi,""),Re=(e={})=>{const t=V(),s={FORBID_TAGS:Te,FORBID_ATTR:Ne,ALLOW_DATA_ATTR:!1,ALLOW_UNKNOWN_PROTOCOLS:!1};return t.addHook("afterSanitizeAttributes",r=>{if(r.tagName==="IMG"){const n=r.getAttribute("src")||"";if(n.startsWith("data:"))return;if(n.startsWith("cid:")){const l=n.slice(4).replace(/^<|>$/g,""),m=e.resolveCid?.(l);m&&(r.setAttribute("src",m),r.classList.add("inline-content"));return}e.allowExternalImages||(r.setAttribute("data-blocked-src",n),r.setAttribute("src",Ce),r.setAttribute("alt","[Blocked image]"),r.classList.add("blocked-image"))}if(r.tagName==="A"){const n=r.getAttribute("href")||"";if(/^(javascript|data):/i.test(n)){r.removeAttribute("href");return}r.setAttribute("target","_blank"),r.setAttribute("rel","noopener noreferrer nofollow"),r.classList.add("external-link")}if(r.hasAttribute("style")){const n=r.getAttribute("style")||"";r.setAttribute("style",je(n))}}),t.addHook("uponSanitizeElement",(r,n)=>{if(n.tagName==="style"){const o=r.textContent||"";r.textContent=Le(o)}}),r=>{const n=he(r),o=Ee(r),l=t.sanitize(r,s);return{html:`<style>${de()}</style>${l}`,hasAuthorBackground:n,hasAuthorSpacing:o}}},_e='"Geist Variable", "Geist", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',v={light:{fg:"oklch(0.3 0.025 235)",canvas:"oklch(0.96 0.015 90)",accent:"oklch(0.55 0.14 150)"},dark:{fg:"oklch(0.88 0.02 90)",canvas:"oklch(0.22 0.025 220)",accent:"oklch(0.78 0.16 150)"}},Be={background:!1,spacing:!1},Ie="16px",Oe=()=>`html{padding:0}body{padding:${Ie};box-sizing:border-box}`,Me=()=>"html{overflow:hidden}body{overflow-x:auto}",$e=/prefers-color-scheme\s*:\s*dark|color-scheme\s*:\s*[^;}"']*\bdark\b/i,De='<meta name="viewport" content="width=device-width, initial-scale=1">',ze=e=>{const t=e?v.dark:v.light;return`
63
+ `),je=e=>e.replace(/url\s*\([^)]*\)/gi,"none").replace(/expression\s*\([^)]*\)/gi,"").replace(/-moz-binding\s*:[^;]*/gi,""),Le=e=>e.replace(/@import[^;]*;/gi,"/* @import blocked */").replace(/url\s*\([^)]*\)/gi,"none").replace(/expression\s*\([^)]*\)/gi,"").replace(/-moz-binding\s*:[^;]*/gi,""),Re=(e={})=>{const t=V(),s={FORBID_TAGS:Te,FORBID_ATTR:Ne,ALLOW_DATA_ATTR:!1,ALLOW_UNKNOWN_PROTOCOLS:!1};return t.addHook("afterSanitizeAttributes",r=>{if(r.tagName==="IMG"){const n=r.getAttribute("src")||"";if(n.startsWith("data:"))return;if(n.startsWith("cid:")){const l=n.slice(4).replace(/^<|>$/g,""),m=e.resolveCid?.(l);m&&(r.setAttribute("src",m),r.classList.add("inline-content"));return}e.allowExternalImages||(r.setAttribute("data-blocked-src",n),r.setAttribute("src",Ce),r.setAttribute("alt","[Blocked image]"),r.classList.add("blocked-image"))}if(r.tagName==="A"){const n=r.getAttribute("href")||"";if(/^(javascript|data):/i.test(n)){r.removeAttribute("href");return}r.setAttribute("target","_blank"),r.setAttribute("rel","noopener noreferrer nofollow"),r.classList.add("external-link")}if(r.hasAttribute("style")){const n=r.getAttribute("style")||"";r.setAttribute("style",je(n))}}),t.addHook("uponSanitizeElement",(r,n)=>{if(n.tagName==="style"){const o=r.textContent||"";r.textContent=Le(o)}}),r=>{const n=he(r),o=Ee(r),l=t.sanitize(r,s);return{html:`<style>${de()}</style>${l}`,hasAuthorBackground:n,hasAuthorSpacing:o}}},_e='"Geist Variable", "Geist", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',v={light:{fg:"oklch(0.3 0.025 235)",canvas:"oklch(0.96 0.015 90)",accent:"oklch(0.55 0.14 150)"},dark:{fg:"oklch(0.88 0.02 90)",canvas:"oklch(0.22 0.025 220)",accent:"oklch(0.78 0.16 150)"}},Be={background:!1,spacing:!1},Ie="16px",Me=()=>`html{padding:0}body{padding:${Ie};box-sizing:border-box}`,Oe=()=>"html{overflow:hidden}body{overflow-x:auto}",$e=/prefers-color-scheme\s*:\s*dark|color-scheme\s*:\s*[^;}"']*\bdark\b/i,De='<meta name="viewport" content="width=device-width, initial-scale=1">',ze=e=>{const t=e?v.dark:v.light;return`
64
64
  /* Plain-email base: UI font-stack + theme-aware colors (#424) */
65
65
  html, body {
66
66
  font-family: ${_e};
@@ -81,4 +81,4 @@ a, a:visited {
81
81
  color: ${t.accent} !important;
82
82
  text-decoration: underline;
83
83
  }
84
- `},S="invert(0.92) hue-rotate(180deg)",N=`img,picture,video,svg,canvas,[style*='background-image'],[background]{filter:${S}}`,Pe=(e,t,s)=>{const r=e?v.dark.canvas:v.light.canvas;return s?e?t?`html,body{margin:0;background-color:${r};color-scheme:dark light}`:`html{margin:0;background-color:#ffffff;filter:${S}}body{margin:0}${N}`:"html,body{margin:0;background-color:#ffffff;color-scheme:light}":e?t?`html,body{margin:0;background-color:${r};color-scheme:dark light}`:`html{margin:0;background-color:${r}}body{margin:0;filter:${S}}${N}`:`html,body{margin:0;background-color:${r};color-scheme:light}`},Ke=(e,t,s,r=Be)=>{const n=t==="plain"?ze(s):Pe(s,$e.test(e),r.background),o=r.spacing?"":Oe();return`${De}<style>${n}</style>${e}<style>${Me()}${o}</style>`},Fe=5e4,He="allow-same-origin allow-popups allow-popups-to-escape-sandbox",Ue=(e,t,s)=>Math.min(Math.ceil(Math.max(e,t)),s),Ge=new Set(["Enter","Escape","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End"]),We=e=>e===" "?!1:e.length===1?!0:Ge.has(e),A=e=>{if(e.metaKey||e.ctrlKey||e.altKey||!We(e.key))return;const t=e.currentTarget??e.target,s=t?.defaultView?.parent;!s||s===t?.defaultView||s.dispatchEvent(new KeyboardEvent("keydown",{key:e.key,code:e.code,shiftKey:e.shiftKey,bubbles:!0,cancelable:!0}))},C=({html:e,variant:t="framed",isDark:s=!1,declares:r,className:n})=>{const o=g.useRef(null),[l,m]=g.useState(0),d=g.useMemo(()=>Ke(e,t,s,r),[e,t,s,r]);return g.useEffect(()=>{const c=o.current;if(!c)return;const f=()=>{const i=c.contentDocument;if(!i?.body)return;const x=i.documentElement,y=Ue(i.body.scrollHeight,x?.scrollHeight??0,Fe);m(w=>w===y?w:y)};let u,h;const p=()=>{f(),u?.disconnect(),u=void 0,h?.removeEventListener("keydown",A),h?.removeEventListener("load",f,!0),h=void 0;const i=c.contentDocument;i?.body&&(u=new ResizeObserver(f),u.observe(i.body),i.documentElement&&u.observe(i.documentElement),i.addEventListener("load",f,!0),i.fonts?.ready.then(f),i.addEventListener("keydown",A),h=i)};return c.addEventListener("load",p),()=>{c.removeEventListener("load",p),h?.removeEventListener("keydown",A),h?.removeEventListener("load",f,!0),u?.disconnect()}},[]),a.jsx("iframe",{ref:o,title:"Email content",sandbox:He,srcDoc:d,className:n,style:{width:"100%",border:"none",display:"block",height:l===0?"1px":`${l}px`,colorScheme:"normal"}})},j=()=>a.jsx("p",{className:"text-fg-muted text-sm italic",children:"This message has no body content."}),vt=({className:e,children:t})=>a.jsx("div",{className:b("[&_.message-body-frame]:-mx-2 lg:[&_.message-body-frame]:-mx-4",e),children:t}),Ve=({html:e,text:t,isDark:s=!1,category:r,allowImages:n=!1,resolveCid:o,className:l,renderBlockedNotice:m})=>{const d=g.useMemo(()=>!e||typeof document>"u"?null:Re({allowExternalImages:n,resolveCid:o})(e),[e,n,o]),c=d?.html??null,{framed:f,isPlain:u}=le(r,d?.hasAuthorBackground??!1),h=g.useMemo(()=>({background:d?.hasAuthorBackground??!1,spacing:d?.hasAuthorSpacing??!1}),[d?.hasAuthorBackground,d?.hasAuthorSpacing]),p=g.useMemo(()=>!c||n?0:(c.match(/data-blocked-src/g)||[]).length,[c,n]);return!c&&!t?a.jsx("div",{className:b("message-body",l),children:a.jsx(j,{})}):a.jsxs("div",{className:b("message-body",l),children:[p>0&&a.jsx("div",{children:m?.(p)}),c?a.jsx("div",{className:"message-body-frame",children:f?a.jsx("div",{className:"w-full max-w-full",children:a.jsx(C,{html:c,variant:"framed",isDark:s,declares:h})}):a.jsx("div",{className:"max-w-full lg:max-w-2xl",children:a.jsx(C,{html:c,variant:u?"plain":"framed",isDark:s,declares:h})})}):t?a.jsx("pre",{className:"email-text whitespace-pre-wrap text-sm leading-relaxed",children:t}):a.jsx(j,{})]})};function kt({message:e="Select a thread to read",icon:t,showHints:s=!0,className:r}){return a.jsxs("div",{className:b("flex flex-1 flex-col items-center justify-center text-center",r),children:[t??a.jsx(Q,{className:"size-10 text-fg-subtle"}),a.jsx("p",{className:"mt-3 text-sm text-fg-muted",children:e}),s&&a.jsxs("p",{className:"text-2xs text-fg-subtle",children:[a.jsx(k,{children:"j"})," / ",a.jsx(k,{children:"k"})," to move, ",a.jsx(k,{children:"Enter"})," to open"]})]})}function O(e){const t=[];let s=-1,r=!1;for(let n=0;n<e.length;n++){const o=e[n];if(o==='"'){r=!r,s<0&&(s=n);continue}if(!r&&/\s/.test(o)){s>=0&&t.push({raw:e.slice(s,n),start:s,end:n}),s=-1;continue}s<0&&(s=n)}return s>=0&&t.push({raw:e.slice(s),start:s,end:e.length}),t}const Qe=e=>{if(!e.startsWith('"'))return e;const t=e.slice(1);return t.endsWith('"')?t.slice(0,-1):t};function Ye(e){const t=e.indexOf(":");if(t<=0)return;const s=e.slice(t+1);return{name:e.slice(0,t).toLowerCase(),value:Qe(s),rawValue:s}}const qe=e=>/[\s"]/.test(e),Xe=e=>qe(e)?`"${e.replace(/"/g,"")}"`:e,At=(e,t)=>`${e}:${Xe(t)}`,M=(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=M(!0,r):delete n.trusted,{...e,flags:n}},Je=(e,t,s,r)=>{const n=o=>o.map(l=>Ze(l,t,s,r));return{...e,envelope:{...e.envelope,from:n(e.envelope.from),to:n(e.envelope.to),cc:n(e.envelope.cc),bcc:n(e.envelope.bcc),replyTo:n(e.envelope.replyTo)}}},et=({messageId:e})=>{const t=Y(),{pushError:s}=q(),{mutate:r,isPending:n,error:o,reset:l}=X({...ee(),onMutate:async d=>{const c=d.path.addressId,u=d.body.flags?.trusted?.value===!0,h=J({path:{messageId:e}});await t.cancelQueries({queryKey:h});const p=t.getQueriesData({queryKey:h}).filter(i=>i[1]!==void 0).map(([i,x])=>({queryKey:i,data:x}));return t.setQueriesData({queryKey:h},i=>i&&Je(i,c,u)),{describePrefix:h,previous:p}},onError:(d,c,f)=>{if(f)for(const u of f.previous)t.setQueryData(u.queryKey,u.data);s(Z("Couldn't trust sender","The change wasn't saved.",d))},onSettled:(d,c,f,u)=>{u&&t.invalidateQueries({queryKey:u.describePrefix})}});return{toggleTrusted:(d,c)=>{r({path:{addressId:d},body:{flags:{trusted:M(!c)}}})},isPending:n,error:o,reset:l}},tt=()=>{const[e,t]=g.useState(()=>typeof document<"u"&&document.documentElement.classList.contains("dark"));return g.useEffect(()=>{const s=document.documentElement,r=new MutationObserver(()=>{t(s.classList.contains("dark"))});return r.observe(s,{attributes:!0,attributeFilter:["class"]}),()=>r.disconnect()},[]),e},st=({blockedImageCount:e,canAlwaysTrust:t,isTrustPending:s,onLoadOnce:r,onAlwaysTrust:n})=>a.jsxs("div",{className:"mb-3 flex items-center justify-between rounded-md bg-surface-sunken/50 px-3 py-2 text-sm",children:[a.jsxs("span",{className:"text-fg-muted",children:[e," image",e>1?"s":""," blocked for privacy"]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("button",{type:"button",onClick:r,className:"text-accent hover:underline",children:"Load once"}),t&&a.jsx("button",{type:"button",onClick:n,"aria-busy":s,className:"text-accent hover:underline aria-busy:opacity-50",children:s?"Trusting…":"Always trust"})]})]}),rt=(e,t)=>{switch(e){case"auth":return{title:"Your session expired",detail:"Sign in again to reload the message body. Other parts of the app may also stop responding until you do."};case"body-missing":return{title:"Message body is missing in storage",detail:"A sync failure may have left this message without its body bytes. Contact support, or run the reconcile script to refetch from the upstream IMAP server."};case"content-type-mismatch":return{title:"Couldn't load message body",detail:"The server returned an unexpected content type for this part. The message body has not been rendered to keep you safe."};case"spa-shell-leak":return{title:"Couldn't load message body",detail:"The server returned the app shell instead of the message body. This is an infrastructure bug — please report it."};case"not-ready":return{title:"Message body is still syncing",detail:"This message's body hasn't finished downloading from the mail server yet. It should appear shortly — reopen the message to try again."};default:return{title:"Couldn't load message body",detail:t}}},nt=e=>e instanceof oe?e.reason:"generic",at=e=>e instanceof Error?e.message:typeof e=="string"?e:"An unexpected error occurred while loading the message body.",ot=({error:e,onRetry:t})=>{const s=nt(e),r=at(e),{title:n,detail:o}=rt(s,r),[l,m]=g.useState(!1),{Account:d}=te();return l?null:a.jsxs("div",{role:"alert","data-testid":"message-body-error-banner","data-reason":s,className:"flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-sm",children:[a.jsx(se,{className:"size-4 shrink-0 text-danger mt-0.5","aria-hidden":"true"}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"font-medium text-danger",children:n}),a.jsx("p",{className:"text-fg-muted mt-1 break-words",children:o})]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-3",children:[s==="auth"&&a.jsx(d,{children:({signOut:c})=>a.jsx("button",{type:"button",onClick:()=>c(),className:"text-sm font-medium text-accent hover:underline",children:"Sign in again"})}),t&&a.jsx("button",{type:"button",onClick:t,className:"text-sm font-medium text-accent hover:underline",children:"Retry"}),a.jsx("button",{type:"button",onClick:()=>m(!0),"aria-label":"Dismiss message body error",className:"rounded-md p-1 text-fg-muted hover:bg-surface-raised hover:text-fg transition-colors",children:a.jsx(re,{className:"size-4","aria-hidden":"true"})})]})]})},it=()=>a.jsxs("div",{className:"animate-pulse space-y-2",role:"status","aria-label":"Loading message body",children:[a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-full"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-11/12"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-3/4"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-5/6"})]}),L=()=>a.jsx("p",{className:"text-fg-muted text-sm italic",children:"This message has no body content."}),St=({bodyParts:e,html:t,text:s,isTrusted:r=!1,messageId:n,fromAddressId:o,category:l,className:m})=>{const[d,c]=g.useState(!1),f=r||d,u=tt(),{toggleTrusted:h,isPending:p}=et({messageId:n??""}),i=!!e&&e.length>0,{picked:x,data:y,isLoading:w,isError:D,error:z,refetch:P}=ie({messageId:n,bodyParts:e,enabled:i}),K=g.useMemo(()=>ue(e??[]),[e]),F=i&&y?.kind==="html"?y.body:t,H=i&&y?.kind==="text"?y.body:s;if(i){if(w)return a.jsx("div",{className:b("message-body",m),children:a.jsx(it,{})});if(D)return a.jsx("div",{className:b("message-body",m),children:a.jsx(ot,{error:z,onRetry:()=>P()})});if(!x)return a.jsx("div",{className:b("message-body",m),children:a.jsx(L,{})})}else if(!t&&!s)return a.jsx("div",{className:b("message-body",m),children:a.jsx(L,{})});const U=!!(o&&n),G=()=>{!o||p||(c(!0),h(o,!1))};return a.jsx(Ve,{className:m,html:F,text:H,isDark:u,category:l,allowImages:f,resolveCid:K,renderBlockedNotice:W=>a.jsx(st,{blockedImageCount:W,canAlwaysTrust:U,isTrustPending:p,onLoadOnce:()=>c(!0),onAlwaysTrust:G})})},$={personal:"Personal",uncategorized:"Unclassified",transactional:"Transactional",newsletter:"Newsletter",marketing:"Marketing",social:"Social",automated:"Automated"},ct=Object.values(R).map(e=>({value:e,label:$[e]})),lt={unclassified:"uncategorized"},dt=[{name:"from",label:"Sender",values:"contact"},{name:"subject",label:"Subject",values:"text"},{name:"category",label:"Category",values:"fixed",options:ct},{name:"is",label:"State",values:"fixed",options:[{value:"unread",label:"Unread"},{value:"read",label:"Read"},{value:"starred",label:"Starred"}]},{name:"has",label:"Contents",values:"fixed",options:[{value:"attachment",label:"Has attachment"}]},{name:"in",label:"Folder",values:"mailbox"},{name:"account",label:"Account",values:"account"},{name:"after",label:"Sent on or after",values:"date"},{name:"before",label:"Sent before",values:"date"}],ut=new Map(dt.map(e=>[e.name,e])),Et=e=>ut.get(e.toLowerCase()),mt=/^\d{4}-\d{2}-\d{2}$/;function ft(e,t,s){if(!mt.test(s))return;const r=Date.parse(`${s}T00:00:00Z`);if(!Number.isNaN(r))return{type:e,raw:t,value:s,epochSeconds:Math.floor(r/1e3)}}function ht(e){const t=e.toLowerCase(),s=lt[t];return s||Object.values(R).find(n=>n===t)}function gt(e,t){switch(t.toLowerCase()){case"unread":return{type:"isUnread",raw:e};case"read":return{type:"isRead",raw:e};case"starred":case"flagged":return{type:"isStarred",raw:e};default:return}}function pt(e,t){const s=Ye(e);if(!s||s.value.length===0)return;const{name:r,value:n}=s;switch(r){case"from":return{type:"from",raw:e,value:n};case"subject":return{type:"subject",raw:e,value:n};case"category":{const o=ht(n);return o?{type:"category",raw:e,value:n,category:o}:void 0}case"is":return gt(e,n);case"has":return n.toLowerCase()==="attachment"?{type:"hasAttachment",raw:e}:void 0;case"before":case"after":return ft(r,e,n);case"in":{const o=t.mailboxesByName?.get(n.toLowerCase());return o?{type:"in",raw:e,value:n,mailboxId:o}:void 0}case"account":{const o=t.accountsByName?.get(n.toLowerCase());return o?{type:"account",raw:e,value:n,accountId:o}:void 0}default:return}}function Tt(e,t={}){const s=[],r=[];for(const n of O(e)){const o=pt(n.raw,t);o?s.push(o):r.push(n.raw)}return{freeText:r.join(" "),tokens:s}}function Nt(e,t){return O(e).filter(s=>s.raw!==t.raw).map(s=>s.raw).join(" ")}function Ct(e){switch(e.type){case"from":return`From: ${e.value}`;case"subject":return`Subject: ${e.value}`;case"category":return`Category: ${$[e.category]}`;case"hasAttachment":return"Has attachment";case"isUnread":return"Unread";case"isRead":return"Read";case"isStarred":return"Starred";case"before":return`Before ${e.value}`;case"after":return`After ${e.value}`;case"in":return`In: ${e.value}`;case"account":return`Account: ${e.value}`}}function jt(){const{mailboxNameIndex:e,accountNameIndex:t}=ne(),s=ae();return{...ce(s)?{}:{mailboxesByName:e},accountsByName:t}}export{vt as M,kt as R,dt as S,O as a,Ye as b,Ve as c,et as d,St as e,Ct as f,Et as g,Tt as p,Nt as r,At as s,jt as u};
84
+ `},S="invert(0.92) hue-rotate(180deg)",N=`img,picture,video,svg,canvas,[style*='background-image'],[background]{filter:${S}}`,Pe=(e,t,s)=>{const r=e?v.dark.canvas:v.light.canvas;return s?e?t?`html,body{margin:0;background-color:${r};color-scheme:dark light}`:`html{margin:0;background-color:#ffffff;filter:${S}}body{margin:0}${N}`:"html,body{margin:0;background-color:#ffffff;color-scheme:light}":e?t?`html,body{margin:0;background-color:${r};color-scheme:dark light}`:`html{margin:0;background-color:${r}}body{margin:0;filter:${S}}${N}`:`html,body{margin:0;background-color:${r};color-scheme:light}`},Ke=(e,t,s,r=Be)=>{const n=t==="plain"?ze(s):Pe(s,$e.test(e),r.background),o=r.spacing?"":Me();return`${De}<style>${n}</style>${e}<style>${Oe()}${o}</style>`},Fe=5e4,He="allow-same-origin allow-popups allow-popups-to-escape-sandbox",Ue=(e,t,s)=>Math.min(Math.ceil(Math.max(e,t)),s),Ge=new Set(["Enter","Escape","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End"]),We=e=>e===" "?!1:e.length===1?!0:Ge.has(e),A=e=>{if(e.metaKey||e.ctrlKey||e.altKey||!We(e.key))return;const t=e.currentTarget??e.target,s=t?.defaultView?.parent;!s||s===t?.defaultView||s.dispatchEvent(new KeyboardEvent("keydown",{key:e.key,code:e.code,shiftKey:e.shiftKey,bubbles:!0,cancelable:!0}))},C=({html:e,variant:t="framed",isDark:s=!1,declares:r,className:n})=>{const o=g.useRef(null),[l,m]=g.useState(0),d=g.useMemo(()=>Ke(e,t,s,r),[e,t,s,r]);return g.useEffect(()=>{const c=o.current;if(!c)return;const f=()=>{const i=c.contentDocument;if(!i?.body)return;const x=i.documentElement,y=Ue(i.body.scrollHeight,x?.scrollHeight??0,Fe);m(w=>w===y?w:y)};let u,h;const p=()=>{f(),u?.disconnect(),u=void 0,h?.removeEventListener("keydown",A),h?.removeEventListener("load",f,!0),h=void 0;const i=c.contentDocument;i?.body&&(u=new ResizeObserver(f),u.observe(i.body),i.documentElement&&u.observe(i.documentElement),i.addEventListener("load",f,!0),i.fonts?.ready.then(f),i.addEventListener("keydown",A),h=i)};return c.addEventListener("load",p),()=>{c.removeEventListener("load",p),h?.removeEventListener("keydown",A),h?.removeEventListener("load",f,!0),u?.disconnect()}},[]),a.jsx("iframe",{ref:o,title:"Email content",sandbox:He,srcDoc:d,className:n,style:{width:"100%",border:"none",display:"block",height:l===0?"1px":`${l}px`,colorScheme:"normal"}})},j=()=>a.jsx("p",{className:"text-fg-muted text-sm italic",children:"This message has no body content."}),vt=({className:e,children:t})=>a.jsx("div",{className:b("[&_.message-body-frame]:-mx-2 lg:[&_.message-body-frame]:-mx-4",e),children:t}),Ve=({html:e,text:t,isDark:s=!1,category:r,allowImages:n=!1,resolveCid:o,className:l,renderBlockedNotice:m})=>{const d=g.useMemo(()=>!e||typeof document>"u"?null:Re({allowExternalImages:n,resolveCid:o})(e),[e,n,o]),c=d?.html??null,{framed:f,isPlain:u}=le(r,d?.hasAuthorBackground??!1),h=g.useMemo(()=>({background:d?.hasAuthorBackground??!1,spacing:d?.hasAuthorSpacing??!1}),[d?.hasAuthorBackground,d?.hasAuthorSpacing]),p=g.useMemo(()=>!c||n?0:(c.match(/data-blocked-src/g)||[]).length,[c,n]);return!c&&!t?a.jsx("div",{className:b("message-body",l),children:a.jsx(j,{})}):a.jsxs("div",{className:b("message-body",l),children:[p>0&&a.jsx("div",{children:m?.(p)}),c?a.jsx("div",{className:"message-body-frame",children:f?a.jsx("div",{className:"w-full max-w-full",children:a.jsx(C,{html:c,variant:"framed",isDark:s,declares:h})}):a.jsx("div",{className:"max-w-full lg:max-w-2xl",children:a.jsx(C,{html:c,variant:u?"plain":"framed",isDark:s,declares:h})})}):t?a.jsx("pre",{className:"email-text whitespace-pre-wrap text-sm leading-relaxed",children:t}):a.jsx(j,{})]})};function kt({message:e="Select a thread to read",icon:t,showHints:s=!0,className:r}){return a.jsxs("div",{className:b("flex flex-1 flex-col items-center justify-center text-center",r),children:[t??a.jsx(Q,{className:"size-10 text-fg-subtle"}),a.jsx("p",{className:"mt-3 text-sm text-fg-muted",children:e}),s&&a.jsxs("p",{className:"text-2xs text-fg-subtle",children:[a.jsx(k,{children:"j"})," / ",a.jsx(k,{children:"k"})," to move, ",a.jsx(k,{children:"Enter"})," to open"]})]})}function M(e){const t=[];let s=-1,r=!1;for(let n=0;n<e.length;n++){const o=e[n];if(o==='"'){r=!r,s<0&&(s=n);continue}if(!r&&/\s/.test(o)){s>=0&&t.push({raw:e.slice(s,n),start:s,end:n}),s=-1;continue}s<0&&(s=n)}return s>=0&&t.push({raw:e.slice(s),start:s,end:e.length}),t}const Qe=e=>{if(!e.startsWith('"'))return e;const t=e.slice(1);return t.endsWith('"')?t.slice(0,-1):t};function Ye(e){const t=e.indexOf(":");if(t<=0)return;const s=e.slice(t+1);return{name:e.slice(0,t).toLowerCase(),value:Qe(s),rawValue:s}}const qe=e=>/[\s"]/.test(e),Xe=e=>qe(e)?`"${e.replace(/"/g,"")}"`:e,At=(e,t)=>`${e}:${Xe(t)}`,O=(e,t=Date.now())=>({value:e,setAt:t}),Ze=(e,t,s,r)=>{if(e.addressId!==t)return e;const n={...e.flags??{}};return s?n.trusted=O(!0,r):delete n.trusted,{...e,flags:n}},Je=(e,t,s,r)=>{const n=o=>o.map(l=>Ze(l,t,s,r));return{...e,envelope:{...e.envelope,from:n(e.envelope.from),to:n(e.envelope.to),cc:n(e.envelope.cc),bcc:n(e.envelope.bcc),replyTo:n(e.envelope.replyTo)}}},et=({messageId:e})=>{const t=Y(),{pushError:s}=q(),{mutate:r,isPending:n,error:o,reset:l}=X({...ee(),onMutate:async d=>{const c=d.path.addressId,u=d.body.flags?.trusted?.value===!0,h=J({path:{messageId:e}});await t.cancelQueries({queryKey:h});const p=t.getQueriesData({queryKey:h}).filter(i=>i[1]!==void 0).map(([i,x])=>({queryKey:i,data:x}));return t.setQueriesData({queryKey:h},i=>i&&Je(i,c,u)),{describePrefix:h,previous:p}},onError:(d,c,f)=>{if(f)for(const u of f.previous)t.setQueryData(u.queryKey,u.data);s(Z("Couldn't trust sender","The change wasn't saved.",d))},onSettled:(d,c,f,u)=>{u&&t.invalidateQueries({queryKey:u.describePrefix})}});return{toggleTrusted:(d,c)=>{r({path:{addressId:d},body:{flags:{trusted:O(!c)}}})},isPending:n,error:o,reset:l}},tt=()=>{const[e,t]=g.useState(()=>typeof document<"u"&&document.documentElement.classList.contains("dark"));return g.useEffect(()=>{const s=document.documentElement,r=new MutationObserver(()=>{t(s.classList.contains("dark"))});return r.observe(s,{attributes:!0,attributeFilter:["class"]}),()=>r.disconnect()},[]),e},st=({blockedImageCount:e,canAlwaysTrust:t,isTrustPending:s,onLoadOnce:r,onAlwaysTrust:n})=>a.jsxs("div",{className:"mb-3 flex items-center justify-between rounded-md bg-surface-sunken/50 px-3 py-2 text-sm",children:[a.jsxs("span",{className:"text-fg-muted",children:[e," image",e>1?"s":""," blocked for privacy"]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("button",{type:"button",onClick:r,className:"text-accent hover:underline",children:"Load once"}),t&&a.jsx("button",{type:"button",onClick:n,"aria-busy":s,className:"text-accent hover:underline aria-busy:opacity-50",children:s?"Trusting…":"Always trust"})]})]}),rt=(e,t)=>{switch(e){case"auth":return{title:"Your session expired",detail:"Sign in again to reload the message body. Other parts of the app may also stop responding until you do."};case"body-missing":return{title:"Message body is missing in storage",detail:"A sync failure may have left this message without its body bytes. Contact support, or run the reconcile script to refetch from the upstream IMAP server."};case"content-type-mismatch":return{title:"Couldn't load message body",detail:"The server returned an unexpected content type for this part. The message body has not been rendered to keep you safe."};case"spa-shell-leak":return{title:"Couldn't load message body",detail:"The server returned the app shell instead of the message body. This is an infrastructure bug — please report it."};case"not-ready":return{title:"Message body is still syncing",detail:"This message's body hasn't finished downloading from the mail server yet. It should appear shortly — reopen the message to try again."};default:return{title:"Couldn't load message body",detail:t}}},nt=e=>e instanceof oe?e.reason:"generic",at=e=>e instanceof Error?e.message:typeof e=="string"?e:"An unexpected error occurred while loading the message body.",ot=({error:e,onRetry:t})=>{const s=nt(e),r=at(e),{title:n,detail:o}=rt(s,r),[l,m]=g.useState(!1),{Account:d}=te();return l?null:a.jsxs("div",{role:"alert","data-testid":"message-body-error-banner","data-reason":s,className:"flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-sm",children:[a.jsx(se,{className:"size-4 shrink-0 text-danger mt-0.5","aria-hidden":"true"}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"font-medium text-danger",children:n}),a.jsx("p",{className:"text-fg-muted mt-1 break-words",children:o})]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-3",children:[s==="auth"&&a.jsx(d,{children:({signOut:c})=>a.jsx("button",{type:"button",onClick:()=>c(),className:"text-sm font-medium text-accent hover:underline",children:"Sign in again"})}),t&&a.jsx("button",{type:"button",onClick:t,className:"text-sm font-medium text-accent hover:underline",children:"Retry"}),a.jsx("button",{type:"button",onClick:()=>m(!0),"aria-label":"Dismiss message body error",className:"rounded-md p-1 text-fg-muted hover:bg-surface-raised hover:text-fg transition-colors",children:a.jsx(re,{className:"size-4","aria-hidden":"true"})})]})]})},it=()=>a.jsxs("div",{className:"animate-pulse space-y-2",role:"status","aria-label":"Loading message body",children:[a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-full"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-11/12"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-3/4"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-5/6"})]}),L=()=>a.jsx("p",{className:"text-fg-muted text-sm italic",children:"This message has no body content."}),St=({bodyParts:e,html:t,text:s,isTrusted:r=!1,messageId:n,fromAddressId:o,category:l,className:m})=>{const[d,c]=g.useState(!1),f=r||d,u=tt(),{toggleTrusted:h,isPending:p}=et({messageId:n??""}),i=!!e&&e.length>0,{picked:x,data:y,isLoading:w,isError:D,error:z,refetch:P}=ie({messageId:n,bodyParts:e,enabled:i}),K=g.useMemo(()=>ue(e??[]),[e]),F=i&&y?.kind==="html"?y.body:t,H=i&&y?.kind==="text"?y.body:s;if(i){if(w)return a.jsx("div",{className:b("message-body",m),children:a.jsx(it,{})});if(D)return a.jsx("div",{className:b("message-body",m),children:a.jsx(ot,{error:z,onRetry:()=>P()})});if(!x)return a.jsx("div",{className:b("message-body",m),children:a.jsx(L,{})})}else if(!t&&!s)return a.jsx("div",{className:b("message-body",m),children:a.jsx(L,{})});const U=!!(o&&n),G=()=>{!o||p||(c(!0),h(o,!1))};return a.jsx(Ve,{className:m,html:F,text:H,isDark:u,category:l,allowImages:f,resolveCid:K,renderBlockedNotice:W=>a.jsx(st,{blockedImageCount:W,canAlwaysTrust:U,isTrustPending:p,onLoadOnce:()=>c(!0),onAlwaysTrust:G})})},$={personal:"Personal",uncategorized:"Unclassified",transactional:"Transactional",newsletter:"Newsletter",marketing:"Marketing",social:"Social",automated:"Automated"},ct=Object.values(R).map(e=>({value:e,label:$[e]})),lt={unclassified:"uncategorized"},dt=[{name:"from",label:"Sender",values:"contact"},{name:"subject",label:"Subject",values:"text"},{name:"category",label:"Category",values:"fixed",options:ct},{name:"is",label:"State",values:"fixed",options:[{value:"unread",label:"Unread"},{value:"read",label:"Read"},{value:"starred",label:"Starred"}]},{name:"has",label:"Contents",values:"fixed",options:[{value:"attachment",label:"Has attachment"}]},{name:"in",label:"Folder",values:"mailbox"},{name:"account",label:"Account",values:"account"},{name:"after",label:"Sent on or after",values:"date"},{name:"before",label:"Sent before",values:"date"}],ut=new Map(dt.map(e=>[e.name,e])),Et=e=>ut.get(e.toLowerCase()),mt=/^\d{4}-\d{2}-\d{2}$/;function ft(e,t,s){if(!mt.test(s))return;const r=Date.parse(`${s}T00:00:00Z`);if(!Number.isNaN(r))return{type:e,raw:t,value:s,epochSeconds:Math.floor(r/1e3)}}function ht(e){const t=e.toLowerCase(),s=lt[t];return s||Object.values(R).find(n=>n===t)}function gt(e,t){switch(t.toLowerCase()){case"unread":return{type:"isUnread",raw:e};case"read":return{type:"isRead",raw:e};case"starred":case"flagged":return{type:"isStarred",raw:e};default:return}}function pt(e,t){const s=Ye(e);if(!s||s.value.length===0)return;const{name:r,value:n}=s;switch(r){case"from":return{type:"from",raw:e,value:n};case"subject":return{type:"subject",raw:e,value:n};case"category":{const o=ht(n);return o?{type:"category",raw:e,value:n,category:o}:void 0}case"is":return gt(e,n);case"has":return n.toLowerCase()==="attachment"?{type:"hasAttachment",raw:e}:void 0;case"before":case"after":return ft(r,e,n);case"in":{const o=t.mailboxesByName?.get(n.toLowerCase());return o?{type:"in",raw:e,value:n,mailboxId:o}:void 0}case"account":{const o=t.accountsByName?.get(n.toLowerCase());return o?{type:"account",raw:e,value:n,accountId:o}:void 0}default:return}}function Tt(e,t={}){const s=[],r=[];for(const n of M(e)){const o=pt(n.raw,t);o?s.push(o):r.push(n.raw)}return{freeText:r.join(" "),tokens:s}}function Nt(e,t){return M(e).filter(s=>s.raw!==t.raw).map(s=>s.raw).join(" ")}function Ct(e){switch(e.type){case"from":return`From: ${e.value}`;case"subject":return`Subject: ${e.value}`;case"category":return`Category: ${$[e.category]}`;case"hasAttachment":return"Has attachment";case"isUnread":return"Unread";case"isRead":return"Read";case"isStarred":return"Starred";case"before":return`Before ${e.value}`;case"after":return`After ${e.value}`;case"in":return`In: ${e.value}`;case"account":return`Account: ${e.value}`}}function jt(){const{mailboxNameIndex:e,accountNameIndex:t}=ne(),s=ae();return{...ce(s)?{}:{mailboxesByName:e},accountsByName:t}}export{vt as M,kt as R,dt as S,M as a,Ye as b,Ve as c,et as d,St as e,Ct as f,Et as g,Tt as p,Nt as r,At as s,jt as u};
@@ -1 +1 @@
1
- import{x as T,ai as I,ak as k,bL as C,bZ as A,r as v,j as p,b_ as h,b$ as E,c0 as D,v as j,c1 as w,D as z,c2 as O,bO as Q}from"./index-C0YbF1L6.js";import{P as R}from"./attachment-file-DdY-ZgnJ.js";import{E as _,F as P,ao as N,ap as q}from"./MailListHeader-CE3fumXQ.js";import{a as B}from"./useLabels-1rNWGQyV.js";import{n as F}from"./search-query-Cr_ZXBCp.js";import{s as U}from"./search-scope-DTcpOp3S.js";import{u as G,p as H}from"./useSearchTokenContext-9FUSRyq-.js";const ae=e=>{const t=new Set;for(const a of e)a&&t.add(a);return t.size>1?{accountId:void 0,restriction:"spansAccounts",moveDisabledHint:"Move only works within one account — clear selection or pick messages from a single account"}:{accountId:t.size===1?[...t][0]:void 0,restriction:void 0,moveDisabledHint:void 0}},$=e=>{const{mailboxId:t,messages:a}=e,c=T(),{pushError:l}=I(),{mutateAsync:i,isPending:o}=k({...A(),onError:(n,u)=>{l({title:u.body.action==="Remove"?"Couldn't remove label":"Couldn't apply label",detail:C(n),error:n})},onSettled:(n,u,d)=>{_(c,P(N(d.body.messageIds??[],a??[],t)))}});return{applyLabel:v.useCallback((n,u,d)=>{n.length!==0&&q(n,m=>i({body:{messageIds:m,labelId:u,action:d}}))},[i]),isPending:o}};function ne({accountId:e,mailboxId:t,messageIds:a}){const{labels:c}=B(e),{applyLabel:l}=$({mailboxId:t}),i=v.useMemo(()=>c.map(o=>({key:o.labelId,label:o.name,icon:p.jsx("span",{className:`size-2.5 rounded-full ${E(o.color)?h[o.color]:h.Default}`}),onSelect:()=>l(a,o.labelId,"Apply")})),[c,a,l]);return i.length===0?null:p.jsx(R,{triggerLabel:"Apply label to selected messages",triggerIcon:p.jsx(D,{className:"size-4 text-fg-subtle"}),triggerText:"Apply label",items:i,align:"start",nested:!0,touch:!1,triggerClassName:"min-h-11 w-full justify-start gap-3 px-4 py-2.5 text-sm font-normal text-fg"})}const K=20,V=new Set(Object.values(Q)),Z=e=>e!==void 0&&V.has(e)?e:void 0,J=e=>{if(e.some(t=>t.type==="isUnread"))return!1;if(e.some(t=>t.type==="isRead"))return!0};function re({mailboxId:e,filterCategory:t}={}){const{searchQuery:a}=j(),c=G(),l=w(),i=F(a),{freeText:o,tokens:r}=H(i,c),n=o.length>0,u=r.find(s=>s.type==="category"),d=Z(t)??u?.category,m=r.some(s=>s.type==="hasAttachment")?!0:void 0,b=r.some(s=>s.type==="isStarred")?!0:void 0,y=J(r),f=r.find(s=>s.type==="after"),g=r.find(s=>s.type==="before"),x=r.find(s=>s.type==="in"),S=U({browsed:l,callerMailboxId:e,inTokenMailboxId:x?.mailboxId}),{data:L,isLoading:M}=z({...O({query:{query:o,mailboxId:S,limit:K,...d!==void 0?{category:d}:{},...m!==void 0?{hasAttachment:m}:{},...b!==void 0?{hasStars:b}:{},...y!==void 0?{isRead:y}:{},...f?{sentDateFrom:f.epochSeconds}:{},...g?{sentDateTo:g.epochSeconds}:{}}}),enabled:n,staleTime:6e4});return{hits:L?.items??[],isLoading:n&&M}}export{ne as L,ae as r,re as u};
1
+ import{x as T,ai as I,ak as k,bK as C,bY as A,r as v,j as p,bZ as h,b_ as E,b$ as D,v as j,c0 as w,D as z,c1 as Q,bN as R}from"./index-BWDUs3V6.js";import{P as _}from"./attachment-file-DEH4WgYf.js";import{E as N,F as O,ao as P,ap as q}from"./MailListHeader-C9Ahbu_k.js";import{a as B}from"./useLabels-B3A1qgdI.js";import{n as F}from"./search-query-Cr_ZXBCp.js";import{s as U}from"./search-scope-DTcpOp3S.js";import{u as G,p as H}from"./useSearchTokenContext-w53PxiHs.js";const ae=e=>{const t=new Set;for(const a of e)a&&t.add(a);return t.size>1?{accountId:void 0,restriction:"spansAccounts",moveDisabledHint:"Move only works within one account — clear selection or pick messages from a single account"}:{accountId:t.size===1?[...t][0]:void 0,restriction:void 0,moveDisabledHint:void 0}},K=e=>{const{mailboxId:t,messages:a}=e,c=T(),{pushError:l}=I(),{mutateAsync:i,isPending:o}=k({...A(),onError:(n,u)=>{l({title:u.body.action==="Remove"?"Couldn't remove label":"Couldn't apply label",detail:C(n),error:n})},onSettled:(n,u,d)=>{N(c,O(P(d.body.messageIds??[],a??[],t)))}});return{applyLabel:v.useCallback((n,u,d)=>{n.length!==0&&q(n,m=>i({body:{messageIds:m,labelId:u,action:d}}))},[i]),isPending:o}};function ne({accountId:e,mailboxId:t,messageIds:a}){const{labels:c}=B(e),{applyLabel:l}=K({mailboxId:t}),i=v.useMemo(()=>c.map(o=>({key:o.labelId,label:o.name,icon:p.jsx("span",{className:`size-2.5 rounded-full ${E(o.color)?h[o.color]:h.Default}`}),onSelect:()=>l(a,o.labelId,"Apply")})),[c,a,l]);return i.length===0?null:p.jsx(_,{triggerLabel:"Apply label to selected messages",triggerIcon:p.jsx(D,{className:"size-4 text-fg-subtle"}),triggerText:"Apply label",items:i,align:"start",nested:!0,touch:!1,triggerClassName:"min-h-11 w-full justify-start gap-3 px-4 py-2.5 text-sm font-normal text-fg"})}const $=20,V=new Set(Object.values(R)),Y=e=>e!==void 0&&V.has(e)?e:void 0,Z=e=>{if(e.some(t=>t.type==="isUnread"))return!1;if(e.some(t=>t.type==="isRead"))return!0};function re({mailboxId:e,filterCategory:t}={}){const{searchQuery:a}=j(),c=G(),l=w(),i=F(a),{freeText:o,tokens:r}=H(i,c),n=o.length>0,u=r.find(s=>s.type==="category"),d=Y(t)??u?.category,m=r.some(s=>s.type==="hasAttachment")?!0:void 0,b=r.some(s=>s.type==="isStarred")?!0:void 0,y=Z(r),f=r.find(s=>s.type==="after"),g=r.find(s=>s.type==="before"),x=r.find(s=>s.type==="in"),S=U({browsed:l,callerMailboxId:e,inTokenMailboxId:x?.mailboxId}),{data:L,isLoading:M}=z({...Q({query:{query:o,mailboxId:S,limit:$,...d!==void 0?{category:d}:{},...m!==void 0?{hasAttachment:m}:{},...b!==void 0?{hasStars:b}:{},...y!==void 0?{isRead:y}:{},...f?{sentDateFrom:f.epochSeconds}:{},...g?{sentDateTo:g.epochSeconds}:{}}}),enabled:n,staleTime:6e4});return{hits:L?.items??[],isLoading:n&&M}}export{ne as L,ae as r,re as u};
@@ -1 +1 @@
1
- import{x as g,ai as p,D as f,a2 as m,r,ak as y,al as T,a6 as x,am as E}from"./index-C0YbF1L6.js";const i={html:"",plainText:""},d=e=>{const u=g(),{pushError:o}=p(),{data:n}=f({...m(),staleTime:1/0}),l=r.useMemo(()=>{if(!e||!n)return i;const t=n.accounts.find(s=>s.accountId===e);return t?{html:t.signatureHtml??"",plainText:t.signaturePlainText??""}:i},[e,n]),a=y({...E(),onSuccess:()=>{u.invalidateQueries({queryKey:x()})},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{d as u};
1
+ import{x as g,ai as p,D as f,a2 as m,r,ak as y,al as T,a6 as x,am as E}from"./index-BWDUs3V6.js";const i={html:"",plainText:""},d=e=>{const u=g(),{pushError:o}=p(),{data:n}=f({...m(),staleTime:1/0}),l=r.useMemo(()=>{if(!e||!n)return i;const t=n.accounts.find(s=>s.accountId===e);return t?{html:t.signatureHtml??"",plainText:t.signaturePlainText??""}:i},[e,n]),a=y({...E(),onSuccess:()=>{u.invalidateQueries({queryKey:x()})},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{d 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-C0YbF1L6.js"></script>
41
+ <script type="module" crossorigin src="/assets/index-BWDUs3V6.js"></script>
42
42
  <link rel="stylesheet" crossorigin href="/assets/index-OWhz0EKb.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.466",
3
+ "version": "0.0.468",
4
4
  "description": "Built Remit web client — static assets and the default runtime config.",
5
5
  "files": [
6
6
  "**/*"
@@ -1 +0,0 @@
1
- import{j as n,as as Xe,S as Ze,bT as es,v as Y,b4 as ss,bG as ts,r as a,D as ne,bU as oe,z as ns,bV as os,bW as as,bX as rs,e as Ce,bY as is,a9 as cs,bQ as ls,bR as ds}from"./index-C0YbF1L6.js";import{s as je,a as us,b as Re,u as ms,p as fs,R as hs}from"./useSearchTokenContext-9FUSRyq-.js";import{aa as be,H as ve,ab as gs,ac as xs,I as ps,ad as ye,ae as Is,af as bs,ag as vs,a9 as ys,ah as Ss,ai as Ts,aj as Cs,M as js,ak as Rs,al as ws,am as Ms,e as ks,v as Fs,an as As,q as Os,S as Ns,L as Bs,Q as Se,P as Ds,N as Ls,d as Es,_ as Ps,$ as qs,a1 as we,a2 as Me,a3 as zs,a4 as Qs,a5 as Hs}from"./MailListHeader-CE3fumXQ.js";import{u as _s,a as Ws,R as $s,i as Gs,b as Us}from"./useRefreshControl-0RtlFTjR.js";import{f as Vs,p as Ys,d as Js,R as Ks,k as Xs,l as Zs}from"./search-token-index-C2zFed-7.js";import{a as et}from"./useLabels-1rNWGQyV.js";import{u as st,r as tt,L as nt}from"./useSemanticSearch-CndRDdLY.js";import{w as ot}from"./wizard-selection-B1bng5Jq.js";import{u as ke}from"./index-Xoco-tet.js";import{a as at}from"./useMessageBodyContent-DUyoMT7-.js";function rt({sync:e}){return e?n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 py-12 text-center px-4",role:"status","aria-live":"polite",children:[n.jsx(Xe,{className:"size-8 animate-spin text-fg-subtle","aria-hidden":"true"}),n.jsx("p",{className:"text-sm font-medium text-fg",children:"Still syncing your mail"}),n.jsx("p",{className:"text-xs text-fg-subtle",children:it(e)})]}):n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 py-12 text-center px-4",children:[n.jsx(Ze,{className:"size-8 text-fg-subtle","aria-hidden":"true"}),n.jsx("p",{className:"text-sm font-medium text-fg",children:"You're caught up"}),n.jsx("p",{className:"text-xs text-fg-subtle",children:"Nothing needs attention."})]})}function it({synced:e,total:s}){return s>0?`${e.toLocaleString()} of ${s.toLocaleString()} messages downloaded. This list fills in as they arrive.`:"Downloading your messages. This list fills in as they arrive."}const Fe=[{id:"unread",name:"is",value:"unread"},{id:"attachment",name:"has",value:"attachment"}],Ae="category",ct={unclassified:"uncategorized"},W=e=>us(e).map(s=>s.raw),_=e=>e.join(" "),ae=e=>{const s=Re(e);if(s)return Fe.find(o=>o.name===s.name&&o.value===s.value.toLowerCase())?.id},re=e=>{const s=Re(e);if(!s||s.name!==Ae)return;const o=s.value.toLowerCase(),r=ct[o];if(r)return r;if(!(!es(o)||o==="all"))return o},Oe=e=>Fe.find(s=>s.id===e),Ne=e=>Oe(e)!==void 0,lt=e=>{const s=new Set;for(const o of W(e)){const r=ae(o);r&&s.add(r)}return s},dt=e=>{let s="all";for(const o of W(e)){const r=re(o);r&&(s=r)}return s},ut=(e,s)=>{const o=Oe(s);if(!o)return;const r=W(e),l=r.filter(d=>ae(d)!==s);return l.length<r.length?_(l):_([...r,je(o.name,o.value)])},mt=(e,s)=>{const o=W(e).filter(r=>!re(r));return _(s==="all"?o:[...o,je(Ae,s)])},ft=e=>_(W(e).filter(s=>!ae(s)&&!re(s))),Be=e=>e.trim().length>0,ht=e=>{if(!Be(e.query))return e.ownFilters;const s=new Set(lt(e.query));for(const o of e.ownFilters)Ne(o)||s.add(o);return s},gt=e=>Be(e.query)?dt(e.query):e.ownCategory,xt=(e,s)=>e.createdAt!==s.createdAt?e.createdAt-s.createdAt:e.accountId.localeCompare(s.accountId),pt=e=>[...e].sort(xt),It=200,Te=()=>n.jsx("div",{className:"animate-pulse",children:Array.from({length:3}).map((e,s)=>n.jsxs("div",{className:"flex items-start gap-3 py-2 pl-5 pr-4 border-b border-line",children:[n.jsx("div",{className:"size-7 rounded-full bg-surface-sunken shrink-0 mt-0.5"}),n.jsxs("div",{className:"flex-1 space-y-1.5",children:[n.jsxs("div",{className:"flex justify-between gap-2",children:[n.jsx("div",{className:"h-3.5 bg-surface-sunken rounded w-28"}),n.jsx("div",{className:"h-3 bg-surface-sunken rounded w-12"})]}),n.jsx("div",{className:"h-3.5 bg-surface-sunken rounded w-48"}),n.jsx("div",{className:"h-3 bg-surface-sunken rounded w-full"})]})]},s))}),bt=({accountEmail:e})=>{const s=ke();return n.jsxs("div",{className:"flex items-center gap-2 px-row-inset py-2 border-b border-line bg-danger-soft/40 text-xs text-danger",children:[n.jsx(Ce,{className:"size-3.5 shrink-0"}),n.jsxs("span",{className:"flex-1 truncate",children:[e," can't connect"]}),n.jsx("button",{type:"button",onClick:()=>s("accounts"),className:"shrink-0 underline text-danger hover:opacity-80",children:"Reconnect"})]})},vt=(e,s)=>{if(s.size===0)return{};const o=e.filter(d=>s.has(d.id)),r=tt(o.map(d=>d.accountId));if(r.restriction)return r;const l=new Set;for(const d of o)d.mailboxId&&l.add(d.mailboxId);return l.size>1?{accountId:r.accountId,restriction:"spansFolders",moveDisabledHint:`Move only works within one folder — this selection spans ${l.size} folders`}:{accountId:r.accountId,mailboxId:l.size===1?[...l][0]:void 0}};function yt({header:e,rows:s,wizard:o,children:r}){const{selectedIds:l,selectedCount:d,exitSelection:u,orderedIds:m,allSelected:b,toggleAllLoaded:f}=Ms(),x=a.useMemo(()=>vt(s,l),[s,l]),{junkMailboxId:D}=ks(x.accountId),{labels:I}=et(x.accountId),p=a.useMemo(()=>Array.from(l),[l]),L=a.useMemo(()=>ot(s,l),[s,l]),h=Fs(D,x.mailboxId),v=a.useMemo(()=>m.length>0?{checked:b,indeterminate:d>0&&!b,onChange:f}:void 0,[m.length,b,d,f]),F=x.moveDisabledHint?{tone:"warning",text:x.moveDisabledHint}:void 0,S=T=>n.jsx(Ns,{title:T.title,navSlot:T.navSlot,titleMeta:T.titleMeta,searchSlot:T.searchSlot,searchField:T.searchField,idleSlot:T.makeFilterSlot,count:d,onCancel:u,onDelete:()=>o.start("delete"),onMove:()=>o.start("move"),onOrganize:()=>o.start("organize"),onJunk:h?()=>o.start("junk"):void 0,onMarkRead:()=>o.start("markRead"),overflowSlot:x.accountId&&x.mailboxId&&d>0&&I.length>0?n.jsx(nt,{accountId:x.accountId,mailboxId:x.mailboxId,messageIds:p}):void 0,selectAll:v,notice:F});return n.jsx(As,{...e,selectionBar:S,paneOverlay:n.jsx(Os,{verb:o.verb,accountId:x.accountId,mailboxId:x.mailboxId,selection:L,selectionRestriction:x.restriction,onFinished:u}),children:r})}function St({accounts:e,selectedMessageId:s,onOpenThread:o,commandsRef:r,onTriageContextChange:l,onDeleteMessages:d}){const{searchQuery:u,searchInput:m,resultFolderIndex:b,onSearchChange:f}=Y(),x=ms(),D=ss(),I=Vs(),p=ts(),L=Ys(),h=a.useMemo(()=>pt(e.filter(t=>!t.muted?.value)),[e]),[v,F]=a.useState("all"),[S,T]=a.useState("all"),[$,E]=a.useState(new Set),[K,C]=a.useState(!1),P=a.useCallback(t=>{E(i=>{const c=new Set(i);return c.has(t)?c.delete(t):c.add(t),c})},[]),G=a.useCallback(()=>E(new Set),[]),R=m.trim().length>0,j=a.useMemo(()=>ht({query:m,ownFilters:$}),[m,$]),w=a.useMemo(()=>gt({query:m,ownCategory:S}),[m,S]),A=a.useCallback(t=>{if(!R||!Ne(t)){P(t);return}const i=ut(m,t);i!==void 0&&f(i)},[R,m,f,P]),q=a.useCallback(t=>{if(!R){T(t);return}f(mt(m,t))},[R,m,f]),z=a.useCallback(()=>{T("all"),F("all"),G(),R&&f(ft(m))},[R,m,f,G]),{data:O,isLoading:Q,isError:g,refetch:N}=ne({...oe(),staleTime:6e4}),B=Js({queries:h.map(t=>({...ns({path:{accountId:t.accountId}}),staleTime:1/0,meta:{softError:!0}}))}),U=a.useMemo(()=>{const t=new Map;for(let i=0;i<h.length;i++){const c=h[i].accountId,Ye=(B[i]?.data?.items??[]).reduce((Je,Ke)=>Je+(Ke.unseenCount??0),0);t.set(c,Ye)}return t},[h,B]),Ee=a.useMemo(()=>h.filter((t,i)=>{const c=B[i];return c?.isError?!os(c.error):!1}),[h,B]),{freeText:M,tokens:X}=fs(u.trim().toLowerCase(),x),{data:ie,isFetching:Pe}=ne({...oe({query:{query:M,limit:It}}),enabled:M.length>0,staleTime:3e4}),y=a.useMemo(()=>{const t=be(O?.items??[]).map(ve);return(M?gs(t.filter(c=>xs(c,M)),be(ie?.items??[]).map(ve)):t).filter(c=>(v==="all"||c.accountId===v)&&ps(c,X))},[O,ie,v,M,X]),{bodyRows:ce,briefSpamOffer:Z}=a.useMemo(()=>{if(!M)return{bodyRows:y,briefSpamOffer:void 0};const t=y.map(k=>ye(k,b)),{spam:i}=Is(t);if(i.length===0)return{bodyRows:y,briefSpamOffer:void 0};const c=new Set(i.map(k=>k.id));return{bodyRows:y.filter(k=>!c.has(k.id)),briefSpamOffer:bs(t)}},[y,M,b]),le=a.useMemo(()=>vs(ce),[ce]),de=a.useCallback((t,i)=>{const c=y.find(k=>k.id===t)?.threadId;c&&o?.({threadId:c,messageId:t},i)},[y,o]),qe=a.useCallback(t=>{const i=t.threadId??y.find(c=>c.id===t.id)?.threadId;i&&o?.({threadId:i,messageId:t.id})},[y,o]),ee=a.useMemo(()=>h.length<=1?[]:[{id:"all",label:"All",active:v==="all"},...h.map(t=>({id:t.accountId,label:t.email.split("@")[0]??t.email,count:U.get(t.accountId),active:v===t.accountId}))],[h,U,v]),H=a.useMemo(()=>e.filter(t=>t.muted?.value).length,[e]),ze=a.useMemo(()=>Array.from(U.values()).reduce((t,i)=>t+i,0),[U]),se=a.useMemo(()=>h.map(t=>t.accountId),[h]),{hasNewMail:ue}=_s(),{state:me,errorMessage:fe,refresh:he}=Ws(se,{onSettled:()=>N()}),Qe=a.useMemo(()=>n.jsx($s,{state:me,onRefresh:he,label:"Refresh daily brief",errorMessage:fe,hasUpdate:ue(se)}),[me,he,fe,ue,se]),te=a.useMemo(()=>y.filter(t=>(w==="all"||t.category===w)&&as(t,j)).map(t=>ye(t,b)),[y,w,j,b]),{hits:ge,isLoading:He}=st(),_e=a.useMemo(()=>{const t=new Map;for(const c of O?.items??[])t.set(c.messageId,c.threadId);const i=te.map(c=>t.get(c.id)).filter(c=>c!=null);return ys(ge,i,b)},[ge,te,O,b]),We=a.useMemo(()=>{const t=Ss(ee.map(i=>({id:i.id,label:i.label,count:i.count,active:i.active})));return{categories:t.categories,filters:t.filters,sources:t.sources,sourcesNote:H>0?`+${H} muted`:void 0,selectedCategory:w,activeFilters:j,expanded:K,onExpandedChange:C,onSelectCategory:i=>q(i),onSelectSource:F,onToggleFilter:i=>A(i),onClear:z}},[ee,H,w,j,K,A,q,z]),xe=le.length===0&&v==="all"&&M.length===0&&X.length===0,$e=a.useMemo(()=>h.map(t=>t.accountId),[h]),Ge=a.useMemo(()=>h.some(t=>Gs(t.syncPhase)),[h]),V=Us($e,xe||Ge),pe=n.jsxs("div",{className:"h-full overflow-y-auto",children:[n.jsx(Te,{}),n.jsx(Te,{})]}),Ie=!Q&&!g&&!xe,Ue=Ts({tier:I,hasLiveInput:R,hasCommittedQuery:u.trim().length>0,bodyRendersCommittedResults:!0}),Ve=Ie?n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[Z&&n.jsx(Cs,{count:Z.count,onScopeToSpam:()=>L(Z.mailboxId,u)}),n.jsx("div",{className:"min-h-0 flex-1",children:n.jsx(rs,{sections:le,briefCategory:w,Row:js,selectedThreadId:s,onSelectThread:de,onSelectBriefCategory:q,sources:ee,sourcesNote:H>0?`+${H} muted`:void 0,onSelectSource:F,activeFilters:j,onToggleFilter:A,onClearFilters:z})})]}):Q?pe:g?n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 py-12 text-sm text-fg-muted",children:[n.jsx(Ce,{className:"size-8 text-danger"}),n.jsx("p",{children:"Couldn't load your messages"}),n.jsxs("button",{type:"button",onClick:()=>N(),className:"flex items-center gap-1 text-accent underline text-xs",children:[n.jsx(Ks,{className:"size-3.5"}),"Try again"]})]}):V.resolved?n.jsx(rt,{sync:V.syncing?{synced:V.synced,total:V.total}:void 0}):pe;return n.jsx(is,{hasSheet:Ie&&!Ue,children:n.jsx(Rs,{selectedMessageId:s,rows:y,onOpen:de,onDeleteMessages:d,onSelectionVerb:p.start,commandsRef:r,onTriageContextChange:l,children:n.jsx(yt,{wizard:p,header:{title:"Daily brief",unreadCount:ze,footer:D?n.jsx(ws,{}):void 0,searchFilter:We,searchResults:te,searchLoading:Q||Pe,relatedResults:_e,relatedLoading:He,onSelectSearchResult:qe,searchResultsInBody:!0,refreshControl:Qe},rows:y,children:n.jsxs("div",{className:"flex h-full flex-col",children:[Ee.map(t=>n.jsx(bt,{accountEmail:t.email,accountId:t.accountId},t.accountId)),n.jsx("div",{className:"min-h-0 flex-1",children:Ve})]})})})})}const De=a.createContext(null);function J(){const e=a.useContext(De);if(!e)throw new Error("BriefPane.* must be used inside <BriefPane>");return e}function Tt({thread:e,children:s}){const o=Xs(),r=Zs(),l=ke(),{searchInput:d}=Y(),u=e?.threadId,m=e?.messageId,{data:b}=ne({...oe(),staleTime:6e4}),f=a.useMemo(()=>b?.items??[],[b]),x=a.useMemo(()=>{if(u)return f.find(g=>g.messageId===m)??f.find(g=>g.threadId===u)},[f,u,m]),D=Bs(u,m),I=x??D,p=m??I?.messageId,L=a.useMemo(()=>{if(u)return{threadId:u,mailboxId:I?.mailboxId??"",subject:I?.subject,messageId:p,authenticity:I?.authenticity}},[u,I,p]),h=a.useCallback((g,N)=>{o(g,{replace:N?.replace,query:d})},[o,d]),v=a.useCallback(g=>{p&&g.includes(p)&&r()},[p,r]),F=Se({thread:I,isOpen:!0,onAfterOptimisticRemove:v}),S=Ds(),{deleteMessages:T}=Ls({mailboxId:I?.mailboxId??"",messages:f,onAfterOptimisticRemove:v}),{toggleReadFor:$}=Es({mailboxId:I?.mailboxId??"",messages:f}),E=S.focusedMessageId,C=a.useMemo(()=>f.find(g=>g.messageId===E),[f,E])??I,P=Se({thread:C,isOpen:C?.messageId===p}),G=at(),R=cs(),j=ls(),w=a.useMemo(()=>ds(j,u,p),[j,u,p]),A=a.useMemo(()=>{if(C)return g=>j({threadId:C.threadId,messageId:C.messageId,mode:g})},[j,C]),{nextMessageId:q,previousMessageId:z}=Ps({context:S,orderedIds:S.orderedIds,selectedMessageId:p,enabled:!G&&!R,hasOpenThread:u!==void 0,onClose:r,handlers:{reply:()=>A?.("reply"),replyAll:()=>A?.("reply-all"),forward:()=>A?.("forward"),delete:()=>{S.listCommandsRef.current?.requestVerb("delete")||P.deleteThread()},toggleStar:P.toggleStar,toggleRead:()=>{S.listCommandsRef.current?.requestVerb("markRead")||C&&$([C.messageId],!C.isRead)},goFlagged:()=>l("flagged"),goSettings:()=>l("settings")}}),O=a.useCallback(g=>{if(!g)return;const N=f.find(B=>B.messageId===g);return N?{threadId:N.threadId,messageId:g}:void 0},[f]),Q={selectedMessageId:p,selectedThread:I,conversation:L,onOpenThread:h,onCloseThread:r,nextThread:O(q),previousThread:O(z),actions:F,onReply:w,triage:S,onDeleteMessages:T,handleDeselectIfRemoved:v};return n.jsx(De.Provider,{value:Q,children:s})}function Le(){const{selectedMessageId:e,onOpenThread:s,triage:o,onDeleteMessages:r}=J(),{accounts:l}=Y();return n.jsx(St,{accounts:l,selectedMessageId:e,onOpenThread:s,commandsRef:o.listCommandsRef,onTriageContextChange:o.onTriageContextChange,onDeleteMessages:r})}function Ct(){const{conversation:e,selectedThread:s,actions:o,onReply:r,handleDeselectIfRemoved:l}=J(),d=!!e,u=Qs(e?.threadId);return n.jsxs(n.Fragment,{children:[n.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[n.jsx(Hs,{hasThread:d,intelligenceOpen:u.isShowing,canToggleIntelligence:u.canToggle,onToggleIntelligence:u.toggle,onReply:r?()=>r("reply"):void 0,onReplyAll:r?()=>r("reply-all"):void 0,onForward:r?()=>r("forward"):void 0,onDelete:d?o.deleteThread:void 0,onToggleStar:d?o.toggleStar:void 0,isStarred:o.isStarred,moveContext:d&&o.accountId&&o.mailboxId?{accountId:o.accountId,currentMailboxId:o.mailboxId,onMove:o.moveThread}:void 0}),n.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e?n.jsx(we,{threadId:e.threadId,mailboxId:e.mailboxId,subject:e.subject,selectedMessageId:e.messageId,authenticity:e.authenticity,onOpenIntelligence:u.open,listOnScreen:!0}):n.jsx(hs,{})})]}),n.jsx(Me,{isOpen:u.drawerOpen,onClose:u.closeDrawer,thread:s,mailboxId:s?.mailboxId,accountId:s?.accountId,onAfterOptimisticRemove:l})]})}function jt(){const{selectedThread:e,handleDeselectIfRemoved:s}=J(),{onToggleIntelligence:o}=Y();return n.jsx(zs,{onClose:o,thread:e,mailboxId:e?.mailboxId,accountId:e?.accountId,onAfterOptimisticRemove:s})}function Rt(){const{selectedThread:e,conversation:s,onOpenThread:o,onCloseThread:r,nextThread:l,previousThread:d,handleDeselectIfRemoved:u}=J(),m=qs(s?.threadId??null);return s?n.jsxs(n.Fragment,{children:[n.jsx(we,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onBack:r,onOpenIntelligence:m.toggle,onSwipeNext:l?()=>o(l):void 0,onSwipePrevious:d?()=>o(d):void 0,mobileIntelligenceOpen:m.isOpen}),n.jsx(Me,{isOpen:m.isOpen,onClose:m.close,thread:e,mailboxId:e?.mailboxId,accountId:e?.accountId,onAfterOptimisticRemove:u})]}):n.jsx("div",{className:"h-full",children:n.jsx(Le,{})})}const Et=Object.assign(Tt,{List:Le,Reading:Ct,Intelligence:jt,Phone:Rt});export{Et as B};
@@ -1 +0,0 @@
1
- import{a8 as m,j as o,a5 as p}from"./index-C0YbF1L6.js";import{a}from"./MailShell-DM51bkst.js";import{M as r}from"./MailboxPane-CfEuGJke.js";import{g as e}from"./search-token-index-C2zFed-7.js";import{u as s}from"./search-mirror-BxxbguOQ.js";import"./FullCompose-BRl0TTg1.js";import"./ErrorState-DahaLsPP.js";import"./index-Xoco-tet.js";import"./useMessageBodyContent-DUyoMT7-.js";import"./useSignature-Dh1YfrLK.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-Nd03opjC.js";import"./confirm-dialog-BsxoJB1K.js";import"./useSearchTokenContext-9FUSRyq-.js";import"./kbd-BroWJblw.js";import"./search-scope-DTcpOp3S.js";import"./useRefreshControl-0RtlFTjR.js";import"./circle-check-big-LmiZ66Yc.js";import"./MailListHeader-CE3fumXQ.js";import"./attachment-file-DdY-ZgnJ.js";import"./mail-Dk_5qV5Y.js";import"./avatar-CgRc9nHj.js";import"./format-Q6SH-IHD.js";import"./download-D8jdmJXi.js";import"./shield-check-CcjA5zAM.js";import"./useFilters-CyHmS5pJ.js";import"./clock-C7yqRbXe.js";import"./menu-D9zjxEPa.js";import"./MailViewChrome-rCAcUprL.js";import"./NavMenuButton-D7OnVn0n.js";import"./useLabels-1rNWGQyV.js";import"./useSemanticSearch-CndRDdLY.js";import"./search-query-Cr_ZXBCp.js";import"./bottom-sheet-Buif-5NL.js";import"./circle-help-C-uModsr.js";import"./circle-check-Cj5oazRb.js";function N(){const{mailboxId:t}=m.useParams(),i=e();return s({to:"/mail/$mailboxId",params:{mailboxId:t}}),o.jsx(r,{mailboxId:t,thread:i,children:o.jsx(a,{phone:o.jsx(r.Phone,{}),list:o.jsx(r.List,{}),reading:o.jsx(p,{}),intelligence:o.jsx(r.Intelligence,{}),hasThread:!!i})})}export{N as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-C0YbF1L6.js";import{M as r}from"./MailboxPane-CfEuGJke.js";import"./useSearchTokenContext-9FUSRyq-.js";import"./kbd-BroWJblw.js";import"./useMessageBodyContent-DUyoMT7-.js";import"./search-scope-DTcpOp3S.js";import"./useRefreshControl-0RtlFTjR.js";import"./circle-check-big-LmiZ66Yc.js";import"./search-token-index-C2zFed-7.js";import"./MailListHeader-CE3fumXQ.js";import"./attachment-file-DdY-ZgnJ.js";import"./mail-Dk_5qV5Y.js";import"./avatar-CgRc9nHj.js";import"./index-Xoco-tet.js";import"./useSignature-Dh1YfrLK.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-Nd03opjC.js";import"./ErrorState-DahaLsPP.js";import"./format-Q6SH-IHD.js";import"./download-D8jdmJXi.js";import"./shield-check-CcjA5zAM.js";import"./useFilters-CyHmS5pJ.js";import"./confirm-dialog-BsxoJB1K.js";import"./clock-C7yqRbXe.js";import"./menu-D9zjxEPa.js";import"./MailViewChrome-rCAcUprL.js";import"./NavMenuButton-D7OnVn0n.js";import"./useLabels-1rNWGQyV.js";import"./useSemanticSearch-CndRDdLY.js";import"./search-query-Cr_ZXBCp.js";import"./bottom-sheet-Buif-5NL.js";import"./circle-help-C-uModsr.js";import"./circle-check-Cj5oazRb.js";function G(){return o.jsx(r.Reading,{})}export{G as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-C0YbF1L6.js";import{F as r}from"./FlaggedPane-BnLZg3bX.js";import"./useSearchTokenContext-9FUSRyq-.js";import"./kbd-BroWJblw.js";import"./useMessageBodyContent-DUyoMT7-.js";import"./search-scope-DTcpOp3S.js";import"./MailListHeader-CE3fumXQ.js";import"./search-token-index-C2zFed-7.js";import"./attachment-file-DdY-ZgnJ.js";import"./mail-Dk_5qV5Y.js";import"./avatar-CgRc9nHj.js";import"./index-Xoco-tet.js";import"./useSignature-Dh1YfrLK.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-Nd03opjC.js";import"./ErrorState-DahaLsPP.js";import"./format-Q6SH-IHD.js";import"./download-D8jdmJXi.js";import"./shield-check-CcjA5zAM.js";import"./useFilters-CyHmS5pJ.js";import"./confirm-dialog-BsxoJB1K.js";import"./clock-C7yqRbXe.js";import"./menu-D9zjxEPa.js";import"./MailViewChrome-rCAcUprL.js";import"./wizard-selection-B1bng5Jq.js";function v(){return o.jsx(r.Reading,{})}export{v as component};
@@ -1 +0,0 @@
1
- import{j as r}from"./index-C0YbF1L6.js";import{B as o}from"./BriefPane-CccvxIPm.js";import"./useSearchTokenContext-9FUSRyq-.js";import"./kbd-BroWJblw.js";import"./useMessageBodyContent-DUyoMT7-.js";import"./search-scope-DTcpOp3S.js";import"./MailListHeader-CE3fumXQ.js";import"./search-token-index-C2zFed-7.js";import"./attachment-file-DdY-ZgnJ.js";import"./mail-Dk_5qV5Y.js";import"./avatar-CgRc9nHj.js";import"./index-Xoco-tet.js";import"./useSignature-Dh1YfrLK.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-Nd03opjC.js";import"./ErrorState-DahaLsPP.js";import"./format-Q6SH-IHD.js";import"./download-D8jdmJXi.js";import"./shield-check-CcjA5zAM.js";import"./useFilters-CyHmS5pJ.js";import"./confirm-dialog-BsxoJB1K.js";import"./clock-C7yqRbXe.js";import"./menu-D9zjxEPa.js";import"./useRefreshControl-0RtlFTjR.js";import"./circle-check-big-LmiZ66Yc.js";import"./useLabels-1rNWGQyV.js";import"./useSemanticSearch-CndRDdLY.js";import"./search-query-Cr_ZXBCp.js";import"./wizard-selection-B1bng5Jq.js";function A(){return r.jsx(o.Reading,{})}export{A as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-C0YbF1L6.js";import{O as t}from"./OutboxPane-CHY4zzPd.js";import"./useSearchTokenContext-9FUSRyq-.js";import"./kbd-BroWJblw.js";import"./useMessageBodyContent-DUyoMT7-.js";import"./search-scope-DTcpOp3S.js";import"./circle-check-big-LmiZ66Yc.js";import"./clock-C7yqRbXe.js";import"./row-actions-CgwuP_XL.js";import"./rotate-ccw-BhOBHPpy.js";import"./NavMenuButton-D7OnVn0n.js";import"./menu-D9zjxEPa.js";import"./format-Q6SH-IHD.js";import"./outbox-status-BlKn6P0x.js";import"./search-query-Cr_ZXBCp.js";function P(){return o.jsx(t.Reading,{})}export{P as component};
@@ -1 +0,0 @@
1
- import{a5 as o}from"./index-C0YbF1L6.js";const n=o;export{n as component};
@@ -1 +0,0 @@
1
- import{a5 as o}from"./index-C0YbF1L6.js";const n=o;export{n as component};
@@ -1 +0,0 @@
1
- import{a5 as o}from"./index-C0YbF1L6.js";const n=o;export{n as component};
@@ -1,4 +0,0 @@
1
- import{c as b,j as e,aA as C,B as i,aL as p,aG as R,aM as V,aN as L,aF as T,ag as x,aO as z,r as h,as as y,aP as g,b as O,aQ as D,D as q,aR as U,aS as S,aT as I,aU as H,a0 as F,aV as Q,aW as Y,aX as G,a1 as W,aE as Z,aI as J}from"./index-C0YbF1L6.js";import{S as K}from"./settings-screen-oaXSGTtC.js";import{B as A}from"./bug-DJcpDTib.js";import{C as _}from"./circle-check-Cj5oazRb.js";import{f as X}from"./ErrorState-DahaLsPP.js";import{D as M}from"./download-D8jdmJXi.js";import{R as k}from"./rotate-ccw-BhOBHPpy.js";import{C as ee}from"./clock-C7yqRbXe.js";import{S as se}from"./shield-check-CcjA5zAM.js";import{b as ae}from"./help-copy-CqGXlWWr.js";import"./avatar-CgRc9nHj.js";import"./menu-D9zjxEPa.js";import"./circle-help-C-uModsr.js";import"./kbd-BroWJblw.js";const te=b("CloudOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193",key:"yfwify"}],["path",{d:"M21.532 16.5A4.5 4.5 0 0 0 17.5 10h-1.79A7.008 7.008 0 0 0 10 5.07",key:"jlfiyv"}]]);const ne=b("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);const v=b("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]),re={BodyParse:"The message is built in a way Remit could not read."};function ie(s){return re[s]}function $(s){return s.split(";")[0].trim()}const w=/^[A-Za-z0-9!#$%&'*+._-]+$/,E=/^[A-Za-z0-9!#$%&'*+._-]+\/[A-Za-z0-9!#$%&'*+._-]+$/;function j(s,a){return a.test(s)?`\`${s}\``:`\`${JSON.stringify(s).replace(/`/g,"\\u0060")}\` (malformed)`}function le(s){const a=$(s);return E.test(a)?a:JSON.stringify(a)}const N="_not read_";function ce(s){return s.length===0?["(no MIME structure was read)"]:s.map(a=>`${" ".repeat(a.depth)}- ${le(a.contentType)}`)}const oe="_No message content, addresses, subject, attachment names or parser output are included._";function P(s){return{head:[`### Message quarantined at \`${s.failureStage}\``,"",`- **Failure**: \`${s.failureCode}\``,`- **Folder role**: ${s.mailboxRole??"_none appointed_"}`,`- **Failing part**: ${s.failurePartPath==null?"_whole message_":`\`${s.failurePartPath}\``}`,`- **Attempts before quarantine**: ${s.attempts}`,`- **Worker build**: ${s.workerVersion}`,`- **Message-ID hash**: ${s.messageIdHash==null?"_none declared_":`\`${s.messageIdHash}\``}`,"","#### Message shape","",`- **Content-Type**: ${s.contentType==null?N:j($(s.contentType),E)}`,`- **Content-Transfer-Encoding**: ${s.transferEncoding==null?N:j(s.transferEncoding,w)}`,`- **Charset**: ${s.charset==null?"_not declared_":j(s.charset,w)}`,`- **Size**: ${s.sizeBytes==null?N:`${s.sizeBytes} bytes`}`,"","MIME structure:"].join(`
2
- `),structure:ce(s.structure).join(`
3
- `),disclaimer:oe}}function de(s){const{head:a,structure:t,disclaimer:r}=P(s);return[a,"","```",t,"```","",r].join(`
4
- `)}function me(s){return`Message quarantined: ${s.failureCode} at ${s.failureStage}`}function xe({entry:s,onClose:a,issueUrl:t,onCopy:r}){if(!s)return null;const n=de(s);return e.jsx(C,{open:!0,onClose:a,title:"Report this message",children:e.jsxs("div",{className:"flex max-h-[80vh] flex-col",children:[e.jsxs("header",{className:"space-y-1 border-b border-line px-4 py-3",children:[e.jsx("h3",{className:"text-sm font-semibold text-fg",children:"Report this message"}),e.jsx("p",{className:"text-xs text-fg-muted",children:"This is everything the report contains. It describes the shape of the message — never its contents, addresses, subject, attachment names, or the parser's own error text."})]}),e.jsx("pre",{className:"flex-1 overflow-auto bg-surface-sunken px-4 py-3 text-2xs leading-relaxed whitespace-pre-wrap text-fg-muted",children:n}),e.jsxs("footer",{className:"flex flex-wrap items-center justify-end gap-2 border-t border-line px-4 py-3",children:[e.jsx(i,{variant:"ghost",size:"sm",onClick:a,children:"Cancel"}),e.jsx(i,{variant:"secondary",size:"sm",icon:e.jsx(ne,{className:"size-3.5"}),onClick:()=>r(n),children:"Copy report"}),e.jsx(p,{external:!0,size:"sm",href:t,icon:e.jsx(v,{className:"size-3.5"}),children:"Open on GitHub"})]})]})})}function he(s){return new Date(s).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}function ue({entry:s,onCutBug:a}){return e.jsxs("li",{className:"flex flex-col gap-2 border-b border-line px-row-inset py-3 last:border-b-0 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("p",{className:"text-sm text-fg",children:ie(s.failureStage)}),e.jsx("p",{className:"truncate text-xs text-fg-muted",title:s.failureMessage,children:s.failureMessage}),e.jsxs("p",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-2xs text-fg-subtle",children:[s.mailboxRole&&e.jsx(R,{tone:"warning",children:V(s.mailboxRole)}),e.jsx("span",{className:"truncate",title:s.mailboxPath,children:L(s.mailboxPath)}),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{children:`uid ${s.uid}`}),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{children:he(s.quarantinedAt)}),s.attempts>1&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{children:`${s.attempts} attempts`})]})]})]}),e.jsx(i,{variant:"secondary",size:"sm",className:"shrink-0",icon:e.jsx(A,{className:"size-3.5"}),onClick:()=>a(s),children:"Cut a bug"})]})}function pe({entries:s,onCutBug:a}){return e.jsxs("section",{className:"space-y-3",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Messages set aside"}),e.jsx("p",{className:"text-xs text-fg-muted",children:"Mail Remit could not read is set aside here instead of being skipped, so nothing goes missing quietly. The rest of the folder keeps syncing. Recovering a set-aside message is a re-sync, not a per-row action."})]}),s.length===0&&e.jsxs("div",{className:"flex items-center gap-2 rounded-sm border border-line bg-surface px-row-inset py-3",children:[e.jsx(_,{className:"size-4 shrink-0 text-positive","aria-hidden":!0}),e.jsx("p",{className:"text-sm text-fg-muted",children:"Every message has been read successfully. Nothing is set aside."})]}),s.length>1&&e.jsx(T,{tone:"warning",children:e.jsxs("p",{className:"flex items-start gap-2",children:[e.jsx(x,{className:"mt-0.5 size-4 shrink-0","aria-hidden":!0}),e.jsxs("span",{children:[e.jsx("span",{className:"font-semibold",children:`${s.length} messages could not be read.`})," ","More than one means something is wrong with how Remit reads mail, not with the mail. Reporting one of these gets it fixed."]})]})}),s.length>0&&e.jsx("ul",{className:"rounded-sm border border-line bg-surface",children:s.map(t=>e.jsx(ue,{entry:t,onCutBug:a},t.quarantineId))})]})}const fe=["Remit restarts. Mail stops loading for about a minute and this page will lose its connection while that happens.","Nothing is sent, deleted or moved. Your mail stays at your provider.","If the new version does not come back up, the version you are running now is restored automatically."];function ge({open:s,currentVersion:a,release:t,appliesSchemaMigration:r=!1,onClose:n,onConfirm:c}){return s?e.jsx(C,{open:!0,onClose:n,title:`Install Remit ${t.version}`,children:e.jsxs("div",{className:"flex max-h-[80vh] flex-col",children:[e.jsxs("header",{className:"space-y-1 border-b border-line px-4 py-3",children:[e.jsxs("h3",{className:"text-sm font-semibold text-fg",children:["Install Remit ",t.version,"?"]}),e.jsxs("p",{className:"text-xs text-fg-muted",children:["You are on ",a,". ",t.version," was released"," ",z(t.releasedAt),"."]})]}),e.jsxs("div",{className:"flex-1 space-y-3 overflow-auto px-4 py-3",children:[e.jsx("p",{className:"text-sm text-fg-muted",children:t.summary}),e.jsxs("ul",{className:"space-y-2",children:[fe.map(l=>e.jsxs("li",{className:"flex gap-2 text-sm text-fg-muted",children:[e.jsx("span",{className:"mt-1.5 size-1.5 shrink-0 rounded-full bg-fg-subtle"}),e.jsx("span",{children:l})]},l)),r&&e.jsxs("li",{className:"flex gap-2 text-sm text-fg-muted",children:[e.jsx("span",{className:"mt-1.5 size-1.5 shrink-0 rounded-full bg-fg-subtle"}),e.jsx("span",{children:"This version updates the database while Remit is offline. The step forward cannot be undone by hand, but a failed start is still rolled back to the version and data you have now."})]})]}),e.jsx("p",{className:"text-xs text-fg-subtle",children:"Good moment for this: when you are not waiting on a message."})]}),e.jsxs("footer",{className:"flex flex-wrap items-center justify-end gap-2 border-t border-line px-4 py-3",children:[e.jsx(i,{variant:"ghost",size:"sm",onClick:n,children:"Not now"}),e.jsx(p,{variant:"secondary",size:"sm",external:!0,href:t.releaseNotesUrl,icon:e.jsx(v,{className:"size-3.5"}),children:"Release notes"}),e.jsx(i,{size:"sm",icon:e.jsx(M,{className:"size-3.5"}),onClick:c,children:"Install and restart"})]})]})}):null}function o({children:s,tone:a}){return e.jsx("div",{className:O("rounded-sm border bg-surface px-row-inset py-3",a==="danger"?"border-danger/50":"border-line"),children:s})}function je({state:s,onCheck:a,onInstall:t,onDismissResult:r,now:n=Date.now()}){const[c,l]=h.useState(null),m=s.status==="checking",d=s.status==="available",u=()=>{if(m){l("Already checking. The result appears here in a moment.");return}l(null),a()},f=()=>{if(!d&&s.status!=="rolledBack"&&s.status!=="abandoned"){l("There is no update to install. Check for updates first — if one is found it appears here.");return}l(null),t()},B=(()=>{switch(s.status){case"upToDate":return e.jsx(o,{children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(_,{className:"size-4 shrink-0 text-positive","aria-hidden":!0}),e.jsxs("p",{className:"text-sm text-fg",children:["Remit ",s.version," is the latest version.",e.jsxs("span",{className:"text-fg-subtle",children:[" ","Checked ",g(s.checkedAt,n),"."]})]})]}),e.jsx(i,{variant:"secondary",size:"sm",className:"shrink-0",onClick:u,children:"Check again"})]})});case"checking":return e.jsx(o,{children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(y,{className:"size-4 shrink-0 animate-spin text-fg-subtle","aria-hidden":!0}),e.jsxs("p",{className:"text-sm text-fg-muted",children:["Looking for a newer version. You are on ",s.version,"."]})]}),e.jsx(i,{variant:"secondary",size:"sm",className:"shrink-0",onClick:u,children:"Check again"})]})});case"neverChecked":return e.jsx(o,{children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[e.jsx(ee,{className:"mt-0.5 size-4 shrink-0 text-fg-subtle","aria-hidden":!0}),e.jsxs("p",{className:"text-sm text-fg-muted",children:["No update check has run yet. Remit checks for updates on its own in the background.",s.lastCheckedAt!==void 0&&e.jsxs("span",{className:"text-fg-subtle",children:[" ","Last checked"," ",g(s.lastCheckedAt,n),"."]})]})]}),e.jsx(i,{variant:"secondary",size:"sm",className:"shrink-0",onClick:u,children:"Check now"})]})});case"checkFailed":return e.jsx(o,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(te,{className:"mt-0.5 size-4 shrink-0 text-fg-subtle","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("p",{className:"text-sm text-fg",children:"Could not reach the update source."}),e.jsx("p",{className:"text-xs text-fg-muted",children:s.reason}),e.jsxs("p",{className:"text-xs text-fg-subtle",children:["You are still on ",s.version," and it keeps working.",s.lastCheckedAt!==void 0&&e.jsxs(e.Fragment,{children:[" ","Last successful check"," ",g(s.lastCheckedAt,n),"."]})]})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(i,{variant:"secondary",size:"sm",onClick:u,children:"Try again"})})]})});case"available":return e.jsx(o,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"text-sm font-semibold text-fg",children:["Remit ",s.release.version]}),e.jsx(R,{tone:"accent",children:"update available"}),e.jsxs("span",{className:"text-2xs text-fg-subtle",children:["released ",z(s.release.releasedAt)," · you are on ",s.version]})]}),e.jsx("p",{className:"text-sm text-fg-muted",children:s.release.summary}),e.jsx("p",{className:"text-xs text-fg-subtle",children:"Installing restarts Remit, so mail stops loading for about a minute. If the new version does not come back up, the one you are running now is restored on its own."}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(i,{size:"sm",icon:e.jsx(M,{className:"size-3.5"}),onClick:f,children:["Install ",s.release.version]}),e.jsx(p,{variant:"secondary",size:"sm",external:!0,href:s.release.releaseNotesUrl,icon:e.jsx(v,{className:"size-3.5"}),children:"Release notes"})]})]})});case"applying":return e.jsx(o,{children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(y,{className:"size-4 shrink-0 animate-spin text-accent-2","aria-hidden":!0}),e.jsxs("p",{className:"text-sm text-fg-muted",children:["Installing Remit ",s.target,". The restart screen has the details."]})]})});case"succeeded":return e.jsx(T,{tone:"success",onDismiss:r,children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"font-semibold",children:["Updated to Remit ",s.version,"."]}),e.jsxs("p",{children:["You were on ",s.previousVersion,"."," ",e.jsx("a",{href:s.releaseNotesUrl,target:"_blank",rel:"noopener noreferrer",className:"underline",children:"See what changed"}),"."]})]})});case"rolledBack":return e.jsx(o,{tone:"danger",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(x,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("p",{className:"text-sm font-semibold text-fg",children:["Remit ",s.attemptedVersion," did not start. Remit reports that it put ",s.version," back."]}),e.jsxs("p",{className:"text-sm text-fg-muted",children:["You are running ",s.version," again. A failed update can still have changed things on the way — the log below is the only account of what it got as far as doing."]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-fg-subtle",children:"What Remit reported as the failure"}),e.jsx("code",{className:"block rounded-xs bg-danger-soft px-2 py-1 text-2xs text-danger",children:s.reason})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-fg-subtle",children:"Read the full log before trying again:"}),e.jsx("code",{className:"block rounded-xs bg-surface-sunken px-2 py-1 text-2xs text-fg-muted",children:s.logsCommand})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(i,{variant:"secondary",size:"sm",icon:e.jsx(k,{className:"size-3.5"}),onClick:f,children:["Try ",s.attemptedVersion," again"]}),e.jsxs(i,{variant:"ghost",size:"sm",onClick:r,children:["Stay on ",s.version]})]})]})});case"unreachable":return e.jsx(o,{tone:"danger",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(x,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("p",{className:"text-sm font-semibold text-fg",children:["Installing ",s.attemptedVersion," left the server unreachable."]}),e.jsx("p",{className:"text-sm text-fg-muted",children:"Remit has answered again since, but nothing here can say what happened during the silence."})]})]}),e.jsx("code",{className:"block rounded-xs bg-surface-sunken px-2 py-1 text-2xs text-fg-muted",children:s.logsCommand}),e.jsx("div",{className:"flex justify-end",children:e.jsx(i,{variant:"ghost",size:"sm",onClick:r,children:"Dismiss"})})]})});case"rollbackFailed":return e.jsx(o,{tone:"danger",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(x,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("p",{className:"text-sm font-semibold text-fg",children:["Remit ",s.attemptedVersion," did not start, and Remit could not put ",s.previousVersion," back."]}),e.jsx("p",{className:"text-sm text-fg-muted",children:"This is the one outcome Remit cannot resolve on its own. The server is in a half-changed state and needs you at a shell. The log below is the only account of where it stopped."})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-fg-subtle",children:"What Remit reported as the failure"}),e.jsx("code",{className:"block rounded-xs bg-danger-soft px-2 py-1 text-2xs text-danger",children:s.reason})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-fg-subtle",children:"Read the full log on the server:"}),e.jsx("code",{className:"block rounded-xs bg-surface-sunken px-2 py-1 text-2xs text-fg-muted",children:s.logsCommand})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(i,{variant:"ghost",size:"sm",onClick:r,children:"Dismiss"})})]})});case"abandoned":return e.jsx(o,{tone:"danger",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(x,{className:"mt-0.5 size-4 shrink-0 text-fg-subtle","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("p",{className:"text-sm font-semibold text-fg",children:["Remit ",s.attemptedVersion," was not installed. Nothing changed."]}),e.jsxs("p",{className:"text-sm text-fg-muted",children:["The update stopped before it altered anything. You are still running ",s.version,"."]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-fg-subtle",children:"What Remit reported"}),e.jsx("code",{className:"block rounded-xs bg-surface-sunken px-2 py-1 text-2xs text-fg-muted",children:s.reason})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-fg-subtle",children:"Read the full log before trying again:"}),e.jsx("code",{className:"block rounded-xs bg-surface-sunken px-2 py-1 text-2xs text-fg-muted",children:s.logsCommand})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(i,{variant:"secondary",size:"sm",icon:e.jsx(k,{className:"size-3.5"}),onClick:f,children:["Try ",s.attemptedVersion," again"]}),e.jsxs(i,{variant:"ghost",size:"sm",onClick:r,children:["Stay on ",s.version]})]})]})});default:return s}})();return e.jsxs("section",{className:"space-y-3",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Updates"}),e.jsx("p",{className:"text-xs text-fg-muted",children:"This Remit runs on your own server, so it updates when you say so. Your mail lives at your provider and is never touched by an update."})]}),B,c&&e.jsx("p",{role:"status",className:"text-xs text-fg-muted",children:c})]})}function Ne(s){return{quarantineId:s.quarantineId,accountId:s.accountId,mailboxId:s.mailboxId,uidValidity:s.uidValidity,uid:s.uid,mailboxRole:s.mailboxRole?D[s.mailboxRole]:void 0,mailboxPath:s.mailboxPath,failureStage:s.failureStage,failureCode:s.failureCode,failureMessage:s.failureMessage,failurePartPath:s.failurePartPath,quarantinedAt:s.quarantinedAt,attempts:s.attempts,sizeBytes:s.sizeBytes,contentType:s.contentType,transferEncoding:s.transferEncoding,charset:s.charset,structure:s.structure,messageIdHash:s.messageIdHash,workerVersion:s.workerVersion}}function be(s){window.open(s,"_blank","noopener,noreferrer")}function ve(s){return S(I({quarantine:P(s),title:me(s)}))}function ye({error:s}){return e.jsxs("section",{role:"alert",className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Messages set aside"}),e.jsxs("div",{className:"space-y-2 rounded-sm border border-danger/40 bg-danger-soft px-row-inset py-3",children:[e.jsx("p",{className:"text-sm font-medium text-danger",children:"The list of set-aside messages could not be read."}),e.jsx("p",{className:"break-words text-sm text-fg-muted",children:X(s)}),e.jsx("p",{className:"text-xs text-fg-muted",children:"Mail may still have been set aside — this page cannot say either way until it can read the list. Reporting this gets it fixed."}),e.jsx(i,{variant:"secondary",size:"sm",icon:e.jsx(A,{className:"size-3.5"}),onClick:()=>be(S(I())),children:"Report this"})]})]})}function ke({entries:s,isPending:a,error:t}){const[r,n]=h.useState(null),[c,l]=h.useState(!1);if(a)return e.jsx("p",{className:"animate-pulse text-sm text-fg-subtle",children:"Checking for messages set aside…"});if(t)return e.jsx(ye,{error:t});const m=d=>{navigator.clipboard.writeText(d).then(()=>{l(!1),n(null)},()=>{l(!0),n(null)})};return e.jsxs(e.Fragment,{children:[c&&e.jsx("p",{role:"alert",className:"mb-3 text-sm text-danger",children:"The report was not copied — this browser refused clipboard access. Cut the bug again and use Open on GitHub, which needs no clipboard."}),e.jsx(pe,{entries:s,onCutBug:n}),e.jsx(xe,{entry:r,issueUrl:r?ve(r):"",onClose:()=>n(null),onCopy:m})]})}function we(){const{data:s,isPending:a,error:t}=q(U());return e.jsx(ke,{entries:(s?.entries??[]).map(Ne),isPending:a,error:t})}function Ce(){const{surface:s,release:a,currentVersion:t,appliesSchemaMigration:r,onCheck:n,install:c,onDismissResult:l}=H(),[m,d]=h.useState(!1);return s.status!=="ready"?null:e.jsxs(e.Fragment,{children:[e.jsx(je,{state:s.section,onCheck:n,onInstall:()=>d(!0),onDismissResult:l}),a&&t&&e.jsx(ge,{open:m,currentVersion:t,release:a,appliesSchemaMigration:r,onClose:()=>d(!1),onConfirm:()=>{d(!1),c(a.version)}})]})}function Re(){return F().tlsMode!=="internal"?null:e.jsxs("div",{className:"border-t border-line pt-4 mt-4",children:[e.jsx("p",{className:"text-sm font-medium text-fg mb-1",children:"TLS root certificate"}),e.jsx("p",{className:"text-sm text-fg-muted mb-2",children:"This deployment signs its own certificate. Import it into the trust store of each device you browse from, and the browser warning stops for good."}),e.jsx(p,{href:"/tls-root-ca.crt",download:!0,variant:"secondary",size:"sm",icon:e.jsx(se,{className:"size-3.5"}),children:"Download root certificate"})]})}function Te(s){try{return new Date(s).toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return s}}function ze({sha:s=Y,commitUrl:a=Q,buildTime:t=G}){return e.jsxs("p",{className:"text-xs text-fg-subtle",children:["Version"," ",a?e.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"font-mono hover:text-fg-muted hover:underline",children:s}):e.jsx("span",{className:"font-mono",children:s})," · ",e.jsxs("span",{children:["Built ",Te(t)]})]})}function He(){const s=W(),[a,t]=h.useState(!0),r=n=>{const c=J[n];c&&s({to:c})};return e.jsxs(K,{items:Z,activeId:"advanced",title:"Advanced",description:"Notification rules, export, and diagnostics.",help:ae,helpOpen:a,onToggleHelp:()=>t(n=>!n),onSelect:r,onBackToMail:()=>{s({to:"/mail"})},children:[e.jsx(Ce,{}),e.jsx(we,{}),e.jsx("div",{className:"mt-6 border-t border-line pt-4",children:e.jsx("p",{className:"text-sm text-fg-muted",children:"Notification rules and data export are coming in a future release."})}),e.jsx(Re,{}),e.jsxs("div",{className:"border-t border-line pt-4 mt-4",children:[e.jsx("p",{className:"text-sm font-medium text-fg mb-1",children:"About"}),e.jsx(ze,{})]})]})}export{He as component};
@@ -1 +0,0 @@
1
- import{j as r,a5 as i}from"./index-C0YbF1L6.js";import{a as m}from"./MailShell-DM51bkst.js";import{B as o}from"./BriefPane-CccvxIPm.js";import{g as p}from"./search-token-index-C2zFed-7.js";import{u as e}from"./search-mirror-BxxbguOQ.js";import"./FullCompose-BRl0TTg1.js";import"./ErrorState-DahaLsPP.js";import"./index-Xoco-tet.js";import"./useMessageBodyContent-DUyoMT7-.js";import"./useSignature-Dh1YfrLK.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-Nd03opjC.js";import"./confirm-dialog-BsxoJB1K.js";import"./useSearchTokenContext-9FUSRyq-.js";import"./kbd-BroWJblw.js";import"./search-scope-DTcpOp3S.js";import"./MailListHeader-CE3fumXQ.js";import"./attachment-file-DdY-ZgnJ.js";import"./mail-Dk_5qV5Y.js";import"./avatar-CgRc9nHj.js";import"./format-Q6SH-IHD.js";import"./download-D8jdmJXi.js";import"./shield-check-CcjA5zAM.js";import"./useFilters-CyHmS5pJ.js";import"./clock-C7yqRbXe.js";import"./menu-D9zjxEPa.js";import"./useRefreshControl-0RtlFTjR.js";import"./circle-check-big-LmiZ66Yc.js";import"./useLabels-1rNWGQyV.js";import"./useSemanticSearch-CndRDdLY.js";import"./search-query-Cr_ZXBCp.js";import"./wizard-selection-B1bng5Jq.js";function F(){const t=p();return e({to:"/mail/brief"}),r.jsx(o,{thread:t,children:r.jsx(m,{phone:r.jsx(o.Phone,{}),list:r.jsx(o.List,{}),reading:r.jsx(i,{}),intelligence:r.jsx(o.Intelligence,{}),hasThread:!!t})})}export{F as component};
@@ -1 +0,0 @@
1
- import{F as o}from"./FullCompose-BRl0TTg1.js";import"./index-C0YbF1L6.js";import"./ErrorState-DahaLsPP.js";import"./index-Xoco-tet.js";import"./useMessageBodyContent-DUyoMT7-.js";import"./useSignature-Dh1YfrLK.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-Nd03opjC.js";import"./confirm-dialog-BsxoJB1K.js";const a=o;export{a as component};
@@ -1 +0,0 @@
1
- import{F as o}from"./FullCompose-BRl0TTg1.js";import"./index-C0YbF1L6.js";import"./ErrorState-DahaLsPP.js";import"./index-Xoco-tet.js";import"./useMessageBodyContent-DUyoMT7-.js";import"./useSignature-Dh1YfrLK.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-Nd03opjC.js";import"./confirm-dialog-BsxoJB1K.js";const a=o;export{a as component};
@@ -1 +0,0 @@
1
- import{F as o}from"./FullCompose-BRl0TTg1.js";import"./index-C0YbF1L6.js";import"./ErrorState-DahaLsPP.js";import"./index-Xoco-tet.js";import"./useMessageBodyContent-DUyoMT7-.js";import"./useSignature-Dh1YfrLK.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-Nd03opjC.js";import"./confirm-dialog-BsxoJB1K.js";const a=o;export{a as component};
@@ -1 +0,0 @@
1
- import{F as o}from"./FullCompose-BRl0TTg1.js";import"./index-C0YbF1L6.js";import"./ErrorState-DahaLsPP.js";import"./index-Xoco-tet.js";import"./useMessageBodyContent-DUyoMT7-.js";import"./useSignature-Dh1YfrLK.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-Nd03opjC.js";import"./confirm-dialog-BsxoJB1K.js";const a=o;export{a as component};
@@ -1 +0,0 @@
1
- import{j as o,a5 as i}from"./index-C0YbF1L6.js";import{a as m}from"./MailShell-DM51bkst.js";import{F as r}from"./FlaggedPane-BnLZg3bX.js";import{g as p}from"./search-token-index-C2zFed-7.js";import{u as e}from"./search-mirror-BxxbguOQ.js";import"./FullCompose-BRl0TTg1.js";import"./ErrorState-DahaLsPP.js";import"./index-Xoco-tet.js";import"./useMessageBodyContent-DUyoMT7-.js";import"./useSignature-Dh1YfrLK.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-Nd03opjC.js";import"./confirm-dialog-BsxoJB1K.js";import"./useSearchTokenContext-9FUSRyq-.js";import"./kbd-BroWJblw.js";import"./search-scope-DTcpOp3S.js";import"./MailListHeader-CE3fumXQ.js";import"./attachment-file-DdY-ZgnJ.js";import"./mail-Dk_5qV5Y.js";import"./avatar-CgRc9nHj.js";import"./format-Q6SH-IHD.js";import"./download-D8jdmJXi.js";import"./shield-check-CcjA5zAM.js";import"./useFilters-CyHmS5pJ.js";import"./clock-C7yqRbXe.js";import"./menu-D9zjxEPa.js";import"./MailViewChrome-rCAcUprL.js";import"./wizard-selection-B1bng5Jq.js";function w(){const t=p();return e({to:"/mail/flagged"}),o.jsx(r,{thread:t,children:o.jsx(m,{phone:o.jsx(r.Phone,{}),list:o.jsx(r.List,{}),reading:o.jsx(i,{}),intelligence:o.jsx(r.Intelligence,{}),hasThread:!!t})})}export{w as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-C0YbF1L6.js";import{M as i}from"./MailboxPane-CfEuGJke.js";import"./useSearchTokenContext-9FUSRyq-.js";import"./kbd-BroWJblw.js";import"./useMessageBodyContent-DUyoMT7-.js";import"./search-scope-DTcpOp3S.js";import"./useRefreshControl-0RtlFTjR.js";import"./circle-check-big-LmiZ66Yc.js";import"./search-token-index-C2zFed-7.js";import"./MailListHeader-CE3fumXQ.js";import"./attachment-file-DdY-ZgnJ.js";import"./mail-Dk_5qV5Y.js";import"./avatar-CgRc9nHj.js";import"./index-Xoco-tet.js";import"./useSignature-Dh1YfrLK.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-Nd03opjC.js";import"./ErrorState-DahaLsPP.js";import"./format-Q6SH-IHD.js";import"./download-D8jdmJXi.js";import"./shield-check-CcjA5zAM.js";import"./useFilters-CyHmS5pJ.js";import"./confirm-dialog-BsxoJB1K.js";import"./clock-C7yqRbXe.js";import"./menu-D9zjxEPa.js";import"./MailViewChrome-rCAcUprL.js";import"./NavMenuButton-D7OnVn0n.js";import"./useLabels-1rNWGQyV.js";import"./useSemanticSearch-CndRDdLY.js";import"./search-query-Cr_ZXBCp.js";import"./bottom-sheet-Buif-5NL.js";import"./circle-help-C-uModsr.js";import"./circle-check-Cj5oazRb.js";function G(){return o.jsx(i.Reading,{})}export{G as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-C0YbF1L6.js";import{F as r}from"./FlaggedPane-BnLZg3bX.js";import"./useSearchTokenContext-9FUSRyq-.js";import"./kbd-BroWJblw.js";import"./useMessageBodyContent-DUyoMT7-.js";import"./search-scope-DTcpOp3S.js";import"./MailListHeader-CE3fumXQ.js";import"./search-token-index-C2zFed-7.js";import"./attachment-file-DdY-ZgnJ.js";import"./mail-Dk_5qV5Y.js";import"./avatar-CgRc9nHj.js";import"./index-Xoco-tet.js";import"./useSignature-Dh1YfrLK.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-Nd03opjC.js";import"./ErrorState-DahaLsPP.js";import"./format-Q6SH-IHD.js";import"./download-D8jdmJXi.js";import"./shield-check-CcjA5zAM.js";import"./useFilters-CyHmS5pJ.js";import"./confirm-dialog-BsxoJB1K.js";import"./clock-C7yqRbXe.js";import"./menu-D9zjxEPa.js";import"./MailViewChrome-rCAcUprL.js";import"./wizard-selection-B1bng5Jq.js";function w(){return o.jsx(r.Reading,{})}export{w as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-C0YbF1L6.js";import{O as t}from"./OutboxPane-CHY4zzPd.js";import"./useSearchTokenContext-9FUSRyq-.js";import"./kbd-BroWJblw.js";import"./useMessageBodyContent-DUyoMT7-.js";import"./search-scope-DTcpOp3S.js";import"./circle-check-big-LmiZ66Yc.js";import"./clock-C7yqRbXe.js";import"./row-actions-CgwuP_XL.js";import"./rotate-ccw-BhOBHPpy.js";import"./NavMenuButton-D7OnVn0n.js";import"./menu-D9zjxEPa.js";import"./format-Q6SH-IHD.js";import"./outbox-status-BlKn6P0x.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 o}from"./index-C0YbF1L6.js";import{M as r}from"./MailboxPane-CfEuGJke.js";import"./useSearchTokenContext-9FUSRyq-.js";import"./kbd-BroWJblw.js";import"./useMessageBodyContent-DUyoMT7-.js";import"./search-scope-DTcpOp3S.js";import"./useRefreshControl-0RtlFTjR.js";import"./circle-check-big-LmiZ66Yc.js";import"./search-token-index-C2zFed-7.js";import"./MailListHeader-CE3fumXQ.js";import"./attachment-file-DdY-ZgnJ.js";import"./mail-Dk_5qV5Y.js";import"./avatar-CgRc9nHj.js";import"./index-Xoco-tet.js";import"./useSignature-Dh1YfrLK.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-Nd03opjC.js";import"./ErrorState-DahaLsPP.js";import"./format-Q6SH-IHD.js";import"./download-D8jdmJXi.js";import"./shield-check-CcjA5zAM.js";import"./useFilters-CyHmS5pJ.js";import"./confirm-dialog-BsxoJB1K.js";import"./clock-C7yqRbXe.js";import"./menu-D9zjxEPa.js";import"./MailViewChrome-rCAcUprL.js";import"./NavMenuButton-D7OnVn0n.js";import"./useLabels-1rNWGQyV.js";import"./useSemanticSearch-CndRDdLY.js";import"./search-query-Cr_ZXBCp.js";import"./bottom-sheet-Buif-5NL.js";import"./circle-help-C-uModsr.js";import"./circle-check-Cj5oazRb.js";function F(){return o.jsx(r.Reading,{})}export{F as component};
@@ -1 +0,0 @@
1
- import{j as r}from"./index-C0YbF1L6.js";import{B as o}from"./BriefPane-CccvxIPm.js";import"./useSearchTokenContext-9FUSRyq-.js";import"./kbd-BroWJblw.js";import"./useMessageBodyContent-DUyoMT7-.js";import"./search-scope-DTcpOp3S.js";import"./MailListHeader-CE3fumXQ.js";import"./search-token-index-C2zFed-7.js";import"./attachment-file-DdY-ZgnJ.js";import"./mail-Dk_5qV5Y.js";import"./avatar-CgRc9nHj.js";import"./index-Xoco-tet.js";import"./useSignature-Dh1YfrLK.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-Nd03opjC.js";import"./ErrorState-DahaLsPP.js";import"./format-Q6SH-IHD.js";import"./download-D8jdmJXi.js";import"./shield-check-CcjA5zAM.js";import"./useFilters-CyHmS5pJ.js";import"./confirm-dialog-BsxoJB1K.js";import"./clock-C7yqRbXe.js";import"./menu-D9zjxEPa.js";import"./useRefreshControl-0RtlFTjR.js";import"./circle-check-big-LmiZ66Yc.js";import"./useLabels-1rNWGQyV.js";import"./useSemanticSearch-CndRDdLY.js";import"./search-query-Cr_ZXBCp.js";import"./wizard-selection-B1bng5Jq.js";function C(){return r.jsx(o.Reading,{})}export{C as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-C0YbF1L6.js";import{F as r}from"./FlaggedPane-BnLZg3bX.js";import"./useSearchTokenContext-9FUSRyq-.js";import"./kbd-BroWJblw.js";import"./useMessageBodyContent-DUyoMT7-.js";import"./search-scope-DTcpOp3S.js";import"./MailListHeader-CE3fumXQ.js";import"./search-token-index-C2zFed-7.js";import"./attachment-file-DdY-ZgnJ.js";import"./mail-Dk_5qV5Y.js";import"./avatar-CgRc9nHj.js";import"./index-Xoco-tet.js";import"./useSignature-Dh1YfrLK.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-Nd03opjC.js";import"./ErrorState-DahaLsPP.js";import"./format-Q6SH-IHD.js";import"./download-D8jdmJXi.js";import"./shield-check-CcjA5zAM.js";import"./useFilters-CyHmS5pJ.js";import"./confirm-dialog-BsxoJB1K.js";import"./clock-C7yqRbXe.js";import"./menu-D9zjxEPa.js";import"./MailViewChrome-rCAcUprL.js";import"./wizard-selection-B1bng5Jq.js";function v(){return o.jsx(r.Reading,{})}export{v as component};
@@ -1 +0,0 @@
1
- import{j as r}from"./index-C0YbF1L6.js";import{B as o}from"./BriefPane-CccvxIPm.js";import"./useSearchTokenContext-9FUSRyq-.js";import"./kbd-BroWJblw.js";import"./useMessageBodyContent-DUyoMT7-.js";import"./search-scope-DTcpOp3S.js";import"./MailListHeader-CE3fumXQ.js";import"./search-token-index-C2zFed-7.js";import"./attachment-file-DdY-ZgnJ.js";import"./mail-Dk_5qV5Y.js";import"./avatar-CgRc9nHj.js";import"./index-Xoco-tet.js";import"./useSignature-Dh1YfrLK.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-Nd03opjC.js";import"./ErrorState-DahaLsPP.js";import"./format-Q6SH-IHD.js";import"./download-D8jdmJXi.js";import"./shield-check-CcjA5zAM.js";import"./useFilters-CyHmS5pJ.js";import"./confirm-dialog-BsxoJB1K.js";import"./clock-C7yqRbXe.js";import"./menu-D9zjxEPa.js";import"./useRefreshControl-0RtlFTjR.js";import"./circle-check-big-LmiZ66Yc.js";import"./useLabels-1rNWGQyV.js";import"./useSemanticSearch-CndRDdLY.js";import"./search-query-Cr_ZXBCp.js";import"./wizard-selection-B1bng5Jq.js";function A(){return r.jsx(o.Reading,{})}export{A as component};
@@ -1 +0,0 @@
1
- import{j as t,ac as o}from"./index-C0YbF1L6.js";const n=()=>t.jsx(o,{to:"/settings/accounts"});export{n as component};
@@ -1 +0,0 @@
1
- import{c as A,r as u,u as Ee,j as e,S as Pe,a as pe,b as k,C as ee,d as te,e as Ae,f as ge,F as Le,g as ze,X as be,T as Te,O as Fe,M as De,A as _e,h as Be,I as Ke,i as ve,B as F,k as Qe,l as Ve,m as z,n as qe,o as U,p as se,q as He,s as $e,t as Ue,v as ye,w as je,x as Se,y as Ge,z as J,D as Ne,E as Ye,G as Je,H as G,J as We,N as E,K as Xe,L as Ze,P as et,Q as tt,R as st,U as at,V as nt,W as rt,Y as ot,Z as it,_ as lt,$ as ct,a0 as ut,a1 as dt,a2 as mt,a3 as xt,a4 as ht,a5 as ft}from"./index-C0YbF1L6.js";import{B as pt,S as gt,D as bt,a as vt,b as yt,u as jt,s as St,c as Nt,d as W,K as Ct,e as kt,f as Ce,g as It,h as wt,i as Mt,j as Ot}from"./search-token-index-C2zFed-7.js";import{u as X,a as Rt}from"./useMessageBodyContent-DUyoMT7-.js";import{P as Et}from"./pencil-lIIqlS7F.js";import{c as Pt,s as At,M as Lt}from"./MailShell-DM51bkst.js";import{u as zt,a as Tt,R as Ft,M as Dt}from"./useRefreshControl-0RtlFTjR.js";import{M as _t}from"./menu-D9zjxEPa.js";import{B as ke}from"./bug-DJcpDTib.js";import{A as Bt}from"./avatar-CgRc9nHj.js";import{u as Kt,a as Qt}from"./index-Xoco-tet.js";import{i as Vt}from"./outbox-status-BlKn6P0x.js";import{E as qt}from"./ErrorState-DahaLsPP.js";import{K as ae}from"./kbd-BroWJblw.js";import{u as Ht}from"./useDebouncedValue-Nd03opjC.js";import"./search-scope-DTcpOp3S.js";import"./FullCompose-BRl0TTg1.js";import"./confirm-dialog-BsxoJB1K.js";import"./circle-check-big-LmiZ66Yc.js";import"./useSignature-Dh1YfrLK.js";import"./account-form-helpers-DhckT_PN.js";const $t=A("BookmarkPlus",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}],["line",{x1:"12",x2:"12",y1:"7",y2:"13",key:"1cppfj"}],["line",{x1:"15",x2:"9",y1:"10",y2:"10",key:"1gty7f"}]]);const Ut=A("CalendarDays",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 18h.01",key:"lrp35t"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M16 18h.01",key:"kzsmim"}]]);const Ie=A("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);const we=A("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const Gt=A("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]),Yt="button:not([disabled]), a[href]",R="outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-surface-sunken";function Jt({active:t,dimmed:s,indent:a}){return k("flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-sm transition-colors",R,a&&"pl-7",t?"bg-accent-2-soft font-medium text-accent-2":"text-fg-muted hover:bg-surface hover:text-fg",s&&"opacity-55")}function Wt({icon:t,label:s,count:a,active:n}){return e.jsxs(e.Fragment,{children:[t&&e.jsx("span",{className:k("shrink-0",n?"text-accent-2":"text-fg-subtle"),children:t}),e.jsx("span",{className:"flex-1 truncate",children:s}),a!=null&&a>0&&e.jsx("span",{className:k("text-2xs tabular-nums",n?"text-accent-2":"text-fg-subtle"),children:a})]})}function P({icon:t,label:s,count:a,active:n,dimmed:r,indent:o,navId:l,linkComponent:c,ariaLabel:h,title:d,onClick:g}){const x=Jt({active:n,dimmed:r,indent:o}),p=e.jsx(Wt,{icon:t,label:s,count:a,active:n});return l&&c?c({navId:l,className:x,ariaLabel:h??s,title:d,onClick:g,children:p}):e.jsx("button",{type:"button",onClick:g,className:x,"aria-label":h,title:d,children:p})}const ne={inbox:0,flagged:1,drafts:2,sent:3,archive:4,all:5,junk:6,trash:7};function Xt(t){switch(t){case"inbox":return e.jsx(Ke,{className:"size-4"});case"flagged":return e.jsx(pe,{className:"size-4"});case"drafts":return e.jsx(Be,{className:"size-4"});case"sent":return e.jsx(ge,{className:"size-4"});case"archive":return e.jsx(_e,{className:"size-4"});case"all":return e.jsx(De,{className:"size-4"});case"junk":return e.jsx(Fe,{className:"size-4"});case"trash":return e.jsx(Te,{className:"size-4"})}}const re=t=>t.role!=null,$=8,oe="remit.nav.folders.open.",ie="remit.nav.account.open.";function le(t,s,a){if(typeof localStorage>"u")return a;const n=localStorage.getItem(t+s);return n===null?a:n!=="0"}function ce(t,s,a){typeof localStorage>"u"||localStorage.setItem(t+s,a?"1":"0")}function Zt({query:t,onSelect:s,onRemove:a}){return e.jsxs("div",{className:"group flex w-full items-center gap-1 rounded-md pr-1 hover:bg-surface",children:[e.jsxs("button",{type:"button",onClick:s,className:k("flex min-w-0 flex-1 items-center gap-2 px-2 py-1 text-left text-sm text-fg-muted transition-colors hover:text-fg",R),children:[e.jsx(ze,{className:"size-4 shrink-0 text-fg-subtle"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:t})]}),a&&e.jsx("button",{type:"button",onClick:a,"aria-label":`Remove saved search: ${t}`,className:k("shrink-0 rounded-full p-1 text-fg-subtle opacity-0 transition-opacity hover:bg-surface-sunken hover:text-fg group-hover:opacity-100 focus-visible:opacity-100",R),children:e.jsx(be,{className:"size-3.5"})})]})}function es({savedSearches:t,saveableQuery:s,onSelectSavedSearch:a,onRemoveSavedSearch:n,onSaveCurrentSearch:r}){return t.length===0&&!s?null:e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:"px-2 pb-1 text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Saved searches"}),s&&e.jsxs("button",{type:"button",onClick:r,className:k("flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-sm text-accent transition-colors hover:bg-surface",R),children:[e.jsx($t,{className:"size-4 shrink-0"}),e.jsxs("span",{className:"min-w-0 flex-1 truncate",children:["Save “",s,"”"]})]}),t.map(o=>e.jsx(Zt,{query:o,onSelect:()=>a?.(o),onRemove:n?()=>n(o):void 0},o))]})}function ts({account:t,selectedNavId:s,onSelectNav:a,linkComponent:n}){const[r,o]=u.useState(()=>le(ie,t.id,!0)),[l,c]=u.useState(()=>le(oe,t.id,!0)),[h,d]=u.useState(!1),g=()=>{o(i=>{const S=!i;return ce(ie,t.id,S),S})},x=()=>{c(i=>{const S=!i;return ce(oe,t.id,S),S})},p=t.mailboxes.filter(re).sort((i,S)=>ne[i.role]-ne[S.role]),m=t.mailboxes.filter(i=>!re(i)),b=h||m.length<=$?m:m.slice(0,$),j=m.length-b.length,y=t.status??"ready",N=y==="ready"&&p.length===0&&m.length===0;return e.jsxs("div",{className:"mt-3",children:[e.jsxs("button",{type:"button",onClick:g,"aria-expanded":r,className:k("flex w-full items-center gap-1.5 px-2 pb-1 text-left transition-colors hover:text-fg",R,t.muted&&"opacity-55"),children:[r?e.jsx(ee,{className:"size-3 shrink-0 text-fg-subtle"}):e.jsx(te,{className:"size-3 shrink-0 text-fg-subtle"}),e.jsx("span",{className:"truncate text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:t.label}),t.muted&&e.jsxs(e.Fragment,{children:[e.jsx(pt,{className:"size-3 shrink-0 text-fg-subtle"}),e.jsx("span",{className:"text-2xs text-fg-subtle",children:"muted"})]})]}),r&&e.jsxs(e.Fragment,{children:[y==="loading"&&e.jsx("div",{className:"px-2 py-1 text-sm text-fg-muted",children:"Loading…"}),y==="error"&&e.jsxs("div",{role:"alert",className:"mx-2 my-1 flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-2 py-1.5 text-sm",children:[e.jsx(Ae,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":"true"}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("p",{className:"font-medium text-danger",children:"Couldn't load mailboxes"})}),t.onRetry&&e.jsx("button",{type:"button",onClick:t.onRetry,className:"shrink-0 text-sm font-medium text-accent hover:underline",children:"Retry"})]}),N&&e.jsx("div",{className:"px-2 py-1 text-sm text-fg-muted",children:"No mailboxes"}),y==="ready"&&e.jsxs(e.Fragment,{children:[p.map(i=>e.jsx(P,{navId:i.id,linkComponent:n,icon:Xt(i.role),label:i.name,ariaLabel:i.name,title:i.fullPath??i.name,count:i.unseen,active:s===i.id,dimmed:t.muted,onClick:()=>a?.(i.id)},i.id)),t.outboxPending!==void 0&&e.jsx(P,{navId:"outbox",linkComponent:n,icon:e.jsx(ge,{className:"size-4"}),label:"Outbox",ariaLabel:"Outbox",count:t.outboxPending>0?t.outboxPending:void 0,active:s==="outbox",dimmed:t.muted,onClick:()=>a?.("outbox")}),m.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:x,"aria-expanded":l,className:k("mt-1 flex w-full items-center gap-1 px-2 py-1 text-left text-2xs font-semibold uppercase tracking-wider text-fg-subtle transition-colors hover:text-fg",R),children:[l?e.jsx(ee,{className:"size-3 shrink-0"}):e.jsx(te,{className:"size-3 shrink-0"}),e.jsx("span",{className:"flex-1",children:"Folders"}),e.jsx("span",{className:"tabular-nums opacity-70",children:m.length})]}),l&&e.jsxs(e.Fragment,{children:[b.map(i=>e.jsx(P,{navId:i.id,linkComponent:n,icon:e.jsx(Le,{className:"size-4"}),label:i.name,ariaLabel:i.name,title:i.fullPath??i.name,count:i.unseen,active:s===i.id,dimmed:t.muted,onClick:()=>a?.(i.id)},i.id)),(j>0||h)&&m.length>$&&e.jsx("button",{type:"button",onClick:()=>d(i=>!i),className:k("ml-7 flex items-center px-2 py-1 text-2xs font-medium text-accent transition-colors hover:underline",R),children:h?"Show less":`Show all (${m.length})`})]})]})]})]})]})}function ss({accounts:t,selectedNavId:s,briefUnseen:a,onSelectNav:n,variant:r="desktop",linkComponent:o,calendarNav:l="hidden",savedSearches:c=[],saveableQuery:h,onSelectSavedSearch:d,onRemoveSavedSearch:g,onSaveCurrentSearch:x}){const p=u.useRef(null);Ee({containerRef:p,itemSelector:Yt});const m=r==="drawer",b=e.jsxs("nav",{ref:m?p:void 0,className:m?"px-2 py-2":"flex-1 overflow-y-auto px-2 py-2","aria-label":"Mailboxes",children:[e.jsx(P,{navId:"brief",linkComponent:o,icon:e.jsx(Pe,{className:"size-4"}),label:"Daily brief",ariaLabel:"Daily brief",count:a,active:s==="brief",onClick:()=>n?.("brief")}),l==="shown"&&e.jsx(P,{navId:"calendar",linkComponent:o,icon:e.jsx(Ut,{className:"size-4"}),label:"Calendar",ariaLabel:"Calendar",active:s==="calendar",onClick:()=>n?.("calendar")}),e.jsx(P,{navId:"flagged",linkComponent:o,icon:e.jsx(pe,{className:"size-4"}),label:"Starred",ariaLabel:"Starred",active:s==="flagged",onClick:()=>n?.("flagged")}),e.jsx(es,{savedSearches:c,saveableQuery:h,onSelectSavedSearch:d,onRemoveSavedSearch:g,onSaveCurrentSearch:x}),t.length===0?e.jsx("div",{className:"px-2 py-4 text-center text-sm text-fg-muted",children:"No accounts configured"}):t.map(j=>e.jsx(ts,{account:j,selectedNavId:s,onSelectNav:n,linkComponent:o},j.id))]});return m?b:e.jsx("aside",{ref:p,className:"flex h-full w-full flex-col bg-surface-sunken",children:b})}function as({leading:t,search:s,actions:a,className:n}){return e.jsxs("header",{className:k("flex min-h-pane-header w-full shrink-0 items-center gap-2 border-b border-line bg-canvas px-row-inset py-1",n),children:[t&&e.jsx("div",{className:"flex shrink-0 items-center gap-1",children:t}),e.jsx("div",{className:"flex min-w-0 flex-1 justify-start",children:e.jsx("div",{className:"w-full max-w-xs transition-[max-width] duration-150 ease-out focus-within:max-w-lg",children:s})}),a&&e.jsx("div",{className:"flex shrink-0 items-center gap-1",children:a})]})}function ns(){const t=ve();if(!t)return null;const s=t.showNavPane?!t.navCollapsed:!1;return e.jsx(F,{variant:"ghost",size:"sm",icon:e.jsx(_t,{className:"size-4"}),onClick:t.toggleNav,"aria-label":s?"Hide folders":"Show folders","aria-expanded":s,title:"Folders",className:"shrink-0"})}const rs={global:"Search all mail",pending:"Search mail",scoped:"Search this folder"};function os({search:t,onCompose:s,onReportBug:a,onOpenSettings:n,composeShortcut:r,refreshControl:o,account:l}){return e.jsx(as,{leading:e.jsx(ns,{}),search:e.jsx(gt,{value:t.value,onChange:t.onChange,onClear:t.onClear,onClearQuery:t.onClearQuery,chips:t.chips,onRemoveChip:t.onRemoveChip,placeholder:rs[t.scope]}),actions:e.jsxs(e.Fragment,{children:[e.jsx(F,{variant:"ghost",size:"sm",icon:e.jsx(Gt,{className:"size-4"}),title:r?`Compose (${r})`:"Compose","aria-label":"Compose",onClick:s}),e.jsx(F,{variant:"ghost",size:"sm",icon:e.jsx(ke,{className:"size-4"}),title:"Report a bug","aria-label":"Report a bug",onClick:a}),e.jsx(F,{variant:"ghost",size:"sm",icon:e.jsx(we,{className:"size-4"}),title:"Settings","aria-label":"Settings",onClick:n}),o,l]})})}function is(){const{pathname:t}=Qe(),s=Ve({from:"/mail/$mailboxId",shouldThrow:!1});return z(t,"/settings")?"settings":z(t,"/mail/outbox")?"outbox":z(t,"/mail/flagged")?"flagged":z(t,"/mail/brief")?"brief":s?.mailboxId??""}function ls(){const t=qe(),s=U({select:d=>se(d.location.pathname)}),a=U({select:d=>He(d.location.search)}),[n,r]=u.useState(a),o=Ht(n,200),[l,c]=u.useState(s);if(l!==s){const d=At(l,s,a);c(s),d!==void 0&&r(d)}const h=u.useCallback(d=>{c(se(t.state.location.pathname)),r(d)},[t]);return{searchInput:n,committedQuery:Pt(n,o),viewKey:s,setSearchInput:h}}const cs=()=>{const t=X();return $e()?null:e.jsx("button",{type:"button",onClick:t,"aria-label":"Compose new message",className:"lg:hidden fixed right-4 z-30 h-14 w-14 rounded-full bg-accent text-accent-fg shadow-lg flex items-center justify-center hover:opacity-90 active:scale-95 transition-all",style:{bottom:"calc(env(safe-area-inset-bottom, 0) + 1rem)"},children:e.jsx(Et,{className:"size-6"})})},Me=({children:t})=>{const{Account:s}=Ue();return e.jsx(s,{children:t})},us=({email:t,onSignOut:s})=>{const a=t??"Account";return e.jsxs(bt,{trigger:e.jsx(Bt,{name:a,email:t??void 0,size:"sm"}),align:"right",children:[t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 py-2 text-xs text-fg-muted truncate",title:t,"data-testid":"account-menu-email",children:t}),e.jsx(vt,{})]}),e.jsxs(yt,{onClick:s,children:[e.jsx(Ie,{className:"size-4"}),"Sign out"]})]})},ds=()=>e.jsx(Me,{children:({email:t,signOut:s})=>e.jsx(us,{email:t,onSignOut:s})});function ms({accounts:t}){const{searchInput:s,onSearchChange:a,onSearchClear:n,onSearchClearQuery:r}=ye(),o=Kt(),l=X(),{scope:c,clearScope:h}=jt(t),d=c.kind==="scoped"?[{id:c.chip.id,label:c.chip.label,tone:"scope"}]:void 0,g=u.useMemo(()=>t.map(j=>j.accountId),[t]),{hasNewMail:x}=zt(),{state:p,errorMessage:m,refresh:b}=Tt(g);return e.jsx(os,{search:{value:s,scope:c.kind,chips:d,onChange:a,onClear:n,onClearQuery:r,onRemoveChip:h},onCompose:l,onReportBug:je,onOpenSettings:()=>o("accounts"),composeShortcut:St("compose"),refreshControl:e.jsx(Ft,{state:p,onRefresh:b,label:"Refresh all accounts",errorMessage:m,hasUpdate:x(g)}),account:e.jsx(ds,{})})}const Z="remit.savedSearches",xs=25;function _(){try{const t=localStorage.getItem(Z);if(!t)return[];const s=JSON.parse(t);return Array.isArray(s)?s.filter(a=>typeof a=="string"):[]}catch{return[]}}function hs(t){const s=t.trim();if(!s)return _();const a=[s,..._().filter(n=>n!==s)].slice(0,xs);try{localStorage.setItem(Z,JSON.stringify(a))}catch{return a}return a}function fs(t){const s=_().filter(a=>a!==t);try{localStorage.setItem(Z,JSON.stringify(s))}catch{return s}return s}const ue=t=>/^\d/.test(t),ps=(t,s)=>{const a=ue(t),n=ue(s);return a&&!n?-1:!a&&n?1:t.localeCompare(s,void 0,{sensitivity:"base",numeric:!0})};function gs(t,s,a){const n=[],r=[];for(const o of t)s.has(o.mailboxId)?n.push(o):r.push(o);return r.sort((o,l)=>ps(G(o,void 0,a),G(l,void 0,a))),{system:n,labels:r}}function bs(t,s,a){const n=We(s)&&t.unseenCount>0;return{id:t.mailboxId,name:G(t,s,a),unseen:n?t.unseenCount:void 0,role:s,fullPath:t.fullPath}}function de({accounts:t,onMailboxSelect:s,variant:a="desktop"}){const n=Se(),r=Nt(),o=is(),{searchInput:l,onSearchChange:c}=ye(),[h,d]=u.useState(_),{t:g}=Ge("mail",{useSuspense:!1}),x=u.useCallback((f,C)=>g(f,{defaultValue:C}),[g]),p=W({queries:t.map(f=>({...J({path:{accountId:f.accountId}}),staleTime:1/0}))}),{data:m}=Ne(Ye()),b=u.useMemo(()=>(m?.items??[]).filter(f=>Vt(f.status)).length,[m?.items]),j=u.useMemo(()=>t.map((f,C)=>{const v=p[C],w=v?.data?.items??[],I=Je(f.folderAppointments),{system:M,labels:V}=gs(w,I,x),q=v?.isError?"error":v?.isLoading?"loading":"ready";return{id:f.accountId,label:f.email,email:f.email,muted:!!f.muted,outboxPending:b,status:q,onRetry:()=>v?.refetch(),mailboxes:[...M,...V].map(L=>bs(L,I.get(L.mailboxId),x))}}),[t,p,b,x]),y=f=>{n.invalidateQueries({queryKey:Xe({path:{mailboxId:f},query:{order:"desc"}})})},N=({navId:f,className:C,ariaLabel:v,title:w,children:I,onClick:M})=>f==="brief"?e.jsx(E,{to:"/mail/brief",search:{q:void 0},activeOptions:{includeSearch:!1},onClick:()=>M?.(),className:C,"aria-label":v,title:w,children:I}):f==="outbox"?e.jsx(E,{to:"/mail/outbox",search:{q:void 0},onClick:()=>M?.(),className:C,"aria-label":v,title:w,children:I}):f==="flagged"?e.jsx(E,{to:"/mail/flagged",search:{q:void 0},onClick:()=>M?.(),className:C,"aria-label":v,title:w,children:I}):f==="settings"?e.jsx(E,{to:"/settings/accounts",onClick:()=>M?.(),className:C,"aria-label":v,title:w,children:I}):e.jsx(E,{to:"/mail/$mailboxId",params:{mailboxId:f},search:{q:void 0},onClick:()=>{y(f),M?.()},className:C,"aria-label":v,title:w,children:I}),i=()=>{c(""),s?.()},S=l.trim(),O=S.length>0&&!h.includes(S)?S:void 0,B=u.useCallback(()=>{O&&d(hs(O))},[O]),K=u.useCallback(f=>{d(fs(f))},[]),Q=u.useCallback(f=>{c(f),r(f),s?.()},[c,r,s]);return e.jsx(ss,{accounts:j,selectedNavId:o,onSelectNav:i,linkComponent:N,variant:a,savedSearches:h,saveableQuery:O,onSaveCurrentSearch:B,onSelectSavedSearch:Q,onRemoveSavedSearch:K})}function vs(){return e.jsxs("button",{type:"button",onClick:je,className:"flex w-full items-center gap-2 rounded-md px-2 py-1 text-sm text-fg-muted transition-colors hover:bg-surface hover:text-fg",children:[e.jsx(ke,{className:"size-4 shrink-0"}),e.jsx("span",{className:"flex-1 truncate text-left",children:"Report a bug"})]})}function ys({accounts:t,onMailboxSelect:s}){return ve()?.showNavPane??!0?e.jsx(de,{accounts:t}):e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsx(de,{accounts:t,onMailboxSelect:s,variant:"drawer"})}),e.jsxs("div",{className:"border-t border-line px-2 py-2",children:[e.jsxs(E,{to:"/settings/accounts",onClick:s,children:[e.jsx(we,{className:"size-4 shrink-0"}),e.jsx("span",{className:"flex-1 truncate text-left",children:"Settings"})]}),e.jsx(vs,{}),e.jsx(Me,{children:({signOut:r})=>e.jsxs("button",{type:"button",onClick:()=>{s?.(),r()},className:"flex min-h-11 w-full items-center gap-2 rounded-md px-2 py-1 text-sm text-fg-muted transition-colors hover:bg-surface hover:text-fg","data-testid":"sign-out-button",children:[e.jsx(Ie,{className:"size-4 shrink-0"}),e.jsx("span",{className:"flex-1 truncate text-left",children:"Sign out"})]})})]})]})}const js=({isOpen:t,onClose:s})=>(Ze({id:"shortcuts",open:t,answers:{back:s}}),t?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx(et,{label:"Dismiss keyboard shortcuts",onDismiss:s,className:"backdrop-blur-sm"}),e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Keyboard shortcuts",className:k("relative z-10 max-h-[85vh] w-full max-w-2xl overflow-y-auto","rounded-lg border border-line bg-surface shadow-lg","p-6"),children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Keyboard shortcuts"}),e.jsx("button",{type:"button",onClick:s,className:"p-1 text-fg-muted transition-colors hover:text-fg","aria-label":"Close",children:e.jsx(be,{className:"size-5"})})]}),e.jsx("div",{className:"grid gap-x-8 gap-y-6 sm:grid-cols-2",children:Ct.map(a=>e.jsxs("div",{children:[e.jsx("h3",{className:"mb-3 text-sm font-medium text-fg-muted",children:a.title}),e.jsx("div",{className:"space-y-2",children:a.hints.map(n=>e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{className:"text-sm",children:n.description}),e.jsx("span",{className:"flex shrink-0 items-center gap-1",children:n.keys.map((r,o)=>e.jsxs(u.Fragment,{children:[o>0&&n.keys[0]==="g"&&e.jsx("span",{className:"text-2xs text-fg-subtle",children:"then"}),e.jsx(ae,{children:r})]},r))})]},`${n.action}-${n.keys.join("+")}`))})]},a.title))}),e.jsx("div",{className:"mt-6 border-t border-line pt-4",children:e.jsxs("p",{className:"text-center text-xs text-fg-muted",children:["Press ",e.jsx(ae,{children:"Esc"})," to close"]})})]})]}):null);function Ss(t){const s=W({queries:t.map(a=>({...J({path:{accountId:a.accountId}}),staleTime:1/0}))});return u.useMemo(()=>kt(s.map(a=>a.data?.items??[])),[s])}const Oe="remit:intelligence-open";function Ns(){try{return localStorage.getItem(Oe)!=="closed"}catch{return!0}}function Cs(t){try{localStorage.setItem(Oe,t?"open":"closed")}catch{}}function me({panels:t,prefersOpen:s,isDesktop:a,hasThread:n,raisedFor:r,openMessage:o}){return r!==null&&r===o?!0:t.length>0?t.includes("intelligence"):a&&n&&s}const ks=()=>{const t=Ce(),s=tt(),a=st(),n=s.find(at),r=It(),[o,l]=u.useState(Ns),c=r?`${r.threadId}/${r.messageId??""}`:null,[h,d]=u.useState(null),g={panels:s,prefersOpen:o,isDesktop:t==="desktop",hasThread:r!==void 0,openMessage:c},x=me({...g,raisedFor:h}),p=me({...g,raisedFor:null}),m=u.useCallback((N,i)=>{a([...N?["intelligence"]:[],...i?[i]:[]])},[a]),b=u.useCallback(N=>{m(p,N)},[p,m]),j=u.useCallback(()=>{if(x&&!p){d(null);return}const N=!x;Cs(N),l(N),d(null),m(N,n)},[p,x,n,m]),y=u.useCallback(()=>{d(c)},[c]);return{openOverlay:n,intelligenceOpen:x,showOverlay:b,toggleIntelligence:j,raiseIntelligence:y}},Is=t=>t.map(s=>s.data?.items??[]);function ws(t){const s=W({queries:t.map(a=>({...J({path:{accountId:a.accountId}}),staleTime:1/0})),combine:Is});return u.useMemo(()=>nt(t.map((a,n)=>({folderAppointments:a.folderAppointments,mailboxes:s[n]??[]}))),[t,s])}var T={exports:{}},xe;function Ms(){if(xe)return T.exports;xe=1;const t=(s,a,n)=>new Promise((r,o)=>{if(n=Object.assign({concurrency:1/0},n),typeof a!="function")throw new TypeError("Mapper function is required");const{concurrency:l}=n;if(!(typeof l=="number"&&l>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${l}\` (${typeof l})`);const c=[],h=s[Symbol.iterator]();let d=!1,g=!1,x=0,p=0;const m=()=>{if(d)return;const b=h.next(),j=p;if(p++,b.done){g=!0,x===0&&r(c);return}x++,Promise.resolve(b.value).then(y=>a(y,j)).then(y=>{c[j]=y,x--,m()},y=>{d=!0,o(y)})};for(let b=0;b<l&&(m(),!g);b++);});return T.exports=t,T.exports.default=t,T.exports}var Os=Ms();const Rs=rt(Os),Es=900*1e3,Ps=300,As=(t,s)=>{if(!t)return s;const a=Number.parseInt(t,10);return Number.isFinite(a)&&a>0?a:s},Ls=60*1e3,zs=t=>Math.max(As(t,Ps)*1e3,Ls),D=zs(ut().mailboxPollIntervalSeconds),Ts=5,Y=new Set,Fs=(t,s,a=Es)=>t.filter(n=>{const r=n.lastSyncAt;return r==null?!0:s-r>a}).map(n=>n.accountId),Ds=(t,s,a=D)=>t-s>=a,_s=(t,s)=>t.filter(a=>!s.has(a)),he=(t,s)=>{if(Y.delete(t),lt(s,{softError:!0},"nobody")){ct(s);return}console.warn("[remit] background mailbox sync failed",{accountId:t,error:s})},fe=(t,s)=>ot({path:{accountId:t},throwOnError:!0}).then(()=>{s.invalidateQueries({queryKey:it({path:{accountId:t}})})}),Bs=t=>{const s=Se(),a=u.useRef(t);a.current=t;const n=t.map(r=>r.accountId).join(",");u.useEffect(()=>{const r=Date.now(),l=Fs(a.current,r).filter(c=>!Y.has(c));if(l.length!==0)for(const c of l)Y.add(c),fe(c,s).catch(h=>{he(c,h)})},[n,s]),u.useEffect(()=>{let r=Date.now(),o;const l=new Set,c=()=>{r=Date.now();const g=_s(a.current.map(x=>x.accountId),l);for(const x of g)l.add(x);Rs(g,x=>fe(x,s).catch(p=>{he(x,p)}).finally(()=>{l.delete(x)}),{concurrency:Ts})},h=()=>{if(document.visibilityState==="visible"){c(),o=setTimeout(h,D);return}},d=()=>{document.visibilityState==="visible"&&Ds(Date.now(),r)&&(o!==void 0&&clearTimeout(o),c(),o=setTimeout(h,D))};return o=setTimeout(h,D),document.addEventListener("visibilitychange",d),()=>{o!==void 0&&clearTimeout(o),document.removeEventListener("visibilitychange",d)}},[n,s])};function ia(){const t=dt(),s=Ce(),a=Ot(s),{openOverlay:n,intelligenceOpen:r,showOverlay:o,toggleIntelligence:l,raiseIntelligence:c}=ks(),h=n==="shortcuts",d=n==="nav",{searchInput:g,committedQuery:x,viewKey:p,setSearchInput:m}=ls(),{data:b,isLoading:j,isError:y,error:N,refetch:i}=Ne({...mt(),staleTime:1/0}),S=!!(b&&(b.accounts?.length??0)===0);u.useEffect(()=>{S&&t({to:"/onboarding",replace:!0})},[S,t]),Qt({enabled:!h,bindings:[{key:"?",action:"help",handler:()=>o("shortcuts"),noModifiers:!1,preventDefault:!0}]});const O=X(),B=Rt(),K=U({select:H=>xt(H.matches)?.list==="mailbox"}),Q=u.useMemo(()=>({compose:O}),[O]);wt({enabled:!K&&!B,handlers:Q});const f=u.useCallback(()=>{m("")},[m]),C=u.useCallback(()=>{m("")},[m]),v=b?.accounts??[],w=u.useMemo(()=>v.map(H=>H.accountId),[v]),I=Ss(v),M=ws(v),V=u.useMemo(()=>Mt(v),[v]);Bs(v);const q=u.useCallback(()=>{n==="nav"&&o(void 0)},[n,o]),L={accounts:v,mailboxNameIndex:I,accountNameIndex:V,resultFolderIndex:M,searchQuery:x,searchInput:g,searchViewKey:p,onSearchChange:m,onSearchClear:f,onSearchClearQuery:C,intelligenceOpen:r,onToggleIntelligence:l,onRaiseIntelligence:c},Re={isSinglePane:a,isLoading:j||S,intelligenceOpen:r,nav:e.jsx(ys,{accounts:v,onMailboxSelect:q}),topBar:a?void 0:e.jsx(ms,{accounts:v}),overlay:a?e.jsx(cs,{}):void 0,navOpen:d,onOpenNav:()=>o("nav"),onCloseNav:()=>o(void 0)};return e.jsx(ht.Provider,{value:L,children:e.jsxs(Dt,{accountIds:w,children:[y?e.jsx("div",{className:"flex h-full items-center justify-center bg-canvas p-4",children:e.jsx(qt,{title:"Couldn't load your account",error:N,onRetry:()=>{i()}})}):e.jsx(Lt,{chrome:Re,children:e.jsx(ft,{})}),e.jsx(js,{isOpen:h,onClose:()=>o(void 0)})]})})}export{ia as component,ye as useMailContext};
@@ -1 +0,0 @@
1
- import{j as o,a5 as i}from"./index-C0YbF1L6.js";import{a as m}from"./MailShell-DM51bkst.js";import{u as p,O as t}from"./OutboxPane-CHY4zzPd.js";import{u as s}from"./search-mirror-BxxbguOQ.js";import"./FullCompose-BRl0TTg1.js";import"./ErrorState-DahaLsPP.js";import"./index-Xoco-tet.js";import"./useMessageBodyContent-DUyoMT7-.js";import"./useSignature-Dh1YfrLK.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-Nd03opjC.js";import"./confirm-dialog-BsxoJB1K.js";import"./useSearchTokenContext-9FUSRyq-.js";import"./kbd-BroWJblw.js";import"./search-scope-DTcpOp3S.js";import"./circle-check-big-LmiZ66Yc.js";import"./clock-C7yqRbXe.js";import"./row-actions-CgwuP_XL.js";import"./rotate-ccw-BhOBHPpy.js";import"./NavMenuButton-D7OnVn0n.js";import"./menu-D9zjxEPa.js";import"./format-Q6SH-IHD.js";import"./outbox-status-BlKn6P0x.js";import"./search-query-Cr_ZXBCp.js";function q(){const r=p();return s({to:"/mail/outbox"}),o.jsx(t,{outboxMessageId:r,children:o.jsx(m,{phone:o.jsx(t.Phone,{}),list:o.jsx(t.List,{}),reading:o.jsx(i,{})})})}export{q as component};
@@ -1 +0,0 @@
1
- import{c as B,r as l,j as g,g as X,b as v,c8 as Y,X as J,c9 as H,ca as Z,cb as ee,cc as te,cd as se,ce as ne,cf as P,cg as re,ch as oe,ci as U,x as ie,cj as ae,ck as ce,cl as ue,cm as le,cn as de,co as fe,cp as Q,cq as he,cr as pe,l as C,a1 as D,cs as me,c1 as S,ct as ge,L as ye,y as be,z as q,G as xe,H as ke,v as we,bA as F,bB as Ce,cu as A}from"./index-C0YbF1L6.js";import{a as ve,S as Ie}from"./search-scope-DTcpOp3S.js";const $e=B("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 Be=B("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"}]]),Se=[{action:"focusNext",keys:["j","k"],label:"navigate"},{action:"muteSender",keys:["m"],label:"mute"},{action:"help",keys:["?"],label:"all shortcuts"}];function He(e){return Se.filter(t=>e[t.action]!==void 0)}const Ee=[{title:"Navigation",hints:[{action:"focusNext",keys:["j"],description:"Focus the message below"},{action:"focusPrevious",keys:["k"],description:"Focus the message above"},{action:"focusNext",keys:["↓"],description:"Focus the message below"},{action:"focusPrevious",keys:["↑"],description:"Focus the message above"},{action:"focusFirst",keys:["Home"],description:"Focus first"},{action:"focusLast",keys:["End"],description:"Focus last"},{action:"openFocused",keys:["Enter"],description:"Open focused thread"},{action:"back",keys:["Esc"],description:"Back / close overlay"}]},{title:"Selection",hints:[{action:"toggleSelect",keys:["x"],description:"Toggle select"},{action:"toggleSelect",keys:["Space"],description:"Toggle select"},{action:"extendSelectDown",keys:["Shift","j"],description:"Extend selection down"},{action:"extendSelectUp",keys:["Shift","k"],description:"Extend selection up"},{action:"extendSelectDown",keys:["Shift","↓"],description:"Extend selection down"},{action:"extendSelectUp",keys:["Shift","↑"],description:"Extend selection up"},{action:"selectAll",keys:["⌘","A"],description:"Select all"}]},{title:"Actions",hints:[{action:"reply",keys:["r"],description:"Reply"},{action:"replyAll",keys:["a"],description:"Reply all"},{action:"forward",keys:["f"],description:"Forward"},{action:"delete",keys:["#"],description:"Delete"},{action:"toggleStar",keys:["s"],description:"Star / unstar"},{action:"toggleRead",keys:["u"],description:"Toggle read / unread"}]},{title:"Sender",hints:[{action:"muteSender",keys:["m"],description:"Mute sender"},{action:"blockSender",keys:["b"],description:"Block sender"},{action:"vipSender",keys:["v"],description:"VIP sender"},{action:"markJunk",keys:["!"],description:"Mark junk"}]},{title:"Go to",hints:[{action:"goBrief",keys:["g","b"],description:"Daily brief"},{action:"goInbox",keys:["g","i"],description:"Inbox"},{action:"goSent",keys:["g","s"],description:"Sent"},{action:"goFlagged",keys:["g","f"],description:"Starred"},{action:"goSettings",keys:["g",","],description:"Settings"}]},{title:"View & global",hints:[{action:"toggleIntelligence",keys:["i"],description:"Toggle intelligence"},{action:"toggleDensity",keys:["d"],description:"Toggle density"},{action:"focusSearch",keys:["/"],description:"Focus search"},{action:"compose",keys:["c"],description:"Compose"},{action:"compose",keys:["⌘","N"],description:"Compose"},{action:"help",keys:["?"],description:"Shortcut help"}]}];function Re(e){for(const t of Ee){const s=t.hints.find(n=>n.action===e);if(s)return s.keys}}function Te(e){const t=Re(e);return!t||t.length===0?"":t.length===1?t[0]??"":t[0]==="g"?t.join(" then "):t.join("")}function Ue(e){const t=Te(e);return t===""?"":`(${t})`}function Me({key:e,shiftKey:t=!1,repeat:s=!1,caretAtStart:n,hasValue:o,chipCount:r}){const i=r-1;return e==="Escape"?o?{type:"clearQuery"}:{type:"blur"}:e==="Tab"&&t?r===0?{type:"none"}:{type:"focusChip",index:i}:e==="Backspace"||e==="ArrowLeft"?!n||r===0?{type:"none"}:s?{type:"none"}:{type:"focusChip",index:i}:{type:"none"}}function Oe({key:e,repeat:t=!1,index:s,chipCount:n}){return e==="Backspace"||e==="Delete"?t?{type:"none"}:{type:"removeChip",index:s}:e==="ArrowLeft"?s===0?{type:"none"}:{type:"focusChip",index:s-1}:e==="ArrowRight"?s>=n-1?{type:"focusInput"}:{type:"focusChip",index:s+1}:e==="Enter"||e===" "?{type:"activateChip",index:s}:e==="Escape"?{type:"focusInput"}:{type:"none"}}function Le(e,t){const s=t-1;return s<=0?null:e<s?e:s-1}const Ne=e=>e instanceof HTMLElement?e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.isContentEditable:!1,Pe=({chips:e=[],onRemoveChip:t,value:s,onChange:n,onClear:o,onClearQuery:r,placeholder:i="Search mail...",globalFocusKey:c=!0,showClearButton:h=!0,size:p="sm",inputId:u,suggest:f,className:x})=>{const E=l.useId(),I=u??E,m=l.useRef(null),y=l.useRef([]),b=r??o,[R,T]=l.useState(null),O=l.useRef(void 0),[_,z]=l.useState(""),L=e.length>0;l.useEffect(()=>{T(a=>a!==null&&a>=e.length?null:a)},[e.length]),l.useEffect(()=>{const a=O.current;if(a!==void 0){if(O.current=void 0,a===null){m.current?.focus();return}y.current[a]?.focus()}});const K=l.useRef(void 0);l.useEffect(()=>{const a=f?.caret;if(!a||a===K.current)return;K.current=a;const d=m.current;!d||d.ownerDocument.activeElement!==d||(d.setSelectionRange(a.cursor,a.cursor),f?.onCaretChange(a.cursor))});const M=a=>{f?.onCaretChange(a.selectionStart??a.value.length)},k=l.useCallback(a=>{T(a),O.current=a},[]),N=l.useCallback(a=>{const d=e[a];d&&t&&(k(Le(a,e.length)),z(`${d.label} removed`),t(d.id))},[e,t,k]),V=l.useCallback(()=>{k(null),o()},[o,k]),G=l.useCallback(a=>{const d=a.currentTarget;if(f?.onKeyDown(a))return;const w=Me({key:a.key,shiftKey:a.shiftKey,repeat:a.repeat,caretAtStart:d.selectionStart===0&&d.selectionEnd===0,hasValue:s.length>0,chipCount:e.length});switch(w.type){case"focusChip":a.preventDefault(),k(w.index);return;case"clearQuery":b();return;case"blur":d.blur();return;case"none":return}},[e.length,s,b,k,f]),W=l.useCallback(a=>d=>{const w=Oe({key:d.key,repeat:d.repeat,index:a,chipCount:e.length});switch(w.type!=="none"&&d.preventDefault(),w.type){case"removeChip":N(w.index);return;case"focusChip":k(w.index);return;case"focusInput":k(null);return;case"activateChip":return;case"none":return}},[e,N,k]);return l.useEffect(()=>{if(!c)return;const a=d=>{d.key!=="/"||d.metaKey||d.ctrlKey||d.altKey||Ne(d.target)||H("focusSearch")||(d.preventDefault(),m.current?.focus())};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[c]),g.jsxs("label",{htmlFor:I,className:v("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",p==="lg"?"rounded-xl px-4 py-2":"rounded-md px-2.5 py-1",x),children:[g.jsx(X,{className:v("shrink-0 text-fg-muted pointer-events-none",p==="lg"?"size-5":"size-4")}),g.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1",children:[L&&g.jsx("div",{role:"grid","aria-label":"Search filters",className:"flex min-w-0 flex-wrap items-center gap-1",children:e.map((a,d)=>g.jsx(Y,{ref:w=>{y.current[d]=w},label:a.label,tone:a.tone,focused:R===d,onFocusLabel:()=>T(d),onKeyDown:W(d),onRemove:()=>N(d)},a.id))}),g.jsx("input",{ref:m,id:I,name:"q",type:"text","aria-label":"Search mail",autoComplete:"off",value:s,tabIndex:R===null?0:-1,onChange:a=>{n(a.target.value),M(a.target)},onKeyDown:G,onKeyUp:a=>M(a.currentTarget),onClick:a=>M(a.currentTarget),onFocus:a=>{T(null),f?.onFocusChange?.(!0),M(a.currentTarget)},onBlur:()=>f?.onFocusChange?.(!1),...f?.comboboxProps,placeholder:L?void 0:i,className:"min-w-24 flex-1 bg-transparent text-fg outline-none placeholder:text-fg-muted"})]}),(s||L)&&h&&g.jsx("button",{type:"button",onClick:V,className:"shrink-0 rounded p-0.5 hover:bg-surface-raised transition-colors","aria-label":"Clear search",children:g.jsx(J,{className:v("text-fg-muted",p==="lg"?"size-5":"size-4")})}),g.jsx("span",{role:"status","aria-live":"polite",className:"sr-only",children:_})]})},_e=({value:e,onChange:t,onClear:s,onClearQuery:n,chips:o,onRemoveChip:r,placeholder:i="Search mail...",globalFocusKey:c=!0,showClearButton:h=!0,size:p,inputId:u,suggest:f,className:x})=>g.jsx(Pe,{value:e,onChange:t,onClear:s,onClearQuery:n,chips:o,onRemoveChip:r,placeholder:i,globalFocusKey:c,showClearButton:h,size:p,inputId:u,suggest:f,className:x});function ze({handlers:e,enabled:t=!0,target:s,sequenceTimeoutMs:n=1e3}){const o=l.useRef(e);o.current=e;const r=l.useRef(null),i=l.useRef(null);l.useEffect(()=>{if(!t)return;const c=()=>{i.current!==null&&(clearTimeout(i.current),i.current=null)},h=u=>{const f=Z({key:u.key,shiftKey:u.shiftKey,metaKey:u.metaKey,ctrlKey:u.ctrlKey,altKey:u.altKey,inEditable:te(u.target),onControl:ee(u.target)},r.current);if(se().length>0){c(),r.current=null;return}if(c(),r.current=f.nextPrefix,f.nextPrefix!==null&&(i.current=setTimeout(()=>{r.current=null,i.current=null},n)),f.action===null||H(f.action)!==null)return;const x=o.current[f.action];x&&(f.preventDefault&&u.preventDefault(),x())},p=s===void 0?window:s;if(p!==null)return p.addEventListener("keydown",h),()=>{p.removeEventListener("keydown",h),c(),r.current=null}},[t,n,s])}function $(e,t){const s=new Set(t);return e.filter(n=>!s.has(n))}function Ae(e,t,s){const n=e.slice(0);return n[t]=s,n}var De=class extends ne{#r;#e;#o;#n;#t;#s;#i;#a;#c;#u=[];constructor(e,t,s){super(),this.#r=e,this.#n=s,this.#o=[],this.#t=[],this.#e=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#t.forEach(e=>{e.subscribe(t=>{this.#h(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#t.forEach(e=>{e.destroy()})}setQueries(e,t){this.#o=e,this.#n=t,P.batch(()=>{const s=this.#t,n=this.#f(this.#o);n.forEach(u=>u.observer.setOptions(u.defaultedQueryOptions));const o=n.map(u=>u.observer),r=o.map(u=>u.getCurrentResult()),i=s.length!==o.length,c=o.some((u,f)=>u!==s[f]),h=i||c,p=h?!0:r.some((u,f)=>{const x=this.#e[f];return!x||!re(u,x)});!h&&!p||(h&&(this.#u=n,this.#t=o),this.#e=r,this.hasListeners()&&(h&&($(s,o).forEach(u=>{u.destroy()}),$(o,s).forEach(u=>{u.subscribe(f=>{this.#h(u,f)})})),this.#p()))})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map(e=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,t){const s=this.#f(e),n=s.map(r=>r.observer.getOptimisticResult(r.defaultedQueryOptions)),o=s.map(r=>r.defaultedQueryOptions.queryHash);return[n,r=>this.#d(r??n,t,o),()=>this.#l(n,s)]}#l(e,t){return t.map((s,n)=>{const o=e[n];return s.defaultedQueryOptions.notifyOnChangeProps?o:s.observer.trackResult(o,r=>{t.forEach(i=>{i.observer.trackProp(r)})})})}#d(e,t,s){if(t){const n=this.#c,o=s!==void 0&&n!==void 0&&(n.length!==s.length||s.some((r,i)=>r!==n[i]));return(!this.#s||this.#e!==this.#a||o||t!==this.#i)&&(this.#i=t,this.#a=this.#e,s!==void 0&&(this.#c=s),this.#s=oe(this.#s,t(e))),this.#s}return e}#m(){return this.#n?.combine!==void 0&&this.#t.some((e,t)=>e.options.suspense&&this.#e[t]?.data===void 0)}#f(e){const t=new Map;this.#t.forEach(n=>{const o=n.options.queryHash;if(!o)return;const r=t.get(o);r?r.push(n):t.set(o,[n])});const s=[];return e.forEach(n=>{const o=this.#r.defaultQueryOptions(n),i=t.get(o.queryHash)?.shift()??new U(this.#r,o);s.push({defaultedQueryOptions:o,observer:i})}),s}#h(e,t){const s=this.#t.indexOf(e);s!==-1&&(this.#e=Ae(this.#e,s,t),this.#p())}#p(){if(this.hasListeners()){const e=this.#l(this.#e,this.#u),t=this.#m(),s=this.#s,n=t?s:this.#d(e,this.#n?.combine);(t||s!==n)&&P.batch(()=>{this.listeners.forEach(o=>{o(this.#e)})})}}};function j({queries:e,...t},s){const n=ie(),o=ae(),r=ce(),i=l.useMemo(()=>e.map(m=>{const y=n.defaultQueryOptions(m);return y._optimisticResults=o?"isRestoring":"optimistic",y}),[e,n,o]);i.forEach(m=>{ue(m);const y=n.getQueryCache().get(m.queryHash);le(m,r,y)}),de(r);const[c]=l.useState(()=>new De(n,i,t)),[h,p,u]=c.getOptimisticResult(i,t.combine),f=!o&&t.subscribed!==!1;l.useSyncExternalStore(l.useCallback(m=>f?c.subscribe(P.batchCalls(m)):fe,[c,f]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),l.useEffect(()=>{c.setQueries(i,t)},[i,t,c]);const E=h.some((m,y)=>Q(i[y],m))?h.flatMap((m,y)=>{const b=i[y];if(b&&Q(b,m)){const R=new U(n,b);return he(b,R,r)}return[]}):[];if(E.length>0)throw Promise.all(E);const I=h.find((m,y)=>{const b=i[y];return b&&pe({result:m,errorResetBoundary:r,throwOnError:b.throwOnError,query:n.getQueryCache().get(b.queryHash),suspense:b.suspense})});if(I?.error)throw I.error;return p(u())}function Ve(){const e=C({from:"/mail/brief/$threadId",shouldThrow:!1}),t=C({from:"/mail/brief/$threadId/$messageId",shouldThrow:!1}),s=C({from:"/mail/flagged/$threadId",shouldThrow:!1}),n=C({from:"/mail/flagged/$threadId/$messageId",shouldThrow:!1}),o=C({from:"/mail/$mailboxId/$threadId",shouldThrow:!1}),r=C({from:"/mail/$mailboxId/$threadId/$messageId",shouldThrow:!1}),i=e?.threadId??s?.threadId??o?.threadId,c=t?.messageId??n?.messageId??r?.messageId;return l.useMemo(()=>i?{threadId:i,messageId:c}:void 0,[i,c])}function Ge(){const e=D(),t=me(),{list:s,mailboxId:n}=S();return l.useCallback((o,r)=>{const i=r?.query,h={search:u=>i===void 0?u:{...u,q:i||void 0},hash:t,replace:r?.replace??!1};if(s==="flagged"){e({to:"/mail/flagged/$threadId/$messageId",params:o,...h});return}const p=r?.mailboxId??n;if(s==="mailbox"&&p){e({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:p,...o},...h});return}e({to:"/mail/brief/$threadId/$messageId",params:o,...h})},[e,t,s,n])}function We(){return ge()}function qe(){const e=D();return l.useCallback(t=>{e({to:"/mail/brief",search:{q:t||void 0}})},[e])}function Xe(){const e=D();return l.useCallback((t,s)=>{e({to:"/mail/$mailboxId",params:{mailboxId:t},search:{q:s||void 0}})},[e])}const Ye=({trigger:e,children:t,align:s="right"})=>{const[n,o]=l.useState(!1),r=l.useRef(null),i=l.useCallback(c=>{r.current&&!r.current.contains(c.target)&&o(!1)},[]);return ye({id:"dropdown-menu",open:n,answers:{back:()=>o(!1)}}),l.useEffect(()=>(n&&document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)),[n,i]),g.jsxs("div",{ref:r,className:"relative",children:[g.jsx("button",{type:"button",onClick:c=>{c.stopPropagation(),o(!n)},className:v("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}),n&&g.jsx("div",{className:v("absolute z-50 mt-1 min-w-[180px] py-1","bg-surface border border-line rounded-md shadow-lg",s==="right"?"right-0":"left-0"),children:t})]})},Je=({onClick:e,disabled:t,destructive:s,children:n})=>g.jsx("button",{type:"button",onClick:o=>{o.stopPropagation(),t||e()},disabled:t,className:v("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",s&&"text-danger hover:text-danger"),children:n}),Ze=()=>g.jsx("div",{className:"my-1 h-px bg-line"}),je=({accounts:e})=>{const{list:t,mailboxId:s}=S(),{t:n}=be("mail",{useSuspense:!1}),o=l.useCallback((i,c)=>n(i,{defaultValue:c}),[n]),r=j({queries:e.map(i=>({...q({path:{accountId:i.accountId}}),staleTime:1/0}))});if(t==="outbox")return"Outbox";if(!s)return null;for(let i=0;i<e.length;i++){const c=r[i]?.data?.items;if(!c)continue;const h=c.find(u=>u.mailboxId===s);if(!h)continue;const p=xe(e[i].folderAppointments);return ke(h,p.get(s),o)}return null},et=({accounts:e})=>{const{mailboxId:t}=S(),s=j({queries:e.map(n=>({...q({path:{accountId:n.accountId}}),staleTime:1/0}))});if(!t)return null;for(const n of s){const o=n.data?.items;if(!o)continue;const r=o.find(i=>i.mailboxId===t);if(r)return r.unseenCount}return null},tt=({accounts:e})=>{const{mailboxId:t}=S(),s=j({queries:e.map(n=>({...q({path:{accountId:n.accountId}}),staleTime:1/0}))});if(!t)return 0;for(const n of s){const o=n.data?.items;if(!o)continue;const r=o.find(i=>i.mailboxId===t);if(r)return r.messageCount}return 0};function st(e){const t=qe(),{searchInput:s}=we(),n=je({accounts:e}),o=S(),r=ve(o,n),i=l.useCallback(c=>{c===Ie&&t(s)},[t,s]);return{scope:r,clearScope:i}}const Ke=768,nt=e=>e!=="desktop",rt=()=>{const e=F(`(min-width: ${Ke}px)`);return F(Ce)?"desktop":e?"tablet":"phone"};function ot(e){const t=new Map;for(const s of e){const n=s.email.toLowerCase(),o=n.split("@")[0];o&&!t.has(o)&&t.set(o,s.accountId),t.has(n)||t.set(n,s.accountId)}return t}function it(e){const t=new Map;for(const s of e)for(const n of s){const o=n.fullPath?.toLowerCase();if(!o)continue;const r=A(n).toLowerCase();t.has(o)||t.set(o,n.mailboxId),t.has(r)||t.set(r,n.mailboxId)}return t}function at(e,t=[]){const s=e.flat().filter(r=>r.fullPath),n=new Map;for(const r of s){const i=A(r).toLowerCase();n.set(i,(n.get(i)??0)+1)}const o=new Map(t.map(r=>[r.accountId,r.email]));return s.map(r=>{const i=A(r),c=n.get(i.toLowerCase())===1,h=t.length>1?o.get(r.accountId):void 0;return{value:c?i:r.fullPath,label:r.displayNameOverride?.trim()||i,...h?{hint:h}:{}}})}function ct(e){const t=new Map;for(const s of e){const n=s.email.toLowerCase().split("@")[0]??"";t.set(n,(t.get(n)??0)+1)}return e.map(s=>{const n=s.email.split("@")[0]??s.email,o=t.get(n.toLowerCase())===1,r=s.displayName?.trim();return{value:o?n:s.email,label:r||s.email,...r?{hint:s.email}:{}}})}export{$e as B,Ye as D,Ee as K,Be as R,_e as S,Ze as a,Je as b,qe as c,j as d,it as e,rt as f,Ve as g,ze as h,ot as i,nt as j,Ge as k,We as l,je as m,et as n,tt as o,Xe as p,Se as q,at as r,Te as s,Ue as t,st as u,ct as v,He as w};
@@ -1 +0,0 @@
1
- import{j as t,a5 as o}from"./index-C0YbF1L6.js";const n=()=>t.jsx(o,{});export{n as component};
@@ -1 +0,0 @@
1
- import{j as E,e as q,b as j,B as A,r as i,aK as R,x as T,v as L,a7 as D,Z as K,Y as Q,_ as $,$ as z}from"./index-C0YbF1L6.js";import{C as B}from"./circle-check-big-LmiZ66Yc.js";import{R as G,d as _}from"./search-token-index-C2zFed-7.js";function ae({state:e,onRefresh:t,label:s,errorMessage:n,hasUpdate:a,size:u="sm",className:c}){const o=e==="refreshing",m=e==="error",f=e==="success",g=m?E.jsx(q,{className:"size-4 text-danger"}):f?E.jsx(B,{className:"size-4 text-positive"}):E.jsx(G,{className:j("size-4",o&&"animate-spin")}),y=m?`${s} — failed: ${n??"try again"}`:o?`${s} — refreshing`:f?`${s} — up to date`:a?`${s} — new mail`:s;return E.jsxs("div",{className:"relative inline-flex",children:[E.jsx(A,{variant:"ghost",size:u,icon:g,onClick:t,disabled:o,"aria-label":y,"aria-busy":o||void 0,title:m?n:s,className:c}),e==="idle"&&a&&E.jsx("span",{"aria-hidden":"true",className:"absolute right-1 top-1 size-1.5 rounded-full bg-accent-2"})]})}const H=new Set(["discovering_mailboxes","syncing_inbox","syncing_others"]);function N(e){return!!e&&H.has(e)}const P=3e3,U=P*2,v={syncing:!1,resolved:!1,synced:0,total:0};function oe(e,t){const s=e.join(","),[n,a]=i.useState(!1),[u,c]=i.useState(!1);i.useEffect(()=>{a(!1),c(!1)},[s,t]),i.useEffect(()=>{if(!t)return;const r=setTimeout(()=>c(!0),U);return()=>clearTimeout(r)},[s,t]);const o=_({queries:e.map(r=>({...R({path:{accountId:r}}),enabled:t&&!n,refetchInterval:P,meta:{softError:!0}}))}),m=o.every(r=>r.isSuccess||r.isError),f=o.length===0||m||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&&f&&!g;return i.useEffect(()=>{S&&a(!0)},[S]),!t||!f?v:{syncing:g,resolved:!0,synced:y,total:w}}const M=6e4,W=new Set(["sent","drafts","trash","archive"]),b=(e,t)=>{const s=new Map;for(const n of e){const a=t.get(n.mailboxId)?.role;a&&W.has(a)||s.set(n.mailboxId,n.messagesTotal)}return s},X=(e,t)=>{for(const[s,n]of t)if(n>(e.get(s)??0))return!0;return!1},F=i.createContext(null),Y=()=>{const e=i.useContext(F);if(!e)throw new Error("useMailFreshness must be used inside <MailFreshnessProvider>");return e};function ie({accountIds:e,children:t}){const s=T(),{resultFolderIndex:n}=L(),a=i.useRef(new Map),u=i.useRef(new Set),[c,o]=i.useState(new Set),m=_({queries:e.map(r=>({...R({path:{accountId:r}}),refetchInterval:M,staleTime:M,meta:{softError:!0}}))}),f=m.map(r=>r.dataUpdatedAt).join(","),g=e.join(",");i.useEffect(()=>{let r=!1;const l=new Set(c);e.forEach((d,x)=>{const p=m[x]?.data;if(!p)return;const h=b(p.mailboxes??[],n);if(!u.current.has(d)){u.current.add(d),a.current.set(d,h);return}if(l.has(d))return;const O=a.current.get(d)??new Map;X(O,h)&&(l.add(d),r=!0)}),r&&o(l)},[g,f]);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);a.current.set(l,b(d?.mailboxes??[],n)),u.current.add(l)}},[s,n]),S=i.useMemo(()=>({hasNewMail:y,acknowledge:w}),[y,w]);return E.jsx(F.Provider,{value:S,children:t})}const Z=2e3,I=45e3,J=e=>new Promise(t=>setTimeout(t,e)),k=e=>e instanceof Error&&e.message?e.message:"Something went wrong",V=e=>{$(e,{softError:!0},"user")&&z(e)},C=(e,t)=>e.fetchQuery({...R({path:{accountId:t}}),staleTime:0}),ee=async({accountId:e,readStatus:t,baselineLastSyncAt:s,deadline:n,pollMs:a=Z})=>{for(;;){const u=await t().then(f=>({ok:!0,data:f})).catch(f=>({ok:!1,error:f}));if(!u.ok)return{accountId:e,message:k(u.error)};const{syncPhase:c,lastSyncAt:o}=u.data;if((o??0)>s&&!N(c))return c==="error"?{accountId:e,message:"Sync failed for this account"}:void 0;if(Date.now()>=n)return{accountId:e,message:"Refresh is taking longer than usual"};await J(a)}},se=async(e,t,s,n)=>{const a=await C(e,s).then(o=>({ok:!0,lastSyncAt:o.lastSyncAt??0})).catch(o=>({ok:!1,error:o}));if(!a.ok)return{accountId:s,enqueued:!1,ok:!1,message:k(a.error)};const u=await Q({path:{accountId:s},throwOnError:!0}).then(()=>({ok:!0})).catch(o=>({ok:!1,error:o}));if(!u.ok)return V(u.error),{accountId:s,enqueued:!1,ok:!1,message:k(u.error)};t.recordEvent("sync.triggered");const c=await ee({accountId:s,readStatus:()=>C(e,s),baselineLastSyncAt:a.lastSyncAt,deadline:n});return c?{accountId:s,enqueued:!0,ok:!1,message:c.message}:{accountId:s,enqueued:!0,ok:!0}},ce=(e,t={})=>{const s=T(),n=D(),{acknowledge:a}=Y(),[u,c]=i.useState("idle"),[o,m]=i.useState(),f=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"),m("Nothing to refresh yet");return}const r=++f.current;c("refreshing"),m(void 0),(async()=>{const l=Date.now()+I,d=await Promise.all(S.map(h=>se(s,n,h,l)));if(f.current!==r)return;const x=d.filter(h=>h.enqueued).map(h=>h.accountId);for(const h of x)s.invalidateQueries({queryKey:K({path:{accountId:h}})});x.length>0&&(y.current.onSettled?.(),a(x));const p=d.filter(h=>!h.ok);p.length===0?c("success"):(c("error"),m(p[0]?.message))})()},[a,s,n]);return{state:u,errorMessage:o,refresh:w}};export{ie as M,ae as R,ce as a,oe as b,N as i,Y as u};