@remit/web-client-dist 0.0.330 → 0.0.331

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 (100) hide show
  1. package/assets/{BriefPane-C1eqvaCk.js → BriefPane-B4OnBw7A.js} +1 -1
  2. package/assets/{ErrorState-Xgz5SZ1i.js → ErrorState-9wFdKXpo.js} +1 -1
  3. package/assets/{FlaggedPane-CHjYkYPa.js → FlaggedPane-VNYPSCvj.js} +1 -1
  4. package/assets/{MailListHeader-XjtEHsNb.js → MailListHeader-CA5lvtZs.js} +8 -8
  5. package/assets/{MailViewChrome-DzdQIg9X.js → MailViewChrome-D-68x2uE.js} +1 -1
  6. package/assets/{MailboxPane-zOiUq9W3.js → MailboxPane-BWOjvlNs.js} +1 -1
  7. package/assets/{NavMenuButton-DoGvk8wx.js → NavMenuButton-cseqHrgr.js} +1 -1
  8. package/assets/{OnboardingWizard-C2iCTPCo.js → OnboardingWizard-DAdN9w-x.js} +1 -1
  9. package/assets/{OutboxPane-CAD8JF4k.js → OutboxPane-VocIZWXW.js} +1 -1
  10. package/assets/_mailboxId-BYy5x0wE.js +1 -0
  11. package/assets/_messageId-0tY_nYQ1.js +1 -0
  12. package/assets/_messageId-C7Dc1hnG.js +1 -0
  13. package/assets/_messageId-C8LAzwtA.js +1 -0
  14. package/assets/_outboxMessageId-BHx_kFyq.js +1 -0
  15. package/assets/_threadId-BpoqHy6Q.js +1 -0
  16. package/assets/_threadId-Dcpkewj-.js +1 -0
  17. package/assets/_threadId-QRWabVsi.js +1 -0
  18. package/assets/{account-form-helpers-Buy_HBYK.js → account-form-helpers-COfJkI9V.js} +1 -1
  19. package/assets/{accounts-BzJANMcx.js → accounts-CZ83UwON.js} +1 -1
  20. package/assets/{advanced-3PVpC1JX.js → advanced-CIk7-tvi.js} +1 -1
  21. package/assets/{appearance-irISnZrI.js → appearance-DamZUddD.js} +1 -1
  22. package/assets/{avatar-sJ32b2ZB.js → avatar-BvDbtKy6.js} +1 -1
  23. package/assets/{bottom-sheet-Du7lm3N2.js → bottom-sheet-0UhJ47Gv.js} +1 -1
  24. package/assets/brief-CAe8f7q6.js +1 -0
  25. package/assets/{brief-qI-Ns5Ua.js → brief-JcrOpUjt.js} +1 -1
  26. package/assets/{browser-ponyfill-IzUT47To.js → browser-ponyfill-CU-pwafu.js} +1 -1
  27. package/assets/{circle-check-B0efcy-K.js → circle-check-Bxbx7HfB.js} +1 -1
  28. package/assets/{circle-check-big-D3RJmZBi.js → circle-check-big-CjzecMB6.js} +1 -1
  29. package/assets/{circle-help-DNaIbW9w.js → circle-help-BK_hzj_i.js} +1 -1
  30. package/assets/{clock-CAIXj_wn.js → clock-B1X_i57Q.js} +1 -1
  31. package/assets/{confirm-dialog-tg4IO863.js → confirm-dialog-Dh8sRH0e.js} +1 -1
  32. package/assets/{download-CZYAEXR3.js → download-CZ0V6I3x.js} +1 -1
  33. package/assets/{filters-D_4-GKkF.js → filters-CdfgcLH2.js} +1 -1
  34. package/assets/flagged-5fgl4f2w.js +1 -0
  35. package/assets/{flagged-Cao7LXlK.js → flagged-DZMd8zSP.js} +1 -1
  36. package/assets/{folders-DdNR5vUs.js → folders-CWWWGsQ5.js} +1 -1
  37. package/assets/index-B3m_6Q-7.js +1 -0
  38. package/assets/index-C7Dc1hnG.js +1 -0
  39. package/assets/index-C8LAzwtA.js +1 -0
  40. package/assets/index-CHntB8XM.js +1 -0
  41. package/assets/index-DIEk2vzA.js +1 -0
  42. package/assets/index-DdWkZUge.js +1 -0
  43. package/assets/index-DgAf2bQz.js +1 -0
  44. package/assets/index-DuJrRaFE.js +1 -0
  45. package/assets/{index-B_E2UDsv.js → index-tka6wZr_.js} +4 -4
  46. package/assets/{kbd-BCoy2IeN.js → kbd-Dt_vzEGr.js} +1 -1
  47. package/assets/{labels-DEWxeP4-.js → labels-DIFvP3py.js} +1 -1
  48. package/assets/{mail-K056GElV.js → mail-O6_yrku3.js} +1 -1
  49. package/assets/{menu-CyQNIqgm.js → menu-DAXEVDbj.js} +1 -1
  50. package/assets/{move-options-BDhHrsb6.js → move-options-MgiRekSU.js} +1 -1
  51. package/assets/{nav-link-D2neGN8U.js → nav-link-CBO_nghm.js} +1 -1
  52. package/assets/{onboarding-gCMR_L2A.js → onboarding-BY09gnzV.js} +1 -1
  53. package/assets/outbox-CvxSD7ed.js +1 -0
  54. package/assets/{pencil-BTDLG6o9.js → pencil-B5Es_aSh.js} +1 -1
  55. package/assets/rich-text-DmHS1zFG.js +29 -0
  56. package/assets/rich-text-spellcheck-words-C1Zx88ZY.js +1 -0
  57. package/assets/rich-text-spellcheck-worker-C399ph5r.js +1 -0
  58. package/assets/rich-text-spellcheck-worker-provider-CYQ5Q4f9.js +1 -0
  59. package/assets/{rotate-ccw-CJ6ZyB3Y.js → rotate-ccw-Bez3srEV.js} +1 -1
  60. package/assets/{row-actions-D5tHz-Kt.js → row-actions-Bqp5HmTh.js} +1 -1
  61. package/assets/{search-scope-5RASGpum.js → search-scope-By6SdCOd.js} +1 -1
  62. package/assets/{search-token-index-C4Fe_kHI.js → search-token-index-Bw0eYLiL.js} +1 -1
  63. package/assets/{search-view-DMyiUtsQ.js → search-view-Cv6MXaNP.js} +1 -1
  64. package/assets/{senders-bpUhaM6M.js → senders-FBv_d32p.js} +1 -1
  65. package/assets/settings-C-JiUEpC.js +1 -0
  66. package/assets/{settings-screen-t6UPYsh-.js → settings-screen-ClWEZnOS.js} +1 -1
  67. package/assets/{shield-check-CdGNmVbB.js → shield-check-C78q6yIg.js} +1 -1
  68. package/assets/{suggested-vips-MyOxkJXk.js → suggested-vips-BFYmT1iv.js} +1 -1
  69. package/assets/{use-match-media-oLZSDQbf.js → use-match-media-BrJFrufZ.js} +1 -1
  70. package/assets/{useDebouncedValue-BFQNA4LE.js → useDebouncedValue-DiRlxnWS.js} +1 -1
  71. package/assets/{useFilters-Ch0Rz-QY.js → useFilters-Cafs9rMu.js} +1 -1
  72. package/assets/{useLabels-C_RuDPDr.js → useLabels-Dg_FXfB1.js} +1 -1
  73. package/assets/{useRefreshControl-B5Wc-mkG.js → useRefreshControl-BHJbdmbT.js} +1 -1
  74. package/assets/{useSearchMirror-4nvtBo0Y.js → useSearchMirror-Df_I-_ih.js} +1 -1
  75. package/assets/{useSearchTokenContext-DFAPyUzs.js → useSearchTokenContext-B60LlfMs.js} +1 -1
  76. package/assets/{useSemanticSearch-DpJZep87.js → useSemanticSearch-ocRX-T7M.js} +1 -1
  77. package/assets/{useSignature-CUY9s-pk.js → useSignature-BboURLQ5.js} +1 -1
  78. package/index.html +1 -1
  79. package/package.json +1 -1
  80. package/assets/_mailboxId-Btckx8tp.js +0 -1
  81. package/assets/_messageId-BDYmbwt3.js +0 -1
  82. package/assets/_messageId-DfrVM9nA.js +0 -1
  83. package/assets/_messageId-Dzj1PERE.js +0 -1
  84. package/assets/_outboxMessageId-DgEN5BZl.js +0 -1
  85. package/assets/_threadId-CR-7fZw6.js +0 -1
  86. package/assets/_threadId-DgpxvW8b.js +0 -1
  87. package/assets/_threadId-WgMhSWLQ.js +0 -1
  88. package/assets/brief-CzT_8oMU.js +0 -1
  89. package/assets/flagged-DgBNfl93.js +0 -1
  90. package/assets/index-BIP9pzjX.js +0 -1
  91. package/assets/index-C7lRyAZj.js +0 -1
  92. package/assets/index-DDYDIsO2.js +0 -1
  93. package/assets/index-DarLHUir.js +0 -1
  94. package/assets/index-DfrVM9nA.js +0 -1
  95. package/assets/index-DgcxbW2K.js +0 -1
  96. package/assets/index-Dzj1PERE.js +0 -1
  97. package/assets/index-T_2lKmJ5.js +0 -1
  98. package/assets/outbox-CyCx1pkU.js +0 -1
  99. package/assets/rich-text-6u8XzJZ0.js +0 -29
  100. package/assets/settings-CVQVSphQ.js +0 -1
