@remit/web-client-dist 0.0.344 → 0.0.346

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/assets/{BriefPane-Cf0qx6oW.js → BriefPane-MeJy6Zwp.js} +1 -1
  2. package/assets/{ErrorState-EG2eHLL1.js → ErrorState-DH_p36q7.js} +1 -1
  3. package/assets/{FlaggedPane-WLhe7MTQ.js → FlaggedPane-DAWH7jyR.js} +1 -1
  4. package/assets/MailListHeader-CfGZ2a_j.js +52 -0
  5. package/assets/{MailViewChrome-7pIGoTSB.js → MailViewChrome-BC4sBDQe.js} +1 -1
  6. package/assets/MailboxPane-Dypv0VNE.js +1 -0
  7. package/assets/{NavMenuButton-DiNk3STC.js → NavMenuButton-BBt5cXaH.js} +1 -1
  8. package/assets/{OnboardingWizard-Q6QD6xGn.js → OnboardingWizard-B7_i4bqQ.js} +1 -1
  9. package/assets/{OutboxPane-DzBz96fV.js → OutboxPane-DYfu__9s.js} +1 -1
  10. package/assets/_mailboxId-CPUiJhKQ.js +1 -0
  11. package/assets/_messageId-CJ0WHc7V.js +1 -0
  12. package/assets/_messageId-Cnkc1wMO.js +1 -0
  13. package/assets/_messageId-DKz1WUUv.js +1 -0
  14. package/assets/_outboxMessageId-C7Ux5abw.js +1 -0
  15. package/assets/_threadId-3u_efTw3.js +1 -0
  16. package/assets/_threadId-DaoSduVf.js +1 -0
  17. package/assets/_threadId-DbAb-c6f.js +1 -0
  18. package/assets/{account-form-helpers-1QlePfxz.js → account-form-helpers-TELLBZNz.js} +1 -1
  19. package/assets/accounts-e6hRmzzC.js +1 -0
  20. package/assets/{advanced-BHmSZ0Kb.js → advanced-54kbkUdM.js} +1 -1
  21. package/assets/{appearance-Ber4IHv_.js → appearance-FFXIQLly.js} +1 -1
  22. package/assets/{avatar-BpcGfGBY.js → avatar-B5F_rga_.js} +1 -1
  23. package/assets/{bottom-sheet-Bb9_P1q_.js → bottom-sheet-oW0eH2Zy.js} +1 -1
  24. package/assets/{brief-snQhmfLP.js → brief-595xDzzA.js} +1 -1
  25. package/assets/brief-BbyFi6I8.js +1 -0
  26. package/assets/{browser-ponyfill-Dth-IE_T.js → browser-ponyfill-jFT5NuxN.js} +1 -1
  27. package/assets/{bug-CDavBQtl.js → bug-CODF1l-i.js} +1 -1
  28. package/assets/{circle-check-rylkL795.js → circle-check-YndyKtr4.js} +1 -1
  29. package/assets/{circle-check-big-CBG0107E.js → circle-check-big-K3iakyF_.js} +1 -1
  30. package/assets/{circle-help-aRUYdfvH.js → circle-help-4plHPqfw.js} +1 -1
  31. package/assets/{clock-tsMaR7Oh.js → clock-DfsuMtxB.js} +1 -1
  32. package/assets/{confirm-dialog-C2G4kIKu.js → confirm-dialog-UADneuFw.js} +1 -1
  33. package/assets/{download-CdBITb1R.js → download-Biicok59.js} +1 -1
  34. package/assets/filters-B8KIBaJt.js +1 -0
  35. package/assets/flagged-BETBvXmG.js +1 -0
  36. package/assets/{flagged-BkzKKM9G.js → flagged-Bv3b1jp7.js} +1 -1
  37. package/assets/{folders-qdT9HdHz.js → folders-7yJavcsY.js} +1 -1
  38. package/assets/index-BTtX9VN6.js +1 -0
  39. package/assets/index-BVX3cLFd.js +1 -0
  40. package/assets/index-CJ0WHc7V.js +1 -0
  41. package/assets/index-Cnkc1wMO.js +1 -0
  42. package/assets/{index-CoNvZIm_.js → index-DEg5iEg8.js} +60 -60
  43. package/assets/index-DfWcvGO-.js +1 -0
  44. package/assets/{index-B5g0rcGz.css → index-DivxHcM7.css} +1 -1
  45. package/assets/index-DvlFY9o3.js +1 -0
  46. package/assets/index-O2feOV1N.js +1 -0
  47. package/assets/index-nBb9peDI.js +1 -0
  48. package/assets/{kbd-37YHrOod.js → kbd-qEVHeb9_.js} +1 -1
  49. package/assets/{labels-Dz8ChP9r.js → labels-BQQvsl-D.js} +1 -1
  50. package/assets/mail-Dq1V1PeL.js +1 -0
  51. package/assets/{menu-B6RXxSm8.js → menu-3tmv8rnN.js} +1 -1
  52. package/assets/{move-options-BHPhC1Kk.js → move-options-CFt8tu_e.js} +1 -1
  53. package/assets/{nav-link-7QYETm4r.js → nav-link-DLagJK45.js} +1 -1
  54. package/assets/{onboarding-DZlyKY0e.js → onboarding-CZwCP-nV.js} +1 -1
  55. package/assets/outbox-prd9xdB-.js +1 -0
  56. package/assets/{pencil-DUvdHUlD.js → pencil-8uBVwe4Q.js} +1 -1
  57. package/assets/{rich-text-DYkgFghh.js → rich-text-LXDUxzYy.js} +3 -3
  58. package/assets/rich-text-spellcheck-worker-provider-CMlxVud3.js +1 -0
  59. package/assets/{rotate-ccw-BozetpiQ.js → rotate-ccw-BHoXW6hX.js} +1 -1
  60. package/assets/{row-actions-DzYchsTL.js → row-actions-76lcvueG.js} +1 -1
  61. package/assets/{search-scope-DpxLT3gw.js → search-scope-CA_aogbp.js} +1 -1
  62. package/assets/search-token-index-CpRlEuF6.js +1 -0
  63. package/assets/{search-view-DBvRPRa1.js → search-view-C41e5831.js} +1 -1
  64. package/assets/{senders-BhtoX47B.js → senders-B1lwqMMC.js} +1 -1
  65. package/assets/{settings-screen-QrhNeHVs.js → settings-screen-CFTBAmuI.js} +1 -1
  66. package/assets/settings-zSKN6k1H.js +1 -0
  67. package/assets/{shield-check-XKwP5L-S.js → shield-check-Dotwirm-.js} +1 -1
  68. package/assets/{suggested-vips-B2_DnQVw.js → suggested-vips-CclCHgpv.js} +1 -1
  69. package/assets/use-match-media-Zexb3l8o.js +1 -0
  70. package/assets/{useDebouncedValue-CDnuOkob.js → useDebouncedValue-BaEIknbc.js} +1 -1
  71. package/assets/useFilters-D0QjQ-gI.js +1 -0
  72. package/assets/{useLabels-Dxb6ajq-.js → useLabels-Ko8K1hA6.js} +1 -1
  73. package/assets/{useRefreshControl-DlypbbhJ.js → useRefreshControl-B7OevCbf.js} +1 -1
  74. package/assets/{useSearchMirror-eiX731bE.js → useSearchMirror-CHzlKiiz.js} +1 -1
  75. package/assets/useSearchTokenContext-BUweVJYK.js +84 -0
  76. package/assets/{useSemanticSearch-Dn1P2d8-.js → useSemanticSearch-cE8OBKU2.js} +1 -1
  77. package/assets/{useSignature-DIdZs8UQ.js → useSignature-nBcCgOlO.js} +1 -1
  78. package/index.html +2 -2
  79. package/package.json +1 -1
  80. package/assets/MailListHeader-CsMXujM8.js +0 -52
  81. package/assets/MailboxPane-DkPAPzBT.js +0 -1
  82. package/assets/_mailboxId-BseanUYV.js +0 -1
  83. package/assets/_messageId-BDqdIyPR.js +0 -1
  84. package/assets/_messageId-DUX8pRMi.js +0 -1
  85. package/assets/_messageId-DaIDf_Wh.js +0 -1
  86. package/assets/_outboxMessageId-Vm0R3pBD.js +0 -1
  87. package/assets/_threadId-BjK4yKxL.js +0 -1
  88. package/assets/_threadId-D0JNHKu7.js +0 -1
  89. package/assets/_threadId-D5xYU6At.js +0 -1
  90. package/assets/accounts-Cs4TZIog.js +0 -1
  91. package/assets/brief-CpdHVxqD.js +0 -1
  92. package/assets/filters-DZsPSqyt.js +0 -1
  93. package/assets/flagged-DW5dkEVI.js +0 -1
  94. package/assets/index-BDqdIyPR.js +0 -1
  95. package/assets/index-BfDh6SQq.js +0 -1
  96. package/assets/index-C7HIuKEc.js +0 -1
  97. package/assets/index-ChQ-GJlE.js +0 -1
  98. package/assets/index-DBQOX_n6.js +0 -1
  99. package/assets/index-DaIDf_Wh.js +0 -1
  100. package/assets/index-bfL1KkHk.js +0 -1
  101. package/assets/index-xIZcq_pa.js +0 -1
  102. package/assets/layout-breakpoints-BWjiUQKh.js +0 -1
  103. package/assets/mail-CcVoV5W-.js +0 -1
  104. package/assets/outbox-H1kfEi9p.js +0 -1
  105. package/assets/rich-text-spellcheck-worker-provider-YYonaQ2v.js +0 -1
  106. package/assets/search-token-index-e3fTB436.js +0 -1
  107. package/assets/settings-C1W1bpOs.js +0 -1
  108. package/assets/use-match-media-BezqzsJW.js +0 -1
  109. package/assets/useFilters-BBQH0MKH.js +0 -1
  110. package/assets/useSearchTokenContext-BnSrnFlb.js +0 -67
