@remit/web-client-dist 0.0.350 → 0.0.352

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 (107) hide show
  1. package/assets/BriefPane-p-hSuFHs.js +1 -0
  2. package/assets/{ErrorState-DoRAGdox.js → ErrorState-DZuvygoB.js} +1 -1
  3. package/assets/FlaggedPane-hgkHMzJs.js +1 -0
  4. package/assets/MailListHeader-ChgoSBi9.js +52 -0
  5. package/assets/{MailViewChrome-BfjRaJ19.js → MailViewChrome-Bmclnv4Y.js} +1 -1
  6. package/assets/MailboxPane-BMQDZJjp.js +1 -0
  7. package/assets/{NavMenuButton-BS79vTSG.js → NavMenuButton-BMHaKadd.js} +1 -1
  8. package/assets/{OnboardingWizard-F-TaNHAB.js → OnboardingWizard-D_CKlYeE.js} +1 -1
  9. package/assets/OutboxPane-CZaWhBtj.js +1 -0
  10. package/assets/_mailboxId-CFnhtqtO.js +1 -0
  11. package/assets/_messageId-BGy2iRwR.js +1 -0
  12. package/assets/_messageId-C5W69cMm.js +1 -0
  13. package/assets/_messageId-Coqf3iOq.js +1 -0
  14. package/assets/_outboxMessageId-BPomNqIM.js +1 -0
  15. package/assets/_threadId-BeFC5p1-.js +1 -0
  16. package/assets/_threadId-C4vJmEsZ.js +1 -0
  17. package/assets/_threadId-CuZmFZv-.js +1 -0
  18. package/assets/{account-form-helpers-B8wNcuKv.js → account-form-helpers-BfY-Ea9J.js} +1 -1
  19. package/assets/accounts-L7qmNB9J.js +1 -0
  20. package/assets/{advanced-BlT3tDbs.js → advanced-BJY8Omuf.js} +2 -2
  21. package/assets/{appearance-CP2rAXSb.js → appearance-DpQj7mfH.js} +1 -1
  22. package/assets/{avatar-PdnvM963.js → avatar-BFQ0qcwg.js} +1 -1
  23. package/assets/{bottom-sheet-Bk_TVO-_.js → bottom-sheet-B093xbW6.js} +1 -1
  24. package/assets/brief-BRJwDJxo.js +1 -0
  25. package/assets/{brief-D84se38N.js → brief-DDFdGXoV.js} +1 -1
  26. package/assets/{browser-ponyfill-DZShSotr.js → browser-ponyfill-B6ZDdJ1B.js} +1 -1
  27. package/assets/{bug-wt8JvdWM.js → bug-J1y1e9ln.js} +1 -1
  28. package/assets/{circle-check-HhU-1j11.js → circle-check-Cc5r3mNv.js} +1 -1
  29. package/assets/{circle-check-big-DILQ0UlV.js → circle-check-big-CbFDK_1e.js} +1 -1
  30. package/assets/{circle-help-B1FPU1VH.js → circle-help-CP-9GEES.js} +1 -1
  31. package/assets/{clock-VpKLm0s2.js → clock-96u1OlQy.js} +1 -1
  32. package/assets/{confirm-dialog-Dt7c_-Hc.js → confirm-dialog-D9ePPVOy.js} +1 -1
  33. package/assets/{download-7bj5MyVu.js → download-D7nu5tCC.js} +1 -1
  34. package/assets/{filters-BmMNr1sB.js → filters-DNNLGo5R.js} +1 -1
  35. package/assets/flagged-B9fZ1GqU.js +1 -0
  36. package/assets/{flagged-B3gSwDyx.js → flagged-W35-YQH1.js} +1 -1
  37. package/assets/{folders-BkaGLo6W.js → folders-TMV5XV0z.js} +1 -1
  38. package/assets/index-1WA7SdKy.js +1 -0
  39. package/assets/{index-BRCDRo29.js → index-BDlRWNu5.js} +63 -63
  40. package/assets/index-BGy2iRwR.js +1 -0
  41. package/assets/index-BMYggitW.js +1 -0
  42. package/assets/index-BV0ZMlSc.js +1 -0
  43. package/assets/index-BrDwfz9a.js +1 -0
  44. package/assets/index-BtDSe1NC.js +1 -0
  45. package/assets/index-C5W69cMm.js +1 -0
  46. package/assets/index-D60Mtde_.js +1 -0
  47. package/assets/{kbd-CsPdP9wb.js → kbd-Nj3PirXE.js} +1 -1
  48. package/assets/{labels-Bc46ITVM.js → labels-BTNthaM_.js} +1 -1
  49. package/assets/mail-D33vNQBN.js +1 -0
  50. package/assets/{menu-DfVnoVYt.js → menu-Cge3eG3G.js} +1 -1
  51. package/assets/{move-options-CGXIzBuT.js → move-options-_Jvq5Spv.js} +1 -1
  52. package/assets/{nav-link-CWDzdgm8.js → nav-link-ChkTofbC.js} +1 -1
  53. package/assets/{onboarding-DG15x7nQ.js → onboarding-Bzi09G3e.js} +1 -1
  54. package/assets/outbox-rJugUzue.js +1 -0
  55. package/assets/{pencil-B1hrkgzK.js → pencil-CAWN6ewF.js} +1 -1
  56. package/assets/{rich-text-BRnrEpbz.js → rich-text-Dp3cktQa.js} +1 -1
  57. package/assets/{rich-text-spellcheck-worker-provider-CHfEkKbD.js → rich-text-spellcheck-worker-provider-D7aFt0ey.js} +1 -1
  58. package/assets/{rotate-ccw-C_tFdrda.js → rotate-ccw-CUMpjKIx.js} +1 -1
  59. package/assets/{row-actions-Cb-L2i4O.js → row-actions-DRYVYMB6.js} +1 -1
  60. package/assets/search-token-index-BCcAcKHl.js +1 -0
  61. package/assets/{search-view-Dq4wh09L.js → search-view-DaSWxA7w.js} +1 -1
  62. package/assets/{senders-DdLa7kvs.js → senders-DhbxI1sv.js} +1 -1
  63. package/assets/settings-cYD6emkb.js +1 -0
  64. package/assets/{settings-screen-CIG8V8_w.js → settings-screen-CJpNRhuf.js} +1 -1
  65. package/assets/{shield-check-D0e9fF2a.js → shield-check-wZ0xR1_v.js} +1 -1
  66. package/assets/{suggested-vips-CG-DYao7.js → suggested-vips-ByzIj3y1.js} +1 -1
  67. package/assets/{use-match-media-BPAxbeec.js → use-match-media-C-UI0_qJ.js} +1 -1
  68. package/assets/{useDebouncedValue-DEKIbYmm.js → useDebouncedValue-BCfUYA_a.js} +1 -1
  69. package/assets/{useFilters-DU9a5EsI.js → useFilters-DnPMMAYI.js} +1 -1
  70. package/assets/{useLabels-Bx0M2eO2.js → useLabels-BCPsJjR6.js} +1 -1
  71. package/assets/{useRefreshControl-DXnlAPXi.js → useRefreshControl-CkuN__QT.js} +1 -1
  72. package/assets/{useSearchMirror-CbAX1Wtu.js → useSearchMirror-sL1Jjp51.js} +1 -1
  73. package/assets/useSearchTokenContext-CD-tKLIr.js +84 -0
  74. package/assets/{useSemanticSearch-CngSoHz3.js → useSemanticSearch-DOYK8s17.js} +1 -1
  75. package/assets/useSignature-CeeqBJpG.js +1 -0
  76. package/index.html +1 -1
  77. package/package.json +1 -1
  78. package/assets/BriefPane-CIBzBLar.js +0 -1
  79. package/assets/FlaggedPane-DdICDYH6.js +0 -1
  80. package/assets/MailListHeader-rmY0HqPF.js +0 -52
  81. package/assets/MailboxPane-Dl2l5qWx.js +0 -1
  82. package/assets/OutboxPane-7aoZUfA7.js +0 -1
  83. package/assets/_mailboxId-ChxGJRMN.js +0 -1
  84. package/assets/_messageId-BUTz--x0.js +0 -1
  85. package/assets/_messageId-Dnc4nHKm.js +0 -1
  86. package/assets/_messageId-Y7ZXfbvW.js +0 -1
  87. package/assets/_outboxMessageId-3rQNAYUA.js +0 -1
  88. package/assets/_threadId-BHskCRJT.js +0 -1
  89. package/assets/_threadId-BUA2GOyT.js +0 -1
  90. package/assets/_threadId-CNSh0ofh.js +0 -1
  91. package/assets/accounts-6M3nWAiW.js +0 -1
  92. package/assets/brief-aG6uovSM.js +0 -1
  93. package/assets/flagged-CQ2S8QX8.js +0 -1
  94. package/assets/index-1r0qJlWv.js +0 -1
  95. package/assets/index-3zilF24c.js +0 -1
  96. package/assets/index-82OludOM.js +0 -1
  97. package/assets/index-B43zVi5V.js +0 -1
  98. package/assets/index-CXTHqtUw.js +0 -1
  99. package/assets/index-DHq96ldB.js +0 -1
  100. package/assets/index-Dnc4nHKm.js +0 -1
  101. package/assets/index-Y7ZXfbvW.js +0 -1
  102. package/assets/mail-CrY_2MXy.js +0 -1
  103. package/assets/outbox-CxhsVpX5.js +0 -1
  104. package/assets/search-token-index-B-Ijdoxu.js +0 -1
  105. package/assets/settings-7p-dBvcw.js +0 -1
  106. package/assets/useSearchTokenContext-De3uvO-G.js +0 -84
  107. package/assets/useSignature-ClDKKTqd.js +0 -1