@@ -1 +1 @@
1
- import{j as s,b as t}from"./index-B_E2UDsv.js";function x({className:e,...n}){return s.jsx("kbd",{className:t("inline-flex h-4 min-w-4 items-center justify-center rounded-xs border border-line bg-surface-sunken px-1 font-sans text-2xs text-fg-muted",e),...n})}export{x as K};
1
+ import{j as s,b as t}from"./index-tka6wZr_.js";function x({className:e,...n}){return s.jsx("kbd",{className:t("inline-flex h-4 min-w-4 items-center justify-center rounded-xs border border-line bg-surface-sunken px-1 font-sans text-2xs text-fg-muted",e),...n})}export{x as K};
@@ -1 +1 @@
1
- import{r as x,j as e,al as h,aV as y,ak as b,b7 as g,B as v,T as N,p as C,x as L,Z as I,az as D,aD as S,aA as w}from"./index-B_E2UDsv.js";import{C as E}from"./confirm-dialog-tg4IO863.js";import{S as $}from"./settings-screen-t6UPYsh-.js";import{E as j}from"./ErrorState-Xgz5SZ1i.js";import{a as T,b as k,c as R,u as O}from"./useLabels-C_RuDPDr.js";import"./avatar-sJ32b2ZB.js";import"./menu-CyQNIqgm.js";import"./circle-help-DNaIbW9w.js";function B({labels:l,onRename:i,onRecolor:n,onDelete:m,deletingLabelId:c}){const[u,r]=x.useState(),[o,d]=x.useState("");if(l.length===0)return e.jsx("p",{className:"py-6 text-sm text-fg-muted",children:"No labels yet. Create one below, then use it in a filter or apply it to mail directly."});const t=a=>{const s=o.trim();s!==""&&i(a,s),r(void 0)};return e.jsx("ul",{className:"divide-y divide-line rounded-md border border-line",children:l.map(a=>e.jsxs("li",{className:"flex items-center gap-3 px-3 py-2.5",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[u===a.labelId?e.jsx(h,{autoFocus:!0,value:o,onChange:s=>d(s.target.value),onBlur:()=>t(a.labelId),onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),t(a.labelId)),s.key==="Escape"&&(s.preventDefault(),r(void 0))},"aria-label":`Rename label ${a.name}`}):e.jsx("button",{type:"button",onClick:()=>{r(a.labelId),d(a.name)},"aria-label":`Rename label ${a.name}`,className:"flex items-center gap-2 rounded-sm text-left hover:opacity-80",children:e.jsx(y,{label:a})}),e.jsx("p",{className:"mt-0.5 text-xs text-fg-subtle",children:a.filterCount===0?"Not used in any filter":`Used in ${a.filterCount} ${a.filterCount===1?"filter":"filters"}`})]}),e.jsx(b,{"aria-label":`Color for ${a.name}`,value:a.color,onChange:s=>n(a.labelId,s.target.value),className:"w-28 shrink-0",children:g.map(s=>e.jsx("option",{value:s,children:s},s))}),e.jsx(v,{variant:"ghost",size:"sm",icon:e.jsx(N,{className:"size-4 text-danger"}),onClick:()=>m(a),disabled:c===a.labelId,"aria-label":`Delete label ${a.name}`})]},a.labelId))})}const P=(l,i)=>{if(i===0)return{title:`Delete the "${l}" label?`};const n=i===1?"filter":"filters";return{title:`Delete the "${l}" label?`,description:`This also deletes ${i} ${n} that ${i===1?"applies":"apply"} it — they can't be recovered.`}},_=e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{children:"Labels mark mail without moving it — a message can carry any number of them alongside whichever folder it lives in."}),e.jsx("p",{children:"Use a label in a filter's action to have new (and existing) mail label itself automatically, or apply one to a selection directly from the mailbox."}),e.jsx("p",{children:"Deleting a label removes it from every message, and deletes every filter that applies it — the confirmation names how many."})]});function A({accountId:l}){const{createLabel:i,isPending:n,isError:m}=O(l),[c,u]=x.useState(""),[r,o]=x.useState("Default"),d=()=>{const t=c.trim();t!==""&&i(t,r).then(()=>{u(""),o("Default")})};return e.jsxs("div",{className:"space-y-2 rounded-sm border border-line bg-surface p-3",children:[e.jsx("p",{className:"text-sm font-medium text-fg",children:"New label"}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-end",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx("span",{className:"text-xs text-fg-muted",children:"Name"}),e.jsx(h,{value:c,onChange:t=>u(t.target.value),placeholder:"e.g. Receipts","aria-label":"Label name",onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),d())}})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-xs text-fg-muted",children:"Color"}),e.jsx(b,{value:r,onChange:t=>o(t.target.value),"aria-label":"Label color",className:"w-28",children:g.map(t=>e.jsx("option",{value:t,children:t},t))})]}),e.jsx(v,{variant:"primary",onClick:d,disabled:n||c.trim()==="",children:n?"Creating…":"Create label"})]}),m&&e.jsx(w,{tone:"danger",variant:"soft",children:"Couldn't create that label. Please try again."})]})}function H({account:l}){const i=l.accountId,{labels:n,isPending:m,isError:c,error:u,refetch:r}=T(i),{updateLabel:o}=k(i),{deleteLabel:d,deletingLabelId:t}=R(i),[a,s]=x.useState();return e.jsxs("section",{className:"space-y-2",children:[e.jsx("h2",{className:"text-sm font-semibold text-fg",children:l.email}),m?e.jsx("div",{className:"h-16 animate-pulse rounded-md border border-line bg-surface","aria-busy":"true","aria-label":`Loading labels for ${l.email}`}):c?e.jsx(j,{variant:"inline",title:`Couldn't load labels for ${l.email}`,error:u,onRetry:()=>{r()}}):e.jsx(B,{labels:n,onRename:(p,f)=>o(p,{name:f}),onRecolor:(p,f)=>o(p,{color:f}),onDelete:s,deletingLabelId:t}),e.jsx(A,{accountId:i}),a&&(()=>{const p=P(a.name,a.filterCount);return e.jsx(E,{isOpen:!0,title:p.title,description:p.description,confirmLabel:"Delete label",destructive:!0,isBusy:t===a.labelId,onConfirm:()=>{d(a.labelId),s(void 0)},onCancel:()=>s(void 0)})})()]})}function Z(){const l=C(),[i,n]=x.useState(!0),{data:m,isPending:c,isError:u,error:r,refetch:o}=L(I()),d=t=>{const a=S[t];a&&l({to:a})};return e.jsx($,{items:D,activeId:"labels",title:"Labels",description:"Mark mail without moving it, per account.",help:_,helpOpen:i,onToggleHelp:()=>n(t=>!t),onSelect:d,onBackToMail:()=>{l({to:"/mail"})},children:c?e.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":"Loading accounts"}):u?e.jsx(j,{title:"Couldn't load accounts",error:r,onRetry:()=>{o()}}):m.accounts.length===0?e.jsx("p",{className:"py-12 text-sm text-fg-muted",children:"No accounts configured."}):e.jsx("div",{className:"space-y-8",children:m.accounts.map(t=>e.jsx(H,{account:t},t.accountId))})})}export{Z as component};
1
+ import{r as x,j as e,al as h,aV as y,ak as b,b7 as g,B as v,T as N,p as C,x as L,Z as I,az as D,aD as S,aA as w}from"./index-tka6wZr_.js";import{C as E}from"./confirm-dialog-Dh8sRH0e.js";import{S as $}from"./settings-screen-ClWEZnOS.js";import{E as j}from"./ErrorState-9wFdKXpo.js";import{a as T,b as k,c as R,u as O}from"./useLabels-Dg_FXfB1.js";import"./avatar-BvDbtKy6.js";import"./menu-DAXEVDbj.js";import"./circle-help-BK_hzj_i.js";function B({labels:l,onRename:i,onRecolor:n,onDelete:m,deletingLabelId:c}){const[u,r]=x.useState(),[o,d]=x.useState("");if(l.length===0)return e.jsx("p",{className:"py-6 text-sm text-fg-muted",children:"No labels yet. Create one below, then use it in a filter or apply it to mail directly."});const t=a=>{const s=o.trim();s!==""&&i(a,s),r(void 0)};return e.jsx("ul",{className:"divide-y divide-line rounded-md border border-line",children:l.map(a=>e.jsxs("li",{className:"flex items-center gap-3 px-3 py-2.5",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[u===a.labelId?e.jsx(h,{autoFocus:!0,value:o,onChange:s=>d(s.target.value),onBlur:()=>t(a.labelId),onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),t(a.labelId)),s.key==="Escape"&&(s.preventDefault(),r(void 0))},"aria-label":`Rename label ${a.name}`}):e.jsx("button",{type:"button",onClick:()=>{r(a.labelId),d(a.name)},"aria-label":`Rename label ${a.name}`,className:"flex items-center gap-2 rounded-sm text-left hover:opacity-80",children:e.jsx(y,{label:a})}),e.jsx("p",{className:"mt-0.5 text-xs text-fg-subtle",children:a.filterCount===0?"Not used in any filter":`Used in ${a.filterCount} ${a.filterCount===1?"filter":"filters"}`})]}),e.jsx(b,{"aria-label":`Color for ${a.name}`,value:a.color,onChange:s=>n(a.labelId,s.target.value),className:"w-28 shrink-0",children:g.map(s=>e.jsx("option",{value:s,children:s},s))}),e.jsx(v,{variant:"ghost",size:"sm",icon:e.jsx(N,{className:"size-4 text-danger"}),onClick:()=>m(a),disabled:c===a.labelId,"aria-label":`Delete label ${a.name}`})]},a.labelId))})}const P=(l,i)=>{if(i===0)return{title:`Delete the "${l}" label?`};const n=i===1?"filter":"filters";return{title:`Delete the "${l}" label?`,description:`This also deletes ${i} ${n} that ${i===1?"applies":"apply"} it — they can't be recovered.`}},_=e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{children:"Labels mark mail without moving it — a message can carry any number of them alongside whichever folder it lives in."}),e.jsx("p",{children:"Use a label in a filter's action to have new (and existing) mail label itself automatically, or apply one to a selection directly from the mailbox."}),e.jsx("p",{children:"Deleting a label removes it from every message, and deletes every filter that applies it — the confirmation names how many."})]});function A({accountId:l}){const{createLabel:i,isPending:n,isError:m}=O(l),[c,u]=x.useState(""),[r,o]=x.useState("Default"),d=()=>{const t=c.trim();t!==""&&i(t,r).then(()=>{u(""),o("Default")})};return e.jsxs("div",{className:"space-y-2 rounded-sm border border-line bg-surface p-3",children:[e.jsx("p",{className:"text-sm font-medium text-fg",children:"New label"}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-end",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx("span",{className:"text-xs text-fg-muted",children:"Name"}),e.jsx(h,{value:c,onChange:t=>u(t.target.value),placeholder:"e.g. Receipts","aria-label":"Label name",onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),d())}})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-xs text-fg-muted",children:"Color"}),e.jsx(b,{value:r,onChange:t=>o(t.target.value),"aria-label":"Label color",className:"w-28",children:g.map(t=>e.jsx("option",{value:t,children:t},t))})]}),e.jsx(v,{variant:"primary",onClick:d,disabled:n||c.trim()==="",children:n?"Creating…":"Create label"})]}),m&&e.jsx(w,{tone:"danger",variant:"soft",children:"Couldn't create that label. Please try again."})]})}function H({account:l}){const i=l.accountId,{labels:n,isPending:m,isError:c,error:u,refetch:r}=T(i),{updateLabel:o}=k(i),{deleteLabel:d,deletingLabelId:t}=R(i),[a,s]=x.useState();return e.jsxs("section",{className:"space-y-2",children:[e.jsx("h2",{className:"text-sm font-semibold text-fg",children:l.email}),m?e.jsx("div",{className:"h-16 animate-pulse rounded-md border border-line bg-surface","aria-busy":"true","aria-label":`Loading labels for ${l.email}`}):c?e.jsx(j,{variant:"inline",title:`Couldn't load labels for ${l.email}`,error:u,onRetry:()=>{r()}}):e.jsx(B,{labels:n,onRename:(p,f)=>o(p,{name:f}),onRecolor:(p,f)=>o(p,{color:f}),onDelete:s,deletingLabelId:t}),e.jsx(A,{accountId:i}),a&&(()=>{const p=P(a.name,a.filterCount);return e.jsx(E,{isOpen:!0,title:p.title,description:p.description,confirmLabel:"Delete label",destructive:!0,isBusy:t===a.labelId,onConfirm:()=>{d(a.labelId),s(void 0)},onCancel:()=>s(void 0)})})()]})}function Z(){const l=C(),[i,n]=x.useState(!0),{data:m,isPending:c,isError:u,error:r,refetch:o}=L(I()),d=t=>{const a=S[t];a&&l({to:a})};return e.jsx($,{items:D,activeId:"labels",title:"Labels",description:"Mark mail without moving it, per account.",help:_,helpOpen:i,onToggleHelp:()=>n(t=>!t),onSelect:d,onBackToMail:()=>{l({to:"/mail"})},children:c?e.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":"Loading accounts"}):u?e.jsx(j,{title:"Couldn't load accounts",error:r,onRetry:()=>{o()}}):m.accounts.length===0?e.jsx("p",{className:"py-12 text-sm text-fg-muted",children:"No accounts configured."}):e.jsx("div",{className:"space-y-8",children:m.accounts.map(t=>e.jsx(H,{account:t},t.accountId))})})}export{Z as component};
@@ -1 +1 @@
1
- import{c as P,r as i,u as Pe,j as e,S as De,a as pe,b as M,C as ee,d as te,e as Fe,f as ge,F as Te,g as _e,X as be,T as Be,O as Ke,M as Ve,A as qe,h as Qe,I as He,i as ye,B as T,k as U,l as ve,m as $e,n as We,o as je,p as Y,q as Se,s as Ne,t as Ue,v as G,w as J,x as ke,y as Ye,z as Ge,D as Je,E as $,G as Xe,H as Ze,J as et,K as tt,L as st,N as at,P as nt,Q as rt,R as ot,U as it,V as lt,W as ct,Y as ut,Z as dt,_ as mt,$ as xt,a0 as ht}from"./index-B_E2UDsv.js";import{B as ft,S as pt,D as gt,a as bt,b as yt,u as vt,s as jt,K as St,c as Nt,d as kt,e as Ct,f as wt,g as Mt,i as It}from"./search-token-index-C4Fe_kHI.js";import{u as se}from"./search-scope-5RASGpum.js";import{P as Et}from"./pencil-BTDLG6o9.js";import{M as Ot,s as Rt,c as At}from"./search-view-DMyiUtsQ.js";import{u as zt,a as Lt,R as Pt,M as Dt}from"./useRefreshControl-B5Wc-mkG.js";import{M as Ft}from"./menu-CyQNIqgm.js";import{A as Tt}from"./avatar-sJ32b2ZB.js";import{i as _t}from"./outbox-status-CPfNHfUQ.js";import{N as z}from"./nav-link-D2neGN8U.js";import{E as Bt}from"./ErrorState-Xgz5SZ1i.js";import{K as ae}from"./kbd-BCoy2IeN.js";import{u as Kt}from"./useDebouncedValue-BFQNA4LE.js";import{w as ne}from"./intelligence-pref-C6lFpj6U.js";import"./use-match-media-oLZSDQbf.js";import"./layout-breakpoints-BWjiUQKh.js";import"./circle-check-big-D3RJmZBi.js";const Vt=P("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 Ce=P("Bug",[["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}],["path",{d:"M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",key:"xs1cw7"}],["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M17.2 17c2.1.1 3.8 1.9 3.8 4",key:"k3fwyw"}]]);const qt=P("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 we=P("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 Me=P("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 Qt=P("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"}]]),Ht="button:not([disabled]), a[href]",O="outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-surface-sunken";function $t({active:t,dimmed:s,indent:a}){return M("flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-sm transition-colors",O,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:M("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:M("text-2xs tabular-nums",n?"text-accent-2":"text-fg-subtle"),children:a})]})}function L({icon:t,label:s,count:a,active:n,dimmed:r,indent:o,navId:l,linkComponent:m,ariaLabel:x,title:p,onClick:b}){const u=$t({active:n,dimmed:r,indent:o}),h=e.jsx(Wt,{icon:t,label:s,count:a,active:n});return l&&m?m({navId:l,className:u,ariaLabel:x??s,title:p,onClick:b,children:h}):e.jsx("button",{type:"button",onClick:b,className:u,"aria-label":x,title:p,children:h})}const re={inbox:0,flagged:1,drafts:2,sent:3,archive:4,all:5,junk:6,trash:7};function Ut(t){switch(t){case"inbox":return e.jsx(He,{className:"size-4"});case"flagged":return e.jsx(pe,{className:"size-4"});case"drafts":return e.jsx(Qe,{className:"size-4"});case"sent":return e.jsx(ge,{className:"size-4"});case"archive":return e.jsx(qe,{className:"size-4"});case"all":return e.jsx(Ve,{className:"size-4"});case"junk":return e.jsx(Ke,{className:"size-4"});case"trash":return e.jsx(Be,{className:"size-4"})}}const oe=t=>t.role!=null,H=8,ie="remit.nav.folders.open.",le="remit.nav.account.open.";function ce(t,s,a){if(typeof localStorage>"u")return a;const n=localStorage.getItem(t+s);return n===null?a:n!=="0"}function ue(t,s,a){typeof localStorage>"u"||localStorage.setItem(t+s,a?"1":"0")}function Yt({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:M("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",O),children:[e.jsx(_e,{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:M("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",O),children:e.jsx(be,{className:"size-3.5"})})]})}function Gt({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:M("flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-sm text-accent transition-colors hover:bg-surface",O),children:[e.jsx(Vt,{className:"size-4 shrink-0"}),e.jsxs("span",{className:"min-w-0 flex-1 truncate",children:["Save “",s,"”"]})]}),t.map(o=>e.jsx(Yt,{query:o,onSelect:()=>a?.(o),onRemove:n?()=>n(o):void 0},o))]})}function Jt({account:t,selectedNavId:s,onSelectNav:a,linkComponent:n}){const[r,o]=i.useState(()=>ce(le,t.id,!0)),[l,m]=i.useState(()=>ce(ie,t.id,!0)),[x,p]=i.useState(!1),b=()=>{o(c=>{const v=!c;return ue(le,t.id,v),v})},u=()=>{m(c=>{const v=!c;return ue(ie,t.id,v),v})},h=t.mailboxes.filter(oe).sort((c,v)=>re[c.role]-re[v.role]),f=t.mailboxes.filter(c=>!oe(c)),y=x||f.length<=H?f:f.slice(0,H),S=f.length-y.length,g=t.status??"ready",R=g==="ready"&&h.length===0&&f.length===0;return e.jsxs("div",{className:"mt-3",children:[e.jsxs("button",{type:"button",onClick:b,"aria-expanded":r,className:M("flex w-full items-center gap-1.5 px-2 pb-1 text-left transition-colors hover:text-fg",O,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(ft,{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:[g==="loading"&&e.jsx("div",{className:"px-2 py-1 text-sm text-fg-muted",children:"Loading…"}),g==="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(Fe,{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"})]}),R&&e.jsx("div",{className:"px-2 py-1 text-sm text-fg-muted",children:"No mailboxes"}),g==="ready"&&e.jsxs(e.Fragment,{children:[h.map(c=>e.jsx(L,{navId:c.id,linkComponent:n,icon:Ut(c.role),label:c.name,ariaLabel:c.name,title:c.fullPath??c.name,count:c.unseen,active:s===c.id,dimmed:t.muted,onClick:()=>a?.(c.id)},c.id)),t.outboxPending!==void 0&&e.jsx(L,{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")}),f.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:u,"aria-expanded":l,className:M("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",O),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:f.length})]}),l&&e.jsxs(e.Fragment,{children:[y.map(c=>e.jsx(L,{navId:c.id,linkComponent:n,icon:e.jsx(Te,{className:"size-4"}),label:c.name,ariaLabel:c.name,title:c.fullPath??c.name,count:c.unseen,active:s===c.id,dimmed:t.muted,onClick:()=>a?.(c.id)},c.id)),(S>0||x)&&f.length>H&&e.jsx("button",{type:"button",onClick:()=>p(c=>!c),className:M("ml-7 flex items-center px-2 py-1 text-2xs font-medium text-accent transition-colors hover:underline",O),children:x?"Show less":`Show all (${f.length})`})]})]})]})]})]})}function Xt({accounts:t,selectedNavId:s,briefUnseen:a,onSelectNav:n,variant:r="desktop",linkComponent:o,calendarNav:l="hidden",savedSearches:m=[],saveableQuery:x,onSelectSavedSearch:p,onRemoveSavedSearch:b,onSaveCurrentSearch:u}){const h=i.useRef(null);Pe({containerRef:h,itemSelector:Ht});const f=r==="drawer",y=e.jsxs("nav",{ref:f?h:void 0,className:f?"px-2 py-2":"flex-1 overflow-y-auto px-2 py-2","aria-label":"Mailboxes",children:[e.jsx(L,{navId:"brief",linkComponent:o,icon:e.jsx(De,{className:"size-4"}),label:"Daily brief",ariaLabel:"Daily brief",count:a,active:s==="brief",onClick:()=>n?.("brief")}),l==="shown"&&e.jsx(L,{navId:"calendar",linkComponent:o,icon:e.jsx(qt,{className:"size-4"}),label:"Calendar",ariaLabel:"Calendar",active:s==="calendar",onClick:()=>n?.("calendar")}),e.jsx(L,{navId:"flagged",linkComponent:o,icon:e.jsx(pe,{className:"size-4"}),label:"Starred",ariaLabel:"Starred",active:s==="flagged",onClick:()=>n?.("flagged")}),e.jsx(Gt,{savedSearches:m,saveableQuery:x,onSelectSavedSearch:p,onRemoveSavedSearch:b,onSaveCurrentSearch:u}),t.length===0?e.jsx("div",{className:"px-2 py-4 text-center text-sm text-fg-muted",children:"No accounts configured"}):t.map(S=>e.jsx(Jt,{account:S,selectedNavId:s,onSelectNav:n,linkComponent:o},S.id))]});return f?y:e.jsx("aside",{ref:h,className:"flex h-full w-full flex-col bg-surface-sunken",children:y})}function Zt({leading:t,search:s,actions:a,className:n}){return e.jsxs("header",{className:M("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 es(){const t=ye();if(!t)return null;const s=t.showNavPane?!t.navCollapsed:!1;return e.jsx(T,{variant:"ghost",size:"sm",icon:e.jsx(Ft,{className:"size-4"}),onClick:t.toggleNav,"aria-label":s?"Hide folders":"Show folders","aria-expanded":s,title:"Folders",className:"shrink-0"})}const ts={global:"Search all mail",pending:"Search mail",scoped:"Search this folder"};function ss({search:t,onCompose:s,onReportBug:a,onOpenSettings:n,composeShortcut:r,refreshControl:o,account:l}){return e.jsx(Zt,{leading:e.jsx(es,{}),search:e.jsx(pt,{value:t.value,onChange:t.onChange,onClear:t.onClear,onClearQuery:t.onClearQuery,chips:t.chips,onRemoveChip:t.onRemoveChip,placeholder:ts[t.scope]}),actions:e.jsxs(e.Fragment,{children:[e.jsx(T,{variant:"ghost",size:"sm",icon:e.jsx(Qt,{className:"size-4"}),title:r?`Compose (${r})`:"Compose","aria-label":"Compose",onClick:s}),e.jsx(T,{variant:"ghost",size:"sm",icon:e.jsx(Ce,{className:"size-4"}),title:"Report a bug","aria-label":"Report a bug",onClick:a}),e.jsx(T,{variant:"ghost",size:"sm",icon:e.jsx(Me,{className:"size-4"}),title:"Settings","aria-label":"Settings",onClick:n}),o,l]})})}const as=()=>{const{state:t,openCompose:s}=U(),a=ve(),n=i.useCallback(()=>{s({mode:"new"})},[s]),r=$e(a.pathname);return!a.pathname.startsWith("/mail")||t.isOpen||r?null:e.jsx("button",{type:"button",onClick:n,"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"})})},Ie=({children:t})=>{const{Account:s}=We();return e.jsx(s,{children:t})},ns=({email:t,onSignOut:s})=>{const a=t??"Account";return e.jsxs(gt,{trigger:e.jsx(Tt,{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(bt,{})]}),e.jsxs(yt,{onClick:s,children:[e.jsx(we,{className:"size-4"}),"Sign out"]})]})},rs=()=>e.jsx(Ie,{children:({email:t,signOut:s})=>e.jsx(ns,{email:t,onSignOut:s})});function os({accounts:t}){const{searchInput:s,onSearchChange:a,onSearchClear:n,onSearchClearQuery:r}=je(),o=Y(),{openCompose:l}=U(),m=i.useCallback(()=>{l({mode:"new"})},[l]),{scope:x,clearScope:p}=vt(t),b=x.kind==="scoped"?[{id:x.chip.id,label:x.chip.label,tone:"scope"}]:void 0,u=i.useMemo(()=>t.map(g=>g.accountId),[t]),{hasNewMail:h}=zt(),{state:f,errorMessage:y,refresh:S}=Lt(u);return e.jsx(ss,{search:{value:s,scope:x.kind,chips:b,onChange:a,onClear:n,onClearQuery:r,onRemoveChip:p},onCompose:m,onReportBug:Se,onOpenSettings:()=>o({to:"/settings/accounts"}),composeShortcut:jt("compose"),refreshControl:e.jsx(Pt,{state:f,onRefresh:S,label:"Refresh all accounts",errorMessage:y,hasUpdate:h(u)}),account:e.jsx(rs,{})})}const X="remit.savedSearches",is=25;function B(){try{const t=localStorage.getItem(X);if(!t)return[];const s=JSON.parse(t);return Array.isArray(s)?s.filter(a=>typeof a=="string"):[]}catch{return[]}}function ls(t){const s=t.trim();if(!s)return B();const a=[s,...B().filter(n=>n!==s)].slice(0,is);try{localStorage.setItem(X,JSON.stringify(a))}catch{return a}return a}function cs(t){const s=B().filter(a=>a!==t);try{localStorage.setItem(X,JSON.stringify(s))}catch{return s}return s}const de=t=>/^\d/.test(t),us=(t,s)=>{const a=de(t),n=de(s);return a&&!n?-1:!a&&n?1:t.localeCompare(s,void 0,{sensitivity:"base",numeric:!0})};function ds(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)=>us($(o,void 0,a),$(l,void 0,a))),{system:n,labels:r}}function ms(t,s,a){const n=Xe(s)&&t.unseenCount>0;return{id:t.mailboxId,name:$(t,s,a),unseen:n?t.unseenCount:void 0,role:s,fullPath:t.fullPath}}function xs(){const t=ve(),s=Je({strict:!1});return t.pathname.startsWith("/settings")?"settings":t.pathname.startsWith("/mail/outbox")?"outbox":t.pathname.startsWith("/mail/flagged")?"flagged":t.pathname.startsWith("/mail/brief")?"brief":s.mailboxId?s.mailboxId:""}function me({accounts:t,onMailboxSelect:s,variant:a="desktop"}){const n=Ne(),r=Y(),o=xs(),{searchInput:l,onSearchChange:m}=je(),[x,p]=i.useState(B),{t:b}=Ue("mail",{useSuspense:!1}),u=i.useCallback((d,N)=>b(d,{defaultValue:N}),[b]),h=G({queries:t.map(d=>({...J({path:{accountId:d.accountId}}),staleTime:1/0}))}),{data:f}=ke(Ye()),y=i.useMemo(()=>(f?.items??[]).filter(d=>_t(d.status)).length,[f?.items]),S=i.useMemo(()=>t.map((d,N)=>{const k=h[N],I=k?.data?.items??[],w=Ge(d.folderAppointments),{system:E,labels:Q}=ds(I,w,u),C=k?.isError?"error":k?.isLoading?"loading":"ready";return{id:d.accountId,label:d.email,email:d.email,muted:!!d.muted,outboxPending:y,status:C,onRetry:()=>k?.refetch(),mailboxes:[...E,...Q].map(D=>ms(D,w.get(D.mailboxId),u))}}),[t,h,y,u]),g=d=>{n.invalidateQueries({queryKey:Ze({path:{mailboxId:d},query:{order:"desc"}})})},R=({navId:d,className:N,ariaLabel:k,title:I,children:w,onClick:E})=>d==="brief"?e.jsx(z,{to:"/mail/brief",search:{q:void 0},activeOptions:{includeSearch:!1},onClick:()=>E?.(),className:N,"aria-label":k,title:I,children:w}):d==="outbox"?e.jsx(z,{to:"/mail/outbox",search:{q:void 0},onClick:()=>E?.(),className:N,"aria-label":k,title:I,children:w}):d==="flagged"?e.jsx(z,{to:"/mail/flagged",search:{q:void 0},onClick:()=>E?.(),className:N,"aria-label":k,title:I,children:w}):d==="settings"?e.jsx(z,{to:"/settings/accounts",onClick:()=>E?.(),className:N,"aria-label":k,title:I,children:w}):e.jsx(z,{to:"/mail/$mailboxId",params:{mailboxId:d},search:{q:void 0},onClick:()=>{g(d),E?.()},className:N,"aria-label":k,title:I,children:w}),c=()=>{m(""),s?.()},v=l.trim(),A=v.length>0&&!x.includes(v)?v:void 0,K=i.useCallback(()=>{A&&p(ls(A))},[A]),V=i.useCallback(d=>{p(cs(d))},[]),q=i.useCallback(d=>{m(d),r({to:"/mail/brief",search:{q:d}}),s?.()},[m,r,s]);return e.jsx(Xt,{accounts:S,selectedNavId:o,onSelectNav:c,linkComponent:R,variant:a,savedSearches:x,saveableQuery:A,onSaveCurrentSearch:K,onSelectSavedSearch:q,onRemoveSavedSearch:V})}function hs(){return e.jsxs("button",{type:"button",onClick:Se,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(Ce,{className:"size-4 shrink-0"}),e.jsx("span",{className:"flex-1 truncate text-left",children:"Report a bug"})]})}function fs({accounts:t,onMailboxSelect:s}){return ye()?.showNavPane??!0?e.jsx(me,{accounts:t}):e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsx(me,{accounts:t,onMailboxSelect:s,variant:"drawer"})}),e.jsxs("div",{className:"border-t border-line px-2 py-2",children:[e.jsxs(z,{to:"/settings/accounts",onClick:s,children:[e.jsx(Me,{className:"size-4 shrink-0"}),e.jsx("span",{className:"flex-1 truncate text-left",children:"Settings"})]}),e.jsx(hs,{}),e.jsx(Ie,{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(we,{className:"size-4 shrink-0"}),e.jsx("span",{className:"flex-1 truncate text-left",children:"Sign out"})]})})]})]})}const ps=({isOpen:t,onClose:s})=>{const a=i.useCallback(n=>{n.key==="Escape"&&(n.preventDefault(),s())},[s]);return i.useEffect(()=>{if(t)return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[t,a]),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:tt("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:St.map(n=>e.jsxs("div",{children:[e.jsx("h3",{className:"mb-3 text-sm font-medium text-fg-muted",children:n.title}),e.jsx("div",{className:"space-y-2",children:n.hints.map(r=>e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{className:"text-sm",children:r.description}),e.jsx("span",{className:"flex shrink-0 items-center gap-1",children:r.keys.map((o,l)=>e.jsxs(i.Fragment,{children:[l>0&&r.keys[0]==="g"&&e.jsx("span",{className:"text-2xs text-fg-subtle",children:"then"}),e.jsx(ae,{children:o})]},o))})]},`${r.action}-${r.keys.join("+")}`))})]},n.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 gs(t){const s=G({queries:t.map(a=>({...J({path:{accountId:a.accountId}}),staleTime:1/0}))});return i.useMemo(()=>Nt(s.map(a=>a.data?.items??[])),[s])}const bs=t=>t.map(s=>s.data?.items??[]);function ys(t){const s=G({queries:t.map(a=>({...J({path:{accountId:a.accountId}}),staleTime:1/0})),combine:bs});return i.useMemo(()=>st(t.map((a,n)=>({folderAppointments:a.folderAppointments,mailboxes:s[n]??[]}))),[t,s])}var F={exports:{}},xe;function vs(){if(xe)return F.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 m=[],x=s[Symbol.iterator]();let p=!1,b=!1,u=0,h=0;const f=()=>{if(p)return;const y=x.next(),S=h;if(h++,y.done){b=!0,u===0&&r(m);return}u++,Promise.resolve(y.value).then(g=>a(g,S)).then(g=>{m[S]=g,u--,f()},g=>{p=!0,o(g)})};for(let y=0;y<l&&(f(),!b);y++);});return F.exports=t,F.exports.default=t,F.exports}var js=vs();const Ss=at(js),Ns=900*1e3,ks=300,Cs=(t,s)=>{if(!t)return s;const a=Number.parseInt(t,10);return Number.isFinite(a)&&a>0?a:s},ws=60*1e3,Ms=t=>Math.max(Cs(t,ks)*1e3,ws),_=Ms(lt().mailboxPollIntervalSeconds),Is=5,W=new Set,Es=(t,s,a=Ns)=>t.filter(n=>{const r=n.lastSyncAt;return r==null?!0:s-r>a}).map(n=>n.accountId),Os=(t,s,a=_)=>t-s>=a,Rs=(t,s)=>t.filter(a=>!s.has(a)),he=(t,s)=>{if(W.delete(t),ot(s,{softError:!0})){it(s);return}console.warn("[remit] background mailbox sync failed",{accountId:t,error:s})},fe=(t,s)=>nt({path:{accountId:t},throwOnError:!0}).then(()=>{s.invalidateQueries({queryKey:rt({path:{accountId:t}})})}),As=t=>{const s=Ne(),a=i.useRef(t);a.current=t;const n=t.map(r=>r.accountId).join(",");i.useEffect(()=>{const r=Date.now(),l=Es(a.current,r).filter(m=>!W.has(m));if(l.length!==0)for(const m of l)W.add(m),fe(m,s).catch(x=>{he(m,x)})},[n,s]),i.useEffect(()=>{let r=Date.now(),o;const l=new Set,m=()=>{r=Date.now();const b=Rs(a.current.map(u=>u.accountId),l);for(const u of b)l.add(u);Ss(b,u=>fe(u,s).catch(h=>{he(u,h)}).finally(()=>{l.delete(u)}),{concurrency:Is})},x=()=>{if(document.visibilityState==="visible"){m(),o=setTimeout(x,_);return}},p=()=>{document.visibilityState==="visible"&&Os(Date.now(),r)&&(o!==void 0&&clearTimeout(o),m(),o=setTimeout(x,_))};return o=setTimeout(x,_),document.addEventListener("visibilitychange",p),()=>{o!==void 0&&clearTimeout(o),document.removeEventListener("visibilitychange",p)}},[n,s])};function Gs(){const{q:t=""}=ct({from:"/mail"}),s=Y(),a=kt(),n=It(a),[r,o]=i.useState(!1),[l,m]=i.useState(!1),[x,p]=i.useState(!1),b=i.useCallback(j=>{p(j),ne(j)},[]),[u,h]=i.useState(t),f=Kt(u,200),y=At(u,f),S=se({select:j=>j.location.pathname}),g=se({select:j=>ut(j.matches)}),[R,c]=i.useState(g);if(R!==g){const j=Rt(R,g,t);c(g),j!==void 0&&h(j)}const{data:v,isLoading:A,isError:K,error:V,refetch:q}=ke({...dt(),staleTime:1/0}),d=!!(v&&(v.accounts?.length??0)===0);i.useEffect(()=>{d&&s({to:"/onboarding",replace:!0})},[d,s]),Ct({enabled:!r,bindings:[{key:"?",handler:()=>o(!0),noModifiers:!1,preventDefault:!0}]});const{openCompose:N}=U(),k=i.useMemo(()=>({compose:()=>N({mode:"new"})}),[N]);wt({enabled:!mt(S),handlers:k});const I=i.useCallback(j=>{h(j)},[]),w=i.useCallback(()=>{h("")},[]),E=i.useCallback(()=>{h("")},[]),Q=i.useCallback(()=>{p(j=>{const Z=!j;return ne(Z),Z})},[]),C=v?.accounts??[],D=i.useMemo(()=>C.map(j=>j.accountId),[C]),Ee=gs(C),Oe=ys(C),Re=i.useMemo(()=>Mt(C),[C]);As(C);const Ae=i.useCallback(()=>{m(!1)},[]),ze={accounts:C,mailboxNameIndex:Ee,accountNameIndex:Re,resultFolderIndex:Oe,searchQuery:y,searchInput:u,searchViewKey:g,onSearchChange:I,onSearchClear:w,onSearchClearQuery:E,intelligenceOpen:x,onToggleIntelligence:Q,onSetIntelligenceOpen:b},Le={isSinglePane:n,isLoading:A||d,intelligenceOpen:x,nav:e.jsx(fs,{accounts:C,onMailboxSelect:Ae}),topBar:n?void 0:e.jsx(os,{accounts:C}),overlay:n?e.jsx(as,{}):void 0,navOpen:l,onOpenNav:()=>m(!0),onCloseNav:()=>m(!1)};return e.jsx(xt.Provider,{value:ze,children:e.jsxs(Dt,{accountIds:D,children:[K?e.jsx("div",{className:"flex h-full items-center justify-center bg-canvas p-4",children:e.jsx(Bt,{title:"Couldn't load your account",error:V,onRetry:()=>{q()}})}):e.jsx(Ot,{chrome:Le,children:e.jsx(ht,{})}),e.jsx(ps,{isOpen:r,onClose:()=>o(!1)})]})})}export{Gs as component,je as useMailContext};
1
+ import{c as P,r as i,u as Pe,j as e,S as De,a as pe,b as M,C as ee,d as te,e as Fe,f as ge,F as Te,g as _e,X as be,T as Be,O as Ke,M as Ve,A as qe,h as Qe,I as He,i as ye,B as T,k as U,l as ve,m as $e,n as We,o as je,p as Y,q as Se,s as Ne,t as Ue,v as G,w as J,x as ke,y as Ye,z as Ge,D as Je,E as $,G as Xe,H as Ze,J as et,K as tt,L as st,N as at,P as nt,Q as rt,R as ot,U as it,V as lt,W as ct,Y as ut,Z as dt,_ as mt,$ as xt,a0 as ht}from"./index-tka6wZr_.js";import{B as ft,S as pt,D as gt,a as bt,b as yt,u as vt,s as jt,K as St,c as Nt,d as kt,e as Ct,f as wt,g as Mt,i as It}from"./search-token-index-Bw0eYLiL.js";import{u as se}from"./search-scope-By6SdCOd.js";import{P as Et}from"./pencil-B5Es_aSh.js";import{M as Ot,s as Rt,c as At}from"./search-view-Cv6MXaNP.js";import{u as zt,a as Lt,R as Pt,M as Dt}from"./useRefreshControl-BHJbdmbT.js";import{M as Ft}from"./menu-DAXEVDbj.js";import{A as Tt}from"./avatar-BvDbtKy6.js";import{i as _t}from"./outbox-status-CPfNHfUQ.js";import{N as z}from"./nav-link-CBO_nghm.js";import{E as Bt}from"./ErrorState-9wFdKXpo.js";import{K as ae}from"./kbd-Dt_vzEGr.js";import{u as Kt}from"./useDebouncedValue-DiRlxnWS.js";import{w as ne}from"./intelligence-pref-C6lFpj6U.js";import"./use-match-media-BrJFrufZ.js";import"./layout-breakpoints-BWjiUQKh.js";import"./circle-check-big-CjzecMB6.js";const Vt=P("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 Ce=P("Bug",[["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}],["path",{d:"M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",key:"xs1cw7"}],["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M17.2 17c2.1.1 3.8 1.9 3.8 4",key:"k3fwyw"}]]);const qt=P("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 we=P("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 Me=P("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 Qt=P("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"}]]),Ht="button:not([disabled]), a[href]",O="outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-surface-sunken";function $t({active:t,dimmed:s,indent:a}){return M("flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-sm transition-colors",O,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:M("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:M("text-2xs tabular-nums",n?"text-accent-2":"text-fg-subtle"),children:a})]})}function L({icon:t,label:s,count:a,active:n,dimmed:r,indent:o,navId:l,linkComponent:m,ariaLabel:x,title:p,onClick:b}){const u=$t({active:n,dimmed:r,indent:o}),h=e.jsx(Wt,{icon:t,label:s,count:a,active:n});return l&&m?m({navId:l,className:u,ariaLabel:x??s,title:p,onClick:b,children:h}):e.jsx("button",{type:"button",onClick:b,className:u,"aria-label":x,title:p,children:h})}const re={inbox:0,flagged:1,drafts:2,sent:3,archive:4,all:5,junk:6,trash:7};function Ut(t){switch(t){case"inbox":return e.jsx(He,{className:"size-4"});case"flagged":return e.jsx(pe,{className:"size-4"});case"drafts":return e.jsx(Qe,{className:"size-4"});case"sent":return e.jsx(ge,{className:"size-4"});case"archive":return e.jsx(qe,{className:"size-4"});case"all":return e.jsx(Ve,{className:"size-4"});case"junk":return e.jsx(Ke,{className:"size-4"});case"trash":return e.jsx(Be,{className:"size-4"})}}const oe=t=>t.role!=null,H=8,ie="remit.nav.folders.open.",le="remit.nav.account.open.";function ce(t,s,a){if(typeof localStorage>"u")return a;const n=localStorage.getItem(t+s);return n===null?a:n!=="0"}function ue(t,s,a){typeof localStorage>"u"||localStorage.setItem(t+s,a?"1":"0")}function Yt({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:M("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",O),children:[e.jsx(_e,{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:M("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",O),children:e.jsx(be,{className:"size-3.5"})})]})}function Gt({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:M("flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-sm text-accent transition-colors hover:bg-surface",O),children:[e.jsx(Vt,{className:"size-4 shrink-0"}),e.jsxs("span",{className:"min-w-0 flex-1 truncate",children:["Save “",s,"”"]})]}),t.map(o=>e.jsx(Yt,{query:o,onSelect:()=>a?.(o),onRemove:n?()=>n(o):void 0},o))]})}function Jt({account:t,selectedNavId:s,onSelectNav:a,linkComponent:n}){const[r,o]=i.useState(()=>ce(le,t.id,!0)),[l,m]=i.useState(()=>ce(ie,t.id,!0)),[x,p]=i.useState(!1),b=()=>{o(c=>{const v=!c;return ue(le,t.id,v),v})},u=()=>{m(c=>{const v=!c;return ue(ie,t.id,v),v})},h=t.mailboxes.filter(oe).sort((c,v)=>re[c.role]-re[v.role]),f=t.mailboxes.filter(c=>!oe(c)),y=x||f.length<=H?f:f.slice(0,H),S=f.length-y.length,g=t.status??"ready",R=g==="ready"&&h.length===0&&f.length===0;return e.jsxs("div",{className:"mt-3",children:[e.jsxs("button",{type:"button",onClick:b,"aria-expanded":r,className:M("flex w-full items-center gap-1.5 px-2 pb-1 text-left transition-colors hover:text-fg",O,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(ft,{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:[g==="loading"&&e.jsx("div",{className:"px-2 py-1 text-sm text-fg-muted",children:"Loading…"}),g==="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(Fe,{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"})]}),R&&e.jsx("div",{className:"px-2 py-1 text-sm text-fg-muted",children:"No mailboxes"}),g==="ready"&&e.jsxs(e.Fragment,{children:[h.map(c=>e.jsx(L,{navId:c.id,linkComponent:n,icon:Ut(c.role),label:c.name,ariaLabel:c.name,title:c.fullPath??c.name,count:c.unseen,active:s===c.id,dimmed:t.muted,onClick:()=>a?.(c.id)},c.id)),t.outboxPending!==void 0&&e.jsx(L,{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")}),f.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:u,"aria-expanded":l,className:M("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",O),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:f.length})]}),l&&e.jsxs(e.Fragment,{children:[y.map(c=>e.jsx(L,{navId:c.id,linkComponent:n,icon:e.jsx(Te,{className:"size-4"}),label:c.name,ariaLabel:c.name,title:c.fullPath??c.name,count:c.unseen,active:s===c.id,dimmed:t.muted,onClick:()=>a?.(c.id)},c.id)),(S>0||x)&&f.length>H&&e.jsx("button",{type:"button",onClick:()=>p(c=>!c),className:M("ml-7 flex items-center px-2 py-1 text-2xs font-medium text-accent transition-colors hover:underline",O),children:x?"Show less":`Show all (${f.length})`})]})]})]})]})]})}function Xt({accounts:t,selectedNavId:s,briefUnseen:a,onSelectNav:n,variant:r="desktop",linkComponent:o,calendarNav:l="hidden",savedSearches:m=[],saveableQuery:x,onSelectSavedSearch:p,onRemoveSavedSearch:b,onSaveCurrentSearch:u}){const h=i.useRef(null);Pe({containerRef:h,itemSelector:Ht});const f=r==="drawer",y=e.jsxs("nav",{ref:f?h:void 0,className:f?"px-2 py-2":"flex-1 overflow-y-auto px-2 py-2","aria-label":"Mailboxes",children:[e.jsx(L,{navId:"brief",linkComponent:o,icon:e.jsx(De,{className:"size-4"}),label:"Daily brief",ariaLabel:"Daily brief",count:a,active:s==="brief",onClick:()=>n?.("brief")}),l==="shown"&&e.jsx(L,{navId:"calendar",linkComponent:o,icon:e.jsx(qt,{className:"size-4"}),label:"Calendar",ariaLabel:"Calendar",active:s==="calendar",onClick:()=>n?.("calendar")}),e.jsx(L,{navId:"flagged",linkComponent:o,icon:e.jsx(pe,{className:"size-4"}),label:"Starred",ariaLabel:"Starred",active:s==="flagged",onClick:()=>n?.("flagged")}),e.jsx(Gt,{savedSearches:m,saveableQuery:x,onSelectSavedSearch:p,onRemoveSavedSearch:b,onSaveCurrentSearch:u}),t.length===0?e.jsx("div",{className:"px-2 py-4 text-center text-sm text-fg-muted",children:"No accounts configured"}):t.map(S=>e.jsx(Jt,{account:S,selectedNavId:s,onSelectNav:n,linkComponent:o},S.id))]});return f?y:e.jsx("aside",{ref:h,className:"flex h-full w-full flex-col bg-surface-sunken",children:y})}function Zt({leading:t,search:s,actions:a,className:n}){return e.jsxs("header",{className:M("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 es(){const t=ye();if(!t)return null;const s=t.showNavPane?!t.navCollapsed:!1;return e.jsx(T,{variant:"ghost",size:"sm",icon:e.jsx(Ft,{className:"size-4"}),onClick:t.toggleNav,"aria-label":s?"Hide folders":"Show folders","aria-expanded":s,title:"Folders",className:"shrink-0"})}const ts={global:"Search all mail",pending:"Search mail",scoped:"Search this folder"};function ss({search:t,onCompose:s,onReportBug:a,onOpenSettings:n,composeShortcut:r,refreshControl:o,account:l}){return e.jsx(Zt,{leading:e.jsx(es,{}),search:e.jsx(pt,{value:t.value,onChange:t.onChange,onClear:t.onClear,onClearQuery:t.onClearQuery,chips:t.chips,onRemoveChip:t.onRemoveChip,placeholder:ts[t.scope]}),actions:e.jsxs(e.Fragment,{children:[e.jsx(T,{variant:"ghost",size:"sm",icon:e.jsx(Qt,{className:"size-4"}),title:r?`Compose (${r})`:"Compose","aria-label":"Compose",onClick:s}),e.jsx(T,{variant:"ghost",size:"sm",icon:e.jsx(Ce,{className:"size-4"}),title:"Report a bug","aria-label":"Report a bug",onClick:a}),e.jsx(T,{variant:"ghost",size:"sm",icon:e.jsx(Me,{className:"size-4"}),title:"Settings","aria-label":"Settings",onClick:n}),o,l]})})}const as=()=>{const{state:t,openCompose:s}=U(),a=ve(),n=i.useCallback(()=>{s({mode:"new"})},[s]),r=$e(a.pathname);return!a.pathname.startsWith("/mail")||t.isOpen||r?null:e.jsx("button",{type:"button",onClick:n,"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"})})},Ie=({children:t})=>{const{Account:s}=We();return e.jsx(s,{children:t})},ns=({email:t,onSignOut:s})=>{const a=t??"Account";return e.jsxs(gt,{trigger:e.jsx(Tt,{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(bt,{})]}),e.jsxs(yt,{onClick:s,children:[e.jsx(we,{className:"size-4"}),"Sign out"]})]})},rs=()=>e.jsx(Ie,{children:({email:t,signOut:s})=>e.jsx(ns,{email:t,onSignOut:s})});function os({accounts:t}){const{searchInput:s,onSearchChange:a,onSearchClear:n,onSearchClearQuery:r}=je(),o=Y(),{openCompose:l}=U(),m=i.useCallback(()=>{l({mode:"new"})},[l]),{scope:x,clearScope:p}=vt(t),b=x.kind==="scoped"?[{id:x.chip.id,label:x.chip.label,tone:"scope"}]:void 0,u=i.useMemo(()=>t.map(g=>g.accountId),[t]),{hasNewMail:h}=zt(),{state:f,errorMessage:y,refresh:S}=Lt(u);return e.jsx(ss,{search:{value:s,scope:x.kind,chips:b,onChange:a,onClear:n,onClearQuery:r,onRemoveChip:p},onCompose:m,onReportBug:Se,onOpenSettings:()=>o({to:"/settings/accounts"}),composeShortcut:jt("compose"),refreshControl:e.jsx(Pt,{state:f,onRefresh:S,label:"Refresh all accounts",errorMessage:y,hasUpdate:h(u)}),account:e.jsx(rs,{})})}const X="remit.savedSearches",is=25;function B(){try{const t=localStorage.getItem(X);if(!t)return[];const s=JSON.parse(t);return Array.isArray(s)?s.filter(a=>typeof a=="string"):[]}catch{return[]}}function ls(t){const s=t.trim();if(!s)return B();const a=[s,...B().filter(n=>n!==s)].slice(0,is);try{localStorage.setItem(X,JSON.stringify(a))}catch{return a}return a}function cs(t){const s=B().filter(a=>a!==t);try{localStorage.setItem(X,JSON.stringify(s))}catch{return s}return s}const de=t=>/^\d/.test(t),us=(t,s)=>{const a=de(t),n=de(s);return a&&!n?-1:!a&&n?1:t.localeCompare(s,void 0,{sensitivity:"base",numeric:!0})};function ds(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)=>us($(o,void 0,a),$(l,void 0,a))),{system:n,labels:r}}function ms(t,s,a){const n=Xe(s)&&t.unseenCount>0;return{id:t.mailboxId,name:$(t,s,a),unseen:n?t.unseenCount:void 0,role:s,fullPath:t.fullPath}}function xs(){const t=ve(),s=Je({strict:!1});return t.pathname.startsWith("/settings")?"settings":t.pathname.startsWith("/mail/outbox")?"outbox":t.pathname.startsWith("/mail/flagged")?"flagged":t.pathname.startsWith("/mail/brief")?"brief":s.mailboxId?s.mailboxId:""}function me({accounts:t,onMailboxSelect:s,variant:a="desktop"}){const n=Ne(),r=Y(),o=xs(),{searchInput:l,onSearchChange:m}=je(),[x,p]=i.useState(B),{t:b}=Ue("mail",{useSuspense:!1}),u=i.useCallback((d,N)=>b(d,{defaultValue:N}),[b]),h=G({queries:t.map(d=>({...J({path:{accountId:d.accountId}}),staleTime:1/0}))}),{data:f}=ke(Ye()),y=i.useMemo(()=>(f?.items??[]).filter(d=>_t(d.status)).length,[f?.items]),S=i.useMemo(()=>t.map((d,N)=>{const k=h[N],I=k?.data?.items??[],w=Ge(d.folderAppointments),{system:E,labels:Q}=ds(I,w,u),C=k?.isError?"error":k?.isLoading?"loading":"ready";return{id:d.accountId,label:d.email,email:d.email,muted:!!d.muted,outboxPending:y,status:C,onRetry:()=>k?.refetch(),mailboxes:[...E,...Q].map(D=>ms(D,w.get(D.mailboxId),u))}}),[t,h,y,u]),g=d=>{n.invalidateQueries({queryKey:Ze({path:{mailboxId:d},query:{order:"desc"}})})},R=({navId:d,className:N,ariaLabel:k,title:I,children:w,onClick:E})=>d==="brief"?e.jsx(z,{to:"/mail/brief",search:{q:void 0},activeOptions:{includeSearch:!1},onClick:()=>E?.(),className:N,"aria-label":k,title:I,children:w}):d==="outbox"?e.jsx(z,{to:"/mail/outbox",search:{q:void 0},onClick:()=>E?.(),className:N,"aria-label":k,title:I,children:w}):d==="flagged"?e.jsx(z,{to:"/mail/flagged",search:{q:void 0},onClick:()=>E?.(),className:N,"aria-label":k,title:I,children:w}):d==="settings"?e.jsx(z,{to:"/settings/accounts",onClick:()=>E?.(),className:N,"aria-label":k,title:I,children:w}):e.jsx(z,{to:"/mail/$mailboxId",params:{mailboxId:d},search:{q:void 0},onClick:()=>{g(d),E?.()},className:N,"aria-label":k,title:I,children:w}),c=()=>{m(""),s?.()},v=l.trim(),A=v.length>0&&!x.includes(v)?v:void 0,K=i.useCallback(()=>{A&&p(ls(A))},[A]),V=i.useCallback(d=>{p(cs(d))},[]),q=i.useCallback(d=>{m(d),r({to:"/mail/brief",search:{q:d}}),s?.()},[m,r,s]);return e.jsx(Xt,{accounts:S,selectedNavId:o,onSelectNav:c,linkComponent:R,variant:a,savedSearches:x,saveableQuery:A,onSaveCurrentSearch:K,onSelectSavedSearch:q,onRemoveSavedSearch:V})}function hs(){return e.jsxs("button",{type:"button",onClick:Se,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(Ce,{className:"size-4 shrink-0"}),e.jsx("span",{className:"flex-1 truncate text-left",children:"Report a bug"})]})}function fs({accounts:t,onMailboxSelect:s}){return ye()?.showNavPane??!0?e.jsx(me,{accounts:t}):e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsx(me,{accounts:t,onMailboxSelect:s,variant:"drawer"})}),e.jsxs("div",{className:"border-t border-line px-2 py-2",children:[e.jsxs(z,{to:"/settings/accounts",onClick:s,children:[e.jsx(Me,{className:"size-4 shrink-0"}),e.jsx("span",{className:"flex-1 truncate text-left",children:"Settings"})]}),e.jsx(hs,{}),e.jsx(Ie,{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(we,{className:"size-4 shrink-0"}),e.jsx("span",{className:"flex-1 truncate text-left",children:"Sign out"})]})})]})]})}const ps=({isOpen:t,onClose:s})=>{const a=i.useCallback(n=>{n.key==="Escape"&&(n.preventDefault(),s())},[s]);return i.useEffect(()=>{if(t)return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[t,a]),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:tt("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:St.map(n=>e.jsxs("div",{children:[e.jsx("h3",{className:"mb-3 text-sm font-medium text-fg-muted",children:n.title}),e.jsx("div",{className:"space-y-2",children:n.hints.map(r=>e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{className:"text-sm",children:r.description}),e.jsx("span",{className:"flex shrink-0 items-center gap-1",children:r.keys.map((o,l)=>e.jsxs(i.Fragment,{children:[l>0&&r.keys[0]==="g"&&e.jsx("span",{className:"text-2xs text-fg-subtle",children:"then"}),e.jsx(ae,{children:o})]},o))})]},`${r.action}-${r.keys.join("+")}`))})]},n.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 gs(t){const s=G({queries:t.map(a=>({...J({path:{accountId:a.accountId}}),staleTime:1/0}))});return i.useMemo(()=>Nt(s.map(a=>a.data?.items??[])),[s])}const bs=t=>t.map(s=>s.data?.items??[]);function ys(t){const s=G({queries:t.map(a=>({...J({path:{accountId:a.accountId}}),staleTime:1/0})),combine:bs});return i.useMemo(()=>st(t.map((a,n)=>({folderAppointments:a.folderAppointments,mailboxes:s[n]??[]}))),[t,s])}var F={exports:{}},xe;function vs(){if(xe)return F.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 m=[],x=s[Symbol.iterator]();let p=!1,b=!1,u=0,h=0;const f=()=>{if(p)return;const y=x.next(),S=h;if(h++,y.done){b=!0,u===0&&r(m);return}u++,Promise.resolve(y.value).then(g=>a(g,S)).then(g=>{m[S]=g,u--,f()},g=>{p=!0,o(g)})};for(let y=0;y<l&&(f(),!b);y++);});return F.exports=t,F.exports.default=t,F.exports}var js=vs();const Ss=at(js),Ns=900*1e3,ks=300,Cs=(t,s)=>{if(!t)return s;const a=Number.parseInt(t,10);return Number.isFinite(a)&&a>0?a:s},ws=60*1e3,Ms=t=>Math.max(Cs(t,ks)*1e3,ws),_=Ms(lt().mailboxPollIntervalSeconds),Is=5,W=new Set,Es=(t,s,a=Ns)=>t.filter(n=>{const r=n.lastSyncAt;return r==null?!0:s-r>a}).map(n=>n.accountId),Os=(t,s,a=_)=>t-s>=a,Rs=(t,s)=>t.filter(a=>!s.has(a)),he=(t,s)=>{if(W.delete(t),ot(s,{softError:!0})){it(s);return}console.warn("[remit] background mailbox sync failed",{accountId:t,error:s})},fe=(t,s)=>nt({path:{accountId:t},throwOnError:!0}).then(()=>{s.invalidateQueries({queryKey:rt({path:{accountId:t}})})}),As=t=>{const s=Ne(),a=i.useRef(t);a.current=t;const n=t.map(r=>r.accountId).join(",");i.useEffect(()=>{const r=Date.now(),l=Es(a.current,r).filter(m=>!W.has(m));if(l.length!==0)for(const m of l)W.add(m),fe(m,s).catch(x=>{he(m,x)})},[n,s]),i.useEffect(()=>{let r=Date.now(),o;const l=new Set,m=()=>{r=Date.now();const b=Rs(a.current.map(u=>u.accountId),l);for(const u of b)l.add(u);Ss(b,u=>fe(u,s).catch(h=>{he(u,h)}).finally(()=>{l.delete(u)}),{concurrency:Is})},x=()=>{if(document.visibilityState==="visible"){m(),o=setTimeout(x,_);return}},p=()=>{document.visibilityState==="visible"&&Os(Date.now(),r)&&(o!==void 0&&clearTimeout(o),m(),o=setTimeout(x,_))};return o=setTimeout(x,_),document.addEventListener("visibilitychange",p),()=>{o!==void 0&&clearTimeout(o),document.removeEventListener("visibilitychange",p)}},[n,s])};function Gs(){const{q:t=""}=ct({from:"/mail"}),s=Y(),a=kt(),n=It(a),[r,o]=i.useState(!1),[l,m]=i.useState(!1),[x,p]=i.useState(!1),b=i.useCallback(j=>{p(j),ne(j)},[]),[u,h]=i.useState(t),f=Kt(u,200),y=At(u,f),S=se({select:j=>j.location.pathname}),g=se({select:j=>ut(j.matches)}),[R,c]=i.useState(g);if(R!==g){const j=Rt(R,g,t);c(g),j!==void 0&&h(j)}const{data:v,isLoading:A,isError:K,error:V,refetch:q}=ke({...dt(),staleTime:1/0}),d=!!(v&&(v.accounts?.length??0)===0);i.useEffect(()=>{d&&s({to:"/onboarding",replace:!0})},[d,s]),Ct({enabled:!r,bindings:[{key:"?",handler:()=>o(!0),noModifiers:!1,preventDefault:!0}]});const{openCompose:N}=U(),k=i.useMemo(()=>({compose:()=>N({mode:"new"})}),[N]);wt({enabled:!mt(S),handlers:k});const I=i.useCallback(j=>{h(j)},[]),w=i.useCallback(()=>{h("")},[]),E=i.useCallback(()=>{h("")},[]),Q=i.useCallback(()=>{p(j=>{const Z=!j;return ne(Z),Z})},[]),C=v?.accounts??[],D=i.useMemo(()=>C.map(j=>j.accountId),[C]),Ee=gs(C),Oe=ys(C),Re=i.useMemo(()=>Mt(C),[C]);As(C);const Ae=i.useCallback(()=>{m(!1)},[]),ze={accounts:C,mailboxNameIndex:Ee,accountNameIndex:Re,resultFolderIndex:Oe,searchQuery:y,searchInput:u,searchViewKey:g,onSearchChange:I,onSearchClear:w,onSearchClearQuery:E,intelligenceOpen:x,onToggleIntelligence:Q,onSetIntelligenceOpen:b},Le={isSinglePane:n,isLoading:A||d,intelligenceOpen:x,nav:e.jsx(fs,{accounts:C,onMailboxSelect:Ae}),topBar:n?void 0:e.jsx(os,{accounts:C}),overlay:n?e.jsx(as,{}):void 0,navOpen:l,onOpenNav:()=>m(!0),onCloseNav:()=>m(!1)};return e.jsx(xt.Provider,{value:ze,children:e.jsxs(Dt,{accountIds:D,children:[K?e.jsx("div",{className:"flex h-full items-center justify-center bg-canvas p-4",children:e.jsx(Bt,{title:"Couldn't load your account",error:V,onRetry:()=>{q()}})}):e.jsx(Ot,{chrome:Le,children:e.jsx(ht,{})}),e.jsx(ps,{isOpen:r,onClose:()=>o(!1)})]})})}export{Gs as component,je as useMailContext};
@@ -1 +1 @@
1
- import{c as e}from"./index-B_E2UDsv.js";const n=e("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);export{n as M};
1
+ import{c as e}from"./index-tka6wZr_.js";const n=e("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);export{n as M};
@@ -1 +1 @@
1
- import{s as g,x as C,w,af as L,Q as _,cX as A,r as b,cn as x,t as D,z as O,cY as p,E as N}from"./index-B_E2UDsv.js";import{a as I}from"./enums-CCxx0t2v.js";const F=3e4,R=1e3,$="The folder couldn't be created on the mail server. Please try again.",B="The folder was created but the mail server hasn't confirmed it yet, so nothing was attached to it. It's in your folder list — try again in a moment.",Y=(e,t)=>new Promise((a,o)=>{if(t?.aborted){o(t.reason);return}const n=setTimeout(()=>{t?.removeEventListener("abort",r),a()},e),r=()=>{clearTimeout(n),o(t?.reason)};t?.addEventListener("abort",r,{once:!0})});async function k({fetchMailboxes:e,mailboxId:t,signal:a,timeoutMs:o=F,pollIntervalMs:n=R,delay:r=Y,now:l=Date.now}){const s=l()+o;for(;;){a?.throwIfAborted();const c=(await e()).find(u=>u.mailboxId===t);if(c?.syncStatus===I.synced)return c;if(c?.syncStatus===I.failed)throw new Error($);if(l()>=s)throw new Error(B);await r(n,a)}}function S(e,t){const a=e.trim();return t?`${t.fullPath}${t.hierarchyDelimiter}${a}`:a}const P=(e,t)=>{const a=e.split(t);return a[0]?.toLowerCase()==="inbox"&&(a[0]="INBOX"),a.join(t)};function X({name:e,delimiter:t,parent:a,existingPaths:o}){const n=e.trim();if(n==="")return"Enter a folder name.";if(n.includes(t))return`A folder name can't contain "${t}".`;const r=P(S(n,a),t);if(o.some(s=>P(s,t)===r))return"A folder with that name already exists."}function j(e){const t=g(),{data:a}=C({...w({path:{accountId:e??""}}),enabled:!!e}),o=L({...A(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:_({path:{accountId:e}})})}}),n=b.useRef(new Map),r=b.useCallback(async(s,i,c)=>{if(!e)throw new Error("No account to create the folder in. Pick messages from a single account first.");const u=a?.items??[],d=i?u.find(h=>h.fullPath===i):void 0;if(i&&!d)throw new Error(`Couldn't find the folder "${i}" to create this one inside.`);const y=d?{fullPath:d.fullPath,hierarchyDelimiter:d.hierarchyDelimiter}:void 0,f=S(s,y);let m=n.current.get(f);if(!m){const h=y?.hierarchyDelimiter??u[0]?.hierarchyDelimiter??"/",v=X({name:s,delimiter:h,parent:y,existingPaths:u.map(T=>T.fullPath)});if(v)throw new Error(v);m=(await o.mutateAsync({path:{accountId:e},body:{fullPath:f,namespaceType:"personal"}})).mailboxId,n.current.set(f,m)}const M=await k({mailboxId:m,signal:c,fetchMailboxes:async()=>(await t.fetchQuery({...w({path:{accountId:e}}),staleTime:0})).items??[]});return n.current.delete(f),{id:M.mailboxId,label:x(M.fullPath),path:M.fullPath}},[o,e,a,t]);return{createFolder:b.useCallback((s,i)=>r(s,"",i),[r]),createFolderIn:r,mutation:o}}const J=()=>{const{t:e}=D("mail",{useSuspense:!1});return b.useCallback((t,a)=>e(t,{defaultValue:a}),[e])},ee=100,Q=e=>e.trim().toLowerCase()==="inbox",z=(e,t)=>{const a=`${e.fullPath}${e.hierarchyDelimiter}`;return t.some(o=>o.mailboxId!==e.mailboxId&&o.fullPath.startsWith(a))},U=(e,t)=>t.find(a=>a.mailboxId!=null&&a.mailboxId===e)?.role;function te(e,t,a){if(Q(e.fullPath))return{deletable:!1,reason:"inbox",message:"The inbox can't be deleted."};const o=U(e.mailboxId,a);return o?{deletable:!1,reason:"role",message:`This folder is your ${o} folder. Reassign that role before deleting it.`}:z(e,t)?{deletable:!1,reason:"children",message:"This folder has subfolders. Delete them first."}:{deletable:!0}}function V(e,t){return e.filter(a=>a.mailboxId!==t)}function ae(e){return{total:e,moved:0,phase:e===0?"moved":"moving"}}function oe(e,t){if(e.phase!=="moving")return e;const a=Math.min(e.total,e.moved+Math.max(0,t));return{...e,moved:a,phase:a>=e.total?"moved":"moving"}}function ne(e,t){return{...e,phase:"failed",error:t}}function re(e){return`Moved ${e.moved} of ${e.total}`}function ie(e){return e>0?"choose-fate":"confirm-empty"}const q=new Set(["outbox","postvak uit","boîte d'envoi","postausgang","buzón de salida","posta in uscita","送信トレイ","送件匣","发件箱","skrzynka nadawcza"]),G=e=>{const t=x(e.fullPath).trim().toLowerCase();return q.has(t)},E=p.length,K=(e,t)=>{const a=O(t);return[...e.filter(n=>{const r=a.get(n.mailboxId);return r==="drafts"||r==="sent"?!1:!G(n)})].sort((n,r)=>{const l=a.has(n.mailboxId)?p.indexOf(a.get(n.mailboxId)??"inbox"):E,s=a.has(r.mailboxId)?p.indexOf(a.get(r.mailboxId)??"inbox"):E;return l!==s?l-s:x(n.fullPath).localeCompare(x(r.fullPath),void 0,{sensitivity:"base",numeric:!0})})},se=e=>e[0]?.hierarchyDelimiter??"/",le=({mailboxes:e,folderAppointments:t,currentMailboxId:a,excludeMailboxId:o,translator:n})=>{const r=K(e,t),l=O(t);return(o?V(r,o):r).map(i=>({id:i.mailboxId,label:N(i,l.get(i.mailboxId),n),path:i.fullPath,isCurrent:i.mailboxId===a}))};export{ee as M,J as a,le as b,ae as c,ne as d,oe as e,se as f,te as g,ie as i,re as m,j as u};
1
+ import{s as g,x as C,w,af as L,Q as _,cX as A,r as b,cn as x,t as D,z as O,cY as p,E as N}from"./index-tka6wZr_.js";import{a as I}from"./enums-CCxx0t2v.js";const F=3e4,R=1e3,$="The folder couldn't be created on the mail server. Please try again.",B="The folder was created but the mail server hasn't confirmed it yet, so nothing was attached to it. It's in your folder list — try again in a moment.",Y=(e,t)=>new Promise((a,o)=>{if(t?.aborted){o(t.reason);return}const n=setTimeout(()=>{t?.removeEventListener("abort",r),a()},e),r=()=>{clearTimeout(n),o(t?.reason)};t?.addEventListener("abort",r,{once:!0})});async function k({fetchMailboxes:e,mailboxId:t,signal:a,timeoutMs:o=F,pollIntervalMs:n=R,delay:r=Y,now:l=Date.now}){const s=l()+o;for(;;){a?.throwIfAborted();const c=(await e()).find(u=>u.mailboxId===t);if(c?.syncStatus===I.synced)return c;if(c?.syncStatus===I.failed)throw new Error($);if(l()>=s)throw new Error(B);await r(n,a)}}function S(e,t){const a=e.trim();return t?`${t.fullPath}${t.hierarchyDelimiter}${a}`:a}const P=(e,t)=>{const a=e.split(t);return a[0]?.toLowerCase()==="inbox"&&(a[0]="INBOX"),a.join(t)};function X({name:e,delimiter:t,parent:a,existingPaths:o}){const n=e.trim();if(n==="")return"Enter a folder name.";if(n.includes(t))return`A folder name can't contain "${t}".`;const r=P(S(n,a),t);if(o.some(s=>P(s,t)===r))return"A folder with that name already exists."}function j(e){const t=g(),{data:a}=C({...w({path:{accountId:e??""}}),enabled:!!e}),o=L({...A(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:_({path:{accountId:e}})})}}),n=b.useRef(new Map),r=b.useCallback(async(s,i,c)=>{if(!e)throw new Error("No account to create the folder in. Pick messages from a single account first.");const u=a?.items??[],d=i?u.find(h=>h.fullPath===i):void 0;if(i&&!d)throw new Error(`Couldn't find the folder "${i}" to create this one inside.`);const y=d?{fullPath:d.fullPath,hierarchyDelimiter:d.hierarchyDelimiter}:void 0,f=S(s,y);let m=n.current.get(f);if(!m){const h=y?.hierarchyDelimiter??u[0]?.hierarchyDelimiter??"/",v=X({name:s,delimiter:h,parent:y,existingPaths:u.map(T=>T.fullPath)});if(v)throw new Error(v);m=(await o.mutateAsync({path:{accountId:e},body:{fullPath:f,namespaceType:"personal"}})).mailboxId,n.current.set(f,m)}const M=await k({mailboxId:m,signal:c,fetchMailboxes:async()=>(await t.fetchQuery({...w({path:{accountId:e}}),staleTime:0})).items??[]});return n.current.delete(f),{id:M.mailboxId,label:x(M.fullPath),path:M.fullPath}},[o,e,a,t]);return{createFolder:b.useCallback((s,i)=>r(s,"",i),[r]),createFolderIn:r,mutation:o}}const J=()=>{const{t:e}=D("mail",{useSuspense:!1});return b.useCallback((t,a)=>e(t,{defaultValue:a}),[e])},ee=100,Q=e=>e.trim().toLowerCase()==="inbox",z=(e,t)=>{const a=`${e.fullPath}${e.hierarchyDelimiter}`;return t.some(o=>o.mailboxId!==e.mailboxId&&o.fullPath.startsWith(a))},U=(e,t)=>t.find(a=>a.mailboxId!=null&&a.mailboxId===e)?.role;function te(e,t,a){if(Q(e.fullPath))return{deletable:!1,reason:"inbox",message:"The inbox can't be deleted."};const o=U(e.mailboxId,a);return o?{deletable:!1,reason:"role",message:`This folder is your ${o} folder. Reassign that role before deleting it.`}:z(e,t)?{deletable:!1,reason:"children",message:"This folder has subfolders. Delete them first."}:{deletable:!0}}function V(e,t){return e.filter(a=>a.mailboxId!==t)}function ae(e){return{total:e,moved:0,phase:e===0?"moved":"moving"}}function oe(e,t){if(e.phase!=="moving")return e;const a=Math.min(e.total,e.moved+Math.max(0,t));return{...e,moved:a,phase:a>=e.total?"moved":"moving"}}function ne(e,t){return{...e,phase:"failed",error:t}}function re(e){return`Moved ${e.moved} of ${e.total}`}function ie(e){return e>0?"choose-fate":"confirm-empty"}const q=new Set(["outbox","postvak uit","boîte d'envoi","postausgang","buzón de salida","posta in uscita","送信トレイ","送件匣","发件箱","skrzynka nadawcza"]),G=e=>{const t=x(e.fullPath).trim().toLowerCase();return q.has(t)},E=p.length,K=(e,t)=>{const a=O(t);return[...e.filter(n=>{const r=a.get(n.mailboxId);return r==="drafts"||r==="sent"?!1:!G(n)})].sort((n,r)=>{const l=a.has(n.mailboxId)?p.indexOf(a.get(n.mailboxId)??"inbox"):E,s=a.has(r.mailboxId)?p.indexOf(a.get(r.mailboxId)??"inbox"):E;return l!==s?l-s:x(n.fullPath).localeCompare(x(r.fullPath),void 0,{sensitivity:"base",numeric:!0})})},se=e=>e[0]?.hierarchyDelimiter??"/",le=({mailboxes:e,folderAppointments:t,currentMailboxId:a,excludeMailboxId:o,translator:n})=>{const r=K(e,t),l=O(t);return(o?V(r,o):r).map(i=>({id:i.mailboxId,label:N(i,l.get(i.mailboxId),n),path:i.fullPath,isCurrent:i.mailboxId===a}))};export{ee as M,J as a,le as b,ae as c,ne as d,oe as e,se as f,te as g,ie as i,re as m,j as u};
@@ -1 +1 @@
1
- import{cN as s,j as t,cO as a,cP as r}from"./index-B_E2UDsv.js";const c=["intelligence","nav","shortcuts","filters"];s(c);const i=a(r);function u({fragment:n,...e}){return t.jsx(i,{...e,hash:n})}export{u as N};
1
+ import{cN as s,j as t,cO as a,cP as r}from"./index-tka6wZr_.js";const c=["intelligence","nav","shortcuts","filters"];s(c);const i=a(r);function u({fragment:n,...e}){return t.jsx(i,{...e,hash:n})}export{u as N};
@@ -1 +1 @@
1
- import{a1 as t,a2 as r,s as a,r as i,j as s}from"./index-B_E2UDsv.js";import{O as c}from"./OnboardingWizard-C2iCTPCo.js";import"./kbd-BCoy2IeN.js";import"./account-form-helpers-Buy_HBYK.js";async function l(e){e.recordCompleted(),await e.queryClient.refetchQueries({queryKey:t()}),e.navigateToInbox()}function y(){const e=r(),o=a(),n=i.useCallback(m=>{l({queryClient:o,recordCompleted:()=>e.recordEvent("onboarding.completed"),navigateToInbox:()=>{window.location.assign("/mail")}})},[e,o]);return s.jsx(c,{skipWelcome:!1,onComplete:n})}export{y as component};
1
+ import{a1 as t,a2 as r,s as a,r as i,j as s}from"./index-tka6wZr_.js";import{O as c}from"./OnboardingWizard-DAdN9w-x.js";import"./kbd-Dt_vzEGr.js";import"./account-form-helpers-COfJkI9V.js";async function l(e){e.recordCompleted(),await e.queryClient.refetchQueries({queryKey:t()}),e.navigateToInbox()}function y(){const e=r(),o=a(),n=i.useCallback(m=>{l({queryClient:o,recordCompleted:()=>e.recordEvent("onboarding.completed"),navigateToInbox:()=>{window.location.assign("/mail")}})},[e,o]);return s.jsx(c,{skipWelcome:!1,onComplete:n})}export{y as component};
@@ -0,0 +1 @@
1
+ import{D as i,j as o,a0 as s}from"./index-tka6wZr_.js";import{a as m}from"./search-view-Cv6MXaNP.js";import{O as t}from"./OutboxPane-VocIZWXW.js";import{u as a}from"./useSearchMirror-Df_I-_ih.js";import"./nav-link-CBO_nghm.js";import"./useSearchTokenContext-B60LlfMs.js";import"./kbd-Dt_vzEGr.js";import"./use-match-media-BrJFrufZ.js";import"./enums-CCxx0t2v.js";import"./search-scope-By6SdCOd.js";import"./circle-check-big-CjzecMB6.js";import"./clock-B1X_i57Q.js";import"./row-actions-Bqp5HmTh.js";import"./rotate-ccw-Bez3srEV.js";import"./NavMenuButton-cseqHrgr.js";import"./menu-DAXEVDbj.js";import"./format-De9HZKjg.js";import"./outbox-status-CPfNHfUQ.js";import"./search-query-Cr_ZXBCp.js";function e(){return i({from:"/mail/outbox/draft/$outboxMessageId",shouldThrow:!1})?.outboxMessageId}function w(){const r=e();return a({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(s,{})})})}export{w as component};
@@ -1 +1 @@
1
- import{c as a}from"./index-B_E2UDsv.js";const c=a("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);export{c as P};
1
+ import{c as a}from"./index-tka6wZr_.js";const c=a("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);export{c as P};