@remit/web-client-dist 0.0.321 → 0.0.322
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-BvS6OY3_.js → BriefPane-DezRv9-w.js} +1 -1
- package/assets/{ErrorState-By22X09V.js → ErrorState-jd3sUtw2.js} +1 -1
- package/assets/{FlaggedPane-COtoIxw_.js → FlaggedPane-BgXdB7fI.js} +1 -1
- package/assets/{MailListHeader-CzkFVHra.js → MailListHeader-BOYr_Fx1.js} +3 -3
- package/assets/{MailViewChrome-_M0MZo3I.js → MailViewChrome-BXIDTmDB.js} +1 -1
- package/assets/{MailboxPane-DxXhzeri.js → MailboxPane-CSGgyJPw.js} +1 -1
- package/assets/{NavMenuButton-DmFeFE-H.js → NavMenuButton-D1uGMYR-.js} +1 -1
- package/assets/{OnboardingWizard-KL6He6rZ.js → OnboardingWizard-3dJlW04p.js} +1 -1
- package/assets/{OutboxPane-BTeGPBk1.js → OutboxPane-B6gtUtio.js} +1 -1
- package/assets/_mailboxId-CdAgtOlI.js +1 -0
- package/assets/_messageId-6lPAdp0m.js +1 -0
- package/assets/_threadId-BrqBXqAP.js +1 -0
- package/assets/{account-form-helpers-DgsG82nf.js → account-form-helpers-Cku237WR.js} +1 -1
- package/assets/{accounts-DPg0TXKK.js → accounts-CU5kUkm3.js} +1 -1
- package/assets/{advanced-BcHKt9Ee.js → advanced-hXmT8qLX.js} +1 -1
- package/assets/{appearance-BTcWKzSp.js → appearance-DJTClN8w.js} +1 -1
- package/assets/{avatar-B5Xfa_Aj.js → avatar-4b13Sges.js} +1 -1
- package/assets/{bottom-sheet-CWKDKUBi.js → bottom-sheet-C3JBOSmc.js} +1 -1
- package/assets/brief-CpgXwwJY.js +1 -0
- package/assets/{brief-B121wlDA.js → brief-DQPJM7OE.js} +1 -1
- package/assets/{browser-ponyfill-Dnwm2Nul.js → browser-ponyfill-DmploGtW.js} +1 -1
- package/assets/{circle-check-D_nZdueG.js → circle-check-C-7XlClB.js} +1 -1
- package/assets/{circle-check-big-Dm9DZK8n.js → circle-check-big-BobfkM_J.js} +1 -1
- package/assets/{circle-help-BGR1fVqk.js → circle-help-B6RKeBQK.js} +1 -1
- package/assets/{clock-LgAy7KhC.js → clock-BUUHl7WR.js} +1 -1
- package/assets/{confirm-dialog-d8zs8D-F.js → confirm-dialog-Cv7dfJpV.js} +1 -1
- package/assets/{download-FAYYcvQP.js → download-D3GqdQOq.js} +1 -1
- package/assets/{filters-DTju1R14.js → filters-BC4W3kpG.js} +1 -1
- package/assets/flagged-BWq-bDju.js +1 -0
- package/assets/{flagged-BoYv9IB6.js → flagged-BzD4EfLb.js} +1 -1
- package/assets/{folders-BfrtWUpW.js → folders-CENuTc1Y.js} +1 -1
- package/assets/index-5mN-PDkZ.js +1 -0
- package/assets/index-6lPAdp0m.js +1 -0
- package/assets/index-7FGoKqZt.js +1 -0
- package/assets/index-BWxakx7D.js +1 -0
- package/assets/index-BdbY0XUZ.js +1 -0
- package/assets/{index-3eAE16lF.js → index-BvAPtXhR.js} +4 -4
- package/assets/index-U8NZZ6qQ.js +1 -0
- package/assets/{kbd-BVVVI8MK.js → kbd-B_dXE-g6.js} +1 -1
- package/assets/{labels-BjFJ4XU1.js → labels-DwtAhy6A.js} +1 -1
- package/assets/{mail-C8sEJWa1.js → mail-c3oo-7Wz.js} +1 -1
- package/assets/{menu-B3HPQBVa.js → menu-CtxXDmfA.js} +1 -1
- package/assets/{move-options-s_k2CE-Q.js → move-options-DoOvwIBJ.js} +1 -1
- package/assets/{onboarding-BxbMIMO7.js → onboarding-DjrlkbvU.js} +1 -1
- package/assets/outbox-BCTQBKu0.js +1 -0
- package/assets/{pencil-6AbAHB79.js → pencil-BWiEkJDV.js} +1 -1
- package/assets/{rich-text-BA11pr6t.js → rich-text-BjPEBAWr.js} +1 -1
- package/assets/{rotate-ccw-CgMVBPU0.js → rotate-ccw-Dh4JFwXs.js} +1 -1
- package/assets/{row-actions-Cfzm03L2.js → row-actions-Cvyykro8.js} +1 -1
- package/assets/{search-scope-Bcn1kzwd.js → search-scope-Ckwa5VkC.js} +1 -1
- package/assets/{search-token-index-XT09xk5-.js → search-token-index-BRBf_vfX.js} +1 -1
- package/assets/{search-view-BtUa3wf0.js → search-view-DXuisrUv.js} +1 -1
- package/assets/{senders-DsoPkIii.js → senders-EtXn1WFX.js} +1 -1
- package/assets/settings-D2gTt9bY.js +1 -0
- package/assets/{settings-screen-jzEUDPFx.js → settings-screen-CSEcljVe.js} +1 -1
- package/assets/{shield-check-Dq-7lUbt.js → shield-check-Cn8BIwb9.js} +1 -1
- package/assets/{suggested-vips-9VOMpahq.js → suggested-vips-CGuDO6eu.js} +1 -1
- package/assets/{useDebouncedValue-nan84ZZT.js → useDebouncedValue-BHLEjbFG.js} +1 -1
- package/assets/{useFilters-laocR3nD.js → useFilters-BoZ6Fc_g.js} +1 -1
- package/assets/{useLabels-Bzefby_I.js → useLabels-BMQ04w-1.js} +1 -1
- package/assets/{useMediaQuery-vS62WMhd.js → useMediaQuery-WUMWXwuZ.js} +1 -1
- package/assets/{useRefreshControl-DivGdE-V.js → useRefreshControl-6DemzxWn.js} +1 -1
- package/assets/{useSearchMirror-BJ2isjrf.js → useSearchMirror-Bxz_MBiG.js} +1 -1
- package/assets/{useSearchTokenContext-DKU_0B8G.js → useSearchTokenContext-Ca1mZv-e.js} +1 -1
- package/assets/{useSemanticSearch-Br2klJqm.js → useSemanticSearch-D1X6-Yo0.js} +1 -1
- package/assets/{useSignature-DEHQxXCm.js → useSignature-CVAEV1or.js} +1 -1
- package/index.html +1 -1
- package/package.json +1 -1
- package/assets/_mailboxId-CNHu38xX.js +0 -1
- package/assets/_messageId-D_A2HKiL.js +0 -1
- package/assets/_threadId-BVUvwFWI.js +0 -1
- package/assets/brief-BaArslj1.js +0 -1
- package/assets/flagged-BU2-QoPm.js +0 -1
- package/assets/index-BJYlc6-u.js +0 -1
- package/assets/index-BLqvw8Q9.js +0 -1
- package/assets/index-C-5LrpJf.js +0 -1
- package/assets/index-C6qTCMjJ.js +0 -1
- package/assets/index-CLxW3Goq.js +0 -1
- package/assets/index-D_A2HKiL.js +0 -1
- package/assets/outbox-D7_yfM4h.js +0 -1
- package/assets/settings-6lKvObGd.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/rich-text-
|
|
2
|
-
import{aa as $,bQ as Ui,r as l,c as Ae,j as a,C as bt,d as Ms,X as en,b as X,B as te,az as lt,bR as Ea,a as Pt,S as At,aT as Ki,bx as Hi,am as Rn,T as tn,bS as Na,b0 as As,bT as Wi,by as ja,at as qi,al as Ds,e as Vi,f as Qi,bU as Ta,bV as Ra,a9 as Gi,bW as Yi,bX as Xi,ay as Ia,bY as Ji,bZ as Zi,b_ as el,b$ as tl,bw as nl,c0 as sl,c1 as rl,c2 as al,c3 as ol,c4 as Ps,bd as Ma,c5 as at,c6 as Aa,c7 as il,c8 as ll,q as De,ad as Me,c9 as cl,ca as ul,x as dl,w as he,b9 as In,o as Ls,W as Lt,k as fl,ab as Ye,cb as ml,cc as pl,bF as Ve,bz as hl,ae as hs,bc as gl,ac as bl,cd as vl,ce as xl,J as Ze,t as Os,v as nn,G as Da,bk as Pa,bn as La,P as Ot,cf as Mn,cg as dt,ch as yl,ci as wl,cj as Sl,ck as kl,cl as Cl,cm as El,cn as Nl,s as jl,aU as Tl,V as Rl,bg as Il,bh as Ml,co as Al,m as Dl,cp as Pl,cq as Ll,cr as An,cs as Ol,bE as $l,bK as Fl,bC as ir,ct as _l,cu as zl,b8 as Bl,R as Ul,a0 as Kl,H as Hl,bl as lr,a_ as Wl,cv as ql,cw as Vl,bj as Ql,cx as Gl,cy as Yl,n as $s,cz as Xl,cA as Jl,cB as cr,cC as Zl,cD as ec,cE as tc,cF as nc,cG as Fs,i as sc,cH as rc,cI as ac,cJ as ur,g as oc}from"./index-3eAE16lF.js";import{B as ic,k as lc,m as cc,S as Oa,D as uc,b as dn,a as dc,e as fc,N as $a,t as Bt,f as mc,n as pc,o as hc,d as gc,u as bc,i as vc}from"./search-token-index-XT09xk5-.js";import{K as xc}from"./kbd-BVVVI8MK.js";import{M as yc,b as wc}from"./account-form-helpers-DgsG82nf.js";import{A as Qt}from"./avatar-B5Xfa_Aj.js";import{c as Sc,d as kc,e as Fa,f as Cc,M as Ec,g as _a,h as za,a as Nc,b as jc,S as dr,s as Ba,u as Ua,p as Tc,r as Rc}from"./useSearchTokenContext-DKU_0B8G.js";import{u as Ic}from"./useSignature-DEHQxXCm.js";import{u as _s}from"./useDebouncedValue-nan84ZZT.js";import{u as Dn}from"./useMediaQuery-vS62WMhd.js";import{E as sn}from"./ErrorState-By22X09V.js";import{e as Ka,b as $t,a as Mc,c as vt,d as Ac}from"./format-De9HZKjg.js";import{P as fr,C as Dc,D as mr,M as Je}from"./enums-CCxx0t2v.js";import{D as Pc}from"./download-FAYYcvQP.js";import{S as Lc}from"./shield-check-Dq-7lUbt.js";import{a as Ha,u as Wa,b as qa,f as Va}from"./move-options-s_k2CE-Q.js";import{h as pr,u as Oc,a as $c,i as Fc,n as _c,o as zc,j as Bc,k as Uc,S as Kc}from"./useFilters-laocR3nD.js";import{C as Hc}from"./confirm-dialog-d8zs8D-F.js";import{C as Wc}from"./clock-LgAy7KhC.js";import{u as qc,r as Vc,b as Qc}from"./search-scope-Bcn1kzwd.js";import{M as Gc}from"./menu-B3HPQBVa.js";function Gt(e){if(Yc())e.focus({preventScroll:!0});else{let t=Xc(e);e.focus(),Jc(t)}}let fn=null;function Yc(){if(fn==null){fn=!1;try{document.createElement("div").focus({get preventScroll(){return fn=!0,!0}})}catch{}}return fn}function Xc(e){let t=e.parentNode,n=[],s=document.scrollingElement||document.documentElement;for(;t instanceof HTMLElement&&t!==s;)(t.offsetHeight<t.scrollHeight||t.offsetWidth<t.scrollWidth)&&n.push({element:t,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft}),t=t.parentNode;return s instanceof HTMLElement&&n.push({element:s,scrollTop:s.scrollTop,scrollLeft:s.scrollLeft}),n}function Jc(e){for(let{element:t,scrollTop:n,scrollLeft:s}of e)t.scrollTop=n,t.scrollLeft=s}const it=e=>e?.ownerDocument??document,ut=e=>e&&"window"in e&&e.window===e?e:it(e).defaultView||window;function Zc(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&typeof e.nodeType=="number"}function eu(e){return Zc(e)&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in e}let tu=!1;function Qa(){return tu}function Ge(e,t){if(!Qa())return t&&e?e.contains(t):!1;if(!e||!t)return!1;let n=t;for(;n!==null;){if(n===e)return!0;n.tagName==="SLOT"&&n.assignedSlot?n=n.assignedSlot.parentNode:eu(n)?n=n.host:n=n.parentNode}return!1}function Se(e){if(Qa()&&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 nu=typeof Element<"u"&&"checkVisibility"in Element.prototype;function su(e){const t=ut(e);if(!(e instanceof t.HTMLElement)&&!(e instanceof t.SVGElement))return!1;let{display:n,visibility:s}=e.style,r=n!=="none"&&s!=="hidden"&&s!=="collapse";if(r){const{getComputedStyle:o}=ut(e);let{display:i,visibility:c}=o(e);r=i!=="none"&&c!=="hidden"&&c!=="collapse"}return r}function ru(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 Ga(e,t){return nu?e.checkVisibility({visibilityProperty:!0})&&!e.closest("[data-react-aria-prevent-focus]"):e.nodeName!=="#comment"&&su(e)&&ru(e,t)&&(!e.parentElement||Ga(e.parentElement,e))}const Ya=["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"],au=Ya.join(":not([hidden]),")+",[tabindex]:not([disabled]):not([hidden])";Ya.push('[tabindex]:not([tabindex="-1"]):not([disabled])');function ou(e,t){return e.matches(au)&&!iu(e)&&(t?.skipVisibilityCheck||Ga(e))}function iu(e){let t=e;for(;t!=null;){if(t instanceof ut(t).HTMLElement&&t.inert)return!0;t=t.parentElement}return!1}const zs=typeof document<"u"?$.useLayoutEffect:()=>{};function lu(e){let t=e;return t.nativeEvent=e,t.isDefaultPrevented=()=>t.defaultPrevented,t.isPropagationStopped=()=>t.cancelBubble,t.persist=()=>{},t}function cu(e,t){Object.defineProperty(e,"target",{value:t}),Object.defineProperty(e,"currentTarget",{value:t})}function uu(e){for(;e&&!ou(e,{skipVisibilityCheck:!0});)e=e.parentElement;let t=ut(e),n=t.document.activeElement;if(!n||n===e)return;let s=!1,r=m=>{(Se(m)===n||s)&&m.stopImmediatePropagation()},o=m=>{(Se(m)===n||s)&&(m.stopImmediatePropagation(),!e&&!s&&(s=!0,Gt(n),u()))},i=m=>{(Se(m)===e||s)&&m.stopImmediatePropagation()},c=m=>{(Se(m)===e||s)&&(m.stopImmediatePropagation(),s||(s=!0,Gt(n),u()))};t.addEventListener("blur",r,!0),t.addEventListener("focusout",o,!0),t.addEventListener("focusin",c,!0),t.addEventListener("focus",i,!0);let u=()=>{cancelAnimationFrame(h),t.removeEventListener("blur",r,!0),t.removeEventListener("focusout",o,!0),t.removeEventListener("focusin",c,!0),t.removeEventListener("focus",i,!0),s=!1},h=requestAnimationFrame(u);return u}function Pn(e){if(typeof window>"u"||window.navigator==null)return!1;let t=window.navigator.userAgentData?.brands;return Array.isArray(t)&&t.some(n=>e.test(n.brand))||e.test(window.navigator.userAgent)}function Bs(e){return typeof window<"u"&&window.navigator!=null?e.test(window.navigator.userAgentData?.platform||window.navigator.platform):!1}function ft(e){let t=null;return()=>(t==null&&(t=e()),t)}const En=ft(function(){return Bs(/^Mac/i)}),du=ft(function(){return Bs(/^iPhone/i)}),Xa=ft(function(){return Bs(/^iPad/i)||En()&&navigator.maxTouchPoints>1}),Ja=ft(function(){return du()||Xa()}),fu=ft(function(){return Pn(/AppleWebKit/i)&&!mu()}),mu=ft(function(){return Pn(/Chrome/i)}),Za=ft(function(){return Pn(/Android/i)}),pu=ft(function(){return Pn(/Firefox/i)});function hu(e){return e.pointerType===""&&e.isTrusted?!0:Za()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function gu(e){return!Za()&&e.width===0&&e.height===0||e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType==="mouse"}function Yt(e,t,n=!0){let{metaKey:s,ctrlKey:r,altKey:o,shiftKey:i}=t;pu()&&window.event?.type?.startsWith("key")&&e.target==="_blank"&&(En()?s=!0:r=!0);let c=fu()&&En()&&!Xa()?new KeyboardEvent("keydown",{keyIdentifier:"Enter",metaKey:s,ctrlKey:r,altKey:o,shiftKey:i}):new MouseEvent("click",{metaKey:s,ctrlKey:r,altKey:o,shiftKey:i,detail:1,bubbles:!0,cancelable:!0});Yt.isOpening=n,Gt(e),e.dispatchEvent(c),Yt.isOpening=!1}Yt.isOpening=!1;let ot=new Map,gs=new Set;function hr(){if(typeof window>"u")return;function e(s){return"propertyName"in s}let t=s=>{let r=Se(s);if(!e(s)||!r)return;let o=ot.get(r);o||(o=new Set,ot.set(r,o),r.addEventListener("transitioncancel",n,{once:!0})),o.add(s.propertyName)},n=s=>{let r=Se(s);if(!e(s)||!r)return;let o=ot.get(r);if(o&&(o.delete(s.propertyName),o.size===0&&(r.removeEventListener("transitioncancel",n),ot.delete(r)),ot.size===0)){for(let i of gs)i();gs.clear()}};document.body.addEventListener("transitionrun",t),document.body.addEventListener("transitionend",n)}typeof document<"u"&&(document.readyState!=="loading"?hr():document.addEventListener("DOMContentLoaded",hr));function bu(){for(const[e]of ot)"isConnected"in e&&!e.isConnected&&ot.delete(e)}function vu(e){requestAnimationFrame(()=>{bu(),ot.size===0?e():gs.add(e)})}function eo(...e){return(...t)=>{for(let n of e)typeof n=="function"&&n(...t)}}let bs=new Map;typeof FinalizationRegistry<"u"&&new FinalizationRegistry(e=>{bs.delete(e)});function xu(e,t){if(e===t)return e;let n=bs.get(e);if(n)return n.forEach(r=>r.current=t),t;let s=bs.get(t);return s?(s.forEach(r=>r.current=e),e):t}function yu(...e){return e.length===1&&e[0]?e[0]:t=>{let n=!1;const s=e.map(r=>{const o=gr(r,t);return n||=typeof o=="function",o});if(n)return()=>{s.forEach((r,o)=>{typeof r=="function"?r():gr(e[o],null)})}}}function gr(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function rn(...e){let t={...e[0]};for(let n=1;n<e.length;n++){let s=e[n];for(let r in s){let o=t[r],i=s[r];typeof o=="function"&&typeof i=="function"&&r[0]==="o"&&r[1]==="n"&&r.charCodeAt(2)>=65&&r.charCodeAt(2)<=90?t[r]=eo(o,i):(r==="className"||r==="UNSAFE_className")&&typeof o=="string"&&typeof i=="string"?t[r]=Ui(o,i):r==="id"&&o&&i?t.id=xu(o,i):r==="ref"&&o&&i?t.ref=yu(o,i):t[r]=i!==void 0?i:o}}return t}function wu(e,t){zs(()=>{if(e&&e.ref&&t)return e.ref.current=t.current,()=>{e.ref&&(e.ref.current=null)}})}const Su=$.useInsertionEffect??zs;function qn(e){const t=l.useRef(null);return Su(()=>{t.current=e},[e]),l.useCallback((...n)=>{const s=t.current;return s?.(...n)},[])}let Rt="default",vs="",Sn=new WeakMap;function ku(e){if(Ja()){if(Rt==="default"){const t=it(e);vs=t.documentElement.style.webkitUserSelect,t.documentElement.style.webkitUserSelect="none"}Rt="disabled"}else if(e instanceof HTMLElement||e instanceof SVGElement){let t="userSelect"in e.style?"userSelect":"webkitUserSelect";Sn.set(e,e.style[t]),e.style[t]="none"}}function br(e){if(Ja()){if(Rt!=="disabled")return;Rt="restoring",setTimeout(()=>{vu(()=>{if(Rt==="restoring"){const t=it(e);t.documentElement.style.webkitUserSelect==="none"&&(t.documentElement.style.webkitUserSelect=vs||""),vs="",Rt="default"}})},300)}else if((e instanceof HTMLElement||e instanceof SVGElement)&&e&&Sn.has(e)){let t=Sn.get(e),n="userSelect"in e.style?"userSelect":"webkitUserSelect";e.style[n]==="none"&&(e.style[n]=t),e.getAttribute("style")===""&&e.removeAttribute("style"),Sn.delete(e)}}function vr(e){return e?.defaultView?.__webpack_nonce__||globalThis.__webpack_nonce__||void 0}let Vn=new WeakMap;function Cu(e){let t=e??(typeof document<"u"?document:void 0);if(!t)return vr(t);if(Vn.has(t))return Vn.get(t);let n=t.querySelector('meta[property="csp-nonce"]'),s=n&&n instanceof ut(n).HTMLMetaElement&&(n.nonce||n.content)||vr(t)||void 0;return s!==void 0&&Vn.set(t,s),s}const to=$.createContext({register:()=>{}});to.displayName="PressResponderContext";function no(){let e=l.useRef(new Map),t=l.useCallback((r,o,i,c)=>{let u=c?.once?(...h)=>{e.current.delete(i),i(...h)}:i;e.current.set(i,{type:o,eventTarget:r,fn:u,options:c}),r.addEventListener(o,u,c)},[]),n=l.useCallback((r,o,i,c)=>{let u=e.current.get(i)?.fn||i;r.removeEventListener(o,u,c),e.current.delete(i)},[]),s=l.useCallback(()=>{e.current.forEach((r,o)=>{n(r.eventTarget,r.type,o,r.options)})},[n]);return l.useEffect(()=>s,[s]),{addGlobalListener:t,removeGlobalListener:n,removeAllGlobalListeners:s}}function Eu(e){let t=l.useContext(to);if(t){let{register:n,ref:s,...r}=t;e=rn(r,e),n()}return wu(t,e.ref),e}class mn{#e;constructor(t,n,s,r){this.#e=!0;const i=(r?.target??s.currentTarget)?.getBoundingClientRect();let c,u=0,h,m=null;s.clientX!=null&&s.clientY!=null&&(h=s.clientX,m=s.clientY),i&&(h!=null&&m!=null?(c=h-i.left,u=m-i.top):(c=i.width/2,u=i.height/2)),this.type=t,this.pointerType=n,this.target=s.currentTarget,this.shiftKey=s.shiftKey,this.metaKey=s.metaKey,this.ctrlKey=s.ctrlKey,this.altKey=s.altKey,this.x=c,this.y=u,this.key=s.key}continuePropagation(){this.#e=!1}get shouldStopPropagation(){return this.#e}}const xr=Symbol("linkClicked"),yr="react-aria-pressable-style",wr="data-react-aria-pressable";function Nu(e){let{onPress:t,onPressChange:n,onPressStart:s,onPressEnd:r,onPressUp:o,onClick:i,isDisabled:c,isPressed:u,preventFocusOnPress:h,shouldCancelOnPointerExit:m,allowTextSelectionOnPress:f,ref:p,...v}=Eu(e),[y,d]=l.useState(!1),g=l.useRef({isPressed:!1,ignoreEmulatedMouseEvents:!1,didFirePressStart:!1,isTriggeringEvent:!1,activePointerId:null,target:null,isOverTarget:!1,pointerType:null,disposables:[]}),{addGlobalListener:x,removeAllGlobalListeners:k}=no(),b=l.useCallback((S,M)=>{let O=g.current;if(c||O.didFirePressStart)return!1;let C=!0;if(O.isTriggeringEvent=!0,s){let D=new mn("pressstart",M,S);s(D),C=D.shouldStopPropagation}return n&&n(!0),O.isTriggeringEvent=!1,O.didFirePressStart=!0,d(!0),C},[c,s,n]),w=l.useCallback((S,M,O=!0)=>{let C=g.current;if(!C.didFirePressStart)return!1;C.didFirePressStart=!1,C.isTriggeringEvent=!0;let D=!0;if(r){let N=new mn("pressend",M,S);r(N),D=N.shouldStopPropagation}if(n&&n(!1),d(!1),t&&O&&!c){let N=new mn("press",M,S);t(N),D&&=N.shouldStopPropagation}return C.isTriggeringEvent=!1,D},[c,r,n,t]),E=qn(w),j=l.useCallback((S,M)=>{let O=g.current;if(c)return!1;if(o){O.isTriggeringEvent=!0;let C=new mn("pressup",M,S);return o(C),O.isTriggeringEvent=!1,C.shouldStopPropagation}return!0},[c,o]),R=qn(j),T=l.useCallback(S=>{let M=g.current;if(M.isPressed&&M.target){M.didFirePressStart&&M.pointerType!=null&&w(pt(M.target,S),M.pointerType,!1),M.isPressed=!1,M.isOverTarget=!1,M.activePointerId=null,M.pointerType=null,k(),f||br(M.target);for(let O of M.disposables)O();M.disposables=[]}},[f,k,w]),P=qn(T);l.useEffect(()=>{c&&g.current.isPressed&&P({currentTarget:g.current.target,shiftKey:!1,ctrlKey:!1,metaKey:!1,altKey:!1})},[c]);let F=l.useCallback(S=>{m&&T(S)},[m,T]),I=l.useCallback(S=>{c||i?.(S)},[c,i]),z=l.useCallback((S,M)=>{if(!c&&i){let O=new MouseEvent("click",S);cu(O,M),i(lu(O))}},[c,i]),A=l.useMemo(()=>{let S=g.current,M={onKeyDown(C){if(Qn(C.nativeEvent,C.currentTarget)&&Ge(C.currentTarget,Se(C))){Sr(Se(C),C.key)&&C.preventDefault();let D=!0;!S.isPressed&&!C.repeat&&(S.target=C.currentTarget,S.isPressed=!0,S.pointerType="keyboard",D=b(C,"keyboard"));let N=C.currentTarget,V=W=>{Qn(W,N)&&!W.repeat&&Ge(N,Se(W))&&S.target&&R(pt(S.target,W),"keyboard")};x(it(C.currentTarget),"keyup",eo(V,O),!0),D&&C.stopPropagation(),C.metaKey&&En()&&S.metaKeyEvents?.set(C.key,C.nativeEvent)}else C.key==="Meta"&&(S.metaKeyEvents=new Map)},onClick(C){if(!(C&&!Ge(C.currentTarget,Se(C)))&&C&&C.button===0&&!S.isTriggeringEvent&&!Yt.isOpening){let D=!0;if(c&&C.preventDefault(),!S.ignoreEmulatedMouseEvents&&!S.isPressed&&(S.pointerType==="virtual"||hu(C.nativeEvent))){let N=b(C,"virtual"),V=R(C,"virtual"),W=E(C,"virtual");I(C),D=N&&V&&W}else if(S.isPressed&&S.pointerType!=="keyboard"){let N=S.pointerType||C.nativeEvent.pointerType||"virtual",V=R(pt(C.currentTarget,C),N),W=E(pt(C.currentTarget,C),N,!0);D=V&&W,S.isOverTarget=!1,I(C),P(C)}S.ignoreEmulatedMouseEvents=!1,D&&C.stopPropagation()}}},O=C=>{if(S.isPressed&&S.target&&Qn(C,S.target)){Sr(Se(C),C.key)&&C.preventDefault();let D=Se(C),N=Ge(S.target,D);E(pt(S.target,C),"keyboard",N),N&&z(C,S.target),k(),C.key!=="Enter"&&Us(S.target)&&Ge(S.target,D)&&!C[xr]&&(C[xr]=!0,Yt(S.target,C,!1)),S.isPressed=!1,S.metaKeyEvents?.delete(C.key)}else if(C.key==="Meta"&&S.metaKeyEvents?.size){let D=S.metaKeyEvents;S.metaKeyEvents=void 0;for(let N of D.values())S.target?.dispatchEvent(new KeyboardEvent("keyup",N))}};if(typeof PointerEvent<"u"){M.onPointerDown=N=>{if(N.button!==0||!Ge(N.currentTarget,Se(N)))return;if(gu(N.nativeEvent)){S.pointerType="virtual";return}S.pointerType=N.pointerType;let V=!0;if(!S.isPressed){S.isPressed=!0,S.isOverTarget=!0,S.activePointerId=N.pointerId,S.target=N.currentTarget,f||ku(S.target),V=b(N,S.pointerType);let W=Se(N);"releasePointerCapture"in W&&("hasPointerCapture"in W?W.hasPointerCapture(N.pointerId)&&W.releasePointerCapture(N.pointerId):W.releasePointerCapture(N.pointerId)),x(it(N.currentTarget),"pointerup",C,!1),x(it(N.currentTarget),"pointercancel",D,!1)}V&&N.stopPropagation()},M.onMouseDown=N=>{if(Ge(N.currentTarget,Se(N))&&N.button===0){if(h){let V=uu(N.target);V&&S.disposables.push(V)}N.stopPropagation()}},M.onPointerUp=N=>{!Ge(N.currentTarget,Se(N))||S.pointerType==="virtual"||N.button===0&&!S.isPressed&&R(N,S.pointerType||N.pointerType)},M.onPointerEnter=N=>{N.pointerId===S.activePointerId&&S.target&&!S.isOverTarget&&S.pointerType!=null&&(S.isOverTarget=!0,b(pt(S.target,N),S.pointerType))},M.onPointerLeave=N=>{N.pointerId===S.activePointerId&&S.target&&S.isOverTarget&&S.pointerType!=null&&(S.isOverTarget=!1,E(pt(S.target,N),S.pointerType,!1),F(N))};let C=N=>{if(N.pointerId===S.activePointerId&&S.isPressed&&N.button===0&&S.target){if(Ge(S.target,Se(N))&&S.pointerType!=null){let V=!1,W=setTimeout(()=>{S.isPressed&&S.target instanceof HTMLElement&&(V?P(N):(Gt(S.target),S.target.click()))},80);x(N.currentTarget,"click",()=>V=!0,!0),S.disposables.push(()=>clearTimeout(W))}else P(N);S.isOverTarget=!1}},D=N=>{P(N)};M.onDragStart=N=>{Ge(N.currentTarget,Se(N))&&P(N)}}return M},[x,c,h,k,f,F,b,I,z]);return l.useEffect(()=>{if(!p)return;const S=it(p.current);if(!S||!S.head||S.getElementById(yr))return;const M=S.createElement("style");M.id=yr;let O=Cu(S);O&&(M.nonce=O),M.textContent=`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/rich-text-BjPEBAWr.js","assets/index-BvAPtXhR.js","assets/index-B9v7X7iy.css","assets/confirm-dialog-Cv7dfJpV.js","assets/search-token-index-BRBf_vfX.js","assets/search-scope-Ckwa5VkC.js","assets/useMediaQuery-WUMWXwuZ.js","assets/kbd-B_dXE-g6.js","assets/account-form-helpers-Cku237WR.js","assets/avatar-4b13Sges.js","assets/useSearchTokenContext-Ca1mZv-e.js","assets/enums-CCxx0t2v.js","assets/useSignature-CVAEV1or.js","assets/useDebouncedValue-BHLEjbFG.js","assets/ErrorState-jd3sUtw2.js","assets/format-De9HZKjg.js","assets/download-D3GqdQOq.js","assets/shield-check-Cn8BIwb9.js","assets/move-options-DoOvwIBJ.js","assets/useFilters-BoZ6Fc_g.js","assets/clock-BUUHl7WR.js","assets/menu-CtxXDmfA.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{aa as $,bQ as Ui,r as l,c as Ae,j as a,C as bt,d as Ms,X as en,b as X,B as te,az as lt,bR as Ea,a as Pt,S as At,aT as Ki,bx as Hi,am as Rn,T as tn,bS as Na,b0 as As,bT as Wi,by as ja,at as qi,al as Ds,e as Vi,f as Qi,bU as Ta,bV as Ra,a9 as Gi,bW as Yi,bX as Xi,ay as Ia,bY as Ji,bZ as Zi,b_ as el,b$ as tl,bw as nl,c0 as sl,c1 as rl,c2 as al,c3 as ol,c4 as Ps,bd as Ma,c5 as at,c6 as Aa,c7 as il,c8 as ll,q as De,ad as Me,c9 as cl,ca as ul,x as dl,w as he,b9 as In,o as Ls,W as Lt,k as fl,ab as Ye,cb as ml,cc as pl,bF as Ve,bz as hl,ae as hs,bc as gl,ac as bl,cd as vl,ce as xl,J as Ze,t as Os,v as nn,G as Da,bk as Pa,bn as La,P as Ot,cf as Mn,cg as dt,ch as yl,ci as wl,cj as Sl,ck as kl,cl as Cl,cm as El,cn as Nl,s as jl,aU as Tl,V as Rl,bg as Il,bh as Ml,co as Al,m as Dl,cp as Pl,cq as Ll,cr as An,cs as Ol,bE as $l,bK as Fl,bC as ir,ct as _l,cu as zl,b8 as Bl,R as Ul,a0 as Kl,H as Hl,bl as lr,a_ as Wl,cv as ql,cw as Vl,bj as Ql,cx as Gl,cy as Yl,n as $s,cz as Xl,cA as Jl,cB as cr,cC as Zl,cD as ec,cE as tc,cF as nc,cG as Fs,i as sc,cH as rc,cI as ac,cJ as ur,g as oc}from"./index-BvAPtXhR.js";import{B as ic,k as lc,m as cc,S as Oa,D as uc,b as dn,a as dc,e as fc,N as $a,t as Bt,f as mc,n as pc,o as hc,d as gc,u as bc,i as vc}from"./search-token-index-BRBf_vfX.js";import{K as xc}from"./kbd-B_dXE-g6.js";import{M as yc,b as wc}from"./account-form-helpers-Cku237WR.js";import{A as Qt}from"./avatar-4b13Sges.js";import{c as Sc,d as kc,e as Fa,f as Cc,M as Ec,g as _a,h as za,a as Nc,b as jc,S as dr,s as Ba,u as Ua,p as Tc,r as Rc}from"./useSearchTokenContext-Ca1mZv-e.js";import{u as Ic}from"./useSignature-CVAEV1or.js";import{u as _s}from"./useDebouncedValue-BHLEjbFG.js";import{u as Dn}from"./useMediaQuery-WUMWXwuZ.js";import{E as sn}from"./ErrorState-jd3sUtw2.js";import{e as Ka,b as $t,a as Mc,c as vt,d as Ac}from"./format-De9HZKjg.js";import{P as fr,C as Dc,D as mr,M as Je}from"./enums-CCxx0t2v.js";import{D as Pc}from"./download-D3GqdQOq.js";import{S as Lc}from"./shield-check-Cn8BIwb9.js";import{a as Ha,u as Wa,b as qa,f as Va}from"./move-options-DoOvwIBJ.js";import{h as pr,u as Oc,a as $c,i as Fc,n as _c,o as zc,j as Bc,k as Uc,S as Kc}from"./useFilters-BoZ6Fc_g.js";import{C as Hc}from"./confirm-dialog-Cv7dfJpV.js";import{C as Wc}from"./clock-BUUHl7WR.js";import{u as qc,r as Vc,b as Qc}from"./search-scope-Ckwa5VkC.js";import{M as Gc}from"./menu-CtxXDmfA.js";function Gt(e){if(Yc())e.focus({preventScroll:!0});else{let t=Xc(e);e.focus(),Jc(t)}}let fn=null;function Yc(){if(fn==null){fn=!1;try{document.createElement("div").focus({get preventScroll(){return fn=!0,!0}})}catch{}}return fn}function Xc(e){let t=e.parentNode,n=[],s=document.scrollingElement||document.documentElement;for(;t instanceof HTMLElement&&t!==s;)(t.offsetHeight<t.scrollHeight||t.offsetWidth<t.scrollWidth)&&n.push({element:t,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft}),t=t.parentNode;return s instanceof HTMLElement&&n.push({element:s,scrollTop:s.scrollTop,scrollLeft:s.scrollLeft}),n}function Jc(e){for(let{element:t,scrollTop:n,scrollLeft:s}of e)t.scrollTop=n,t.scrollLeft=s}const it=e=>e?.ownerDocument??document,ut=e=>e&&"window"in e&&e.window===e?e:it(e).defaultView||window;function Zc(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&typeof e.nodeType=="number"}function eu(e){return Zc(e)&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in e}let tu=!1;function Qa(){return tu}function Ge(e,t){if(!Qa())return t&&e?e.contains(t):!1;if(!e||!t)return!1;let n=t;for(;n!==null;){if(n===e)return!0;n.tagName==="SLOT"&&n.assignedSlot?n=n.assignedSlot.parentNode:eu(n)?n=n.host:n=n.parentNode}return!1}function Se(e){if(Qa()&&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 nu=typeof Element<"u"&&"checkVisibility"in Element.prototype;function su(e){const t=ut(e);if(!(e instanceof t.HTMLElement)&&!(e instanceof t.SVGElement))return!1;let{display:n,visibility:s}=e.style,r=n!=="none"&&s!=="hidden"&&s!=="collapse";if(r){const{getComputedStyle:o}=ut(e);let{display:i,visibility:c}=o(e);r=i!=="none"&&c!=="hidden"&&c!=="collapse"}return r}function ru(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 Ga(e,t){return nu?e.checkVisibility({visibilityProperty:!0})&&!e.closest("[data-react-aria-prevent-focus]"):e.nodeName!=="#comment"&&su(e)&&ru(e,t)&&(!e.parentElement||Ga(e.parentElement,e))}const Ya=["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"],au=Ya.join(":not([hidden]),")+",[tabindex]:not([disabled]):not([hidden])";Ya.push('[tabindex]:not([tabindex="-1"]):not([disabled])');function ou(e,t){return e.matches(au)&&!iu(e)&&(t?.skipVisibilityCheck||Ga(e))}function iu(e){let t=e;for(;t!=null;){if(t instanceof ut(t).HTMLElement&&t.inert)return!0;t=t.parentElement}return!1}const zs=typeof document<"u"?$.useLayoutEffect:()=>{};function lu(e){let t=e;return t.nativeEvent=e,t.isDefaultPrevented=()=>t.defaultPrevented,t.isPropagationStopped=()=>t.cancelBubble,t.persist=()=>{},t}function cu(e,t){Object.defineProperty(e,"target",{value:t}),Object.defineProperty(e,"currentTarget",{value:t})}function uu(e){for(;e&&!ou(e,{skipVisibilityCheck:!0});)e=e.parentElement;let t=ut(e),n=t.document.activeElement;if(!n||n===e)return;let s=!1,r=m=>{(Se(m)===n||s)&&m.stopImmediatePropagation()},o=m=>{(Se(m)===n||s)&&(m.stopImmediatePropagation(),!e&&!s&&(s=!0,Gt(n),u()))},i=m=>{(Se(m)===e||s)&&m.stopImmediatePropagation()},c=m=>{(Se(m)===e||s)&&(m.stopImmediatePropagation(),s||(s=!0,Gt(n),u()))};t.addEventListener("blur",r,!0),t.addEventListener("focusout",o,!0),t.addEventListener("focusin",c,!0),t.addEventListener("focus",i,!0);let u=()=>{cancelAnimationFrame(h),t.removeEventListener("blur",r,!0),t.removeEventListener("focusout",o,!0),t.removeEventListener("focusin",c,!0),t.removeEventListener("focus",i,!0),s=!1},h=requestAnimationFrame(u);return u}function Pn(e){if(typeof window>"u"||window.navigator==null)return!1;let t=window.navigator.userAgentData?.brands;return Array.isArray(t)&&t.some(n=>e.test(n.brand))||e.test(window.navigator.userAgent)}function Bs(e){return typeof window<"u"&&window.navigator!=null?e.test(window.navigator.userAgentData?.platform||window.navigator.platform):!1}function ft(e){let t=null;return()=>(t==null&&(t=e()),t)}const En=ft(function(){return Bs(/^Mac/i)}),du=ft(function(){return Bs(/^iPhone/i)}),Xa=ft(function(){return Bs(/^iPad/i)||En()&&navigator.maxTouchPoints>1}),Ja=ft(function(){return du()||Xa()}),fu=ft(function(){return Pn(/AppleWebKit/i)&&!mu()}),mu=ft(function(){return Pn(/Chrome/i)}),Za=ft(function(){return Pn(/Android/i)}),pu=ft(function(){return Pn(/Firefox/i)});function hu(e){return e.pointerType===""&&e.isTrusted?!0:Za()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function gu(e){return!Za()&&e.width===0&&e.height===0||e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType==="mouse"}function Yt(e,t,n=!0){let{metaKey:s,ctrlKey:r,altKey:o,shiftKey:i}=t;pu()&&window.event?.type?.startsWith("key")&&e.target==="_blank"&&(En()?s=!0:r=!0);let c=fu()&&En()&&!Xa()?new KeyboardEvent("keydown",{keyIdentifier:"Enter",metaKey:s,ctrlKey:r,altKey:o,shiftKey:i}):new MouseEvent("click",{metaKey:s,ctrlKey:r,altKey:o,shiftKey:i,detail:1,bubbles:!0,cancelable:!0});Yt.isOpening=n,Gt(e),e.dispatchEvent(c),Yt.isOpening=!1}Yt.isOpening=!1;let ot=new Map,gs=new Set;function hr(){if(typeof window>"u")return;function e(s){return"propertyName"in s}let t=s=>{let r=Se(s);if(!e(s)||!r)return;let o=ot.get(r);o||(o=new Set,ot.set(r,o),r.addEventListener("transitioncancel",n,{once:!0})),o.add(s.propertyName)},n=s=>{let r=Se(s);if(!e(s)||!r)return;let o=ot.get(r);if(o&&(o.delete(s.propertyName),o.size===0&&(r.removeEventListener("transitioncancel",n),ot.delete(r)),ot.size===0)){for(let i of gs)i();gs.clear()}};document.body.addEventListener("transitionrun",t),document.body.addEventListener("transitionend",n)}typeof document<"u"&&(document.readyState!=="loading"?hr():document.addEventListener("DOMContentLoaded",hr));function bu(){for(const[e]of ot)"isConnected"in e&&!e.isConnected&&ot.delete(e)}function vu(e){requestAnimationFrame(()=>{bu(),ot.size===0?e():gs.add(e)})}function eo(...e){return(...t)=>{for(let n of e)typeof n=="function"&&n(...t)}}let bs=new Map;typeof FinalizationRegistry<"u"&&new FinalizationRegistry(e=>{bs.delete(e)});function xu(e,t){if(e===t)return e;let n=bs.get(e);if(n)return n.forEach(r=>r.current=t),t;let s=bs.get(t);return s?(s.forEach(r=>r.current=e),e):t}function yu(...e){return e.length===1&&e[0]?e[0]:t=>{let n=!1;const s=e.map(r=>{const o=gr(r,t);return n||=typeof o=="function",o});if(n)return()=>{s.forEach((r,o)=>{typeof r=="function"?r():gr(e[o],null)})}}}function gr(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function rn(...e){let t={...e[0]};for(let n=1;n<e.length;n++){let s=e[n];for(let r in s){let o=t[r],i=s[r];typeof o=="function"&&typeof i=="function"&&r[0]==="o"&&r[1]==="n"&&r.charCodeAt(2)>=65&&r.charCodeAt(2)<=90?t[r]=eo(o,i):(r==="className"||r==="UNSAFE_className")&&typeof o=="string"&&typeof i=="string"?t[r]=Ui(o,i):r==="id"&&o&&i?t.id=xu(o,i):r==="ref"&&o&&i?t.ref=yu(o,i):t[r]=i!==void 0?i:o}}return t}function wu(e,t){zs(()=>{if(e&&e.ref&&t)return e.ref.current=t.current,()=>{e.ref&&(e.ref.current=null)}})}const Su=$.useInsertionEffect??zs;function qn(e){const t=l.useRef(null);return Su(()=>{t.current=e},[e]),l.useCallback((...n)=>{const s=t.current;return s?.(...n)},[])}let Rt="default",vs="",Sn=new WeakMap;function ku(e){if(Ja()){if(Rt==="default"){const t=it(e);vs=t.documentElement.style.webkitUserSelect,t.documentElement.style.webkitUserSelect="none"}Rt="disabled"}else if(e instanceof HTMLElement||e instanceof SVGElement){let t="userSelect"in e.style?"userSelect":"webkitUserSelect";Sn.set(e,e.style[t]),e.style[t]="none"}}function br(e){if(Ja()){if(Rt!=="disabled")return;Rt="restoring",setTimeout(()=>{vu(()=>{if(Rt==="restoring"){const t=it(e);t.documentElement.style.webkitUserSelect==="none"&&(t.documentElement.style.webkitUserSelect=vs||""),vs="",Rt="default"}})},300)}else if((e instanceof HTMLElement||e instanceof SVGElement)&&e&&Sn.has(e)){let t=Sn.get(e),n="userSelect"in e.style?"userSelect":"webkitUserSelect";e.style[n]==="none"&&(e.style[n]=t),e.getAttribute("style")===""&&e.removeAttribute("style"),Sn.delete(e)}}function vr(e){return e?.defaultView?.__webpack_nonce__||globalThis.__webpack_nonce__||void 0}let Vn=new WeakMap;function Cu(e){let t=e??(typeof document<"u"?document:void 0);if(!t)return vr(t);if(Vn.has(t))return Vn.get(t);let n=t.querySelector('meta[property="csp-nonce"]'),s=n&&n instanceof ut(n).HTMLMetaElement&&(n.nonce||n.content)||vr(t)||void 0;return s!==void 0&&Vn.set(t,s),s}const to=$.createContext({register:()=>{}});to.displayName="PressResponderContext";function no(){let e=l.useRef(new Map),t=l.useCallback((r,o,i,c)=>{let u=c?.once?(...h)=>{e.current.delete(i),i(...h)}:i;e.current.set(i,{type:o,eventTarget:r,fn:u,options:c}),r.addEventListener(o,u,c)},[]),n=l.useCallback((r,o,i,c)=>{let u=e.current.get(i)?.fn||i;r.removeEventListener(o,u,c),e.current.delete(i)},[]),s=l.useCallback(()=>{e.current.forEach((r,o)=>{n(r.eventTarget,r.type,o,r.options)})},[n]);return l.useEffect(()=>s,[s]),{addGlobalListener:t,removeGlobalListener:n,removeAllGlobalListeners:s}}function Eu(e){let t=l.useContext(to);if(t){let{register:n,ref:s,...r}=t;e=rn(r,e),n()}return wu(t,e.ref),e}class mn{#e;constructor(t,n,s,r){this.#e=!0;const i=(r?.target??s.currentTarget)?.getBoundingClientRect();let c,u=0,h,m=null;s.clientX!=null&&s.clientY!=null&&(h=s.clientX,m=s.clientY),i&&(h!=null&&m!=null?(c=h-i.left,u=m-i.top):(c=i.width/2,u=i.height/2)),this.type=t,this.pointerType=n,this.target=s.currentTarget,this.shiftKey=s.shiftKey,this.metaKey=s.metaKey,this.ctrlKey=s.ctrlKey,this.altKey=s.altKey,this.x=c,this.y=u,this.key=s.key}continuePropagation(){this.#e=!1}get shouldStopPropagation(){return this.#e}}const xr=Symbol("linkClicked"),yr="react-aria-pressable-style",wr="data-react-aria-pressable";function Nu(e){let{onPress:t,onPressChange:n,onPressStart:s,onPressEnd:r,onPressUp:o,onClick:i,isDisabled:c,isPressed:u,preventFocusOnPress:h,shouldCancelOnPointerExit:m,allowTextSelectionOnPress:f,ref:p,...v}=Eu(e),[y,d]=l.useState(!1),g=l.useRef({isPressed:!1,ignoreEmulatedMouseEvents:!1,didFirePressStart:!1,isTriggeringEvent:!1,activePointerId:null,target:null,isOverTarget:!1,pointerType:null,disposables:[]}),{addGlobalListener:x,removeAllGlobalListeners:k}=no(),b=l.useCallback((S,M)=>{let O=g.current;if(c||O.didFirePressStart)return!1;let C=!0;if(O.isTriggeringEvent=!0,s){let D=new mn("pressstart",M,S);s(D),C=D.shouldStopPropagation}return n&&n(!0),O.isTriggeringEvent=!1,O.didFirePressStart=!0,d(!0),C},[c,s,n]),w=l.useCallback((S,M,O=!0)=>{let C=g.current;if(!C.didFirePressStart)return!1;C.didFirePressStart=!1,C.isTriggeringEvent=!0;let D=!0;if(r){let N=new mn("pressend",M,S);r(N),D=N.shouldStopPropagation}if(n&&n(!1),d(!1),t&&O&&!c){let N=new mn("press",M,S);t(N),D&&=N.shouldStopPropagation}return C.isTriggeringEvent=!1,D},[c,r,n,t]),E=qn(w),j=l.useCallback((S,M)=>{let O=g.current;if(c)return!1;if(o){O.isTriggeringEvent=!0;let C=new mn("pressup",M,S);return o(C),O.isTriggeringEvent=!1,C.shouldStopPropagation}return!0},[c,o]),R=qn(j),T=l.useCallback(S=>{let M=g.current;if(M.isPressed&&M.target){M.didFirePressStart&&M.pointerType!=null&&w(pt(M.target,S),M.pointerType,!1),M.isPressed=!1,M.isOverTarget=!1,M.activePointerId=null,M.pointerType=null,k(),f||br(M.target);for(let O of M.disposables)O();M.disposables=[]}},[f,k,w]),P=qn(T);l.useEffect(()=>{c&&g.current.isPressed&&P({currentTarget:g.current.target,shiftKey:!1,ctrlKey:!1,metaKey:!1,altKey:!1})},[c]);let F=l.useCallback(S=>{m&&T(S)},[m,T]),I=l.useCallback(S=>{c||i?.(S)},[c,i]),z=l.useCallback((S,M)=>{if(!c&&i){let O=new MouseEvent("click",S);cu(O,M),i(lu(O))}},[c,i]),A=l.useMemo(()=>{let S=g.current,M={onKeyDown(C){if(Qn(C.nativeEvent,C.currentTarget)&&Ge(C.currentTarget,Se(C))){Sr(Se(C),C.key)&&C.preventDefault();let D=!0;!S.isPressed&&!C.repeat&&(S.target=C.currentTarget,S.isPressed=!0,S.pointerType="keyboard",D=b(C,"keyboard"));let N=C.currentTarget,V=W=>{Qn(W,N)&&!W.repeat&&Ge(N,Se(W))&&S.target&&R(pt(S.target,W),"keyboard")};x(it(C.currentTarget),"keyup",eo(V,O),!0),D&&C.stopPropagation(),C.metaKey&&En()&&S.metaKeyEvents?.set(C.key,C.nativeEvent)}else C.key==="Meta"&&(S.metaKeyEvents=new Map)},onClick(C){if(!(C&&!Ge(C.currentTarget,Se(C)))&&C&&C.button===0&&!S.isTriggeringEvent&&!Yt.isOpening){let D=!0;if(c&&C.preventDefault(),!S.ignoreEmulatedMouseEvents&&!S.isPressed&&(S.pointerType==="virtual"||hu(C.nativeEvent))){let N=b(C,"virtual"),V=R(C,"virtual"),W=E(C,"virtual");I(C),D=N&&V&&W}else if(S.isPressed&&S.pointerType!=="keyboard"){let N=S.pointerType||C.nativeEvent.pointerType||"virtual",V=R(pt(C.currentTarget,C),N),W=E(pt(C.currentTarget,C),N,!0);D=V&&W,S.isOverTarget=!1,I(C),P(C)}S.ignoreEmulatedMouseEvents=!1,D&&C.stopPropagation()}}},O=C=>{if(S.isPressed&&S.target&&Qn(C,S.target)){Sr(Se(C),C.key)&&C.preventDefault();let D=Se(C),N=Ge(S.target,D);E(pt(S.target,C),"keyboard",N),N&&z(C,S.target),k(),C.key!=="Enter"&&Us(S.target)&&Ge(S.target,D)&&!C[xr]&&(C[xr]=!0,Yt(S.target,C,!1)),S.isPressed=!1,S.metaKeyEvents?.delete(C.key)}else if(C.key==="Meta"&&S.metaKeyEvents?.size){let D=S.metaKeyEvents;S.metaKeyEvents=void 0;for(let N of D.values())S.target?.dispatchEvent(new KeyboardEvent("keyup",N))}};if(typeof PointerEvent<"u"){M.onPointerDown=N=>{if(N.button!==0||!Ge(N.currentTarget,Se(N)))return;if(gu(N.nativeEvent)){S.pointerType="virtual";return}S.pointerType=N.pointerType;let V=!0;if(!S.isPressed){S.isPressed=!0,S.isOverTarget=!0,S.activePointerId=N.pointerId,S.target=N.currentTarget,f||ku(S.target),V=b(N,S.pointerType);let W=Se(N);"releasePointerCapture"in W&&("hasPointerCapture"in W?W.hasPointerCapture(N.pointerId)&&W.releasePointerCapture(N.pointerId):W.releasePointerCapture(N.pointerId)),x(it(N.currentTarget),"pointerup",C,!1),x(it(N.currentTarget),"pointercancel",D,!1)}V&&N.stopPropagation()},M.onMouseDown=N=>{if(Ge(N.currentTarget,Se(N))&&N.button===0){if(h){let V=uu(N.target);V&&S.disposables.push(V)}N.stopPropagation()}},M.onPointerUp=N=>{!Ge(N.currentTarget,Se(N))||S.pointerType==="virtual"||N.button===0&&!S.isPressed&&R(N,S.pointerType||N.pointerType)},M.onPointerEnter=N=>{N.pointerId===S.activePointerId&&S.target&&!S.isOverTarget&&S.pointerType!=null&&(S.isOverTarget=!0,b(pt(S.target,N),S.pointerType))},M.onPointerLeave=N=>{N.pointerId===S.activePointerId&&S.target&&S.isOverTarget&&S.pointerType!=null&&(S.isOverTarget=!1,E(pt(S.target,N),S.pointerType,!1),F(N))};let C=N=>{if(N.pointerId===S.activePointerId&&S.isPressed&&N.button===0&&S.target){if(Ge(S.target,Se(N))&&S.pointerType!=null){let V=!1,W=setTimeout(()=>{S.isPressed&&S.target instanceof HTMLElement&&(V?P(N):(Gt(S.target),S.target.click()))},80);x(N.currentTarget,"click",()=>V=!0,!0),S.disposables.push(()=>clearTimeout(W))}else P(N);S.isOverTarget=!1}},D=N=>{P(N)};M.onDragStart=N=>{Ge(N.currentTarget,Se(N))&&P(N)}}return M},[x,c,h,k,f,F,b,I,z]);return l.useEffect(()=>{if(!p)return;const S=it(p.current);if(!S||!S.head||S.getElementById(yr))return;const M=S.createElement("style");M.id=yr;let O=Cu(S);O&&(M.nonce=O),M.textContent=`
|
|
3
3
|
@layer {
|
|
4
4
|
[${wr}] {
|
|
5
5
|
touch-action: pan-x pan-y pinch-zoom;
|
|
@@ -46,7 +46,7 @@ import{aa as $,bQ as Ui,r as l,c as Ae,j as a,C as bt,d as Ms,X as en,b as X,B a
|
|
|
46
46
|
`)},Xr=function(){var e=parseInt(document.body.getAttribute(Mt)||"0",10);return isFinite(e)?e:0},Bm=function(){l.useEffect(function(){return document.body.setAttribute(Mt,(Xr()+1).toString()),function(){var e=Xr()-1;e<=0?document.body.removeAttribute(Mt):document.body.setAttribute(Mt,e.toString())}},[])},Um=function(e){var t=e.noRelative,n=e.noImportant,s=e.gapMode,r=s===void 0?"margin":s;Bm();var o=l.useMemo(function(){return Fm(r)},[r]);return l.createElement(_m,{styles:zm(o,!t,r,n?"":"!important")})},ks=!1;if(typeof window<"u")try{var vn=Object.defineProperty({},"passive",{get:function(){return ks=!0,!0}});window.addEventListener("test",vn,vn),window.removeEventListener("test",vn,vn)}catch{ks=!1}var Nt=ks?{passive:!1}:!1,Km=function(e){return e.tagName==="TEXTAREA"},Fo=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Km(e)&&n[t]==="visible")},Hm=function(e){return Fo(e,"overflowY")},Wm=function(e){return Fo(e,"overflowX")},Jr=function(e,t){var n=t.ownerDocument,s=t;do{typeof ShadowRoot<"u"&&s instanceof ShadowRoot&&(s=s.host);var r=_o(e,s);if(r){var o=zo(e,s),i=o[1],c=o[2];if(i>c)return!0}s=s.parentNode}while(s&&s!==n.body);return!1},qm=function(e){var t=e.scrollTop,n=e.scrollHeight,s=e.clientHeight;return[t,n,s]},Vm=function(e){var t=e.scrollLeft,n=e.scrollWidth,s=e.clientWidth;return[t,n,s]},_o=function(e,t){return e==="v"?Hm(t):Wm(t)},zo=function(e,t){return e==="v"?qm(t):Vm(t)},Qm=function(e,t){return e==="h"&&t==="rtl"?-1:1},Gm=function(e,t,n,s,r){var o=Qm(e,window.getComputedStyle(t).direction),i=o*s,c=n.target,u=t.contains(c),h=!1,m=i>0,f=0,p=0;do{if(!c)break;var v=zo(e,c),y=v[0],d=v[1],g=v[2],x=d-g-o*y;(y||x)&&_o(e,c)&&(f+=x,p+=y);var k=c.parentNode;c=k&&k.nodeType===Node.DOCUMENT_FRAGMENT_NODE?k.host:k}while(!u&&c!==document.body||u&&(t.contains(c)||t===c));return(m&&Math.abs(f)<1||!m&&Math.abs(p)<1)&&(h=!0),h},xn=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Zr=function(e){return[e.deltaX,e.deltaY]},ea=function(e){return e&&"current"in e?e.current:e},Ym=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Xm=function(e){return`
|
|
47
47
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
48
48
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
49
|
-
`)},Jm=0,jt=[];function Zm(e){var t=l.useRef([]),n=l.useRef([0,0]),s=l.useRef(),r=l.useState(Jm++)[0],o=l.useState($o)[0],i=l.useRef(e);l.useEffect(function(){i.current=e},[e]),l.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(r));var d=il([e.lockRef.current],(e.shards||[]).map(ea),!0).filter(Boolean);return d.forEach(function(g){return g.classList.add("allow-interactivity-".concat(r))}),function(){document.body.classList.remove("block-interactivity-".concat(r)),d.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(r))})}}},[e.inert,e.lockRef.current,e.shards]);var c=l.useCallback(function(d,g){if("touches"in d&&d.touches.length===2||d.type==="wheel"&&d.ctrlKey)return!i.current.allowPinchZoom;var x=xn(d),k=n.current,b="deltaX"in d?d.deltaX:k[0]-x[0],w="deltaY"in d?d.deltaY:k[1]-x[1],E,j=d.target,R=Math.abs(b)>Math.abs(w)?"h":"v";if("touches"in d&&R==="h"&&j.type==="range")return!1;var T=window.getSelection(),P=T&&T.anchorNode,F=P?P===j||P.contains(j):!1;if(F)return!1;var I=Jr(R,j);if(!I)return!0;if(I?E=R:(E=R==="v"?"h":"v",I=Jr(R,j)),!I)return!1;if(!s.current&&"changedTouches"in d&&(b||w)&&(s.current=E),!E)return!0;var z=s.current||E;return Gm(z,g,d,z==="h"?b:w)},[]),u=l.useCallback(function(d){var g=d;if(!(!jt.length||jt[jt.length-1]!==o)){var x="deltaY"in g?Zr(g):xn(g),k=t.current.filter(function(E){return E.name===g.type&&(E.target===g.target||g.target===E.shadowParent)&&Ym(E.delta,x)})[0];if(k&&k.should){g.cancelable&&g.preventDefault();return}if(!k){var b=(i.current.shards||[]).map(ea).filter(Boolean).filter(function(E){return E.contains(g.target)}),w=b.length>0?c(g,b[0]):!i.current.noIsolation;w&&g.cancelable&&g.preventDefault()}}},[]),h=l.useCallback(function(d,g,x,k){var b={name:d,delta:g,target:x,should:k,shadowParent:ep(x)};t.current.push(b),setTimeout(function(){t.current=t.current.filter(function(w){return w!==b})},1)},[]),m=l.useCallback(function(d){n.current=xn(d),s.current=void 0},[]),f=l.useCallback(function(d){h(d.type,Zr(d),d.target,c(d,e.lockRef.current))},[]),p=l.useCallback(function(d){h(d.type,xn(d),d.target,c(d,e.lockRef.current))},[]);l.useEffect(function(){return jt.push(o),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:p}),document.addEventListener("wheel",u,Nt),document.addEventListener("touchmove",u,Nt),document.addEventListener("touchstart",m,Nt),function(){jt=jt.filter(function(d){return d!==o}),document.removeEventListener("wheel",u,Nt),document.removeEventListener("touchmove",u,Nt),document.removeEventListener("touchstart",m,Nt)}},[]);var v=e.removeScrollBar,y=e.inert;return l.createElement(l.Fragment,null,y?l.createElement(o,{styles:Xm(r)}):null,v?l.createElement(Um,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function ep(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const tp=Rm(Oo,Zm);var Bo=l.forwardRef(function(e,t){return l.createElement(zn,at({},e,{ref:t,sideCar:tp}))});Bo.classNames=zn.classNames;function np(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 n=!!(e.condition??!0),s=e.blockerFn;return{shouldBlockFn:async()=>n&&s!==void 0?await s():n,enableBeforeUnload:n,withResolver:s===void 0}}function sp(e,t){const{shouldBlockFn:n,enableBeforeUnload:s=!0,disabled:r=!1,withResolver:o=!1}=np(e),i=ll(),{history:c}=i,[u,h]=l.useState({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0});return l.useEffect(()=>{const m=async f=>{function p(x){const k=i.parseLocation(x),b=i.getMatchedRoutes(k.pathname);return b.foundRoute===void 0?{routeId:"__notFound__",fullPath:k.pathname,pathname:k.pathname,params:b.routeParams,search:i.options.parseSearch(x.search)}:{routeId:b.foundRoute.id,fullPath:b.foundRoute.fullPath,pathname:k.pathname,params:b.routeParams,search:i.options.parseSearch(x.search)}}const v=p(f.currentLocation),y=p(f.nextLocation);if(v.routeId==="__notFound__"&&y.routeId!=="__notFound__")return!1;const d=await n({action:f.action,current:v,next:y});if(!o)return d;if(!d)return!1;const g=await new Promise(x=>{h({status:"blocked",current:v,next:y,action:f.action,proceed:()=>x(!1),reset:()=>x(!0)})});return h({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0}),g};return r?void 0:c.block({blockerFn:m,enableBeforeUnload:s})},[n,s,r,o,c,i]),u}const rp=e=>e.then(()=>{},()=>{}),ap=({outboxMessageId:e,onDraftCreated:t})=>{const[n,s]=l.useState("idle"),[r,o]=l.useState(null),i=l.useRef(void 0),c=l.useRef(new Set),u=De(),h=l.useRef(e),m=l.useRef(e);h.current!==e&&(h.current=e,m.current=e);const f=Me(cl()),p=Me(ul()),v=l.useCallback(async b=>{s("saving"),o(null);const w=m.current;if(w){const j=await p.mutateAsync({path:{outboxMessageId:w},body:{toAddresses:b.toAddresses,ccAddresses:b.ccAddresses,bccAddresses:b.bccAddresses,subject:b.subject,textBody:b.textBody,htmlBody:b.htmlBody,inReplyTo:b.inReplyTo,references:b.references}});return s("saved"),j}const E=await f.mutateAsync({body:{...b,sendImmediately:!1}});return m.current=E.outboxMessageId,t(E.outboxMessageId),s("saved"),u.invalidateQueries({queryKey:dl().queryKey}),E},[f,p,t,u]),y=l.useRef(Promise.resolve()),d=l.useCallback(b=>{const w=y.current.then(()=>v(b));return y.current=rp(w),w},[v]),g=l.useCallback(b=>{i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{const w=m.current;w&&c.current.has(w)||d(b).catch(E=>{o(E),s("error")})},2e3)},[d]),x=l.useCallback(b=>(i.current&&clearTimeout(i.current),d(b).then(w=>({outcome:"saved",outboxMessageId:w.outboxMessageId})).catch(w=>(s("error"),{outcome:"failed",error:w}))),[d]),k=l.useCallback(b=>{i.current&&clearTimeout(i.current),b&&c.current.add(b)},[]);return{saveStatus:n,saveError:r,saveDraft:g,saveImmediately:x,stopAutoSave:k}},os=({label:e,addresses:t,onChange:n,placeholder:s})=>{const[r,o]=l.useState(""),i=_s(r,200),{data:c}=he({...In({query:{q:i,limit:8}}),enabled:i.length>=2}),u=l.useMemo(()=>(c?.items??[]).map(h=>({email:h.normalizedEmail,displayName:h.displayName})),[c]);return a.jsx(Cd,{label:e,addresses:t,onChange:n,placeholder:s,suggestions:u,onQueryChange:o})},op=({accountId:e,configureRef:t})=>{const n=Ls();return a.jsx(Rd,{configureRef:t,onConfigure:()=>{n({to:"/settings/accounts",search:{editAccountId:e,focusSmtp:!0}})}})},ta=150,ip=()=>{const[e,t]=l.useState(()=>{if(typeof window>"u"||!window.visualViewport)return{viewportHeight:0,isKeyboardOpen:!1};const n=window.visualViewport.height;return{viewportHeight:n,isKeyboardOpen:window.innerHeight-n>ta}});return l.useEffect(()=>{if(typeof window>"u"||!window.visualViewport)return;const n=window.visualViewport,s=()=>{const r=n.height;t({viewportHeight:r,isKeyboardOpen:window.innerHeight-r>ta})};return s(),n.addEventListener("resize",s),()=>n.removeEventListener("resize",s)},[]),e},lp=({selectedAccountId:e,onSelect:t})=>{const{data:n}=he({...Lt(),staleTime:1/0}),s=n?.accounts??[];if(l.useEffect(()=>{!e&&s.length===1&&s[0]&&t(s[0])},[e,s,t]),s.length<=1){const r=s[0];return r?a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx("label",{className:"text-sm text-fg-muted shrink-0 w-12 pt-1.5",children:"From:"}),a.jsx("div",{className:"text-sm py-1.5",children:r.email})]}):null}return a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx("label",{htmlFor:"from-account-selector",className:"text-sm text-fg-muted shrink-0 w-12 pt-1.5",children:"From:"}),a.jsx("select",{id:"from-account-selector",value:e??"",onChange:r=>{const o=s.find(i=>i.accountId===r.target.value);o&&t(o)},className:"flex-1 px-2 py-1.5 border rounded-md bg-canvas text-sm",children:s.map(r=>a.jsx("option",{value:r.accountId,children:r.email},r.accountId))})]})},cp=l.lazy(()=>xl(()=>import("./rich-text-
|
|
49
|
+
`)},Jm=0,jt=[];function Zm(e){var t=l.useRef([]),n=l.useRef([0,0]),s=l.useRef(),r=l.useState(Jm++)[0],o=l.useState($o)[0],i=l.useRef(e);l.useEffect(function(){i.current=e},[e]),l.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(r));var d=il([e.lockRef.current],(e.shards||[]).map(ea),!0).filter(Boolean);return d.forEach(function(g){return g.classList.add("allow-interactivity-".concat(r))}),function(){document.body.classList.remove("block-interactivity-".concat(r)),d.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(r))})}}},[e.inert,e.lockRef.current,e.shards]);var c=l.useCallback(function(d,g){if("touches"in d&&d.touches.length===2||d.type==="wheel"&&d.ctrlKey)return!i.current.allowPinchZoom;var x=xn(d),k=n.current,b="deltaX"in d?d.deltaX:k[0]-x[0],w="deltaY"in d?d.deltaY:k[1]-x[1],E,j=d.target,R=Math.abs(b)>Math.abs(w)?"h":"v";if("touches"in d&&R==="h"&&j.type==="range")return!1;var T=window.getSelection(),P=T&&T.anchorNode,F=P?P===j||P.contains(j):!1;if(F)return!1;var I=Jr(R,j);if(!I)return!0;if(I?E=R:(E=R==="v"?"h":"v",I=Jr(R,j)),!I)return!1;if(!s.current&&"changedTouches"in d&&(b||w)&&(s.current=E),!E)return!0;var z=s.current||E;return Gm(z,g,d,z==="h"?b:w)},[]),u=l.useCallback(function(d){var g=d;if(!(!jt.length||jt[jt.length-1]!==o)){var x="deltaY"in g?Zr(g):xn(g),k=t.current.filter(function(E){return E.name===g.type&&(E.target===g.target||g.target===E.shadowParent)&&Ym(E.delta,x)})[0];if(k&&k.should){g.cancelable&&g.preventDefault();return}if(!k){var b=(i.current.shards||[]).map(ea).filter(Boolean).filter(function(E){return E.contains(g.target)}),w=b.length>0?c(g,b[0]):!i.current.noIsolation;w&&g.cancelable&&g.preventDefault()}}},[]),h=l.useCallback(function(d,g,x,k){var b={name:d,delta:g,target:x,should:k,shadowParent:ep(x)};t.current.push(b),setTimeout(function(){t.current=t.current.filter(function(w){return w!==b})},1)},[]),m=l.useCallback(function(d){n.current=xn(d),s.current=void 0},[]),f=l.useCallback(function(d){h(d.type,Zr(d),d.target,c(d,e.lockRef.current))},[]),p=l.useCallback(function(d){h(d.type,xn(d),d.target,c(d,e.lockRef.current))},[]);l.useEffect(function(){return jt.push(o),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:p}),document.addEventListener("wheel",u,Nt),document.addEventListener("touchmove",u,Nt),document.addEventListener("touchstart",m,Nt),function(){jt=jt.filter(function(d){return d!==o}),document.removeEventListener("wheel",u,Nt),document.removeEventListener("touchmove",u,Nt),document.removeEventListener("touchstart",m,Nt)}},[]);var v=e.removeScrollBar,y=e.inert;return l.createElement(l.Fragment,null,y?l.createElement(o,{styles:Xm(r)}):null,v?l.createElement(Um,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function ep(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const tp=Rm(Oo,Zm);var Bo=l.forwardRef(function(e,t){return l.createElement(zn,at({},e,{ref:t,sideCar:tp}))});Bo.classNames=zn.classNames;function np(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 n=!!(e.condition??!0),s=e.blockerFn;return{shouldBlockFn:async()=>n&&s!==void 0?await s():n,enableBeforeUnload:n,withResolver:s===void 0}}function sp(e,t){const{shouldBlockFn:n,enableBeforeUnload:s=!0,disabled:r=!1,withResolver:o=!1}=np(e),i=ll(),{history:c}=i,[u,h]=l.useState({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0});return l.useEffect(()=>{const m=async f=>{function p(x){const k=i.parseLocation(x),b=i.getMatchedRoutes(k.pathname);return b.foundRoute===void 0?{routeId:"__notFound__",fullPath:k.pathname,pathname:k.pathname,params:b.routeParams,search:i.options.parseSearch(x.search)}:{routeId:b.foundRoute.id,fullPath:b.foundRoute.fullPath,pathname:k.pathname,params:b.routeParams,search:i.options.parseSearch(x.search)}}const v=p(f.currentLocation),y=p(f.nextLocation);if(v.routeId==="__notFound__"&&y.routeId!=="__notFound__")return!1;const d=await n({action:f.action,current:v,next:y});if(!o)return d;if(!d)return!1;const g=await new Promise(x=>{h({status:"blocked",current:v,next:y,action:f.action,proceed:()=>x(!1),reset:()=>x(!0)})});return h({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0}),g};return r?void 0:c.block({blockerFn:m,enableBeforeUnload:s})},[n,s,r,o,c,i]),u}const rp=e=>e.then(()=>{},()=>{}),ap=({outboxMessageId:e,onDraftCreated:t})=>{const[n,s]=l.useState("idle"),[r,o]=l.useState(null),i=l.useRef(void 0),c=l.useRef(new Set),u=De(),h=l.useRef(e),m=l.useRef(e);h.current!==e&&(h.current=e,m.current=e);const f=Me(cl()),p=Me(ul()),v=l.useCallback(async b=>{s("saving"),o(null);const w=m.current;if(w){const j=await p.mutateAsync({path:{outboxMessageId:w},body:{toAddresses:b.toAddresses,ccAddresses:b.ccAddresses,bccAddresses:b.bccAddresses,subject:b.subject,textBody:b.textBody,htmlBody:b.htmlBody,inReplyTo:b.inReplyTo,references:b.references}});return s("saved"),j}const E=await f.mutateAsync({body:{...b,sendImmediately:!1}});return m.current=E.outboxMessageId,t(E.outboxMessageId),s("saved"),u.invalidateQueries({queryKey:dl().queryKey}),E},[f,p,t,u]),y=l.useRef(Promise.resolve()),d=l.useCallback(b=>{const w=y.current.then(()=>v(b));return y.current=rp(w),w},[v]),g=l.useCallback(b=>{i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{const w=m.current;w&&c.current.has(w)||d(b).catch(E=>{o(E),s("error")})},2e3)},[d]),x=l.useCallback(b=>(i.current&&clearTimeout(i.current),d(b).then(w=>({outcome:"saved",outboxMessageId:w.outboxMessageId})).catch(w=>(s("error"),{outcome:"failed",error:w}))),[d]),k=l.useCallback(b=>{i.current&&clearTimeout(i.current),b&&c.current.add(b)},[]);return{saveStatus:n,saveError:r,saveDraft:g,saveImmediately:x,stopAutoSave:k}},os=({label:e,addresses:t,onChange:n,placeholder:s})=>{const[r,o]=l.useState(""),i=_s(r,200),{data:c}=he({...In({query:{q:i,limit:8}}),enabled:i.length>=2}),u=l.useMemo(()=>(c?.items??[]).map(h=>({email:h.normalizedEmail,displayName:h.displayName})),[c]);return a.jsx(Cd,{label:e,addresses:t,onChange:n,placeholder:s,suggestions:u,onQueryChange:o})},op=({accountId:e,configureRef:t})=>{const n=Ls();return a.jsx(Rd,{configureRef:t,onConfigure:()=>{n({to:"/settings/accounts",search:{editAccountId:e,focusSmtp:!0}})}})},ta=150,ip=()=>{const[e,t]=l.useState(()=>{if(typeof window>"u"||!window.visualViewport)return{viewportHeight:0,isKeyboardOpen:!1};const n=window.visualViewport.height;return{viewportHeight:n,isKeyboardOpen:window.innerHeight-n>ta}});return l.useEffect(()=>{if(typeof window>"u"||!window.visualViewport)return;const n=window.visualViewport,s=()=>{const r=n.height;t({viewportHeight:r,isKeyboardOpen:window.innerHeight-r>ta})};return s(),n.addEventListener("resize",s),()=>n.removeEventListener("resize",s)},[]),e},lp=({selectedAccountId:e,onSelect:t})=>{const{data:n}=he({...Lt(),staleTime:1/0}),s=n?.accounts??[];if(l.useEffect(()=>{!e&&s.length===1&&s[0]&&t(s[0])},[e,s,t]),s.length<=1){const r=s[0];return r?a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx("label",{className:"text-sm text-fg-muted shrink-0 w-12 pt-1.5",children:"From:"}),a.jsx("div",{className:"text-sm py-1.5",children:r.email})]}):null}return a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx("label",{htmlFor:"from-account-selector",className:"text-sm text-fg-muted shrink-0 w-12 pt-1.5",children:"From:"}),a.jsx("select",{id:"from-account-selector",value:e??"",onChange:r=>{const o=s.find(i=>i.accountId===r.target.value);o&&t(o)},className:"flex-1 px-2 py-1.5 border rounded-md bg-canvas text-sm",children:s.map(r=>a.jsx("option",{value:r.accountId,children:r.email},r.accountId))})]})},cp=l.lazy(()=>xl(()=>import("./rich-text-BjPEBAWr.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21])).then(e=>({default:e.ComposeBody}))),up=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),dp=e=>e.split(`
|
|
50
50
|
`).map(t=>`<p>${up(t)}</p>`).join(""),na=e=>e?`<p></p><p>-- </p>${dp(e)}`:"",fp=e=>e?/^re:\s/i.test(e)?e:`Re: ${e}`:"Re: ",mp=e=>e?/^fwd?:\s/i.test(e)?e:`Fwd: ${e}`:"Fwd: ",pp=(e,t,n)=>{const{envelope:s}=e,o=(s.replyTo.length>0?s.replyTo:s.from).map(h=>({email:h.normalizedEmail,displayName:h.displayName}));if(t!=="reply_all")return{to:o,cc:[]};const i=n?.toLowerCase(),c=new Set(o.map(h=>h.email.toLowerCase())),u=[...s.to,...s.cc].filter(h=>h.normalizedEmail.toLowerCase()!==i&&!c.has(h.normalizedEmail.toLowerCase())).map(h=>({email:h.normalizedEmail,displayName:h.displayName}));return{to:o,cc:u}},hp=e=>{const t=e.envelope.messageIdValue,s=[...e.references.filter(r=>r.referenceType==="references").sort((r,o)=>r.referenceOrder-o.referenceOrder).map(r=>r.messageIdValue)];return t&&!s.includes(t)&&s.push(t),{inReplyTo:t,references:s}},sa=(e,t,n)=>({textBody:t.text||void 0,htmlBody:e==="plain"?"":t.html?vl(t.html,n):void 0}),gp=(e,t,n,s,r)=>e.length===0&&t.length===0&&n.length===0&&s.trim()===""&&r.text.trim()==="",bp=({documentGeneration:e,selectedAccountId:t,onAccountChange:n,toAddresses:s,setToAddresses:r,ccAddresses:o,setCcAddresses:i,bccAddresses:c,setBccAddresses:u,showCc:h,setShowCc:m,showBcc:f,setShowBcc:p,subject:v,setSubject:y})=>{const d=Dn(),{isKeyboardOpen:g}=ip(),[x,k]=l.useState(void 0),b=x===e;return a.jsx(Td,{collapsed:!d&&g&&!b,onExpand:()=>k(e),summary:jd({to:s,cc:o,bcc:c,subject:v}),from:a.jsx(lp,{selectedAccountId:t,onSelect:n}),to:a.jsx(os,{label:"To",addresses:s,onChange:r,placeholder:"Recipients"}),cc:h?a.jsx(os,{label:"Cc",addresses:o,onChange:i}):void 0,bcc:f?a.jsx(os,{label:"Bcc",addresses:c,onChange:u}):void 0,subject:a.jsx(Id,{value:v,onChange:y}),onShowCc:()=>m(!0),onShowBcc:()=>p(!0)})},vp=({mode:e,account:t,sourceMessage:n,onClose:s,onAccountChange:r})=>{const{state:o,setOutboxMessageId:i,startSendPolling:c}=fl(),{pushError:u}=Ye(),{outboxMessageId:h}=o,[m,f]=l.useState([]),[p,v]=l.useState([]),[y,d]=l.useState([]),[g,x]=l.useState(""),[k,b]=l.useState(!1),[w,E]=l.useState(!1),[j,R]=l.useState(t?.accountId),[T,P]=l.useState(!1),F=l.useRef(null),I=l.useRef(h);l.useEffect(()=>{const ee=I.current;ee!==h&&(I.current=h,!(!h||ee===void 0)&&(f([]),v([]),d([]),x(""),b(!1),E(!1),O(""),D(""),V("rich"),de(void 0),ge(Bd),S(we=>we+1),P(!1)))},[h]);const{signature:z}=Ic(j),[A,S]=l.useState(0),[M,O]=l.useState(()=>na(z.plainText)),[C,D]=l.useState(z.plainText),[N,V]=l.useState("rich"),[W,re]=l.useState("en"),[ne,de]=l.useState(),[se,ge]=l.useState(()=>({html:na(z.plainText),text:z.plainText,formatting:[]})),{data:q}=he({...ml({path:{outboxMessageId:h??""}}),enabled:!!h&&!T});l.useEffect(()=>{if(!q||T)return;f(q.toAddresses.map(_=>({email:_,displayName:void 0}))),q.ccAddresses&&q.ccAddresses.length>0&&(v(q.ccAddresses.map(_=>({email:_,displayName:void 0}))),b(!0)),q.bccAddresses&&q.bccAddresses.length>0&&(d(q.bccAddresses.map(_=>({email:_,displayName:void 0}))),E(!0)),q.subject&&x(q.subject);const ee=pl(q.htmlBody??""),we=ee.html,me=q.textBody??"";V(Zd(q.htmlBody)),de(ee.language??void 0),O(we),D(me),ge({html:we,text:me,formatting:[]}),S(_=>_+1),R(q.accountId),P(!0)},[q,T]),l.useEffect(()=>{if(n){if(e==="reply"||e==="reply_all"){const{to:ee,cc:we}=pp(n,e,t?.email);f(ee),v(we),we.length>0&&b(!0),x(fp(n.envelope.subject))}e==="forward"&&x(mp(n.envelope.subject))}},[e,n,t?.email]);const xe=e==="reply"||e==="reply_all"||e==="forward",{data:J}=kc({messageId:n?.message.messageId,bodyParts:n?.bodyParts,enabled:xe&&!!n}),ke=J?.kind==="text"?J.body:"",be=J?.kind==="html"?Jd(J.body):void 0,Te=n?.envelope.from[0]?.displayName??n?.envelope.from[0]?.normalizedEmail,Ce=l.useCallback(ee=>{P(!0),i(ee)},[i]),{saveStatus:U,saveError:ye,saveDraft:Ne,saveImmediately:Pe,stopAutoSave:Q}=ap({outboxMessageId:h,onDraftCreated:Ce});l.useEffect(()=>{ye&&u({title:"Couldn't save draft",detail:Ve(ye)??"Saving the draft failed.",error:ye})},[ye,u]);const Z=Me(hl()),ae=Me({...gl(),onError:ee=>{u(hs("Couldn't discard draft","The draft wasn't discarded.",ee))}}),{data:$e}=he({...Lt(),staleTime:1/0}),Fe=$e?.accounts.find(ee=>ee.accountId===j),G=Fe?wc(Fe):!1,He=Fe?.composeLanguages,je=l.useMemo(()=>He&&He.length>0?He:bl(navigator.languages),[He]),Le=l.useRef(!1),[ze,_e]=l.useState(!1),le=l.useMemo(()=>ze?{status:"sending"}:j?G?{status:"blocked",reason:ys}:m.length===0?{status:"blocked",reason:"Add at least one recipient."}:{status:"ready",accountId:j}:{status:"blocked",reason:"Choose an account to send from."},[ze,j,G,m.length]),oe=le;l.useEffect(()=>{if(!j||h&&!T||gp(m,p,y,g,se))return;const{htmlBody:ee,textBody:we}=sa(N,se,W);Ne({accountId:j,toAddresses:m.map(me=>me.email),ccAddresses:p.length>0?p.map(me=>me.email):void 0,bccAddresses:y.length>0?y.map(me=>me.email):void 0,subject:g||void 0,textBody:we,htmlBody:ee})},[j,h,T,m,p,y,g,se,N,W,Ne]);const Xe=l.useCallback(async ee=>{if(!Le.current){Le.current=!0,_e(!0);try{Q();const we=n&&(e==="reply"||e==="reply_all")?hp(n):{},{htmlBody:me,textBody:_}=sa(N,se,W),Y=!h,K=await Pe({accountId:ee,toAddresses:m.map(ie=>ie.email),ccAddresses:p.length>0?p.map(ie=>ie.email):void 0,bccAddresses:y.length>0?y.map(ie=>ie.email):void 0,subject:g||void 0,textBody:_,htmlBody:me,...we});if(K.outcome==="failed"){u({title:"Couldn't send message",detail:Ve(K.error)??"Saving the message failed, so nothing was sent. Try again.",error:K.error});return}const H=K.outboxMessageId;if(await Z.mutateAsync({path:{outboxMessageId:H}}).catch(ie=>(u({title:"Couldn't send message",detail:Ve(ie)??(Y?"The draft was saved but the send request failed. Try again from the Outbox.":"The send request failed. Try again."),error:ie}),null))===null)return;Q(H),c(H),s()}finally{Le.current=!1,_e(!1)}}},[m,p,y,g,se,N,W,e,n,h,Pe,Z,Q,c,u,s]),Be=l.useCallback(()=>{Q(h),h&&ae.mutate({path:{outboxMessageId:h}}),s()},[Q,h,ae,s]),We=l.useCallback(ee=>{u({title:"Can't send yet",detail:ee}),ee===ys&&F.current?.focus()},[u]),st=l.useCallback(()=>{if(le.status!=="sending"){if(le.status==="blocked"){We(le.reason);return}Xe(le.accountId)}},[le,We,Xe]),Oe=l.useCallback(ee=>{R(ee.accountId),r?.(ee)},[r]);return a.jsx(Nd,{banner:Fe&&G?a.jsx(op,{accountId:Fe.accountId,configureRef:F}):void 0,header:a.jsx(bp,{documentGeneration:A,selectedAccountId:j,onAccountChange:Oe,toAddresses:m,setToAddresses:f,ccAddresses:p,setCcAddresses:v,bccAddresses:y,setBccAddresses:d,showCc:k,setShowCc:b,showBcc:w,setShowBcc:E,subject:g,setSubject:x}),quoted:ke||be?a.jsx(zd,{text:ke,html:be,senderName:Te}):void 0,actionBar:a.jsx(wd,{send:oe,onSend:st,onBlocked:We,onDiscard:Be,saveStatus:U}),children:a.jsx(l.Suspense,{fallback:a.jsx(Ed,{}),children:a.jsx(cp,{mode:N,onModeChange:V,initialHtml:M,initialText:C,onChange:ge,onSubmit:st,initialCaret:e==="new"?"start":void 0,onConversionError:u,languages:je,initialLanguage:ne,onLanguageChange:re},A)})})};var Bn="Dialog",[Uo]=If(Bn),[xp,Qe]=Uo(Bn),Ko=e=>{const{__scopeDialog:t,children:n,open:s,defaultOpen:r,onOpenChange:o,modal:i=!0}=e,c=l.useRef(null),u=l.useRef(null),[h,m]=Df({prop:s,defaultProp:r??!1,onChange:o,caller:Bn});return a.jsx(xp,{scope:t,triggerRef:c,contentRef:u,contentId:ts(),titleId:ts(),descriptionId:ts(),open:h,onOpenChange:m,onOpenToggle:l.useCallback(()=>m(f=>!f),[m]),modal:i,children:n})};Ko.displayName=Bn;var Ho="DialogTrigger",yp=l.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,r=Qe(Ho,n),o=xt(t,r.triggerRef);return a.jsx(et.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.open?r.contentId:void 0,"data-state":Gs(r.open),...s,ref:o,onClick:ct(e.onClick,r.onOpenToggle)})});yp.displayName=Ho;var Qs="DialogPortal",[wp,Wo]=Uo(Qs,{forceMount:void 0}),qo=e=>{const{__scopeDialog:t,forceMount:n,children:s,container:r}=e,o=Qe(Qs,t);return a.jsx(wp,{scope:t,forceMount:n,children:l.Children.map(s,i=>a.jsx(_n,{present:n||o.open,children:a.jsx(Do,{asChild:!0,container:r,children:i})}))})};qo.displayName=Qs;var jn="DialogOverlay",Vo=l.forwardRef((e,t)=>{const n=Wo(jn,e.__scopeDialog),{forceMount:s=n.forceMount,...r}=e,o=Qe(jn,e.__scopeDialog);return o.modal?a.jsx(_n,{present:s||o.open,children:a.jsx(kp,{...r,ref:t})}):null});Vo.displayName=jn;var Sp=To("DialogOverlay.RemoveScroll"),kp=l.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,r=Qe(jn,n),o=Jf(),i=xt(t,o);return a.jsx(Bo,{as:Sp,allowPinchZoom:!0,shards:[r.contentRef],children:a.jsx(et.div,{"data-state":Gs(r.open),...s,ref:i,style:{pointerEvents:"auto",...s.style}})})}),Dt="DialogContent",Qo=l.forwardRef((e,t)=>{const n=Wo(Dt,e.__scopeDialog),{forceMount:s=n.forceMount,...r}=e,o=Qe(Dt,e.__scopeDialog);return a.jsx(_n,{present:s||o.open,children:o.modal?a.jsx(Cp,{...r,ref:t}):a.jsx(Ep,{...r,ref:t})})});Qo.displayName=Dt;var Cp=l.forwardRef((e,t)=>{const n=Qe(Dt,e.__scopeDialog),s=l.useRef(null),r=xt(t,n.contentRef,s);return l.useEffect(()=>{const o=s.current;if(o)return ym(o)},[]),a.jsx(Go,{...e,ref:r,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:ct(e.onCloseAutoFocus,o=>{o.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:ct(e.onPointerDownOutside,o=>{const i=o.detail.originalEvent,c=i.button===0&&i.ctrlKey===!0;(i.button===2||c)&&o.preventDefault()}),onFocusOutside:ct(e.onFocusOutside,o=>o.preventDefault())})}),Ep=l.forwardRef((e,t)=>{const n=Qe(Dt,e.__scopeDialog),s=l.useRef(!1),r=l.useRef(!1);return a.jsx(Go,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{e.onCloseAutoFocus?.(o),o.defaultPrevented||(s.current||n.triggerRef.current?.focus(),o.preventDefault()),s.current=!1,r.current=!1},onInteractOutside:o=>{e.onInteractOutside?.(o),o.defaultPrevented||(s.current=!0,o.detail.originalEvent.type==="pointerdown"&&(r.current=!0));const i=o.target;n.triggerRef.current?.contains(i)&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&r.current&&o.preventDefault()}})}),Go=l.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:s,onOpenAutoFocus:r,onCloseAutoFocus:o,...i}=e,c=Qe(Dt,n);return nm(),a.jsx(a.Fragment,{children:a.jsx(Mo,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:r,onUnmountAutoFocus:o,children:a.jsx(Ro,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":Gs(c.open),...i,ref:t,deferPointerDownOutside:!0,onDismiss:()=>c.onOpenChange(!1)})})})}),Yo="DialogTitle",Xo=l.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,r=Qe(Yo,n);return a.jsx(et.h2,{id:r.titleId,...s,ref:t})});Xo.displayName=Yo;var Jo="DialogDescription",Np=l.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,r=Qe(Jo,n);return a.jsx(et.p,{id:r.descriptionId,...s,ref:t})});Np.displayName=Jo;var Zo="DialogClose",jp=l.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,r=Qe(Zo,n);return a.jsx(et.button,{type:"button",...s,ref:t,onClick:ct(e.onClick,()=>r.onOpenChange(!1))})});jp.displayName=Zo;function Gs(e){return e?"open":"closed"}function Tp(e){if(typeof document>"u")return;let t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}const ei=$.createContext({drawerRef:{current:null},overlayRef:{current:null},onPress:()=>{},onRelease:()=>{},onDrag:()=>{},onNestedDrag:()=>{},onNestedOpenChange:()=>{},onNestedRelease:()=>{},openProp:void 0,dismissible:!1,isOpen:!1,isDragging:!1,keyboardIsOpen:{current:!1},snapPointsOffset:null,snapPoints:null,handleOnly:!1,modal:!1,shouldFade:!1,activeSnapPoint:null,onOpenChange:()=>{},setActiveSnapPoint:()=>{},closeDrawer:()=>{},direction:"bottom",shouldAnimate:{current:!0},shouldScaleBackground:!1,setBackgroundColorOnScale:!0,noBodyStyles:!1,container:null,autoFocus:!1}),an=()=>{const e=$.useContext(ei);if(!e)throw new Error("useDrawerContext must be used within a Drawer.Root");return e};Tp(`[data-vaul-drawer]{touch-action:none;will-change:transform;transition:transform .5s cubic-bezier(.32, .72, 0, 1);animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=open]{animation-name:slideFromBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=closed]{animation-name:slideToBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=open]{animation-name:slideFromTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=closed]{animation-name:slideToTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=open]{animation-name:slideFromLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=closed]{animation-name:slideToLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=open]{animation-name:slideFromRight}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=closed]{animation-name:slideToRight}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--initial-transform,100%),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--initial-transform,100%),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-overlay][data-vaul-snap-points=false]{animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-overlay][data-vaul-snap-points=false][data-state=open]{animation-name:fadeIn}[data-vaul-overlay][data-state=closed]{animation-name:fadeOut}[data-vaul-animate=false]{animation:none!important}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:0;transition:opacity .5s cubic-bezier(.32, .72, 0, 1)}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:1}[data-vaul-drawer]:not([data-vaul-custom-container=true])::after{content:'';position:absolute;background:inherit;background-color:inherit}[data-vaul-drawer][data-vaul-drawer-direction=top]::after{top:initial;bottom:100%;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=bottom]::after{top:100%;bottom:initial;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=left]::after{left:initial;right:100%;top:0;bottom:0;width:200%}[data-vaul-drawer][data-vaul-drawer-direction=right]::after{left:100%;right:initial;top:0;bottom:0;width:200%}[data-vaul-overlay][data-vaul-snap-points=true]:not([data-vaul-snap-points-overlay=true]):not(
|
|
51
51
|
[data-state=closed]
|
|
52
52
|
){opacity:0}[data-vaul-overlay][data-vaul-snap-points-overlay=true]{opacity:1}[data-vaul-handle]{display:block;position:relative;opacity:.7;background:#e2e2e4;margin-left:auto;margin-right:auto;height:5px;width:32px;border-radius:1rem;touch-action:pan-y}[data-vaul-handle]:active,[data-vaul-handle]:hover{opacity:1}[data-vaul-handle-hitarea]{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:max(100%,2.75rem);height:max(100%,2.75rem);touch-action:inherit}@media (hover:hover) and (pointer:fine){[data-vaul-drawer]{user-select:none}}@media (pointer:fine){[data-vaul-handle-hitarea]:{width:100%;height:100%}}@keyframes fadeIn{from{opacity:0}to{opacity:1}}@keyframes fadeOut{to{opacity:0}}@keyframes slideFromBottom{from{transform:translate3d(0,var(--initial-transform,100%),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToBottom{to{transform:translate3d(0,var(--initial-transform,100%),0)}}@keyframes slideFromTop{from{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToTop{to{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}}@keyframes slideFromLeft{from{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToLeft{to{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}}@keyframes slideFromRight{from{transform:translate3d(var(--initial-transform,100%),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToRight{to{transform:translate3d(var(--initial-transform,100%),0,0)}}`);function Rp(){const e=navigator.userAgent;return typeof window<"u"&&(/Firefox/.test(e)&&/Mobile/.test(e)||/FxiOS/.test(e))}function Ip(){return Ys(/^Mac/)}function Mp(){return Ys(/^iPhone/)}function ra(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function Ap(){return Ys(/^iPad/)||Ip()&&navigator.maxTouchPoints>1}function ti(){return Mp()||Ap()}function Ys(e){return typeof window<"u"&&window.navigator!=null?e.test(window.navigator.platform):void 0}const Dp=24,Pp=typeof window<"u"?l.useLayoutEffect:l.useEffect;function aa(...e){return(...t)=>{for(let n of e)typeof n=="function"&&n(...t)}}const is=typeof document<"u"&&window.visualViewport;function oa(e){let t=window.getComputedStyle(e);return/(auto|scroll)/.test(t.overflow+t.overflowX+t.overflowY)}function ni(e){for(oa(e)&&(e=e.parentElement);e&&!oa(e);)e=e.parentElement;return e||document.scrollingElement||document.documentElement}const Lp=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);let yn=0,ls;function Op(e={}){let{isDisabled:t}=e;Pp(()=>{if(!t)return yn++,yn===1&&ti()&&(ls=$p()),()=>{yn--,yn===0&&ls?.()}},[t])}function $p(){let e,t=0,n=f=>{e=ni(f.target),!(e===document.documentElement&&e===document.body)&&(t=f.changedTouches[0].pageY)},s=f=>{if(!e||e===document.documentElement||e===document.body){f.preventDefault();return}let p=f.changedTouches[0].pageY,v=e.scrollTop,y=e.scrollHeight-e.clientHeight;y!==0&&((v<=0&&p>t||v>=y&&p<t)&&f.preventDefault(),t=p)},r=f=>{let p=f.target;Cs(p)&&p!==document.activeElement&&(f.preventDefault(),p.style.transform="translateY(-2000px)",p.focus(),requestAnimationFrame(()=>{p.style.transform=""}))},o=f=>{let p=f.target;Cs(p)&&(p.style.transform="translateY(-2000px)",requestAnimationFrame(()=>{p.style.transform="",is&&(is.height<window.innerHeight?requestAnimationFrame(()=>{ia(p)}):is.addEventListener("resize",()=>ia(p),{once:!0}))}))},i=()=>{window.scrollTo(0,0)},c=window.pageXOffset,u=window.pageYOffset,h=aa(Fp(document.documentElement,"paddingRight",`${window.innerWidth-document.documentElement.clientWidth}px`));window.scrollTo(0,0);let m=aa(Wt(document,"touchstart",n,{passive:!1,capture:!0}),Wt(document,"touchmove",s,{passive:!1,capture:!0}),Wt(document,"touchend",r,{passive:!1,capture:!0}),Wt(document,"focus",o,!0),Wt(window,"scroll",i));return()=>{h(),m(),window.scrollTo(c,u)}}function Fp(e,t,n){let s=e.style[t];return e.style[t]=n,()=>{e.style[t]=s}}function Wt(e,t,n,s){return e.addEventListener(t,n,s),()=>{e.removeEventListener(t,n,s)}}function ia(e){let t=document.scrollingElement||document.documentElement;for(;e&&e!==t;){let n=ni(e);if(n!==document.documentElement&&n!==document.body&&n!==e){let s=n.getBoundingClientRect().top,r=e.getBoundingClientRect().top,o=e.getBoundingClientRect().bottom;const i=n.getBoundingClientRect().bottom+Dp;o>i&&(n.scrollTop+=r-s)}e=n.parentElement}}function Cs(e){return e instanceof HTMLInputElement&&!Lp.has(e.type)||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}function _p(e,t){typeof e=="function"?e(t):e!=null&&(e.current=t)}function zp(...e){return t=>e.forEach(n=>_p(n,t))}function si(...e){return l.useCallback(zp(...e),e)}const ri=new WeakMap;function ve(e,t,n=!1){if(!e||!(e instanceof HTMLElement))return;let s={};Object.entries(t).forEach(([r,o])=>{if(r.startsWith("--")){e.style.setProperty(r,o);return}s[r]=e.style[r],e.style[r]=o}),!n&&ri.set(e,s)}function Bp(e,t){if(!e||!(e instanceof HTMLElement))return;let n=ri.get(e);n&&(e.style[t]=n[t])}const pe=e=>{switch(e){case"top":case"bottom":return!0;case"left":case"right":return!1;default:return e}};function wn(e,t){if(!e)return null;const n=window.getComputedStyle(e),s=n.transform||n.webkitTransform||n.mozTransform;let r=s.match(/^matrix3d\((.+)\)$/);return r?parseFloat(r[1].split(", ")[pe(t)?13:12]):(r=s.match(/^matrix\((.+)\)$/),r?parseFloat(r[1].split(", ")[pe(t)?5:4]):null)}function Up(e){return 8*(Math.log(e+1)-2)}function cs(e,t){if(!e)return()=>{};const n=e.style.cssText;return Object.assign(e.style,t),()=>{e.style.cssText=n}}function Kp(...e){return(...t)=>{for(const n of e)typeof n=="function"&&n(...t)}}const fe={DURATION:.5,EASE:[.32,.72,0,1]},ai=.4,Hp=.25,Wp=100,oi=8,ht=16,Es=26,us="vaul-dragging";function ii(e){const t=$.useRef(e);return $.useEffect(()=>{t.current=e}),$.useMemo(()=>(...n)=>t.current==null?void 0:t.current.call(t,...n),[])}function qp({defaultProp:e,onChange:t}){const n=$.useState(e),[s]=n,r=$.useRef(s),o=ii(t);return $.useEffect(()=>{r.current!==s&&(o(s),r.current=s)},[s,r,o]),n}function li({prop:e,defaultProp:t,onChange:n=()=>{}}){const[s,r]=qp({defaultProp:t,onChange:n}),o=e!==void 0,i=o?e:s,c=ii(n),u=$.useCallback(h=>{if(o){const f=typeof h=="function"?h(e):h;f!==e&&c(f)}else r(h)},[o,e,r,c]);return[i,u]}function Vp({activeSnapPointProp:e,setActiveSnapPointProp:t,snapPoints:n,drawerRef:s,overlayRef:r,fadeFromIndex:o,onSnapPointChange:i,direction:c="bottom",container:u,snapToSequentialPoint:h}){const[m,f]=li({prop:e,defaultProp:n?.[0],onChange:t}),[p,v]=$.useState(typeof window<"u"?{innerWidth:window.innerWidth,innerHeight:window.innerHeight}:void 0);$.useEffect(()=>{function R(){v({innerWidth:window.innerWidth,innerHeight:window.innerHeight})}return window.addEventListener("resize",R),()=>window.removeEventListener("resize",R)},[]);const y=$.useMemo(()=>m===n?.[n.length-1]||null,[n,m]),d=$.useMemo(()=>{var R;return(R=n?.findIndex(T=>T===m))!=null?R:null},[n,m]),g=n&&n.length>0&&(o||o===0)&&!Number.isNaN(o)&&n[o]===m||!n,x=$.useMemo(()=>{const R=u?{width:u.getBoundingClientRect().width,height:u.getBoundingClientRect().height}:typeof window<"u"?{width:window.innerWidth,height:window.innerHeight}:{width:0,height:0};var T;return(T=n?.map(P=>{const F=typeof P=="string";let I=0;if(F&&(I=parseInt(P,10)),pe(c)){const A=F?I:p?P*R.height:0;return p?c==="bottom"?R.height-A:-R.height+A:A}const z=F?I:p?P*R.width:0;return p?c==="right"?R.width-z:-R.width+z:z}))!=null?T:[]},[n,p,u]),k=$.useMemo(()=>d!==null?x?.[d]:null,[x,d]),b=$.useCallback(R=>{var T;const P=(T=x?.findIndex(F=>F===R))!=null?T:null;i(P),ve(s.current,{transition:`transform ${fe.DURATION}s cubic-bezier(${fe.EASE.join(",")})`,transform:pe(c)?`translate3d(0, ${R}px, 0)`:`translate3d(${R}px, 0, 0)`}),x&&P!==x.length-1&&o!==void 0&&P!==o&&P<o?ve(r.current,{transition:`opacity ${fe.DURATION}s cubic-bezier(${fe.EASE.join(",")})`,opacity:"0"}):ve(r.current,{transition:`opacity ${fe.DURATION}s cubic-bezier(${fe.EASE.join(",")})`,opacity:"1"}),f(n?.[Math.max(P,0)])},[s.current,n,x,o,r,f]);$.useEffect(()=>{if(m||e){var R;const T=(R=n?.findIndex(P=>P===e||P===m))!=null?R:-1;x&&T!==-1&&typeof x[T]=="number"&&b(x[T])}},[m,e,n,x,b]);function w({draggedDistance:R,closeDrawer:T,velocity:P,dismissible:F}){if(o===void 0)return;const I=c==="bottom"||c==="right"?(k??0)-R:(k??0)+R,z=d===o-1,A=d===0,S=R>0;if(z&&ve(r.current,{transition:`opacity ${fe.DURATION}s cubic-bezier(${fe.EASE.join(",")})`}),!h&&P>2&&!S){F?T():b(x[0]);return}if(!h&&P>2&&S&&x&&n){b(x[n.length-1]);return}const M=x?.reduce((C,D)=>typeof C!="number"||typeof D!="number"?C:Math.abs(D-I)<Math.abs(C-I)?D:C),O=pe(c)?window.innerHeight:window.innerWidth;if(P>ai&&Math.abs(R)<O*.4){const C=S?1:-1;if(C>0&&y&&n){b(x[n.length-1]);return}if(A&&C<0&&F&&T(),d===null)return;b(x[d+C]);return}b(M)}function E({draggedDistance:R}){if(k===null)return;const T=c==="bottom"||c==="right"?k-R:k+R;(c==="bottom"||c==="right")&&T<x[x.length-1]||(c==="top"||c==="left")&&T>x[x.length-1]||ve(s.current,{transform:pe(c)?`translate3d(0, ${T}px, 0)`:`translate3d(${T}px, 0, 0)`})}function j(R,T){if(!n||typeof d!="number"||!x||o===void 0)return null;const P=d===o-1;if(d>=o&&T)return 0;if(P&&!T)return 1;if(!g&&!P)return null;const I=P?d+1:d-1,z=P?x[I]-x[I-1]:x[I+1]-x[I],A=R/Math.abs(z);return P?1-A:A}return{isLastSnapPoint:y,activeSnapPoint:m,shouldFade:g,getPercentageDragged:j,setActiveSnapPoint:f,activeSnapPointIndex:d,onRelease:w,onDrag:E,snapPointsOffset:x}}const Qp=()=>()=>{};function Gp(){const{direction:e,isOpen:t,shouldScaleBackground:n,setBackgroundColorOnScale:s,noBodyStyles:r}=an(),o=$.useRef(null),i=l.useMemo(()=>document.body.style.backgroundColor,[]);function c(){return(window.innerWidth-Es)/window.innerWidth}$.useEffect(()=>{if(t&&n){o.current&&clearTimeout(o.current);const u=document.querySelector("[data-vaul-drawer-wrapper]")||document.querySelector("[vaul-drawer-wrapper]");if(!u)return;Kp(s&&!r?cs(document.body,{background:"black"}):Qp,cs(u,{transformOrigin:pe(e)?"top":"left",transitionProperty:"transform, border-radius",transitionDuration:`${fe.DURATION}s`,transitionTimingFunction:`cubic-bezier(${fe.EASE.join(",")})`}));const h=cs(u,{borderRadius:`${oi}px`,overflow:"hidden",...pe(e)?{transform:`scale(${c()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`}:{transform:`scale(${c()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`}});return()=>{h(),o.current=window.setTimeout(()=>{i?document.body.style.background=i:document.body.style.removeProperty("background")},fe.DURATION*1e3)}}},[t,n,i])}let qt=null;function Yp({isOpen:e,modal:t,nested:n,hasBeenOpened:s,preventScrollRestoration:r,noBodyStyles:o}){const[i,c]=$.useState(()=>typeof window<"u"?window.location.href:""),u=$.useRef(0),h=$.useCallback(()=>{if(ra()&&qt===null&&e&&!o){qt={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left,height:document.body.style.height,right:"unset"};const{scrollX:f,innerHeight:p}=window;document.body.style.setProperty("position","fixed","important"),Object.assign(document.body.style,{top:`${-u.current}px`,left:`${-f}px`,right:"0px",height:"auto"}),window.setTimeout(()=>window.requestAnimationFrame(()=>{const v=p-window.innerHeight;v&&u.current>=p&&(document.body.style.top=`${-(u.current+v)}px`)}),300)}},[e]),m=$.useCallback(()=>{if(ra()&&qt!==null&&!o){const f=-parseInt(document.body.style.top,10),p=-parseInt(document.body.style.left,10);Object.assign(document.body.style,qt),window.requestAnimationFrame(()=>{if(r&&i!==window.location.href){c(window.location.href);return}window.scrollTo(p,f)}),qt=null}},[i]);return $.useEffect(()=>{function f(){u.current=window.scrollY}return f(),window.addEventListener("scroll",f),()=>{window.removeEventListener("scroll",f)}},[]),$.useEffect(()=>{if(t)return()=>{typeof document>"u"||document.querySelector("[data-vaul-drawer]")||m()}},[t,m]),$.useEffect(()=>{n||!s||(e?(!window.matchMedia("(display-mode: standalone)").matches&&h(),t||window.setTimeout(()=>{m()},500)):m())},[e,s,i,t,n,h,m]),{restorePositionSetting:m}}function Xp({open:e,onOpenChange:t,children:n,onDrag:s,onRelease:r,snapPoints:o,shouldScaleBackground:i=!1,setBackgroundColorOnScale:c=!0,closeThreshold:u=Hp,scrollLockTimeout:h=Wp,dismissible:m=!0,handleOnly:f=!1,fadeFromIndex:p=o&&o.length-1,activeSnapPoint:v,setActiveSnapPoint:y,fixed:d,modal:g=!0,onClose:x,nested:k,noBodyStyles:b=!1,direction:w="bottom",defaultOpen:E=!1,disablePreventScroll:j=!0,snapToSequentialPoint:R=!1,preventScrollRestoration:T=!1,repositionInputs:P=!0,onAnimationEnd:F,container:I,autoFocus:z=!1}){var A,S;const[M=!1,O]=li({defaultProp:E,prop:e,onChange:_=>{t?.(_),!_&&!k&&ze(),setTimeout(()=>{F?.(_)},fe.DURATION*1e3),_&&!g&&typeof window<"u"&&window.requestAnimationFrame(()=>{document.body.style.pointerEvents="auto"}),_||(document.body.style.pointerEvents="auto")}}),[C,D]=$.useState(!1),[N,V]=$.useState(!1),[W,re]=$.useState(!1),ne=$.useRef(null),de=$.useRef(null),se=$.useRef(null),ge=$.useRef(null),q=$.useRef(null),xe=$.useRef(!1),J=$.useRef(null),ke=$.useRef(0),be=$.useRef(!1),Te=$.useRef(!E),Ce=$.useRef(0),U=$.useRef(null),ye=$.useRef(((A=U.current)==null?void 0:A.getBoundingClientRect().height)||0),Ne=$.useRef(((S=U.current)==null?void 0:S.getBoundingClientRect().width)||0),Pe=$.useRef(0),Q=$.useCallback(_=>{o&&_===G.length-1&&(de.current=new Date)},[]),{activeSnapPoint:Z,activeSnapPointIndex:ae,setActiveSnapPoint:$e,onRelease:Fe,snapPointsOffset:G,onDrag:He,shouldFade:je,getPercentageDragged:Le}=Vp({snapPoints:o,activeSnapPointProp:v,setActiveSnapPointProp:y,drawerRef:U,fadeFromIndex:p,overlayRef:ne,onSnapPointChange:Q,direction:w,container:I,snapToSequentialPoint:R});Op({isDisabled:!M||N||!g||W||!C||!P||!j});const{restorePositionSetting:ze}=Yp({isOpen:M,modal:g,nested:k??!1,hasBeenOpened:C,preventScrollRestoration:T,noBodyStyles:b});function _e(){return(window.innerWidth-Es)/window.innerWidth}function le(_){var Y,K;!m&&!o||U.current&&!U.current.contains(_.target)||(ye.current=((Y=U.current)==null?void 0:Y.getBoundingClientRect().height)||0,Ne.current=((K=U.current)==null?void 0:K.getBoundingClientRect().width)||0,V(!0),se.current=new Date,ti()&&window.addEventListener("touchend",()=>xe.current=!1,{once:!0}),_.target.setPointerCapture(_.pointerId),ke.current=pe(w)?_.pageY:_.pageX)}function oe(_,Y){var K;let H=_;const ce=(K=window.getSelection())==null?void 0:K.toString(),ie=U.current?wn(U.current,w):null,Ee=new Date;if(H.tagName==="SELECT"||H.hasAttribute("data-vaul-no-drag")||H.closest("[data-vaul-no-drag]"))return!1;if(w==="right"||w==="left")return!0;if(de.current&&Ee.getTime()-de.current.getTime()<500)return!1;if(ie!==null&&(w==="bottom"?ie>0:ie<0))return!0;if(ce&&ce.length>0)return!1;if(q.current&&Ee.getTime()-q.current.getTime()<h&&ie===0||Y)return q.current=Ee,!1;for(;H;){if(H.scrollHeight>H.clientHeight){if(H.scrollTop!==0)return q.current=new Date,!1;if(H.getAttribute("role")==="dialog")return!0}H=H.parentNode}return!0}function Xe(_){if(U.current&&N){const Y=w==="bottom"||w==="right"?1:-1,K=(ke.current-(pe(w)?_.pageY:_.pageX))*Y,H=K>0,ce=o&&!m&&!H;if(ce&&ae===0)return;const ie=Math.abs(K),Ee=document.querySelector("[data-vaul-drawer-wrapper]"),Ue=w==="bottom"||w==="top"?ye.current:Ne.current;let Re=ie/Ue;const Ke=Le(ie,H);if(Ke!==null&&(Re=Ke),ce&&Re>=1||!xe.current&&!oe(_.target,H))return;if(U.current.classList.add(us),xe.current=!0,ve(U.current,{transition:"none"}),ve(ne.current,{transition:"none"}),o&&He({draggedDistance:K}),H&&!o){const Ie=Up(K),yt=Math.min(Ie*-1,0)*Y;ve(U.current,{transform:pe(w)?`translate3d(0, ${yt}px, 0)`:`translate3d(${yt}px, 0, 0)`});return}const qe=1-Re;if((je||p&&ae===p-1)&&(s?.(_,Re),ve(ne.current,{opacity:`${qe}`,transition:"none"},!0)),Ee&&ne.current&&i){const Ie=Math.min(_e()+Re*(1-_e()),1),yt=8-Re*8,_t=Math.max(0,14-Re*14);ve(Ee,{borderRadius:`${yt}px`,transform:pe(w)?`scale(${Ie}) translate3d(0, ${_t}px, 0)`:`scale(${Ie}) translate3d(${_t}px, 0, 0)`,transition:"none"},!0)}if(!o){const Ie=ie*Y;ve(U.current,{transform:pe(w)?`translate3d(0, ${Ie}px, 0)`:`translate3d(${Ie}px, 0, 0)`})}}}$.useEffect(()=>{window.requestAnimationFrame(()=>{Te.current=!0})},[]),$.useEffect(()=>{var _;function Y(){if(!U.current||!P)return;const K=document.activeElement;if(Cs(K)||be.current){var H;const ce=((H=window.visualViewport)==null?void 0:H.height)||0,ie=window.innerHeight;let Ee=ie-ce;const Ue=U.current.getBoundingClientRect().height||0,Re=Ue>ie*.8;Pe.current||(Pe.current=Ue);const Ke=U.current.getBoundingClientRect().top;if(Math.abs(Ce.current-Ee)>60&&(be.current=!be.current),o&&o.length>0&&G&&ae){const qe=G[ae]||0;Ee+=qe}if(Ce.current=Ee,Ue>ce||be.current){const qe=U.current.getBoundingClientRect().height;let Ie=qe;qe>ce&&(Ie=ce-(Re?Ke:Es)),d?U.current.style.height=`${qe-Math.max(Ee,0)}px`:U.current.style.height=`${Math.max(Ie,ce-Ke)}px`}else Rp()||(U.current.style.height=`${Pe.current}px`);o&&o.length>0&&!be.current?U.current.style.bottom="0px":U.current.style.bottom=`${Math.max(Ee,0)}px`}}return(_=window.visualViewport)==null||_.addEventListener("resize",Y),()=>{var K;return(K=window.visualViewport)==null?void 0:K.removeEventListener("resize",Y)}},[ae,o,G]);function Be(_){st(),x?.(),_||O(!1),setTimeout(()=>{o&&$e(o[0])},fe.DURATION*1e3)}function We(){if(!U.current)return;const _=document.querySelector("[data-vaul-drawer-wrapper]"),Y=wn(U.current,w);ve(U.current,{transform:"translate3d(0, 0, 0)",transition:`transform ${fe.DURATION}s cubic-bezier(${fe.EASE.join(",")})`}),ve(ne.current,{transition:`opacity ${fe.DURATION}s cubic-bezier(${fe.EASE.join(",")})`,opacity:"1"}),i&&Y&&Y>0&&M&&ve(_,{borderRadius:`${oi}px`,overflow:"hidden",...pe(w)?{transform:`scale(${_e()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,transformOrigin:"top"}:{transform:`scale(${_e()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`,transformOrigin:"left"},transitionProperty:"transform, border-radius",transitionDuration:`${fe.DURATION}s`,transitionTimingFunction:`cubic-bezier(${fe.EASE.join(",")})`},!0)}function st(){!N||!U.current||(U.current.classList.remove(us),xe.current=!1,V(!1),ge.current=new Date)}function Oe(_){if(!N||!U.current)return;U.current.classList.remove(us),xe.current=!1,V(!1),ge.current=new Date;const Y=wn(U.current,w);if(!_||!oe(_.target,!1)||!Y||Number.isNaN(Y)||se.current===null)return;const K=ge.current.getTime()-se.current.getTime(),H=ke.current-(pe(w)?_.pageY:_.pageX),ce=Math.abs(H)/K;if(ce>.05&&(re(!0),setTimeout(()=>{re(!1)},200)),o){Fe({draggedDistance:H*(w==="bottom"||w==="right"?1:-1),closeDrawer:Be,velocity:ce,dismissible:m}),r?.(_,!0);return}if(w==="bottom"||w==="right"?H>0:H<0){We(),r?.(_,!0);return}if(ce>ai){Be(),r?.(_,!1);return}var ie;const Ee=Math.min((ie=U.current.getBoundingClientRect().height)!=null?ie:0,window.innerHeight);var Ue;const Re=Math.min((Ue=U.current.getBoundingClientRect().width)!=null?Ue:0,window.innerWidth),Ke=w==="left"||w==="right";if(Math.abs(Y)>=(Ke?Re:Ee)*u){Be(),r?.(_,!1);return}r?.(_,!0),We()}$.useEffect(()=>(M&&(ve(document.documentElement,{scrollBehavior:"auto"}),de.current=new Date),()=>{Bp(document.documentElement,"scrollBehavior")}),[M]);function ee(_){const Y=_?(window.innerWidth-ht)/window.innerWidth:1,K=_?-ht:0;J.current&&window.clearTimeout(J.current),ve(U.current,{transition:`transform ${fe.DURATION}s cubic-bezier(${fe.EASE.join(",")})`,transform:pe(w)?`scale(${Y}) translate3d(0, ${K}px, 0)`:`scale(${Y}) translate3d(${K}px, 0, 0)`}),!_&&U.current&&(J.current=setTimeout(()=>{const H=wn(U.current,w);ve(U.current,{transition:"none",transform:pe(w)?`translate3d(0, ${H}px, 0)`:`translate3d(${H}px, 0, 0)`})},500))}function we(_,Y){if(Y<0)return;const K=(window.innerWidth-ht)/window.innerWidth,H=K+Y*(1-K),ce=-ht+Y*ht;ve(U.current,{transform:pe(w)?`scale(${H}) translate3d(0, ${ce}px, 0)`:`scale(${H}) translate3d(${ce}px, 0, 0)`,transition:"none"})}function me(_,Y){const K=pe(w)?window.innerHeight:window.innerWidth,H=Y?(K-ht)/K:1,ce=Y?-ht:0;Y&&ve(U.current,{transition:`transform ${fe.DURATION}s cubic-bezier(${fe.EASE.join(",")})`,transform:pe(w)?`scale(${H}) translate3d(0, ${ce}px, 0)`:`scale(${H}) translate3d(${ce}px, 0, 0)`})}return $.useEffect(()=>{g||window.requestAnimationFrame(()=>{document.body.style.pointerEvents="auto"})},[g]),$.createElement(Ko,{defaultOpen:E,onOpenChange:_=>{!m&&!_||(_?D(!0):Be(!0),O(_))},open:M},$.createElement(ei.Provider,{value:{activeSnapPoint:Z,snapPoints:o,setActiveSnapPoint:$e,drawerRef:U,overlayRef:ne,onOpenChange:t,onPress:le,onRelease:Oe,onDrag:Xe,dismissible:m,shouldAnimate:Te,handleOnly:f,isOpen:M,isDragging:N,shouldFade:je,closeDrawer:Be,onNestedDrag:we,onNestedOpenChange:ee,onNestedRelease:me,keyboardIsOpen:be,modal:g,snapPointsOffset:G,activeSnapPointIndex:ae,direction:w,shouldScaleBackground:i,setBackgroundColorOnScale:c,noBodyStyles:b,container:I,autoFocus:z}},n))}const ci=$.forwardRef(function({...e},t){const{overlayRef:n,snapPoints:s,onRelease:r,shouldFade:o,isOpen:i,modal:c,shouldAnimate:u}=an(),h=si(t,n),m=s&&s.length>0;if(!c)return null;const f=$.useCallback(p=>r(p),[r]);return $.createElement(Vo,{onMouseUp:f,ref:h,"data-vaul-overlay":"","data-vaul-snap-points":i&&m?"true":"false","data-vaul-snap-points-overlay":i&&o?"true":"false","data-vaul-animate":u?.current?"true":"false",...e})});ci.displayName="Drawer.Overlay";const ui=$.forwardRef(function({onPointerDownOutside:e,style:t,onOpenAutoFocus:n,...s},r){const{drawerRef:o,onPress:i,onRelease:c,onDrag:u,keyboardIsOpen:h,snapPointsOffset:m,activeSnapPointIndex:f,modal:p,isOpen:v,direction:y,snapPoints:d,container:g,handleOnly:x,shouldAnimate:k,autoFocus:b}=an(),[w,E]=$.useState(!1),j=si(r,o),R=$.useRef(null),T=$.useRef(null),P=$.useRef(!1),F=d&&d.length>0;Gp();const I=(A,S,M=0)=>{if(P.current)return!0;const O=Math.abs(A.y),C=Math.abs(A.x),D=C>O,N=["bottom","right"].includes(S)?1:-1;if(S==="left"||S==="right"){if(!(A.x*N<0)&&C>=0&&C<=M)return D}else if(!(A.y*N<0)&&O>=0&&O<=M)return!D;return P.current=!0,!0};$.useEffect(()=>{F&&window.requestAnimationFrame(()=>{E(!0)})},[]);function z(A){R.current=null,P.current=!1,c(A)}return $.createElement(Qo,{"data-vaul-drawer-direction":y,"data-vaul-drawer":"","data-vaul-delayed-snap-points":w?"true":"false","data-vaul-snap-points":v&&F?"true":"false","data-vaul-custom-container":g?"true":"false","data-vaul-animate":k?.current?"true":"false",...s,ref:j,style:m&&m.length>0?{"--snap-point-height":`${m[f??0]}px`,...t}:t,onPointerDown:A=>{x||(s.onPointerDown==null||s.onPointerDown.call(s,A),R.current={x:A.pageX,y:A.pageY},i(A))},onOpenAutoFocus:A=>{n?.(A),b||A.preventDefault()},onPointerDownOutside:A=>{if(e?.(A),!p||A.defaultPrevented){A.preventDefault();return}h.current&&(h.current=!1)},onFocusOutside:A=>{if(!p){A.preventDefault();return}},onPointerMove:A=>{if(T.current=A,x||(s.onPointerMove==null||s.onPointerMove.call(s,A),!R.current))return;const S=A.pageY-R.current.y,M=A.pageX-R.current.x,O=A.pointerType==="touch"?10:2;I({x:M,y:S},y,O)?u(A):(Math.abs(M)>O||Math.abs(S)>O)&&(R.current=null)},onPointerUp:A=>{s.onPointerUp==null||s.onPointerUp.call(s,A),R.current=null,P.current=!1,c(A)},onPointerOut:A=>{s.onPointerOut==null||s.onPointerOut.call(s,A),z(T.current)},onContextMenu:A=>{s.onContextMenu==null||s.onContextMenu.call(s,A),T.current&&z(T.current)}})});ui.displayName="Drawer.Content";const Jp=250,Zp=120,di=$.forwardRef(function({preventCycle:e=!1,children:t,...n},s){const{closeDrawer:r,isDragging:o,snapPoints:i,activeSnapPoint:c,setActiveSnapPoint:u,dismissible:h,handleOnly:m,isOpen:f,onPress:p,onDrag:v}=an(),y=$.useRef(null),d=$.useRef(!1);function g(){if(d.current){b();return}window.setTimeout(()=>{x()},Zp)}function x(){if(o||e||d.current){b();return}if(b(),!i||i.length===0){h||r();return}if(c===i[i.length-1]&&h){r();return}const E=i.findIndex(R=>R===c);if(E===-1)return;const j=i[E+1];u(j)}function k(){y.current=window.setTimeout(()=>{d.current=!0},Jp)}function b(){y.current&&window.clearTimeout(y.current),d.current=!1}return $.createElement("div",{onClick:g,onPointerCancel:b,onPointerDown:w=>{m&&p(w),k()},onPointerMove:w=>{m&&v(w)},ref:s,"data-vaul-drawer-visible":f?"true":"false","data-vaul-handle":"","aria-hidden":"true",...n},$.createElement("span",{"data-vaul-handle-hitarea":"","aria-hidden":"true"},t))});di.displayName="Drawer.Handle";function eh(e){const t=an(),{container:n=t.container,...s}=e;return $.createElement(qo,{container:n,...s})}const Tt={Root:Xp,Content:ui,Overlay:ci,Portal:eh,Handle:di,Title:Xo},cv=({isOpen:e,onClose:t,children:n,ariaLabel:s="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 h=p=>{p.key==="Escape"&&(p.preventDefault(),t())};document.addEventListener("keydown",h),i.current?.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])")?.focus();const f=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",h),document.body.style.overflow=f,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 lg:hidden",role:"dialog","aria-modal":"true","aria-label":s,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:Ze("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(en,{className:"size-5"})})}),a.jsx("div",{className:"flex-1 overflow-y-auto",children:n})]})]})},la=({mode:e,account:t,sourceMessage:n,onClose:s})=>a.jsx("div",{className:"border-t border-line bg-canvas max-h-[min(400px,60dvh)] flex flex-col lg:h-[min(560px,55dvh)] lg:max-h-none",children:a.jsx(vp,{mode:e,account:t,sourceMessage:n,onClose:s})}),fi=({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})]}),mi=e=>{const{data:t,isLoading:n}=he({...Lt(),staleTime:1/0}),s=l.useMemo(()=>(t?.accounts??[]).map(c=>c.accountId),[t?.accounts]),r=Os({queries:s.map(c=>({...nn({path:{accountId:c}}),staleTime:1/0,enabled:!!e}))}),o=n||r.some(c=>c.isLoading);return{accountId:l.useMemo(()=>{if(e){for(let c=0;c<s.length;c++)if((r[c].data?.items??[]).some(m=>m.mailboxId===e))return s[c]}},[e,s,r]),isLoading:o}},th=100,Ns=async e=>e.then(t=>({ok:!0,value:t}),t=>({ok:!1,error:t})),nh=(e,t=th)=>{if(e.length===0)return[];const n=[];for(let s=0;s<e.length;s+=t)n.push(e.slice(s,s+t));return n},pi=async(e,t,n,s)=>{const r=nh(e),o=e.length;let i=0;const c=[];for(let u=0;u<r.length;u++){if(s())return c.push(...r.slice(u).flat()),{done:i,failedIds:c,cancelled:!0};const h=r[u],m=await Ns(t(h));if(!m.ok)return c.push(...r.slice(u).flat()),n({done:i,total:o}),{done:i,failedIds:c,cancelled:!1,error:m.error};i+=h.length,n({done:i,total:o})}return{done:i,failedIds:c,cancelled:!1}},Zt=async(e,t)=>{await pi(e,async n=>(await t(n),{successCount:n.length,failureCount:0}),()=>{},()=>!1)},sh=async(e,t,n,s,r)=>{let o=0;const i=[];let c;do{if(r())return{done:o,failedIds:i,cancelled:!0};const u=await Ns(e(c));if(!u.ok)return{done:o,failedIds:i,cancelled:!1,error:u.error};const h=u.value;if(h.ids.length>0){const m=await Ns(n(h.ids));if(!m.ok)return{done:o,failedIds:i,cancelled:!1,error:m.error};o+=h.ids.length,s({done:o,total:t})}c=h.continuationToken}while(c);return{done:o,failedIds:i,cancelled:!1}},rh=e=>({done:e.done,total:Math.max(e.total,e.done)}),hi=e=>typeof e=="object"&&e!==null&&Array.isArray(e.pages),gi=e=>typeof e=="object"&&e!==null&&Array.isArray(e.items),bi=(e,t)=>e===void 0?e:hi(e)?{...e,pages:e.pages.map(n=>({...n,items:t(n.items)}))}:gi(e)?{...e,items:t(e.items)}:e,tt=e=>{const t=[];for(const n of new Set(e))t.push(Da({path:{mailboxId:n}})),t.push(Pa({path:{mailboxId:n}}));return t.push(La()),t},on=(e,t)=>Promise.all(t.map(n=>e.cancelQueries({queryKey:n}))),ln=(e,t)=>t.flatMap(n=>e.getQueriesData({queryKey:n})).filter(n=>n[1]!==void 0).map(([n,s])=>({queryKey:n,data:s})),cn=(e,t,n)=>{const s=r=>bi(r,n);for(const r of t)e.setQueriesData({queryKey:r},s)},un=(e,t)=>{for(const n of t)e.setQueryData(n.queryKey,n.data)},nt=(e,t)=>{for(const n of t)e.invalidateQueries({queryKey:n})},ah=3e3,oh=(e,t,n)=>{if(e.length===0)return()=>{};const s=setTimeout(()=>n(e),t);return()=>clearTimeout(s)},Xs=(e,t,n)=>{const s=new Map(t.map(o=>[o.messageId,o.mailboxId])),r=new Set;for(const o of e)r.add(s.get(o)??n);return[...r]},Tn=(e,t,n)=>e.map(s=>t.has(s.messageId)?{...s,isRead:n}:s),ih=(e,t,n,s)=>e.filter(r=>!r.isRead&&t.has(r.threadMessageId)&&!n.has(r.messageId)&&!s.has(r.messageId)).map(r=>r.messageId),lh=({messages:e,expandedIds:t,threadId:n,mailboxId:s,accountId:r})=>{const o=De(),{pushError:i}=Ye(),c=l.useRef(new Set),u=l.useRef(new Set),{mutate:h}=Me({...Mn(),onMutate:async p=>{const v=new Set(p.body.messageIds??[]),y=p.body.isRead??!0,d=dt({path:{threadId:n}}),g=tt(Xs(v,e,s));await Promise.all([o.cancelQueries({queryKey:d}),on(o,g)]);const x=o.getQueriesData({queryKey:d}).filter(b=>b[1]!==void 0).map(([b,w])=>({queryKey:b,data:w})),k=ln(o,g);return o.setQueriesData({queryKey:d},b=>b&&{...b,items:Tn(b.items,v,y)}),cn(o,g,b=>Tn(b,v,y)),{threadMessagesPrefix:d,listPrefixes:g,previousThreadMessages:x,previousThreadsList:k}},onSuccess:(p,v)=>{const y=v.body.messageIds??[];for(const d of y)c.current.add(d),u.current.delete(d)},onError:(p,v,y)=>{const d=v.body.messageIds??[];for(const x of d)u.current.delete(x);if(y){for(const x of y.previousThreadMessages)o.setQueryData(x.queryKey,x.data);un(o,y.previousThreadsList)}const g=v.body.isRead??!0;i({title:g?"Couldn't mark as read":"Couldn't mark as unread",detail:Ve(p),error:p})},onSettled:(p,v,y,d)=>{d&&(o.invalidateQueries({queryKey:d.threadMessagesPrefix}),nt(o,d.listPrefixes),r&&o.invalidateQueries({queryKey:Ot({path:{accountId:r}})}))}}),m=l.useCallback(p=>{const v=p.filter(y=>!c.current.has(y)&&!u.current.has(y));if(v.length!==0){for(const y of v)u.current.add(y);h({body:{messageIds:v,isRead:!0}})}},[h]),f=l.useMemo(()=>ih(e,t,c.current,u.current),[e,t]);l.useEffect(()=>oh(f,ah,m),[f,m]),l.useEffect(()=>{c.current.clear(),u.current.clear()},[n])},uv=e=>{const{mailboxId:t,accountId:n,messages:s}=e,r=De(),{pushError:o}=Ye(),{mutateAsync:i,isPending:c}=Me({...Mn(),onError:(h,m)=>{const f=m.body.isRead??!0;o({title:f?"Couldn't mark as read":"Couldn't mark as unread",detail:Ve(h),error:h})},onSettled:(h,m,f)=>{nt(r,tt(Xs(f.body.messageIds??[],s??[],t))),n&&r.invalidateQueries({queryKey:Ot({path:{accountId:n}})})}});return{toggleReadFor:l.useCallback((h,m)=>{h.length!==0&&Zt(h,f=>i({body:{messageIds:f,isRead:m}}))},[i]),isPending:c}},ch=60,uh=1.5,dh=(e,t,n)=>{const s=Math.abs(e),r=Math.abs(t);return s<n?{direction:null}:s<r*uh?{direction:null}:{direction:e<0?"left":"right"}},fh=({onSwipeLeft:e,onSwipeRight:t,thresholdPx:n=ch})=>{const s=l.useRef(null),r=l.useCallback(u=>{if(u.pointerType==="mouse"){s.current=null;return}s.current={x:u.clientX,y:u.clientY}},[]),o=l.useCallback(()=>{},[]),i=l.useCallback(u=>{const h=s.current;if(s.current=null,!h)return;const{direction:m}=dh(u.clientX-h.x,u.clientY-h.y,n);m==="left"&&e?.(),m==="right"&&t?.()},[e,t,n]),c=l.useCallback(()=>{s.current=null},[]);return{handlers:{onPointerDown:r,onPointerMove:o,onPointerUp:i,onPointerCancel:c}}},mh=(e,t,n)=>t?.find(s=>s.messageId===e)?.mailboxId??n,ca=(e,t,n)=>e.map(s=>s.messageId===t?{...s,hasStars:n}:s),vi=({threadId:e,mailboxId:t,messages:n})=>{const s=De(),{pushError:r}=Ye(),{mutate:o,isPending:i,variables:c}=Me({...yl(),onMutate:async h=>{const m=h.path.messageId,f=h.body.isStarred??!1,p=dt({path:{threadId:e}}),v=tt([mh(m,n,t)]);await Promise.all([s.cancelQueries({queryKey:p}),on(s,v)]);const y=s.getQueriesData({queryKey:p}).filter(g=>g[1]!==void 0).map(([g,x])=>({queryKey:g,data:x})),d=ln(s,v);return s.setQueriesData({queryKey:p},g=>bi(g,x=>ca(x,m,f))),cn(s,v,g=>ca(g,m,f)),{threadMessagesPrefix:p,listPrefixes:v,previousThreadMessages:y,previousThreadsList:d}},onError:(h,m,f)=>{if(f){for(const v of f.previousThreadMessages)s.setQueryData(v.queryKey,v.data);un(s,f.previousThreadsList)}const p=m.body.isStarred??!1;r({title:p?"Couldn't star message":"Couldn't unstar message",detail:Ve(h),error:h})},onSettled:(h,m,f,p)=>{p&&(s.invalidateQueries({queryKey:p.threadMessagesPrefix}),nt(s,p.listPrefixes))}});return{toggleStar:(h,m)=>{o({path:{messageId:h},body:{isStarred:!m}})},isPending:i,pendingMessageId:i?c?.path.messageId:void 0}};function xi(e){return e===void 0?"uncategorized":e}const ph={inbox:"Inbox",junk:"Junk"},Js=e=>e.destinationMailboxId!==void 0,hh=(e,t)=>{if(Js(e))return`Moved from ${t??"another folder"} by Remit`;const n=e.fromPlacement??"";return`Moved from ${ph[n]??"another folder"} by Remit`},gh=(e,t)=>{if(e===fr.MoveToInbox)return t.inboxMailboxId;if(e===fr.MoveToJunk)return t.junkMailboxId},bh=(e,t,n)=>{if(!e||!t)return!1;const s=Js(e)?e.destinationMailboxId:gh(e.action,n);return s!==void 0&&s===t},vh="Reported as spam",xh=(e,t)=>{if(e){if(Js(e))return e.fromMailboxId;if(e.fromPlacement==="inbox")return t.inboxMailboxId;if(e.fromPlacement==="junk")return t.junkMailboxId}},Un=(e,t)=>{const{data:n,isLoading:s}=he({...Lt(),staleTime:1/0,enabled:!!e});return{mailboxId:l.useMemo(()=>e?n?.accounts.find(i=>i.accountId===e)?.folderAppointments.find(i=>i.role===t)?.mailboxId:void 0,[n,e,t]),isLoading:s}},dv=e=>{const{mailboxId:t,isLoading:n}=Un(e,"Archive");return{archiveMailboxId:t,isLoading:n}},fv=e=>{const{mailboxId:t,isLoading:n}=Un(e,"Drafts");return{draftsMailboxId:t,isLoading:n}},yh=e=>{const{mailboxId:t,isLoading:n}=Un(e,"Inbox");return{inboxMailboxId:t,isLoading:n}},yi=e=>{const{mailboxId:t,isLoading:n}=Un(e,"Junk");return{junkMailboxId:t,isLoading:n}},wi=e=>{const{data:t}=he({...Lt(),staleTime:1/0,enabled:!!e});return l.useMemo(()=>t?.accounts.find(n=>n.accountId===e)?.folderAppointments??[],[t,e])},ua=(e,t)=>e.filter(n=>!t.has(n.messageId)),Kn=({mailboxId:e,threadId:t,accountId:n,onAfterOptimisticRemove:s})=>{const r=De(),{pushError:o}=Ye(),{mutateAsync:i,isPending:c,isError:u}=Me({...wl(),onMutate:async m=>{const f=new Set(m.body.messageIds??[]),p=t?dt({path:{threadId:t}}):[],v=tt([e,m.body.destinationMailboxId]);await Promise.all([...t?[r.cancelQueries({queryKey:p})]:[],on(r,v)]);const y=t?r.getQueriesData({queryKey:p}).filter(g=>g[1]!==void 0).map(([g,x])=>({queryKey:g,data:x})):[],d=ln(r,v);return t&&r.setQueriesData({queryKey:p},g=>g&&{...g,items:ua(g.items,f)}),cn(r,v,g=>ua(g,f)),s?.(Array.from(f)),{threadMessagesPrefix:p,listPrefixes:v,previousThreadMessages:y,previousThreadsList:d}},onError:(m,f,p)=>{if(p){for(const y of p.previousThreadMessages)r.setQueryData(y.queryKey,y.data);un(r,p.previousThreadsList)}const v=f.body.messageIds?.length??0;o({title:v>1?`Couldn't move ${v} messages`:"Couldn't move this message",detail:Ve(m),error:m})},onSettled:(m,f,p,v)=>{v&&(t&&r.invalidateQueries({queryKey:v.threadMessagesPrefix}),nt(r,v.listPrefixes),n&&r.invalidateQueries({queryKey:Ot({path:{accountId:n}})}))}});return{moveMessages:l.useCallback((m,f)=>{m.length!==0&&Zt(m,p=>i({body:{messageIds:p,destinationMailboxId:f}}))},[i]),isPending:c,isError:u}},wh="This message could not be processed. Please try again.",Sh=(e,t)=>e.replace(`Message ${t}'s`,"This message's"),da=e=>{if(e.failureCount===0)return;const t=e.failures?.[0],n=t?.reason??wh,s=t?Sh(n,t.messageId):n;throw new Cl(s,422)};function Si({mailboxId:e,threadId:t,accountId:n,onAfterOptimisticRemove:s}){const r=De(),{pushError:o}=Ye(),i=tt([e]),c=t?dt({path:{threadId:t}}):[],u=()=>{t&&r.invalidateQueries({queryKey:c}),nt(r,i),n&&r.invalidateQueries({queryKey:Ot({path:{accountId:n}})})},h=()=>(d,g)=>{u(),s?.(g.body.messageIds)},m=d=>(g,x)=>{o({title:d(x.body.messageIds.length),detail:Ve(g),error:g})},f=Me({mutationFn:async d=>{const{data:g}=await Sl({...d,throwOnError:!0});return da(g),g},meta:{softError:!0},onSuccess:h(),onError:m(d=>d>1?`Couldn't report ${d} messages as spam`:"Couldn't report this message as spam")}),p=Me({mutationFn:async d=>{const{data:g}=await kl({...d,throwOnError:!0});return da(g),g},meta:{softError:!0},onSuccess:h(),onError:m(d=>d>1?`Couldn't undo the spam report for ${d} messages`:"Couldn't undo the spam report")}),v=l.useCallback(d=>{d.length!==0&&Zt(d,g=>f.mutateAsync({body:{messageIds:g}}))},[f.mutateAsync]),y=l.useCallback(d=>{d.length!==0&&Zt(d,g=>p.mutateAsync({body:{messageIds:g}}))},[p.mutateAsync]);return{reportSpam:v,notSpam:y,isReporting:f.isPending,isRestoring:p.isPending}}const kh=({accountId:e,messageId:t,threadId:n,mailboxId:s,autoMoved:r,spamReport:o})=>{const{inboxMailboxId:i}=yh(e),{junkMailboxId:c}=yi(e),{moveMessages:u,isPending:h}=Kn({mailboxId:s,threadId:n,accountId:e}),{notSpam:m,isRestoring:f}=Si({mailboxId:s,threadId:n,accountId:e}),{data:p}=he({...nn({path:{accountId:e??""}}),staleTime:1/0,enabled:!!e&&r?.fromMailboxId!==void 0}),v={inboxMailboxId:i,junkMailboxId:c},y=xh(r,v),d=l.useCallback(()=>{y&&u([t],y)},[u,t,y]),g=l.useCallback(()=>{m([t])},[m,t]);if(o)return{show:!0,label:vh,onUndo:g,isUndoing:f};if(!bh(r,s,v)||!r)return{show:!1,label:"",isUndoing:!1};const k=r.fromMailboxId?p?.items.filter(b=>b.mailboxId===r.fromMailboxId).map(b=>El(b.fullPath))[0]:void 0;return{show:!0,label:hh(r,k),onUndo:y?d:void 0,isUndoing:h,...r.filterId?{filtersHref:"/settings/filters"}:{}}};function Ch({accountId:e,messageId:t,threadId:n,mailboxId:s,autoMoved:r,spamReport:o}){const i=kh({accountId:e,messageId:t,threadId:n,mailboxId:s,autoMoved:r,spamReport:o});return i.show?a.jsx(bd,{label:i.label,onUndo:i.onUndo,undoLabel:i.isUndoing?"Undoing…":"Undo",filtersHref:i.filtersHref}):null}const fa=(e,t)=>e.filter(n=>!t.has(n.messageId)),mv=e=>e.filter(t=>t.isDeleted!==!0),Zs=({mailboxId:e,threadId:t,accountId:n,messages:s,onAfterOptimisticRemove:r})=>{const o=De(),{pushError:i}=Ye(),{mutateAsync:c,isPending:u}=Me({...Nl(),onMutate:async m=>{const f=new Set(m.body.messageIds??[]),p=t?dt({path:{threadId:t}}):[],v=tt(Xs(f,s??[],e));await Promise.all([o.cancelQueries({queryKey:p}),on(o,v)]);const y=t?o.getQueriesData({queryKey:p}).filter(g=>g[1]!==void 0).map(([g,x])=>({queryKey:g,data:x})):[],d=ln(o,v);return t&&o.setQueriesData({queryKey:p},g=>g&&{...g,items:fa(g.items,f)}),cn(o,v,g=>fa(g,f)),r?.(Array.from(f)),{threadMessagesPrefix:p,listPrefixes:v,previousThreadMessages:y,previousThreadsList:d}},onError:(m,f,p)=>{if(p){for(const y of p.previousThreadMessages)o.setQueryData(y.queryKey,y.data);un(o,p.previousThreadsList)}const v=f.body.messageIds?.length??0;i({title:v>1?`Couldn't delete ${v} messages`:"Couldn't delete this message",detail:Ve(m),error:m})},onSettled:(m,f,p,v)=>{v&&(t&&o.invalidateQueries({queryKey:v.threadMessagesPrefix}),nt(o,v.listPrefixes),n&&o.invalidateQueries({queryKey:Ot({path:{accountId:n}})}))}});return{deleteMessages:l.useCallback(m=>{m.length!==0&&Zt(m,f=>c({body:{messageIds:f}}))},[c]),isPending:u}},ki="inline-flex items-center justify-center transition-colors",Eh=Ze(ki,"min-h-11 min-w-11 rounded hover:bg-surface-raised"),Nh=Ze(ki,"min-h-11 gap-1.5 px-3 rounded text-sm font-medium hover:bg-surface-raised"),er=({accountId:e,currentMailboxId:t,onMove:n,disabled:s=!1,disabledHint:r,variant:o="icon-only",label:i})=>{const[c,u]=l.useState(!1),[h,m]=l.useState(),f=Dn(),p=l.useRef(null),v=i??"Move to folder",y=l.useId(),{t:d}=jl("mail",{useSuspense:!1}),g=Ha(),{data:x,isLoading:k,isError:b,error:w,refetch:E}=he({...nn({path:{accountId:e}}),staleTime:1/0,enabled:c}),j=wi(e),{createFolderIn:R}=Wa(e),T=l.useMemo(()=>qa({mailboxes:x?.items??[],folderAppointments:j,currentMailboxId:t,translator:g}),[x?.items,j,t,g]),P=Va(x?.items??[]),F=T.find(C=>C.id===h),I=l.useCallback(()=>{u(!1),m(void 0)},[]),z=l.useCallback(()=>{F&&(I(),n(F.id))},[F,I,n]);l.useEffect(()=>{if(!c||!f)return;const C=N=>{p.current&&!p.current.contains(N.target)&&I()},D=N=>{N.key==="Escape"&&I()};return document.addEventListener("mousedown",C),document.addEventListener("keydown",D),()=>{document.removeEventListener("mousedown",C),document.removeEventListener("keydown",D)}},[c,f,I]);const A=s||!!r,S=a.jsxs("button",{type:"button",onClick:C=>{C.stopPropagation(),!A&&u(D=>!D)},"aria-label":v,"aria-haspopup":f?"tree":"dialog","aria-expanded":c,"aria-controls":c?y:void 0,title:r,className:o==="icon-only"?Eh:Nh,children:[a.jsx(As,{className:o==="icon-only"?"size-5":"size-4"}),o==="compact"&&a.jsx("span",{className:"hidden sm:inline",children:"Move"})]}),M=k?a.jsx("div",{className:"px-3 py-5 text-sm text-fg-muted",children:"Loading folders…"}):b?a.jsx("div",{className:"p-3",children:a.jsx(sn,{variant:"inline",title:"Couldn't load folders",error:w,onRetry:()=>E()})}):a.jsx(Tl,{folders:T,selectedId:h,delimiter:P,onSelect:m,onCreateFolder:R,onCancel:I,labels:{filterPlaceholder:d("move_picker_filter_placeholder",{defaultValue:"Filter folders…"}),filterAriaLabel:d("move_picker_filter_label",{defaultValue:"Filter folders"})}}),O=F&&a.jsx("div",{className:"shrink-0 border-t border-line p-2",children:a.jsx(te,{variant:"primary",onClick:z,className:"h-11 w-full font-semibold",children:`Move to ${F.label}`})});return f?a.jsxs("div",{ref:p,className:"relative inline-block",children:[S,c&&a.jsxs("div",{id:y,className:Ze("absolute right-0 mt-1 z-50 w-72 max-h-96 flex flex-col","bg-surface border border-line rounded-md shadow-lg"),children:[M,O]})]}):a.jsxs(a.Fragment,{children:[S,a.jsx(Tt.Root,{open:c,onOpenChange:C=>C?u(!0):I(),children:a.jsxs(Tt.Portal,{children:[a.jsx(Tt.Overlay,{className:"fixed inset-0 z-40 bg-black/40"}),a.jsxs(Tt.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:y,children:[a.jsx(Tt.Handle,{className:"mx-auto mt-2 mb-1 h-1.5 w-12 rounded-full bg-fg-subtle/30"}),a.jsx(Tt.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:M}),O]})]})})]})},jh=({messageId:e,threadId:t,mailboxId:n,isRead:s,accountId:r,fromAddressId:o,isTrusted:i=!1,showRaw:c=!1,onToggleRaw:u})=>{const h=De(),m=Ls(),{pushError:f}=Ye(),{selectedMessageId:p}=Rl({strict:!1}),{mutate:v,isPending:y}=Me({...Mn(),onMutate:async M=>{const O=M.body.isRead??!0,C=new Set(M.body.messageIds??[]),D=dt({path:{threadId:t}}),N=tt([n]);await Promise.all([h.cancelQueries({queryKey:D}),on(h,N)]);const V=h.getQueriesData({queryKey:D}).filter(re=>re[1]!==void 0).map(([re,ne])=>({queryKey:re,data:ne})),W=ln(h,N);return h.setQueriesData({queryKey:D},re=>re&&{...re,items:Tn(re.items,C,O)}),cn(h,N,re=>Tn(re,C,O)),{threadMessagesPrefix:D,listPrefixes:N,previousThreadMessages:V,previousThreadsList:W}},onError:(M,O,C)=>{if(C){for(const N of C.previousThreadMessages)h.setQueryData(N.queryKey,N.data);un(h,C.previousThreadsList)}const D=O.body.isRead??!0;f({title:D?"Couldn't mark as read":"Couldn't mark as unread",detail:Ve(M),error:M})},onSettled:(M,O,C,D)=>{D&&(h.invalidateQueries({queryKey:D.threadMessagesPrefix}),nt(h,D.listPrefixes))}}),d=l.useCallback(M=>{p&&M.includes(p)&&m({to:"/mail/$mailboxId",params:{mailboxId:n},search:O=>({...O,selectedMessageId:void 0})})},[p,n,m]),{deleteMessages:g,isPending:x}=Zs({mailboxId:n,threadId:t,onAfterOptimisticRemove:d}),{moveMessages:k,isPending:b}=Kn({mailboxId:n,threadId:t,accountId:r,onAfterOptimisticRemove:d}),{toggleTrusted:w,isPending:E,error:j,reset:R}=Fa({messageId:e}),T=()=>{v({body:{messageIds:[e],isRead:!1}})},P=()=>{g([e])},F=()=>{o&&w(o,i)},I=y||x||b||E,z=I||!o,A=l.useCallback(M=>{k([e],M)},[k,e]),S=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(er,{accountId:r,currentMailboxId:n,onMove:A,disabled:I,label:"Move this message"}),a.jsxs(uc,{trigger:a.jsx(ao,{className:"size-4"}),children:[a.jsxs(dn,{onClick:F,disabled:z,children:[i?a.jsx(Ln,{className:"size-4 text-positive"}):a.jsx(Rn,{className:"size-4 opacity-0"}),a.jsx("span",{title:S,children:"Trusted sender"})]}),s&&a.jsxs(dn,{onClick:T,disabled:I,children:[a.jsx(Ks,{className:"size-4"}),"Mark as unread"]}),u&&a.jsxs(dn,{onClick:u,children:[a.jsx(ro,{className:"size-4"}),c?"Show formatted":"Show raw email"]}),a.jsx(dc,{}),a.jsxs(dn,{onClick:P,disabled:I,destructive:!0,children:[a.jsx(tn,{className:"size-4"}),"Delete"]})]})]}),j&&a.jsx("div",{className:"w-64",children:a.jsx(sn,{variant:"inline",title:"Couldn't update trust",error:j,onRetry:()=>{R(),F()}})})]})},Th=e=>e==="link-expired"||e==="not-ready";class js extends Error{reason;status;constructor(t,n,s){super(n),this.name="AttachmentFetchError",this.reason=t,this.status=s}}const Rh="x-remit-403-reason",Ih="expired",Mh=(e,t)=>{if(t?.trim()===Ih)return"link-expired";const n=Cc(e,t);return n==="auth"?"auth":n==="body-missing"?"missing":"generic"},Ah=300*1e3,ma=async(e,t)=>{const n={},s=await t();s&&(n.Authorization=`Bearer ${s}`);const r=await Al(e,{headers:n,signal:AbortSignal.timeout(Ah)});if(r.status===202)throw new js("not-ready","Attachment is still being fetched from the mail server",202);if(!r.ok)throw new js(Mh(r.status,r.headers.get(Rh)),`Failed to download attachment (${r.status} ${r.statusText})`,r.status);return r.blob()},Dh=(e,t,n)=>{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:n}}},pa=e=>e instanceof js?e.reason:"generic",Ph=e=>e instanceof Error?e.message:typeof e=="string"?e:"An unexpected error occurred while downloading this attachment.",Lh=(e,t,n)=>{if(e!=="auth")return Il(Ml({title:`Bug: attachment download failed (${e})`,errorMessage:`Downloading "${t}" failed: ${n}`}))},Oh=(e,t)=>{const n=URL.createObjectURL(e),s=document.createElement("a");s.href=n,s.download=t,s.rel="noopener",document.body.append(s),s.click(),s.remove(),setTimeout(()=>URL.revokeObjectURL(n),0)},$h=e=>{const t=e.toUpperCase();return t==="OCTET-STREAM"?"FILE":t},Fh=e=>{const t=e.toLowerCase().replace(/[^a-z0-9]/g,"");return t.length>0?`attachment.${t}`:"attachment"},ha=e=>e.filter(t=>!t.isMultipart&&t.disposition===Dc.Attachment&&t.contentUrl.length>0).map(t=>({bodyPartId:t.bodyPartId,filename:md(t.dispositionFilename??"",Fh(t.mediaSubtype)),typeLabel:$h(t.mediaSubtype),sizeOctets:t.sizeOctets,contentUrl:t.contentUrl})),ga={status:"idle"},_h=({messageId:e,bodyParts:t,hasAttachment:n=!1,className:s})=>{const{getToken:r}=Dl(),o=De(),[i,c]=l.useState({}),u=l.useMemo(()=>ha(t??[]),[t]),h=Pl({path:{messageId:e}}),m=y=>ma(y.contentUrl,r).catch(d=>{if(!Th(pa(d)))throw d;return o.refetchQueries({queryKey:h}).then(()=>{const g=o.getQueryData(h),x=g?ha(g.bodyParts).find(k=>k.bodyPartId===y.bodyPartId):void 0;return ma(x?.contentUrl??y.contentUrl,r)})}),f=(y,d)=>c(g=>({...g,[y]:d})),p=y=>{const d=u.find(g=>g.bodyPartId===y);if(!d)throw new Error(`No attachment part ${y} on message ${e}`);f(y,{status:"downloading"}),m(d).then(g=>{Oh(g,d.filename),f(y,ga)}).catch(g=>{const x=pa(g),k=Ph(g),{title:b,detail:w}=Dh(x,d.filename,k);f(y,{status:"failed",title:b,detail:w,reportUrl:Lh(x,d.filename,k)})})},v=n&&t!==void 0&&u.length===0;return a.jsx(gd,{className:s,attachments:u.map(y=>({attachmentId:y.bodyPartId,filename:y.filename,typeLabel:y.typeLabel,sizeOctets:y.sizeOctets,download:i[y.bodyPartId]??ga})),onDownload:p,hasUnlistedAttachment:v})},zh=({messageId:e,threadId:t,mailboxId:n,accountId:s,isRead:r,isStarred:o,onToggleStar:i,fromAddressId:c,isTrusted:u,showRaw:h,onToggleRaw:m,onReply:f,onReplyAll:p,onForward:v})=>{const y=De(),{deleteMessages:d}=Zs({mailboxId:n,threadId:t}),{moveMessages:g}=Kn({mailboxId:n,threadId:t,accountId:s}),{toggleTrusted:x}=Fa({messageId:e}),{mutate:k}=Me({...Mn(),onSettled:()=>{y.invalidateQueries({queryKey:dt({path:{threadId:t}})}),nt(y,tt([n]))}}),b=l.useCallback(R=>{g([e],R)},[g,e]),w=l.useCallback(()=>{d([e])},[d,e]),E=l.useCallback(()=>{k({body:{messageIds:[e],isRead:!r}})},[k,e,r]),j=[];return c&&j.push({key:"trusted",label:u?"Trusted sender":"Mark sender trusted",icon:u?a.jsx(Ln,{className:"size-4 text-positive"}):a.jsx(Rn,{className:"size-4"}),onSelect:()=>x(c,u)}),m&&j.push({key:"raw",label:h?"Show formatted":"Show raw email",icon:a.jsx(ro,{className:"size-4"}),onSelect:m}),a.jsx(bo,{hasThread:!0,onReply:f,onReplyAll:p,onForward:v,isStarred:o,onToggleStar:i,onDelete:w,isRead:r,onToggleRead:E,overflowItems:j,moveSlot:s?a.jsx(er,{accountId:s,currentMailboxId:n,onMove:b,label:"Move this message"}):void 0})},Bh=()=>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"})]}),Uh=({messageId:e,enabled:t=!0})=>{const{data:n,isLoading:s,isError:r,error:o,refetch:i}=he({...Ll({path:{messageId:e}}),enabled:t});if(s)return a.jsx("div",{className:"message-body",children:a.jsx(Bh,{})});if(r)return a.jsx("div",{className:"message-body",children:a.jsx(sn,{variant:"inline",title:"Couldn't load the raw email",error:o,onRetry:()=>i()})});const c=n?.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})})},Kh=()=>a.jsx(Ln,{className:"inline-block size-4 ml-1 -mt-0.5 text-positive align-middle","aria-label":"Trusted sender","data-testid":"trusted-sender-badge"}),Ci=(e,t)=>({id:e.messageId,fromName:e.fromName??e.fromEmail??"?",fromEmail:e.fromEmail??"",toLabel:"",dateLabel:t,snippet:e.snippet||"",bodyHtml:""}),Ei=({isStarred:e,onToggleStar:t,isStarPending:n,hoverReveal:s})=>a.jsx("button",{type:"button",onClick:r=>{r.stopPropagation(),t()},disabled:n,"aria-label":e?"Remove star":"Add star",className:Ze("shrink-0 p-0.5 rounded transition-colors",e?"text-warning":Ze("text-fg-subtle hover:text-warning",s&&"opacity-0 group-hover:opacity-100 focus:opacity-100"),n&&"opacity-50"),children:a.jsx(Pt,{className:Ze("size-3.5",e&&"fill-current")})}),Hh=({threadMessage:e,isFocused:t,onToggle:n,onToggleStar:s,isStarPending:r})=>{const o=Ka(e.sentDate,"datetime"),i=Ci(e,o);return a.jsx(vo,{message:i,onClick:n,isFocused:t,isUnread:!e.isRead,trailing:a.jsxs(a.Fragment,{children:[e.hasAttachment&&a.jsx(On,{className:"size-3 shrink-0 text-fg-subtle",role:"img","aria-label":"Has an attachment"}),a.jsx(Ei,{isStarred:e.hasStars,onToggleStar:s,isStarPending:r,hoverReveal:!0}),a.jsx("span",{"data-testid":"message-date",className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:o})]})})},Wh=({threadMessage:e,messageData:t,isLoading:n,isError:s,error:r,onRetry:o,isFocused:i,onToggle:c,onToggleStar:u,isStarPending:h,accountId:m,showRaw:f,onToggleRaw:p,mobile:v,onReply:y,onReplyAll:d,onForward:g})=>{const x=Ka(e.sentDate,"long"),k=!e.isRead,b=t?.envelope.from[0]?.flags?.trusted?.value===!0,w=t?.envelope.from[0]?.addressId,E=Ci(e,x),j=e.autoMoved||e.spamReport?a.jsx(Ch,{accountId:m,messageId:e.messageId,threadId:e.threadId,mailboxId:e.mailboxId,autoMoved:e.autoMoved,spamReport:e.spamReport}):null;return a.jsx(xo,{message:E,isFocused:v?!1:i,onHeaderClick:c,senderBadge:b?a.jsx(Kh,{}):void 0,trailing:a.jsx("span",{"data-testid":"message-date",className:"text-2xs text-fg-subtle",children:x}),to:t?a.jsx(zu,{label:"To",addresses:t.envelope.to}):null,indicators:j||!v?a.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mt-0.5",children:[j,!v&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"flex items-center justify-end gap-1",children:a.jsx(Ei,{isStarred:e.hasStars,onToggleStar:u,isStarPending:h})}),k&&a.jsx("span",{className:"size-1.5 rounded-full bg-accent","aria-label":"Unread"})]})]}):void 0,actionMenu:v?void 0:a.jsx(jh,{messageId:e.messageId,threadId:e.threadId,mailboxId:e.mailboxId,isRead:e.isRead,accountId:m,fromAddressId:w,isTrusted:b,showRaw:f,onToggleRaw:p}),actionBar:v?a.jsx(zh,{messageId:e.messageId,threadId:e.threadId,mailboxId:e.mailboxId,accountId:m,isRead:e.isRead,isStarred:e.hasStars,onToggleStar:u,fromAddressId:w,isTrusted:b,showRaw:f,onToggleRaw:p,onReply:y,onReplyAll:d,onForward:g}):void 0,body:n?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"})]}):s&&Ol(r)?a.jsx("div",{className:"mt-3",children:a.jsx(fi,{message:"This message has been deleted"})}):s?a.jsx("div",{className:"mt-3",children:a.jsx(sn,{variant:"inline",title:"Couldn't load this message",error:r,onRetry:o})}):f?a.jsx("div",{className:"mt-3",children:a.jsx(Uh,{messageId:e.messageId})}):a.jsxs("div",{className:"mt-3",children:[a.jsx(Ec,{bodyParts:t?.bodyParts,messageId:e.messageId,fromAddressId:t?.envelope.from[0]?.addressId,isTrusted:b,category:xi(e.category)}),a.jsx(_h,{messageId:e.messageId,bodyParts:t?.bodyParts,hasAttachment:e.hasAttachment,className:"mt-4 px-2 lg:px-0"})]})})},qh=({threadMessage:e,isExpanded:t,isFocused:n,onToggle:s,onToggleStar:r,isStarPending:o,accountId:i,mobile:c,onReply:u,onReplyAll:h,onForward:m})=>{const[f,p]=l.useState(!1),{data:v,isLoading:y,isError:d,error:g,refetch:x}=he({...An({path:{messageId:e.messageId}}),enabled:t,meta:{softError:!0}});return t?a.jsx(Wh,{threadMessage:e,messageData:v,isLoading:y,isError:d,error:g,onRetry:()=>x(),isFocused:n,onToggle:s,onToggleStar:r,isStarPending:o,accountId:i,showRaw:f,onToggleRaw:()=>p(k=>!k),mobile:c,onReply:u,onReplyAll:h,onForward:m}):a.jsx(Hh,{threadMessage:e,isFocused:n,onToggle:s,onToggleStar:r,isStarPending:o})},Vh=()=>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))})]});function ba({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(Ft,{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:"shrink-0 text-2xs font-medium text-danger hover:underline",children:"Why?"})]}):null}const pv=({threadId:e,mailboxId:t,subject:n,selectedMessageId:s,authenticity:r,onOpenIntelligence:o,onBack:i,composeRequest:c,onComposeClose:u,onSwipeNext:h,onSwipePrevious:m,mobileIntelligenceOpen:f})=>{const p=Dn(),{handlers:v}=fh({onSwipeLeft:h,onSwipeRight:m}),{accountId:y}=mi(t),{data:d,isLoading:g,isError:x,error:k,refetch:b}=he({...$l({path:{threadId:e}})}),w=l.useMemo(()=>d?.items??[],[d?.items]),E=w[w.length-1],j=l.useRef(new Map),[R,T]=l.useState(new Set),[P,F]=l.useState(null),[I,z]=l.useState(0);l.useEffect(()=>{if(w.length>0&&e!==P){F(e);const Q=new Set([w[w.length-1].threadMessageId]);if(s){const Z=w.find(ae=>ae.messageId===s);Z&&Q.add(Z.threadMessageId)}T(Q),z(w.length-1)}},[e,w,P,s]);const A=l.useCallback(Q=>{T(Z=>{const ae=new Set(Z);return ae.has(Q)?ae.delete(Q):ae.add(Q),ae})},[]),S=l.useCallback(Q=>{const Z=w[Q];if(!Z)return;j.current.get(Z.threadMessageId)?.scrollIntoView({behavior:"smooth",block:"nearest"})},[w]),M=l.useCallback(()=>{if(w.length===0)return;const Q=Math.min(I+1,w.length-1);z(Q),S(Q)},[w.length,I,S]),O=l.useCallback(()=>{if(w.length===0)return;const Q=Math.max(I-1,0);z(Q),S(Q)},[w.length,I,S]),C=l.useCallback(()=>{const Q=w[I];Q&&A(Q.threadMessageId)},[w,I,A]),{data:D}=he({...Lt(),staleTime:1/0}),N=D?.accounts?.[0];lh({messages:w,expandedIds:R,threadId:e,mailboxId:t,accountId:N?.accountId});const{toggleStar:V,isPending:W,pendingMessageId:re}=vi({threadId:e,mailboxId:t,messages:w}),[ne,de]=l.useState(null),[se,ge]=l.useState(0),q=l.useCallback(Q=>{de(Q),ge(Z=>Z+1)},[]);l.useEffect(()=>{c&&c!=="new"&&(q(c),u?.())},[c,u,q]);const{data:xe}=he({...An({path:{messageId:E?.messageId??""}}),enabled:!!E&&ne!==null}),J=l.useCallback(()=>q("reply"),[q]),ke=l.useCallback(()=>q("reply_all"),[q]),be=l.useCallback(()=>q("forward"),[q]),Te=l.useCallback(()=>{de(null),u?.()},[u]),Ce=l.useRef(null);if(l.useEffect(()=>{if(ne===null||se===0)return;const Q=Ce.current;if(!Q)return;const Z=()=>Q.scrollIntoView({behavior:"smooth",block:"end"});if(Z(),typeof ResizeObserver>"u")return;const ae=new ResizeObserver(Z);return ae.observe(Q),()=>ae.disconnect()},[se,ne]),fc({enabled:!g&&w.length>0&&ne===null,bindings:[{key:"j",handler:M,preventDefault:!0},{key:"ArrowDown",handler:M,preventDefault:!0},{key:"k",handler:O,preventDefault:!0},{key:"ArrowUp",handler:O,preventDefault:!0},{key:"Enter",handler:C,preventDefault:!0},{key:"o",handler:C,preventDefault:!0},{key:"r",handler:J,preventDefault:!0},{key:"R",handler:ke,noModifiers:!1,preventDefault:!0},{key:"f",handler:be,preventDefault:!0}]}),g)return a.jsx(Vh,{});if(x)return a.jsx("div",{className:"flex h-full items-center justify-center",children:a.jsx(sn,{title:"Couldn't load this conversation",error:k,onRetry:()=>b()})});if(w.length===0)return a.jsx("div",{className:"flex h-full items-center justify-center",children:a.jsx(fi,{message:"No messages in this thread"})});const U=n||w[0]?.subject||"(No subject)",ye=w.length,Ne=Q=>a.jsx("div",{children:w.map((Z,ae)=>a.jsx("div",{ref:$e=>{$e&&j.current.set(Z.threadMessageId,$e)},children:a.jsx(qh,{threadMessage:Z,isExpanded:R.has(Z.threadMessageId),isFocused:ae===I,onToggle:()=>A(Z.threadMessageId),onToggleStar:()=>V(Z.messageId,Z.hasStars),isStarPending:W&&re===Z.messageId,accountId:y,mobile:Q,onReply:Q?J:void 0,onReplyAll:Q?ke:void 0,onForward:Q?be:void 0})},Z.threadMessageId))}),Pe=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:U}),a.jsxs("p",{className:"mt-1 text-2xs text-fg-subtle",children:[ye," ",ye===1?"message":"messages"]})]});return p?a.jsxs("article",{className:"h-full flex flex-col",children:[Pe,r?.dkimMismatch&&a.jsx(ba,{authenticity:r,onOpenIntelligence:o}),a.jsxs("div",{className:"min-h-0 flex-1 overflow-auto",children:[Ne(!1),ne!==null&&a.jsx("div",{ref:Ce,children:a.jsx(la,{mode:ne,account:N,sourceMessage:xe,onClose:Te})})]})]}):a.jsxs(id,{thread:{subject:U,messages:[]},onBack:i??(()=>{}),intelligenceOpen:f,onToggleIntelligence:o,touchHandlers:v,children:[r?.dkimMismatch&&a.jsx(ba,{authenticity:r,onOpenIntelligence:o}),Ne(!0),ne!==null&&a.jsx("div",{ref:Ce,children:a.jsx(la,{mode:ne,account:N,sourceMessage:xe,onClose:Te})})]})},Qh=10,Ni=e=>({q:e?.toLowerCase()??"",limit:Qh}),Gh=(e,t)=>{if(!t)return;const n=t.toLowerCase();return e?.find(s=>s.normalizedEmail===n)};function Yh(e){const t=new Date(e),n=new Date;return t.toDateString()===n.toDateString()?"today":Mc(t,{month:"short",year:"numeric"})}function ji(e){if(!e)return!0;const[,t]=e.split("@");return t?!t.includes("."):!0}const Xh="We can't verify the sender of this email, which could mean it's from an insecure source.",Jh="We couldn't read this sender's address, so we can't confirm who really sent this message.";function Zh(e,t){const n=e.category??"personal";return{value:_l(n)?n:"uncategorized",overridden:t?.flags?.category?.value!=null&&t.flags.category.value!==e.category}}function eg(e,t){return{name:e.fromName??e.fromEmail??"Unknown",email:e.fromEmail??"",trust:e.senderTrust,firstSeenLabel:t?Yh(t.createdAt):"unknown",inboundCount:t?.inboundCount,replyCount:t?.replyCount,addressUnverified:ji(e.fromEmail)}}function tg(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 va(e){if(e.fromName&&e.fromName!==e.fromEmail)return e.fromName}function ng(e){return e.length===1?e[0]:`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function sg(e,t){const n=[],s=e.displayNameCorrespondence;t&&(s===mr.Unrelated?n.push(`The name it shows, "${t}", has nothing to do with ${e.fromDomain}.`):s===mr.Lookalike&&n.push(`The name it shows, "${t}", only looks like ${e.fromDomain}.`));const r=rg(e.offDomainLinkDomains);return r.length>0&&n.push(`Its links go to ${ng(r.slice(0,3))}.`),n}function rg(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function ag(e,t){const n=t>0?t:void 0;if(ji(e.fromEmail))return{verdict:"mismatch",fromDomain:"",addressUnreadable:!0,summary:Jh,similarCount:n};const s=e.authenticity;if(!s)return{verdict:"caution",fromDomain:e.fromEmail?.split("@")[1]??"",summary:Xh};if(!s.dkimMismatch){const h=va(e),m=sg(s,h);return m.length>0?{verdict:"caution",fromDomain:s.fromDomain,dkimDomain:s.dkimDomain,claimedBrand:h,summary:m.join(" ")}:{verdict:"aligned",fromDomain:s.fromDomain,dkimDomain:s.dkimDomain,summary:s.dkimDomain?`This message was signed by ${s.dkimDomain}.`:"Nothing looks unusual about this sender."}}const r=s.fromDomain,o=s.dkimDomain,i=va(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:n}}function og(e,t){const n=e?.fromEmail??null,s=e?.subject??"",{data:r,error:o}=he({...In({query:Ni(n??void 0)}),enabled:!!n,staleTime:3e4}),i=Gh(r?.items,n??void 0),c=[s,n].filter(Boolean).join(" "),{data:u,isLoading:h,error:m}=he({...Fl({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(x=>x.messageId!==e.messageId).map(x=>({id:x.messageId,mailboxId:t!=null&&x.mailboxIds.includes(t)?t:x.mailboxIds[0]??"",fromName:x.fromName??"",subject:x.subject??"(No subject)",timeLabel:x.sentDate!=null?$t(x.sentDate*1e3):"",matched:x.matchedChunkType})),v=eg(e,i),y=ag(e,p.length),d=Zh(e,i),g=tg(i);return{sender:v,authenticity:y,category:d,flags:g,similar:p}},[e,i,u,t]),isSimilarLoading:h,similarError:m,similarErrorIsFatal:ir(m),addressErrorIsFatal:ir(o),addressId:i?.addressId,address:i}}function ig(e,t){const n={...e??{}};for(const[s,r]of Object.entries(t))r==null?delete n[s]:n[s]={...r,setAt:r.setAt??Date.now()};return n}function lg({addressId:e,senderEmail:t}){const n=De(),{pushError:s}=Ye(),r=zl({query:Ni(t)}),{mutate:o,isPending:i}=Me({...Bl(),onMutate:async u=>{const h=u.body.flags??{};await n.cancelQueries({queryKey:r});const m=n.getQueryData(r);return n.setQueryData(r,f=>f&&{...f,items:f.items.map(p=>p.addressId===u.path.addressId?{...p,flags:ig(p.flags,h)}:p)}),{previous:m}},onError:(u,h,m)=>{m?.previous!==void 0&&n.setQueryData(r,m.previous),s({title:"Couldn't update sender preference",detail:Ve(u),error:u})},onSettled:()=>{n.invalidateQueries({queryKey:r})}});return{updateFlags:l.useCallback(u=>{if(!e){Ul(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 hv=e=>e==="vip"?"A sender you know":e==="wellknown"?"You've emailed them before":"Passed authentication",cg=e=>e.senderTrust!=="vip"&&e.senderTrust!=="wellknown"?!1:e.authenticity?.dkimMismatch!==!0;function gv(e,t){e.recordEvent("rescue.candidates_surfaced",{count:String(t)})}function bv(e,t){e.recordEvent("rescue.flow_opened",{count:String(t)})}function vv(e,t){e.recordEvent("rescue.committed",{selected:String(t.selected),total:String(t.total),destination:t.toInbox?"inbox":"other"})}function ug(e,t){e.recordEvent("rescue.sent_to_junk",{count:String(t.count),senderTrust:t.senderTrust,wasRescuable:String(t.wasRescuable)})}const dg=["personal","newsletter","marketing","automated","transactional","social"],fg=e=>e.spamReport?"notSpam":"reportSpam",mg=e=>{const{similarError:t,similarErrorIsFatal:n,isSimilarLoading:s}=e;return t&&!n?"error":s?"loading":"ready"};function pg(){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(At,{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 hg({isOpen:e,current:t,onSelect:n,onCancel:s}){return e?a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[a.jsx(Hl,{label:"Dismiss reclassify sender",onDismiss:s,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:dg.map(r=>a.jsxs("button",{type:"button",onClick:()=>n(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:s,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 gg({thread:e,onClose:t,mailboxId:n,accountId:s,hideCloseButton:r,onAfterOptimisticRemove:o}){const{data:i,addressId:c,isSimilarLoading:u,similarError:h,similarErrorIsFatal:m}=og(e,n),[f,p]=l.useState(!1),v=e.fromEmail??void 0,{updateFlags:y}=lg({addressId:c,senderEmail:v}),{reportSpam:d,notSpam:g,isReporting:x,isRestoring:k}=Si({mailboxId:e.mailboxId,threadId:e.threadId,accountId:s,onAfterOptimisticRemove:o}),b=Kl(),w=fg(e),E=l.useCallback(()=>{g([e.messageId])},[g,e.messageId]),j=l.useCallback(()=>{ug(b,{count:1,senderTrust:e.senderTrust,wasRescuable:cg(e)}),d([e.messageId])},[d,e,b]),R=l.useCallback(()=>{},[]),T=l.useCallback(()=>{const O=i?.flags?.vip!==!0;y({vip:{value:O}})},[i?.flags?.vip,y]),P=l.useCallback(()=>{const O=i?.flags?.muted!==!0;y({muted:{value:O}})},[i?.flags?.muted,y]),F=l.useCallback(()=>{const O=i?.flags?.unsubscribed!==!0;y({unsubscribed:{value:O}})},[i?.flags?.unsubscribed,y]),I=l.useCallback(O=>{p(!1),y({category:{value:O}})},[y]),z=c!==void 0,A={onToggleVip:z?T:void 0,onToggleMute:z?P:void 0,onToggleUnsubscribe:z?F:void 0,onReclassify:z?()=>p(!0):void 0,onNotSpam:w==="notSpam"?E:void 0,onReportSpam:w==="reportSpam"?j:void 0},S=({mailboxId:O,messageId:C,className:D,ariaLabel:N,children:V})=>a.jsx($a,{to:"/mail/$mailboxId",params:{mailboxId:O},search:W=>({...W,selectedMessageId:C}),variant:"row",className:D,"aria-label":N,children:V});if(!i)return a.jsx(pg,{});const M=mg({similarError:h,similarErrorIsFatal:m,isSimilarLoading:u});return a.jsxs(a.Fragment,{children:[a.jsx(co,{data:i,onClose:t,hideCloseButton:r,onShowSimilar:R,actions:A,similarState:M,similarLinkComponent:S,reportSpamPending:x,notSpamPending:k,className:"border-l-0 h-full w-full"}),a.jsx(hg,{isOpen:f,current:i.category.value,onSelect:I,onCancel:()=>p(!1)})]})}const xv=({onClose:e,thread:t,mailboxId:n,accountId:s,hideCloseButton:r,onAfterOptimisticRemove:o})=>t?a.jsx(gg,{thread:t,onClose:e,mailboxId:n,accountId:s,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(At,{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(At,{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."})]})]}),bg={delete:(e,t)=>`Deleting ${e} of ${t}…`,move:(e,t)=>`Moving ${e} of ${t}…`,markRead:(e,t)=>`Marking ${e} of ${t} as read…`},Ti={delete:"moved to Trash",move:"moved",markRead:"marked as read"},vg={delete:"couldn't be deleted",move:"couldn't be moved",markRead:"couldn't be marked as read"},xg={delete:"Couldn't delete these messages",move:"Couldn't move these messages",markRead:"Couldn't mark these messages as read"},yg={delete:"The delete didn't finish.",move:"The move didn't finish.",markRead:"The update didn't finish."},yv=(e,t,n)=>bg[e](vt(t),vt(n)),wv=(e,t)=>`${vt(t)} ${Ti[e]}. Your mail server is still catching up.`,Sv=e=>`Stopped after ${vt(e)}`,kv=(e,t,n)=>`${vt(t)} of ${vt(n)} ${Ti[e]}. Nothing was sent for the rest, so they are untouched.`,wg=(e,t)=>t>0?`Stopped after ${vt(t)} — some messages ${vg[e]}`:xg[e],Sg=e=>yg[e],Cv=e=>e==="delete"?"danger":"info",kg=100,Cg=(e,t)=>e.kind==="move"?[t,e.destinationMailboxId]:[t],Eg=({mailboxId:e,accountId:t,enabled:n,predicateKey:s,searchQuery:r})=>{const[o,i]=l.useState({kind:"idle"}),[c,u]=l.useState(void 0),[h,m]=l.useState(void 0),f=l.useRef(!1),p=l.useRef(!1),v=De(),{pushError:y}=Ye();l.useEffect(()=>{p.current||(f.current=!0),i({kind:"idle"})},[n,s]);const d=l.useRef(r);d.current=r;const g=l.useCallback(T=>async P=>{const{data:F}=await lr({path:{mailboxId:e},query:{...T,continuationToken:P,limit:kg},throwOnError:!0});return{ids:(F.items??[]).map(I=>I.messageId),continuationToken:F.continuationToken}},[e]),x=l.useCallback(async()=>{const{data:T}=await lr({path:{mailboxId:e},query:{...d.current,count:!0,results:!1},throwOnError:!0});if(T.count===void 0)throw new Error("the search returned no count for the selection");return T.count},[e]),k=l.useCallback(T=>async P=>{if(T.kind==="move"){const{data:I}=await Wl({body:{messageIds:P,destinationMailboxId:T.destinationMailboxId},throwOnError:!0});return I}if(T.kind==="markRead"){const{data:I}=await ql({body:{messageIds:P,isRead:!0},throwOnError:!0});return I}const{data:F}=await Vl({body:{messageIds:P},throwOnError:!0});return F},[]),b=l.useCallback(T=>{nt(v,tt(Cg(T,e))),t&&v.invalidateQueries({queryKey:Ot({path:{accountId:t}})})},[v,e,t]),w=l.useCallback(()=>{f.current=!1,i({kind:"counting"}),x().then(T=>{if(f.current){i({kind:"idle"});return}i({kind:"escalated",total:T})},T=>{y(hs("Couldn't count matching messages","The count didn't finish.",T)),i({kind:"idle"})})},[x,y]),E=l.useCallback(()=>{f.current=!0},[]),j=l.useCallback(()=>{p.current||(f.current=!0,i({kind:"idle"}))},[]),R=l.useCallback(async(T,P)=>{f.current=!1,p.current=!0,u(T);const F=S=>m(rh(S)),I=k(T),z=g(d.current);let A;try{A=P!==void 0?await pi(P,I,F,()=>f.current):await sh(z,o.kind==="escalated"?o.total:0,I,F,()=>f.current)}finally{p.current=!1}return u(void 0),m(void 0),i({kind:"idle"}),A.error&&y(hs(wg(T.kind,A.done),Sg(T.kind),A.error)),A.done>0&&b(T),A},[k,g,o,y,b]);return{phase:o,escalate:w,stop:E,clear:j,isRunning:c!==void 0,runningAction:c,progress:h,runAction:R}},Ng=120,jg=({keyboardFocusedMessageId:e,openMessageId:t,enabled:n,open:s,delayMs:r=Ng})=>{const o=l.useRef(s);o.current=s;const i=l.useRef(void 0);l.useEffect(()=>{const c=e;if(!n){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)},[n,e,t,r])},Ri="This account has no Junk folder appointed, so there is nowhere to file these. Appoint one under Settings › Folders.",Tg="These are already in Junk, so there is nowhere to file them.",Rg=(e,t)=>e!==void 0&&e!==t?e:void 0,Ev=(e,t)=>{if(Rg(e,t)===void 0)return e===void 0?Ri:Tg};function Ig(e,t){if(e.length!==0)return t!==void 0&&e.includes(t)?t:e[0]}const Mg={title:"",navSlot:null,titleMeta:null,searchSlot:null,searchField:null,searchResults:null,makeFilterSlot:null},Ts=l.createContext(Mg),Ii=()=>l.useContext(Ts),Mi=8,Ai=e=>e==="From"||e==="FromDomain",Ag=e=>({value:e.email,label:e.displayName??e.email,...e.displayName?{hint:e.email}:{},...e.fromSelection?{source:"selected"}:{}}),Dg=e=>{const t=No(e.email);if(t!==null)return{value:t,...e.fromSelection?{source:"selected"}:{}}},Pg=(e,t)=>e.value.toLowerCase().includes(t)||(e.label??"").toLowerCase().includes(t),Lg=(e,t,n)=>{if(!Ai(e))return[];const s=t.trim().toLowerCase(),r=new Set,o=[];for(const i of n){if(i.email.trim()==="")continue;const c=e==="From"?Ag(i):Dg(i);if(!c)continue;const u=c.value.toLowerCase();if(!(u===""||r.has(u))&&(r.add(u),u!==s&&!(s!==""&&!Pg(c,s))&&(o.push(c),o.length===Mi)))break}return o},Og=250,$g=2,Fg=(e,t,n)=>{const s=t.trim(),r=_s(s,Og),o=e!==void 0&&Ai(e),{data:i}=he({...In({query:{q:r,limit:Mi}}),enabled:o&&r.length>=$g});if(!o||e===void 0)return[];const c=[...n.map(u=>({email:u,fromSelection:!0})),...(i?.items??[]).map(u=>({email:u.normalizedEmail,...u.displayName?{displayName:u.displayName}:{}}))];return Lg(e,s,c)},Di=12,_g=e=>{const{envelope:t}=e,n=t.from[0];return{id:t.messageId,sender:n?jo({normalizedEmail:n.normalizedEmail,displayName:n.displayName}):"Unknown",subject:t.subject??"(No subject)",date:$t(t.date)}},zg=(e,t)=>{const n=e!==void 0&&t!==void 0,{data:s,isLoading:r}=he({...Ql({path:{mailboxId:e??""},query:{...t,limit:Di}}),enabled:n,staleTime:3e4});return{messages:(s?.items??[]).map(Bg),isPending:n&&r}},Bg=e=>({id:e.messageId,sender:e.fromName||e.fromEmail||"Unknown",subject:e.subject??"(No subject)",date:$t(e.sentDate)}),Ug=e=>Os({queries:e.slice(0,Di).map(t=>({...An({path:{messageId:t}}),staleTime:Number.POSITIVE_INFINITY})),combine:t=>({messages:t.map(n=>n.data).filter(n=>n!==void 0).map(_g),isPending:t.some(n=>n.isPending)})}),Kg=e=>({matchOperator:"Or",literalClauses:Fn(e)}),Hg=(e,t,n)=>{const s=Me(Gl()),{mutate:r,reset:o}=s,[i,c]=l.useState(!1),u=l.useMemo(()=>$n(n),[n]),h=l.useCallback(()=>{!e||!t||(c(!1),r({path:{accountId:e},body:pr({anchorMessageId:t,matchOperator:"And",literalClauses:[]})}))},[e,t,r]),m=l.useCallback(()=>{c(!1),o()},[o]),f=s.data,p=f?.semanticUnavailable===!0&&!i&&u.length>0;l.useEffect(()=>{!p||!e||(c(!0),r({path:{accountId:e},body:pr(Kg(u))}))},[p,e,u,r]);const v=i||(f?.semanticUnavailable??!1),y=s.isPending||p,d=i?{matchOperator:"Or",literalClauses:Fn(u)}:{...t?{anchorMessageId:t}:{},matchOperator:"And",literalClauses:[]};return{preview:h,reset:m,matchedCount:y?void 0:f?.matchedCount,messageIds:y?void 0:f?.messageIds,semanticUnavailable:v,senderFallback:i,senders:u,matchPredicate:d,isPending:y,isError:s.isError,error:s.error}},Wg=()=>[Da({path:{mailboxId:""}}),Pa({path:{mailboxId:""}}),La()].map(e=>[{_id:e[0]._id}]),qg=e=>hi(e)?e.pages:gi(e)?[e]:[],Vg=e=>typeof e=="object"&&e!==null&&typeof e.messageId=="string",Qg=(e,t)=>{const n=new Set(t),s=new Map;for(const r of e)for(const o of qg(r))for(const i of o.items){if(!Vg(i)||!n.has(i.messageId))continue;const c=i.subject?.trim();c&&s.set(i.messageId,c)}return t.map(r=>s.get(r)).filter(r=>r!==void 0)},Gg=e=>{const t=De(),n=e.join("\0");return l.useMemo(()=>{const s=Wg().flatMap(r=>t.getQueriesData({queryKey:r}).map(([,o])=>o));return Qg(s,e)},[t,n])},Yg=new Set(["hasAttachment","isUnread","isRead","isStarred","category","before","after"]),Xg=e=>Yg.has(e),Jg=(e,{searchHadSemanticReach:t})=>{const n=[],s=[];let r,o;for(const u of e.tokens){if(u.type==="from"){n.push({field:"From",value:u.value});continue}if(u.type==="subject"){n.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}Xg(u.type)&&s.push({type:u.type,label:_a(u)})}const i=e.freeText.trim(),c=i.length>0;return c&&n.push({field:"HasWords",value:i}),{clauses:n,matchOperator:"all",scopedOut:r,droppedFacets:s,targetAccountId:o,keptTerms:c,droppedSemantic:c&&t}},Zg=(e,t,n)=>e.targetAccountId??t??n[0]?.accountId,eb=({failure:e,isStarting:t,isRunning:n,isDone:s,failedCount:r,ruleSaved:o})=>e?.kind==="restartFailed"?"backApplyRestartFailed":e?.kind==="startFailed"?o?"backApplyStartFailed":"commitFailed":s?r>0?"backApplyFailed":"backApplyComplete":e?.kind==="statusUnreadable"?"statusUnknown":t||n?"backApplyRunning":"saving",tb={clauses:[],matchOperator:"any"},nb={clauses:[],matchOperator:"all",droppedFacets:[],keptTerms:!1,droppedSemantic:!1},sb=[],gt={state:"saving",matched:0,applied:0,failed:0,failures:[]},ds=(e,t)=>e.map((n,s)=>({...n,id:`${t}-${s}`})),xa=(e,t,n)=>{if(e==="delete")return{kind:"delete"};if(e==="markRead")return{kind:"markRead"};const s=e==="junk"?n:t;return s?{kind:"move",destinationMailboxId:s}:void 0},fs=e=>e==="move"||e==="junk"||e==="organize",ya=e=>e==="junk"?Ri:"No destination was chosen, so there is nowhere to file these. Go back and pick a folder.";function rb({verb:e,accountId:t,mailboxId:n,selection:s,crossAccount:r=!1,escalated:o,escalatedProgress:i,searchConversion:c,onFinished:u,onRunEnded:h,step:m,goToStep:f,goBack:p,closeWizard:v}){const[y]=l.useState(()=>c),[d]=l.useState(()=>o),g=y!==void 0,[x,k]=l.useState(g?"properties":"selected"),b=d?"escalated":x,[w,E]=l.useState(()=>y?{clauses:ds(y.clauses,"search"),matchOperator:y.matchOperator}:tb),[j,R]=l.useState(void 0),[T,P]=l.useState(void 0),[F,I]=l.useState(!1),[z,A]=l.useState(void 0),[S,M]=l.useState(void 0),[O,C]=l.useState(),D=l.useRef(!1),N=l.useRef(!1),V=l.useMemo(()=>s.map(L=>L.id),[s]),W=l.useMemo(()=>s.map(L=>L.email).filter(Boolean),[s]),re=V[0],ne=Gg(V),{junkMailboxId:de}=yi(t),se=Hg(d?void 0:t,re,W),{preview:ge}=se;l.useEffect(()=>{ge()},[ge]);const q=b==="similar"||b==="properties",xe=l.useMemo(()=>({matchOperator:w.matchOperator==="all"?"And":"Or",literalClauses:w.clauses.map(L=>({field:L.field,value:L.value}))}),[w.clauses,w.matchOperator]),J=b==="similar"?se.matchPredicate:xe,{count:ke,matchedIds:be}=Oc(q?t:void 0,J),Te=Ug(q?be:[]),Ce=zg(d?n:void 0,d?.searchQuery),U=d?{status:"ready",count:d.total}:q?ke:{status:"ready",count:s.length},{data:ye}=he({...nn({path:{accountId:t??""}}),enabled:!!t,staleTime:Number.POSITIVE_INFINITY}),Ne=wi(t),Pe=Ha(),Q=l.useMemo(()=>qa({mailboxes:ye?.items??[],folderAppointments:Ne,currentMailboxId:n,translator:Pe}),[ye?.items,Ne,n,Pe]),{createFolderIn:Z}=Wa(t),ae=Q.find(L=>L.id===w.moveMailboxId)?.label,$e=bf(s.map(L=>({normalizedEmail:L.email,displayName:L.sender}))),Fe=Ef({match:b==="properties"&&w.clauses[0]?.value.trim()||void 0,sender:$e?jo($e):void 0,folder:ae}),G=l.useMemo(()=>({...w,name:w.name??Fe}),[w,Fe]),He=Fg(j?.draft.field,j?.draft.value??"",W),je=$c(t),Le=Fc(t),ze=Eg({mailboxId:n??"",accountId:t,enabled:!1,predicateKey:"selection-wizard",searchQuery:{}}),{runAction:_e}=ze,le=Jl({verb:e,mode:b,scope:w.scope,fromSearch:g}),oe=le[cr(le,m)],Xe=!r&&!!t,Be=Xe?void 0:tc,We=Xe?void 0:nc,Oe=(L=>{if(L==="folder")return We;if(L==="rule")return G.scope==="standing"||G.scope==="until"?Be:void 0})(oe)??Zl(oe,G,U),ee=l.useCallback(()=>ds(Cf(W,ne),"seed"),[W,ne]),we=l.useCallback(L=>{k(L),E(B=>({...B,widen:L==="similar"&&re?{anchorCount:Math.max(s.length,1)}:void 0,...L==="properties"&&B.clauses.length===0?{clauses:ee()}:{}}))},[re,s.length,ee]),me=l.useCallback(()=>{I(!0),k("properties"),E(L=>({...L,widen:void 0,clauses:ds(Fn(W),"sender"),matchOperator:"any"})),f("properties")},[W,f]),_=se.semanticUnavailable||se.isError;l.useEffect(()=>{oe==="match"&&(b!=="similar"||!_||F||me())},[oe,b,_,F,me]);const Y=l.useCallback(()=>{R({mode:"add",draft:{field:"From",value:""}})},[]),K=l.useCallback(L=>{const B=w.clauses.find(ue=>ue.id===L);B&&R({mode:"edit",clauseId:L,draft:{field:B.field,value:B.value}})},[w.clauses]),H=l.useCallback(L=>{E(B=>({...B,clauses:B.clauses.filter(ue=>ue.id!==L)}))},[]),ce=l.useCallback(L=>{R(B=>B&&{...B,draft:L})},[]),ie=l.useCallback(()=>{R(L=>{if(!L)return;const B=_c(L.draft.field,L.draft.value),ue={...L.draft,value:B};E(wt=>({...wt,clauses:L.clauseId?wt.clauses.map(zt=>zt.id===L.clauseId?{...zt,...ue}:zt):[...wt.clauses,{id:crypto.randomUUID(),...ue}]}))})},[]),Ee=l.useCallback(()=>{if(Oe){P(oe);return}P(void 0);const L=le[cr(le,oe)+1];L&&f(L)},[Oe,oe,le,f]),Ue=l.useCallback(async L=>{const B=xa(e,G.moveMailboxId,de);if(!B){M({matched:L.length,failureReason:ya(e)});return}M({matched:L.length});const ue=await _e(B,[...L]);M({matched:L.length,outcome:ue}),N.current&&h?.(B.kind,L.length,ue)},[e,G.moveMailboxId,de,_e,h]),Re=l.useCallback(async()=>{if(!d)return;const L=xa(e,G.moveMailboxId,de);if(!L){M({matched:d.total,failureReason:ya(e)});return}M({matched:d.total});const B=await d.run(L);M({matched:d.total,outcome:B}),N.current&&h?.(L.kind,d.total,B)},[d,e,G.moveMailboxId,de,h]),{start:Ke}=je,{createFilterAsync:qe}=Le,Ie=l.useCallback(()=>{if(d){Re();return}const L=zc({mode:x,ruleScope:G.scope}),B=Bc({mode:x,ruleScope:G.scope,anchorMessageId:re,clauses:G.clauses,matchOperator:G.matchOperator,moveMailboxId:G.moveMailboxId,until:G.until});if(A(L),L==="standing"||L==="temporary"){const ue=Uc(B)?B:void 0;C(ue),qe(B,L,(G.name??"").trim()).then(wt=>{wt&&ue&&Ke(ue)});return}if(L==="all-like-these"&&fs(e)){Ke(B);return}Ue(L==="just-these"?V:be)},[d,Re,x,G,re,e,V,be,qe,Ke,Ue]),yt=l.useCallback(()=>{if(Oe){P(oe);return}D.current||(D.current=!0,f("run"),Ie())},[Oe,oe,f,Ie]),_t=l.useCallback(L=>{const B=je.progress,ue=eb({failure:je.failure,isStarting:je.isStarting,isRunning:je.isRunning,isDone:je.isDone,failedCount:B.failedCount,ruleSaved:L});return ue==="saving"||ue==="commitFailed"||ue==="backApplyStartFailed"?{...gt,state:ue}:{state:ue,matched:B.matchedCount,applied:B.appliedCount,failed:ue==="backApplyFailed"||ue==="backApplyRestartFailed"?B.failedCount:0,failures:[]}},[je]),sr=l.useMemo(()=>{const L=new Map;for(const B of[...s,...Te.messages,...Ce.messages])L.set(B.id,B);return L},[s,Te.messages,Ce.messages]),rr=d?i:ze.progress,ar=l.useCallback(()=>{if(!S)return gt;const{matched:L,outcome:B,failureReason:ue}=S;if(ue!==void 0)return{...gt,state:"commitFailed",failureReason:ue};if(!B){const St=rr?.done??0;return{state:"backApplyRunning",matched:Math.max(L,St),applied:St,failed:0,failures:[]}}if(!(B.cancelled||B.error!==void 0))return{state:"backApplyComplete",matched:Math.max(L,B.done),applied:B.done,failed:0,failures:[]};if(B.done===0)return{...gt,state:"commitFailed"};const zt=B.failedIds.map(St=>sr.get(St)).filter(St=>St!==void 0),Bi=B.failedIds.length>0?B.failedIds.length:Math.max(L-B.done,1);return{state:"runStopped",matched:Math.max(L,B.done),applied:B.done,failed:Bi,failures:zt}},[S,rr,sr]),mt=d?ar():z==="standing"||z==="temporary"?Le.isError?{...gt,state:"commitFailed"}:Le.isSuccess?O?_t(!0):{...gt,state:"filterSaved"}:gt:z==="all-like-these"&&fs(e)?_t(!1):ar(),$i=()=>{if(mt.state==="statusUnknown"){je.refreshStatus();return}if(d){Re();return}if(z==="standing"||z==="temporary"){if(Le.isError){Le.reset(),Ie();return}O&&Ke(O);return}if(z==="all-like-these"&&fs(e)){Ie();return}const L=S?.outcome?.failedIds??[];Ue(L.length>0?L:V)},Fi=l.useCallback(()=>{v(le,oe)},[v,le,oe]),Hn=l.useCallback(()=>{N.current=!0,v(le,oe),u()},[v,le,oe,u]),{stop:or}=ze,_i=S!==void 0&&S.outcome===void 0&&S.failureReason===void 0,zi=l.useCallback(()=>{if(d){d.stop();return}or()},[d,or]);sp({shouldBlockFn:({action:L})=>L!=="BACK"?!1:(Hn(),!0),enableBeforeUnload:!1,disabled:oe!=="run"});const Wn={messages:d?Ce.messages:q?Te.messages:s,count:U,label:b==="selected"?"Your selection":"A sample of what matches",emptyReason:b==="similar"&&_?"notIndexed":"noMatch",loading:d?Ce.isPending:q&&(U.status==="loading"||Te.isPending)};return a.jsx(ec,{verb:e,steps:le,step:oe,blockedReason:Oe,nudged:T===oe,onBack:p,onExit:oe==="run"?Hn:Fi,onContinue:Ee,onCommit:yt,match:{selectedCount:s.length,mode:b,onModeChange:we,semanticUnavailable:_,semanticErrorDetail:se.error instanceof Error?se.error.message:void 0,semanticFallbackTaken:F,onSemanticFallback:me,escalatedScope:d?.scope,sample:Wn},properties:{clauses:G.clauses,matchOperator:G.matchOperator,onMatchOperatorChange:L=>E(B=>({...B,matchOperator:L})),clauseEdit:j,onStartAddClause:Y,onStartEditClause:K,onRemoveClause:H,onChangeDraft:ce,onSubmitClause:ie,onCancelClause:()=>R(void 0),clauseFields:Kc,clauseSuggestions:He,conversionNotice:y?jf(y):void 0,semanticFallbackTaken:F,sample:{...Wn,label:"What this matches"}},folder:{folders:Q,mailboxId:G.moveMailboxId,delimiter:Va(ye?.items??[]),onSelect:L=>E(B=>({...B,moveMailboxId:L})),onCreateFolder:t?Z:void 0,restriction:We},rule:{draft:G,onScopeChange:L=>E(B=>({...B,scope:L})),onUntilChange:L=>E(B=>({...B,until:L})),restriction:Be},name:{name:G.name??"",onNameChange:L=>E(B=>({...B,name:L})),nudged:T===oe},review:{verb:e,mode:b,selectedCount:s.length,clauses:G.clauses,matchOperator:G.matchOperator,folder:ae,scope:G.scope,until:G.until,ruleName:le.includes("name")?G.name:void 0,escalatedScope:d?.scope,sample:Wn},run:{state:mt.state,verb:e,scope:G.scope,matched:mt.matched,applied:mt.applied,failedCount:mt.failed,failures:mt.failures,failureReason:mt.failureReason,onRetry:$i,onDismiss:Hn,onCancelRun:_i?zi:void 0}})}function Nv(e){const t=Yl()==="search",{searchConversion:n}=Ii(),{accounts:s}=$s(),{step:r,goToStep:o,goBack:i,closeWizard:c}=Xl(t?"properties":"match");if(!r)return null;const u=t?n??nb:void 0;return a.jsx(rb,{...e,...u?{verb:"organize",accountId:Zg(u,e.accountId,s),selection:sb,crossAccount:!1,escalated:void 0,searchConversion:u}:{},step:r,goToStep:o,goBack:i,closeWizard:c})}const tr=l.createContext(null),ab=e=>{const t=l.useContext(tr);return t?t.rowInteraction(e):null},ob=()=>{const e=l.useContext(tr);if(!e)throw new Error("useThreadListSelection must be used inside <ThreadListInteraction>");return e},ib="[data-message-id]",lb=e=>Array.from(e.querySelectorAll(ib)).map(t=>t.dataset.messageId).filter(t=>t!==void 0),cb=(e,t)=>e.length===t.length&&e.every((n,s)=>n===t[s]),ub=e=>{const[t,n]=l.useState([]);return l.useEffect(()=>{const s=e.current;if(!s)return;const r=()=>{const i=lb(s);n(c=>cb(c,i)?c:i)};r();const o=new MutationObserver(r);return o.observe(s,{childList:!0,subtree:!0}),()=>o.disconnect()},[e]),t};function jv({selectedMessageId:e,onOpen:t,onDeleteMessages:n,onSelectionVerb:s,wizardOpen:r=!1,isDeleting:o=!1,commandsRef:i,onTriageContextChange:c,children:u}){const h=Dn(),m=l.useRef(null),f=ub(m),p=Tf({orderedIds:f,isDesktop:h,initialFocusedId:e}),{focusedMessageId:v,setFocusedMessageId:y,pendingDomFocusRef:d,cursorMovedByPointerRef:g,selection:x,isMultiSelectMode:k,exitSelection:b,handleRowSelect:w}=p,{selectedIds:E,selectedCount:j,isSelected:R,toggle:T,select:P,toggleAll:F}=x,I=f.length>0&&f.every(J=>E.has(J)),z=l.useCallback(()=>{f.length>0&&F(f)},[f,F]),{intersectWith:A}=x;l.useEffect(()=>{A(f)},[A,f]),l.useEffect(()=>{const J=d.current;J!==null&&(d.current=null,m.current?.querySelector(`[data-message-id="${J}"]`)?.focus())});const S=l.useCallback(J=>{g.current=!0,y(J)},[g,y]),M=l.useCallback(J=>{h||P(J)},[h,P]),O=l.useCallback(()=>{v&&t(v)},[v,t]),C=l.useCallback(J=>t(J,{replace:!0}),[t]);jg({keyboardFocusedMessageId:p.keyboardFocusedMessageId,openMessageId:e,enabled:h&&j===0,open:C});const[D,N]=l.useState(null),V=l.useCallback(J=>D!==null?!0:j>0?(s(J),!0):J!=="delete"||!v?!1:(N([v]),!0),[D,j,s,v]),W=l.useCallback(()=>{D!==null&&(n(D),N(null),b())},[D,n,b]),re=l.useCallback(()=>N(null),[]),ne=l.useCallback(()=>j===0?!1:(b(),!0),[j,b]),de=f.length>0;l.useEffect(()=>{if(i){if(!de){i.current=null;return}return i.current={focusNext:p.focusNext,focusPrevious:p.focusPrevious,focusFirst:p.focusFirst,focusLast:p.focusLast,openFocused:O,toggleSelect:p.toggleFocusedSelection,extendSelectDown:p.extendRangeDown,extendSelectUp:p.extendRangeUp,selectAll:p.selectAllLoaded,clearSelection:ne,requestVerb:V,toggleDensity:()=>{}},()=>{i.current=null}}},[i,de,p.focusNext,p.focusPrevious,p.focusFirst,p.focusLast,p.toggleFocusedSelection,p.extendRangeDown,p.extendRangeUp,p.selectAllLoaded,O,ne,V]);const se=l.useMemo(()=>Array.from(E),[E]),ge=D!==null;l.useEffect(()=>{c?.({focusedMessageId:v,selectedIds:se,orderedIds:f,hasList:de,blocksKeyboard:ge||r})},[c,v,se,f,de,ge,r]);const q=Ig(f,v),xe=l.useMemo(()=>({selectedIds:E,selectedCount:j,exitSelection:b,startSelectionVerb:s,orderedIds:f,allSelected:I,toggleAllLoaded:z,rowInteraction:J=>({focused:J===v,isTabStop:J===q,isDesktop:h,onFocusRow:S,selection:{isChecked:R(J),onToggleCheck:T,onRowSelect:w,isMultiSelectMode:k,onLongPress:M}})}),[E,j,b,s,f,I,z,v,q,h,S,R,T,w,k,M]);return a.jsxs(tr.Provider,{value:xe,children:[a.jsx("div",{ref:m,className:"contents",children:u}),a.jsx(Hc,{isOpen:ge,title:Ac(D?.length??0),description:"You can restore them from Trash later.",confirmLabel:"Move to Trash",destructive:!0,isBusy:o,onConfirm:W,onCancel:re})]})}function Tv({title:e,isDeleting:t}){const n=Ii(),{selectedCount:s,exitSelection:r,startSelectionVerb:o,orderedIds:i,allSelected:c,toggleAllLoaded:u}=ob();return a.jsx(Ud,{title:n.title||e,navSlot:n.navSlot,titleMeta:n.titleMeta,searchSlot:n.searchSlot,searchField:n.searchField,idleSlot:n.makeFilterSlot,count:s,onCancel:r,onDelete:()=>o("delete"),onMarkRead:()=>o("markRead"),isBusy:t,selectAll:i.length>0?{checked:c,indeterminate:s>0&&!c,onChange:u}:void 0})}const ms=e=>{e.preventDefault(),e.stopPropagation()},db=(e,t)=>{const n=l.useRef(!1),s=l.useCallback(i=>{if(n.current=!1,i.button!==0)return;const c=xs(i);kr(c)&&t?.(e,c)&&(ms(i),n.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(n.current)return n.current=!1,ms(i),!0;const c=xs(i);return!kr(c)||!t?.(e,c)?!1:(ms(i),c.shiftKey&&window.getSelection()?.removeAllRanges(),!0)},[t,e]);return{onMouseDown:s,onContextMenu:r,claimClick:o}},fb=({thread:e,active:t=!1,focused:n,isTabStop:s,density:r="comfortable",isDesktop:o,badge:i,selection:c,inListbox:u=!1,linkMailboxId:h,onClick:m,onFocusRow:f})=>{const p=De(),v=e.id,y=ab(v),d=n??y?.focused??!1,g=s??y?.isTabStop??!1,x=c??y?.selection,k=f??y?.onFocusRow,b=o??y?.isDesktop??!0,w=x?.isChecked??!1,E=x?.isMultiSelectMode??!1,j=x?.onToggleCheck,R=x?.onRowSelect,T=x?.onLongPress,P=l.useCallback(N=>{N.preventDefault(),N.stopPropagation(),j?.(v)},[j,v]),F=db(v,R),I=l.useCallback(N=>{if(!F.claimClick(N)){if(!b){if(E){N.preventDefault(),N.stopPropagation(),j?.(v);return}m?.();return}R?.(v,xs(N)),m?.()}},[F,b,E,j,R,m,v]),z=l.useCallback(()=>{T?.(v)},[T,v]),{longPressProps:A}=rd({onLongPress:z,accessibilityDescription:w?"Deselect message":"Select message"}),S=l.useCallback(()=>{p.prefetchQuery(An({path:{messageId:v}}))},[p,v]),M=l.useCallback(()=>{S(),k?.(v)},[S,k,v]),O=rn({"data-list-row":"","data-message-row":!0,"data-message-id":v,...u?{role:"option","aria-selected":w}:{},tabIndex:g?0:-1,onClick:I,onMouseDown:F.onMouseDown,onContextMenu:F.onContextMenu,onMouseEnter:S,onFocus:M},b||!x?{}:A),C=Ze(r==="compact"?fo({active:t,focused:d}):Ze("group",Hs({active:t,focused:d})),"outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-inset",w&&"bg-accent-soft",!b&&"min-h-11 select-none [-webkit-touch-callout:none]"),D=r==="compact"?a.jsx(mo,{thread:e}):a.jsx(Ws,{thread:e,badge:i,selection:x?{checked:w,alwaysVisible:E,onToggle:P}:void 0});return h===void 0?a.jsx("button",{type:"button",...O,className:C,children:D}):a.jsx($a,{to:"/mail/$mailboxId",params:{mailboxId:h},search:N=>({...N,selectedMessageId:v}),variant:"row",...O,className:C,children:D})},Rv=l.memo(fb),ps="Open a message first",Iv=({hasThread:e,intelligenceOpen:t,canToggleIntelligence:n,onToggleIntelligence:s,onReply:r,onReplyAll:o,onForward:i,onDelete:c,canDelete:u,onToggleStar:h,isStarred:m,moveContext:f})=>{const[p,v]=l.useState(null),y=u??e,d=g=>()=>v(g);return a.jsx(od,{hasThread:e,isStarred:m,onUnavailable:g=>v(ps),unavailableHint:p,replyTitle:`Reply ${Bt("reply")}`,replyAllTitle:`Reply all ${Bt("replyAll")}`,forwardTitle:`Forward ${Bt("forward")}`,deleteTitle:`Move to Trash ${Bt("delete")}`,flagTitle:`Star ${Bt("toggleStar")}`,onReply:r,onReplyAll:o,onForward:i,onDelete:y?c:d(ps),onToggleStar:h,onMove:d(ps),moveSlot:f?a.jsx(er,{accountId:f.accountId,currentMailboxId:f.currentMailboxId,onMove:f.onMove,label:"Move to mailbox"}):void 0,children:a.jsx(ad,{open:t,enabled:n,onToggle:s})})},mb=()=>{const e=De();return l.useCallback(t=>{const n=dt({path:{threadId:t.threadId}}),r=e.getQueriesData({queryKey:n}).flatMap(([,o])=>o?.items.map(i=>i.messageId)??[]);return r.length>0?r:[t.messageId]},[e])},Mv=({thread:e,mailboxId:t,accountId:n,onAfterOptimisticRemove:s})=>{const r=t??e?.mailboxId,o=n??e?.accountId,{accountId:i}=mi(o?void 0:r),c=o??i,u=mb(),{deleteMessages:h}=Zs({mailboxId:r??"",threadId:e?.threadId,accountId:c,onAfterOptimisticRemove:s}),{moveMessages:m}=Kn({mailboxId:r??"",threadId:e?.threadId,accountId:c,onAfterOptimisticRemove:s}),{toggleStar:f}=vi({threadId:e?.threadId??"",mailboxId:r??""}),p=l.useCallback(()=>{e&&h(u(e))},[e,u,h]),v=l.useCallback(k=>{e&&m(u(e),k)},[e,u,m]),y=l.useCallback(()=>{e&&f(e.messageId,e.hasStars)},[e,f]),[d,g]=l.useState(null),x=l.useCallback(()=>g(null),[]);return{mailboxId:r,accountId:c,isStarred:e?.hasStars,deleteThread:p,moveThread:v,toggleStar:y,composeRequest:d,requestCompose:g,clearComposeRequest:x}},wa=(e,t,n)=>{if(!t)return null;const s=e.indexOf(t);if(s===-1)return null;const r=n==="next"?s+1:s-1;return r<0||r>=e.length?null:e[r]},Av=()=>{const[e,t]=l.useState(void 0),[n,s]=l.useState([]),[r,o]=l.useState([]),i=l.useRef(null),[c,u]=l.useState(!1),[h,m]=l.useState(!1),f=l.useCallback(p=>{t(p.focusedMessageId),s(p.selectedIds),p.orderedIds&&o(p.orderedIds),u(p.hasList),m(p.blocksKeyboard)},[]);return{listCommandsRef:i,onTriageContextChange:f,focusedMessageId:e,selectedIds:n,orderedIds:r,hasList:c,blocksKeyboard:h}},Dv=({context:e,orderedIds:t,selectedMessageId:n,enabled:s=!0,onClose:r,handlers:o})=>{const{listCommandsRef:i,hasList:c,blocksKeyboard:u}=e,h=l.useCallback(()=>{i.current?.clearSelection()||n&&r()},[i,n,r]);return mc({enabled:s&&!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:h,...o}}),{goBack:h,nextMessageId:wa(t,n,"next")??void 0,previousMessageId:wa(t,n,"previous")??void 0}},pb={sender:"sender",recipient:"recipient",subject:"subject",attachment:"attachment",body:"body",entities:"entities"};function hb(e){return pb[e]??e}function Pv(e,t){const{folder:n}=Fs(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:$t(e.sentDate),unread:!e.isRead,flagged:e.hasStars===!0,threadId:e.threadId,mailboxId:e.mailboxId,...n?{folder:n}:{}}}function Lv(e,t){const{folder:n}=Fs(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}:{},...n?{folder:n}:{}}}function gb(e,t){const{mailboxId:n,folder:s}=Fs(t,e.mailboxIds);return{id:e.messageId,sender:e.fromName??"Unknown",subject:e.subject??"(No subject)",snippet:"",date:e.sentDate!=null?$t(e.sentDate*1e3):"",threadId:e.threadId,matchedChunkLabel:hb(e.matchedChunkType),score:e.score,...n?{mailboxId:n}:{},...s?{folder:s}:{}}}function Ov(e,t,n){const s=new Set(t),r=[];for(const o of[...e].sort((i,c)=>c.score-i.score))s.has(o.threadId)||(s.add(o.threadId),r.push(gb(o,n)));return r}function $v(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:$t(e.sentDate),sentDate:e.sentDate,isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:xi(e.category),suspicious:t}}function Fv(e){return e.filter(t=>t.muted!==!0)}function _v(e,t){const n=new Set,s=[];for(const r of[...e,...t])n.has(r.id)||(n.add(r.id),s.push(r));return s.sort((r,o)=>(o.sentDate??0)-(r.sentDate??0))}const Sa=[{id:"personal",label:"Personal",category:Je.personal},{id:"transactional",label:"Transactional",category:Je.transactional},{id:"newsletter",label:"Newsletter",category:Je.newsletter},{id:"marketing",label:"Marketing",category:Je.marketing},{id:"social",label:"Social",category:Je.social},{id:"automated",label:"Automated",category:Je.automated},{id:"uncategorized",label:"Unclassified",category:Je.uncategorized}];function zv(e){const t=new Map(Sa.map(s=>[s.category,[]]));for(const s of e){const r=s.category??Je.uncategorized;(t.get(r)??t.get(Je.uncategorized))?.push(s)}const n=[];for(const s of Sa){const r=t.get(s.category);r&&r.length>0&&n.push({id:s.id,label:s.label,threads:r})}return n}function Bv(e,t){return e.fromName.toLowerCase().includes(t)||e.fromEmail.toLowerCase().includes(t)||e.subject.toLowerCase().includes(t)||e.snippet.toLowerCase().includes(t)}function Uv(e,t){return t.every(n=>{switch(n.type){case"from":{const s=n.value.toLowerCase();return e.fromEmail.toLowerCase().includes(s)||e.fromName.toLowerCase().includes(s)}case"subject":return e.subject.toLowerCase().includes(n.value.toLowerCase());case"category":return(e.category??"uncategorized")===n.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>=n.epochSeconds*1e3;case"before":return e.sentDate!=null&&e.sentDate<n.epochSeconds*1e3;case"in":return e.mailboxId===n.mailboxId;case"account":return e.accountId===n.accountId;default:return!1}})}const Pi=8;function nr(e,t){const n=Math.max(0,Math.min(t,e.length)),s=Nc(e).find(o=>n>=o.start&&n<=o.end);if(!s)return{start:n,end:n,raw:""};const r=jc(s.raw);return r?{start:s.start,end:s.end,raw:s.raw,name:r.name,value:r.value}:{start:s.start,end:s.end,raw:s.raw}}function bb(e,t){const n=nr(e,t);if(n.name===void 0)return{kind:"token",query:n.raw};const s=za(n.name);if(s)return{kind:"value",token:s.name,source:s.values,query:n.value??""}}const vb={mailbox:"mailboxes",account:"accounts",contact:"contacts"},xb=(e,t)=>{if(e.values==="fixed")return e.options??[];const n=vb[e.values];return n?t[n]??[]:[]},yb=(e,t)=>{if(t==="")return 1;const n=e.toLowerCase();return n.startsWith(t)?0:n.includes(t)?1:-1},Rs=(e,...t)=>{let n=-1;for(const s of t){if(s===void 0)continue;const r=yb(s,e);r<0||(n<0||r<n)&&(n=r)}return n},Li=e=>{const t=new Set;return e.filter(n=>n.rank>=0).sort((n,s)=>n.rank-s.rank).filter(n=>{const s=n.suggestion.value.toLowerCase();return t.has(s)?!1:(t.add(s),!0)}).slice(0,Pi).map(n=>n.suggestion)},ka=e=>({value:`${e.name}:`,label:`${e.name}:`,hint:e.label});function wb(e){const t=e.trim().toLowerCase();if(t==="")return dr.map(ka);const n=[];for(const s of dr)if(n.push({rank:Rs(t,`${s.name}:`,s.label),suggestion:ka(s)}),s.values==="fixed")for(const r of s.options??[]){const o=Ba(s.name,r.value);n.push({rank:Rs(t,o,r.label),suggestion:{value:o,label:r.label??o,hint:o}})}return Li(n)}function Sb(e,t,n){const s=t.trim().toLowerCase(),r=xb(e,n).map(o=>({rank:Rs(s,o.value,o.label),suggestion:{value:Ba(e.name,o.value),label:o.label??o.value,...o.hint?{hint:o.hint}:{}}}));return Li(r)}function kb(e,t,n={}){const s=nr(e,t);if(s.name===void 0)return wb(s.raw);const r=za(s.name);return r?Sb(r,s.value??"",n):[]}function Cb(e,t,n){const s=nr(e,t),r=!n.value.endsWith(":"),o=/\s/.test(e.slice(s.end,s.end+1)),i=r&&!o?`${n.value} `:n.value;return{query:e.slice(0,s.start)+i+e.slice(s.end),cursor:s.start+i.length+(r&&o?1:0)}}const Eb=e=>({value:e.normalizedEmail,...e.displayName?{label:e.displayName,hint:e.normalizedEmail}:{}}),Nb=250,jb=2;function Tb({query:e,cursor:t,enabled:n}){const{accounts:s}=$s(),{mailboxesByName:r}=Ua(),o=r!==void 0,i=n?bb(e,t):void 0,c=i?.source==="contact"?i.query.trim():"",u=_s(c,Nb),{data:h}=he({...In({query:{q:u,limit:Pi}}),enabled:u.length>=jb}),m=Os({queries:s.map(y=>({...nn({path:{accountId:y.accountId}}),staleTime:1/0}))}),f=l.useMemo(()=>o?pc(m.map(y=>y.data?.items??[]),s):[],[o,m,s]),p=l.useMemo(()=>hc(s),[s]),v=l.useMemo(()=>(h?.items??[]).map(Eb),[h]);return l.useMemo(()=>{if(!n)return[];const y=kb(e,t,{mailboxes:f,accounts:p,contacts:v});return o?y:y.filter(d=>d.value!=="in:")},[n,e,t,f,p,v,o])}const Oi="remit.recentSearches",Rb=5;function Is(){try{const e=localStorage.getItem(Oi);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}catch{return[]}}function Ca(e){const t=e.trim();if(!t)return Is();const n=[t,...Is().filter(s=>s!==t)].slice(0,Rb);try{localStorage.setItem(Oi,JSON.stringify(n))}catch{return n}return n}const Ib=e=>e.tier!=="phone"&&e.hasLiveInput&&!(e.bodyRendersCommittedResults&&e.hasCommittedQuery);function Mb(e){const{spam:t}=yo([...e]),n=new Map;for(const r of t)r.mailboxId&&n.set(r.mailboxId,(n.get(r.mailboxId)??0)+1);let s;for(const[r,o]of n)(!s||o>s.count)&&(s={mailboxId:r,count:o});return s}function Kv({title:e,unreadCount:t,children:n,selectionBar:s,paneOverlay:r,footer:o,searchFilter:i,searchResults:c,searchLoading:u,relatedResults:h,relatedLoading:m,onSelectSearchResult:f,searchResultsLabel:p="Top matches",relatedResultsLabel:v="Related",searchResultsInBody:y=!1,refreshControl:d}){const{accounts:g,resultFolderIndex:x,searchQuery:k,searchInput:b,onSearchChange:w,onSearchClear:E,searchViewKey:j}=$s(),R=Ua(),T=Ls(),P=sc(),F=gc(),[I,z]=l.useState(!1),[A,S]=l.useState(Is),M=rc(),O=l.useRef(j);l.useEffect(()=>{O.current!==j&&(O.current=j,z(!1))},[j]);const[C,D]=l.useState(0),[N,V]=l.useState(!1),[W,re]=l.useState(void 0),ne=Tb({query:b,cursor:C,enabled:N&&b.trim().length>0}),de=l.useCallback(K=>{const H=Cb(b,C,K);w(H.query),re({cursor:H.cursor})},[b,C,w]),se=Ta({count:ne.length,onAccept:K=>{const H=ne[K];H&&de(H)}}),{comboboxProps:ge,handleKeyDown:q}=se,xe=l.useMemo(()=>({comboboxProps:ge,onKeyDown:q,onCaretChange:D,onFocusChange:V,...W?{caret:W}:{}}),[ge,q,W]),J=se.open?a.jsx(Ra,{id:se.listId,suggestions:ne,activeIndex:se.activeIndex,optionId:se.optionId,onPick:de,onHighlight:se.setActiveIndex,label:"Search suggestions",className:"mx-row-inset mt-1 shrink-0"}):null,ke=b.trim().length>0,{mailboxesByName:be,accountsByName:Te}=R,Ce=l.useMemo(()=>Tc(b,{mailboxesByName:be,accountsByName:Te}),[b,be,Te]),U=Ce.tokens.map(K=>({label:_a(K),onRemove:()=>w(Rc(b,K))})),ye=c??[],Ne=h??[],Pe=ke?[{id:"top",label:p,results:ye},{id:"related",label:v,results:Ne}]:[],Z=!(ye.length+Ne.length>0)&&(u===!0||m===!0),{scope:ae}=bc(g),$e=qc({select:K=>K.matches}),Fe=Vc($e),G=Qc($e,ae,Fe?x.get(Fe)?.role:void 0),He=G.kind==="global"?Mb([...ye,...Ne]):void 0,je=He?{kind:"global",onScopeToSpam:()=>T({to:"/mail/$mailboxId",params:{mailboxId:He.mailboxId},search:{q:k||void 0,selectedMessageId:void 0,selectedThreadId:void 0}})}:G,Le=Ne.length>0,ze=l.useMemo(()=>Jg(Ce,{searchHadSemanticReach:Le}),[Ce,Le]),_e=ke?ze:void 0,le=ke?{onClick:()=>{z(!1),M("properties","search")},blockedReason:Nf(ze)?void 0:ac(ze.droppedFacets.map(K=>K.label))}:void 0,oe=le?a.jsx(wo,{...le}):null,Xe=Ib({tier:F,hasLiveInput:ke,hasCommittedQuery:k.trim().length>0,bodyRendersCommittedResults:y}),Be=K=>{S(Ca(b)),f?.(K)},We=a.jsx(So,{value:b,sections:Pe,loading:Z,onSelectResult:Be,tokens:U,scope:je}),st=s===void 0,Oe=Xe?a.jsx("div",{className:"h-full overflow-y-auto",children:We}):null,ee=Oe&&!st?Oe:n,we=Oe&&st?Oe:null,me=vc(F),_=me&&(I||ke),Y=l.useMemo(()=>({title:e,searchResults:we,makeFilterSlot:oe,searchConversion:_e,navSlot:P&&!P.showNavPane&&a.jsx(te,{variant:"ghost",size:"touch",icon:a.jsx(Gc,{className:"size-5"}),onClick:()=>P.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(ur,{}),d]}),searchSlot:me&&!_&&a.jsx(te,{variant:"ghost",size:"touch",icon:a.jsx(oc,{className:"size-5"}),onClick:()=>z(!0),"aria-label":"Search",className:"shrink-0"}),searchField:_&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"min-w-0 flex-1",children:a.jsx(Oa,{value:b,onChange:w,onClear:E,globalFocusKey:!1,showClearButton:!1,suggest:xe})}),a.jsx(te,{variant:"ghost",size:"touch",icon:a.jsx(en,{className:"size-5"}),onClick:()=>{E(),z(!1)},"aria-label":"Close search",className:"shrink-0"}),a.jsx(ur,{})]})}),[e,t,P,me,_,b,w,E,xe,we,oe,_e,d]);if(F==="phone"&&I){const K=H=>{S(Ca(b)),z(!1),f?.(H)};return a.jsxs(Ts.Provider,{value:Y,children:[a.jsx(_d,{value:b,onChange:w,onClear:E,onCancel:()=>{z(!1),E()},filter:i,recentSearches:A,onPickRecent:w,makeFilter:le,sections:Pe,loading:Z,onSelectResult:K,tokens:U,scope:je,suggest:xe,suggestList:J}),r]})}return a.jsx(Ts.Provider,{value:Y,children:a.jsxs("section",{className:"relative flex h-full w-full flex-col bg-surface",children:[s?.(Y),J,a.jsx("div",{className:"min-h-0 flex-1",children:ee}),o,r]})})}export{Iv as $,bv as A,vv as B,xd as C,Tt as D,hv as E,$v as F,Uv as G,Zs as H,mi as I,Kn as J,mv as K,Av as L,Rv as M,Mv as N,fv as O,dv as P,mb as Q,vi as R,Ud as S,og as T,lg as U,ug as V,cg as W,Dv as X,pv as Y,cv as Z,xv as _,vp as a,rv as a0,Pv as a1,Ov as a2,Bv as a3,av as a4,Lv as a5,jv as a6,Tv as a7,ob as a8,rd as a9,rn as aa,Ks as ab,xs as ac,tv as ad,nv as ae,ev as af,Kv as ag,Fv as ah,_v as ai,yo as aj,Mb as ak,zv as al,sv as am,Ib as an,Pd as ao,nt as ap,tt as aq,Xs as ar,Zt as as,go as at,ov as au,Fu as av,lv as aw,iv as ax,Bd as ay,ed as b,Hs as c,Ii as d,uv as e,yi as f,Ju as g,Eg as h,kv as i,Ev as j,Sv as k,wv as l,jg as m,Xu as n,sp as o,yv as p,Cv as q,Ig as r,Nv as s,xi as t,db as u,Vu as v,Rg as w,yh as x,wi as y,gv as z};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,al as re,B as A,e as ie,r as x,b as Q,am as oe,T as ce,bo as le,u as ue,bp as U,bq as de,br as fe,bs as me,bt as xe,bu as ge,n as he,bv as pe,bw as be}from"./index-3eAE16lF.js";import{R as ve,k as je,l as we}from"./search-token-index-XT09xk5-.js";import{a9 as Ne,aa as ye,c as Pe,b as q,ab as Ce,v as Re,ac as ke,ad as Se,ae as Me,af as Ee,ag as Ie}from"./MailListHeader-CzkFVHra.js";import{A as ze}from"./avatar-B5Xfa_Aj.js";import{M as Oe}from"./account-form-helpers-DgsG82nf.js";import{M as Le}from"./menu-B3HPQBVa.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 z=72,V=10,He=z/2,J="__swipeableRowAxisCancel";function Z(s){return s==="leading"?z:s==="trailing"?-z:0}function Xe(s){return s>=z/2?"leading":s<=-z/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>He&&(o.escaped=!0,k(i)),o.axis!=="horizontal")return;const F=Z(m),H=Math.max(-z,Math.min(z,F+u));v(H)},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(Xe(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,I=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(q,{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:I,onPointerMove:I,onPointerUp:I,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(ze,{name:s.fromName,email:s.fromEmail,size:"sm"})}),e.jsx(q,{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 I=k==="compact"?Se:Me,T=x.useRef(null),i=x.useRef(null),o=le(l);ue({containerRef:T,itemSelector:U,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(`${U}[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",[H,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),X=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(I,{thread:t,active:c,focused:t.id===u,tabIndex:O(t.id),selection:X(t.id),onClick:ae=>{B(t.id,ae)||W?.()}}),[I,X,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:H}):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(I,{thread:c,active:c.id===P,focused:c.id===u,tabIndex:O(c.id),selection:X(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(Ie,{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,al as re,B as A,e as ie,r as x,b as Q,am as oe,T as ce,bo as le,u as ue,bp as U,bq as de,br as fe,bs as me,bt as xe,bu as ge,n as he,bv as pe,bw as be}from"./index-BvAPtXhR.js";import{R as ve,k as je,l as we}from"./search-token-index-BRBf_vfX.js";import{a9 as Ne,aa as ye,c as Pe,b as q,ab as Ce,v as Re,ac as ke,ad as Se,ae as Me,af as Ee,ag as Ie}from"./MailListHeader-BOYr_Fx1.js";import{A as ze}from"./avatar-4b13Sges.js";import{M as Oe}from"./account-form-helpers-Cku237WR.js";import{M as Le}from"./menu-CtxXDmfA.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 z=72,V=10,He=z/2,J="__swipeableRowAxisCancel";function Z(s){return s==="leading"?z:s==="trailing"?-z:0}function Xe(s){return s>=z/2?"leading":s<=-z/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>He&&(o.escaped=!0,k(i)),o.axis!=="horizontal")return;const F=Z(m),H=Math.max(-z,Math.min(z,F+u));v(H)},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(Xe(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,I=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(q,{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:I,onPointerMove:I,onPointerUp:I,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(ze,{name:s.fromName,email:s.fromEmail,size:"sm"})}),e.jsx(q,{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 I=k==="compact"?Se:Me,T=x.useRef(null),i=x.useRef(null),o=le(l);ue({containerRef:T,itemSelector:U,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(`${U}[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",[H,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),X=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(I,{thread:t,active:c,focused:t.id===u,tabIndex:O(t.id),selection:X(t.id),onClick:ae=>{B(t.id,ae)||W?.()}}),[I,X,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:H}):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(I,{thread:c,active:c.id===P,focused:c.id===u,tabIndex:O(c.id),selection:X(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(Ie,{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};
|