@@ -1 +0,0 @@
1
- import{c as j,r as l,j as m,g as Q,b as T,cN as V,X as z,K as N,D as b,l as G,t as X,v as F,w as O,z as W,E as J,p as Y,o as Z,co as L}from"./index-BRCDRo29.js";import{b as ee,e as te,S as ne}from"./nav-link-CWDzdgm8.js";import{u as A,D as oe}from"./use-match-media-BPAxbeec.js";const ve=j("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 Ee=j("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]),re=[{action:"focusNext",keys:["j","k"],label:"navigate"},{action:"muteSender",keys:["m"],label:"mute"},{action:"help",keys:["?"],label:"all shortcuts"}];function Te(e){return re.filter(t=>e[t.action]!==void 0)}const se=[{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 ae(e){for(const t of se){const n=t.hints.find(r=>r.action===e);if(n)return n.keys}}function ie(e){const t=ae(e);return!t||t.length===0?"":t.length===1?t[0]??"":t[0]==="g"?t.join(" then "):t.join("")}function Ne(e){const t=ie(e);return t===""?"":`(${t})`}const k={action:null,nextPrefix:null,preventDefault:!1},ce={b:"goBrief",i:"goInbox",s:"goSent",f:"goFlagged",",":"goSettings"},le={j:{action:"focusNext"},k:{action:"focusPrevious"},arrowdown:{action:"focusNext"},arrowup:{action:"focusPrevious"},home:{action:"focusFirst"},end:{action:"focusLast"},enter:{action:"openFocused"}," ":{action:"toggleSelect"},delete:{action:"delete"},backspace:{action:"delete"},u:{action:"toggleRead"},x:{action:"toggleSelect"},r:{action:"reply"},a:{action:"replyAll"},f:{action:"forward"},"#":{action:"delete"},s:{action:"toggleStar"},m:{action:"muteSender"},b:{action:"blockSender"},v:{action:"vipSender"},"!":{action:"markJunk"},i:{action:"toggleIntelligence"},d:{action:"toggleDensity"},"/":{action:"focusSearch"},c:{action:"compose"},"?":{action:"help"}};function ue(e,t){const n=e.key.toLowerCase(),r=e.metaKey||e.ctrlKey;if(e.inEditable)return{...k,nextPrefix:t==="g"?null:t};if(e.onControl&&(n==="enter"||n===" "))return{...k,nextPrefix:t==="g"?null:t};if(r&&n==="n")return{action:"compose",nextPrefix:null,preventDefault:!0};if(r&&n==="a")return{action:"selectAll",nextPrefix:null,preventDefault:!0};if(r)return{...k,nextPrefix:t==="g"?null:t};if(n==="escape")return{action:"back",nextPrefix:null,preventDefault:!1};if(t==="g"){const a=ce[n===","?",":n]??null;return{action:a,nextPrefix:null,preventDefault:a!==null}}if(n==="g"&&!e.shiftKey)return{action:null,nextPrefix:"g",preventDefault:!0};if(e.shiftKey){const s=n==="j"||n==="arrowdown";if(s||(n==="k"||n==="arrowup"))return{action:s?"extendSelectDown":"extendSelectUp",nextPrefix:null,preventDefault:!0}}const o=le[n];if(o){const s=o.requireShift===!0,a=n.length===1&&!/[a-z0-9]/.test(n);return!s&&e.shiftKey&&!a?k:{action:o.action,nextPrefix:null,preventDefault:!0}}return k}function fe(e){if(!(e instanceof HTMLElement))return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable}const de="data-message-row",pe='button, a[href], summary, [role="button"], [role="menuitem"], [role="tab"], [role="switch"], [role="checkbox"]';function me(e){if(!(e instanceof HTMLElement))return!1;const t=e.closest(pe);return t?!t.hasAttribute(de):!1}function he({key:e,shiftKey:t=!1,repeat:n=!1,caretAtStart:r,hasValue:o,chipCount:s}){const a=s-1;return e==="Escape"?o?{type:"clearQuery"}:{type:"blur"}:e==="Tab"&&t?s===0?{type:"none"}:{type:"focusChip",index:a}:e==="Backspace"||e==="ArrowLeft"?!r||s===0?{type:"none"}:n?{type:"none"}:{type:"focusChip",index:a}:{type:"none"}}function ge({key:e,repeat:t=!1,index:n,chipCount:r}){return e==="Backspace"||e==="Delete"?t?{type:"none"}:{type:"removeChip",index:n}:e==="ArrowLeft"?n===0?{type:"none"}:{type:"focusChip",index:n-1}:e==="ArrowRight"?n>=r-1?{type:"focusInput"}:{type:"focusChip",index:n+1}:e==="Enter"||e===" "?{type:"activateChip",index:n}:e==="Escape"?{type:"focusInput"}:{type:"none"}}function ye(e,t){const n=t-1;return n<=0?null:e<n?e:n-1}const be=e=>e instanceof HTMLElement?e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.isContentEditable:!1,xe=({chips:e=[],onRemoveChip:t,value:n,onChange:r,onClear:o,onClearQuery:s,placeholder:a="Search mail...",globalFocusKey:c=!0,showClearButton:f=!0,size:h="sm",inputId:p,suggest:d,className:x})=>{const q=l.useId(),P=p??q,w=l.useRef(null),D=l.useRef([]),M=s??o,[K,S]=l.useState(null),I=l.useRef(void 0),[$,B]=l.useState(""),v=e.length>0;l.useEffect(()=>{S(i=>i!==null&&i>=e.length?null:i)},[e.length]),l.useEffect(()=>{const i=I.current;if(i!==void 0){if(I.current=void 0,i===null){w.current?.focus();return}D.current[i]?.focus()}});const R=l.useRef(void 0);l.useEffect(()=>{const i=d?.caret;if(!i||i===R.current)return;R.current=i;const u=w.current;!u||u.ownerDocument.activeElement!==u||(u.setSelectionRange(i.cursor,i.cursor),d?.onCaretChange(i.cursor))});const C=i=>{d?.onCaretChange(i.selectionStart??i.value.length)},g=l.useCallback(i=>{S(i),I.current=i},[]),E=l.useCallback(i=>{const u=e[i];u&&t&&(g(ye(i,e.length)),B(`${u.label} removed`),t(u.id))},[e,t,g]),H=l.useCallback(()=>{g(null),o()},[o,g]),_=l.useCallback(i=>{const u=i.currentTarget;if(d?.onKeyDown(i))return;const y=he({key:i.key,shiftKey:i.shiftKey,repeat:i.repeat,caretAtStart:u.selectionStart===0&&u.selectionEnd===0,hasValue:n.length>0,chipCount:e.length});switch(y.type){case"focusChip":i.preventDefault(),g(y.index);return;case"clearQuery":M();return;case"blur":u.blur();return;case"none":return}},[e.length,n,M,g,d]),U=l.useCallback(i=>u=>{const y=ge({key:u.key,repeat:u.repeat,index:i,chipCount:e.length});switch(y.type!=="none"&&u.preventDefault(),y.type){case"removeChip":E(y.index);return;case"focusChip":g(y.index);return;case"focusInput":g(null);return;case"activateChip":return;case"none":return}},[e,E,g]);return l.useEffect(()=>{if(!c)return;const i=u=>{u.key!=="/"||u.metaKey||u.ctrlKey||u.altKey||be(u.target)||(u.preventDefault(),w.current?.focus())};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[c]),m.jsxs("label",{htmlFor:P,className:T("flex w-full items-center gap-1.5 text-sm","bg-surface-sunken/50 border border-transparent","focus-within:bg-canvas focus-within:border-line focus-within:ring-2 focus-within:ring-ring","transition-colors",h==="lg"?"rounded-xl px-4 py-2":"rounded-md px-2.5 py-1",x),children:[m.jsx(Q,{className:T("shrink-0 text-fg-muted pointer-events-none",h==="lg"?"size-5":"size-4")}),m.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1",children:[v&&m.jsx("div",{role:"grid","aria-label":"Search filters",className:"flex min-w-0 flex-wrap items-center gap-1",children:e.map((i,u)=>m.jsx(V,{ref:y=>{D.current[u]=y},label:i.label,tone:i.tone,focused:K===u,onFocusLabel:()=>S(u),onKeyDown:U(u),onRemove:()=>E(u)},i.id))}),m.jsx("input",{ref:w,id:P,name:"q",type:"text","aria-label":"Search mail",autoComplete:"off",value:n,tabIndex:K===null?0:-1,onChange:i=>{r(i.target.value),C(i.target)},onKeyDown:_,onKeyUp:i=>C(i.currentTarget),onClick:i=>C(i.currentTarget),onFocus:i=>{S(null),d?.onFocusChange?.(!0),C(i.currentTarget)},onBlur:()=>d?.onFocusChange?.(!1),...d?.comboboxProps,placeholder:v?void 0:a,className:"min-w-24 flex-1 bg-transparent text-fg outline-none placeholder:text-fg-muted"})]}),(n||v)&&f&&m.jsx("button",{type:"button",onClick:H,className:"shrink-0 rounded p-0.5 hover:bg-surface-raised transition-colors","aria-label":"Clear search",children:m.jsx(z,{className:T("text-fg-muted",h==="lg"?"size-5":"size-4")})}),m.jsx("span",{role:"status","aria-live":"polite",className:"sr-only",children:$})]})},Pe=({value:e,onChange:t,onClear:n,onClearQuery:r,chips:o,onRemoveChip:s,placeholder:a="Search mail...",globalFocusKey:c=!0,showClearButton:f=!0,size:h,inputId:p,suggest:d,className:x})=>m.jsx(xe,{value:e,onChange:t,onClear:n,onClearQuery:r,chips:o,onRemoveChip:s,placeholder:a,globalFocusKey:c,showClearButton:f,size:h,inputId:p,suggest:d,className:x});function De({handlers:e,enabled:t=!0,target:n,sequenceTimeoutMs:r=1e3}){const o=l.useRef(e);o.current=e;const s=l.useRef(null),a=l.useRef(null);l.useEffect(()=>{if(!t)return;const c=()=>{a.current!==null&&(clearTimeout(a.current),a.current=null)},f=p=>{const d=ue({key:p.key,shiftKey:p.shiftKey,metaKey:p.metaKey,ctrlKey:p.ctrlKey,altKey:p.altKey,inEditable:fe(p.target),onControl:me(p.target)},s.current);if(c(),s.current=d.nextPrefix,d.nextPrefix!==null&&(a.current=setTimeout(()=>{s.current=null,a.current=null},r)),d.action===null)return;const x=o.current[d.action];x&&(d.preventDefault&&p.preventDefault(),x())},h=n===void 0?window:n;if(h!==null)return h.addEventListener("keydown",f),()=>{h.removeEventListener("keydown",f),c(),s.current=null}},[t,r,n])}const Me=({trigger:e,children:t,align:n="right"})=>{const[r,o]=l.useState(!1),s=l.useRef(null),a=l.useCallback(f=>{s.current&&!s.current.contains(f.target)&&o(!1)},[]),c=l.useCallback(f=>{f.key==="Escape"&&o(!1)},[]);return l.useEffect(()=>(r&&(document.addEventListener("mousedown",a),document.addEventListener("keydown",c)),()=>{document.removeEventListener("mousedown",a),document.removeEventListener("keydown",c)}),[r,a,c]),m.jsxs("div",{ref:s,className:"relative",children:[m.jsx("button",{type:"button",onClick:f=>{f.stopPropagation(),o(!r)},className:N("p-1.5 min-h-11 min-w-11 inline-flex items-center justify-center rounded-md transition-colors","hover:bg-surface-raised text-fg-muted hover:text-fg"),children:e}),r&&m.jsx("div",{className:N("absolute z-50 mt-1 min-w-[180px] py-1","bg-surface border border-line rounded-md shadow-lg",n==="right"?"right-0":"left-0"),children:t})]})},Ke=({onClick:e,disabled:t,destructive:n,children:r})=>m.jsx("button",{type:"button",onClick:o=>{o.stopPropagation(),t||e()},disabled:t,className:N("w-full px-3 py-2 text-left text-sm transition-colors","flex items-center gap-2",t&&"opacity-50 cursor-not-allowed",!t&&"hover:bg-surface-raised",n&&"text-danger hover:text-danger"),children:r}),Re=()=>m.jsx("div",{className:"my-1 h-px bg-line"}),ke=({accounts:e})=>{const t=b({strict:!1}),n=G(),r=t.mailboxId,{t:o}=X("mail",{useSuspense:!1}),s=l.useCallback((c,f)=>o(c,{defaultValue:f}),[o]),a=F({queries:e.map(c=>({...O({path:{accountId:c.accountId}}),staleTime:1/0}))});if(n.pathname.startsWith("/mail/outbox"))return"Outbox";if(!r)return null;for(let c=0;c<e.length;c++){const f=a[c]?.data?.items;if(!f)continue;const h=f.find(d=>d.mailboxId===r);if(!h)continue;const p=W(e[c].folderAppointments);return J(h,p.get(r),s)}return null},Le=({accounts:e})=>{const n=b({strict:!1}).mailboxId,r=F({queries:e.map(o=>({...O({path:{accountId:o.accountId}}),staleTime:1/0}))});if(!n)return null;for(const o of r){const s=o.data?.items;if(!s)continue;const a=s.find(c=>c.mailboxId===n);if(a)return a.unseenCount}return null};function Ae(e){const t=Y(),{searchInput:n}=Z(),r=ke({accounts:e}),o=ee({select:c=>c.matches}),s=te(o,r),a=l.useCallback(c=>{c===ne&&t({to:"/mail/brief",search:{q:n||void 0}})},[t,n]);return{scope:s,clearScope:a}}function je(){const e=b({from:"/mail/brief/$threadId",shouldThrow:!1}),t=b({from:"/mail/brief/$threadId/$messageId",shouldThrow:!1}),n=b({from:"/mail/flagged/$threadId",shouldThrow:!1}),r=b({from:"/mail/flagged/$threadId/$messageId",shouldThrow:!1}),o=b({from:"/mail/$mailboxId/$threadId",shouldThrow:!1}),s=b({from:"/mail/$mailboxId/$threadId/$messageId",shouldThrow:!1}),a=e?.threadId??n?.threadId??o?.threadId,c=t?.messageId??r?.messageId??s?.messageId;return l.useMemo(()=>a?{threadId:a,messageId:c}:void 0,[a,c])}const Fe=({enabled:e=!0,bindings:t,capture:n=!1})=>{const r=l.useCallback(o=>{const s=o.target;if(!(s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.isContentEditable))for(const a of t){if(!(o.key.toLowerCase()===a.key.toLowerCase())||a.requireShift!==void 0&&a.requireShift!==o.shiftKey)continue;const f=o.ctrlKey||o.metaKey;if(a.requireMeta!==void 0){if(a.requireMeta!==f)continue}else{const h=a.noModifiers??!0,p=f||o.altKey||a.requireShift===void 0&&o.shiftKey;if(h&&p)continue}a.preventDefault&&o.preventDefault(),a.stopPropagation&&(o.stopPropagation(),o.stopImmediatePropagation()),a.handler(o);return}},[t]);l.useEffect(()=>{if(e)return window.addEventListener("keydown",r,n),()=>window.removeEventListener("keydown",r,n)},[e,r,n])},we=768,Oe=e=>e!=="desktop",qe=()=>{const e=A(`(min-width: ${we}px)`);return A(oe)?"desktop":e?"tablet":"phone"};function $e(e){const t=new Map;for(const n of e){const r=n.email.toLowerCase(),o=r.split("@")[0];o&&!t.has(o)&&t.set(o,n.accountId),t.has(r)||t.set(r,n.accountId)}return t}function Be(e){const t=new Map;for(const n of e)for(const r of n){const o=r.fullPath?.toLowerCase();if(!o)continue;const s=o.split("/").pop();t.has(o)||t.set(o,r.mailboxId),s&&!t.has(s)&&t.set(s,r.mailboxId)}return t}function He(e,t=[]){const n=e.flat().filter(s=>s.fullPath),r=new Map;for(const s of n){const a=L(s.fullPath).toLowerCase();r.set(a,(r.get(a)??0)+1)}const o=new Map(t.map(s=>[s.accountId,s.email]));return n.map(s=>{const a=L(s.fullPath),c=r.get(a.toLowerCase())===1,f=t.length>1?o.get(s.accountId):void 0;return{value:c?a:s.fullPath,label:s.displayNameOverride?.trim()||a,...f?{hint:f}:{}}})}function _e(e){const t=new Map;for(const n of e){const r=n.email.toLowerCase().split("@")[0]??"";t.set(r,(t.get(r)??0)+1)}return e.map(n=>{const r=n.email.split("@")[0]??n.email,o=t.get(r.toLowerCase())===1,s=n.displayName?.trim();return{value:o?r:n.email,label:s||n.email,...s?{hint:n.email}:{}}})}export{ve as B,Me as D,se as K,Ee as R,Pe as S,Re as a,Ke as b,Be as c,qe as d,je as e,Fe as f,De as g,$e as h,Oe as i,ke as j,Le as k,re as l,Te as m,de as n,He as o,_e as p,ie as s,Ne as t,Ae as u};
@@ -1 +0,0 @@
1
- import{j as t,a0 as o}from"./index-BRCDRo29.js";const n=()=>t.jsx(o,{});export{n as component};
@@ -1,84 +0,0 @@
1
- import{c3 as J,r as g,j as a,b as k,I as ee,a2 as te,n as B,s as $,x as se,cr as D,cq as re,ad as ne,af as ae,ag as oe,bd as ie,e as ce,X as le,K as v,o as de}from"./index-BRCDRo29.js";import{K as S}from"./kbd-CsPdP9wb.js";import{M as O}from"./enums-CCxx0t2v.js";import{b as ue,f as me}from"./nav-link-CWDzdgm8.js";const fe=(e,t)=>{const r=e==="newsletter"||e==="marketing"||t;return{framed:r,isPlain:!r}},he=()=>`
2
- /* Zero the UA default body margin and clamp the document to the iframe width so
3
- wide author markup can't push the body (and the page) past the viewport. */
4
- html, body {
5
- margin: 0;
6
- padding: 0;
7
- max-width: 100%;
8
- }
9
- body {
10
- overflow-wrap: anywhere;
11
- word-break: break-word;
12
- }
13
- /* Media never wider than the frame; keep aspect ratio when width is capped. */
14
- img, video, iframe, svg, canvas {
15
- max-width: 100% !important;
16
- height: auto;
17
- }
18
- /* Fixed-width author tables (\`<table width="600">\`) collapse to fit. */
19
- table {
20
- max-width: 100% !important;
21
- table-layout: auto;
22
- }
23
- /* Cells carry the fixed widths in real newsletters (\`<td width="600">\`);
24
- cap them too or the table can't actually shrink. */
25
- td, th {
26
- max-width: 100% !important;
27
- }
28
- /* \`max-width\` alone can't beat an inline \`min-width\`; zeroing the min lets
29
- flex / grid / table children actually collapse to the clamped width. */
30
- * {
31
- min-width: 0;
32
- }
33
- /* An author \`nowrap\` assumes a viewport as wide as the line. The frame is the
34
- pane's width whatever the mail is, so a pinned paragraph turns reading one
35
- sentence into a sideways drag — and inside an author \`overflow:hidden\` it is
36
- cut mid-character with nothing left to scroll at all. Flowing text wraps. The
37
- \`i\` flag is load-bearing: Outlook and older generators emit \`WHITE-SPACE:
38
- NOWRAP\`, and an attribute value match is case-sensitive without it. */
39
- [nowrap]:not(pre, code, pre *, code *),
40
- [style*="nowrap" i]:not(pre, code, pre *, code *) {
41
- white-space: normal !important;
42
- }
43
- /* Long unbroken strings (URLs, tokens) wrap instead of forcing a wide line. */
44
- pre, code {
45
- white-space: pre-wrap;
46
- overflow-wrap: anywhere;
47
- word-break: break-word;
48
- }
49
- /* Preformatted text keeps its spacing even where a nowrap is declared — on the
50
- block or on a span inside it. \`normal\` would collapse the runs of spaces that
51
- are the entire content of a \`pre\`, and the un-important rule above cannot
52
- defend an inline style, so this wraps to \`pre-wrap\` instead of unwrapping. */
53
- :is(pre, code, pre *, code *):is([nowrap], [style*="nowrap" i]) {
54
- white-space: pre-wrap !important;
55
- }
56
- `,ge=e=>{const t=new Map;for(const s of e){if(!s.contentId||s.contentUrl.length===0)continue;const r=s.contentId.replace(/^<|>$/g,"");t.set(r,s.contentUrl)}return s=>t.get(s.replace(/^<|>$/g,""))},pe=/^(none|transparent|inherit|initial|unset)\s*$/i,I=e=>{const t=[],s=/<style[^>]*>([\s\S]*?)<\/style>/gi;let r;for(r=s.exec(e);r!==null;)t.push(r[1]),r=s.exec(e);return t},ye=e=>{const t=/background(?:-color)?\s*:\s*([^;}\n]+)/gi;let s;for(s=t.exec(e);s!==null;){const r=s[1].trim();if(!pe.test(r))return!0;s=t.exec(e)}return!1},be=e=>{if(/\bstyle\s*=\s*["'][^"']*background/i.test(e)||/\bbgcolor\s*=/i.test(e))return!0;for(const t of I(e))if(ye(t))return!0;return!1},xe=new Set(["auto","none","initial","inherit","unset","revert","revert-layer"]),we=new RegExp(`(?<![-\\w])(?:padding|margin)(?:-(top|right|bottom|left|block|inline)(?:-(?:start|end))?)?\\s*:\\s*([^;}"']+)`,"gi"),ve=new Set(["top","bottom","block"]),K=e=>e.replace(/\/\*[\s\S]*?\*\//g,""),N=e=>{const t=e.toLowerCase();if(!t||xe.has(t)||t.startsWith("-"))return!1;const s=/^\+?(\d*\.?\d+)[a-z%]*$/.exec(t);return s?Number.parseFloat(s[1])!==0:!0},ke=e=>{const t=e.split(/\s+/).filter(Boolean);return t.length<2?t:t.length<4?[t[1]]:[t[1],t[3]]},Ae=(e,t)=>{if(e&&ve.has(e))return!1;const s=t.replace(/!\s*important/gi,"").trim();return s?e?s.split(/\s+/).some(N):ke(s).some(N):!1},R=e=>{for(const t of K(e).matchAll(we))if(Ae(t[1],t[2]))return!0;return!1},z=new Set(["blockquote"]),Se=e=>e.replace(/<!--[\s\S]*?-->/g,""),Ee=e=>{const t=[],s=/<([a-zA-Z][\w:-]*)((?:"[^"]*"|'[^']*'|[^>"'])*)>/g,r=/\bstyle\s*=\s*(?:"([^"]*)"|'([^']*)')/gi;for(const[,n,o]of e.matchAll(s))for(const c of o.matchAll(r))t.push({tag:n.toLowerCase(),style:c[1]??c[2]??""});return t},Te=e=>[...K(e).matchAll(/([^{}]*)\{([^{}]*)\}/g)].map(t=>({selector:t[1].trim(),body:t[2]})),Ce=e=>{const t=e.trim().split(/[\s>+~]+/).pop()??"";return(/^[a-zA-Z][\w-]*/.exec(t)?.[0]??"").toLowerCase()},Ne=e=>e.split(",").every(t=>z.has(Ce(t))),Re=e=>{const t=I(e),s=Se(e);if(/\bcellpadding\s*=\s*["']?(?!0["'\s>])\d/i.test(s))return!0;for(const{tag:r,style:n}of Ee(s))if(!z.has(r)&&R(n))return!0;for(const r of t)for(const n of Te(r))if(!Ne(n.selector)&&R(n.body))return!0;return!1},je=["script","iframe","object","embed","form","input","button","textarea","select","meta","link","base"],Le=["onerror","onload","onclick","onmouseover","onmouseout","onfocus","onblur","onsubmit","onkeydown","onkeyup","formaction","xlink:href","data-bind"],Me="data:image/svg+xml,"+encodeURIComponent(`
57
- <svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100">
58
- <rect fill="#f0f0f0" width="100" height="100"/>
59
- <text x="50" y="50" text-anchor="middle" dy=".3em" fill="#999" font-size="12">
60
- Image blocked
61
- </text>
62
- </svg>
63
- `),_e=e=>e.replace(/url\s*\([^)]*\)/gi,"none").replace(/expression\s*\([^)]*\)/gi,"").replace(/-moz-binding\s*:[^;]*/gi,""),Be=e=>e.replace(/@import[^;]*;/gi,"/* @import blocked */").replace(/url\s*\([^)]*\)/gi,"none").replace(/expression\s*\([^)]*\)/gi,"").replace(/-moz-binding\s*:[^;]*/gi,""),$e=(e={})=>{const t=J(),s={FORBID_TAGS:je,FORBID_ATTR:Le,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 c=n.slice(4).replace(/^<|>$/g,""),m=e.resolveCid?.(c);m&&(r.setAttribute("src",m),r.classList.add("inline-content"));return}e.allowExternalImages||(r.setAttribute("data-blocked-src",n),r.setAttribute("src",Me),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",_e(n))}}),t.addHook("uponSanitizeElement",(r,n)=>{if(n.tagName==="style"){const o=r.textContent||"";r.textContent=Be(o)}}),r=>{const n=be(r),o=Re(r),c=t.sanitize(r,s);return{html:`<style>${he()}</style>${c}`,hasAuthorBackground:n,hasAuthorSpacing:o}}},De='"Geist Variable", "Geist", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',A={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)"}},Oe={background:!1,spacing:!1},Ie="16px",Ke=()=>`html{padding:0}body{padding:${Ie};box-sizing:border-box}`,ze=()=>"html{overflow:hidden}body{overflow-x:auto}",Fe=/prefers-color-scheme\s*:\s*dark|color-scheme\s*:\s*[^;}"']*\bdark\b/i,Pe='<meta name="viewport" content="width=device-width, initial-scale=1">',Ue=e=>{const t=e?A.dark:A.light;return`
64
- /* Plain-email base: UI font-stack + theme-aware colors (#424) */
65
- html, body {
66
- font-family: ${De};
67
- font-size: 14px;
68
- line-height: 1.6;
69
- color: ${t.fg};
70
- background-color: ${t.canvas};
71
- margin: 0;
72
- padding: 0;
73
- }
74
- /* Strip author unreadable text colors and element backgrounds, scoped to body
75
- descendants so the themed html/body surface above survives this reset. */
76
- body * {
77
- color: inherit !important;
78
- background-color: transparent !important;
79
- }
80
- a, a:visited {
81
- color: ${t.accent} !important;
82
- text-decoration: underline;
83
- }
84
- `},T="invert(0.92) hue-rotate(180deg)",j=`img,picture,video,svg,canvas,[style*='background-image'],[background]{filter:${T}}`,He=(e,t,s)=>{const r=e?A.dark.canvas:A.light.canvas;return s?e?t?`html,body{margin:0;background-color:${r};color-scheme:dark light}`:`html{margin:0;background-color:#ffffff;filter:${T}}body{margin:0}${j}`:"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:${T}}${j}`:`html,body{margin:0;background-color:${r};color-scheme:light}`},We=(e,t,s,r=Oe)=>{const n=t==="plain"?Ue(s):He(s,Fe.test(e),r.background),o=r.spacing?"":Ke();return`${Pe}<style>${n}</style>${e}<style>${ze()}${o}</style>`},Ge=5e4,Qe="allow-same-origin allow-popups allow-popups-to-escape-sandbox",qe=(e,t,s)=>Math.min(Math.ceil(Math.max(e,t)),s),Ve=new Set(["Enter","Escape","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End"]),Ye=e=>e===" "?!1:e.length===1?!0:Ve.has(e),E=e=>{if(e.metaKey||e.ctrlKey||e.altKey||!Ye(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}))},L=({html:e,variant:t="framed",isDark:s=!1,declares:r,className:n})=>{const o=g.useRef(null),[c,m]=g.useState(0),d=g.useMemo(()=>We(e,t,s,r),[e,t,s,r]);return g.useEffect(()=>{const l=o.current;if(!l)return;const h=()=>{const i=l.contentDocument;if(!i?.body)return;const p=i.documentElement,b=qe(i.body.scrollHeight,p?.scrollHeight??0,Ge);m(w=>w===b?w:b)};let u,f;const y=()=>{h(),u?.disconnect(),u=void 0,f?.removeEventListener("keydown",E),f?.removeEventListener("load",h,!0),f=void 0;const i=l.contentDocument;i?.body&&(u=new ResizeObserver(h),u.observe(i.body),i.documentElement&&u.observe(i.documentElement),i.addEventListener("load",h,!0),i.fonts?.ready.then(h),i.addEventListener("keydown",E),f=i)};return l.addEventListener("load",y),()=>{l.removeEventListener("load",y),f?.removeEventListener("keydown",E),f?.removeEventListener("load",h,!0),u?.disconnect()}},[]),a.jsx("iframe",{ref:o,title:"Email content",sandbox:Qe,srcDoc:d,className:n,style:{width:"100%",border:"none",display:"block",height:c===0?"1px":`${c}px`,colorScheme:"normal"}})},M=()=>a.jsx("p",{className:"text-fg-muted text-sm italic",children:"This message has no body content."}),$t=({className:e,children:t})=>a.jsx("div",{className:k("[&_.message-body-frame]:-mx-2 lg:[&_.message-body-frame]:-mx-4",e),children:t}),Xe=({html:e,text:t,isDark:s=!1,category:r,allowImages:n=!1,resolveCid:o,className:c,renderBlockedNotice:m})=>{const d=g.useMemo(()=>!e||typeof document>"u"?null:$e({allowExternalImages:n,resolveCid:o})(e),[e,n,o]),l=d?.html??null,{framed:h,isPlain:u}=fe(r,d?.hasAuthorBackground??!1),f=g.useMemo(()=>({background:d?.hasAuthorBackground??!1,spacing:d?.hasAuthorSpacing??!1}),[d?.hasAuthorBackground,d?.hasAuthorSpacing]),y=g.useMemo(()=>!l||n?0:(l.match(/data-blocked-src/g)||[]).length,[l,n]);return!l&&!t?a.jsx("div",{className:k("message-body",c),children:a.jsx(M,{})}):a.jsxs("div",{className:k("message-body",c),children:[y>0&&a.jsx("div",{children:m?.(y)}),l?a.jsx("div",{className:"message-body-frame",children:h?a.jsx("div",{className:"w-full max-w-full",children:a.jsx(L,{html:l,variant:"framed",isDark:s,declares:f})}):a.jsx("div",{className:"max-w-full lg:max-w-2xl",children:a.jsx(L,{html:l,variant:u?"plain":"framed",isDark:s,declares:f})})}):t?a.jsx("pre",{className:"email-text whitespace-pre-wrap text-sm leading-relaxed",children:t}):a.jsx(M,{})]})};function Dt({message:e="Select a thread to read",icon:t,showHints:s=!0,className:r}){return a.jsxs("div",{className:k("flex flex-1 flex-col items-center justify-center text-center",r),children:[t??a.jsx(ee,{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(S,{children:"j"})," / ",a.jsx(S,{children:"k"})," to move, ",a.jsx(S,{children:"Enter"})," to open"]})]})}function F(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 Ze=e=>{if(!e.startsWith('"'))return e;const t=e.slice(1);return t.endsWith('"')?t.slice(0,-1):t};function Je(e){const t=e.indexOf(":");if(t<=0)return;const s=e.slice(t+1);return{name:e.slice(0,t).toLowerCase(),value:Ze(s),rawValue:s}}const et=e=>/[\s"]/.test(e),tt=e=>et(e)?`"${e.replace(/"/g,"")}"`:e,Ot=(e,t)=>`${e}:${tt(t)}`,st=e=>{const t=e.filter(n=>!n.isMultipart&&n.disposition!=="attachment"&&n.mediaType==="TEXT"&&n.contentUrl.length>0),s=t.find(n=>n.mediaSubtype.toUpperCase()==="HTML");if(s)return{kind:"html",contentUrl:s.contentUrl};const r=t.find(n=>n.mediaSubtype.toUpperCase()==="PLAIN");return r?{kind:"text",contentUrl:r.contentUrl}:null},C={all:["messages"],detail:e=>[...C.all,"detail",e],body:e=>[...C.detail(e),"body"]};class x extends Error{reason;status;retryAfterSeconds;constructor(t,s,r,n){super(s),this.name="BodyFetchError",this.reason=t,this.status=r,this.retryAfterSeconds=n}}const rt=e=>{const t=Number.parseInt(e??"",10);return!Number.isFinite(t)||t<=0?1:Math.min(t,30)},nt=8,at="x-remit-403-reason",ot=(e,t)=>{const s=t?.trim()??"";return e===401?"auth":e===403?s.length>0?"auth":"body-missing":e===404?"body-missing":"generic"},it=(e,t)=>(t??"").toLowerCase().startsWith("text/html")?/<div\s+id=["']root["']/i.test(e):!1,ct=(e,t)=>{const s=(t??"").toLowerCase();return!!(e==="text"&&s.startsWith("text/html"))},lt=async(e,t,s=async()=>null)=>{const r={},n=await s();n&&(r.Authorization=`Bearer ${n}`);const o=await re(e,{headers:r});if(o.status===202)throw new x("not-ready","Message body is still syncing",202,rt(o.headers.get("Retry-After")));if(!o.ok){const d=o.headers.get(at),l=ot(o.status,d);throw new x(l,`Failed to load message body (${o.status} ${o.statusText})`,o.status)}const c=o.headers.get("content-type");if(ct(t,c))throw new x("content-type-mismatch",`Refusing to render message body — expected ${t}, got Content-Type ${c}`);const m=await o.text();if(it(m,c))throw new x("spa-shell-leak","Refusing to render message body — response looks like the SPA shell (CloudFront 403/404 fallback leaked through to /content/*)");return m},dt=async(e,t)=>(t.isRetryAfterNotReady&&await e.refetchDescribeMessage(),e.fetchContent(t.contentUrl,t.kind)),ut=({messageId:e,bodyParts:t,enabled:s=!0})=>{const r=t?st(t):null,n=te(),{getToken:o}=B(),c=g.useRef(null),m=$(),d=g.useRef(!1),l=g.useRef(null),h=e&&r?`${e}:${r.contentUrl}`:null;l.current!==h&&(l.current=h,d.current=!1);const u=se({queryKey:e?[...C.body(e),r?.contentUrl??null]:["messages","body","noop"],queryFn:()=>{if(!r)throw new Error("No renderable body part");if(!e)throw new Error("No messageId");const i=d.current;return d.current=!1,dt({fetchContent:(p,b)=>lt(p,b,o),refetchDescribeMessage:()=>m.refetchQueries({queryKey:D({path:{messageId:e}})})},{contentUrl:r.contentUrl,kind:r.kind,isRetryAfterNotReady:i})},enabled:s&&!!e&&!!r,staleTime:300*1e3,gcTime:1800*1e3,retry:(i,p)=>p instanceof x&&p.reason==="not-ready"?i<nt:i<1,retryDelay:(i,p)=>p instanceof x&&p.reason==="not-ready"?(d.current=!0,(p.retryAfterSeconds??1)*1e3):1e3,meta:{softError:!0}}),f=u.isLoading&&!!r;g.useEffect(()=>{f&&(c.current=performance.now())},[f]),g.useEffect(()=>{u.isSuccess&&c.current!==null&&(n.recordTiming("message.body.load",Math.round(performance.now()-c.current)),c.current=null)},[u.isSuccess,n]);const y=u.data&&r?{kind:r.kind,body:u.data}:void 0;return{picked:r,data:y,isLoading:f,isError:u.isError,error:u.error,refetch:u.refetch}},P=(e,t=Date.now())=>({value:e,setAt:t}),mt=(e,t,s,r)=>{if(e.addressId!==t)return e;const n={...e.flags??{}};return s?n.trusted=P(!0,r):delete n.trusted,{...e,flags:n}},ft=(e,t,s,r)=>{const n=o=>o.map(c=>mt(c,t,s,r));return{...e,envelope:{...e.envelope,from:n(e.envelope.from),to:n(e.envelope.to),cc:n(e.envelope.cc),bcc:n(e.envelope.bcc),replyTo:n(e.envelope.replyTo)}}},ht=({messageId:e})=>{const t=$(),{pushError:s}=ne(),{mutate:r,isPending:n,error:o,reset:c}=ae({...ie(),onMutate:async d=>{const l=d.path.addressId,u=d.body.flags?.trusted?.value===!0,f=D({path:{messageId:e}});await t.cancelQueries({queryKey:f});const y=t.getQueriesData({queryKey:f}).filter(i=>i[1]!==void 0).map(([i,p])=>({queryKey:i,data:p}));return t.setQueriesData({queryKey:f},i=>i&&ft(i,l,u)),{describePrefix:f,previous:y}},onError:(d,l,h)=>{if(h)for(const u of h.previous)t.setQueryData(u.queryKey,u.data);s(oe("Couldn't trust sender","The change wasn't saved.",d))},onSettled:(d,l,h,u)=>{u&&t.invalidateQueries({queryKey:u.describePrefix})}});return{toggleTrusted:(d,l)=>{r({path:{addressId:d},body:{flags:{trusted:P(!l)}}})},isPending:n,error:o,reset:c}},gt=()=>{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},pt=({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"})]})]}),yt=(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}}},bt=e=>e instanceof x?e.reason:"generic",xt=e=>e instanceof Error?e.message:typeof e=="string"?e:"An unexpected error occurred while loading the message body.",wt=({error:e,onRetry:t})=>{const s=bt(e),r=xt(e),{title:n,detail:o}=yt(s,r),[c,m]=g.useState(!1),{Account:d}=B();return c?null:a.jsxs("div",{role:"alert","data-testid":"message-body-error-banner","data-reason":s,className:"flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-sm",children:[a.jsx(ce,{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:l})=>a.jsx("button",{type:"button",onClick:()=>l(),className:"text-sm font-medium text-accent hover:underline",children:"Sign in again"})}),t&&a.jsx("button",{type:"button",onClick:t,className:"text-sm font-medium text-accent hover:underline",children:"Retry"}),a.jsx("button",{type:"button",onClick:()=>m(!0),"aria-label":"Dismiss message body error",className:"rounded-md p-1 text-fg-muted hover:bg-surface-raised hover:text-fg transition-colors",children:a.jsx(le,{className:"size-4","aria-hidden":"true"})})]})]})},vt=()=>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"})]}),_=()=>a.jsx("p",{className:"text-fg-muted text-sm italic",children:"This message has no body content."}),It=({bodyParts:e,html:t,text:s,isTrusted:r=!1,messageId:n,fromAddressId:o,category:c,className:m})=>{const[d,l]=g.useState(!1),h=r||d,u=gt(),{toggleTrusted:f,isPending:y}=ht({messageId:n??""}),i=!!e&&e.length>0,{picked:p,data:b,isLoading:w,isError:H,error:W,refetch:G}=ut({messageId:n,bodyParts:e,enabled:i}),Q=g.useMemo(()=>ge(e??[]),[e]),q=i&&b?.kind==="html"?b.body:t,V=i&&b?.kind==="text"?b.body:s;if(i){if(w)return a.jsx("div",{className:v("message-body",m),children:a.jsx(vt,{})});if(H)return a.jsx("div",{className:v("message-body",m),children:a.jsx(wt,{error:W,onRetry:()=>G()})});if(!p)return a.jsx("div",{className:v("message-body",m),children:a.jsx(_,{})})}else if(!t&&!s)return a.jsx("div",{className:v("message-body",m),children:a.jsx(_,{})});const Y=!!(o&&n),X=()=>{!o||y||(l(!0),f(o,!1))};return a.jsx(Xe,{className:m,html:q,text:V,isDark:u,category:c,allowImages:h,resolveCid:Q,renderBlockedNotice:Z=>a.jsx(pt,{blockedImageCount:Z,canAlwaysTrust:Y,isTrustPending:y,onLoadOnce:()=>l(!0),onAlwaysTrust:X})})},U={personal:"Personal",uncategorized:"Unclassified",transactional:"Transactional",newsletter:"Newsletter",marketing:"Marketing",social:"Social",automated:"Automated"},kt=Object.values(O).map(e=>({value:e,label:U[e]})),At={unclassified:"uncategorized"},St=[{name:"from",label:"Sender",values:"contact"},{name:"subject",label:"Subject",values:"text"},{name:"category",label:"Category",values:"fixed",options:kt},{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"}],Et=new Map(St.map(e=>[e.name,e])),Kt=e=>Et.get(e.toLowerCase()),Tt=/^\d{4}-\d{2}-\d{2}$/;function Ct(e,t,s){if(!Tt.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 Nt(e){const t=e.toLowerCase(),s=At[t];return s||Object.values(O).find(n=>n===t)}function Rt(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 jt(e,t){const s=Je(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=Nt(n);return o?{type:"category",raw:e,value:n,category:o}:void 0}case"is":return Rt(e,n);case"has":return n.toLowerCase()==="attachment"?{type:"hasAttachment",raw:e}:void 0;case"before":case"after":return Ct(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 zt(e,t={}){const s=[],r=[];for(const n of F(e)){const o=jt(n.raw,t);o?s.push(o):r.push(n.raw)}return{freeText:r.join(" "),tokens:s}}function Ft(e,t){return F(e).filter(s=>s.raw!==t.raw).map(s=>s.raw).join(" ")}function Pt(e){switch(e.type){case"from":return`From: ${e.value}`;case"subject":return`Subject: ${e.value}`;case"category":return`Category: ${U[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 Ut(){const{mailboxNameIndex:e,accountNameIndex:t}=de();return{...ue({select:r=>me(r.matches)})?{}:{mailboxesByName:e},accountsByName:t}}export{$t as M,Dt as R,St as S,F as a,Je as b,Xe as c,ut as d,ht as e,ot as f,It as g,Pt as h,Kt as i,zt as p,Ft as r,Ot as s,Ut as u};
@@ -1 +0,0 @@
1
- import{s as c,ad as f,x as p,Z as m,r,af as y,ag as T,a1 as x,ah as E}from"./index-BRCDRo29.js";const i={html:"",plainText:""},h=e=>{const u=c(),{pushError:o}=f(),{data:n}=p({...m(),staleTime:1/0}),g=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))}}),l=r.useCallback((t,s)=>{e&&a.mutate({path:{accountId:e},body:{signatureHtml:t,signaturePlainText:s}})},[e,a]);return{signature:g,setSignature:l,isSaving:a.isPending}};export{h as u};