@remit/web-client-dist 0.0.443 → 0.0.445
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-DXz-TuiD.js → BriefPane-Cblx3dGb.js} +1 -1
- package/assets/{ErrorState-BN8KmB6p.js → ErrorState-Cp-q2w9w.js} +1 -1
- package/assets/{FlaggedPane-DHHDJfR7.js → FlaggedPane-Ch58MU9E.js} +1 -1
- package/assets/{FullCompose-DWM84HQ_.js → FullCompose-BdIpZxG9.js} +1 -1
- package/assets/MailListHeader-C4iFTdSN.js +7 -0
- package/assets/{MailShell-CSXqEQqP.js → MailShell-B0aQqEP7.js} +1 -1
- package/assets/{MailViewChrome-BUvYgs_E.js → MailViewChrome-DLb2fNYu.js} +1 -1
- package/assets/{MailboxPane-om2ac-8n.js → MailboxPane-tM9Qnk8K.js} +1 -1
- package/assets/{NavMenuButton-DeoLSdkq.js → NavMenuButton-BEErFBgW.js} +1 -1
- package/assets/{OnboardingWizard-DWLZ6gbB.js → OnboardingWizard-CLEu4Eq2.js} +1 -1
- package/assets/{OutboxPane-jFQfgisp.js → OutboxPane-CH8APoTv.js} +1 -1
- package/assets/_mailboxId-DcISVk3F.js +1 -0
- package/assets/_messageId-BZtIYzNu.js +1 -0
- package/assets/_messageId-DFnLvvGO.js +1 -0
- package/assets/_messageId-DzbGwFwZ.js +1 -0
- package/assets/_outboxMessageId-BEfNt7nb.js +1 -0
- package/assets/_threadId-Ci_-K0C6.js +1 -0
- package/assets/_threadId-DvFA5v_L.js +1 -0
- package/assets/_threadId-dk1ldVTF.js +1 -0
- package/assets/{accounts-DyY-qdCD.js → accounts-C1FX-wXA.js} +1 -1
- package/assets/{advanced-BYICw3Os.js → advanced-C2AEDPuc.js} +1 -1
- package/assets/{appearance-6PhJ1yR0.js → appearance-CkC1P9AI.js} +1 -1
- package/assets/{attachment-file-C-4xxD3u.js → attachment-file-DKdoDsJb.js} +1 -1
- package/assets/{avatar-Cg3od6Sb.js → avatar-66IHVolP.js} +1 -1
- package/assets/{bottom-sheet-cVuKX2Nh.js → bottom-sheet-BuQUdfIO.js} +1 -1
- package/assets/brief-C86Uy-43.js +1 -0
- package/assets/{brief-w83dCLdN.js → brief-CqCGPd9D.js} +1 -1
- package/assets/{browser-ponyfill-9xiO6-AF.js → browser-ponyfill-Bv-32OYZ.js} +1 -1
- package/assets/{bug-DxDR-Rxh.js → bug-JqbSSZae.js} +1 -1
- package/assets/{circle-check-D4WEyzS0.js → circle-check-D7Qb9gYa.js} +1 -1
- package/assets/{circle-check-big-C6YYI5Pt.js → circle-check-big-3v1UEeDx.js} +1 -1
- package/assets/{circle-help-Bi4SjIUh.js → circle-help-DmuGFuc3.js} +1 -1
- package/assets/{clock-B3Mloy-j.js → clock-BcUfg-A3.js} +1 -1
- package/assets/compose._-_outboxMessageId_-3VUipX_Q.js +1 -0
- package/assets/compose._-_outboxMessageId_-DAnrZybQ.js +1 -0
- package/assets/compose._-_outboxMessageId_-Du-G4jNM.js +1 -0
- package/assets/compose._-_outboxMessageId_-RHFyqrwf.js +1 -0
- package/assets/{confirm-dialog-y8eNTKiu.js → confirm-dialog-ivQtQll4.js} +1 -1
- package/assets/{download-Bh4rD_mU.js → download-mx2VQnFX.js} +1 -1
- package/assets/{filters-BJUQAk21.js → filters-HyB2nktC.js} +1 -1
- package/assets/{flagged-BhrxIwEO.js → flagged-B2Ah_D4L.js} +1 -1
- package/assets/flagged-DjIUOfzE.js +1 -0
- package/assets/{folders-cHWuJpbr.js → folders-CM8k-aJT.js} +1 -1
- package/assets/{help-copy-C_HiYKk6.js → help-copy-DaC5HYBZ.js} +1 -1
- package/assets/index-53xrH7Fb.js +1 -0
- package/assets/index-BBeUuXvu.js +1 -0
- package/assets/index-BZdlt25E.js +1 -0
- package/assets/index-BZtIYzNu.js +1 -0
- package/assets/{index-Bkjd6ag4.js → index-C8zyy3XE.js} +4 -4
- package/assets/index-CKNZWQuQ.js +1 -0
- package/assets/{index-CxAqYMzw.js → index-C_T2dvXA.js} +3 -3
- package/assets/index-DdEGI_Za.js +1 -0
- package/assets/index-DzbGwFwZ.js +1 -0
- package/assets/index-vx2VgI_F.js +1 -0
- package/assets/{kbd-D-7j6x78.js → kbd-CX9mOiuU.js} +1 -1
- package/assets/{labels-By4Kwsa3.js → labels-DkmAGZ7K.js} +1 -1
- package/assets/{mail-cIZigcLz.js → mail-Do62nxWg.js} +1 -1
- package/assets/{mail-r533UYo-.js → mail-bfhHdZI4.js} +1 -1
- package/assets/{menu-C8xNLlit.js → menu-B4qp5h8W.js} +1 -1
- package/assets/{onboarding-DnSIgd01.js → onboarding-q1FU68bt.js} +1 -1
- package/assets/outbox-BdjOpLA8.js +1 -0
- package/assets/{pencil-DCIikUwt.js → pencil-HWlQ-VeT.js} +1 -1
- package/assets/{rich-text-CQjuTGKL.js → rich-text-CnDN7D4n.js} +1 -1
- package/assets/{rich-text-spellcheck-worker-provider-CJrnd8F6.js → rich-text-spellcheck-worker-provider-DekTHQo0.js} +1 -1
- package/assets/{rotate-ccw-B163PDFd.js → rotate-ccw-o3IPokHS.js} +1 -1
- package/assets/{row-actions-Bv8Kk0rO.js → row-actions-D2-obDQJ.js} +1 -1
- package/assets/{search-mirror-BqjecuKm.js → search-mirror-Bz6qYFNs.js} +1 -1
- package/assets/{search-token-index-B0AHm8CX.js → search-token-index-Cu3vEtDY.js} +1 -1
- package/assets/{senders-B8uZSxbR.js → senders-DPVdGxvA.js} +1 -1
- package/assets/settings-BkFq1Zf9.js +1 -0
- package/assets/{settings-screen-DJXhppdf.js → settings-screen-Ai1ERiVR.js} +1 -1
- package/assets/{shield-check-RPwWQeiw.js → shield-check-D5RHQNp7.js} +1 -1
- package/assets/{suggested-vips-DgPRoAcK.js → suggested-vips-DLXmRg2R.js} +1 -1
- package/assets/{useDebouncedValue-C9pmx2_Q.js → useDebouncedValue-KxXY_DAe.js} +1 -1
- package/assets/{useFilters-gjNTMJWD.js → useFilters-BG3A-lfv.js} +1 -1
- package/assets/{useLabels-CY1luwCK.js → useLabels-BAvJi8nW.js} +1 -1
- package/assets/{useMessageBodyContent-DRSoOPZL.js → useMessageBodyContent-CBSYjeOA.js} +1 -1
- package/assets/{useRefreshControl-Cjv2o2wP.js → useRefreshControl-CrWcN2XJ.js} +1 -1
- package/assets/{useSearchTokenContext-CQV_cdyN.js → useSearchTokenContext-C6RcQO8N.js} +1 -1
- package/assets/{useSemanticSearch-D2oASHlP.js → useSemanticSearch-De9TD-3t.js} +1 -1
- package/assets/{useSignature-CG-sQrZb.js → useSignature-B4CKEb6v.js} +1 -1
- package/index.html +1 -1
- package/package.json +1 -1
- package/assets/MailListHeader-DBawPIAH.js +0 -7
- package/assets/_mailboxId-fFBPv8_p.js +0 -1
- package/assets/_messageId-B0CKuDXl.js +0 -1
- package/assets/_messageId-fy8DrtOd.js +0 -1
- package/assets/_messageId-gZCzfW6D.js +0 -1
- package/assets/_outboxMessageId-B79_7tdA.js +0 -1
- package/assets/_threadId-CXdSa_n0.js +0 -1
- package/assets/_threadId-Djs_2CUg.js +0 -1
- package/assets/_threadId-Dzh1TrUt.js +0 -1
- package/assets/brief-B7pe1GQX.js +0 -1
- package/assets/compose._-_outboxMessageId_-BytNLy-S.js +0 -1
- package/assets/compose._-_outboxMessageId_-CH9gVrVG.js +0 -1
- package/assets/compose._-_outboxMessageId_-CP001jBH.js +0 -1
- package/assets/compose._-_outboxMessageId_-CUtybPHs.js +0 -1
- package/assets/flagged-DL7GDOQc.js +0 -1
- package/assets/index-B0CKuDXl.js +0 -1
- package/assets/index-BMeBTQuR.js +0 -1
- package/assets/index-C098sy-P.js +0 -1
- package/assets/index-C5zkz2Tt.js +0 -1
- package/assets/index-D1sLtdaq.js +0 -1
- package/assets/index-D6eBht-q.js +0 -1
- package/assets/index-gZCzfW6D.js +0 -1
- package/assets/index-kH9zPjDC.js +0 -1
- package/assets/outbox-Mg8ad1rj.js +0 -1
- package/assets/settings-Czfiem0K.js +0 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{ag as vs,cK as kr,r as l,c as ie,j as a,C as ut,d as zn,B as V,X as Pt,aF as Ie,cL as _n,b as U,a as Ye,S as We,b5 as jr,cM as wr,as as Dt,T as Ft,cN as Un,bn as ks,cO as Sr,cP as Bn,az as Cr,ar as Kn,e as Nr,cQ as Tr,aE as qn,cR as Ir,cS as Er,cT as Rr,cU as Mr,cV as Ar,cW as $r,cX as Lr,cY as Pr,n as Dr,D as Z,a1 as gt,z as bt,cZ as Fr,c_ as Or,c$ as Ot,K as Qn,bO as Hn,d0 as Gn,x as ae,ah as be,aj as pe,Y as Je,bK as Re,d1 as zt,cx as zr,d2 as Me,d3 as _r,d4 as Gs,d5 as Ur,d6 as Br,d7 as Kr,d8 as qr,co as Qr,bI as Vn,bJ as Hr,d9 as Gr,b3 as js,y as Vr,b6 as Wn,b0 as Yn,b7 as Jn,b8 as Xn,b9 as Wr,aR as Yr,aS as Jr,cJ as Xr,da as Zr,t as Zn,cI as eo,db as to,dc as so,dd as ea,de as no,bP as ao,by as ws,c1 as ro,bU as Vs,df as oo,dg as es,dh as io,bx as lo,_ as co,a6 as uo,N as ta,L as fo,bR as Ws,bh as mo,di as po,dj as ho,ak as Ys,bM as go,dk as bo,dl as xo,v as _t,dm as yo,dn as vo,dp as Js,dq as ko,dr as jo,ds as wo,i as sa,dt as Ss,bN as ve,du as So,cp as Co,c0 as No,dv as To,dw as Xs,g as Io,cq as Eo}from"./index-C8zyy3XE.js";import{B as Ro,q as Mo,r as Ao,S as na,d as Cs,l as $o,g as Lo,D as Po,b as Tt,a as Do,t as it,h as Fo,v as Oo,w as zo,p as _o,f as Uo,u as Bo,j as Ko}from"./search-token-index-Cu3vEtDY.js";import{K as qo}from"./kbd-CX9mOiuU.js";import{P as aa,f as Qo,U as Ho,a as Go,E as Vo,s as Wo}from"./attachment-file-DKdoDsJb.js";import{M as Yo}from"./mail-bfhHdZI4.js";import{A as ft}from"./avatar-66IHVolP.js";import{M as Jo,c as Xo,d as ra,e as Zo,f as oa,g as ia,a as ei,b as ti,S as Zs,s as la,u as ca,p as si,r as ni}from"./useSearchTokenContext-C6RcQO8N.js";import{C as ai,D as Qe,a as ri}from"./index-C_T2dvXA.js";import{E as Oe}from"./ErrorState-Cp-q2w9w.js";import{e as da,b as Xe,a as oi,g as ii,c as ze,d as li}from"./format-23Av07Go.js";import{D as ci}from"./download-mx2VQnFX.js";import{g as di}from"./useMessageBodyContent-CBSYjeOA.js";import{S as ui}from"./shield-check-D5RHQNp7.js";import{u as ua}from"./useDebouncedValue-KxXY_DAe.js";import{h as en,u as fi,a as mi,i as pi,n as hi,o as gi,j as bi,k as xi,S as yi}from"./useFilters-BG3A-lfv.js";import{C as It}from"./confirm-dialog-ivQtQll4.js";import{C as vi}from"./clock-BcUfg-A3.js";import{r as ki,b as ji}from"./search-scope-DTcpOp3S.js";import{M as wi}from"./menu-B4qp5h8W.js";function mt(e){if(Si())e.focus({preventScroll:!0});else{let t=Ci(e);e.focus(),Ni(t)}}let Et=null;function Si(){if(Et==null){Et=!1;try{document.createElement("div").focus({get preventScroll(){return Et=!0,!0}})}catch{}}return Et}function Ci(e){let t=e.parentNode,s=[],n=document.scrollingElement||document.documentElement;for(;t instanceof HTMLElement&&t!==n;)(t.offsetHeight<t.scrollHeight||t.offsetWidth<t.scrollWidth)&&s.push({element:t,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft}),t=t.parentNode;return n instanceof HTMLElement&&s.push({element:n,scrollTop:n.scrollTop,scrollLeft:n.scrollLeft}),s}function Ni(e){for(let{element:t,scrollTop:s,scrollLeft:n}of e)t.scrollTop=s,t.scrollLeft=n}const Te=e=>e?.ownerDocument??document,Ee=e=>e&&"window"in e&&e.window===e?e:Te(e).defaultView||window;function Ti(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&typeof e.nodeType=="number"}function Ii(e){return Ti(e)&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in e}let Ei=!1;function fa(){return Ei}function ge(e,t){if(!fa())return t&&e?e.contains(t):!1;if(!e||!t)return!1;let s=t;for(;s!==null;){if(s===e)return!0;s.tagName==="SLOT"&&s.assignedSlot?s=s.assignedSlot.parentNode:Ii(s)?s=s.host:s=s.parentNode}return!1}function X(e){if(fa()&&e.target instanceof Element&&e.target.shadowRoot){if("composedPath"in e)return e.composedPath()[0]??null;if("composedPath"in e.nativeEvent)return e.nativeEvent.composedPath()[0]??null}return e.target}const Ri=typeof Element<"u"&&"checkVisibility"in Element.prototype;function Mi(e){const t=Ee(e);if(!(e instanceof t.HTMLElement)&&!(e instanceof t.SVGElement))return!1;let{display:s,visibility:n}=e.style,r=s!=="none"&&n!=="hidden"&&n!=="collapse";if(r){const{getComputedStyle:o}=Ee(e);let{display:i,visibility:c}=o(e);r=i!=="none"&&c!=="hidden"&&c!=="collapse"}return r}function Ai(e,t){return!e.hasAttribute("hidden")&&!e.hasAttribute("data-react-aria-prevent-focus")&&(e.nodeName==="DETAILS"&&t&&t.nodeName!=="SUMMARY"?e.hasAttribute("open"):!0)}function ma(e,t){return Ri?e.checkVisibility({visibilityProperty:!0})&&!e.closest("[data-react-aria-prevent-focus]"):e.nodeName!=="#comment"&&Mi(e)&&Ai(e,t)&&(!e.parentElement||ma(e.parentElement,e))}const pa=["input:not([disabled]):not([type=hidden])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","a[href]","area[href]","summary","iframe","object","embed","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable^="false"])',"permission"],$i=pa.join(":not([hidden]),")+",[tabindex]:not([disabled]):not([hidden])";pa.push('[tabindex]:not([tabindex="-1"]):not([disabled])');function Li(e,t){return e.matches($i)&&!Pi(e)&&(t?.skipVisibilityCheck||ma(e))}function Pi(e){let t=e;for(;t!=null;){if(t instanceof Ee(t).HTMLElement&&t.inert)return!0;t=t.parentElement}return!1}const Ns=typeof document<"u"?vs.useLayoutEffect:()=>{};function Di(e){let t=e;return t.nativeEvent=e,t.isDefaultPrevented=()=>t.defaultPrevented,t.isPropagationStopped=()=>t.cancelBubble,t.persist=()=>{},t}function Fi(e,t){Object.defineProperty(e,"target",{value:t}),Object.defineProperty(e,"currentTarget",{value:t})}function Oi(e){for(;e&&!Li(e,{skipVisibilityCheck:!0});)e=e.parentElement;let t=Ee(e),s=t.document.activeElement;if(!s||s===e)return;let n=!1,r=g=>{(X(g)===s||n)&&g.stopImmediatePropagation()},o=g=>{(X(g)===s||n)&&(g.stopImmediatePropagation(),!e&&!n&&(n=!0,mt(s),u()))},i=g=>{(X(g)===e||n)&&g.stopImmediatePropagation()},c=g=>{(X(g)===e||n)&&(g.stopImmediatePropagation(),n||(n=!0,mt(s),u()))};t.addEventListener("blur",r,!0),t.addEventListener("focusout",o,!0),t.addEventListener("focusin",c,!0),t.addEventListener("focus",i,!0);let u=()=>{cancelAnimationFrame(x),t.removeEventListener("blur",r,!0),t.removeEventListener("focusout",o,!0),t.removeEventListener("focusin",c,!0),t.removeEventListener("focus",i,!0),n=!1},x=requestAnimationFrame(u);return u}function Ut(e){if(typeof window>"u"||window.navigator==null)return!1;let t=window.navigator.userAgentData?.brands;return Array.isArray(t)&&t.some(s=>e.test(s.brand))||e.test(window.navigator.userAgent)}function Ts(e){return typeof window<"u"&&window.navigator!=null?e.test(window.navigator.userAgentData?.platform||window.navigator.platform):!1}function Ae(e){let t=null;return()=>(t==null&&(t=e()),t)}const At=Ae(function(){return Ts(/^Mac/i)}),zi=Ae(function(){return Ts(/^iPhone/i)}),ha=Ae(function(){return Ts(/^iPad/i)||At()&&navigator.maxTouchPoints>1}),ga=Ae(function(){return zi()||ha()}),_i=Ae(function(){return Ut(/AppleWebKit/i)&&!Ui()}),Ui=Ae(function(){return Ut(/Chrome/i)}),ba=Ae(function(){return Ut(/Android/i)}),Bi=Ae(function(){return Ut(/Firefox/i)});function Ki(e){return e.pointerType===""&&e.isTrusted?!0:ba()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function qi(e){return!ba()&&e.width===0&&e.height===0||e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType==="mouse"}function pt(e,t,s=!0){let{metaKey:n,ctrlKey:r,altKey:o,shiftKey:i}=t;Bi()&&window.event?.type?.startsWith("key")&&e.target==="_blank"&&(At()?n=!0:r=!0);let c=_i()&&At()&&!ha()?new KeyboardEvent("keydown",{keyIdentifier:"Enter",metaKey:n,ctrlKey:r,altKey:o,shiftKey:i}):new MouseEvent("click",{metaKey:n,ctrlKey:r,altKey:o,shiftKey:i,detail:1,bubbles:!0,cancelable:!0});pt.isOpening=s,mt(e),e.dispatchEvent(c),pt.isOpening=!1}pt.isOpening=!1;let Ne=new Map,ds=new Set;function tn(){if(typeof window>"u")return;function e(n){return"propertyName"in n}let t=n=>{let r=X(n);if(!e(n)||!r)return;let o=Ne.get(r);o||(o=new Set,Ne.set(r,o),r.addEventListener("transitioncancel",s,{once:!0})),o.add(n.propertyName)},s=n=>{let r=X(n);if(!e(n)||!r)return;let o=Ne.get(r);if(o&&(o.delete(n.propertyName),o.size===0&&(r.removeEventListener("transitioncancel",s),Ne.delete(r)),Ne.size===0)){for(let i of ds)i();ds.clear()}};document.body.addEventListener("transitionrun",t),document.body.addEventListener("transitionend",s)}typeof document<"u"&&(document.readyState!=="loading"?tn():document.addEventListener("DOMContentLoaded",tn));function Qi(){for(const[e]of Ne)"isConnected"in e&&!e.isConnected&&Ne.delete(e)}function Hi(e){requestAnimationFrame(()=>{Qi(),Ne.size===0?e():ds.add(e)})}function xa(...e){return(...t)=>{for(let s of e)typeof s=="function"&&s(...t)}}let us=new Map;typeof FinalizationRegistry<"u"&&new FinalizationRegistry(e=>{us.delete(e)});function Gi(e,t){if(e===t)return e;let s=us.get(e);if(s)return s.forEach(r=>r.current=t),t;let n=us.get(t);return n?(n.forEach(r=>r.current=e),e):t}function Vi(...e){return e.length===1&&e[0]?e[0]:t=>{let s=!1;const n=e.map(r=>{const o=sn(r,t);return s||=typeof o=="function",o});if(s)return()=>{n.forEach((r,o)=>{typeof r=="function"?r():sn(e[o],null)})}}}function sn(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function xt(...e){let t={...e[0]};for(let s=1;s<e.length;s++){let n=e[s];for(let r in n){let o=t[r],i=n[r];typeof o=="function"&&typeof i=="function"&&r[0]==="o"&&r[1]==="n"&&r.charCodeAt(2)>=65&&r.charCodeAt(2)<=90?t[r]=xa(o,i):(r==="className"||r==="UNSAFE_className")&&typeof o=="string"&&typeof i=="string"?t[r]=kr(o,i):r==="id"&&o&&i?t.id=Gi(o,i):r==="ref"&&o&&i?t.ref=Vi(o,i):t[r]=i!==void 0?i:o}}return t}function Wi(e,t){Ns(()=>{if(e&&e.ref&&t)return e.ref.current=t.current,()=>{e.ref&&(e.ref.current=null)}})}const Yi=vs.useInsertionEffect??Ns;function ts(e){const t=l.useRef(null);return Yi(()=>{t.current=e},[e]),l.useCallback((...s)=>{const n=t.current;return n?.(...s)},[])}let Ge="default",fs="",Mt=new WeakMap;function Ji(e){if(ga()){if(Ge==="default"){const t=Te(e);fs=t.documentElement.style.webkitUserSelect,t.documentElement.style.webkitUserSelect="none"}Ge="disabled"}else if(e instanceof HTMLElement||e instanceof SVGElement){let t="userSelect"in e.style?"userSelect":"webkitUserSelect";Mt.set(e,e.style[t]),e.style[t]="none"}}function nn(e){if(ga()){if(Ge!=="disabled")return;Ge="restoring",setTimeout(()=>{Hi(()=>{if(Ge==="restoring"){const t=Te(e);t.documentElement.style.webkitUserSelect==="none"&&(t.documentElement.style.webkitUserSelect=fs||""),fs="",Ge="default"}})},300)}else if((e instanceof HTMLElement||e instanceof SVGElement)&&e&&Mt.has(e)){let t=Mt.get(e),s="userSelect"in e.style?"userSelect":"webkitUserSelect";e.style[s]==="none"&&(e.style[s]=t),e.getAttribute("style")===""&&e.removeAttribute("style"),Mt.delete(e)}}function an(e){return e?.defaultView?.__webpack_nonce__||globalThis.__webpack_nonce__||void 0}let ss=new WeakMap;function Xi(e){let t=e??(typeof document<"u"?document:void 0);if(!t)return an(t);if(ss.has(t))return ss.get(t);let s=t.querySelector('meta[property="csp-nonce"]'),n=s&&s instanceof Ee(s).HTMLMetaElement&&(s.nonce||s.content)||an(t)||void 0;return n!==void 0&&ss.set(t,n),n}const ya=vs.createContext({register:()=>{}});ya.displayName="PressResponderContext";function va(){let e=l.useRef(new Map),t=l.useCallback((r,o,i,c)=>{let u=c?.once?(...x)=>{e.current.delete(i),i(...x)}:i;e.current.set(i,{type:o,eventTarget:r,fn:u,options:c}),r.addEventListener(o,u,c)},[]),s=l.useCallback((r,o,i,c)=>{let u=e.current.get(i)?.fn||i;r.removeEventListener(o,u,c),e.current.delete(i)},[]),n=l.useCallback(()=>{e.current.forEach((r,o)=>{s(r.eventTarget,r.type,o,r.options)})},[s]);return l.useEffect(()=>n,[n]),{addGlobalListener:t,removeGlobalListener:s,removeAllGlobalListeners:n}}function Zi(e){let t=l.useContext(ya);if(t){let{register:s,ref:n,...r}=t;e=xt(r,e),s()}return Wi(t,e.ref),e}class Rt{#e;constructor(t,s,n,r){this.#e=!0;const i=(r?.target??n.currentTarget)?.getBoundingClientRect();let c,u=0,x,g=null;n.clientX!=null&&n.clientY!=null&&(x=n.clientX,g=n.clientY),i&&(x!=null&&g!=null?(c=x-i.left,u=g-i.top):(c=i.width/2,u=i.height/2)),this.type=t,this.pointerType=s,this.target=n.currentTarget,this.shiftKey=n.shiftKey,this.metaKey=n.metaKey,this.ctrlKey=n.ctrlKey,this.altKey=n.altKey,this.x=c,this.y=u,this.key=n.key}continuePropagation(){this.#e=!1}get shouldStopPropagation(){return this.#e}}const rn=Symbol("linkClicked"),on="react-aria-pressable-style",ln="data-react-aria-pressable";function el(e){let{onPress:t,onPressChange:s,onPressStart:n,onPressEnd:r,onPressUp:o,onClick:i,isDisabled:c,isPressed:u,preventFocusOnPress:x,shouldCancelOnPointerExit:g,allowTextSelectionOnPress:b,ref:p,...y}=Zi(e),[f,d]=l.useState(!1),m=l.useRef({isPressed:!1,ignoreEmulatedMouseEvents:!1,didFirePressStart:!1,isTriggeringEvent:!1,activePointerId:null,target:null,isOverTarget:!1,pointerType:null,disposables:[]}),{addGlobalListener:h,removeAllGlobalListeners:w}=va(),v=l.useCallback((k,I)=>{let $=m.current;if(c||$.didFirePressStart)return!1;let S=!0;if($.isTriggeringEvent=!0,n){let M=new Rt("pressstart",I,k);n(M),S=M.shouldStopPropagation}return s&&s(!0),$.isTriggeringEvent=!1,$.didFirePressStart=!0,d(!0),S},[c,n,s]),j=l.useCallback((k,I,$=!0)=>{let S=m.current;if(!S.didFirePressStart)return!1;S.didFirePressStart=!1,S.isTriggeringEvent=!0;let M=!0;if(r){let C=new Rt("pressend",I,k);r(C),M=C.shouldStopPropagation}if(s&&s(!1),d(!1),t&&$&&!c){let C=new Rt("press",I,k);t(C),M&&=C.shouldStopPropagation}return S.isTriggeringEvent=!1,M},[c,r,s,t]),T=ts(j),R=l.useCallback((k,I)=>{let $=m.current;if(c)return!1;if(o){$.isTriggeringEvent=!0;let S=new Rt("pressup",I,k);return o(S),$.isTriggeringEvent=!1,S.shouldStopPropagation}return!0},[c,o]),D=ts(R),E=l.useCallback(k=>{let I=m.current;if(I.isPressed&&I.target){I.didFirePressStart&&I.pointerType!=null&&j(De(I.target,k),I.pointerType,!1),I.isPressed=!1,I.isOverTarget=!1,I.activePointerId=null,I.pointerType=null,w(),b||nn(I.target);for(let $ of I.disposables)$();I.disposables=[]}},[b,w,j]),F=ts(E);l.useEffect(()=>{c&&m.current.isPressed&&F({currentTarget:m.current.target,shiftKey:!1,ctrlKey:!1,metaKey:!1,altKey:!1})},[c]);let P=l.useCallback(k=>{g&&E(k)},[g,E]),_=l.useCallback(k=>{c||i?.(k)},[c,i]),K=l.useCallback((k,I)=>{if(!c&&i){let $=new MouseEvent("click",k);Fi($,I),i(Di($))}},[c,i]),B=l.useMemo(()=>{let k=m.current,I={onKeyDown(S){if(ns(S.nativeEvent,S.currentTarget)&&ge(S.currentTarget,X(S))){cn(X(S),S.key)&&S.preventDefault();let M=!0;!k.isPressed&&!S.repeat&&(k.target=S.currentTarget,k.isPressed=!0,k.pointerType="keyboard",M=v(S,"keyboard"));let C=S.currentTarget,z=O=>{ns(O,C)&&!O.repeat&&ge(C,X(O))&&k.target&&D(De(k.target,O),"keyboard")};h(Te(S.currentTarget),"keyup",xa(z,$),!0),M&&S.stopPropagation(),S.metaKey&&At()&&k.metaKeyEvents?.set(S.key,S.nativeEvent)}else S.key==="Meta"&&(k.metaKeyEvents=new Map)},onClick(S){if(!(S&&!ge(S.currentTarget,X(S)))&&S&&S.button===0&&!k.isTriggeringEvent&&!pt.isOpening){let M=!0;if(c&&S.preventDefault(),!k.ignoreEmulatedMouseEvents&&!k.isPressed&&(k.pointerType==="virtual"||Ki(S.nativeEvent))){let C=v(S,"virtual"),z=D(S,"virtual"),O=T(S,"virtual");_(S),M=C&&z&&O}else if(k.isPressed&&k.pointerType!=="keyboard"){let C=k.pointerType||S.nativeEvent.pointerType||"virtual",z=D(De(S.currentTarget,S),C),O=T(De(S.currentTarget,S),C,!0);M=z&&O,k.isOverTarget=!1,_(S),F(S)}k.ignoreEmulatedMouseEvents=!1,M&&S.stopPropagation()}}},$=S=>{if(k.isPressed&&k.target&&ns(S,k.target)){cn(X(S),S.key)&&S.preventDefault();let M=X(S),C=ge(k.target,M);T(De(k.target,S),"keyboard",C),C&&K(S,k.target),w(),S.key!=="Enter"&&Is(k.target)&&ge(k.target,M)&&!S[rn]&&(S[rn]=!0,pt(k.target,S,!1)),k.isPressed=!1,k.metaKeyEvents?.delete(S.key)}else if(S.key==="Meta"&&k.metaKeyEvents?.size){let M=k.metaKeyEvents;k.metaKeyEvents=void 0;for(let C of M.values())k.target?.dispatchEvent(new KeyboardEvent("keyup",C))}};if(typeof PointerEvent<"u"){I.onPointerDown=C=>{if(C.button!==0||!ge(C.currentTarget,X(C)))return;if(qi(C.nativeEvent)){k.pointerType="virtual";return}k.pointerType=C.pointerType;let z=!0;if(!k.isPressed){k.isPressed=!0,k.isOverTarget=!0,k.activePointerId=C.pointerId,k.target=C.currentTarget,b||Ji(k.target),z=v(C,k.pointerType);let O=X(C);"releasePointerCapture"in O&&("hasPointerCapture"in O?O.hasPointerCapture(C.pointerId)&&O.releasePointerCapture(C.pointerId):O.releasePointerCapture(C.pointerId)),h(Te(C.currentTarget),"pointerup",S,!1),h(Te(C.currentTarget),"pointercancel",M,!1)}z&&C.stopPropagation()},I.onMouseDown=C=>{if(ge(C.currentTarget,X(C))&&C.button===0){if(x){let z=Oi(C.target);z&&k.disposables.push(z)}C.stopPropagation()}},I.onPointerUp=C=>{!ge(C.currentTarget,X(C))||k.pointerType==="virtual"||C.button===0&&!k.isPressed&&D(C,k.pointerType||C.pointerType)},I.onPointerEnter=C=>{C.pointerId===k.activePointerId&&k.target&&!k.isOverTarget&&k.pointerType!=null&&(k.isOverTarget=!0,v(De(k.target,C),k.pointerType))},I.onPointerLeave=C=>{C.pointerId===k.activePointerId&&k.target&&k.isOverTarget&&k.pointerType!=null&&(k.isOverTarget=!1,T(De(k.target,C),k.pointerType,!1),P(C))};let S=C=>{if(C.pointerId===k.activePointerId&&k.isPressed&&C.button===0&&k.target){if(ge(k.target,X(C))&&k.pointerType!=null){let z=!1,O=setTimeout(()=>{k.isPressed&&k.target instanceof HTMLElement&&(z?F(C):(mt(k.target),k.target.click()))},80);h(C.currentTarget,"click",()=>z=!0,!0),k.disposables.push(()=>clearTimeout(O))}else F(C);k.isOverTarget=!1}},M=C=>{F(C)};I.onDragStart=C=>{ge(C.currentTarget,X(C))&&F(C)}}return I},[h,c,x,w,b,P,v,_,K]);return l.useEffect(()=>{if(!p)return;const k=Te(p.current);if(!k||!k.head||k.getElementById(on))return;const I=k.createElement("style");I.id=on;let $=Xi(k);$&&(I.nonce=$),I.textContent=`
|
|
2
|
+
@layer {
|
|
3
|
+
[${ln}] {
|
|
4
|
+
touch-action: pan-x pan-y pinch-zoom;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
`.trim(),k.head.prepend(I)},[p]),l.useEffect(()=>{let k=m.current;return()=>{b||nn(k.target??void 0);for(let I of k.disposables)I();k.disposables=[]}},[b]),{isPressed:u||f,pressProps:xt(y,B,{[ln]:!0})}}function Is(e){return e.tagName==="A"&&e.hasAttribute("href")}function ns(e,t){const{key:s,code:n}=e,r=t,o=r.getAttribute("role");return(s==="Enter"||s===" "||s==="Spacebar"||n==="Space")&&!(r instanceof Ee(r).HTMLInputElement&&!ka(r,s)||r instanceof Ee(r).HTMLTextAreaElement||r.isContentEditable)&&!((o==="link"||!o&&Is(r))&&s!=="Enter")}function De(e,t){let s=t.clientX,n=t.clientY;return{currentTarget:e,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,metaKey:t.metaKey,altKey:t.altKey,clientX:s,clientY:n,key:t.key}}function tl(e){return e instanceof HTMLInputElement?!1:e instanceof HTMLButtonElement?e.type!=="submit"&&e.type!=="reset":!Is(e)}function cn(e,t){return e instanceof HTMLInputElement?!ka(e,t):tl(e)}const sl=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function ka(e,t){return e.type==="checkbox"||e.type==="radio"?t===" ":sl.has(e.type)}let nl=0;const as=new Map;function al(e){let[t,s]=l.useState();return Ns(()=>{if(!e)return;let n=as.get(e);if(n)s(n.element.id);else{let r=`react-aria-description-${nl++}`;s(r);let o=document.createElement("div");o.id=r,o.style.display="none",o.textContent=e,document.body.appendChild(o),n={refCount:0,element:o},as.set(e,n)}return n.refCount++,()=>{n&&--n.refCount===0&&(n.element.remove(),as.delete(e))}},[e]),{"aria-describedby":e?t:void 0}}const rl=500;function ol(e){let{isDisabled:t,onLongPressStart:s,onLongPressEnd:n,onLongPress:r,threshold:o=rl,accessibilityDescription:i}=e;const c=l.useRef(void 0);let{addGlobalListener:u,removeGlobalListener:x}=va(),{pressProps:g}=el({isDisabled:t,onPressStart(p){if(p.continuePropagation(),(p.pointerType==="mouse"||p.pointerType==="touch")&&(s&&s({...p,type:"longpressstart"}),c.current=setTimeout(()=>{p.target.dispatchEvent(new PointerEvent("pointercancel",{bubbles:!0})),Te(p.target).activeElement!==p.target&&mt(p.target),r&&r({...p,type:"longpress"}),c.current=void 0},o),p.pointerType==="touch")){let y=d=>{d.preventDefault()},f=Ee(p.target);u(p.target,"contextmenu",y,{once:!0}),u(f,"pointerup",()=>{setTimeout(()=>{x(p.target,"contextmenu",y)},30)},{once:!0})}},onPressEnd(p){c.current&&clearTimeout(c.current),n&&(p.pointerType==="mouse"||p.pointerType==="touch")&&n({...p,type:"longpressend"})}}),b=al(r&&!t?i:void 0);return{longPressProps:xt(g,b)}}const Bt=ie("BadgeCheck",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const ja=ie("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);const wa=ie("Forward",[["polyline",{points:"15 17 20 12 15 7",key:"1w3sku"}],["path",{d:"M4 18v-2a4 4 0 0 1 4-4h12",key:"jmiej9"}]]);const il=ie("MailCheck",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8",key:"12jkf8"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}]]);const Es=ie("MailOpen",[["path",{d:"M21.2 8.4c.5.38.8.97.8 1.6v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V10a2 2 0 0 1 .8-1.6l8-6a2 2 0 0 1 2.4 0l8 6Z",key:"1jhwl8"}],["path",{d:"m22 10-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 10",key:"1qfld7"}]]);const ll=ie("MailX",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h9",key:"1j9vog"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"m17 17 4 4",key:"1b3523"}],["path",{d:"m21 17-4 4",key:"uinynz"}]]);const cl=ie("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);const Kt=ie("Paperclip",[["path",{d:"M13.234 20.252 21 12.3",key:"1cbrk9"}],["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 0 2.828 2 2 0 0 0 2.828 0l8.414-8.586a4 4 0 0 0 0-5.656 4 4 0 0 0-5.656 0l-8.415 8.585a6 6 0 1 0 8.486 8.486",key:"1pkts6"}]]);const Sa=ie("ReplyAll",[["polyline",{points:"7 17 2 12 7 7",key:"t83bqg"}],["polyline",{points:"12 17 7 12 12 7",key:"1g4ajm"}],["path",{d:"M22 18v-2a4 4 0 0 0-4-4H7",key:"1fcyog"}]]);const Ca=ie("Reply",[["polyline",{points:"9 17 4 12 9 7",key:"hvgpf2"}],["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}]]);const Ze=ie("ShieldAlert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);const dl=ie("ShieldQuestion",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const ul=ie("ShieldX",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]),fl=({address:e,showTrustedBadge:t=!1})=>{const s=t?a.jsx(Bt,{className:"inline-block size-4 ml-1 -mt-0.5 text-positive","aria-label":"Trusted sender","data-testid":"trusted-sender-badge"}):null;return e.displayName?a.jsxs("span",{children:[a.jsx("span",{className:"text-fg",children:e.displayName}),a.jsxs("span",{className:"text-fg-muted",children:[" ","<",e.normalizedEmail,">"]}),s]}):a.jsxs("span",{className:"text-fg",children:[e.normalizedEmail,s]})},ml=({label:e,addresses:t,showTrustedBadge:s=!1})=>{const[n,r]=l.useState(!1);if(t.length===0)return null;const o=t.length>3,i=c=>{const u=s&&c.flags?.trusted?.value===!0;return a.jsx(fl,{address:c,showTrustedBadge:u})};return a.jsxs("div",{className:"flex gap-2 text-sm",children:[a.jsxs("span",{className:"text-fg-muted shrink-0 w-12",children:[e,":"]}),a.jsx("div",{className:"flex-1 min-w-0",children:n?a.jsx("div",{className:"flex flex-wrap gap-1",children:t.map((c,u)=>a.jsxs("span",{children:[i(c),u<t.length-1&&", "]},u))}):a.jsx("div",{className:"truncate",children:t.map((c,u)=>a.jsxs("span",{children:[i(c),u<t.length-1&&", "]},u))})}),o&&a.jsx("button",{type:"button",onClick:c=>{c.stopPropagation(),r(!n)},className:"shrink-0 text-fg-muted hover:text-fg transition-colors","aria-label":n?"Collapse":"Expand",children:n?a.jsx(ut,{className:"h-4 w-4"}):a.jsx(zn,{className:"h-4 w-4"})})]})},pl={unknown:{label:"Unknown sender",tone:"neutral"},wellknown:{label:"Known sender",tone:"positive"},vip:{label:"VIP",tone:"accent"}};function He({label:e,children:t,className:s}){return a.jsxs("section",{className:U("border-b border-line px-row-inset py-3",s),children:[a.jsx("h3",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:e}),a.jsx("div",{className:"mt-2",children:t})]})}function hl({sender:e}){const t=pl[e.trust],s=e.inboundCount==null?null:(e.replyCount??0)>0?`${e.inboundCount} received · you replied ${e.replyCount}×`:`${e.inboundCount} received · you've never replied`;return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(ft,{name:e.name,email:e.email,size:"md"}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"truncate text-sm font-semibold text-fg",children:e.name}),a.jsx("div",{className:"truncate text-2xs text-fg-subtle",children:e.email})]})]}),a.jsx("div",{className:"mt-2 flex items-center gap-2",children:e.addressUnverified?a.jsx(Ie,{tone:"danger",dot:!0,children:"Address couldn't be verified"}):a.jsx(Ie,{tone:t.tone,dot:!0,children:t.label})}),a.jsxs("p",{className:"mt-2 text-xs text-fg-muted",children:["First seen ",e.firstSeenLabel,s?` · ${s}`:""]})]})}function gl({auth:e,onShowSimilar:t}){if(e.verdict==="aligned")return a.jsxs("div",{className:"flex items-start gap-2 text-xs text-fg-muted",children:[a.jsx(ui,{className:"mt-0.5 size-3.5 shrink-0 text-positive"}),a.jsx("span",{children:e.summary})]});if(e.verdict==="caution")return a.jsxs("div",{className:"flex items-start gap-2 rounded-md bg-warning/10 p-3 text-warning",children:[a.jsx(dl,{className:"mt-0.5 size-4 shrink-0"}),a.jsx("p",{className:"text-xs leading-relaxed",children:e.summary})]});const s=e.addressUnreadable?"This sender can't be verified":"This message may be impersonating someone";return a.jsxs("div",{className:"rounded-md bg-danger-soft p-3",children:[a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx(Ze,{className:"mt-0.5 size-4 shrink-0 text-danger"}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-sm font-semibold text-danger",children:s}),a.jsx("p",{className:"mt-1 text-xs leading-relaxed text-fg",children:e.summary}),!e.addressUnreadable&&e.dkimDomain&&a.jsxs("p",{className:"mt-1 text-2xs text-fg-muted",children:["Sent from"," ",a.jsx("code",{className:"rounded bg-surface px-1 py-0.5",children:e.dkimDomain}),", claims to be"," ",a.jsx("code",{className:"rounded bg-surface px-1 py-0.5",children:e.fromDomain})]})]})]}),e.similarCount!=null&&e.similarCount>0&&a.jsxs(V,{variant:"secondary",size:"sm",className:"mt-2 w-full border-danger/30 text-danger hover:bg-danger-soft",onClick:t,children:[e.similarCount," similar messages"]})]})}function lt({icon:e,label:t,active:s,danger:n,onClick:r,pending:o}){const i=r===void 0||o===!0;return a.jsxs("button",{type:"button",onClick:r,disabled:i,className:U("flex items-center gap-2 rounded-md border px-2 py-1 text-xs transition-colors",s?"border-accent-2 bg-accent-2-soft text-accent-2":"border-line text-fg-muted hover:border-line-strong hover:text-fg",n&&!s&&"text-danger hover:bg-danger-soft",i&&"cursor-not-allowed opacity-50 hover:border-line"),children:[e,t]})}const bl={sender:"matched: sender",recipient:"matched: recipient",subject:"matched: subject",attachment:"matched: attachment",body:"matched: body",entities:"matched: entities"};function Na({data:e,onClose:t,onShowSimilar:s,actions:n,similarState:r="ready",similarLinkComponent:o,className:i,hideCloseButton:c=!1,reportSpamPending:u=!1,notSpamPending:x=!1}){const{sender:g,authenticity:b,category:p,flags:y={},similar:f}=e;return a.jsxs("aside",{className:U("flex w-76 shrink-0 flex-col overflow-y-auto border-l border-line bg-surface",i),children:[a.jsxs("header",{className:"flex h-pane-header shrink-0 items-center justify-between border-b border-line px-row-inset",children:[a.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Intelligence"}),!c&&a.jsx(V,{variant:"ghost",size:"sm",icon:a.jsx(Pt,{className:"size-3.5"}),onClick:t,"aria-label":"Collapse intelligence sidebar"})]}),a.jsx(He,{label:"Sender",children:a.jsx(hl,{sender:g})}),a.jsx(He,{label:"Authenticity",children:a.jsx(gl,{auth:b,onShowSimilar:s})}),a.jsx(He,{label:"Category",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ie,{tone:_n[p.value],children:p.value}),p.overridden&&a.jsx("span",{className:"text-2xs text-fg-subtle",children:"your override"}),a.jsx("button",{type:"button",className:U("ml-auto text-2xs text-accent hover:underline",!n?.onReclassify&&"cursor-not-allowed opacity-50 hover:no-underline"),disabled:!n?.onReclassify,onClick:n?.onReclassify,children:"reclassify"})]})}),a.jsxs(He,{label:"Quick actions",children:[a.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[a.jsx(lt,{icon:a.jsx(Ye,{className:"size-3.5"}),label:"VIP",active:y.vip,onClick:n?.onToggleVip}),a.jsx(lt,{icon:a.jsx(Ro,{className:"size-3.5"}),label:"Mute",active:y.muted,onClick:n?.onToggleMute}),n?.onNotSpam&&a.jsx(lt,{icon:a.jsx(il,{className:"size-3.5"}),label:x?"Undoing…":"Not spam",active:!0,onClick:n.onNotSpam,pending:x}),n?.onReportSpam&&a.jsx(lt,{icon:a.jsx(ul,{className:"size-3.5"}),label:u?"Reporting…":"Report spam",danger:!0,onClick:n.onReportSpam,pending:u}),a.jsx(lt,{icon:a.jsx(ll,{className:"size-3.5"}),label:"Unsubscribe",active:y.unsubscribed,onClick:n?.onToggleUnsubscribe})]}),n?.onNotSpam&&a.jsx("p",{className:"mt-1.5 text-2xs text-fg-subtle",children:"You reported this message as spam"})]}),(r!=="ready"||f.length>0)&&a.jsx(He,{label:"Similar messages",children:r==="loading"?a.jsx("div",{className:"animate-pulse space-y-2",children:Array.from({length:3}).map((d,m)=>a.jsxs("div",{className:"space-y-1",children:[a.jsx("div",{className:"h-3 w-3/4 rounded bg-surface-sunken"}),a.jsx("div",{className:"h-2.5 w-1/2 rounded bg-surface-sunken"})]},m))}):r==="error"?a.jsx("p",{className:"text-xs text-fg-subtle",children:"Similarity search unavailable"}):a.jsx("ul",{className:"-mx-1 space-y-1",children:f.map(d=>{const m="block w-full rounded-md px-1 py-1 text-left hover:bg-surface-sunken",h=`Open message from ${d.fromName||"unknown sender"}: ${d.subject}`,w=a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[a.jsx("span",{className:"truncate text-xs font-medium text-fg",children:d.fromName}),a.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:d.timeLabel})]}),a.jsx("div",{className:"truncate text-xs text-fg-muted",children:d.subject}),a.jsx("span",{className:"mt-1 inline-block rounded-full bg-surface-sunken px-1.5 py-px text-2xs text-fg-subtle",children:bl[d.matched]})]});return a.jsx("li",{children:o?o({mailboxId:d.mailboxId,threadId:d.threadId,messageId:d.id,className:m,ariaLabel:h,children:w}):a.jsx("div",{className:m,children:w})},d.id)})})}),a.jsx(He,{label:"Coming soon",className:"border-b-0 opacity-70",children:a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-dashed border-line p-2",children:[a.jsx(We,{className:"mt-0.5 size-3.5 shrink-0 text-fg-subtle"}),a.jsxs("div",{children:[a.jsx("div",{className:"text-xs font-medium text-fg-muted",children:"Suggested actions"}),a.jsx("div",{className:"text-2xs text-fg-subtle",children:'"Create a filter for messages like this" — on-device model'})]})]}),a.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-dashed border-line p-2",children:[a.jsx(We,{className:"mt-0.5 size-3.5 shrink-0 text-fg-subtle"}),a.jsxs("div",{children:[a.jsx("div",{className:"text-xs font-medium text-fg-muted",children:"Thread summary"}),a.jsx("div",{className:"text-2xs text-fg-subtle",children:"One-paragraph digest — Bedrock"})]})]})]})})]})}const ms=e=>({shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey}),dn=e=>e.shiftKey||e.metaKey||e.ctrlKey,xl=e=>e.shiftKey?"range":e.metaKey||e.ctrlKey?"toggle":"open",yl=(e,t)=>!t&&e>0,vl=(e,t,s)=>{const n=e.indexOf(s);if(n===-1)return[];const r=t===void 0?-1:e.indexOf(t);if(r===-1)return[s];const o=Math.min(r,n),i=Math.max(r,n);return e.slice(o,i+1)},kl=(e,t,s,n)=>t!==void 0&&e.includes(t)?t:s!==void 0&&e.includes(s)?s:n,jl=(e,t)=>{const s=new Set(t),n=new Set;for(const r of e)s.has(r)&&n.add(r);return n},wl=(e,t,s)=>{if(e.length===0)return;const n=t===void 0?-1:e.indexOf(t);if(n===-1)return s>0?e[0]:e[e.length-1];const r=Math.min(Math.max(n+s,0),e.length-1);return e[r]},Sl=e=>{const[t,s]=l.useState(()=>new Set(e?.initialSelectedIds)),[n,r]=l.useState(void 0),o=l.useCallback(d=>t.has(d),[t]),i=l.useCallback(d=>{r(d),s(m=>{const h=new Set(m);return h.has(d)?h.delete(d):h.add(d),h})},[]),c=l.useCallback(d=>{r(d),s(m=>{if(m.has(d))return m;const h=new Set(m);return h.add(d),h})},[]),u=l.useCallback(d=>{s(m=>{if(!m.has(d))return m;const h=new Set(m);return h.delete(d),h})},[]),x=l.useCallback(d=>{s(new Set(d))},[]),g=l.useCallback(()=>{r(void 0),s(new Set)},[]),b=l.useCallback(d=>{s(m=>d.every(w=>m.has(w))?new Set:new Set(d))},[]),p=l.useCallback(d=>{r(d)},[]),y=l.useCallback(d=>{s(m=>{if(m.size===0)return m;const h=jl(m,d);return h.size===m.size?m:h})},[]),f=l.useCallback((d,m,h)=>{const w=kl(d,n,h,m);s(v=>{const j=vl(d,w,m);if(j.length===0)return v;const T=new Set(v);for(const R of j)T.add(R);return T}),r(w)},[n]);return{selectedIds:t,selectedCount:t.size,hasSelection:t.size>0,isSelected:o,toggle:i,select:c,deselect:u,selectAll:x,clearSelection:g,toggleAll:b,selectRange:f,setAnchor:p,anchorId:n,intersectWith:y}};function Yf({hints:e=Mo,className:t}){return e.length===0?null:a.jsx("footer",{className:U("flex items-center gap-2 border-t border-line px-row-inset py-1 text-2xs text-fg-subtle",t),children:e.map(s=>a.jsx(Cl,{hint:s},s.label))})}function Cl({hint:e}){return a.jsxs("span",{className:"flex items-center gap-1",children:[e.keys.map(t=>a.jsx(qo,{children:t},t)),a.jsx("span",{children:e.label})]})}const Ta="outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",Ia=({active:e,focused:t})=>U("relative flex h-8 w-full items-center gap-2 px-row-inset text-left",Ta,e?"bg-accent-2-soft":t?"bg-surface-sunken":"hover:bg-surface-sunken",t&&!e&&"before:absolute before:inset-y-0 before:left-0 before:w-0.5 before:bg-accent-2"),Rs=({active:e,focused:t})=>U("relative flex w-full items-start gap-3 py-2 pl-5 pr-row-inset text-left transition-colors",Ta,e?"bg-accent-2-soft":t?"bg-surface-sunken":"hover:bg-surface-sunken",t&&!e&&"before:absolute before:inset-y-0 before:left-0 before:w-0.5 before:bg-accent-2");function Ea({thread:e}){const t=!e.isRead;return a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"flex w-4 shrink-0 items-center justify-center",children:e.suspicious?a.jsx(Ze,{className:"size-3.5 text-danger"}):e.starred?a.jsx(Ye,{className:"size-3 fill-warning text-warning"}):t?a.jsx("span",{className:"size-1.5 rounded-full bg-accent"}):null}),a.jsx("span",{className:U("w-36 shrink-0 truncate text-xs",t?"font-semibold text-fg":"text-fg-muted"),children:e.fromName}),a.jsxs("span",{className:"min-w-0 flex-1 truncate text-xs",children:[a.jsx("span",{className:U(t?"font-medium text-fg":"text-fg-muted"),children:e.subject}),a.jsxs("span",{className:"text-fg-subtle",children:[" — ",e.snippet]})]}),e.hasAttachment&&a.jsx(Kt,{className:"size-3 shrink-0 text-fg-subtle",role:"img","aria-label":"Has an attachment"}),a.jsx("span",{className:"w-11 shrink-0 text-right text-2xs text-fg-subtle tabular-nums",children:e.timeLabel})]})}function un(e,t){const s=t?.trim();if(!s)return e;const n=e.toLowerCase(),r=s.toLowerCase(),o=[];let i=0,c=n.indexOf(r,i),u=0;for(;c!==-1;)c>i&&o.push(e.slice(i,c)),o.push(a.jsx("mark",{className:"bg-transparent font-semibold text-fg",children:e.slice(c,c+r.length)},u++)),i=c+r.length,c=n.indexOf(r,i);return i<e.length&&o.push(e.slice(i)),o}function Nl({thread:e,badge:t,highlightQuery:s}){const n=!e.isRead;return a.jsxs("span",{className:"min-w-0 flex-1",children:[a.jsxs("span",{className:"flex items-baseline justify-between gap-2",children:[a.jsxs("span",{className:U("flex min-w-0 items-center gap-1.5 truncate text-sm",n?"font-semibold text-fg":"font-medium text-fg-muted"),children:[e.trust==="vip"&&a.jsx("span",{className:"size-1.5 shrink-0 rounded-full bg-accent-2"}),a.jsx("span",{className:"truncate",children:e.fromName}),e.messageCount!=null&&e.messageCount>1&&a.jsx("span",{className:"shrink-0 text-2xs font-normal text-fg-subtle",children:e.messageCount})]}),a.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:e.timeLabel})]}),a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx("span",{className:U("truncate text-sm",n?"text-fg":"text-fg-muted"),children:un(e.subject,s)}),e.suspicious&&a.jsx(Ze,{className:"size-3.5 shrink-0 text-danger"}),e.starred&&a.jsx(Ye,{className:"size-3 shrink-0 fill-warning text-warning"}),e.hasAttachment&&a.jsx(Kt,{className:"size-3 shrink-0 text-fg-subtle",role:"img","aria-label":"Has an attachment"})]}),a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx("span",{className:"line-clamp-1 min-w-0 flex-1 text-xs text-fg-subtle",children:un(e.snippet,s)}),e.category&&e.category!=="personal"&&a.jsx(Ie,{tone:_n[e.category],className:"shrink-0",children:e.category}),e.labels?.map(r=>a.jsx(jr,{label:r,className:"max-w-20"},r.labelId)),t]})]})}function Tl({thread:e,selection:t}){if(!t)return a.jsx(ft,{name:e.fromName,email:e.fromEmail,size:"sm"});const{checked:s,alwaysVisible:n}=t;return a.jsxs("span",{className:"relative size-7 shrink-0",children:[a.jsx(ft,{name:e.fromName,email:e.fromEmail,size:"sm",className:U("absolute inset-0 transition-opacity sm:group-hover:opacity-0",(s||n)&&"opacity-0")}),a.jsx("span",{role:"button",tabIndex:-1,onClick:t.onToggle,onKeyDown:r=>{r.key!=="Enter"&&r.key!==" "||(r.preventDefault(),r.stopPropagation(),t.onToggle(r))},className:U("absolute inset-0 size-7 items-center justify-center rounded-full border transition-opacity",n?"flex":"hidden sm:flex",s?"bg-accent border-accent text-accent-fg opacity-100":n?"border-fg-subtle/40 bg-canvas opacity-100":"border-fg-subtle/40 bg-canvas opacity-0 group-hover:opacity-100"),"aria-label":s?"Deselect message":"Select message",children:s&&a.jsx(Dt,{className:"size-3"})})]})}function Ms({thread:e,selection:t,badge:s,highlightQuery:n}){const r=!e.isRead;return a.jsxs(a.Fragment,{children:[r&&a.jsx("span",{className:"absolute left-1.5 top-1/2 size-1.5 -translate-y-1/2 rounded-full bg-accent"}),a.jsx(Tl,{thread:e,selection:t}),a.jsx(Nl,{thread:e,badge:s,highlightQuery:n})]})}const Ra=e=>({...wr,[Ao]:"","data-message-id":e.id});function Jf({thread:e,active:t,focused:s,tabIndex:n,onClick:r}){return a.jsx("button",{type:"button",...Ra(e),tabIndex:n,onClick:r,className:Ia({active:t,focused:s}),children:a.jsx(Ea,{thread:e})})}function Xf({thread:e,active:t,focused:s,tabIndex:n,selection:r,onClick:o}){return a.jsx("button",{type:"button",...Ra(e),tabIndex:n,onClick:o,className:U("group",Rs({active:t,focused:s})),children:a.jsx(Ms,{thread:e,selection:r})})}let Ve;const Il=5e3;function Ma(e){e.preventDefault(),$t()}function $t(){Ve!==void 0&&(clearTimeout(Ve),Ve=void 0,document.removeEventListener("contextmenu",Ma,!0),document.removeEventListener("pointerup",$t,!0))}function El(){Ve===void 0?(document.addEventListener("contextmenu",Ma,!0),document.addEventListener("pointerup",$t,!0)):clearTimeout(Ve),Ve=setTimeout($t,Il)}function Rl({onLongPress:e,isDisabled:t,delayMs:s=500,accessibilityDescription:n}){const{longPressProps:r}=ol({isDisabled:t,threshold:s,accessibilityDescription:n,onLongPress:e}),o=l.useCallback(i=>{i.pointerType!=="touch"&&i.pointerType!=="pen"||El()},[]);return{longPressProps:xt(r,{onPointerDown:o})}}const ct="min-h-11 min-w-11 px-0";function Aa({hasThread:e,onReply:t,onReplyAll:s,onForward:n,isStarred:r,onToggleStar:o,onDelete:i,isRead:c,onToggleRead:u,moveSlot:x,overflowItems:g=[],onUnavailable:b,unavailableHint:p,className:y}){const f=(m,h)=>()=>{if(!e){b?.(m);return}h?.()},d=u?[{key:"toggle-read",label:c?"Mark as unread":"Mark as read",icon:c?a.jsx(Yo,{className:"size-4"}):a.jsx(Es,{className:"size-4"}),onSelect:f("toggleRead",u)}]:[];return a.jsxs("div",{className:U("relative",y),children:[a.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-0.5 bg-canvas px-1",children:[t&&a.jsx(V,{variant:"ghost",size:"sm",icon:a.jsx(Ca,{className:"size-5"}),onClick:f("reply",t),"aria-label":"Reply",title:"Reply",className:ct}),s&&a.jsx(V,{variant:"ghost",size:"sm",icon:a.jsx(Sa,{className:"size-5"}),onClick:f("replyAll",s),"aria-label":"Reply all",title:"Reply all",className:ct}),n&&a.jsx(V,{variant:"ghost",size:"sm",icon:a.jsx(wa,{className:"size-5"}),onClick:f("forward",n),"aria-label":"Forward",title:"Forward",className:ct}),a.jsx("div",{className:"flex-1"}),o&&a.jsx(V,{variant:"ghost",size:"sm",icon:a.jsx(Ye,{className:U("size-5",r&&"fill-warning text-warning")}),onClick:f("star",o),"aria-label":r?"Unstar":"Star","aria-pressed":r,title:r?"Unstar":"Star",className:ct}),x,i&&a.jsx(V,{variant:"ghost",size:"sm",icon:a.jsx(Ft,{className:"size-5"}),onClick:f("delete",i),"aria-label":"Move to Trash",title:"Move to Trash",className:ct}),a.jsx(aa,{triggerLabel:"More actions",items:[...d,...g]})]}),!e&&p&&a.jsx("p",{role:"status",className:"bg-surface-sunken px-3 py-1 text-2xs text-fg-subtle",children:p})]})}function Ml({open:e=!1,enabled:t=!0,onToggle:s,className:n}){return a.jsx(V,{variant:"ghost",size:"sm",icon:a.jsx(Un,{className:"size-4"}),title:"Intelligence","aria-label":e?"Hide intelligence sidebar":"Show intelligence sidebar","aria-pressed":e,disabled:!t,onClick:s,className:U(e&&"bg-accent-2-soft text-accent-2",n)})}function Al({hasThread:e,onUnavailable:t,unavailableHint:s,isStarred:n,showTriage:r=!0,onReply:o,onReplyAll:i,onForward:c,onDelete:u,onToggleStar:x,moveSlot:g,onMove:b,replyTitle:p="Reply (r)",replyAllTitle:y="Reply all (a)",forwardTitle:f="Forward (f)",deleteTitle:d="Move to Trash (#)",flagTitle:m="Star (s)",children:h,className:w}){const v=(j,T)=>()=>{if(!e||!T){t?.(j);return}T()};return a.jsxs("div",{className:"relative",children:[a.jsxs("header",{className:U("flex h-pane-header shrink-0 items-center gap-1 border-b border-line bg-surface px-3",w),children:[a.jsx(V,{variant:"ghost",size:"sm",icon:a.jsx(Ca,{className:"size-4"}),title:p,"aria-label":"Reply",onClick:v("reply",o)}),a.jsx(V,{variant:"ghost",size:"sm",icon:a.jsx(Sa,{className:"size-4"}),title:y,"aria-label":"Reply all",onClick:v("replyAll",i)}),a.jsx(V,{variant:"ghost",size:"sm",icon:a.jsx(wa,{className:"size-4"}),title:f,"aria-label":"Forward",onClick:v("forward",c)}),r&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"mx-1 h-4 w-px bg-line","aria-hidden":!0}),a.jsx(V,{variant:"ghost",size:"sm",icon:a.jsx(Ft,{className:"size-4"}),title:d,"aria-label":"Move to Trash",onClick:v("delete",u)}),g??a.jsx(V,{variant:"ghost",size:"sm",icon:a.jsx(ks,{className:"size-4"}),title:"Move to mailbox","aria-label":"Move to mailbox",onClick:v("move",b)}),a.jsx(V,{variant:"ghost",size:"sm",icon:a.jsx(Ye,{className:U("size-4",n&&"fill-warning text-warning")}),title:m,"aria-label":"Star","aria-pressed":n,onClick:v("flag",x)})]}),a.jsx("div",{className:"flex-1"}),h]}),s&&a.jsx("p",{role:"status",className:"border-b border-line bg-surface-sunken px-3 py-1 text-2xs text-fg-subtle",children:s})]})}function $a({message:e,onClick:t,isFocused:s,isUnread:n,trailing:r}){const o=a.jsxs(a.Fragment,{children:[a.jsx(zn,{className:"size-3.5 shrink-0 text-fg-subtle"}),a.jsxs("div",{className:"relative shrink-0",children:[a.jsx(ft,{name:e.fromName,email:e.fromEmail,size:"md"}),n&&a.jsx("span",{className:"absolute -top-0.5 -right-0.5 size-2 rounded-full border border-canvas bg-accent"})]}),a.jsx("span",{className:U("w-36 shrink-0 truncate text-sm",n?"font-semibold text-fg":"font-medium text-fg-muted"),children:e.fromName}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-fg-subtle",children:e.snippet}),r??a.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:e.dateLabel})]}),i=U("group flex h-section-row w-full items-center gap-3 border-b border-line px-2 text-left transition-colors hover:bg-surface-sunken lg:px-4",s&&"bg-surface-sunken ring-1 ring-inset ring-accent/30");return t?a.jsx("div",{role:"button",tabIndex:0,"aria-expanded":!1,onClick:t,onKeyDown:c=>{Sr(c)&&(c.preventDefault(),t())},className:U(i,"cursor-pointer"),children:o}):a.jsx("div",{className:i,children:o})}function La({message:e,warning:t,onHeaderClick:s,isFocused:n,senderBadge:r,trailing:o,to:i,indicators:c,actionMenu:u,actionBar:x,body:g}){const b=a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[a.jsxs("span",{className:"text-sm font-semibold text-fg",children:[e.fromName,r]}),o??a.jsx("span",{className:"text-2xs text-fg-subtle",children:e.dateLabel})]}),a.jsx("div",{className:"text-xs text-fg-subtle",children:e.fromEmail}),i!==null&&a.jsx("div",{className:"text-xs text-fg-subtle",children:i??a.jsxs(a.Fragment,{children:["to ",e.toLabel]})})]});return a.jsxs("div",{className:"px-2 py-3 lg:px-4",children:[a.jsxs("div",{className:U("-mx-2 -my-1 flex items-start gap-3 rounded-sm px-2 py-1",n&&"ring-1 ring-inset ring-accent/30"),children:[s?a.jsx("button",{type:"button",onClick:s,"aria-expanded":!0,"aria-label":"Collapse message",className:"mt-1 shrink-0 text-fg-subtle transition-colors hover:text-fg",children:a.jsx(ut,{className:"size-3.5"})}):a.jsx(ut,{className:"mt-1 size-3.5 shrink-0 text-fg-subtle"}),a.jsx(ft,{name:e.fromName,email:e.fromEmail,size:"md"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[s?a.jsx("button",{type:"button",onClick:s,className:"w-full text-left",children:b}):b,c]}),u&&a.jsx("div",{className:"shrink-0",children:u})]}),t&&a.jsxs("div",{className:"mt-3 flex items-start gap-3 rounded-md bg-danger-soft p-3",children:[a.jsx(Ze,{className:"mt-0.5 size-4 shrink-0 text-danger"}),a.jsxs("div",{className:"text-sm text-fg",children:[a.jsx("span",{className:"font-semibold text-danger",children:"Caution: "}),t," ",a.jsx("button",{type:"button",className:"text-accent underline",children:"Why?"})]})]}),x&&a.jsx("div",{className:"mt-3 -mx-2 lg:-mx-4",children:x}),a.jsx(Jo,{children:g??a.jsx(Xo,{className:"mt-3",html:e.bodyHtml,category:e.framed?"newsletter":"personal",allowImages:!0})})]})}function $l({thread:e,onBack:t,intelligence:s,intelligenceOpen:n,onToggleIntelligence:r,actions:o,children:i,touchHandlers:c}){const[u,x]=l.useState(!1),g=r!==void 0,b=g?n??!1:u,p=!!s||g,y=()=>{if(g){r?.();return}x(d=>!d)},f=()=>{if(g){b&&r?.();return}x(!1)};return a.jsxs("article",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[a.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line bg-surface px-row-inset",children:[a.jsx(V,{variant:"ghost",size:"sm",icon:a.jsx(Bn,{className:"size-4"}),onClick:t,"aria-label":"Back to messages",className:"-ml-1 shrink-0"}),a.jsx("h2",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:e.subject}),p&&a.jsx(V,{variant:"ghost",size:"sm",icon:a.jsx(Un,{className:"size-4"}),onClick:y,"aria-label":b?"Hide intelligence panel":"Show intelligence panel","aria-pressed":b,title:"Intelligence",className:U("shrink-0",b&&"bg-accent-2-soft text-accent-2")})]}),a.jsx("div",{className:"flex-1 overflow-y-auto",style:c?{touchAction:"pan-y"}:void 0,...c,children:i??[...e.messages].reverse().map(d=>{const m=h=>h?()=>h(d.id):void 0;return d.expanded?a.jsx(La,{message:d,warning:e.warning,onHeaderClick:m(o?.onToggleExpand),actionBar:a.jsx(Aa,{hasThread:!0,onReply:m(o?.onReply),onReplyAll:m(o?.onReplyAll),onForward:m(o?.onForward),onToggleStar:m(o?.onToggleStar),onDelete:m(o?.onDelete),onToggleRead:m(o?.onToggleRead),moveSlot:o?.moveSlot?.(d.id)})},d.id):a.jsx($a,{message:d,onClick:m(o?.onToggleExpand)},d.id)})}),s&&!g&&a.jsx(Cr,{open:b,onClose:f,title:"Intelligence",anchor:"right",className:"p-0",children:a.jsx(Na,{data:s,onClose:f,className:"h-full w-full border-l-0"})})]})}function Ll({state:e,onRetry:t}){return a.jsxs("div",{role:"alert","data-testid":"attachment-error",className:"flex items-start gap-2 border-t border-danger/30 bg-danger-soft px-2 py-2 text-xs",children:[a.jsx(Nr,{className:"mt-0.5 size-3.5 shrink-0 text-danger","aria-hidden":!0}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"font-medium text-danger",children:e.title}),a.jsx("p",{className:"mt-0.5 text-fg-muted",children:e.detail})]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-3",children:[a.jsx("button",{type:"button",onClick:t,className:"font-medium text-accent hover:underline",children:"Try again"}),e.reportUrl&&a.jsx("a",{href:e.reportUrl,target:"_blank",rel:"noreferrer",className:"font-medium text-accent hover:underline",children:"Report this"})]})]})}function Pl({attachments:e,onDownload:t,hasUnlistedAttachment:s=!1,className:n}){return e.length===0&&!s?null:a.jsxs("section",{"aria-label":"Attachments","data-testid":"attachment-list",className:U("space-y-1.5",n),children:[a.jsxs("h3",{className:"flex items-center gap-1.5 text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:[a.jsx(Kt,{className:"size-3","aria-hidden":!0}),e.length===0?"Attachment":e.length===1?"1 attachment":`${e.length} attachments`]}),e.length>0&&a.jsx("ul",{className:"overflow-hidden rounded-sm border border-line bg-surface",children:e.map(r=>{const o=r.download.status==="downloading";return a.jsxs("li",{className:"border-t border-line first:border-t-0",children:[a.jsxs("button",{type:"button",onClick:()=>t(r.attachmentId),disabled:o,"data-testid":"attachment-download","aria-label":`Download ${r.filename}`,className:"flex w-full items-center gap-2 px-2 py-2 text-left transition-colors hover:bg-surface-sunken disabled:cursor-progress disabled:opacity-60",children:[a.jsxs("span",{className:"min-w-0 flex-1",children:[a.jsx("bdi",{className:"block truncate text-sm text-fg",title:r.filename,children:r.filename}),a.jsxs("span",{className:"block truncate text-2xs text-fg-subtle",children:[r.typeLabel," ·"," ",Qo(r.sizeOctets)]})]}),o?a.jsx(Kn,{className:"size-4 shrink-0 animate-spin text-fg-subtle","aria-hidden":!0}):a.jsx(ci,{className:"size-4 shrink-0 text-fg-subtle","aria-hidden":!0})]}),r.download.status==="failed"&&a.jsx(Ll,{state:r.download,onRetry:()=>t(r.attachmentId)})]},r.attachmentId)})}),s&&a.jsx("p",{role:"alert","data-testid":"attachment-unlisted",className:"rounded-sm border border-line bg-surface px-2 py-2 text-xs text-fg-muted",children:"The mail server says this message carries an attachment, but none of its parts describe one. Re-sync the account from Settings; if the attachment still does not appear, the message is worth reporting."})]})}function Dl({label:e,onUndo:t,undoLabel:s="Undo",filtersHref:n,className:r}){return a.jsxs(Ie,{tone:"accent",className:U("py-1 text-xs",r),children:[a.jsx(Ho,{className:"size-3.5 shrink-0","aria-hidden":!0}),a.jsx("span",{children:e}),t&&a.jsx("button",{type:"button",onClick:o=>{o.stopPropagation(),t()},className:"font-semibold underline decoration-dotted underline-offset-2 hover:decoration-solid",children:s}),n&&a.jsx("a",{href:n,onClick:o=>{o.stopPropagation()},className:"font-semibold underline decoration-dotted underline-offset-2 hover:decoration-solid",children:"Manage filter"})]})}const Fl="peer relative size-5 shrink-0 cursor-pointer appearance-none rounded-md border border-line-strong bg-surface outline-none transition-colors checked:border-positive checked:bg-positive indeterminate:border-positive indeterminate:bg-positive focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-surface",fn="pointer-events-none absolute inset-0 m-auto size-3.5 text-accent-fg";function Ol({label:e,description:t,indeterminate:s=!1,checked:n,onChange:r,className:o,...i}){const c=l.useRef(null);l.useEffect(()=>{c.current&&(c.current.indeterminate=s)},[s]);const u=a.jsxs("span",{className:"relative inline-flex",children:[a.jsx("input",{ref:c,type:"checkbox",checked:n,onChange:r,className:Fl,...i}),a.jsx(Dt,{className:U(fn,"hidden peer-checked:block"),"aria-hidden":!0}),a.jsx(cl,{className:U(fn,"hidden peer-indeterminate:block"),"aria-hidden":!0})]});return e===void 0&&t===void 0?a.jsx("span",{className:o,children:u}):a.jsxs("label",{className:U("flex min-h-11 cursor-pointer items-center gap-3 text-left",o),children:[u,a.jsxs("span",{className:"flex min-w-0 flex-col",children:[e!==void 0&&a.jsx("span",{className:"text-sm text-fg",children:e}),t!==void 0&&a.jsx("span",{className:"text-xs text-fg-subtle",children:t})]})]})}function zl(e){return{id:e.id,fromName:e.sender,fromEmail:e.senderEmail??e.sender,subject:e.subject,snippet:e.snippet,timeLabel:e.date,isRead:!e.unread,starred:e.flagged,...e.mailboxId?{mailboxId:e.mailboxId}:{}}}function _l({result:e,onClick:t,query:s,showFolder:n=!0}){const r=n&&e.folder?Tr(e.folder):void 0;return a.jsx("button",{type:"button",onClick:t,className:U("group",Rs({}),"border-b border-line"),children:a.jsx(Ms,{thread:zl(e),highlightQuery:s,badge:a.jsxs(a.Fragment,{children:[r&&a.jsx(Ie,{tone:"neutral",className:"shrink-0",children:r}),e.category&&a.jsx(Ie,{tone:e.category.tone??"neutral",className:"shrink-0",children:e.category.label}),e.matchedChunkLabel&&a.jsx(Ie,{tone:"neutral",className:"shrink-0",children:`matched: ${e.matchedChunkLabel}`}),e.score!=null&&a.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:e.score.toFixed(2)})]})})})}const Ul=e=>e===1?"result":"results";function Bl({count:e,onScopeToSpam:t}){return a.jsx(qn,{tone:"info",variant:"soft",className:"items-center justify-between gap-3 rounded-none border-b border-line",children:a.jsxs("div",{className:"flex items-center justify-between gap-3",children:[a.jsxs("p",{className:"min-w-0 text-xs text-fg-muted",children:[a.jsx("span",{className:"font-semibold text-fg tabular-nums",children:e})," ",`${Ul(e)} from Spam`]}),a.jsx(V,{variant:"ghost",size:"sm",onClick:t,className:"shrink-0 text-accent",children:"Go to Spam"})]})})}const mn=6,Kl={kind:"global"},ql=e=>e.kind==="folder"&&e.role==="junk",Ql=e=>e.folder?.role==="junk";function Pa(e){const t=[],s=[];for(const n of e)Ql(n)?s.push(n):t.push(n);return{kept:t,spam:s}}function Da({onClick:e,blockedReason:t}){const s=l.useId(),[n,r]=l.useState(!1);return a.jsxs("div",{className:"border-b border-line px-row-inset py-1.5",children:[a.jsxs("button",{type:"button",onClick:()=>{if(t){r(!0);return}e()},"aria-describedby":t?s:void 0,className:U("flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium transition-colors",t?"text-fg-subtle opacity-55":"text-accent hover:bg-surface-sunken"),children:[a.jsx(Ir,{className:"size-3.5 shrink-0","aria-hidden":"true"}),a.jsx("span",{children:"Make this a filter"})]}),t&&a.jsx(Er,{id:s,reason:t,nudged:n,className:"px-2 pt-1 text-2xs text-warning"})]})}function Hl({section:e,query:t,onSelectResult:s,showFolder:n}){const[r,o]=l.useState(e.initialCollapsed??!1),[i,c]=l.useState(!1),u=e.results.length>mn,g=!i&&u?e.results.slice(0,mn):e.results,b=e.results.length-g.length;return a.jsxs("div",{children:[a.jsxs("button",{type:"button","aria-expanded":!r,onClick:()=>o(p=>!p),className:"sticky top-0 z-10 flex h-section-row w-full items-center gap-1.5 border-b border-line bg-surface-sunken px-row-inset text-left transition-colors hover:bg-surface",children:[a.jsx("span",{className:"flex-1 text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:e.label}),a.jsx("span",{className:"text-2xs text-fg-subtle tabular-nums",children:e.results.length}),a.jsx(ut,{className:U("size-3 shrink-0 text-fg-subtle transition-transform duration-200",r?"rotate-0":"rotate-180")})]}),!r&&a.jsxs(a.Fragment,{children:[g.map(p=>a.jsx(_l,{result:p,query:t,showFolder:n,onClick:s?()=>s(p):void 0},p.id)),u&&a.jsxs("button",{type:"button",onClick:()=>c(p=>!p),className:"flex w-full items-center justify-center border-b border-line px-row-inset py-1.5 text-2xs font-medium text-accent transition-colors hover:bg-surface",children:[i?"Show less":`Show ${b} more`,!i&&a.jsx(ut,{className:"ml-1 size-3"})]})]})]})}function Fa({value:e,recentSearches:t,onPickRecent:s,sections:n,loading:r,onSelectResult:o,tokens:i,scope:c=Kl,makeFilter:u}){if(!(e.trim().length>0))return t&&t.length>0?a.jsxs("div",{className:"flex flex-col",children:[a.jsx("h3",{className:"px-row-inset pb-1 pt-3 text-2xs font-semibold uppercase tracking-wide text-fg-subtle",children:"Recent searches"}),t.map(j=>a.jsxs("button",{type:"button",onClick:()=>s?.(j),className:"flex w-full items-center gap-2.5 border-b border-line px-row-inset py-2.5 text-left transition-colors hover:bg-surface-sunken",children:[a.jsx(vi,{className:"size-4 shrink-0 text-fg-subtle"}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-fg-muted",children:j})]},j))]}):a.jsx("p",{className:"px-row-inset py-6 text-center text-sm text-fg-subtle",children:"Search across your mail by sender, subject or words in the message."});const g=i&&i.length>0&&a.jsx(Rr,{tokens:i}),b=u&&a.jsx(Da,{...u});if(r)return a.jsxs("div",{className:"flex flex-col",children:[b,g,a.jsx("div",{className:"flex flex-col gap-3 px-row-inset py-4",children:[0,1,2,3].map(j=>a.jsxs("div",{className:"flex flex-col gap-1.5",children:[a.jsx("div",{className:"h-3 w-1/3 animate-pulse rounded bg-surface-sunken"}),a.jsx("div",{className:"h-3 w-2/3 animate-pulse rounded bg-surface-sunken"}),a.jsx("div",{className:"h-2.5 w-1/2 animate-pulse rounded bg-surface-sunken"})]},j))})]});const p=c.kind==="global",y=ql(c)||c.kind==="collection",f=p||c.kind==="collection",d=(n??[]).map(j=>{if(y)return{section:j,spam:[]};const{kept:T,spam:R}=Pa(j.results);return{section:{...j,results:T},spam:R}}),m=d.map(j=>j.section),h=d.reduce((j,T)=>j+T.spam.length,0),w=c.kind==="global"&&h>0&&c.onScopeToSpam!==void 0?a.jsx(Bl,{count:h,onScopeToSpam:c.onScopeToSpam}):void 0;return m.some(j=>j.results.length>0)?a.jsxs("div",{className:"flex flex-col",children:[b,g,w,m.filter(j=>j.results.length>0).map(j=>a.jsx(Hl,{section:j,query:e,showFolder:f,onSelectResult:o},j.id))]}):a.jsxs("div",{className:"flex flex-col",children:[b,g,w,a.jsxs("div",{className:"px-row-inset py-10 text-center",children:[a.jsxs("p",{className:"text-sm font-medium text-fg",children:["No matches for “",e,"”"]}),a.jsx("p",{className:"mt-1 text-xs text-fg-subtle",children:"Try a different word, or adjust the filters above."})]})]})}function Gl({value:e,onChange:t,onClear:s,onCancel:n,filter:r,recentSearches:o,onPickRecent:i,sections:c,loading:u,onSelectResult:x,tokens:g,chips:b,onRemoveChip:p,scope:y,makeFilter:f,suggest:d,suggestList:m}){const h=a.jsx(Fa,{value:e,recentSearches:o,onPickRecent:i,sections:c,loading:u,onSelectResult:x,tokens:g,scope:y,makeFilter:f});return a.jsxs("article",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[a.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line bg-surface px-row-inset",children:[a.jsx("div",{className:"min-w-0 flex-1",children:a.jsx(na,{value:e,onChange:t,onClear:s,chips:b,onRemoveChip:p,globalFocusKey:!1,showClearButton:!1,suggest:d})}),a.jsx(V,{variant:"ghost",size:"sm",icon:a.jsx(Pt,{className:"size-4"}),onClick:n,"aria-label":"Clear and close search",className:"-mr-1 shrink-0"})]}),m,r&&e.trim().length===0?a.jsx(Mr,{children:a.jsx(Ar,{...r,children:h})}):a.jsx("div",{className:"flex-1 overflow-y-auto",children:h})]})}const pn=e=>e.toLocaleString();function hn({selectAll:e,selecting:t,className:s}){return a.jsx(Ol,{className:s,checked:e.checked,indeterminate:e.indeterminate,onChange:e.onChange,label:a.jsx("span",{className:"font-medium text-accent",children:e.checked&&t?"Deselect all":"Select all"})})}function Vl({title:e,count:t,onCancel:s,onDelete:n,onMove:r,onOrganize:o,onJunk:i,onMarkRead:c,navSlot:u,titleMeta:x,searchSlot:g,searchField:b,idleSlot:p,overflowSlot:y,isBusy:f=!1,isCounting:d=!1,selectAll:m,statusLabel:h,progress:w,notice:v}){const j=t>0||d,T=m?.checked?`All ${pn(t)} loaded selected`:`${pn(t)} ${t===1?"message":"messages"} selected`,R=[];return i&&!f&&!d&&R.push({key:"junk",label:"Junk",icon:a.jsx(Ze,{className:"size-4"}),onSelect:i}),c&&!f&&!d&&R.push({key:"mark-read",label:"Mark read",icon:a.jsx(Es,{className:"size-4"}),onSelect:c}),a.jsxs("header",{"data-selection-bar":"",className:"flex shrink-0 flex-col border-b border-line bg-surface-sunken",children:[a.jsxs("div",{"data-selection-bar-row":"actions",className:"flex h-pane-header items-center gap-1 px-row-inset",children:[j?a.jsx(V,{variant:"ghost",size:"touch",icon:a.jsx(Bn,{className:"size-5"}),onClick:s,"aria-label":"Cancel selection",className:"-ml-2 shrink-0"}):u,m&&a.jsx(hn,{selectAll:m,selecting:j,className:"hidden shrink-0 pr-2 md:flex"}),j?a.jsx("span",{"data-selection-count":"",className:"min-w-0 flex-1 truncate px-1 text-sm font-medium text-fg",role:"status","aria-live":"polite",children:h??T}):b?a.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1",children:b}):a.jsxs(a.Fragment,{children:[a.jsx("h1",{className:"min-w-0 flex-1 truncate px-1 text-sm font-semibold text-fg",children:e}),x,g]}),j&&!d&&a.jsxs(a.Fragment,{children:[a.jsx(V,{variant:"ghost",size:"touch",icon:f?a.jsx(Kn,{className:"size-5 animate-spin"}):a.jsx(Ft,{className:"size-5 text-danger"}),onClick:f?void 0:n,"aria-label":"Move selected messages to Trash","aria-busy":f||void 0,className:"shrink-0"}),!f&&r&&a.jsx(V,{variant:"ghost",size:"touch",icon:a.jsx(ks,{className:"size-5"}),onClick:r,"aria-label":"Move selected messages",className:"shrink-0"}),!f&&o&&a.jsx(V,{variant:"ghost",size:"touch",icon:a.jsx(We,{className:"size-5"}),onClick:o,"aria-label":"Organize selected messages",className:"shrink-0"})]}),j&&a.jsx(aa,{triggerLabel:"More actions",items:R,className:"shrink-0",children:!f&&!d&&y})]}),!j&&p,j&&m&&a.jsx("div",{"data-selection-bar-row":"select-all",className:"px-row-inset pb-2 md:hidden",children:a.jsx(hn,{selectAll:m,selecting:j,className:"w-full"})}),w&&a.jsx("div",{className:"px-row-inset pb-2",children:a.jsx($r,{value:w.value,max:w.max,tone:w.tone})}),v&&a.jsx(qn,{"data-selection-notice":"",tone:v.tone,variant:"soft",role:"status","aria-live":"polite",className:"mx-row-inset mb-2",children:a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[v.text&&a.jsx("span",{children:v.text}),v.action&&a.jsx(V,{variant:"ghost",size:"md",onClick:v.action.onClick,className:"-my-1 min-h-11 shrink-0",children:v.action.label})]})})]})}const As=[{id:"all",label:"All",tone:"neutral"},{id:"personal",label:"Personal",tone:"accent"},{id:"uncategorized",label:"Unclassified",tone:"neutral"},{id:"transactional",label:"Transactional",tone:"positive"},{id:"newsletter",label:"Newsletter",tone:"neutral"},{id:"marketing",label:"Marketing",tone:"warning"},{id:"social",label:"Social",tone:"warning"},{id:"automated",label:"Automated",tone:"neutral"}],Oa={id:"unread",label:"Unread"},Wl={id:"flagged",label:"Starred"},za={id:"attachment",label:"Has attachment"};function Yl(e){if(!(e.length<=1))return e.map(t=>({id:t.id,label:t.label,count:t.count,active:t.active}))}function Zf(e=[]){return{categories:[...As],filters:Lr,sources:Yl(e)}}function em(){return{categories:[...As],filters:[Oa,Wl,za]}}function tm(){return{categories:[...As],filters:[Oa,za]}}function Jl(e,t){return e.endsWith(t)?e.length===t.length||e[e.length-t.length-1]===".":!1}function Xl(e,t){const s=e.length-t.length-2,n=e.lastIndexOf(".",s);return n===-1?e:e.slice(n+1)}function Zl(e,t,s){if(s.validHosts!==null){const r=s.validHosts;for(const o of r)if(Jl(t,o))return o}let n=0;if(t.startsWith("."))for(;n<t.length&&t[n]===".";)n+=1;return e.length===t.length-n?null:Xl(t,e)}const rs=/[\t\n\r]/g;let ps=!1;function gn(e){return e>=97&&e<=122||e>=48&&e<=57||e>127||e>=65&&e<=90||e===45||e===95}function bn(e,t,s){const n=s-t,r=e.charCodeAt(t)|32;if(n===2)return r===119&&(e.charCodeAt(t+1)|32)===115?1:0;if(n===3){const o=e.charCodeAt(t+1)|32,i=e.charCodeAt(t+2)|32;return r===119&&o===115&&i===115||r===102&&o===116&&i===112?1:0}else if(n===4){const o=e.charCodeAt(t+1)|32,i=e.charCodeAt(t+2)|32,c=e.charCodeAt(t+3)|32;return r===104&&o===116&&i===116&&c===112?1:r===102&&o===105&&i===108&&c===101?2:0}else if(n===5)return r===104&&(e.charCodeAt(t+1)|32)===116&&(e.charCodeAt(t+2)|32)===116&&(e.charCodeAt(t+3)|32)===112&&(e.charCodeAt(t+4)|32)===115?1:0;return 0}function dt(e,t,s=!1){let n=0,r=e.length,o=!1,i=!1;if(ps=!1,!t){if(e.startsWith("data:"))return null;for(;n<e.length&&e.charCodeAt(n)<=32;)n+=1;for(;r>n+1&&e.charCodeAt(r-1)<=32;)r-=1;if(e.charCodeAt(n)===47&&e.charCodeAt(n+1)===47)n+=2;else{const m=e.indexOf(":/",n);if(m!==-1){const h=bn(e,n,m);if(h===1)for(i=!0,n=m+2;e.charCodeAt(n)===47||e.charCodeAt(n)===92;)n+=1;else if(h===2){i=!0,n=m+1;let w=0;for(;(e.charCodeAt(n)===47||e.charCodeAt(n)===92)&&w<2;)n+=1,w+=1;if(w<2)return null}else{for(let w=n;w<m;w+=1){const v=e.charCodeAt(w)|32;if(!(v>=97&&v<=122||v>=48&&v<=57||v===46||v===45||v===43)){const j=e.charCodeAt(w);return j===9||j===10||j===13?dt(e.replace(rs,""),t,s):null}}if(e.charCodeAt(m+2)===47)n=m+3;else return null}}else if(e.charCodeAt(n)!==91){let h=-1;for(let w=n;w<r;w+=1){const v=e.charCodeAt(w);if(v===9||v===10||v===13)return dt(e.replace(rs,""),t,s);if(v===58){h=w;break}if(v===47||v===92||v===63||v===35)break}if(h!==-1){let w=!1;for(let v=h+1;v<r;v+=1){const j=e.charCodeAt(v);if(j===47||j===92||j===63||j===35)break;if(j===64){w=!0;break}}if(!w){let v=!0,j=h+1;for(;j<r;j+=1){const T=e.charCodeAt(j);if(T===47||T===92||T===63||T===35)break;if(T<48||T>57){v=!1;break}}if(j===h+1&&(v=!1),!v){const T=bn(e,n,h);if(T===0){let R=!1;for(let D=h+1;D<r;D+=1){const E=e.charCodeAt(D);if(E===47||E===92||E===63||E===35)break;if(E===58){R=!0;break}}if(!R)return null}else if(i=!0,n=h+1,T===2){let R=0;for(;(e.charCodeAt(n)===47||e.charCodeAt(n)===92)&&R<2;)n+=1,R+=1;if(R<2)return null}else for(;e.charCodeAt(n)===47||e.charCodeAt(n)===92;)n+=1}}}}}let u=-1,x=-1,g=-1,b=-1,p=!1,y=s,f=n-1,d=-1;if(s&&n<r){const m=e.charCodeAt(n);(!(gn(m)||m===46||m===95)||m===45)&&(y=!1)}for(let m=n;m<r;m+=1){const h=e.charCodeAt(m);if(h<64)if(h===47||h===35||h===63){r=m;break}else h===58?(b===-1&&(b=m),g=m):h===9||h===10||h===13?p=!0:s&&(h===46?((m-f>64||d===46||d===45)&&(y=!1),f=m):(h<48||h>57)&&(h!==45||d===46)&&(y=!1));else if(i&&h===92){r=m;break}else h===64?(u=m,b=-1):h===93?x=m:h>=65&&h<=90?o=!0:s&&!gn(h)&&(y=!1);s&&(d=h)}if(p)return dt(e.replace(rs,""),t,s);if(u!==-1&&u>=n&&u<r&&(n=u+1),e.charCodeAt(n)===91)return x!==-1?e.slice(n+1,x).toLowerCase():null;if(g!==-1&&g>n&&g<r&&b===g&&(r=g),n>=r)return null;s&&y&&u===-1&&g===-1&&x===-1&&e.charCodeAt(r-1)!==46&&r-n<=255&&r-f-1<=63&&d!==45&&(ps=!0)}for(;r>n+1&&e.charCodeAt(r-1)===46;)r-=1;const c=n!==0||r!==e.length?e.slice(n,r):e;return o?c.toLowerCase():c}function ec(e){if(e.length<7||e.length>15)return!1;let t=0;for(let s=0;s<e.length;s+=1){const n=e.charCodeAt(s);if(n===46)t+=1;else if(n<48||n>57)return!1}return t===3&&e.charCodeAt(0)!==46&&e.charCodeAt(e.length-1)!==46}function tc(e){if(e.length<3)return!1;let t=e.startsWith("[")?1:0,s=e.length;if(e[s-1]==="]"&&(s-=1),s-t>39)return!1;let n=!1;for(;t<s;t+=1){const r=e.charCodeAt(t);if(r===58)n=!0;else if(!(r>=48&&r<=57||r>=97&&r<=102||r>=65&&r<=70))return!1}return n}function sc(e){return tc(e)||ec(e)}function xn(e){return e>=97&&e<=122||e>=48&&e<=57||e>127}function yn(e){if(e.length>255||e.length===0||!xn(e.charCodeAt(0))&&e.charCodeAt(0)!==46&&e.charCodeAt(0)!==95)return!1;let t=-1,s=-1;const n=e.length;for(let r=0;r<n;r+=1){const o=e.charCodeAt(r);if(o===46){if(r-t>64||s===46||s===45)return!1;t=r}else if(!(xn(o)||o===45||o===95)||o===45&&s===46)return!1;s=o}return n-t-1<=63&&s!==45}function nc({allowIcannDomains:e=!0,allowPrivateDomains:t=!1,detectIp:s=!0,detectSpecialUse:n=!1,extractHostname:r=!0,mixedInputs:o=!0,validHosts:i=null,validateHostname:c=!0}){return{allowIcannDomains:e,allowPrivateDomains:t,detectIp:s,detectSpecialUse:n,extractHostname:r,mixedInputs:o,validHosts:i,validateHostname:c}}const ac=nc({});function rc(e){return ac}function oc(){return{domain:null,domainWithoutSuffix:null,hostname:null,isIcann:null,isIp:null,isPrivate:null,isSpecialUse:null,publicSuffix:null,subdomain:null}}function ic(e){e.domain=null,e.domainWithoutSuffix=null,e.hostname=null,e.isIcann=null,e.isIp=null,e.isPrivate=null,e.isSpecialUse=null,e.publicSuffix=null,e.subdomain=null}function lc(e,t,s,n,r){const o=rc();if(typeof e!="string")return r;let i=!1;return o.extractHostname?o.mixedInputs?(i=yn(e),r.hostname=dt(e,i,o.validateHostname)):r.hostname=dt(e,!1,o.validateHostname):r.hostname=e,o.detectIp&&r.hostname!==null&&(r.isIp=sc(r.hostname),r.isIp)?r:o.validateHostname&&o.extractHostname&&r.hostname!==null&&!(i&&r.hostname===e)&&!ps&&!yn(r.hostname)?(r.hostname=null,r):(r.hostname===null||(s(r.hostname,o,r),r.publicSuffix===null)||(r.domain=Zl(r.publicSuffix,r.hostname,o)),r)}const vn=oc();function cc(e,t){return ic(vn),lc(e,3,Pr,t,vn).domain}const qt=e=>{const t=new Set,s=[];for(const n of e){const r=n.trim();if(r==="")continue;const o=r.toLowerCase();t.has(o)||(t.add(o),s.push(r))}return s},dc=e=>{const t=e.lastIndexOf("@");return t>=0?e.slice(t+1):e},_a=e=>cc(dc(e.trim())),uc=e=>{const t=qt(e);if(t.length<2)return null;let s=null;for(const n of t){const r=_a(n);if(r===null)return null;if(s===null)s=r;else if(s!==r)return null}return s},Qt=e=>{const t=uc(e);return t!==null?[{field:"FromDomain",value:t}]:qt(e).map(s=>({field:"From",value:s}))},fc=e=>{const t=new Map;for(const r of e){const o=r.normalizedEmail.trim().toLowerCase();if(o==="")continue;const i=t.get(o);i?i.count+=1:t.set(o,{sender:r,count:1})}let s,n=0;for(const{sender:r,count:o}of t.values())o<=n||(s=r,n=o);return s},Ua=e=>e.displayName?.trim()||e.normalizedEmail,mc=/^\s*(?:(?:re|aw|fwd?|vs|sv|antw|res|enc|tr)\s*(?:\[\d+\])?\s*:|\[[^\]]{1,32}\])\s*/i,pc=e=>{let t=e.replace(/\s+/g," ").trim();for(;;){const s=t.replace(mc,"");if(s===t)return t.trim();t=s}},hc=new Set(["a","an","and","are","as","at","be","by","for","from","has","have","in","is","it","me","my","new","of","on","or","our","the","this","to","was","we","with","you","your"]),gc=3,os=e=>e.split(" ").filter(t=>t!==""),kn=e=>e.length===0||e.join(" ").length<gc?!1:e.some(t=>!hc.has(t.toLowerCase())),bc=(e,t)=>e.findIndex((s,n)=>t.every((r,o)=>e[n+o]?.toLowerCase()===r.toLowerCase())),xc=e=>{const t=e.map(pc).filter(o=>o!=="");if(t.length===0)return;const[s,...n]=t;if(n.length===0)return kn(os(s))?s:void 0;const r=os(s);for(let o=r.length;o>0;o-=1)for(let i=0;i+o<=r.length;i+=1){const c=r.slice(i,i+o);if(kn(c)&&n.every(u=>bc(os(u),c)>=0))return c.join(" ")}},yc=(e,t)=>{const s=Qt(e);if(qt(e).length===1||s.length===1&&s[0].field==="FromDomain")return s;const n=xc(t);return n!==void 0?[{field:"Subject",value:n}]:s},vc=({match:e,sender:t,folder:s})=>{const n=e??t;return n?s?`${n} → ${s}`:e?`Mail matching ${e}`:`Mail from ${n}`:s?`Mail to ${s}`:""},kc=e=>e.clauses.length>0,jc=e=>({scopedOutFolder:e.scopedOut?.label,droppedFacets:e.droppedFacets.map(t=>t.label),droppedSemantic:e.droppedSemantic}),wc=({orderedIds:e,isDesktop:t,initialFocusedId:s,initialSelectedIds:n,onExitSelection:r})=>{const[o,i]=l.useState(s),[c,u]=l.useState(),x=l.useCallback(S=>{u(M=>M===S?M:void 0),i(S)},[]),g=Sl({initialSelectedIds:n}),{selectedCount:b,toggle:p,clearSelection:y,selectRange:f,setAnchor:d,selectAll:m}=g,h=yl(b,t),w=l.useRef(null),v=l.useRef(!1),j=l.useCallback(()=>{r?.(),y()},[y,r]),T=l.useMemo(()=>o?e.indexOf(o):-1,[e,o]),R=l.useCallback(S=>{if(S<0||S>=e.length)return;const M=e[S];if(h){p(M);return}w.current=M,v.current=!1,u(M),i(M)},[e,h,p]),D=l.useCallback(()=>{e.length!==0&&R(T<0?0:Math.min(T+1,e.length-1))},[e.length,T,R]),E=l.useCallback(()=>{e.length!==0&&R(T<=0?0:T-1)},[e.length,T,R]),F=l.useCallback(()=>R(0),[R]),P=l.useCallback(()=>R(e.length-1),[R,e.length]),_=l.useCallback(()=>{o&&p(o)},[o,p]),K=l.useCallback((S,M)=>{const C=xl(M);return C==="range"?(f(e,S,o),!0):C==="toggle"?(p(S),!0):(j(),d(S),!1)},[e,o,f,p,j,d]),B=l.useCallback(S=>{const M=wl(e,o,S);M!==void 0&&(f(e,M),w.current=M,v.current=!1,u(void 0),i(M))},[e,o,f]),k=l.useCallback(()=>B(-1),[B]),I=l.useCallback(()=>B(1),[B]),$=l.useCallback(()=>{e.length>0&&m(e)},[e,m]);return{focusedMessageId:o,setFocusedMessageId:x,keyboardFocusedMessageId:c,focusIndex:T,pendingDomFocusRef:w,cursorMovedByPointerRef:v,selection:g,isMultiSelectMode:h,exitSelection:j,moveFocusToIndex:R,focusNext:D,focusPrevious:E,focusFirst:F,focusLast:P,toggleFocusedSelection:_,extendRangeUp:k,extendRangeDown:I,selectAllLoaded:$,handleRowSelect:K}};function Sc(e,t){if(e===void 0)return{shouldBlockFn:()=>!0,withResolver:!1};if("shouldBlockFn"in e)return e;if(typeof e=="function")return{shouldBlockFn:async()=>await e(),enableBeforeUnload:!0,withResolver:!1};const s=!!(e.condition??!0),n=e.blockerFn;return{shouldBlockFn:async()=>s&&n!==void 0?await n():s,enableBeforeUnload:s,withResolver:n===void 0}}function Cc(e,t){const{shouldBlockFn:s,enableBeforeUnload:n=!0,disabled:r=!1,withResolver:o=!1}=Sc(e),i=Dr(),{history:c}=i,[u,x]=l.useState({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0});return l.useEffect(()=>{const g=async b=>{function p(h){const w=i.parseLocation(h),v=i.getMatchedRoutes(w.pathname);return v.foundRoute===void 0?{routeId:"__notFound__",fullPath:w.pathname,pathname:w.pathname,params:v.routeParams,search:i.options.parseSearch(h.search)}:{routeId:v.foundRoute.id,fullPath:v.foundRoute.fullPath,pathname:w.pathname,params:v.routeParams,search:i.options.parseSearch(h.search)}}const y=p(b.currentLocation),f=p(b.nextLocation);if(y.routeId==="__notFound__"&&f.routeId!=="__notFound__")return!1;const d=await s({action:b.action,current:y,next:f});if(!o)return d;if(!d)return!1;const m=await new Promise(h=>{x({status:"blocked",current:y,next:f,action:b.action,proceed:()=>h(!1),reset:()=>h(!0)})});return x({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0}),m};return r?void 0:c.block({blockerFn:g,enableBeforeUnload:n})},[s,n,r,o,c,i]),u}const $s=e=>{const{data:t,isLoading:s}=Z({...gt(),staleTime:1/0}),n=l.useMemo(()=>(t?.accounts??[]).map(c=>c.accountId),[t?.accounts]),r=Cs({queries:n.map(c=>({...bt({path:{accountId:c}}),staleTime:1/0,enabled:!!e}))}),o=s||r.some(c=>c.isLoading);return{accountId:l.useMemo(()=>{if(e){for(let c=0;c<n.length;c++)if((r[c].data?.items??[]).some(g=>g.mailboxId===e))return n[c]}},[e,n,r]),isLoading:o}},Nc=({surface:e})=>{const t=Fr(),s=Or(),{data:n}=Z({...Ot({path:{messageId:e.sourceMessageId}})}),{data:r}=Z({...gt(),staleTime:1/0}),{accountId:o}=$s(n?.message.mailboxId),i=r?.accounts?.find(c=>c.accountId===o);return a.jsx("div",{className:"border-b border-line bg-canvas",children:a.jsx(ai,{layout:"flow",mode:e.mode,account:i,sourceMessage:n,outboxMessageId:e.outboxMessageId,onDraftCreated:t,onClose:s})})},Ba=({message:e,icon:t})=>a.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:[t&&a.jsx("div",{className:"mb-4 text-fg-muted",children:t}),a.jsx("p",{className:"text-fg-muted",children:e})]}),Ka=100,hs=async e=>e.then(t=>({ok:!0,value:t}),t=>({ok:!1,error:t})),Tc=(e,t=Ka)=>{if(e.length===0)return[];const s=[];for(let n=0;n<e.length;n+=t)s.push(e.slice(n,n+t));return s},Ic=(e,t=Ka)=>{const s=new Map;for(const n of e){const r=s.get(n.accountId);if(r){r.push(n.id);continue}s.set(n.accountId,[n.id])}return[...s.values()].flatMap(n=>Tc(n,t))},qa=async(e,t,s,n)=>{const r=Ic(e),o=e.length;let i=0;const c=[];for(let u=0;u<r.length;u++){if(n())return c.push(...r.slice(u).flat()),{done:i,failedIds:c,cancelled:!0};const x=r[u],g=await hs(t(x));if(!g.ok)return c.push(...r.slice(u).flat()),s({done:i,total:o}),{done:i,failedIds:c,cancelled:!1,error:g.error};i+=x.length,s({done:i,total:o})}return{done:i,failedIds:c,cancelled:!1}},ht=async(e,t)=>{await qa(e.map(s=>({id:s,accountId:void 0})),async s=>(await t(s),{successCount:s.length,failureCount:0}),()=>{},()=>!1)},Ec=async(e,t,s,n,r)=>{let o=0;const i=[];let c;do{if(r())return{done:o,failedIds:i,cancelled:!0};const u=await hs(e(c));if(!u.ok)return{done:o,failedIds:i,cancelled:!1,error:u.error};const x=u.value;if(x.ids.length>0){const g=await hs(s(x.ids));if(!g.ok)return{done:o,failedIds:i,cancelled:!1,error:g.error};o+=x.ids.length,n({done:o,total:t})}c=x.continuationToken}while(c);return{done:o,failedIds:i,cancelled:!1}},Rc=e=>({done:e.done,total:Math.max(e.total,e.done)}),Qa=e=>typeof e=="object"&&e!==null&&Array.isArray(e.pages),Ha=e=>typeof e=="object"&&e!==null&&Array.isArray(e.items),Ga=(e,t)=>e===void 0?e:Qa(e)?{...e,pages:e.pages.map(s=>({...s,items:t(s.items)}))}:Ha(e)?{...e,items:t(e.items)}:e,ke=e=>{const t=[];for(const s of new Set(e))t.push(Qn({path:{mailboxId:s}})),t.push(Hn({path:{mailboxId:s}}));return t.push(Gn()),t},yt=(e,t)=>Promise.all(t.map(s=>e.cancelQueries({queryKey:s}))),vt=(e,t)=>t.flatMap(s=>e.getQueriesData({queryKey:s})).filter(s=>s[1]!==void 0).map(([s,n])=>({queryKey:s,data:n})),kt=(e,t,s)=>{const n=r=>Ga(r,s);for(const r of t)e.setQueriesData({queryKey:r},n)},jt=(e,t)=>{for(const s of t)e.setQueryData(s.queryKey,s.data)},je=(e,t)=>{for(const s of t)e.invalidateQueries({queryKey:s})},Mc=3e3,Ac=(e,t,s)=>{if(e.length===0)return()=>{};const n=setTimeout(()=>s(e),t);return()=>clearTimeout(n)},Ls=(e,t,s)=>{const n=new Map(t.map(o=>[o.messageId,o.mailboxId])),r=new Set;for(const o of e)r.add(n.get(o)??s);return[...r]},Lt=(e,t,s)=>e.map(n=>t.has(n.messageId)?{...n,isRead:s}:n),$c=(e,t,s,n)=>e.filter(r=>!r.isRead&&t.has(r.threadMessageId)&&!s.has(r.messageId)&&!n.has(r.messageId)).map(r=>r.messageId),Lc=({messages:e,expandedIds:t,threadId:s,mailboxId:n,accountId:r})=>{const o=ae(),{pushError:i}=be(),c=l.useRef(new Set),u=l.useRef(new Set),{mutate:x}=pe({...zt(),meta:zr,onMutate:async p=>{const y=new Set(p.body.messageIds??[]),f=p.body.isRead??!0,d=Me({path:{threadId:s}}),m=ke(Ls(y,e,n));await Promise.all([o.cancelQueries({queryKey:d}),yt(o,m)]);const h=o.getQueriesData({queryKey:d}).filter(v=>v[1]!==void 0).map(([v,j])=>({queryKey:v,data:j})),w=vt(o,m);return o.setQueriesData({queryKey:d},v=>v&&{...v,items:Lt(v.items,y,f)}),kt(o,m,v=>Lt(v,y,f)),{threadMessagesPrefix:d,listPrefixes:m,previousThreadMessages:h,previousThreadsList:w}},onSuccess:(p,y)=>{const f=y.body.messageIds??[];for(const d of f)c.current.add(d),u.current.delete(d)},onError:(p,y,f)=>{const d=y.body.messageIds??[];for(const h of d)u.current.delete(h);if(f){for(const h of f.previousThreadMessages)o.setQueryData(h.queryKey,h.data);jt(o,f.previousThreadsList)}const m=y.body.isRead??!0;i({title:m?"Couldn't mark as read":"Couldn't mark as unread",detail:Re(p),error:p})},onSettled:(p,y,f,d)=>{d&&(o.invalidateQueries({queryKey:d.threadMessagesPrefix}),je(o,d.listPrefixes),r&&o.invalidateQueries({queryKey:Je({path:{accountId:r}})}))}}),g=l.useCallback(p=>{const y=p.filter(f=>!c.current.has(f)&&!u.current.has(f));if(y.length!==0){for(const f of y)u.current.add(f);x({body:{messageIds:y,isRead:!0}})}},[x]),b=l.useMemo(()=>$c(e,t,c.current,u.current),[e,t]);l.useEffect(()=>Ac(b,Mc,g),[b,g]),l.useEffect(()=>{c.current.clear(),u.current.clear()},[s])},sm=e=>{const{mailboxId:t,accountId:s,messages:n}=e,r=ae(),{pushError:o}=be(),{mutateAsync:i,isPending:c}=pe({...zt(),onError:(x,g)=>{const b=g.body.isRead??!0;o({title:b?"Couldn't mark as read":"Couldn't mark as unread",detail:Re(x),error:x})},onSettled:(x,g,b)=>{je(r,ke(Ls(b.body.messageIds??[],n??[],t))),s&&r.invalidateQueries({queryKey:Je({path:{accountId:s}})})}});return{toggleReadFor:l.useCallback((x,g)=>{x.length!==0&&ht(x,b=>i({body:{messageIds:b,isRead:g}}))},[i]),isPending:c}},Pc=60,Dc=1.5,Fc=(e,t,s)=>{const n=Math.abs(e),r=Math.abs(t);return n<s?{direction:null}:n<r*Dc?{direction:null}:{direction:e<0?"left":"right"}},Oc=({onSwipeLeft:e,onSwipeRight:t,thresholdPx:s=Pc})=>{const n=l.useRef(null),r=l.useCallback(u=>{if(u.pointerType==="mouse"){n.current=null;return}n.current={x:u.clientX,y:u.clientY}},[]),o=l.useCallback(()=>{},[]),i=l.useCallback(u=>{const x=n.current;if(n.current=null,!x)return;const{direction:g}=Fc(u.clientX-x.x,u.clientY-x.y,s);g==="left"&&e?.(),g==="right"&&t?.()},[e,t,s]),c=l.useCallback(()=>{n.current=null},[]);return{handlers:{onPointerDown:r,onPointerMove:o,onPointerUp:i,onPointerCancel:c}}},zc=(e,t,s)=>t?.find(n=>n.messageId===e)?.mailboxId??s,jn=(e,t,s)=>e.map(n=>n.messageId===t?{...n,hasStars:s}:n),Va=({threadId:e,mailboxId:t,messages:s})=>{const n=ae(),{pushError:r}=be(),{mutate:o,isPending:i,variables:c}=pe({..._r(),onMutate:async x=>{const g=x.path.messageId,b=x.body.isStarred??!1,p=Me({path:{threadId:e}}),y=ke([zc(g,s,t)]);await Promise.all([n.cancelQueries({queryKey:p}),yt(n,y)]);const f=n.getQueriesData({queryKey:p}).filter(m=>m[1]!==void 0).map(([m,h])=>({queryKey:m,data:h})),d=vt(n,y);return n.setQueriesData({queryKey:p},m=>Ga(m,h=>jn(h,g,b))),kt(n,y,m=>jn(m,g,b)),{threadMessagesPrefix:p,listPrefixes:y,previousThreadMessages:f,previousThreadsList:d}},onError:(x,g,b)=>{if(b){for(const y of b.previousThreadMessages)n.setQueryData(y.queryKey,y.data);jt(n,b.previousThreadsList)}const p=g.body.isStarred??!1;r({title:p?"Couldn't star message":"Couldn't unstar message",detail:Re(x),error:x})},onSettled:(x,g,b,p)=>{p&&(n.invalidateQueries({queryKey:p.threadMessagesPrefix}),je(n,p.listPrefixes))}});return{toggleStar:(x,g)=>{o({path:{messageId:x},body:{isStarred:!g}})},isPending:i,pendingMessageId:i?c?.path.messageId:void 0}};function wn({authenticity:e,onOpenIntelligence:t}){return e.dkimMismatch?a.jsxs("div",{className:"flex items-start gap-2 rounded-none border-b border-danger/20 bg-danger-soft px-5 py-2.5 text-sm",children:[a.jsx(Ze,{className:"mt-0.5 size-4 shrink-0 text-danger"}),a.jsxs("p",{className:"flex-1 leading-snug text-fg",children:["This message claims to be from"," ",a.jsx("span",{className:"font-semibold",children:e.fromDomain})," but was sent",e.dkimDomain?` via ${e.dkimDomain}`:" from a different domain","."," ",t&&a.jsx("button",{type:"button",onClick:t,className:"font-medium text-danger hover:underline",children:"Why?"})]})]}):null}function Wa(e){return e===void 0?"uncategorized":e}const _c={inbox:"Inbox",junk:"Junk"},Ps=e=>e.destinationMailboxId!==void 0,Uc=(e,t)=>{if(Ps(e))return`Moved from ${t??"another folder"} by Remit`;const s=e.fromPlacement??"";return`Moved from ${_c[s]??"another folder"} by Remit`},Bc=(e,t)=>{if(e===Gs.MoveToInbox)return t.inboxMailboxId;if(e===Gs.MoveToJunk)return t.junkMailboxId},Kc=(e,t,s)=>{if(!e||!t)return!1;const n=Ps(e)?e.destinationMailboxId:Bc(e.action,s);return n!==void 0&&n===t},qc="Reported as spam",Qc=(e,t)=>{if(e){if(Ps(e))return e.fromMailboxId;if(e.fromPlacement==="inbox")return t.inboxMailboxId;if(e.fromPlacement==="junk")return t.junkMailboxId}},wt=(e,t)=>{const{data:s,isLoading:n}=Z({...gt(),staleTime:1/0,enabled:!!e});return{mailboxId:l.useMemo(()=>e?s?.accounts.find(i=>i.accountId===e)?.folderAppointments.find(i=>i.role===t)?.mailboxId:void 0,[s,e,t]),isLoading:n}},nm=e=>{const{mailboxId:t,isLoading:s}=wt(e,"Archive");return{archiveMailboxId:t,isLoading:s}},am=e=>{const{mailboxId:t,isLoading:s}=wt(e,"Drafts");return{draftsMailboxId:t,isLoading:s}},Hc=e=>{const{mailboxId:t,isLoading:s}=wt(e,"Inbox");return{inboxMailboxId:t,isLoading:s}},Ya=e=>{const{mailboxId:t,isLoading:s}=wt(e,"Junk");return{junkMailboxId:t,isLoading:s}},rm=e=>{const{mailboxId:t,isLoading:s}=wt(e,"Trash");return{trashMailboxId:t,isLoading:s}},Gc=()=>{const{data:e,isError:t}=Z({...gt(),staleTime:1/0});return{trashByAccount:l.useMemo(()=>{const n=new Map;for(const r of e?.accounts??[]){const o=r.folderAppointments.find(i=>i.role==="Trash");n.set(r.accountId,{mailboxId:o?.mailboxId,source:o?.source??"None",staleFolderPath:o?.staleAppointmentPath})}return n},[e]),hasAppointments:e!==void 0,isError:t}},Ja=e=>{const{data:t}=Z({...gt(),staleTime:1/0,enabled:!!e});return l.useMemo(()=>t?.accounts.find(s=>s.accountId===e)?.folderAppointments??[],[t,e])},Sn=(e,t)=>e.filter(s=>!t.has(s.messageId)),Ht=({mailboxId:e,threadId:t,accountId:s,onAfterOptimisticRemove:n})=>{const r=ae(),{pushError:o}=be(),{mutateAsync:i,isPending:c,isError:u}=pe({...Ur(),onMutate:async g=>{const b=new Set(g.body.messageIds??[]),p=t?Me({path:{threadId:t}}):[],y=ke([e,g.body.destinationMailboxId]);await Promise.all([...t?[r.cancelQueries({queryKey:p})]:[],yt(r,y)]);const f=t?r.getQueriesData({queryKey:p}).filter(m=>m[1]!==void 0).map(([m,h])=>({queryKey:m,data:h})):[],d=vt(r,y);return t&&r.setQueriesData({queryKey:p},m=>m&&{...m,items:Sn(m.items,b)}),kt(r,y,m=>Sn(m,b)),n?.(Array.from(b)),{threadMessagesPrefix:p,listPrefixes:y,previousThreadMessages:f,previousThreadsList:d}},onError:(g,b,p)=>{if(p){for(const f of p.previousThreadMessages)r.setQueryData(f.queryKey,f.data);jt(r,p.previousThreadsList)}const y=b.body.messageIds?.length??0;o({title:y>1?`Couldn't move ${y} messages`:"Couldn't move this message",detail:Re(g),error:g})},onSettled:(g,b,p,y)=>{y&&(t&&r.invalidateQueries({queryKey:y.threadMessagesPrefix}),je(r,y.listPrefixes),s&&r.invalidateQueries({queryKey:Je({path:{accountId:s}})}))}});return{moveMessages:l.useCallback((g,b)=>{g.length!==0&&ht(g,p=>i({body:{messageIds:p,destinationMailboxId:b}}))},[i]),isPending:c,isError:u}},Vc="This message could not be processed. Please try again. If it keeps failing, report it.",Wc=(e,t)=>e.replace(`Message ${t}'s`,"This message's"),Cn=e=>{if(e.failureCount===0)return;const t=e.failures?.[0],s=t?.reason??Vc,n=t?Wc(s,t.messageId):s;throw new qr(n,422)};function Xa({mailboxId:e,threadId:t,accountId:s,onAfterOptimisticRemove:n}){const r=ae(),{pushError:o}=be(),i=ke([e]),c=t?Me({path:{threadId:t}}):[],u=()=>{t&&r.invalidateQueries({queryKey:c}),je(r,i),s&&r.invalidateQueries({queryKey:Je({path:{accountId:s}})})},x=()=>(d,m)=>{u(),n?.(m.body.messageIds)},g=d=>(m,h)=>{o({title:d(h.body.messageIds.length),detail:Re(m),error:m})},b=pe({mutationFn:async d=>{const{data:m}=await Br({...d,throwOnError:!0});return Cn(m),m},meta:{softError:!0},onSuccess:x(),onError:g(d=>d>1?`Couldn't report ${d} messages as spam`:"Couldn't report this message as spam")}),p=pe({mutationFn:async d=>{const{data:m}=await Kr({...d,throwOnError:!0});return Cn(m),m},meta:{softError:!0},onSuccess:x(),onError:g(d=>d>1?`Couldn't undo the spam report for ${d} messages`:"Couldn't undo the spam report")}),y=l.useCallback(d=>{d.length!==0&&ht(d,m=>b.mutateAsync({body:{messageIds:m}}))},[b.mutateAsync]),f=l.useCallback(d=>{d.length!==0&&ht(d,m=>p.mutateAsync({body:{messageIds:m}}))},[p.mutateAsync]);return{reportSpam:y,notSpam:f,isReporting:b.isPending,isRestoring:p.isPending}}const Yc=({accountId:e,messageId:t,threadId:s,mailboxId:n,autoMoved:r,spamReport:o})=>{const{inboxMailboxId:i}=Hc(e),{junkMailboxId:c}=Ya(e),{moveMessages:u,isPending:x}=Ht({mailboxId:n,threadId:s,accountId:e}),{notSpam:g,isRestoring:b}=Xa({mailboxId:n,threadId:s,accountId:e}),{data:p}=Z({...bt({path:{accountId:e??""}}),staleTime:1/0,enabled:!!e&&r?.fromMailboxId!==void 0}),y={inboxMailboxId:i,junkMailboxId:c},f=Qc(r,y),d=l.useCallback(()=>{f&&u([t],f)},[u,t,f]),m=l.useCallback(()=>{g([t])},[g,t]);if(o)return{show:!0,label:qc,onUndo:m,isUndoing:b};if(!Kc(r,n,y)||!r)return{show:!1,label:"",isUndoing:!1};const w=r.fromMailboxId?p?.items.filter(v=>v.mailboxId===r.fromMailboxId).map(v=>Qr(v))[0]:void 0;return{show:!0,label:Uc(r,w),onUndo:f?d:void 0,isUndoing:x,...r.filterId?{filtersHref:"/settings/filters"}:{}}};function Jc({accountId:e,messageId:t,threadId:s,mailboxId:n,autoMoved:r,spamReport:o}){const i=Yc({accountId:e,messageId:t,threadId:s,mailboxId:n,autoMoved:r,spamReport:o});return i.show?a.jsx(Dl,{label:i.label,onUndo:i.onUndo,undoLabel:i.isUndoing?"Undoing…":"Undo",filtersHref:i.filtersHref}):null}const Nn=(e,t)=>e.filter(s=>!t.has(s.messageId)),om=e=>e.filter(t=>t.isDeleted!==!0),Ds=({mailboxId:e,threadId:t,accountId:s,messages:n,onAfterOptimisticRemove:r})=>{const o=ae(),{pushError:i}=be(),{requestAppointment:c}=Vn(),u=l.useRef([]),x=l.useRef(async()=>{}),{mutateAsync:g,isPending:b}=pe({...Gr(),onMutate:async f=>{const d=new Set(f.body.messageIds??[]),m=t?Me({path:{threadId:t}}):[],h=ke(Ls(d,n??[],e));await Promise.all([o.cancelQueries({queryKey:m}),yt(o,h)]);const w=t?o.getQueriesData({queryKey:m}).filter(j=>j[1]!==void 0).map(([j,T])=>({queryKey:j,data:T})):[],v=vt(o,h);return t&&o.setQueriesData({queryKey:m},j=>j&&{...j,items:Nn(j.items,d)}),kt(o,h,j=>Nn(j,d)),r?.(Array.from(d)),{threadMessagesPrefix:m,listPrefixes:h,previousThreadMessages:w,previousThreadsList:v}},onError:(f,d,m)=>{if(m){for(const v of m.previousThreadMessages)o.setQueryData(v.queryKey,v.data);jt(o,m.previousThreadsList)}const h=Hr(f);if(h){const v=u.current;c({accountId:h.accountId,role:h.role,reason:h.reason,action:{kind:"delete",count:v.length},onAppointed:()=>x.current(v)});return}const w=d.body.messageIds?.length??0;i({title:w>1?`Couldn't delete ${w} messages`:"Couldn't delete this message",detail:Re(f),error:f})},onSettled:(f,d,m,h)=>{h&&(t&&o.invalidateQueries({queryKey:h.threadMessagesPrefix}),je(o,h.listPrefixes),s&&o.invalidateQueries({queryKey:Je({path:{accountId:s}})}))}}),p=l.useCallback(f=>ht(f,d=>g({body:{messageIds:d}})),[g]);return l.useEffect(()=>{x.current=p},[p]),{deleteMessages:l.useCallback(f=>{f.length!==0&&(u.current=f,p(f))},[p]),isPending:b}},Za="inline-flex items-center justify-center transition-colors",Xc=U(Za,"min-h-11 min-w-11 rounded hover:bg-surface-raised"),Zc=U(Za,"min-h-11 gap-1.5 px-3 rounded text-sm font-medium hover:bg-surface-raised"),Fs=({accountId:e,currentMailboxId:t,onMove:s,disabled:n=!1,disabledHint:r,variant:o="icon-only",label:i,defaultOpen:c=!1})=>{const[u,x]=l.useState(c),[g,b]=l.useState(),p=js(),y=l.useRef(null),f=l.useRef(null),d=l.useRef(null),m=i??"Move to folder",h=l.useId(),{t:w}=Vr("mail",{useSuspense:!1}),v=Wn(),{data:j,isLoading:T,isError:R,error:D,refetch:E}=Z({...bt({path:{accountId:e}}),staleTime:1/0,enabled:u}),F=Ja(e),{createFolderIn:P}=Yn(e),_=l.useMemo(()=>Jn({mailboxes:j?.items??[],folderAppointments:F,currentMailboxId:t,translator:v}),[j?.items,F,t,v]),K=Xn(j?.items??[]),B=_.find(O=>O.id===g),k=l.useCallback(()=>{x(!1),b(void 0);const O=document.activeElement;O&&f.current?.contains(O)&&d.current?.focus()},[]),I=l.useCallback(()=>{B&&(k(),s(B.id))},[B,k,s]);l.useEffect(()=>{if(!u||!p)return;const O=G=>{const le=G.target;y.current?.contains(le)||f.current?.contains(le)||k()},q=G=>{G.key==="Escape"&&(G.stopPropagation(),k())};return document.addEventListener("mousedown",O),document.addEventListener("keydown",q),()=>{document.removeEventListener("mousedown",O),document.removeEventListener("keydown",q)}},[u,p,k]);const $=()=>y.current?.getBoundingClientRect()??null,S=n||!!r,M=a.jsxs("button",{type:"button",ref:d,onClick:O=>{O.stopPropagation(),!S&&x(q=>!q)},"aria-label":m,"aria-haspopup":p?"tree":"dialog","aria-expanded":u,"aria-controls":u?h:void 0,title:r,className:o==="icon-only"?Xc:Zc,children:[a.jsx(ks,{className:o==="icon-only"?"size-5":"size-4"}),o==="compact"&&a.jsx("span",{className:"hidden sm:inline",children:"Move"})]}),C=T?a.jsx("div",{className:"px-3 py-5 text-sm text-fg-muted",children:"Loading folders…"}):R?a.jsx("div",{className:"p-3",children:a.jsx(Oe,{variant:"inline",title:"Couldn't load folders",error:D,onRetry:()=>E()})}):a.jsx(Wr,{folders:_,selectedId:g,delimiter:K,onSelect:b,onCreateFolder:P,onCancel:k,autoFocusFilter:p,labels:{filterPlaceholder:w("move_picker_filter_placeholder",{defaultValue:"Filter folders…"}),filterAriaLabel:w("move_picker_filter_label",{defaultValue:"Filter folders"})}}),z=B&&a.jsx("div",{className:"shrink-0 border-t border-line p-2",children:a.jsx(V,{variant:"primary",onClick:I,className:"h-11 w-full font-semibold",children:`Move to ${B.label}`})});return p?a.jsxs("div",{ref:y,className:"relative inline-block",children:[M,a.jsx(Go,{open:u,align:"end",panelRef:f,getAnchor:$,children:a.jsxs("div",{id:h,ref:f,className:U("w-72 max-h-96 flex flex-col","bg-surface border border-line rounded-md shadow-lg"),children:[C,z]})})]}):a.jsxs(a.Fragment,{children:[M,a.jsx(Qe.Root,{open:u,onOpenChange:O=>O?x(!0):k(),children:a.jsxs(Qe.Portal,{children:[a.jsx(Qe.Overlay,{className:"fixed inset-0 z-40 bg-black/40"}),a.jsxs(Qe.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:{maxHeight:"85dvh"},id:h,children:[a.jsx(Qe.Handle,{className:"mx-auto mt-2 mb-1 h-1.5 w-12 rounded-full bg-fg-subtle/30"}),a.jsx(Qe.Title,{className:"px-4 py-2 text-base font-semibold border-b border-line",children:"Move to folder"}),a.jsx("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:C}),z]})]})})]})},ed=({messageId:e,threadId:t,mailboxId:s,isRead:n,accountId:r,fromAddressId:o,isTrusted:i=!1,showRaw:c=!1,onToggleRaw:u})=>{const x=ae(),g=$o(),{pushError:b}=be(),p=Lo()?.messageId,{mutate:y,isPending:f}=pe({...zt(),onMutate:async I=>{const $=I.body.isRead??!0,S=new Set(I.body.messageIds??[]),M=Me({path:{threadId:t}}),C=ke([s]);await Promise.all([x.cancelQueries({queryKey:M}),yt(x,C)]);const z=x.getQueriesData({queryKey:M}).filter(q=>q[1]!==void 0).map(([q,G])=>({queryKey:q,data:G})),O=vt(x,C);return x.setQueriesData({queryKey:M},q=>q&&{...q,items:Lt(q.items,S,$)}),kt(x,C,q=>Lt(q,S,$)),{threadMessagesPrefix:M,listPrefixes:C,previousThreadMessages:z,previousThreadsList:O}},onError:(I,$,S)=>{if(S){for(const C of S.previousThreadMessages)x.setQueryData(C.queryKey,C.data);jt(x,S.previousThreadsList)}const M=$.body.isRead??!0;b({title:M?"Couldn't mark as read":"Couldn't mark as unread",detail:Re(I),error:I})},onSettled:(I,$,S,M)=>{M&&(x.invalidateQueries({queryKey:M.threadMessagesPrefix}),je(x,M.listPrefixes))}}),d=l.useCallback(I=>{p&&I.includes(p)&&g()},[p,g]),{deleteMessages:m,isPending:h}=Ds({mailboxId:s,threadId:t,onAfterOptimisticRemove:d}),{moveMessages:w,isPending:v}=Ht({mailboxId:s,threadId:t,accountId:r,onAfterOptimisticRemove:d}),{toggleTrusted:j,isPending:T,error:R,reset:D}=ra({messageId:e}),E=()=>{y({body:{messageIds:[e],isRead:!1}})},F=()=>{m([e])},P=()=>{o&&j(o,i)},_=f||h||v||T,K=_||!o,B=l.useCallback(I=>{w([e],I)},[w,e]),k=o?void 0:"Sender has no parseable address";return a.jsxs("div",{className:"flex flex-col items-end gap-1",children:[a.jsxs("div",{className:"flex items-center gap-1",children:[r&&a.jsx(Fs,{accountId:r,currentMailboxId:s,onMove:B,disabled:_,label:"Move this message"}),a.jsxs(Po,{trigger:a.jsx(Vo,{className:"size-4"}),children:[a.jsxs(Tt,{onClick:P,disabled:K,children:[i?a.jsx(Bt,{className:"size-4 text-positive"}):a.jsx(Dt,{className:"size-4 opacity-0"}),a.jsx("span",{title:k,children:"Trusted sender"})]}),n&&a.jsxs(Tt,{onClick:E,disabled:_,children:[a.jsx(Es,{className:"size-4"}),"Mark as unread"]}),u&&a.jsxs(Tt,{onClick:u,children:[a.jsx(ja,{className:"size-4"}),c?"Show formatted":"Show raw email"]}),a.jsx(Do,{}),a.jsxs(Tt,{onClick:F,disabled:_,destructive:!0,children:[a.jsx(Ft,{className:"size-4"}),"Delete"]})]})]}),R&&a.jsx("div",{className:"w-64",children:a.jsx(Oe,{variant:"inline",title:"Couldn't update trust",error:R,onRetry:()=>{D(),P()}})})]})},td=e=>e==="link-expired"||e==="not-ready";class gs extends Error{reason;status;constructor(t,s,n){super(s),this.name="AttachmentFetchError",this.reason=t,this.status=n}}const sd="x-remit-403-reason",nd="expired",ad=(e,t)=>{if(t?.trim()===nd)return"link-expired";const s=di(e,t);return s==="auth"?"auth":s==="body-missing"?"missing":"generic"},rd=300*1e3,Tn=async(e,t)=>{const s={},n=await t();n&&(s.Authorization=`Bearer ${n}`);const r=await Xr(e,{headers:s,signal:AbortSignal.timeout(rd)});if(r.status===202)throw new gs("not-ready","Attachment is still being fetched from the mail server",202);if(!r.ok)throw new gs(ad(r.status,r.headers.get(sd)),`Failed to download attachment (${r.status} ${r.statusText})`,r.status);return r.blob()},od=(e,t,s)=>{switch(e){case"auth":return{title:"Your session expired",detail:`Sign in again, then download ${t} once more. Other parts of the app may also stop responding until you do.`};case"link-expired":return{title:"This download link expired and could not be renewed",detail:`Reload the page, then download ${t} again. If that keeps failing, this is worth reporting.`};case"missing":return{title:"This attachment is missing from storage",detail:"Remit has the message but not the file. Re-sync the account from Settings, then try again."};case"not-ready":return{title:"Still fetching this attachment",detail:"Remit is downloading it from the mail server now. Try again in a few seconds."};default:return{title:"Couldn't download this attachment",detail:s}}},In=e=>e instanceof gs?e.reason:"generic",id=e=>e instanceof Error?e.message:typeof e=="string"?e:"An unexpected error occurred while downloading this attachment.",ld=(e,t,s)=>{if(e!=="auth")return Yr(Jr({title:`Bug: attachment download failed (${e})`,errorMessage:`Downloading "${t}" failed: ${s}`}))},cd=(e,t)=>{const s=URL.createObjectURL(e),n=document.createElement("a");n.href=s,n.download=t,n.rel="noopener",document.body.append(n),n.click(),n.remove(),setTimeout(()=>URL.revokeObjectURL(s),0)},dd=e=>{const t=e.toUpperCase();return t==="OCTET-STREAM"?"FILE":t},ud=e=>{const t=e.toLowerCase().replace(/[^a-z0-9]/g,"");return t.length>0?`attachment.${t}`:"attachment"},En=e=>e.filter(t=>!t.isMultipart&&t.disposition===Zr.Attachment&&t.contentUrl.length>0).map(t=>({bodyPartId:t.bodyPartId,filename:Wo(t.dispositionFilename??"",ud(t.mediaSubtype)),typeLabel:dd(t.mediaSubtype),sizeOctets:t.sizeOctets,contentUrl:t.contentUrl})),Rn={status:"idle"},fd=({messageId:e,bodyParts:t,hasAttachment:s=!1,className:n})=>{const{getToken:r}=Zn(),o=ae(),[i,c]=l.useState({}),u=l.useMemo(()=>En(t??[]),[t]),x=eo({path:{messageId:e}}),g=f=>Tn(f.contentUrl,r).catch(d=>{if(!td(In(d)))throw d;return o.refetchQueries({queryKey:x}).then(()=>{const m=o.getQueryData(x),h=m?En(m.bodyParts).find(w=>w.bodyPartId===f.bodyPartId):void 0;return Tn(h?.contentUrl??f.contentUrl,r)})}),b=(f,d)=>c(m=>({...m,[f]:d})),p=f=>{const d=u.find(m=>m.bodyPartId===f);if(!d)throw new Error(`No attachment part ${f} on message ${e}`);b(f,{status:"downloading"}),g(d).then(m=>{cd(m,d.filename),b(f,Rn)}).catch(m=>{const h=In(m),w=id(m),{title:v,detail:j}=od(h,d.filename,w);b(f,{status:"failed",title:v,detail:j,reportUrl:ld(h,d.filename,w)})})},y=s&&t!==void 0&&u.length===0;return a.jsx(Pl,{className:n,attachments:u.map(f=>({attachmentId:f.bodyPartId,filename:f.filename,typeLabel:f.typeLabel,sizeOctets:f.sizeOctets,download:i[f.bodyPartId]??Rn})),onDownload:p,hasUnlistedAttachment:y})},md=({messageId:e,threadId:t,mailboxId:s,accountId:n,isRead:r,isStarred:o,onToggleStar:i,fromAddressId:c,isTrusted:u,showRaw:x,onToggleRaw:g,onReply:b,onReplyAll:p,onForward:y})=>{const f=ae(),{deleteMessages:d}=Ds({mailboxId:s,threadId:t}),{moveMessages:m}=Ht({mailboxId:s,threadId:t,accountId:n}),{toggleTrusted:h}=ra({messageId:e}),{mutate:w}=pe({...zt(),onSettled:()=>{f.invalidateQueries({queryKey:Me({path:{threadId:t}})}),je(f,ke([s]))}}),v=l.useCallback(D=>{m([e],D)},[m,e]),j=l.useCallback(()=>{d([e])},[d,e]),T=l.useCallback(()=>{w({body:{messageIds:[e],isRead:!r}})},[w,e,r]),R=[];return c&&R.push({key:"trusted",label:u?"Trusted sender":"Mark sender trusted",icon:u?a.jsx(Bt,{className:"size-4 text-positive"}):a.jsx(Dt,{className:"size-4"}),onSelect:()=>h(c,u)}),g&&R.push({key:"raw",label:x?"Show formatted":"Show raw email",icon:a.jsx(ja,{className:"size-4"}),onSelect:g}),a.jsx(Aa,{hasThread:!0,onReply:b,onReplyAll:p,onForward:y,isStarred:o,onToggleStar:i,onDelete:j,isRead:r,onToggleRead:T,overflowItems:R,moveSlot:n?a.jsx(Fs,{accountId:n,currentMailboxId:s,onMove:v,label:"Move this message"}):void 0})},pd=()=>a.jsxs("div",{className:"animate-pulse space-y-2",role:"status","aria-label":"Loading raw email",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-5/6"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-3/4"})]}),hd=({messageId:e,enabled:t=!0})=>{const{data:s,isLoading:n,isError:r,error:o,refetch:i}=Z({...to({path:{messageId:e}}),enabled:t});if(n)return a.jsx("div",{className:"message-body",children:a.jsx(pd,{})});if(r)return a.jsx("div",{className:"message-body",children:a.jsx(Oe,{variant:"inline",title:"Couldn't load the raw email",error:o,onRetry:()=>i()})});const c=s?.raw??"";return c===""?a.jsx("div",{className:"message-body",children:a.jsx("p",{className:"text-fg-muted text-sm italic",children:"No raw source available for this message."})}):a.jsx("div",{className:"message-body",children:a.jsx("pre",{className:"email-text whitespace-pre-wrap break-words text-sm leading-relaxed bg-surface-sunken rounded-md p-3 max-h-[32rem] overflow-auto",children:c})})},gd=()=>a.jsx(Bt,{className:"inline-block size-4 ml-1 -mt-0.5 text-positive align-middle","aria-label":"Trusted sender","data-testid":"trusted-sender-badge"}),er=(e,t)=>({id:e.messageId,fromName:e.fromName??e.fromEmail??"?",fromEmail:e.fromEmail??"",toLabel:"",dateLabel:t,snippet:e.snippet||"",bodyHtml:""}),tr=({isStarred:e,onToggleStar:t,isStarPending:s,hoverReveal:n})=>a.jsx("button",{type:"button",onClick:r=>{r.stopPropagation(),t()},disabled:s,"aria-label":e?"Remove star":"Add star",className:U("shrink-0 p-0.5 rounded transition-colors",e?"text-warning":U("text-fg-subtle hover:text-warning",n&&"opacity-0 group-hover:opacity-100 focus:opacity-100"),s&&"opacity-50"),children:a.jsx(Ye,{className:U("size-3.5",e&&"fill-current")})}),bd=({threadMessage:e,isFocused:t,onToggle:s,onToggleStar:n,isStarPending:r})=>{const o=da(e.sentDate,"datetime"),i=er(e,o);return a.jsx($a,{message:i,onClick:s,isFocused:t,isUnread:!e.isRead,trailing:a.jsxs(a.Fragment,{children:[e.hasAttachment&&a.jsx(Kt,{className:"size-3 shrink-0 text-fg-subtle",role:"img","aria-label":"Has an attachment"}),a.jsx(tr,{isStarred:e.hasStars,onToggleStar:n,isStarPending:r,hoverReveal:!0}),a.jsx("span",{"data-testid":"message-date",className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:o})]})})},xd=({threadMessage:e,messageData:t,isLoading:s,isError:n,error:r,onRetry:o,isFocused:i,onToggle:c,onToggleStar:u,isStarPending:x,accountId:g,showRaw:b,onToggleRaw:p,mobile:y,onReply:f,onReplyAll:d,onForward:m})=>{const h=da(e.sentDate,"long"),w=!e.isRead,v=t?.envelope.from[0]?.flags?.trusted?.value===!0,j=t?.envelope.from[0]?.addressId,T=er(e,h),R=e.autoMoved||e.spamReport?a.jsx(Jc,{accountId:g,messageId:e.messageId,threadId:e.threadId,mailboxId:e.mailboxId,autoMoved:e.autoMoved,spamReport:e.spamReport}):null;return a.jsx(La,{message:T,isFocused:y?!1:i,onHeaderClick:c,senderBadge:v?a.jsx(gd,{}):void 0,trailing:a.jsx("span",{"data-testid":"message-date",className:"text-2xs text-fg-subtle",children:h}),to:t?a.jsx(ml,{label:"To",addresses:t.envelope.to}):null,indicators:R||!y?a.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mt-0.5",children:[R,!y&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"flex items-center justify-end gap-1",children:a.jsx(tr,{isStarred:e.hasStars,onToggleStar:u,isStarPending:x})}),w&&a.jsx("span",{className:"size-1.5 rounded-full bg-accent","aria-label":"Unread"})]})]}):void 0,actionMenu:y?void 0:a.jsx(ed,{messageId:e.messageId,threadId:e.threadId,mailboxId:e.mailboxId,isRead:e.isRead,accountId:g,fromAddressId:j,isTrusted:v,showRaw:b,onToggleRaw:p}),actionBar:y?a.jsx(md,{messageId:e.messageId,threadId:e.threadId,mailboxId:e.mailboxId,accountId:g,isRead:e.isRead,isStarred:e.hasStars,onToggleStar:u,fromAddressId:j,isTrusted:v,showRaw:b,onToggleRaw:p,onReply:f,onReplyAll:d,onForward:m}):void 0,body:s?a.jsxs("div",{className:"mt-3 animate-pulse space-y-2",children:[a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-full"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-3/4"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-1/2"})]}):n&&so(r)?a.jsx("div",{className:"mt-3",children:a.jsx(Ba,{message:"This message has been deleted"})}):n?a.jsx("div",{className:"mt-3",children:a.jsx(Oe,{variant:"inline",title:"Couldn't load this message",error:r,onRetry:o})}):b?a.jsx("div",{className:"mt-3",children:a.jsx(hd,{messageId:e.messageId})}):a.jsxs("div",{className:"mt-3",children:[a.jsx(Zo,{bodyParts:t?.bodyParts,messageId:e.messageId,fromAddressId:t?.envelope.from[0]?.addressId,isTrusted:v,category:Wa(e.category)}),a.jsx(fd,{messageId:e.messageId,bodyParts:t?.bodyParts,hasAttachment:e.hasAttachment,className:"mt-4"})]})})},yd=({threadMessage:e,isExpanded:t,isFocused:s,onToggle:n,onToggleStar:r,isStarPending:o,accountId:i,mobile:c,onReply:u,onReplyAll:x,onForward:g})=>{const[b,p]=l.useState(!1),{data:y,isLoading:f,isError:d,error:m,refetch:h}=Z({...Ot({path:{messageId:e.messageId}}),enabled:t,meta:{softError:!0}});return t?a.jsx(xd,{threadMessage:e,messageData:y,isLoading:f,isError:d,error:m,onRetry:()=>h(),isFocused:s,onToggle:n,onToggleStar:r,isStarPending:o,accountId:i,showRaw:b,onToggleRaw:()=>p(w=>!w),mobile:c,onReply:u,onReplyAll:x,onForward:g}):a.jsx(bd,{threadMessage:e,isFocused:s,onToggle:n,onToggleStar:r,isStarPending:o})},vd=()=>a.jsxs("div",{className:"animate-pulse p-4",children:[a.jsx("div",{className:"h-6 bg-surface-sunken rounded w-3/4 mb-5"}),a.jsx("div",{className:"space-y-4",children:Array.from({length:2}).map((e,t)=>a.jsxs("div",{className:"flex gap-3 py-3",children:[a.jsx("div",{className:"size-10 bg-surface-sunken rounded-full shrink-0"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-32 mb-2"}),a.jsx("div",{className:"h-3 bg-surface-sunken rounded w-48"})]})]},t))})]}),im=({threadId:e,mailboxId:t,subject:s,selectedMessageId:n,authenticity:r,onOpenIntelligence:o,onBack:i,onSwipeNext:c,onSwipePrevious:u,mobileIntelligenceOpen:x})=>{const g=js(),{handlers:b}=Oc({onSwipeLeft:c,onSwipeRight:u}),{accountId:p}=$s(t),{data:y,isLoading:f,isError:d,error:m,refetch:h}=Z({...ea({path:{threadId:e}})}),w=l.useMemo(()=>y?.items??[],[y?.items]),v=w[w.length-1],j=l.useMemo(()=>[...w].reverse(),[w]),T=l.useRef(new Map),[R,D]=l.useState(new Set),[E,F]=l.useState(null),[P,_]=l.useState(0);l.useEffect(()=>{if(w.length>0&&e!==E){F(e);const L=new Set([w[w.length-1].threadMessageId]);if(n){const Q=w.find(Y=>Y.messageId===n);Q&&L.add(Q.threadMessageId)}D(L),_(0)}},[e,w,E,n]);const K=l.useCallback(L=>{D(Q=>{const Y=new Set(Q);return Y.has(L)?Y.delete(L):Y.add(L),Y})},[]),B=l.useCallback(L=>{const Q=j[L];if(!Q)return;T.current.get(Q.threadMessageId)?.scrollIntoView({behavior:"smooth",block:"nearest"})},[j]),k=l.useCallback(()=>{if(j.length===0)return;const L=Math.min(P+1,j.length-1);_(L),B(L)},[j.length,P,B]),I=l.useCallback(()=>{if(j.length===0)return;const L=Math.max(P-1,0);_(L),B(L)},[j.length,P,B]),$=l.useCallback(()=>{const L=j[P];L&&K(L.threadMessageId)},[j,P,K]);Lc({messages:w,expandedIds:R,threadId:e,mailboxId:t,accountId:p});const{toggleStar:S,isPending:M,pendingMessageId:C}=Va({threadId:e,mailboxId:t,messages:w}),z=no(),O=ao(),q=n??v?.messageId,G=l.useCallback((L,Q)=>{Q&&O({threadId:e,messageId:Q,mode:L})},[O,e]),le=l.useCallback(()=>G("reply",q),[G,q]),ee=l.useCallback(()=>G("reply-all",q),[G,q]),re=l.useCallback(()=>G("forward",q),[G,q]),he=l.useRef(null),te=z?.kind==="reply"?`${z.mode}:${z.sourceMessageId}`:void 0;if(l.useEffect(()=>{te&&he.current?.scrollIntoView({behavior:"smooth",block:"start"})},[te]),ri({enabled:!f&&w.length>0&&z===void 0,bindings:[{key:"j",handler:k,preventDefault:!0},{key:"ArrowDown",handler:k,preventDefault:!0},{key:"k",handler:I,preventDefault:!0},{key:"ArrowUp",handler:I,preventDefault:!0},{key:"Enter",handler:$,preventDefault:!0},{key:"o",handler:$,preventDefault:!0},{key:"r",handler:le,preventDefault:!0},{key:"R",handler:ee,noModifiers:!1,preventDefault:!0},{key:"f",handler:re,preventDefault:!0}]}),f)return a.jsx(vd,{});if(d)return a.jsx("div",{className:"flex h-full items-center justify-center",children:a.jsx(Oe,{title:z?"Couldn't load this conversation, so there is nothing to answer":"Couldn't load this conversation",error:m,onRetry:()=>h()})});if(w.length===0)return a.jsx("div",{className:"flex h-full items-center justify-center p-4",children:z?a.jsx(Oe,{variant:"inline",title:"There is nothing here to answer",error:"This conversation has no messages left. Another mail client may have moved or deleted them."}):a.jsx(Ba,{message:"No messages in this thread"})});const ce=s||w[0]?.subject||"(No subject)",oe=w.length,fe=L=>a.jsx("div",{"data-testid":"conversation-messages",children:j.map((Q,Y)=>a.jsx("div",{ref:we=>{we&&T.current.set(Q.threadMessageId,we)},children:a.jsx(yd,{threadMessage:Q,isExpanded:R.has(Q.threadMessageId),isFocused:Y===P,onToggle:()=>K(Q.threadMessageId),onToggleStar:()=>S(Q.messageId,Q.hasStars),isStarPending:M&&C===Q.messageId,accountId:p,mobile:L,onReply:L?()=>G("reply",Q.messageId):void 0,onReplyAll:L?()=>G("reply-all",Q.messageId):void 0,onForward:L?()=>G("forward",Q.messageId):void 0})},Q.threadMessageId))}),de=z&&a.jsx("div",{ref:he,children:z.kind==="reply"?a.jsx(Nc,{surface:z}):a.jsx("div",{className:"border-b border-line bg-canvas p-4",children:a.jsx(Oe,{variant:"inline",title:"That is not a way to answer a message",error:`"${z.segment}" is not reply, reply-all or forward.`})})}),ue=a.jsxs("header",{className:"border-b border-line px-5 pt-5 pb-3",children:[a.jsx("h1",{className:"max-w-2xl text-lg font-semibold leading-snug text-fg",children:ce}),a.jsxs("p",{className:"mt-1 text-2xs text-fg-subtle",children:[oe," ",oe===1?"message":"messages"]})]});return g?a.jsxs("article",{className:"h-full flex flex-col",children:[ue,r?.dkimMismatch&&a.jsx(wn,{authenticity:r,onOpenIntelligence:o}),a.jsxs("div",{className:"min-h-0 flex-1 overflow-auto",children:[de,fe(!1)]})]}):a.jsxs($l,{thread:{subject:ce,messages:[]},onBack:i??(()=>{}),intelligenceOpen:x,onToggleIntelligence:o,touchHandlers:b,children:[r?.dkimMismatch&&a.jsx(wn,{authenticity:r,onOpenIntelligence:o}),de,fe(!0)]})},kd="a[href], button, input, select, textarea, [tabindex]",jd=e=>{if(e.tabIndex<0||e.hasAttribute("disabled")||e.getAttribute("aria-disabled")==="true"||e.closest("[inert], [hidden], [aria-hidden='true']"))return!1;const t=getComputedStyle(e);return t.display!=="none"&&t.visibility!=="hidden"},Mn=e=>{const t=e.querySelectorAll('[role="dialog"][aria-modal="true"]');return[...(t[t.length-1]??e).querySelectorAll(kd)].filter(jd)},wd=({isOpen:e,onClose:t,children:s,ariaLabel:n="Navigation",side:r="left",widthClassName:o="w-[80vw] max-w-[320px]"})=>{const i=l.useRef(null),c=l.useRef(null);if(l.useEffect(()=>{if(!e)return;c.current=document.activeElement;const x=b=>{if(b.key==="Escape"){b.preventDefault(),t();return}if(b.key!=="Tab"||!i.current)return;const p=Mn(i.current);if(p.length===0)return;const y=p[0],f=p[p.length-1],d=document.activeElement;if(b.shiftKey){d===y&&(b.preventDefault(),f.focus());return}d===f&&(b.preventDefault(),y.focus())};document.addEventListener("keydown",x),i.current&&Mn(i.current)[0]?.focus();const g=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",x),document.body.style.overflow=g,c.current?.focus()}},[e,t]),!e)return null;const u=r==="left"?"left-0 border-r animate-in slide-in-from-left duration-150":"right-0 border-l animate-in slide-in-from-right duration-150";return a.jsxs("div",{className:"fixed inset-0 z-50",role:"dialog","aria-modal":"true","aria-label":n,children:[a.jsx("button",{type:"button","aria-label":"Close menu",onClick:t,className:"absolute inset-0 bg-black/40 animate-in fade-in duration-150 cursor-default"}),a.jsxs("div",{ref:i,className:U("safe-area-frame absolute top-0 bottom-0 bg-canvas border-line shadow-xl flex flex-col",o,u),children:[a.jsx("div",{className:"flex items-center justify-end h-12 px-2 border-b border-line shrink-0",children:a.jsx("button",{type:"button",onClick:t,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 menu",children:a.jsx(Pt,{className:"size-5"})})}),a.jsx("div",{className:"flex-1 overflow-y-auto",children:s})]})]})},Sd=10,sr=e=>({q:e?.toLowerCase()??"",limit:Sd}),Cd=(e,t)=>{if(!t)return;const s=t.toLowerCase();return e?.find(n=>n.normalizedEmail===s)};function Nd(e){const t=new Date(e),s=new Date;return t.toDateString()===s.toDateString()?"today":oi(t,{month:"short",year:"numeric"})}function nr(e){if(!e)return!0;const[,t]=e.split("@");return t?!t.includes("."):!0}const Td="We can't verify the sender of this email, which could mean it's from an insecure source.",Id="We couldn't read this sender's address, so we can't confirm who really sent this message.";function Ed(e,t){const s=e.category??"personal";return{value:oo(s)?s:"uncategorized",overridden:t?.flags?.category?.value!=null&&t.flags.category.value!==e.category}}function Rd(e,t){return{name:e.fromName??e.fromEmail??"Unknown",email:e.fromEmail??"",trust:e.senderTrust,firstSeenLabel:t?Nd(t.createdAt):"unknown",inboundCount:t?.inboundCount,replyCount:t?.replyCount,addressUnverified:nr(e.fromEmail)}}function Md(e){return e?.flags?{vip:e.flags.vip?.value===!0,muted:e.flags.muted?.value===!0,blocked:e.flags.blocked?.value===!0,unsubscribed:e.flags.unsubscribed?.value===!0}:{}}function An(e){if(e.fromName&&e.fromName!==e.fromEmail)return e.fromName}function Ad(e){return e.length===1?e[0]:`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function $d(e,t){const s=[],n=e.displayNameCorrespondence;t&&(n===es.Unrelated?s.push(`The name it shows, "${t}", has nothing to do with ${e.fromDomain}.`):n===es.Lookalike?s.push(`The name it shows, "${t}", only looks like ${e.fromDomain}.`):n===es.ForeignAddress&&s.push(`The name it shows, "${t}", is an address ${e.fromDomain} cannot send from.`));const r=Ld(e.offDomainLinkDomains);return r.length>0&&s.push(`Its links go to ${Ad(r.slice(0,3))}.`),s}function Ld(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function Pd(e,t){const s=t>0?t:void 0;if(nr(e.fromEmail))return{verdict:"mismatch",fromDomain:"",addressUnreadable:!0,summary:Id,similarCount:s};const n=e.authenticity;if(!n)return{verdict:"caution",fromDomain:e.fromEmail?.split("@")[1]??"",summary:Td};if(!n.dkimMismatch){const x=An(e),g=$d(n,x);return g.length>0?{verdict:"caution",fromDomain:n.fromDomain,dkimDomain:n.dkimDomain,claimedBrand:x,summary:g.join(" ")}:{verdict:"aligned",fromDomain:n.fromDomain,dkimDomain:n.dkimDomain,summary:n.dkimDomain?`This message was signed by ${n.dkimDomain}.`:"Nothing looks unusual about this sender."}}const r=n.fromDomain,o=n.dkimDomain,i=An(e),c=o?`it was actually sent from ${o}`:"its signature failed to verify",u=i?`The display name claims "${i}", but ${c}${o?` — not ${r}`:""}. Real senders use their own address.`:`This message claims to be from ${r}, but ${c}.`;return{verdict:"mismatch",fromDomain:r,dkimDomain:o,claimedBrand:i,summary:u,similarCount:s}}function Dd(e,t){const s=e?.fromEmail??null,n=e?.subject??"",{data:r,error:o}=Z({...ws({query:sr(s??void 0)}),enabled:!!s,staleTime:3e4}),i=Cd(r?.items,s??void 0),c=[n,s].filter(Boolean).join(" "),{data:u,isLoading:x,error:g}=Z({...ro({query:{query:c,limit:5}}),enabled:!!(e&&c.length>3),staleTime:6e4,retry:1});return{data:l.useMemo(()=>{if(!e)return null;const p=(u?.items??[]).filter(h=>h.messageId!==e.messageId).map(h=>({id:h.messageId,threadId:h.threadId,mailboxId:t!=null&&h.mailboxIds.includes(t)?t:h.mailboxIds[0]??"",fromName:h.fromName??"",subject:h.subject??"(No subject)",timeLabel:h.sentDate!=null?Xe(h.sentDate*1e3):"",matched:h.matchedChunkType})),y=Rd(e,i),f=Pd(e,p.length),d=Ed(e,i),m=Md(i);return{sender:y,authenticity:f,category:d,flags:m,similar:p}},[e,i,u,t]),isSimilarLoading:x,similarError:g,similarErrorIsFatal:Vs(g),addressErrorIsFatal:Vs(o),addressId:i?.addressId,address:i}}function Fd(e,t){const s={...e??{}};for(const[n,r]of Object.entries(t))r==null?delete s[n]:s[n]={...r,setAt:r.setAt??Date.now()};return s}function Od({addressId:e,senderEmail:t}){const s=ae(),{pushError:n}=be(),r=io({query:sr(t)}),{mutate:o,isPending:i}=pe({...lo(),onMutate:async u=>{const x=u.body.flags??{};await s.cancelQueries({queryKey:r});const g=s.getQueryData(r);return s.setQueryData(r,b=>b&&{...b,items:b.items.map(p=>p.addressId===u.path.addressId?{...p,flags:Fd(p.flags,x)}:p)}),{previous:g}},onError:(u,x,g)=>{g?.previous!==void 0&&s.setQueryData(r,g.previous),n({title:"Couldn't update sender preference",detail:Re(u),error:u})},onSettled:()=>{s.invalidateQueries({queryKey:r})}});return{updateFlags:l.useCallback(u=>{if(!e){co(new Error(`Quick action fired but the sender's address record did not resolve (sender: ${t??"unknown"}). This should never happen — the address row exists.`));return}o({path:{addressId:e},body:{flags:u}})},[e,o,t]),isPending:i}}const lm=e=>e==="vip"?"A sender you know":e==="wellknown"?"You've emailed them before":"Passed authentication",zd=e=>e.senderTrust!=="vip"&&e.senderTrust!=="wellknown"?!1:e.authenticity?.dkimMismatch!==!0;function cm(e,t){e.recordEvent("rescue.candidates_surfaced",{count:String(t)})}function dm(e,t){e.recordEvent("rescue.flow_opened",{count:String(t)})}function um(e,t){e.recordEvent("rescue.committed",{selected:String(t.selected),total:String(t.total),destination:t.toInbox?"inbox":"other"})}function _d(e,t){e.recordEvent("rescue.sent_to_junk",{count:String(t.count),senderTrust:t.senderTrust,wasRescuable:String(t.wasRescuable)})}const Ud=["personal","newsletter","marketing","automated","transactional","social"],Bd=e=>e.spamReport?"notSpam":"reportSpam",Kd=e=>{const{similarError:t,similarErrorIsFatal:s,isSimilarLoading:n}=e;return t&&!s?"error":n?"loading":"ready"};function qd(){return a.jsxs("aside",{className:"flex h-full w-full flex-col bg-surface-sunken",children:[a.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-1.5 border-b border-line px-row-inset",children:[a.jsx(We,{className:"size-3.5 text-fg-subtle"}),a.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Intelligence"})]}),a.jsxs("div",{className:"flex-1 animate-pulse space-y-4 p-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{className:"h-2.5 rounded bg-surface w-1/4"}),a.jsxs("div",{className:"flex gap-3",children:[a.jsx("div",{className:"size-10 rounded-full bg-surface shrink-0"}),a.jsxs("div",{className:"flex-1 space-y-1.5",children:[a.jsx("div",{className:"h-3 rounded bg-surface w-3/4"}),a.jsx("div",{className:"h-2.5 rounded bg-surface w-1/2"})]})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{className:"h-2.5 rounded bg-surface w-1/4"}),a.jsx("div",{className:"h-8 rounded bg-surface"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{className:"h-2.5 rounded bg-surface w-1/4"}),a.jsx("div",{className:"flex gap-1.5 flex-wrap",children:Array.from({length:5}).map((e,t)=>a.jsx("div",{className:"h-6 w-16 rounded bg-surface"},t))})]})]})]})}function Qd({isOpen:e,current:t,onSelect:s,onCancel:n}){return e?a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[a.jsx(fo,{label:"Dismiss reclassify sender",onDismiss:n,className:"backdrop-blur-sm"}),a.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Reclassify sender",className:"relative z-10 w-full max-w-sm rounded-sm border border-line bg-surface p-6 shadow-lg",children:[a.jsx("h2",{className:"text-lg font-semibold",children:"Reclassify this sender"}),a.jsx("p",{className:"mt-2 text-sm text-fg-muted",children:"Set a category override for future messages from this sender."}),a.jsx("div",{className:"mt-4 flex flex-col gap-1",children:Ud.map(r=>a.jsxs("button",{type:"button",onClick:()=>s(r),className:`flex min-h-11 items-center justify-between rounded px-3 text-left text-sm capitalize transition-colors hover:bg-surface-raised ${r===t?"font-semibold text-accent":"text-fg"}`,children:[r,r===t&&a.jsx("span",{className:"text-2xs text-fg-subtle",children:"current"})]},r))}),a.jsx("div",{className:"mt-6 flex justify-end",children:a.jsx("button",{type:"button",onClick:n,className:"inline-flex min-h-11 items-center justify-center rounded border border-line px-4 text-sm font-medium transition-colors hover:bg-surface-raised",children:"Cancel"})})]})]}):null}function Hd({thread:e,onClose:t,mailboxId:s,accountId:n,hideCloseButton:r,onAfterOptimisticRemove:o}){const{data:i,addressId:c,isSimilarLoading:u,similarError:x,similarErrorIsFatal:g}=Dd(e,s),[b,p]=l.useState(!1),y=e.fromEmail??void 0,{updateFlags:f}=Od({addressId:c,senderEmail:y}),{reportSpam:d,notSpam:m,isReporting:h,isRestoring:w}=Xa({mailboxId:e.mailboxId,threadId:e.threadId,accountId:n,onAfterOptimisticRemove:o}),v=uo(),j=Bd(e),T=l.useCallback(()=>{m([e.messageId])},[m,e.messageId]),R=l.useCallback(()=>{_d(v,{count:1,senderTrust:e.senderTrust,wasRescuable:zd(e)}),d([e.messageId])},[d,e,v]),D=l.useCallback(()=>{},[]),E=l.useCallback(()=>{const $=i?.flags?.vip!==!0;f({vip:{value:$}})},[i?.flags?.vip,f]),F=l.useCallback(()=>{const $=i?.flags?.muted!==!0;f({muted:{value:$}})},[i?.flags?.muted,f]),P=l.useCallback(()=>{const $=i?.flags?.unsubscribed!==!0;f({unsubscribed:{value:$}})},[i?.flags?.unsubscribed,f]),_=l.useCallback($=>{p(!1),f({category:{value:$}})},[f]),K=c!==void 0,B={onToggleVip:K?E:void 0,onToggleMute:K?F:void 0,onToggleUnsubscribe:K?P:void 0,onReclassify:K?()=>p(!0):void 0,onNotSpam:j==="notSpam"?T:void 0,onReportSpam:j==="reportSpam"?R:void 0},k=({mailboxId:$,threadId:S,messageId:M,className:C,ariaLabel:z,children:O})=>a.jsx(ta,{to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:$,threadId:S,messageId:M},search:q=>q,variant:"row",className:C,"aria-label":z,children:O});if(!i)return a.jsx(qd,{});const I=Kd({similarError:x,similarErrorIsFatal:g,isSimilarLoading:u});return a.jsxs(a.Fragment,{children:[a.jsx(Na,{data:i,onClose:t,hideCloseButton:r,onShowSimilar:D,actions:B,similarState:I,similarLinkComponent:k,reportSpamPending:h,notSpamPending:w,className:"border-l-0 h-full w-full"}),a.jsx(Qd,{isOpen:b,current:i.category.value,onSelect:_,onCancel:()=>p(!1)})]})}const Gd=({onClose:e,thread:t,mailboxId:s,accountId:n,hideCloseButton:r,onAfterOptimisticRemove:o})=>t?a.jsx(Hd,{thread:t,onClose:e,mailboxId:s,accountId:n,hideCloseButton:r,onAfterOptimisticRemove:o}):a.jsxs("aside",{className:"flex h-full w-full flex-col bg-surface-sunken",children:[a.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-1.5 border-b border-line px-row-inset",children:[a.jsx(We,{className:"size-3.5 text-fg-subtle"}),a.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Intelligence"})]}),a.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center px-row-inset text-center",children:[a.jsx(We,{className:"size-8 text-fg-subtle"}),a.jsx("p",{className:"mt-3 text-sm text-fg-muted",children:"Intelligence"}),a.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:"Sender trust, authenticity and similar messages will appear here."})]})]});function fm({isOpen:e,onClose:t,thread:s,mailboxId:n,accountId:r,onAfterOptimisticRemove:o}){return a.jsx(wd,{isOpen:e,onClose:t,ariaLabel:"Message details",side:"right",children:a.jsx(Gd,{onClose:t,thread:s,mailboxId:n,accountId:r,hideCloseButton:!0,onAfterOptimisticRemove:o})})}const Vd=e=>{const{trashByAccount:t,hasAppointments:s,isError:n}=Gc();return l.useMemo(()=>{const r=ii({targets:e,trashByAccount:t,hasAppointments:s,isError:n}),o=i=>i.accountId?t.get(i.accountId):void 0;return{outcome:r,trashIsUnconfirmed:e.some(i=>{const c=o(i);return c?.source==="Proposed"&&c.mailboxId===i.mailboxId}),staleFolderLabel:e.map(o).find(i=>i?.source==="Stale")?.staleFolderPath}},[e,t,s,n])},Wd={delete:(e,t)=>`Deleting ${e} of ${t}…`,move:(e,t)=>`Moving ${e} of ${t}…`,markRead:(e,t)=>`Marking ${e} of ${t} as read…`},Yd={delete:"moved to Trash",move:"moved",markRead:"marked as read"},ar=(e,t)=>e==="delete"&&t==="permanent"?"permanently deleted":Yd[e],Jd={delete:"couldn't be deleted",move:"couldn't be moved",markRead:"couldn't be marked as read"},Xd={delete:"Couldn't delete these messages",move:"Couldn't move these messages",markRead:"Couldn't mark these messages as read"},Zd={delete:"The delete didn't finish.",move:"The move didn't finish.",markRead:"The update didn't finish."},mm=(e,t,s)=>Wd[e](ze(t),ze(s)),eu=(e,t,s="trash")=>`${ze(t)} ${ar(e,s)}. Your mail server is still catching up.`,tu=e=>`Stopped after ${ze(e)}`,su=(e,t,s,n="trash")=>`${ze(t)} of ${ze(s)} ${ar(e,n)}. Nothing was sent for the rest, so they are untouched.`,nu=(e,t)=>t>0?`Stopped after ${ze(t)} — some messages ${Jd[e]}`:Xd[e],au=e=>Zd[e],pm=e=>e==="delete"?"danger":"info",hm=(e,t,s,n)=>s.error!==void 0?null:s.cancelled?{severity:"warning",title:tu(s.done),detail:su(e,s.done,t,n)}:{severity:"info",title:eu(e,s.done,n)},ru=100,ou=(e,t)=>e.kind==="move"?[t,e.destinationMailboxId]:[t],iu=({mailboxId:e,accountId:t,enabled:s,predicateKey:n,searchQuery:r})=>{const[o,i]=l.useState({kind:"idle"}),[c,u]=l.useState(void 0),[x,g]=l.useState(void 0),b=l.useRef(!1),p=l.useRef(!1),y=ae(),{pushError:f}=be();l.useEffect(()=>{p.current||(b.current=!0),i({kind:"idle"})},[s,n]);const d=l.useRef(r);d.current=r;const m=l.useCallback(E=>async F=>{const{data:P}=await Ws({path:{mailboxId:e},query:{...E,continuationToken:F,limit:ru},throwOnError:!0});return{ids:(P.items??[]).map(_=>_.messageId),continuationToken:P.continuationToken}},[e]),h=l.useCallback(async()=>{const{data:E}=await Ws({path:{mailboxId:e},query:{...d.current,count:!0,results:!1},throwOnError:!0});if(E.count===void 0)throw new Error("the search returned no count for the selection");return E.count},[e]),w=l.useCallback(E=>async F=>{if(E.kind==="move"){const{data:_}=await mo({body:{messageIds:F,destinationMailboxId:E.destinationMailboxId},throwOnError:!0});return _}if(E.kind==="markRead"){const{data:_}=await po({body:{messageIds:F,isRead:!0},throwOnError:!0});return _}const{data:P}=await ho({body:{messageIds:F},throwOnError:!0});return P},[]),v=l.useCallback((E,F)=>{je(y,ke(ou(E,e)));const P=new Set;t&&P.add(t);for(const _ of F)_.accountId&&P.add(_.accountId);for(const _ of P)y.invalidateQueries({queryKey:Je({path:{accountId:_}})})},[y,e,t]),j=l.useCallback(()=>{b.current=!1,i({kind:"counting"}),h().then(E=>{if(b.current){i({kind:"idle"});return}i({kind:"escalated",total:E})},E=>{f(Ys("Couldn't count matching messages","The count didn't finish.",E)),i({kind:"idle"})})},[h,f]),T=l.useCallback(()=>{b.current=!0},[]),R=l.useCallback(()=>{p.current||(b.current=!0,i({kind:"idle"}))},[]),D=l.useCallback(async(E,F)=>{b.current=!1,p.current=!0,u(E);const P=k=>g(Rc(k)),_=w(E),K=m(d.current);let B;try{B=F!==void 0?await qa(F,_,P,()=>b.current):await Ec(K,o.kind==="escalated"?o.total:0,_,P,()=>b.current)}finally{p.current=!1}return u(void 0),g(void 0),i({kind:"idle"}),B.error&&f(Ys(nu(E.kind,B.done),au(E.kind),B.error)),B.done>0&&v(E,F??[]),B},[w,m,o,f,v]);return{phase:o,escalate:j,stop:T,clear:R,isRunning:c!==void 0,runningAction:c,progress:x,runAction:D}},lu=120,cu=({keyboardFocusedMessageId:e,openMessageId:t,enabled:s,open:n,delayMs:r=lu})=>{const o=l.useRef(n);o.current=n;const i=l.useRef(void 0);l.useEffect(()=>{const c=e;if(!s){i.current=c;return}if(c===void 0||c===t)return;if(c===i.current){i.current=void 0;return}const u=setTimeout(()=>o.current(c),r);return()=>clearTimeout(u)},[s,e,t,r])},rr="This account has no Junk folder appointed, so there is nowhere to file these. Appoint one under Settings › Folder roles.",du="These are already in Junk, so there is nowhere to file them.",uu=(e,t)=>e!==void 0&&e!==t?e:void 0,gm=(e,t)=>{if(uu(e,t)===void 0)return e===void 0?rr:du};function fu(e,t){if(e.length!==0)return t!==void 0&&e.includes(t)?t:e[0]}const mu={title:"",navSlot:null,titleMeta:null,searchSlot:null,searchField:null,searchResults:null,makeFilterSlot:null},bs=l.createContext(mu),or=()=>l.useContext(bs),pu=({isOpen:e,messageIds:t,outcome:s,accountId:n,trashFolderLabel:r,staleFolderLabel:o,trashIsUnconfirmed:i=!1,isDeleting:c=!1,onConfirm:u,onCancel:x})=>{const{Account:g}=Zn(),{requestAppointment:b}=Vn(),p=t.length,y=()=>u([...t]),f=li(p,s,{trashFolderLabel:r,staleFolderLabel:o,trashIsUnconfirmed:i});return s==="noTrash"||s==="staleTrash"?a.jsx(It,{isOpen:e,...f,onConfirm:()=>{if(!n)return y();const d=[...t];x(),b({accountId:n,role:"Trash",reason:s==="noTrash"?"none":"stale",action:{kind:"delete",count:p},staleFolderLabel:o,onAppointed:async()=>u(d)})},onCancel:x}):s==="unavailable"?a.jsx(g,{fallback:a.jsx(It,{isOpen:e,...f,confirmLabel:"Reload reader",onConfirm:()=>window.location.reload(),onCancel:x}),children:({signOut:d})=>a.jsx(It,{isOpen:e,...f,onConfirm:()=>d(),onCancel:x})}):a.jsx(It,{isOpen:e,...f,destructive:!0,isBusy:c||s==="unknown",onConfirm:y,onCancel:x})},ir=8,lr=e=>e==="From"||e==="FromDomain",hu=e=>({value:e.email,label:e.displayName??e.email,...e.displayName?{hint:e.email}:{},...e.fromSelection?{source:"selected"}:{}}),gu=e=>{const t=_a(e.email);if(t!==null)return{value:t,...e.fromSelection?{source:"selected"}:{}}},bu=(e,t)=>e.value.toLowerCase().includes(t)||(e.label??"").toLowerCase().includes(t),xu=(e,t,s)=>{if(!lr(e))return[];const n=t.trim().toLowerCase(),r=new Set,o=[];for(const i of s){if(i.email.trim()==="")continue;const c=e==="From"?hu(i):gu(i);if(!c)continue;const u=c.value.toLowerCase();if(!(u===""||r.has(u))&&(r.add(u),u!==n&&!(n!==""&&!bu(c,n))&&(o.push(c),o.length===ir)))break}return o},yu=250,vu=2,ku=(e,t,s)=>{const n=t.trim(),r=ua(n,yu),o=e!==void 0&&lr(e),{data:i}=Z({...ws({query:{q:r,limit:ir}}),enabled:o&&r.length>=vu});if(!o||e===void 0)return[];const c=[...s.map(u=>({email:u,fromSelection:!0})),...(i?.items??[]).map(u=>({email:u.normalizedEmail,...u.displayName?{displayName:u.displayName}:{}}))];return xu(e,n,c)},cr=12,ju=e=>{const{envelope:t}=e,s=t.from[0];return{id:t.messageId,sender:s?Ua({normalizedEmail:s.normalizedEmail,displayName:s.displayName}):"Unknown",subject:t.subject??"(No subject)",date:Xe(t.date)}},wu=(e,t)=>{const s=e!==void 0&&t!==void 0,{data:n,isLoading:r}=Z({...go({path:{mailboxId:e??""},query:{...t,limit:cr}}),enabled:s,staleTime:3e4});return{messages:(n?.items??[]).map(Su),isPending:s&&r}},Su=e=>({id:e.messageId,sender:e.fromName||e.fromEmail||"Unknown",subject:e.subject??"(No subject)",date:Xe(e.sentDate)}),Cu=e=>Cs({queries:e.slice(0,cr).map(t=>({...Ot({path:{messageId:t}}),staleTime:Number.POSITIVE_INFINITY})),combine:t=>({messages:t.map(s=>s.data).filter(s=>s!==void 0).map(ju),isPending:t.some(s=>s.isPending)})}),Nu=e=>({matchOperator:"Or",literalClauses:Qt(e)}),Tu=(e,t,s)=>{const n=pe(bo()),{mutate:r,reset:o}=n,[i,c]=l.useState(!1),u=l.useMemo(()=>qt(s),[s]),x=l.useCallback(()=>{!e||!t||(c(!1),r({path:{accountId:e},body:en({anchorMessageId:t,matchOperator:"And",literalClauses:[]})}))},[e,t,r]),g=l.useCallback(()=>{c(!1),o()},[o]),b=n.data,p=b?.semanticUnavailable===!0&&!i&&u.length>0;l.useEffect(()=>{!p||!e||(c(!0),r({path:{accountId:e},body:en(Nu(u))}))},[p,e,u,r]);const y=i||(b?.semanticUnavailable??!1),f=n.isPending||p,d=i?{matchOperator:"Or",literalClauses:Qt(u)}:{...t?{anchorMessageId:t}:{},matchOperator:"And",literalClauses:[]};return{preview:x,reset:g,matchedCount:f?void 0:b?.matchedCount,messageIds:f?void 0:b?.messageIds,semanticUnavailable:y,senderFallback:i,senders:u,matchPredicate:d,isPending:f,isError:n.isError,error:n.error}},Iu=()=>[Qn({path:{mailboxId:""}}),Hn({path:{mailboxId:""}}),Gn()].map(e=>[{_id:e[0]._id}]),Eu=e=>Qa(e)?e.pages:Ha(e)?[e]:[],Ru=e=>typeof e=="object"&&e!==null&&typeof e.messageId=="string",Mu=(e,t)=>{const s=new Set(t),n=new Map;for(const r of e)for(const o of Eu(r))for(const i of o.items){if(!Ru(i)||!s.has(i.messageId))continue;const c=i.subject?.trim();c&&n.set(i.messageId,c)}return t.map(r=>n.get(r)).filter(r=>r!==void 0)},Au=e=>{const t=ae(),s=e.join("\0");return l.useMemo(()=>{const n=Iu().flatMap(r=>t.getQueriesData({queryKey:r}).map(([,o])=>o));return Mu(n,e)},[t,s])},$u=new Set(["hasAttachment","isUnread","isRead","isStarred","category","before","after"]),Lu=e=>$u.has(e),Pu=(e,{searchHadSemanticReach:t})=>{const s=[],n=[];let r,o;for(const u of e.tokens){if(u.type==="from"){s.push({field:"From",value:u.value});continue}if(u.type==="subject"){s.push({field:"Subject",value:u.value});continue}if(u.type==="in"){r={mailboxId:u.mailboxId,label:u.value};continue}if(u.type==="account"){o=u.accountId;continue}Lu(u.type)&&n.push({type:u.type,label:oa(u)})}const i=e.freeText.trim(),c=i.length>0;return c&&s.push({field:"HasWords",value:i}),{clauses:s,matchOperator:"all",scopedOut:r,droppedFacets:n,targetAccountId:o,keptTerms:c,droppedSemantic:c&&t}},Du=(e,t,s)=>e.targetAccountId??t??s[0]?.accountId,Fu=({failure:e,isStarting:t,isRunning:s,isDone:n,failedCount:r,ruleSaved:o})=>e?.kind==="restartFailed"?"backApplyRestartFailed":e?.kind==="startFailed"?o?"backApplyStartFailed":"commitFailed":n?r>0?"backApplyFailed":"backApplyComplete":e?.kind==="statusUnreadable"?"statusUnknown":t||s?"backApplyRunning":"saving",Ou=e=>{if(e.runState==="statusUnknown")return{kind:"refreshStatus"};if(e.isEscalated)return{kind:"rerunEscalated"};if(e.committedScope==="standing"||e.committedScope==="temporary")return e.createFilterFailed?{kind:"resetAndResend"}:e.backApplyPending?{kind:"startBackApply"}:{kind:"waitOnJob"};if(e.committedScope==="all-like-these"&&e.widenRunsAsJob)return{kind:"resend"};const t=new Set(e.failedIds);return{kind:"rerunBulk",targets:t.size>0?e.sent.filter(s=>t.has(s.id)):e.sent}},zu=e=>e!==void 0&&e.outcome===void 0&&e.failureReason===void 0,_u=(e,t)=>{if(e){e.stop();return}t()},Uu=(e,t)=>e==="run"?t.dismiss:t.cancel,Bu={clauses:[],matchOperator:"any"},Ku={clauses:[],matchOperator:"all",droppedFacets:[],keptTerms:!1,droppedSemantic:!1},qu=[],Qu=(e,t,s)=>({verb:"organize",accountId:Du(e,t.accountId,s),selection:qu,selectionRestriction:void 0,escalated:void 0,searchConversion:e}),Fe={state:"saving",matched:0,applied:0,failed:0,failures:[]},is=(e,t)=>e.map((s,n)=>({...s,id:`${t}-${n}`})),$n=(e,t,s)=>{if(e==="delete")return{kind:"delete"};if(e==="markRead")return{kind:"markRead"};const n=e==="junk"?s:t;return n?{kind:"move",destinationMailboxId:n}:void 0},ls=e=>e==="move"||e==="junk"||e==="organize",Ln=e=>e==="junk"?rr:"No destination was chosen, so there is nowhere to file these. Go back and pick a folder.";function Hu({verb:e,accountId:t,mailboxId:s,selection:n,selectionRestriction:r,escalated:o,escalatedProgress:i,searchConversion:c,onFinished:u,onRunEnded:x,step:g,goToStep:b,goBack:p,closeWizard:y}){const[f]=l.useState(()=>c),[d]=l.useState(()=>o),m=f!==void 0,[h,w]=l.useState(m?"properties":"selected"),v=d?"escalated":h,[j,T]=l.useState(()=>f?{clauses:is(f.clauses,"search"),matchOperator:f.matchOperator}:Bu),[R,D]=l.useState(void 0),[E,F]=l.useState(void 0),[P,_]=l.useState(!1),[K,B]=l.useState(void 0),[k,I]=l.useState(void 0),[$,S]=l.useState(),M=l.useRef(!1),C=l.useRef(!1),z=l.useMemo(()=>n.map(N=>N.id),[n]),O=l.useMemo(()=>n.map(N=>({id:N.id,accountId:N.accountId})),[n]),q=l.useMemo(()=>n.map(N=>N.email).filter(Boolean),[n]),G=z[0],le=Au(z),{junkMailboxId:ee}=Ya(t),re=Tu(d?void 0:t,G,q),{preview:he}=re;l.useEffect(()=>{he()},[he]);const te=v==="similar"||v==="properties",ce=l.useMemo(()=>({matchOperator:j.matchOperator==="all"?"And":"Or",literalClauses:j.clauses.map(N=>({field:N.field,value:N.value}))}),[j.clauses,j.matchOperator]),oe=v==="similar"?re.matchPredicate:ce,{count:fe,matchedIds:de}=fi(te?t:void 0,oe),ue=Cu(te?de:[]),L=wu(d?s:void 0,d?.searchQuery),Q=d?{status:"ready",count:d.total}:te?fe:{status:"ready",count:n.length},{data:Y}=Z({...bt({path:{accountId:t??""}}),enabled:!!t,staleTime:Number.POSITIVE_INFINITY}),we=Ja(t),Gt=Wn(),et=l.useMemo(()=>Jn({mailboxes:Y?.items??[],folderAppointments:we,currentMailboxId:s,translator:Gt}),[Y?.items,we,s,Gt]),{createFolderIn:Vt}=Yn(t),tt=et.find(N=>N.id===j.moveMailboxId)?.label,st=fc(n.map(N=>({normalizedEmail:N.email,displayName:N.sender}))),nt=vc({match:v==="properties"&&j.clauses[0]?.value.trim()||void 0,sender:st?Ua(st):void 0,folder:tt}),H=l.useMemo(()=>({...j,name:j.name??nt}),[j,nt]),St=ku(R?.draft.field,R?.draft.value??"",q),me=mi(t),xe=pi(t),_e=iu({mailboxId:s??"",accountId:t,enabled:!1,predicateKey:"selection-wizard",searchQuery:{}}),{runAction:Ue}=_e,se=vo({verb:e,mode:v,scope:j.scope,fromSearch:m}),J=se[Js(se,g)],$e=ko(t,r),Se=(N=>{if(N==="folder")return $e.destination;if(N==="rule")return H.scope==="standing"||H.scope==="until"?$e.rule:void 0})(J)??jo(J,H,Q),Le=l.useCallback(()=>is(yc(q,le),"seed"),[q,le]),Wt=l.useCallback(N=>{w(N),T(A=>({...A,widen:N==="similar"&&G?{anchorCount:Math.max(n.length,1)}:void 0,...N==="properties"&&A.clauses.length===0?{clauses:Le()}:{}}))},[G,n.length,Le]),Be=l.useCallback(()=>{_(!0),w("properties"),T(N=>({...N,widen:void 0,clauses:is(Qt(q),"sender"),matchOperator:"any"})),b("properties")},[q,b]),Ce=re.semanticUnavailable||re.isError;l.useEffect(()=>{J==="match"&&(v!=="similar"||!Ce||P||Be())},[J,v,Ce,P,Be]);const at=l.useCallback(()=>{D({mode:"add",draft:{field:"From",value:""}})},[]),rt=l.useCallback(N=>{const A=j.clauses.find(W=>W.id===N);A&&D({mode:"edit",clauseId:N,draft:{field:A.field,value:A.value}})},[j.clauses]),ne=l.useCallback(N=>{T(A=>({...A,clauses:A.clauses.filter(W=>W.id!==N)}))},[]),ye=l.useCallback(N=>{D(A=>A&&{...A,draft:N})},[]),pr=l.useCallback(()=>{D(N=>{if(!N)return;const A=hi(N.draft.field,N.draft.value),W={...N.draft,value:A};T(Ke=>({...Ke,clauses:N.clauseId?Ke.clauses.map(ot=>ot.id===N.clauseId?{...ot,...W}:ot):[...Ke.clauses,{id:crypto.randomUUID(),...W}]}))})},[]),hr=l.useCallback(()=>{if(Se){F(J);return}F(void 0);const N=se[Js(se,J)+1];N&&b(N)},[Se,J,se,b]),Yt=l.useCallback(async N=>{const A=$n(e,H.moveMailboxId,ee);if(!A){I({matched:N.length,sent:N,failureReason:Ln(e)});return}I({matched:N.length,sent:N});const W=await Ue(A,N);I({matched:N.length,sent:N,outcome:W}),C.current&&x?.(A.kind,N.length,W)},[e,H.moveMailboxId,ee,Ue,x]),Jt=l.useCallback(async()=>{if(!d)return;const N=$n(e,H.moveMailboxId,ee);if(!N){I({matched:d.total,sent:[],failureReason:Ln(e)});return}I({matched:d.total,sent:[]});const A=await d.run(N);I({matched:d.total,sent:[],outcome:A}),C.current&&x?.(N.kind,d.total,A)},[d,e,H.moveMailboxId,ee,x]),{start:Ct}=me,{createFilterAsync:Us}=xe,Nt=l.useCallback(()=>{if(d){Jt();return}const N=gi({mode:h,ruleScope:H.scope}),A=bi({mode:h,ruleScope:H.scope,anchorMessageId:G,clauses:H.clauses,matchOperator:H.matchOperator,moveMailboxId:H.moveMailboxId,until:H.until});if(B(N),N==="standing"||N==="temporary"){const W=xi(A)?A:void 0;S(W),Us(A,N,(H.name??"").trim()).then(Ke=>{Ke&&W&&Ct(W)});return}if(N==="all-like-these"&&ls(e)){Ct(A);return}Yt(N==="just-these"?O:de.map(W=>({id:W,accountId:t})))},[d,Jt,h,H,G,e,t,O,de,Us,Ct,Yt]),gr=l.useCallback(()=>{if(Se){F(J);return}M.current||(M.current=!0,b("run"),Nt())},[Se,J,b,Nt]),Bs=l.useCallback(N=>{const A=me.progress,W=Fu({failure:me.failure,isStarting:me.isStarting,isRunning:me.isRunning,isDone:me.isDone,failedCount:A.failedCount,ruleSaved:N});return W==="saving"||W==="commitFailed"||W==="backApplyStartFailed"?{...Fe,state:W}:{state:W,matched:A.matchedCount,applied:A.appliedCount,failed:W==="backApplyFailed"||W==="backApplyRestartFailed"?A.failedCount:0,failures:[]}},[me]),Ks=l.useMemo(()=>{const N=new Map;for(const A of[...n,...ue.messages,...L.messages])N.set(A.id,A);return N},[n,ue.messages,L.messages]),qs=d?i:_e.progress,Qs=l.useCallback(()=>{if(!k)return Fe;const{matched:N,outcome:A,failureReason:W}=k;if(W!==void 0)return{...Fe,state:"commitFailed",failureReason:W};if(!A){const qe=qs?.done??0;return{state:"backApplyRunning",matched:Math.max(N,qe),applied:qe,failed:0,failures:[]}}if(!(A.cancelled||A.error!==void 0))return{state:"backApplyComplete",matched:Math.max(N,A.done),applied:A.done,failed:0,failures:[]};if(A.done===0)return{...Fe,state:"commitFailed"};const ot=A.failedIds.map(qe=>Ks.get(qe)).filter(qe=>qe!==void 0),vr=A.failedIds.length>0?A.failedIds.length:Math.max(N-A.done,1);return{state:"runStopped",matched:Math.max(N,A.done),applied:A.done,failed:vr,failures:ot}},[k,qs,Ks]),Pe=d?Qs():K==="standing"||K==="temporary"?xe.isError?{...Fe,state:"commitFailed"}:xe.isSuccess?$?Bs(!0):{...Fe,state:"filterSaved"}:Fe:K==="all-like-these"&&ls(e)?Bs(!1):Qs(),br=()=>{const N=Ou({runState:Pe.state,isEscalated:d!==void 0,committedScope:K,createFilterFailed:xe.isError,backApplyPending:$!==void 0,widenRunsAsJob:ls(e),failedIds:k?.outcome?.failedIds??[],sent:k?.sent??O});switch(N.kind){case"refreshStatus":me.refreshStatus();return;case"rerunEscalated":Jt();return;case"resetAndResend":xe.reset(),Nt();return;case"resend":Nt();return;case"startBackApply":$&&Ct($);return;case"waitOnJob":return;case"rerunBulk":Yt(N.targets);return}},xr=l.useCallback(()=>{y(se,J)},[y,se,J]),Xt=l.useCallback(()=>{C.current=!0,y(se,J),u()},[y,se,J,u]),{stop:Hs}=_e,yr=l.useCallback(()=>{_u(d,Hs)},[d,Hs]);Cc({shouldBlockFn:({action:N})=>N!=="BACK"?!1:(Xt(),!0),enableBeforeUnload:!1,disabled:J!=="run"});const Zt={messages:d?L.messages:te?ue.messages:n,count:Q,label:v==="selected"?"Your selection":"A sample of what matches",emptyReason:v==="similar"&&Ce?"notIndexed":"noMatch",loading:d?L.isPending:te&&(Q.status==="loading"||ue.isPending)};return a.jsx(wo,{verb:e,steps:se,step:J,blockedReason:Se,nudged:E===J,onBack:p,onExit:Uu(J,{dismiss:Xt,cancel:xr}),onContinue:hr,onCommit:gr,match:{selectedCount:n.length,mode:v,accountId:$e.accountId,onModeChange:Wt,semanticUnavailable:Ce,semanticErrorDetail:re.error instanceof Error?re.error.message:void 0,semanticFallbackTaken:P,onSemanticFallback:Be,escalatedScope:d?.scope,sample:Zt},properties:{clauses:H.clauses,matchOperator:H.matchOperator,onMatchOperatorChange:N=>T(A=>({...A,matchOperator:N})),clauseEdit:R,onStartAddClause:at,onStartEditClause:rt,onRemoveClause:ne,onChangeDraft:ye,onSubmitClause:pr,onCancelClause:()=>D(void 0),clauseFields:yi,clauseSuggestions:St,conversionNotice:f?jc(f):void 0,semanticFallbackTaken:P,sample:{...Zt,label:"What this matches"}},folder:{folders:et,mailboxId:H.moveMailboxId,delimiter:Xn(Y?.items??[]),onSelect:N=>T(A=>({...A,moveMailboxId:N})),onCreateFolder:t?Vt:void 0,restriction:$e.destination},rule:{draft:H,onScopeChange:N=>T(A=>({...A,scope:N})),onUntilChange:N=>T(A=>({...A,until:N})),restriction:$e.rule},name:{name:H.name??"",onNameChange:N=>T(A=>({...A,name:N})),nudged:E===J},review:{verb:e,mode:v,selectedCount:n.length,clauses:H.clauses,matchOperator:H.matchOperator,folder:tt,scope:H.scope,until:H.until,ruleName:se.includes("name")?H.name:void 0,escalatedScope:d?.scope,sample:Zt},run:{state:Pe.state,verb:e,scope:H.scope,matched:Pe.matched,applied:Pe.applied,failedCount:Pe.failed,failures:Pe.failures,failureReason:Pe.failureReason,onRetry:br,onDismiss:Xt,onCancelRun:zu(k)?yr:void 0}})}function bm(e){const t=xo()==="search",{searchConversion:s}=or(),{accounts:n}=_t(),{step:r,goToStep:o,goBack:i,closeWizard:c}=yo(t?"properties":"match");if(!r)return null;const u=t?s??Ku:void 0;return a.jsx(Hu,{...e,...u?Qu(u,e,n):{},step:r,goToStep:o,goBack:i,closeWizard:c})}const Gu=[],Os=l.createContext(null),Vu=e=>{const t=l.useContext(Os);return t?t.rowInteraction(e):null},Wu=()=>{const e=l.useContext(Os);if(!e)throw new Error("useThreadListSelection must be used inside <ThreadListInteraction>");return e},Yu="[data-message-id]",Ju=e=>Array.from(e.querySelectorAll(Yu)).map(t=>t.dataset.messageId).filter(t=>t!==void 0),Xu=(e,t)=>e.length===t.length&&e.every((s,n)=>s===t[n]),Zu=e=>{const[t,s]=l.useState([]);return l.useEffect(()=>{const n=e.current;if(!n)return;const r=()=>{const i=Ju(n);s(c=>Xu(c,i)?c:i)};r();const o=new MutationObserver(r);return o.observe(n,{childList:!0,subtree:!0}),()=>o.disconnect()},[e]),t};function xm({selectedMessageId:e,rows:t,onOpen:s,onDeleteMessages:n,onSelectionVerb:r,wizardOpen:o=!1,isDeleting:i=!1,commandsRef:c,onTriageContextChange:u,children:x}){const g=js(),{pushError:b}=be(),p=l.useRef(null),y=Zu(p),f=wc({orderedIds:y,isDesktop:g,initialFocusedId:e}),{focusedMessageId:d,setFocusedMessageId:m,pendingDomFocusRef:h,cursorMovedByPointerRef:w,selection:v,isMultiSelectMode:j,exitSelection:T,handleRowSelect:R}=f,{selectedIds:D,selectedCount:E,isSelected:F,toggle:P,select:_,toggleAll:K}=v,B=y.length>0&&y.every(L=>D.has(L)),k=l.useCallback(()=>{y.length>0&&K(y)},[y,K]),{intersectWith:I}=v;l.useEffect(()=>{I(y)},[I,y]),l.useEffect(()=>{const L=h.current;L!==null&&(h.current=null,p.current?.querySelector(`[data-message-id="${L}"]`)?.focus())});const $=l.useCallback(L=>{w.current=!0,m(L)},[w,m]),S=l.useCallback(L=>{g||_(L)},[g,_]),M=l.useCallback(()=>{d&&s(d)},[d,s]),C=l.useCallback(L=>s(L,{replace:!0}),[s]);cu({keyboardFocusedMessageId:f.keyboardFocusedMessageId,openMessageId:e,enabled:g&&E===0,open:C});const[z,O]=l.useState(null),{outcome:q,trashIsUnconfirmed:G,staleFolderLabel:le}=Vd(z?.targets??Gu),ee=l.useCallback(L=>{if(z!==null)return!0;if(E>0)return r(L),!0;if(L!=="delete"||!d)return!1;const Q=t.find(Y=>Y.id===d);return!Q?.mailboxId||!Q.accountId?(b({title:"Couldn't delete this message",detail:"This list has lost track of which account and folder it is in, so reader can't tell whether deleting it would move it to Trash or erase it. Nothing was deleted.",action:{label:"Reload the list",href:window.location.href}}),!0):(O({ids:[d],targets:[{accountId:Q.accountId,mailboxId:Q.mailboxId}]}),!0)},[z,E,r,d,t,b]),re=l.useCallback(L=>{L.length!==0&&(n(L),O(null),T())},[n,T]),he=l.useCallback(()=>O(null),[]),te=l.useCallback(()=>E===0?!1:(T(),!0),[E,T]),ce=y.length>0;l.useEffect(()=>{if(c){if(!ce){c.current=null;return}return c.current={focusNext:f.focusNext,focusPrevious:f.focusPrevious,focusFirst:f.focusFirst,focusLast:f.focusLast,openFocused:M,toggleSelect:f.toggleFocusedSelection,extendSelectDown:f.extendRangeDown,extendSelectUp:f.extendRangeUp,selectAll:f.selectAllLoaded,clearSelection:te,requestVerb:ee,toggleDensity:()=>{}},()=>{c.current=null}}},[c,ce,f.focusNext,f.focusPrevious,f.focusFirst,f.focusLast,f.toggleFocusedSelection,f.extendRangeDown,f.extendRangeUp,f.selectAllLoaded,M,te,ee]);const oe=l.useMemo(()=>Array.from(D),[D]),fe=z!==null;l.useEffect(()=>{u?.({focusedMessageId:d,selectedIds:oe,orderedIds:y,hasList:ce,blocksKeyboard:fe||o})},[u,d,oe,y,ce,fe,o]);const de=fu(y,d),ue=l.useMemo(()=>({selectedIds:D,selectedCount:E,exitSelection:T,startSelectionVerb:r,orderedIds:y,allSelected:B,toggleAllLoaded:k,rowInteraction:L=>({focused:L===d,isTabStop:L===de,isDesktop:g,onFocusRow:$,selection:{isChecked:F(L),onToggleCheck:P,onRowSelect:R,isMultiSelectMode:j,onLongPress:S}})}),[D,E,T,r,y,B,k,d,de,g,$,F,P,R,j,S]);return a.jsxs(Os.Provider,{value:ue,children:[a.jsx("div",{ref:p,className:"contents",children:x}),a.jsx(pu,{isOpen:fe,messageIds:z?.ids??[],outcome:q,accountId:z?.targets[0]?.accountId,staleFolderLabel:le,trashIsUnconfirmed:G,isDeleting:i,onConfirm:re,onCancel:he})]})}function ym({title:e,isDeleting:t}){const s=or(),{selectedCount:n,exitSelection:r,startSelectionVerb:o,orderedIds:i,allSelected:c,toggleAllLoaded:u}=Wu();return a.jsx(Vl,{title:s.title||e,navSlot:s.navSlot,titleMeta:s.titleMeta,searchSlot:s.searchSlot,searchField:s.searchField,idleSlot:s.makeFilterSlot,count:n,onCancel:r,onDelete:()=>o("delete"),onMarkRead:()=>o("markRead"),isBusy:t,selectAll:i.length>0?{checked:c,indeterminate:n>0&&!c,onChange:u}:void 0})}const cs=e=>{e.preventDefault(),e.stopPropagation()},ef=(e,t)=>{const s=l.useRef(!1),n=l.useCallback(i=>{if(s.current=!1,i.button!==0)return;const c=ms(i);dn(c)&&t?.(e,c)&&(cs(i),s.current=!0,i.currentTarget.focus(),c.shiftKey&&window.getSelection()?.removeAllRanges())},[t,e]),r=l.useCallback(i=>{!i.ctrlKey||!t||i.preventDefault()},[t]),o=l.useCallback(i=>{if(s.current)return s.current=!1,cs(i),!0;const c=ms(i);return!dn(c)||!t?.(e,c)?!1:(cs(i),c.shiftKey&&window.getSelection()?.removeAllRanges(),!0)},[t,e]);return{onMouseDown:n,onContextMenu:r,claimClick:o}},tf=({thread:e,active:t=!1,focused:s,isTabStop:n,density:r="comfortable",isDesktop:o,badge:i,selection:c,inListbox:u=!1,link:x,onClick:g,onFocusRow:b})=>{const p=ae(),y=e.id,f=Vu(y),d=s??f?.focused??!1,m=n??f?.isTabStop??!1,h=c??f?.selection,w=b??f?.onFocusRow,v=o??f?.isDesktop??!0,j=h?.isChecked??!1,T=h?.isMultiSelectMode??!1,R=h?.onToggleCheck,D=h?.onRowSelect,E=h?.onLongPress,F=l.useCallback(C=>{C.preventDefault(),C.stopPropagation(),R?.(y)},[R,y]),P=ef(y,D),_=l.useCallback(C=>{if(!P.claimClick(C)){if(!v){if(T){C.preventDefault(),C.stopPropagation(),R?.(y);return}g?.();return}D?.(y,ms(C)),g?.()}},[P,v,T,R,D,g,y]),K=l.useCallback(()=>{E?.(y)},[E,y]),{longPressProps:B}=Rl({onLongPress:K,accessibilityDescription:j?"Deselect message":"Select message"}),k=l.useCallback(()=>{p.prefetchQuery(Ot({path:{messageId:y}}))},[p,y]),I=l.useCallback(()=>{k(),w?.(y)},[k,w,y]),$=xt({"data-list-row":"","data-message-row":!0,"data-message-id":y,...u?{role:"option","aria-selected":j}:{},tabIndex:m?0:-1,onClick:_,onMouseDown:P.onMouseDown,onContextMenu:P.onContextMenu,onMouseEnter:k,onFocus:I},v||!h?{}:B),S=U(r==="compact"?Ia({active:t,focused:d}):U("group",Rs({active:t,focused:d})),"outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-inset",j&&"bg-accent-soft",!v&&"min-h-11 select-none [-webkit-touch-callout:none]"),M=r==="compact"?a.jsx(Ea,{thread:e}):a.jsx(Ms,{thread:e,badge:i,selection:h?{checked:j,alwaysVisible:T,onToggle:F}:void 0});return x===void 0?a.jsx("button",{type:"button",...$,className:S,children:M}):a.jsx(ta,{to:"/mail/$mailboxId/$threadId/$messageId",params:{...x,messageId:y},search:C=>C,variant:"row",...$,className:S,children:M})},vm=l.memo(tf),sf="Open a message first",nf="This conversation hasn't loaded yet",af="The mailbox list hasn't loaded yet",rf="Couldn't find this mailbox's account — reload to try again",of={reply:"Reply",replyAll:"Reply all",forward:"Forward",delete:"Move to Trash",move:"Move to mailbox",flag:"Star"},km=({hasThread:e,messageId:t,intelligenceOpen:s,canToggleIntelligence:n,onToggleIntelligence:r,onReply:o,onReplyAll:i,onForward:c,onDelete:u,onToggleStar:x,isStarred:g,moveContext:b,moveContextLoading:p})=>{const[y,f]=l.useState(null),d=t??null,m=E=>e?E==="move"?b?null:p?af:rf:{reply:o,replyAll:i,forward:c,delete:u,flag:x}[E]?null:nf:sf,h=y&&y.messageId===d?y:null,w=h?m(h.action):null,v=h?.action==="move"&&h.overThread&&!!b,j=w??(h&&!v?`${of[h.action]} is ready — press it again`:null),T=E=>f({action:E,messageId:d,overThread:e}),R=E=>()=>T(E),D=(E,F)=>F?()=>{f(null),F()}:R(E);return a.jsx(Al,{hasThread:e,isStarred:g,onUnavailable:T,unavailableHint:j,replyTitle:`Reply ${it("reply")}`,replyAllTitle:`Reply all ${it("replyAll")}`,forwardTitle:`Forward ${it("forward")}`,deleteTitle:`Move to Trash ${it("delete")}`,flagTitle:`Star ${it("toggleStar")}`,onReply:D("reply",o),onReplyAll:D("replyAll",i),onForward:D("forward",c),onDelete:D("delete",u),onToggleStar:D("flag",x),onMove:R("move"),moveSlot:b?a.jsx(Fs,{accountId:b.accountId,currentMailboxId:b.currentMailboxId,onMove:b.onMove,label:"Move to mailbox",defaultOpen:v}):void 0,children:a.jsx(Ml,{open:s,enabled:n,onToggle:r})})};function lf(e){const[t,s]=l.useState(null);t!==null&&t!==e&&s(null);const n=e!==null&&t===e,r=l.useCallback(()=>s(null),[]),o=l.useCallback(()=>s(e),[e]),i=l.useCallback(()=>s(n?null:e),[n,e]);return{isOpen:n,open:o,close:r,toggle:i}}const jm=e=>{const{intelligenceOpen:t,onToggleIntelligence:s,onRaiseIntelligence:n}=_t(),r=sa()?.showIntelligencePane??!1,o=e??null,i=lf(o),c=!r&&i.isOpen,{open:u,toggle:x}=i,g=l.useCallback(()=>{if(r){s();return}x()},[r,s,x]),b=l.useCallback(()=>{!r||t||n()},[r,t,n]),p=l.useCallback(()=>{if(!r){u();return}b()},[r,u,b]);return{canToggle:o!==null,isShowing:o!==null&&(r?t:c),toggle:g,open:p,drawerOpen:c,closeDrawer:i.close,railFits:r,openRail:b}},wm=(e,{toggle:t,open:s})=>{l.useEffect(()=>(e.current={toggle:t,open:s},()=>{e.current=null}),[e,t,s])},cf=()=>{const e=ae();return l.useCallback(t=>{const s=Me({path:{threadId:t.threadId}}),r=e.getQueriesData({queryKey:s}).flatMap(([,o])=>o?.items.map(i=>i.messageId)??[]);return r.length>0?r:[t.messageId]},[e])},df=[],dr=e=>{const{data:t}=Z({...ea({path:{threadId:e??""}}),enabled:!!e});return t?.items??df},Sm=(e,t)=>{const s=dr(e),n=t?s.find(o=>o.messageId===t):void 0,r=s.length>0?s[s.length-1]:void 0;return n??r},Cm=({thread:e,isOpen:t=!1,mailboxId:s,accountId:n,onAfterOptimisticRemove:r})=>{const o=s??e?.mailboxId,i=n??e?.accountId,{accountId:c}=$s(i?void 0:o),u=i??c,x=cf(),{deleteMessages:g}=Ds({mailboxId:o??"",threadId:e?.threadId,accountId:u,onAfterOptimisticRemove:r}),{moveMessages:b}=Ht({mailboxId:o??"",threadId:e?.threadId,accountId:u,onAfterOptimisticRemove:r}),p=dr(t?e?.threadId:void 0),f=p.find(v=>v.messageId===e?.messageId)?.hasStars??e?.hasStars,{toggleStar:d}=Va({threadId:e?.threadId??"",mailboxId:o??"",messages:p}),m=l.useCallback(()=>{e&&g(x(e))},[e,x,g]),h=l.useCallback(v=>{e&&b(x(e),v)},[e,x,b]),w=l.useCallback(()=>{e&&d(e.messageId,f??!1)},[e,f,d]);return{mailboxId:o,accountId:u,isStarred:f,deleteThread:m,moveThread:h,toggleStar:w}},Pn=(e,t,s)=>{if(!t)return null;const n=e.indexOf(t);if(n===-1)return null;const r=s==="next"?n+1:n-1;return r<0||r>=e.length?null:e[r]},Nm=()=>{const[e,t]=l.useState(void 0),[s,n]=l.useState([]),[r,o]=l.useState([]),i=l.useRef(null),[c,u]=l.useState(!1),[x,g]=l.useState(!1),b=l.useCallback(p=>{t(p.focusedMessageId),n(p.selectedIds),p.orderedIds&&o(p.orderedIds),u(p.hasList),g(p.blocksKeyboard)},[]);return{listCommandsRef:i,onTriageContextChange:b,focusedMessageId:e,selectedIds:s,orderedIds:r,hasList:c,blocksKeyboard:x}},Tm=({context:e,orderedIds:t,selectedMessageId:s,enabled:n=!0,onClose:r,handlers:o})=>{const{listCommandsRef:i,hasList:c,blocksKeyboard:u}=e,x=l.useCallback(()=>{i.current?.clearSelection()||s&&r()},[i,s,r]);return Fo({enabled:n&&!u,handlers:{...c?{focusNext:()=>i.current?.focusNext(),focusPrevious:()=>i.current?.focusPrevious(),focusFirst:()=>i.current?.focusFirst(),focusLast:()=>i.current?.focusLast(),openFocused:()=>i.current?.openFocused(),toggleSelect:()=>i.current?.toggleSelect(),extendSelectDown:()=>i.current?.extendSelectDown(),extendSelectUp:()=>i.current?.extendSelectUp(),selectAll:()=>i.current?.selectAll(),toggleDensity:()=>i.current?.toggleDensity()}:{},back:x,...o}}),{goBack:x,nextMessageId:Pn(t,s,"next")??void 0,previousMessageId:Pn(t,s,"previous")??void 0}},uf={sender:"sender",recipient:"recipient",subject:"subject",attachment:"attachment",body:"body",entities:"entities"};function ff(e){return uf[e]??e}function Im(e,t){const{folder:s}=Ss(t,[e.mailboxId]);return{id:e.messageId,sender:e.fromName??e.fromEmail??"Unknown",...e.fromEmail?{senderEmail:e.fromEmail}:{},subject:e.subject??"(No subject)",snippet:e.snippet??"",date:Xe(e.sentDate),unread:!e.isRead,flagged:e.hasStars===!0,threadId:e.threadId,mailboxId:e.mailboxId,...s?{folder:s}:{}}}function Em(e,t){const{folder:s}=Ss(t,e.mailboxId?[e.mailboxId]:[]);return{id:e.id,sender:e.fromName,...e.fromEmail?{senderEmail:e.fromEmail}:{},subject:e.subject,snippet:e.snippet,date:e.timeLabel,unread:!e.isRead,flagged:e.starred===!0,...e.threadId?{threadId:e.threadId}:{},...e.mailboxId?{mailboxId:e.mailboxId}:{},...s?{folder:s}:{}}}function mf(e,t){const{mailboxId:s,folder:n}=Ss(t,e.mailboxIds);return{id:e.messageId,sender:e.fromName??"Unknown",subject:e.subject??"(No subject)",snippet:"",date:e.sentDate!=null?Xe(e.sentDate*1e3):"",threadId:e.threadId,matchedChunkLabel:ff(e.matchedChunkType),score:e.score,...s?{mailboxId:s}:{},...n?{folder:n}:{}}}function Rm(e,t,s){const n=new Set(t),r=[];for(const o of[...e].sort((i,c)=>c.score-i.score))n.has(o.threadId)||(n.add(o.threadId),r.push(mf(o,s)));return r}function Mm(e){const t=e.authenticity?.dkimMismatch===!0;return{id:e.messageId,accountId:e.accountId,mailboxId:e.mailboxId,threadId:e.threadId,fromName:e.fromName??e.fromEmail??"Unknown",fromEmail:e.fromEmail??"",subject:e.subject??"(No subject)",snippet:e.snippet??"",timeLabel:Xe(e.sentDate),sentDate:e.sentDate,isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:Wa(e.category),suspicious:t}}function Am(e){return e.filter(t=>t.muted!==!0)}function $m(e,t){const s=new Set,n=[];for(const r of[...e,...t])s.has(r.id)||(s.add(r.id),n.push(r));return n.sort((r,o)=>(o.sentDate??0)-(r.sentDate??0))}const Dn=[{id:"personal",label:"Personal",category:ve.personal},{id:"transactional",label:"Transactional",category:ve.transactional},{id:"newsletter",label:"Newsletter",category:ve.newsletter},{id:"marketing",label:"Marketing",category:ve.marketing},{id:"social",label:"Social",category:ve.social},{id:"automated",label:"Automated",category:ve.automated},{id:"uncategorized",label:"Unclassified",category:ve.uncategorized}];function Lm(e){const t=new Map(Dn.map(n=>[n.category,[]]));for(const n of e){const r=n.category??ve.uncategorized;(t.get(r)??t.get(ve.uncategorized))?.push(n)}const s=[];for(const n of Dn){const r=t.get(n.category);r&&r.length>0&&s.push({id:n.id,label:n.label,threads:r})}return s}function Pm(e,t){return e.fromName.toLowerCase().includes(t)||e.fromEmail.toLowerCase().includes(t)||e.subject.toLowerCase().includes(t)||e.snippet.toLowerCase().includes(t)}function Dm(e,t){return t.every(s=>{switch(s.type){case"from":{const n=s.value.toLowerCase();return e.fromEmail.toLowerCase().includes(n)||e.fromName.toLowerCase().includes(n)}case"subject":return e.subject.toLowerCase().includes(s.value.toLowerCase());case"category":return(e.category??"uncategorized")===s.category;case"hasAttachment":return e.hasAttachment===!0;case"isUnread":return!e.isRead;case"isRead":return e.isRead===!0;case"isStarred":return e.starred===!0;case"after":return e.sentDate!=null&&e.sentDate>=s.epochSeconds*1e3;case"before":return e.sentDate!=null&&e.sentDate<s.epochSeconds*1e3;case"in":return e.mailboxId===s.mailboxId;case"account":return e.accountId===s.accountId;default:return!1}})}const ur=8;function zs(e,t){const s=Math.max(0,Math.min(t,e.length)),n=ei(e).find(o=>s>=o.start&&s<=o.end);if(!n)return{start:s,end:s,raw:""};const r=ti(n.raw);return r?{start:n.start,end:n.end,raw:n.raw,name:r.name,value:r.value}:{start:n.start,end:n.end,raw:n.raw}}function pf(e,t){const s=zs(e,t);if(s.name===void 0)return{kind:"token",query:s.raw};const n=ia(s.name);if(n)return{kind:"value",token:n.name,source:n.values,query:s.value??""}}const hf={mailbox:"mailboxes",account:"accounts",contact:"contacts"},gf=(e,t)=>{if(e.values==="fixed")return e.options??[];const s=hf[e.values];return s?t[s]??[]:[]},bf=(e,t)=>{if(t==="")return 1;const s=e.toLowerCase();return s.startsWith(t)?0:s.includes(t)?1:-1},xs=(e,...t)=>{let s=-1;for(const n of t){if(n===void 0)continue;const r=bf(n,e);r<0||(s<0||r<s)&&(s=r)}return s},fr=e=>{const t=new Set;return e.filter(s=>s.rank>=0).sort((s,n)=>s.rank-n.rank).filter(s=>{const n=s.suggestion.value.toLowerCase();return t.has(n)?!1:(t.add(n),!0)}).slice(0,ur).map(s=>s.suggestion)},Fn=e=>({value:`${e.name}:`,label:`${e.name}:`,hint:e.label});function xf(e){const t=e.trim().toLowerCase();if(t==="")return Zs.map(Fn);const s=[];for(const n of Zs)if(s.push({rank:xs(t,`${n.name}:`,n.label),suggestion:Fn(n)}),n.values==="fixed")for(const r of n.options??[]){const o=la(n.name,r.value);s.push({rank:xs(t,o,r.label),suggestion:{value:o,label:r.label??o,hint:o}})}return fr(s)}function yf(e,t,s){const n=t.trim().toLowerCase(),r=gf(e,s).map(o=>({rank:xs(n,o.value,o.label),suggestion:{value:la(e.name,o.value),label:o.label??o.value,...o.hint?{hint:o.hint}:{}}}));return fr(r)}function vf(e,t,s={}){const n=zs(e,t);if(n.name===void 0)return xf(n.raw);const r=ia(n.name);return r?yf(r,n.value??"",s):[]}function kf(e,t,s){const n=zs(e,t),r=!s.value.endsWith(":"),o=/\s/.test(e.slice(n.end,n.end+1)),i=r&&!o?`${s.value} `:s.value;return{query:e.slice(0,n.start)+i+e.slice(n.end),cursor:n.start+i.length+(r&&o?1:0)}}const jf=e=>({value:e.normalizedEmail,...e.displayName?{label:e.displayName,hint:e.normalizedEmail}:{}}),wf=250,Sf=2;function Cf({query:e,cursor:t,enabled:s}){const{accounts:n}=_t(),{mailboxesByName:r}=ca(),o=r!==void 0,i=s?pf(e,t):void 0,c=i?.source==="contact"?i.query.trim():"",u=ua(c,wf),{data:x}=Z({...ws({query:{q:u,limit:ur}}),enabled:u.length>=Sf}),g=Cs({queries:n.map(f=>({...bt({path:{accountId:f.accountId}}),staleTime:1/0}))}),b=l.useMemo(()=>o?Oo(g.map(f=>f.data?.items??[]),n):[],[o,g,n]),p=l.useMemo(()=>zo(n),[n]),y=l.useMemo(()=>(x?.items??[]).map(jf),[x]);return l.useMemo(()=>{if(!s)return[];const f=vf(e,t,{mailboxes:b,accounts:p,contacts:y});return o?f:f.filter(d=>d.value!=="in:")},[s,e,t,b,p,y,o])}const mr="remit.recentSearches",Nf=5;function ys(){try{const e=localStorage.getItem(mr);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.filter(s=>typeof s=="string"):[]}catch{return[]}}function On(e){const t=e.trim();if(!t)return ys();const s=[t,...ys().filter(n=>n!==t)].slice(0,Nf);try{localStorage.setItem(mr,JSON.stringify(s))}catch{return s}return s}const Tf=e=>e.tier!=="phone"&&e.hasLiveInput&&!(e.bodyRendersCommittedResults&&e.hasCommittedQuery);function If(e){const{spam:t}=Pa([...e]),s=new Map;for(const r of t)r.mailboxId&&s.set(r.mailboxId,(s.get(r.mailboxId)??0)+1);let n;for(const[r,o]of s)(!n||o>n.count)&&(n={mailboxId:r,count:o});return n}function Fm({title:e,unreadCount:t,children:s,selectionBar:n,paneOverlay:r,footer:o,searchFilter:i,searchResults:c,searchLoading:u,relatedResults:x,relatedLoading:g,onSelectSearchResult:b,searchResultsLabel:p="Top matches",relatedResultsLabel:y="Related",searchResultsInBody:f=!1,refreshControl:d}){const{accounts:m,resultFolderIndex:h,searchQuery:w,searchInput:v,onSearchChange:j,onSearchClear:T,searchViewKey:R}=_t(),D=ca(),E=_o(),F=sa(),P=Uo(),[_,K]=l.useState(!1),[B,k]=l.useState(ys),I=So(),$=l.useRef(R);l.useEffect(()=>{$.current!==R&&($.current=R,K(!1))},[R]);const[S,M]=l.useState(0),[C,z]=l.useState(!1),[O,q]=l.useState(void 0),G=Cf({query:v,cursor:S,enabled:C&&v.trim().length>0}),le=l.useCallback(ne=>{const ye=kf(v,S,ne);j(ye.query),q({cursor:ye.cursor})},[v,S,j]),ee=Co({count:G.length,onAccept:ne=>{const ye=G[ne];ye&&le(ye)}}),{comboboxProps:re,handleKeyDown:he}=ee,te=l.useMemo(()=>({comboboxProps:re,onKeyDown:he,onCaretChange:M,onFocusChange:z,...O?{caret:O}:{}}),[re,he,O]),ce=ee.open?a.jsx(Eo,{id:ee.listId,suggestions:G,activeIndex:ee.activeIndex,optionId:ee.optionId,onPick:le,onHighlight:ee.setActiveIndex,label:"Search suggestions",className:"mx-row-inset mt-1 shrink-0"}):null,oe=v.trim().length>0,{mailboxesByName:fe,accountsByName:de}=D,ue=l.useMemo(()=>si(v,{mailboxesByName:fe,accountsByName:de}),[v,fe,de]),L=ue.tokens.map(ne=>({label:oa(ne),onRemove:()=>j(ni(v,ne))})),Q=c??[],Y=x??[],we=oe?[{id:"top",label:p,results:Q},{id:"related",label:y,results:Y}]:[],et=!(Q.length+Y.length>0)&&(u===!0||g===!0),{scope:Vt}=Bo(m),tt=No(),st=ki(tt),nt=ji(tt,Vt,st?h.get(st)?.role:void 0),H=nt.kind==="global"?If([...Q,...Y]):void 0,St=H?{kind:"global",onScopeToSpam:()=>E(H.mailboxId,w)}:nt,me=Y.length>0,xe=l.useMemo(()=>Pu(ue,{searchHadSemanticReach:me}),[ue,me]),_e=oe?xe:void 0,Ue=oe?{onClick:()=>{K(!1),I("properties","search")},blockedReason:kc(xe)?void 0:To(xe.droppedFacets.map(ne=>ne.label))}:void 0,se=Ue?a.jsx(Da,{...Ue}):null,J=Tf({tier:P,hasLiveInput:oe,hasCommittedQuery:w.trim().length>0,bodyRendersCommittedResults:f}),$e=ne=>{k(On(v)),b?.(ne)},_s=a.jsx(Fa,{value:v,sections:we,loading:et,onSelectResult:$e,tokens:L,scope:St}),Se=n===void 0,Le=J?a.jsx("div",{className:"h-full overflow-y-auto",children:_s}):null,Wt=Le&&!Se?Le:s,Be=Le&&Se?Le:null,Ce=Ko(P),at=Ce&&(_||oe),rt=l.useMemo(()=>({title:e,searchResults:Be,makeFilterSlot:se,searchConversion:_e,navSlot:F&&!F.showNavPane&&a.jsx(V,{variant:"ghost",size:"touch",icon:a.jsx(wi,{className:"size-5"}),onClick:()=>F.openNav(),"aria-label":"Menu",className:"-ml-2 shrink-0"}),titleMeta:a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle",children:[t.toLocaleString()," unread"]}),a.jsx(Xs,{}),d]}),searchSlot:Ce&&!at&&a.jsx(V,{variant:"ghost",size:"touch",icon:a.jsx(Io,{className:"size-5"}),onClick:()=>K(!0),"aria-label":"Search",className:"shrink-0"}),searchField:at&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"min-w-0 flex-1",children:a.jsx(na,{value:v,onChange:j,onClear:T,globalFocusKey:!1,showClearButton:!1,suggest:te})}),a.jsx(V,{variant:"ghost",size:"touch",icon:a.jsx(Pt,{className:"size-5"}),onClick:()=>{T(),K(!1)},"aria-label":"Close search",className:"shrink-0"}),a.jsx(Xs,{})]})}),[e,t,F,Ce,at,v,j,T,te,Be,se,_e,d]);if(P==="phone"&&_){const ne=ye=>{k(On(v)),K(!1),b?.(ye)};return a.jsxs(bs.Provider,{value:rt,children:[a.jsx(Gl,{value:v,onChange:j,onClear:T,onCancel:()=>{K(!1),T()},filter:i,recentSearches:B,onPickRecent:j,makeFilter:Ue,sections:we,loading:et,onSelectResult:ne,tokens:L,scope:St,suggest:te,suggestList:ce}),r]})}return a.jsx(bs.Provider,{value:rt,children:a.jsxs("section",{className:"relative flex h-full w-full flex-col bg-surface",children:[n?.(rt),ce,a.jsx("div",{className:"min-h-0 flex-1",children:Wt}),o,r]})})}export{lf as $,um as A,Gc as B,Ol as C,pu as D,je as E,ke as F,lm as G,Mm as H,Dm as I,$s as J,om as K,Sm as L,vm as M,Ds as N,Ht as O,Nm as P,Cm as Q,am as R,Vl as S,nm as T,cf as U,Va as V,Dd as W,Od as X,_d as Y,zd as Z,Tm as _,Nl as a,wm as a0,im as a1,fm as a2,Gd as a3,jm as a4,km as a5,em as a6,rm as a7,Im as a8,Rm as a9,Am as aa,$m as ab,Pm as ac,Em as ad,Pa as ae,If as af,Lm as ag,Zf as ah,Tf as ai,Bl as aj,xm as ak,Yf as al,Wu as am,Fm as an,Ls as ao,ht as ap,Rl as aq,xt as ar,Es as as,ms as at,Jf as au,Xf as av,tm as aw,ym as ax,or as b,Rs as c,sm as d,Ya as e,Vd as f,Sl as g,iu as h,cu as i,gm as j,eu as k,Cc as l,mm as m,wl as n,pm as o,fu as p,bm as q,hm as r,yl as s,Wa as t,ef as u,uu as v,Hc as w,Ja as x,cm as y,dm as z};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{m as v,r as u,j as s,a9 as l,aa as p}from"./index-
|
|
1
|
+
import{m as v,r as u,j as s,a9 as l,aa as p}from"./index-C8zyy3XE.js";import{F as x}from"./FullCompose-BdIpZxG9.js";import{a as m}from"./useMessageBodyContent-CBSYjeOA.js";function S(o,n,r){if(o!==n)return r}function d(o,n){return o===""?"":n}function j({searchInput:o,committedQuery:n,urlQuery:r,pathname:t,listPath:a}){return!v(t,a)||n!==o?!1:n!==r}const c=u.createContext(null),C=({chrome:o,children:n})=>s.jsx(c.Provider,{value:o,children:n});function M({phone:o,list:n,reading:r,intelligence:t,hasThread:a=!1}){const e=u.useContext(c),f=m();if(!e)return s.jsx(l,{});const i={nav:e.nav,overlay:e.overlay,skeleton:s.jsx(l,{}),isLoading:e.isLoading,navOpen:e.navOpen,onOpenNav:e.onOpenNav,onCloseNav:e.onCloseNav};return e.isSinglePane?s.jsx(p,{...i,list:f?s.jsx(x,{}):o,intelligenceOpen:e.intelligenceOpen}):s.jsx(p,{...i,topBar:e.topBar,list:n,reading:r,intelligence:t,intelligenceOpen:e.intelligenceOpen,hasThread:a})}export{C as M,M as a,j as b,d as c,S as s};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,ar as re,B as A,e as ie,r as x,b as Q,as as oe,T as ce,dx as le,u as ue,dy as q,bW as de,cc as fe,dz as me,dA as xe,dB as ge,v as he,bX as pe,cV as be}from"./index-Bkjd6ag4.js";import{R as ve,q as je,x as we}from"./search-token-index-B0AHm8CX.js";import{aq as Ne,ar as ye,c as Pe,a as U,as as Ce,s as Re,at as ke,au as Se,av as Me,al as Ee,an as ze}from"./MailListHeader-DBawPIAH.js";import{A as Ie}from"./avatar-Cg3od6Sb.js";import{M as Oe}from"./mail-r533UYo-.js";import{M as Le}from"./menu-C8xNLlit.js";function De(){return e.jsx("div",{className:"space-y-0",role:"status","aria-busy":"true","aria-label":"Loading messages",children:Array.from({length:8}).map((s,n)=>e.jsxs("div",{className:"animate-pulse border-b border-line px-3 py-2",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("div",{className:"h-4 w-32 rounded bg-surface-sunken"}),e.jsx("div",{className:"h-3 w-16 rounded bg-surface-sunken"})]}),e.jsx("div",{className:"mb-2 h-4 w-48 rounded bg-surface-sunken"}),e.jsx("div",{className:"h-3 w-full rounded bg-surface-sunken"})]},n))})}function Te({filter:s,scopeLabel:n,searchQuery:r}){const f=r?.trim();return s?e.jsxs(G,{children:[e.jsx("p",{className:"font-medium text-fg",children:$e(s.label,n,f)}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:_e[s.reach]}),e.jsx(A,{variant:"secondary",size:"sm",className:"mt-4",onClick:s.onClear,children:"Clear filter"})]}):e.jsx(G,{children:e.jsx("p",{className:"text-fg-muted",children:Ae(f,n)})})}const _e={"whole-folder":"Every message in this folder was checked.","loaded-pages":"Only the messages loaded so far were checked."};function Ae(s,n){return s?"No messages match your search":n?`No messages in ${n}`:"No messages in this mailbox"}function $e(s,n,r){return r?`No results for “${r}” in ${s}`:n?`No ${s} mail in ${n}`:`No ${s} mail`}function G({children:s}){return e.jsx("div",{className:"flex h-full flex-1 items-center justify-center",children:e.jsx("div",{className:"flex max-w-sm flex-col items-center justify-center p-8 text-center",children:s})})}function Ze(){return e.jsxs("div",{className:"flex items-center justify-center gap-2 py-4 text-sm text-fg-muted",role:"status","aria-live":"polite",children:[e.jsx(re,{className:"size-4 animate-spin","aria-hidden":"true"}),e.jsx("span",{children:"Loading more…"})]})}function Fe({message:s="Something went wrong loading this mailbox.",onRetry:n,onReport:r}){return e.jsx("div",{className:"flex h-full flex-1 items-center justify-center p-4",children:e.jsxs("div",{role:"alert",className:"flex max-w-sm flex-col items-center justify-center gap-3 text-center",children:[e.jsx(ie,{className:"size-8 text-danger","aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-danger",children:"Couldn't load messages"}),e.jsx("p",{className:"mt-1 break-words text-sm text-fg-muted",children:s})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[n&&e.jsx(A,{variant:"secondary",size:"sm",onClick:n,children:"Retry"}),r&&e.jsx(A,{variant:"ghost",size:"sm",onClick:r,children:"Report a problem"})]})]})})}const I=72,V=10,Xe=I/2,J="__swipeableRowAxisCancel";function Z(s){return s==="leading"?I:s==="trailing"?-I:0}function He(s){return s>=I/2?"leading":s<=-I/2?"trailing":"none"}function Be({thread:s,selectionMode:n,checked:r,active:f,peek:m,onPeek:g,onToggleCheck:y,onLongPress:j,onOpen:h,onAct:p}){const d=x.useRef(null),[b,v]=x.useState(null),{longPressProps:P}=Ne({onLongPress:j,isDisabled:n,accessibilityDescription:"Select message"}),k=i=>{const o=new PointerEvent("pointercancel",{bubbles:!0});o[J]=!0,i.currentTarget.dispatchEvent(o)},a=ye(P,{onPointerDown:i=>{d.current={startX:i.clientX,startY:i.clientY,axis:"none",escaped:!1}},onPointerMove:i=>{if(n)return;const o=d.current;if(!o)return;const u=i.clientX-o.startX,M=i.clientY-o.startY;if(o.axis==="none"&&(Math.abs(M)>V&&Math.abs(M)>Math.abs(u)?o.axis="vertical":Math.abs(u)>V&&Math.abs(u)>Math.abs(M)&&(o.axis="horizontal",i.currentTarget.setPointerCapture(i.pointerId))),o.axis==="none")return;const O=o.axis==="horizontal"?Math.abs(u):Math.abs(M);if(!o.escaped&&O>Xe&&(o.escaped=!0,k(i)),o.axis!=="horizontal")return;const F=Z(m),X=Math.max(-I,Math.min(I,F+u));v(X)},onPointerUp:i=>{const o=d.current;d.current=null;const u=b;if(v(null),!!o){if(o.axis!=="none"&&!o.escaped&&k(i),o.axis==="horizontal"){u!==null&&g(He(u));return}if(o.axis!=="vertical"){if(n){y();return}if(m!=="none"){g("none");return}h()}}},onPointerCancel:i=>{i.nativeEvent[J]||(d.current=null,v(null))}}),l=b??Z(m),N=l>0?"leading":l<0?"trailing":"none",C=Q("relative touch-pan-y bg-surface","select-none",Pe({active:r||f})),D={transform:l!==0?`translateX(${l}px)`:void 0,transition:b===null?"transform 150ms ease":"none",minHeight:44},$=!s.isRead,z=i=>i.stopPropagation(),T=n?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:Q("inline-flex size-7 shrink-0 items-center justify-center rounded-full border",r?"border-accent bg-accent text-accent-fg":"border-line-strong bg-canvas"),children:r&&e.jsx(oe,{className:"size-3.5"})}),e.jsx(U,{thread:s})]}):e.jsxs(e.Fragment,{children:[$&&e.jsx("span",{className:"absolute left-1.5 top-1/2 size-1.5 -translate-y-1/2 rounded-full bg-accent"}),e.jsx("span",{role:"checkbox",tabIndex:0,"aria-checked":r,"aria-label":`Select message from ${s.fromName}`,onPointerDown:z,onPointerMove:z,onPointerUp:z,onClick:i=>{i.preventDefault(),i.stopPropagation(),j()},onKeyDown:i=>{i.key!=="Enter"&&i.key!==" "||(i.preventDefault(),i.stopPropagation(),j())},className:"-m-2 inline-flex size-11 shrink-0 items-center justify-center rounded-full",children:e.jsx(Ie,{name:s.fromName,email:s.fromEmail,size:"sm"})}),e.jsx(U,{thread:s})]});return e.jsxs("div",{className:"relative overflow-hidden",children:[N==="leading"&&e.jsx("button",{type:"button",onClick:()=>p("leading"),"aria-label":s.isRead?"Mark as unread":"Mark as read",className:"absolute inset-y-0 left-0 flex items-center justify-start bg-accent-2 px-6 text-accent-fg",children:s.isRead?e.jsx(Oe,{className:"size-6"}):e.jsx(Ce,{className:"size-6"})}),N==="trailing"&&e.jsx("button",{type:"button",onClick:()=>p("trailing"),"aria-label":"Delete message",className:"absolute inset-y-0 right-0 flex items-center justify-end bg-danger px-6 text-canvas",children:e.jsx(ce,{className:"size-6"})}),e.jsx("button",{type:"button",role:n?"checkbox":void 0,"aria-checked":n?r:void 0,"data-message-row":!0,"data-message-id":s.id,...a,className:C,style:D,children:T})]})}function We({sections:s,selectedThreadId:n,selectionMode:r,checkedIds:f,initialPeek:m,onToggleCheck:g,onEnterSelection:y,onOpenThread:j,onRefresh:h,refreshing:p,busy:d=!1}){const[b,v]=x.useState(new Set),[P,k]=x.useState(new Map),w=s.flatMap(a=>a.threads).filter(a=>!b.has(a.id)).map(a=>{const l=P.get(a.id);return l===void 0?a:{...a,isRead:l}}),[S,R]=x.useState(m&&m!=="none"&&w[1]?{id:w[1].id,side:m}:null),E=(a,l)=>{if(l==="trailing")v(N=>new Set(N).add(a));else{const N=w.find(C=>C.id===a);k(C=>new Map(C).set(a,!N?.isRead))}R(null)};return e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[p&&e.jsxs("div",{className:"flex items-center justify-center gap-2 border-b border-line py-3 text-fg-muted",children:[e.jsx(ve,{className:"size-4 animate-spin"}),e.jsx("span",{className:"text-xs",children:"Checking for new mail…"})]}),e.jsx("div",{className:"divide-y divide-line",children:w.map(a=>e.jsx("div",{className:d?"pointer-events-none opacity-50":void 0,children:e.jsx(Be,{thread:a,selectionMode:r,checked:f.has(a.id),active:a.id===n,peek:S?.id===a.id?S.side:"none",onPeek:l=>R(l==="none"?null:{id:a.id,side:l}),onToggleCheck:()=>g(a.id),onLongPress:()=>y(a.id),onOpen:()=>j(a.id),onAct:l=>E(a.id,l)})},a.id))}),!r&&!p&&!d&&e.jsx("button",{type:"button",onClick:h,className:"w-full border-t border-line py-2 text-center text-2xs text-fg-subtle transition-colors hover:bg-surface-sunken",children:"Pull to refresh"})]})}const Ye=new Set;function es({listTitle:s,listMeta:n,sections:r,briefFilters:f,flatList:m,listState:g="ready",searchQuery:y,listFilter:j,listScopeLabel:h,errorMessage:p,onRetry:d,onReportError:b,briefFilter:v,selectedThreadId:P,density:k="comfortable",onSelectThread:w,onOpenNav:S,isDesktop:R,initialTouchState:E,selection:a,keyboard:l,selectionBar:N,paneOverlay:C,listBody:D,hideHeader:$=!1}){const z=k==="compact"?Se:Me,T=x.useRef(null),i=x.useRef(null),o=le(l);ue({containerRef:T,itemSelector:q,enabled:!o});const u=o?l.focusedId:void 0,M=o?u??r[0]?.threads[0]?.id:void 0,O=x.useCallback(t=>M===void 0?void 0:t===M?0:-1,[M]);x.useEffect(()=>{if(u===void 0)return;const t=i.current;if(!t)return;const c=t.querySelector(`${q}[data-message-id="${u}"]`);!c||c===t.ownerDocument.activeElement||c.focus({preventScroll:!1})},[u]),x.useEffect(()=>{if(!o)return;const t=i.current;if(!t)return;const c=t.ownerDocument.activeElement;c!==null&&c!==t.ownerDocument.body||t.focus({preventScroll:!0})},[o]);const F=!R&&!f&&g==="ready",[X,Y]=x.useState(!1),ee=E==="peek-trailing"?"trailing":E==="peek-leading"?"leading":void 0,se=()=>{Y(!0),setTimeout(()=>Y(!1),1400)},_=a?.selectedIds??Ye,L=a?.onToggle,K=a?.onRowSelect,te=Re(_.size,R),H=x.useCallback(t=>{if(L)return{checked:_.has(t),onToggle:c=>{c.preventDefault(),c.stopPropagation(),L(t)}}},[_,L]),B=x.useCallback((t,c)=>K?.(t,ke(c))?(c.preventDefault(),c.shiftKey&&window.getSelection()?.removeAllRanges(),!0):!1,[K]),ne=x.useCallback(({thread:t,active:c,onClick:W})=>e.jsx(z,{thread:t,active:c,focused:t.id===u,tabIndex:O(t.id),selection:H(t.id),onClick:ae=>{B(t.id,ae)||W?.()}}),[z,H,B,u,O]);return e.jsxs("section",{ref:t=>{i.current=t,l?.ref(t)},tabIndex:o?-1:void 0,className:"relative flex h-full w-full flex-col bg-surface outline-none",children:[N??($?null:e.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[S&&e.jsx(A,{variant:"ghost",size:"sm",icon:e.jsx(Le,{className:"size-4"}),onClick:S,"aria-label":"Open folders",className:"-ml-1 shrink-0"}),e.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:s}),n&&e.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle",children:n})]})),g==="loading"?e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsx(De,{})}):g==="empty"?e.jsx(Te,{filter:j,scopeLabel:h,searchQuery:y}):g==="error"?e.jsx(Fe,{message:p,onRetry:d,onReport:b}):f?e.jsx(de,{...v??{},sections:r,selectedThreadId:P,Row:ne,keyboard:l,onSelectThread:w}):D??(F?e.jsx(We,{sections:r,selectedThreadId:P,selectionMode:te,checkedIds:_,initialPeek:ee,onToggleCheck:t=>L?.(t),onEnterSelection:t=>L?.(t),onOpenThread:t=>w?.(t),onRefresh:se,refreshing:X}):e.jsx("div",{ref:T,className:"flex-1 overflow-y-auto",children:r.map(t=>e.jsxs("div",{children:[!m&&t.label&&e.jsxs("div",{className:"sticky top-0 flex h-section-row items-center justify-between border-b border-line bg-surface-sunken px-row-inset",children:[e.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:t.label}),e.jsx("span",{className:"text-2xs text-fg-subtle tabular-nums",children:t.threads.length})]}),e.jsx("div",{className:"divide-y divide-line",children:t.threads.map(c=>e.jsx(z,{thread:c,active:c.id===P,focused:c.id===u,tabIndex:O(c.id),selection:H(c.id),onClick:W=>{B(c.id,W)||w?.(c.id)}},c.id))})]},t.id))})),R&&e.jsx(Ee,{hints:l?we(l.handlers):je}),C]})}var Ke=class extends fe{constructor(s,n){super(s,n)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(s){s._type="infinite",super.setOptions(s)}getOptimisticResult(s){return s._type="infinite",super.getOptimisticResult(s)}fetchNextPage(s){return this.fetch({...s,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(s){return this.fetch({...s,meta:{fetchMore:{direction:"backward"}}})}createResult(s,n){const{state:r}=s,f=super.createResult(s,n),{isFetching:m,isRefetching:g,isError:y,isRefetchError:j}=f,h=r.fetchMeta?.fetchMore?.direction,p=y&&h==="forward",d=m&&h==="forward",b=y&&h==="backward",v=m&&h==="backward";return{...f,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:xe(n,r.data),hasPreviousPage:me(n,r.data),isFetchNextPageError:p,isFetchingNextPage:d,isFetchPreviousPageError:b,isFetchingPreviousPage:v,isRefetchError:j&&!p&&!b,isRefetching:g&&!d&&!v}}};function ss(s,n){return ge(s,Ke)}function ts({title:s,unreadCount:n,preset:r,selectedCategory:f,activeFilters:m,onSelectCategory:g,onToggleFilter:y,onSelectSource:j,onClearFilters:h,children:p,footer:d,searchResults:b,searchLoading:v,relatedResults:P,relatedLoading:k,onSelectSearchResult:w,searchResultsLabel:S,relatedResultsLabel:R,searchResultsInBody:E,refreshControl:a}){const{searchInput:l}=he(),N=l.trim().length>0,C={categories:r.categories,filters:r.filters,sources:r.sources,selectedCategory:f,activeFilters:m,onSelectCategory:g,onSelectSource:j,onToggleFilter:y,onClear:h};return e.jsx(pe,{hasSheet:!N,children:e.jsx(ze,{title:s,unreadCount:n,footer:d,searchFilter:C,searchResults:b,searchLoading:v,relatedResults:P,relatedLoading:k,onSelectSearchResult:w,searchResultsLabel:S,relatedResultsLabel:R,searchResultsInBody:E,refreshControl:a,children:e.jsx(be,{...C,hideChrome:N,children:p})})})}export{Ze as M,Be as S,es as a,ts as b,ss as u};
|
|
1
|
+
import{j as e,ar as re,B as A,e as ie,r as x,b as Q,as as oe,T as ce,dx as le,u as ue,dy as q,bW as de,cc as fe,dz as me,dA as xe,dB as ge,v as he,bX as pe,cV as be}from"./index-C8zyy3XE.js";import{R as ve,q as je,x as we}from"./search-token-index-Cu3vEtDY.js";import{aq as Ne,ar as ye,c as Pe,a as U,as as Ce,s as Re,at as ke,au as Se,av as Me,al as Ee,an as ze}from"./MailListHeader-C4iFTdSN.js";import{A as Ie}from"./avatar-66IHVolP.js";import{M as Oe}from"./mail-bfhHdZI4.js";import{M as Le}from"./menu-B4qp5h8W.js";function De(){return e.jsx("div",{className:"space-y-0",role:"status","aria-busy":"true","aria-label":"Loading messages",children:Array.from({length:8}).map((s,n)=>e.jsxs("div",{className:"animate-pulse border-b border-line px-3 py-2",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("div",{className:"h-4 w-32 rounded bg-surface-sunken"}),e.jsx("div",{className:"h-3 w-16 rounded bg-surface-sunken"})]}),e.jsx("div",{className:"mb-2 h-4 w-48 rounded bg-surface-sunken"}),e.jsx("div",{className:"h-3 w-full rounded bg-surface-sunken"})]},n))})}function Te({filter:s,scopeLabel:n,searchQuery:r}){const f=r?.trim();return s?e.jsxs(G,{children:[e.jsx("p",{className:"font-medium text-fg",children:$e(s.label,n,f)}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:_e[s.reach]}),e.jsx(A,{variant:"secondary",size:"sm",className:"mt-4",onClick:s.onClear,children:"Clear filter"})]}):e.jsx(G,{children:e.jsx("p",{className:"text-fg-muted",children:Ae(f,n)})})}const _e={"whole-folder":"Every message in this folder was checked.","loaded-pages":"Only the messages loaded so far were checked."};function Ae(s,n){return s?"No messages match your search":n?`No messages in ${n}`:"No messages in this mailbox"}function $e(s,n,r){return r?`No results for “${r}” in ${s}`:n?`No ${s} mail in ${n}`:`No ${s} mail`}function G({children:s}){return e.jsx("div",{className:"flex h-full flex-1 items-center justify-center",children:e.jsx("div",{className:"flex max-w-sm flex-col items-center justify-center p-8 text-center",children:s})})}function Ze(){return e.jsxs("div",{className:"flex items-center justify-center gap-2 py-4 text-sm text-fg-muted",role:"status","aria-live":"polite",children:[e.jsx(re,{className:"size-4 animate-spin","aria-hidden":"true"}),e.jsx("span",{children:"Loading more…"})]})}function Fe({message:s="Something went wrong loading this mailbox.",onRetry:n,onReport:r}){return e.jsx("div",{className:"flex h-full flex-1 items-center justify-center p-4",children:e.jsxs("div",{role:"alert",className:"flex max-w-sm flex-col items-center justify-center gap-3 text-center",children:[e.jsx(ie,{className:"size-8 text-danger","aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-danger",children:"Couldn't load messages"}),e.jsx("p",{className:"mt-1 break-words text-sm text-fg-muted",children:s})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[n&&e.jsx(A,{variant:"secondary",size:"sm",onClick:n,children:"Retry"}),r&&e.jsx(A,{variant:"ghost",size:"sm",onClick:r,children:"Report a problem"})]})]})})}const I=72,V=10,Xe=I/2,J="__swipeableRowAxisCancel";function Z(s){return s==="leading"?I:s==="trailing"?-I:0}function He(s){return s>=I/2?"leading":s<=-I/2?"trailing":"none"}function Be({thread:s,selectionMode:n,checked:r,active:f,peek:m,onPeek:g,onToggleCheck:y,onLongPress:j,onOpen:h,onAct:p}){const d=x.useRef(null),[b,v]=x.useState(null),{longPressProps:P}=Ne({onLongPress:j,isDisabled:n,accessibilityDescription:"Select message"}),k=i=>{const o=new PointerEvent("pointercancel",{bubbles:!0});o[J]=!0,i.currentTarget.dispatchEvent(o)},a=ye(P,{onPointerDown:i=>{d.current={startX:i.clientX,startY:i.clientY,axis:"none",escaped:!1}},onPointerMove:i=>{if(n)return;const o=d.current;if(!o)return;const u=i.clientX-o.startX,M=i.clientY-o.startY;if(o.axis==="none"&&(Math.abs(M)>V&&Math.abs(M)>Math.abs(u)?o.axis="vertical":Math.abs(u)>V&&Math.abs(u)>Math.abs(M)&&(o.axis="horizontal",i.currentTarget.setPointerCapture(i.pointerId))),o.axis==="none")return;const O=o.axis==="horizontal"?Math.abs(u):Math.abs(M);if(!o.escaped&&O>Xe&&(o.escaped=!0,k(i)),o.axis!=="horizontal")return;const F=Z(m),X=Math.max(-I,Math.min(I,F+u));v(X)},onPointerUp:i=>{const o=d.current;d.current=null;const u=b;if(v(null),!!o){if(o.axis!=="none"&&!o.escaped&&k(i),o.axis==="horizontal"){u!==null&&g(He(u));return}if(o.axis!=="vertical"){if(n){y();return}if(m!=="none"){g("none");return}h()}}},onPointerCancel:i=>{i.nativeEvent[J]||(d.current=null,v(null))}}),l=b??Z(m),N=l>0?"leading":l<0?"trailing":"none",C=Q("relative touch-pan-y bg-surface","select-none",Pe({active:r||f})),D={transform:l!==0?`translateX(${l}px)`:void 0,transition:b===null?"transform 150ms ease":"none",minHeight:44},$=!s.isRead,z=i=>i.stopPropagation(),T=n?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:Q("inline-flex size-7 shrink-0 items-center justify-center rounded-full border",r?"border-accent bg-accent text-accent-fg":"border-line-strong bg-canvas"),children:r&&e.jsx(oe,{className:"size-3.5"})}),e.jsx(U,{thread:s})]}):e.jsxs(e.Fragment,{children:[$&&e.jsx("span",{className:"absolute left-1.5 top-1/2 size-1.5 -translate-y-1/2 rounded-full bg-accent"}),e.jsx("span",{role:"checkbox",tabIndex:0,"aria-checked":r,"aria-label":`Select message from ${s.fromName}`,onPointerDown:z,onPointerMove:z,onPointerUp:z,onClick:i=>{i.preventDefault(),i.stopPropagation(),j()},onKeyDown:i=>{i.key!=="Enter"&&i.key!==" "||(i.preventDefault(),i.stopPropagation(),j())},className:"-m-2 inline-flex size-11 shrink-0 items-center justify-center rounded-full",children:e.jsx(Ie,{name:s.fromName,email:s.fromEmail,size:"sm"})}),e.jsx(U,{thread:s})]});return e.jsxs("div",{className:"relative overflow-hidden",children:[N==="leading"&&e.jsx("button",{type:"button",onClick:()=>p("leading"),"aria-label":s.isRead?"Mark as unread":"Mark as read",className:"absolute inset-y-0 left-0 flex items-center justify-start bg-accent-2 px-6 text-accent-fg",children:s.isRead?e.jsx(Oe,{className:"size-6"}):e.jsx(Ce,{className:"size-6"})}),N==="trailing"&&e.jsx("button",{type:"button",onClick:()=>p("trailing"),"aria-label":"Delete message",className:"absolute inset-y-0 right-0 flex items-center justify-end bg-danger px-6 text-canvas",children:e.jsx(ce,{className:"size-6"})}),e.jsx("button",{type:"button",role:n?"checkbox":void 0,"aria-checked":n?r:void 0,"data-message-row":!0,"data-message-id":s.id,...a,className:C,style:D,children:T})]})}function We({sections:s,selectedThreadId:n,selectionMode:r,checkedIds:f,initialPeek:m,onToggleCheck:g,onEnterSelection:y,onOpenThread:j,onRefresh:h,refreshing:p,busy:d=!1}){const[b,v]=x.useState(new Set),[P,k]=x.useState(new Map),w=s.flatMap(a=>a.threads).filter(a=>!b.has(a.id)).map(a=>{const l=P.get(a.id);return l===void 0?a:{...a,isRead:l}}),[S,R]=x.useState(m&&m!=="none"&&w[1]?{id:w[1].id,side:m}:null),E=(a,l)=>{if(l==="trailing")v(N=>new Set(N).add(a));else{const N=w.find(C=>C.id===a);k(C=>new Map(C).set(a,!N?.isRead))}R(null)};return e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[p&&e.jsxs("div",{className:"flex items-center justify-center gap-2 border-b border-line py-3 text-fg-muted",children:[e.jsx(ve,{className:"size-4 animate-spin"}),e.jsx("span",{className:"text-xs",children:"Checking for new mail…"})]}),e.jsx("div",{className:"divide-y divide-line",children:w.map(a=>e.jsx("div",{className:d?"pointer-events-none opacity-50":void 0,children:e.jsx(Be,{thread:a,selectionMode:r,checked:f.has(a.id),active:a.id===n,peek:S?.id===a.id?S.side:"none",onPeek:l=>R(l==="none"?null:{id:a.id,side:l}),onToggleCheck:()=>g(a.id),onLongPress:()=>y(a.id),onOpen:()=>j(a.id),onAct:l=>E(a.id,l)})},a.id))}),!r&&!p&&!d&&e.jsx("button",{type:"button",onClick:h,className:"w-full border-t border-line py-2 text-center text-2xs text-fg-subtle transition-colors hover:bg-surface-sunken",children:"Pull to refresh"})]})}const Ye=new Set;function es({listTitle:s,listMeta:n,sections:r,briefFilters:f,flatList:m,listState:g="ready",searchQuery:y,listFilter:j,listScopeLabel:h,errorMessage:p,onRetry:d,onReportError:b,briefFilter:v,selectedThreadId:P,density:k="comfortable",onSelectThread:w,onOpenNav:S,isDesktop:R,initialTouchState:E,selection:a,keyboard:l,selectionBar:N,paneOverlay:C,listBody:D,hideHeader:$=!1}){const z=k==="compact"?Se:Me,T=x.useRef(null),i=x.useRef(null),o=le(l);ue({containerRef:T,itemSelector:q,enabled:!o});const u=o?l.focusedId:void 0,M=o?u??r[0]?.threads[0]?.id:void 0,O=x.useCallback(t=>M===void 0?void 0:t===M?0:-1,[M]);x.useEffect(()=>{if(u===void 0)return;const t=i.current;if(!t)return;const c=t.querySelector(`${q}[data-message-id="${u}"]`);!c||c===t.ownerDocument.activeElement||c.focus({preventScroll:!1})},[u]),x.useEffect(()=>{if(!o)return;const t=i.current;if(!t)return;const c=t.ownerDocument.activeElement;c!==null&&c!==t.ownerDocument.body||t.focus({preventScroll:!0})},[o]);const F=!R&&!f&&g==="ready",[X,Y]=x.useState(!1),ee=E==="peek-trailing"?"trailing":E==="peek-leading"?"leading":void 0,se=()=>{Y(!0),setTimeout(()=>Y(!1),1400)},_=a?.selectedIds??Ye,L=a?.onToggle,K=a?.onRowSelect,te=Re(_.size,R),H=x.useCallback(t=>{if(L)return{checked:_.has(t),onToggle:c=>{c.preventDefault(),c.stopPropagation(),L(t)}}},[_,L]),B=x.useCallback((t,c)=>K?.(t,ke(c))?(c.preventDefault(),c.shiftKey&&window.getSelection()?.removeAllRanges(),!0):!1,[K]),ne=x.useCallback(({thread:t,active:c,onClick:W})=>e.jsx(z,{thread:t,active:c,focused:t.id===u,tabIndex:O(t.id),selection:H(t.id),onClick:ae=>{B(t.id,ae)||W?.()}}),[z,H,B,u,O]);return e.jsxs("section",{ref:t=>{i.current=t,l?.ref(t)},tabIndex:o?-1:void 0,className:"relative flex h-full w-full flex-col bg-surface outline-none",children:[N??($?null:e.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[S&&e.jsx(A,{variant:"ghost",size:"sm",icon:e.jsx(Le,{className:"size-4"}),onClick:S,"aria-label":"Open folders",className:"-ml-1 shrink-0"}),e.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:s}),n&&e.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle",children:n})]})),g==="loading"?e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsx(De,{})}):g==="empty"?e.jsx(Te,{filter:j,scopeLabel:h,searchQuery:y}):g==="error"?e.jsx(Fe,{message:p,onRetry:d,onReport:b}):f?e.jsx(de,{...v??{},sections:r,selectedThreadId:P,Row:ne,keyboard:l,onSelectThread:w}):D??(F?e.jsx(We,{sections:r,selectedThreadId:P,selectionMode:te,checkedIds:_,initialPeek:ee,onToggleCheck:t=>L?.(t),onEnterSelection:t=>L?.(t),onOpenThread:t=>w?.(t),onRefresh:se,refreshing:X}):e.jsx("div",{ref:T,className:"flex-1 overflow-y-auto",children:r.map(t=>e.jsxs("div",{children:[!m&&t.label&&e.jsxs("div",{className:"sticky top-0 flex h-section-row items-center justify-between border-b border-line bg-surface-sunken px-row-inset",children:[e.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:t.label}),e.jsx("span",{className:"text-2xs text-fg-subtle tabular-nums",children:t.threads.length})]}),e.jsx("div",{className:"divide-y divide-line",children:t.threads.map(c=>e.jsx(z,{thread:c,active:c.id===P,focused:c.id===u,tabIndex:O(c.id),selection:H(c.id),onClick:W=>{B(c.id,W)||w?.(c.id)}},c.id))})]},t.id))})),R&&e.jsx(Ee,{hints:l?we(l.handlers):je}),C]})}var Ke=class extends fe{constructor(s,n){super(s,n)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(s){s._type="infinite",super.setOptions(s)}getOptimisticResult(s){return s._type="infinite",super.getOptimisticResult(s)}fetchNextPage(s){return this.fetch({...s,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(s){return this.fetch({...s,meta:{fetchMore:{direction:"backward"}}})}createResult(s,n){const{state:r}=s,f=super.createResult(s,n),{isFetching:m,isRefetching:g,isError:y,isRefetchError:j}=f,h=r.fetchMeta?.fetchMore?.direction,p=y&&h==="forward",d=m&&h==="forward",b=y&&h==="backward",v=m&&h==="backward";return{...f,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:xe(n,r.data),hasPreviousPage:me(n,r.data),isFetchNextPageError:p,isFetchingNextPage:d,isFetchPreviousPageError:b,isFetchingPreviousPage:v,isRefetchError:j&&!p&&!b,isRefetching:g&&!d&&!v}}};function ss(s,n){return ge(s,Ke)}function ts({title:s,unreadCount:n,preset:r,selectedCategory:f,activeFilters:m,onSelectCategory:g,onToggleFilter:y,onSelectSource:j,onClearFilters:h,children:p,footer:d,searchResults:b,searchLoading:v,relatedResults:P,relatedLoading:k,onSelectSearchResult:w,searchResultsLabel:S,relatedResultsLabel:R,searchResultsInBody:E,refreshControl:a}){const{searchInput:l}=he(),N=l.trim().length>0,C={categories:r.categories,filters:r.filters,sources:r.sources,selectedCategory:f,activeFilters:m,onSelectCategory:g,onSelectSource:j,onToggleFilter:y,onClear:h};return e.jsx(pe,{hasSheet:!N,children:e.jsx(ze,{title:s,unreadCount:n,footer:d,searchFilter:C,searchResults:b,searchLoading:v,relatedResults:P,relatedLoading:k,onSelectSearchResult:w,searchResultsLabel:S,relatedResultsLabel:R,searchResultsInBody:E,refreshControl:a,children:e.jsx(be,{...C,hideChrome:N,children:p})})})}export{Ze as M,Be as S,es as a,ts as b,ss as u};
|