@@ -1 +0,0 @@
1
- import{j as r,bf as Rs,aA as _t,B as fe,S as Es,b as Be,aB as Xt,r as l,C as Os,d as As,b0 as Ns,k as vt,x as tt,Z as Zt,X as zs,p as st,s as Lt,y as Ds,af as Pt,bg as es,bh as ts,I as Fs,h as _s,T as Ls,bi as Ps,bj as $s,bk as Bs,ad as ss,aN as Ws,aO as Ks,K as Vs,g as qs,a2 as $t,bl as Hs,Q as Us,w as Qs,bm as Js,o as ns,bn as Gs,H as Ys,ag as Xs,i as Zs,bo as en,b5 as tn}from"./index-CoNvZIm_.js";import{u as sn,p as nn,R as on}from"./useSearchTokenContext-BnSrnFlb.js";import{u as rn,a as an,R as ln}from"./useRefreshControl-DlypbbhJ.js";import{C as os,D as Pe,a as is,b as rs,c as as,j as cn,M as dn,t as ls,d as un,e as hn,f as cs,g as ds,h as fn,i as mn,k as gn,l as pn,m as qt,n as xn,o as bn,p as vn,q as Sn,r as yn,S as Cn,s as In,v as wn,w as jn,x as us,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 Fn,L as Ht,N as Ut,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 Un,_ as hs,$ as fs,a0 as Bt,a1 as Qn,a2 as ms,a3 as Jn,a4 as Gn}from"./MailListHeader-CsMXujM8.js";import{S as Yn,M as Xn,a as Zn,u as eo,b as to}from"./MailViewChrome-7pIGoTSB.js";import{E as gs,f as so}from"./ErrorState-EG2eHLL1.js";import{d as ps}from"./useFilters-BBQH0MKH.js";import{C as xs}from"./confirm-dialog-C2G4kIKu.js";import{A as Wt}from"./avatar-BpcGfGBY.js";import{b as nt,c as no,d as oo}from"./format-De9HZKjg.js";import{N as io}from"./NavMenuButton-DiNk3STC.js";import{a as ro}from"./useLabels-Dxb6ajq-.js";import{L as ao,u as lo}from"./useSemanticSearch-Dn1P2d8-.js";import{D as co}from"./layout-breakpoints-BWjiUQKh.js";import{u as uo}from"./use-match-media-BezqzsJW.js";import{S as St}from"./shield-check-XKwP5L-S.js";import{B as ho}from"./bottom-sheet-Bb9_P1q_.js";import{C as fo}from"./circle-help-aRUYdfvH.js";import{C as mo}from"./circle-check-rylkL795.js";import{a as go,b as po,f as xo}from"./move-options-BHPhC1Kk.js";import{d as bs,h as bo,j as vo,e as So}from"./search-token-index-e3fTB436.js";import{M as yo}from"./enums-CCxx0t2v.js";import{r as Co}from"./intelligence-pref-C6lFpj6U.js";import{n as Io}from"./search-query-Cr_ZXBCp.js";const wo=({children:e,onRefresh:n,isRefreshing:t})=>uo(co)?e:r.jsx(Rs,{onRefresh:n,isPullable:!t,children:e}),jo=e=>e===1?"message":"messages";function ko({count:e,onReview:n,onDismiss:t,actionLabel:s="Review & rescue"}){return r.jsx(_t,{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(St,{className:"mt-0.5 size-4 shrink-0 text-positive","aria-hidden":!0}),r.jsxs("span",{children:[r.jsx("span",{className:"font-semibold text-fg",children:`${e} ${jo(e)} here`})," ","may not be spam — they're from senders we can verify."]})]}),r.jsx(fe,{variant:"primary",size:"sm",onClick:n,className:"self-start",children:s})]})})}const Mo=(e,n)=>e==="vip"?"vip":e==="unknown"&&n==="md"?"unknown-pill":"hidden",vs=({senderTrust:e,size:n="sm",className:t})=>{const s=Mo(e,n);return s==="vip"?r.jsx(Es,{className:Be("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:Be("inline-flex items-center rounded border border-dashed border-fg-subtle/40 font-medium uppercase tracking-wide text-fg-muted/80 shrink-0","px-2 py-0.5 text-xs",t),title:"First message from this sender","aria-label":"First message from this sender","data-testid":"sender-trust-unknown",children:"new"}):null};function To({candidate:e,selected:n,onToggle:t,hideSender:s=!1}){const{senderName:o,senderAddress:i,subject:c,snippet:a,trustReason:d,trustSubReason:u,senderTrust:f}=e;return r.jsxs("label",{className:Be("flex w-full cursor-pointer items-start gap-3 px-3 py-2.5 text-left transition-colors",s&&"pl-11",n?"bg-positive/10":"bg-surface hover:bg-surface-sunken"),children:[r.jsx(os,{className:"mt-0.5",checked:n,onChange:t,"aria-label":`${n?"Deselect":"Select"} ${s?c:`message from ${o}`}`}),!s&&r.jsx(Wt,{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(vs,{senderTrust:f,size:"sm"}),r.jsx("span",{className:"truncate text-2xs text-fg-subtle",children:i})]}),r.jsx("span",{className:"block truncate text-sm text-fg-muted",children:c}),r.jsx("span",{className:"block line-clamp-1 text-xs text-fg-subtle",children:a}),!s&&r.jsxs("span",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[r.jsxs(Xt,{tone:"positive",children:[r.jsx(St,{className:"size-3","aria-hidden":!0}),d]}),r.jsx("span",{className:"text-2xs text-fg-subtle",children:u})]})]})]})}const Ro=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)},Eo=(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 Oo({group:e,selected:n,onToggleGroup:t,onToggleMessage:s}){const[o,i]=l.useState(!1),c=Eo(e,n),a=e.messages.length,d=o?Os:As;return r.jsxs("div",{className:Be(c!=="none"?"bg-positive/10":"bg-surface"),children:[r.jsxs("div",{className:"flex w-full items-start gap-3 px-3 py-2.5",children:[r.jsx(os,{className:"mt-0.5",checked:c==="all",indeterminate:c==="some",onChange:()=>t(e,c!=="all"),"aria-label":`${c==="all"?"Deselect":"Select"} all ${a} ${Qt(a)} from ${e.senderName}`}),r.jsx(Wt,{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(vs,{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(Xt,{tone:"positive",children:[r.jsx(St,{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(u=>!u),"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(d,{className:"size-3.5","aria-hidden":!0})]})]}),o&&r.jsx("div",{className:"divide-y divide-line border-t border-line",children:e.messages.map(u=>r.jsx(To,{candidate:u,selected:n.has(u.id),onToggle:()=>s(u.id),hideSender:!0},u.id))})]})}const Kt=e=>e===1?"message":"messages",Ao=(e,n)=>`Moves ${e===1?"this message":`these ${e} ${Kt(e)}`} out of Spam to ${n} now. Nothing later.`,Ft=(e,n)=>e.find(t=>t.id===n)?.label??"Inbox";function No(){return r.jsx(_t,{tone:"info",variant:"soft",children:r.jsx("p",{className:"text-2xs text-fg-muted",children:"We list a message here only when we can confirm the sender is who they say — usually someone you've emailed before, write to often, or a service that consistently checks out. We never guess from words in the subject. Anything we can't confirm stays in Spam."})})}function zo({candidates:e,selected:n,onToggle:t,onToggleGroup:s,onSelectAll:o,onSelectNone:i,onContinue:c,onCancel:a}){const[d,u]=l.useState(!1),f=n.size,g=l.useMemo(()=>Ro(e),[e]);return r.jsxs("div",{className:"flex min-h-0 flex-col",children:[r.jsxs("div",{className:"px-row-inset pb-2 pt-1",children:[r.jsxs("div",{className:"flex items-start justify-between gap-2",children:[r.jsxs("h2",{className:"flex items-center gap-2 text-sm font-semibold text-fg",children:[r.jsx(St,{className:"size-4 text-positive","aria-hidden":!0}),"Rescue from Spam"]}),r.jsx(fe,{variant:"ghost",size:"sm",icon:r.jsx(fo,{className:"size-3.5"}),onClick:()=>u(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."}),d&&r.jsx("div",{className:"mt-2",children:r.jsx(No,{})})]}),r.jsxs("div",{className:"flex items-center justify-between px-row-inset pb-1.5",children:[r.jsx("span",{className:"text-2xs font-medium text-fg-muted",children:`${f} of ${e.length} selected · ${g.length} ${g.length===1?"sender":"senders"}`}),r.jsxs("span",{className:"flex gap-1",children:[r.jsx(fe,{variant:"ghost",size:"sm",onClick:o,children:"Select all"}),r.jsx(fe,{variant:"ghost",size:"sm",onClick:i,children:"Select none"})]})]}),r.jsx("div",{className:"min-h-0 flex-1 divide-y divide-line overflow-y-auto border-y border-line",children:g.map(m=>r.jsx(Oo,{group:m,selected:n,onToggleGroup: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(fe,{variant:"primary",onClick:c,className:"h-11 w-full font-semibold",children:`Continue with ${f} ${Kt(f)}`}),r.jsx(fe,{variant:"ghost",onClick:a,className:"h-11 w-full",children:"Cancel"})]})]})}function Do({count:e,folders:n,delimiter:t,destination:s,onPick:o,onMove:i,onBack:c}){const[a,d]=l.useState(!1);return r.jsxs("div",{className:"flex min-h-0 flex-col",children:[r.jsxs("div",{className:"px-row-inset pb-2 pt-1",children:[r.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Where should they go?"}),r.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:"Pick a folder, then we move them out of Spam."})]}),r.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-y-auto px-row-inset py-2",children:a?r.jsx("div",{className:"flex min-h-0 flex-1 overflow-hidden rounded-xl border border-line bg-surface",children:r.jsx(Ns,{folders:n,selectedId:s,delimiter:t,onSelect:o,onCancel:()=>d(!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:Ft(n,s)}),r.jsx(fe,{variant:"ghost",size:"sm",onClick:()=>d(!0),className:"mt-2 px-0",children:"Move to a different folder"})]})}),r.jsxs("div",{className:"space-y-2 border-t border-line bg-surface px-row-inset py-3",children:[r.jsx("p",{className:"text-2xs text-fg-subtle",children:Ao(e,Ft(n,s))}),r.jsx(fe,{variant:"primary",onClick:i,className:"h-11 w-full font-semibold",children:`Move ${e} out of Spam`}),r.jsx(fe,{variant:"ghost",onClick:c,className:"h-11 w-full",children:"Back"})]})]})}function Fo({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(mo,{className:"size-10 text-positive","aria-hidden":!0}),r.jsx("p",{className:"text-base font-semibold text-fg",children:`Moved ${e} ${Kt(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(fe,{variant:"primary",onClick:t,className:"h-11 w-full font-semibold",children:"Done"})})]})}function _o({open:e,candidates:n,defaultDestinationId:t,availableFolders:s,delimiter:o,onConfirmMove:i,onCancel:c}){const[a,d]=l.useState("review"),[u,f]=l.useState(()=>e?new Set(n.map(I=>I.id)):new Set),[g,m]=l.useState(t),[S,C]=l.useState(0),j=l.useRef(!1);l.useEffect(()=>{e&&!j.current&&(d("review"),f(new Set(n.map(I=>I.id))),m(t),C(0)),j.current=e},[e,n,t]);const T=u.size,x=I=>{f(k=>{const R=new Set(k);return R.has(I)?R.delete(I):R.add(I),R})},b=(I,k)=>{f(R=>{const E=new Set(R);for(const _ of I.messages)k?E.add(_.id):E.delete(_.id);return E})},y=()=>{const I=Array.from(u);C(I.length),i(I,g),d("done")};return r.jsxs(ho,{open:e,onClose:c,dismissLabel:"Close rescue",children:[a==="review"&&r.jsx(zo,{candidates:n,selected:u,onToggle:x,onToggleGroup:b,onSelectAll:()=>f(new Set(n.map(I=>I.id))),onSelectNone:()=>f(new Set),onContinue:()=>d("destination"),onCancel:c}),a==="destination"&&r.jsx(Do,{count:T,folders:s,delimiter:o,destination:g,onPick:m,onMove:y,onBack:()=>d("review")}),a==="done"&&r.jsx(Fo,{count:S,destinationLabel:Ft(s,g),onClose:c})]})}const Lo={reply:"Reply",reply_all:"Reply All",forward:"Forward",new:"New Message"},Po=()=>{const e=l.useRef(!1);return l.useCallback(()=>{const 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},[])},$o=()=>{const{state:e,closeCompose:n}=vt(),t=Po(),[s,o]=l.useState(!1),{isError:i,error:c,refetch:a}=tt({...Zt(),staleTime:1/0}),d=l.useCallback(m=>{m||(t()?o(!0):n())},[n,t]),u=l.useCallback(()=>{o(!1),n()},[n]),f=l.useCallback(()=>{o(!1)},[]);if(!e.isOpen)return null;const g=Lo[e.mode]??"New Message";return r.jsxs(Pe.Root,{open:e.isOpen,onOpenChange:d,children:[r.jsxs(Pe.Portal,{children:[r.jsx(Pe.Overlay,{className:"fixed inset-0 z-40 bg-black/40"}),r.jsxs(Pe.Content,{className:"fixed inset-x-0 bottom-0 z-50 flex flex-col rounded-t-lg bg-canvas pb-[env(safe-area-inset-bottom,0px)]",style:{height:"95dvh"},children:[r.jsx(Pe.Handle,{className:"mx-auto mt-2 mb-1 h-1.5 w-12 rounded-full bg-fg-muted/30"}),r.jsx(Pe.Title,{className:"px-4 py-2 text-base font-semibold border-b border-line",children:g}),i?r.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:r.jsx(gs,{title:"Couldn't load compose",error:c,onRetry:()=>{a()}})}):r.jsx("div",{className:"flex-1 overflow-hidden",children:r.jsx(is,{mode:e.mode,account:e.account,sourceMessage:e.sourceMessage,onClose:n})})]})]}),r.jsx(xs,{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:u,onCancel:f})]})},Bo={reply:"Reply",reply_all:"Reply All",forward:"Forward",new:"New Message"},Ss=()=>{const{state:e,closeCompose:n}=vt(),t=ps(),{isError:s,error:o,refetch:i}=tt({...Zt(),staleTime:1/0});if(!t)return r.jsx($o,{});if(!e.isOpen)return null;const c=Bo[e.mode]??"New Message",a=r.jsxs("header",{className:"flex items-center justify-between gap-2 px-4 py-3 border-b border-line shrink-0",children:[r.jsx("div",{className:"flex items-center gap-2 min-w-0",children:r.jsx("h2",{className:"text-lg font-semibold truncate",children:c})}),r.jsx("button",{type:"button",onClick:n,className:"p-2 rounded-md hover:bg-surface-raised transition-colors min-h-11 min-w-11 inline-flex items-center justify-center","aria-label":"Close",children:r.jsx(zs,{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(gs,{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(is,{mode:e.mode,account:e.account,sourceMessage:e.sourceMessage,onClose:n},e.outboxMessageId??"new")})]})};function Wo(e){const n=e.toAddresses.join(", ");return{id:e.outboxMessageId,accountId:e.accountId,fromName:e.fromName??e.fromAddress??"Me",fromEmail:e.fromAddress??"",subject:e.subject??"(No subject)",snippet:n?`To: ${n}`:"(No recipients)",timeLabel:nt(e.updatedAt),isRead:!0}}function Ko(e){return{id:e.messageId,accountId:e.accountId,fromName:e.fromName??e.fromEmail??"Unknown",fromEmail:e.fromEmail??"",subject:e.subject??"(No subject)",snippet:e.snippet??"",timeLabel:nt(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0}}function Vo({outboxMessages:e,accountId:n,imapThreads:t}){const s=e.filter(c=>c.status==="draft"&&c.accountId===n).map(Wo),o=t.map(Ko),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 qo=({label:e,count:n})=>r.jsxs("div",{className:"sticky top-0 z-10 flex items-baseline justify-between border-b border-line bg-surface-sunken px-row-inset py-1",children:[r.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:e}),r.jsx("span",{className:"text-2xs text-fg-subtle tabular-nums",children:n})]}),Ho=({row:e,isSelected:n,onOpen:t,onDelete:s,isDeleting:o})=>r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:Be("group",as({active:n})),children:[r.jsx(_s,{className:"size-7 shrink-0 text-fg-muted mt-0.5"}),r.jsx(rs,{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(Ls,{className:"size-3.5"})})})]}),Uo=({row:e,isSelected:n,onOpen:t})=>{const s=!e.isRead;return r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:Be("group",as({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(Wt,{name:e.fromName,email:e.fromEmail,size:"sm"}),r.jsx(rs,{thread:e})]})};function Qo({mailboxId:e,accountId:n,selectedMessageId:t,imapThreads:s,title:o,unreadCount:i}){const{openCompose:c,state:a}=vt(),d=st(),u=Lt(),{data:f}=tt(Ds()),g=l.useMemo(()=>Vo({outboxMessages:f?.items??[],accountId:n,imapThreads:s}),[f?.items,n,s]),m=Pt({...ts(),onSuccess:()=>{u.invalidateQueries({queryKey:es()})}}),S=x=>{m.mutate({path:{outboxMessageId:x}})},C=x=>{c({mode:"new",outboxMessageId:x})},j=x=>{const b=s.find(y=>y.messageId===x)?.threadId;b&&d({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:e,threadId:b,messageId:x},search:y=>y})},T=g.length===0;return r.jsxs("section",{className:"flex h-full w-full flex-col bg-surface",children:[r.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[r.jsx(io,{}),r.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:o}),(i??0)>0&&r.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:[i," unread"]})]}),r.jsx("div",{className:"flex-1 overflow-y-auto",children:T?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 text-center px-4",children:[r.jsx(Fs,{className:"size-8 text-fg-subtle"}),r.jsx("p",{className:"text-sm font-medium text-fg",children:"No drafts"}),r.jsx("p",{className:"text-xs text-fg-subtle",children:"Messages you start composing will appear here."})]}):g.map(x=>r.jsxs("div",{children:[x.label&&r.jsx(qo,{label:x.label,count:x.threads.length}),r.jsx("div",{className:"divide-y divide-line",children:x.threads.map(b=>x.id==="remit-drafts"?r.jsx(Ho,{row:b,isSelected:a.isOpen&&b.id===a.outboxMessageId,onOpen:C,onDelete:S,isDeleting:m.isPending},b.id):r.jsx(Uo,{row:b,isSelected:b.id===t,onOpen:j},b.id))})]},x.id))})]})}function Jo(e,n,t){const s=new Array(e);return new Proxy(s,{get(o,i,c){if(typeof i=="string"){const a=i.charCodeAt(0);if(a>=48&&a<=57){const d=+i;if(Number.isInteger(d)&&d>=0&&d<e){let u=o[d];if(!u){const f=n[d*2];u=o[d]={index:d,key:t(d),start:f,size:n[d*2+1],end:f+n[d*2+1],lane:0}}return u}}if(i==="length")return e}return Reflect.get(o,i,c)}})}function $e(e,n,t){let s=t.initialDeps??[],o,i=!0;function c(){const a=e();return(a.length!==s.length||a.some((u,f)=>s[f]!==u))&&(s=a,o=n(...a),t?.onChange&&!(i&&t.skipInitialOnChange)&&t.onChange(o),i=!1),o}return c.updateDeps=a=>{s=a},c}function Jt(e,n){if(e===void 0)throw new Error("Unexpected undefined");return e}const Go=(e,n)=>Math.abs(e-n)<1.01,Yo=(e,n,t)=>{let s;return function(...o){e.clearTimeout(s),s=e.setTimeout(()=>n.apply(this,o),t)}};let et;const zt=()=>{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},Gt=e=>{const{offsetWidth:n,offsetHeight:t}=e;return{width:n,height:t}},Xo=e=>e,Zo=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},ei=(e,n)=>{const t=e.scrollElement;if(!t)return;const s=e.targetWindow;if(!s)return;const o=c=>{const{width:a,height:d}=c;n({width:Math.round(a),height:Math.round(d)})};if(o(Gt(t)),!s.ResizeObserver)return()=>{};const i=new s.ResizeObserver(c=>{const a=()=>{const d=c[0];if(d?.borderBoxSize){const u=d.borderBoxSize[0];if(u){o({width:u.inlineSize,height:u.blockSize});return}}o(Gt(t))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return i.observe(t,{box:"border-box"}),()=>{i.unobserve(t)}},bt={passive:!0},ti=typeof window>"u"?!0:"onscrollend"in window,si=(e,n,t)=>{const s=e.scrollElement;if(!s)return;const o=e.targetWindow;if(!o)return;const i=e.options.useScrollendEvent&&ti;let c=0;const a=i?null:Yo(o,()=>n(c,!1),e.options.isScrollingResetDelay),d=g=>()=>{c=t(s),a?.(),n(c,g)},u=d(!0),f=d(!1);return s.addEventListener("scroll",u,bt),i&&s.addEventListener("scrollend",f,bt),()=>{s.removeEventListener("scroll",u),i&&s.removeEventListener("scrollend",f)}},ni=(e,n)=>si(e,n,t=>{const{horizontal:s,isRtl:o}=e.options;return s?t.scrollLeft*(o&&-1||1):t.scrollTop}),oi=(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"]},ii=(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})},ri=ii;class ai{constructor(n){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var 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 c=()=>{const a=i.target,d=this.indexFromElement(a);if(!a.isConnected){this.observer.unobserve(a);for(const[u,f]of this.elementsCache)if(f===a){this.elementsCache.delete(u);break}return}this.shouldMeasureDuringScroll(d)&&this.resizeItem(d,this.options.measureElement(a,i,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(c):c()})}));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:Xo,rangeExtractor:Zo,onChange:()=>{},measureElement:oi,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const m in t){const S=t[m];S!==void 0&&(i[m]=S)}const c=this.options;let a=null,d=null,u=!1;if(c!==void 0&&c.enabled&&i.enabled&&i.anchorTo==="end"&&this.scrollElement!==null){const m=c.count,S=i.count,C=this.getMeasurements(),j=m>0?((s=C[0])==null?void 0:s.key)??c.getItemKey(0):null,T=m>0?((o=C[m-1])==null?void 0:o.key)??c.getItemKey(m-1):null;if(S!==m||m>0&&S>0&&(i.getItemKey(0)!==j||i.getItemKey(S-1)!==T)){u=!0;const y=m>0?this.getVirtualItemForOffset(this.getScrollOffset())??C[0]:null;y&&(a=[y.key,this.getScrollOffset()-y.start]);const I=i.followOnAppend===!0?"auto":i.followOnAppend||null;I&&S>m&&this.isAtEnd(c.scrollEndThreshold)&&(m===0||i.getItemKey(S-1)!==T)&&(d=I)}}this.options=i,u&&(this.pendingMin=0,this.itemSizeCacheVersion++);let f=!1,g=0;if(a&&this.scrollOffset!==null){const[m,S]=a,C=this.getMeasurements(),{count:j,getItemKey:T}=this.options;let x=0;for(;x<j&&T(x)!==m;)x++;if(x<j){const b=C[x];if(b){const y=b.start+S;y!==this.scrollOffset&&(g=y-this.scrollOffset,this.scrollOffset=y,f=!0)}}}(f||d)&&(this.pendingScrollAnchor=[f?a[0]:null,f?a[1]:0,d,g])},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,c)=>{if(c&&this._intendedScrollOffset===null&&i===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(i-this._intendedScrollOffset)<1.5&&(i=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;const a=this.getScrollOffset();this.scrollDirection=c?a===i?this.scrollDirection:a<i?"forward":"backward":null,this.scrollOffset=i,this.isScrolling=c,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const i=this.scrollElement,c=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},a=()=>{this._iosTouching=!1,!(!zt()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};i.addEventListener("touchstart",c,bt),i.addEventListener("touchend",a,bt),this.unsubs.push(()=>{i.removeEventListener("touchstart",c),i.removeEventListener("touchend",a),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const o=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,o&&this.scrollElement&&this.options.enabled){const[i,c,a,d]=o;i!==null&&!a&&(zt()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?d!==0&&(this._iosDeferredAdjustment+=d):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,c,a,d,u)=>(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:c,lanes:a,laneAssignmentMode:d,gap:u}),{key:!1}),this.getMeasurements=$e(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:t,paddingStart:s,scrollMargin:o,getItemKey:i,enabled:c,lanes:a,laneAssignmentMode:d,gap:u},f)=>{const g=this.itemSizeCache;if(!c)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 k=new Float64Array(x);b&&m>0&&k.set(b.subarray(0,m*2)),b=k,this._flatMeasurements=b}let y;if(m===0)y=s+o;else{const k=m-1;y=b[k*2]+b[k*2+1]+u}for(let k=m;k<t;k++){const R=i(k),E=g.get(R),_=typeof E=="number"?E:this.options.estimateSize(k);b[k*2]=y,b[k*2+1]=_,y+=_+u}const I=Jo(t,b,i);return this.measurementsCache=I,I}const S=this.measurementsCache.slice(0,m),C=new Array(a).fill(void 0),j=new Float64Array(a);let T=0;for(let x=0;x<m;x++){const b=S[x];b&&(C[b.lane]===void 0&&T++,C[b.lane]=x,j[b.lane]=b.end)}for(let x=m;x<t;x++){const b=i(x),y=this.laneAssignments.get(x);let I,k;const R=d==="estimate"||g.has(b);if(y!==void 0&&this.options.lanes>1){I=y;const W=C[I],$=W!==void 0?S[W]:void 0;k=$?$.end+u:s+o}else if(T===a){let W=0,$=j[0],N=C[0];for(let K=1;K<a;K++){const se=j[K];(se<$||se===$&&C[K]<N)&&(W=K,$=se,N=C[K])}I=W,k=$+u,R&&this.laneAssignments.set(x,I)}else I=x%this.options.lanes,k=s+o,R&&this.laneAssignments.set(x,I);const E=g.get(b),_=typeof E=="number"?E:this.options.estimateSize(x),D=k+_;S[x]={index:x,start:k,size:_,end:D,key:b,lane:I},C[I]===void 0&&T++,C[I]=x,j[I]=D}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=ci(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,c)=>i===null||c===null?[]:t({startIndex:i,endIndex:c,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)),c=Math.max(0,o-i),a=Math.min(this.options.count-1,o+i);return t>=c&&t<=a}return!0},this.measureElement=t=>{if(!t){this.elementsCache.forEach((c,a)=>{c.isConnected||(this.observer.unobserve(c),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 c,a,d;const u=this._flatMeasurements;if(this.options.lanes===1&&u!==null)d=this.options.getItemKey(t),a=u[t*2],c=u[t*2+1];else{const m=this.measurementsCache[t];if(!m)return;d=m.key,a=m.start,c=m.size}const f=this.itemSizeCache.get(d)??c,g=s-f;if(g!==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,C=((i=this.scrollState)==null?void 0:i.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[t]??{index:t,key:d,start:a,size:c,end:a+c,lane:0},g,this):a<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(d)||this.scrollDirection!=="backward"));(this.pendingMin===null||t<this.pendingMin)&&(this.pendingMin=t),this.itemSizeCache.set(d,s),this.itemSizeCacheVersion++,m?this.applyScrollAdjustment(this.getTotalSize()-S):C&&this.applyScrollAdjustment(g),this.notify(!1)}},this.getVirtualItems=$e(()=>[this.getVirtualIndexes(),this.getMeasurements()],(t,s)=>{const o=[];for(let i=0,c=t.length;i<c;i++){const a=t[i],d=s[a];o.push(d)}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,c=ys(0,s.length-1,i?a=>o[a*2]:a=>Jt(s[a]).start,t);return Jt(s[c])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const 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(),c=this.getScrollOffset();s==="auto"&&(s=t>=c+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(),c=this.measurementsCache[t];if(!c)return;if(s==="auto")if(c.end>=i+o-this.options.scrollPaddingEnd)s="end";else if(c.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"?c.end+this.options.scrollPaddingEnd:c.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,s,c.size),s]},this.scrollToOffset=(t,{align:s="start",behavior:o="auto"}={})=>{const i=this.getOffsetForAlignment(t,s),c=this.now();this.scrollState={index:null,align:s,behavior:o,startedAt:c,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[c,a]=i,d=this.now();this.scrollState={index:t,align:a,behavior:o,startedAt:d,lastTargetOffset:c,stableFrames:0},this._scrollToOffset(c,{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,c=this._flatMeasurements;c!=null?o=c[i*2]+c[i*2+1]:o=((t=s[i])==null?void 0:t.end)??0}else{const i=Array(this.options.lanes).fill(null);let c=s.length-1;for(;c>=0&&i.some(a=>a===null);){const a=s[c];i[a.lane]===null&&(i[a.lane]=a.end),c--}o=Math.max(...i.filter(a=>a!==null))}return Math.max(o-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const 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&&(zt()&&(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,c=o!==this.scrollState.lastTargetOffset;if(!c&&Go(o,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=i){this.getScrollOffset()!==o&&this._scrollToOffset(o,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,c){const a=this.getSize()||600,d=Math.abs(o-this.getScrollOffset()),u=this.scrollState.behavior==="smooth"&&d>a;this.scrollState.lastTargetOffset=o,u||(this.scrollState.behavior="auto"),this._scrollToOffset(o,{adjustments:void 0,behavior:u?"smooth":"auto"})}this.scheduleScrollReconcile()}}const ys=(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 li(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 ci(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 u=li(o,i,t);let f=u;const g=t+n;for(;f<i&&o[f*2]+o[f*2+1]<g;)f++;return{startIndex:u,endIndex:f}}let a=ys(0,i,u=>e[u].start,t),d=a;if(s===1)for(;d<i&&e[d].end<t+n;)d++;else if(s>1){const u=Array(s).fill(0);for(;d<i&&u.some(g=>g<t+n);){const g=e[d];u[g.lane]=g.end,d++}const f=Array(s).fill(t+n);for(;a>=0&&f.some(g=>g>=t);){const g=e[a];f[g.lane]=g.start,a--}a=Math.max(0,a-a%s),d=Math.min(i,d+(s-1-d%s))}return{startIndex:a,endIndex:d}}const Dt=typeof document<"u"?l.useLayoutEffect:l.useEffect;function di({useFlushSync:e=!0,directDomUpdates:n=!1,directDomUpdatesMode:t="transform",...s}){const o=l.useReducer(u=>u+1,0)[1],i=l.useRef({enabled:n,mode:t,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});i.current.enabled=n,i.current.mode=t;const c=u=>{const f=i.current;if(!f.enabled||!f.container)return;const g=u.getTotalSize();if(g!==f.lastSize){f.lastSize=g;const x=u.options.horizontal?"width":"height";f.container.style[x]=`${g}px`}const m=!!u.options.horizontal,S=f.mode==="transform",C=m?"left":"top",j=u.options.scrollMargin,T=u.getVirtualItems();for(const x of T){const b=x.start-j,y=u.elementsCache.get(x.key);y&&f.lastPositions.get(y)!==b&&(f.lastPositions.set(y,b),S?y.style.transform=m?`translate3d(${b}px, 0, 0)`:`translate3d(0, ${b}px, 0)`:y.style[C]=`${b}px`)}},a={...s,onChange:(u,f)=>{var g;const m=i.current;let S=!0;if(m.enabled){c(u);const C=u.range,j=m.prevRange;S=!j||j.isScrolling!==u.isScrolling||j.startIndex!==C?.startIndex||j.endIndex!==C?.endIndex,S&&(m.prevRange=C?{startIndex:C.startIndex,endIndex:C.endIndex,isScrolling:u.isScrolling}:null)}S&&(e&&f?Ps.flushSync(o):o()),(g=s.onChange)==null||g.call(s,u,f)}},[d]=l.useState(()=>{const u=new ai(a);return Object.assign(u,{containerRef:f=>{const g=i.current;if(g.container=f,g.lastSize=null,f&&g.enabled){const m=u.getTotalSize();g.lastSize=m;const S=u.options.horizontal?"width":"height";f.style[S]=`${m}px`}}})});return d.setOptions(a),Dt(()=>d._didMount(),[]),Dt(()=>d._willUpdate()),Dt(()=>{c(d)}),d}function ui(e){return di({observeElementRect:ei,observeElementOffset:ni,scrollToFn:ri,...e})}const Vt=e=>e.query?`matching "${e.query}"`:e.from?`from "${e.from}"`:"matching your search",hi=e=>`Select all ${Vt(e)}`,fi=(e,n)=>`All ${no(n)} ${Vt(e)} selected`,mi=({verb:e,confirmingDelete:n,hasSelection:t,junkMailboxId:s,currentMailboxId:o,deletableMessageId:i})=>{if(n)return{kind:"withheld"};if(e==="junk"){const c=cn(s,o);if(c!==void 0)return{kind:"unavailable",reason:c}}return t?{kind:"openWizard"}:e!=="delete"||i===void 0?{kind:"declined"}:{kind:"confirmDelete",messageId:i}},gi=(e,n,t)=>e==="BACK"&&n&&t===void 0,pi=(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:ls(e.category),messageCount:n,suspicious:e.authenticity?.dkimMismatch===!0,labels:e.labels}),xi=({thread:e,mailboxId:n,isSelected:t,isFocused:s,isTabStop:o,onFocusRow:i,isChecked:c,onToggleCheck:a,onRowSelect:d,messageCount:u,isMultiSelectMode:f,onLongPress:g,isDesktop:m,density:S})=>r.jsx(dn,{thread:pi(e,u),link:{mailboxId:n,threadId:e.threadId},inListbox:!0,active:t,focused:s,isTabStop:o,density:S,isDesktop:m,onFocusRow:i,selection:{isChecked:c,onToggleCheck:a,onRowSelect:d,isMultiSelectMode:f,onLongPress:g}}),bi=l.memo(xi),vi=e=>{const n=e.authenticity?.dkimMismatch===!0;return{id:e.messageId,accountId:e.accountId,fromName:e.fromName??e.fromEmail??"Unknown",fromEmail:e.fromEmail??"",subject:e.subject??"(No subject)",snippet:e.snippet??"",timeLabel:nt(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:ls(e.category),suspicious:n}},Si=({thread:e,mailboxId:n,isSelected:t,isFocused:s,isTabStop:o,onFocusRow:i,isChecked:c,onToggleCheck:a,onRowSelect:d,isMultiSelectMode:u,onLongPress:f,isDesktop:g,onDelete:m,onToggleRead:S,density:C})=>{const[j,T]=l.useState("none"),x=st(),b=l.useCallback(E=>{navigator.vibrate?.(10),E==="trailing"?m(e.messageId):S(e.messageId,e.isRead),T("none")},[m,S,e.messageId,e.isRead]),y=l.useCallback(()=>{f(e.messageId)},[f,e.messageId]),I=l.useCallback(()=>{a(e.messageId)},[a,e.messageId]),k=l.useCallback(()=>{x({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:n,threadId:e.threadId,messageId:e.messageId},search:E=>E})},[x,n,e.threadId,e.messageId]),R=un(e.messageId,d);return g||u?r.jsx(bi,{thread:e,mailboxId:n,isSelected:t,isFocused:s,isTabStop:o,onFocusRow:i,isChecked:c,onToggleCheck:a,onRowSelect:d,isMultiSelectMode:u,onLongPress:f,isDesktop:g,density:C}):r.jsx("div",{role:"presentation",onPointerDownCapture:R.onMouseDown,onClickCapture:R.claimClick,onContextMenu:R.onContextMenu,children:r.jsx(Yn,{thread:vi(e),selectionMode:!1,checked:!1,active:t,peek:j,onPeek:T,onToggleCheck:I,onLongPress:y,onOpen:k,onAct:b})})},yi=72,Ci=32,Ii=5,Cs="remit:list-density",wi=()=>{try{const e=localStorage.getItem(Cs);if(e==="compact"||e==="comfortable")return e}catch{}return"comfortable"},ji=({query:e})=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-line bg-surface-sunken/30",children:[r.jsx(qs,{className:"size-4 text-fg-muted"}),r.jsxs("span",{className:"text-sm text-fg-muted",children:["Results for “",e,"”"]})]}),ki=({mailboxId:e,threads:n,selectedMessageId:t,isLoading:s,isError:o=!1,error:i,onRetry:c,searchQuery:a,searchPredicate:d,onDeleteMessages:u,isDeleting:f=!1,isMoving:g=!1,onLoadMore:m,hasMore:S=!1,isLoadingMore:C=!1,accountId:j,listTitle:T,listMeta:x,listFilter:b,listScopeLabel:y,onTriageContextChange:I,commandsRef:k,hideHeader:R=!1})=>{const E=l.useRef(null),_=st(),D=ps(),W=$s(),{verb:$,start:N,startFromSearch:K}=W,se=Bs(),Ie=!!a?.trim(),V=hn(),{labels:We}=ro(j),{pushError:le}=ss(),[M,we]=l.useState(t),[je,pe]=l.useState(),z=l.useCallback(h=>{pe(v=>v===h?v:void 0),we(h)},[]),[xe,q]=l.useState(wi),Ee=l.useCallback(()=>{q(h=>{const v=h==="comfortable"?"compact":"comfortable";try{localStorage.setItem(Cs,v)}catch{}return v})},[]),{toggleReadFor:Oe}=cs({mailboxId:e}),{junkMailboxId:me}=ds(j),Ae=us(me,e),{selectedIds:ee,selectedCount:ne,hasSelection:oe,isSelected:O,toggle:A,select:Ne,clearSelection:H,selectRange:ie,setAnchor:J,selectAll:ot,toggleAll:Ct,intersectWith:it}=fn(),Ke=jn(ne,D),[re,te]=l.useState(null),rt=Ie&&!!d,ke=`${e}|${JSON.stringify(d??{})}`,w=mn({mailboxId:e,accountId:j,enabled:rt,predicateKey:ke,searchQuery:d??{}}),F=l.useCallback((h,v,Y)=>{if(Y.error===void 0){if(Y.cancelled){le({severity:"warning",title:pn(Y.done),detail:gn(h,Y.done,v)});return}le({severity:"info",title:qt(h,Y.done)})}},[le]),Ve=w.phase.kind,qe=w.clear,Q=l.useCallback(()=>{Ve==="escalated"&&qe(),H()},[H,qe,Ve]),[He,at]=l.useState(null),G=l.useRef(null),ce=l.useRef(!1),be=l.useRef(null),ze=!s&&n.length>0,Ue=re!==null,L=ui({count:n.length,getScrollElement:()=>E.current,estimateSize:()=>xe==="compact"?Ci:yi,overscan:Ii}),lt=t?n.findIndex(h=>h.messageId===t):-1,ae=M?n.findIndex(h=>h.messageId===M):-1,de=l.useCallback(h=>{if(h<0||h>=n.length)return;const v=n[h];if(Ke){A(v.messageId);return}G.current=v.messageId,ce.current=!1,pe(v.messageId),we(v.messageId)},[n,Ke,A]),ue=l.useCallback(()=>{if(n.length===0)return;const h=ae<0?0:Math.min(ae+1,n.length-1);de(h)},[n.length,ae,de]),Qe=l.useCallback(()=>{if(n.length===0)return;const h=ae<=0?0:ae-1;de(h)},[n.length,ae,de]),ge=l.useCallback(()=>de(0),[de]),ct=l.useCallback(()=>de(n.length-1),[de,n.length]),Je=l.useCallback(()=>{M&&A(M)},[M,A]),B=l.useMemo(()=>n.map(h=>h.messageId),[n]),It=l.useMemo(()=>{const h=[];for(const v of n)ee.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,ee]),dt=l.useCallback((h,v)=>v.shiftKey?(ie(B,h,M),!0):v.metaKey||v.ctrlKey?(A(h),!0):(Q(),J(h),!1),[B,M,ie,A,Q,J]),De=l.useCallback(h=>{!u||h.length===0||(be.current=M??null,te(h))},[u,M]),Me=l.useCallback(h=>{const v=xn(B,M,h);v!==void 0&&(ie(B,v),G.current=v,ce.current=!1,pe(void 0),we(v))},[B,M,ie]),ve=l.useCallback(()=>Me(-1),[Me]),Ge=l.useCallback(()=>Me(1),[Me]),Fe=l.useCallback(()=>{B.length>0&&ot(B)},[B,ot]),ut=l.useCallback(h=>{const v=mi({verb:h,confirmingDelete:re!==null,hasSelection:oe,junkMailboxId:me,currentMailboxId:e,deletableMessageId:u?M:void 0});return v.kind==="openWizard"?(N(h),!0):v.kind==="confirmDelete"?(De([v.messageId]),!0):v.kind==="unavailable"?(le({severity:"warning",title:v.reason}),!0):v.kind==="withheld"},[re,u,oe,me,e,N,M,De,le]),he=l.useCallback((h,v)=>{const Y=n.find(X=>X.messageId===h)?.threadId;Y&&_({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:e,threadId:Y,messageId:h},search:X=>X,replace:v?.replace})},[_,e,n]),Ye=l.useCallback(()=>{M&&he(M)},[M,he]),Te=l.useCallback(h=>he(h,{replace:!0}),[he]);bn({keyboardFocusedMessageId:je,openMessageId:t,enabled:D&&ne===0,open:Te});const Se=w.phase.kind==="escalated"?{scope:Vt(d??{}),total:w.phase.total,searchQuery:d??{},run:h=>w.runAction(h),stop:w.stop}:void 0,_e=l.useCallback(()=>{if(!re)return;const h=re;if(h.length===0){te(null);return}const v=new Set(h),Y=n.findIndex(Z=>v.has(Z.messageId));let X;for(let Z=Y+1;Z<n.length;Z++)if(!v.has(n[Z].messageId)){X=n[Z].messageId;break}if(X===void 0){for(let Z=Y-1;Z>=0;Z--)if(!v.has(n[Z].messageId)){X=n[Z].messageId;break}}u?.(h),Q(),be.current=null,te(null),X!==void 0&&(G.current=X,ce.current=!1,z(X),D&&he(X,{replace:!0})),D||at(qt("delete",h.length))},[re,n,u,Q,he,D,z]),ye=l.useCallback(()=>{const h=be.current;be.current=null,te(null),h!==null&&(G.current=h,ce.current=!1,z(h))},[z]),Xe=l.useMemo(()=>{if(ne===0)return;const h=new Set;for(const v of n)ee.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"},[ne,ee,n]),wt=l.useCallback(()=>{if(Se){K();return}N("organize")},[Se,K,N]),jt=l.useCallback(h=>{u?.([h])},[u]),Ce=l.useCallback((h,v)=>{Oe([h],!v)},[Oe]),kt=l.useCallback(h=>{D||Ne(h)},[D,Ne]),Mt=l.useCallback(()=>{if(w.isRunning||w.phase.kind==="counting"){w.stop();return}Q()},[w,Q]),Tt=l.useCallback(()=>{w.clear()},[w]);l.useEffect(()=>{if(ce.current||!D&&t)return;const h=ae>=0?ae:lt;h>=0&&L.scrollToIndex(h,{align:"auto"})},[ae,lt,L,D,t]),l.useEffect(()=>{t&&(ce.current=!1,z(t))},[t,z]),l.useEffect(()=>{M&&(n.some(h=>h.messageId===M)||z(n[0]?.messageId))},[n,M,z]),l.useEffect(()=>{I?.({focusedMessageId:M,selectedIds:Array.from(ee),hasList:ze,blocksKeyboard:Ue||W.isOpen})},[M,ee,ze,Ue,W.isOpen,I]);const ht=l.useRef(I);ht.current=I,l.useEffect(()=>()=>ht.current?.({focusedMessageId:void 0,selectedIds:[],hasList:!1,blocksKeyboard:!1}),[]),l.useEffect(()=>{w.phase.kind!=="idle"||w.isRunning||it(n.map(h=>h.messageId))},[n,it,w.phase,w.isRunning]);const ft=l.useRef(e);l.useEffect(()=>{ft.current!==e&&(ft.current=e,Q())},[e,Q]),vn({shouldBlockFn:({action:h})=>gi(h,oe,se)?(Q(),!0):!1,enableBeforeUnload:!1,disabled:!oe||se!==void 0}),l.useEffect(()=>{const h=E.current;if(!h||!S||!m)return;const v=()=>{if(C)return;const{scrollTop:Y,scrollHeight:X,clientHeight:Z}=h;Y+Z>=X-200&&m()};return h.addEventListener("scroll",v,{passive:!0}),v(),()=>h.removeEventListener("scroll",v)},[S,C,m]),l.useEffect(()=>{const h=G.current;if(!h)return;const v=E.current?.querySelector(`[data-message-id="${h}"]`);v&&(G.current=null,v.focus({preventScroll:!0}))}),l.useEffect(()=>{if(k){if(!ze){k.current=null;return}return k.current={focusNext:ue,focusPrevious:Qe,focusFirst:ge,focusLast:ct,openFocused:Ye,toggleSelect:Je,extendSelectDown:Ge,extendSelectUp:ve,selectAll:Fe,clearSelection:()=>oe?(Q(),!0):!1,requestVerb:ut,toggleDensity:Ee},()=>{k.current=null}}},[k,ze,ue,Qe,ge,ct,Ye,Je,Ge,ve,Fe,oe,Q,ut,Ee]);const mt=s?"loading":o?"error":n.length===0?"empty":"ready",Rt=o?so(i):void 0,Re=l.useCallback(()=>{const h=Ws(Ks());window.open(h,"_blank","noopener,noreferrer")},[]),gt=[{id:"inbox",threads:[]}],Le=B.length>0&&B.every(h=>ee.has(h)),Et=rt&&S&&Le&&!f&&!g&&w.phase.kind==="idle"&&!w.isRunning,Ot=f||g||w.isRunning,Ze=w.phase.kind==="escalated"?w.phase.total:ne,At=w.runningAction?Sn(w.runningAction.kind,w.progress?.done??0,w.progress?.total??Ze):w.phase.kind==="counting"?"Counting matches…":w.phase.kind==="escalated"?fi(d??{},w.phase.total):void 0,pt=w.phase.kind!=="escalated"&&B.length>0?{checked:Le,indeterminate:ne>0&&!Le,onChange:()=>Ct(B)}:void 0,Nt=w.runningAction?{value:w.progress?.done??0,max:w.progress?.total??Ze,tone:yn(w.runningAction.kind)}:void 0,P=(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:Tt}}:Et?{tone:"info",text:"",action:{label:hi(d??{}),onClick:w.escalate}}:void 0)??(Xe?{tone:"warning",text:Xe}:void 0),U=r.jsx(Cn,{title:V.title||T,navSlot:V.navSlot,titleMeta:V.titleMeta,searchSlot:V.searchSlot,searchField:V.searchField,idleSlot:V.makeFilterSlot,count:Ze,onCancel:Mt,onDelete:()=>N("delete"),onMove:()=>N("move"),onOrganize:wt,onJunk:Ae?()=>N("junk"):void 0,onMarkRead:()=>N("markRead"),overflowSlot:j&&e&&ne>0&&We.length>0?r.jsx(ao,{accountId:j,mailboxId:e,messageIds:Array.from(ee)}):void 0,isBusy:Ot,isCounting:w.phase.kind==="counting",selectAll:pt,statusLabel:At,progress:Nt,notice:P}),ks=In(B,M),Ms=l.useCallback(h=>{ce.current=!0,z(h)},[z]),Ts=r.jsxs(r.Fragment,{children:[Ie&&a&&r.jsx(ji,{query:a}),r.jsxs("div",{ref:E,role:"listbox","aria-multiselectable":!0,"aria-label":T,className:"flex-1 overflow-y-auto",children:[r.jsx("div",{role:"presentation",className:"relative w-full",style:{height:`${L.getTotalSize()}px`},children:L.getVirtualItems().map(h=>{const v=n[h.index];return r.jsx("div",{role:"presentation","data-index":h.index,ref:L.measureElement,className:Vs("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(Si,{thread:v,mailboxId:e,isSelected:t===v.messageId,isFocused:M===v.messageId,isTabStop:ks===v.messageId,onFocusRow:Ms,isChecked:O(v.messageId),onToggleCheck:A,onRowSelect:dt,isMultiSelectMode:Ke,onLongPress:kt,isDesktop:D,onDelete:jt,onToggleRead:Ce,density:xe})},h.key)})}),C&&r.jsx(Xn,{})]})]});return r.jsxs(r.Fragment,{children:[He&&!D&&r.jsx(_t,{tone:"success",variant:"soft",className:"m-2 rounded-md",onDismiss:()=>at(null),children:He}),r.jsx(Zn,{listTitle:T,listMeta:x,sections:gt,flatList:!0,listState:V.searchResults?"ready":mt,searchQuery:Ie?a:void 0,listFilter:b,listScopeLabel:y,errorMessage:Rt,onRetry:c,onReportError:Re,density:xe,selectedThreadId:t,onSelectThread:h=>he(h),isDesktop:D,hideHeader:R,selectionBar:U,listBody:V.searchResults??(mt==="ready"?Ts:void 0)}),r.jsx(xs,{isOpen:re!==null,title:oo(re?.length??0),description:"You can restore them from Trash later.",confirmLabel:"Move to Trash",destructive:!0,isBusy:f,onConfirm:_e,onCancel:ye}),r.jsx(wn,{verb:$,accountId:j,mailboxId:e,selection:It,crossAccount:Xe!==void 0,escalated:Se,escalatedProgress:w.progress,onFinished:Q,onRunEnded:F})]})},Mi=e=>Us({path:{accountId:e}}),Ti=e=>{const n=Lt(),t=$t(),s=Pt({...Hs(),onSuccess:()=>{t.recordEvent("sync.triggered"),n.invalidateQueries({queryKey:Mi(e)})}});return{trigger:()=>{s.mutate({path:{accountId:e}})},triggerAsync:()=>s.mutateAsync({path:{accountId:e}}),isPending:s.isPending,error:s.error,reset:s.reset}},Ri=({accountId:e,children:n})=>{const{triggerAsync:t,isPending:s}=Ti(e);return r.jsx(wo,{onRefresh:t,isRefreshing:s,children:n})};function Ei({accountId:e,currentMailboxId:n,candidates:t,onMove:s,children:o}){const[i,c]=l.useState(!1),a=$t(),d=go(),{inboxMailboxId:u}=kn(e),f=Mn(e),{data:g}=tt({...Qs({path:{accountId:e}}),staleTime:1/0}),m=l.useMemo(()=>po({mailboxes:g?.items??[],folderAppointments:f,currentMailboxId:n,translator:d}),[g?.items,f,n,d]),S=l.useMemo(()=>u||(m.find(b=>b.label.toLowerCase()==="inbox")?.id??m.find(b=>!b.isCurrent)?.id??""),[u,m]),C=l.useRef(!1);l.useEffect(()=>{C.current||(C.current=!0,Tn(a,t.length))},[a,t.length]);const j=l.useCallback(()=>{Rn(a,t.length),c(!0)},[a,t.length]),T=l.useCallback((x,b)=>{En(a,{selected:x.length,total:t.length,toInbox:b===u}),s(x,b)},[a,t.length,u,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(ko,{count:t.length,onReview:j})}),r.jsx("div",{className:"min-h-0 flex-1",children:o}),r.jsx(_o,{open:i,candidates:t,defaultDestinationId:S,availableFolders:m,delimiter:xo(g?.items??[]),onConfirmMove:T,onCancel:()=>c(!1)})]})}const Oi="We can verify this sender";function Ai(e){const{data:n}=tt({...Js({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:Oi,trustSubReason:On(s.senderTrust),senderTrust:s.senderTrust}))}}const Ni=e=>{const n=new Set,t=[];for(const s of e)n.has(s.threadMessageId)||(n.add(s.threadMessageId),t.push(s));return t},zi={unread:"unread",flagged:"starred",attachment:"attachments"},Di=new Set(Object.values(yo)),Is=e=>Di.has(e),Fi=e=>Is(e.category)||e.attributes.size>0,_i=e=>{const n={};Is(e.category)&&(n.category=[e.category]);for(const t of e.attributes){const s=zi[t];s&&(n[s]=!0)}return n},Li=e=>(e.senderTrust?.length??0)>0||e.dkimMismatch!==void 0?"loaded-pages":"whole-folder",Pi=["category","unread","starred","attachments"],Yt=e=>JSON.stringify(Pi.map(n=>e?.[n]??null)),$i=e=>{if(!Array.isArray(e))return;const[n]=e;if(typeof n!="object"||n===null)return;const t=n.query;if(!(typeof t!="object"||t===null))return t},Bi=(e,n)=>{const t=$i(e);return t?Yt(t)===Yt(n):!1},xt=e=>e[0],Wi=e=>{const n=xt(e.filter(a=>a.type==="from").map(a=>a.value)),t=xt(e.filter(a=>a.type==="subject").map(a=>a.value)),s=xt(e.filter(a=>a.type==="category").map(a=>a.category)),o=xt(e.filter(a=>a.type==="isUnread"||a.type==="isRead").map(a=>a.type==="isUnread")),i=e.some(a=>a.type==="isStarred")?!0:void 0,c=e.some(a=>a.type==="hasAttachment")?!0:void 0;return{...n!==void 0?{from:n}:{},...t!==void 0?{subject:t}:{},...s!==void 0?{category:[s]}:{},...o!==void 0?{unread:o}:{},...i!==void 0?{starred:i}:{},...c!==void 0?{attachments:c}:{}}},Ki=(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 Vi(e,n={}){const t=Wi(e),s={...t,...n};return{params:t,residual:e.filter(o=>!Ki(s,o))}}function qi(e,n,t){if(n.length===0)return e;const s=[...n];return e.filter(o=>{const i=An(o);return Nn({...i,accountId:i.accountId??t},s)})}const Hi=50,Ui=new Map(ms().categories.filter(e=>e.id!=="all").map(e=>[e.id,e.label])),ws=l.createContext(null);function yt(){const e=l.useContext(ws);if(!e)throw new Error("MailboxPane.* must be used inside <MailboxPane>");return e}function Qi({mailboxId:e,thread:n,children:t}){const s=st(),o=n?.threadId,i=n?.messageId,a=bs()==="desktop",d=$t(),{accounts:u,searchQuery:f,intelligenceOpen:g,onToggleIntelligence:m,onSetIntelligenceOpen:S}=ns(),C=sn(),j=Io(f),T=j.length>0,{freeText:x,tokens:b}=nn(j,C),[y,I]=l.useState("all"),[k,R]=l.useState(new Set),E=l.useMemo(()=>({category:y,attributes:k}),[y,k]),_=l.useMemo(()=>_i(E),[E]),D=T||Fi(E),{params:W,residual:$}=Vi(b,_),N={order:"desc",limit:Hi,...x?{query:x}:{},...W,..._},K={category:N.category,unread:N.unread,starred:N.starred,attachments:N.attachments},se=D?Gs({path:{mailboxId:e},query:N}):Ys({path:{mailboxId:e},query:{order:"desc"}}),{data:Ie,isLoading:V,isError:We,error:le,refetch:M,fetchNextPage:we,hasNextPage:je,isFetchingNextPage:pe}=eo({queryKey:se,queryFn:async({pageParam:p})=>{if(D){const{data:U}=await en({path:{mailboxId:e},query:{...N,continuationToken:p},throwOnError:!0});return U}const{data:P}=await tn({path:{mailboxId:e},query:{order:"desc",continuationToken:p},throwOnError:!0});return P},initialPageParam:void 0,getNextPageParam:p=>p.continuationToken,placeholderData:(p,P)=>Bi(P?.queryKey,K)?p:void 0}),{accountId:z}=zn(e),xe=bo({accounts:u}),q=qi(Dn(Ni(Ie?.pages.flatMap(p=>p.items??[])??[])),$,z),Ee=l.useCallback(p=>{I(p)},[]),Oe=l.useCallback(p=>{R(P=>{const U=new Set(P);return U.has(p)?U.delete(p):U.add(p),U})},[]),me=l.useCallback(()=>{I("all"),R(new Set)},[]),Ae=Ui.get(y),ee=Ae?{label:Ae,reach:$.length>0?"loaded-pages":Li(N),onClear:me}:void 0,ne=o?q.find(p=>p.messageId===i)??q.find(p=>p.threadId===o):void 0,oe=Fn(o,i),O=ne??oe,A=i??O?.messageId,Ne=l.useMemo(()=>{if(o)return{threadId:o,mailboxId:O?.mailboxId??e,subject:O?.subject,messageId:A,authenticity:O?.authenticity}},[o,O,A,e]),H=l.useCallback(()=>{s({to:"/mail/$mailboxId",params:{mailboxId:e},search:p=>p})},[e,s]),ie=l.useCallback(p=>{s({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:e,...p},search:P=>P})},[e,s]),J=l.useCallback(p=>{A&&p.includes(A)&&H()},[A,H]),{deleteMessages:ot,isPending:Ct}=Ht({mailboxId:e,onAfterOptimisticRemove:J}),{moveMessages:it,isPending:Ke}=Ut({mailboxId:e,accountId:z,onAfterOptimisticRemove:J}),re=_n(),{listCommandsRef:te,onTriageContextChange:rt,focusedMessageId:ke,selectedIds:w}=re,F=q.find(p=>p.messageId===ke)??O,Ve=l.useRef(null);l.useEffect(()=>{const p=O?.messageId??null;p&&Ve.current!==p&&O?.authenticity?.dkimMismatch&&(Ve.current=p,g||m())},[O?.messageId,O?.authenticity?.dkimMismatch,g,m]);const qe=l.useRef(!1);l.useEffect(()=>{qe.current||a&&O?.messageId&&(qe.current=!0,Co()&&!g&&S(!0))},[a,O?.messageId,g,S]);const Q=vo({accounts:u})??0,He=Lt(),{pushError:at}=ss(),G=Ln({thread:O,mailboxId:e,accountId:z,onAfterOptimisticRemove:J}),{draftsMailboxId:ce}=Pn(z),be=ce!==void 0&&ce===e,{archiveMailboxId:ze}=$n(z),Ue=Bn(),{requestCompose:L}=G,lt=l.useCallback(()=>{L("reply")},[L]),ae=l.useCallback(()=>{L("reply_all")},[L]),de=l.useCallback(()=>{L("forward")},[L]),{state:ue,openCompose:Qe,closeCompose:ge}=vt(),ct=l.useCallback(()=>{Qe({mode:"new"})},[Qe]),Je=l.useRef(A);l.useEffect(()=>{const p=Je.current;Je.current=A,!(!A||A===p)&&ge()},[A,ge]);const B=Pt({...ts(),onError:p=>{at(Xs("Couldn't discard draft","The draft wasn't deleted.",p))}}),It=l.useCallback(()=>{const p=ue.outboxMessageId;p&&(B.mutate({path:{outboxMessageId:p}}),He.invalidateQueries({queryKey:es()}),ge())},[ue.outboxMessageId,B,He,ge]),dt=l.useCallback(p=>p?Ue(p):[],[Ue]),{toggleStar:De}=Wn({threadId:F?.threadId??"",mailboxId:e}),{toggleReadFor:Me}=cs({mailboxId:e,accountId:z}),{junkMailboxId:ve}=ds(z),Ge=ve!=null&&ve===e,Fe=us(ve,e),{candidates:ut}=Ai(Ge?ve:void 0),{moveMessages:he}=Ut({mailboxId:e,threadId:F?.threadId,accountId:z,onAfterOptimisticRemove:J}),{deleteMessages:Ye}=Ht({mailboxId:e,threadId:F?.threadId,onAfterOptimisticRemove:J}),{addressId:Te,address:Se}=Kn(F),{updateFlags:_e}=Vn({addressId:Te,senderEmail:F?.fromEmail??void 0}),ye=l.useCallback(()=>{if(A||!ke)return!1;const p=q.find(P=>P.messageId===ke);return p?(ie({threadId:p.threadId,messageId:ke}),!0):!1},[A,ke,q,ie]),Xe=l.useCallback(()=>{ye()||O&&L("reply")},[ye,O,L]),wt=l.useCallback(()=>{ye()||O&&L("reply_all")},[ye,O,L]),jt=l.useCallback(()=>{ye()||O&&L("forward")},[ye,O,L]),Ce=l.useCallback(()=>dt(F),[dt,F]),kt=l.useCallback(()=>{if(te.current?.requestVerb("delete"))return;const p=Ce();p.length>0&&Ye(p)},[te,Ce,Ye]),Mt=l.useCallback(()=>{if(te.current?.requestVerb("junk")||!Fe)return;const p=Ce();p.length!==0&&(qn(d,{count:p.length,senderTrust:F?.senderTrust??"unknown",wasRescuable:F?Hn(F):!1}),he(p,Fe))},[te,Fe,Ce,he,d,F]),Tt=l.useCallback(()=>{if(w.length>0){const p=!(F?.hasStars??!1),P=new Set(w);for(const U of q)P.has(U.messageId)&&U.hasStars!==p&&De(U.messageId,U.hasStars);return}F&&De(F.messageId,F.hasStars)},[w,q,F,De]),ht=l.useCallback(()=>{if(te.current?.requestVerb("markRead"))return;const p=Ce();if(p.length===0)return;const P=!(F?.isRead??!1);Me(p,P)},[te,Ce,F,Me]),ft=l.useCallback(()=>{if(!Te)return;const p=Se?.flags?.muted?.value!==!0;_e({muted:{value:p}})},[Te,Se,_e]),mt=l.useCallback(()=>{if(!Te)return;const p=Se?.flags?.vip?.value!==!0;_e({vip:{value:p}})},[Te,Se,_e]),Rt=l.useCallback(()=>{g||m()},[g,m]),Re=l.useCallback(p=>{s({to:p})},[s]),gt=be?"drafts":ze===e?"archive":ve===e?"junk":"inbox",Le=l.useRef("");l.useEffect(()=>{const p=Le.current;Le.current=j,j.length>0&&p.length===0&&d.recordEvent("search.submitted",{mailboxType:gt})},[j,gt,d]);const Et=be&&ue.isOpen&&!!ue.outboxMessageId&&!O,{goBack:Ot,nextMessageId:Ze,previousMessageId:At}=Un({context:re,orderedIds:q.map(p=>p.messageId),selectedMessageId:A,enabled:!ue.isOpen,onClose:H,handlers:{reply:Xe,replyAll:wt,forward:jt,delete:kt,toggleStar:Tt,toggleRead:ht,muteSender:ft,blockSender:Rt,vipSender:mt,markJunk:Mt,toggleIntelligence:O?m:void 0,compose:ct,goBrief:()=>Re("/mail/brief"),goInbox:()=>Re("/mail/brief"),goSent:()=>Re("/mail/brief"),goFlagged:()=>Re("/mail/flagged"),goSettings:()=>Re("/settings")}});So({enabled:ue.isOpen,bindings:[{key:"Escape",handler:ge,preventDefault:!0}]});const pt=p=>{if(!p)return;const P=q.find(U=>U.messageId===p);return P?{threadId:P.threadId,messageId:p}:void 0},Nt={mailboxId:e,selectedMessageId:A,selectedThread:O,conversation:Ne,onOpenThread:ie,threads:q,isLoading:V,isError:We,error:le,mailboxAccountId:z,mailboxName:xe,unreadCount:Q,isDraftsMailbox:be,isSpamFolder:Ge,rescueCandidates:ut,filterCategory:y,filterAttributes:k,onSelectFilterCategory:Ee,onToggleFilterAttribute:Oe,onClearFilters:me,listFilter:ee,intelligenceOpen:g,onToggleIntelligence:m,handleDeselectIfRemoved:J,searchPredicate:T&&$.length===0?N:void 0,onDeleteMessages:ot,onMoveMessages:it,isDeleting:Ct,isMoving:Ke,onLoadMore:we,hasMore:je,isLoadingMore:pe,onTriageContextChange:rt,listCommandsRef:te,onRetry:()=>M(),toolbarComposeRequest:G.composeRequest,onToolbarReply:lt,onToolbarReplyAll:ae,onToolbarForward:de,onClearComposeRequest:G.clearComposeRequest,onToolbarDelete:G.deleteThread,onToolbarStar:G.toggleStar,onToolbarDiscardDraft:It,onToolbarMove:G.moveThread,composeState:ue,closeCompose:ge,hasRemitDraftOpen:Et,onBack:Ot,nextThread:pt(Ze),previousThread:pt(At)};return r.jsx(ws.Provider,{value:Nt,children:t})}function js(){const{mailboxId:e,selectedMessageId:n,threads:t,isLoading:s,isError:o,error:i,onDeleteMessages:c,onMoveMessages:a,isDeleting:d,isMoving:u,onLoadMore:f,hasMore:g,isLoadingMore:m,mailboxAccountId:S,mailboxName:C,unreadCount:j,isDraftsMailbox:T,isSpamFolder:x,rescueCandidates:b,onTriageContextChange:y,listCommandsRef:I,onRetry:k,filterCategory:R,filterAttributes:E,onSelectFilterCategory:_,onToggleFilterAttribute:D,onClearFilters:W,listFilter:$,searchPredicate:N}=yt(),{searchQuery:K,searchInput:se,accounts:Ie,resultFolderIndex:V}=ns(),We=bs(),le=st(),M=C??"Inbox",we=l.useMemo(()=>ms(),[]),je=l.useMemo(()=>S?[S]:[],[S]),{hasNewMail:pe}=rn(),{state:z,errorMessage:xe,refresh:q}=an(je,{onSettled:k}),Ee=l.useMemo(()=>r.jsx(ln,{state:z,onRefresh:q,label:`Refresh ${M}`,errorMessage:xe,hasUpdate:pe(je)}),[z,q,M,xe,pe,je]),Oe=l.useMemo(()=>t.map(H=>Jn(H,V)),[t,V]),{hits:me,isLoading:Ae}=lo({mailboxId:e,filterCategory:R}),ee=l.useMemo(()=>Gn(me,t.map(H=>H.threadId),V),[me,t,V]),ne=l.useCallback(H=>{const ie=H.threadId??t.find(J=>J.messageId===H.id)?.threadId;ie&&le({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:H.mailboxId??e,threadId:ie,messageId:H.id},search:J=>({...J,q:se||void 0})})},[e,le,se,t]);if(T&&S)return r.jsx(Qo,{mailboxId:e,accountId:S,selectedMessageId:n,imapThreads:t,title:C??"Drafts",unreadCount:j??void 0});const oe=r.jsx(ki,{mailboxId:e,threads:t,selectedMessageId:n,isLoading:s,isError:o,error:i,onRetry:k,searchQuery:K,searchPredicate:N,onDeleteMessages:c,isDeleting:d,isMoving:u,onLoadMore:f,hasMore:g,isLoadingMore:m,accountId:S,listTitle:M,listFilter:$,listScopeLabel:M,hideHeader:!0,onTriageContextChange:y,commandsRef:I}),O=Ie[0]?.accountId,A=We==="phone"&&O?r.jsx(Ri,{accountId:O,children:oe}):oe,Ne=x&&b.length>0&&S?r.jsx(Ei,{accountId:S,currentMailboxId:e,candidates:b,onMove:a,children:A}):A;return r.jsx(to,{title:M,unreadCount:j,preset:we,selectedCategory:R,activeFilters:E,onSelectCategory:_,onToggleFilter:D,onClearFilters:W,searchResults:Oe,searchLoading:s,relatedResults:ee,relatedLoading:Ae,onSelectSearchResult:ne,searchResultsInBody:!0,refreshControl:Ee,children:Ne})}function Ji(){const{mailboxId:e,mailboxAccountId:n,selectedThread:t,conversation:s,hasRemitDraftOpen:o,intelligenceOpen:i,onToggleIntelligence:c,toolbarComposeRequest:a,onToolbarReply:d,onToolbarReplyAll:u,onToolbarForward:f,onClearComposeRequest:g,onToolbarDelete:m,onToolbarStar:S,onToolbarDiscardDraft:C,onToolbarMove:j,composeState:T,handleDeselectIfRemoved:x}=yt(),b=Zs()?.showIntelligencePane??!1,y=!!s,[I,k]=l.useState(null),R=s?.threadId??null,E=!b&&R!==null&&I===R,_=l.useCallback(()=>k(null),[]),D=l.useCallback(()=>k(R),[R]),W=b?c:D,$=l.useCallback(()=>{if(b){c();return}k(E?null:R)},[b,c,E,R]),N=y&&(b?i:E),K=T.isOpen&&!s?r.jsx(Ss,{}):s?r.jsx(hs,{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:g}):r.jsx(on,{});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(Qn,{hasThread:y,intelligenceOpen:N,canToggleIntelligence:y,onToggleIntelligence:$,onReply:y?d:void 0,onReplyAll:y?u:void 0,onForward:y?f:void 0,canDelete:y||o,onDelete:y?m:o?C:void 0,onToggleStar:y?S:void 0,isStarred:t?.hasStars,moveContext:y&&n?{accountId:n,currentMailboxId:e,onMove:j}:void 0}),r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:K})]}),r.jsx(fs,{isOpen:E,onClose:_,ariaLabel:"Message details",side:"right",children:r.jsx(Bt,{onClose:_,thread:t,mailboxId:e,accountId:n,hideCloseButton:!0,onAfterOptimisticRemove:x})})]})}function Gi(){const{mailboxId:e,mailboxAccountId:n,selectedThread:t,onToggleIntelligence:s,handleDeselectIfRemoved:o}=yt();return r.jsx(Bt,{onClose:s,thread:t,mailboxId:e,accountId:n,onAfterOptimisticRemove:o})}function Yi(){const{mailboxId:e,mailboxAccountId:n,selectedThread:t,conversation:s,onOpenThread:o,intelligenceOpen:i,onToggleIntelligence:c,onBack:a,nextThread:d,previousThread:u,composeState:f,handleDeselectIfRemoved:g}=yt();return s?r.jsxs(r.Fragment,{children:[r.jsx(hs,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onBack:a,onOpenIntelligence:c,onSwipeNext:d?()=>o(d):void 0,onSwipePrevious:u?()=>o(u):void 0,mobileIntelligenceOpen:i}),r.jsx(fs,{isOpen:i,onClose:c,ariaLabel:"Message details",side:"right",children:r.jsx(Bt,{onClose:c,thread:t,mailboxId:e,accountId:n,hideCloseButton:!0,onAfterOptimisticRemove:g})})]}):f.isOpen?r.jsx("div",{className:"h-full",children:r.jsx(Ss,{})}):r.jsx(js,{})}const Ir=Object.assign(Qi,{List:js,Reading:Ji,Intelligence:Gi,Phone:Yi});export{Ir as M};
@@ -1 +0,0 @@
1
- import{a3 as m,j as o,a0 as p}from"./index-CoNvZIm_.js";import{a}from"./search-view-DBvRPRa1.js";import{M as r}from"./MailboxPane-DkPAPzBT.js";import{u as e}from"./useSearchMirror-eiX731bE.js";import"./nav-link-7QYETm4r.js";import{u as s}from"./MailListHeader-CsMXujM8.js";import"./useSearchTokenContext-BnSrnFlb.js";import"./kbd-37YHrOod.js";import"./use-match-media-BezqzsJW.js";import"./enums-CCxx0t2v.js";import"./search-scope-DpxLT3gw.js";import"./useRefreshControl-DlypbbhJ.js";import"./circle-check-big-CBG0107E.js";import"./search-token-index-e3fTB436.js";import"./layout-breakpoints-BWjiUQKh.js";import"./MailViewChrome-7pIGoTSB.js";import"./avatar-BpcGfGBY.js";import"./account-form-helpers-1QlePfxz.js";import"./menu-B6RXxSm8.js";import"./ErrorState-EG2eHLL1.js";import"./useFilters-BBQH0MKH.js";import"./confirm-dialog-C2G4kIKu.js";import"./format-De9HZKjg.js";import"./NavMenuButton-DiNk3STC.js";import"./useLabels-Dxb6ajq-.js";import"./useSemanticSearch-Dn1P2d8-.js";import"./search-query-Cr_ZXBCp.js";import"./shield-check-XKwP5L-S.js";import"./bottom-sheet-Bb9_P1q_.js";import"./circle-help-aRUYdfvH.js";import"./circle-check-rylkL795.js";import"./move-options-BHPhC1Kk.js";import"./intelligence-pref-C6lFpj6U.js";import"./useSignature-DIdZs8UQ.js";import"./useDebouncedValue-CDnuOkob.js";import"./download-CdBITb1R.js";import"./clock-tsMaR7Oh.js";function Q(){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{Q as component};
@@ -1 +0,0 @@
1
- import{j as r}from"./index-CoNvZIm_.js";import{B as o}from"./BriefPane-Cf0qx6oW.js";import"./useSearchTokenContext-BnSrnFlb.js";import"./kbd-37YHrOod.js";import"./use-match-media-BezqzsJW.js";import"./enums-CCxx0t2v.js";import"./search-scope-DpxLT3gw.js";import"./MailListHeader-CsMXujM8.js";import"./search-token-index-e3fTB436.js";import"./layout-breakpoints-BWjiUQKh.js";import"./account-form-helpers-1QlePfxz.js";import"./avatar-BpcGfGBY.js";import"./useSignature-DIdZs8UQ.js";import"./useDebouncedValue-CDnuOkob.js";import"./useFilters-BBQH0MKH.js";import"./ErrorState-EG2eHLL1.js";import"./format-De9HZKjg.js";import"./nav-link-7QYETm4r.js";import"./download-CdBITb1R.js";import"./shield-check-XKwP5L-S.js";import"./move-options-BHPhC1Kk.js";import"./confirm-dialog-C2G4kIKu.js";import"./clock-tsMaR7Oh.js";import"./menu-B6RXxSm8.js";import"./useRefreshControl-DlypbbhJ.js";import"./circle-check-big-CBG0107E.js";import"./useLabels-Dxb6ajq-.js";import"./useSemanticSearch-Dn1P2d8-.js";import"./search-query-Cr_ZXBCp.js";function A(){return r.jsx(o.Reading,{})}export{A as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-CoNvZIm_.js";import{M as r}from"./MailboxPane-DkPAPzBT.js";import"./useSearchTokenContext-BnSrnFlb.js";import"./kbd-37YHrOod.js";import"./use-match-media-BezqzsJW.js";import"./enums-CCxx0t2v.js";import"./search-scope-DpxLT3gw.js";import"./useRefreshControl-DlypbbhJ.js";import"./circle-check-big-CBG0107E.js";import"./search-token-index-e3fTB436.js";import"./layout-breakpoints-BWjiUQKh.js";import"./MailListHeader-CsMXujM8.js";import"./account-form-helpers-1QlePfxz.js";import"./avatar-BpcGfGBY.js";import"./useSignature-DIdZs8UQ.js";import"./useDebouncedValue-CDnuOkob.js";import"./useFilters-BBQH0MKH.js";import"./ErrorState-EG2eHLL1.js";import"./format-De9HZKjg.js";import"./nav-link-7QYETm4r.js";import"./download-CdBITb1R.js";import"./shield-check-XKwP5L-S.js";import"./move-options-BHPhC1Kk.js";import"./confirm-dialog-C2G4kIKu.js";import"./clock-tsMaR7Oh.js";import"./menu-B6RXxSm8.js";import"./MailViewChrome-7pIGoTSB.js";import"./NavMenuButton-DiNk3STC.js";import"./useLabels-Dxb6ajq-.js";import"./useSemanticSearch-Dn1P2d8-.js";import"./search-query-Cr_ZXBCp.js";import"./bottom-sheet-Bb9_P1q_.js";import"./circle-help-aRUYdfvH.js";import"./circle-check-rylkL795.js";import"./intelligence-pref-C6lFpj6U.js";function I(){return o.jsx(r.Reading,{})}export{I as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-CoNvZIm_.js";import{F as r}from"./FlaggedPane-WLhe7MTQ.js";import"./useSearchTokenContext-BnSrnFlb.js";import"./kbd-37YHrOod.js";import"./use-match-media-BezqzsJW.js";import"./enums-CCxx0t2v.js";import"./search-scope-DpxLT3gw.js";import"./MailListHeader-CsMXujM8.js";import"./search-token-index-e3fTB436.js";import"./layout-breakpoints-BWjiUQKh.js";import"./account-form-helpers-1QlePfxz.js";import"./avatar-BpcGfGBY.js";import"./useSignature-DIdZs8UQ.js";import"./useDebouncedValue-CDnuOkob.js";import"./useFilters-BBQH0MKH.js";import"./ErrorState-EG2eHLL1.js";import"./format-De9HZKjg.js";import"./nav-link-7QYETm4r.js";import"./download-CdBITb1R.js";import"./shield-check-XKwP5L-S.js";import"./move-options-BHPhC1Kk.js";import"./confirm-dialog-C2G4kIKu.js";import"./clock-tsMaR7Oh.js";import"./menu-B6RXxSm8.js";import"./MailViewChrome-7pIGoTSB.js";function v(){return o.jsx(r.Reading,{})}export{v as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-CoNvZIm_.js";import{O as t}from"./OutboxPane-DzBz96fV.js";import"./useSearchTokenContext-BnSrnFlb.js";import"./kbd-37YHrOod.js";import"./use-match-media-BezqzsJW.js";import"./enums-CCxx0t2v.js";import"./search-scope-DpxLT3gw.js";import"./circle-check-big-CBG0107E.js";import"./clock-tsMaR7Oh.js";import"./row-actions-DzYchsTL.js";import"./rotate-ccw-BozetpiQ.js";import"./NavMenuButton-DiNk3STC.js";import"./menu-B6RXxSm8.js";import"./format-De9HZKjg.js";import"./outbox-status-CPfNHfUQ.js";import"./search-query-Cr_ZXBCp.js";function R(){return o.jsx(t.Reading,{})}export{R as component};
@@ -1 +0,0 @@
1
- import{a0 as o}from"./index-CoNvZIm_.js";const n=o;export{n as component};
@@ -1 +0,0 @@
1
- import{a0 as o}from"./index-CoNvZIm_.js";const n=o;export{n as component};
@@ -1 +0,0 @@
1
- import{a0 as o}from"./index-CoNvZIm_.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-CoNvZIm_.js";import{R as Zs}from"./row-actions-DzYchsTL.js";import{S as Qs,A as Xs}from"./settings-screen-QrhNeHVs.js";import{g as Dt,P as Js,s as Be,u as er,O as tr}from"./OnboardingWizard-Q6QD6xGn.js";import{u as sr}from"./useSignature-DIdZs8UQ.js";import{c as rr,a as Ct,d as ar}from"./account-form-helpers-1QlePfxz.js";import{D as ir}from"./download-CdBITb1R.js";import{E as nr}from"./ErrorState-EG2eHLL1.js";import{f as or}from"./format-De9HZKjg.js";import"./avatar-BpcGfGBY.js";import"./menu-B6RXxSm8.js";import"./circle-help-aRUYdfvH.js";import"./kbd-37YHrOod.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 h-full w-full 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 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 h-[calc(100%-3.5rem)] 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&&lt(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&&lt({},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&&lt({},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};
@@ -1 +0,0 @@
1
- import{j as r,a0 as i}from"./index-CoNvZIm_.js";import{a as m}from"./search-view-DBvRPRa1.js";import{B as o}from"./BriefPane-Cf0qx6oW.js";import{u as p}from"./useSearchMirror-eiX731bE.js";import"./nav-link-7QYETm4r.js";import{u as e}from"./MailListHeader-CsMXujM8.js";import"./useSearchTokenContext-BnSrnFlb.js";import"./kbd-37YHrOod.js";import"./use-match-media-BezqzsJW.js";import"./enums-CCxx0t2v.js";import"./search-scope-DpxLT3gw.js";import"./useRefreshControl-DlypbbhJ.js";import"./circle-check-big-CBG0107E.js";import"./search-token-index-e3fTB436.js";import"./layout-breakpoints-BWjiUQKh.js";import"./useLabels-Dxb6ajq-.js";import"./useFilters-BBQH0MKH.js";import"./useSemanticSearch-Dn1P2d8-.js";import"./search-query-Cr_ZXBCp.js";import"./account-form-helpers-1QlePfxz.js";import"./avatar-BpcGfGBY.js";import"./useSignature-DIdZs8UQ.js";import"./useDebouncedValue-CDnuOkob.js";import"./ErrorState-EG2eHLL1.js";import"./format-De9HZKjg.js";import"./download-CdBITb1R.js";import"./shield-check-XKwP5L-S.js";import"./move-options-BHPhC1Kk.js";import"./confirm-dialog-C2G4kIKu.js";import"./clock-tsMaR7Oh.js";import"./menu-B6RXxSm8.js";function D(){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{D as component};
@@ -1 +0,0 @@
1
- import{s as Z,af as X,aW as ee,aX as te,r as x,j as t,aY as ae,aZ as se,an as R,B as N,av as ie,aB as ne,a_ as re,a$ as oe,T as le,x as z,w as ce,z as de,E as me,p as ue,Z as pe,az as xe,aD as fe}from"./index-CoNvZIm_.js";import{S as he}from"./settings-screen-QrhNeHVs.js";import{B as ge}from"./bottom-sheet-Bb9_P1q_.js";import{b as ve,N as S,p as be,u as ye,r as je,a as Ne,S as L,c as Ce,n as Se,d as Fe,f as Me,e as Ie,g as we,h as Ee}from"./useFilters-BBQH0MKH.js";import{u as Oe,a as De,b as Ae,f as Le}from"./move-options-BHPhC1Kk.js";import{u as Te,a as ke}from"./useLabels-Dxb6ajq-.js";import{C as A}from"./circle-check-rylkL795.js";import{E as P}from"./ErrorState-EG2eHLL1.js";import"./avatar-BpcGfGBY.js";import"./menu-B6RXxSm8.js";import"./circle-help-aRUYdfvH.js";import"./use-match-media-BezqzsJW.js";import"./layout-breakpoints-BWjiUQKh.js";import"./enums-CCxx0t2v.js";const Re=(e,a)=>{const r=Z(),i=X({...te(),onSuccess:()=>{e&&(r.invalidateQueries({queryKey:ve(e)}),a&&r.invalidateQueries({queryKey:ee({path:{accountId:e,filterId:a}})}))}}),{mutate:c}=i;return{updateFilter:x.useCallback(d=>{!e||!a||c({path:{accountId:e,filterId:a},body:d})},[e,a,c]),isPending:i.isPending,isSuccess:i.isSuccess,isError:i.isError,error:i.error,reset:i.reset}},ze=(e,a=!1)=>({clauses:e.literalClauses.map((i,c)=>({id:`clause-${c}`,field:i.field,value:i.value})),matchOperator:e.matchOperator==="And"?"all":"any",widen:e.hasAnchor?{anchorCount:1,...a?{inactive:!0}:{}}:void 0,moveMailboxId:e.actionMailboxId!==S?e.actionMailboxId:void 0,labelId:e.actionLabelId!==S?e.actionLabelId:void 0,scope:e.scope==="Temporary"?"until":"standing",until:e.scope==="Temporary"?Pe(e.expiresAt):void 0,name:e.name}),Pe=e=>{if(!e)return"";const a=Date.parse(e);if(Number.isNaN(a))return"";const r=new Date(a),i=c=>String(c).padStart(2,"0");return`${r.getFullYear()}-${i(r.getMonth()+1)}-${i(r.getDate())}`},T=e=>JSON.stringify({clauses:e.clauses.map(a=>[a.field,a.value]),operator:e.matchOperator,move:e.moveMailboxId??null,label:e.labelId??null,widen:e.widen?e.widen.inactive?"inactive":"active":"none"}),$=(e,a)=>T(e)!==T(a),k=e=>JSON.stringify({scope:e.scope==="until"?"until":"standing",until:e.scope==="until"?e.until??"":""}),_=(e,a)=>k(e)!==k(a),$e=(e,a)=>{const r={},i=(e.name??"").trim();return i!==(a.name??"").trim()&&(r.name=i),$(e,a)&&(r.matchOperator=e.matchOperator==="all"?"And":"Or",r.literalClauses=e.clauses.map(c=>({field:c.field,value:c.value})),r.actionMailboxId=e.moveMailboxId??S,r.actionLabelId=e.labelId??S),_(e,a)&&(r.scope=e.scope==="until"?"Temporary":"Standing",e.scope==="until"&&(r.expiresAt=be(e.until??""))),r};function _e({accountId:e,filter:a,folders:r,delimiter:i,labels:c,semanticUnavailable:g=!1,onClose:d}){const f=x.useMemo(()=>ze(a,g),[a,g]),[n,l]=x.useState(f),[m,u]=x.useState(),[h,b]=x.useState(!1),M=x.useRef(0),{count:C}=ye(e,je(n)),j=Re(e,a.filterId),v=Ne(e),{createFolderIn:F}=Oe(e),{createLabel:E}=Te(e),I=async o=>{const s=await E(o);return{id:s.labelId,name:s.name,color:s.color}},p=()=>u({mode:"add",draft:{field:L[0],value:""}}),w=o=>{const s=n.clauses.find(y=>y.id===o);s&&u({mode:"edit",clauseId:o,draft:{field:s.field,value:s.value}})},O=o=>u(s=>s&&{...s,draft:{...s.draft,field:o}}),B=o=>u(s=>s&&{...s,draft:{...s.draft,value:o}}),U=()=>{if(!m)return;const o=m.draft.field,s=Se(o,m.draft.value);s!==""&&(l(y=>m.mode==="edit"&&m.clauseId?{...y,clauses:y.clauses.map(D=>D.id===m.clauseId?{id:D.id,field:o,value:s}:D)}:(M.current+=1,{...y,clauses:[...y.clauses,{id:`new-${M.current}`,field:o,value:s}]})),u(void 0))},K=o=>l(s=>({...s,clauses:s.clauses.filter(y=>y.id!==o)})),Q=o=>l(s=>({...s,matchOperator:o})),G=o=>l(s=>({...s,moveMailboxId:o||void 0})),H=o=>l(s=>({...s,labelId:o||void 0})),J=o=>l(s=>({...s,name:o})),V=o=>l(s=>({...s,scope:o,until:o==="until"?s.until:void 0})),q=o=>l(s=>({...s,until:o})),W=()=>{const o=$(n,f)||_(n,f),s=$e(n,f);if(Object.keys(s).length===0){d();return}b(o),j.updateFilter(s)},Y=()=>v.start(Ce(n));return v.isStarting||v.isRunning||v.isDone?t.jsx(Qe,{progress:v.progress,isDone:v.isDone,onClose:d}):j.isPending?t.jsx(Be,{}):j.isError?t.jsx(Ge,{onRetry:j.reset,onClose:d}):j.isSuccess?h?t.jsx(Ke,{preview:ae(C),blocked:C.status!=="ready"||C.stale===!0,onReapply:Y,onClose:d}):t.jsx(Ue,{onClose:d}):t.jsx(se,{rule:n,folders:r,delimiter:i,labels:c,preview:C,semanticAvailable:!1,clauseFields:L,anchorLocked:!0,clauseEdit:m,onStartAddClause:p,onStartEditClause:w,onRemoveClause:K,onChangeDraftField:O,onChangeDraftValue:B,onSubmitClause:U,onCancelClause:()=>u(void 0),onChangeMatchOperator:Q,onChangeMove:G,onCreateFolder:F,onChangeLabel:H,onCreateLabel:I,onChangeName:J,onChangeScope:V,onChangeUntil:q,onCommit:W,onCancel:d})}function Be(){return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[t.jsx(R,{className:"size-8 animate-spin text-accent-2"}),t.jsx("p",{className:"text-sm font-medium text-fg",children:"Saving changes…"})]})}function Ue({onClose:e}){return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[t.jsx(A,{className:"size-8 text-positive"}),t.jsx("p",{className:"text-sm font-medium text-fg",children:"Filter updated"}),t.jsx(N,{variant:"primary",onClick:e,className:"mt-2",children:"Done"})]})}function Ke({preview:e,blocked:a,onReapply:r,onClose:i}){return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[t.jsx(A,{className:"size-8 text-positive"}),t.jsx("p",{className:"text-sm font-medium text-fg",children:"Rule saved"}),t.jsxs("p",{className:"max-w-xs text-xs text-fg-muted",children:["New mail follows the rule automatically. ",e," — move the mail already in your mailbox too?"]}),t.jsxs("div",{className:"mt-2 flex gap-2",children:[t.jsx(N,{variant:"primary",onClick:r,disabled:a,children:"Move existing mail"}),t.jsx(N,{variant:"ghost",onClick:i,children:"Not now"})]})]})}function Qe({progress:e,isDone:a,onClose:r}){const i=e.state==="Failed";return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[a?i?t.jsx("span",{className:"text-sm font-semibold text-danger",children:"Move failed"}):t.jsx(A,{className:"size-8 text-positive"}):t.jsx(R,{className:"size-8 animate-spin text-accent-2"}),!a&&t.jsx("p",{className:"text-sm font-medium text-fg",children:"Moving existing mail…"}),a&&!i&&t.jsxs("div",{className:"text-sm text-fg",children:[t.jsx("p",{className:"font-medium",children:"Done"}),t.jsxs("p",{className:"mt-1 text-xs text-fg-muted",children:[e.appliedCount," of ",e.matchedCount," moved",e.failedCount>0?` · ${e.failedCount} failed`:"","."]})]}),a&&i&&t.jsx("p",{className:"max-w-xs text-xs text-fg-muted",children:e.errorMessage||"Something went wrong. Please try again."}),a&&t.jsx(N,{variant:"primary",onClick:r,className:"mt-2",children:"Done"})]})}function Ge({onRetry:e,onClose:a}){return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[t.jsx("p",{className:"text-sm font-medium text-danger",children:"Couldn't save changes"}),t.jsx("p",{className:"max-w-xs text-xs text-fg-muted",children:"Please try again."}),t.jsxs("div",{className:"mt-2 flex gap-2",children:[t.jsx(N,{variant:"primary",onClick:e,children:"Try again"}),t.jsx(N,{variant:"ghost",onClick:a,children:"Not now"})]})]})}function He({accountId:e,filter:a,folders:r,delimiter:i,labels:c,semanticUnavailable:g,onClose:d}){const f=Fe(),n=t.jsx(_e,{accountId:e,filter:a,folders:r,delimiter:i,labels:c,semanticUnavailable:g,onClose:d});return f?t.jsx(ie,{open:!0,onClose:d,title:"Filter rule",children:n}):t.jsx(ge,{open:!0,onClose:d,dismissLabel:"Dismiss filter rule",children:n})}function Je({filters:e,mailboxName:a,labelById:r,onEdit:i,onDelete:c,deletingFilterId:g,semanticUnavailable:d=!1,now:f=Date.now()}){return e.length===0?t.jsx("p",{className:"py-6 text-sm text-fg-muted",children:"No filters yet. Select a few messages in the inbox and choose Organize to make one."}):t.jsx("ul",{className:"divide-y divide-line rounded-md border border-line",children:e.map(n=>{const l=Me(n,f),m=l==="Expired",u=n.actionMailboxId!==S?a(n.actionMailboxId):void 0,h=n.actionLabelId!==S?r.get(n.actionLabelId):void 0,b=Ie(n.expiresAt);return t.jsxs("li",{className:"flex items-start gap-3 px-3 py-2.5",children:[t.jsxs("button",{type:"button",onClick:()=>i(n.filterId),"aria-label":`Edit filter ${n.name}`,className:"min-w-0 flex-1 rounded-sm text-left hover:opacity-80",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`truncate text-sm font-medium ${m?"text-fg-muted":"text-fg"}`,children:n.name}),t.jsx(ne,{tone:m?"neutral":"positive",dot:!0,children:l})]}),t.jsxs("p",{className:"mt-0.5 text-xs text-fg-subtle",children:[u?`Moves matches to ${u}`:"No move action",n.scope==="Temporary"&&b?m?` · expired ${b}`:` · until ${b}`:n.scope==="Standing"?" · always":""]}),(n.hasAnchor||h)&&t.jsxs("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:[n.hasAnchor&&t.jsx(re,{widen:{anchorCount:1,...d?{inactive:!0}:{}}}),h&&t.jsx(oe,{label:{labelId:h.id,name:h.name,color:h.color}})]})]}),t.jsx(N,{variant:"ghost",size:"sm",icon:t.jsx(le,{className:"size-4 text-danger"}),onClick:()=>c(n.filterId),disabled:g===n.filterId,"aria-label":`Delete filter ${n.name}`})]},n.filterId)})})}const Ve=t.jsxs("div",{className:"space-y-3",children:[t.jsxs("p",{children:["Filters are the standing rules Organize creates. A"," ",t.jsx("strong",{children:"Standing"})," filter keeps working on new mail; a"," ",t.jsx("strong",{children:"Temporary"})," one stops on its own at the date you picked."]}),t.jsx("p",{children:"An expired filter isn't deleted the instant it lapses — it stays here, marked Expired, so you can see what it did and when it stopped."})]});function qe({account:e}){const a=e.accountId,{filters:r,isPending:i,isError:c,error:g,refetch:d}=we(a),{deleteFilter:f,deletingFilterId:n}=Ee(a),[l,m]=x.useState(),{data:u}=z({...ce({path:{accountId:a}}),staleTime:1/0}),h=De(),b=x.useMemo(()=>de(e.folderAppointments),[e.folderAppointments]),M=x.useCallback(p=>{const w=u?.items.find(O=>O.mailboxId===p);if(w)return me(w,b.get(p),h)},[u?.items,b,h]),C=x.useMemo(()=>Ae({mailboxes:u?.items??[],folderAppointments:e.folderAppointments,translator:h}),[u?.items,e.folderAppointments,h]),j=Le(u?.items??[]),{labels:v}=ke(a),F=x.useMemo(()=>v.map(p=>({id:p.labelId,name:p.name,color:p.color})),[v]),E=x.useMemo(()=>new Map(F.map(p=>[p.id,p])),[F]),I=r.find(p=>p.filterId===l);return t.jsxs("section",{className:"space-y-2",children:[t.jsx("h2",{className:"text-sm font-semibold text-fg",children:e.email}),I&&t.jsx(He,{accountId:a,filter:I,folders:C,delimiter:j,labels:F,onClose:()=>m(void 0)}),i?t.jsx("div",{className:"h-16 animate-pulse rounded-md border border-line bg-surface","aria-busy":"true","aria-label":`Loading filters for ${e.email}`}):c?t.jsx(P,{variant:"inline",title:`Couldn't load filters for ${e.email}`,error:g,onRetry:()=>{d()}}):t.jsx(Je,{filters:r,mailboxName:M,labelById:E,onEdit:m,onDelete:f,deletingFilterId:n})]})}function dt(){const e=ue(),[a,r]=x.useState(!0),{data:i,isPending:c,isError:g,error:d,refetch:f}=z(pe()),n=l=>{const m=fe[l];m&&e({to:m})};return t.jsx(he,{items:xe,activeId:"filters",title:"Filters",description:"Standing and temporary rules created by Organize, per account.",help:Ve,helpOpen:a,onToggleHelp:()=>r(l=>!l),onSelect:n,onBackToMail:()=>{e({to:"/mail"})},children:c?t.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":"Loading accounts"}):g?t.jsx(P,{title:"Couldn't load accounts",error:d,onRetry:()=>{f()}}):i.accounts.length===0?t.jsx("p",{className:"py-12 text-sm text-fg-muted",children:"No accounts configured."}):t.jsx("div",{className:"space-y-8",children:i.accounts.map(l=>t.jsx(qe,{account:l},l.accountId))})})}export{qe as AccountFilters,dt as component};
@@ -1 +0,0 @@
1
- import{j as o,a0 as i}from"./index-CoNvZIm_.js";import{a as m}from"./search-view-DBvRPRa1.js";import{F as r}from"./FlaggedPane-WLhe7MTQ.js";import{u as p}from"./useSearchMirror-eiX731bE.js";import"./nav-link-7QYETm4r.js";import{u as e}from"./MailListHeader-CsMXujM8.js";import"./useSearchTokenContext-BnSrnFlb.js";import"./kbd-37YHrOod.js";import"./use-match-media-BezqzsJW.js";import"./enums-CCxx0t2v.js";import"./search-scope-DpxLT3gw.js";import"./MailViewChrome-7pIGoTSB.js";import"./search-token-index-e3fTB436.js";import"./layout-breakpoints-BWjiUQKh.js";import"./avatar-BpcGfGBY.js";import"./account-form-helpers-1QlePfxz.js";import"./menu-B6RXxSm8.js";import"./ErrorState-EG2eHLL1.js";import"./useFilters-BBQH0MKH.js";import"./useSignature-DIdZs8UQ.js";import"./useDebouncedValue-CDnuOkob.js";import"./format-De9HZKjg.js";import"./download-CdBITb1R.js";import"./shield-check-XKwP5L-S.js";import"./move-options-BHPhC1Kk.js";import"./confirm-dialog-C2G4kIKu.js";import"./clock-tsMaR7Oh.js";function v(){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{v as component};
@@ -1 +0,0 @@
1
- import{j as r}from"./index-CoNvZIm_.js";import{B as o}from"./BriefPane-Cf0qx6oW.js";import"./useSearchTokenContext-BnSrnFlb.js";import"./kbd-37YHrOod.js";import"./use-match-media-BezqzsJW.js";import"./enums-CCxx0t2v.js";import"./search-scope-DpxLT3gw.js";import"./MailListHeader-CsMXujM8.js";import"./search-token-index-e3fTB436.js";import"./layout-breakpoints-BWjiUQKh.js";import"./account-form-helpers-1QlePfxz.js";import"./avatar-BpcGfGBY.js";import"./useSignature-DIdZs8UQ.js";import"./useDebouncedValue-CDnuOkob.js";import"./useFilters-BBQH0MKH.js";import"./ErrorState-EG2eHLL1.js";import"./format-De9HZKjg.js";import"./nav-link-7QYETm4r.js";import"./download-CdBITb1R.js";import"./shield-check-XKwP5L-S.js";import"./move-options-BHPhC1Kk.js";import"./confirm-dialog-C2G4kIKu.js";import"./clock-tsMaR7Oh.js";import"./menu-B6RXxSm8.js";import"./useRefreshControl-DlypbbhJ.js";import"./circle-check-big-CBG0107E.js";import"./useLabels-Dxb6ajq-.js";import"./useSemanticSearch-Dn1P2d8-.js";import"./search-query-Cr_ZXBCp.js";function A(){return r.jsx(o.Reading,{})}export{A as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-CoNvZIm_.js";import{M as r}from"./MailboxPane-DkPAPzBT.js";import"./useSearchTokenContext-BnSrnFlb.js";import"./kbd-37YHrOod.js";import"./use-match-media-BezqzsJW.js";import"./enums-CCxx0t2v.js";import"./search-scope-DpxLT3gw.js";import"./useRefreshControl-DlypbbhJ.js";import"./circle-check-big-CBG0107E.js";import"./search-token-index-e3fTB436.js";import"./layout-breakpoints-BWjiUQKh.js";import"./MailListHeader-CsMXujM8.js";import"./account-form-helpers-1QlePfxz.js";import"./avatar-BpcGfGBY.js";import"./useSignature-DIdZs8UQ.js";import"./useDebouncedValue-CDnuOkob.js";import"./useFilters-BBQH0MKH.js";import"./ErrorState-EG2eHLL1.js";import"./format-De9HZKjg.js";import"./nav-link-7QYETm4r.js";import"./download-CdBITb1R.js";import"./shield-check-XKwP5L-S.js";import"./move-options-BHPhC1Kk.js";import"./confirm-dialog-C2G4kIKu.js";import"./clock-tsMaR7Oh.js";import"./menu-B6RXxSm8.js";import"./MailViewChrome-7pIGoTSB.js";import"./NavMenuButton-DiNk3STC.js";import"./useLabels-Dxb6ajq-.js";import"./useSemanticSearch-Dn1P2d8-.js";import"./search-query-Cr_ZXBCp.js";import"./bottom-sheet-Bb9_P1q_.js";import"./circle-help-aRUYdfvH.js";import"./circle-check-rylkL795.js";import"./intelligence-pref-C6lFpj6U.js";function H(){return o.jsx(r.Reading,{})}export{H as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-CoNvZIm_.js";import{F as r}from"./FlaggedPane-WLhe7MTQ.js";import"./useSearchTokenContext-BnSrnFlb.js";import"./kbd-37YHrOod.js";import"./use-match-media-BezqzsJW.js";import"./enums-CCxx0t2v.js";import"./search-scope-DpxLT3gw.js";import"./MailListHeader-CsMXujM8.js";import"./search-token-index-e3fTB436.js";import"./layout-breakpoints-BWjiUQKh.js";import"./account-form-helpers-1QlePfxz.js";import"./avatar-BpcGfGBY.js";import"./useSignature-DIdZs8UQ.js";import"./useDebouncedValue-CDnuOkob.js";import"./useFilters-BBQH0MKH.js";import"./ErrorState-EG2eHLL1.js";import"./format-De9HZKjg.js";import"./nav-link-7QYETm4r.js";import"./download-CdBITb1R.js";import"./shield-check-XKwP5L-S.js";import"./move-options-BHPhC1Kk.js";import"./confirm-dialog-C2G4kIKu.js";import"./clock-tsMaR7Oh.js";import"./menu-B6RXxSm8.js";import"./MailViewChrome-7pIGoTSB.js";function w(){return o.jsx(r.Reading,{})}export{w as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-CoNvZIm_.js";import{M as i}from"./MailboxPane-DkPAPzBT.js";import"./useSearchTokenContext-BnSrnFlb.js";import"./kbd-37YHrOod.js";import"./use-match-media-BezqzsJW.js";import"./enums-CCxx0t2v.js";import"./search-scope-DpxLT3gw.js";import"./useRefreshControl-DlypbbhJ.js";import"./circle-check-big-CBG0107E.js";import"./search-token-index-e3fTB436.js";import"./layout-breakpoints-BWjiUQKh.js";import"./MailListHeader-CsMXujM8.js";import"./account-form-helpers-1QlePfxz.js";import"./avatar-BpcGfGBY.js";import"./useSignature-DIdZs8UQ.js";import"./useDebouncedValue-CDnuOkob.js";import"./useFilters-BBQH0MKH.js";import"./ErrorState-EG2eHLL1.js";import"./format-De9HZKjg.js";import"./nav-link-7QYETm4r.js";import"./download-CdBITb1R.js";import"./shield-check-XKwP5L-S.js";import"./move-options-BHPhC1Kk.js";import"./confirm-dialog-C2G4kIKu.js";import"./clock-tsMaR7Oh.js";import"./menu-B6RXxSm8.js";import"./MailViewChrome-7pIGoTSB.js";import"./NavMenuButton-DiNk3STC.js";import"./useLabels-Dxb6ajq-.js";import"./useSemanticSearch-Dn1P2d8-.js";import"./search-query-Cr_ZXBCp.js";import"./bottom-sheet-Bb9_P1q_.js";import"./circle-help-aRUYdfvH.js";import"./circle-check-rylkL795.js";import"./intelligence-pref-C6lFpj6U.js";function I(){return o.jsx(i.Reading,{})}export{I as component};
@@ -1 +0,0 @@
1
- import{j as r}from"./index-CoNvZIm_.js";import{B as o}from"./BriefPane-Cf0qx6oW.js";import"./useSearchTokenContext-BnSrnFlb.js";import"./kbd-37YHrOod.js";import"./use-match-media-BezqzsJW.js";import"./enums-CCxx0t2v.js";import"./search-scope-DpxLT3gw.js";import"./MailListHeader-CsMXujM8.js";import"./search-token-index-e3fTB436.js";import"./layout-breakpoints-BWjiUQKh.js";import"./account-form-helpers-1QlePfxz.js";import"./avatar-BpcGfGBY.js";import"./useSignature-DIdZs8UQ.js";import"./useDebouncedValue-CDnuOkob.js";import"./useFilters-BBQH0MKH.js";import"./ErrorState-EG2eHLL1.js";import"./format-De9HZKjg.js";import"./nav-link-7QYETm4r.js";import"./download-CdBITb1R.js";import"./shield-check-XKwP5L-S.js";import"./move-options-BHPhC1Kk.js";import"./confirm-dialog-C2G4kIKu.js";import"./clock-tsMaR7Oh.js";import"./menu-B6RXxSm8.js";import"./useRefreshControl-DlypbbhJ.js";import"./circle-check-big-CBG0107E.js";import"./useLabels-Dxb6ajq-.js";import"./useSemanticSearch-Dn1P2d8-.js";import"./search-query-Cr_ZXBCp.js";function C(){return r.jsx(o.Reading,{})}export{C as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-CoNvZIm_.js";import{F as r}from"./FlaggedPane-WLhe7MTQ.js";import"./useSearchTokenContext-BnSrnFlb.js";import"./kbd-37YHrOod.js";import"./use-match-media-BezqzsJW.js";import"./enums-CCxx0t2v.js";import"./search-scope-DpxLT3gw.js";import"./MailListHeader-CsMXujM8.js";import"./search-token-index-e3fTB436.js";import"./layout-breakpoints-BWjiUQKh.js";import"./account-form-helpers-1QlePfxz.js";import"./avatar-BpcGfGBY.js";import"./useSignature-DIdZs8UQ.js";import"./useDebouncedValue-CDnuOkob.js";import"./useFilters-BBQH0MKH.js";import"./ErrorState-EG2eHLL1.js";import"./format-De9HZKjg.js";import"./nav-link-7QYETm4r.js";import"./download-CdBITb1R.js";import"./shield-check-XKwP5L-S.js";import"./move-options-BHPhC1Kk.js";import"./confirm-dialog-C2G4kIKu.js";import"./clock-tsMaR7Oh.js";import"./menu-B6RXxSm8.js";import"./MailViewChrome-7pIGoTSB.js";function v(){return o.jsx(r.Reading,{})}export{v as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-CoNvZIm_.js";import{O as t}from"./OutboxPane-DzBz96fV.js";import"./useSearchTokenContext-BnSrnFlb.js";import"./kbd-37YHrOod.js";import"./use-match-media-BezqzsJW.js";import"./enums-CCxx0t2v.js";import"./search-scope-DpxLT3gw.js";import"./circle-check-big-CBG0107E.js";import"./clock-tsMaR7Oh.js";import"./row-actions-DzYchsTL.js";import"./rotate-ccw-BozetpiQ.js";import"./NavMenuButton-DiNk3STC.js";import"./menu-B6RXxSm8.js";import"./format-De9HZKjg.js";import"./outbox-status-CPfNHfUQ.js";import"./search-query-Cr_ZXBCp.js";function d(){return o.jsx(t.Reading,{})}export{d as component};
@@ -1 +0,0 @@
1
- import{j as t,a7 as o}from"./index-CoNvZIm_.js";const n=()=>t.jsx(o,{to:"/settings/accounts"});export{n as component};
@@ -1 +0,0 @@
1
- const t="(min-width: 1024px) and (not ((orientation: portrait) and (pointer: coarse)))";export{t as D};