@remit/web-client-dist 0.0.314 → 0.0.315
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.
- package/assets/BriefPane-UBjV3kAo.js +1 -0
- package/assets/{ErrorState-C50k8wSf.js → ErrorState-bFPcHMNG.js} +1 -1
- package/assets/{FlaggedPane-CKu3JMTH.js → FlaggedPane-T0VjfKl2.js} +1 -1
- package/assets/{MailListHeader-BOSCy5bv.js → MailListHeader-C2XMv19y.js} +8 -8
- package/assets/{MailViewChrome-CBOYFcSh.js → MailViewChrome-C6m_pDnZ.js} +1 -1
- package/assets/MailboxPane-BU8zCLD6.js +1 -0
- package/assets/{NavMenuButton-Dr1eU_Rz.js → NavMenuButton-Bc0ya-6h.js} +1 -1
- package/assets/{OnboardingWizard-d-6RmCTs.js → OnboardingWizard-6m2T8a81.js} +1 -1
- package/assets/{OutboxPane-Bd6n9Se3.js → OutboxPane-B64cQ2E1.js} +1 -1
- package/assets/_mailboxId-DmcIPbDX.js +1 -0
- package/assets/_messageId-DYT-kkKi.js +1 -0
- package/assets/_threadId-CZXedbw1.js +1 -0
- package/assets/{account-form-helpers-BYwQxXgp.js → account-form-helpers-CDUMl54m.js} +1 -1
- package/assets/{accounts-CKtdv_sx.js → accounts-Csv5z9Pb.js} +1 -1
- package/assets/{advanced-UCLNh-a8.js → advanced-BPYBoHzx.js} +1 -1
- package/assets/{appearance-D8oiUKuc.js → appearance-AvqrMQ0z.js} +1 -1
- package/assets/{avatar--BbHXv4F.js → avatar-CkV43qNd.js} +1 -1
- package/assets/{bottom-sheet-B99l3DPu.js → bottom-sheet-CSAuySol.js} +1 -1
- package/assets/{brief-lFn2hucv.js → brief-B292MGUz.js} +1 -1
- package/assets/brief-mpl7lfdv.js +1 -0
- package/assets/{browser-ponyfill-DDcionow.js → browser-ponyfill-EroWIxM4.js} +2 -2
- package/assets/{circle-check-C034sO1l.js → circle-check-C1aqHG_v.js} +1 -1
- package/assets/{circle-check-big-CuTKLMII.js → circle-check-big-CCL6N41e.js} +1 -1
- package/assets/{circle-help-DnuJPeYC.js → circle-help-DBmWdT_j.js} +1 -1
- package/assets/{clock-TTEOnf9z.js → clock-CBOpHqJt.js} +1 -1
- package/assets/{confirm-dialog-Beh3oaKJ.js → confirm-dialog-gTN2dcdp.js} +1 -1
- package/assets/{download-CLl5tpC0.js → download-e6r8RHJO.js} +1 -1
- package/assets/{filters-CpYdw-N_.js → filters-DWPLjAW_.js} +1 -1
- package/assets/flagged-DS5J3piH.js +1 -0
- package/assets/{flagged-Cj99YGuy.js → flagged-DfUTut30.js} +1 -1
- package/assets/{folders-CRpPJQ3Q.js → folders-B5O7MvMk.js} +1 -1
- package/assets/index-BCub0rZ5.js +1 -0
- package/assets/index-COFYryXv.js +1 -0
- package/assets/index-CPWJFJAN.js +1 -0
- package/assets/index-DTjmSgyE.js +1 -0
- package/assets/index-DYT-kkKi.js +1 -0
- package/assets/{index-2IDEAuVk.js → index-DiRuAyHr.js} +59 -59
- package/assets/index-ISnRPeaJ.js +1 -0
- package/assets/{kbd-DChhqIGO.js → kbd-Ck8m_jWP.js} +1 -1
- package/assets/{labels-B_jIpudH.js → labels-gRJasT-_.js} +1 -1
- package/assets/mail-DQ4G6-6G.js +1 -0
- package/assets/{menu-CZ3Yivjh.js → menu-DsDiLJbw.js} +1 -1
- package/assets/{move-options-c2tU4zu_.js → move-options-DxlogUsy.js} +1 -1
- package/assets/{onboarding-DKHiiPaJ.js → onboarding-BPjXE00k.js} +1 -1
- package/assets/outbox-D32D_T_T.js +1 -0
- package/assets/{pencil-DVNcM1UM.js → pencil-BgGG2KqT.js} +1 -1
- package/assets/{rich-text-CBWBuOM1.js → rich-text-ZMeTtbCM.js} +1 -1
- package/assets/{rotate-ccw-BzC7e0ZK.js → rotate-ccw-zMf97sS0.js} +1 -1
- package/assets/{row-actions-CVH5R-3R.js → row-actions-TrSHoo_D.js} +1 -1
- package/assets/search-scope-DJwbffIz.js +1 -0
- package/assets/{search-token-index-CjGaBFWZ.js → search-token-index-cTe1CL2O.js} +1 -1
- package/assets/search-view-D4TA8cJz.js +1 -0
- package/assets/{senders-Cc7nKMMz.js → senders-DhOVgXHi.js} +1 -1
- package/assets/settings-CBI0jIp1.js +1 -0
- package/assets/{settings-screen-BtAttEPX.js → settings-screen-Cyi6AWJq.js} +1 -1
- package/assets/{shield-check-D92P20s8.js → shield-check-D79TXoi7.js} +1 -1
- package/assets/{suggested-vips-CUXCE7hA.js → suggested-vips-MN_YceT0.js} +1 -1
- package/assets/{useDebouncedValue-CjDiLKbc.js → useDebouncedValue-yaYbAyts.js} +1 -1
- package/assets/{useFilters-DkEunDKz.js → useFilters-BEEaWifb.js} +1 -1
- package/assets/{useLabels-GspP5G0M.js → useLabels-CCPzRB-4.js} +1 -1
- package/assets/{useMediaQuery-BisfJ3kn.js → useMediaQuery-BdTbWPMJ.js} +1 -1
- package/assets/{useRefreshControl-DMDgy7HW.js → useRefreshControl-CAZ6vgao.js} +1 -1
- package/assets/useSearchMirror-BlFU9LhB.js +1 -0
- package/assets/{useSearchTokenContext-CO76ckqM.js → useSearchTokenContext-C1W1J3dC.js} +2 -2
- package/assets/useSemanticSearch-D_O-Fl32.js +1 -0
- package/assets/useSignature-DHSw00HY.js +1 -0
- package/index.html +1 -1
- package/package.json +1 -1
- package/assets/BriefPane-a8xrpS_b.js +0 -1
- package/assets/MailboxPane-C6jto7AV.js +0 -1
- package/assets/_mailboxId-B_rMQdOc.js +0 -1
- package/assets/brief-BxT7fAQ3.js +0 -1
- package/assets/conversation-target-Cm8-sdZJ.js +0 -1
- package/assets/flagged-B-psl_QK.js +0 -1
- package/assets/index-BI_C1qQz.js +0 -1
- package/assets/index-BgNzrLG4.js +0 -1
- package/assets/index-C8mdfTeQ.js +0 -1
- package/assets/index-DCsP4GTQ.js +0 -1
- package/assets/index-zDF0J9ig.js +0 -1
- package/assets/mail-CH5cJzvM.js +0 -1
- package/assets/outbox-B2L1G8KM.js +0 -1
- package/assets/search-scope--Ck4E_N-.js +0 -1
- package/assets/search-view-DgVmeGdu.js +0 -1
- package/assets/settings-DMcBwfhg.js +0 -1
- package/assets/useSearchMirror-D0HCJr-S.js +0 -1
- package/assets/useSignature-CvkAmh3B.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as s}from"./index-
|
|
1
|
+
import{r as s}from"./index-DiRuAyHr.js";const r=1024,c=`(min-width: ${r}px) and (not ((orientation: portrait) and (pointer: coarse)))`,d=e=>{const[o,n]=s.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(e).matches);return s.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const t=window.matchMedia(e),a=i=>n(i.matches);return n(t.matches),t.addEventListener("change",a),()=>t.removeEventListener("change",a)},[e]),o},m=()=>d(c);export{c as D,d as a,m as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as
|
|
1
|
+
import{j as E,e as T,b as j,B as D,r as i,t as C,aD as R,q as P,n as K,a0 as Q,P as A,N as $,Q as z,R as B}from"./index-DiRuAyHr.js";import{C as G}from"./circle-check-big-CCL6N41e.js";import{R as H}from"./search-token-index-cTe1CL2O.js";function oe({state:e,onRefresh:t,label:s,errorMessage:a,hasUpdate:n,size:u="sm",className:c}){const o=e==="refreshing",f=e==="error",h=e==="success",g=f?E.jsx(T,{className:"size-4 text-danger"}):h?E.jsx(G,{className:"size-4 text-positive"}):E.jsx(H,{className:j("size-4",o&&"animate-spin")}),y=f?`${s} — failed: ${a??"try again"}`:o?`${s} — refreshing`:h?`${s} — up to date`:n?`${s} — new mail`:s;return E.jsxs("div",{className:"relative inline-flex",children:[E.jsx(D,{variant:"ghost",size:u,icon:g,onClick:t,disabled:o,"aria-label":y,"aria-busy":o||void 0,title:f?a:s,className:c}),e==="idle"&&n&&E.jsx("span",{"aria-hidden":"true",className:"absolute right-1 top-1 size-1.5 rounded-full bg-accent-2"})]})}const U=new Set(["discovering_mailboxes","syncing_inbox","syncing_others"]);function N(e){return!!e&&U.has(e)}const _=3e3,W=_*2,M={syncing:!1,resolved:!1,synced:0,total:0};function ie(e,t){const s=e.join(","),[a,n]=i.useState(!1),[u,c]=i.useState(!1);i.useEffect(()=>{n(!1),c(!1)},[s,t]),i.useEffect(()=>{if(!t)return;const r=setTimeout(()=>c(!0),W);return()=>clearTimeout(r)},[s,t]);const o=C({queries:e.map(r=>({...R({path:{accountId:r}}),enabled:t&&!a,refetchInterval:_,meta:{softError:!0}}))}),f=o.every(r=>r.isSuccess||r.isError),h=o.length===0||f||u;let g=!1,y=0,w=0;for(const r of o)if(N(r.data?.syncPhase)){g=!0;for(const l of r.data?.mailboxes??[])y+=l.messagesSynced,w+=l.messagesTotal}const S=t&&h&&!g;return i.useEffect(()=>{S&&n(!0)},[S]),!t||!h?M:{syncing:g,resolved:!0,synced:y,total:w}}const k=6e4,I=new Set(["sent","drafts","trash","archive"]),v=(e,t)=>{const s=new Map;for(const a of e){const n=t.get(a.mailboxId)?.role;n&&I.has(n)||s.set(a.mailboxId,a.messagesTotal)}return s},X=(e,t)=>{for(const[s,a]of t)if(a>(e.get(s)??0))return!0;return!1},q=i.createContext(null),J=()=>{const e=i.useContext(q);if(!e)throw new Error("useMailFreshness must be used inside <MailFreshnessProvider>");return e};function ce({accountIds:e,children:t}){const s=P(),{resultFolderIndex:a}=K(),n=i.useRef(new Map),u=i.useRef(new Set),[c,o]=i.useState(new Set),f=C({queries:e.map(r=>({...R({path:{accountId:r}}),refetchInterval:k,staleTime:k,meta:{softError:!0}}))}),h=f.map(r=>r.dataUpdatedAt).join(","),g=e.join(",");i.useEffect(()=>{let r=!1;const l=new Set(c);e.forEach((d,x)=>{const p=f[x]?.data;if(!p)return;const m=v(p.mailboxes??[],a);if(!u.current.has(d)){u.current.add(d),n.current.set(d,m);return}if(l.has(d))return;const O=n.current.get(d)??new Map;X(O,m)&&(l.add(d),r=!0)}),r&&o(l)},[g,h]);const y=i.useCallback(r=>r.some(l=>c.has(l)),[c]),w=i.useCallback(r=>{o(l=>{if(r.every(x=>!l.has(x)))return l;const d=new Set(l);for(const x of r)d.delete(x);return d});for(const l of r){const d=s.getQueryData(R({path:{accountId:l}}).queryKey);n.current.set(l,v(d?.mailboxes??[],a)),u.current.add(l)}},[s,a]),S=i.useMemo(()=>({hasNewMail:y,acknowledge:w}),[y,w]);return E.jsx(q.Provider,{value:S,children:t})}const V=2e3,Y=45e3,Z=e=>new Promise(t=>setTimeout(t,e)),b=e=>e instanceof Error&&e.message?e.message:"Something went wrong",ee=e=>{z(e,{softError:!0})&&B(e)},F=e=>e.reduce((t,s)=>Math.max(t,s.lastSyncedAt??0),0),L=(e,t)=>e.fetchQuery({...R({path:{accountId:t}}),staleTime:0}),se=async(e,t,s,a)=>{let n=!1;for(;;){const u=await L(e,t).then(f=>({ok:!0,data:f})).catch(f=>({ok:!1,error:f}));if(!u.ok)return{accountId:t,message:b(u.error)};const{syncPhase:c,mailboxes:o}=u.data;if(N(c))n=!0;else if(n||F(o??[])>s)return c==="error"?{accountId:t,message:"Sync failed for this account"}:void 0;if(Date.now()>=a)return{accountId:t,message:"Refresh is taking longer than usual"};await Z(V)}},te=async(e,t,s,a)=>{const n=await L(e,s).then(o=>({ok:!0,maxLastSynced:F(o.mailboxes??[])})).catch(o=>({ok:!1,error:o}));if(!n.ok)return{accountId:s,enqueued:!1,ok:!1,message:b(n.error)};const u=await $({path:{accountId:s},throwOnError:!0}).then(()=>({ok:!0})).catch(o=>({ok:!1,error:o}));if(!u.ok)return ee(u.error),{accountId:s,enqueued:!1,ok:!1,message:b(u.error)};t.recordEvent("sync.triggered");const c=await se(e,s,n.maxLastSynced,a);return c?{accountId:s,enqueued:!0,ok:!1,message:c.message}:{accountId:s,enqueued:!0,ok:!0}},ue=(e,t={})=>{const s=P(),a=Q(),{acknowledge:n}=J(),[u,c]=i.useState("idle"),[o,f]=i.useState(),h=i.useRef(0),g=i.useRef(e);g.current=e;const y=i.useRef(t);y.current=t,i.useEffect(()=>{if(u!=="success")return;const S=setTimeout(()=>c("idle"),2e3);return()=>clearTimeout(S)},[u]);const w=i.useCallback(()=>{const S=g.current;if(S.length===0){c("error"),f("Nothing to refresh yet");return}const r=++h.current;c("refreshing"),f(void 0),(async()=>{const l=Date.now()+Y,d=await Promise.all(S.map(m=>te(s,a,m,l)));if(h.current!==r)return;const x=d.filter(m=>m.enqueued).map(m=>m.accountId);for(const m of x)s.invalidateQueries({queryKey:A({path:{accountId:m}})});x.length>0&&(y.current.onSettled?.(),n(x));const p=d.filter(m=>!m.ok);p.length===0?c("success"):(c("error"),f(p[0]?.message))})()},[n,s,a]);return{state:u,errorMessage:o,refresh:w}};export{ce as M,oe as R,ue as a,ie as b,N as i,J as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as h,n as y,V as v,r as p}from"./index-DiRuAyHr.js";import{u as x}from"./search-scope-DJwbffIz.js";import{b as I}from"./search-view-D4TA8cJz.js";function q(o){const a=h(),{searchInput:c,searchQuery:e}=y(),{q:i=""}=v({from:"/mail"}),n=x({select:m=>m.location.pathname}),s=p.useRef(i);s.current=i;const{to:r}=o,t="params"in o?o.params.mailboxId:void 0,l=t?`/mail/${t}`:r;p.useEffect(()=>{if(!I({searchInput:c,committedQuery:e,urlQuery:s.current,pathname:n,listPath:l}))return;const d=!!e&&s.current!==e,u=f=>({...f,q:e||void 0,...d?{selectedMessageId:void 0,selectedThreadId:void 0,selectedMailboxId:void 0}:{}});if(!d){a({to:".",search:u,replace:!0});return}if(r==="/mail/$mailboxId"){if(!t)return;a({to:r,params:{mailboxId:t},search:u,replace:!0});return}a({to:r,search:u,replace:!0})},[c,e,a,r,t,l,n])}export{q as u};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{c2 as X,r as f,j as a,b as B,I as Y,a0 as Z,m as P,q as W,w as J,cp as H,co as ee,ab as te,ad as se,ae as re,b8 as ne,e as ae,X as oe,J as C,n as ie}from"./index-DiRuAyHr.js";import{K as L}from"./kbd-Ck8m_jWP.js";import{M as Q}from"./enums-CCxx0t2v.js";import{u as ce,i as le}from"./search-scope-DJwbffIz.js";const de=(e,t)=>{const r=e==="newsletter"||e==="marketing"||t;return{framed:r,isPlain:!r}},ue=()=>`
|
|
2
2
|
/* Zero the UA default body margin and clamp the document to the iframe width so
|
|
3
3
|
wide author markup can't push the body (and the page) past the viewport. */
|
|
4
4
|
html, body {
|
|
@@ -64,4 +64,4 @@ a, a:visited {
|
|
|
64
64
|
color: ${t.accent} !important;
|
|
65
65
|
text-decoration: underline;
|
|
66
66
|
}
|
|
67
|
-
`},Te=(e,t)=>e?t?"html,body{margin:0;color-scheme:dark light}":"html{margin:0;background-color:#ffffff;filter:invert(0.92) hue-rotate(180deg)}body{margin:0}img,picture,video,svg,canvas,[style*='background-image'],[background]{filter:invert(0.92) hue-rotate(180deg)}":"html,body{margin:0;background-color:#ffffff;color-scheme:light}",Ne=(e,t,s)=>{if(t==="plain")return`${O}<style>${Se(s)}</style>${e}`;const r=Ae.test(e);return`${O}<style>${Te(s,r)}</style>${e}`},je=5e4,Re=1e4,Ce="(max-width: 640px)",Me=.4,Le="allow-same-origin allow-popups allow-popups-to-escape-sandbox",I=(e,t,s)=>Math.min(Math.ceil(Math.max(e,t)),s),Be=(e,t)=>e<=0||t<=0||e<=t?1:Math.max(Me,t/e),De=e=>{const[t,s]=f.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(e).matches);return f.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const r=window.matchMedia(e);s(r.matches);const n=o=>s(o.matches);return r.addEventListener("change",n),()=>r.removeEventListener("change",n)},[e]),t},$e=new Set(["Enter","Escape","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End"]),_e=e=>e===" "?!1:e.length===1?!0:$e.has(e),U=e=>{if(e.metaKey||e.ctrlKey||e.altKey||!_e(e.key))return;const t=e.currentTarget??e.target,s=t?.defaultView?.parent;!s||s===t?.defaultView||s.dispatchEvent(new KeyboardEvent("keydown",{key:e.key,code:e.code,shiftKey:e.shiftKey,bubbles:!0,cancelable:!0}))},K=({html:e,variant:t="framed",isDark:s=!1,className:r})=>{const n=f.useRef(null),o=f.useRef(null),[c,m]=f.useState(0),[i,l]=f.useState(0),[p,d]=f.useState(0),g=De(Ce),x=f.useMemo(()=>Ne(e,t,s),[e,t,s]);f.useEffect(()=>{const b=n.current;if(!b)return;const k=()=>d(E=>E===b.clientWidth?E:b.clientWidth);k();const w=new ResizeObserver(k);return w.observe(b),()=>w.disconnect()},[]),f.useEffect(()=>{const b=o.current;if(!b)return;const k=()=>{const y=b.contentDocument;if(!y?.body)return;const j=y.documentElement,R=I(y.body.scrollHeight,j?.scrollHeight??0,je);m(S=>S===R?S:R);const $=I(y.body.scrollWidth,j?.scrollWidth??0,Re);l(S=>S===$?S:$)};let w,E;const N=()=>{k();const y=b.contentDocument;y?.body&&(w=new ResizeObserver(k),w.observe(y.body),y.documentElement&&w.observe(y.documentElement),y.addEventListener("keydown",U),E=y)};return b.addEventListener("load",N),()=>{b.removeEventListener("load",N),E?.removeEventListener("keydown",U),w?.disconnect()}},[]);const u=g?Be(i,p):1,h=u<1,v=h?`${i}px`:g?"100%":t==="framed"&&i>0?`max(100%, ${i}px)`:i===0?"100%":`${i}px`,M=c===0?"1px":`${c}px`,T=a.jsx("iframe",{ref:o,title:"Email content",sandbox:Le,srcDoc:x,className:h?void 0:r,scrolling:"no",style:{width:v,maxWidth:h?"none":void 0,border:"none",display:"block",height:M,overflow:"hidden",transform:h?`scale(${u})`:void 0,transformOrigin:h?"top left":void 0,colorScheme:"normal"}});return a.jsx("div",{ref:n,className:h?r:void 0,children:h?a.jsx("div",{style:{width:"100%",height:`${Math.ceil(c*u)}px`,overflow:"hidden"},children:T}):T})},F=()=>a.jsx("p",{className:"text-fg-muted text-sm italic",children:"This message has no body content."}),Oe=({html:e,text:t,isDark:s=!1,category:r,allowImages:n=!1,resolveCid:o,className:c,renderBlockedNotice:m})=>{const i=f.useMemo(()=>!e||typeof document>"u"?null:ke({allowExternalImages:n,resolveCid:o})(e),[e,n,o]),l=i?.html??null,{framed:p,isPlain:d}=de(r,i?.hasAuthorBackground??!1),g=f.useMemo(()=>!l||n?0:(l.match(/data-blocked-src/g)||[]).length,[l,n]);return!l&&!t?a.jsx("div",{className:B("message-body",c),children:a.jsx(F,{})}):a.jsxs("div",{className:B("message-body",c),children:[g>0&&a.jsx("div",{className:"message-body-notice",children:m?.(g)}),l?p?a.jsx("div",{className:"w-full max-w-full overflow-x-auto",children:a.jsx(K,{html:l,variant:"framed",isDark:s})}):a.jsx("div",{className:"max-w-full overflow-x-auto lg:max-w-2xl",children:a.jsx(K,{html:l,variant:d?"plain":"framed",isDark:s})}):t?a.jsx("pre",{className:"email-text whitespace-pre-wrap text-sm leading-relaxed",children:t}):a.jsx(F,{})]})};function vt({message:e="Select a thread to read",icon:t,showHints:s=!0,className:r}){return a.jsxs("div",{className:B("flex flex-1 flex-col items-center justify-center text-center",r),children:[t??a.jsx(Y,{className:"size-10 text-fg-subtle"}),a.jsx("p",{className:"mt-3 text-sm text-fg-muted",children:e}),s&&a.jsxs("p",{className:"text-2xs text-fg-subtle",children:[a.jsx(L,{children:"j"})," / ",a.jsx(L,{children:"k"})," to move, ",a.jsx(L,{children:"Enter"})," to open"]})]})}function G(e){const t=[];let s=-1,r=!1;for(let n=0;n<e.length;n++){const o=e[n];if(o==='"'){r=!r,s<0&&(s=n);continue}if(!r&&/\s/.test(o)){s>=0&&t.push({raw:e.slice(s,n),start:s,end:n}),s=-1;continue}s<0&&(s=n)}return s>=0&&t.push({raw:e.slice(s),start:s,end:e.length}),t}const Ie=e=>{if(!e.startsWith('"'))return e;const t=e.slice(1);return t.endsWith('"')?t.slice(0,-1):t};function Ue(e){const t=e.indexOf(":");if(t<=0)return;const s=e.slice(t+1);return{name:e.slice(0,t).toLowerCase(),value:Ie(s),rawValue:s}}const Ke=e=>/[\s"]/.test(e),Fe=e=>Ke(e)?`"${e.replace(/"/g,"")}"`:e,kt=(e,t)=>`${e}:${Fe(t)}`,ze=e=>{const t=e.filter(n=>!n.isMultipart&&n.disposition!=="attachment"&&n.mediaType==="TEXT"&&n.contentUrl.length>0),s=t.find(n=>n.mediaSubtype.toUpperCase()==="HTML");if(s)return{kind:"html",contentUrl:s.contentUrl};const r=t.find(n=>n.mediaSubtype.toUpperCase()==="PLAIN");return r?{kind:"text",contentUrl:r.contentUrl}:null},D={all:["messages"],detail:e=>[...D.all,"detail",e],body:e=>[...D.detail(e),"body"]};class A extends Error{reason;status;retryAfterSeconds;constructor(t,s,r,n){super(s),this.name="BodyFetchError",this.reason=t,this.status=r,this.retryAfterSeconds=n}}const Pe=e=>{const t=Number.parseInt(e??"",10);return!Number.isFinite(t)||t<=0?1:Math.min(t,30)},We=8,He="x-remit-403-reason",Qe=(e,t)=>{const s=t?.trim()??"";return e===401?"auth":e===403?s.length>0?"auth":"body-missing":e===404?"body-missing":"generic"},Ge=(e,t)=>(t??"").toLowerCase().startsWith("text/html")?/<div\s+id=["']root["']/i.test(e):!1,qe=(e,t)=>{const s=(t??"").toLowerCase();return!!(e==="text"&&s.startsWith("text/html"))},Ve=async(e,t,s=async()=>null)=>{const r={},n=await s();n&&(r.Authorization=`Bearer ${n}`);const o=await ee(e,{headers:r});if(o.status===202)throw new A("not-ready","Message body is still syncing",202,Pe(o.headers.get("Retry-After")));if(!o.ok){const i=o.headers.get(He),l=Qe(o.status,i);throw new A(l,`Failed to load message body (${o.status} ${o.statusText})`,o.status)}const c=o.headers.get("content-type");if(qe(t,c))throw new A("content-type-mismatch",`Refusing to render message body — expected ${t}, got Content-Type ${c}`);const m=await o.text();if(Ge(m,c))throw new A("spa-shell-leak","Refusing to render message body — response looks like the SPA shell (CloudFront 403/404 fallback leaked through to /content/*)");return m},Xe=async(e,t)=>(t.isRetryAfterNotReady&&await e.refetchDescribeMessage(),e.fetchContent(t.contentUrl,t.kind)),Ye=({messageId:e,bodyParts:t,enabled:s=!0})=>{const r=t?ze(t):null,n=Z(),{getToken:o}=P(),c=f.useRef(null),m=W(),i=f.useRef(!1),l=f.useRef(null),p=e&&r?`${e}:${r.contentUrl}`:null;l.current!==p&&(l.current=p,i.current=!1);const d=J({queryKey:e?[...D.body(e),r?.contentUrl??null]:["messages","body","noop"],queryFn:()=>{if(!r)throw new Error("No renderable body part");if(!e)throw new Error("No messageId");const u=i.current;return i.current=!1,Xe({fetchContent:(h,v)=>Ve(h,v,o),refetchDescribeMessage:()=>m.refetchQueries({queryKey:H({path:{messageId:e}})})},{contentUrl:r.contentUrl,kind:r.kind,isRetryAfterNotReady:u})},enabled:s&&!!e&&!!r,staleTime:300*1e3,gcTime:1800*1e3,retry:(u,h)=>h instanceof A&&h.reason==="not-ready"?u<We:u<1,retryDelay:(u,h)=>h instanceof A&&h.reason==="not-ready"?(i.current=!0,(h.retryAfterSeconds??1)*1e3):1e3,meta:{softError:!0}}),g=d.isLoading&&!!r;f.useEffect(()=>{g&&(c.current=performance.now())},[g]),f.useEffect(()=>{d.isSuccess&&c.current!==null&&(n.recordTiming("message.body.load",Math.round(performance.now()-c.current)),c.current=null)},[d.isSuccess,n]);const x=d.data&&r?{kind:r.kind,body:d.data}:void 0;return{picked:r,data:x,isLoading:g,isError:d.isError,error:d.error,refetch:d.refetch}},q=(e,t=Date.now())=>({value:e,setAt:t}),Ze=(e,t,s,r)=>{if(e.addressId!==t)return e;const n={...e.flags??{}};return s?n.trusted=q(!0,r):delete n.trusted,{...e,flags:n}},Je=(e,t,s,r)=>{const n=o=>o.map(c=>Ze(c,t,s,r));return{...e,envelope:{...e.envelope,from:n(e.envelope.from),to:n(e.envelope.to),cc:n(e.envelope.cc),bcc:n(e.envelope.bcc),replyTo:n(e.envelope.replyTo)}}},et=({messageId:e})=>{const t=W(),{pushError:s}=te(),{mutate:r,isPending:n,error:o,reset:c}=se({...ne(),onMutate:async i=>{const l=i.path.addressId,d=i.body.flags?.trusted?.value===!0,g=H({path:{messageId:e}});await t.cancelQueries({queryKey:g});const x=t.getQueriesData({queryKey:g}).filter(u=>u[1]!==void 0).map(([u,h])=>({queryKey:u,data:h}));return t.setQueriesData({queryKey:g},u=>u&&Je(u,l,d)),{describePrefix:g,previous:x}},onError:(i,l,p)=>{if(p)for(const d of p.previous)t.setQueryData(d.queryKey,d.data);s(re("Couldn't trust sender","The change wasn't saved.",i))},onSettled:(i,l,p,d)=>{d&&t.invalidateQueries({queryKey:d.describePrefix})}});return{toggleTrusted:(i,l)=>{r({path:{addressId:i},body:{flags:{trusted:q(!l)}}})},isPending:n,error:o,reset:c}},tt=()=>{const[e,t]=f.useState(()=>typeof document<"u"&&document.documentElement.classList.contains("dark"));return f.useEffect(()=>{const s=document.documentElement,r=new MutationObserver(()=>{t(s.classList.contains("dark"))});return r.observe(s,{attributes:!0,attributeFilter:["class"]}),()=>r.disconnect()},[]),e},st=({blockedImageCount:e,canAlwaysTrust:t,isTrustPending:s,onLoadOnce:r,onAlwaysTrust:n})=>a.jsxs("div",{className:"mb-3 flex items-center justify-between rounded-md bg-surface-sunken/50 px-3 py-2 text-sm",children:[a.jsxs("span",{className:"text-fg-muted",children:[e," image",e>1?"s":""," blocked for privacy"]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("button",{type:"button",onClick:r,className:"text-accent hover:underline",children:"Load once"}),t&&a.jsx("button",{type:"button",onClick:n,"aria-busy":s,className:"text-accent hover:underline aria-busy:opacity-50",children:s?"Trusting…":"Always trust"})]})]}),rt=(e,t)=>{switch(e){case"auth":return{title:"Your session expired",detail:"Sign in again to reload the message body. Other parts of the app may also stop responding until you do."};case"body-missing":return{title:"Message body is missing in storage",detail:"A sync failure may have left this message without its body bytes. Contact support, or run the reconcile script to refetch from the upstream IMAP server."};case"content-type-mismatch":return{title:"Couldn't load message body",detail:"The server returned an unexpected content type for this part. The message body has not been rendered to keep you safe."};case"spa-shell-leak":return{title:"Couldn't load message body",detail:"The server returned the app shell instead of the message body. This is an infrastructure bug — please report it."};case"not-ready":return{title:"Message body is still syncing",detail:"This message's body hasn't finished downloading from the mail server yet. It should appear shortly — reopen the message to try again."};default:return{title:"Couldn't load message body",detail:t}}},nt=e=>e instanceof A?e.reason:"generic",at=e=>e instanceof Error?e.message:typeof e=="string"?e:"An unexpected error occurred while loading the message body.",ot=({error:e,onRetry:t})=>{const s=nt(e),r=at(e),{title:n,detail:o}=rt(s,r),[c,m]=f.useState(!1),{Account:i}=P();return c?null:a.jsxs("div",{role:"alert","data-testid":"message-body-error-banner","data-reason":s,className:"flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-sm",children:[a.jsx(ae,{className:"size-4 shrink-0 text-danger mt-0.5","aria-hidden":"true"}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"font-medium text-danger",children:n}),a.jsx("p",{className:"text-fg-muted mt-1 break-words",children:o})]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-3",children:[s==="auth"&&a.jsx(i,{children:({signOut:l})=>a.jsx("button",{type:"button",onClick:()=>l(),className:"text-sm font-medium text-accent hover:underline",children:"Sign in again"})}),t&&a.jsx("button",{type:"button",onClick:t,className:"text-sm font-medium text-accent hover:underline",children:"Retry"}),a.jsx("button",{type:"button",onClick:()=>m(!0),"aria-label":"Dismiss message body error",className:"rounded-md p-1 text-fg-muted hover:bg-surface-raised hover:text-fg transition-colors",children:a.jsx(oe,{className:"size-4","aria-hidden":"true"})})]})]})},it=()=>a.jsxs("div",{className:"animate-pulse space-y-2",role:"status","aria-label":"Loading message body",children:[a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-full"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-11/12"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-3/4"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-5/6"})]}),z=()=>a.jsx("p",{className:"text-fg-muted text-sm italic",children:"This message has no body content."}),Et=({bodyParts:e,html:t,text:s,isTrusted:r=!1,messageId:n,fromAddressId:o,category:c,className:m})=>{const[i,l]=f.useState(!1),p=r||i,d=tt(),{toggleTrusted:g,isPending:x}=et({messageId:n??""}),u=!!e&&e.length>0,{picked:h,data:v,isLoading:M,isError:T,error:b,refetch:k}=Ye({messageId:n,bodyParts:e,enabled:u}),w=f.useMemo(()=>fe(e??[]),[e]),E=u&&v?.kind==="html"?v.body:t,N=u&&v?.kind==="text"?v.body:s;if(u){if(M)return a.jsx("div",{className:C("message-body",m),children:a.jsx(it,{})});if(T)return a.jsx("div",{className:C("message-body",m),children:a.jsx(ot,{error:b,onRetry:()=>k()})});if(!h)return a.jsx("div",{className:C("message-body",m),children:a.jsx(z,{})})}else if(!t&&!s)return a.jsx("div",{className:C("message-body",m),children:a.jsx(z,{})});const y=!!(o&&n),j=()=>{!o||x||(l(!0),g(o,!1))};return a.jsx(Oe,{className:m,html:E,text:N,isDark:d,category:c,allowImages:p,resolveCid:w,renderBlockedNotice:R=>a.jsx(st,{blockedImageCount:R,canAlwaysTrust:y,isTrustPending:x,onLoadOnce:()=>l(!0),onAlwaysTrust:j})})},V={personal:"Personal",uncategorized:"Unclassified",transactional:"Transactional",newsletter:"Newsletter",marketing:"Marketing",social:"Social",automated:"Automated"},ct=Object.values(Q).map(e=>({value:e,label:V[e]})),lt={unclassified:"uncategorized"},dt=[{name:"from",label:"Sender",values:"contact"},{name:"subject",label:"Subject",values:"text"},{name:"category",label:"Category",values:"fixed",options:ct},{name:"is",label:"State",values:"fixed",options:[{value:"unread",label:"Unread"},{value:"read",label:"Read"},{value:"starred",label:"Starred"}]},{name:"has",label:"Contents",values:"fixed",options:[{value:"attachment",label:"Has attachment"}]},{name:"in",label:"Folder",values:"mailbox"},{name:"account",label:"Account",values:"account"},{name:"after",label:"Sent on or after",values:"date"},{name:"before",label:"Sent before",values:"date"}],ut=new Map(dt.map(e=>[e.name,e])),At=e=>ut.get(e.toLowerCase()),ft=/^\d{4}-\d{2}-\d{2}$/;function mt(e,t,s){if(!ft.test(s))return;const r=Date.parse(`${s}T00:00:00Z`);if(!Number.isNaN(r))return{type:e,raw:t,value:s,epochSeconds:Math.floor(r/1e3)}}function ht(e){const t=e.toLowerCase(),s=lt[t];return s||Object.values(Q).find(n=>n===t)}function gt(e,t){switch(t.toLowerCase()){case"unread":return{type:"isUnread",raw:e};case"read":return{type:"isRead",raw:e};case"starred":case"flagged":return{type:"isStarred",raw:e};default:return}}function pt(e,t){const s=Ue(e);if(!s||s.value.length===0)return;const{name:r,value:n}=s;switch(r){case"from":return{type:"from",raw:e,value:n};case"subject":return{type:"subject",raw:e,value:n};case"category":{const o=ht(n);return o?{type:"category",raw:e,value:n,category:o}:void 0}case"is":return gt(e,n);case"has":return n.toLowerCase()==="attachment"?{type:"hasAttachment",raw:e}:void 0;case"before":case"after":return mt(r,e,n);case"in":{const o=t.mailboxesByName?.get(n.toLowerCase());return o?{type:"in",raw:e,value:n,mailboxId:o}:void 0}case"account":{const o=t.accountsByName?.get(n.toLowerCase());return o?{type:"account",raw:e,value:n,accountId:o}:void 0}default:return}}function St(e,t={}){const s=[],r=[];for(const n of G(e)){const o=pt(n.raw,t);o?s.push(o):r.push(n.raw)}return{freeText:r.join(" "),tokens:s}}function Tt(e,t){return G(e).filter(s=>s.raw!==t.raw).map(s=>s.raw).join(" ")}function Nt(e){switch(e.type){case"from":return`From: ${e.value}`;case"subject":return`Subject: ${e.value}`;case"category":return`Category: ${V[e.category]}`;case"hasAttachment":return"Has attachment";case"isUnread":return"Unread";case"isRead":return"Read";case"isStarred":return"Starred";case"before":return`Before ${e.value}`;case"after":return`After ${e.value}`;case"in":return`In: ${e.value}`;case"account":return`Account: ${e.value}`}}function jt(){const{mailboxNameIndex:e,accountNameIndex:t}=ie();return{...ce({select:r=>le(r.matches)})?{}:{mailboxesByName:e},accountsByName:t}}export{Oe as M,vt as R,dt as S,G as a,Ue as b,Ye as c,et as d,Qe as e,Et as f,Nt as g,At as h,St as p,Tt as r,kt as s,jt as u};
|
|
67
|
+
`},Te=(e,t)=>e?t?"html,body{margin:0;color-scheme:dark light}":"html{margin:0;background-color:#ffffff;filter:invert(0.92) hue-rotate(180deg)}body{margin:0}img,picture,video,svg,canvas,[style*='background-image'],[background]{filter:invert(0.92) hue-rotate(180deg)}":"html,body{margin:0;background-color:#ffffff;color-scheme:light}",Ne=(e,t,s)=>{if(t==="plain")return`${O}<style>${Se(s)}</style>${e}`;const r=Ae.test(e);return`${O}<style>${Te(s,r)}</style>${e}`},je=5e4,Re=1e4,Ce="(max-width: 640px)",Me=.4,Le="allow-same-origin allow-popups allow-popups-to-escape-sandbox",I=(e,t,s)=>Math.min(Math.ceil(Math.max(e,t)),s),Be=(e,t)=>e<=0||t<=0||e<=t?1:Math.max(Me,t/e),De=e=>{const[t,s]=f.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(e).matches);return f.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const r=window.matchMedia(e);s(r.matches);const n=o=>s(o.matches);return r.addEventListener("change",n),()=>r.removeEventListener("change",n)},[e]),t},$e=new Set(["Enter","Escape","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End"]),_e=e=>e===" "?!1:e.length===1?!0:$e.has(e),U=e=>{if(e.metaKey||e.ctrlKey||e.altKey||!_e(e.key))return;const t=e.currentTarget??e.target,s=t?.defaultView?.parent;!s||s===t?.defaultView||s.dispatchEvent(new KeyboardEvent("keydown",{key:e.key,code:e.code,shiftKey:e.shiftKey,bubbles:!0,cancelable:!0}))},K=({html:e,variant:t="framed",isDark:s=!1,className:r})=>{const n=f.useRef(null),o=f.useRef(null),[c,m]=f.useState(0),[i,l]=f.useState(0),[p,d]=f.useState(0),g=De(Ce),x=f.useMemo(()=>Ne(e,t,s),[e,t,s]);f.useEffect(()=>{const b=n.current;if(!b)return;const k=()=>d(E=>E===b.clientWidth?E:b.clientWidth);k();const w=new ResizeObserver(k);return w.observe(b),()=>w.disconnect()},[]),f.useEffect(()=>{const b=o.current;if(!b)return;const k=()=>{const y=b.contentDocument;if(!y?.body)return;const j=y.documentElement,R=I(y.body.scrollHeight,j?.scrollHeight??0,je);m(S=>S===R?S:R);const $=I(y.body.scrollWidth,j?.scrollWidth??0,Re);l(S=>S===$?S:$)};let w,E;const N=()=>{k();const y=b.contentDocument;y?.body&&(w=new ResizeObserver(k),w.observe(y.body),y.documentElement&&w.observe(y.documentElement),y.addEventListener("keydown",U),E=y)};return b.addEventListener("load",N),()=>{b.removeEventListener("load",N),E?.removeEventListener("keydown",U),w?.disconnect()}},[]);const u=g?Be(i,p):1,h=u<1,v=h?`${i}px`:g?"100%":t==="framed"&&i>0?`max(100%, ${i}px)`:i===0?"100%":`${i}px`,M=c===0?"1px":`${c}px`,T=a.jsx("iframe",{ref:o,title:"Email content",sandbox:Le,srcDoc:x,className:h?void 0:r,scrolling:"no",style:{width:v,maxWidth:h?"none":void 0,border:"none",display:"block",height:M,overflow:"hidden",transform:h?`scale(${u})`:void 0,transformOrigin:h?"top left":void 0,colorScheme:"normal"}});return a.jsx("div",{ref:n,className:h?r:void 0,children:h?a.jsx("div",{style:{width:"100%",height:`${Math.ceil(c*u)}px`,overflow:"hidden"},children:T}):T})},F=()=>a.jsx("p",{className:"text-fg-muted text-sm italic",children:"This message has no body content."}),Oe=({html:e,text:t,isDark:s=!1,category:r,allowImages:n=!1,resolveCid:o,className:c,renderBlockedNotice:m})=>{const i=f.useMemo(()=>!e||typeof document>"u"?null:ke({allowExternalImages:n,resolveCid:o})(e),[e,n,o]),l=i?.html??null,{framed:p,isPlain:d}=de(r,i?.hasAuthorBackground??!1),g=f.useMemo(()=>!l||n?0:(l.match(/data-blocked-src/g)||[]).length,[l,n]);return!l&&!t?a.jsx("div",{className:B("message-body",c),children:a.jsx(F,{})}):a.jsxs("div",{className:B("message-body",c),children:[g>0&&a.jsx("div",{className:"message-body-notice",children:m?.(g)}),l?p?a.jsx("div",{className:"w-full max-w-full overflow-x-auto",children:a.jsx(K,{html:l,variant:"framed",isDark:s})}):a.jsx("div",{className:"max-w-full overflow-x-auto lg:max-w-2xl",children:a.jsx(K,{html:l,variant:d?"plain":"framed",isDark:s})}):t?a.jsx("pre",{className:"email-text whitespace-pre-wrap text-sm leading-relaxed",children:t}):a.jsx(F,{})]})};function vt({message:e="Select a thread to read",icon:t,showHints:s=!0,className:r}){return a.jsxs("div",{className:B("flex flex-1 flex-col items-center justify-center text-center",r),children:[t??a.jsx(Y,{className:"size-10 text-fg-subtle"}),a.jsx("p",{className:"mt-3 text-sm text-fg-muted",children:e}),s&&a.jsxs("p",{className:"text-2xs text-fg-subtle",children:[a.jsx(L,{children:"j"})," / ",a.jsx(L,{children:"k"})," to move, ",a.jsx(L,{children:"Enter"})," to open"]})]})}function G(e){const t=[];let s=-1,r=!1;for(let n=0;n<e.length;n++){const o=e[n];if(o==='"'){r=!r,s<0&&(s=n);continue}if(!r&&/\s/.test(o)){s>=0&&t.push({raw:e.slice(s,n),start:s,end:n}),s=-1;continue}s<0&&(s=n)}return s>=0&&t.push({raw:e.slice(s),start:s,end:e.length}),t}const Ie=e=>{if(!e.startsWith('"'))return e;const t=e.slice(1);return t.endsWith('"')?t.slice(0,-1):t};function Ue(e){const t=e.indexOf(":");if(t<=0)return;const s=e.slice(t+1);return{name:e.slice(0,t).toLowerCase(),value:Ie(s),rawValue:s}}const Ke=e=>/[\s"]/.test(e),Fe=e=>Ke(e)?`"${e.replace(/"/g,"")}"`:e,kt=(e,t)=>`${e}:${Fe(t)}`,ze=e=>{const t=e.filter(n=>!n.isMultipart&&n.disposition!=="attachment"&&n.mediaType==="TEXT"&&n.contentUrl.length>0),s=t.find(n=>n.mediaSubtype.toUpperCase()==="HTML");if(s)return{kind:"html",contentUrl:s.contentUrl};const r=t.find(n=>n.mediaSubtype.toUpperCase()==="PLAIN");return r?{kind:"text",contentUrl:r.contentUrl}:null},D={all:["messages"],detail:e=>[...D.all,"detail",e],body:e=>[...D.detail(e),"body"]};class A extends Error{reason;status;retryAfterSeconds;constructor(t,s,r,n){super(s),this.name="BodyFetchError",this.reason=t,this.status=r,this.retryAfterSeconds=n}}const Pe=e=>{const t=Number.parseInt(e??"",10);return!Number.isFinite(t)||t<=0?1:Math.min(t,30)},We=8,He="x-remit-403-reason",Qe=(e,t)=>{const s=t?.trim()??"";return e===401?"auth":e===403?s.length>0?"auth":"body-missing":e===404?"body-missing":"generic"},Ge=(e,t)=>(t??"").toLowerCase().startsWith("text/html")?/<div\s+id=["']root["']/i.test(e):!1,qe=(e,t)=>{const s=(t??"").toLowerCase();return!!(e==="text"&&s.startsWith("text/html"))},Ve=async(e,t,s=async()=>null)=>{const r={},n=await s();n&&(r.Authorization=`Bearer ${n}`);const o=await ee(e,{headers:r});if(o.status===202)throw new A("not-ready","Message body is still syncing",202,Pe(o.headers.get("Retry-After")));if(!o.ok){const i=o.headers.get(He),l=Qe(o.status,i);throw new A(l,`Failed to load message body (${o.status} ${o.statusText})`,o.status)}const c=o.headers.get("content-type");if(qe(t,c))throw new A("content-type-mismatch",`Refusing to render message body — expected ${t}, got Content-Type ${c}`);const m=await o.text();if(Ge(m,c))throw new A("spa-shell-leak","Refusing to render message body — response looks like the SPA shell (CloudFront 403/404 fallback leaked through to /content/*)");return m},Xe=async(e,t)=>(t.isRetryAfterNotReady&&await e.refetchDescribeMessage(),e.fetchContent(t.contentUrl,t.kind)),Ye=({messageId:e,bodyParts:t,enabled:s=!0})=>{const r=t?ze(t):null,n=Z(),{getToken:o}=P(),c=f.useRef(null),m=W(),i=f.useRef(!1),l=f.useRef(null),p=e&&r?`${e}:${r.contentUrl}`:null;l.current!==p&&(l.current=p,i.current=!1);const d=J({queryKey:e?[...D.body(e),r?.contentUrl??null]:["messages","body","noop"],queryFn:()=>{if(!r)throw new Error("No renderable body part");if(!e)throw new Error("No messageId");const u=i.current;return i.current=!1,Xe({fetchContent:(h,v)=>Ve(h,v,o),refetchDescribeMessage:()=>m.refetchQueries({queryKey:H({path:{messageId:e}})})},{contentUrl:r.contentUrl,kind:r.kind,isRetryAfterNotReady:u})},enabled:s&&!!e&&!!r,staleTime:300*1e3,gcTime:1800*1e3,retry:(u,h)=>h instanceof A&&h.reason==="not-ready"?u<We:u<1,retryDelay:(u,h)=>h instanceof A&&h.reason==="not-ready"?(i.current=!0,(h.retryAfterSeconds??1)*1e3):1e3,meta:{softError:!0}}),g=d.isLoading&&!!r;f.useEffect(()=>{g&&(c.current=performance.now())},[g]),f.useEffect(()=>{d.isSuccess&&c.current!==null&&(n.recordTiming("message.body.load",Math.round(performance.now()-c.current)),c.current=null)},[d.isSuccess,n]);const x=d.data&&r?{kind:r.kind,body:d.data}:void 0;return{picked:r,data:x,isLoading:g,isError:d.isError,error:d.error,refetch:d.refetch}},q=(e,t=Date.now())=>({value:e,setAt:t}),Ze=(e,t,s,r)=>{if(e.addressId!==t)return e;const n={...e.flags??{}};return s?n.trusted=q(!0,r):delete n.trusted,{...e,flags:n}},Je=(e,t,s,r)=>{const n=o=>o.map(c=>Ze(c,t,s,r));return{...e,envelope:{...e.envelope,from:n(e.envelope.from),to:n(e.envelope.to),cc:n(e.envelope.cc),bcc:n(e.envelope.bcc),replyTo:n(e.envelope.replyTo)}}},et=({messageId:e})=>{const t=W(),{pushError:s}=te(),{mutate:r,isPending:n,error:o,reset:c}=se({...ne(),onMutate:async i=>{const l=i.path.addressId,d=i.body.flags?.trusted?.value===!0,g=H({path:{messageId:e}});await t.cancelQueries({queryKey:g});const x=t.getQueriesData({queryKey:g}).filter(u=>u[1]!==void 0).map(([u,h])=>({queryKey:u,data:h}));return t.setQueriesData({queryKey:g},u=>u&&Je(u,l,d)),{describePrefix:g,previous:x}},onError:(i,l,p)=>{if(p)for(const d of p.previous)t.setQueryData(d.queryKey,d.data);s(re("Couldn't trust sender","The change wasn't saved.",i))},onSettled:(i,l,p,d)=>{d&&t.invalidateQueries({queryKey:d.describePrefix})}});return{toggleTrusted:(i,l)=>{r({path:{addressId:i},body:{flags:{trusted:q(!l)}}})},isPending:n,error:o,reset:c}},tt=()=>{const[e,t]=f.useState(()=>typeof document<"u"&&document.documentElement.classList.contains("dark"));return f.useEffect(()=>{const s=document.documentElement,r=new MutationObserver(()=>{t(s.classList.contains("dark"))});return r.observe(s,{attributes:!0,attributeFilter:["class"]}),()=>r.disconnect()},[]),e},st=({blockedImageCount:e,canAlwaysTrust:t,isTrustPending:s,onLoadOnce:r,onAlwaysTrust:n})=>a.jsxs("div",{className:"mb-3 flex items-center justify-between rounded-md bg-surface-sunken/50 px-3 py-2 text-sm",children:[a.jsxs("span",{className:"text-fg-muted",children:[e," image",e>1?"s":""," blocked for privacy"]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("button",{type:"button",onClick:r,className:"text-accent hover:underline",children:"Load once"}),t&&a.jsx("button",{type:"button",onClick:n,"aria-busy":s,className:"text-accent hover:underline aria-busy:opacity-50",children:s?"Trusting…":"Always trust"})]})]}),rt=(e,t)=>{switch(e){case"auth":return{title:"Your session expired",detail:"Sign in again to reload the message body. Other parts of the app may also stop responding until you do."};case"body-missing":return{title:"Message body is missing in storage",detail:"A sync failure may have left this message without its body bytes. Contact support, or run the reconcile script to refetch from the upstream IMAP server."};case"content-type-mismatch":return{title:"Couldn't load message body",detail:"The server returned an unexpected content type for this part. The message body has not been rendered to keep you safe."};case"spa-shell-leak":return{title:"Couldn't load message body",detail:"The server returned the app shell instead of the message body. This is an infrastructure bug — please report it."};case"not-ready":return{title:"Message body is still syncing",detail:"This message's body hasn't finished downloading from the mail server yet. It should appear shortly — reopen the message to try again."};default:return{title:"Couldn't load message body",detail:t}}},nt=e=>e instanceof A?e.reason:"generic",at=e=>e instanceof Error?e.message:typeof e=="string"?e:"An unexpected error occurred while loading the message body.",ot=({error:e,onRetry:t})=>{const s=nt(e),r=at(e),{title:n,detail:o}=rt(s,r),[c,m]=f.useState(!1),{Account:i}=P();return c?null:a.jsxs("div",{role:"alert","data-testid":"message-body-error-banner","data-reason":s,className:"flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-sm",children:[a.jsx(ae,{className:"size-4 shrink-0 text-danger mt-0.5","aria-hidden":"true"}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"font-medium text-danger",children:n}),a.jsx("p",{className:"text-fg-muted mt-1 break-words",children:o})]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-3",children:[s==="auth"&&a.jsx(i,{children:({signOut:l})=>a.jsx("button",{type:"button",onClick:()=>l(),className:"text-sm font-medium text-accent hover:underline",children:"Sign in again"})}),t&&a.jsx("button",{type:"button",onClick:t,className:"text-sm font-medium text-accent hover:underline",children:"Retry"}),a.jsx("button",{type:"button",onClick:()=>m(!0),"aria-label":"Dismiss message body error",className:"rounded-md p-1 text-fg-muted hover:bg-surface-raised hover:text-fg transition-colors",children:a.jsx(oe,{className:"size-4","aria-hidden":"true"})})]})]})},it=()=>a.jsxs("div",{className:"animate-pulse space-y-2",role:"status","aria-label":"Loading message body",children:[a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-full"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-11/12"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-3/4"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-5/6"})]}),z=()=>a.jsx("p",{className:"text-fg-muted text-sm italic",children:"This message has no body content."}),Et=({bodyParts:e,html:t,text:s,isTrusted:r=!1,messageId:n,fromAddressId:o,category:c,className:m})=>{const[i,l]=f.useState(!1),p=r||i,d=tt(),{toggleTrusted:g,isPending:x}=et({messageId:n??""}),u=!!e&&e.length>0,{picked:h,data:v,isLoading:M,isError:T,error:b,refetch:k}=Ye({messageId:n,bodyParts:e,enabled:u}),w=f.useMemo(()=>fe(e??[]),[e]),E=u&&v?.kind==="html"?v.body:t,N=u&&v?.kind==="text"?v.body:s;if(u){if(M)return a.jsx("div",{className:C("message-body",m),children:a.jsx(it,{})});if(T)return a.jsx("div",{className:C("message-body",m),children:a.jsx(ot,{error:b,onRetry:()=>k()})});if(!h)return a.jsx("div",{className:C("message-body",m),children:a.jsx(z,{})})}else if(!t&&!s)return a.jsx("div",{className:C("message-body",m),children:a.jsx(z,{})});const y=!!(o&&n),j=()=>{!o||x||(l(!0),g(o,!1))};return a.jsx(Oe,{className:m,html:E,text:N,isDark:d,category:c,allowImages:p,resolveCid:w,renderBlockedNotice:R=>a.jsx(st,{blockedImageCount:R,canAlwaysTrust:y,isTrustPending:x,onLoadOnce:()=>l(!0),onAlwaysTrust:j})})},V={personal:"Personal",uncategorized:"Unclassified",transactional:"Transactional",newsletter:"Newsletter",marketing:"Marketing",social:"Social",automated:"Automated"},ct=Object.values(Q).map(e=>({value:e,label:V[e]})),lt={unclassified:"uncategorized"},dt=[{name:"from",label:"Sender",values:"contact"},{name:"subject",label:"Subject",values:"text"},{name:"category",label:"Category",values:"fixed",options:ct},{name:"is",label:"State",values:"fixed",options:[{value:"unread",label:"Unread"},{value:"read",label:"Read"},{value:"starred",label:"Starred"}]},{name:"has",label:"Contents",values:"fixed",options:[{value:"attachment",label:"Has attachment"}]},{name:"in",label:"Folder",values:"mailbox"},{name:"account",label:"Account",values:"account"},{name:"after",label:"Sent on or after",values:"date"},{name:"before",label:"Sent before",values:"date"}],ut=new Map(dt.map(e=>[e.name,e])),At=e=>ut.get(e.toLowerCase()),ft=/^\d{4}-\d{2}-\d{2}$/;function mt(e,t,s){if(!ft.test(s))return;const r=Date.parse(`${s}T00:00:00Z`);if(!Number.isNaN(r))return{type:e,raw:t,value:s,epochSeconds:Math.floor(r/1e3)}}function ht(e){const t=e.toLowerCase(),s=lt[t];return s||Object.values(Q).find(n=>n===t)}function gt(e,t){switch(t.toLowerCase()){case"unread":return{type:"isUnread",raw:e};case"read":return{type:"isRead",raw:e};case"starred":case"flagged":return{type:"isStarred",raw:e};default:return}}function pt(e,t){const s=Ue(e);if(!s||s.value.length===0)return;const{name:r,value:n}=s;switch(r){case"from":return{type:"from",raw:e,value:n};case"subject":return{type:"subject",raw:e,value:n};case"category":{const o=ht(n);return o?{type:"category",raw:e,value:n,category:o}:void 0}case"is":return gt(e,n);case"has":return n.toLowerCase()==="attachment"?{type:"hasAttachment",raw:e}:void 0;case"before":case"after":return mt(r,e,n);case"in":{const o=t.mailboxesByName?.get(n.toLowerCase());return o?{type:"in",raw:e,value:n,mailboxId:o}:void 0}case"account":{const o=t.accountsByName?.get(n.toLowerCase());return o?{type:"account",raw:e,value:n,accountId:o}:void 0}default:return}}function St(e,t={}){const s=[],r=[];for(const n of G(e)){const o=pt(n.raw,t);o?s.push(o):r.push(n.raw)}return{freeText:r.join(" "),tokens:s}}function Tt(e,t){return G(e).filter(s=>s.raw!==t.raw).map(s=>s.raw).join(" ")}function Nt(e){switch(e.type){case"from":return`From: ${e.value}`;case"subject":return`Subject: ${e.value}`;case"category":return`Category: ${V[e.category]}`;case"hasAttachment":return"Has attachment";case"isUnread":return"Unread";case"isRead":return"Read";case"isStarred":return"Starred";case"before":return`Before ${e.value}`;case"after":return`After ${e.value}`;case"in":return`In: ${e.value}`;case"account":return`Account: ${e.value}`}}function jt(){const{mailboxNameIndex:e,accountNameIndex:t}=ie();return{...ce({select:r=>le(r.matches)})?{}:{mailboxesByName:e},accountsByName:t}}export{Et as M,vt as R,dt as S,G as a,Ue as b,Oe as c,Ye as d,et as e,Qe as f,Nt as g,At as h,St as p,Tt as r,kt as s,jt as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{q as L,ab as C,ad as I,bF as k,bG as E,r as x,j as p,bH as h,bI as A,bJ as j,n as R,w as Q,bK as q}from"./index-DiRuAyHr.js";import{ap as D,aq as O,ar as _,as as z,at as N}from"./MailListHeader-C2XMv19y.js";import{a as P}from"./useLabels-CCPzRB-4.js";import{M as w}from"./enums-CCxx0t2v.js";import{u as F,s as G}from"./search-scope-DJwbffIz.js";import{n as U}from"./search-query-Cr_ZXBCp.js";import{u as B,p as K}from"./useSearchTokenContext-C1W1J3dC.js";const H=t=>{const{mailboxId:s,messages:i}=t,l=L(),{pushError:c}=C(),{mutateAsync:r,isPending:a}=I({...E(),onError:(o,u)=>{c({title:u.body.action==="Remove"?"Couldn't remove label":"Couldn't apply label",detail:k(o),error:o})},onSettled:(o,u,m)=>{D(l,O(_(m.body.messageIds??[],i??[],s)))}});return{applyLabel:x.useCallback((o,u,m)=>{o.length!==0&&z(o,d=>r({body:{messageIds:d,labelId:u,action:m}}))},[r]),isPending:a}};function oe({accountId:t,mailboxId:s,messageIds:i}){const{labels:l}=P(t),{applyLabel:c}=H({mailboxId:s}),r=x.useMemo(()=>l.map(a=>({key:a.labelId,label:a.name,icon:p.jsx("span",{className:`size-2.5 rounded-full ${A(a.color)?h[a.color]:h.Default}`}),onSelect:()=>c(i,a.labelId,"Apply")})),[l,i,c]);return r.length===0?null:p.jsx(N,{triggerLabel:"Apply label to selected messages",triggerIcon:p.jsx(j,{className:"size-4 text-fg-subtle"}),triggerText:"Apply label",items:r,align:"start",nested:!0,touch:!1,triggerClassName:"min-h-11 w-full justify-start gap-3 px-4 py-2.5 text-sm font-normal text-fg"})}const J=20,V=new Set(Object.values(w)),$=t=>t!==void 0&&V.has(t)?t:void 0,W=t=>{if(t.some(s=>s.type==="isUnread"))return!1;if(t.some(s=>s.type==="isRead"))return!0};function ne({mailboxId:t,filterCategory:s}={}){const{searchQuery:i}=R(),l=B(),c=F({select:e=>e.matches}),r=U(i),{freeText:a,tokens:n}=K(r,l),o=a.length>0,u=n.find(e=>e.type==="category"),m=$(s)??u?.category,d=n.some(e=>e.type==="hasAttachment")?!0:void 0,b=n.some(e=>e.type==="isStarred")?!0:void 0,y=W(n),f=n.find(e=>e.type==="after"),g=n.find(e=>e.type==="before"),S=n.find(e=>e.type==="in"),M=G({matches:c,callerMailboxId:t,inTokenMailboxId:S?.mailboxId}),{data:T,isLoading:v}=Q({...q({query:{query:a,mailboxId:M,limit:J,...m!==void 0?{category:m}:{},...d!==void 0?{hasAttachment:d}:{},...b!==void 0?{hasStars:b}:{},...y!==void 0?{isRead:y}:{},...f?{sentDateFrom:f.epochSeconds}:{},...g?{sentDateTo:g.epochSeconds}:{}}}),enabled:o,staleTime:6e4});return{hits:T?.items??[],isLoading:o&&v}}export{oe as L,ne as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{q as g,ab as f,w as p,W as m,r,ad as y,ae as T,$ as E,af as d}from"./index-DiRuAyHr.js";const i={html:"",plainText:""},C=e=>{const u=g(),{pushError:o}=f(),{data:n}=p({...m(),staleTime:1/0}),l=r.useMemo(()=>{if(!e||!n)return i;const t=n.accounts.find(s=>s.accountId===e);return t?{html:t.signatureHtml??"",plainText:t.signaturePlainText??""}:i},[e,n]),a=y({...d(),onSuccess:()=>{u.invalidateQueries({queryKey:E()})},onError:t=>{o(T("Couldn't save signature","The signature wasn't saved.",t))}}),c=r.useCallback((t,s)=>{e&&a.mutate({path:{accountId:e},body:{signatureHtml:t,signaturePlainText:s}})},[e,a]);return{signature:l,setSignature:c,isSaving:a.isPending}};export{C as u};
|
package/index.html
CHANGED
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
} catch (_) {}
|
|
39
39
|
})();
|
|
40
40
|
</script>
|
|
41
|
-
<script type="module" crossorigin src="/assets/index-
|
|
41
|
+
<script type="module" crossorigin src="/assets/index-DiRuAyHr.js"></script>
|
|
42
42
|
<link rel="stylesheet" crossorigin href="/assets/index-qflIxZzw.css">
|
|
43
43
|
</head>
|
|
44
44
|
<body>
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as t,am as Ke,S as Xe,bn as es,n as B,bf as ss,o as re,r as n,w as oe,bo as ne,t as ts,v as as,bp as os,bq as ns,br as rs,e as Te,bs as is,V as ls,i as cs}from"./index-2IDEAuVk.js";import{s as Re,a as ds,b as we,u as us,p as ms,R as fs}from"./useSearchTokenContext-CO76ckqM.js";import{a3 as Se,F as Ce,a4 as hs,a5 as gs,G as xs,a6 as ae,a7 as ps,a8 as bs,a9 as Is,a2 as vs,aa as ys,ab as Ss,ac as Cs,M as js,ad as Ms,ae as Ts,af as Rs,f as ws,w as ks,ag as Ns,s as As,S as Fs,N as je,L as Bs,H as Os,e as Ls,X as Es,Y as ke,Z as qs,_ as Ne,$ as Ds}from"./MailListHeader-BOSCy5bv.js";import{u as Ps,a as zs,R as Hs,i as _s,b as Qs}from"./useRefreshControl-DMDgy7HW.js";import{a as $s}from"./useLabels-GspP5G0M.js";import{d as Vs,R as Ws}from"./search-token-index-CjGaBFWZ.js";import{u as Gs}from"./useMediaQuery-BisfJ3kn.js";import{u as Us,L as Ys,b as Js}from"./conversation-target-Cm8-sdZJ.js";function Zs({sync:e}){return e?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 py-12 text-center px-4",role:"status","aria-live":"polite",children:[t.jsx(Ke,{className:"size-8 animate-spin text-fg-subtle","aria-hidden":"true"}),t.jsx("p",{className:"text-sm font-medium text-fg",children:"Still syncing your mail"}),t.jsx("p",{className:"text-xs text-fg-subtle",children:Ks(e)})]}):t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 py-12 text-center px-4",children:[t.jsx(Xe,{className:"size-8 text-fg-subtle","aria-hidden":"true"}),t.jsx("p",{className:"text-sm font-medium text-fg",children:"You're caught up"}),t.jsx("p",{className:"text-xs text-fg-subtle",children:"Nothing needs attention."})]})}function Ks({synced:e,total:s}){return s>0?`${e.toLocaleString()} of ${s.toLocaleString()} messages downloaded. This list fills in as they arrive.`:"Downloading your messages. This list fills in as they arrive."}const Ae=[{id:"unread",name:"is",value:"unread"},{id:"attachment",name:"has",value:"attachment"}],Fe="category",Xs={unclassified:"uncategorized"},D=e=>ds(e).map(s=>s.raw),q=e=>e.join(" "),ie=e=>{const s=we(e);if(s)return Ae.find(o=>o.name===s.name&&o.value===s.value.toLowerCase())?.id},le=e=>{const s=we(e);if(!s||s.name!==Fe)return;const o=s.value.toLowerCase(),r=Xs[o];if(r)return r;if(!(!es(o)||o==="all"))return o},Be=e=>Ae.find(s=>s.id===e),Oe=e=>Be(e)!==void 0,et=e=>{const s=new Set;for(const o of D(e)){const r=ie(o);r&&s.add(r)}return s},st=e=>{let s="all";for(const o of D(e)){const r=le(o);r&&(s=r)}return s},tt=(e,s)=>{const o=Be(s);if(!o)return;const r=D(e),d=r.filter(i=>ie(i)!==s);return d.length<r.length?q(d):q([...r,Re(o.name,o.value)])},at=(e,s)=>{const o=D(e).filter(r=>!le(r));return q(s==="all"?o:[...o,Re(Fe,s)])},ot=e=>q(D(e).filter(s=>!ie(s)&&!le(s))),Le=e=>e.trim().length>0,nt=e=>{if(!Le(e.query))return e.ownFilters;const s=new Set(et(e.query));for(const o of e.ownFilters)Oe(o)||s.add(o);return s},rt=e=>Le(e.query)?st(e.query):e.ownCategory,it=(e,s)=>e.createdAt!==s.createdAt?e.createdAt-s.createdAt:e.accountId.localeCompare(s.accountId),lt=e=>[...e].sort(it),ct=200,Me=()=>t.jsx("div",{className:"animate-pulse",children:Array.from({length:3}).map((e,s)=>t.jsxs("div",{className:"flex items-start gap-3 py-2 pl-5 pr-4 border-b border-line",children:[t.jsx("div",{className:"size-7 rounded-full bg-surface-sunken shrink-0 mt-0.5"}),t.jsxs("div",{className:"flex-1 space-y-1.5",children:[t.jsxs("div",{className:"flex justify-between gap-2",children:[t.jsx("div",{className:"h-3.5 bg-surface-sunken rounded w-28"}),t.jsx("div",{className:"h-3 bg-surface-sunken rounded w-12"})]}),t.jsx("div",{className:"h-3.5 bg-surface-sunken rounded w-48"}),t.jsx("div",{className:"h-3 bg-surface-sunken rounded w-full"})]})]},s))}),dt=({accountEmail:e})=>{const s=re();return t.jsxs("div",{className:"flex items-center gap-2 px-row-inset py-2 border-b border-line bg-danger-soft/40 text-xs text-danger",children:[t.jsx(Te,{className:"size-3.5 shrink-0"}),t.jsxs("span",{className:"flex-1 truncate",children:[e," can't connect"]}),t.jsx("button",{type:"button",onClick:()=>s({to:"/settings/accounts"}),className:"shrink-0 underline text-danger hover:opacity-80",children:"Reconnect"})]})},ut=(e,s)=>{if(s.size===0)return{};const o=new Set,r=new Set;for(const i of e)s.has(i.id)&&(i.accountId&&o.add(i.accountId),i.mailboxId&&r.add(i.mailboxId));if(o.size>1)return{moveDisabledHint:"Move only works within one account — clear selection or pick messages from a single account"};const d=o.size===1?[...o][0]:void 0;return r.size>1?{accountId:d,moveDisabledHint:`Move only works within one folder — this selection spans ${r.size} folders`}:{accountId:d,mailboxId:r.size===1?[...r][0]:void 0}};function mt({header:e,rows:s,wizard:o,children:r}){const{selectedIds:d,selectedCount:i,exitSelection:x,orderedIds:g,allSelected:u,toggleAllLoaded:b}=Rs(),m=n.useMemo(()=>ut(s,d),[s,d]),{junkMailboxId:w}=ws(m.accountId),{labels:C}=$s(m.accountId),N=n.useMemo(()=>Array.from(d),[d]),I=n.useMemo(()=>s.filter(h=>d.has(h.id)).map(h=>({id:h.id,sender:h.fromName,email:h.fromEmail,subject:h.subject,date:h.timeLabel})),[s,d]),A=ks(w,m.mailboxId),f=n.useMemo(()=>g.length>0?{checked:u,indeterminate:i>0&&!u,onChange:b}:void 0,[g.length,u,i,b]),v=m.moveDisabledHint?{tone:"warning",text:m.moveDisabledHint}:void 0,j=h=>t.jsx(Fs,{title:h.title,navSlot:h.navSlot,titleMeta:h.titleMeta,searchSlot:h.searchSlot,searchField:h.searchField,idleSlot:h.makeFilterSlot,count:i,onCancel:x,onDelete:()=>o.start("delete"),onMove:()=>o.start("move"),onOrganize:()=>o.start("organize"),onJunk:A?()=>o.start("junk"):void 0,onMarkRead:()=>o.start("markRead"),overflowSlot:m.accountId&&m.mailboxId&&i>0&&C.length>0?t.jsx(Ys,{accountId:m.accountId,mailboxId:m.mailboxId,messageIds:N}):void 0,selectAll:f,notice:v});return t.jsx(Ns,{...e,selectionBar:j,paneOverlay:t.jsx(As,{verb:o.verb,accountId:m.accountId,mailboxId:m.mailboxId,selection:I,crossAccount:m.moveDisabledHint!==void 0,onFinished:x}),children:r})}function ft({accounts:e,selectedMessageId:s,onSelectMessage:o,onSelectSearchResult:r,commandsRef:d,onTriageContextChange:i,onDeleteMessages:x}){const{searchQuery:g,searchInput:u,resultFolderIndex:b,onSearchChange:m}=B(),w=us(),C=Gs(),N=Vs(),I=ss(),A=re(),f=n.useMemo(()=>lt(e.filter(a=>!a.muted?.value)),[e]),[v,j]=n.useState("all"),[h,k]=n.useState("all"),[O,P]=n.useState(new Set),[z,G]=n.useState(!1),p=n.useCallback(a=>{P(l=>{const c=new Set(l);return c.has(a)?c.delete(a):c.add(a),c})},[]),M=n.useCallback(()=>P(new Set),[]),y=u.trim().length>0,L=n.useMemo(()=>nt({query:u,ownFilters:O}),[u,O]),F=n.useMemo(()=>rt({query:u,ownCategory:h}),[u,h]),U=n.useCallback(a=>{if(!y||!Oe(a)){p(a);return}const l=tt(u,a);l!==void 0&&m(l)},[y,u,m,p]),Y=n.useCallback(a=>{if(!y){k(a);return}m(at(u,a))},[y,u,m]),J=n.useCallback(()=>{k("all"),j("all"),M(),y&&m(ot(u))},[y,u,m,M]),{data:H,isLoading:Z,isError:ce,refetch:de}=oe({...ne(),staleTime:6e4}),_=ts({queries:f.map(a=>({...as({path:{accountId:a.accountId}}),staleTime:1/0,meta:{softError:!0}}))}),Q=n.useMemo(()=>{const a=new Map;for(let l=0;l<f.length;l++){const c=f[l].accountId,Ye=(_[l]?.data?.items??[]).reduce((Je,Ze)=>Je+(Ze.unseenCount??0),0);a.set(c,Ye)}return a},[f,_]),De=n.useMemo(()=>f.filter((a,l)=>{const c=_[l];return c?.isError?!os(c.error):!1}),[f,_]),{freeText:S,tokens:K}=ms(g.trim().toLowerCase(),w),{data:ue,isFetching:Pe}=oe({...ne({query:{query:S,limit:ct}}),enabled:S.length>0,staleTime:3e4}),T=n.useMemo(()=>{const a=Se(H?.items??[]).map(Ce);return(S?hs(a.filter(c=>gs(c,S)),Se(ue?.items??[]).map(Ce)):a).filter(c=>(v==="all"||c.accountId===v)&&xs(c,K))},[H,ue,v,S,K]),{bodyRows:$,briefSpamOffer:X}=n.useMemo(()=>{if(!S)return{bodyRows:T,briefSpamOffer:void 0};const a=T.map(R=>ae(R,b)),{spam:l}=ps(a);if(l.length===0)return{bodyRows:T,briefSpamOffer:void 0};const c=new Set(l.map(R=>R.id));return{bodyRows:T.filter(R=>!c.has(R.id)),briefSpamOffer:bs(a)}},[T,S,b]),me=n.useMemo(()=>Is($),[$]),fe=n.useCallback((a,l)=>{const c=S?$.find(R=>R.id===a):void 0;if(c?.threadId&&c.mailboxId&&r){r(ae(c,b),l);return}o?.(a,l)},[S,$,b,r,o]),ee=n.useMemo(()=>f.length<=1?[]:[{id:"all",label:"All",active:v==="all"},...f.map(a=>({id:a.accountId,label:a.email.split("@")[0]??a.email,count:Q.get(a.accountId),active:v===a.accountId}))],[f,Q,v]),E=n.useMemo(()=>e.filter(a=>a.muted?.value).length,[e]),ze=n.useMemo(()=>Array.from(Q.values()).reduce((a,l)=>a+l,0),[Q]),se=n.useMemo(()=>f.map(a=>a.accountId),[f]),{hasNewMail:he}=Ps(),{state:ge,errorMessage:xe,refresh:pe}=zs(se,{onSettled:()=>de()}),He=n.useMemo(()=>t.jsx(Hs,{state:ge,onRefresh:pe,label:"Refresh daily brief",errorMessage:xe,hasUpdate:he(se)}),[ge,pe,xe,he,se]),te=n.useMemo(()=>T.filter(a=>(F==="all"||a.category===F)&&ns(a,L)).map(a=>ae(a,b)),[T,F,L,b]),{hits:be,isLoading:_e}=Us(),Qe=n.useMemo(()=>{const a=new Map;for(const c of H?.items??[])a.set(c.messageId,c.threadId);const l=te.map(c=>a.get(c.id)).filter(c=>c!=null);return vs(be,l,b)},[be,te,H,b]),$e=n.useMemo(()=>{const a=ys(ee.map(l=>({id:l.id,label:l.label,count:l.count,active:l.active})));return{categories:a.categories,filters:a.filters,sources:a.sources,sourcesNote:E>0?`+${E} muted`:void 0,selectedCategory:F,activeFilters:L,expanded:z,onExpandedChange:G,onSelectCategory:l=>Y(l),onSelectSource:j,onToggleFilter:l=>U(l),onClear:J}},[ee,E,F,L,z,U,Y,J]),Ie=me.length===0&&v==="all"&&S.length===0&&K.length===0,Ve=n.useMemo(()=>f.map(a=>a.accountId),[f]),We=n.useMemo(()=>f.some(a=>_s(a.syncPhase)),[f]),V=Qs(Ve,Ie||We),ve=t.jsxs("div",{className:"h-full overflow-y-auto",children:[t.jsx(Me,{}),t.jsx(Me,{})]}),ye=!Z&&!ce&&!Ie,Ge=Ss({tier:N,hasLiveInput:y,hasCommittedQuery:g.trim().length>0,bodyRendersCommittedResults:!0}),Ue=ye?t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[X&&t.jsx(Cs,{count:X.count,onScopeToSpam:()=>A({to:"/mail/$mailboxId",params:{mailboxId:X.mailboxId},search:{q:g||void 0,selectedMessageId:void 0,selectedThreadId:void 0}})}),t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(rs,{sections:me,briefCategory:F,Row:js,selectedThreadId:s,onSelectThread:fe,onSelectBriefCategory:Y,sources:ee,sourcesNote:E>0?`+${E} muted`:void 0,onSelectSource:j,activeFilters:L,onToggleFilter:U,onClearFilters:J})})]}):Z?ve:ce?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 py-12 text-sm text-fg-muted",children:[t.jsx(Te,{className:"size-8 text-danger"}),t.jsx("p",{children:"Couldn't load your messages"}),t.jsxs("button",{type:"button",onClick:()=>de(),className:"flex items-center gap-1 text-accent underline text-xs",children:[t.jsx(Ws,{className:"size-3.5"}),"Try again"]})]}):V.resolved?t.jsx(Zs,{sync:V.syncing?{synced:V.synced,total:V.total}:void 0}):ve;return t.jsx(is,{hasSheet:ye&&!Ge,children:t.jsx(Ms,{selectedMessageId:s,onOpen:fe,onDeleteMessages:x,onSelectionVerb:I.start,wizardOpen:I.isOpen,commandsRef:d,onTriageContextChange:i,children:t.jsx(mt,{wizard:I,header:{title:"Daily brief",unreadCount:ze,footer:C?t.jsx(Ts,{}):void 0,searchFilter:$e,searchResults:te,searchLoading:Z||Pe,relatedResults:Qe,relatedLoading:_e,onSelectSearchResult:r,searchResultsInBody:!0,refreshControl:He},rows:T,children:t.jsxs("div",{className:"flex h-full flex-col",children:[De.map(a=>t.jsx(dt,{accountEmail:a.email,accountId:a.accountId},a.accountId)),t.jsx("div",{className:"min-h-0 flex-1",children:Ue})]})})})})}const Ee=n.createContext(null);function W(){const e=n.useContext(Ee);if(!e)throw new Error("BriefPane.* must be used inside <BriefPane>");return e}function ht({selectedMessageId:e,children:s}){const o=re(),{searchInput:r}=B(),{selectedThreadId:d,selectedMailboxId:i}=ls({strict:!1}),{data:x}=oe({...ne(),staleTime:6e4}),g=n.useMemo(()=>{if(e)return x?.items.find(p=>p.messageId===e)},[x,e]),u=n.useMemo(()=>Js(g,{messageId:e,threadId:d,mailboxId:i}),[g,e,d,i]),b=n.useCallback((p,M)=>{o({to:"/mail/brief",search:y=>({...y,selectedMessageId:p,selectedThreadId:void 0,selectedMailboxId:void 0}),replace:M?.replace})},[o]),m=n.useCallback((p,M)=>{o({to:"/mail/brief",replace:M?.replace,search:y=>({...y,q:r||void 0,selectedMessageId:p.id,selectedThreadId:p.threadId,selectedMailboxId:p.mailboxId})})},[o,r]),w=n.useCallback(p=>{e&&p.includes(e)&&o({to:"/mail/brief",search:M=>({...M,selectedMessageId:void 0,selectedThreadId:void 0,selectedMailboxId:void 0})})},[e,o]),C=je({thread:g,onAfterOptimisticRemove:w}),N=n.useCallback(()=>{o({to:"/mail/brief",search:p=>({...p,selectedMessageId:void 0,selectedThreadId:void 0,selectedMailboxId:void 0})})},[o]),I=Bs(),A=n.useMemo(()=>x?.items??[],[x]),{deleteMessages:f}=Os({mailboxId:g?.mailboxId??"",messages:A,onAfterOptimisticRemove:w}),{toggleReadFor:v}=Ls({mailboxId:g?.mailboxId??"",messages:A}),j=I.focusedMessageId,k=n.useMemo(()=>x?.items.find(p=>p.messageId===j),[x,j])??g,O=je({thread:k}),{nextMessageId:P,previousMessageId:z}=Es({context:I,orderedIds:I.orderedIds,selectedMessageId:e,onClose:N,handlers:{reply:()=>C.requestCompose("reply"),replyAll:()=>C.requestCompose("reply_all"),forward:()=>C.requestCompose("forward"),delete:()=>{I.listCommandsRef.current?.requestVerb("delete")||O.deleteThread()},toggleStar:O.toggleStar,toggleRead:()=>{I.listCommandsRef.current?.requestVerb("markRead")||k&&v([k.messageId],!k.isRead)},goFlagged:()=>o({to:"/mail/flagged"}),goSettings:()=>o({to:"/settings"})}}),G={selectedMessageId:e,selectedThread:g,conversation:u,onSelectMessage:b,onSelectSearchResult:m,onCloseThread:N,actions:C,triage:I,onDeleteMessages:f,nextMessageId:P,previousMessageId:z,handleDeselectIfRemoved:w};return t.jsx(Ee.Provider,{value:G,children:s})}function qe(){const{selectedMessageId:e,onSelectMessage:s,onSelectSearchResult:o,triage:r,onDeleteMessages:d}=W(),{accounts:i}=B();return t.jsx(ft,{accounts:i,selectedMessageId:e,onSelectMessage:s,onSelectSearchResult:o,commandsRef:r.listCommandsRef,onTriageContextChange:r.onTriageContextChange,onDeleteMessages:d})}function gt(){const{conversation:e,actions:s}=W(),{intelligenceOpen:o,onToggleIntelligence:r}=B(),d=cs()?.showIntelligencePane??!1,i=!!e,x=d&&i;return t.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[t.jsx(Ds,{hasThread:i,intelligenceOpen:x&&o,canToggleIntelligence:x,onToggleIntelligence:r,onReply:i?()=>s.requestCompose("reply"):void 0,onReplyAll:i?()=>s.requestCompose("reply_all"):void 0,onForward:i?()=>s.requestCompose("forward"):void 0,onDelete:i?s.deleteThread:void 0,onToggleStar:i?s.toggleStar:void 0,isStarred:s.isStarred,moveContext:i&&s.accountId&&s.mailboxId?{accountId:s.accountId,currentMailboxId:s.mailboxId,onMove:s.moveThread}:void 0}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e?t.jsx(ke,{threadId:e.threadId,mailboxId:e.mailboxId,subject:e.subject,selectedMessageId:e.messageId,authenticity:e.authenticity,composeRequest:s.composeRequest,onComposeClose:s.clearComposeRequest}):t.jsx(fs,{})})]})}function xt(){const{selectedThread:e,handleDeselectIfRemoved:s}=W(),{onToggleIntelligence:o}=B();return t.jsx(Ne,{onClose:o,thread:e,mailboxId:e?.mailboxId,accountId:e?.accountId,onAfterOptimisticRemove:s})}function pt(){const{selectedThread:e,conversation:s,onSelectMessage:o,onCloseThread:r,nextMessageId:d,previousMessageId:i,handleDeselectIfRemoved:x}=W(),{intelligenceOpen:g,onToggleIntelligence:u}=B();return s?t.jsxs(t.Fragment,{children:[t.jsx(ke,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onBack:r,onOpenIntelligence:u,onSwipeNext:d?()=>o(d):void 0,onSwipePrevious:i?()=>o(i):void 0,mobileIntelligenceOpen:g}),t.jsx(qs,{isOpen:g,onClose:u,ariaLabel:"Message details",side:"right",children:t.jsx(Ne,{onClose:u,thread:e,mailboxId:e?.mailboxId,accountId:e?.accountId,hideCloseButton:!0,onAfterOptimisticRemove:x})})]}):t.jsx("div",{className:"h-full",children:t.jsx(qe,{})})}const Tt=Object.assign(ht,{List:qe,Reading:gt,Intelligence:xt,Phone:pt});export{Tt as B};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as r,bb as Ms,r as l,az as Ft,B as le,S as Ts,b as Be,aA as Gt,C as Rs,d as Es,aV as Os,k as bt,w as Ze,W as Yt,X as As,o as We,q as _t,x as Ns,ae as Lt,bc as Xt,bd as Zt,I as zs,h as Ds,T as Fs,be as _s,bf as Ls,bg as Ps,ac as es,bh as $s,bi as Bs,J as Ws,g as Ks,a0 as Pt,bj as Vs,P as qs,v as Hs,bk as Us,n as ts,bl as Qs,G as Js,V as Gs,af as Ys,i as Xs,bm as Zs,b0 as en}from"./index-2IDEAuVk.js";import{u as tn,p as sn,R as nn}from"./useSearchTokenContext-CO76ckqM.js";import{u as on,a as rn,R as an}from"./useRefreshControl-DMDgy7HW.js";import{C as ss,D as Pe,a as ns,b as os,c as is,j as ln,M as cn,t as rs,u as un,d as dn,e as as,f as ls,g as hn,h as fn,i as mn,k as gn,l as Kt,n as pn,m as xn,o as bn,p as vn,q as Sn,S as yn,r as Cn,s as wn,v as In,w as cs,x as jn,y as kn,z as Mn,A as Tn,B as Rn,E as En,F as On,G as An,H as Vt,I as Nn,J as qt,K as zn,L as Dn,N as Fn,O as _n,P as Ln,Q as Pn,R as $n,T as Bn,U as Wn,V as Kn,W as Vn,X as qn,Y as us,Z as Hn,_ as ds,$ as Un,a0 as hs,a1 as Qn,a2 as Jn}from"./MailListHeader-BOSCy5bv.js";import{S as Gn,M as Yn,a as Xn,u as Zn,b as eo}from"./MailViewChrome-CBOYFcSh.js";import{E as fs,f as to}from"./ErrorState-C50k8wSf.js";import{D as so,u as ms}from"./useMediaQuery-BisfJ3kn.js";import{C as gs}from"./confirm-dialog-Beh3oaKJ.js";import{A as $t}from"./avatar--BbHXv4F.js";import{b as et,c as no,d as oo}from"./format-De9HZKjg.js";import{N as io}from"./NavMenuButton-Dr1eU_Rz.js";import{a as ro}from"./useLabels-GspP5G0M.js";import{L as ao,b as lo,u as co}from"./conversation-target-Cm8-sdZJ.js";import{S as vt}from"./shield-check-D92P20s8.js";import{B as uo}from"./bottom-sheet-B99l3DPu.js";import{C as ho}from"./circle-help-DnuJPeYC.js";import{C as fo}from"./circle-check-C034sO1l.js";import{a as mo,b as go,f as po}from"./move-options-c2tU4zu_.js";import{d as ps,h as xo,j as bo,e as vo}from"./search-token-index-CjGaBFWZ.js";import{M as So}from"./enums-CCxx0t2v.js";import{r as yo}from"./intelligence-pref-C6lFpj6U.js";import{n as Co}from"./search-query-Cr_ZXBCp.js";const wo=e=>{const[n,s]=l.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(e).matches);return l.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const t=window.matchMedia(e);s(t.matches);const o=i=>s(i.matches);return t.addEventListener("change",o),()=>t.removeEventListener("change",o)},[e]),n},Io=({children:e,onRefresh:n,isRefreshing:s})=>wo(so)?e:r.jsx(Ms,{onRefresh:n,isPullable:!s,children:e}),jo=e=>e===1?"message":"messages";function ko({count:e,onReview:n,onDismiss:s,actionLabel:t="Review & rescue"}){return r.jsx(Ft,{tone:"info",variant:"soft",onDismiss:s,children:r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsxs("p",{className:"flex items-start gap-2 text-sm text-fg",children:[r.jsx(vt,{className:"mt-0.5 size-4 shrink-0 text-positive","aria-hidden":!0}),r.jsxs("span",{children:[r.jsx("span",{className:"font-semibold text-fg",children:`${e} ${jo(e)} here`})," ","may not be spam — they're from senders we can verify."]})]}),r.jsx(le,{variant:"primary",size:"sm",onClick:n,className:"self-start",children:t})]})})}const Mo=(e,n)=>e==="vip"?"vip":e==="unknown"&&n==="md"?"unknown-pill":"hidden",xs=({senderTrust:e,size:n="sm",className:s})=>{const t=Mo(e,n);return t==="vip"?r.jsx(Ts,{className:Be("text-warning shrink-0",n==="sm"&&"size-3.5",n==="md"&&"size-4",s),"aria-label":"VIP sender","data-testid":"sender-trust-vip"}):t==="unknown-pill"?r.jsx("span",{className:Be("inline-flex items-center rounded border border-dashed border-fg-subtle/40 font-medium uppercase tracking-wide text-fg-muted/80 shrink-0","px-2 py-0.5 text-xs",s),title:"First message from this sender","aria-label":"First message from this sender","data-testid":"sender-trust-unknown",children:"new"}):null};function To({candidate:e,selected:n,onToggle:s,hideSender:t=!1}){const{senderName:o,senderAddress:i,subject:c,snippet:a,trustReason:u,trustSubReason:d,senderTrust:f}=e;return r.jsxs("label",{className:Be("flex w-full cursor-pointer items-start gap-3 px-3 py-2.5 text-left transition-colors",t&&"pl-11",n?"bg-positive/10":"bg-surface hover:bg-surface-sunken"),children:[r.jsx(ss,{className:"mt-0.5",checked:n,onChange:s,"aria-label":`${n?"Deselect":"Select"} ${t?c:`message from ${o}`}`}),!t&&r.jsx($t,{name:o,email:i,size:"sm"}),r.jsxs("span",{className:"min-w-0 flex-1",children:[!t&&r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"truncate text-sm font-medium text-fg",children:o}),f&&r.jsx(xs,{senderTrust:f,size:"sm"}),r.jsx("span",{className:"truncate text-2xs text-fg-subtle",children:i})]}),r.jsx("span",{className:"block truncate text-sm text-fg-muted",children:c}),r.jsx("span",{className:"block line-clamp-1 text-xs text-fg-subtle",children:a}),!t&&r.jsxs("span",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[r.jsxs(Gt,{tone:"positive",children:[r.jsx(vt,{className:"size-3","aria-hidden":!0}),u]}),r.jsx("span",{className:"text-2xs text-fg-subtle",children:d})]})]})]})}const Ro=e=>{const n=new Map,s=[];for(const t of e){const o=(t.senderAddress||t.senderName).toLowerCase(),i=n.get(o);if(i){i.messages.push(t);continue}n.set(o,{key:o,senderName:t.senderName,senderAddress:t.senderAddress,trustReason:t.trustReason,trustSubReason:t.trustSubReason,senderTrust:t.senderTrust,messages:[t]}),s.push(o)}return s.map(t=>n.get(t)).sort((t,o)=>o.messages.length-t.messages.length)},Eo=(e,n)=>{const s=e.messages.filter(t=>n.has(t.id)).length;return s===0?"none":s===e.messages.length?"all":"some"},Ht=e=>e===1?"message":"messages";function Oo({group:e,selected:n,onToggleGroup:s,onToggleMessage:t}){const[o,i]=l.useState(!1),c=Eo(e,n),a=e.messages.length,u=o?Rs:Es;return r.jsxs("div",{className:Be(c!=="none"?"bg-positive/10":"bg-surface"),children:[r.jsxs("div",{className:"flex w-full items-start gap-3 px-3 py-2.5",children:[r.jsx(ss,{className:"mt-0.5",checked:c==="all",indeterminate:c==="some",onChange:()=>s(e,c!=="all"),"aria-label":`${c==="all"?"Deselect":"Select"} all ${a} ${Ht(a)} from ${e.senderName}`}),r.jsx($t,{name:e.senderName,email:e.senderAddress,size:"sm"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"truncate text-sm font-medium text-fg",children:e.senderName}),e.senderTrust&&r.jsx(xs,{senderTrust:e.senderTrust,size:"sm"}),r.jsx("span",{className:"truncate text-2xs text-fg-subtle",children:e.senderAddress})]}),r.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[r.jsxs(Gt,{tone:"positive",children:[r.jsx(vt,{className:"size-3","aria-hidden":!0}),e.trustReason]}),r.jsx("span",{className:"text-2xs text-fg-subtle",children:e.trustSubReason})]})]}),r.jsxs("button",{type:"button",onClick:()=>i(d=>!d),"aria-expanded":o,className:"flex shrink-0 items-center gap-1 rounded-md px-1.5 py-1 text-2xs text-fg-muted transition-colors hover:bg-surface-sunken hover:text-fg",children:[`${a} ${Ht(a)}`,r.jsx(u,{className:"size-3.5","aria-hidden":!0})]})]}),o&&r.jsx("div",{className:"divide-y divide-line border-t border-line",children:e.messages.map(d=>r.jsx(To,{candidate:d,selected:n.has(d.id),onToggle:()=>t(d.id),hideSender:!0},d.id))})]})}const Bt=e=>e===1?"message":"messages",Ao=(e,n)=>`Moves ${e===1?"this message":`these ${e} ${Bt(e)}`} out of Spam to ${n} now. Nothing later.`,Dt=(e,n)=>e.find(s=>s.id===n)?.label??"Inbox";function No(){return r.jsx(Ft,{tone:"info",variant:"soft",children:r.jsx("p",{className:"text-2xs text-fg-muted",children:"We list a message here only when we can confirm the sender is who they say — usually someone you've emailed before, write to often, or a service that consistently checks out. We never guess from words in the subject. Anything we can't confirm stays in Spam."})})}function zo({candidates:e,selected:n,onToggle:s,onToggleGroup:t,onSelectAll:o,onSelectNone:i,onContinue:c,onCancel:a}){const[u,d]=l.useState(!1),f=n.size,g=l.useMemo(()=>Ro(e),[e]);return r.jsxs("div",{className:"flex min-h-0 flex-col",children:[r.jsxs("div",{className:"px-row-inset pb-2 pt-1",children:[r.jsxs("div",{className:"flex items-start justify-between gap-2",children:[r.jsxs("h2",{className:"flex items-center gap-2 text-sm font-semibold text-fg",children:[r.jsx(vt,{className:"size-4 text-positive","aria-hidden":!0}),"Rescue from Spam"]}),r.jsx(le,{variant:"ghost",size:"sm",icon:r.jsx(ho,{className:"size-3.5"}),onClick:()=>d(m=>!m),className:"-mr-1.5 -mt-0.5",children:"Why these?"})]}),r.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:"These look safe — from senders we can verify. Uncheck any sender that belongs in Spam, or open a sender to pick individual messages."}),u&&r.jsx("div",{className:"mt-2",children:r.jsx(No,{})})]}),r.jsxs("div",{className:"flex items-center justify-between px-row-inset pb-1.5",children:[r.jsx("span",{className:"text-2xs font-medium text-fg-muted",children:`${f} of ${e.length} selected · ${g.length} ${g.length===1?"sender":"senders"}`}),r.jsxs("span",{className:"flex gap-1",children:[r.jsx(le,{variant:"ghost",size:"sm",onClick:o,children:"Select all"}),r.jsx(le,{variant:"ghost",size:"sm",onClick:i,children:"Select none"})]})]}),r.jsx("div",{className:"min-h-0 flex-1 divide-y divide-line overflow-y-auto border-y border-line",children:g.map(m=>r.jsx(Oo,{group:m,selected:n,onToggleGroup:t,onToggleMessage:s},m.key))}),r.jsxs("div",{className:"space-y-2 border-t border-line bg-surface px-row-inset py-3",children:[r.jsx(le,{variant:"primary",onClick:c,className:"h-11 w-full font-semibold",children:`Continue with ${f} ${Bt(f)}`}),r.jsx(le,{variant:"ghost",onClick:a,className:"h-11 w-full",children:"Cancel"})]})]})}function Do({count:e,folders:n,delimiter:s,destination:t,onPick:o,onMove:i,onBack:c}){const[a,u]=l.useState(!1);return r.jsxs("div",{className:"flex min-h-0 flex-col",children:[r.jsxs("div",{className:"px-row-inset pb-2 pt-1",children:[r.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Where should they go?"}),r.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:"Pick a folder, then we move them out of Spam."})]}),r.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-y-auto px-row-inset py-2",children:a?r.jsx("div",{className:"flex min-h-0 flex-1 overflow-hidden rounded-xl border border-line bg-surface",children:r.jsx(Os,{folders:n,selectedId:t,delimiter:s,onSelect:o,onCancel:()=>u(!1)})}):r.jsxs("div",{className:"rounded-xl border border-line bg-surface-sunken p-3",children:[r.jsx("p",{className:"text-2xs text-fg-subtle",children:"Destination"}),r.jsx("p",{className:"mt-0.5 text-sm font-medium text-fg",children:Dt(n,t)}),r.jsx(le,{variant:"ghost",size:"sm",onClick:()=>u(!0),className:"mt-2 px-0",children:"Move to a different folder"})]})}),r.jsxs("div",{className:"space-y-2 border-t border-line bg-surface px-row-inset py-3",children:[r.jsx("p",{className:"text-2xs text-fg-subtle",children:Ao(e,Dt(n,t))}),r.jsx(le,{variant:"primary",onClick:i,className:"h-11 w-full font-semibold",children:`Move ${e} out of Spam`}),r.jsx(le,{variant:"ghost",onClick:c,className:"h-11 w-full",children:"Back"})]})]})}function Fo({count:e,destinationLabel:n,onClose:s}){return r.jsxs("div",{className:"flex min-h-0 flex-col",children:[r.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-row-inset py-10 text-center",children:[r.jsx(fo,{className:"size-10 text-positive","aria-hidden":!0}),r.jsx("p",{className:"text-base font-semibold text-fg",children:`Moved ${e} ${Bt(e)} out of Spam.`}),r.jsx("p",{className:"text-2xs text-fg-subtle",children:`You'll find them in ${n}.`})]}),r.jsx("div",{className:"border-t border-line bg-surface px-row-inset py-3",children:r.jsx(le,{variant:"primary",onClick:s,className:"h-11 w-full font-semibold",children:"Done"})})]})}function _o({open:e,candidates:n,defaultDestinationId:s,availableFolders:t,delimiter:o,onConfirmMove:i,onCancel:c}){const[a,u]=l.useState("review"),[d,f]=l.useState(()=>e?new Set(n.map(w=>w.id)):new Set),[g,m]=l.useState(s),[y,C]=l.useState(0),I=l.useRef(!1);l.useEffect(()=>{e&&!I.current&&(u("review"),f(new Set(n.map(w=>w.id))),m(s),C(0)),I.current=e},[e,n,s]);const T=d.size,x=w=>{f(j=>{const R=new Set(j);return R.has(w)?R.delete(w):R.add(w),R})},p=(w,j)=>{f(R=>{const E=new Set(R);for(const A of w.messages)j?E.add(A.id):E.delete(A.id);return E})},k=()=>{const w=Array.from(d);C(w.length),i(w,g),u("done")};return r.jsxs(uo,{open:e,onClose:c,dismissLabel:"Close rescue",children:[a==="review"&&r.jsx(zo,{candidates:n,selected:d,onToggle:x,onToggleGroup:p,onSelectAll:()=>f(new Set(n.map(w=>w.id))),onSelectNone:()=>f(new Set),onContinue:()=>u("destination"),onCancel:c}),a==="destination"&&r.jsx(Do,{count:T,folders:t,delimiter:o,destination:g,onPick:m,onMove:k,onBack:()=>u("review")}),a==="done"&&r.jsx(Fo,{count:y,destinationLabel:Dt(t,g),onClose:c})]})}const Lo={reply:"Reply",reply_all:"Reply All",forward:"Forward",new:"New Message"},Po=()=>{const e=l.useRef(!1);return l.useCallback(()=>{const s=document.querySelector("[data-subject-field]")?.value??"",i=(document.querySelector('[data-testid="compose-body"]')?.textContent??"").replace(/--\s*/g,"").trim();return e.current=s.trim().length>0||i.length>0,e.current},[])},$o=()=>{const{state:e,closeCompose:n}=bt(),s=Po(),[t,o]=l.useState(!1),{isError:i,error:c,refetch:a}=Ze({...Yt(),staleTime:1/0}),u=l.useCallback(m=>{m||(s()?o(!0):n())},[n,s]),d=l.useCallback(()=>{o(!1),n()},[n]),f=l.useCallback(()=>{o(!1)},[]);if(!e.isOpen)return null;const g=Lo[e.mode]??"New Message";return r.jsxs(Pe.Root,{open:e.isOpen,onOpenChange:u,children:[r.jsxs(Pe.Portal,{children:[r.jsx(Pe.Overlay,{className:"fixed inset-0 z-40 bg-black/40"}),r.jsxs(Pe.Content,{className:"fixed inset-x-0 bottom-0 z-50 flex flex-col rounded-t-lg bg-canvas pb-[env(safe-area-inset-bottom,0px)]",style:{height:"95dvh"},children:[r.jsx(Pe.Handle,{className:"mx-auto mt-2 mb-1 h-1.5 w-12 rounded-full bg-fg-muted/30"}),r.jsx(Pe.Title,{className:"px-4 py-2 text-base font-semibold border-b border-line",children:g}),i?r.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:r.jsx(fs,{title:"Couldn't load compose",error:c,onRetry:()=>{a()}})}):r.jsx("div",{className:"flex-1 overflow-hidden",children:r.jsx(ns,{mode:e.mode,account:e.account,sourceMessage:e.sourceMessage,onClose:n})})]})]}),r.jsx(gs,{isOpen:t,title:"Discard draft?",description:"Your message has unsaved content. Are you sure you want to discard it?",confirmLabel:"Discard",cancelLabel:"Keep editing",destructive:!0,onConfirm:d,onCancel:f})]})},Bo={reply:"Reply",reply_all:"Reply All",forward:"Forward",new:"New Message"},bs=()=>{const{state:e,closeCompose:n}=bt(),s=ms(),{isError:t,error:o,refetch:i}=Ze({...Yt(),staleTime:1/0});if(!s)return r.jsx($o,{});if(!e.isOpen)return null;const c=Bo[e.mode]??"New Message",a=r.jsxs("header",{className:"flex items-center justify-between gap-2 px-4 py-3 border-b border-line shrink-0",children:[r.jsx("div",{className:"flex items-center gap-2 min-w-0",children:r.jsx("h2",{className:"text-lg font-semibold truncate",children:c})}),r.jsx("button",{type:"button",onClick:n,className:"p-2 rounded-md hover:bg-surface-raised transition-colors min-h-11 min-w-11 inline-flex items-center justify-center","aria-label":"Close",children:r.jsx(As,{className:"size-5"})})]});return t?r.jsxs("div",{className:"h-full flex flex-col bg-canvas",children:[a,r.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:r.jsx(fs,{title:"Couldn't load compose",error:o,onRetry:()=>{i()}})})]}):r.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-canvas",children:[a,r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:r.jsx(ns,{mode:e.mode,account:e.account,sourceMessage:e.sourceMessage,onClose:n},e.outboxMessageId??"new")})]})};function Wo(e){const n=e.toAddresses.join(", ");return{id:e.outboxMessageId,accountId:e.accountId,fromName:e.fromName??e.fromAddress??"Me",fromEmail:e.fromAddress??"",subject:e.subject??"(No subject)",snippet:n?`To: ${n}`:"(No recipients)",timeLabel:et(e.updatedAt),isRead:!0}}function Ko(e){return{id:e.messageId,accountId:e.accountId,fromName:e.fromName??e.fromEmail??"Unknown",fromEmail:e.fromEmail??"",subject:e.subject??"(No subject)",snippet:e.snippet??"",timeLabel:et(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0}}function Vo({outboxMessages:e,accountId:n,imapThreads:s}){const t=e.filter(c=>c.status==="draft"&&c.accountId===n).map(Wo),o=s.map(Ko),i=[];return t.length>0&&i.push({id:"remit-drafts",label:"Not yet sent (Remit)",threads:t}),o.length>0&&i.push({id:"imap-drafts",label:"On the server",threads:o}),i}const qo=({label:e,count:n})=>r.jsxs("div",{className:"sticky top-0 z-10 flex items-baseline justify-between border-b border-line bg-surface-sunken px-row-inset py-1",children:[r.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:e}),r.jsx("span",{className:"text-2xs text-fg-subtle tabular-nums",children:n})]}),Ho=({row:e,isSelected:n,onOpen:s,onDelete:t,isDeleting:o})=>r.jsxs("button",{type:"button",onClick:()=>s(e.id),className:Be("group",is({active:n})),children:[r.jsx(Ds,{className:"size-7 shrink-0 text-fg-muted mt-0.5"}),r.jsx(os,{thread:e}),r.jsx("div",{className:"flex items-center gap-1 shrink-0",children:r.jsx("button",{type:"button",onClick:i=>{i.stopPropagation(),t(e.id)},disabled:o,className:"p-1.5 rounded-md text-fg-muted hover:text-danger hover:bg-surface-raised transition-colors opacity-0 group-hover:opacity-100 focus:opacity-100",title:"Delete draft",children:r.jsx(Fs,{className:"size-3.5"})})})]}),Uo=({row:e,isSelected:n,onOpen:s})=>{const t=!e.isRead;return r.jsxs("button",{type:"button",onClick:()=>s(e.id),className:Be("group",is({active:n})),children:[t&&r.jsx("span",{className:"absolute left-1.5 top-1/2 size-1.5 -translate-y-1/2 rounded-full bg-accent"}),r.jsx($t,{name:e.fromName,email:e.fromEmail,size:"sm"}),r.jsx(os,{thread:e})]})};function Qo({mailboxId:e,accountId:n,selectedMessageId:s,imapThreads:t,title:o,unreadCount:i}){const{openCompose:c,state:a}=bt(),u=We(),d=_t(),{data:f}=Ze(Ns()),g=l.useMemo(()=>Vo({outboxMessages:f?.items??[],accountId:n,imapThreads:t}),[f?.items,n,t]),m=Lt({...Zt(),onSuccess:()=>{d.invalidateQueries({queryKey:Xt()})}}),y=x=>{m.mutate({path:{outboxMessageId:x}})},C=x=>{c({mode:"new",outboxMessageId:x})},I=x=>{u({to:"/mail/$mailboxId",params:{mailboxId:e},search:{selectedMessageId:x}})},T=g.length===0;return r.jsxs("section",{className:"flex h-full w-full flex-col bg-surface",children:[r.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[r.jsx(io,{}),r.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:o}),(i??0)>0&&r.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:[i," unread"]})]}),r.jsx("div",{className:"flex-1 overflow-y-auto",children:T?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 text-center px-4",children:[r.jsx(zs,{className:"size-8 text-fg-subtle"}),r.jsx("p",{className:"text-sm font-medium text-fg",children:"No drafts"}),r.jsx("p",{className:"text-xs text-fg-subtle",children:"Messages you start composing will appear here."})]}):g.map(x=>r.jsxs("div",{children:[x.label&&r.jsx(qo,{label:x.label,count:x.threads.length}),r.jsx("div",{className:"divide-y divide-line",children:x.threads.map(p=>x.id==="remit-drafts"?r.jsx(Ho,{row:p,isSelected:a.isOpen&&p.id===a.outboxMessageId,onOpen:C,onDelete:y,isDeleting:m.isPending},p.id):r.jsx(Uo,{row:p,isSelected:p.id===s,onOpen:I},p.id))})]},x.id))})]})}function Jo(e,n,s){const t=new Array(e);return new Proxy(t,{get(o,i,c){if(typeof i=="string"){const a=i.charCodeAt(0);if(a>=48&&a<=57){const u=+i;if(Number.isInteger(u)&&u>=0&&u<e){let d=o[u];if(!d){const f=n[u*2];d=o[u]={index:u,key:s(u),start:f,size:n[u*2+1],end:f+n[u*2+1],lane:0}}return d}}if(i==="length")return e}return Reflect.get(o,i,c)}})}function $e(e,n,s){let t=s.initialDeps??[],o,i=!0;function c(){const a=e();return(a.length!==t.length||a.some((d,f)=>t[f]!==d))&&(t=a,o=n(...a),s?.onChange&&!(i&&s.skipInitialOnChange)&&s.onChange(o),i=!1),o}return c.updateDeps=a=>{t=a},c}function Ut(e,n){if(e===void 0)throw new Error("Unexpected undefined");return e}const Go=(e,n)=>Math.abs(e-n)<1.01,Yo=(e,n,s)=>{let t;return function(...o){e.clearTimeout(t),t=e.setTimeout(()=>n.apply(this,o),s)}};let Xe;const Nt=()=>{if(Xe!==void 0)return Xe;if(typeof navigator>"u")return Xe=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Xe=!0;const e=navigator.maxTouchPoints;return Xe=navigator.platform==="MacIntel"&&e!==void 0&&e>0},Qt=e=>{const{offsetWidth:n,offsetHeight:s}=e;return{width:n,height:s}},Xo=e=>e,Zo=e=>{const n=Math.max(e.startIndex-e.overscan,0),t=Math.min(e.endIndex+e.overscan,e.count-1)-n+1,o=new Array(t);for(let i=0;i<t;i++)o[i]=n+i;return o},ei=(e,n)=>{const s=e.scrollElement;if(!s)return;const t=e.targetWindow;if(!t)return;const o=c=>{const{width:a,height:u}=c;n({width:Math.round(a),height:Math.round(u)})};if(o(Qt(s)),!t.ResizeObserver)return()=>{};const i=new t.ResizeObserver(c=>{const a=()=>{const u=c[0];if(u?.borderBoxSize){const d=u.borderBoxSize[0];if(d){o({width:d.inlineSize,height:d.blockSize});return}}o(Qt(s))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return i.observe(s,{box:"border-box"}),()=>{i.unobserve(s)}},xt={passive:!0},ti=typeof window>"u"?!0:"onscrollend"in window,si=(e,n,s)=>{const t=e.scrollElement;if(!t)return;const o=e.targetWindow;if(!o)return;const i=e.options.useScrollendEvent&&ti;let c=0;const a=i?null:Yo(o,()=>n(c,!1),e.options.isScrollingResetDelay),u=g=>()=>{c=s(t),a?.(),n(c,g)},d=u(!0),f=u(!1);return t.addEventListener("scroll",d,xt),i&&t.addEventListener("scrollend",f,xt),()=>{t.removeEventListener("scroll",d),i&&t.removeEventListener("scrollend",f)}},ni=(e,n)=>si(e,n,s=>{const{horizontal:t,isRtl:o}=e.options;return t?s.scrollLeft*(o&&-1||1):s.scrollTop}),oi=(e,n,s)=>{if(s.options.useCachedMeasurements){const t=s.indexFromElement(e),o=s.options.getItemKey(t);return s.itemSizeCache.get(o)??s.options.estimateSize(t)}if(n?.borderBoxSize){const t=n.borderBoxSize[0];if(t)return Math.round(t[s.options.horizontal?"inlineSize":"blockSize"])}if(!n){const t=s.indexFromElement(e),o=s.options.getItemKey(t),i=s.itemSizeCache.get(o);if(i!==void 0)return i}return e[s.options.horizontal?"offsetWidth":"offsetHeight"]},ii=(e,{adjustments:n=0,behavior:s},t)=>{var o,i;(i=(o=t.scrollElement)==null?void 0:o.scrollTo)==null||i.call(o,{[t.options.horizontal?"left":"top"]:e+n,behavior:s})},ri=ii;class ai{constructor(n){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var s,t,o;return((o=(t=(s=this.targetWindow)==null?void 0:s.performance)==null?void 0:t.now)==null?void 0:o.call(t))??Date.now()},this.observer=(()=>{let s=null;const t=()=>s||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:s=new this.targetWindow.ResizeObserver(o=>{o.forEach(i=>{const c=()=>{const a=i.target,u=this.indexFromElement(a);if(!a.isConnected){this.observer.unobserve(a);for(const[d,f]of this.elementsCache)if(f===a){this.elementsCache.delete(d);break}return}this.shouldMeasureDuringScroll(u)&&this.resizeItem(u,this.options.measureElement(a,i,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(c):c()})}));return{disconnect:()=>{var o;(o=t())==null||o.disconnect(),s=null},observe:o=>{var i;return(i=t())==null?void 0:i.observe(o,{box:"border-box"})},unobserve:o=>{var i;return(i=t())==null?void 0:i.unobserve(o)}}})(),this.range=null,this.setOptions=s=>{var t,o;const i={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Xo,rangeExtractor:Zo,onChange:()=>{},measureElement:oi,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const m in s){const y=s[m];y!==void 0&&(i[m]=y)}const c=this.options;let a=null,u=null,d=!1;if(c!==void 0&&c.enabled&&i.enabled&&i.anchorTo==="end"&&this.scrollElement!==null){const m=c.count,y=i.count,C=this.getMeasurements(),I=m>0?((t=C[0])==null?void 0:t.key)??c.getItemKey(0):null,T=m>0?((o=C[m-1])==null?void 0:o.key)??c.getItemKey(m-1):null;if(y!==m||m>0&&y>0&&(i.getItemKey(0)!==I||i.getItemKey(y-1)!==T)){d=!0;const k=m>0?this.getVirtualItemForOffset(this.getScrollOffset())??C[0]:null;k&&(a=[k.key,this.getScrollOffset()-k.start]);const w=i.followOnAppend===!0?"auto":i.followOnAppend||null;w&&y>m&&this.isAtEnd(c.scrollEndThreshold)&&(m===0||i.getItemKey(y-1)!==T)&&(u=w)}}this.options=i,d&&(this.pendingMin=0,this.itemSizeCacheVersion++);let f=!1,g=0;if(a&&this.scrollOffset!==null){const[m,y]=a,C=this.getMeasurements(),{count:I,getItemKey:T}=this.options;let x=0;for(;x<I&&T(x)!==m;)x++;if(x<I){const p=C[x];if(p){const k=p.start+y;k!==this.scrollOffset&&(g=k-this.scrollOffset,this.scrollOffset=k,f=!0)}}}(f||u)&&(this.pendingScrollAnchor=[f?a[0]:null,f?a[1]:0,u,g])},this.notify=s=>{var t,o;(o=(t=this.options).onChange)==null||o.call(t,this,s)},this.maybeNotify=$e(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),s=>{this.notify(s)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(s=>s()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var s;const t=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==t){if(this.cleanup(),!t){this.maybeNotify();return}if(this.scrollElement=t,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((s=this.scrollElement)==null?void 0:s.window)??null,this.elementsCache.forEach(i=>{this.observer.observe(i)}),this.unsubs.push(this.options.observeElementRect(this,i=>{this.scrollRect=i,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(i,c)=>{if(c&&this._intendedScrollOffset===null&&i===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(i-this._intendedScrollOffset)<1.5&&(i=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;const a=this.getScrollOffset();this.scrollDirection=c?a===i?this.scrollDirection:a<i?"forward":"backward":null,this.scrollOffset=i,this.isScrolling=c,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const i=this.scrollElement,c=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},a=()=>{this._iosTouching=!1,!(!Nt()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};i.addEventListener("touchstart",c,xt),i.addEventListener("touchend",a,xt),this.unsubs.push(()=>{i.removeEventListener("touchstart",c),i.removeEventListener("touchend",a),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const o=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,o&&this.scrollElement&&this.options.enabled){const[i,c,a,u]=o;i!==null&&!a&&(Nt()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?u!==0&&(this._iosDeferredAdjustment+=u):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),a&&this.scrollToEnd({behavior:a})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const s=this.getScrollOffset(),t=this.getMaxScrollOffset();if(s<0||s>t)return;const o=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(s,{adjustments:this.scrollAdjustments+=o,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=$e(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(s,t,o,i,c,a,u,d)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:s,paddingStart:t,scrollMargin:o,getItemKey:i,enabled:c,lanes:a,laneAssignmentMode:u,gap:d}),{key:!1}),this.getMeasurements=$e(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:s,paddingStart:t,scrollMargin:o,getItemKey:i,enabled:c,lanes:a,laneAssignmentMode:u,gap:d},f)=>{const g=this.itemSizeCache;if(!c)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>s)for(const x of this.laneAssignments.keys())x>=s&&this.laneAssignments.delete(x);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(x=>{this.itemSizeCache.set(x.key,x.size)}));const m=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===s&&(this.lanesSettling=!1),a===1){const x=s*2;let p=this._flatMeasurements;if(!p||p.length<x){const j=new Float64Array(x);p&&m>0&&j.set(p.subarray(0,m*2)),p=j,this._flatMeasurements=p}let k;if(m===0)k=t+o;else{const j=m-1;k=p[j*2]+p[j*2+1]+d}for(let j=m;j<s;j++){const R=i(j),E=g.get(R),A=typeof E=="number"?E:this.options.estimateSize(j);p[j*2]=k,p[j*2+1]=A,k+=A+d}const w=Jo(s,p,i);return this.measurementsCache=w,w}const y=this.measurementsCache.slice(0,m),C=new Array(a).fill(void 0),I=new Float64Array(a);let T=0;for(let x=0;x<m;x++){const p=y[x];p&&(C[p.lane]===void 0&&T++,C[p.lane]=x,I[p.lane]=p.end)}for(let x=m;x<s;x++){const p=i(x),k=this.laneAssignments.get(x);let w,j;const R=u==="estimate"||g.has(p);if(k!==void 0&&this.options.lanes>1){w=k;const _=C[w],N=_!==void 0?y[_]:void 0;j=N?N.end+d:t+o}else if(T===a){let _=0,N=I[0],L=C[0];for(let U=1;U<a;U++){const ee=I[U];(ee<N||ee===N&&C[U]<L)&&(_=U,N=ee,L=C[U])}w=_,j=N+d,R&&this.laneAssignments.set(x,w)}else w=x%this.options.lanes,j=t+o,R&&this.laneAssignments.set(x,w);const E=g.get(p),A=typeof E=="number"?E:this.options.estimateSize(x),z=j+A;y[x]={index:x,start:j,size:A,end:z,key:p,lane:w},C[w]===void 0&&T++,C[w]=x,I[w]=z}return this.measurementsCache=y,y},{key:!1,debug:()=>this.options.debug}),this.calculateRange=$e(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(s,t,o,i)=>s.length===0||t===0?(this.range=null,null):(this.range=ci(s,t,o,i,i===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=$e(()=>{let s=null,t=null;const o=this.calculateRange();return o&&(s=o.startIndex,t=o.endIndex),this.maybeNotify.updateDeps([this.isScrolling,s,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,s,t]},(s,t,o,i,c)=>i===null||c===null?[]:s({startIndex:i,endIndex:c,overscan:t,count:o}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=s=>{const t=this.options.indexAttribute,o=s.getAttribute(t);return o?parseInt(o,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=s=>{var t;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const o=this.scrollState.index??((t=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:t.index);if(o!==void 0&&this.range){const i=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),c=Math.max(0,o-i),a=Math.min(this.options.count-1,o+i);return s>=c&&s<=a}return!0},this.measureElement=s=>{if(!s){this.elementsCache.forEach((c,a)=>{c.isConnected||(this.observer.unobserve(c),this.elementsCache.delete(a))});return}const t=this.indexFromElement(s),o=this.options.getItemKey(t),i=this.elementsCache.get(o);i!==s&&(i&&this.observer.unobserve(i),this.observer.observe(s),this.elementsCache.set(o,s)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(s,void 0,this))},this.resizeItem=(s,t)=>{var o,i;if(s<0||s>=this.options.count)return;let c,a,u;const d=this._flatMeasurements;if(this.options.lanes===1&&d!==null)u=this.options.getItemKey(s),a=d[s*2],c=d[s*2+1];else{const m=this.measurementsCache[s];if(!m)return;u=m.key,a=m.start,c=m.size}const f=this.itemSizeCache.get(u)??c,g=t-f;if(g!==0){const m=this.options.anchorTo==="end"&&((o=this.scrollState)==null?void 0:o.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,y=m?this.getTotalSize():0,C=((i=this.scrollState)==null?void 0:i.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[s]??{index:s,key:u,start:a,size:c,end:a+c,lane:0},g,this):a<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(u)||this.scrollDirection!=="backward"));(this.pendingMin===null||s<this.pendingMin)&&(this.pendingMin=s),this.itemSizeCache.set(u,t),this.itemSizeCacheVersion++,m?this.applyScrollAdjustment(this.getTotalSize()-y):C&&this.applyScrollAdjustment(g),this.notify(!1)}},this.getVirtualItems=$e(()=>[this.getVirtualIndexes(),this.getMeasurements()],(s,t)=>{const o=[];for(let i=0,c=s.length;i<c;i++){const a=s[i],u=t[a];o.push(u)}return o},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=s=>{const t=this.getMeasurements();if(t.length===0)return;const o=this._flatMeasurements,i=this.options.lanes===1&&o!=null,c=vs(0,t.length-1,i?a=>o[a*2]:a=>Ut(t[a]).start,s);return Ut(t[c])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const s=this.scrollElement.document.documentElement;return this.options.horizontal?s.scrollWidth-this.scrollElement.innerWidth:s.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(s=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=s,this.getOffsetForAlignment=(s,t,o=0)=>{if(!this.scrollElement)return 0;const i=this.getSize(),c=this.getScrollOffset();t==="auto"&&(t=s>=c+i?"end":"start"),t==="center"?s+=(o-i)/2:t==="end"&&(s-=i);const a=this.getMaxScrollOffset();return Math.max(Math.min(a,s),0)},this.getOffsetForIndex=(s,t="auto")=>{s=Math.max(0,Math.min(s,this.options.count-1));const o=this.getSize(),i=this.getScrollOffset(),c=this.measurementsCache[s];if(!c)return;if(t==="auto")if(c.end>=i+o-this.options.scrollPaddingEnd)t="end";else if(c.start<=i+this.options.scrollPaddingStart)t="start";else return[i,t];if(t==="end"&&s===this.options.count-1)return[this.getMaxScrollOffset(),t];const a=t==="end"?c.end+this.options.scrollPaddingEnd:c.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,c.size),t]},this.scrollToOffset=(s,{align:t="start",behavior:o="auto"}={})=>{const i=this.getOffsetForAlignment(s,t),c=this.now();this.scrollState={index:null,align:t,behavior:o,startedAt:c,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollToIndex=(s,{align:t="auto",behavior:o="auto"}={})=>{s=Math.max(0,Math.min(s,this.options.count-1));const i=this.getOffsetForIndex(s,t);if(!i)return;const[c,a]=i,u=this.now();this.scrollState={index:s,align:a,behavior:o,startedAt:u,lastTargetOffset:c,stableFrames:0},this._scrollToOffset(c,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollBy=(s,{behavior:t="auto"}={})=>{const o=this.getScrollOffset()+s,i=this.now();this.scrollState={index:null,align:"start",behavior:t,startedAt:i,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:s="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:s});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:s})},this.getTotalSize=()=>{var s;const t=this.getMeasurements();let o;if(t.length===0)o=this.options.paddingStart;else if(this.options.lanes===1){const i=t.length-1,c=this._flatMeasurements;c!=null?o=c[i*2]+c[i*2+1]:o=((s=t[i])==null?void 0:s.end)??0}else{const i=Array(this.options.lanes).fill(null);let c=t.length-1;for(;c>=0&&i.some(a=>a===null);){const a=t[c];i[a.lane]===null&&(i[a.lane]=a.end),c--}o=Math.max(...i.filter(a=>a!==null))}return Math.max(o-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const s=[];if(this.itemSizeCache.size===0)return s;const t=this.getMeasurements();for(const o of t)o&&this.itemSizeCache.has(o.key)&&s.push({index:o.index,key:o.key,start:o.start,size:o.size,end:o.end,lane:o.lane});return s},this._scrollToOffset=(s,{adjustments:t,behavior:o})=>{this._intendedScrollOffset=s+(t??0),this.options.scrollToFn(s,{behavior:o,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(n)}applyScrollAdjustment(n,s){n!==0&&(Nt()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=n:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=n,behavior:s}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollAdjustments=0)))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const t=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,o=t?t[0]:this.scrollState.lastTargetOffset,i=1,c=o!==this.scrollState.lastTargetOffset;if(!c&&Go(o,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=i){this.getScrollOffset()!==o&&this._scrollToOffset(o,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,c){const a=this.getSize()||600,u=Math.abs(o-this.getScrollOffset()),d=this.scrollState.behavior==="smooth"&&u>a;this.scrollState.lastTargetOffset=o,d||(this.scrollState.behavior="auto"),this._scrollToOffset(o,{adjustments:void 0,behavior:d?"smooth":"auto"})}this.scheduleScrollReconcile()}}const vs=(e,n,s,t)=>{for(;e<=n;){const o=(e+n)/2|0,i=s(o);if(i<t)e=o+1;else if(i>t)n=o-1;else return o}return e>0?e-1:0};function li(e,n,s){let t=0;for(;t<=n;){const o=(t+n)/2|0,i=e[o*2];if(i<s)t=o+1;else if(i>s)n=o-1;else return o}return t>0?t-1:0}function ci(e,n,s,t,o){const i=e.length-1;if(e.length<=t)return{startIndex:0,endIndex:i};if(t===1&&o!==null){const d=li(o,i,s);let f=d;const g=s+n;for(;f<i&&o[f*2]+o[f*2+1]<g;)f++;return{startIndex:d,endIndex:f}}let a=vs(0,i,d=>e[d].start,s),u=a;if(t===1)for(;u<i&&e[u].end<s+n;)u++;else if(t>1){const d=Array(t).fill(0);for(;u<i&&d.some(g=>g<s+n);){const g=e[u];d[g.lane]=g.end,u++}const f=Array(t).fill(s+n);for(;a>=0&&f.some(g=>g>=s);){const g=e[a];f[g.lane]=g.start,a--}a=Math.max(0,a-a%t),u=Math.min(i,u+(t-1-u%t))}return{startIndex:a,endIndex:u}}const zt=typeof document<"u"?l.useLayoutEffect:l.useEffect;function ui({useFlushSync:e=!0,directDomUpdates:n=!1,directDomUpdatesMode:s="transform",...t}){const o=l.useReducer(d=>d+1,0)[1],i=l.useRef({enabled:n,mode:s,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});i.current.enabled=n,i.current.mode=s;const c=d=>{const f=i.current;if(!f.enabled||!f.container)return;const g=d.getTotalSize();if(g!==f.lastSize){f.lastSize=g;const x=d.options.horizontal?"width":"height";f.container.style[x]=`${g}px`}const m=!!d.options.horizontal,y=f.mode==="transform",C=m?"left":"top",I=d.options.scrollMargin,T=d.getVirtualItems();for(const x of T){const p=x.start-I,k=d.elementsCache.get(x.key);k&&f.lastPositions.get(k)!==p&&(f.lastPositions.set(k,p),y?k.style.transform=m?`translate3d(${p}px, 0, 0)`:`translate3d(0, ${p}px, 0)`:k.style[C]=`${p}px`)}},a={...t,onChange:(d,f)=>{var g;const m=i.current;let y=!0;if(m.enabled){c(d);const C=d.range,I=m.prevRange;y=!I||I.isScrolling!==d.isScrolling||I.startIndex!==C?.startIndex||I.endIndex!==C?.endIndex,y&&(m.prevRange=C?{startIndex:C.startIndex,endIndex:C.endIndex,isScrolling:d.isScrolling}:null)}y&&(e&&f?_s.flushSync(o):o()),(g=t.onChange)==null||g.call(t,d,f)}},[u]=l.useState(()=>{const d=new ai(a);return Object.assign(d,{containerRef:f=>{const g=i.current;if(g.container=f,g.lastSize=null,f&&g.enabled){const m=d.getTotalSize();g.lastSize=m;const y=d.options.horizontal?"width":"height";f.style[y]=`${m}px`}}})});return u.setOptions(a),zt(()=>u._didMount(),[]),zt(()=>u._willUpdate()),zt(()=>{c(u)}),u}function di(e){return ui({observeElementRect:ei,observeElementOffset:ni,scrollToFn:ri,...e})}const Wt=e=>e.query?`matching "${e.query}"`:e.from?`from "${e.from}"`:"matching your search",hi=e=>`Select all ${Wt(e)}`,fi=(e,n)=>`All ${no(n)} ${Wt(e)} selected`,mi=({verb:e,confirmingDelete:n,hasSelection:s,junkMailboxId:t,currentMailboxId:o,deletableMessageId:i})=>{if(n)return{kind:"withheld"};if(e==="junk"){const c=ln(t,o);if(c!==void 0)return{kind:"unavailable",reason:c}}return s?{kind:"openWizard"}:e!=="delete"||i===void 0?{kind:"declined"}:{kind:"confirmDelete",messageId:i}},gi=(e,n,s)=>e==="BACK"&&n&&s===void 0,pi=(e,n)=>({id:e.messageId,accountId:e.accountId,mailboxId:e.mailboxId,fromName:e.fromName??e.fromEmail??"Unknown",fromEmail:e.fromEmail??"",subject:e.subject??"(No subject)",snippet:e.snippet??"",timeLabel:et(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:rs(e.category),messageCount:n,suspicious:e.authenticity?.dkimMismatch===!0,labels:e.labels}),xi=({thread:e,mailboxId:n,isSelected:s,isFocused:t,isTabStop:o,onFocusRow:i,isChecked:c,onToggleCheck:a,onRowSelect:u,messageCount:d,isMultiSelectMode:f,onLongPress:g,isDesktop:m,density:y})=>r.jsx(cn,{thread:pi(e,d),linkMailboxId:n,inListbox:!0,active:s,focused:t,isTabStop:o,density:y,isDesktop:m,onFocusRow:i,selection:{isChecked:c,onToggleCheck:a,onRowSelect:u,isMultiSelectMode:f,onLongPress:g}}),bi=l.memo(xi),vi=e=>{const n=e.authenticity?.dkimMismatch===!0;return{id:e.messageId,accountId:e.accountId,fromName:e.fromName??e.fromEmail??"Unknown",fromEmail:e.fromEmail??"",subject:e.subject??"(No subject)",snippet:e.snippet??"",timeLabel:et(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:rs(e.category),suspicious:n}},Si=({thread:e,mailboxId:n,isSelected:s,isFocused:t,isTabStop:o,onFocusRow:i,isChecked:c,onToggleCheck:a,onRowSelect:u,isMultiSelectMode:d,onLongPress:f,isDesktop:g,onDelete:m,onToggleRead:y,density:C})=>{const[I,T]=l.useState("none"),x=We(),p=l.useCallback(E=>{navigator.vibrate?.(10),E==="trailing"?m(e.messageId):y(e.messageId,e.isRead),T("none")},[m,y,e.messageId,e.isRead]),k=l.useCallback(()=>{f(e.messageId)},[f,e.messageId]),w=l.useCallback(()=>{a(e.messageId)},[a,e.messageId]),j=l.useCallback(()=>{x({to:"/mail/$mailboxId",params:{mailboxId:n},search:E=>({...E,selectedMessageId:e.messageId})})},[x,n,e.messageId]),R=un(e.messageId,u);return g||d?r.jsx(bi,{thread:e,mailboxId:n,isSelected:s,isFocused:t,isTabStop:o,onFocusRow:i,isChecked:c,onToggleCheck:a,onRowSelect:u,isMultiSelectMode:d,onLongPress:f,isDesktop:g,density:C}):r.jsx("div",{role:"presentation",onPointerDownCapture:R.onMouseDown,onClickCapture:R.claimClick,onContextMenu:R.onContextMenu,children:r.jsx(Gn,{thread:vi(e),selectionMode:!1,checked:!1,active:s,peek:I,onPeek:T,onToggleCheck:w,onLongPress:k,onOpen:j,onAct:p})})},yi=72,Ci=32,wi=5,Ss="remit:list-density",Ii=()=>{try{const e=localStorage.getItem(Ss);if(e==="compact"||e==="comfortable")return e}catch{}return"comfortable"},ji=({query:e})=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-line bg-surface-sunken/30",children:[r.jsx(Ks,{className:"size-4 text-fg-muted"}),r.jsxs("span",{className:"text-sm text-fg-muted",children:["Results for “",e,"”"]})]}),ki=({mailboxId:e,threads:n,selectedMessageId:s,isLoading:t,isError:o=!1,error:i,onRetry:c,searchQuery:a,searchPredicate:u,onDeleteMessages:d,isDeleting:f=!1,isMoving:g=!1,onLoadMore:m,hasMore:y=!1,isLoadingMore:C=!1,accountId:I,listTitle:T,listMeta:x,listFilter:p,listScopeLabel:k,onTriageContextChange:w,commandsRef:j,hideHeader:R=!1})=>{const E=l.useRef(null),A=We(),z=ms(),_=Ls(),{verb:N,start:L,startFromSearch:U}=_,ee=Ps(),Se=!!a?.trim(),P=dn(),{labels:Ke}=ro(I),{pushError:oe}=es(),[M,ye]=l.useState(s),[Ce,Q]=l.useState(),$=l.useCallback(h=>{Q(b=>b===h?b:void 0),ye(h)},[]),[ge,H]=l.useState(Ii),Re=l.useCallback(()=>{H(h=>{const b=h==="comfortable"?"compact":"comfortable";try{localStorage.setItem(Ss,b)}catch{}return b})},[]),{toggleReadFor:Ee}=as({mailboxId:e}),{junkMailboxId:pe}=ls(I),ie=cs(pe,e),{selectedIds:Y,selectedCount:te,hasSelection:X,isSelected:we,toggle:Z,select:ce,clearSelection:B,selectRange:xe,setAnchor:tt,selectAll:O,toggleAll:st,intersectWith:nt}=hn(),Oe=In(te,z),[D,Ae]=l.useState(null),Ie=Se&&!!u,Ve=`${e}|${JSON.stringify(u??{})}`,v=fn({mailboxId:e,accountId:I,enabled:Ie,predicateKey:Ve,searchQuery:u??{}}),ot=l.useCallback((h,b,ae)=>{if(ae.error===void 0){if(ae.cancelled){oe({severity:"warning",title:gn(ae.done),detail:mn(h,ae.done,b)});return}oe({severity:"info",title:Kt(h,ae.done)})}},[oe]),qe=v.phase.kind,it=v.clear,W=l.useCallback(()=>{qe==="escalated"&&it(),B()},[B,it,qe]),[rt,ue]=l.useState(null),de=l.useRef(null),se=l.useRef(!1),Ne=l.useRef(null),je=!t&&n.length>0,K=D!==null,ke=di({count:n.length,getScrollElement:()=>E.current,estimateSize:()=>ge==="compact"?Ci:yi,overscan:wi}),at=s?n.findIndex(h=>h.messageId===s):-1,ne=M?n.findIndex(h=>h.messageId===M):-1,F=l.useCallback(h=>{if(h<0||h>=n.length)return;const b=n[h];if(Oe){Z(b.messageId);return}de.current=b.messageId,se.current=!1,Q(b.messageId),ye(b.messageId)},[n,Oe,Z]),He=l.useCallback(()=>{if(n.length===0)return;const h=ne<0?0:Math.min(ne+1,n.length-1);F(h)},[n.length,ne,F]),he=l.useCallback(()=>{if(n.length===0)return;const h=ne<=0?0:ne-1;F(h)},[n.length,ne,F]),lt=l.useCallback(()=>F(0),[F]),Ue=l.useCallback(()=>F(n.length-1),[F,n.length]),Qe=l.useCallback(()=>{M&&Z(M)},[M,Z]),V=l.useMemo(()=>n.map(h=>h.messageId),[n]),yt=l.useMemo(()=>{const h=[];for(const b of n)Y.has(b.messageId)&&h.push({id:b.messageId,sender:b.fromName??b.fromEmail??"Unknown",email:b.fromEmail??"",subject:b.subject??"(No subject)",date:et(b.sentDate)});return h},[n,Y]),ct=l.useCallback((h,b)=>b.shiftKey?(xe(V,h,M),!0):b.metaKey||b.ctrlKey?(Z(h),!0):(W(),tt(h),!1),[V,M,xe,Z,W,tt]),ze=l.useCallback(h=>{!d||h.length===0||(Ne.current=M??null,Ae(h))},[d,M]),Me=l.useCallback(h=>{const b=pn(V,M,h);b!==void 0&&(xe(V,b),de.current=b,se.current=!1,Q(void 0),ye(b))},[V,M,xe]),be=l.useCallback(()=>Me(-1),[Me]),Je=l.useCallback(()=>Me(1),[Me]),De=l.useCallback(()=>{V.length>0&&O(V)},[V,O]),ut=l.useCallback(h=>{const b=mi({verb:h,confirmingDelete:D!==null,hasSelection:X,junkMailboxId:pe,currentMailboxId:e,deletableMessageId:d?M:void 0});return b.kind==="openWizard"?(L(h),!0):b.kind==="confirmDelete"?(ze([b.messageId]),!0):b.kind==="unavailable"?(oe({severity:"warning",title:b.reason}),!0):b.kind==="withheld"},[D,d,X,pe,e,L,M,ze,oe]),Ge=l.useCallback(()=>{M&&A({to:"/mail/$mailboxId",params:{mailboxId:e},search:h=>({...h,selectedMessageId:M})})},[M,A,e]),dt=l.useCallback(h=>{A({to:"/mail/$mailboxId",params:{mailboxId:e},search:b=>({...b,selectedMessageId:h}),replace:!0})},[A,e]);xn({keyboardFocusedMessageId:Ce,openMessageId:s,enabled:z&&te===0,open:dt});const fe=v.phase.kind==="escalated"?{scope:Wt(u??{}),total:v.phase.total,searchQuery:u??{},run:h=>v.runAction(h),stop:v.stop}:void 0,Fe=l.useCallback(()=>{if(!D)return;const h=D;if(h.length===0){Ae(null);return}const b=new Set(h),ae=n.findIndex(q=>b.has(q.messageId));let me;for(let q=ae+1;q<n.length;q++)if(!b.has(n[q].messageId)){me=n[q].messageId;break}if(me===void 0){for(let q=ae-1;q>=0;q--)if(!b.has(n[q].messageId)){me=n[q].messageId;break}}d?.(h),W(),Ne.current=null,Ae(null),me!==void 0&&(de.current=me,se.current=!1,$(me),z&&A({to:"/mail/$mailboxId",params:{mailboxId:e},search:q=>({...q,selectedMessageId:me}),replace:!0})),z||ue(Kt("delete",h.length))},[D,n,d,W,A,e,z,$]),_e=l.useCallback(()=>{const h=Ne.current;Ne.current=null,Ae(null),h!==null&&(de.current=h,se.current=!1,$(h))},[$]),re=l.useMemo(()=>{if(te===0)return;const h=new Set;for(const b of n)Y.has(b.messageId)&&h.add(b.accountConfigId);if(h.size>1)return"Move only works within one account — clear selection or pick messages from a single account"},[te,Y,n]),Ct=l.useCallback(()=>{if(fe){U();return}L("organize")},[fe,U,L]),wt=l.useCallback(h=>{d?.([h])},[d]),It=l.useCallback((h,b)=>{Ee([h],!b)},[Ee]),ve=l.useCallback(h=>{z||ce(h)},[z,ce]),jt=l.useCallback(()=>{if(v.isRunning||v.phase.kind==="counting"){v.stop();return}W()},[v,W]),kt=l.useCallback(()=>{v.clear()},[v]);l.useEffect(()=>{if(se.current||!z&&s)return;const h=ne>=0?ne:at;h>=0&&ke.scrollToIndex(h,{align:"auto"})},[ne,at,ke,z,s]),l.useEffect(()=>{s&&(se.current=!1,$(s))},[s,$]),l.useEffect(()=>{M&&(n.some(h=>h.messageId===M)||$(n[0]?.messageId))},[n,M,$]),l.useEffect(()=>{w?.({focusedMessageId:M,selectedIds:Array.from(Y),hasList:je,blocksKeyboard:K||_.isOpen})},[M,Y,je,K,_.isOpen,w]);const ht=l.useRef(w);ht.current=w,l.useEffect(()=>()=>ht.current?.({focusedMessageId:void 0,selectedIds:[],hasList:!1,blocksKeyboard:!1}),[]),l.useEffect(()=>{v.phase.kind!=="idle"||v.isRunning||nt(n.map(h=>h.messageId))},[n,nt,v.phase,v.isRunning]);const ft=l.useRef(e);l.useEffect(()=>{ft.current!==e&&(ft.current=e,W())},[e,W]),bn({shouldBlockFn:({action:h})=>gi(h,X,ee)?(W(),!0):!1,enableBeforeUnload:!1,disabled:!X||ee!==void 0}),l.useEffect(()=>{const h=E.current;if(!h||!y||!m)return;const b=()=>{if(C)return;const{scrollTop:ae,scrollHeight:me,clientHeight:q}=h;ae+q>=me-200&&m()};return h.addEventListener("scroll",b,{passive:!0}),b(),()=>h.removeEventListener("scroll",b)},[y,C,m]),l.useEffect(()=>{const h=de.current;if(!h)return;const b=E.current?.querySelector(`[data-message-id="${h}"]`);b&&(de.current=null,b.focus({preventScroll:!0}))}),l.useEffect(()=>{if(j){if(!je){j.current=null;return}return j.current={focusNext:He,focusPrevious:he,focusFirst:lt,focusLast:Ue,openFocused:Ge,toggleSelect:Qe,extendSelectDown:Je,extendSelectUp:be,selectAll:De,clearSelection:()=>X?(W(),!0):!1,requestVerb:ut,toggleDensity:Re},()=>{j.current=null}}},[j,je,He,he,lt,Ue,Ge,Qe,Je,be,De,X,W,ut,Re]);const mt=t?"loading":o?"error":n.length===0?"empty":"ready",Mt=o?to(i):void 0,Tt=l.useCallback(()=>{const h=$s(Bs());window.open(h,"_blank","noopener,noreferrer")},[]),Te=[{id:"inbox",threads:[]}],Le=V.length>0&&V.every(h=>Y.has(h)),gt=Ie&&y&&Le&&!f&&!g&&v.phase.kind==="idle"&&!v.isRunning,Rt=f||g||v.isRunning,Ye=v.phase.kind==="escalated"?v.phase.total:te,Et=v.runningAction?vn(v.runningAction.kind,v.progress?.done??0,v.progress?.total??Ye):v.phase.kind==="counting"?"Counting matches…":v.phase.kind==="escalated"?fi(u??{},v.phase.total):void 0,Ot=v.phase.kind!=="escalated"&&V.length>0?{checked:Le,indeterminate:te>0&&!Le,onChange:()=>st(V)}:void 0,At=v.runningAction?{value:v.progress?.done??0,max:v.progress?.total??Ye,tone:Sn(v.runningAction.kind)}:void 0,J=(v.phase.kind==="counting"?{tone:"info",text:"",action:{label:"Stop",onClick:v.stop}}:v.phase.kind==="escalated"&&!v.isRunning?{tone:"info",text:"",action:{label:"Clear selection",onClick:kt}}:gt?{tone:"info",text:"",action:{label:hi(u??{}),onClick:v.escalate}}:void 0)??(re?{tone:"warning",text:re}:void 0),G=r.jsx(yn,{title:P.title||T,navSlot:P.navSlot,titleMeta:P.titleMeta,searchSlot:P.searchSlot,searchField:P.searchField,idleSlot:P.makeFilterSlot,count:Ye,onCancel:jt,onDelete:()=>L("delete"),onMove:()=>L("move"),onOrganize:Ct,onJunk:ie?()=>L("junk"):void 0,onMarkRead:()=>L("markRead"),overflowSlot:I&&e&&te>0&&Ke.length>0?r.jsx(ao,{accountId:I,mailboxId:e,messageIds:Array.from(Y)}):void 0,isBusy:Rt,isCounting:v.phase.kind==="counting",selectAll:Ot,statusLabel:Et,progress:At,notice:J}),Is=Cn(V,M),js=l.useCallback(h=>{se.current=!0,$(h)},[$]),ks=r.jsxs(r.Fragment,{children:[Se&&a&&r.jsx(ji,{query:a}),r.jsxs("div",{ref:E,role:"listbox","aria-multiselectable":!0,"aria-label":T,className:"flex-1 overflow-y-auto",children:[r.jsx("div",{role:"presentation",className:"relative w-full",style:{height:`${ke.getTotalSize()}px`},children:ke.getVirtualItems().map(h=>{const b=n[h.index];return r.jsx("div",{role:"presentation","data-index":h.index,ref:ke.measureElement,className:Ws("absolute left-0 top-0 w-full border-b border-line",v.isRunning&&"pointer-events-none opacity-50"),style:{transform:`translateY(${h.start}px)`},children:r.jsx(Si,{thread:b,mailboxId:e,isSelected:s===b.messageId,isFocused:M===b.messageId,isTabStop:Is===b.messageId,onFocusRow:js,isChecked:we(b.messageId),onToggleCheck:Z,onRowSelect:ct,isMultiSelectMode:Oe,onLongPress:ve,isDesktop:z,onDelete:wt,onToggleRead:It,density:ge})},h.key)})}),C&&r.jsx(Yn,{})]})]});return r.jsxs(r.Fragment,{children:[rt&&!z&&r.jsx(Ft,{tone:"success",variant:"soft",className:"m-2 rounded-md",onDismiss:()=>ue(null),children:rt}),r.jsx(Xn,{listTitle:T,listMeta:x,sections:Te,flatList:!0,listState:P.searchResults?"ready":mt,searchQuery:Se?a:void 0,listFilter:p,listScopeLabel:k,errorMessage:Mt,onRetry:c,onReportError:Tt,density:ge,selectedThreadId:s,onSelectThread:h=>A({to:"/mail/$mailboxId",params:{mailboxId:e},search:b=>({...b,selectedMessageId:h})}),isDesktop:z,hideHeader:R,selectionBar:G,listBody:P.searchResults??(mt==="ready"?ks:void 0)}),r.jsx(gs,{isOpen:D!==null,title:oo(D?.length??0),description:"You can restore them from Trash later.",confirmLabel:"Move to Trash",destructive:!0,isBusy:f,onConfirm:Fe,onCancel:_e}),r.jsx(wn,{verb:N,accountId:I,mailboxId:e,selection:yt,crossAccount:re!==void 0,escalated:fe,escalatedProgress:v.progress,onFinished:W,onRunEnded:ot})]})},Mi=e=>qs({path:{accountId:e}}),Ti=e=>{const n=_t(),s=Pt(),t=Lt({...Vs(),onSuccess:()=>{s.recordEvent("sync.triggered"),n.invalidateQueries({queryKey:Mi(e)})}});return{trigger:()=>{t.mutate({path:{accountId:e}})},triggerAsync:()=>t.mutateAsync({path:{accountId:e}}),isPending:t.isPending,error:t.error,reset:t.reset}},Ri=({accountId:e,children:n})=>{const{triggerAsync:s,isPending:t}=Ti(e);return r.jsx(Io,{onRefresh:s,isRefreshing:t,children:n})};function Ei({accountId:e,currentMailboxId:n,candidates:s,onMove:t,children:o}){const[i,c]=l.useState(!1),a=Pt(),u=mo(),{inboxMailboxId:d}=jn(e),f=kn(e),{data:g}=Ze({...Hs({path:{accountId:e}}),staleTime:1/0}),m=l.useMemo(()=>go({mailboxes:g?.items??[],folderAppointments:f,currentMailboxId:n,translator:u}),[g?.items,f,n,u]),y=l.useMemo(()=>d||(m.find(p=>p.label.toLowerCase()==="inbox")?.id??m.find(p=>!p.isCurrent)?.id??""),[d,m]),C=l.useRef(!1);l.useEffect(()=>{C.current||(C.current=!0,Mn(a,s.length))},[a,s.length]);const I=l.useCallback(()=>{Tn(a,s.length),c(!0)},[a,s.length]),T=l.useCallback((x,p)=>{Rn(a,{selected:x.length,total:s.length,toInbox:p===d}),t(x,p)},[a,s.length,d,t]);return r.jsxs("div",{className:"relative flex h-full min-h-0 flex-col",children:[r.jsx("div",{className:"shrink-0 px-row-inset pt-2",children:r.jsx(ko,{count:s.length,onReview:I})}),r.jsx("div",{className:"min-h-0 flex-1",children:o}),r.jsx(_o,{open:i,candidates:s,defaultDestinationId:y,availableFolders:m,delimiter:po(g?.items??[]),onConfirmMove:T,onCancel:()=>c(!1)})]})}const Oi="We can verify this sender";function Ai(e){const{data:n}=Ze({...Us({path:{mailboxId:e??""},query:{senderTrust:["vip","wellknown"],dkimMismatch:!1,results:!0,limit:500}}),enabled:!!e,staleTime:6e4});return{candidates:(n?.items??[]).map(t=>({id:t.messageId,senderName:t.fromName||t.fromEmail||"Unknown sender",senderAddress:t.fromEmail??"",subject:t.subject||"(no subject)",snippet:t.snippet??"",trustReason:Oi,trustSubReason:En(t.senderTrust),senderTrust:t.senderTrust}))}}const Ni=e=>{const n=new Set,s=[];for(const t of e)n.has(t.threadMessageId)||(n.add(t.threadMessageId),s.push(t));return s},zi={unread:"unread",flagged:"starred",attachment:"attachments"},Di=new Set(Object.values(So)),ys=e=>Di.has(e),Fi=e=>ys(e.category)||e.attributes.size>0,_i=e=>{const n={};ys(e.category)&&(n.category=[e.category]);for(const s of e.attributes){const t=zi[s];t&&(n[t]=!0)}return n},Li=e=>(e.senderTrust?.length??0)>0||e.dkimMismatch!==void 0?"loaded-pages":"whole-folder",Pi=["category","unread","starred","attachments"],Jt=e=>JSON.stringify(Pi.map(n=>e?.[n]??null)),$i=e=>{if(!Array.isArray(e))return;const[n]=e;if(typeof n!="object"||n===null)return;const s=n.query;if(!(typeof s!="object"||s===null))return s},Bi=(e,n)=>{const s=$i(e);return s?Jt(s)===Jt(n):!1},Wi=(e,n)=>e!==n,Ki=(e,n,s)=>{if(!(s||!n))return e.find(t=>t.messageId===n)},Vi=(e,n,s,t)=>{if(e)return e;if(!(t||!s))return n?.messageId===s?n:void 0},pt=e=>e[0],qi=e=>{const n=pt(e.filter(a=>a.type==="from").map(a=>a.value)),s=pt(e.filter(a=>a.type==="subject").map(a=>a.value)),t=pt(e.filter(a=>a.type==="category").map(a=>a.category)),o=pt(e.filter(a=>a.type==="isUnread"||a.type==="isRead").map(a=>a.type==="isUnread")),i=e.some(a=>a.type==="isStarred")?!0:void 0,c=e.some(a=>a.type==="hasAttachment")?!0:void 0;return{...n!==void 0?{from:n}:{},...s!==void 0?{subject:s}:{},...t!==void 0?{category:[t]}:{},...o!==void 0?{unread:o}:{},...i!==void 0?{starred:i}:{},...c!==void 0?{attachments:c}:{}}},Hi=(e,n)=>{switch(n.type){case"from":return e.from?.toLowerCase()===n.value.toLowerCase();case"subject":return e.subject?.toLowerCase()===n.value.toLowerCase();case"category":return e.category?.length===1&&e.category[0]===n.category;case"isUnread":return e.unread===!0;case"isRead":return e.unread===!1;case"isStarred":return e.starred===!0;case"hasAttachment":return e.attachments===!0;case"before":case"after":case"in":case"account":return!1}};function Ui(e,n={}){const s=qi(e),t={...s,...n};return{params:s,residual:e.filter(o=>!Hi(t,o))}}function Qi(e,n,s){if(n.length===0)return e;const t=[...n];return e.filter(o=>{const i=On(o);return An({...i,accountId:i.accountId??s},t)})}const Ji=50,Gi=new Map(hs().categories.filter(e=>e.id!=="all").map(e=>[e.id,e.label])),Cs=l.createContext(null);function St(){const e=l.useContext(Cs);if(!e)throw new Error("MailboxPane.* must be used inside <MailboxPane>");return e}function Yi({mailboxId:e,selectedMessageId:n,children:s}){const t=We(),i=ps()==="desktop",c=Pt(),{accounts:a,searchQuery:u,searchInput:d,intelligenceOpen:f,onToggleIntelligence:g,onSetIntelligenceOpen:m}=ts(),y=tn(),C=Co(u),I=C.length>0,{freeText:T,tokens:x}=sn(C,y),[p,k]=l.useState("all"),[w,j]=l.useState(new Set),R=l.useMemo(()=>({category:p,attributes:w}),[p,w]),E=l.useMemo(()=>_i(R),[R]),A=I||Fi(R),{params:z,residual:_}=Ui(x,E),N={order:"desc",limit:Ji,...T?{query:T}:{},...z,...E},L={category:N.category,unread:N.unread,starred:N.starred,attachments:N.attachments},U=A?Qs({path:{mailboxId:e},query:N}):Js({path:{mailboxId:e},query:{order:"desc"}}),{data:ee,isLoading:Se,isError:P,error:Ke,refetch:oe,fetchNextPage:M,hasNextPage:ye,isFetchingNextPage:Ce}=Zn({queryKey:U,queryFn:async({pageParam:S})=>{if(A){const{data:G}=await Zs({path:{mailboxId:e},query:{...N,continuationToken:S},throwOnError:!0});return G}const{data:J}=await en({path:{mailboxId:e},query:{order:"desc",continuationToken:S},throwOnError:!0});return J},initialPageParam:void 0,getNextPageParam:S=>S.continuationToken,placeholderData:(S,J)=>Bi(J?.queryKey,L)?S:void 0}),Q=l.useCallback(S=>{n&&S.includes(n)&&t({to:"/mail/$mailboxId",params:{mailboxId:e},search:J=>({...J,selectedMessageId:void 0,selectedThreadId:void 0})})},[n,e,t]),{deleteMessages:$,isPending:ge}=Vt({mailboxId:e,onAfterOptimisticRemove:Q}),{accountId:H}=Nn(e),Re=xo({accounts:a}),{moveMessages:Ee,isPending:pe}=qt({mailboxId:e,accountId:H,onAfterOptimisticRemove:Q}),ie=Qi(zn(Ni(ee?.pages.flatMap(S=>S.items??[])??[])),_,H),Y=l.useCallback(S=>{k(S)},[]),te=l.useCallback(S=>{j(J=>{const G=new Set(J);return G.has(S)?G.delete(S):G.add(S),G})},[]),X=l.useCallback(()=>{k("all"),j(new Set)},[]),we=Gi.get(p),Z=we?{label:we,reach:_.length>0?"loaded-pages":Li(N),onClear:X}:void 0,ce=Wi(d,u),B=Ki(ie,n,ce),[xe,tt]=l.useState(void 0);l.useEffect(()=>{B&&tt(B)},[B]);const O=Vi(B,xe,n,ce),{selectedThreadId:st}=Gs({strict:!1}),nt=l.useMemo(()=>lo(O,{messageId:n,threadId:ce?void 0:st,mailboxId:e}),[O,n,st,ce,e]),Oe=Dn(),{listCommandsRef:D,onTriageContextChange:Ae,focusedMessageId:Ie,selectedIds:Ve}=Oe,v=ie.find(S=>S.messageId===Ie)??O,ot=l.useRef(null);l.useEffect(()=>{const S=O?.messageId??null;S&&ot.current!==S&&O?.authenticity?.dkimMismatch&&(ot.current=S,f||g())},[O?.messageId,O?.authenticity?.dkimMismatch,f,g]);const qe=l.useRef(!1);l.useEffect(()=>{qe.current||i&&O?.messageId&&(qe.current=!0,yo()&&!f&&m(!0))},[i,O?.messageId,f,m]);const it=bo({accounts:a})??0,W=_t(),{pushError:rt}=es(),ue=Fn({thread:O,mailboxId:e,accountId:H,onAfterOptimisticRemove:Q}),{draftsMailboxId:de}=_n(H),se=de!==void 0&&de===e,{archiveMailboxId:Ne}=Ln(H),je=Pn(),{requestCompose:K}=ue,ke=l.useCallback(()=>{K("reply")},[K]),at=l.useCallback(()=>{K("reply_all")},[K]),ne=l.useCallback(()=>{K("forward")},[K]),{state:F,openCompose:He,closeCompose:he}=bt(),lt=l.useCallback(()=>{He({mode:"new"})},[He]),Ue=l.useRef(n);l.useEffect(()=>{const S=Ue.current;Ue.current=n,!(!n||n===S)&&he()},[n,he]);const Qe=Lt({...Zt(),onError:S=>{rt(Ys("Couldn't discard draft","The draft wasn't deleted.",S))}}),V=l.useCallback(()=>{const S=F.outboxMessageId;S&&(Qe.mutate({path:{outboxMessageId:S}}),W.invalidateQueries({queryKey:Xt()}),he())},[F.outboxMessageId,Qe,W,he]),yt=l.useCallback(()=>{t({to:"/mail/$mailboxId",params:{mailboxId:e},search:S=>({...S,selectedMessageId:void 0,selectedThreadId:void 0})})},[e,t]),ct=l.useCallback(S=>S?je(S):[],[je]),{toggleStar:ze}=$n({threadId:v?.threadId??"",mailboxId:e}),{toggleReadFor:Me}=as({mailboxId:e,accountId:H}),{junkMailboxId:be}=ls(H),Je=be!=null&&be===e,De=cs(be,e),{candidates:ut}=Ai(Je?be:void 0),{moveMessages:Ge}=qt({mailboxId:e,threadId:v?.threadId,accountId:H,onAfterOptimisticRemove:Q}),{deleteMessages:dt}=Vt({mailboxId:e,threadId:v?.threadId,onAfterOptimisticRemove:Q}),{addressId:fe,address:Fe}=Bn(v),{updateFlags:_e}=Wn({addressId:fe,senderEmail:v?.fromEmail??void 0}),re=l.useCallback(()=>n||!Ie?!1:(t({to:"/mail/$mailboxId",params:{mailboxId:e},search:S=>({...S,selectedMessageId:Ie})}),!0),[n,Ie,e,t]),Ct=l.useCallback(()=>{re()||O&&K("reply")},[re,O,K]),wt=l.useCallback(()=>{re()||O&&K("reply_all")},[re,O,K]),It=l.useCallback(()=>{re()||O&&K("forward")},[re,O,K]),ve=l.useCallback(()=>ct(v),[ct,v]),jt=l.useCallback(()=>{if(D.current?.requestVerb("delete"))return;const S=ve();S.length>0&&dt(S)},[D,ve,dt]),kt=l.useCallback(()=>{if(D.current?.requestVerb("junk")||!De)return;const S=ve();S.length!==0&&(Kn(c,{count:S.length,senderTrust:v?.senderTrust??"unknown",wasRescuable:v?Vn(v):!1}),Ge(S,De))},[D,De,ve,Ge,c,v]),ht=l.useCallback(()=>{if(Ve.length>0){const S=!(v?.hasStars??!1),J=new Set(Ve);for(const G of ie)J.has(G.messageId)&&G.hasStars!==S&&ze(G.messageId,G.hasStars);return}v&&ze(v.messageId,v.hasStars)},[Ve,ie,v,ze]),ft=l.useCallback(()=>{if(D.current?.requestVerb("markRead"))return;const S=ve();if(S.length===0)return;const J=!(v?.isRead??!1);Me(S,J)},[D,ve,v,Me]),mt=l.useCallback(()=>{if(!fe)return;const S=Fe?.flags?.muted?.value!==!0;_e({muted:{value:S}})},[fe,Fe,_e]),Mt=l.useCallback(()=>{if(!fe)return;const S=Fe?.flags?.vip?.value!==!0;_e({vip:{value:S}})},[fe,Fe,_e]),Tt=l.useCallback(()=>{f||g()},[f,g]),Te=l.useCallback(S=>{t({to:S})},[t]),Le=se?"drafts":Ne===e?"archive":be===e?"junk":"inbox",gt=l.useRef("");l.useEffect(()=>{const S=gt.current;gt.current=C,C.length>0&&S.length===0&&c.recordEvent("search.submitted",{mailboxType:Le})},[C,Le,c]);const Rt=se&&F.isOpen&&!!F.outboxMessageId&&!O,{goBack:Ye,nextMessageId:Et,previousMessageId:Ot}=qn({context:Oe,orderedIds:ie.map(S=>S.messageId),selectedMessageId:n,enabled:!F.isOpen,onClose:yt,handlers:{reply:Ct,replyAll:wt,forward:It,delete:jt,toggleStar:ht,toggleRead:ft,muteSender:mt,blockSender:Tt,vipSender:Mt,markJunk:kt,toggleIntelligence:O?g:void 0,compose:lt,goBrief:()=>Te("/mail/brief"),goInbox:()=>Te("/mail/brief"),goSent:()=>Te("/mail/brief"),goFlagged:()=>Te("/mail/flagged"),goSettings:()=>Te("/settings")}});vo({enabled:F.isOpen,bindings:[{key:"Escape",handler:he,preventDefault:!0}]});const At={mailboxId:e,selectedMessageId:n,selectedThread:O,conversation:nt,threads:ie,isLoading:Se,isError:P,error:Ke,mailboxAccountId:H,mailboxName:Re,unreadCount:it,isDraftsMailbox:se,isSpamFolder:Je,rescueCandidates:ut,filterCategory:p,filterAttributes:w,onSelectFilterCategory:Y,onToggleFilterAttribute:te,onClearFilters:X,listFilter:Z,intelligenceOpen:f,onToggleIntelligence:g,handleDeselectIfRemoved:Q,searchPredicate:I&&_.length===0?N:void 0,onDeleteMessages:$,onMoveMessages:Ee,isDeleting:ge,isMoving:pe,onLoadMore:M,hasMore:ye,isLoadingMore:Ce,onTriageContextChange:Ae,listCommandsRef:D,onRetry:()=>oe(),toolbarComposeRequest:ue.composeRequest,onToolbarReply:ke,onToolbarReplyAll:at,onToolbarForward:ne,onClearComposeRequest:ue.clearComposeRequest,onToolbarDelete:ue.deleteThread,onToolbarStar:ue.toggleStar,onToolbarDiscardDraft:V,onToolbarMove:ue.moveThread,composeState:F,closeCompose:he,hasRemitDraftOpen:Rt,onBack:Ye,nextMessageId:Et,previousMessageId:Ot};return r.jsx(Cs.Provider,{value:At,children:s})}function ws(){const{mailboxId:e,selectedMessageId:n,threads:s,isLoading:t,isError:o,error:i,onDeleteMessages:c,onMoveMessages:a,isDeleting:u,isMoving:d,onLoadMore:f,hasMore:g,isLoadingMore:m,mailboxAccountId:y,mailboxName:C,unreadCount:I,isDraftsMailbox:T,isSpamFolder:x,rescueCandidates:p,onTriageContextChange:k,listCommandsRef:w,onRetry:j,filterCategory:R,filterAttributes:E,onSelectFilterCategory:A,onToggleFilterAttribute:z,onClearFilters:_,listFilter:N,searchPredicate:L}=St(),{searchQuery:U,searchInput:ee,accounts:Se,resultFolderIndex:P}=ts(),Ke=ps(),oe=We(),M=C??"Inbox",ye=l.useMemo(()=>hs(),[]),Ce=l.useMemo(()=>y?[y]:[],[y]),{hasNewMail:Q}=on(),{state:$,errorMessage:ge,refresh:H}=rn(Ce,{onSettled:j}),Re=l.useMemo(()=>r.jsx(an,{state:$,onRefresh:H,label:`Refresh ${M}`,errorMessage:ge,hasUpdate:Q(Ce)}),[$,H,M,ge,Q,Ce]),Ee=l.useMemo(()=>s.map(B=>Qn(B,P)),[s,P]),{hits:pe,isLoading:ie}=co({mailboxId:e,filterCategory:R}),Y=l.useMemo(()=>Jn(pe,s.map(B=>B.threadId),P),[pe,s,P]),te=l.useCallback(B=>oe({to:"/mail/$mailboxId",params:{mailboxId:B.mailboxId??e},search:xe=>({...xe,q:ee||void 0,selectedMessageId:B.id,selectedThreadId:B.threadId})}),[e,oe,ee]);if(T&&y)return r.jsx(Qo,{mailboxId:e,accountId:y,selectedMessageId:n,imapThreads:s,title:C??"Drafts",unreadCount:I??void 0});const X=r.jsx(ki,{mailboxId:e,threads:s,selectedMessageId:n,isLoading:t,isError:o,error:i,onRetry:j,searchQuery:U,searchPredicate:L,onDeleteMessages:c,isDeleting:u,isMoving:d,onLoadMore:f,hasMore:g,isLoadingMore:m,accountId:y,listTitle:M,listFilter:N,listScopeLabel:M,hideHeader:!0,onTriageContextChange:k,commandsRef:w}),we=Se[0]?.accountId,Z=Ke==="phone"&&we?r.jsx(Ri,{accountId:we,children:X}):X,ce=x&&p.length>0&&y?r.jsx(Ei,{accountId:y,currentMailboxId:e,candidates:p,onMove:a,children:Z}):Z;return r.jsx(eo,{title:M,unreadCount:I,preset:ye,selectedCategory:R,activeFilters:E,onSelectCategory:A,onToggleFilter:z,onClearFilters:_,searchResults:Ee,searchLoading:t,relatedResults:Y,relatedLoading:ie,onSelectSearchResult:te,searchResultsInBody:!0,refreshControl:Re,children:ce})}function Xi(){const{mailboxId:e,mailboxAccountId:n,selectedThread:s,conversation:t,hasRemitDraftOpen:o,intelligenceOpen:i,onToggleIntelligence:c,toolbarComposeRequest:a,onToolbarReply:u,onToolbarReplyAll:d,onToolbarForward:f,onClearComposeRequest:g,onToolbarDelete:m,onToolbarStar:y,onToolbarDiscardDraft:C,onToolbarMove:I,composeState:T}=St(),x=Xs()?.showIntelligencePane??!1,p=!!t,k=x&&p,w=T.isOpen&&!t?r.jsx(bs,{}):t?r.jsx(us,{threadId:t.threadId,mailboxId:t.mailboxId,subject:t.subject,selectedMessageId:t.messageId,authenticity:t.authenticity,onOpenIntelligence:t.authenticity?.dkimMismatch?c:void 0,composeRequest:a,onComposeClose:g}):r.jsx(nn,{});return r.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[r.jsx(Un,{hasThread:p,intelligenceOpen:k&&i,canToggleIntelligence:k,onToggleIntelligence:c,onReply:p?u:void 0,onReplyAll:p?d:void 0,onForward:p?f:void 0,canDelete:p||o,onDelete:p?m:o?C:void 0,onToggleStar:p?y:void 0,isStarred:s?.hasStars,moveContext:p&&n?{accountId:n,currentMailboxId:e,onMove:I}:void 0}),r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:w})]})}function Zi(){const{mailboxId:e,mailboxAccountId:n,selectedThread:s,onToggleIntelligence:t,handleDeselectIfRemoved:o}=St();return r.jsx(ds,{onClose:t,thread:s,mailboxId:e,accountId:n,onAfterOptimisticRemove:o})}function er(){const{mailboxId:e,mailboxAccountId:n,selectedThread:s,conversation:t,intelligenceOpen:o,onToggleIntelligence:i,onBack:c,nextMessageId:a,previousMessageId:u,composeState:d,handleDeselectIfRemoved:f}=St(),g=We();if(t){const m=y=>g({to:"/mail/$mailboxId",params:{mailboxId:e},search:C=>({...C,selectedMessageId:y,selectedThreadId:void 0})});return r.jsxs(r.Fragment,{children:[r.jsx(us,{threadId:t.threadId,mailboxId:t.mailboxId,subject:t.subject,selectedMessageId:t.messageId,authenticity:t.authenticity,onBack:c,onOpenIntelligence:i,onSwipeNext:a?()=>m(a):void 0,onSwipePrevious:u?()=>m(u):void 0,mobileIntelligenceOpen:o}),r.jsx(Hn,{isOpen:o,onClose:i,ariaLabel:"Message details",side:"right",children:r.jsx(ds,{onClose:i,thread:s,mailboxId:e,accountId:n,hideCloseButton:!0,onAfterOptimisticRemove:f})})]})}return d.isOpen?r.jsx("div",{className:"h-full",children:r.jsx(bs,{})}):r.jsx(ws,{})}const Ir=Object.assign(Yi,{List:ws,Reading:Xi,Intelligence:Zi,Phone:er});export{Ir as M};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a1 as m,j as o,_ as p}from"./index-2IDEAuVk.js";import{a as e}from"./search-view-DgVmeGdu.js";import{M as r}from"./MailboxPane-C6jto7AV.js";import{u as a}from"./useSearchMirror-D0HCJr-S.js";import"./search-scope--Ck4E_N-.js";import"./useSearchTokenContext-CO76ckqM.js";import"./kbd-DChhqIGO.js";import"./enums-CCxx0t2v.js";import"./useRefreshControl-DMDgy7HW.js";import"./circle-check-big-CuTKLMII.js";import"./search-token-index-CjGaBFWZ.js";import"./useMediaQuery-BisfJ3kn.js";import"./MailListHeader-BOSCy5bv.js";import"./account-form-helpers-BYwQxXgp.js";import"./avatar--BbHXv4F.js";import"./useSignature-CvkAmh3B.js";import"./useDebouncedValue-CjDiLKbc.js";import"./ErrorState-C50k8wSf.js";import"./format-De9HZKjg.js";import"./download-CLl5tpC0.js";import"./shield-check-D92P20s8.js";import"./move-options-c2tU4zu_.js";import"./useFilters-DkEunDKz.js";import"./confirm-dialog-Beh3oaKJ.js";import"./clock-TTEOnf9z.js";import"./menu-CZ3Yivjh.js";import"./MailViewChrome-CBOYFcSh.js";import"./NavMenuButton-Dr1eU_Rz.js";import"./useLabels-GspP5G0M.js";import"./conversation-target-Cm8-sdZJ.js";import"./search-query-Cr_ZXBCp.js";import"./bottom-sheet-B99l3DPu.js";import"./circle-help-DnuJPeYC.js";import"./circle-check-C034sO1l.js";import"./intelligence-pref-C6lFpj6U.js";function H(){const{mailboxId:t}=m.useParams(),{selectedMessageId:i}=m.useSearch();return a({to:"/mail/$mailboxId",params:{mailboxId:t}}),o.jsx(r,{mailboxId:t,selectedMessageId:i,children:o.jsx(e,{phone:o.jsx(r.Phone,{}),list:o.jsx(r.List,{}),reading:o.jsx(p,{}),intelligence:o.jsx(r.Intelligence,{}),hasThread:!!i})})}export{H as component};
|
package/assets/brief-BxT7fAQ3.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a2 as i,j as r,_ as m}from"./index-2IDEAuVk.js";import{a as p}from"./search-view-DgVmeGdu.js";import{B as o}from"./BriefPane-a8xrpS_b.js";import{u as e}from"./useSearchMirror-D0HCJr-S.js";import"./search-scope--Ck4E_N-.js";import"./useSearchTokenContext-CO76ckqM.js";import"./kbd-DChhqIGO.js";import"./enums-CCxx0t2v.js";import"./MailListHeader-BOSCy5bv.js";import"./search-token-index-CjGaBFWZ.js";import"./useMediaQuery-BisfJ3kn.js";import"./account-form-helpers-BYwQxXgp.js";import"./avatar--BbHXv4F.js";import"./useSignature-CvkAmh3B.js";import"./useDebouncedValue-CjDiLKbc.js";import"./ErrorState-C50k8wSf.js";import"./format-De9HZKjg.js";import"./download-CLl5tpC0.js";import"./shield-check-D92P20s8.js";import"./move-options-c2tU4zu_.js";import"./useFilters-DkEunDKz.js";import"./confirm-dialog-Beh3oaKJ.js";import"./clock-TTEOnf9z.js";import"./menu-CZ3Yivjh.js";import"./useRefreshControl-DMDgy7HW.js";import"./circle-check-big-CuTKLMII.js";import"./useLabels-GspP5G0M.js";import"./conversation-target-Cm8-sdZJ.js";import"./search-query-Cr_ZXBCp.js";function z(){const{selectedMessageId:t}=i.useSearch();return e({to:"/mail/brief"}),r.jsx(o,{selectedMessageId:t,children:r.jsx(p,{phone:r.jsx(o.Phone,{}),list:r.jsx(o.List,{}),reading:r.jsx(m,{}),intelligence:r.jsx(o.Intelligence,{}),hasThread:!!t})})}export{z as component};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{q as M,ac as C,ae as L,bt as E,bu as A,r as x,j as p,bv as f,bw as j,bx as k,n as R,w as Q,by as D}from"./index-2IDEAuVk.js";import{ah as O,ai as _,aj as q,ak as w,al as z}from"./MailListHeader-BOSCy5bv.js";import{a as N}from"./useLabels-GspP5G0M.js";import{M as P}from"./enums-CCxx0t2v.js";import{u as U,s as B}from"./search-scope--Ck4E_N-.js";import{n as F}from"./search-query-Cr_ZXBCp.js";import{u as G,p as K}from"./useSearchTokenContext-CO76ckqM.js";const V=e=>{const{mailboxId:t,messages:i}=e,l=M(),{pushError:c}=C(),{mutateAsync:r,isPending:a}=L({...A(),onError:(o,u)=>{c({title:u.body.action==="Remove"?"Couldn't remove label":"Couldn't apply label",detail:E(o),error:o})},onSettled:(o,u,d)=>{O(l,_(q(d.body.messageIds??[],i??[],t)))}});return{applyLabel:x.useCallback((o,u,d)=>{o.length!==0&&w(o,m=>r({body:{messageIds:m,labelId:u,action:d}}))},[r]),isPending:a}};function ne({accountId:e,mailboxId:t,messageIds:i}){const{labels:l}=N(e),{applyLabel:c}=V({mailboxId:t}),r=x.useMemo(()=>l.map(a=>({key:a.labelId,label:a.name,icon:p.jsx("span",{className:`size-2.5 rounded-full ${j(a.color)?f[a.color]:f.Default}`}),onSelect:()=>c(i,a.labelId,"Apply")})),[l,i,c]);return r.length===0?null:p.jsx(z,{triggerLabel:"Apply label to selected messages",triggerIcon:p.jsx(k,{className:"size-4 text-fg-subtle"}),triggerText:"Apply label",items:r,align:"start",nested:!0,touch:!1,triggerClassName:"min-h-11 w-full justify-start gap-3 px-4 py-2.5 text-sm font-normal text-fg"})}const $=20,H=new Set(Object.values(P)),J=e=>e!==void 0&&H.has(e)?e:void 0,W=e=>{if(e.some(t=>t.type==="isUnread"))return!1;if(e.some(t=>t.type==="isRead"))return!0};function re({mailboxId:e,filterCategory:t}={}){const{searchQuery:i}=R(),l=G(),c=U({select:s=>s.matches}),r=F(i),{freeText:a,tokens:n}=K(r,l),o=a.length>0,u=n.find(s=>s.type==="category"),d=J(t)??u?.category,m=n.some(s=>s.type==="hasAttachment")?!0:void 0,b=n.some(s=>s.type==="isStarred")?!0:void 0,y=W(n),g=n.find(s=>s.type==="after"),h=n.find(s=>s.type==="before"),I=n.find(s=>s.type==="in"),S=B({matches:c,callerMailboxId:e,inTokenMailboxId:I?.mailboxId}),{data:v,isLoading:T}=Q({...D({query:{query:a,mailboxId:S,limit:$,...d!==void 0?{category:d}:{},...m!==void 0?{hasAttachment:m}:{},...b!==void 0?{hasStars:b}:{},...y!==void 0?{isRead:y}:{},...g?{sentDateFrom:g.epochSeconds}:{},...h?{sentDateTo:h.epochSeconds}:{}}}),enabled:o,staleTime:6e4});return{hits:v?.items??[],isLoading:o&&T}}function X(e){return{threadId:e.threadId,mailboxId:e.mailboxId,subject:e.subject,messageId:e.messageId,authenticity:e.authenticity}}function ie(e,t){if(e)return X(e);if(t.messageId&&t.threadId&&t.mailboxId)return{threadId:t.threadId,mailboxId:t.mailboxId,messageId:t.messageId}}export{ne as L,ie as b,re as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a3 as i,j as o,_ as e}from"./index-2IDEAuVk.js";import{a as m}from"./search-view-DgVmeGdu.js";import{F as t}from"./FlaggedPane-CKu3JMTH.js";import{u as p}from"./useSearchMirror-D0HCJr-S.js";import"./search-scope--Ck4E_N-.js";import"./useSearchTokenContext-CO76ckqM.js";import"./kbd-DChhqIGO.js";import"./enums-CCxx0t2v.js";import"./MailListHeader-BOSCy5bv.js";import"./search-token-index-CjGaBFWZ.js";import"./useMediaQuery-BisfJ3kn.js";import"./account-form-helpers-BYwQxXgp.js";import"./avatar--BbHXv4F.js";import"./useSignature-CvkAmh3B.js";import"./useDebouncedValue-CjDiLKbc.js";import"./ErrorState-C50k8wSf.js";import"./format-De9HZKjg.js";import"./download-CLl5tpC0.js";import"./shield-check-D92P20s8.js";import"./move-options-c2tU4zu_.js";import"./useFilters-DkEunDKz.js";import"./confirm-dialog-Beh3oaKJ.js";import"./clock-TTEOnf9z.js";import"./menu-CZ3Yivjh.js";import"./MailViewChrome-CBOYFcSh.js";function b(){const{selectedMessageId:r}=i.useSearch();return p({to:"/mail/flagged"}),o.jsx(t,{selectedMessageId:r,children:o.jsx(m,{phone:o.jsx(t.Phone,{}),list:o.jsx(t.List,{}),reading:o.jsx(e,{}),intelligence:o.jsx(t.Intelligence,{}),hasThread:!!r})})}export{b as component};
|
package/assets/index-BI_C1qQz.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as o}from"./index-2IDEAuVk.js";import{O as t}from"./OutboxPane-Bd6n9Se3.js";import"./useSearchTokenContext-CO76ckqM.js";import"./kbd-DChhqIGO.js";import"./enums-CCxx0t2v.js";import"./search-scope--Ck4E_N-.js";import"./circle-check-big-CuTKLMII.js";import"./clock-TTEOnf9z.js";import"./row-actions-CVH5R-3R.js";import"./rotate-ccw-BzC7e0ZK.js";import"./NavMenuButton-Dr1eU_Rz.js";import"./menu-CZ3Yivjh.js";import"./format-De9HZKjg.js";import"./outbox-status-CPfNHfUQ.js";import"./search-query-Cr_ZXBCp.js";function c(){return o.jsx(t.Reading,{})}export{c as component};
|
package/assets/index-BgNzrLG4.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as o}from"./index-2IDEAuVk.js";import{M as i}from"./MailboxPane-C6jto7AV.js";import"./useSearchTokenContext-CO76ckqM.js";import"./kbd-DChhqIGO.js";import"./enums-CCxx0t2v.js";import"./search-scope--Ck4E_N-.js";import"./useRefreshControl-DMDgy7HW.js";import"./circle-check-big-CuTKLMII.js";import"./search-token-index-CjGaBFWZ.js";import"./useMediaQuery-BisfJ3kn.js";import"./MailListHeader-BOSCy5bv.js";import"./account-form-helpers-BYwQxXgp.js";import"./avatar--BbHXv4F.js";import"./useSignature-CvkAmh3B.js";import"./useDebouncedValue-CjDiLKbc.js";import"./ErrorState-C50k8wSf.js";import"./format-De9HZKjg.js";import"./download-CLl5tpC0.js";import"./shield-check-D92P20s8.js";import"./move-options-c2tU4zu_.js";import"./useFilters-DkEunDKz.js";import"./confirm-dialog-Beh3oaKJ.js";import"./clock-TTEOnf9z.js";import"./menu-CZ3Yivjh.js";import"./MailViewChrome-CBOYFcSh.js";import"./NavMenuButton-Dr1eU_Rz.js";import"./useLabels-GspP5G0M.js";import"./conversation-target-Cm8-sdZJ.js";import"./search-query-Cr_ZXBCp.js";import"./bottom-sheet-B99l3DPu.js";import"./circle-help-DnuJPeYC.js";import"./circle-check-C034sO1l.js";import"./intelligence-pref-C6lFpj6U.js";function G(){return o.jsx(i.Reading,{})}export{G as component};
|
package/assets/index-C8mdfTeQ.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as t,a6 as o}from"./index-2IDEAuVk.js";const n=()=>t.jsx(o,{to:"/settings/accounts"});export{n as component};
|
package/assets/index-DCsP4GTQ.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as r}from"./index-2IDEAuVk.js";import{B as o}from"./BriefPane-a8xrpS_b.js";import"./useSearchTokenContext-CO76ckqM.js";import"./kbd-DChhqIGO.js";import"./enums-CCxx0t2v.js";import"./search-scope--Ck4E_N-.js";import"./MailListHeader-BOSCy5bv.js";import"./search-token-index-CjGaBFWZ.js";import"./useMediaQuery-BisfJ3kn.js";import"./account-form-helpers-BYwQxXgp.js";import"./avatar--BbHXv4F.js";import"./useSignature-CvkAmh3B.js";import"./useDebouncedValue-CjDiLKbc.js";import"./ErrorState-C50k8wSf.js";import"./format-De9HZKjg.js";import"./download-CLl5tpC0.js";import"./shield-check-D92P20s8.js";import"./move-options-c2tU4zu_.js";import"./useFilters-DkEunDKz.js";import"./confirm-dialog-Beh3oaKJ.js";import"./clock-TTEOnf9z.js";import"./menu-CZ3Yivjh.js";import"./useRefreshControl-DMDgy7HW.js";import"./circle-check-big-CuTKLMII.js";import"./useLabels-GspP5G0M.js";import"./conversation-target-Cm8-sdZJ.js";import"./search-query-Cr_ZXBCp.js";function z(){return r.jsx(o.Reading,{})}export{z as component};
|
package/assets/index-zDF0J9ig.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as o}from"./index-2IDEAuVk.js";import{F as r}from"./FlaggedPane-CKu3JMTH.js";import"./useSearchTokenContext-CO76ckqM.js";import"./kbd-DChhqIGO.js";import"./enums-CCxx0t2v.js";import"./search-scope--Ck4E_N-.js";import"./MailListHeader-BOSCy5bv.js";import"./search-token-index-CjGaBFWZ.js";import"./useMediaQuery-BisfJ3kn.js";import"./account-form-helpers-BYwQxXgp.js";import"./avatar--BbHXv4F.js";import"./useSignature-CvkAmh3B.js";import"./useDebouncedValue-CjDiLKbc.js";import"./ErrorState-C50k8wSf.js";import"./format-De9HZKjg.js";import"./download-CLl5tpC0.js";import"./shield-check-D92P20s8.js";import"./move-options-c2tU4zu_.js";import"./useFilters-DkEunDKz.js";import"./confirm-dialog-Beh3oaKJ.js";import"./clock-TTEOnf9z.js";import"./menu-CZ3Yivjh.js";import"./MailViewChrome-CBOYFcSh.js";function q(){return o.jsx(r.Reading,{})}export{q as component};
|
package/assets/mail-CH5cJzvM.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as L,r as i,u as Le,j as e,S as Fe,a as pe,b as I,C as ee,d as te,e as Te,f as ge,F as De,g as Be,X as be,T as _e,O as Ke,M as Ve,A as qe,h as Qe,I as He,i as ve,B as D,k as U,l as ye,m as $e,n as je,o as Y,p as Se,q as Ne,s as We,t as G,v as J,w as Ce,x as Ue,y as Ye,z as Ge,D as $,E as Je,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}from"./index-2IDEAuVk.js";import{B as xt,S as ht,D as ft,a as pt,b as gt,u as bt,s as vt,N as P,K as yt,c as jt,d as St,e as Nt,f as Ct,g as kt,i as wt}from"./search-token-index-CjGaBFWZ.js";import{u as se,m as It}from"./search-scope--Ck4E_N-.js";import{P as Mt}from"./pencil-DVNcM1UM.js";import{M as Et,s as Ot,c as Rt}from"./search-view-DgVmeGdu.js";import{u as At,a as Pt,R as zt,M as Lt}from"./useRefreshControl-DMDgy7HW.js";import{M as Ft}from"./menu-CZ3Yivjh.js";import{A as Tt}from"./avatar--BbHXv4F.js";import{i as Dt}from"./outbox-status-CPfNHfUQ.js";import{E as Bt}from"./ErrorState-C50k8wSf.js";import{K as ae}from"./kbd-DChhqIGO.js";import{u as _t}from"./useDebouncedValue-CjDiLKbc.js";import{w as ne}from"./intelligence-pref-C6lFpj6U.js";import"./useMediaQuery-BisfJ3kn.js";import"./circle-check-big-CuTKLMII.js";const Kt=L("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 ke=L("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 we=L("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 Ie=L("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 Vt=L("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"}]]),qt="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 Qt({active:t,dimmed:s,indent:a}){return I("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 Ht({icon:t,label:s,count:a,active:n}){return e.jsxs(e.Fragment,{children:[t&&e.jsx("span",{className:I("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:I("text-2xs tabular-nums",n?"text-accent-2":"text-fg-subtle"),children:a})]})}function z({icon:t,label:s,count:a,active:n,dimmed:r,indent:o,navId:l,linkComponent:m,ariaLabel:x,title:p,onClick:b}){const u=Qt({active:n,dimmed:r,indent:o}),h=e.jsx(Ht,{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 $t(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(_e,{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 Wt({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:I("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(Be,{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:I("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 Ut({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:I("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(Kt,{className:"size-4 shrink-0"}),e.jsxs("span",{className:"min-w-0 flex-1 truncate",children:["Save “",s,"”"]})]}),t.map(o=>e.jsx(Wt,{query:o,onSelect:()=>a?.(o),onRemove:n?()=>n(o):void 0},o))]})}function Yt({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 y=!c;return ue(le,t.id,y),y})},u=()=>{m(c=>{const y=!c;return ue(ie,t.id,y),y})},h=t.mailboxes.filter(oe).sort((c,y)=>re[c.role]-re[y.role]),f=t.mailboxes.filter(c=>!oe(c)),v=x||f.length<=H?f:f.slice(0,H),k=f.length-v.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:I("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(xt,{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(Te,{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(z,{navId:c.id,linkComponent:n,icon:$t(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(z,{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:I("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:[v.map(c=>e.jsx(z,{navId:c.id,linkComponent:n,icon:e.jsx(De,{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)),(k>0||x)&&f.length>H&&e.jsx("button",{type:"button",onClick:()=>p(c=>!c),className:I("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 Gt({accounts:t,selectedNavId:s,briefUnseen:a,onSelectNav:n,variant:r="desktop",linkComponent:o,savedSearches:l=[],saveableQuery:m,onSelectSavedSearch:x,onRemoveSavedSearch:p,onSaveCurrentSearch:b}){const u=i.useRef(null);Le({containerRef:u,itemSelector:qt});const h=r==="drawer",f=e.jsxs("nav",{ref:h?u:void 0,className:h?"px-2 py-2":"flex-1 overflow-y-auto px-2 py-2","aria-label":"Mailboxes",children:[e.jsx(z,{navId:"brief",linkComponent:o,icon:e.jsx(Fe,{className:"size-4"}),label:"Daily brief",ariaLabel:"Daily brief",count:a,active:s==="brief",onClick:()=>n?.("brief")}),e.jsx(z,{navId:"flagged",linkComponent:o,icon:e.jsx(pe,{className:"size-4"}),label:"Starred",ariaLabel:"Starred",active:s==="flagged",onClick:()=>n?.("flagged")}),e.jsx(Ut,{savedSearches:l,saveableQuery:m,onSelectSavedSearch:x,onRemoveSavedSearch:p,onSaveCurrentSearch:b}),t.length===0?e.jsx("div",{className:"px-2 py-4 text-center text-sm text-fg-muted",children:"No accounts configured"}):t.map(v=>e.jsx(Yt,{account:v,selectedNavId:s,onSelectNav:n,linkComponent:o},v.id))]});return h?f:e.jsx("aside",{ref:u,className:"flex h-full w-full flex-col bg-surface-sunken",children:f})}function Jt({leading:t,search:s,actions:a,className:n}){return e.jsxs("header",{className:I("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 Xt(){const t=ve();if(!t)return null;const s=t.showNavPane?!t.navCollapsed:!1;return e.jsx(D,{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 Zt={global:"Search all mail",pending:"Search mail",scoped:"Search this folder"};function es({search:t,onCompose:s,onReportBug:a,onOpenSettings:n,composeShortcut:r,refreshControl:o,account:l}){return e.jsx(Jt,{leading:e.jsx(Xt,{}),search:e.jsx(ht,{value:t.value,onChange:t.onChange,onClear:t.onClear,onClearQuery:t.onClearQuery,chips:t.chips,onRemoveChip:t.onRemoveChip,placeholder:Zt[t.scope]}),actions:e.jsxs(e.Fragment,{children:[e.jsx(D,{variant:"ghost",size:"sm",icon:e.jsx(Vt,{className:"size-4"}),title:r?`Compose (${r})`:"Compose","aria-label":"Compose",onClick:s}),e.jsx(D,{variant:"ghost",size:"sm",icon:e.jsx(ke,{className:"size-4"}),title:"Report a bug","aria-label":"Report a bug",onClick:a}),e.jsx(D,{variant:"ghost",size:"sm",icon:e.jsx(Ie,{className:"size-4"}),title:"Settings","aria-label":"Settings",onClick:n}),o,l]})})}const ts=()=>{const{state:t,openCompose:s}=U(),a=ye(),n=i.useCallback(()=>{s({mode:"new"})},[s]),o=!!a.search?.selectedMessageId;return!a.pathname.startsWith("/mail")||t.isOpen||o?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(Mt,{className:"size-6"})})},Me=({children:t})=>{const{Account:s}=$e();return e.jsx(s,{children:t})},ss=({email:t,onSignOut:s})=>{const a=t??"Account";return e.jsxs(ft,{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(pt,{})]}),e.jsxs(gt,{onClick:s,children:[e.jsx(we,{className:"size-4"}),"Sign out"]})]})},as=()=>e.jsx(Me,{children:({email:t,signOut:s})=>e.jsx(ss,{email:t,onSignOut:s})});function ns({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}=bt(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}=At(),{state:f,errorMessage:v,refresh:k}=Pt(u);return e.jsx(es,{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:vt("compose"),refreshControl:e.jsx(zt,{state:f,onRefresh:k,label:"Refresh all accounts",errorMessage:v,hasUpdate:h(u)}),account:e.jsx(as,{})})}const X="remit.savedSearches",rs=25;function _(){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 os(t){const s=t.trim();if(!s)return _();const a=[s,..._().filter(n=>n!==s)].slice(0,rs);try{localStorage.setItem(X,JSON.stringify(a))}catch{return a}return a}function is(t){const s=_().filter(a=>a!==t);try{localStorage.setItem(X,JSON.stringify(s))}catch{return s}return s}const de=t=>/^\d/.test(t),ls=(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 cs(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)=>ls($(o,void 0,a),$(l,void 0,a))),{system:n,labels:r}}function us(t,s,a){const n=Je(s)&&t.unseenCount>0;return{id:t.mailboxId,name:$(t,s,a),unseen:n?t.unseenCount:void 0,role:s,fullPath:t.fullPath}}function ds(){const t=ye(),s=Ge({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=ds(),{searchInput:l,onSearchChange:m}=je(),[x,p]=i.useState(_),{t:b}=We("mail",{useSuspense:!1}),u=i.useCallback((d,S)=>b(d,{defaultValue:S}),[b]),h=G({queries:t.map(d=>({...J({path:{accountId:d.accountId}}),staleTime:1/0}))}),{data:f}=Ce(Ue()),v=i.useMemo(()=>(f?.items??[]).filter(d=>Dt(d.status)).length,[f?.items]),k=i.useMemo(()=>t.map((d,S)=>{const N=h[S],M=N?.data?.items??[],w=Ye(d.folderAppointments),{system:E,labels:Q}=cs(M,w,u),C=N?.isError?"error":N?.isLoading?"loading":"ready";return{id:d.accountId,label:d.email,email:d.email,muted:!!d.muted,outboxPending:v,status:C,onRetry:()=>N?.refetch(),mailboxes:[...E,...Q].map(F=>us(F,w.get(F.mailboxId),u))}}),[t,h,v,u]),g=d=>{n.invalidateQueries({queryKey:Xe({path:{mailboxId:d},query:{order:"desc"}})})},R=({navId:d,className:S,ariaLabel:N,title:M,children:w,onClick:E})=>d==="brief"?e.jsx(P,{to:"/mail/brief",search:{q:void 0,selectedMessageId:void 0},activeOptions:{includeSearch:!1},onClick:()=>E?.(),className:S,"aria-label":N,title:M,children:w}):d==="outbox"?e.jsx(P,{to:"/mail/outbox",search:{q:void 0,selectedOutboxMessageId:void 0},onClick:()=>E?.(),className:S,"aria-label":N,title:M,children:w}):d==="flagged"?e.jsx(P,{to:"/mail/flagged",search:{q:void 0,selectedMessageId:void 0},onClick:()=>E?.(),className:S,"aria-label":N,title:M,children:w}):d==="settings"?e.jsx(P,{to:"/settings/accounts",onClick:()=>E?.(),className:S,"aria-label":N,title:M,children:w}):e.jsx(P,{to:"/mail/$mailboxId",params:{mailboxId:d},search:{q:void 0,selectedMessageId:void 0},onClick:()=>{g(d),E?.()},className:S,"aria-label":N,title:M,children:w}),c=()=>{m(""),s?.()},y=l.trim(),A=y.length>0&&!x.includes(y)?y:void 0,K=i.useCallback(()=>{A&&p(os(A))},[A]),V=i.useCallback(d=>{p(is(d))},[]),q=i.useCallback(d=>{m(d),r({to:"/mail/brief",search:{q:d,selectedMessageId:void 0}}),s?.()},[m,r,s]);return e.jsx(Gt,{accounts:k,selectedNavId:o,onSelectNav:c,linkComponent:R,variant:a,savedSearches:x,saveableQuery:A,onSaveCurrentSearch:K,onSelectSavedSearch:q,onRemoveSavedSearch:V})}function ms(){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(ke,{className:"size-4 shrink-0"}),e.jsx("span",{className:"flex-1 truncate text-left",children:"Report a bug"})]})}function xs({accounts:t,onMailboxSelect:s}){return ve()?.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(P,{to:"/settings/accounts",onClick:s,children:[e.jsx(Ie,{className:"size-4 shrink-0"}),e.jsx("span",{className:"flex-1 truncate text-left",children:"Settings"})]}),e.jsx(ms,{}),e.jsx(Me,{children:({signOut:r})=>e.jsxs("button",{type:"button",onClick:()=>{s?.(),r()},className:"flex min-h-11 w-full items-center gap-2 rounded-md px-2 py-1 text-sm text-fg-muted transition-colors hover:bg-surface hover:text-fg","data-testid":"sign-out-button",children:[e.jsx(we,{className:"size-4 shrink-0"}),e.jsx("span",{className:"flex-1 truncate text-left",children:"Sign out"})]})})]})]})}const hs=({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(Ze,{label:"Dismiss keyboard shortcuts",onDismiss:s,className:"backdrop-blur-sm"}),e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Keyboard shortcuts",className:et("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:yt.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 fs(t){const s=G({queries:t.map(a=>({...J({path:{accountId:a.accountId}}),staleTime:1/0}))});return i.useMemo(()=>jt(s.map(a=>a.data?.items??[])),[s])}const ps=t=>t.map(s=>s.data?.items??[]);function gs(t){const s=G({queries:t.map(a=>({...J({path:{accountId:a.accountId}}),staleTime:1/0})),combine:ps});return i.useMemo(()=>tt(t.map((a,n)=>({folderAppointments:a.folderAppointments,mailboxes:s[n]??[]}))),[t,s])}var T={exports:{}},xe;function bs(){if(xe)return T.exports;xe=1;const t=(s,a,n)=>new Promise((r,o)=>{if(n=Object.assign({concurrency:1/0},n),typeof a!="function")throw new TypeError("Mapper function is required");const{concurrency:l}=n;if(!(typeof l=="number"&&l>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${l}\` (${typeof l})`);const m=[],x=s[Symbol.iterator]();let p=!1,b=!1,u=0,h=0;const f=()=>{if(p)return;const v=x.next(),k=h;if(h++,v.done){b=!0,u===0&&r(m);return}u++,Promise.resolve(v.value).then(g=>a(g,k)).then(g=>{m[k]=g,u--,f()},g=>{p=!0,o(g)})};for(let v=0;v<l&&(f(),!b);v++);});return T.exports=t,T.exports.default=t,T.exports}var vs=bs();const ys=st(vs),js=900*1e3,Ss=300,Ns=(t,s)=>{if(!t)return s;const a=Number.parseInt(t,10);return Number.isFinite(a)&&a>0?a:s},Cs=60*1e3,ks=t=>Math.max(Ns(t,Ss)*1e3,Cs),B=ks(it().mailboxPollIntervalSeconds),ws=5,W=new Set,Is=(t,s,a=js)=>t.filter(n=>{const r=n.lastSyncAt;return r==null?!0:s-r>a}).map(n=>n.accountId),Ms=(t,s,a=B)=>t-s>=a,Es=(t,s)=>t.filter(a=>!s.has(a)),he=(t,s)=>{if(W.delete(t),rt(s,{softError:!0})){ot(s);return}console.warn("[remit] background mailbox sync failed",{accountId:t,error:s})},fe=(t,s)=>at({path:{accountId:t},throwOnError:!0}).then(()=>{s.invalidateQueries({queryKey:nt({path:{accountId:t}})})}),Os=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=Is(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=Es(a.current.map(u=>u.accountId),l);for(const u of b)l.add(u);ys(b,u=>fe(u,s).catch(h=>{he(u,h)}).finally(()=>{l.delete(u)}),{concurrency:ws})},x=()=>{if(document.visibilityState==="visible"){m(),o=setTimeout(x,B);return}},p=()=>{document.visibilityState==="visible"&&Ms(Date.now(),r)&&(o!==void 0&&clearTimeout(o),m(),o=setTimeout(x,B))};return o=setTimeout(x,B),document.addEventListener("visibilitychange",p),()=>{o!==void 0&&clearTimeout(o),document.removeEventListener("visibilitychange",p)}},[n,s])};function $s(){const{q:t=""}=lt({from:"/mail"}),s=Y(),a=St(),n=wt(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=_t(u,200),v=Rt(u,f),k=se({select:j=>j.location.pathname}),g=se({select:j=>It(j.matches)}),[R,c]=i.useState(g);if(R!==g){const j=Ot(R,g,t);c(g),j!==void 0&&h(j)}const{data:y,isLoading:A,isError:K,error:V,refetch:q}=Ce({...ct(),staleTime:1/0}),d=!!(y&&(y.accounts?.length??0)===0);i.useEffect(()=>{d&&s({to:"/onboarding",replace:!0})},[d,s]),Nt({enabled:!r,bindings:[{key:"?",handler:()=>o(!0),noModifiers:!1,preventDefault:!0}]});const{openCompose:S}=U(),N=i.useMemo(()=>({compose:()=>S({mode:"new"})}),[S]);Ct({enabled:!ut(k),handlers:N});const M=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=y?.accounts??[],F=i.useMemo(()=>C.map(j=>j.accountId),[C]),Ee=fs(C),Oe=gs(C),Re=i.useMemo(()=>kt(C),[C]);Os(C);const Ae=i.useCallback(()=>{m(!1)},[]),Pe={accounts:C,mailboxNameIndex:Ee,accountNameIndex:Re,resultFolderIndex:Oe,searchQuery:v,searchInput:u,searchViewKey:g,onSearchChange:M,onSearchClear:w,onSearchClearQuery:E,intelligenceOpen:x,onToggleIntelligence:Q,onSetIntelligenceOpen:b},ze={isSinglePane:n,isLoading:A||d,intelligenceOpen:x,nav:e.jsx(xs,{accounts:C,onMailboxSelect:Ae}),topBar:n?void 0:e.jsx(ns,{accounts:C}),overlay:n?e.jsx(ts,{}):void 0,navOpen:l,onOpenNav:()=>m(!0),onCloseNav:()=>m(!1)};return e.jsx(dt.Provider,{value:Pe,children:e.jsxs(Lt,{accountIds:F,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(Et,{chrome:ze,children:e.jsx(mt,{})}),e.jsx(hs,{isOpen:r,onClose:()=>o(!1)})]})})}export{$s as component,je as useMailContext};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as o,_ as r}from"./index-2IDEAuVk.js";import{a as i}from"./search-view-DgVmeGdu.js";import{O as t}from"./OutboxPane-Bd6n9Se3.js";import{u as m}from"./useSearchMirror-D0HCJr-S.js";import"./search-scope--Ck4E_N-.js";import"./useSearchTokenContext-CO76ckqM.js";import"./kbd-DChhqIGO.js";import"./enums-CCxx0t2v.js";import"./circle-check-big-CuTKLMII.js";import"./clock-TTEOnf9z.js";import"./row-actions-CVH5R-3R.js";import"./rotate-ccw-BzC7e0ZK.js";import"./NavMenuButton-Dr1eU_Rz.js";import"./menu-CZ3Yivjh.js";import"./format-De9HZKjg.js";import"./outbox-status-CPfNHfUQ.js";import"./search-query-Cr_ZXBCp.js";function P(){return m({to:"/mail/outbox"}),o.jsx(t,{children:o.jsx(i,{phone:o.jsx(t.Phone,{}),list:o.jsx(t.List,{}),reading:o.jsx(r,{})})})}export{P as component};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c7 as l,cX as c,cY as d}from"./index-2IDEAuVk.js";function _(e){const t=l({warn:e?.router===void 0}),o=e?.router||t;return c(o.stores.__store,d(e,o))}const n="/mail/brief",u="/mail/$mailboxId",s="/mail/outbox",a="/mail/flagged";function r(e){for(const t of e){if(t.routeId===n)return{list:"brief"};if(t.routeId===a)return{list:"flagged"};if(t.routeId===s)return{list:"outbox"};if(t.routeId===u)return{list:"mailbox",mailboxId:t.params?.mailboxId}}}function p(e){const t=r(e);if(!t)return"";switch(t.list){case"mailbox":return t.mailboxId?f(t.mailboxId):"";case"flagged":return a;case"outbox":return s;case"brief":return n}}function f(e){return`${u}:${e}`}function R(e,t){return e===t?!0:e.startsWith(`${t}/`)}const i="search-scope";function b(e){const t=e.trim().replace(/\s+/g," ").toLowerCase();return/\s/.test(t)?`in:"${t}"`:`in:${t}`}function I(e){const t=r(e);return t!==void 0&&t.list!=="brief"}function m(e){const t=r(e);return t?.list==="mailbox"?t.mailboxId:void 0}function g(e){const t=m(e.matches);return t||(I(e.matches)?e.callerMailboxId:e.callerMailboxId??e.inTokenMailboxId)}function M(e,t){const o=r(e);return o?.list==="flagged"?{kind:"scoped",chip:{id:i,label:"is:starred"}}:o?.list==="outbox"?{kind:"scoped",chip:{id:i,label:"in:outbox"}}:o?.list==="mailbox"?t?{kind:"scoped",chip:{id:i,label:b(t)}}:{kind:"pending"}:{kind:"global"}}function S(e,t,o){return t.kind==="global"?{kind:"global"}:r(e)?.list==="flagged"?{kind:"collection"}:{kind:"folder",...o?{role:o}:{}}}export{i as S,S as a,M as b,I as i,R as l,p as m,m as r,g as s,_ as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as u,j as a,a4 as i,a5 as p}from"./index-2IDEAuVk.js";import{l as f}from"./search-scope--Ck4E_N-.js";const c=u.createContext(null),h=({chrome:r,children:n})=>a.jsx(c.Provider,{value:r,children:n});function O({phone:r,list:n,reading:t,intelligence:o,hasThread:l=!1}){const e=u.useContext(c);if(!e)return a.jsx(i,{});const s={nav:e.nav,overlay:e.overlay,skeleton:a.jsx(i,{}),isLoading:e.isLoading,navOpen:e.navOpen,onOpenNav:e.onOpenNav,onCloseNav:e.onCloseNav};return e.isSinglePane?a.jsx(p,{...s,list:r,intelligenceOpen:e.intelligenceOpen}):a.jsx(p,{...s,topBar:e.topBar,list:n,reading:t,intelligence:o,intelligenceOpen:e.intelligenceOpen,hasThread:l})}function S(r,n,t){if(r!==n)return t}function d(r,n){return r===""?"":n}function g({searchInput:r,committedQuery:n,urlQuery:t,pathname:o,listPath:l}){return!f(o,l)||n!==r?!1:n!==t}export{h as M,O as a,g as b,d as c,S as s};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as t,_ as o}from"./index-2IDEAuVk.js";const n=()=>t.jsx(o,{});export{n as component};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as h,n as y,V as v,r as f}from"./index-2IDEAuVk.js";import{u as x}from"./search-scope--Ck4E_N-.js";import{b as I}from"./search-view-DgVmeGdu.js";function q(a){const o=h(),{searchInput:s,searchQuery:e}=y(),{q:i=""}=v({from:"/mail"}),u=x({select:m=>m.location.pathname}),c=f.useRef(i);c.current=i;const{to:r}=a,t="params"in a?a.params.mailboxId:void 0,n=t?`/mail/${t}`:r;f.useEffect(()=>{if(!I({searchInput:s,committedQuery:e,urlQuery:c.current,pathname:u,listPath:n}))return;const l=d=>{const p=d.q===e;return{...d,q:e||void 0,...e&&!p?{selectedMessageId:void 0,selectedThreadId:void 0,selectedMailboxId:void 0}:{}}};if(r==="/mail/$mailboxId"){if(!t)return;o({to:r,params:{mailboxId:t},search:l,replace:!0});return}o({to:r,search:l,replace:!0})},[s,e,o,r,t,n,u])}export{q as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{q as l,ac as f,w as p,W as m,r,ae as y,af as T,$ as E,ag as x}from"./index-2IDEAuVk.js";const i={html:"",plainText:""},d=e=>{const u=l(),{pushError:o}=f(),{data:n}=p({...m(),staleTime:1/0}),c=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({...x(),onSuccess:()=>{u.invalidateQueries({queryKey:E()})},onError:t=>{o(T("Couldn't save signature","The signature wasn't saved.",t))}}),g=r.useCallback((t,s)=>{e&&a.mutate({path:{accountId:e},body:{signatureHtml:t,signaturePlainText:s}})},[e,a]);return{signature:c,setSignature:g,isSaving:a.isPending}};export{d as u};
|