@remit/web-client-dist 0.0.351 → 0.0.352
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/{BriefPane-D5U_FMo6.js → BriefPane-p-hSuFHs.js} +1 -1
- package/assets/{ErrorState-DrA1RdFM.js → ErrorState-DZuvygoB.js} +1 -1
- package/assets/{FlaggedPane-CD0MhkHu.js → FlaggedPane-hgkHMzJs.js} +1 -1
- package/assets/MailListHeader-ChgoSBi9.js +52 -0
- package/assets/{MailViewChrome-wpRug1Q0.js → MailViewChrome-Bmclnv4Y.js} +1 -1
- package/assets/MailboxPane-BMQDZJjp.js +1 -0
- package/assets/{NavMenuButton-Dy0q8FiJ.js → NavMenuButton-BMHaKadd.js} +1 -1
- package/assets/{OnboardingWizard-DxBnC5ZI.js → OnboardingWizard-D_CKlYeE.js} +1 -1
- package/assets/OutboxPane-CZaWhBtj.js +1 -0
- package/assets/_mailboxId-CFnhtqtO.js +1 -0
- package/assets/_messageId-BGy2iRwR.js +1 -0
- package/assets/_messageId-C5W69cMm.js +1 -0
- package/assets/_messageId-Coqf3iOq.js +1 -0
- package/assets/_outboxMessageId-BPomNqIM.js +1 -0
- package/assets/_threadId-BeFC5p1-.js +1 -0
- package/assets/_threadId-C4vJmEsZ.js +1 -0
- package/assets/_threadId-CuZmFZv-.js +1 -0
- package/assets/{account-form-helpers-D1exxHT6.js → account-form-helpers-BfY-Ea9J.js} +1 -1
- package/assets/accounts-L7qmNB9J.js +1 -0
- package/assets/{advanced-BY_XBoCx.js → advanced-BJY8Omuf.js} +2 -2
- package/assets/{appearance-BszRkKRP.js → appearance-DpQj7mfH.js} +1 -1
- package/assets/{avatar-lbydjrIt.js → avatar-BFQ0qcwg.js} +1 -1
- package/assets/{bottom-sheet-BZM-qnW9.js → bottom-sheet-B093xbW6.js} +1 -1
- package/assets/brief-BRJwDJxo.js +1 -0
- package/assets/{brief-DAZY-yDt.js → brief-DDFdGXoV.js} +1 -1
- package/assets/{browser-ponyfill-1mYU3VEo.js → browser-ponyfill-B6ZDdJ1B.js} +1 -1
- package/assets/{bug-LK0uYJOc.js → bug-J1y1e9ln.js} +1 -1
- package/assets/{circle-check-BO9xAEiG.js → circle-check-Cc5r3mNv.js} +1 -1
- package/assets/{circle-check-big-xK5jTBa2.js → circle-check-big-CbFDK_1e.js} +1 -1
- package/assets/{circle-help-D-5uStGy.js → circle-help-CP-9GEES.js} +1 -1
- package/assets/{clock-CdRZkrpV.js → clock-96u1OlQy.js} +1 -1
- package/assets/{confirm-dialog-DZ3dfzvC.js → confirm-dialog-D9ePPVOy.js} +1 -1
- package/assets/{download-BRZRRebx.js → download-D7nu5tCC.js} +1 -1
- package/assets/{filters-CJtRXFIT.js → filters-DNNLGo5R.js} +1 -1
- package/assets/flagged-B9fZ1GqU.js +1 -0
- package/assets/{flagged-B4b0rbUr.js → flagged-W35-YQH1.js} +1 -1
- package/assets/{folders-CMjuCzAd.js → folders-TMV5XV0z.js} +1 -1
- package/assets/index-1WA7SdKy.js +1 -0
- package/assets/{index-Bo-p3LpF.js → index-BDlRWNu5.js} +63 -63
- package/assets/index-BGy2iRwR.js +1 -0
- package/assets/index-BMYggitW.js +1 -0
- package/assets/index-BV0ZMlSc.js +1 -0
- package/assets/index-BrDwfz9a.js +1 -0
- package/assets/index-BtDSe1NC.js +1 -0
- package/assets/index-C5W69cMm.js +1 -0
- package/assets/index-D60Mtde_.js +1 -0
- package/assets/{kbd-0M4qAi49.js → kbd-Nj3PirXE.js} +1 -1
- package/assets/{labels-CuC6gcyn.js → labels-BTNthaM_.js} +1 -1
- package/assets/mail-D33vNQBN.js +1 -0
- package/assets/{menu-vnrvhz9W.js → menu-Cge3eG3G.js} +1 -1
- package/assets/{move-options-_eZlt0v0.js → move-options-_Jvq5Spv.js} +1 -1
- package/assets/{nav-link-BC-lpJt4.js → nav-link-ChkTofbC.js} +1 -1
- package/assets/{onboarding-B1ncdxiJ.js → onboarding-Bzi09G3e.js} +1 -1
- package/assets/outbox-rJugUzue.js +1 -0
- package/assets/{pencil-7SyIHZVc.js → pencil-CAWN6ewF.js} +1 -1
- package/assets/{rich-text-DbpnpZXL.js → rich-text-Dp3cktQa.js} +1 -1
- package/assets/{rich-text-spellcheck-worker-provider-LftNISS3.js → rich-text-spellcheck-worker-provider-D7aFt0ey.js} +1 -1
- package/assets/{rotate-ccw-CKKgjGEq.js → rotate-ccw-CUMpjKIx.js} +1 -1
- package/assets/{row-actions-7xv7AJ82.js → row-actions-DRYVYMB6.js} +1 -1
- package/assets/search-token-index-BCcAcKHl.js +1 -0
- package/assets/{search-view-CB5G4Kva.js → search-view-DaSWxA7w.js} +1 -1
- package/assets/{senders-O9M02K_2.js → senders-DhbxI1sv.js} +1 -1
- package/assets/settings-cYD6emkb.js +1 -0
- package/assets/{settings-screen-CjdCNCJ8.js → settings-screen-CJpNRhuf.js} +1 -1
- package/assets/{shield-check-C48_fmzW.js → shield-check-wZ0xR1_v.js} +1 -1
- package/assets/{suggested-vips-BXGwlIUy.js → suggested-vips-ByzIj3y1.js} +1 -1
- package/assets/{use-match-media-jqJ95ElE.js → use-match-media-C-UI0_qJ.js} +1 -1
- package/assets/{useDebouncedValue-bAON8Yph.js → useDebouncedValue-BCfUYA_a.js} +1 -1
- package/assets/{useFilters-D_O09QB6.js → useFilters-DnPMMAYI.js} +1 -1
- package/assets/{useLabels-wgL9c4lv.js → useLabels-BCPsJjR6.js} +1 -1
- package/assets/{useRefreshControl-hxsw2pLp.js → useRefreshControl-CkuN__QT.js} +1 -1
- package/assets/{useSearchMirror-DylRqxaA.js → useSearchMirror-sL1Jjp51.js} +1 -1
- package/assets/useSearchTokenContext-CD-tKLIr.js +84 -0
- package/assets/{useSemanticSearch-BXCI_0Rt.js → useSemanticSearch-DOYK8s17.js} +1 -1
- package/assets/useSignature-CeeqBJpG.js +1 -0
- package/index.html +1 -1
- package/package.json +1 -1
- package/assets/MailListHeader-BJ9doZxm.js +0 -52
- package/assets/MailboxPane-CUVIV3ip.js +0 -1
- package/assets/OutboxPane-DD3Oj-FL.js +0 -1
- package/assets/_mailboxId-BTlxhtzs.js +0 -1
- package/assets/_messageId-CUwYB2GP.js +0 -1
- package/assets/_messageId-DFuKJd0-.js +0 -1
- package/assets/_messageId-DOJy3_kq.js +0 -1
- package/assets/_outboxMessageId-DkVUQAXG.js +0 -1
- package/assets/_threadId-D6AYslSV.js +0 -1
- package/assets/_threadId-JDDKxHld.js +0 -1
- package/assets/_threadId-oY_n41uG.js +0 -1
- package/assets/accounts-CZkcoZsJ.js +0 -1
- package/assets/brief-BAvH751q.js +0 -1
- package/assets/flagged-Cj1lkP-D.js +0 -1
- package/assets/index-72yU2-kn.js +0 -1
- package/assets/index-BfJZRVVj.js +0 -1
- package/assets/index-BxygYghU.js +0 -1
- package/assets/index-CUwYB2GP.js +0 -1
- package/assets/index-DFS5aq3D.js +0 -1
- package/assets/index-DKsFKmu0.js +0 -1
- package/assets/index-DOJy3_kq.js +0 -1
- package/assets/index-nszVYODK.js +0 -1
- package/assets/mail-DEw6NSuJ.js +0 -1
- package/assets/outbox-C-BbuTN9.js +0 -1
- package/assets/search-token-index-sLIcvT6p.js +0 -1
- package/assets/settings-CI2VbWFc.js +0 -1
- package/assets/useSearchTokenContext-Bb3YnI52.js +0 -84
- package/assets/useSignature-sSo464BG.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as r,bf as Ts,aA as zt,B as de,S as Rs,b as Le,aB as Jt,r as c,C as Es,d as Os,b0 as As,k as pt,x as tt,Z as Gt,X as Ns,p as st,s as Dt,y as zs,af as Ft,bg as Yt,bh as Xt,I as Ds,h as Fs,T as _s,bi as Ls,bj as Ps,bk as $s,ad as Zt,aN as Bs,aO as Ws,K as Ks,g as Vs,a2 as _t,bl as qs,Q as Hs,w as Us,bm as Qs,o as es,bn as Js,H as Gs,ag as Ys,i as Xs,bo as Zs,b5 as en}from"./index-Bo-p3LpF.js";import{u as tn,p as sn,R as nn}from"./useSearchTokenContext-Bb3YnI52.js";import{u as on,a as rn,R as an}from"./useRefreshControl-hxsw2pLp.js";import{C as ts,D as Fe,a as ss,b as ns,c as os,j as ln,M as cn,t as is,u as dn,d as un,e as rs,f as as,g as hn,h as fn,i as mn,k as gn,l as Wt,n as pn,m as xn,o as bn,p as vn,q as Sn,S as yn,r as Cn,s as In,v as wn,w as ls,x as jn,y as kn,z as Mn,A as Tn,B as Rn,E as En,F as On,G as An,H as Nn,I as zn,J as Dn,K as Kt,L as Vt,N as Fn,O as _n,P as Ln,Q as Pn,R as $n,T as Bn,U as Wn,V as Kn,W as Vn,X as qn,Y as Hn,Z as cs,_ as ds,$ as Lt,a0 as Un,a1 as us,a2 as Qn,a3 as Jn}from"./MailListHeader-BJ9doZxm.js";import{S as Gn,M as Yn,a as Xn,u as Zn,b as eo}from"./MailViewChrome-wpRug1Q0.js";import{E as hs,f as to}from"./ErrorState-DrA1RdFM.js";import{d as fs}from"./useFilters-D_O09QB6.js";import{C as ms}from"./confirm-dialog-DZ3dfzvC.js";import{A as Pt}from"./avatar-lbydjrIt.js";import{b as nt,c as so,d as no}from"./format-De9HZKjg.js";import{r as Pe}from"./nav-link-BC-lpJt4.js";import{N as oo}from"./NavMenuButton-Dy0q8FiJ.js";import{a as io}from"./useLabels-wgL9c4lv.js";import{L as ro,u as ao}from"./useSemanticSearch-BXCI_0Rt.js";import{u as lo,D as co}from"./use-match-media-jqJ95ElE.js";import{S as xt}from"./shield-check-C48_fmzW.js";import{B as uo}from"./bottom-sheet-BZM-qnW9.js";import{C as ho}from"./circle-help-D-5uStGy.js";import{C as fo}from"./circle-check-BO9xAEiG.js";import{a as mo,b as go,f as po}from"./move-options-_eZlt0v0.js";import{j as xo,k as bo,f as vo,d as So}from"./search-token-index-sLIcvT6p.js";import{M as yo}from"./enums-CCxx0t2v.js";import{n as Co}from"./search-query-Cr_ZXBCp.js";const Io=({children:e,onRefresh:n,isRefreshing:t})=>lo(co)?e:r.jsx(Ts,{onRefresh:n,isPullable:!t,children:e}),wo=e=>e===1?"message":"messages";function jo({count:e,onReview:n,onDismiss:t,actionLabel:s="Review & rescue"}){return r.jsx(zt,{tone:"info",variant:"soft",onDismiss:t,children:r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsxs("p",{className:"flex items-start gap-2 text-sm text-fg",children:[r.jsx(xt,{className:"mt-0.5 size-4 shrink-0 text-positive","aria-hidden":!0}),r.jsxs("span",{children:[r.jsx("span",{className:"font-semibold text-fg",children:`${e} ${wo(e)} here`})," ","may not be spam — they're from senders we can verify."]})]}),r.jsx(de,{variant:"primary",size:"sm",onClick:n,className:"self-start",children:s})]})})}const ko=(e,n)=>e==="vip"?"vip":e==="unknown"&&n==="md"?"unknown-pill":"hidden",gs=({senderTrust:e,size:n="sm",className:t})=>{const s=ko(e,n);return s==="vip"?r.jsx(Rs,{className:Le("text-warning shrink-0",n==="sm"&&"size-3.5",n==="md"&&"size-4",t),"aria-label":"VIP sender","data-testid":"sender-trust-vip"}):s==="unknown-pill"?r.jsx("span",{className:Le("inline-flex items-center rounded border border-dashed border-fg-subtle/40 font-medium uppercase tracking-wide text-fg-muted/80 shrink-0","px-2 py-0.5 text-xs",t),title:"First message from this sender","aria-label":"First message from this sender","data-testid":"sender-trust-unknown",children:"new"}):null};function Mo({candidate:e,selected:n,onToggle:t,hideSender:s=!1}){const{senderName:o,senderAddress:i,subject:l,snippet:a,trustReason:u,trustSubReason:d,senderTrust:f}=e;return r.jsxs("label",{className:Le("flex w-full cursor-pointer items-start gap-3 px-3 py-2.5 text-left transition-colors",s&&"pl-11",n?"bg-positive/10":"bg-surface hover:bg-surface-sunken"),children:[r.jsx(ts,{className:"mt-0.5",checked:n,onChange:t,"aria-label":`${n?"Deselect":"Select"} ${s?l:`message from ${o}`}`}),!s&&r.jsx(Pt,{name:o,email:i,size:"sm"}),r.jsxs("span",{className:"min-w-0 flex-1",children:[!s&&r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"truncate text-sm font-medium text-fg",children:o}),f&&r.jsx(gs,{senderTrust:f,size:"sm"}),r.jsx("span",{className:"truncate text-2xs text-fg-subtle",children:i})]}),r.jsx("span",{className:"block truncate text-sm text-fg-muted",children:l}),r.jsx("span",{className:"block line-clamp-1 text-xs text-fg-subtle",children:a}),!s&&r.jsxs("span",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[r.jsxs(Jt,{tone:"positive",children:[r.jsx(xt,{className:"size-3","aria-hidden":!0}),u]}),r.jsx("span",{className:"text-2xs text-fg-subtle",children:d})]})]})]})}const To=e=>{const n=new Map,t=[];for(const s of e){const o=(s.senderAddress||s.senderName).toLowerCase(),i=n.get(o);if(i){i.messages.push(s);continue}n.set(o,{key:o,senderName:s.senderName,senderAddress:s.senderAddress,trustReason:s.trustReason,trustSubReason:s.trustSubReason,senderTrust:s.senderTrust,messages:[s]}),t.push(o)}return t.map(s=>n.get(s)).sort((s,o)=>o.messages.length-s.messages.length)},Ro=(e,n)=>{const t=e.messages.filter(s=>n.has(s.id)).length;return t===0?"none":t===e.messages.length?"all":"some"},qt=e=>e===1?"message":"messages";function Eo({group:e,selected:n,onToggleGroup:t,onToggleMessage:s}){const[o,i]=c.useState(!1),l=Ro(e,n),a=e.messages.length,u=o?Es:Os;return r.jsxs("div",{className:Le(l!=="none"?"bg-positive/10":"bg-surface"),children:[r.jsxs("div",{className:"flex w-full items-start gap-3 px-3 py-2.5",children:[r.jsx(ts,{className:"mt-0.5",checked:l==="all",indeterminate:l==="some",onChange:()=>t(e,l!=="all"),"aria-label":`${l==="all"?"Deselect":"Select"} all ${a} ${qt(a)} from ${e.senderName}`}),r.jsx(Pt,{name:e.senderName,email:e.senderAddress,size:"sm"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"truncate text-sm font-medium text-fg",children:e.senderName}),e.senderTrust&&r.jsx(gs,{senderTrust:e.senderTrust,size:"sm"}),r.jsx("span",{className:"truncate text-2xs text-fg-subtle",children:e.senderAddress})]}),r.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[r.jsxs(Jt,{tone:"positive",children:[r.jsx(xt,{className:"size-3","aria-hidden":!0}),e.trustReason]}),r.jsx("span",{className:"text-2xs text-fg-subtle",children:e.trustSubReason})]})]}),r.jsxs("button",{type:"button",onClick:()=>i(d=>!d),"aria-expanded":o,className:"flex shrink-0 items-center gap-1 rounded-md px-1.5 py-1 text-2xs text-fg-muted transition-colors hover:bg-surface-sunken hover:text-fg",children:[`${a} ${qt(a)}`,r.jsx(u,{className:"size-3.5","aria-hidden":!0})]})]}),o&&r.jsx("div",{className:"divide-y divide-line border-t border-line",children:e.messages.map(d=>r.jsx(Mo,{candidate:d,selected:n.has(d.id),onToggle:()=>s(d.id),hideSender:!0},d.id))})]})}const $t=e=>e===1?"message":"messages",Oo=(e,n)=>`Moves ${e===1?"this message":`these ${e} ${$t(e)}`} out of Spam to ${n} now. Nothing later.`,Nt=(e,n)=>e.find(t=>t.id===n)?.label??"Inbox";function Ao(){return r.jsx(zt,{tone:"info",variant:"soft",children:r.jsx("p",{className:"text-2xs text-fg-muted",children:"We list a message here only when we can confirm the sender is who they say — usually someone you've emailed before, write to often, or a service that consistently checks out. We never guess from words in the subject. Anything we can't confirm stays in Spam."})})}function No({candidates:e,selected:n,onToggle:t,onToggleGroup:s,onSelectAll:o,onSelectNone:i,onContinue:l,onCancel:a}){const[u,d]=c.useState(!1),f=n.size,p=c.useMemo(()=>To(e),[e]);return r.jsxs("div",{className:"flex min-h-0 flex-col",children:[r.jsxs("div",{className:"px-row-inset pb-2 pt-1",children:[r.jsxs("div",{className:"flex items-start justify-between gap-2",children:[r.jsxs("h2",{className:"flex items-center gap-2 text-sm font-semibold text-fg",children:[r.jsx(xt,{className:"size-4 text-positive","aria-hidden":!0}),"Rescue from Spam"]}),r.jsx(de,{variant:"ghost",size:"sm",icon:r.jsx(ho,{className:"size-3.5"}),onClick:()=>d(m=>!m),className:"-mr-1.5 -mt-0.5",children:"Why these?"})]}),r.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:"These look safe — from senders we can verify. Uncheck any sender that belongs in Spam, or open a sender to pick individual messages."}),u&&r.jsx("div",{className:"mt-2",children:r.jsx(Ao,{})})]}),r.jsxs("div",{className:"flex items-center justify-between px-row-inset pb-1.5",children:[r.jsx("span",{className:"text-2xs font-medium text-fg-muted",children:`${f} of ${e.length} selected · ${p.length} ${p.length===1?"sender":"senders"}`}),r.jsxs("span",{className:"flex gap-1",children:[r.jsx(de,{variant:"ghost",size:"sm",onClick:o,children:"Select all"}),r.jsx(de,{variant:"ghost",size:"sm",onClick:i,children:"Select none"})]})]}),r.jsx("div",{className:"min-h-0 flex-1 divide-y divide-line overflow-y-auto border-y border-line",children:p.map(m=>r.jsx(Eo,{group:m,selected:n,onToggleGroup:s,onToggleMessage:t},m.key))}),r.jsxs("div",{className:"space-y-2 border-t border-line bg-surface px-row-inset py-3",children:[r.jsx(de,{variant:"primary",onClick:l,className:"h-11 w-full font-semibold",children:`Continue with ${f} ${$t(f)}`}),r.jsx(de,{variant:"ghost",onClick:a,className:"h-11 w-full",children:"Cancel"})]})]})}function zo({count:e,folders:n,delimiter:t,destination:s,onPick:o,onMove:i,onBack:l}){const[a,u]=c.useState(!1);return r.jsxs("div",{className:"flex min-h-0 flex-col",children:[r.jsxs("div",{className:"px-row-inset pb-2 pt-1",children:[r.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Where should they go?"}),r.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:"Pick a folder, then we move them out of Spam."})]}),r.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-y-auto px-row-inset py-2",children:a?r.jsx("div",{className:"flex min-h-0 flex-1 overflow-hidden rounded-xl border border-line bg-surface",children:r.jsx(As,{folders:n,selectedId:s,delimiter:t,onSelect:o,onCancel:()=>u(!1)})}):r.jsxs("div",{className:"rounded-xl border border-line bg-surface-sunken p-3",children:[r.jsx("p",{className:"text-2xs text-fg-subtle",children:"Destination"}),r.jsx("p",{className:"mt-0.5 text-sm font-medium text-fg",children:Nt(n,s)}),r.jsx(de,{variant:"ghost",size:"sm",onClick:()=>u(!0),className:"mt-2 px-0",children:"Move to a different folder"})]})}),r.jsxs("div",{className:"space-y-2 border-t border-line bg-surface px-row-inset py-3",children:[r.jsx("p",{className:"text-2xs text-fg-subtle",children:Oo(e,Nt(n,s))}),r.jsx(de,{variant:"primary",onClick:i,className:"h-11 w-full font-semibold",children:`Move ${e} out of Spam`}),r.jsx(de,{variant:"ghost",onClick:l,className:"h-11 w-full",children:"Back"})]})]})}function Do({count:e,destinationLabel:n,onClose:t}){return r.jsxs("div",{className:"flex min-h-0 flex-col",children:[r.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-row-inset py-10 text-center",children:[r.jsx(fo,{className:"size-10 text-positive","aria-hidden":!0}),r.jsx("p",{className:"text-base font-semibold text-fg",children:`Moved ${e} ${$t(e)} out of Spam.`}),r.jsx("p",{className:"text-2xs text-fg-subtle",children:`You'll find them in ${n}.`})]}),r.jsx("div",{className:"border-t border-line bg-surface px-row-inset py-3",children:r.jsx(de,{variant:"primary",onClick:t,className:"h-11 w-full font-semibold",children:"Done"})})]})}function Fo({open:e,candidates:n,defaultDestinationId:t,availableFolders:s,delimiter:o,onConfirmMove:i,onCancel:l}){const[a,u]=c.useState("review"),[d,f]=c.useState(()=>e?new Set(n.map(I=>I.id)):new Set),[p,m]=c.useState(t),[S,y]=c.useState(0),k=c.useRef(!1);c.useEffect(()=>{e&&!k.current&&(u("review"),f(new Set(n.map(I=>I.id))),m(t),y(0)),k.current=e},[e,n,t]);const M=d.size,x=I=>{f(j=>{const E=new Set(j);return E.has(I)?E.delete(I):E.add(I),E})},b=(I,j)=>{f(E=>{const A=new Set(E);for(const D of I.messages)j?A.add(D.id):A.delete(D.id);return A})},C=()=>{const I=Array.from(d);y(I.length),i(I,p),u("done")};return r.jsxs(uo,{open:e,onClose:l,dismissLabel:"Close rescue",children:[a==="review"&&r.jsx(No,{candidates:n,selected:d,onToggle:x,onToggleGroup:b,onSelectAll:()=>f(new Set(n.map(I=>I.id))),onSelectNone:()=>f(new Set),onContinue:()=>u("destination"),onCancel:l}),a==="destination"&&r.jsx(zo,{count:M,folders:s,delimiter:o,destination:p,onPick:m,onMove:C,onBack:()=>u("review")}),a==="done"&&r.jsx(Do,{count:S,destinationLabel:Nt(s,p),onClose:l})]})}const _o={reply:"Reply",reply_all:"Reply All",forward:"Forward",new:"New Message"},Lo=()=>{const e=c.useRef(!1);return c.useCallback(()=>{const t=document.querySelector("[data-subject-field]")?.value??"",i=(document.querySelector('[data-testid="compose-body"]')?.textContent??"").replace(/--\s*/g,"").trim();return e.current=t.trim().length>0||i.length>0,e.current},[])},Po=()=>{const{state:e,closeCompose:n}=pt(),t=Lo(),[s,o]=c.useState(!1),{isError:i,error:l,refetch:a}=tt({...Gt(),staleTime:1/0}),u=c.useCallback(m=>{m||(t()?o(!0):n())},[n,t]),d=c.useCallback(()=>{o(!1),n()},[n]),f=c.useCallback(()=>{o(!1)},[]);if(!e.isOpen)return null;const p=_o[e.mode]??"New Message";return r.jsxs(Fe.Root,{open:e.isOpen,onOpenChange:u,children:[r.jsxs(Fe.Portal,{children:[r.jsx(Fe.Overlay,{className:"fixed inset-0 z-40 bg-black/40"}),r.jsxs(Fe.Content,{className:"fixed inset-x-0 bottom-0 z-50 flex flex-col rounded-t-lg bg-canvas pb-[env(safe-area-inset-bottom,0px)]",style:{height:"95dvh"},children:[r.jsx(Fe.Handle,{className:"mx-auto mt-2 mb-1 h-1.5 w-12 rounded-full bg-fg-muted/30"}),r.jsx(Fe.Title,{className:"px-4 py-2 text-base font-semibold border-b border-line",children:p}),i?r.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:r.jsx(hs,{title:"Couldn't load compose",error:l,onRetry:()=>{a()}})}):r.jsx("div",{className:"flex-1 overflow-hidden",children:r.jsx(ss,{mode:e.mode,account:e.account,sourceMessage:e.sourceMessage,onClose:n})})]})]}),r.jsx(ms,{isOpen:s,title:"Discard draft?",description:"Your message has unsaved content. Are you sure you want to discard it?",confirmLabel:"Discard",cancelLabel:"Keep editing",destructive:!0,onConfirm:d,onCancel:f})]})},$o={reply:"Reply",reply_all:"Reply All",forward:"Forward",new:"New Message"},ps=()=>{const{state:e,closeCompose:n}=pt(),t=fs(),{isError:s,error:o,refetch:i}=tt({...Gt(),staleTime:1/0});if(!t)return r.jsx(Po,{});if(!e.isOpen)return null;const l=$o[e.mode]??"New Message",a=r.jsxs("header",{className:"flex items-center justify-between gap-2 px-4 py-3 border-b border-line shrink-0",children:[r.jsx("div",{className:"flex items-center gap-2 min-w-0",children:r.jsx("h2",{className:"text-lg font-semibold truncate",children:l})}),r.jsx("button",{type:"button",onClick:n,className:"p-2 rounded-md hover:bg-surface-raised transition-colors min-h-11 min-w-11 inline-flex items-center justify-center","aria-label":"Close",children:r.jsx(Ns,{className:"size-5"})})]});return s?r.jsxs("div",{className:"h-full flex flex-col bg-canvas",children:[a,r.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:r.jsx(hs,{title:"Couldn't load compose",error:o,onRetry:()=>{i()}})})]}):r.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-canvas",children:[a,r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:r.jsx(ss,{mode:e.mode,account:e.account,sourceMessage:e.sourceMessage,onClose:n},e.outboxMessageId??"new")})]})};function Bo(e){const n=e.toAddresses.join(", ");return{id:e.outboxMessageId,accountId:e.accountId,fromName:e.fromName??e.fromAddress??"Me",fromEmail:e.fromAddress??"",subject:e.subject??"(No subject)",snippet:n?`To: ${n}`:"(No recipients)",timeLabel:nt(e.updatedAt),isRead:!0}}function Wo(e){return{id:e.messageId,accountId:e.accountId,fromName:e.fromName??e.fromEmail??"Unknown",fromEmail:e.fromEmail??"",subject:e.subject??"(No subject)",snippet:e.snippet??"",timeLabel:nt(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0}}function Ko({outboxMessages:e,accountId:n,imapThreads:t}){const s=e.filter(l=>l.status==="draft"&&l.accountId===n).map(Bo),o=t.map(Wo),i=[];return s.length>0&&i.push({id:"remit-drafts",label:"Not yet sent (Remit)",threads:s}),o.length>0&&i.push({id:"imap-drafts",label:"On the server",threads:o}),i}const Vo=({label:e,count:n})=>r.jsxs("div",{className:"sticky top-0 z-10 flex items-baseline justify-between border-b border-line bg-surface-sunken px-row-inset py-1",children:[r.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:e}),r.jsx("span",{className:"text-2xs text-fg-subtle tabular-nums",children:n})]}),qo=({row:e,isSelected:n,onOpen:t,onDelete:s,isDeleting:o})=>r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:Le("group",os({active:n})),children:[r.jsx(Fs,{className:"size-7 shrink-0 text-fg-muted mt-0.5"}),r.jsx(ns,{thread:e}),r.jsx("div",{className:"flex items-center gap-1 shrink-0",children:r.jsx("button",{type:"button",onClick:i=>{i.stopPropagation(),s(e.id)},disabled:o,className:"p-1.5 rounded-md text-fg-muted hover:text-danger hover:bg-surface-raised transition-colors opacity-0 group-hover:opacity-100 focus:opacity-100",title:"Delete draft",children:r.jsx(_s,{className:"size-3.5"})})})]}),Ho=({row:e,isSelected:n,onOpen:t})=>{const s=!e.isRead;return r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:Le("group",os({active:n})),children:[s&&r.jsx("span",{className:"absolute left-1.5 top-1/2 size-1.5 -translate-y-1/2 rounded-full bg-accent"}),r.jsx(Pt,{name:e.fromName,email:e.fromEmail,size:"sm"}),r.jsx(ns,{thread:e})]})};function Uo({mailboxId:e,accountId:n,selectedMessageId:t,imapThreads:s,title:o,unreadCount:i}){const{openCompose:l,state:a}=pt(),u=st(),d=Dt(),{data:f}=tt(zs()),p=c.useMemo(()=>Ko({outboxMessages:f?.items??[],accountId:n,imapThreads:s}),[f?.items,n,s]),m=Ft({...Xt(),onSuccess:()=>{d.invalidateQueries({queryKey:Yt()})}}),S=x=>{m.mutate({path:{outboxMessageId:x}})},y=x=>{l({mode:"new",outboxMessageId:x})},k=x=>{const b=s.find(C=>C.messageId===x)?.threadId;b&&u({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:e,threadId:b,messageId:x},search:C=>C,hash:Pe})},M=p.length===0;return r.jsxs("section",{className:"flex h-full w-full flex-col bg-surface",children:[r.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[r.jsx(oo,{}),r.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:o}),(i??0)>0&&r.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:[i," unread"]})]}),r.jsx("div",{className:"flex-1 overflow-y-auto",children:M?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 text-center px-4",children:[r.jsx(Ds,{className:"size-8 text-fg-subtle"}),r.jsx("p",{className:"text-sm font-medium text-fg",children:"No drafts"}),r.jsx("p",{className:"text-xs text-fg-subtle",children:"Messages you start composing will appear here."})]}):p.map(x=>r.jsxs("div",{children:[x.label&&r.jsx(Vo,{label:x.label,count:x.threads.length}),r.jsx("div",{className:"divide-y divide-line",children:x.threads.map(b=>x.id==="remit-drafts"?r.jsx(qo,{row:b,isSelected:a.isOpen&&b.id===a.outboxMessageId,onOpen:y,onDelete:S,isDeleting:m.isPending},b.id):r.jsx(Ho,{row:b,isSelected:b.id===t,onOpen:k},b.id))})]},x.id))})]})}function Qo(e,n,t){const s=new Array(e);return new Proxy(s,{get(o,i,l){if(typeof i=="string"){const a=i.charCodeAt(0);if(a>=48&&a<=57){const u=+i;if(Number.isInteger(u)&&u>=0&&u<e){let d=o[u];if(!d){const f=n[u*2];d=o[u]={index:u,key:t(u),start:f,size:n[u*2+1],end:f+n[u*2+1],lane:0}}return d}}if(i==="length")return e}return Reflect.get(o,i,l)}})}function _e(e,n,t){let s=t.initialDeps??[],o,i=!0;function l(){const a=e();return(a.length!==s.length||a.some((d,f)=>s[f]!==d))&&(s=a,o=n(...a),t?.onChange&&!(i&&t.skipInitialOnChange)&&t.onChange(o),i=!1),o}return l.updateDeps=a=>{s=a},l}function Ht(e,n){if(e===void 0)throw new Error("Unexpected undefined");return e}const Jo=(e,n)=>Math.abs(e-n)<1.01,Go=(e,n,t)=>{let s;return function(...o){e.clearTimeout(s),s=e.setTimeout(()=>n.apply(this,o),t)}};let et;const Ot=()=>{if(et!==void 0)return et;if(typeof navigator>"u")return et=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return et=!0;const e=navigator.maxTouchPoints;return et=navigator.platform==="MacIntel"&&e!==void 0&&e>0},Ut=e=>{const{offsetWidth:n,offsetHeight:t}=e;return{width:n,height:t}},Yo=e=>e,Xo=e=>{const n=Math.max(e.startIndex-e.overscan,0),s=Math.min(e.endIndex+e.overscan,e.count-1)-n+1,o=new Array(s);for(let i=0;i<s;i++)o[i]=n+i;return o},Zo=(e,n)=>{const t=e.scrollElement;if(!t)return;const s=e.targetWindow;if(!s)return;const o=l=>{const{width:a,height:u}=l;n({width:Math.round(a),height:Math.round(u)})};if(o(Ut(t)),!s.ResizeObserver)return()=>{};const i=new s.ResizeObserver(l=>{const a=()=>{const u=l[0];if(u?.borderBoxSize){const d=u.borderBoxSize[0];if(d){o({width:d.inlineSize,height:d.blockSize});return}}o(Ut(t))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return i.observe(t,{box:"border-box"}),()=>{i.unobserve(t)}},gt={passive:!0},ei=typeof window>"u"?!0:"onscrollend"in window,ti=(e,n,t)=>{const s=e.scrollElement;if(!s)return;const o=e.targetWindow;if(!o)return;const i=e.options.useScrollendEvent&&ei;let l=0;const a=i?null:Go(o,()=>n(l,!1),e.options.isScrollingResetDelay),u=p=>()=>{l=t(s),a?.(),n(l,p)},d=u(!0),f=u(!1);return s.addEventListener("scroll",d,gt),i&&s.addEventListener("scrollend",f,gt),()=>{s.removeEventListener("scroll",d),i&&s.removeEventListener("scrollend",f)}},si=(e,n)=>ti(e,n,t=>{const{horizontal:s,isRtl:o}=e.options;return s?t.scrollLeft*(o&&-1||1):t.scrollTop}),ni=(e,n,t)=>{if(t.options.useCachedMeasurements){const s=t.indexFromElement(e),o=t.options.getItemKey(s);return t.itemSizeCache.get(o)??t.options.estimateSize(s)}if(n?.borderBoxSize){const s=n.borderBoxSize[0];if(s)return Math.round(s[t.options.horizontal?"inlineSize":"blockSize"])}if(!n){const s=t.indexFromElement(e),o=t.options.getItemKey(s),i=t.itemSizeCache.get(o);if(i!==void 0)return i}return e[t.options.horizontal?"offsetWidth":"offsetHeight"]},oi=(e,{adjustments:n=0,behavior:t},s)=>{var o,i;(i=(o=s.scrollElement)==null?void 0:o.scrollTo)==null||i.call(o,{[s.options.horizontal?"left":"top"]:e+n,behavior:t})},ii=oi;class ri{constructor(n){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var t,s,o;return((o=(s=(t=this.targetWindow)==null?void 0:t.performance)==null?void 0:s.now)==null?void 0:o.call(s))??Date.now()},this.observer=(()=>{let t=null;const s=()=>t||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:t=new this.targetWindow.ResizeObserver(o=>{o.forEach(i=>{const l=()=>{const a=i.target,u=this.indexFromElement(a);if(!a.isConnected){this.observer.unobserve(a);for(const[d,f]of this.elementsCache)if(f===a){this.elementsCache.delete(d);break}return}this.shouldMeasureDuringScroll(u)&&this.resizeItem(u,this.options.measureElement(a,i,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()})}));return{disconnect:()=>{var o;(o=s())==null||o.disconnect(),t=null},observe:o=>{var i;return(i=s())==null?void 0:i.observe(o,{box:"border-box"})},unobserve:o=>{var i;return(i=s())==null?void 0:i.unobserve(o)}}})(),this.range=null,this.setOptions=t=>{var s,o;const i={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Yo,rangeExtractor:Xo,onChange:()=>{},measureElement:ni,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const m in t){const S=t[m];S!==void 0&&(i[m]=S)}const l=this.options;let a=null,u=null,d=!1;if(l!==void 0&&l.enabled&&i.enabled&&i.anchorTo==="end"&&this.scrollElement!==null){const m=l.count,S=i.count,y=this.getMeasurements(),k=m>0?((s=y[0])==null?void 0:s.key)??l.getItemKey(0):null,M=m>0?((o=y[m-1])==null?void 0:o.key)??l.getItemKey(m-1):null;if(S!==m||m>0&&S>0&&(i.getItemKey(0)!==k||i.getItemKey(S-1)!==M)){d=!0;const C=m>0?this.getVirtualItemForOffset(this.getScrollOffset())??y[0]:null;C&&(a=[C.key,this.getScrollOffset()-C.start]);const I=i.followOnAppend===!0?"auto":i.followOnAppend||null;I&&S>m&&this.isAtEnd(l.scrollEndThreshold)&&(m===0||i.getItemKey(S-1)!==M)&&(u=I)}}this.options=i,d&&(this.pendingMin=0,this.itemSizeCacheVersion++);let f=!1,p=0;if(a&&this.scrollOffset!==null){const[m,S]=a,y=this.getMeasurements(),{count:k,getItemKey:M}=this.options;let x=0;for(;x<k&&M(x)!==m;)x++;if(x<k){const b=y[x];if(b){const C=b.start+S;C!==this.scrollOffset&&(p=C-this.scrollOffset,this.scrollOffset=C,f=!0)}}}(f||u)&&(this.pendingScrollAnchor=[f?a[0]:null,f?a[1]:0,u,p])},this.notify=t=>{var s,o;(o=(s=this.options).onChange)==null||o.call(s,this,t)},this.maybeNotify=_e(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),t=>{this.notify(t)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(t=>t()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var t;const s=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==s){if(this.cleanup(),!s){this.maybeNotify();return}if(this.scrollElement=s,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((t=this.scrollElement)==null?void 0:t.window)??null,this.elementsCache.forEach(i=>{this.observer.observe(i)}),this.unsubs.push(this.options.observeElementRect(this,i=>{this.scrollRect=i,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(i,l)=>{if(l&&this._intendedScrollOffset===null&&i===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(i-this._intendedScrollOffset)<1.5&&(i=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;const a=this.getScrollOffset();this.scrollDirection=l?a===i?this.scrollDirection:a<i?"forward":"backward":null,this.scrollOffset=i,this.isScrolling=l,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const i=this.scrollElement,l=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},a=()=>{this._iosTouching=!1,!(!Ot()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};i.addEventListener("touchstart",l,gt),i.addEventListener("touchend",a,gt),this.unsubs.push(()=>{i.removeEventListener("touchstart",l),i.removeEventListener("touchend",a),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const o=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,o&&this.scrollElement&&this.options.enabled){const[i,l,a,u]=o;i!==null&&!a&&(Ot()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?u!==0&&(this._iosDeferredAdjustment+=u):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),a&&this.scrollToEnd({behavior:a})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const t=this.getScrollOffset(),s=this.getMaxScrollOffset();if(t<0||t>s)return;const o=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(t,{adjustments:this.scrollAdjustments+=o,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=_e(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(t,s,o,i,l,a,u,d)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:t,paddingStart:s,scrollMargin:o,getItemKey:i,enabled:l,lanes:a,laneAssignmentMode:u,gap:d}),{key:!1}),this.getMeasurements=_e(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:t,paddingStart:s,scrollMargin:o,getItemKey:i,enabled:l,lanes:a,laneAssignmentMode:u,gap:d},f)=>{const p=this.itemSizeCache;if(!l)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>t)for(const x of this.laneAssignments.keys())x>=t&&this.laneAssignments.delete(x);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(x=>{this.itemSizeCache.set(x.key,x.size)}));const m=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===t&&(this.lanesSettling=!1),a===1){const x=t*2;let b=this._flatMeasurements;if(!b||b.length<x){const j=new Float64Array(x);b&&m>0&&j.set(b.subarray(0,m*2)),b=j,this._flatMeasurements=b}let C;if(m===0)C=s+o;else{const j=m-1;C=b[j*2]+b[j*2+1]+d}for(let j=m;j<t;j++){const E=i(j),A=p.get(E),D=typeof A=="number"?A:this.options.estimateSize(j);b[j*2]=C,b[j*2+1]=D,C+=D+d}const I=Qo(t,b,i);return this.measurementsCache=I,I}const S=this.measurementsCache.slice(0,m),y=new Array(a).fill(void 0),k=new Float64Array(a);let M=0;for(let x=0;x<m;x++){const b=S[x];b&&(y[b.lane]===void 0&&M++,y[b.lane]=x,k[b.lane]=b.end)}for(let x=m;x<t;x++){const b=i(x),C=this.laneAssignments.get(x);let I,j;const E=u==="estimate"||p.has(b);if(C!==void 0&&this.options.lanes>1){I=C;const W=y[I],K=W!==void 0?S[W]:void 0;j=K?K.end+d:s+o}else if(M===a){let W=0,K=k[0],L=y[0];for(let V=1;V<a;V++){const oe=k[V];(oe<K||oe===K&&y[V]<L)&&(W=V,K=oe,L=y[V])}I=W,j=K+d,E&&this.laneAssignments.set(x,I)}else I=x%this.options.lanes,j=s+o,E&&this.laneAssignments.set(x,I);const A=p.get(b),D=typeof A=="number"?A:this.options.estimateSize(x),O=j+D;S[x]={index:x,start:j,size:D,end:O,key:b,lane:I},y[I]===void 0&&M++,y[I]=x,k[I]=O}return this.measurementsCache=S,S},{key:!1,debug:()=>this.options.debug}),this.calculateRange=_e(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,s,o,i)=>t.length===0||s===0?(this.range=null,null):(this.range=li(t,s,o,i,i===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=_e(()=>{let t=null,s=null;const o=this.calculateRange();return o&&(t=o.startIndex,s=o.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,s]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,s]},(t,s,o,i,l)=>i===null||l===null?[]:t({startIndex:i,endIndex:l,overscan:s,count:o}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=t=>{const s=this.options.indexAttribute,o=t.getAttribute(s);return o?parseInt(o,10):(console.warn(`Missing attribute name '${s}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=t=>{var s;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const o=this.scrollState.index??((s=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:s.index);if(o!==void 0&&this.range){const i=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),l=Math.max(0,o-i),a=Math.min(this.options.count-1,o+i);return t>=l&&t<=a}return!0},this.measureElement=t=>{if(!t){this.elementsCache.forEach((l,a)=>{l.isConnected||(this.observer.unobserve(l),this.elementsCache.delete(a))});return}const s=this.indexFromElement(t),o=this.options.getItemKey(s),i=this.elementsCache.get(o);i!==t&&(i&&this.observer.unobserve(i),this.observer.observe(t),this.elementsCache.set(o,t)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(s)&&this.resizeItem(s,this.options.measureElement(t,void 0,this))},this.resizeItem=(t,s)=>{var o,i;if(t<0||t>=this.options.count)return;let l,a,u;const d=this._flatMeasurements;if(this.options.lanes===1&&d!==null)u=this.options.getItemKey(t),a=d[t*2],l=d[t*2+1];else{const m=this.measurementsCache[t];if(!m)return;u=m.key,a=m.start,l=m.size}const f=this.itemSizeCache.get(u)??l,p=s-f;if(p!==0){const m=this.options.anchorTo==="end"&&((o=this.scrollState)==null?void 0:o.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,S=m?this.getTotalSize():0,y=((i=this.scrollState)==null?void 0:i.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[t]??{index:t,key:u,start:a,size:l,end:a+l,lane:0},p,this):a<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(u)||this.scrollDirection!=="backward"));(this.pendingMin===null||t<this.pendingMin)&&(this.pendingMin=t),this.itemSizeCache.set(u,s),this.itemSizeCacheVersion++,m?this.applyScrollAdjustment(this.getTotalSize()-S):y&&this.applyScrollAdjustment(p),this.notify(!1)}},this.getVirtualItems=_e(()=>[this.getVirtualIndexes(),this.getMeasurements()],(t,s)=>{const o=[];for(let i=0,l=t.length;i<l;i++){const a=t[i],u=s[a];o.push(u)}return o},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=t=>{const s=this.getMeasurements();if(s.length===0)return;const o=this._flatMeasurements,i=this.options.lanes===1&&o!=null,l=xs(0,s.length-1,i?a=>o[a*2]:a=>Ht(s[a]).start,t);return Ht(s[l])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const t=this.scrollElement.document.documentElement;return this.options.horizontal?t.scrollWidth-this.scrollElement.innerWidth:t.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(t=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=t,this.getOffsetForAlignment=(t,s,o=0)=>{if(!this.scrollElement)return 0;const i=this.getSize(),l=this.getScrollOffset();s==="auto"&&(s=t>=l+i?"end":"start"),s==="center"?t+=(o-i)/2:s==="end"&&(t-=i);const a=this.getMaxScrollOffset();return Math.max(Math.min(a,t),0)},this.getOffsetForIndex=(t,s="auto")=>{t=Math.max(0,Math.min(t,this.options.count-1));const o=this.getSize(),i=this.getScrollOffset(),l=this.measurementsCache[t];if(!l)return;if(s==="auto")if(l.end>=i+o-this.options.scrollPaddingEnd)s="end";else if(l.start<=i+this.options.scrollPaddingStart)s="start";else return[i,s];if(s==="end"&&t===this.options.count-1)return[this.getMaxScrollOffset(),s];const a=s==="end"?l.end+this.options.scrollPaddingEnd:l.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,s,l.size),s]},this.scrollToOffset=(t,{align:s="start",behavior:o="auto"}={})=>{const i=this.getOffsetForAlignment(t,s),l=this.now();this.scrollState={index:null,align:s,behavior:o,startedAt:l,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollToIndex=(t,{align:s="auto",behavior:o="auto"}={})=>{t=Math.max(0,Math.min(t,this.options.count-1));const i=this.getOffsetForIndex(t,s);if(!i)return;const[l,a]=i,u=this.now();this.scrollState={index:t,align:a,behavior:o,startedAt:u,lastTargetOffset:l,stableFrames:0},this._scrollToOffset(l,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollBy=(t,{behavior:s="auto"}={})=>{const o=this.getScrollOffset()+t,i=this.now();this.scrollState={index:null,align:"start",behavior:s,startedAt:i,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:s}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:t="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:t});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:t})},this.getTotalSize=()=>{var t;const s=this.getMeasurements();let o;if(s.length===0)o=this.options.paddingStart;else if(this.options.lanes===1){const i=s.length-1,l=this._flatMeasurements;l!=null?o=l[i*2]+l[i*2+1]:o=((t=s[i])==null?void 0:t.end)??0}else{const i=Array(this.options.lanes).fill(null);let l=s.length-1;for(;l>=0&&i.some(a=>a===null);){const a=s[l];i[a.lane]===null&&(i[a.lane]=a.end),l--}o=Math.max(...i.filter(a=>a!==null))}return Math.max(o-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const t=[];if(this.itemSizeCache.size===0)return t;const s=this.getMeasurements();for(const o of s)o&&this.itemSizeCache.has(o.key)&&t.push({index:o.index,key:o.key,start:o.start,size:o.size,end:o.end,lane:o.lane});return t},this._scrollToOffset=(t,{adjustments:s,behavior:o})=>{this._intendedScrollOffset=t+(s??0),this.options.scrollToFn(t,{behavior:o,adjustments:s},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(n)}applyScrollAdjustment(n,t){n!==0&&(Ot()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=n:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=n,behavior:t}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollAdjustments=0)))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const s=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,o=s?s[0]:this.scrollState.lastTargetOffset,i=1,l=o!==this.scrollState.lastTargetOffset;if(!l&&Jo(o,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=i){this.getScrollOffset()!==o&&this._scrollToOffset(o,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,l){const a=this.getSize()||600,u=Math.abs(o-this.getScrollOffset()),d=this.scrollState.behavior==="smooth"&&u>a;this.scrollState.lastTargetOffset=o,d||(this.scrollState.behavior="auto"),this._scrollToOffset(o,{adjustments:void 0,behavior:d?"smooth":"auto"})}this.scheduleScrollReconcile()}}const xs=(e,n,t,s)=>{for(;e<=n;){const o=(e+n)/2|0,i=t(o);if(i<s)e=o+1;else if(i>s)n=o-1;else return o}return e>0?e-1:0};function ai(e,n,t){let s=0;for(;s<=n;){const o=(s+n)/2|0,i=e[o*2];if(i<t)s=o+1;else if(i>t)n=o-1;else return o}return s>0?s-1:0}function li(e,n,t,s,o){const i=e.length-1;if(e.length<=s)return{startIndex:0,endIndex:i};if(s===1&&o!==null){const d=ai(o,i,t);let f=d;const p=t+n;for(;f<i&&o[f*2]+o[f*2+1]<p;)f++;return{startIndex:d,endIndex:f}}let a=xs(0,i,d=>e[d].start,t),u=a;if(s===1)for(;u<i&&e[u].end<t+n;)u++;else if(s>1){const d=Array(s).fill(0);for(;u<i&&d.some(p=>p<t+n);){const p=e[u];d[p.lane]=p.end,u++}const f=Array(s).fill(t+n);for(;a>=0&&f.some(p=>p>=t);){const p=e[a];f[p.lane]=p.start,a--}a=Math.max(0,a-a%s),u=Math.min(i,u+(s-1-u%s))}return{startIndex:a,endIndex:u}}const At=typeof document<"u"?c.useLayoutEffect:c.useEffect;function ci({useFlushSync:e=!0,directDomUpdates:n=!1,directDomUpdatesMode:t="transform",...s}){const o=c.useReducer(d=>d+1,0)[1],i=c.useRef({enabled:n,mode:t,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});i.current.enabled=n,i.current.mode=t;const l=d=>{const f=i.current;if(!f.enabled||!f.container)return;const p=d.getTotalSize();if(p!==f.lastSize){f.lastSize=p;const x=d.options.horizontal?"width":"height";f.container.style[x]=`${p}px`}const m=!!d.options.horizontal,S=f.mode==="transform",y=m?"left":"top",k=d.options.scrollMargin,M=d.getVirtualItems();for(const x of M){const b=x.start-k,C=d.elementsCache.get(x.key);C&&f.lastPositions.get(C)!==b&&(f.lastPositions.set(C,b),S?C.style.transform=m?`translate3d(${b}px, 0, 0)`:`translate3d(0, ${b}px, 0)`:C.style[y]=`${b}px`)}},a={...s,onChange:(d,f)=>{var p;const m=i.current;let S=!0;if(m.enabled){l(d);const y=d.range,k=m.prevRange;S=!k||k.isScrolling!==d.isScrolling||k.startIndex!==y?.startIndex||k.endIndex!==y?.endIndex,S&&(m.prevRange=y?{startIndex:y.startIndex,endIndex:y.endIndex,isScrolling:d.isScrolling}:null)}S&&(e&&f?Ls.flushSync(o):o()),(p=s.onChange)==null||p.call(s,d,f)}},[u]=c.useState(()=>{const d=new ri(a);return Object.assign(d,{containerRef:f=>{const p=i.current;if(p.container=f,p.lastSize=null,f&&p.enabled){const m=d.getTotalSize();p.lastSize=m;const S=d.options.horizontal?"width":"height";f.style[S]=`${m}px`}}})});return u.setOptions(a),At(()=>u._didMount(),[]),At(()=>u._willUpdate()),At(()=>{l(u)}),u}function di(e){return ci({observeElementRect:Zo,observeElementOffset:si,scrollToFn:ii,...e})}const Bt=e=>e.query?`matching "${e.query}"`:e.from?`from "${e.from}"`:"matching your search",ui=e=>`Select all ${Bt(e)}`,hi=(e,n)=>`All ${so(n)} ${Bt(e)} selected`,fi=({verb:e,confirmingDelete:n,hasSelection:t,junkMailboxId:s,currentMailboxId:o,deletableMessageId:i})=>{if(n)return{kind:"withheld"};if(e==="junk"){const l=ln(s,o);if(l!==void 0)return{kind:"unavailable",reason:l}}return t?{kind:"openWizard"}:e!=="delete"||i===void 0?{kind:"declined"}:{kind:"confirmDelete",messageId:i}},mi=(e,n,t)=>e==="BACK"&&n&&t===void 0,gi=(e,n)=>({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:nt(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:is(e.category),messageCount:n,suspicious:e.authenticity?.dkimMismatch===!0,labels:e.labels}),pi=({thread:e,mailboxId:n,isSelected:t,isFocused:s,isTabStop:o,onFocusRow:i,isChecked:l,onToggleCheck:a,onRowSelect:u,messageCount:d,isMultiSelectMode:f,onLongPress:p,isDesktop:m,density:S})=>r.jsx(cn,{thread:gi(e,d),link:{mailboxId:n,threadId:e.threadId},inListbox:!0,active:t,focused:s,isTabStop:o,density:S,isDesktop:m,onFocusRow:i,selection:{isChecked:l,onToggleCheck:a,onRowSelect:u,isMultiSelectMode:f,onLongPress:p}}),xi=c.memo(pi),bi=e=>{const n=e.authenticity?.dkimMismatch===!0;return{id:e.messageId,accountId:e.accountId,fromName:e.fromName??e.fromEmail??"Unknown",fromEmail:e.fromEmail??"",subject:e.subject??"(No subject)",snippet:e.snippet??"",timeLabel:nt(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:is(e.category),suspicious:n}},vi=({thread:e,mailboxId:n,isSelected:t,isFocused:s,isTabStop:o,onFocusRow:i,isChecked:l,onToggleCheck:a,onRowSelect:u,isMultiSelectMode:d,onLongPress:f,isDesktop:p,onDelete:m,onToggleRead:S,density:y})=>{const[k,M]=c.useState("none"),x=st(),b=c.useCallback(A=>{navigator.vibrate?.(10),A==="trailing"?m(e.messageId):S(e.messageId,e.isRead),M("none")},[m,S,e.messageId,e.isRead]),C=c.useCallback(()=>{f(e.messageId)},[f,e.messageId]),I=c.useCallback(()=>{a(e.messageId)},[a,e.messageId]),j=c.useCallback(()=>{x({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:n,threadId:e.threadId,messageId:e.messageId},search:A=>A,hash:Pe})},[x,n,e.threadId,e.messageId]),E=dn(e.messageId,u);return p||d?r.jsx(xi,{thread:e,mailboxId:n,isSelected:t,isFocused:s,isTabStop:o,onFocusRow:i,isChecked:l,onToggleCheck:a,onRowSelect:u,isMultiSelectMode:d,onLongPress:f,isDesktop:p,density:y}):r.jsx("div",{role:"presentation",onPointerDownCapture:E.onMouseDown,onClickCapture:E.claimClick,onContextMenu:E.onContextMenu,children:r.jsx(Gn,{thread:bi(e),selectionMode:!1,checked:!1,active:t,peek:k,onPeek:M,onToggleCheck:I,onLongPress:C,onOpen:j,onAct:b})})},Si=72,yi=32,Ci=5,bs="remit:list-density",Ii=()=>{try{const e=localStorage.getItem(bs);if(e==="compact"||e==="comfortable")return e}catch{}return"comfortable"},wi=({query:e})=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-line bg-surface-sunken/30",children:[r.jsx(Vs,{className:"size-4 text-fg-muted"}),r.jsxs("span",{className:"text-sm text-fg-muted",children:["Results for “",e,"”"]})]}),ji=({mailboxId:e,threads:n,selectedMessageId:t,isLoading:s,isError:o=!1,error:i,onRetry:l,searchQuery:a,searchPredicate:u,onDeleteMessages:d,isDeleting:f=!1,isMoving:p=!1,onLoadMore:m,hasMore:S=!1,isLoadingMore:y=!1,accountId:k,listTitle:M,listMeta:x,listFilter:b,listScopeLabel:C,onTriageContextChange:I,commandsRef:j,hideHeader:E=!1})=>{const A=c.useRef(null),D=st(),O=fs(),W=Ps(),{verb:K,start:L,startFromSearch:V}=W,oe=$s(),Ie=!!a?.trim(),q=un(),{labels:$e}=io(k),{pushError:ae}=Zt(),[T,H]=c.useState(t),[we,P]=c.useState(),U=c.useCallback(h=>{P(v=>v===h?v:void 0),H(h)},[]),[ge,je]=c.useState(Ii),ke=c.useCallback(()=>{je(h=>{const v=h==="comfortable"?"compact":"comfortable";try{localStorage.setItem(bs,v)}catch{}return v})},[]),{toggleReadFor:Re}=rs({mailboxId:e}),{junkMailboxId:pe}=as(k),Be=ls(pe,e),{selectedIds:R,selectedCount:N,hasSelection:ie,isSelected:xe,toggle:G,select:re,clearSelection:X,selectRange:ue,setAnchor:be,selectAll:ot,toggleAll:it,intersectWith:le}=hn(),We=wn(N,O),[Y,ve]=c.useState(null),z=Ie&&!!u,rt=`${e}|${JSON.stringify(u??{})}`,w=fn({mailboxId:e,accountId:k,enabled:z,predicateKey:rt,searchQuery:u??{}}),at=c.useCallback((h,v,ee)=>{if(ee.error===void 0){if(ee.cancelled){ae({severity:"warning",title:gn(ee.done),detail:mn(h,ee.done,v)});return}ae({severity:"info",title:Wt(h,ee.done)})}},[ae]),lt=w.phase.kind,he=w.clear,Q=c.useCallback(()=>{lt==="escalated"&&he(),X()},[X,he,lt]),[Ee,ct]=c.useState(null),fe=c.useRef(null),F=c.useRef(!1),Oe=c.useRef(null),Ae=!s&&n.length>0,dt=Y!==null,Z=di({count:n.length,getScrollElement:()=>A.current,estimateSize:()=>ge==="compact"?yi:Si,overscan:Ci}),Ke=t?n.findIndex(h=>h.messageId===t):-1,$=T?n.findIndex(h=>h.messageId===T):-1,ce=c.useCallback(h=>{if(h<0||h>=n.length)return;const v=n[h];if(We){G(v.messageId);return}fe.current=v.messageId,F.current=!1,P(v.messageId),H(v.messageId)},[n,We,G]),Ve=c.useCallback(()=>{if(n.length===0)return;const h=$<0?0:Math.min($+1,n.length-1);ce(h)},[n.length,$,ce]),qe=c.useCallback(()=>{if(n.length===0)return;const h=$<=0?0:$-1;ce(h)},[n.length,$,ce]),ut=c.useCallback(()=>ce(0),[ce]),He=c.useCallback(()=>ce(n.length-1),[ce,n.length]),Ne=c.useCallback(()=>{T&&G(T)},[T,G]),B=c.useMemo(()=>n.map(h=>h.messageId),[n]),Me=c.useMemo(()=>{const h=[];for(const v of n)R.has(v.messageId)&&h.push({id:v.messageId,sender:v.fromName??v.fromEmail??"Unknown",email:v.fromEmail??"",subject:v.subject??"(No subject)",date:nt(v.sentDate)});return h},[n,R]),ht=c.useCallback((h,v)=>v.shiftKey?(ue(B,h,T),!0):v.metaKey||v.ctrlKey?(G(h),!0):(Q(),be(h),!1),[B,T,ue,G,Q,be]),ze=c.useCallback(h=>{!d||h.length===0||(Oe.current=T??null,ve(h))},[d,T]),De=c.useCallback(h=>{const v=pn(B,T,h);v!==void 0&&(ue(B,v),fe.current=v,F.current=!1,P(void 0),H(v))},[B,T,ue]),Ue=c.useCallback(()=>De(-1),[De]),Qe=c.useCallback(()=>De(1),[De]),Se=c.useCallback(()=>{B.length>0&&ot(B)},[B,ot]),Te=c.useCallback(h=>{const v=fi({verb:h,confirmingDelete:Y!==null,hasSelection:ie,junkMailboxId:pe,currentMailboxId:e,deletableMessageId:d?T:void 0});return v.kind==="openWizard"?(L(h),!0):v.kind==="confirmDelete"?(ze([v.messageId]),!0):v.kind==="unavailable"?(ae({severity:"warning",title:v.reason}),!0):v.kind==="withheld"},[Y,d,ie,pe,e,L,T,ze,ae]),ne=c.useCallback((h,v)=>{const ee=n.find(te=>te.messageId===h)?.threadId;ee&&D({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:e,threadId:ee,messageId:h},search:te=>te,hash:Pe,replace:v?.replace})},[D,e,n]),me=c.useCallback(()=>{T&&ne(T)},[T,ne]),vt=c.useCallback(h=>ne(h,{replace:!0}),[ne]);xn({keyboardFocusedMessageId:we,openMessageId:t,enabled:O&&N===0,open:vt});const Je=w.phase.kind==="escalated"?{scope:Bt(u??{}),total:w.phase.total,searchQuery:u??{},run:h=>w.runAction(h),stop:w.stop}:void 0,St=c.useCallback(()=>{if(!Y)return;const h=Y;if(h.length===0){ve(null);return}const v=new Set(h),ee=n.findIndex(se=>v.has(se.messageId));let te;for(let se=ee+1;se<n.length;se++)if(!v.has(n[se].messageId)){te=n[se].messageId;break}if(te===void 0){for(let se=ee-1;se>=0;se--)if(!v.has(n[se].messageId)){te=n[se].messageId;break}}d?.(h),Q(),Oe.current=null,ve(null),te!==void 0&&(fe.current=te,F.current=!1,U(te),O&&ne(te,{replace:!0})),O||ct(Wt("delete",h.length))},[Y,n,d,Q,ne,O,U]),ye=c.useCallback(()=>{const h=Oe.current;Oe.current=null,ve(null),h!==null&&(fe.current=h,F.current=!1,U(h))},[U]),Ge=c.useMemo(()=>{if(N===0)return;const h=new Set;for(const v of n)R.has(v.messageId)&&h.add(v.accountConfigId);if(h.size>1)return"Move only works within one account — clear selection or pick messages from a single account"},[N,R,n]),yt=c.useCallback(()=>{if(Je){V();return}L("organize")},[Je,V,L]),Ct=c.useCallback(h=>{d?.([h])},[d]),It=c.useCallback((h,v)=>{Re([h],!v)},[Re]),wt=c.useCallback(h=>{O||re(h)},[O,re]),jt=c.useCallback(()=>{if(w.isRunning||w.phase.kind==="counting"){w.stop();return}Q()},[w,Q]),kt=c.useCallback(()=>{w.clear()},[w]);c.useEffect(()=>{if(F.current||!O&&t)return;const h=$>=0?$:Ke;h>=0&&Z.scrollToIndex(h,{align:"auto"})},[$,Ke,Z,O,t]),c.useEffect(()=>{t&&(F.current=!1,U(t))},[t,U]),c.useEffect(()=>{T&&(n.some(h=>h.messageId===T)||U(n[0]?.messageId))},[n,T,U]),c.useEffect(()=>{I?.({focusedMessageId:T,selectedIds:Array.from(R),hasList:Ae,blocksKeyboard:dt||W.isOpen})},[T,R,Ae,dt,W.isOpen,I]);const Ce=c.useRef(I);Ce.current=I,c.useEffect(()=>()=>Ce.current?.({focusedMessageId:void 0,selectedIds:[],hasList:!1,blocksKeyboard:!1}),[]),c.useEffect(()=>{w.phase.kind!=="idle"||w.isRunning||le(n.map(h=>h.messageId))},[n,le,w.phase,w.isRunning]);const Ye=c.useRef(e);c.useEffect(()=>{Ye.current!==e&&(Ye.current=e,Q())},[e,Q]),bn({shouldBlockFn:({action:h})=>mi(h,ie,oe)?(Q(),!0):!1,enableBeforeUnload:!1,disabled:!ie||oe!==void 0}),c.useEffect(()=>{const h=A.current;if(!h||!S||!m)return;const v=()=>{if(y)return;const{scrollTop:ee,scrollHeight:te,clientHeight:se}=h;ee+se>=te-200&&m()};return h.addEventListener("scroll",v,{passive:!0}),v(),()=>h.removeEventListener("scroll",v)},[S,y,m]),c.useEffect(()=>{const h=fe.current;if(!h)return;const v=A.current?.querySelector(`[data-message-id="${h}"]`);v&&(fe.current=null,v.focus({preventScroll:!0}))}),c.useEffect(()=>{if(j){if(!Ae){j.current=null;return}return j.current={focusNext:Ve,focusPrevious:qe,focusFirst:ut,focusLast:He,openFocused:me,toggleSelect:Ne,extendSelectDown:Qe,extendSelectUp:Ue,selectAll:Se,clearSelection:()=>ie?(Q(),!0):!1,requestVerb:Te,toggleDensity:ke},()=>{j.current=null}}},[j,Ae,Ve,qe,ut,He,me,Ne,Qe,Ue,Se,ie,Q,Te,ke]);const Xe=s?"loading":o?"error":n.length===0?"empty":"ready",Mt=o?to(i):void 0,Tt=c.useCallback(()=>{const h=Bs(Ws());window.open(h,"_blank","noopener,noreferrer")},[]),Rt=[{id:"inbox",threads:[]}],Ze=B.length>0&&B.every(h=>R.has(h)),ft=z&&S&&Ze&&!f&&!p&&w.phase.kind==="idle"&&!w.isRunning,Et=f||p||w.isRunning,g=w.phase.kind==="escalated"?w.phase.total:N,_=w.runningAction?vn(w.runningAction.kind,w.progress?.done??0,w.progress?.total??g):w.phase.kind==="counting"?"Counting matches…":w.phase.kind==="escalated"?hi(u??{},w.phase.total):void 0,J=w.phase.kind!=="escalated"&&B.length>0?{checked:Ze,indeterminate:N>0&&!Ze,onChange:()=>it(B)}:void 0,Cs=w.runningAction?{value:w.progress?.done??0,max:w.progress?.total??g,tone:Sn(w.runningAction.kind)}:void 0,Is=(w.phase.kind==="counting"?{tone:"info",text:"",action:{label:"Stop",onClick:w.stop}}:w.phase.kind==="escalated"&&!w.isRunning?{tone:"info",text:"",action:{label:"Clear selection",onClick:kt}}:ft?{tone:"info",text:"",action:{label:ui(u??{}),onClick:w.escalate}}:void 0)??(Ge?{tone:"warning",text:Ge}:void 0),ws=r.jsx(yn,{title:q.title||M,navSlot:q.navSlot,titleMeta:q.titleMeta,searchSlot:q.searchSlot,searchField:q.searchField,idleSlot:q.makeFilterSlot,count:g,onCancel:jt,onDelete:()=>L("delete"),onMove:()=>L("move"),onOrganize:yt,onJunk:Be?()=>L("junk"):void 0,onMarkRead:()=>L("markRead"),overflowSlot:k&&e&&N>0&&$e.length>0?r.jsx(ro,{accountId:k,mailboxId:e,messageIds:Array.from(R)}):void 0,isBusy:Et,isCounting:w.phase.kind==="counting",selectAll:J,statusLabel:_,progress:Cs,notice:Is}),js=Cn(B,T),ks=c.useCallback(h=>{F.current=!0,U(h)},[U]),Ms=r.jsxs(r.Fragment,{children:[Ie&&a&&r.jsx(wi,{query:a}),r.jsxs("div",{ref:A,role:"listbox","aria-multiselectable":!0,"aria-label":M,className:"flex-1 overflow-y-auto",children:[r.jsx("div",{role:"presentation",className:"relative w-full",style:{height:`${Z.getTotalSize()}px`},children:Z.getVirtualItems().map(h=>{const v=n[h.index];return r.jsx("div",{role:"presentation","data-index":h.index,ref:Z.measureElement,className:Ks("absolute left-0 top-0 w-full border-b border-line",w.isRunning&&"pointer-events-none opacity-50"),style:{transform:`translateY(${h.start}px)`},children:r.jsx(vi,{thread:v,mailboxId:e,isSelected:t===v.messageId,isFocused:T===v.messageId,isTabStop:js===v.messageId,onFocusRow:ks,isChecked:xe(v.messageId),onToggleCheck:G,onRowSelect:ht,isMultiSelectMode:We,onLongPress:wt,isDesktop:O,onDelete:Ct,onToggleRead:It,density:ge})},h.key)})}),y&&r.jsx(Yn,{})]})]});return r.jsxs(r.Fragment,{children:[Ee&&!O&&r.jsx(zt,{tone:"success",variant:"soft",className:"m-2 rounded-md",onDismiss:()=>ct(null),children:Ee}),r.jsx(Xn,{listTitle:M,listMeta:x,sections:Rt,flatList:!0,listState:q.searchResults?"ready":Xe,searchQuery:Ie?a:void 0,listFilter:b,listScopeLabel:C,errorMessage:Mt,onRetry:l,onReportError:Tt,density:ge,selectedThreadId:t,onSelectThread:h=>ne(h),isDesktop:O,hideHeader:E,selectionBar:ws,listBody:q.searchResults??(Xe==="ready"?Ms:void 0)}),r.jsx(ms,{isOpen:Y!==null,title:no(Y?.length??0),description:"You can restore them from Trash later.",confirmLabel:"Move to Trash",destructive:!0,isBusy:f,onConfirm:St,onCancel:ye}),r.jsx(In,{verb:K,accountId:k,mailboxId:e,selection:Me,selectionRestriction:Ge?"spansAccounts":void 0,escalated:Je,escalatedProgress:w.progress,onFinished:Q,onRunEnded:at})]})},ki=e=>Hs({path:{accountId:e}}),Mi=e=>{const n=Dt(),t=_t(),s=Ft({...qs(),onSuccess:()=>{t.recordEvent("sync.triggered"),n.invalidateQueries({queryKey:ki(e)})}});return{trigger:()=>{s.mutate({path:{accountId:e}})},triggerAsync:()=>s.mutateAsync({path:{accountId:e}}),isPending:s.isPending,error:s.error,reset:s.reset}},Ti=({accountId:e,children:n})=>{const{triggerAsync:t,isPending:s}=Mi(e);return r.jsx(Io,{onRefresh:t,isRefreshing:s,children:n})};function Ri({accountId:e,currentMailboxId:n,candidates:t,onMove:s,children:o}){const[i,l]=c.useState(!1),a=_t(),u=mo(),{inboxMailboxId:d}=jn(e),f=kn(e),{data:p}=tt({...Us({path:{accountId:e}}),staleTime:1/0}),m=c.useMemo(()=>go({mailboxes:p?.items??[],folderAppointments:f,currentMailboxId:n,translator:u}),[p?.items,f,n,u]),S=c.useMemo(()=>d||(m.find(b=>b.label.toLowerCase()==="inbox")?.id??m.find(b=>!b.isCurrent)?.id??""),[d,m]),y=c.useRef(!1);c.useEffect(()=>{y.current||(y.current=!0,Mn(a,t.length))},[a,t.length]);const k=c.useCallback(()=>{Tn(a,t.length),l(!0)},[a,t.length]),M=c.useCallback((x,b)=>{Rn(a,{selected:x.length,total:t.length,toInbox:b===d}),s(x,b)},[a,t.length,d,s]);return r.jsxs("div",{className:"relative flex h-full min-h-0 flex-col",children:[r.jsx("div",{className:"shrink-0 px-row-inset pt-2",children:r.jsx(jo,{count:t.length,onReview:k})}),r.jsx("div",{className:"min-h-0 flex-1",children:o}),r.jsx(Fo,{open:i,candidates:t,defaultDestinationId:S,availableFolders:m,delimiter:po(p?.items??[]),onConfirmMove:M,onCancel:()=>l(!1)})]})}const Ei="We can verify this sender";function Oi(e){const{data:n}=tt({...Qs({path:{mailboxId:e??""},query:{senderTrust:["vip","wellknown"],dkimMismatch:!1,results:!0,limit:500}}),enabled:!!e,staleTime:6e4});return{candidates:(n?.items??[]).map(s=>({id:s.messageId,senderName:s.fromName||s.fromEmail||"Unknown sender",senderAddress:s.fromEmail??"",subject:s.subject||"(no subject)",snippet:s.snippet??"",trustReason:Ei,trustSubReason:En(s.senderTrust),senderTrust:s.senderTrust}))}}const Ai=e=>{const n=new Set,t=[];for(const s of e)n.has(s.threadMessageId)||(n.add(s.threadMessageId),t.push(s));return t},Ni={unread:"unread",flagged:"starred",attachment:"attachments"},zi=new Set(Object.values(yo)),vs=e=>zi.has(e),Di=e=>vs(e.category)||e.attributes.size>0,Fi=e=>{const n={};vs(e.category)&&(n.category=[e.category]);for(const t of e.attributes){const s=Ni[t];s&&(n[s]=!0)}return n},_i=e=>(e.senderTrust?.length??0)>0||e.dkimMismatch!==void 0?"loaded-pages":"whole-folder",Li=["category","unread","starred","attachments"],Qt=e=>JSON.stringify(Li.map(n=>e?.[n]??null)),Pi=e=>{if(!Array.isArray(e))return;const[n]=e;if(typeof n!="object"||n===null)return;const t=n.query;if(!(typeof t!="object"||t===null))return t},$i=(e,n)=>{const t=Pi(e);return t?Qt(t)===Qt(n):!1},mt=e=>e[0],Bi=e=>{const n=mt(e.filter(a=>a.type==="from").map(a=>a.value)),t=mt(e.filter(a=>a.type==="subject").map(a=>a.value)),s=mt(e.filter(a=>a.type==="category").map(a=>a.category)),o=mt(e.filter(a=>a.type==="isUnread"||a.type==="isRead").map(a=>a.type==="isUnread")),i=e.some(a=>a.type==="isStarred")?!0:void 0,l=e.some(a=>a.type==="hasAttachment")?!0:void 0;return{...n!==void 0?{from:n}:{},...t!==void 0?{subject:t}:{},...s!==void 0?{category:[s]}:{},...o!==void 0?{unread:o}:{},...i!==void 0?{starred:i}:{},...l!==void 0?{attachments:l}:{}}},Wi=(e,n)=>{switch(n.type){case"from":return e.from?.toLowerCase()===n.value.toLowerCase();case"subject":return e.subject?.toLowerCase()===n.value.toLowerCase();case"category":return e.category?.length===1&&e.category[0]===n.category;case"isUnread":return e.unread===!0;case"isRead":return e.unread===!1;case"isStarred":return e.starred===!0;case"hasAttachment":return e.attachments===!0;case"before":case"after":case"in":case"account":return!1}};function Ki(e,n={}){const t=Bi(e),s={...t,...n};return{params:t,residual:e.filter(o=>!Wi(s,o))}}function Vi(e,n,t){if(n.length===0)return e;const s=[...n];return e.filter(o=>{const i=On(o);return An({...i,accountId:i.accountId??t},s)})}const qi=50,Hi=new Map(us().categories.filter(e=>e.id!=="all").map(e=>[e.id,e.label])),Ss=c.createContext(null);function bt(){const e=c.useContext(Ss);if(!e)throw new Error("MailboxPane.* must be used inside <MailboxPane>");return e}function Ui({mailboxId:e,thread:n,children:t}){const s=st(),o=n?.threadId,i=n?.messageId,l=_t(),{accounts:a,searchQuery:u,intelligenceOpen:d,onToggleIntelligence:f}=es(),p=tn(),m=Co(u),S=m.length>0,{freeText:y,tokens:k}=sn(m,p),[M,x]=c.useState("all"),[b,C]=c.useState(new Set),I=c.useMemo(()=>({category:M,attributes:b}),[M,b]),j=c.useMemo(()=>Fi(I),[I]),E=S||Di(I),{params:A,residual:D}=Ki(k,j),O={order:"desc",limit:qi,...y?{query:y}:{},...A,...j},W={category:O.category,unread:O.unread,starred:O.starred,attachments:O.attachments},K=E?Js({path:{mailboxId:e},query:O}):Gs({path:{mailboxId:e},query:{order:"desc"}}),{data:L,isLoading:V,isError:oe,error:Ie,refetch:q,fetchNextPage:$e,hasNextPage:ae,isFetchingNextPage:T}=Zn({queryKey:K,queryFn:async({pageParam:g})=>{if(E){const{data:J}=await Zs({path:{mailboxId:e},query:{...O,continuationToken:g},throwOnError:!0});return J}const{data:_}=await en({path:{mailboxId:e},query:{order:"desc",continuationToken:g},throwOnError:!0});return _},initialPageParam:void 0,getNextPageParam:g=>g.continuationToken,placeholderData:(g,_)=>$i(_?.queryKey,W)?g:void 0}),{accountId:H}=Nn(e),we=xo({accounts:a}),P=Vi(zn(Ai(L?.pages.flatMap(g=>g.items??[])??[])),D,H),U=c.useCallback(g=>{x(g)},[]),ge=c.useCallback(g=>{C(_=>{const J=new Set(_);return J.has(g)?J.delete(g):J.add(g),J})},[]),je=c.useCallback(()=>{x("all"),C(new Set)},[]),ke=Hi.get(M),Re=ke?{label:ke,reach:D.length>0?"loaded-pages":_i(O),onClear:je}:void 0,pe=o?P.find(g=>g.messageId===i)??P.find(g=>g.threadId===o):void 0,Be=Dn(o,i),R=pe??Be,N=i??R?.messageId,ie=c.useMemo(()=>{if(o)return{threadId:o,mailboxId:R?.mailboxId??e,subject:R?.subject,messageId:N,authenticity:R?.authenticity}},[o,R,N,e]),xe=c.useCallback(()=>{s({to:"/mail/$mailboxId",params:{mailboxId:e},search:g=>g,hash:Pe})},[e,s]),G=c.useCallback(g=>{s({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:e,...g},search:_=>_,hash:Pe})},[e,s]),re=c.useCallback(g=>{N&&g.includes(N)&&xe()},[N,xe]),{deleteMessages:X,isPending:ue}=Kt({mailboxId:e,onAfterOptimisticRemove:re}),{moveMessages:be,isPending:ot}=Vt({mailboxId:e,accountId:H,onAfterOptimisticRemove:re}),it=Fn(),{listCommandsRef:le,onTriageContextChange:We,focusedMessageId:Y,selectedIds:ve}=it,z=P.find(g=>g.messageId===Y)??R,rt=c.useRef(null);c.useEffect(()=>{const g=R?.messageId??null;g&&rt.current!==g&&R?.authenticity?.dkimMismatch&&(rt.current=g,d||f())},[R?.messageId,R?.authenticity?.dkimMismatch,d,f]);const w=bo({accounts:a})??0,at=Dt(),{pushError:lt}=Zt(),he=_n({thread:R,mailboxId:e,accountId:H,onAfterOptimisticRemove:re}),{draftsMailboxId:Q}=Ln(H),Ee=Q!==void 0&&Q===e,{archiveMailboxId:ct}=Pn(H),fe=$n(),{requestCompose:F}=he,Oe=c.useCallback(()=>{F("reply")},[F]),Ae=c.useCallback(()=>{F("reply_all")},[F]),dt=c.useCallback(()=>{F("forward")},[F]),{state:Z,openCompose:Ke,closeCompose:$}=pt(),ce=c.useCallback(()=>{Ke({mode:"new"})},[Ke]),Ve=c.useRef(N);c.useEffect(()=>{const g=Ve.current;Ve.current=N,!(!N||N===g)&&$()},[N,$]);const qe=Ft({...Xt(),onError:g=>{lt(Ys("Couldn't discard draft","The draft wasn't deleted.",g))}}),ut=c.useCallback(()=>{const g=Z.outboxMessageId;g&&(qe.mutate({path:{outboxMessageId:g}}),at.invalidateQueries({queryKey:Yt()}),$())},[Z.outboxMessageId,qe,at,$]),He=c.useCallback(g=>g?fe(g):[],[fe]),{toggleStar:Ne}=Bn({threadId:z?.threadId??"",mailboxId:e}),{toggleReadFor:B}=rs({mailboxId:e,accountId:H}),{junkMailboxId:Me}=as(H),ht=Me!=null&&Me===e,ze=ls(Me,e),{candidates:De}=Oi(ht?Me:void 0),{moveMessages:Ue}=Vt({mailboxId:e,threadId:z?.threadId,accountId:H,onAfterOptimisticRemove:re}),{deleteMessages:Qe}=Kt({mailboxId:e,threadId:z?.threadId,onAfterOptimisticRemove:re}),{addressId:Se,address:Te}=Wn(z),{updateFlags:ne}=Kn({addressId:Se,senderEmail:z?.fromEmail??void 0}),me=c.useCallback(()=>{if(N||!Y)return!1;const g=P.find(_=>_.messageId===Y);return g?(G({threadId:g.threadId,messageId:Y}),!0):!1},[N,Y,P,G]),vt=c.useCallback(()=>{me()||R&&F("reply")},[me,R,F]),Je=c.useCallback(()=>{me()||R&&F("reply_all")},[me,R,F]),St=c.useCallback(()=>{me()||R&&F("forward")},[me,R,F]),ye=c.useCallback(()=>He(z),[He,z]),Ge=c.useCallback(()=>{if(le.current?.requestVerb("delete"))return;const g=ye();g.length>0&&Qe(g)},[le,ye,Qe]),yt=c.useCallback(()=>{if(le.current?.requestVerb("junk")||!ze)return;const g=ye();g.length!==0&&(Vn(l,{count:g.length,senderTrust:z?.senderTrust??"unknown",wasRescuable:z?qn(z):!1}),Ue(g,ze))},[le,ze,ye,Ue,l,z]),Ct=c.useCallback(()=>{if(ve.length>0){const g=!(z?.hasStars??!1),_=new Set(ve);for(const J of P)_.has(J.messageId)&&J.hasStars!==g&&Ne(J.messageId,J.hasStars);return}z&&Ne(z.messageId,z.hasStars)},[ve,P,z,Ne]),It=c.useCallback(()=>{if(le.current?.requestVerb("markRead"))return;const g=ye();if(g.length===0)return;const _=!(z?.isRead??!1);B(g,_)},[le,ye,z,B]),wt=c.useCallback(()=>{if(!Se)return;const g=Te?.flags?.muted?.value!==!0;ne({muted:{value:g}})},[Se,Te,ne]),jt=c.useCallback(()=>{if(!Se)return;const g=Te?.flags?.vip?.value!==!0;ne({vip:{value:g}})},[Se,Te,ne]),kt=c.useCallback(()=>{d||f()},[d,f]),Ce=c.useCallback(g=>{s({to:g})},[s]),Ye=Ee?"drafts":ct===e?"archive":Me===e?"junk":"inbox",Xe=c.useRef("");c.useEffect(()=>{const g=Xe.current;Xe.current=m,m.length>0&&g.length===0&&l.recordEvent("search.submitted",{mailboxType:Ye})},[m,Ye,l]);const Mt=Ee&&Z.isOpen&&!!Z.outboxMessageId&&!R,{goBack:Tt,nextMessageId:Rt,previousMessageId:Ze}=Hn({context:it,orderedIds:P.map(g=>g.messageId),selectedMessageId:N,enabled:!Z.isOpen,onClose:xe,handlers:{reply:vt,replyAll:Je,forward:St,delete:Ge,toggleStar:Ct,toggleRead:It,muteSender:wt,blockSender:kt,vipSender:jt,markJunk:yt,toggleIntelligence:R?f:void 0,compose:ce,goBrief:()=>Ce("/mail/brief"),goInbox:()=>Ce("/mail/brief"),goSent:()=>Ce("/mail/brief"),goFlagged:()=>Ce("/mail/flagged"),goSettings:()=>Ce("/settings")}});vo({enabled:Z.isOpen,bindings:[{key:"Escape",handler:$,preventDefault:!0}]});const ft=g=>{if(!g)return;const _=P.find(J=>J.messageId===g);return _?{threadId:_.threadId,messageId:g}:void 0},Et={mailboxId:e,selectedMessageId:N,selectedThread:R,conversation:ie,onOpenThread:G,threads:P,isLoading:V,isError:oe,error:Ie,mailboxAccountId:H,mailboxName:we,unreadCount:w,isDraftsMailbox:Ee,isSpamFolder:ht,rescueCandidates:De,filterCategory:M,filterAttributes:b,onSelectFilterCategory:U,onToggleFilterAttribute:ge,onClearFilters:je,listFilter:Re,intelligenceOpen:d,onToggleIntelligence:f,handleDeselectIfRemoved:re,searchPredicate:S&&D.length===0?O:void 0,onDeleteMessages:X,onMoveMessages:be,isDeleting:ue,isMoving:ot,onLoadMore:$e,hasMore:ae,isLoadingMore:T,onTriageContextChange:We,listCommandsRef:le,onRetry:()=>q(),toolbarComposeRequest:he.composeRequest,onToolbarReply:Oe,onToolbarReplyAll:Ae,onToolbarForward:dt,onClearComposeRequest:he.clearComposeRequest,onToolbarDelete:he.deleteThread,onToolbarStar:he.toggleStar,onToolbarDiscardDraft:ut,onToolbarMove:he.moveThread,composeState:Z,closeCompose:$,hasRemitDraftOpen:Mt,onBack:Tt,nextThread:ft(Rt),previousThread:ft(Ze)};return r.jsx(Ss.Provider,{value:Et,children:t})}function ys(){const{mailboxId:e,selectedMessageId:n,threads:t,isLoading:s,isError:o,error:i,onDeleteMessages:l,onMoveMessages:a,isDeleting:u,isMoving:d,onLoadMore:f,hasMore:p,isLoadingMore:m,mailboxAccountId:S,mailboxName:y,unreadCount:k,isDraftsMailbox:M,isSpamFolder:x,rescueCandidates:b,onTriageContextChange:C,listCommandsRef:I,onRetry:j,filterCategory:E,filterAttributes:A,onSelectFilterCategory:D,onToggleFilterAttribute:O,onClearFilters:W,listFilter:K,searchPredicate:L}=bt(),{searchQuery:V,searchInput:oe,accounts:Ie,resultFolderIndex:q}=es(),$e=So(),ae=st(),T=y??"Inbox",H=c.useMemo(()=>us(),[]),we=c.useMemo(()=>S?[S]:[],[S]),{hasNewMail:P}=on(),{state:U,errorMessage:ge,refresh:je}=rn(we,{onSettled:j}),ke=c.useMemo(()=>r.jsx(an,{state:U,onRefresh:je,label:`Refresh ${T}`,errorMessage:ge,hasUpdate:P(we)}),[U,je,T,ge,P,we]),Re=c.useMemo(()=>t.map(X=>Qn(X,q)),[t,q]),{hits:pe,isLoading:Be}=ao({mailboxId:e,filterCategory:E}),R=c.useMemo(()=>Jn(pe,t.map(X=>X.threadId),q),[pe,t,q]),N=c.useCallback(X=>{const ue=X.threadId??t.find(be=>be.messageId===X.id)?.threadId;ue&&ae({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:X.mailboxId??e,threadId:ue,messageId:X.id},search:be=>({...be,q:oe||void 0}),hash:Pe})},[e,ae,oe,t]);if(M&&S)return r.jsx(Uo,{mailboxId:e,accountId:S,selectedMessageId:n,imapThreads:t,title:y??"Drafts",unreadCount:k??void 0});const ie=r.jsx(ji,{mailboxId:e,threads:t,selectedMessageId:n,isLoading:s,isError:o,error:i,onRetry:j,searchQuery:V,searchPredicate:L,onDeleteMessages:l,isDeleting:u,isMoving:d,onLoadMore:f,hasMore:p,isLoadingMore:m,accountId:S,listTitle:T,listFilter:K,listScopeLabel:T,hideHeader:!0,onTriageContextChange:C,commandsRef:I}),xe=Ie[0]?.accountId,G=$e==="phone"&&xe?r.jsx(Ti,{accountId:xe,children:ie}):ie,re=x&&b.length>0&&S?r.jsx(Ri,{accountId:S,currentMailboxId:e,candidates:b,onMove:a,children:G}):G;return r.jsx(eo,{title:T,unreadCount:k,preset:H,selectedCategory:E,activeFilters:A,onSelectCategory:D,onToggleFilter:O,onClearFilters:W,searchResults:Re,searchLoading:s,relatedResults:R,relatedLoading:Be,onSelectSearchResult:N,searchResultsInBody:!0,refreshControl:ke,children:re})}function Qi(){const{mailboxId:e,mailboxAccountId:n,selectedThread:t,conversation:s,hasRemitDraftOpen:o,intelligenceOpen:i,onToggleIntelligence:l,toolbarComposeRequest:a,onToolbarReply:u,onToolbarReplyAll:d,onToolbarForward:f,onClearComposeRequest:p,onToolbarDelete:m,onToolbarStar:S,onToolbarDiscardDraft:y,onToolbarMove:k,composeState:M,handleDeselectIfRemoved:x}=bt(),b=Xs()?.showIntelligencePane??!1,C=!!s,[I,j]=c.useState(null),E=s?.threadId??null,A=!b&&E!==null&&I===E,D=c.useCallback(()=>j(null),[]),O=c.useCallback(()=>j(E),[E]),W=b?l:O,K=c.useCallback(()=>{if(b){l();return}j(A?null:E)},[b,l,A,E]),L=C&&(b?i:A),V=M.isOpen&&!s?r.jsx(ps,{}):s?r.jsx(cs,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onOpenIntelligence:s.authenticity?.dkimMismatch?W:void 0,composeRequest:a,onComposeClose:p}):r.jsx(nn,{});return r.jsxs(r.Fragment,{children:[r.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[r.jsx(Un,{hasThread:C,intelligenceOpen:L,canToggleIntelligence:C,onToggleIntelligence:K,onReply:C?u:void 0,onReplyAll:C?d:void 0,onForward:C?f:void 0,canDelete:C||o,onDelete:C?m:o?y:void 0,onToggleStar:C?S:void 0,isStarred:t?.hasStars,moveContext:C&&n?{accountId:n,currentMailboxId:e,onMove:k}:void 0}),r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:V})]}),r.jsx(ds,{isOpen:A,onClose:D,ariaLabel:"Message details",side:"right",children:r.jsx(Lt,{onClose:D,thread:t,mailboxId:e,accountId:n,hideCloseButton:!0,onAfterOptimisticRemove:x})})]})}function Ji(){const{mailboxId:e,mailboxAccountId:n,selectedThread:t,onToggleIntelligence:s,handleDeselectIfRemoved:o}=bt();return r.jsx(Lt,{onClose:s,thread:t,mailboxId:e,accountId:n,onAfterOptimisticRemove:o})}function Gi(){const{mailboxId:e,mailboxAccountId:n,selectedThread:t,conversation:s,onOpenThread:o,intelligenceOpen:i,onToggleIntelligence:l,onBack:a,nextThread:u,previousThread:d,composeState:f,handleDeselectIfRemoved:p}=bt();return s?r.jsxs(r.Fragment,{children:[r.jsx(cs,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onBack:a,onOpenIntelligence:l,onSwipeNext:u?()=>o(u):void 0,onSwipePrevious:d?()=>o(d):void 0,mobileIntelligenceOpen:i}),r.jsx(ds,{isOpen:i,onClose:l,ariaLabel:"Message details",side:"right",children:r.jsx(Lt,{onClose:l,thread:t,mailboxId:e,accountId:n,hideCloseButton:!0,onAfterOptimisticRemove:p})})]}):f.isOpen?r.jsx("div",{className:"h-full",children:r.jsx(ps,{})}):r.jsx(ys,{})}const Cr=Object.assign(Ui,{List:ys,Reading:Qi,Intelligence:Ji,Phone:Gi});export{Cr as M};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ab as w,e as k,an as S,j as s,b,bR as H,T as K,f as R,p as W,x as G,y as J,o as V,r as m,u as A,bJ as I,bU as X,K as N,s as Y,k as Z,ad as ee,bg as se,af as v,ag as y,cf as te,bh as ne}from"./index-Bo-p3LpF.js";import{u as ae,p as oe,R as p,g as re}from"./useSearchTokenContext-Bb3YnI52.js";import{C as T}from"./circle-check-big-xK5jTBa2.js";import{C as E}from"./clock-CdRZkrpV.js";import{R as ie}from"./row-actions-7xv7AJ82.js";import{R as le}from"./rotate-ccw-CKKgjGEq.js";import{N as L}from"./NavMenuButton-Dy0q8FiJ.js";import{a as g,t as ce}from"./format-De9HZKjg.js";import{i as de,a as Q}from"./outbox-status-CPfNHfUQ.js";import{n as ue}from"./search-query-Cr_ZXBCp.js";import{r as M}from"./nav-link-BC-lpJt4.js";const xe={queued:{icon:E,label:"Queued",className:"text-warning"},sending:{icon:S,label:"Sending…",className:"text-accent-2",spin:!0},sent:{icon:T,label:"Sent",className:"text-positive"},failed:{icon:k,label:"Failed",className:"text-danger"},blocked:{icon:w,label:"Blocked",className:"text-warning"}};function O({status:e,iconOnly:n,className:a}){const t=xe[e],o=t.icon;return s.jsxs("span",{className:b("inline-flex items-center gap-1.5 text-xs font-medium",t.className,a),children:[s.jsx(o,{className:b("size-4",t.spin&&"animate-spin")}),!n&&t.label]})}const me=(e,n)=>n?"bg-accent-2-soft":e==="failed"?"bg-danger-soft":e==="blocked"?"bg-warning/10":"";function fe({recipients:e,subject:n,time:a,status:t,error:o,selected:i,onSelect:c,onRetry:r,retrying:d,onEdit:l,onDelete:f,deleting:u}){const h=t==="failed"||t==="blocked";return s.jsxs("div",{className:b("flex items-start gap-3 border-b border-line px-4 py-3 transition-colors hover:bg-surface-raised",me(t,i)),children:[s.jsxs("button",{type:"button",...H,onClick:c,className:"flex flex-1 min-w-0 items-start gap-3 text-left",children:[s.jsx("div",{className:"mt-0.5 shrink-0",children:s.jsx(O,{status:t,iconOnly:!0})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"truncate text-sm font-medium",children:e}),s.jsx("span",{className:"shrink-0 text-xs text-fg-muted",children:a})]}),s.jsx("div",{className:"truncate text-sm",children:n||"No subject"}),s.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[s.jsx(O,{status:t}),o&&s.jsxs("span",{className:"truncate text-xs text-fg-muted",children:["— ",o]})]})]})]}),h&&s.jsx("div",{className:"shrink-0",children:s.jsx(ie,{actions:[...t==="failed"&&r?[{label:"Retry sending",iconOnly:!0,icon:s.jsx(le,{className:"size-3.5"}),busy:d,onClick:r}]:[],{label:"Edit as draft",iconOnly:!0,icon:s.jsx(R,{className:"size-3.5"}),onClick:l}],destructive:{label:"Delete message",iconOnly:!0,icon:s.jsx(K,{className:"size-3.5"}),busy:u,confirm:{prompt:"Delete this message?",confirmLabel:"Delete"},onClick:f}})})]})}function he(e,n){const a=n.trim().toLowerCase();if(a.length===0)return!0;const t=[e.subject,e.fromAddress,e.fromName,...e.toAddresses??[],...e.ccAddresses??[]].filter(o=>typeof o=="string").join(" ").toLowerCase();return a.split(/\s+/).every(o=>o.length===0||t.includes(o))}function be(e){return e.tokens.length>0&&e.freeText.trim().length===0}const D={queued:{icon:E,label:"Queued",className:"text-warning"},sending:{icon:S,label:"Sending…",className:"text-accent-2"},sent:{icon:T,label:"Sent",className:"text-positive"},failed:{icon:k,label:"Failed",className:"text-danger"},blocked:{icon:w,label:"Blocked",className:"text-warning"}},ge=e=>ce(e).toDateString()===new Date().toDateString()?g(e,{hour:"numeric",minute:"2-digit"}):g(e,{month:"short",day:"numeric"}),C=e=>g(e,{dateStyle:"medium",timeStyle:"short"}),pe=e=>{const n=e.toAddresses??[];return n.length===0?"No recipients":n.length===1?n[0]:`${n[0]} +${n.length-1}`},P=(e,n)=>n?"The outbox cannot filter on those terms":e?"No matching outbox messages":"No outbox messages",B=m.createContext(null);function j(){const e=m.useContext(B);if(!e)throw new Error("OutboxPane.* must be used inside <OutboxPane>");return e}function je({outboxMessageId:e,children:n}){const a=W(),{data:t,isLoading:o}=G(J()),{searchQuery:i}=V(),c=ae(),r=ue(i),d=oe(r,c),l=r.length>0,f=be(d),u=m.useMemo(()=>f?[]:(t?.items??[]).filter(x=>de(x.status)).filter(x=>he(x,d.freeText)),[t,d.freeText,f]),h=m.useMemo(()=>u.find(x=>x.outboxMessageId===e),[u,e]),$=m.useCallback(x=>{a({to:"/mail/outbox/draft/$outboxMessageId",params:{outboxMessageId:x},search:q=>q,hash:M})},[a]),U=m.useCallback(()=>{a({to:"/mail/outbox",search:x=>x,hash:M})},[a]),_={messages:u,hasQuery:l,unsupportedQuery:f,isLoading:o,selectedMessageId:e,selectedMessage:h,onOpenMessage:$,onCloseMessage:U};return s.jsx(B.Provider,{value:_,children:n})}function z({message:e,isSelected:n,onSelect:a}){const t=Y(),{openCompose:o}=Z(),{pushError:i}=ee(),c=m.useCallback(()=>{t.invalidateQueries({queryKey:se()})},[t]),r=v({...te(),onSuccess:c,onError:u=>{i(y("Couldn't resend message","The message wasn't sent.",u))}}),d=v({...ne(),onSuccess:c,onError:u=>{i(y("Couldn't delete message","The message wasn't deleted.",u))}}),l=e.status;if(!D[l])return null;const f=Q(e.status);return s.jsx(fe,{recipients:pe(e),subject:e.subject||"",time:ge(e.sentAt??e.updatedAt),status:l,error:f?e.lastError??void 0:void 0,selected:n,onSelect:a,onRetry:l==="failed"?()=>r.mutate({path:{outboxMessageId:e.outboxMessageId}}):void 0,retrying:r.isPending,onEdit:()=>o({mode:"new",outboxMessageId:e.outboxMessageId}),onDelete:()=>d.mutate({path:{outboxMessageId:e.outboxMessageId}}),deleting:d.isPending})}function F({message:e,onBack:n}){const a=e.status,t=D[a],o=t?.icon??R,i=e.sentAt?C(e.sentAt):C(e.updatedAt);return s.jsxs("div",{className:"h-full overflow-y-auto bg-canvas",children:[s.jsxs("div",{className:"border-b border-line p-4",children:[n&&s.jsxs("button",{type:"button",onClick:n,className:"mb-3 inline-flex items-center gap-1 text-sm text-fg-muted hover:text-fg",children:[s.jsx(X,{className:"size-4"}),s.jsx("span",{children:"Back"})]}),s.jsx("h1",{className:"text-xl font-semibold mb-3",children:e.subject||"(No subject)"}),s.jsxs("div",{className:"space-y-1 text-sm",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx("span",{className:"text-fg-muted shrink-0 w-12",children:"From:"}),s.jsx("span",{className:"text-fg",children:e.fromName?`${e.fromName} <${e.fromAddress}>`:e.fromAddress})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("span",{className:"text-fg-muted shrink-0 w-12",children:"To:"}),s.jsx("span",{className:"text-fg",children:(e.toAddresses??[]).join(", ")})]}),e.ccAddresses&&e.ccAddresses.length>0&&s.jsxs("div",{className:"flex gap-2",children:[s.jsx("span",{className:"text-fg-muted shrink-0 w-12",children:"Cc:"}),s.jsx("span",{className:"text-fg",children:e.ccAddresses.join(", ")})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("span",{className:"text-fg-muted shrink-0 w-12",children:"Date:"}),s.jsx("span",{className:"text-fg",children:i})]}),t&&s.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[s.jsx(o,{className:N("size-4",t.className,a==="sending"&&"animate-spin")}),s.jsx("span",{className:N("text-xs font-medium",t.className),children:t.label}),Q(e.status)&&e.lastError&&s.jsxs("span",{className:"text-xs text-fg-muted",children:["— ",e.lastError]})]})]})]}),s.jsx("div",{className:"p-4",children:s.jsx(re,{html:e.htmlBody,text:e.textBody})})]})}function Ne(){const{messages:e,hasQuery:n,unsupportedQuery:a,isLoading:t,selectedMessageId:o,onOpenMessage:i}=j(),c=m.useRef(null);return A({containerRef:c,itemSelector:I}),t?s.jsx("div",{className:"flex h-full items-center justify-center bg-canvas",children:s.jsx("span",{className:"text-fg-muted",children:"Loading..."})}):e.length===0?s.jsx("div",{className:"flex h-full bg-surface",children:s.jsx(p,{message:P(n,a),showHints:!1})}):s.jsxs("div",{className:"h-full flex flex-col bg-canvas",children:[s.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[s.jsx(L,{}),s.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:"Outbox"}),s.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle",children:[e.length," ",e.length===1?"message":"messages"]})]}),s.jsx("div",{ref:c,className:"flex-1 overflow-y-auto",children:e.map(r=>s.jsx(z,{message:r,isSelected:o===r.outboxMessageId,onSelect:()=>i(r.outboxMessageId)},r.outboxMessageId))})]})}function ve(){const{selectedMessage:e}=j();return s.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[s.jsx("header",{className:"flex h-pane-header shrink-0 items-center border-b border-line px-3"}),s.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e?s.jsx(F,{message:e}):s.jsx(p,{message:"Select a message to read",showHints:!1})})]})}function ye(){const{messages:e,hasQuery:n,unsupportedQuery:a,isLoading:t,selectedMessageId:o,selectedMessage:i,onOpenMessage:c,onCloseMessage:r}=j(),d=m.useRef(null);return A({containerRef:d,itemSelector:I}),t?s.jsx("div",{className:"flex h-full items-center justify-center bg-canvas",children:s.jsx("span",{className:"text-fg-muted",children:"Loading..."})}):i?s.jsx(F,{message:i,onBack:r}):e.length===0?s.jsx("div",{className:"flex h-full bg-surface",children:s.jsx(p,{message:P(n,a),showHints:!1})}):s.jsxs("div",{className:"h-full flex flex-col bg-canvas",children:[s.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[s.jsx(L,{}),s.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:"Outbox"}),s.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle",children:[e.length," ",e.length===1?"message":"messages"]})]}),s.jsx("div",{ref:d,className:"flex-1 overflow-y-auto",children:e.map(l=>s.jsx(z,{message:l,isSelected:o===l.outboxMessageId,onSelect:()=>c(l.outboxMessageId)},l.outboxMessageId))})]})}const Le=Object.assign(je,{List:Ne,Reading:ve,Phone:ye});export{Le as O};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a3 as m,j as o,a0 as p}from"./index-Bo-p3LpF.js";import{a}from"./search-view-CB5G4Kva.js";import{M as r}from"./MailboxPane-CUVIV3ip.js";import{u as e}from"./useSearchMirror-DylRqxaA.js";import"./nav-link-BC-lpJt4.js";import{e as s}from"./search-token-index-sLIcvT6p.js";import"./useSearchTokenContext-Bb3YnI52.js";import"./kbd-0M4qAi49.js";import"./enums-CCxx0t2v.js";import"./useRefreshControl-hxsw2pLp.js";import"./circle-check-big-xK5jTBa2.js";import"./MailListHeader-BJ9doZxm.js";import"./account-form-helpers-D1exxHT6.js";import"./avatar-lbydjrIt.js";import"./useSignature-sSo464BG.js";import"./useDebouncedValue-bAON8Yph.js";import"./useFilters-D_O09QB6.js";import"./use-match-media-jqJ95ElE.js";import"./ErrorState-DrA1RdFM.js";import"./format-De9HZKjg.js";import"./download-BRZRRebx.js";import"./shield-check-C48_fmzW.js";import"./move-options-_eZlt0v0.js";import"./confirm-dialog-DZ3dfzvC.js";import"./clock-CdRZkrpV.js";import"./menu-vnrvhz9W.js";import"./MailViewChrome-wpRug1Q0.js";import"./NavMenuButton-Dy0q8FiJ.js";import"./useLabels-wgL9c4lv.js";import"./useSemanticSearch-BXCI_0Rt.js";import"./search-query-Cr_ZXBCp.js";import"./bottom-sheet-BZM-qnW9.js";import"./circle-help-D-5uStGy.js";import"./circle-check-BO9xAEiG.js";function J(){const{mailboxId:t}=m.useParams(),i=s();return e({to:"/mail/$mailboxId",params:{mailboxId:t}}),o.jsx(r,{mailboxId:t,thread:i,children:o.jsx(a,{phone:o.jsx(r.Phone,{}),list:o.jsx(r.List,{}),reading:o.jsx(p,{}),intelligence:o.jsx(r.Intelligence,{}),hasThread:!!i})})}export{J as component};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as r}from"./index-Bo-p3LpF.js";import{B as o}from"./BriefPane-D5U_FMo6.js";import"./useSearchTokenContext-Bb3YnI52.js";import"./kbd-0M4qAi49.js";import"./enums-CCxx0t2v.js";import"./nav-link-BC-lpJt4.js";import"./MailListHeader-BJ9doZxm.js";import"./search-token-index-sLIcvT6p.js";import"./use-match-media-jqJ95ElE.js";import"./account-form-helpers-D1exxHT6.js";import"./avatar-lbydjrIt.js";import"./useSignature-sSo464BG.js";import"./useDebouncedValue-bAON8Yph.js";import"./useFilters-D_O09QB6.js";import"./ErrorState-DrA1RdFM.js";import"./format-De9HZKjg.js";import"./download-BRZRRebx.js";import"./shield-check-C48_fmzW.js";import"./move-options-_eZlt0v0.js";import"./confirm-dialog-DZ3dfzvC.js";import"./clock-CdRZkrpV.js";import"./menu-vnrvhz9W.js";import"./useRefreshControl-hxsw2pLp.js";import"./circle-check-big-xK5jTBa2.js";import"./useLabels-wgL9c4lv.js";import"./useSemanticSearch-BXCI_0Rt.js";import"./search-query-Cr_ZXBCp.js";function y(){return r.jsx(o.Reading,{})}export{y as component};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as o}from"./index-Bo-p3LpF.js";import{M as r}from"./MailboxPane-CUVIV3ip.js";import"./useSearchTokenContext-Bb3YnI52.js";import"./kbd-0M4qAi49.js";import"./enums-CCxx0t2v.js";import"./nav-link-BC-lpJt4.js";import"./useRefreshControl-hxsw2pLp.js";import"./circle-check-big-xK5jTBa2.js";import"./search-token-index-sLIcvT6p.js";import"./use-match-media-jqJ95ElE.js";import"./MailListHeader-BJ9doZxm.js";import"./account-form-helpers-D1exxHT6.js";import"./avatar-lbydjrIt.js";import"./useSignature-sSo464BG.js";import"./useDebouncedValue-bAON8Yph.js";import"./useFilters-D_O09QB6.js";import"./ErrorState-DrA1RdFM.js";import"./format-De9HZKjg.js";import"./download-BRZRRebx.js";import"./shield-check-C48_fmzW.js";import"./move-options-_eZlt0v0.js";import"./confirm-dialog-DZ3dfzvC.js";import"./clock-CdRZkrpV.js";import"./menu-vnrvhz9W.js";import"./MailViewChrome-wpRug1Q0.js";import"./NavMenuButton-Dy0q8FiJ.js";import"./useLabels-wgL9c4lv.js";import"./useSemanticSearch-BXCI_0Rt.js";import"./search-query-Cr_ZXBCp.js";import"./bottom-sheet-BZM-qnW9.js";import"./circle-help-D-5uStGy.js";import"./circle-check-BO9xAEiG.js";function F(){return o.jsx(r.Reading,{})}export{F as component};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as o}from"./index-Bo-p3LpF.js";import{F as r}from"./FlaggedPane-CD0MhkHu.js";import"./useSearchTokenContext-Bb3YnI52.js";import"./kbd-0M4qAi49.js";import"./enums-CCxx0t2v.js";import"./nav-link-BC-lpJt4.js";import"./MailListHeader-BJ9doZxm.js";import"./search-token-index-sLIcvT6p.js";import"./use-match-media-jqJ95ElE.js";import"./account-form-helpers-D1exxHT6.js";import"./avatar-lbydjrIt.js";import"./useSignature-sSo464BG.js";import"./useDebouncedValue-bAON8Yph.js";import"./useFilters-D_O09QB6.js";import"./ErrorState-DrA1RdFM.js";import"./format-De9HZKjg.js";import"./download-BRZRRebx.js";import"./shield-check-C48_fmzW.js";import"./move-options-_eZlt0v0.js";import"./confirm-dialog-DZ3dfzvC.js";import"./clock-CdRZkrpV.js";import"./menu-vnrvhz9W.js";import"./MailViewChrome-wpRug1Q0.js";function k(){return o.jsx(r.Reading,{})}export{k as component};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as o}from"./index-Bo-p3LpF.js";import{O as t}from"./OutboxPane-DD3Oj-FL.js";import"./useSearchTokenContext-Bb3YnI52.js";import"./kbd-0M4qAi49.js";import"./enums-CCxx0t2v.js";import"./nav-link-BC-lpJt4.js";import"./circle-check-big-xK5jTBa2.js";import"./clock-CdRZkrpV.js";import"./row-actions-7xv7AJ82.js";import"./rotate-ccw-CKKgjGEq.js";import"./NavMenuButton-Dy0q8FiJ.js";import"./menu-vnrvhz9W.js";import"./format-De9HZKjg.js";import"./outbox-status-CPfNHfUQ.js";import"./search-query-Cr_ZXBCp.js";function P(){return o.jsx(t.Reading,{})}export{P as component};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a0 as o}from"./index-Bo-p3LpF.js";const n=o;export{n as component};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a0 as o}from"./index-Bo-p3LpF.js";const n=o;export{n as component};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a0 as o}from"./index-Bo-p3LpF.js";const n=o;export{n as component};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as r,a8 as ke,B as ee,a as ks,X as Ve,a9 as Vs,aa as Ds,ab as dt,r as C,b as Nt,ac as J,s as ut,ad as Cs,x as Jt,Z as es,ae as Fs,af as Se,ag as Os,a1 as Ae,ah as ts,ai as Is,aj as Ms,ak as Rs,al as ve,am as At,an as at,ao as Tt,K as Et,ap as Ls,aq as Ie,ar as be,as as _t,n as Us,at as zs,au as Hs,av as ss,aw as Pt,p as Bs,ax as qs,ay as $s,az as Ws,aA as kt,aB as Ks,aC as Vt,aD as Gs,T as Ys}from"./index-Bo-p3LpF.js";import{R as Zs}from"./row-actions-7xv7AJ82.js";import{S as Qs,A as Xs}from"./settings-screen-CjdCNCJ8.js";import{g as Dt,P as Js,s as Be,u as er,O as tr}from"./OnboardingWizard-DxBnC5ZI.js";import{u as sr}from"./useSignature-sSo464BG.js";import{c as rr,a as Ct,d as ar}from"./account-form-helpers-D1exxHT6.js";import{D as ir}from"./download-BRZRRebx.js";import{E as nr}from"./ErrorState-DrA1RdFM.js";import{f as or}from"./format-De9HZKjg.js";import"./avatar-lbydjrIt.js";import"./menu-vnrvhz9W.js";import"./circle-help-D-5uStGy.js";import"./kbd-0M4qAi49.js";const lr=e=>{const s=new Set(e.map(Vs));return Ds.map(t=>t.tag).filter(t=>!s.has(t)).sort((t,i)=>ke(t).localeCompare(ke(i)))},cr=({value:e,onChange:s,busy:t=!1})=>{const i=lr(e);return r.jsxs("div",{className:"space-y-2","data-testid":"compose-language-setting",children:[r.jsx("ul",{className:"space-y-1",children:e.map((o,d)=>r.jsxs("li",{"data-testid":`compose-language-row-${o}`,className:"flex items-center gap-2 rounded-md border border-line bg-surface-sunken px-3 py-1.5",children:[r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-fg",lang:o,children:ke(o)}),d===0?r.jsx("span",{className:"shrink-0 text-2xs uppercase tracking-wider text-fg-subtle",children:"Default"}):r.jsx(ee,{variant:"ghost",size:"sm",icon:r.jsx(ks,{className:"size-3.5"}),disabled:t,"aria-label":`Write new messages in ${ke(o)} by default`,onClick:()=>s([o,...e.filter(n=>n!==o)]),children:"Default"}),r.jsx(ee,{variant:"ghost",size:"sm",icon:r.jsx(Ve,{className:"size-3.5"}),disabled:t||e.length===1,"aria-label":`Remove ${ke(o)}`,onClick:()=>s(e.filter(n=>n!==o))})]},o))}),r.jsxs("select",{"aria-label":"Add a language",value:"",disabled:t||i.length===0,onChange:o=>{o.target.value!==""&&s([...e,o.target.value])},className:"w-full rounded-md border border-line bg-surface-sunken px-3 py-2 text-sm text-fg outline-none transition-colors focus-within:border-line-strong focus-within:ring-2 focus-within:ring-ring/30",children:[r.jsx("option",{value:"",children:"Add a language…"}),i.map(o=>r.jsx("option",{value:o,children:ke(o)},o))]}),r.jsx("p",{className:"text-xs text-fg-muted",children:"A message is tagged with the language you write it in, picked from this list. Your browser, not this app, decides which dictionaries it spellchecks against — add the language there too to get its underlines."})]})};function dr({title:e,description:s,action:t}){return r.jsxs("div",{className:"rounded-sm border border-danger/50",children:[r.jsxs("div",{className:"flex items-center gap-2 border-b border-danger/30 bg-danger-soft px-row-inset py-2",children:[r.jsx(dt,{className:"size-4 text-danger"}),r.jsx("h2",{className:"text-sm font-semibold text-danger",children:"Danger zone"})]}),r.jsxs("div",{className:"flex flex-col gap-3 px-row-inset py-3 sm:flex-row sm:items-center sm:justify-between sm:gap-4",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"text-sm font-medium text-fg",children:e}),r.jsx("p",{className:"text-xs text-fg-muted",children:s})]}),r.jsx("div",{className:"shrink-0",children:t})]})]})}function Ft({isOpen:e,onClose:s,title:t,children:i,footer:o}){return C.useEffect(()=>{if(!e)return;const d=n=>{n.key==="Escape"&&s()};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[e,s]),r.jsxs(r.Fragment,{children:[r.jsx("div",{className:Nt("fixed inset-0 z-40 bg-black/30 transition-opacity",e?"opacity-100":"pointer-events-none opacity-0"),onClick:s,"aria-hidden":"true"}),r.jsxs("div",{className:Nt("safe-area-frame fixed top-0 right-0 z-50 flex h-full w-full flex-col border-l border-line bg-canvas shadow-xl sm:w-[400px] sm:max-w-[90vw]","transform transition-transform duration-200 ease-out",e?"translate-x-0":"pointer-events-none translate-x-full"),role:"dialog","aria-modal":"true","aria-hidden":!e,inert:!e,"aria-labelledby":"slide-panel-title",children:[r.jsxs("div",{className:"flex h-14 shrink-0 items-center justify-between border-b border-line px-4",children:[r.jsx("h2",{id:"slide-panel-title",className:"font-semibold",children:t}),r.jsx("button",{type:"button",onClick:s,className:"rounded-md p-1.5 transition-colors hover:bg-surface-raised","aria-label":"Close",children:r.jsx(Ve,{className:"size-5"})})]}),r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[r.jsx("div",{className:"flex-1 overflow-auto p-4",children:i}),o&&r.jsx("div",{className:"flex justify-end gap-3 border-t border-line bg-canvas p-4",children:o})]})]})]})}var Le=e=>e.type==="checkbox",je=e=>e instanceof Date,Y=e=>e==null;const ft=e=>typeof e=="object";var H=e=>!Y(e)&&!Array.isArray(e)&&ft(e)&&!je(e),ur=e=>H(e)&&e.target?Le(e.target)?e.target.checked:e.target.value:e,fr=(e,s)=>s.split(".").some((t,i,o)=>!isNaN(Number(t))&&e.has(o.slice(0,i).join("."))),rs=e=>{const s=e.constructor&&e.constructor.prototype;return H(s)&&s.hasOwnProperty("isPrototypeOf")},Ye=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function B(e){if(e instanceof Date)return new Date(e);const s=typeof FileList<"u"&&e instanceof FileList;if(Ye&&(e instanceof Blob||s))return e;const t=Array.isArray(e);if(!t&&!(H(e)&&rs(e)))return e;const i=t?[]:Object.create(Object.getPrototypeOf(e));for(const o in e)Object.prototype.hasOwnProperty.call(e,o)&&(i[o]=B(e[o]));return i}const _e={BLUR:"blur",FOCUS_OUT:"focusout",SUBMIT:"submit",TRIGGER:"trigger",VALID:"valid"},ue={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},de={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},as="root",mt=["__proto__","constructor","prototype"],mr=/^\w*$/;var Ue=e=>mr.test(e),L=e=>e===void 0;const hr=/[.[\]'"]/;var Ze=e=>e.split(hr).filter(Boolean),y=(e,s,t)=>{if(!s||!H(e))return t;const i=Ue(s)?[s]:Ze(s);if(i.some(d=>mt.includes(d)))return t;const o=i.reduce((d,n)=>Y(d)?void 0:d[n],e);return L(o)||o===e?L(e[s])?t:e[s]:o},me=e=>typeof e=="boolean",ie=e=>typeof e=="function",F=(e,s,t)=>{let i=-1;const o=Ue(s)?[s]:Ze(s),d=o.length,n=d-1;for(;++i<d;){const u=o[i];let j=t;if(i!==n){const E=e[u];j=H(E)||Array.isArray(E)?E:isNaN(+o[i+1])?{}:[]}if(mt.includes(u))return;e[u]=j,e=e[u]}};const pr=J.createContext(null);pr.displayName="HookFormControlContext";var gr=(e,s,t,i=!0)=>{const o={};for(const d in e)Object.defineProperty(o,d,{get:()=>{const n=d;return s._proxyFormState[n]!==ue.all&&(s._proxyFormState[n]=!i||ue.all),e[n]}});return o};const xr=Ye?J.useLayoutEffect:J.useEffect;var Z=e=>typeof e=="string",yr=(e,s,t,i,o)=>Z(e)?(i&&s.watch.add(e),y(t,e,o)):Array.isArray(e)?e.map(d=>(i&&s.watch.add(d),y(t,d))):(i&&(s.watchAll=!0),t),it=e=>Y(e)||!ft(e);const Ot=(e,s)=>s.length===0&&!Array.isArray(e)&&!rs(e);function he(e,s,t=new WeakMap){if(e===s)return!0;if(it(e)||it(s))return Object.is(e,s);if(je(e)&&je(s))return Object.is(e.getTime(),s.getTime());const i=Object.keys(e),o=Object.keys(s);if(i.length!==o.length)return!1;if(Ot(e,i)||Ot(s,o))return Object.is(e,s);if(!i.length&&Array.isArray(e)!==Array.isArray(s))return!1;const d=t.get(e);if(d&&d.has(s))return!0;if(d)d.add(s);else{const n=new WeakSet;n.add(s),t.set(e,n)}for(const n of i){const u=e[n];if(!(n in s))return!1;if(n!=="ref"){const j=s[n];if(je(u)&&je(j)||(H(u)||Array.isArray(u))&&(H(j)||Array.isArray(j))?!he(u,j,t):!Object.is(u,j))return!1}}return!0}var qe=e=>({isOnSubmit:!e||e===ue.onSubmit,isOnBlur:e===ue.onBlur,isOnChange:e===ue.onChange,isOnAll:e===ue.all,isOnTouch:e===ue.onTouched}),tt=(e,s,t)=>{if(t)return!1;if(s.watchAll||s.watch.has(e))return!0;for(const i of s.watch)if(e.startsWith(i)&&e.charAt(i.length)===".")return!0;return!1};const Re=(e,s,t,i)=>{for(const o of t||Object.keys(e)){const d=y(e,o);if(d){const{_f:n,...u}=d;if(n){if(n.refs&&n.refs[0]&&s(n.refs[0],o)&&!i)return!0;if(n.ref&&s(n.ref,n.name)&&!i)return!0;if(Re(u,s))break}else if(H(u)&&Re(u,s))break}}};var It=(e,s,t)=>{const i=y(e,t),o=Array.isArray(i)?i:[];return F(o,as,s[t]),F(e,t,o),e},G=e=>H(e)&&!Object.keys(e).length,ht=e=>e.type==="file",Ke=e=>{if(!Ye)return!1;const s=e?e.ownerDocument:0;return e instanceof(s&&s.defaultView?s.defaultView.HTMLElement:HTMLElement)},pt=e=>e.type==="radio",Ge=e=>e instanceof RegExp,gt=(e,s,t,i,o)=>s?{...t[e],types:{...t[e]&&t[e].types?t[e].types:{},[i]:o||!0}}:{};const Mt={value:!1,isValid:!1},Rt={value:!0,isValid:!0};var is=e=>{if(Array.isArray(e)){if(e.length>1){const s=e.filter(t=>t&&t.checked&&!t.disabled).map(t=>t.value);return{value:s,isValid:!!s.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!L(e[0].attributes.value)?L(e[0].value)||e[0].value===""?Rt:{value:e[0].value,isValid:!0}:Rt:Mt}return Mt};const Lt={isValid:!1,value:null};var ns=e=>Array.isArray(e)?e.reduce((s,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:s,Lt):Lt;function Ut(e,s,t="validate"){if(Z(e)||Array.isArray(e)&&e.every(Z)||me(e)&&!e)return{type:t,message:Z(e)?e:"",ref:s}}var Pe=e=>H(e)&&!Ge(e)?e:{value:e,message:""},zt=async(e,s,t,i,o,d)=>{const{ref:n,refs:u,required:j,maxLength:E,minLength:_,min:z,max:R,pattern:O,validate:T,name:f,valueAsNumber:b,mount:ae}=e._f,N=y(t,f);if(!ae||s.has(f))return{};const W=u?u[0]:n,I=P=>{if(o&&W.reportValidity){const k=me(P)?"":P||"";u?u.forEach(D=>D.setCustomValidity(k)):W.setCustomValidity(k),W.reportValidity()}},A={},ne=pt(n),re=Le(n),pe=ne||re,oe=(b||ht(n))&&L(n.value)&&L(N)||Ke(n)&&n.value===""||N===""||Array.isArray(N)&&!N.length,K=gt.bind(null,f,i,A),te=(P,k,D,$=de.maxLength,w=de.minLength)=>{const M=P?k:D;A[f]={type:P?$:w,message:M,ref:n,...K(P?$:w,M)}};if(d?!Array.isArray(N)||!N.length:j&&(!pe&&(oe||Y(N))||me(N)&&!N||re&&!is(u).isValid||ne&&!ns(u).isValid)){const{value:P,message:k}=Z(j)?{value:!!j,message:j}:Pe(j);if(P&&(A[f]={type:de.required,message:k,ref:W,...K(de.required,k)},!i))return I(k),A}if(!oe&&(!Y(z)||!Y(R))){let P,k;const D=Pe(R),$=Pe(z);if(!Y(N)&&!isNaN(N)){const w=n.valueAsNumber||N&&+N;Y(D.value)||(P=w>D.value),Y($.value)||(k=w<$.value)}else{const w=n.valueAsDate||new Date(N),M=ge=>new Date(new Date().toDateString()+" "+ge),le=n.type=="time",Q=n.type=="week";Z(D.value)&&N&&(P=le?M(N)>M(D.value):Q?N>D.value:w>new Date(D.value)),Z($.value)&&N&&(k=le?M(N)<M($.value):Q?N<$.value:w<new Date($.value))}if((P||k)&&(te(!!P,D.message,$.message,de.max,de.min),!i))return I(A[f].message),A}if((E||_)&&!oe&&(Z(N)||d&&Array.isArray(N))){const P=Pe(E),k=Pe(_),D=!Y(P.value)&&N.length>+P.value,$=!Y(k.value)&&N.length<+k.value;if((D||$)&&(te(D,P.message,k.message),!i))return I(A[f].message),A}if(O&&!oe&&Z(N)){const{value:P,message:k}=Pe(O);if(Ge(P)&&!N.match(P)&&(A[f]={type:de.pattern,message:k,ref:n,...K(de.pattern,k)},!i))return I(k),A}if(T){if(ie(T)){const P=await T(N,t),k=Ut(P,W);if(k&&(A[f]={...k,...K(de.validate,k.message)},!i))return I(k.message),A}else if(H(T)){let P={};for(const k in T){if(!G(P)&&!i)break;const D=Ut(await T[k](N,t),W,k);D&&(P={...D,...K(k,D.message)},I(D.message),i&&(A[f]=P))}if(!G(P)&&(A[f]={ref:W,...P},!i))return A}}return I(!0),A},We=e=>Array.isArray(e)?e:[e],os=e=>Array.isArray(e)?e.filter(Boolean):[];function vr(e,s){const t=s.slice(0,-1).length;let i=0;for(;i<t;){if(Y(e)){e=void 0;break}e=e[s[i]],i++}return e}function br(e){for(const s in e)if(e.hasOwnProperty(s)&&!L(e[s]))return!1;return!0}function q(e,s){if(Z(s)&&Object.prototype.hasOwnProperty.call(e,s))return delete e[s],e;const t=Array.isArray(s)?s:Ue(s)?[s]:Ze(s);if(t.some(n=>mt.includes(String(n))))return e;const i=t.length===1?e:vr(e,t),o=t.length-1,d=t[o];return i&&delete i[d],o!==0&&(H(i)&&G(i)||Array.isArray(i)&&br(i))&&q(e,t.slice(0,-1)),e}const ls=e=>{const s={};for(const t of Object.keys(e))if(ft(e[t])&&e[t]!==null&&!je(e[t])){const i=ls(e[t]);for(const o of Object.keys(i))s[`${t}.${o}`]=i[o]}else s[t]=e[t];return s},jr=J.createContext(null);jr.displayName="HookFormContext";var Ht=()=>{let e=[];return{get observers(){return e},next:o=>{for(const d of e)d.next&&d.next(o)},subscribe:o=>(e.push(o),{unsubscribe:()=>{e=e.filter(d=>d!==o)}}),unsubscribe:()=>{e=[]}}};function cs(e,s){const t={};for(const i in e)if(e.hasOwnProperty(i)){const o=e[i],d=s[i];if(o&&H(o)&&d){const n=cs(o,d);H(n)&&(t[i]=n)}else e[i]&&(t[i]=d)}return t}var ds=e=>e.type==="select-multiple",Sr=e=>pt(e)||Le(e),st=e=>Ke(e)&&e.isConnected,wr=e=>{for(const s in e)if(ie(e[s]))return!0;return!1};function us(e){return Array.isArray(e)||H(e)&&!wr(e)}function fs(e){return!!(e&&"_f"in e)}function ms(e){return Array.isArray(e)?!e.some(s=>!L(s)):!Object.keys(e).length}function nt(e,s){Array.isArray(e)?e[s]=void 0:delete e[s]}function ot(e,s={},t){for(const i in e){const o=e[i],d=t&&t[i];us(o)&&(!Array.isArray(o)||!fs(d))?(s[i]=Array.isArray(o)?[]:{},ot(o,s[i],d),ms(s[i])&&nt(s,i)):L(o)||(s[i]=!0)}return s}function Ne(e,s,t,i){t||(t=ot(s,{},i));for(const o in e){const d=e[o],n=i&&i[o];us(d)&&(!Array.isArray(d)||!fs(n))?(L(s)||it(t[o])?t[o]=ot(d,Array.isArray(d)?[]:{},n):Ne(d,Y(s)?{}:s[o],t[o],n),ms(t[o])&&nt(t,o)):he(d,s[o])?nt(t,o):t[o]=!0}return t}var hs=(e,{valueAsNumber:s,valueAsDate:t,setValueAs:i})=>L(e)?e:s?e===""?NaN:e&&+e:t&&Z(e)?new Date(e):i?i(e):e;function Bt(e){const s=e.ref;return ht(s)?s.files:pt(s)?ns(e.refs).value:ds(s)?[...s.selectedOptions].map(({value:t})=>t):Le(s)?is(e.refs).value:hs(L(s.value)?e.ref.value:s.value,e)}var Nr=(e,s,t,i)=>{const o={};for(const d of e){const n=y(s,d);n&&F(o,d,n._f)}return{criteriaMode:t,names:[...e],fields:o,shouldUseNativeValidation:i}},Me=e=>L(e)?e:Ge(e)?e.source:H(e)?Ge(e.value)?e.value.source:e.value:e;const qt="AsyncFunction";var Ar=e=>{if(!e||!e.validate)return!1;if(ie(e.validate))return e.validate.constructor.name===qt;if(H(e.validate)){for(const s in e.validate)if(e.validate[s].constructor.name===qt)return!0}return!1},Tr=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function $t(e,s,t){const i=y(e,t);if(i||Ue(t))return{error:i,name:t};const o=t.split(".");for(;o.length;){const d=o.join("."),n=y(s,d),u=y(e,d);if(n&&!Array.isArray(n)&&t!==d)return{name:t};if(u&&u.type)return{name:d,error:u};if(u&&u.root&&u.root.type)return{name:`${d}.root`,error:u.root};o.pop()}return{name:t}}var Er=(e,s,t,i)=>{t(e);const{name:o,...d}=e,n=Object.keys(d);return!n.length||i&&n.length>=Object.keys(s).length||n.find(u=>s[u]===(!i||ue.all))},_r=(e,s,t)=>!e||!s||e===s||We(e).some(i=>i&&(t?i===s||i.startsWith(s+"."):i.startsWith(s)||s.startsWith(i))),Pr=(e,s,t,i,o)=>o.isOnAll?!1:!t&&o.isOnTouch?!(s||e):(t?i.isOnBlur:o.isOnBlur)?!e:(t?i.isOnChange:o.isOnChange)?e:!0,kr=(e,s)=>!os(y(e,s)).length&&q(e,s);const Vr={mode:ue.onSubmit,reValidateMode:ue.onChange,shouldFocusError:!0},rt="form",ps={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function Dr(e={}){let s={...Vr,...e},t={...B(ps),isLoading:ie(s.defaultValues),errors:s.errors||{},disabled:s.disabled||!1},i={},o=H(s.defaultValues)||H(s.values)?B(s.defaultValues||s.values)||{}:{},d=s.shouldUnregister?{}:B(o),n={action:!1,mount:!1,watch:!1,keepIsValid:!1},u={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set,registerName:new Set};const j={},E={};let _=0,z=qe(s.mode),R=qe(s.reValidateMode);const O={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},T={...O};let f={...T};const b={array:Ht(),state:Ht()};let ae=0;const N=s.criteriaMode===ue.all,W=(a,l)=>c=>{clearTimeout(E[a]),E[a]=setTimeout(l,c)},I=async a=>{if(!n.keepIsValid&&!s.disabled&&(T.isValid||f.isValid||a)){const l=++ae;let c;s.resolver?(c=G((await D()).errors),l===ae&&A()):c=await M({fields:i,onlyCheckValid:!0,eventType:_e.VALID}),l===ae&&c!==t.isValid&&b.state.next({isValid:c})}},A=(a,l)=>{!s.disabled&&(T.isValidating||T.validatingFields||f.isValidating||f.validatingFields)&&((a||Array.from(u.mount)).forEach(c=>{c&&(l?F(t.validatingFields,c,l):q(t.validatingFields,c))}),b.state.next({validatingFields:t.validatingFields,isValidating:!G(t.validatingFields)}))},ne=()=>{t.dirtyFields=Ne(o,d,void 0,i)},re=(a,l=[],c,m,h=!0,x=!0)=>{if(m&&c&&!s.disabled){if(n.action=!0,x&&Array.isArray(y(i,a))){const g=c(y(i,a),m.argA,m.argB);h&&F(i,a,g)}if(x&&Array.isArray(y(t.errors,a))){const g=c(y(t.errors,a),m.argA,m.argB);h&&F(t.errors,a,g),kr(t.errors,a)}if((T.touchedFields||f.touchedFields)&&x&&Array.isArray(y(t.touchedFields,a))){const g=c(y(t.touchedFields,a),m.argA,m.argB);h&&F(t.touchedFields,a,g)}(T.dirtyFields||f.dirtyFields)&&ne(),b.state.next({name:a,isDirty:Q(a,l),dirtyFields:t.dirtyFields,errors:t.errors,isValid:t.isValid})}else F(d,a,l)},pe=(a,l)=>{F(t.errors,a,l),t.errors={...t.errors},b.state.next({errors:t.errors})},oe=a=>{t.errors=a,b.state.next({errors:t.errors,isValid:!1})},K=a=>{const l=Ue(a)?[a]:Ze(a);let c=d,m=o;for(let h=0;h<l.length-1;h++){const x=l[h];if(c=Y(c)?c:c[x],m=Y(m)?m:m[x],c===null&&m!==null)return!0}return!1},te=(a,l,c,m)=>{const h=y(i,a);if(h){if(K(a))return;const x=L(y(d,a)),g=y(d,a,L(c)?y(o,a):c);L(g)||m&&m.defaultChecked||l?F(d,a,l?g:Bt(h._f)):De(a,g),n.mount&&!n.action&&(I(),x&&t.isDirty&&(T.isDirty||f.isDirty)&&(Q()||(t.isDirty=!1,b.state.next({...t}))),e.shouldUnregister&&x&&!L(y(d,a))&&tt(a,u)&&(n.watch=!0))}},P=(a,l,c,m,h)=>{let x=!1,g=!1;const v={name:a};if(!s.disabled||m===!0){if(!c||m){const S=he(y(o,a),l);(T.isDirty||f.isDirty)&&(g=t.isDirty,t.isDirty=v.isDirty=!S||Q(),x=g!==v.isDirty),g=!!y(t.dirtyFields,a),S!==t.isDirty?t.dirtyFields=Ne(o,d,void 0,i):S?q(t.dirtyFields,a):F(t.dirtyFields,a,!0),v.dirtyFields=t.dirtyFields,x=x||(T.dirtyFields||f.dirtyFields)&&g!==!S}if(c){const S=y(t.touchedFields,a);S||(F(t.touchedFields,a,c),v.touchedFields=t.touchedFields,x=x||(T.touchedFields||f.touchedFields)&&S!==c)}x&&h&&b.state.next(v)}return x?v:{}},k=(a,l,c,m)=>{const h=y(t.errors,a),x=(T.isValid||f.isValid)&&me(l)&&t.isValid!==l;if(s.delayError&&c?(j[a]=W(a,()=>pe(a,c)),j[a](s.delayError)):(clearTimeout(E[a]),delete j[a],c?F(t.errors,a,c):q(t.errors,a),t.errors={...t.errors}),(c?!he(h,c):h)||!G(m)||x){const g={...m,...x&&me(l)?{isValid:l}:{},errors:t.errors,name:a};t={...t,...g},b.state.next(g)}},D=async a=>(A(a,!0),await s.resolver(d,s.context,Nr(a||u.mount,i,s.criteriaMode,s.shouldUseNativeValidation))),$=async a=>{const{errors:l}=await D(a);if(A(a),a){for(const c of a){const m=y(l,c);m?u.array.has(c)&&H(m)&&!Object.keys(m).some(h=>!Number.isNaN(Number(h)))?It(t.errors,{[c]:m},c):F(t.errors,c,m):q(t.errors,c)}t.errors={...t.errors}}else t.errors=l;return l},w=async({name:a,eventType:l})=>{if(e.validate){const c=await e.validate({formValues:d,formState:t,name:a,eventType:l});if(H(c))for(const m in c){const h=c[m];h&&He(`${rt}.${m}`,{message:Z(h.message)?h.message:"",type:h.type||de.validate})}else Z(c)||!c?He(rt,{message:c||"",type:de.validate}):Ee(rt);return c}return!0},M=async({fields:a,onlyCheckValid:l,name:c,eventType:m,context:h={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(h.runRootValidation=!0,!await w({name:c,eventType:m})&&(h.valid=!1,l)))return h.valid;for(const x in a){const g=a[x];if(g){const{_f:v,...S}=g;if(v){const U=u.array.has(v.name),X=g._f&&Ar(g._f),xe=T.validatingFields||T.isValidating||f.validatingFields||f.isValidating;X&&xe&&A([v.name],!0);const ye=await zt(g,u.disabled,d,N,s.shouldUseNativeValidation&&!l,U);if(X&&xe&&A([v.name]),ye[v.name]&&(h.valid=!1,l)||(!l&&(y(ye,v.name)?U?It(t.errors,ye,v.name):F(t.errors,v.name,ye[v.name]):q(t.errors,v.name)),e.shouldUseNativeValidation&&ye[v.name]))break}!G(S)&&await M({context:h,onlyCheckValid:l,fields:S,name:x,eventType:m})}}return h.valid},le=()=>{for(const a of u.unMount){const l=y(i,a);l&&(l._f.refs?l._f.refs.every(c=>!st(c)):!st(l._f.ref))&&Xe(a)}u.unMount=new Set},Q=(a,l)=>(a&&l&&F(d,a,l),!he(n.mount?d:o,o)),ge=(a,l,c)=>yr(a,u,{...n.mount?d:L(l)?o:Z(a)?{[a]:l}:l},c,l),Te=a=>os(y(n.mount?d:o,a,s.shouldUnregister?y(o,a,[]):[])),De=(a,l,c={},m=!1,h=!1)=>{const x=y(i,a);let g=l;if(x){const v=x._f;v&&(!v.disabled&&F(d,a,hs(l,v)),g=Ke(v.ref)&&Y(l)?"":l,ds(v.ref)?[...v.ref.options].forEach(S=>S.selected=g.includes(S.value)):v.refs?Le(v.ref)?v.refs.forEach(S=>{(!S.defaultChecked||!S.disabled)&&(Array.isArray(g)?S.checked=!!g.find(U=>U===S.value):S.checked=g===S.value||!!g)}):v.refs.forEach(S=>S.checked=S.value===g):ht(v.ref)?v.ref.value="":(v.ref.value=g,!v.ref.type&&!h&&b.state.next({name:a,values:m?d:B(d)})))}(c.shouldDirty||c.shouldTouch)&&P(a,g,c.shouldTouch,c.shouldDirty,!h),c.shouldValidate&&fe(a,{delayError:c.delayError})},ze=(a,l,c,m=!1,h=!1)=>{for(const x in l){if(!l.hasOwnProperty(x))return;const g=l[x],v=a+"."+x,S=y(i,v);(u.array.has(a)||H(g)||S&&!S._f)&&!je(g)?ze(v,g,c,m,h):De(v,g,c,m,h)}},Qe=(a,l,c,m,h=!1)=>{const x=y(i,a),g=u.array.has(a),v=m?l:B(l),S=y(d,a),U=he(S,v);if(U||F(d,a,v),g)b.array.next({name:a,values:m?d:B(d)}),(T.isDirty||T.dirtyFields||f.isDirty||f.dirtyFields)&&c.shouldDirty&&(ne(),h||b.state.next({name:a,dirtyFields:t.dirtyFields,isDirty:Q(a,v)}));else{const X=Array.isArray(v)&&!v.length||G(v);!x||x._f||Y(v)||X?De(a,v,c,m,h):ze(a,v,c,m,h)}if(!U&&!h){const X=tt(a,u),xe=m?d:B(d);b.state.next({...X&&t,name:n.mount||X?a:void 0,values:xe})}},p=(a,l,c={})=>Qe(a,l,c,!1),V=(a,l={})=>{const c=ie(a)?a(d):a;if(!he(d,c)){d={...d,...c};const m=ls(c);for(const h of u.mount)h in m&&Qe(h,m[h],l,!0,!0);b.state.next({...t,name:void 0,type:void 0,..._?{values:d}:{}}),l.shouldValidate&&I()}},ce=async a=>{n.mount=!0;const l=a.target;let c=l.name,m=!0;const h=y(i,c),x=g=>{m=Number.isNaN(g)||je(g)&&isNaN(g.getTime())||he(g,y(d,c,g))};if(h){let g,v;const S=l.type?Bt(h._f):ur(a),U=a.type===_e.BLUR||a.type===_e.FOCUS_OUT,X=!Tr(h._f)&&!e.validate&&!s.resolver&&!y(t.errors,c)&&!h._f.deps,xe=X||Pr(U,y(t.touchedFields,c),t.isSubmitted,R,z),ye=tt(c,u,U);if(F(d,c,S),U){if(!l||!l.readOnly){h._f.onBlur&&h._f.onBlur(a);const Oe=j[c];Oe&&Oe(0)}}else h._f.onChange&&h._f.onChange(a);const Fe=P(c,S,U),_s=!G(Fe)||ye;if(!U&&b.state.next({name:c,type:a.type,..._?{values:B(d)}:{}}),xe)return(!X||!t.isValid)&&(T.isValid||f.isValid)&&(s.mode==="onBlur"?U&&I():U||I()),_s&&b.state.next({name:c,...ye?{}:Fe});if(!s.resolver&&e.validate&&await w({name:c,eventType:a.type}),!U&&ye&&b.state.next({...t}),s.resolver){const{errors:Oe}=await D([c]);if(A([c]),x(S),!m){!G(Fe)&&b.state.next(Fe);return}const Ps=$t(t.errors,i,c),wt=$t(Oe,i,Ps.name||c);g=wt.error,c=wt.name,v=G(Oe)}else A([c],!0),g=(await zt(h,u.disabled,d,N,s.shouldUseNativeValidation))[c],A([c]),x(S),m&&(g?v=!1:(T.isValid||f.isValid)&&(v=await M({fields:i,onlyCheckValid:!0,name:c,eventType:a.type})));m&&(h._f.deps&&(!Array.isArray(h._f.deps)||h._f.deps.length>0)&&fe(h._f.deps),k(c,v,g,Fe))}},se=(a,l)=>{if(y(t.errors,l)&&a.focus)return a.focus(),1},fe=async(a,l={})=>{let c,m;const h=We(a);if(s.resolver){const x=await $(L(a)?a:h);c=G(x),m=a?!h.some(g=>y(x,g)):c}else a?(m=(await Promise.all(h.map(async x=>{const g=y(i,x);return await M({fields:g&&g._f?{[x]:g}:g,eventType:_e.TRIGGER})}))).every(Boolean),!(!m&&!t.isValid)&&I()):m=c=await M({fields:i,name:a,eventType:_e.TRIGGER});if(l.delayError&&s.delayError&&Z(a)){const x=y(t.errors,a);x?(q(t.errors,a),j[a]=W(a,()=>pe(a,x)),j[a](s.delayError)):(clearTimeout(E[a]),delete j[a])}return b.state.next({...!Z(a)||(T.isValid||f.isValid)&&c!==t.isValid?{}:{name:a},...s.resolver||!a?{isValid:c}:{},errors:t.errors}),l.shouldFocus&&!m&&Re(i,se,a?h:u.mount),m},we=(a,l)=>{let c={...n.mount?d:o};return l&&(c=cs(l.dirtyFields?t.dirtyFields:t.touchedFields,c)),L(a)?c:Z(a)?y(c,a):a.map(m=>y(c,m))},Ce=(a,l)=>({invalid:!!y((l||t).errors,a),isDirty:!!y((l||t).dirtyFields,a),error:y((l||t).errors,a),isValidating:!!y(t.validatingFields,a),isTouched:!!y((l||t).touchedFields,a)}),Ee=a=>{const l=a?We(a):void 0;l?.forEach(c=>q(t.errors,c)),l?l.forEach(c=>{b.state.next({name:c,errors:t.errors})}):b.state.next({errors:{}})},He=(a,l,c)=>{const m=(y(i,a,{_f:{}})._f||{}).ref,h=y(t.errors,a)||{},{ref:x,message:g,type:v,...S}=h;F(t.errors,a,{...S,...l,ref:m}),b.state.next({name:a,errors:t.errors,isValid:!1}),c&&c.shouldFocus&&m&&m.focus&&m.focus()},Ss=(a,l)=>{if(ie(a)){_++;const{unsubscribe:c}=b.state.subscribe({next:h=>"values"in h&&a(h.values||ge(void 0,l),h)});let m=!1;return{unsubscribe:()=>{m||(m=!0,_--,c())}}}return ge(a,l,!0)},xt=a=>{var l;const c=!!(!((l=a.formState)===null||l===void 0)&&l.values);c&&_++;const{unsubscribe:m}=b.state.subscribe({next:x=>{if(_r(a.name,x.name,a.exact)&&Er(x,a.formState||T,Es,a.reRenderRoot)){const g={...d};a.callback({values:g,...t,...x,defaultValues:o})}}});if(!c)return m;let h=!1;return()=>{h||(h=!0,_--,m())}},ws=a=>(n.mount=!0,f={...f,...a.formState},xt({...a,formState:{...O,...a.formState}})),Xe=(a,l={})=>{for(const c of a?We(a):u.mount)u.mount.delete(c),u.array.delete(c),l.keepValue||(q(i,c),q(d,c)),!l.keepError&&q(t.errors,c),!l.keepDirty&&q(t.dirtyFields,c),!l.keepTouched&&q(t.touchedFields,c),!l.keepIsValidating&&q(t.validatingFields,c),!s.shouldUnregister&&!l.keepDefaultValue&&q(o,c);b.state.next({values:B(d)}),b.state.next({...t,...l.keepDirty?{isDirty:Q()}:{}}),!l.keepIsValid&&I()},yt=({disabled:a,name:l})=>{if(me(a)&&n.mount||a||u.disabled.has(l)){const h=u.disabled.has(l)!==!!a;a?u.disabled.add(l):u.disabled.delete(l),h&&n.mount&&!n.action&&I()}},Je=(a,l={})=>{let c=y(i,a);const m=me(l.disabled)||me(s.disabled),h=!u.registerName.has(a)&&c&&c._f&&!c._f.mount;return F(i,a,{...c||{},_f:{...c&&c._f?c._f:{ref:{name:a}},name:a,mount:!0,...l}}),u.mount.add(a),c&&!h?yt({disabled:me(l.disabled)?l.disabled:s.disabled,name:a}):te(a,!0,l.value),{...m?{disabled:l.disabled||s.disabled}:{},...s.progressive?{required:!!l.required,min:Me(l.min),max:Me(l.max),minLength:Me(l.minLength),maxLength:Me(l.maxLength),pattern:Me(l.pattern)}:{},name:a,onChange:ce,onBlur:ce,ref:x=>{if(x){u.registerName.add(a),Je(a,l),u.registerName.delete(a),c=y(i,a);const g=L(x.value)&&x.querySelectorAll&&x.querySelectorAll("input,select,textarea")[0]||x,v=Sr(g),S=c._f.refs||[];if(v?S.find(U=>U===g):g===c._f.ref)return;F(i,a,{_f:{...c._f,...v?{refs:[...S.filter(st),g,...Array.isArray(y(o,a))?[{}]:[]],ref:{type:g.type,name:a}}:{ref:g}}}),te(a,!1,void 0,g)}else c=y(i,a,{}),c._f&&(c._f.mount=!1),(s.shouldUnregister||l.shouldUnregister)&&!(fr(u.array,a)&&n.action)&&u.unMount.add(a)}}},et=()=>s.shouldFocusError&&!s.shouldUseNativeValidation&&Re(i,se,u.mount),Ns=a=>{me(a)&&(b.state.next({disabled:a}),Re(i,(l,c)=>{const m=y(i,c);m&&(l.disabled=m._f.disabled||a,Array.isArray(m._f.refs)&&m._f.refs.forEach(h=>{h.disabled=m._f.disabled||a}))},0,!1))},vt=(a,l)=>async c=>{let m;c&&(c.preventDefault&&c.preventDefault(),c.persist&&c.persist());let h=B(d);if(b.state.next({isSubmitting:!0}),s.resolver){const{errors:x,values:g}=await D();A(),t.errors=x,h=B(g)}else await M({fields:i,eventType:_e.SUBMIT});if(u.disabled.size)for(const x of u.disabled)q(h,x);if(q(t.errors,as),G(t.errors)){b.state.next({errors:{}});try{await a(h,c)}catch(x){m=x}}else l&&await l({...t.errors},c),et(),setTimeout(et);if(b.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:G(t.errors)&&!m,submitCount:t.submitCount+1,errors:t.errors}),m)throw m},As=(a,l={})=>{y(i,a)&&(L(l.defaultValue)?p(a,B(y(o,a))):(p(a,l.defaultValue),F(o,a,B(l.defaultValue))),l.keepTouched||q(t.touchedFields,a),l.keepDirty||(q(t.dirtyFields,a),t.isDirty=l.defaultValue?Q(a,B(y(o,a))):Q()),l.keepError||(q(t.errors,a),T.isValid&&I()),b.state.next({...t}))},bt=(a,l={})=>{const c=a?B(a):o,m=B(c),h=G(a),x=m,g=i;if(l.keepDefaultValues||(o=c),!l.keepValues){if(l.keepDirtyValues){const v=new Set([...u.mount,...Object.keys(Ne(o,d,void 0,g))]);for(const S of Array.from(v)){const U=y(t.dirtyFields,S),X=y(d,S),xe=y(x,S);U&&!L(X)?F(x,S,X):!U&&!L(xe)&&p(S,xe)}}else{if(Ye&&L(a))for(const v of u.mount){const S=y(i,v);if(S&&S._f){const U=Array.isArray(S._f.refs)?S._f.refs[0]:S._f.ref;if(Ke(U)){const X=U.closest("form");if(X){X.reset();break}}}}if(l.keepFieldsRef)for(const v of u.mount)p(v,y(x,v));else i={}}if(s.shouldUnregister){if(d=l.keepDefaultValues?B(o):{},l.keepFieldsRef)for(const v of u.mount)F(d,v,y(x,v))}else d=B(x);b.array.next({values:{...x}}),b.state.next({name:void 0,type:void 0,values:{...x}})}u={mount:l.keepDirtyValues?u.mount:new Set,unMount:new Set,array:new Set,registerName:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},n.mount=!T.isValid||!!l.keepIsValid||!!l.keepDirtyValues||!s.shouldUnregister&&!G(x),n.watch=!!s.shouldUnregister,n.keepIsValid=!!l.keepIsValid,n.action=!1,l.keepErrors||(t.errors={}),b.state.next({submitCount:l.keepSubmitCount?t.submitCount:0,isDirty:h?!1:l.keepDirty?t.isDirty:l.keepValues?Q():!!(l.keepDefaultValues&&!he(a,o)),isSubmitted:l.keepIsSubmitted?t.isSubmitted:!1,dirtyFields:h?{}:l.keepDirtyValues?l.keepDefaultValues&&d?Ne(o,d,void 0,g):t.dirtyFields:l.keepDefaultValues&&a?Ne(o,a,void 0,g):l.keepDirty?t.dirtyFields:{},touchedFields:l.keepTouched?t.touchedFields:{},errors:l.keepErrors?t.errors:{},isSubmitSuccessful:l.keepIsSubmitSuccessful?t.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:o})},jt=(a,l)=>bt(ie(a)?a(d):a,{...s.resetOptions,...l}),Ts=(a,l={})=>{const c=y(i,a),m=c&&c._f;if(m){const h=m.refs?m.refs[0]:m.ref;h.focus&&setTimeout(()=>{h.focus(),l.shouldSelect&&ie(h.select)&&h.select()})}},Es=a=>{const{name:l,type:c,values:m,...h}=a;t={...t,...h}},St={control:{register:Je,unregister:Xe,getFieldState:Ce,handleSubmit:vt,setError:He,_subscribe:xt,_runSchema:D,_updateIsValidating:A,_focusError:et,_getWatch:ge,_getDirty:Q,_setValid:I,_setFieldArray:re,_setDisabledField:yt,_setErrors:oe,_getFieldArray:Te,_reset:bt,_resetDefaultValues:()=>ie(s.defaultValues)&&s.defaultValues().then(a=>{jt(a,s.resetOptions),b.state.next({isLoading:!1})}),_removeUnmounted:le,_disableForm:Ns,_subjects:b,_proxyFormState:T,get _fields(){return i},get _formValues(){return d},get _state(){return n},set _state(a){n=a},get _defaultValues(){return o},get _names(){return u},set _names(a){u=a},get _formState(){return t},get _options(){return s},set _options(a){s={...s,...a},z=qe(s.mode),R=qe(s.reValidateMode)}},subscribe:ws,trigger:fe,register:Je,handleSubmit:vt,watch:Ss,setValue:p,setValues:V,getValues:we,reset:jt,resetField:As,resetDefaultValues:(a,l={})=>{if(o=B(a),!l.keepDirty){const c=Ne(o,d,void 0,i);t.dirtyFields=c,t.isDirty=!G(c)}l.keepIsValid||I(),b.state.next({...t,defaultValues:o})},clearErrors:Ee,unregister:Xe,setError:He,setFocus:Ts,getFieldState:Ce};return{...St,formControl:St}}function Cr(e={}){const s=J.useRef(void 0),t=J.useRef(void 0),i=J.useRef(e.formControl),[o,d]=J.useState(()=>({...B(ps),isLoading:ie(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1,defaultValues:ie(e.defaultValues)?void 0:e.defaultValues}));if(!s.current||e.formControl&&i.current!==e.formControl)if(i.current=e.formControl,e.formControl)s.current={...e.formControl,formState:o},e.defaultValues&&!ie(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:u,...j}=Dr(e);s.current={...j,formState:o}}const n=s.current.control;return n._options=e,xr(()=>{const u=n._subscribe({formState:n._proxyFormState,callback:()=>d({...n._formState,defaultValues:n._defaultValues}),reRenderRoot:!0});return d(j=>({...j,isReady:!0})),n._formState.isReady=!0,u},[n]),J.useEffect(()=>n._disableForm(e.disabled),[n,e.disabled]),J.useEffect(()=>{e.mode&&(n._options.mode=e.mode),e.reValidateMode&&(n._options.reValidateMode=e.reValidateMode)},[n,e.mode,e.reValidateMode]),J.useEffect(()=>{e.errors&&(n._setErrors(e.errors),n._focusError())},[n,e.errors]),J.useEffect(()=>{e.shouldUnregister&&n._subjects.state.next({values:n._getWatch()})},[n,e.shouldUnregister]),J.useEffect(()=>{if(n._proxyFormState.isDirty){const u=n._getDirty();u!==o.isDirty&&n._subjects.state.next({isDirty:u})}},[n,o.isDirty]),J.useEffect(()=>{var u;e.values&&!he(e.values,t.current)?(n._reset(e.values,{keepFieldsRef:!0,...n._options.resetOptions}),!((u=n._options.resetOptions)===null||u===void 0)&&u.keepIsValid||n._setValid(),t.current=e.values,d(j=>({...j}))):n._resetDefaultValues()},[n,e.values]),J.useEffect(()=>{n._state.mount||(n._setValid(),n._state.mount=!0),n._state.watch&&(n._state.watch=!1,n._subjects.state.next({...n._formState})),n._removeUnmounted()}),s.current.formState=J.useMemo(()=>gr(o,n),[n,o]),s.current}const Wt=(e,s,t)=>{if(e&&"reportValidity"in e){const i=y(t,s);e.setCustomValidity(i&&i.message||""),e.reportValidity()}},lt=(e,s)=>{for(const t in s.fields){const i=s.fields[t];i&&i.ref&&"reportValidity"in i.ref?Wt(i.ref,t,e):i&&i.refs&&i.refs.forEach(o=>Wt(o,t,e))}},Kt=(e,s)=>{s.shouldUseNativeValidation&<(e,s);const t={};for(const i in e){const o=y(s.fields,i),d=Object.assign(e[i]||{},{ref:o&&o.ref});if(Fr(s.names||Object.keys(e),i)){const n=Object.assign({},y(t,i));F(n,"root",d),F(t,i,n)}else F(t,i,d)}return t},Fr=(e,s)=>{const t=Gt(s).replace(/[.*+?^${}()|\\]/g,"\\$&");return e.some(i=>Gt(i).match(`^${t}\\.\\d+`))};function Gt(e){return e.replace(/[\[\]]/g,"")}function gs(e,s,t){function i(u,j){var E;Object.defineProperty(u,"_zod",{value:u._zod??{},enumerable:!1}),(E=u._zod).traits??(E.traits=new Set),u._zod.traits.add(e),s(u,j);for(const _ in n.prototype)_ in u||Object.defineProperty(u,_,{value:n.prototype[_].bind(u)});u._zod.constr=n,u._zod.def=j}const o=t?.Parent??Object;class d extends o{}Object.defineProperty(d,"name",{value:e});function n(u){var j;const E=t?.Parent?new d:this;i(E,u),(j=E._zod).deferred??(j.deferred=[]);for(const _ of E._zod.deferred)_();return E}return Object.defineProperty(n,"init",{value:i}),Object.defineProperty(n,Symbol.hasInstance,{value:u=>t?.Parent&&u instanceof t.Parent?!0:u?._zod?.traits?.has(e)}),Object.defineProperty(n,"name",{value:e}),n}class Or extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const Ir={};function xs(e){return Ir}function Mr(e,s){return typeof s=="bigint"?s.toString():s}const ys=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function $e(e){return typeof e=="string"?e:e?.message}function vs(e,s,t){const i={...e,path:e.path??[]};if(!e.message){const o=$e(e.inst?._zod.def?.error?.(e))??$e(s?.error?.(e))??$e(t.customError?.(e))??$e(t.localeError?.(e))??"Invalid input";i.message=o}return delete i.inst,delete i.continue,s?.reportInput||delete i.input,i}const bs=(e,s)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:s,enumerable:!1}),Object.defineProperty(e,"message",{get(){return JSON.stringify(s,Mr,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Rr=gs("$ZodError",bs),js=gs("$ZodError",bs,{Parent:Error}),Lr=e=>(s,t,i,o)=>{const d=i?Object.assign(i,{async:!1}):{async:!1},n=s._zod.run({value:t,issues:[]},d);if(n instanceof Promise)throw new Or;if(n.issues.length){const u=new(o?.Err??e)(n.issues.map(j=>vs(j,d,xs())));throw ys(u,o?.callee),u}return n.value},Ur=Lr(js),zr=e=>async(s,t,i,o)=>{const d=i?Object.assign(i,{async:!0}):{async:!0};let n=s._zod.run({value:t,issues:[]},d);if(n instanceof Promise&&(n=await n),n.issues.length){const u=new(o?.Err??e)(n.issues.map(j=>vs(j,d,xs())));throw ys(u,o?.callee),u}return n.value},Hr=zr(js);function ct(){return ct=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var t=arguments[s];for(var i in t)({}).hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},ct.apply(null,arguments)}function Yt(e,s){try{var t=e()}catch(i){return s(i)}return t&&t.then?t.then(void 0,s):t}function Br(e,s){for(var t={};e.length;){var i=e[0],o=i.code,d=i.message,n=i.path.join(".");if(!t[n])if("unionErrors"in i){var u=i.unionErrors[0].errors[0];t[n]={message:u.message,type:u.code}}else t[n]={message:d,type:o};if("unionErrors"in i&&i.unionErrors.forEach(function(_){return _.errors.forEach(function(z){return e.push(z)})}),s){var j=t[n].types,E=j&&j[i.code];t[n]=gt(n,s,t,o,E?[].concat(E,i.message):i.message)}e.shift()}return t}function qr(e,s){for(var t={},i=function(){var o=e[0],d=o.code,n=o.message,u=o.path.join(".");if(!t[u])if(o.code==="invalid_union"&&o.errors.length>0){var j=o.errors[0][0];t[u]={message:j.message,type:j.code}}else t[u]={message:n,type:d};if(o.code==="invalid_union"&&o.errors.forEach(function(z){return z.forEach(function(R){return e.push(ct({},R,{path:[].concat(o.path,R.path)}))})}),s){var E=t[u].types,_=E&&E[o.code];t[u]=gt(u,s,t,d,_?[].concat(_,o.message):o.message)}e.shift()};e.length;)i();return t}function $r(e,s,t){if(t===void 0&&(t={}),(function(i){return"_def"in i&&typeof i._def=="object"&&"typeName"in i._def})(e))return function(i,o,d){try{return Promise.resolve(Yt(function(){return Promise.resolve(e[t.mode==="sync"?"parse":"parseAsync"](i,s)).then(function(n){return d.shouldUseNativeValidation&<({},d),{errors:{},values:t.raw?Object.assign({},i):n}})},function(n){if((function(u){return Array.isArray(u?.issues)})(n))return{values:{},errors:Kt(Br(n.errors,!d.shouldUseNativeValidation&&d.criteriaMode==="all"),d)};throw n}))}catch(n){return Promise.reject(n)}};if((function(i){return"_zod"in i&&typeof i._zod=="object"})(e))return function(i,o,d){try{return Promise.resolve(Yt(function(){return Promise.resolve((t.mode==="sync"?Ur:Hr)(e,i,s)).then(function(n){return d.shouldUseNativeValidation&<({},d),{errors:{},values:t.raw?Object.assign({},i):n}})},function(n){if((function(u){return u instanceof Rr})(n))return{values:{},errors:Kt(qr(n.issues,!d.shouldUseNativeValidation&&d.criteriaMode==="all"),d)};throw n}))}catch(n){return Promise.reject(n)}};throw new Error("Invalid input: not a Zod schema")}const Wr=e=>{const s=ut(),{pushError:t}=Cs(),{data:i}=Jt({...es(),staleTime:1/0}),o=i?.accounts.find(j=>j.accountId===e)?.composeLanguages,d=C.useMemo(()=>o&&o.length>0?[...o]:Fs(navigator.languages),[o]),n=Se({...ts(),onSuccess:()=>{s.invalidateQueries({queryKey:Ae()})},onError:j=>{t(Os("Couldn't save languages","The writing languages weren't saved.",j))}}),u=C.useCallback(j=>{e&&n.mutate({path:{accountId:e},body:{composeLanguages:j}})},[e,n]);return{languages:d,setLanguages:u,isSaving:n.isPending}},Kr=e=>e.authType==="oauthMicrosoft",Gr="••••••••••",Yr=e=>{const s=e.smtpUsername?.trim();return s?s!==e.username:!1},Zr=Ls({email:be().email().min(1,"Email is required"),displayName:be().optional(),username:be().optional(),password:be().optional(),imapHost:be().min(1,"IMAP host is required"),imapPort:_t.number().int().min(1).max(65535),imapTls:Ie(),imapStartTls:Ie(),smtpHost:be().optional(),smtpPort:_t.number().int().min(1).max(65535).optional(),smtpTls:Ie().optional(),smtpStartTls:Ie().optional(),smtpUsername:be().optional(),smtpPassword:be().optional(),useDifferentSmtpCreds:Ie().optional()}),Qr=({isOpen:e,onClose:s,account:t,focusSmtp:i})=>{const o=ut(),d=!!t,[n,u]=C.useState(!1),[j,E]=C.useState(""),[_,z]=C.useState(!1),R=Dt(j),O=!!R&&!_,T=C.useRef(null),f=Cr({resolver:$r(Zr),defaultValues:{email:"",displayName:"",username:"",password:"",imapHost:"",imapPort:993,imapTls:!0,imapStartTls:!1,smtpHost:"",smtpPort:587,smtpTls:!1,smtpStartTls:!0,useDifferentSmtpCreds:!1}});C.useEffect(()=>{if(t){const p=Yr(t);f.reset({email:t.email,displayName:t.displayName||"",username:t.username||"",password:Gr,imapHost:t.imapHost,imapPort:t.imapPort,imapTls:t.imapTls,imapStartTls:t.imapStartTls,smtpHost:t.smtpHost||"",smtpPort:t.smtpPort||587,smtpTls:t.smtpTls||!1,smtpStartTls:t.smtpStartTls||!0,smtpUsername:p&&t.smtpUsername||"",smtpPassword:"",useDifferentSmtpCreds:p}),u(!1)}else f.reset({email:"",displayName:"",username:"",password:"",imapHost:"",imapPort:993,imapTls:!0,imapStartTls:!1,smtpHost:"",smtpPort:587,smtpTls:!1,smtpStartTls:!0,useDifferentSmtpCreds:!1}),u(!1)},[t,f]);const b=Se({...Is()}),ae=Se({...Ms(),onSuccess:()=>{o.invalidateQueries({queryKey:Ae()}),s()}}),N=Se({...ts(),onSuccess:()=>{o.invalidateQueries({queryKey:Ae()}),s()}}),W=()=>{const p=f.getValues(),V=d&&!n;b.mutate({body:{accountId:V?t?.accountId:void 0,username:p.username||p.email,password:V?void 0:p.password||void 0,imapHost:p.imapHost,imapPort:Number(p.imapPort),imapTls:p.imapTls,imapStartTls:p.imapStartTls}})},I=()=>{const p=f.getValues(),V=d&&!n;b.mutate({body:{accountId:V?t?.accountId:void 0,username:p.username||p.email,password:V?void 0:p.password||void 0,imapHost:p.imapHost,imapPort:Number(p.imapPort),imapTls:p.imapTls,imapStartTls:p.imapStartTls,smtpHost:p.smtpHost||void 0,smtpPort:p.smtpPort?Number(p.smtpPort):void 0,smtpTls:p.smtpTls,smtpStartTls:p.smtpStartTls,smtpUsername:p.useDifferentSmtpCreds?p.smtpUsername:void 0,smtpPassword:p.useDifferentSmtpCreds?p.smtpPassword:void 0}})},A=f.handleSubmit(p=>{if(!d&&!p.password){f.setError("password",{message:"Password is required"});return}const V=rr({imapHost:p.imapHost,smtpHost:p.smtpHost,smtpPort:p.smtpPort,smtpTls:p.smtpTls,smtpStartTls:p.smtpStartTls});V&&(f.setValue("smtpHost",V.smtpHost),f.setValue("smtpPort",V.smtpPort),f.setValue("smtpTls",V.smtpTls),f.setValue("smtpStartTls",V.smtpStartTls));const ce=V?.smtpHost??p.smtpHost,se=V?.smtpPort??p.smtpPort,fe=V?.smtpTls??p.smtpTls,we=V?.smtpStartTls??p.smtpStartTls,Ce={email:p.email,displayName:p.displayName?.trim()||void 0,username:p.username||void 0,imapHost:p.imapHost,imapPort:Number(p.imapPort),imapTls:p.imapTls,imapStartTls:p.imapStartTls,smtpHost:ce||void 0,smtpPort:se?Number(se):void 0,smtpTls:fe,smtpStartTls:we,smtpUsername:p.useDifferentSmtpCreds&&p.smtpUsername||void 0,smtpPassword:p.useDifferentSmtpCreds&&p.smtpPassword||void 0};if(d&&t){const Ee={...Ce,password:n?p.password:void 0};N.mutate({path:{accountId:t.accountId},body:Ee})}else{const Ee={...Ce,password:p.password};ae.mutate({body:Ee})}}),ne=ae.isPending||N.isPending,{signature:re,setSignature:pe,isSaving:oe}=sr(t?.accountId),[K,te]=C.useState(re.plainText),{languages:P,setLanguages:k,isSaving:D}=Wr(t?.accountId),$=r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Writing languages"}),r.jsx(cr,{value:P,onChange:k,busy:D})]});C.useEffect(()=>{te(re.plainText)},[re.plainText]),C.useEffect(()=>{if(!e||!i)return;const p=T.current;if(!p)return;const V=window.setTimeout(()=>{p.scrollIntoView({behavior:"smooth",block:"start"})},250);return()=>window.clearTimeout(V)},[e,i]);const w=C.useCallback(()=>{K!==re.plainText&&pe(K,K)},[K,re.plainText,pe]),M=p=>{const{tls:V,startTls:ce}=Be(p);f.setValue("imapTls",V),f.setValue("imapStartTls",ce);const se=f.getValues("imapPort");(se===993||se===143)&&f.setValue("imapPort",p==="tls"?993:143)},le=p=>{const{tls:V,startTls:ce}=Be(p);f.setValue("smtpTls",V),f.setValue("smtpStartTls",ce);const se=f.getValues("smtpPort");if(se===465||se===587||se===25){const we=p==="tls"?465:p==="starttls"?587:25;f.setValue("smtpPort",we)}},Q=()=>{const p=f.getValues("imapHost");f.setValue("smtpHost",ar(p)),f.setValue("smtpTls",!1),f.setValue("smtpStartTls",!0),f.setValue("smtpPort",587)},ge=p=>{E(p),z(!1);const V=Dt(p);if(!V)return;const ce=Be(V.imap.security);f.setValue("imapHost",V.imap.host),f.setValue("imapPort",V.imap.port),f.setValue("imapTls",ce.tls),f.setValue("imapStartTls",ce.startTls);const se=Be(V.smtp.security);f.setValue("smtpHost",V.smtp.host),f.setValue("smtpPort",V.smtp.port),f.setValue("smtpTls",se.tls),f.setValue("smtpStartTls",se.startTls);const fe=f.getValues("email").trim(),we=f.getValues("username")?.trim();fe&&!we&&f.setValue("username",fe)},Te=R?.passwordHelp.text,De=Ct(b.data?.imapError,Te),ze=Ct(b.data?.smtpError,Te);return(t?Kr(t):!1)&&d?r.jsx(Ft,{isOpen:e,onClose:s,title:"Edit Account",footer:r.jsx(ee,{type:"button",variant:"secondary",onClick:s,children:"Close"}),children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Microsoft 365 Account"}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"rounded-md border border-line bg-surface-sunken px-3 py-2.5 text-sm text-fg-muted",children:[r.jsx("span",{className:"block text-2xs font-medium uppercase tracking-wider text-fg-subtle mb-1",children:"Email"}),r.jsx("span",{className:"text-fg",children:t?.email})]}),r.jsxs("div",{className:"rounded-md border border-line bg-surface-sunken px-3 py-2.5 text-sm text-fg-muted",children:[r.jsx("span",{className:"block text-2xs font-medium uppercase tracking-wider text-fg-subtle mb-1",children:"Authentication"}),r.jsx("span",{className:"text-fg",children:"Microsoft OAuth (XOAUTH2)"})]}),r.jsx("p",{className:"text-xs text-fg-muted",children:"Server settings are managed automatically for Microsoft 365 accounts. To update credentials, use the Reconnect button."})]})]}),d&&r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Signature"}),r.jsx("div",{className:"space-y-3",children:r.jsxs("div",{children:[r.jsx("label",{htmlFor:"email-sig-view",className:"text-sm font-medium mb-1.5 block",children:"Email Signature"}),r.jsx("textarea",{id:"email-sig-view",value:K,onChange:p=>te(p.target.value),onBlur:w,rows:5,className:"w-full px-3 py-2 border border-line rounded-md bg-surface-sunken text-sm text-fg placeholder:text-fg-subtle focus-within:border-line-strong focus-within:ring-2 focus-within:ring-ring/30 transition-colors resize-y outline-none",placeholder:"Enter your email signature..."}),r.jsx("p",{className:"text-xs text-fg-muted mt-1",children:oe?"Saving signature...":"This signature will be appended to new emails."})]})})]}),d&&$]})}):r.jsx(Ft,{isOpen:e,onClose:s,title:d?"Edit Account":"Add Account",footer:r.jsxs(r.Fragment,{children:[r.jsx(ee,{type:"button",variant:"secondary",onClick:s,children:"Cancel"}),r.jsx(ee,{type:"submit",form:"account-form",variant:"primary",disabled:ne,children:ne?"Saving...":"Save Account"})]}),children:r.jsxs("form",{id:"account-form",onSubmit:A,className:"space-y-6",children:[r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Account Information"}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-provider",className:"text-sm font-medium mb-1.5 block",children:"Provider"}),r.jsxs(Rs,{id:"account-provider",value:j,onChange:p=>ge(p.target.value),children:[r.jsx("option",{value:"",children:"Custom / other"}),Js.map(p=>r.jsx("option",{value:p.id,children:p.label},p.id))]}),r.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Pick your email provider to fill in server settings automatically, or choose Custom to enter them by hand."})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-email",className:"text-sm font-medium mb-1.5 block",children:"Email Address"}),r.jsx(ve,{id:"account-email",...f.register("email"),placeholder:"alice@example.com"}),f.formState.errors.email&&r.jsx("p",{className:"text-sm text-danger mt-1",children:f.formState.errors.email.message})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-displayName",className:"text-sm font-medium mb-1.5 block",children:"Display name (optional)"}),r.jsx(ve,{id:"account-displayName",...f.register("displayName"),placeholder:"Alice"}),r.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"What to call this account in Remit. Leave blank to use a name derived from the address."})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-username",className:"text-sm font-medium mb-1.5 block",children:"Username"}),r.jsx(ve,{id:"account-username",...f.register("username"),placeholder:"Same as email if empty"})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-password",className:"text-sm font-medium mb-1.5 block",children:"Password"}),r.jsx(At,{id:"account-password",...f.register("password",{onChange:()=>u(!0)}),onFocus:()=>{d&&!n&&(f.setValue("password",""),u(!0))},placeholder:d?"Leave empty to keep current":""}),f.formState.errors.password&&r.jsx("p",{className:"text-sm text-danger mt-1",children:f.formState.errors.password.message}),R&&r.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[R.passwordHelp.text," ",r.jsx("a",{href:R.passwordHelp.url,target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline",children:"Get an app password"})]})]})]})]}),r.jsxs("section",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider",children:"Incoming Mail (IMAP)"}),R&&r.jsx("button",{type:"button",onClick:()=>z(p=>!p),className:"text-xs text-fg-muted hover:text-fg transition-colors",children:_?"Use preset settings":"Advanced"})]}),O&&r.jsxs("p",{className:"text-xs text-fg-muted mb-3",children:["Server settings are pre-filled for ",R?.label," and locked. Choose Advanced to edit them by hand."]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"imap-host",className:"text-sm font-medium mb-1.5 block",children:"Server"}),r.jsx(ve,{id:"imap-host",...f.register("imapHost"),readOnly:O,placeholder:"imap.example.com"}),f.formState.errors.imapHost&&r.jsx("p",{className:"text-sm text-danger mt-1",children:f.formState.errors.imapHost.message})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"imap-port",className:"text-sm font-medium mb-1.5 block",children:"Port"}),r.jsx(ve,{id:"imap-port",...f.register("imapPort"),readOnly:O,type:"number"})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-sm font-medium mb-1.5 block",children:"Security"}),r.jsxs("div",{className:"space-y-1.5 mt-2",children:[r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:O,checked:f.watch("imapTls"),onChange:()=>M("tls")}),"TLS (Port 993)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:O,checked:!f.watch("imapTls")&&f.watch("imapStartTls"),onChange:()=>M("starttls")}),"STARTTLS (Port 143)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:O,checked:!f.watch("imapTls")&&!f.watch("imapStartTls"),onChange:()=>M("none")}),"None (Unencrypted)"]})]})]})]}),r.jsx(ee,{type:"button",variant:"secondary",onClick:W,disabled:b.isPending,className:"w-full",icon:b.isPending?r.jsx(at,{className:"size-4 animate-spin"}):void 0,children:b.isPending?"Testing...":"Test IMAP Connection"}),b.data&&r.jsxs("div",{className:Et("p-2 rounded-md text-sm",b.data.imapSuccess?"bg-positive/10 text-positive":"bg-danger-soft text-danger"),children:[b.data.imapSuccess?r.jsx(Tt,{className:"inline size-4 mr-1"}):r.jsx(Ve,{className:"inline size-4 mr-1"}),b.data.imapSuccess?"IMAP Connected":De]})]})]}),r.jsxs("section",{ref:T,"data-testid":"smtp-section",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider",children:"Outgoing Mail (SMTP)"}),!O&&r.jsx("button",{type:"button",onClick:Q,disabled:!f.watch("imapHost"),className:"text-xs text-fg-muted hover:text-fg transition-colors disabled:opacity-50",children:"Pre-fill from IMAP"})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"smtp-host",className:"text-sm font-medium mb-1.5 block",children:"Server"}),r.jsx(ve,{id:"smtp-host",...f.register("smtpHost"),readOnly:O,placeholder:"smtp.example.com"})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"smtp-port",className:"text-sm font-medium mb-1.5 block",children:"Port"}),r.jsx(ve,{id:"smtp-port",...f.register("smtpPort"),readOnly:O,type:"number"})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-sm font-medium mb-1.5 block",children:"Security"}),r.jsxs("div",{className:"space-y-1.5 mt-2",children:[r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:O,checked:f.watch("smtpTls")===!0,onChange:()=>le("tls")}),"TLS (Port 465)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:O,checked:!f.watch("smtpTls")&&f.watch("smtpStartTls")===!0,onChange:()=>le("starttls")}),"STARTTLS (Port 587)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:O,checked:!f.watch("smtpTls")&&!f.watch("smtpStartTls"),onChange:()=>le("none")}),"None (Unencrypted)"]})]})]})]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"checkbox",...f.register("useDifferentSmtpCreds")}),"Use different credentials for SMTP"]}),f.watch("useDifferentSmtpCreds")&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"smtp-username",className:"text-sm font-medium mb-1.5 block",children:"SMTP Username"}),r.jsx(ve,{id:"smtp-username",...f.register("smtpUsername")})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"smtp-password",className:"text-sm font-medium mb-1.5 block",children:"SMTP Password"}),r.jsx(At,{id:"smtp-password",...f.register("smtpPassword")})]})]}),r.jsx(ee,{type:"button",variant:"secondary",onClick:I,disabled:b.isPending||!f.watch("smtpHost"),className:"w-full",icon:b.isPending?r.jsx(at,{className:"size-4 animate-spin"}):void 0,children:b.isPending?"Testing...":"Test SMTP Connection"}),b.data?.smtpSuccess!==void 0&&r.jsxs("div",{className:Et("p-2 rounded-md text-sm",b.data.smtpSuccess?"bg-positive/10 text-positive":"bg-danger-soft text-danger"),children:[b.data.smtpSuccess?r.jsx(Tt,{className:"inline size-4 mr-1"}):r.jsx(Ve,{className:"inline size-4 mr-1"}),b.data.smtpSuccess?"SMTP Connected":ze]})]})]}),d&&r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Signature"}),r.jsx("div",{className:"space-y-3",children:r.jsxs("div",{children:[r.jsx("label",{htmlFor:"email-sig-edit",className:"text-sm font-medium mb-1.5 block",children:"Email Signature"}),r.jsx("textarea",{id:"email-sig-edit",value:K,onChange:p=>te(p.target.value),onBlur:w,rows:5,className:"w-full px-3 py-2 border border-line rounded-md bg-surface-sunken text-sm text-fg placeholder:text-fg-subtle focus-within:border-line-strong focus-within:ring-2 focus-within:ring-ring/30 transition-colors resize-y outline-none",placeholder:"Enter your email signature..."}),r.jsx("p",{className:"text-xs text-fg-muted mt-1",children:oe?"Saving signature...":"This signature will be appended to new emails."})]})})]}),d&&$]})})};function Zt({open:e,onClose:s,accountEmail:t,signOut:i}){const[o,d]=C.useState(""),[n,u]=C.useState(!1),[j,E]=C.useState(!1),_=Se({...zs(),onSuccess:()=>{E(!0),setTimeout(()=>i(),2e3)}}),z=Se(Hs()),R=()=>{_.isPending||(d(""),u(!1),E(!1),_.reset(),z.reset(),s())},O=()=>{if(o.trim().toLowerCase()!==t.toLowerCase()){u(!0);return}u(!1),_.mutate({body:{confirmEmail:o.trim()}})};return r.jsxs(ss,{open:e,onClose:R,title:"Delete your Remit account",children:[r.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[r.jsx(dt,{className:"size-4 shrink-0 text-danger"}),r.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:"Delete your Remit account"}),r.jsx(ee,{variant:"ghost",size:"sm",icon:r.jsx(Ve,{className:"size-3.5"}),onClick:R,"aria-label":"Cancel"})]}),j?r.jsxs("div",{className:"px-5 py-6 text-sm text-fg-muted",children:[r.jsx("p",{className:"font-medium text-fg",children:"Account deletion scheduled."}),r.jsx("p",{className:"mt-1",children:"Your data will be erased shortly. Signing you out…"})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"space-y-4 px-5 py-4 text-sm text-fg-muted",children:[r.jsx("p",{children:"This permanently erases everything Remit holds for you:"}),r.jsxs("ul",{className:"space-y-1.5 text-xs",children:[r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"text-danger",children:"•"}),"All connected accounts disconnected and access tokens revoked."]}),r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"text-danger",children:"•"}),"Synced mail cache and search index."]}),r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"text-danger",children:"•"}),"AI history and insights."]}),r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"text-danger",children:"•"}),"Preferences and rules."]})]}),r.jsxs("div",{className:"rounded-sm border border-line bg-surface-sunken px-3 py-2 text-xs",children:[r.jsx("strong",{className:"text-fg",children:"Your mail at Gmail / IMAP is not deleted."})," ","This only removes Remit's copy and its access — the mail stays in your provider mailboxes."]}),r.jsxs("div",{className:"text-xs",children:[r.jsxs("button",{type:"button",onClick:()=>z.mutate({}),"aria-busy":z.isPending,className:"inline-flex items-center gap-1.5 font-medium text-accent hover:underline",children:[r.jsx(ir,{className:"size-3.5"}),z.isPending?"Requesting export…":"Export my data first"]}),z.isSuccess&&r.jsx("p",{className:"mt-1.5 text-fg-muted",role:"status",children:"Export requested. We'll prepare a ZIP of your mail — find it under your data exports when it's ready."}),z.isError&&r.jsx("p",{className:"mt-1.5 text-danger",role:"alert",children:"Couldn't start the export. Please try again."})]}),r.jsxs("div",{children:[r.jsxs("label",{htmlFor:"confirm-remit-email",className:"mb-1 block text-xs font-medium text-fg",children:["Type"," ",r.jsx("span",{className:"font-mono text-fg-muted",children:t})," ","to confirm"]}),r.jsx(ve,{id:"confirm-remit-email",type:"email",placeholder:t,value:o,onChange:T=>{d(T.target.value),n&&u(!1),_.isError&&_.reset()},autoComplete:"off"}),n&&r.jsx("p",{className:"mt-1.5 text-xs text-danger",role:"alert",children:"That doesn't match your account email. Type it exactly to confirm."}),_.isError&&r.jsx("p",{className:"mt-1.5 text-xs text-danger",role:"alert",children:_.error instanceof Error?_.error.message:"Something went wrong. Please try again."})]})]}),r.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[r.jsx(ee,{variant:"secondary",size:"sm",onClick:R,children:"Cancel"}),r.jsx(ee,{variant:"danger",size:"sm",onClick:O,"aria-busy":_.isPending,children:_.isPending?"Deleting…":"Delete everything"})]})]})]})}function Xr(e){const{Account:s}=Us();return r.jsx(s,{fallback:r.jsx(Zt,{...e,accountEmail:"",signOut:()=>{}}),children:({email:t,signOut:i})=>r.jsx(Zt,{...e,accountEmail:t??"",signOut:i})})}function Jr(){const[e,s]=C.useState(!1);return r.jsxs("section",{className:"mt-8 border-t border-line pt-6",children:[r.jsx(dr,{title:"Delete your Remit account",description:"Disconnects every account and erases Remit's copy of your mail, insights and preferences. Your mail at the providers is untouched.",action:r.jsx(ee,{variant:"danger",size:"sm",onClick:()=>s(!0),children:"Delete your Remit account"})}),r.jsx(Xr,{open:e,onClose:()=>s(!1)})]})}function ea(e){const s=e.toLowerCase();return s==="access_denied"?"You cancelled the sign-in.":s==="consent_required"||s.includes("admin_consent")||s.includes("interaction_required")?"Your organisation's admin needs to approve Remit. Ask your IT admin to grant the required permissions.":s.includes("imap_disabled")||s.includes("imap disabled")?"IMAP is disabled for this account. Ask your admin to enable IMAP access in the Microsoft 365 admin centre.":`Sign-in failed: ${e}. Please try again.`}function ta(e){const s=e.split("@")[0]??"";return s?s.split(/[._-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" "):e}function sa(e){const s=e.displayName?.trim();return s||ta(e.email)}function ra(e){if(!e.lastSyncAt)return"never synced";const s=or(e.lastSyncAt);return s?`synced ${s}`:"never synced"}function Qt(e){return e.muted?.value?"muted":e.lastError?"error":e.connectionState==="authenticated"?"healthy":"error"}function Xt(e){return e.connectionState==="reauth_required"}const aa=r.jsxs("div",{className:"space-y-3",children:[r.jsxs("p",{children:[r.jsx("strong",{className:"text-fg",children:"Sync health"})," shows the IMAP connection state and the last successful sync per account."]}),r.jsxs("p",{children:[r.jsx("strong",{className:"text-fg",children:"Error"})," means the last connection attempt failed — the raw server response is shown on the card. Reconnect re-runs the connection test from the add-account wizard."]}),r.jsxs("p",{children:[r.jsx("strong",{className:"text-fg",children:"Muted"})," accounts keep syncing but stay out of the daily brief and unified counts."]})]}),ia=()=>r.jsx("div",{className:"space-y-3",role:"status","aria-busy":"true","aria-label":"Loading accounts",children:["skeleton-0","skeleton-1"].map(e=>r.jsx("div",{className:"rounded-sm border border-line bg-surface animate-pulse p-4",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"size-10 rounded-full bg-surface-sunken"}),r.jsxs("div",{className:"flex-1 space-y-2",children:[r.jsx("div",{className:"h-4 bg-surface-sunken rounded w-1/3"}),r.jsx("div",{className:"h-3 bg-surface-sunken rounded w-2/3"})]})]})},e))});function ja(){const e=Pt.useSearch(),s=Bs({from:Pt.fullPath}),[t,i]=C.useState(!0),[o,d]=C.useState(!1),[n,u]=C.useState(!1),[j,E]=C.useState(null),[_,z]=C.useState(!1),[R,O]=C.useState(null),[T,f]=C.useState(null),[b,ae]=C.useState(null),[N,W]=C.useState(null),I=ut(),{data:A,isPending:ne,isError:re,error:pe,refetch:oe}=Jt(es());C.useEffect(()=>{e.editAccountId&&(E(e.editAccountId),z(!!e.focusSmtp),s({search:{editAccountId:void 0,focusSmtp:void 0,connected:e.connected,oauthError:e.oauthError},replace:!0}))},[e.editAccountId,e.focusSmtp,s,e.connected,e.oauthError]),C.useEffect(()=>{e.connected&&(f("Account connected successfully."),E(e.connected),I.invalidateQueries({queryKey:Ae()}),s({search:{connected:void 0,oauthError:void 0,editAccountId:void 0,focusSmtp:void 0},replace:!0}))},[e.connected,s,I]),C.useEffect(()=>{e.oauthError&&(ae(ea(e.oauthError)),W(null),s({search:{oauthError:void 0,connected:void 0,editAccountId:void 0,focusSmtp:void 0},replace:!0}))},[e.oauthError,s]),er(N!==null,()=>{I.invalidateQueries({queryKey:Ae()})}),C.useEffect(()=>{if(!N||!A)return;const w=A.accounts.find(M=>M.accountId===N);(!w||!Xt(w))&&W(null)},[A,N]);const K=Se({...qs(),onSuccess:w=>{window.location.assign(w.authorizationUrl)},onError:w=>{ae(w instanceof Error?w.message:"Failed to start reconnect"),W(null)}}),te=Se({...$s(),onSuccess:()=>{I.invalidateQueries({queryKey:Ae()}),O(null)}}),P=A?.accounts.find(w=>w.accountId===R),k=A?.accounts.find(w=>w.accountId===j),D=()=>{d(!1),u(!1),E(null),z(!1)},$=w=>{const M=Gs[w];M&&s({to:M})};return r.jsxs(Qs,{items:Ws,activeId:"accounts",title:"Accounts",description:"Every account keeps syncing — muted ones just stay out of unified views.",help:aa,helpOpen:t,onToggleHelp:()=>i(w=>!w),onSelect:$,onBackToMail:()=>{s({to:"/mail"})},children:[T&&r.jsx(kt,{tone:"success",variant:"soft","data-testid":"oauth-success-banner",onDismiss:()=>f(null),children:T}),b&&r.jsx(kt,{tone:"danger",variant:"soft","data-testid":"oauth-error-banner",onDismiss:()=>ae(null),children:b}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Ks,{tone:"neutral",children:ne||re?"accounts":`${A.accounts.length} ${A.accounts.length===1?"account":"accounts"}`}),r.jsx(ee,{variant:"primary",size:"sm",icon:r.jsx(Vt,{className:"size-3.5"}),onClick:()=>u(!0),children:"Add account"})]}),ne?r.jsx(ia,{}):re?r.jsx(nr,{title:"Couldn't load accounts",error:pe,onRetry:()=>{oe()}}):A.accounts.length===0?r.jsxs("div",{className:"py-12 text-sm text-fg-muted","data-testid":"accounts-empty",children:[r.jsx("p",{className:"mb-3",children:"No accounts configured."}),r.jsx(ee,{variant:"primary",size:"sm",icon:r.jsx(Vt,{className:"size-3.5"}),onClick:()=>u(!0),children:"Add your first account"})]}):r.jsx("div",{className:"space-y-3",children:A.accounts.map(w=>{const M=Xt(w),le=w.authType==="oauthMicrosoft",Q=N===w.accountId&&K.isPending,ge=M&&le?{label:"Reconnect",variant:"secondary",busy:Q,busyLabel:"Redirecting…",onClick:()=>{W(w.accountId),K.mutate({body:{email:w.email}})}}:Qt(w)==="error"?{label:"Reconnect",variant:"secondary",onClick:()=>E(w.accountId)}:{label:"Manage",variant:"ghost",onClick:()=>E(w.accountId)},Te=r.jsx(Zs,{actions:[ge],destructive:{label:"Delete account",iconOnly:!0,icon:r.jsx(Ys,{className:"size-3.5"}),onClick:()=>O(w.accountId)}});return r.jsx(Xs,{label:sa(w),email:w.email,connector:le?"Microsoft 365":"IMAP",syncLabel:ra(w),state:Qt(w),errorDetail:M?"Re-authentication required":w.lastError,trailing:Te},w.accountId)})}),n&&r.jsx("div",{className:"fixed inset-0 z-40 overflow-auto bg-canvas",children:r.jsx(tr,{skipWelcome:!0,onComplete:()=>{u(!1),I.invalidateQueries({queryKey:Ae()})},onCancel:()=>u(!1)})}),r.jsx(Qr,{isOpen:o||!!j,account:k,focusSmtp:_,onClose:D}),r.jsxs(ss,{open:!!R,onClose:()=>O(null),title:"Delete account",children:[r.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[r.jsx(dt,{className:"size-4 shrink-0 text-danger"}),r.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:"Delete account"}),r.jsx(ee,{variant:"ghost",size:"sm",icon:r.jsx(Ve,{className:"size-3.5"}),onClick:()=>O(null),"aria-label":"Cancel"})]}),r.jsxs("div",{className:"space-y-3 px-5 py-4 text-sm text-fg-muted",children:[r.jsx("p",{className:"text-center text-lg font-medium text-fg",children:"Are you sure?"}),P&&r.jsx("p",{className:"text-center",children:P.email}),r.jsxs("ul",{className:"list-inside list-disc space-y-1",children:[r.jsx("li",{children:"Remove the account from your settings"}),r.jsx("li",{children:"Stop syncing mail for this account"}),r.jsx("li",{children:"Delete all associated data (within 24 hours)"})]})]}),r.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[r.jsx(ee,{variant:"secondary",size:"sm",onClick:()=>O(null),children:"Cancel"}),r.jsx(ee,{variant:"danger",size:"sm","aria-busy":te.isPending,icon:te.isPending?r.jsx(at,{className:"size-3.5 animate-spin"}):void 0,onClick:()=>{te.isPending||R&&te.mutate({path:{accountId:R}})},children:te.isPending?"Deleting…":"Delete account"})]})]}),r.jsx(Jr,{})]})}export{ja as component,ea as mapOauthError};
|
package/assets/brief-BAvH751q.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as r,a0 as i}from"./index-Bo-p3LpF.js";import{a as m}from"./search-view-CB5G4Kva.js";import{B as o}from"./BriefPane-D5U_FMo6.js";import{u as p}from"./useSearchMirror-DylRqxaA.js";import"./nav-link-BC-lpJt4.js";import{e}from"./search-token-index-sLIcvT6p.js";import"./useSearchTokenContext-Bb3YnI52.js";import"./kbd-0M4qAi49.js";import"./enums-CCxx0t2v.js";import"./MailListHeader-BJ9doZxm.js";import"./account-form-helpers-D1exxHT6.js";import"./avatar-lbydjrIt.js";import"./useSignature-sSo464BG.js";import"./useDebouncedValue-bAON8Yph.js";import"./useFilters-D_O09QB6.js";import"./use-match-media-jqJ95ElE.js";import"./ErrorState-DrA1RdFM.js";import"./format-De9HZKjg.js";import"./download-BRZRRebx.js";import"./shield-check-C48_fmzW.js";import"./move-options-_eZlt0v0.js";import"./confirm-dialog-DZ3dfzvC.js";import"./clock-CdRZkrpV.js";import"./menu-vnrvhz9W.js";import"./useRefreshControl-hxsw2pLp.js";import"./circle-check-big-xK5jTBa2.js";import"./useLabels-wgL9c4lv.js";import"./useSemanticSearch-BXCI_0Rt.js";import"./search-query-Cr_ZXBCp.js";function A(){const t=e();return p({to:"/mail/brief"}),r.jsx(o,{thread:t,children:r.jsx(m,{phone:r.jsx(o.Phone,{}),list:r.jsx(o.List,{}),reading:r.jsx(i,{}),intelligence:r.jsx(o.Intelligence,{}),hasThread:!!t})})}export{A as component};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as o,a0 as i}from"./index-Bo-p3LpF.js";import{a as m}from"./search-view-CB5G4Kva.js";import{F as r}from"./FlaggedPane-CD0MhkHu.js";import{u as p}from"./useSearchMirror-DylRqxaA.js";import"./nav-link-BC-lpJt4.js";import{e}from"./search-token-index-sLIcvT6p.js";import"./useSearchTokenContext-Bb3YnI52.js";import"./kbd-0M4qAi49.js";import"./enums-CCxx0t2v.js";import"./MailListHeader-BJ9doZxm.js";import"./account-form-helpers-D1exxHT6.js";import"./avatar-lbydjrIt.js";import"./useSignature-sSo464BG.js";import"./useDebouncedValue-bAON8Yph.js";import"./useFilters-D_O09QB6.js";import"./use-match-media-jqJ95ElE.js";import"./ErrorState-DrA1RdFM.js";import"./format-De9HZKjg.js";import"./download-BRZRRebx.js";import"./shield-check-C48_fmzW.js";import"./move-options-_eZlt0v0.js";import"./confirm-dialog-DZ3dfzvC.js";import"./clock-CdRZkrpV.js";import"./menu-vnrvhz9W.js";import"./MailViewChrome-wpRug1Q0.js";function k(){const t=e();return p({to:"/mail/flagged"}),o.jsx(r,{thread:t,children:o.jsx(m,{phone:o.jsx(r.Phone,{}),list:o.jsx(r.List,{}),reading:o.jsx(i,{}),intelligence:o.jsx(r.Intelligence,{}),hasThread:!!t})})}export{k as component};
|
package/assets/index-72yU2-kn.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as t,a7 as o}from"./index-Bo-p3LpF.js";const n=()=>t.jsx(o,{to:"/settings/accounts"});export{n as component};
|
package/assets/index-BfJZRVVj.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as o}from"./index-Bo-p3LpF.js";import{M as r}from"./MailboxPane-CUVIV3ip.js";import"./useSearchTokenContext-Bb3YnI52.js";import"./kbd-0M4qAi49.js";import"./enums-CCxx0t2v.js";import"./nav-link-BC-lpJt4.js";import"./useRefreshControl-hxsw2pLp.js";import"./circle-check-big-xK5jTBa2.js";import"./search-token-index-sLIcvT6p.js";import"./use-match-media-jqJ95ElE.js";import"./MailListHeader-BJ9doZxm.js";import"./account-form-helpers-D1exxHT6.js";import"./avatar-lbydjrIt.js";import"./useSignature-sSo464BG.js";import"./useDebouncedValue-bAON8Yph.js";import"./useFilters-D_O09QB6.js";import"./ErrorState-DrA1RdFM.js";import"./format-De9HZKjg.js";import"./download-BRZRRebx.js";import"./shield-check-C48_fmzW.js";import"./move-options-_eZlt0v0.js";import"./confirm-dialog-DZ3dfzvC.js";import"./clock-CdRZkrpV.js";import"./menu-vnrvhz9W.js";import"./MailViewChrome-wpRug1Q0.js";import"./NavMenuButton-Dy0q8FiJ.js";import"./useLabels-wgL9c4lv.js";import"./useSemanticSearch-BXCI_0Rt.js";import"./search-query-Cr_ZXBCp.js";import"./bottom-sheet-BZM-qnW9.js";import"./circle-help-D-5uStGy.js";import"./circle-check-BO9xAEiG.js";function D(){return o.jsx(r.Reading,{})}export{D as component};
|
package/assets/index-BxygYghU.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as o}from"./index-Bo-p3LpF.js";import{O as t}from"./OutboxPane-DD3Oj-FL.js";import"./useSearchTokenContext-Bb3YnI52.js";import"./kbd-0M4qAi49.js";import"./enums-CCxx0t2v.js";import"./nav-link-BC-lpJt4.js";import"./circle-check-big-xK5jTBa2.js";import"./clock-CdRZkrpV.js";import"./row-actions-7xv7AJ82.js";import"./rotate-ccw-CKKgjGEq.js";import"./NavMenuButton-Dy0q8FiJ.js";import"./menu-vnrvhz9W.js";import"./format-De9HZKjg.js";import"./outbox-status-CPfNHfUQ.js";import"./search-query-Cr_ZXBCp.js";function c(){return o.jsx(t.Reading,{})}export{c as component};
|
package/assets/index-CUwYB2GP.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as r}from"./index-Bo-p3LpF.js";import{B as o}from"./BriefPane-D5U_FMo6.js";import"./useSearchTokenContext-Bb3YnI52.js";import"./kbd-0M4qAi49.js";import"./enums-CCxx0t2v.js";import"./nav-link-BC-lpJt4.js";import"./MailListHeader-BJ9doZxm.js";import"./search-token-index-sLIcvT6p.js";import"./use-match-media-jqJ95ElE.js";import"./account-form-helpers-D1exxHT6.js";import"./avatar-lbydjrIt.js";import"./useSignature-sSo464BG.js";import"./useDebouncedValue-bAON8Yph.js";import"./useFilters-D_O09QB6.js";import"./ErrorState-DrA1RdFM.js";import"./format-De9HZKjg.js";import"./download-BRZRRebx.js";import"./shield-check-C48_fmzW.js";import"./move-options-_eZlt0v0.js";import"./confirm-dialog-DZ3dfzvC.js";import"./clock-CdRZkrpV.js";import"./menu-vnrvhz9W.js";import"./useRefreshControl-hxsw2pLp.js";import"./circle-check-big-xK5jTBa2.js";import"./useLabels-wgL9c4lv.js";import"./useSemanticSearch-BXCI_0Rt.js";import"./search-query-Cr_ZXBCp.js";function y(){return r.jsx(o.Reading,{})}export{y as component};
|
package/assets/index-DFS5aq3D.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as o}from"./index-Bo-p3LpF.js";import{F as r}from"./FlaggedPane-CD0MhkHu.js";import"./useSearchTokenContext-Bb3YnI52.js";import"./kbd-0M4qAi49.js";import"./enums-CCxx0t2v.js";import"./nav-link-BC-lpJt4.js";import"./MailListHeader-BJ9doZxm.js";import"./search-token-index-sLIcvT6p.js";import"./use-match-media-jqJ95ElE.js";import"./account-form-helpers-D1exxHT6.js";import"./avatar-lbydjrIt.js";import"./useSignature-sSo464BG.js";import"./useDebouncedValue-bAON8Yph.js";import"./useFilters-D_O09QB6.js";import"./ErrorState-DrA1RdFM.js";import"./format-De9HZKjg.js";import"./download-BRZRRebx.js";import"./shield-check-C48_fmzW.js";import"./move-options-_eZlt0v0.js";import"./confirm-dialog-DZ3dfzvC.js";import"./clock-CdRZkrpV.js";import"./menu-vnrvhz9W.js";import"./MailViewChrome-wpRug1Q0.js";function q(){return o.jsx(r.Reading,{})}export{q as component};
|
package/assets/index-DKsFKmu0.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as r}from"./index-Bo-p3LpF.js";import{B as o}from"./BriefPane-D5U_FMo6.js";import"./useSearchTokenContext-Bb3YnI52.js";import"./kbd-0M4qAi49.js";import"./enums-CCxx0t2v.js";import"./nav-link-BC-lpJt4.js";import"./MailListHeader-BJ9doZxm.js";import"./search-token-index-sLIcvT6p.js";import"./use-match-media-jqJ95ElE.js";import"./account-form-helpers-D1exxHT6.js";import"./avatar-lbydjrIt.js";import"./useSignature-sSo464BG.js";import"./useDebouncedValue-bAON8Yph.js";import"./useFilters-D_O09QB6.js";import"./ErrorState-DrA1RdFM.js";import"./format-De9HZKjg.js";import"./download-BRZRRebx.js";import"./shield-check-C48_fmzW.js";import"./move-options-_eZlt0v0.js";import"./confirm-dialog-DZ3dfzvC.js";import"./clock-CdRZkrpV.js";import"./menu-vnrvhz9W.js";import"./useRefreshControl-hxsw2pLp.js";import"./circle-check-big-xK5jTBa2.js";import"./useLabels-wgL9c4lv.js";import"./useSemanticSearch-BXCI_0Rt.js";import"./search-query-Cr_ZXBCp.js";function z(){return r.jsx(o.Reading,{})}export{z as component};
|
package/assets/index-DOJy3_kq.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as o}from"./index-Bo-p3LpF.js";import{F as r}from"./FlaggedPane-CD0MhkHu.js";import"./useSearchTokenContext-Bb3YnI52.js";import"./kbd-0M4qAi49.js";import"./enums-CCxx0t2v.js";import"./nav-link-BC-lpJt4.js";import"./MailListHeader-BJ9doZxm.js";import"./search-token-index-sLIcvT6p.js";import"./use-match-media-jqJ95ElE.js";import"./account-form-helpers-D1exxHT6.js";import"./avatar-lbydjrIt.js";import"./useSignature-sSo464BG.js";import"./useDebouncedValue-bAON8Yph.js";import"./useFilters-D_O09QB6.js";import"./ErrorState-DrA1RdFM.js";import"./format-De9HZKjg.js";import"./download-BRZRRebx.js";import"./shield-check-C48_fmzW.js";import"./move-options-_eZlt0v0.js";import"./confirm-dialog-DZ3dfzvC.js";import"./clock-CdRZkrpV.js";import"./menu-vnrvhz9W.js";import"./MailViewChrome-wpRug1Q0.js";function k(){return o.jsx(r.Reading,{})}export{k as component};
|
package/assets/index-nszVYODK.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as o}from"./index-Bo-p3LpF.js";import{M as i}from"./MailboxPane-CUVIV3ip.js";import"./useSearchTokenContext-Bb3YnI52.js";import"./kbd-0M4qAi49.js";import"./enums-CCxx0t2v.js";import"./nav-link-BC-lpJt4.js";import"./useRefreshControl-hxsw2pLp.js";import"./circle-check-big-xK5jTBa2.js";import"./search-token-index-sLIcvT6p.js";import"./use-match-media-jqJ95ElE.js";import"./MailListHeader-BJ9doZxm.js";import"./account-form-helpers-D1exxHT6.js";import"./avatar-lbydjrIt.js";import"./useSignature-sSo464BG.js";import"./useDebouncedValue-bAON8Yph.js";import"./useFilters-D_O09QB6.js";import"./ErrorState-DrA1RdFM.js";import"./format-De9HZKjg.js";import"./download-BRZRRebx.js";import"./shield-check-C48_fmzW.js";import"./move-options-_eZlt0v0.js";import"./confirm-dialog-DZ3dfzvC.js";import"./clock-CdRZkrpV.js";import"./menu-vnrvhz9W.js";import"./MailViewChrome-wpRug1Q0.js";import"./NavMenuButton-Dy0q8FiJ.js";import"./useLabels-wgL9c4lv.js";import"./useSemanticSearch-BXCI_0Rt.js";import"./search-query-Cr_ZXBCp.js";import"./bottom-sheet-BZM-qnW9.js";import"./circle-help-D-5uStGy.js";import"./circle-check-BO9xAEiG.js";function F(){return o.jsx(i.Reading,{})}export{F as component};
|
package/assets/mail-DEw6NSuJ.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as T,r as l,u as Be,j as e,S as Ke,a as pe,b as M,C as te,d as se,e as Ve,f as ge,F as Qe,g as qe,X as be,T as He,O as $e,M as We,A as Ue,h as Ye,I as Ge,i as ve,B as K,k as Y,l as ye,m as Je,n as Xe,o as je,p as G,q as Se,s as Ne,t as Ze,v as J,w as X,x as Ce,y as et,z as tt,D as st,E as W,G as at,H as nt,J as rt,K as ot,L as it,N as lt,P as ct,Q as ut,R as dt,U as mt,V as xt,W as ht,Y as ft,Z as pt,_ as gt,$ as bt,a0 as vt}from"./index-Bo-p3LpF.js";import{B as yt,S as jt,D as St,a as Nt,b as Ct,u as kt,s as wt,K as It,c as Mt,d as Ot,e as Et,f as Rt,g as Pt,h as At,i as Lt}from"./search-token-index-sLIcvT6p.js";import{N as L,u as zt,a as Tt,i as Ft,b as ae}from"./nav-link-BC-lpJt4.js";import{P as Dt}from"./pencil-7SyIHZVc.js";import{M as _t,s as Bt,c as Kt}from"./search-view-CB5G4Kva.js";import{u as Vt,a as Qt,R as qt,M as Ht}from"./useRefreshControl-hxsw2pLp.js";import{M as $t}from"./menu-vnrvhz9W.js";import{B as ke}from"./bug-LK0uYJOc.js";import{A as Wt}from"./avatar-lbydjrIt.js";import{i as Ut}from"./outbox-status-CPfNHfUQ.js";import{E as Yt}from"./ErrorState-DrA1RdFM.js";import{K as ne}from"./kbd-0M4qAi49.js";import{u as Gt}from"./useDebouncedValue-bAON8Yph.js";import"./use-match-media-jqJ95ElE.js";import"./circle-check-big-xK5jTBa2.js";const Jt=T("BookmarkPlus",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}],["line",{x1:"12",x2:"12",y1:"7",y2:"13",key:"1cppfj"}],["line",{x1:"15",x2:"9",y1:"10",y2:"10",key:"1gty7f"}]]);const Xt=T("CalendarDays",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 18h.01",key:"lrp35t"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M16 18h.01",key:"kzsmim"}]]);const we=T("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);const Ie=T("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const Zt=T("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]),es="button:not([disabled]), a[href]",P="outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-surface-sunken";function ts({active:t,dimmed:s,indent:a}){return M("flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-sm transition-colors",P,a&&"pl-7",t?"bg-accent-2-soft font-medium text-accent-2":"text-fg-muted hover:bg-surface hover:text-fg",s&&"opacity-55")}function ss({icon:t,label:s,count:a,active:n}){return e.jsxs(e.Fragment,{children:[t&&e.jsx("span",{className:M("shrink-0",n?"text-accent-2":"text-fg-subtle"),children:t}),e.jsx("span",{className:"flex-1 truncate",children:s}),a!=null&&a>0&&e.jsx("span",{className:M("text-2xs tabular-nums",n?"text-accent-2":"text-fg-subtle"),children:a})]})}function z({icon:t,label:s,count:a,active:n,dimmed:r,indent:o,navId:i,linkComponent:d,ariaLabel:x,title:p,onClick:g}){const m=ts({active:n,dimmed:r,indent:o}),h=e.jsx(ss,{icon:t,label:s,count:a,active:n});return i&&d?d({navId:i,className:m,ariaLabel:x??s,title:p,onClick:g,children:h}):e.jsx("button",{type:"button",onClick:g,className:m,"aria-label":x,title:p,children:h})}const re={inbox:0,flagged:1,drafts:2,sent:3,archive:4,all:5,junk:6,trash:7};function as(t){switch(t){case"inbox":return e.jsx(Ge,{className:"size-4"});case"flagged":return e.jsx(pe,{className:"size-4"});case"drafts":return e.jsx(Ye,{className:"size-4"});case"sent":return e.jsx(ge,{className:"size-4"});case"archive":return e.jsx(Ue,{className:"size-4"});case"all":return e.jsx(We,{className:"size-4"});case"junk":return e.jsx($e,{className:"size-4"});case"trash":return e.jsx(He,{className:"size-4"})}}const oe=t=>t.role!=null,$=8,ie="remit.nav.folders.open.",le="remit.nav.account.open.";function ce(t,s,a){if(typeof localStorage>"u")return a;const n=localStorage.getItem(t+s);return n===null?a:n!=="0"}function ue(t,s,a){typeof localStorage>"u"||localStorage.setItem(t+s,a?"1":"0")}function ns({query:t,onSelect:s,onRemove:a}){return e.jsxs("div",{className:"group flex w-full items-center gap-1 rounded-md pr-1 hover:bg-surface",children:[e.jsxs("button",{type:"button",onClick:s,className:M("flex min-w-0 flex-1 items-center gap-2 px-2 py-1 text-left text-sm text-fg-muted transition-colors hover:text-fg",P),children:[e.jsx(qe,{className:"size-4 shrink-0 text-fg-subtle"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:t})]}),a&&e.jsx("button",{type:"button",onClick:a,"aria-label":`Remove saved search: ${t}`,className:M("shrink-0 rounded-full p-1 text-fg-subtle opacity-0 transition-opacity hover:bg-surface-sunken hover:text-fg group-hover:opacity-100 focus-visible:opacity-100",P),children:e.jsx(be,{className:"size-3.5"})})]})}function rs({savedSearches:t,saveableQuery:s,onSelectSavedSearch:a,onRemoveSavedSearch:n,onSaveCurrentSearch:r}){return t.length===0&&!s?null:e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:"px-2 pb-1 text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Saved searches"}),s&&e.jsxs("button",{type:"button",onClick:r,className:M("flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-sm text-accent transition-colors hover:bg-surface",P),children:[e.jsx(Jt,{className:"size-4 shrink-0"}),e.jsxs("span",{className:"min-w-0 flex-1 truncate",children:["Save “",s,"”"]})]}),t.map(o=>e.jsx(ns,{query:o,onSelect:()=>a?.(o),onRemove:n?()=>n(o):void 0},o))]})}function os({account:t,selectedNavId:s,onSelectNav:a,linkComponent:n}){const[r,o]=l.useState(()=>ce(le,t.id,!0)),[i,d]=l.useState(()=>ce(ie,t.id,!0)),[x,p]=l.useState(!1),g=()=>{o(c=>{const S=!c;return ue(le,t.id,S),S})},m=()=>{d(c=>{const S=!c;return ue(ie,t.id,S),S})},h=t.mailboxes.filter(oe).sort((c,S)=>re[c.role]-re[S.role]),f=t.mailboxes.filter(c=>!oe(c)),b=x||f.length<=$?f:f.slice(0,$),v=f.length-b.length,y=t.status??"ready",E=y==="ready"&&h.length===0&&f.length===0;return e.jsxs("div",{className:"mt-3",children:[e.jsxs("button",{type:"button",onClick:g,"aria-expanded":r,className:M("flex w-full items-center gap-1.5 px-2 pb-1 text-left transition-colors hover:text-fg",P,t.muted&&"opacity-55"),children:[r?e.jsx(te,{className:"size-3 shrink-0 text-fg-subtle"}):e.jsx(se,{className:"size-3 shrink-0 text-fg-subtle"}),e.jsx("span",{className:"truncate text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:t.label}),t.muted&&e.jsxs(e.Fragment,{children:[e.jsx(yt,{className:"size-3 shrink-0 text-fg-subtle"}),e.jsx("span",{className:"text-2xs text-fg-subtle",children:"muted"})]})]}),r&&e.jsxs(e.Fragment,{children:[y==="loading"&&e.jsx("div",{className:"px-2 py-1 text-sm text-fg-muted",children:"Loading…"}),y==="error"&&e.jsxs("div",{role:"alert",className:"mx-2 my-1 flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-2 py-1.5 text-sm",children:[e.jsx(Ve,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":"true"}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("p",{className:"font-medium text-danger",children:"Couldn't load mailboxes"})}),t.onRetry&&e.jsx("button",{type:"button",onClick:t.onRetry,className:"shrink-0 text-sm font-medium text-accent hover:underline",children:"Retry"})]}),E&&e.jsx("div",{className:"px-2 py-1 text-sm text-fg-muted",children:"No mailboxes"}),y==="ready"&&e.jsxs(e.Fragment,{children:[h.map(c=>e.jsx(z,{navId:c.id,linkComponent:n,icon:as(c.role),label:c.name,ariaLabel:c.name,title:c.fullPath??c.name,count:c.unseen,active:s===c.id,dimmed:t.muted,onClick:()=>a?.(c.id)},c.id)),t.outboxPending!==void 0&&e.jsx(z,{navId:"outbox",linkComponent:n,icon:e.jsx(ge,{className:"size-4"}),label:"Outbox",ariaLabel:"Outbox",count:t.outboxPending>0?t.outboxPending:void 0,active:s==="outbox",dimmed:t.muted,onClick:()=>a?.("outbox")}),f.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:m,"aria-expanded":i,className:M("mt-1 flex w-full items-center gap-1 px-2 py-1 text-left text-2xs font-semibold uppercase tracking-wider text-fg-subtle transition-colors hover:text-fg",P),children:[i?e.jsx(te,{className:"size-3 shrink-0"}):e.jsx(se,{className:"size-3 shrink-0"}),e.jsx("span",{className:"flex-1",children:"Folders"}),e.jsx("span",{className:"tabular-nums opacity-70",children:f.length})]}),i&&e.jsxs(e.Fragment,{children:[b.map(c=>e.jsx(z,{navId:c.id,linkComponent:n,icon:e.jsx(Qe,{className:"size-4"}),label:c.name,ariaLabel:c.name,title:c.fullPath??c.name,count:c.unseen,active:s===c.id,dimmed:t.muted,onClick:()=>a?.(c.id)},c.id)),(v>0||x)&&f.length>$&&e.jsx("button",{type:"button",onClick:()=>p(c=>!c),className:M("ml-7 flex items-center px-2 py-1 text-2xs font-medium text-accent transition-colors hover:underline",P),children:x?"Show less":`Show all (${f.length})`})]})]})]})]})]})}function is({accounts:t,selectedNavId:s,briefUnseen:a,onSelectNav:n,variant:r="desktop",linkComponent:o,calendarNav:i="hidden",savedSearches:d=[],saveableQuery:x,onSelectSavedSearch:p,onRemoveSavedSearch:g,onSaveCurrentSearch:m}){const h=l.useRef(null);Be({containerRef:h,itemSelector:es});const f=r==="drawer",b=e.jsxs("nav",{ref:f?h:void 0,className:f?"px-2 py-2":"flex-1 overflow-y-auto px-2 py-2","aria-label":"Mailboxes",children:[e.jsx(z,{navId:"brief",linkComponent:o,icon:e.jsx(Ke,{className:"size-4"}),label:"Daily brief",ariaLabel:"Daily brief",count:a,active:s==="brief",onClick:()=>n?.("brief")}),i==="shown"&&e.jsx(z,{navId:"calendar",linkComponent:o,icon:e.jsx(Xt,{className:"size-4"}),label:"Calendar",ariaLabel:"Calendar",active:s==="calendar",onClick:()=>n?.("calendar")}),e.jsx(z,{navId:"flagged",linkComponent:o,icon:e.jsx(pe,{className:"size-4"}),label:"Starred",ariaLabel:"Starred",active:s==="flagged",onClick:()=>n?.("flagged")}),e.jsx(rs,{savedSearches:d,saveableQuery:x,onSelectSavedSearch:p,onRemoveSavedSearch:g,onSaveCurrentSearch:m}),t.length===0?e.jsx("div",{className:"px-2 py-4 text-center text-sm text-fg-muted",children:"No accounts configured"}):t.map(v=>e.jsx(os,{account:v,selectedNavId:s,onSelectNav:n,linkComponent:o},v.id))]});return f?b:e.jsx("aside",{ref:h,className:"flex h-full w-full flex-col bg-surface-sunken",children:b})}function ls({leading:t,search:s,actions:a,className:n}){return e.jsxs("header",{className:M("flex min-h-pane-header w-full shrink-0 items-center gap-2 border-b border-line bg-canvas px-row-inset py-1",n),children:[t&&e.jsx("div",{className:"flex shrink-0 items-center gap-1",children:t}),e.jsx("div",{className:"flex min-w-0 flex-1 justify-start",children:e.jsx("div",{className:"w-full max-w-xs transition-[max-width] duration-150 ease-out focus-within:max-w-lg",children:s})}),a&&e.jsx("div",{className:"flex shrink-0 items-center gap-1",children:a})]})}function cs(){const t=ve();if(!t)return null;const s=t.showNavPane?!t.navCollapsed:!1;return e.jsx(K,{variant:"ghost",size:"sm",icon:e.jsx($t,{className:"size-4"}),onClick:t.toggleNav,"aria-label":s?"Hide folders":"Show folders","aria-expanded":s,title:"Folders",className:"shrink-0"})}const us={global:"Search all mail",pending:"Search mail",scoped:"Search this folder"};function ds({search:t,onCompose:s,onReportBug:a,onOpenSettings:n,composeShortcut:r,refreshControl:o,account:i}){return e.jsx(ls,{leading:e.jsx(cs,{}),search:e.jsx(jt,{value:t.value,onChange:t.onChange,onClear:t.onClear,onClearQuery:t.onClearQuery,chips:t.chips,onRemoveChip:t.onRemoveChip,placeholder:us[t.scope]}),actions:e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"sm",icon:e.jsx(Zt,{className:"size-4"}),title:r?`Compose (${r})`:"Compose","aria-label":"Compose",onClick:s}),e.jsx(K,{variant:"ghost",size:"sm",icon:e.jsx(ke,{className:"size-4"}),title:"Report a bug","aria-label":"Report a bug",onClick:a}),e.jsx(K,{variant:"ghost",size:"sm",icon:e.jsx(Ie,{className:"size-4"}),title:"Settings","aria-label":"Settings",onClick:n}),o,i]})})}const ms=()=>{const{state:t,openCompose:s}=Y(),a=ye(),n=l.useCallback(()=>{s({mode:"new"})},[s]),r=Je(a.pathname);return!a.pathname.startsWith("/mail")||t.isOpen||r?null:e.jsx("button",{type:"button",onClick:n,"aria-label":"Compose new message",className:"lg:hidden fixed right-4 z-30 h-14 w-14 rounded-full bg-accent text-accent-fg shadow-lg flex items-center justify-center hover:opacity-90 active:scale-95 transition-all",style:{bottom:"calc(env(safe-area-inset-bottom, 0) + 1rem)"},children:e.jsx(Dt,{className:"size-6"})})},Me=({children:t})=>{const{Account:s}=Xe();return e.jsx(s,{children:t})},xs=({email:t,onSignOut:s})=>{const a=t??"Account";return e.jsxs(St,{trigger:e.jsx(Wt,{name:a,email:t??void 0,size:"sm"}),align:"right",children:[t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 py-2 text-xs text-fg-muted truncate",title:t,"data-testid":"account-menu-email",children:t}),e.jsx(Nt,{})]}),e.jsxs(Ct,{onClick:s,children:[e.jsx(we,{className:"size-4"}),"Sign out"]})]})},hs=()=>e.jsx(Me,{children:({email:t,signOut:s})=>e.jsx(xs,{email:t,onSignOut:s})});function fs({accounts:t}){const{searchInput:s,onSearchChange:a,onSearchClear:n,onSearchClearQuery:r}=je(),o=G(),{openCompose:i}=Y(),d=l.useCallback(()=>{i({mode:"new"})},[i]),{scope:x,clearScope:p}=kt(t),g=x.kind==="scoped"?[{id:x.chip.id,label:x.chip.label,tone:"scope"}]:void 0,m=l.useMemo(()=>t.map(y=>y.accountId),[t]),{hasNewMail:h}=Vt(),{state:f,errorMessage:b,refresh:v}=Qt(m);return e.jsx(ds,{search:{value:s,scope:x.kind,chips:g,onChange:a,onClear:n,onClearQuery:r,onRemoveChip:p},onCompose:d,onReportBug:Se,onOpenSettings:()=>o({to:"/settings/accounts"}),composeShortcut:wt("compose"),refreshControl:e.jsx(qt,{state:f,onRefresh:v,label:"Refresh all accounts",errorMessage:b,hasUpdate:h(m)}),account:e.jsx(hs,{})})}const Z="remit.savedSearches",ps=25;function Q(){try{const t=localStorage.getItem(Z);if(!t)return[];const s=JSON.parse(t);return Array.isArray(s)?s.filter(a=>typeof a=="string"):[]}catch{return[]}}function gs(t){const s=t.trim();if(!s)return Q();const a=[s,...Q().filter(n=>n!==s)].slice(0,ps);try{localStorage.setItem(Z,JSON.stringify(a))}catch{return a}return a}function bs(t){const s=Q().filter(a=>a!==t);try{localStorage.setItem(Z,JSON.stringify(s))}catch{return s}return s}const de=t=>/^\d/.test(t),vs=(t,s)=>{const a=de(t),n=de(s);return a&&!n?-1:!a&&n?1:t.localeCompare(s,void 0,{sensitivity:"base",numeric:!0})};function ys(t,s,a){const n=[],r=[];for(const o of t)s.has(o.mailboxId)?n.push(o):r.push(o);return r.sort((o,i)=>vs(W(o,void 0,a),W(i,void 0,a))),{system:n,labels:r}}function js(t,s,a){const n=at(s)&&t.unseenCount>0;return{id:t.mailboxId,name:W(t,s,a),unseen:n?t.unseenCount:void 0,role:s,fullPath:t.fullPath}}function Ss(){const t=ye(),s=st({strict:!1});return t.pathname.startsWith("/settings")?"settings":t.pathname.startsWith("/mail/outbox")?"outbox":t.pathname.startsWith("/mail/flagged")?"flagged":t.pathname.startsWith("/mail/brief")?"brief":s.mailboxId?s.mailboxId:""}function me({accounts:t,onMailboxSelect:s,variant:a="desktop"}){const n=Ne(),r=G(),o=Ss(),{searchInput:i,onSearchChange:d}=je(),[x,p]=l.useState(Q),{t:g}=Ze("mail",{useSuspense:!1}),m=l.useCallback((u,C)=>g(u,{defaultValue:C}),[g]),h=J({queries:t.map(u=>({...X({path:{accountId:u.accountId}}),staleTime:1/0}))}),{data:f}=Ce(et()),b=l.useMemo(()=>(f?.items??[]).filter(u=>Ut(u.status)).length,[f?.items]),v=l.useMemo(()=>t.map((u,C)=>{const N=h[C],O=N?.data?.items??[],w=tt(u.folderAppointments),{system:k,labels:D}=ys(O,w,m),H=N?.isError?"error":N?.isLoading?"loading":"ready";return{id:u.accountId,label:u.email,email:u.email,muted:!!u.muted,outboxPending:b,status:H,onRetry:()=>N?.refetch(),mailboxes:[...k,...D].map(_=>js(_,w.get(_.mailboxId),m))}}),[t,h,b,m]),y=u=>{n.invalidateQueries({queryKey:nt({path:{mailboxId:u},query:{order:"desc"}})})},E=({navId:u,className:C,ariaLabel:N,title:O,children:w,onClick:k})=>u==="brief"?e.jsx(L,{to:"/mail/brief",search:{q:void 0},activeOptions:{includeSearch:!1},onClick:()=>k?.(),className:C,"aria-label":N,title:O,children:w}):u==="outbox"?e.jsx(L,{to:"/mail/outbox",search:{q:void 0},onClick:()=>k?.(),className:C,"aria-label":N,title:O,children:w}):u==="flagged"?e.jsx(L,{to:"/mail/flagged",search:{q:void 0},onClick:()=>k?.(),className:C,"aria-label":N,title:O,children:w}):u==="settings"?e.jsx(L,{to:"/settings/accounts",onClick:()=>k?.(),className:C,"aria-label":N,title:O,children:w}):e.jsx(L,{to:"/mail/$mailboxId",params:{mailboxId:u},search:{q:void 0},onClick:()=>{y(u),k?.()},className:C,"aria-label":N,title:O,children:w}),c=()=>{d(""),s?.()},S=i.trim(),A=S.length>0&&!x.includes(S)?S:void 0,R=l.useCallback(()=>{A&&p(gs(A))},[A]),F=l.useCallback(u=>{p(bs(u))},[]),q=l.useCallback(u=>{d(u),r({to:"/mail/brief",search:{q:u}}),s?.()},[d,r,s]);return e.jsx(is,{accounts:v,selectedNavId:o,onSelectNav:c,linkComponent:E,variant:a,savedSearches:x,saveableQuery:A,onSaveCurrentSearch:R,onSelectSavedSearch:q,onRemoveSavedSearch:F})}function Ns(){return e.jsxs("button",{type:"button",onClick:Se,className:"flex w-full items-center gap-2 rounded-md px-2 py-1 text-sm text-fg-muted transition-colors hover:bg-surface hover:text-fg",children:[e.jsx(ke,{className:"size-4 shrink-0"}),e.jsx("span",{className:"flex-1 truncate text-left",children:"Report a bug"})]})}function Cs({accounts:t,onMailboxSelect:s}){return ve()?.showNavPane??!0?e.jsx(me,{accounts:t}):e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsx(me,{accounts:t,onMailboxSelect:s,variant:"drawer"})}),e.jsxs("div",{className:"border-t border-line px-2 py-2",children:[e.jsxs(L,{to:"/settings/accounts",onClick:s,children:[e.jsx(Ie,{className:"size-4 shrink-0"}),e.jsx("span",{className:"flex-1 truncate text-left",children:"Settings"})]}),e.jsx(Ns,{}),e.jsx(Me,{children:({signOut:r})=>e.jsxs("button",{type:"button",onClick:()=>{s?.(),r()},className:"flex min-h-11 w-full items-center gap-2 rounded-md px-2 py-1 text-sm text-fg-muted transition-colors hover:bg-surface hover:text-fg","data-testid":"sign-out-button",children:[e.jsx(we,{className:"size-4 shrink-0"}),e.jsx("span",{className:"flex-1 truncate text-left",children:"Sign out"})]})})]})]})}const ks=({isOpen:t,onClose:s})=>{const a=l.useCallback(n=>{n.key==="Escape"&&(n.preventDefault(),n.stopPropagation(),n.stopImmediatePropagation(),s())},[s]);return l.useEffect(()=>{if(t)return window.addEventListener("keydown",a,!0),()=>window.removeEventListener("keydown",a,!0)},[t,a]),t?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx(rt,{label:"Dismiss keyboard shortcuts",onDismiss:s,className:"backdrop-blur-sm"}),e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Keyboard shortcuts",className:ot("relative z-10 max-h-[85vh] w-full max-w-2xl overflow-y-auto","rounded-lg border border-line bg-surface shadow-lg","p-6"),children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Keyboard shortcuts"}),e.jsx("button",{type:"button",onClick:s,className:"p-1 text-fg-muted transition-colors hover:text-fg","aria-label":"Close",children:e.jsx(be,{className:"size-5"})})]}),e.jsx("div",{className:"grid gap-x-8 gap-y-6 sm:grid-cols-2",children:It.map(n=>e.jsxs("div",{children:[e.jsx("h3",{className:"mb-3 text-sm font-medium text-fg-muted",children:n.title}),e.jsx("div",{className:"space-y-2",children:n.hints.map(r=>e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{className:"text-sm",children:r.description}),e.jsx("span",{className:"flex shrink-0 items-center gap-1",children:r.keys.map((o,i)=>e.jsxs(l.Fragment,{children:[i>0&&r.keys[0]==="g"&&e.jsx("span",{className:"text-2xs text-fg-subtle",children:"then"}),e.jsx(ne,{children:o})]},o))})]},`${r.action}-${r.keys.join("+")}`))})]},n.title))}),e.jsx("div",{className:"mt-6 border-t border-line pt-4",children:e.jsxs("p",{className:"text-center text-xs text-fg-muted",children:["Press ",e.jsx(ne,{children:"Esc"})," to close"]})})]})]}):null};function ws(t){const s=J({queries:t.map(a=>({...X({path:{accountId:a.accountId}}),staleTime:1/0}))});return l.useMemo(()=>Mt(s.map(a=>a.data?.items??[])),[s])}const Is=t=>t.map(s=>s.data?.items??[]);function Ms(t){const s=J({queries:t.map(a=>({...X({path:{accountId:a.accountId}}),staleTime:1/0})),combine:Is});return l.useMemo(()=>it(t.map((a,n)=>({folderAppointments:a.folderAppointments,mailboxes:s[n]??[]}))),[t,s])}var B={exports:{}},xe;function Os(){if(xe)return B.exports;xe=1;const t=(s,a,n)=>new Promise((r,o)=>{if(n=Object.assign({concurrency:1/0},n),typeof a!="function")throw new TypeError("Mapper function is required");const{concurrency:i}=n;if(!(typeof i=="number"&&i>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${i}\` (${typeof i})`);const d=[],x=s[Symbol.iterator]();let p=!1,g=!1,m=0,h=0;const f=()=>{if(p)return;const b=x.next(),v=h;if(h++,b.done){g=!0,m===0&&r(d);return}m++,Promise.resolve(b.value).then(y=>a(y,v)).then(y=>{d[v]=y,m--,f()},y=>{p=!0,o(y)})};for(let b=0;b<i&&(f(),!g);b++);});return B.exports=t,B.exports.default=t,B.exports}var Es=Os();const Rs=lt(Es),Ps=900*1e3,As=300,Ls=(t,s)=>{if(!t)return s;const a=Number.parseInt(t,10);return Number.isFinite(a)&&a>0?a:s},zs=60*1e3,Ts=t=>Math.max(Ls(t,As)*1e3,zs),V=Ts(xt().mailboxPollIntervalSeconds),Fs=5,U=new Set,Ds=(t,s,a=Ps)=>t.filter(n=>{const r=n.lastSyncAt;return r==null?!0:s-r>a}).map(n=>n.accountId),_s=(t,s,a=V)=>t-s>=a,Bs=(t,s)=>t.filter(a=>!s.has(a)),he=(t,s)=>{if(U.delete(t),dt(s,{softError:!0})){mt(s);return}console.warn("[remit] background mailbox sync failed",{accountId:t,error:s})},fe=(t,s)=>ct({path:{accountId:t},throwOnError:!0}).then(()=>{s.invalidateQueries({queryKey:ut({path:{accountId:t}})})}),Ks=t=>{const s=Ne(),a=l.useRef(t);a.current=t;const n=t.map(r=>r.accountId).join(",");l.useEffect(()=>{const r=Date.now(),i=Ds(a.current,r).filter(d=>!U.has(d));if(i.length!==0)for(const d of i)U.add(d),fe(d,s).catch(x=>{he(d,x)})},[n,s]),l.useEffect(()=>{let r=Date.now(),o;const i=new Set,d=()=>{r=Date.now();const g=Bs(a.current.map(m=>m.accountId),i);for(const m of g)i.add(m);Rs(g,m=>fe(m,s).catch(h=>{he(m,h)}).finally(()=>{i.delete(m)}),{concurrency:Fs})},x=()=>{if(document.visibilityState==="visible"){d(),o=setTimeout(x,V);return}},p=()=>{document.visibilityState==="visible"&&_s(Date.now(),r)&&(o!==void 0&&clearTimeout(o),d(),o=setTimeout(x,V))};return o=setTimeout(x,V),document.addEventListener("visibilitychange",p),()=>{o!==void 0&&clearTimeout(o),document.removeEventListener("visibilitychange",p)}},[n,s])},Oe="remit:intelligence-open";function Vs(){try{return localStorage.getItem(Oe)!=="closed"}catch{return!0}}function Qs(t){try{localStorage.setItem(Oe,t?"open":"closed")}catch{}}function qs({panels:t,prefersOpen:s,isDesktop:a,hasThread:n}){return t.length>0?t.includes("intelligence"):a&&n&&s}function oa(){const{q:t=""}=ht({from:"/mail"}),s=G(),a=Ot(),n=Lt(a),r=zt(),o=Tt(),i=r.find(Ft),d=i==="shortcuts",x=i==="nav",p=Et(),[g,m]=l.useState(Vs),h=qs({panels:r,prefersOpen:g,isDesktop:a==="desktop",hasThread:p!==void 0}),f=l.useCallback((j,ee)=>{o([...j?["intelligence"]:[],...ee?[ee]:[]])},[o]),b=l.useCallback(j=>{Qs(j),m(j),f(j,i)},[i,f]),v=l.useCallback(j=>{f(h,j)},[h,f]),[y,E]=l.useState(t),c=Gt(y,200),S=Kt(y,c),A=ae({select:j=>j.location.pathname}),R=ae({select:j=>ft(j.matches)}),[F,q]=l.useState(R);if(F!==R){const j=Bt(F,R,t);q(R),j!==void 0&&E(j)}const{data:u,isLoading:C,isError:N,error:O,refetch:w}=Ce({...pt(),staleTime:1/0}),k=!!(u&&(u.accounts?.length??0)===0);l.useEffect(()=>{k&&s({to:"/onboarding",replace:!0})},[k,s]),Rt({enabled:!d,bindings:[{key:"?",handler:()=>v("shortcuts"),noModifiers:!1,preventDefault:!0}]});const{openCompose:D}=Y(),H=l.useMemo(()=>({compose:()=>D({mode:"new"})}),[D]);Pt({enabled:!gt(A),handlers:H});const _=l.useCallback(j=>{E(j)},[]),Ee=l.useCallback(()=>{E("")},[]),Re=l.useCallback(()=>{E("")},[]),Pe=l.useCallback(()=>{b(!h)},[b,h]),I=u?.accounts??[],Ae=l.useMemo(()=>I.map(j=>j.accountId),[I]),Le=ws(I),ze=Ms(I),Te=l.useMemo(()=>At(I),[I]);Ks(I);const Fe=l.useCallback(()=>{i==="nav"&&v(void 0)},[i,v]),De={accounts:I,mailboxNameIndex:Le,accountNameIndex:Te,resultFolderIndex:ze,searchQuery:S,searchInput:y,searchViewKey:R,onSearchChange:_,onSearchClear:Ee,onSearchClearQuery:Re,intelligenceOpen:h,onToggleIntelligence:Pe},_e={isSinglePane:n,isLoading:C||k,intelligenceOpen:h,nav:e.jsx(Cs,{accounts:I,onMailboxSelect:Fe}),topBar:n?void 0:e.jsx(fs,{accounts:I}),overlay:n?e.jsx(ms,{}):void 0,navOpen:x,onOpenNav:()=>v("nav"),onCloseNav:()=>v(void 0)};return e.jsx(bt.Provider,{value:De,children:e.jsxs(Ht,{accountIds:Ae,children:[N?e.jsx("div",{className:"flex h-full items-center justify-center bg-canvas p-4",children:e.jsx(Yt,{title:"Couldn't load your account",error:O,onRetry:()=>{w()}})}):e.jsx(_t,{chrome:_e,children:e.jsx(vt,{})}),e.jsx(ks,{isOpen:d,onClose:()=>v(void 0)})]})})}export{oa as component,je as useMailContext};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{D as s,j as o,a0 as i}from"./index-Bo-p3LpF.js";import{a as m}from"./search-view-CB5G4Kva.js";import{O as t}from"./OutboxPane-DD3Oj-FL.js";import{u as a}from"./useSearchMirror-DylRqxaA.js";import"./nav-link-BC-lpJt4.js";import"./useSearchTokenContext-Bb3YnI52.js";import"./kbd-0M4qAi49.js";import"./enums-CCxx0t2v.js";import"./circle-check-big-xK5jTBa2.js";import"./clock-CdRZkrpV.js";import"./row-actions-7xv7AJ82.js";import"./rotate-ccw-CKKgjGEq.js";import"./NavMenuButton-Dy0q8FiJ.js";import"./menu-vnrvhz9W.js";import"./format-De9HZKjg.js";import"./outbox-status-CPfNHfUQ.js";import"./search-query-Cr_ZXBCp.js";function e(){return s({from:"/mail/outbox/draft/$outboxMessageId",shouldThrow:!1})?.outboxMessageId}function L(){const r=e();return a({to:"/mail/outbox"}),o.jsx(t,{outboxMessageId:r,children:o.jsx(m,{phone:o.jsx(t.Phone,{}),list:o.jsx(t.List,{}),reading:o.jsx(i,{})})})}export{L as component};
|