@remit/web-client-dist 0.0.349 → 0.0.351

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 (99) hide show
  1. package/assets/BriefPane-D5U_FMo6.js +1 -0
  2. package/assets/{ErrorState-DlHdbl1h.js → ErrorState-DrA1RdFM.js} +1 -1
  3. package/assets/FlaggedPane-CD0MhkHu.js +1 -0
  4. package/assets/{MailListHeader-BFBjOnAW.js → MailListHeader-BJ9doZxm.js} +11 -11
  5. package/assets/{MailViewChrome-XjLFqRLL.js → MailViewChrome-wpRug1Q0.js} +1 -1
  6. package/assets/{MailboxPane-BwHG9r2e.js → MailboxPane-CUVIV3ip.js} +1 -1
  7. package/assets/{NavMenuButton-D_W6DXrb.js → NavMenuButton-Dy0q8FiJ.js} +1 -1
  8. package/assets/{OnboardingWizard-D8Zk-VXt.js → OnboardingWizard-DxBnC5ZI.js} +1 -1
  9. package/assets/{OutboxPane-D2d4W5AT.js → OutboxPane-DD3Oj-FL.js} +1 -1
  10. package/assets/_mailboxId-BTlxhtzs.js +1 -0
  11. package/assets/_messageId-CUwYB2GP.js +1 -0
  12. package/assets/_messageId-DFuKJd0-.js +1 -0
  13. package/assets/_messageId-DOJy3_kq.js +1 -0
  14. package/assets/_outboxMessageId-DkVUQAXG.js +1 -0
  15. package/assets/_threadId-D6AYslSV.js +1 -0
  16. package/assets/_threadId-JDDKxHld.js +1 -0
  17. package/assets/_threadId-oY_n41uG.js +1 -0
  18. package/assets/{account-form-helpers-CwJTqJha.js → account-form-helpers-D1exxHT6.js} +1 -1
  19. package/assets/{accounts-sOzFT-mC.js → accounts-CZkcoZsJ.js} +1 -1
  20. package/assets/{advanced-MP09rSMr.js → advanced-BY_XBoCx.js} +1 -1
  21. package/assets/{appearance-DHJRN3ld.js → appearance-BszRkKRP.js} +1 -1
  22. package/assets/{avatar-D3R75Qgk.js → avatar-lbydjrIt.js} +1 -1
  23. package/assets/{bottom-sheet-BKnsFMEf.js → bottom-sheet-BZM-qnW9.js} +1 -1
  24. package/assets/brief-BAvH751q.js +1 -0
  25. package/assets/{brief-DqILJyQz.js → brief-DAZY-yDt.js} +1 -1
  26. package/assets/{browser-ponyfill-CTm-DR6u.js → browser-ponyfill-1mYU3VEo.js} +1 -1
  27. package/assets/{bug-C2LRkTHS.js → bug-LK0uYJOc.js} +1 -1
  28. package/assets/{circle-check-C1n1yijO.js → circle-check-BO9xAEiG.js} +1 -1
  29. package/assets/{circle-check-big-BmnT3rLr.js → circle-check-big-xK5jTBa2.js} +1 -1
  30. package/assets/{circle-help-BJLBqOAA.js → circle-help-D-5uStGy.js} +1 -1
  31. package/assets/{clock-BNqM2h_T.js → clock-CdRZkrpV.js} +1 -1
  32. package/assets/{confirm-dialog-C1Q_9oNl.js → confirm-dialog-DZ3dfzvC.js} +1 -1
  33. package/assets/{download-aqyrBjOU.js → download-BRZRRebx.js} +1 -1
  34. package/assets/{filters-y-tc_bzr.js → filters-CJtRXFIT.js} +1 -1
  35. package/assets/{flagged-D6yLzY2X.js → flagged-B4b0rbUr.js} +1 -1
  36. package/assets/flagged-Cj1lkP-D.js +1 -0
  37. package/assets/{folders-KxXDRobS.js → folders-CMjuCzAd.js} +1 -1
  38. package/assets/index-72yU2-kn.js +1 -0
  39. package/assets/index-BfJZRVVj.js +1 -0
  40. package/assets/{index-DKG1l4OE.js → index-Bo-p3LpF.js} +50 -50
  41. package/assets/index-BxygYghU.js +1 -0
  42. package/assets/index-CUwYB2GP.js +1 -0
  43. package/assets/index-DFS5aq3D.js +1 -0
  44. package/assets/index-DKsFKmu0.js +1 -0
  45. package/assets/index-DOJy3_kq.js +1 -0
  46. package/assets/index-nszVYODK.js +1 -0
  47. package/assets/{kbd-CnUDSPH5.js → kbd-0M4qAi49.js} +1 -1
  48. package/assets/{labels-BmRFi78i.js → labels-CuC6gcyn.js} +1 -1
  49. package/assets/{mail-CK2ZaY0m.js → mail-DEw6NSuJ.js} +1 -1
  50. package/assets/{menu-DdqPoHXZ.js → menu-vnrvhz9W.js} +1 -1
  51. package/assets/{move-options-DXhjey10.js → move-options-_eZlt0v0.js} +1 -1
  52. package/assets/{nav-link-BTQmJNls.js → nav-link-BC-lpJt4.js} +1 -1
  53. package/assets/{onboarding-AkJlSpsK.js → onboarding-B1ncdxiJ.js} +1 -1
  54. package/assets/outbox-C-BbuTN9.js +1 -0
  55. package/assets/{pencil-DFHNbAYX.js → pencil-7SyIHZVc.js} +1 -1
  56. package/assets/{rich-text-CBLH_ljE.js → rich-text-DbpnpZXL.js} +1 -1
  57. package/assets/{rich-text-spellcheck-worker-provider-8XL6BOiI.js → rich-text-spellcheck-worker-provider-LftNISS3.js} +1 -1
  58. package/assets/{rotate-ccw-CYszpTkF.js → rotate-ccw-CKKgjGEq.js} +1 -1
  59. package/assets/{row-actions-DjIKrPVk.js → row-actions-7xv7AJ82.js} +1 -1
  60. package/assets/{search-token-index-D13ogntK.js → search-token-index-sLIcvT6p.js} +1 -1
  61. package/assets/{search-view-B5prVpGW.js → search-view-CB5G4Kva.js} +1 -1
  62. package/assets/{senders-BFXe7Id6.js → senders-O9M02K_2.js} +1 -1
  63. package/assets/settings-CI2VbWFc.js +1 -0
  64. package/assets/{settings-screen-BgOpI_Lx.js → settings-screen-CjdCNCJ8.js} +1 -1
  65. package/assets/{shield-check-BBp9gzDX.js → shield-check-C48_fmzW.js} +1 -1
  66. package/assets/{suggested-vips-DFwiEmrP.js → suggested-vips-BXGwlIUy.js} +1 -1
  67. package/assets/{use-match-media-C1DFe6n_.js → use-match-media-jqJ95ElE.js} +1 -1
  68. package/assets/{useDebouncedValue-BazHTAhQ.js → useDebouncedValue-bAON8Yph.js} +1 -1
  69. package/assets/{useFilters-DBElfc_V.js → useFilters-D_O09QB6.js} +1 -1
  70. package/assets/{useLabels-CZdQ7rFS.js → useLabels-wgL9c4lv.js} +1 -1
  71. package/assets/{useRefreshControl-DN40VgNE.js → useRefreshControl-hxsw2pLp.js} +1 -1
  72. package/assets/{useSearchMirror-CiaVi7jg.js → useSearchMirror-DylRqxaA.js} +1 -1
  73. package/assets/{useSearchTokenContext-BNRIlJev.js → useSearchTokenContext-Bb3YnI52.js} +1 -1
  74. package/assets/{useSemanticSearch-BHpjDfP4.js → useSemanticSearch-BXCI_0Rt.js} +1 -1
  75. package/assets/{useSignature-BaYkV0lH.js → useSignature-sSo464BG.js} +1 -1
  76. package/index.html +1 -1
  77. package/package.json +1 -1
  78. package/assets/BriefPane-BfuwvROx.js +0 -1
  79. package/assets/FlaggedPane-DXXvbNMD.js +0 -1
  80. package/assets/_mailboxId-DstK-xUR.js +0 -1
  81. package/assets/_messageId-CLaETLs-.js +0 -1
  82. package/assets/_messageId-DRTBuwn5.js +0 -1
  83. package/assets/_messageId-DmZCgc4u.js +0 -1
  84. package/assets/_outboxMessageId-DSVc6DQy.js +0 -1
  85. package/assets/_threadId-DiPJwQ2o.js +0 -1
  86. package/assets/_threadId-Djs3CNia.js +0 -1
  87. package/assets/_threadId-DtfbogPc.js +0 -1
  88. package/assets/brief-C5lHNp6b.js +0 -1
  89. package/assets/flagged-DsEl2-dg.js +0 -1
  90. package/assets/index-Bmrb3uML.js +0 -1
  91. package/assets/index-C8bsgH_w.js +0 -1
  92. package/assets/index-CcuWjbLO.js +0 -1
  93. package/assets/index-Cf7AKvjm.js +0 -1
  94. package/assets/index-DRTBuwn5.js +0 -1
  95. package/assets/index-DhwJT0Xk.js +0 -1
  96. package/assets/index-DmZCgc4u.js +0 -1
  97. package/assets/index-WhbhbXhS.js +0 -1
  98. package/assets/outbox-CYHiwpl8.js +0 -1
  99. package/assets/settings-DSF3NSGu.js +0 -1
@@ -1 +1 @@
1
- import{j as e,an as re,B as A,e as ie,r as x,b as Q,ao as oe,T as ce,bI as le,u as ue,bJ as U,bt as de,bK as fe,bL as me,bM as xe,bN as ge,o as he,bu as pe,bO as be}from"./index-DKG1l4OE.js";import{R as ve,l as je,m as we}from"./search-token-index-D13ogntK.js";import{ap as Ne,aq as ye,c as Pe,b as q,ar as Ce,v as Re,as as ke,at as Se,au as Me,af as Ee,ah as Ie}from"./MailListHeader-BFBjOnAW.js";import{A as Oe}from"./avatar-D3R75Qgk.js";import{M as ze}from"./account-form-helpers-CwJTqJha.js";import{M as Le}from"./menu-DdqPoHXZ.js";function De(){return e.jsx("div",{className:"space-y-0",role:"status","aria-busy":"true","aria-label":"Loading messages",children:Array.from({length:8}).map((s,n)=>e.jsxs("div",{className:"animate-pulse border-b border-line px-3 py-2",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("div",{className:"h-4 w-32 rounded bg-surface-sunken"}),e.jsx("div",{className:"h-3 w-16 rounded bg-surface-sunken"})]}),e.jsx("div",{className:"mb-2 h-4 w-48 rounded bg-surface-sunken"}),e.jsx("div",{className:"h-3 w-full rounded bg-surface-sunken"})]},n))})}function Te({filter:s,scopeLabel:n,searchQuery:r}){const f=r?.trim();return s?e.jsxs(G,{children:[e.jsx("p",{className:"font-medium text-fg",children:$e(s.label,n,f)}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:_e[s.reach]}),e.jsx(A,{variant:"secondary",size:"sm",className:"mt-4",onClick:s.onClear,children:"Clear filter"})]}):e.jsx(G,{children:e.jsx("p",{className:"text-fg-muted",children:Ae(f,n)})})}const _e={"whole-folder":"Every message in this folder was checked.","loaded-pages":"Only the messages loaded so far were checked."};function Ae(s,n){return s?"No messages match your search":n?`No messages in ${n}`:"No messages in this mailbox"}function $e(s,n,r){return r?`No results for “${r}” in ${s}`:n?`No ${s} mail in ${n}`:`No ${s} mail`}function G({children:s}){return e.jsx("div",{className:"flex h-full flex-1 items-center justify-center",children:e.jsx("div",{className:"flex max-w-sm flex-col items-center justify-center p-8 text-center",children:s})})}function Ze(){return e.jsxs("div",{className:"flex items-center justify-center gap-2 py-4 text-sm text-fg-muted",role:"status","aria-live":"polite",children:[e.jsx(re,{className:"size-4 animate-spin","aria-hidden":"true"}),e.jsx("span",{children:"Loading more…"})]})}function Fe({message:s="Something went wrong loading this mailbox.",onRetry:n,onReport:r}){return e.jsx("div",{className:"flex h-full flex-1 items-center justify-center p-4",children:e.jsxs("div",{role:"alert",className:"flex max-w-sm flex-col items-center justify-center gap-3 text-center",children:[e.jsx(ie,{className:"size-8 text-danger","aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-danger",children:"Couldn't load messages"}),e.jsx("p",{className:"mt-1 break-words text-sm text-fg-muted",children:s})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[n&&e.jsx(A,{variant:"secondary",size:"sm",onClick:n,children:"Retry"}),r&&e.jsx(A,{variant:"ghost",size:"sm",onClick:r,children:"Report a problem"})]})]})})}const O=72,J=10,He=O/2,V="__swipeableRowAxisCancel";function Z(s){return s==="leading"?O:s==="trailing"?-O:0}function Xe(s){return s>=O/2?"leading":s<=-O/2?"trailing":"none"}function Be({thread:s,selectionMode:n,checked:r,active:f,peek:m,onPeek:g,onToggleCheck:y,onLongPress:j,onOpen:h,onAct:p}){const d=x.useRef(null),[b,v]=x.useState(null),{longPressProps:P}=Ne({onLongPress:j,isDisabled:n,accessibilityDescription:"Select message"}),k=i=>{const o=new PointerEvent("pointercancel",{bubbles:!0});o[V]=!0,i.currentTarget.dispatchEvent(o)},a=ye(P,{onPointerDown:i=>{d.current={startX:i.clientX,startY:i.clientY,axis:"none",escaped:!1}},onPointerMove:i=>{if(n)return;const o=d.current;if(!o)return;const u=i.clientX-o.startX,M=i.clientY-o.startY;if(o.axis==="none"&&(Math.abs(M)>J&&Math.abs(M)>Math.abs(u)?o.axis="vertical":Math.abs(u)>J&&Math.abs(u)>Math.abs(M)&&(o.axis="horizontal",i.currentTarget.setPointerCapture(i.pointerId))),o.axis==="none")return;const z=o.axis==="horizontal"?Math.abs(u):Math.abs(M);if(!o.escaped&&z>He&&(o.escaped=!0,k(i)),o.axis!=="horizontal")return;const F=Z(m),H=Math.max(-O,Math.min(O,F+u));v(H)},onPointerUp:i=>{const o=d.current;d.current=null;const u=b;if(v(null),!!o){if(o.axis!=="none"&&!o.escaped&&k(i),o.axis==="horizontal"){u!==null&&g(Xe(u));return}if(o.axis!=="vertical"){if(n){y();return}if(m!=="none"){g("none");return}h()}}},onPointerCancel:i=>{i.nativeEvent[V]||(d.current=null,v(null))}}),l=b??Z(m),N=l>0?"leading":l<0?"trailing":"none",C=Q("relative touch-pan-y bg-surface","select-none",Pe({active:r||f})),D={transform:l!==0?`translateX(${l}px)`:void 0,transition:b===null?"transform 150ms ease":"none",minHeight:44},$=!s.isRead,I=i=>i.stopPropagation(),T=n?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:Q("inline-flex size-7 shrink-0 items-center justify-center rounded-full border",r?"border-accent bg-accent text-accent-fg":"border-line-strong bg-canvas"),children:r&&e.jsx(oe,{className:"size-3.5"})}),e.jsx(q,{thread:s})]}):e.jsxs(e.Fragment,{children:[$&&e.jsx("span",{className:"absolute left-1.5 top-1/2 size-1.5 -translate-y-1/2 rounded-full bg-accent"}),e.jsx("span",{role:"checkbox",tabIndex:0,"aria-checked":r,"aria-label":`Select message from ${s.fromName}`,onPointerDown:I,onPointerMove:I,onPointerUp:I,onClick:i=>{i.preventDefault(),i.stopPropagation(),j()},onKeyDown:i=>{i.key!=="Enter"&&i.key!==" "||(i.preventDefault(),i.stopPropagation(),j())},className:"-m-2 inline-flex size-11 shrink-0 items-center justify-center rounded-full",children:e.jsx(Oe,{name:s.fromName,email:s.fromEmail,size:"sm"})}),e.jsx(q,{thread:s})]});return e.jsxs("div",{className:"relative overflow-hidden",children:[N==="leading"&&e.jsx("button",{type:"button",onClick:()=>p("leading"),"aria-label":s.isRead?"Mark as unread":"Mark as read",className:"absolute inset-y-0 left-0 flex items-center justify-start bg-accent-2 px-6 text-accent-fg",children:s.isRead?e.jsx(ze,{className:"size-6"}):e.jsx(Ce,{className:"size-6"})}),N==="trailing"&&e.jsx("button",{type:"button",onClick:()=>p("trailing"),"aria-label":"Delete message",className:"absolute inset-y-0 right-0 flex items-center justify-end bg-danger px-6 text-canvas",children:e.jsx(ce,{className:"size-6"})}),e.jsx("button",{type:"button",role:n?"checkbox":void 0,"aria-checked":n?r:void 0,"data-message-row":!0,"data-message-id":s.id,...a,className:C,style:D,children:T})]})}function Ke({sections:s,selectedThreadId:n,selectionMode:r,checkedIds:f,initialPeek:m,onToggleCheck:g,onEnterSelection:y,onOpenThread:j,onRefresh:h,refreshing:p,busy:d=!1}){const[b,v]=x.useState(new Set),[P,k]=x.useState(new Map),w=s.flatMap(a=>a.threads).filter(a=>!b.has(a.id)).map(a=>{const l=P.get(a.id);return l===void 0?a:{...a,isRead:l}}),[S,R]=x.useState(m&&m!=="none"&&w[1]?{id:w[1].id,side:m}:null),E=(a,l)=>{if(l==="trailing")v(N=>new Set(N).add(a));else{const N=w.find(C=>C.id===a);k(C=>new Map(C).set(a,!N?.isRead))}R(null)};return e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[p&&e.jsxs("div",{className:"flex items-center justify-center gap-2 border-b border-line py-3 text-fg-muted",children:[e.jsx(ve,{className:"size-4 animate-spin"}),e.jsx("span",{className:"text-xs",children:"Checking for new mail…"})]}),e.jsx("div",{className:"divide-y divide-line",children:w.map(a=>e.jsx("div",{className:d?"pointer-events-none opacity-50":void 0,children:e.jsx(Be,{thread:a,selectionMode:r,checked:f.has(a.id),active:a.id===n,peek:S?.id===a.id?S.side:"none",onPeek:l=>R(l==="none"?null:{id:a.id,side:l}),onToggleCheck:()=>g(a.id),onLongPress:()=>y(a.id),onOpen:()=>j(a.id),onAct:l=>E(a.id,l)})},a.id))}),!r&&!p&&!d&&e.jsx("button",{type:"button",onClick:h,className:"w-full border-t border-line py-2 text-center text-2xs text-fg-subtle transition-colors hover:bg-surface-sunken",children:"Pull to refresh"})]})}const We=new Set;function es({listTitle:s,listMeta:n,sections:r,briefFilters:f,flatList:m,listState:g="ready",searchQuery:y,listFilter:j,listScopeLabel:h,errorMessage:p,onRetry:d,onReportError:b,briefFilter:v,selectedThreadId:P,density:k="comfortable",onSelectThread:w,onOpenNav:S,isDesktop:R,initialTouchState:E,selection:a,keyboard:l,selectionBar:N,paneOverlay:C,listBody:D,hideHeader:$=!1}){const I=k==="compact"?Se:Me,T=x.useRef(null),i=x.useRef(null),o=le(l);ue({containerRef:T,itemSelector:U,enabled:!o});const u=o?l.focusedId:void 0,M=o?u??r[0]?.threads[0]?.id:void 0,z=x.useCallback(t=>M===void 0?void 0:t===M?0:-1,[M]);x.useEffect(()=>{if(u===void 0)return;const t=i.current;if(!t)return;const c=t.querySelector(`${U}[data-message-id="${u}"]`);!c||c===t.ownerDocument.activeElement||c.focus({preventScroll:!1})},[u]),x.useEffect(()=>{if(!o)return;const t=i.current;if(!t)return;const c=t.ownerDocument.activeElement;c!==null&&c!==t.ownerDocument.body||t.focus({preventScroll:!0})},[o]);const F=!R&&!f&&g==="ready",[H,W]=x.useState(!1),ee=E==="peek-trailing"?"trailing":E==="peek-leading"?"leading":void 0,se=()=>{W(!0),setTimeout(()=>W(!1),1400)},_=a?.selectedIds??We,L=a?.onToggle,Y=a?.onRowSelect,te=Re(_.size,R),X=x.useCallback(t=>{if(L)return{checked:_.has(t),onToggle:c=>{c.preventDefault(),c.stopPropagation(),L(t)}}},[_,L]),B=x.useCallback((t,c)=>Y?.(t,ke(c))?(c.preventDefault(),c.shiftKey&&window.getSelection()?.removeAllRanges(),!0):!1,[Y]),ne=x.useCallback(({thread:t,active:c,onClick:K})=>e.jsx(I,{thread:t,active:c,focused:t.id===u,tabIndex:z(t.id),selection:X(t.id),onClick:ae=>{B(t.id,ae)||K?.()}}),[I,X,B,u,z]);return e.jsxs("section",{ref:t=>{i.current=t,l?.ref(t)},tabIndex:o?-1:void 0,className:"relative flex h-full w-full flex-col bg-surface outline-none",children:[N??($?null:e.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[S&&e.jsx(A,{variant:"ghost",size:"sm",icon:e.jsx(Le,{className:"size-4"}),onClick:S,"aria-label":"Open folders",className:"-ml-1 shrink-0"}),e.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:s}),n&&e.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle",children:n})]})),g==="loading"?e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsx(De,{})}):g==="empty"?e.jsx(Te,{filter:j,scopeLabel:h,searchQuery:y}):g==="error"?e.jsx(Fe,{message:p,onRetry:d,onReport:b}):f?e.jsx(de,{...v??{},sections:r,selectedThreadId:P,Row:ne,keyboard:l,onSelectThread:w}):D??(F?e.jsx(Ke,{sections:r,selectedThreadId:P,selectionMode:te,checkedIds:_,initialPeek:ee,onToggleCheck:t=>L?.(t),onEnterSelection:t=>L?.(t),onOpenThread:t=>w?.(t),onRefresh:se,refreshing:H}):e.jsx("div",{ref:T,className:"flex-1 overflow-y-auto",children:r.map(t=>e.jsxs("div",{children:[!m&&t.label&&e.jsxs("div",{className:"sticky top-0 flex h-section-row items-center justify-between border-b border-line bg-surface-sunken px-row-inset",children:[e.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:t.label}),e.jsx("span",{className:"text-2xs text-fg-subtle tabular-nums",children:t.threads.length})]}),e.jsx("div",{className:"divide-y divide-line",children:t.threads.map(c=>e.jsx(I,{thread:c,active:c.id===P,focused:c.id===u,tabIndex:z(c.id),selection:X(c.id),onClick:K=>{B(c.id,K)||w?.(c.id)}},c.id))})]},t.id))})),R&&e.jsx(Ee,{hints:l?we(l.handlers):je}),C]})}var Ye=class extends fe{constructor(s,n){super(s,n)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(s){s._type="infinite",super.setOptions(s)}getOptimisticResult(s){return s._type="infinite",super.getOptimisticResult(s)}fetchNextPage(s){return this.fetch({...s,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(s){return this.fetch({...s,meta:{fetchMore:{direction:"backward"}}})}createResult(s,n){const{state:r}=s,f=super.createResult(s,n),{isFetching:m,isRefetching:g,isError:y,isRefetchError:j}=f,h=r.fetchMeta?.fetchMore?.direction,p=y&&h==="forward",d=m&&h==="forward",b=y&&h==="backward",v=m&&h==="backward";return{...f,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:xe(n,r.data),hasPreviousPage:me(n,r.data),isFetchNextPageError:p,isFetchingNextPage:d,isFetchPreviousPageError:b,isFetchingPreviousPage:v,isRefetchError:j&&!p&&!b,isRefetching:g&&!d&&!v}}};function ss(s,n){return ge(s,Ye)}function ts({title:s,unreadCount:n,preset:r,selectedCategory:f,activeFilters:m,onSelectCategory:g,onToggleFilter:y,onSelectSource:j,onClearFilters:h,children:p,footer:d,searchResults:b,searchLoading:v,relatedResults:P,relatedLoading:k,onSelectSearchResult:w,searchResultsLabel:S,relatedResultsLabel:R,searchResultsInBody:E,refreshControl:a}){const{searchInput:l}=he(),N=l.trim().length>0,C={categories:r.categories,filters:r.filters,sources:r.sources,selectedCategory:f,activeFilters:m,onSelectCategory:g,onSelectSource:j,onToggleFilter:y,onClear:h};return e.jsx(pe,{hasSheet:!N,children:e.jsx(Ie,{title:s,unreadCount:n,footer:d,searchFilter:C,searchResults:b,searchLoading:v,relatedResults:P,relatedLoading:k,onSelectSearchResult:w,searchResultsLabel:S,relatedResultsLabel:R,searchResultsInBody:E,refreshControl:a,children:e.jsx(be,{...C,hideChrome:N,children:p})})})}export{Ze as M,Be as S,es as a,ts as b,ss as u};
1
+ import{j as e,an as re,B as A,e as ie,r as x,b as Q,ao as oe,T as ce,bI as le,u as ue,bJ as U,bt as de,bK as fe,bL as me,bM as xe,bN as ge,o as he,bu as pe,bO as be}from"./index-Bo-p3LpF.js";import{R as ve,l as je,m as we}from"./search-token-index-sLIcvT6p.js";import{ap as Ne,aq as ye,c as Pe,b as q,ar as Ce,v as Re,as as ke,at as Se,au as Me,af as Ee,ah as Ie}from"./MailListHeader-BJ9doZxm.js";import{A as Oe}from"./avatar-lbydjrIt.js";import{M as ze}from"./account-form-helpers-D1exxHT6.js";import{M as Le}from"./menu-vnrvhz9W.js";function De(){return e.jsx("div",{className:"space-y-0",role:"status","aria-busy":"true","aria-label":"Loading messages",children:Array.from({length:8}).map((s,n)=>e.jsxs("div",{className:"animate-pulse border-b border-line px-3 py-2",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("div",{className:"h-4 w-32 rounded bg-surface-sunken"}),e.jsx("div",{className:"h-3 w-16 rounded bg-surface-sunken"})]}),e.jsx("div",{className:"mb-2 h-4 w-48 rounded bg-surface-sunken"}),e.jsx("div",{className:"h-3 w-full rounded bg-surface-sunken"})]},n))})}function Te({filter:s,scopeLabel:n,searchQuery:r}){const f=r?.trim();return s?e.jsxs(G,{children:[e.jsx("p",{className:"font-medium text-fg",children:$e(s.label,n,f)}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:_e[s.reach]}),e.jsx(A,{variant:"secondary",size:"sm",className:"mt-4",onClick:s.onClear,children:"Clear filter"})]}):e.jsx(G,{children:e.jsx("p",{className:"text-fg-muted",children:Ae(f,n)})})}const _e={"whole-folder":"Every message in this folder was checked.","loaded-pages":"Only the messages loaded so far were checked."};function Ae(s,n){return s?"No messages match your search":n?`No messages in ${n}`:"No messages in this mailbox"}function $e(s,n,r){return r?`No results for “${r}” in ${s}`:n?`No ${s} mail in ${n}`:`No ${s} mail`}function G({children:s}){return e.jsx("div",{className:"flex h-full flex-1 items-center justify-center",children:e.jsx("div",{className:"flex max-w-sm flex-col items-center justify-center p-8 text-center",children:s})})}function Ze(){return e.jsxs("div",{className:"flex items-center justify-center gap-2 py-4 text-sm text-fg-muted",role:"status","aria-live":"polite",children:[e.jsx(re,{className:"size-4 animate-spin","aria-hidden":"true"}),e.jsx("span",{children:"Loading more…"})]})}function Fe({message:s="Something went wrong loading this mailbox.",onRetry:n,onReport:r}){return e.jsx("div",{className:"flex h-full flex-1 items-center justify-center p-4",children:e.jsxs("div",{role:"alert",className:"flex max-w-sm flex-col items-center justify-center gap-3 text-center",children:[e.jsx(ie,{className:"size-8 text-danger","aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-danger",children:"Couldn't load messages"}),e.jsx("p",{className:"mt-1 break-words text-sm text-fg-muted",children:s})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[n&&e.jsx(A,{variant:"secondary",size:"sm",onClick:n,children:"Retry"}),r&&e.jsx(A,{variant:"ghost",size:"sm",onClick:r,children:"Report a problem"})]})]})})}const O=72,J=10,He=O/2,V="__swipeableRowAxisCancel";function Z(s){return s==="leading"?O:s==="trailing"?-O:0}function Xe(s){return s>=O/2?"leading":s<=-O/2?"trailing":"none"}function Be({thread:s,selectionMode:n,checked:r,active:f,peek:m,onPeek:g,onToggleCheck:y,onLongPress:j,onOpen:h,onAct:p}){const d=x.useRef(null),[b,v]=x.useState(null),{longPressProps:P}=Ne({onLongPress:j,isDisabled:n,accessibilityDescription:"Select message"}),k=i=>{const o=new PointerEvent("pointercancel",{bubbles:!0});o[V]=!0,i.currentTarget.dispatchEvent(o)},a=ye(P,{onPointerDown:i=>{d.current={startX:i.clientX,startY:i.clientY,axis:"none",escaped:!1}},onPointerMove:i=>{if(n)return;const o=d.current;if(!o)return;const u=i.clientX-o.startX,M=i.clientY-o.startY;if(o.axis==="none"&&(Math.abs(M)>J&&Math.abs(M)>Math.abs(u)?o.axis="vertical":Math.abs(u)>J&&Math.abs(u)>Math.abs(M)&&(o.axis="horizontal",i.currentTarget.setPointerCapture(i.pointerId))),o.axis==="none")return;const z=o.axis==="horizontal"?Math.abs(u):Math.abs(M);if(!o.escaped&&z>He&&(o.escaped=!0,k(i)),o.axis!=="horizontal")return;const F=Z(m),H=Math.max(-O,Math.min(O,F+u));v(H)},onPointerUp:i=>{const o=d.current;d.current=null;const u=b;if(v(null),!!o){if(o.axis!=="none"&&!o.escaped&&k(i),o.axis==="horizontal"){u!==null&&g(Xe(u));return}if(o.axis!=="vertical"){if(n){y();return}if(m!=="none"){g("none");return}h()}}},onPointerCancel:i=>{i.nativeEvent[V]||(d.current=null,v(null))}}),l=b??Z(m),N=l>0?"leading":l<0?"trailing":"none",C=Q("relative touch-pan-y bg-surface","select-none",Pe({active:r||f})),D={transform:l!==0?`translateX(${l}px)`:void 0,transition:b===null?"transform 150ms ease":"none",minHeight:44},$=!s.isRead,I=i=>i.stopPropagation(),T=n?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:Q("inline-flex size-7 shrink-0 items-center justify-center rounded-full border",r?"border-accent bg-accent text-accent-fg":"border-line-strong bg-canvas"),children:r&&e.jsx(oe,{className:"size-3.5"})}),e.jsx(q,{thread:s})]}):e.jsxs(e.Fragment,{children:[$&&e.jsx("span",{className:"absolute left-1.5 top-1/2 size-1.5 -translate-y-1/2 rounded-full bg-accent"}),e.jsx("span",{role:"checkbox",tabIndex:0,"aria-checked":r,"aria-label":`Select message from ${s.fromName}`,onPointerDown:I,onPointerMove:I,onPointerUp:I,onClick:i=>{i.preventDefault(),i.stopPropagation(),j()},onKeyDown:i=>{i.key!=="Enter"&&i.key!==" "||(i.preventDefault(),i.stopPropagation(),j())},className:"-m-2 inline-flex size-11 shrink-0 items-center justify-center rounded-full",children:e.jsx(Oe,{name:s.fromName,email:s.fromEmail,size:"sm"})}),e.jsx(q,{thread:s})]});return e.jsxs("div",{className:"relative overflow-hidden",children:[N==="leading"&&e.jsx("button",{type:"button",onClick:()=>p("leading"),"aria-label":s.isRead?"Mark as unread":"Mark as read",className:"absolute inset-y-0 left-0 flex items-center justify-start bg-accent-2 px-6 text-accent-fg",children:s.isRead?e.jsx(ze,{className:"size-6"}):e.jsx(Ce,{className:"size-6"})}),N==="trailing"&&e.jsx("button",{type:"button",onClick:()=>p("trailing"),"aria-label":"Delete message",className:"absolute inset-y-0 right-0 flex items-center justify-end bg-danger px-6 text-canvas",children:e.jsx(ce,{className:"size-6"})}),e.jsx("button",{type:"button",role:n?"checkbox":void 0,"aria-checked":n?r:void 0,"data-message-row":!0,"data-message-id":s.id,...a,className:C,style:D,children:T})]})}function Ke({sections:s,selectedThreadId:n,selectionMode:r,checkedIds:f,initialPeek:m,onToggleCheck:g,onEnterSelection:y,onOpenThread:j,onRefresh:h,refreshing:p,busy:d=!1}){const[b,v]=x.useState(new Set),[P,k]=x.useState(new Map),w=s.flatMap(a=>a.threads).filter(a=>!b.has(a.id)).map(a=>{const l=P.get(a.id);return l===void 0?a:{...a,isRead:l}}),[S,R]=x.useState(m&&m!=="none"&&w[1]?{id:w[1].id,side:m}:null),E=(a,l)=>{if(l==="trailing")v(N=>new Set(N).add(a));else{const N=w.find(C=>C.id===a);k(C=>new Map(C).set(a,!N?.isRead))}R(null)};return e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[p&&e.jsxs("div",{className:"flex items-center justify-center gap-2 border-b border-line py-3 text-fg-muted",children:[e.jsx(ve,{className:"size-4 animate-spin"}),e.jsx("span",{className:"text-xs",children:"Checking for new mail…"})]}),e.jsx("div",{className:"divide-y divide-line",children:w.map(a=>e.jsx("div",{className:d?"pointer-events-none opacity-50":void 0,children:e.jsx(Be,{thread:a,selectionMode:r,checked:f.has(a.id),active:a.id===n,peek:S?.id===a.id?S.side:"none",onPeek:l=>R(l==="none"?null:{id:a.id,side:l}),onToggleCheck:()=>g(a.id),onLongPress:()=>y(a.id),onOpen:()=>j(a.id),onAct:l=>E(a.id,l)})},a.id))}),!r&&!p&&!d&&e.jsx("button",{type:"button",onClick:h,className:"w-full border-t border-line py-2 text-center text-2xs text-fg-subtle transition-colors hover:bg-surface-sunken",children:"Pull to refresh"})]})}const We=new Set;function es({listTitle:s,listMeta:n,sections:r,briefFilters:f,flatList:m,listState:g="ready",searchQuery:y,listFilter:j,listScopeLabel:h,errorMessage:p,onRetry:d,onReportError:b,briefFilter:v,selectedThreadId:P,density:k="comfortable",onSelectThread:w,onOpenNav:S,isDesktop:R,initialTouchState:E,selection:a,keyboard:l,selectionBar:N,paneOverlay:C,listBody:D,hideHeader:$=!1}){const I=k==="compact"?Se:Me,T=x.useRef(null),i=x.useRef(null),o=le(l);ue({containerRef:T,itemSelector:U,enabled:!o});const u=o?l.focusedId:void 0,M=o?u??r[0]?.threads[0]?.id:void 0,z=x.useCallback(t=>M===void 0?void 0:t===M?0:-1,[M]);x.useEffect(()=>{if(u===void 0)return;const t=i.current;if(!t)return;const c=t.querySelector(`${U}[data-message-id="${u}"]`);!c||c===t.ownerDocument.activeElement||c.focus({preventScroll:!1})},[u]),x.useEffect(()=>{if(!o)return;const t=i.current;if(!t)return;const c=t.ownerDocument.activeElement;c!==null&&c!==t.ownerDocument.body||t.focus({preventScroll:!0})},[o]);const F=!R&&!f&&g==="ready",[H,W]=x.useState(!1),ee=E==="peek-trailing"?"trailing":E==="peek-leading"?"leading":void 0,se=()=>{W(!0),setTimeout(()=>W(!1),1400)},_=a?.selectedIds??We,L=a?.onToggle,Y=a?.onRowSelect,te=Re(_.size,R),X=x.useCallback(t=>{if(L)return{checked:_.has(t),onToggle:c=>{c.preventDefault(),c.stopPropagation(),L(t)}}},[_,L]),B=x.useCallback((t,c)=>Y?.(t,ke(c))?(c.preventDefault(),c.shiftKey&&window.getSelection()?.removeAllRanges(),!0):!1,[Y]),ne=x.useCallback(({thread:t,active:c,onClick:K})=>e.jsx(I,{thread:t,active:c,focused:t.id===u,tabIndex:z(t.id),selection:X(t.id),onClick:ae=>{B(t.id,ae)||K?.()}}),[I,X,B,u,z]);return e.jsxs("section",{ref:t=>{i.current=t,l?.ref(t)},tabIndex:o?-1:void 0,className:"relative flex h-full w-full flex-col bg-surface outline-none",children:[N??($?null:e.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[S&&e.jsx(A,{variant:"ghost",size:"sm",icon:e.jsx(Le,{className:"size-4"}),onClick:S,"aria-label":"Open folders",className:"-ml-1 shrink-0"}),e.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:s}),n&&e.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle",children:n})]})),g==="loading"?e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsx(De,{})}):g==="empty"?e.jsx(Te,{filter:j,scopeLabel:h,searchQuery:y}):g==="error"?e.jsx(Fe,{message:p,onRetry:d,onReport:b}):f?e.jsx(de,{...v??{},sections:r,selectedThreadId:P,Row:ne,keyboard:l,onSelectThread:w}):D??(F?e.jsx(Ke,{sections:r,selectedThreadId:P,selectionMode:te,checkedIds:_,initialPeek:ee,onToggleCheck:t=>L?.(t),onEnterSelection:t=>L?.(t),onOpenThread:t=>w?.(t),onRefresh:se,refreshing:H}):e.jsx("div",{ref:T,className:"flex-1 overflow-y-auto",children:r.map(t=>e.jsxs("div",{children:[!m&&t.label&&e.jsxs("div",{className:"sticky top-0 flex h-section-row items-center justify-between border-b border-line bg-surface-sunken px-row-inset",children:[e.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:t.label}),e.jsx("span",{className:"text-2xs text-fg-subtle tabular-nums",children:t.threads.length})]}),e.jsx("div",{className:"divide-y divide-line",children:t.threads.map(c=>e.jsx(I,{thread:c,active:c.id===P,focused:c.id===u,tabIndex:z(c.id),selection:X(c.id),onClick:K=>{B(c.id,K)||w?.(c.id)}},c.id))})]},t.id))})),R&&e.jsx(Ee,{hints:l?we(l.handlers):je}),C]})}var Ye=class extends fe{constructor(s,n){super(s,n)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(s){s._type="infinite",super.setOptions(s)}getOptimisticResult(s){return s._type="infinite",super.getOptimisticResult(s)}fetchNextPage(s){return this.fetch({...s,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(s){return this.fetch({...s,meta:{fetchMore:{direction:"backward"}}})}createResult(s,n){const{state:r}=s,f=super.createResult(s,n),{isFetching:m,isRefetching:g,isError:y,isRefetchError:j}=f,h=r.fetchMeta?.fetchMore?.direction,p=y&&h==="forward",d=m&&h==="forward",b=y&&h==="backward",v=m&&h==="backward";return{...f,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:xe(n,r.data),hasPreviousPage:me(n,r.data),isFetchNextPageError:p,isFetchingNextPage:d,isFetchPreviousPageError:b,isFetchingPreviousPage:v,isRefetchError:j&&!p&&!b,isRefetching:g&&!d&&!v}}};function ss(s,n){return ge(s,Ye)}function ts({title:s,unreadCount:n,preset:r,selectedCategory:f,activeFilters:m,onSelectCategory:g,onToggleFilter:y,onSelectSource:j,onClearFilters:h,children:p,footer:d,searchResults:b,searchLoading:v,relatedResults:P,relatedLoading:k,onSelectSearchResult:w,searchResultsLabel:S,relatedResultsLabel:R,searchResultsInBody:E,refreshControl:a}){const{searchInput:l}=he(),N=l.trim().length>0,C={categories:r.categories,filters:r.filters,sources:r.sources,selectedCategory:f,activeFilters:m,onSelectCategory:g,onSelectSource:j,onToggleFilter:y,onClear:h};return e.jsx(pe,{hasSheet:!N,children:e.jsx(Ie,{title:s,unreadCount:n,footer:d,searchFilter:C,searchResults:b,searchLoading:v,relatedResults:P,relatedLoading:k,onSelectSearchResult:w,searchResultsLabel:S,relatedResultsLabel:R,searchResultsInBody:E,refreshControl:a,children:e.jsx(be,{...C,hideChrome:N,children:p})})})}export{Ze as M,Be as S,es as a,ts as b,ss as u};
@@ -1 +1 @@
1
- import{j as r,bf as Ts,aA as zt,B as de,S as Rs,b as Le,aB as Jt,r as c,C as Es,d as Os,b0 as As,k as pt,x as tt,Z as Gt,X as Ns,p as st,s as Dt,y as zs,af as Ft,bg as Yt,bh as Xt,I as Ds,h as Fs,T as _s,bi as Ls,bj as Ps,bk as $s,ad as Zt,aN as Bs,aO as Ws,K as Ks,g as Vs,a2 as _t,bl as qs,Q as Hs,w as Us,bm as Qs,o as es,bn as Js,H as Gs,ag as Ys,i as Xs,bo as Zs,b5 as en}from"./index-DKG1l4OE.js";import{u as tn,p as sn,R as nn}from"./useSearchTokenContext-BNRIlJev.js";import{u as on,a as rn,R as an}from"./useRefreshControl-DN40VgNE.js";import{C as ts,D as Fe,a as ss,b as ns,c as os,j as ln,M as cn,t as is,u as dn,d as un,e as rs,f as as,g as hn,h as fn,i as mn,k as gn,l as Wt,n as pn,m as xn,o as bn,p as vn,q as Sn,S as yn,r as Cn,s as In,v as wn,w as ls,x as jn,y as kn,z as Mn,A as Tn,B as Rn,E as En,F as On,G as An,H as Nn,I as zn,J as Dn,K as Kt,L as Vt,N as Fn,O as _n,P as Ln,Q as Pn,R as $n,T as Bn,U as Wn,V as Kn,W as Vn,X as qn,Y as Hn,Z as cs,_ as ds,$ as Lt,a0 as Un,a1 as us,a2 as Qn,a3 as Jn}from"./MailListHeader-BFBjOnAW.js";import{S as Gn,M as Yn,a as Xn,u as Zn,b as eo}from"./MailViewChrome-XjLFqRLL.js";import{E as hs,f as to}from"./ErrorState-DlHdbl1h.js";import{d as fs}from"./useFilters-DBElfc_V.js";import{C as ms}from"./confirm-dialog-C1Q_9oNl.js";import{A as Pt}from"./avatar-D3R75Qgk.js";import{b as nt,c as so,d as no}from"./format-De9HZKjg.js";import{r as Pe}from"./nav-link-BTQmJNls.js";import{N as oo}from"./NavMenuButton-D_W6DXrb.js";import{a as io}from"./useLabels-CZdQ7rFS.js";import{L as ro,u as ao}from"./useSemanticSearch-BHpjDfP4.js";import{u as lo,D as co}from"./use-match-media-C1DFe6n_.js";import{S as xt}from"./shield-check-BBp9gzDX.js";import{B as uo}from"./bottom-sheet-BKnsFMEf.js";import{C as ho}from"./circle-help-BJLBqOAA.js";import{C as fo}from"./circle-check-C1n1yijO.js";import{a as mo,b as go,f as po}from"./move-options-DXhjey10.js";import{j as xo,k as bo,f as vo,d as So}from"./search-token-index-D13ogntK.js";import{M as yo}from"./enums-CCxx0t2v.js";import{n as Co}from"./search-query-Cr_ZXBCp.js";const Io=({children:e,onRefresh:n,isRefreshing:t})=>lo(co)?e:r.jsx(Ts,{onRefresh:n,isPullable:!t,children:e}),wo=e=>e===1?"message":"messages";function jo({count:e,onReview:n,onDismiss:t,actionLabel:s="Review & rescue"}){return r.jsx(zt,{tone:"info",variant:"soft",onDismiss:t,children:r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsxs("p",{className:"flex items-start gap-2 text-sm text-fg",children:[r.jsx(xt,{className:"mt-0.5 size-4 shrink-0 text-positive","aria-hidden":!0}),r.jsxs("span",{children:[r.jsx("span",{className:"font-semibold text-fg",children:`${e} ${wo(e)} here`})," ","may not be spam — they're from senders we can verify."]})]}),r.jsx(de,{variant:"primary",size:"sm",onClick:n,className:"self-start",children:s})]})})}const ko=(e,n)=>e==="vip"?"vip":e==="unknown"&&n==="md"?"unknown-pill":"hidden",gs=({senderTrust:e,size:n="sm",className:t})=>{const s=ko(e,n);return s==="vip"?r.jsx(Rs,{className:Le("text-warning shrink-0",n==="sm"&&"size-3.5",n==="md"&&"size-4",t),"aria-label":"VIP sender","data-testid":"sender-trust-vip"}):s==="unknown-pill"?r.jsx("span",{className:Le("inline-flex items-center rounded border border-dashed border-fg-subtle/40 font-medium uppercase tracking-wide text-fg-muted/80 shrink-0","px-2 py-0.5 text-xs",t),title:"First message from this sender","aria-label":"First message from this sender","data-testid":"sender-trust-unknown",children:"new"}):null};function Mo({candidate:e,selected:n,onToggle:t,hideSender:s=!1}){const{senderName:o,senderAddress:i,subject:l,snippet:a,trustReason:u,trustSubReason:d,senderTrust:f}=e;return r.jsxs("label",{className:Le("flex w-full cursor-pointer items-start gap-3 px-3 py-2.5 text-left transition-colors",s&&"pl-11",n?"bg-positive/10":"bg-surface hover:bg-surface-sunken"),children:[r.jsx(ts,{className:"mt-0.5",checked:n,onChange:t,"aria-label":`${n?"Deselect":"Select"} ${s?l:`message from ${o}`}`}),!s&&r.jsx(Pt,{name:o,email:i,size:"sm"}),r.jsxs("span",{className:"min-w-0 flex-1",children:[!s&&r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"truncate text-sm font-medium text-fg",children:o}),f&&r.jsx(gs,{senderTrust:f,size:"sm"}),r.jsx("span",{className:"truncate text-2xs text-fg-subtle",children:i})]}),r.jsx("span",{className:"block truncate text-sm text-fg-muted",children:l}),r.jsx("span",{className:"block line-clamp-1 text-xs text-fg-subtle",children:a}),!s&&r.jsxs("span",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[r.jsxs(Jt,{tone:"positive",children:[r.jsx(xt,{className:"size-3","aria-hidden":!0}),u]}),r.jsx("span",{className:"text-2xs text-fg-subtle",children:d})]})]})]})}const To=e=>{const n=new Map,t=[];for(const s of e){const o=(s.senderAddress||s.senderName).toLowerCase(),i=n.get(o);if(i){i.messages.push(s);continue}n.set(o,{key:o,senderName:s.senderName,senderAddress:s.senderAddress,trustReason:s.trustReason,trustSubReason:s.trustSubReason,senderTrust:s.senderTrust,messages:[s]}),t.push(o)}return t.map(s=>n.get(s)).sort((s,o)=>o.messages.length-s.messages.length)},Ro=(e,n)=>{const t=e.messages.filter(s=>n.has(s.id)).length;return t===0?"none":t===e.messages.length?"all":"some"},qt=e=>e===1?"message":"messages";function Eo({group:e,selected:n,onToggleGroup:t,onToggleMessage:s}){const[o,i]=c.useState(!1),l=Ro(e,n),a=e.messages.length,u=o?Es:Os;return r.jsxs("div",{className:Le(l!=="none"?"bg-positive/10":"bg-surface"),children:[r.jsxs("div",{className:"flex w-full items-start gap-3 px-3 py-2.5",children:[r.jsx(ts,{className:"mt-0.5",checked:l==="all",indeterminate:l==="some",onChange:()=>t(e,l!=="all"),"aria-label":`${l==="all"?"Deselect":"Select"} all ${a} ${qt(a)} from ${e.senderName}`}),r.jsx(Pt,{name:e.senderName,email:e.senderAddress,size:"sm"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"truncate text-sm font-medium text-fg",children:e.senderName}),e.senderTrust&&r.jsx(gs,{senderTrust:e.senderTrust,size:"sm"}),r.jsx("span",{className:"truncate text-2xs text-fg-subtle",children:e.senderAddress})]}),r.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[r.jsxs(Jt,{tone:"positive",children:[r.jsx(xt,{className:"size-3","aria-hidden":!0}),e.trustReason]}),r.jsx("span",{className:"text-2xs text-fg-subtle",children:e.trustSubReason})]})]}),r.jsxs("button",{type:"button",onClick:()=>i(d=>!d),"aria-expanded":o,className:"flex shrink-0 items-center gap-1 rounded-md px-1.5 py-1 text-2xs text-fg-muted transition-colors hover:bg-surface-sunken hover:text-fg",children:[`${a} ${qt(a)}`,r.jsx(u,{className:"size-3.5","aria-hidden":!0})]})]}),o&&r.jsx("div",{className:"divide-y divide-line border-t border-line",children:e.messages.map(d=>r.jsx(Mo,{candidate:d,selected:n.has(d.id),onToggle:()=>s(d.id),hideSender:!0},d.id))})]})}const $t=e=>e===1?"message":"messages",Oo=(e,n)=>`Moves ${e===1?"this message":`these ${e} ${$t(e)}`} out of Spam to ${n} now. Nothing later.`,Nt=(e,n)=>e.find(t=>t.id===n)?.label??"Inbox";function Ao(){return r.jsx(zt,{tone:"info",variant:"soft",children:r.jsx("p",{className:"text-2xs text-fg-muted",children:"We list a message here only when we can confirm the sender is who they say — usually someone you've emailed before, write to often, or a service that consistently checks out. We never guess from words in the subject. Anything we can't confirm stays in Spam."})})}function No({candidates:e,selected:n,onToggle:t,onToggleGroup:s,onSelectAll:o,onSelectNone:i,onContinue:l,onCancel:a}){const[u,d]=c.useState(!1),f=n.size,p=c.useMemo(()=>To(e),[e]);return r.jsxs("div",{className:"flex min-h-0 flex-col",children:[r.jsxs("div",{className:"px-row-inset pb-2 pt-1",children:[r.jsxs("div",{className:"flex items-start justify-between gap-2",children:[r.jsxs("h2",{className:"flex items-center gap-2 text-sm font-semibold text-fg",children:[r.jsx(xt,{className:"size-4 text-positive","aria-hidden":!0}),"Rescue from Spam"]}),r.jsx(de,{variant:"ghost",size:"sm",icon:r.jsx(ho,{className:"size-3.5"}),onClick:()=>d(m=>!m),className:"-mr-1.5 -mt-0.5",children:"Why these?"})]}),r.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:"These look safe — from senders we can verify. Uncheck any sender that belongs in Spam, or open a sender to pick individual messages."}),u&&r.jsx("div",{className:"mt-2",children:r.jsx(Ao,{})})]}),r.jsxs("div",{className:"flex items-center justify-between px-row-inset pb-1.5",children:[r.jsx("span",{className:"text-2xs font-medium text-fg-muted",children:`${f} of ${e.length} selected · ${p.length} ${p.length===1?"sender":"senders"}`}),r.jsxs("span",{className:"flex gap-1",children:[r.jsx(de,{variant:"ghost",size:"sm",onClick:o,children:"Select all"}),r.jsx(de,{variant:"ghost",size:"sm",onClick:i,children:"Select none"})]})]}),r.jsx("div",{className:"min-h-0 flex-1 divide-y divide-line overflow-y-auto border-y border-line",children:p.map(m=>r.jsx(Eo,{group:m,selected:n,onToggleGroup:s,onToggleMessage:t},m.key))}),r.jsxs("div",{className:"space-y-2 border-t border-line bg-surface px-row-inset py-3",children:[r.jsx(de,{variant:"primary",onClick:l,className:"h-11 w-full font-semibold",children:`Continue with ${f} ${$t(f)}`}),r.jsx(de,{variant:"ghost",onClick:a,className:"h-11 w-full",children:"Cancel"})]})]})}function zo({count:e,folders:n,delimiter:t,destination:s,onPick:o,onMove:i,onBack:l}){const[a,u]=c.useState(!1);return r.jsxs("div",{className:"flex min-h-0 flex-col",children:[r.jsxs("div",{className:"px-row-inset pb-2 pt-1",children:[r.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Where should they go?"}),r.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:"Pick a folder, then we move them out of Spam."})]}),r.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-y-auto px-row-inset py-2",children:a?r.jsx("div",{className:"flex min-h-0 flex-1 overflow-hidden rounded-xl border border-line bg-surface",children:r.jsx(As,{folders:n,selectedId:s,delimiter:t,onSelect:o,onCancel:()=>u(!1)})}):r.jsxs("div",{className:"rounded-xl border border-line bg-surface-sunken p-3",children:[r.jsx("p",{className:"text-2xs text-fg-subtle",children:"Destination"}),r.jsx("p",{className:"mt-0.5 text-sm font-medium text-fg",children:Nt(n,s)}),r.jsx(de,{variant:"ghost",size:"sm",onClick:()=>u(!0),className:"mt-2 px-0",children:"Move to a different folder"})]})}),r.jsxs("div",{className:"space-y-2 border-t border-line bg-surface px-row-inset py-3",children:[r.jsx("p",{className:"text-2xs text-fg-subtle",children:Oo(e,Nt(n,s))}),r.jsx(de,{variant:"primary",onClick:i,className:"h-11 w-full font-semibold",children:`Move ${e} out of Spam`}),r.jsx(de,{variant:"ghost",onClick:l,className:"h-11 w-full",children:"Back"})]})]})}function Do({count:e,destinationLabel:n,onClose:t}){return r.jsxs("div",{className:"flex min-h-0 flex-col",children:[r.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-row-inset py-10 text-center",children:[r.jsx(fo,{className:"size-10 text-positive","aria-hidden":!0}),r.jsx("p",{className:"text-base font-semibold text-fg",children:`Moved ${e} ${$t(e)} out of Spam.`}),r.jsx("p",{className:"text-2xs text-fg-subtle",children:`You'll find them in ${n}.`})]}),r.jsx("div",{className:"border-t border-line bg-surface px-row-inset py-3",children:r.jsx(de,{variant:"primary",onClick:t,className:"h-11 w-full font-semibold",children:"Done"})})]})}function Fo({open:e,candidates:n,defaultDestinationId:t,availableFolders:s,delimiter:o,onConfirmMove:i,onCancel:l}){const[a,u]=c.useState("review"),[d,f]=c.useState(()=>e?new Set(n.map(I=>I.id)):new Set),[p,m]=c.useState(t),[S,y]=c.useState(0),k=c.useRef(!1);c.useEffect(()=>{e&&!k.current&&(u("review"),f(new Set(n.map(I=>I.id))),m(t),y(0)),k.current=e},[e,n,t]);const M=d.size,x=I=>{f(j=>{const E=new Set(j);return E.has(I)?E.delete(I):E.add(I),E})},b=(I,j)=>{f(E=>{const A=new Set(E);for(const D of I.messages)j?A.add(D.id):A.delete(D.id);return A})},C=()=>{const I=Array.from(d);y(I.length),i(I,p),u("done")};return r.jsxs(uo,{open:e,onClose:l,dismissLabel:"Close rescue",children:[a==="review"&&r.jsx(No,{candidates:n,selected:d,onToggle:x,onToggleGroup:b,onSelectAll:()=>f(new Set(n.map(I=>I.id))),onSelectNone:()=>f(new Set),onContinue:()=>u("destination"),onCancel:l}),a==="destination"&&r.jsx(zo,{count:M,folders:s,delimiter:o,destination:p,onPick:m,onMove:C,onBack:()=>u("review")}),a==="done"&&r.jsx(Do,{count:S,destinationLabel:Nt(s,p),onClose:l})]})}const _o={reply:"Reply",reply_all:"Reply All",forward:"Forward",new:"New Message"},Lo=()=>{const e=c.useRef(!1);return c.useCallback(()=>{const t=document.querySelector("[data-subject-field]")?.value??"",i=(document.querySelector('[data-testid="compose-body"]')?.textContent??"").replace(/--\s*/g,"").trim();return e.current=t.trim().length>0||i.length>0,e.current},[])},Po=()=>{const{state:e,closeCompose:n}=pt(),t=Lo(),[s,o]=c.useState(!1),{isError:i,error:l,refetch:a}=tt({...Gt(),staleTime:1/0}),u=c.useCallback(m=>{m||(t()?o(!0):n())},[n,t]),d=c.useCallback(()=>{o(!1),n()},[n]),f=c.useCallback(()=>{o(!1)},[]);if(!e.isOpen)return null;const p=_o[e.mode]??"New Message";return r.jsxs(Fe.Root,{open:e.isOpen,onOpenChange:u,children:[r.jsxs(Fe.Portal,{children:[r.jsx(Fe.Overlay,{className:"fixed inset-0 z-40 bg-black/40"}),r.jsxs(Fe.Content,{className:"fixed inset-x-0 bottom-0 z-50 flex flex-col rounded-t-lg bg-canvas pb-[env(safe-area-inset-bottom,0px)]",style:{height:"95dvh"},children:[r.jsx(Fe.Handle,{className:"mx-auto mt-2 mb-1 h-1.5 w-12 rounded-full bg-fg-muted/30"}),r.jsx(Fe.Title,{className:"px-4 py-2 text-base font-semibold border-b border-line",children:p}),i?r.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:r.jsx(hs,{title:"Couldn't load compose",error:l,onRetry:()=>{a()}})}):r.jsx("div",{className:"flex-1 overflow-hidden",children:r.jsx(ss,{mode:e.mode,account:e.account,sourceMessage:e.sourceMessage,onClose:n})})]})]}),r.jsx(ms,{isOpen:s,title:"Discard draft?",description:"Your message has unsaved content. Are you sure you want to discard it?",confirmLabel:"Discard",cancelLabel:"Keep editing",destructive:!0,onConfirm:d,onCancel:f})]})},$o={reply:"Reply",reply_all:"Reply All",forward:"Forward",new:"New Message"},ps=()=>{const{state:e,closeCompose:n}=pt(),t=fs(),{isError:s,error:o,refetch:i}=tt({...Gt(),staleTime:1/0});if(!t)return r.jsx(Po,{});if(!e.isOpen)return null;const l=$o[e.mode]??"New Message",a=r.jsxs("header",{className:"flex items-center justify-between gap-2 px-4 py-3 border-b border-line shrink-0",children:[r.jsx("div",{className:"flex items-center gap-2 min-w-0",children:r.jsx("h2",{className:"text-lg font-semibold truncate",children:l})}),r.jsx("button",{type:"button",onClick:n,className:"p-2 rounded-md hover:bg-surface-raised transition-colors min-h-11 min-w-11 inline-flex items-center justify-center","aria-label":"Close",children:r.jsx(Ns,{className:"size-5"})})]});return s?r.jsxs("div",{className:"h-full flex flex-col bg-canvas",children:[a,r.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:r.jsx(hs,{title:"Couldn't load compose",error:o,onRetry:()=>{i()}})})]}):r.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-canvas",children:[a,r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:r.jsx(ss,{mode:e.mode,account:e.account,sourceMessage:e.sourceMessage,onClose:n},e.outboxMessageId??"new")})]})};function Bo(e){const n=e.toAddresses.join(", ");return{id:e.outboxMessageId,accountId:e.accountId,fromName:e.fromName??e.fromAddress??"Me",fromEmail:e.fromAddress??"",subject:e.subject??"(No subject)",snippet:n?`To: ${n}`:"(No recipients)",timeLabel:nt(e.updatedAt),isRead:!0}}function Wo(e){return{id:e.messageId,accountId:e.accountId,fromName:e.fromName??e.fromEmail??"Unknown",fromEmail:e.fromEmail??"",subject:e.subject??"(No subject)",snippet:e.snippet??"",timeLabel:nt(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0}}function Ko({outboxMessages:e,accountId:n,imapThreads:t}){const s=e.filter(l=>l.status==="draft"&&l.accountId===n).map(Bo),o=t.map(Wo),i=[];return s.length>0&&i.push({id:"remit-drafts",label:"Not yet sent (Remit)",threads:s}),o.length>0&&i.push({id:"imap-drafts",label:"On the server",threads:o}),i}const Vo=({label:e,count:n})=>r.jsxs("div",{className:"sticky top-0 z-10 flex items-baseline justify-between border-b border-line bg-surface-sunken px-row-inset py-1",children:[r.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:e}),r.jsx("span",{className:"text-2xs text-fg-subtle tabular-nums",children:n})]}),qo=({row:e,isSelected:n,onOpen:t,onDelete:s,isDeleting:o})=>r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:Le("group",os({active:n})),children:[r.jsx(Fs,{className:"size-7 shrink-0 text-fg-muted mt-0.5"}),r.jsx(ns,{thread:e}),r.jsx("div",{className:"flex items-center gap-1 shrink-0",children:r.jsx("button",{type:"button",onClick:i=>{i.stopPropagation(),s(e.id)},disabled:o,className:"p-1.5 rounded-md text-fg-muted hover:text-danger hover:bg-surface-raised transition-colors opacity-0 group-hover:opacity-100 focus:opacity-100",title:"Delete draft",children:r.jsx(_s,{className:"size-3.5"})})})]}),Ho=({row:e,isSelected:n,onOpen:t})=>{const s=!e.isRead;return r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:Le("group",os({active:n})),children:[s&&r.jsx("span",{className:"absolute left-1.5 top-1/2 size-1.5 -translate-y-1/2 rounded-full bg-accent"}),r.jsx(Pt,{name:e.fromName,email:e.fromEmail,size:"sm"}),r.jsx(ns,{thread:e})]})};function Uo({mailboxId:e,accountId:n,selectedMessageId:t,imapThreads:s,title:o,unreadCount:i}){const{openCompose:l,state:a}=pt(),u=st(),d=Dt(),{data:f}=tt(zs()),p=c.useMemo(()=>Ko({outboxMessages:f?.items??[],accountId:n,imapThreads:s}),[f?.items,n,s]),m=Ft({...Xt(),onSuccess:()=>{d.invalidateQueries({queryKey:Yt()})}}),S=x=>{m.mutate({path:{outboxMessageId:x}})},y=x=>{l({mode:"new",outboxMessageId:x})},k=x=>{const b=s.find(C=>C.messageId===x)?.threadId;b&&u({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:e,threadId:b,messageId:x},search:C=>C,hash:Pe})},M=p.length===0;return r.jsxs("section",{className:"flex h-full w-full flex-col bg-surface",children:[r.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[r.jsx(oo,{}),r.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:o}),(i??0)>0&&r.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:[i," unread"]})]}),r.jsx("div",{className:"flex-1 overflow-y-auto",children:M?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 text-center px-4",children:[r.jsx(Ds,{className:"size-8 text-fg-subtle"}),r.jsx("p",{className:"text-sm font-medium text-fg",children:"No drafts"}),r.jsx("p",{className:"text-xs text-fg-subtle",children:"Messages you start composing will appear here."})]}):p.map(x=>r.jsxs("div",{children:[x.label&&r.jsx(Vo,{label:x.label,count:x.threads.length}),r.jsx("div",{className:"divide-y divide-line",children:x.threads.map(b=>x.id==="remit-drafts"?r.jsx(qo,{row:b,isSelected:a.isOpen&&b.id===a.outboxMessageId,onOpen:y,onDelete:S,isDeleting:m.isPending},b.id):r.jsx(Ho,{row:b,isSelected:b.id===t,onOpen:k},b.id))})]},x.id))})]})}function Qo(e,n,t){const s=new Array(e);return new Proxy(s,{get(o,i,l){if(typeof i=="string"){const a=i.charCodeAt(0);if(a>=48&&a<=57){const u=+i;if(Number.isInteger(u)&&u>=0&&u<e){let d=o[u];if(!d){const f=n[u*2];d=o[u]={index:u,key:t(u),start:f,size:n[u*2+1],end:f+n[u*2+1],lane:0}}return d}}if(i==="length")return e}return Reflect.get(o,i,l)}})}function _e(e,n,t){let s=t.initialDeps??[],o,i=!0;function l(){const a=e();return(a.length!==s.length||a.some((d,f)=>s[f]!==d))&&(s=a,o=n(...a),t?.onChange&&!(i&&t.skipInitialOnChange)&&t.onChange(o),i=!1),o}return l.updateDeps=a=>{s=a},l}function Ht(e,n){if(e===void 0)throw new Error("Unexpected undefined");return e}const Jo=(e,n)=>Math.abs(e-n)<1.01,Go=(e,n,t)=>{let s;return function(...o){e.clearTimeout(s),s=e.setTimeout(()=>n.apply(this,o),t)}};let et;const Ot=()=>{if(et!==void 0)return et;if(typeof navigator>"u")return et=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return et=!0;const e=navigator.maxTouchPoints;return et=navigator.platform==="MacIntel"&&e!==void 0&&e>0},Ut=e=>{const{offsetWidth:n,offsetHeight:t}=e;return{width:n,height:t}},Yo=e=>e,Xo=e=>{const n=Math.max(e.startIndex-e.overscan,0),s=Math.min(e.endIndex+e.overscan,e.count-1)-n+1,o=new Array(s);for(let i=0;i<s;i++)o[i]=n+i;return o},Zo=(e,n)=>{const t=e.scrollElement;if(!t)return;const s=e.targetWindow;if(!s)return;const o=l=>{const{width:a,height:u}=l;n({width:Math.round(a),height:Math.round(u)})};if(o(Ut(t)),!s.ResizeObserver)return()=>{};const i=new s.ResizeObserver(l=>{const a=()=>{const u=l[0];if(u?.borderBoxSize){const d=u.borderBoxSize[0];if(d){o({width:d.inlineSize,height:d.blockSize});return}}o(Ut(t))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return i.observe(t,{box:"border-box"}),()=>{i.unobserve(t)}},gt={passive:!0},ei=typeof window>"u"?!0:"onscrollend"in window,ti=(e,n,t)=>{const s=e.scrollElement;if(!s)return;const o=e.targetWindow;if(!o)return;const i=e.options.useScrollendEvent&&ei;let l=0;const a=i?null:Go(o,()=>n(l,!1),e.options.isScrollingResetDelay),u=p=>()=>{l=t(s),a?.(),n(l,p)},d=u(!0),f=u(!1);return s.addEventListener("scroll",d,gt),i&&s.addEventListener("scrollend",f,gt),()=>{s.removeEventListener("scroll",d),i&&s.removeEventListener("scrollend",f)}},si=(e,n)=>ti(e,n,t=>{const{horizontal:s,isRtl:o}=e.options;return s?t.scrollLeft*(o&&-1||1):t.scrollTop}),ni=(e,n,t)=>{if(t.options.useCachedMeasurements){const s=t.indexFromElement(e),o=t.options.getItemKey(s);return t.itemSizeCache.get(o)??t.options.estimateSize(s)}if(n?.borderBoxSize){const s=n.borderBoxSize[0];if(s)return Math.round(s[t.options.horizontal?"inlineSize":"blockSize"])}if(!n){const s=t.indexFromElement(e),o=t.options.getItemKey(s),i=t.itemSizeCache.get(o);if(i!==void 0)return i}return e[t.options.horizontal?"offsetWidth":"offsetHeight"]},oi=(e,{adjustments:n=0,behavior:t},s)=>{var o,i;(i=(o=s.scrollElement)==null?void 0:o.scrollTo)==null||i.call(o,{[s.options.horizontal?"left":"top"]:e+n,behavior:t})},ii=oi;class ri{constructor(n){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var t,s,o;return((o=(s=(t=this.targetWindow)==null?void 0:t.performance)==null?void 0:s.now)==null?void 0:o.call(s))??Date.now()},this.observer=(()=>{let t=null;const s=()=>t||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:t=new this.targetWindow.ResizeObserver(o=>{o.forEach(i=>{const l=()=>{const a=i.target,u=this.indexFromElement(a);if(!a.isConnected){this.observer.unobserve(a);for(const[d,f]of this.elementsCache)if(f===a){this.elementsCache.delete(d);break}return}this.shouldMeasureDuringScroll(u)&&this.resizeItem(u,this.options.measureElement(a,i,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()})}));return{disconnect:()=>{var o;(o=s())==null||o.disconnect(),t=null},observe:o=>{var i;return(i=s())==null?void 0:i.observe(o,{box:"border-box"})},unobserve:o=>{var i;return(i=s())==null?void 0:i.unobserve(o)}}})(),this.range=null,this.setOptions=t=>{var s,o;const i={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Yo,rangeExtractor:Xo,onChange:()=>{},measureElement:ni,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const m in t){const S=t[m];S!==void 0&&(i[m]=S)}const l=this.options;let a=null,u=null,d=!1;if(l!==void 0&&l.enabled&&i.enabled&&i.anchorTo==="end"&&this.scrollElement!==null){const m=l.count,S=i.count,y=this.getMeasurements(),k=m>0?((s=y[0])==null?void 0:s.key)??l.getItemKey(0):null,M=m>0?((o=y[m-1])==null?void 0:o.key)??l.getItemKey(m-1):null;if(S!==m||m>0&&S>0&&(i.getItemKey(0)!==k||i.getItemKey(S-1)!==M)){d=!0;const C=m>0?this.getVirtualItemForOffset(this.getScrollOffset())??y[0]:null;C&&(a=[C.key,this.getScrollOffset()-C.start]);const I=i.followOnAppend===!0?"auto":i.followOnAppend||null;I&&S>m&&this.isAtEnd(l.scrollEndThreshold)&&(m===0||i.getItemKey(S-1)!==M)&&(u=I)}}this.options=i,d&&(this.pendingMin=0,this.itemSizeCacheVersion++);let f=!1,p=0;if(a&&this.scrollOffset!==null){const[m,S]=a,y=this.getMeasurements(),{count:k,getItemKey:M}=this.options;let x=0;for(;x<k&&M(x)!==m;)x++;if(x<k){const b=y[x];if(b){const C=b.start+S;C!==this.scrollOffset&&(p=C-this.scrollOffset,this.scrollOffset=C,f=!0)}}}(f||u)&&(this.pendingScrollAnchor=[f?a[0]:null,f?a[1]:0,u,p])},this.notify=t=>{var s,o;(o=(s=this.options).onChange)==null||o.call(s,this,t)},this.maybeNotify=_e(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),t=>{this.notify(t)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(t=>t()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var t;const s=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==s){if(this.cleanup(),!s){this.maybeNotify();return}if(this.scrollElement=s,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((t=this.scrollElement)==null?void 0:t.window)??null,this.elementsCache.forEach(i=>{this.observer.observe(i)}),this.unsubs.push(this.options.observeElementRect(this,i=>{this.scrollRect=i,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(i,l)=>{if(l&&this._intendedScrollOffset===null&&i===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(i-this._intendedScrollOffset)<1.5&&(i=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;const a=this.getScrollOffset();this.scrollDirection=l?a===i?this.scrollDirection:a<i?"forward":"backward":null,this.scrollOffset=i,this.isScrolling=l,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const i=this.scrollElement,l=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},a=()=>{this._iosTouching=!1,!(!Ot()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};i.addEventListener("touchstart",l,gt),i.addEventListener("touchend",a,gt),this.unsubs.push(()=>{i.removeEventListener("touchstart",l),i.removeEventListener("touchend",a),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const o=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,o&&this.scrollElement&&this.options.enabled){const[i,l,a,u]=o;i!==null&&!a&&(Ot()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?u!==0&&(this._iosDeferredAdjustment+=u):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),a&&this.scrollToEnd({behavior:a})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const t=this.getScrollOffset(),s=this.getMaxScrollOffset();if(t<0||t>s)return;const o=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(t,{adjustments:this.scrollAdjustments+=o,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=_e(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(t,s,o,i,l,a,u,d)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:t,paddingStart:s,scrollMargin:o,getItemKey:i,enabled:l,lanes:a,laneAssignmentMode:u,gap:d}),{key:!1}),this.getMeasurements=_e(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:t,paddingStart:s,scrollMargin:o,getItemKey:i,enabled:l,lanes:a,laneAssignmentMode:u,gap:d},f)=>{const p=this.itemSizeCache;if(!l)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>t)for(const x of this.laneAssignments.keys())x>=t&&this.laneAssignments.delete(x);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(x=>{this.itemSizeCache.set(x.key,x.size)}));const m=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===t&&(this.lanesSettling=!1),a===1){const x=t*2;let b=this._flatMeasurements;if(!b||b.length<x){const j=new Float64Array(x);b&&m>0&&j.set(b.subarray(0,m*2)),b=j,this._flatMeasurements=b}let C;if(m===0)C=s+o;else{const j=m-1;C=b[j*2]+b[j*2+1]+d}for(let j=m;j<t;j++){const E=i(j),A=p.get(E),D=typeof A=="number"?A:this.options.estimateSize(j);b[j*2]=C,b[j*2+1]=D,C+=D+d}const I=Qo(t,b,i);return this.measurementsCache=I,I}const S=this.measurementsCache.slice(0,m),y=new Array(a).fill(void 0),k=new Float64Array(a);let M=0;for(let x=0;x<m;x++){const b=S[x];b&&(y[b.lane]===void 0&&M++,y[b.lane]=x,k[b.lane]=b.end)}for(let x=m;x<t;x++){const b=i(x),C=this.laneAssignments.get(x);let I,j;const E=u==="estimate"||p.has(b);if(C!==void 0&&this.options.lanes>1){I=C;const W=y[I],K=W!==void 0?S[W]:void 0;j=K?K.end+d:s+o}else if(M===a){let W=0,K=k[0],L=y[0];for(let V=1;V<a;V++){const oe=k[V];(oe<K||oe===K&&y[V]<L)&&(W=V,K=oe,L=y[V])}I=W,j=K+d,E&&this.laneAssignments.set(x,I)}else I=x%this.options.lanes,j=s+o,E&&this.laneAssignments.set(x,I);const A=p.get(b),D=typeof A=="number"?A:this.options.estimateSize(x),O=j+D;S[x]={index:x,start:j,size:D,end:O,key:b,lane:I},y[I]===void 0&&M++,y[I]=x,k[I]=O}return this.measurementsCache=S,S},{key:!1,debug:()=>this.options.debug}),this.calculateRange=_e(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,s,o,i)=>t.length===0||s===0?(this.range=null,null):(this.range=li(t,s,o,i,i===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=_e(()=>{let t=null,s=null;const o=this.calculateRange();return o&&(t=o.startIndex,s=o.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,s]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,s]},(t,s,o,i,l)=>i===null||l===null?[]:t({startIndex:i,endIndex:l,overscan:s,count:o}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=t=>{const s=this.options.indexAttribute,o=t.getAttribute(s);return o?parseInt(o,10):(console.warn(`Missing attribute name '${s}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=t=>{var s;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const o=this.scrollState.index??((s=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:s.index);if(o!==void 0&&this.range){const i=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),l=Math.max(0,o-i),a=Math.min(this.options.count-1,o+i);return t>=l&&t<=a}return!0},this.measureElement=t=>{if(!t){this.elementsCache.forEach((l,a)=>{l.isConnected||(this.observer.unobserve(l),this.elementsCache.delete(a))});return}const s=this.indexFromElement(t),o=this.options.getItemKey(s),i=this.elementsCache.get(o);i!==t&&(i&&this.observer.unobserve(i),this.observer.observe(t),this.elementsCache.set(o,t)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(s)&&this.resizeItem(s,this.options.measureElement(t,void 0,this))},this.resizeItem=(t,s)=>{var o,i;if(t<0||t>=this.options.count)return;let l,a,u;const d=this._flatMeasurements;if(this.options.lanes===1&&d!==null)u=this.options.getItemKey(t),a=d[t*2],l=d[t*2+1];else{const m=this.measurementsCache[t];if(!m)return;u=m.key,a=m.start,l=m.size}const f=this.itemSizeCache.get(u)??l,p=s-f;if(p!==0){const m=this.options.anchorTo==="end"&&((o=this.scrollState)==null?void 0:o.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,S=m?this.getTotalSize():0,y=((i=this.scrollState)==null?void 0:i.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[t]??{index:t,key:u,start:a,size:l,end:a+l,lane:0},p,this):a<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(u)||this.scrollDirection!=="backward"));(this.pendingMin===null||t<this.pendingMin)&&(this.pendingMin=t),this.itemSizeCache.set(u,s),this.itemSizeCacheVersion++,m?this.applyScrollAdjustment(this.getTotalSize()-S):y&&this.applyScrollAdjustment(p),this.notify(!1)}},this.getVirtualItems=_e(()=>[this.getVirtualIndexes(),this.getMeasurements()],(t,s)=>{const o=[];for(let i=0,l=t.length;i<l;i++){const a=t[i],u=s[a];o.push(u)}return o},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=t=>{const s=this.getMeasurements();if(s.length===0)return;const o=this._flatMeasurements,i=this.options.lanes===1&&o!=null,l=xs(0,s.length-1,i?a=>o[a*2]:a=>Ht(s[a]).start,t);return Ht(s[l])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const t=this.scrollElement.document.documentElement;return this.options.horizontal?t.scrollWidth-this.scrollElement.innerWidth:t.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(t=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=t,this.getOffsetForAlignment=(t,s,o=0)=>{if(!this.scrollElement)return 0;const i=this.getSize(),l=this.getScrollOffset();s==="auto"&&(s=t>=l+i?"end":"start"),s==="center"?t+=(o-i)/2:s==="end"&&(t-=i);const a=this.getMaxScrollOffset();return Math.max(Math.min(a,t),0)},this.getOffsetForIndex=(t,s="auto")=>{t=Math.max(0,Math.min(t,this.options.count-1));const o=this.getSize(),i=this.getScrollOffset(),l=this.measurementsCache[t];if(!l)return;if(s==="auto")if(l.end>=i+o-this.options.scrollPaddingEnd)s="end";else if(l.start<=i+this.options.scrollPaddingStart)s="start";else return[i,s];if(s==="end"&&t===this.options.count-1)return[this.getMaxScrollOffset(),s];const a=s==="end"?l.end+this.options.scrollPaddingEnd:l.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,s,l.size),s]},this.scrollToOffset=(t,{align:s="start",behavior:o="auto"}={})=>{const i=this.getOffsetForAlignment(t,s),l=this.now();this.scrollState={index:null,align:s,behavior:o,startedAt:l,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollToIndex=(t,{align:s="auto",behavior:o="auto"}={})=>{t=Math.max(0,Math.min(t,this.options.count-1));const i=this.getOffsetForIndex(t,s);if(!i)return;const[l,a]=i,u=this.now();this.scrollState={index:t,align:a,behavior:o,startedAt:u,lastTargetOffset:l,stableFrames:0},this._scrollToOffset(l,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollBy=(t,{behavior:s="auto"}={})=>{const o=this.getScrollOffset()+t,i=this.now();this.scrollState={index:null,align:"start",behavior:s,startedAt:i,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:s}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:t="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:t});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:t})},this.getTotalSize=()=>{var t;const s=this.getMeasurements();let o;if(s.length===0)o=this.options.paddingStart;else if(this.options.lanes===1){const i=s.length-1,l=this._flatMeasurements;l!=null?o=l[i*2]+l[i*2+1]:o=((t=s[i])==null?void 0:t.end)??0}else{const i=Array(this.options.lanes).fill(null);let l=s.length-1;for(;l>=0&&i.some(a=>a===null);){const a=s[l];i[a.lane]===null&&(i[a.lane]=a.end),l--}o=Math.max(...i.filter(a=>a!==null))}return Math.max(o-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const t=[];if(this.itemSizeCache.size===0)return t;const s=this.getMeasurements();for(const o of s)o&&this.itemSizeCache.has(o.key)&&t.push({index:o.index,key:o.key,start:o.start,size:o.size,end:o.end,lane:o.lane});return t},this._scrollToOffset=(t,{adjustments:s,behavior:o})=>{this._intendedScrollOffset=t+(s??0),this.options.scrollToFn(t,{behavior:o,adjustments:s},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(n)}applyScrollAdjustment(n,t){n!==0&&(Ot()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=n:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=n,behavior:t}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollAdjustments=0)))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const s=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,o=s?s[0]:this.scrollState.lastTargetOffset,i=1,l=o!==this.scrollState.lastTargetOffset;if(!l&&Jo(o,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=i){this.getScrollOffset()!==o&&this._scrollToOffset(o,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,l){const a=this.getSize()||600,u=Math.abs(o-this.getScrollOffset()),d=this.scrollState.behavior==="smooth"&&u>a;this.scrollState.lastTargetOffset=o,d||(this.scrollState.behavior="auto"),this._scrollToOffset(o,{adjustments:void 0,behavior:d?"smooth":"auto"})}this.scheduleScrollReconcile()}}const xs=(e,n,t,s)=>{for(;e<=n;){const o=(e+n)/2|0,i=t(o);if(i<s)e=o+1;else if(i>s)n=o-1;else return o}return e>0?e-1:0};function ai(e,n,t){let s=0;for(;s<=n;){const o=(s+n)/2|0,i=e[o*2];if(i<t)s=o+1;else if(i>t)n=o-1;else return o}return s>0?s-1:0}function li(e,n,t,s,o){const i=e.length-1;if(e.length<=s)return{startIndex:0,endIndex:i};if(s===1&&o!==null){const d=ai(o,i,t);let f=d;const p=t+n;for(;f<i&&o[f*2]+o[f*2+1]<p;)f++;return{startIndex:d,endIndex:f}}let a=xs(0,i,d=>e[d].start,t),u=a;if(s===1)for(;u<i&&e[u].end<t+n;)u++;else if(s>1){const d=Array(s).fill(0);for(;u<i&&d.some(p=>p<t+n);){const p=e[u];d[p.lane]=p.end,u++}const f=Array(s).fill(t+n);for(;a>=0&&f.some(p=>p>=t);){const p=e[a];f[p.lane]=p.start,a--}a=Math.max(0,a-a%s),u=Math.min(i,u+(s-1-u%s))}return{startIndex:a,endIndex:u}}const At=typeof document<"u"?c.useLayoutEffect:c.useEffect;function ci({useFlushSync:e=!0,directDomUpdates:n=!1,directDomUpdatesMode:t="transform",...s}){const o=c.useReducer(d=>d+1,0)[1],i=c.useRef({enabled:n,mode:t,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});i.current.enabled=n,i.current.mode=t;const l=d=>{const f=i.current;if(!f.enabled||!f.container)return;const p=d.getTotalSize();if(p!==f.lastSize){f.lastSize=p;const x=d.options.horizontal?"width":"height";f.container.style[x]=`${p}px`}const m=!!d.options.horizontal,S=f.mode==="transform",y=m?"left":"top",k=d.options.scrollMargin,M=d.getVirtualItems();for(const x of M){const b=x.start-k,C=d.elementsCache.get(x.key);C&&f.lastPositions.get(C)!==b&&(f.lastPositions.set(C,b),S?C.style.transform=m?`translate3d(${b}px, 0, 0)`:`translate3d(0, ${b}px, 0)`:C.style[y]=`${b}px`)}},a={...s,onChange:(d,f)=>{var p;const m=i.current;let S=!0;if(m.enabled){l(d);const y=d.range,k=m.prevRange;S=!k||k.isScrolling!==d.isScrolling||k.startIndex!==y?.startIndex||k.endIndex!==y?.endIndex,S&&(m.prevRange=y?{startIndex:y.startIndex,endIndex:y.endIndex,isScrolling:d.isScrolling}:null)}S&&(e&&f?Ls.flushSync(o):o()),(p=s.onChange)==null||p.call(s,d,f)}},[u]=c.useState(()=>{const d=new ri(a);return Object.assign(d,{containerRef:f=>{const p=i.current;if(p.container=f,p.lastSize=null,f&&p.enabled){const m=d.getTotalSize();p.lastSize=m;const S=d.options.horizontal?"width":"height";f.style[S]=`${m}px`}}})});return u.setOptions(a),At(()=>u._didMount(),[]),At(()=>u._willUpdate()),At(()=>{l(u)}),u}function di(e){return ci({observeElementRect:Zo,observeElementOffset:si,scrollToFn:ii,...e})}const Bt=e=>e.query?`matching "${e.query}"`:e.from?`from "${e.from}"`:"matching your search",ui=e=>`Select all ${Bt(e)}`,hi=(e,n)=>`All ${so(n)} ${Bt(e)} selected`,fi=({verb:e,confirmingDelete:n,hasSelection:t,junkMailboxId:s,currentMailboxId:o,deletableMessageId:i})=>{if(n)return{kind:"withheld"};if(e==="junk"){const l=ln(s,o);if(l!==void 0)return{kind:"unavailable",reason:l}}return t?{kind:"openWizard"}:e!=="delete"||i===void 0?{kind:"declined"}:{kind:"confirmDelete",messageId:i}},mi=(e,n,t)=>e==="BACK"&&n&&t===void 0,gi=(e,n)=>({id:e.messageId,accountId:e.accountId,mailboxId:e.mailboxId,threadId:e.threadId,fromName:e.fromName??e.fromEmail??"Unknown",fromEmail:e.fromEmail??"",subject:e.subject??"(No subject)",snippet:e.snippet??"",timeLabel:nt(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:is(e.category),messageCount:n,suspicious:e.authenticity?.dkimMismatch===!0,labels:e.labels}),pi=({thread:e,mailboxId:n,isSelected:t,isFocused:s,isTabStop:o,onFocusRow:i,isChecked:l,onToggleCheck:a,onRowSelect:u,messageCount:d,isMultiSelectMode:f,onLongPress:p,isDesktop:m,density:S})=>r.jsx(cn,{thread:gi(e,d),link:{mailboxId:n,threadId:e.threadId},inListbox:!0,active:t,focused:s,isTabStop:o,density:S,isDesktop:m,onFocusRow:i,selection:{isChecked:l,onToggleCheck:a,onRowSelect:u,isMultiSelectMode:f,onLongPress:p}}),xi=c.memo(pi),bi=e=>{const n=e.authenticity?.dkimMismatch===!0;return{id:e.messageId,accountId:e.accountId,fromName:e.fromName??e.fromEmail??"Unknown",fromEmail:e.fromEmail??"",subject:e.subject??"(No subject)",snippet:e.snippet??"",timeLabel:nt(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:is(e.category),suspicious:n}},vi=({thread:e,mailboxId:n,isSelected:t,isFocused:s,isTabStop:o,onFocusRow:i,isChecked:l,onToggleCheck:a,onRowSelect:u,isMultiSelectMode:d,onLongPress:f,isDesktop:p,onDelete:m,onToggleRead:S,density:y})=>{const[k,M]=c.useState("none"),x=st(),b=c.useCallback(A=>{navigator.vibrate?.(10),A==="trailing"?m(e.messageId):S(e.messageId,e.isRead),M("none")},[m,S,e.messageId,e.isRead]),C=c.useCallback(()=>{f(e.messageId)},[f,e.messageId]),I=c.useCallback(()=>{a(e.messageId)},[a,e.messageId]),j=c.useCallback(()=>{x({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:n,threadId:e.threadId,messageId:e.messageId},search:A=>A,hash:Pe})},[x,n,e.threadId,e.messageId]),E=dn(e.messageId,u);return p||d?r.jsx(xi,{thread:e,mailboxId:n,isSelected:t,isFocused:s,isTabStop:o,onFocusRow:i,isChecked:l,onToggleCheck:a,onRowSelect:u,isMultiSelectMode:d,onLongPress:f,isDesktop:p,density:y}):r.jsx("div",{role:"presentation",onPointerDownCapture:E.onMouseDown,onClickCapture:E.claimClick,onContextMenu:E.onContextMenu,children:r.jsx(Gn,{thread:bi(e),selectionMode:!1,checked:!1,active:t,peek:k,onPeek:M,onToggleCheck:I,onLongPress:C,onOpen:j,onAct:b})})},Si=72,yi=32,Ci=5,bs="remit:list-density",Ii=()=>{try{const e=localStorage.getItem(bs);if(e==="compact"||e==="comfortable")return e}catch{}return"comfortable"},wi=({query:e})=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-line bg-surface-sunken/30",children:[r.jsx(Vs,{className:"size-4 text-fg-muted"}),r.jsxs("span",{className:"text-sm text-fg-muted",children:["Results for “",e,"”"]})]}),ji=({mailboxId:e,threads:n,selectedMessageId:t,isLoading:s,isError:o=!1,error:i,onRetry:l,searchQuery:a,searchPredicate:u,onDeleteMessages:d,isDeleting:f=!1,isMoving:p=!1,onLoadMore:m,hasMore:S=!1,isLoadingMore:y=!1,accountId:k,listTitle:M,listMeta:x,listFilter:b,listScopeLabel:C,onTriageContextChange:I,commandsRef:j,hideHeader:E=!1})=>{const A=c.useRef(null),D=st(),O=fs(),W=Ps(),{verb:K,start:L,startFromSearch:V}=W,oe=$s(),Ie=!!a?.trim(),q=un(),{labels:$e}=io(k),{pushError:ae}=Zt(),[T,H]=c.useState(t),[we,P]=c.useState(),U=c.useCallback(h=>{P(v=>v===h?v:void 0),H(h)},[]),[ge,je]=c.useState(Ii),ke=c.useCallback(()=>{je(h=>{const v=h==="comfortable"?"compact":"comfortable";try{localStorage.setItem(bs,v)}catch{}return v})},[]),{toggleReadFor:Re}=rs({mailboxId:e}),{junkMailboxId:pe}=as(k),Be=ls(pe,e),{selectedIds:R,selectedCount:N,hasSelection:ie,isSelected:xe,toggle:G,select:re,clearSelection:X,selectRange:ue,setAnchor:be,selectAll:ot,toggleAll:it,intersectWith:le}=hn(),We=wn(N,O),[Y,ve]=c.useState(null),z=Ie&&!!u,rt=`${e}|${JSON.stringify(u??{})}`,w=fn({mailboxId:e,accountId:k,enabled:z,predicateKey:rt,searchQuery:u??{}}),at=c.useCallback((h,v,ee)=>{if(ee.error===void 0){if(ee.cancelled){ae({severity:"warning",title:gn(ee.done),detail:mn(h,ee.done,v)});return}ae({severity:"info",title:Wt(h,ee.done)})}},[ae]),lt=w.phase.kind,he=w.clear,Q=c.useCallback(()=>{lt==="escalated"&&he(),X()},[X,he,lt]),[Ee,ct]=c.useState(null),fe=c.useRef(null),F=c.useRef(!1),Oe=c.useRef(null),Ae=!s&&n.length>0,dt=Y!==null,Z=di({count:n.length,getScrollElement:()=>A.current,estimateSize:()=>ge==="compact"?yi:Si,overscan:Ci}),Ke=t?n.findIndex(h=>h.messageId===t):-1,$=T?n.findIndex(h=>h.messageId===T):-1,ce=c.useCallback(h=>{if(h<0||h>=n.length)return;const v=n[h];if(We){G(v.messageId);return}fe.current=v.messageId,F.current=!1,P(v.messageId),H(v.messageId)},[n,We,G]),Ve=c.useCallback(()=>{if(n.length===0)return;const h=$<0?0:Math.min($+1,n.length-1);ce(h)},[n.length,$,ce]),qe=c.useCallback(()=>{if(n.length===0)return;const h=$<=0?0:$-1;ce(h)},[n.length,$,ce]),ut=c.useCallback(()=>ce(0),[ce]),He=c.useCallback(()=>ce(n.length-1),[ce,n.length]),Ne=c.useCallback(()=>{T&&G(T)},[T,G]),B=c.useMemo(()=>n.map(h=>h.messageId),[n]),Me=c.useMemo(()=>{const h=[];for(const v of n)R.has(v.messageId)&&h.push({id:v.messageId,sender:v.fromName??v.fromEmail??"Unknown",email:v.fromEmail??"",subject:v.subject??"(No subject)",date:nt(v.sentDate)});return h},[n,R]),ht=c.useCallback((h,v)=>v.shiftKey?(ue(B,h,T),!0):v.metaKey||v.ctrlKey?(G(h),!0):(Q(),be(h),!1),[B,T,ue,G,Q,be]),ze=c.useCallback(h=>{!d||h.length===0||(Oe.current=T??null,ve(h))},[d,T]),De=c.useCallback(h=>{const v=pn(B,T,h);v!==void 0&&(ue(B,v),fe.current=v,F.current=!1,P(void 0),H(v))},[B,T,ue]),Ue=c.useCallback(()=>De(-1),[De]),Qe=c.useCallback(()=>De(1),[De]),Se=c.useCallback(()=>{B.length>0&&ot(B)},[B,ot]),Te=c.useCallback(h=>{const v=fi({verb:h,confirmingDelete:Y!==null,hasSelection:ie,junkMailboxId:pe,currentMailboxId:e,deletableMessageId:d?T:void 0});return v.kind==="openWizard"?(L(h),!0):v.kind==="confirmDelete"?(ze([v.messageId]),!0):v.kind==="unavailable"?(ae({severity:"warning",title:v.reason}),!0):v.kind==="withheld"},[Y,d,ie,pe,e,L,T,ze,ae]),ne=c.useCallback((h,v)=>{const ee=n.find(te=>te.messageId===h)?.threadId;ee&&D({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:e,threadId:ee,messageId:h},search:te=>te,hash:Pe,replace:v?.replace})},[D,e,n]),me=c.useCallback(()=>{T&&ne(T)},[T,ne]),vt=c.useCallback(h=>ne(h,{replace:!0}),[ne]);xn({keyboardFocusedMessageId:we,openMessageId:t,enabled:O&&N===0,open:vt});const Je=w.phase.kind==="escalated"?{scope:Bt(u??{}),total:w.phase.total,searchQuery:u??{},run:h=>w.runAction(h),stop:w.stop}:void 0,St=c.useCallback(()=>{if(!Y)return;const h=Y;if(h.length===0){ve(null);return}const v=new Set(h),ee=n.findIndex(se=>v.has(se.messageId));let te;for(let se=ee+1;se<n.length;se++)if(!v.has(n[se].messageId)){te=n[se].messageId;break}if(te===void 0){for(let se=ee-1;se>=0;se--)if(!v.has(n[se].messageId)){te=n[se].messageId;break}}d?.(h),Q(),Oe.current=null,ve(null),te!==void 0&&(fe.current=te,F.current=!1,U(te),O&&ne(te,{replace:!0})),O||ct(Wt("delete",h.length))},[Y,n,d,Q,ne,O,U]),ye=c.useCallback(()=>{const h=Oe.current;Oe.current=null,ve(null),h!==null&&(fe.current=h,F.current=!1,U(h))},[U]),Ge=c.useMemo(()=>{if(N===0)return;const h=new Set;for(const v of n)R.has(v.messageId)&&h.add(v.accountConfigId);if(h.size>1)return"Move only works within one account — clear selection or pick messages from a single account"},[N,R,n]),yt=c.useCallback(()=>{if(Je){V();return}L("organize")},[Je,V,L]),Ct=c.useCallback(h=>{d?.([h])},[d]),It=c.useCallback((h,v)=>{Re([h],!v)},[Re]),wt=c.useCallback(h=>{O||re(h)},[O,re]),jt=c.useCallback(()=>{if(w.isRunning||w.phase.kind==="counting"){w.stop();return}Q()},[w,Q]),kt=c.useCallback(()=>{w.clear()},[w]);c.useEffect(()=>{if(F.current||!O&&t)return;const h=$>=0?$:Ke;h>=0&&Z.scrollToIndex(h,{align:"auto"})},[$,Ke,Z,O,t]),c.useEffect(()=>{t&&(F.current=!1,U(t))},[t,U]),c.useEffect(()=>{T&&(n.some(h=>h.messageId===T)||U(n[0]?.messageId))},[n,T,U]),c.useEffect(()=>{I?.({focusedMessageId:T,selectedIds:Array.from(R),hasList:Ae,blocksKeyboard:dt||W.isOpen})},[T,R,Ae,dt,W.isOpen,I]);const Ce=c.useRef(I);Ce.current=I,c.useEffect(()=>()=>Ce.current?.({focusedMessageId:void 0,selectedIds:[],hasList:!1,blocksKeyboard:!1}),[]),c.useEffect(()=>{w.phase.kind!=="idle"||w.isRunning||le(n.map(h=>h.messageId))},[n,le,w.phase,w.isRunning]);const Ye=c.useRef(e);c.useEffect(()=>{Ye.current!==e&&(Ye.current=e,Q())},[e,Q]),bn({shouldBlockFn:({action:h})=>mi(h,ie,oe)?(Q(),!0):!1,enableBeforeUnload:!1,disabled:!ie||oe!==void 0}),c.useEffect(()=>{const h=A.current;if(!h||!S||!m)return;const v=()=>{if(y)return;const{scrollTop:ee,scrollHeight:te,clientHeight:se}=h;ee+se>=te-200&&m()};return h.addEventListener("scroll",v,{passive:!0}),v(),()=>h.removeEventListener("scroll",v)},[S,y,m]),c.useEffect(()=>{const h=fe.current;if(!h)return;const v=A.current?.querySelector(`[data-message-id="${h}"]`);v&&(fe.current=null,v.focus({preventScroll:!0}))}),c.useEffect(()=>{if(j){if(!Ae){j.current=null;return}return j.current={focusNext:Ve,focusPrevious:qe,focusFirst:ut,focusLast:He,openFocused:me,toggleSelect:Ne,extendSelectDown:Qe,extendSelectUp:Ue,selectAll:Se,clearSelection:()=>ie?(Q(),!0):!1,requestVerb:Te,toggleDensity:ke},()=>{j.current=null}}},[j,Ae,Ve,qe,ut,He,me,Ne,Qe,Ue,Se,ie,Q,Te,ke]);const Xe=s?"loading":o?"error":n.length===0?"empty":"ready",Mt=o?to(i):void 0,Tt=c.useCallback(()=>{const h=Bs(Ws());window.open(h,"_blank","noopener,noreferrer")},[]),Rt=[{id:"inbox",threads:[]}],Ze=B.length>0&&B.every(h=>R.has(h)),ft=z&&S&&Ze&&!f&&!p&&w.phase.kind==="idle"&&!w.isRunning,Et=f||p||w.isRunning,g=w.phase.kind==="escalated"?w.phase.total:N,_=w.runningAction?vn(w.runningAction.kind,w.progress?.done??0,w.progress?.total??g):w.phase.kind==="counting"?"Counting matches…":w.phase.kind==="escalated"?hi(u??{},w.phase.total):void 0,J=w.phase.kind!=="escalated"&&B.length>0?{checked:Ze,indeterminate:N>0&&!Ze,onChange:()=>it(B)}:void 0,Cs=w.runningAction?{value:w.progress?.done??0,max:w.progress?.total??g,tone:Sn(w.runningAction.kind)}:void 0,Is=(w.phase.kind==="counting"?{tone:"info",text:"",action:{label:"Stop",onClick:w.stop}}:w.phase.kind==="escalated"&&!w.isRunning?{tone:"info",text:"",action:{label:"Clear selection",onClick:kt}}:ft?{tone:"info",text:"",action:{label:ui(u??{}),onClick:w.escalate}}:void 0)??(Ge?{tone:"warning",text:Ge}:void 0),ws=r.jsx(yn,{title:q.title||M,navSlot:q.navSlot,titleMeta:q.titleMeta,searchSlot:q.searchSlot,searchField:q.searchField,idleSlot:q.makeFilterSlot,count:g,onCancel:jt,onDelete:()=>L("delete"),onMove:()=>L("move"),onOrganize:yt,onJunk:Be?()=>L("junk"):void 0,onMarkRead:()=>L("markRead"),overflowSlot:k&&e&&N>0&&$e.length>0?r.jsx(ro,{accountId:k,mailboxId:e,messageIds:Array.from(R)}):void 0,isBusy:Et,isCounting:w.phase.kind==="counting",selectAll:J,statusLabel:_,progress:Cs,notice:Is}),js=Cn(B,T),ks=c.useCallback(h=>{F.current=!0,U(h)},[U]),Ms=r.jsxs(r.Fragment,{children:[Ie&&a&&r.jsx(wi,{query:a}),r.jsxs("div",{ref:A,role:"listbox","aria-multiselectable":!0,"aria-label":M,className:"flex-1 overflow-y-auto",children:[r.jsx("div",{role:"presentation",className:"relative w-full",style:{height:`${Z.getTotalSize()}px`},children:Z.getVirtualItems().map(h=>{const v=n[h.index];return r.jsx("div",{role:"presentation","data-index":h.index,ref:Z.measureElement,className:Ks("absolute left-0 top-0 w-full border-b border-line",w.isRunning&&"pointer-events-none opacity-50"),style:{transform:`translateY(${h.start}px)`},children:r.jsx(vi,{thread:v,mailboxId:e,isSelected:t===v.messageId,isFocused:T===v.messageId,isTabStop:js===v.messageId,onFocusRow:ks,isChecked:xe(v.messageId),onToggleCheck:G,onRowSelect:ht,isMultiSelectMode:We,onLongPress:wt,isDesktop:O,onDelete:Ct,onToggleRead:It,density:ge})},h.key)})}),y&&r.jsx(Yn,{})]})]});return r.jsxs(r.Fragment,{children:[Ee&&!O&&r.jsx(zt,{tone:"success",variant:"soft",className:"m-2 rounded-md",onDismiss:()=>ct(null),children:Ee}),r.jsx(Xn,{listTitle:M,listMeta:x,sections:Rt,flatList:!0,listState:q.searchResults?"ready":Xe,searchQuery:Ie?a:void 0,listFilter:b,listScopeLabel:C,errorMessage:Mt,onRetry:l,onReportError:Tt,density:ge,selectedThreadId:t,onSelectThread:h=>ne(h),isDesktop:O,hideHeader:E,selectionBar:ws,listBody:q.searchResults??(Xe==="ready"?Ms:void 0)}),r.jsx(ms,{isOpen:Y!==null,title:no(Y?.length??0),description:"You can restore them from Trash later.",confirmLabel:"Move to Trash",destructive:!0,isBusy:f,onConfirm:St,onCancel:ye}),r.jsx(In,{verb:K,accountId:k,mailboxId:e,selection:Me,crossAccount:Ge!==void 0,escalated:Je,escalatedProgress:w.progress,onFinished:Q,onRunEnded:at})]})},ki=e=>Hs({path:{accountId:e}}),Mi=e=>{const n=Dt(),t=_t(),s=Ft({...qs(),onSuccess:()=>{t.recordEvent("sync.triggered"),n.invalidateQueries({queryKey:ki(e)})}});return{trigger:()=>{s.mutate({path:{accountId:e}})},triggerAsync:()=>s.mutateAsync({path:{accountId:e}}),isPending:s.isPending,error:s.error,reset:s.reset}},Ti=({accountId:e,children:n})=>{const{triggerAsync:t,isPending:s}=Mi(e);return r.jsx(Io,{onRefresh:t,isRefreshing:s,children:n})};function Ri({accountId:e,currentMailboxId:n,candidates:t,onMove:s,children:o}){const[i,l]=c.useState(!1),a=_t(),u=mo(),{inboxMailboxId:d}=jn(e),f=kn(e),{data:p}=tt({...Us({path:{accountId:e}}),staleTime:1/0}),m=c.useMemo(()=>go({mailboxes:p?.items??[],folderAppointments:f,currentMailboxId:n,translator:u}),[p?.items,f,n,u]),S=c.useMemo(()=>d||(m.find(b=>b.label.toLowerCase()==="inbox")?.id??m.find(b=>!b.isCurrent)?.id??""),[d,m]),y=c.useRef(!1);c.useEffect(()=>{y.current||(y.current=!0,Mn(a,t.length))},[a,t.length]);const k=c.useCallback(()=>{Tn(a,t.length),l(!0)},[a,t.length]),M=c.useCallback((x,b)=>{Rn(a,{selected:x.length,total:t.length,toInbox:b===d}),s(x,b)},[a,t.length,d,s]);return r.jsxs("div",{className:"relative flex h-full min-h-0 flex-col",children:[r.jsx("div",{className:"shrink-0 px-row-inset pt-2",children:r.jsx(jo,{count:t.length,onReview:k})}),r.jsx("div",{className:"min-h-0 flex-1",children:o}),r.jsx(Fo,{open:i,candidates:t,defaultDestinationId:S,availableFolders:m,delimiter:po(p?.items??[]),onConfirmMove:M,onCancel:()=>l(!1)})]})}const Ei="We can verify this sender";function Oi(e){const{data:n}=tt({...Qs({path:{mailboxId:e??""},query:{senderTrust:["vip","wellknown"],dkimMismatch:!1,results:!0,limit:500}}),enabled:!!e,staleTime:6e4});return{candidates:(n?.items??[]).map(s=>({id:s.messageId,senderName:s.fromName||s.fromEmail||"Unknown sender",senderAddress:s.fromEmail??"",subject:s.subject||"(no subject)",snippet:s.snippet??"",trustReason:Ei,trustSubReason:En(s.senderTrust),senderTrust:s.senderTrust}))}}const Ai=e=>{const n=new Set,t=[];for(const s of e)n.has(s.threadMessageId)||(n.add(s.threadMessageId),t.push(s));return t},Ni={unread:"unread",flagged:"starred",attachment:"attachments"},zi=new Set(Object.values(yo)),vs=e=>zi.has(e),Di=e=>vs(e.category)||e.attributes.size>0,Fi=e=>{const n={};vs(e.category)&&(n.category=[e.category]);for(const t of e.attributes){const s=Ni[t];s&&(n[s]=!0)}return n},_i=e=>(e.senderTrust?.length??0)>0||e.dkimMismatch!==void 0?"loaded-pages":"whole-folder",Li=["category","unread","starred","attachments"],Qt=e=>JSON.stringify(Li.map(n=>e?.[n]??null)),Pi=e=>{if(!Array.isArray(e))return;const[n]=e;if(typeof n!="object"||n===null)return;const t=n.query;if(!(typeof t!="object"||t===null))return t},$i=(e,n)=>{const t=Pi(e);return t?Qt(t)===Qt(n):!1},mt=e=>e[0],Bi=e=>{const n=mt(e.filter(a=>a.type==="from").map(a=>a.value)),t=mt(e.filter(a=>a.type==="subject").map(a=>a.value)),s=mt(e.filter(a=>a.type==="category").map(a=>a.category)),o=mt(e.filter(a=>a.type==="isUnread"||a.type==="isRead").map(a=>a.type==="isUnread")),i=e.some(a=>a.type==="isStarred")?!0:void 0,l=e.some(a=>a.type==="hasAttachment")?!0:void 0;return{...n!==void 0?{from:n}:{},...t!==void 0?{subject:t}:{},...s!==void 0?{category:[s]}:{},...o!==void 0?{unread:o}:{},...i!==void 0?{starred:i}:{},...l!==void 0?{attachments:l}:{}}},Wi=(e,n)=>{switch(n.type){case"from":return e.from?.toLowerCase()===n.value.toLowerCase();case"subject":return e.subject?.toLowerCase()===n.value.toLowerCase();case"category":return e.category?.length===1&&e.category[0]===n.category;case"isUnread":return e.unread===!0;case"isRead":return e.unread===!1;case"isStarred":return e.starred===!0;case"hasAttachment":return e.attachments===!0;case"before":case"after":case"in":case"account":return!1}};function Ki(e,n={}){const t=Bi(e),s={...t,...n};return{params:t,residual:e.filter(o=>!Wi(s,o))}}function Vi(e,n,t){if(n.length===0)return e;const s=[...n];return e.filter(o=>{const i=On(o);return An({...i,accountId:i.accountId??t},s)})}const qi=50,Hi=new Map(us().categories.filter(e=>e.id!=="all").map(e=>[e.id,e.label])),Ss=c.createContext(null);function bt(){const e=c.useContext(Ss);if(!e)throw new Error("MailboxPane.* must be used inside <MailboxPane>");return e}function Ui({mailboxId:e,thread:n,children:t}){const s=st(),o=n?.threadId,i=n?.messageId,l=_t(),{accounts:a,searchQuery:u,intelligenceOpen:d,onToggleIntelligence:f}=es(),p=tn(),m=Co(u),S=m.length>0,{freeText:y,tokens:k}=sn(m,p),[M,x]=c.useState("all"),[b,C]=c.useState(new Set),I=c.useMemo(()=>({category:M,attributes:b}),[M,b]),j=c.useMemo(()=>Fi(I),[I]),E=S||Di(I),{params:A,residual:D}=Ki(k,j),O={order:"desc",limit:qi,...y?{query:y}:{},...A,...j},W={category:O.category,unread:O.unread,starred:O.starred,attachments:O.attachments},K=E?Js({path:{mailboxId:e},query:O}):Gs({path:{mailboxId:e},query:{order:"desc"}}),{data:L,isLoading:V,isError:oe,error:Ie,refetch:q,fetchNextPage:$e,hasNextPage:ae,isFetchingNextPage:T}=Zn({queryKey:K,queryFn:async({pageParam:g})=>{if(E){const{data:J}=await Zs({path:{mailboxId:e},query:{...O,continuationToken:g},throwOnError:!0});return J}const{data:_}=await en({path:{mailboxId:e},query:{order:"desc",continuationToken:g},throwOnError:!0});return _},initialPageParam:void 0,getNextPageParam:g=>g.continuationToken,placeholderData:(g,_)=>$i(_?.queryKey,W)?g:void 0}),{accountId:H}=Nn(e),we=xo({accounts:a}),P=Vi(zn(Ai(L?.pages.flatMap(g=>g.items??[])??[])),D,H),U=c.useCallback(g=>{x(g)},[]),ge=c.useCallback(g=>{C(_=>{const J=new Set(_);return J.has(g)?J.delete(g):J.add(g),J})},[]),je=c.useCallback(()=>{x("all"),C(new Set)},[]),ke=Hi.get(M),Re=ke?{label:ke,reach:D.length>0?"loaded-pages":_i(O),onClear:je}:void 0,pe=o?P.find(g=>g.messageId===i)??P.find(g=>g.threadId===o):void 0,Be=Dn(o,i),R=pe??Be,N=i??R?.messageId,ie=c.useMemo(()=>{if(o)return{threadId:o,mailboxId:R?.mailboxId??e,subject:R?.subject,messageId:N,authenticity:R?.authenticity}},[o,R,N,e]),xe=c.useCallback(()=>{s({to:"/mail/$mailboxId",params:{mailboxId:e},search:g=>g,hash:Pe})},[e,s]),G=c.useCallback(g=>{s({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:e,...g},search:_=>_,hash:Pe})},[e,s]),re=c.useCallback(g=>{N&&g.includes(N)&&xe()},[N,xe]),{deleteMessages:X,isPending:ue}=Kt({mailboxId:e,onAfterOptimisticRemove:re}),{moveMessages:be,isPending:ot}=Vt({mailboxId:e,accountId:H,onAfterOptimisticRemove:re}),it=Fn(),{listCommandsRef:le,onTriageContextChange:We,focusedMessageId:Y,selectedIds:ve}=it,z=P.find(g=>g.messageId===Y)??R,rt=c.useRef(null);c.useEffect(()=>{const g=R?.messageId??null;g&&rt.current!==g&&R?.authenticity?.dkimMismatch&&(rt.current=g,d||f())},[R?.messageId,R?.authenticity?.dkimMismatch,d,f]);const w=bo({accounts:a})??0,at=Dt(),{pushError:lt}=Zt(),he=_n({thread:R,mailboxId:e,accountId:H,onAfterOptimisticRemove:re}),{draftsMailboxId:Q}=Ln(H),Ee=Q!==void 0&&Q===e,{archiveMailboxId:ct}=Pn(H),fe=$n(),{requestCompose:F}=he,Oe=c.useCallback(()=>{F("reply")},[F]),Ae=c.useCallback(()=>{F("reply_all")},[F]),dt=c.useCallback(()=>{F("forward")},[F]),{state:Z,openCompose:Ke,closeCompose:$}=pt(),ce=c.useCallback(()=>{Ke({mode:"new"})},[Ke]),Ve=c.useRef(N);c.useEffect(()=>{const g=Ve.current;Ve.current=N,!(!N||N===g)&&$()},[N,$]);const qe=Ft({...Xt(),onError:g=>{lt(Ys("Couldn't discard draft","The draft wasn't deleted.",g))}}),ut=c.useCallback(()=>{const g=Z.outboxMessageId;g&&(qe.mutate({path:{outboxMessageId:g}}),at.invalidateQueries({queryKey:Yt()}),$())},[Z.outboxMessageId,qe,at,$]),He=c.useCallback(g=>g?fe(g):[],[fe]),{toggleStar:Ne}=Bn({threadId:z?.threadId??"",mailboxId:e}),{toggleReadFor:B}=rs({mailboxId:e,accountId:H}),{junkMailboxId:Me}=as(H),ht=Me!=null&&Me===e,ze=ls(Me,e),{candidates:De}=Oi(ht?Me:void 0),{moveMessages:Ue}=Vt({mailboxId:e,threadId:z?.threadId,accountId:H,onAfterOptimisticRemove:re}),{deleteMessages:Qe}=Kt({mailboxId:e,threadId:z?.threadId,onAfterOptimisticRemove:re}),{addressId:Se,address:Te}=Wn(z),{updateFlags:ne}=Kn({addressId:Se,senderEmail:z?.fromEmail??void 0}),me=c.useCallback(()=>{if(N||!Y)return!1;const g=P.find(_=>_.messageId===Y);return g?(G({threadId:g.threadId,messageId:Y}),!0):!1},[N,Y,P,G]),vt=c.useCallback(()=>{me()||R&&F("reply")},[me,R,F]),Je=c.useCallback(()=>{me()||R&&F("reply_all")},[me,R,F]),St=c.useCallback(()=>{me()||R&&F("forward")},[me,R,F]),ye=c.useCallback(()=>He(z),[He,z]),Ge=c.useCallback(()=>{if(le.current?.requestVerb("delete"))return;const g=ye();g.length>0&&Qe(g)},[le,ye,Qe]),yt=c.useCallback(()=>{if(le.current?.requestVerb("junk")||!ze)return;const g=ye();g.length!==0&&(Vn(l,{count:g.length,senderTrust:z?.senderTrust??"unknown",wasRescuable:z?qn(z):!1}),Ue(g,ze))},[le,ze,ye,Ue,l,z]),Ct=c.useCallback(()=>{if(ve.length>0){const g=!(z?.hasStars??!1),_=new Set(ve);for(const J of P)_.has(J.messageId)&&J.hasStars!==g&&Ne(J.messageId,J.hasStars);return}z&&Ne(z.messageId,z.hasStars)},[ve,P,z,Ne]),It=c.useCallback(()=>{if(le.current?.requestVerb("markRead"))return;const g=ye();if(g.length===0)return;const _=!(z?.isRead??!1);B(g,_)},[le,ye,z,B]),wt=c.useCallback(()=>{if(!Se)return;const g=Te?.flags?.muted?.value!==!0;ne({muted:{value:g}})},[Se,Te,ne]),jt=c.useCallback(()=>{if(!Se)return;const g=Te?.flags?.vip?.value!==!0;ne({vip:{value:g}})},[Se,Te,ne]),kt=c.useCallback(()=>{d||f()},[d,f]),Ce=c.useCallback(g=>{s({to:g})},[s]),Ye=Ee?"drafts":ct===e?"archive":Me===e?"junk":"inbox",Xe=c.useRef("");c.useEffect(()=>{const g=Xe.current;Xe.current=m,m.length>0&&g.length===0&&l.recordEvent("search.submitted",{mailboxType:Ye})},[m,Ye,l]);const Mt=Ee&&Z.isOpen&&!!Z.outboxMessageId&&!R,{goBack:Tt,nextMessageId:Rt,previousMessageId:Ze}=Hn({context:it,orderedIds:P.map(g=>g.messageId),selectedMessageId:N,enabled:!Z.isOpen,onClose:xe,handlers:{reply:vt,replyAll:Je,forward:St,delete:Ge,toggleStar:Ct,toggleRead:It,muteSender:wt,blockSender:kt,vipSender:jt,markJunk:yt,toggleIntelligence:R?f:void 0,compose:ce,goBrief:()=>Ce("/mail/brief"),goInbox:()=>Ce("/mail/brief"),goSent:()=>Ce("/mail/brief"),goFlagged:()=>Ce("/mail/flagged"),goSettings:()=>Ce("/settings")}});vo({enabled:Z.isOpen,bindings:[{key:"Escape",handler:$,preventDefault:!0}]});const ft=g=>{if(!g)return;const _=P.find(J=>J.messageId===g);return _?{threadId:_.threadId,messageId:g}:void 0},Et={mailboxId:e,selectedMessageId:N,selectedThread:R,conversation:ie,onOpenThread:G,threads:P,isLoading:V,isError:oe,error:Ie,mailboxAccountId:H,mailboxName:we,unreadCount:w,isDraftsMailbox:Ee,isSpamFolder:ht,rescueCandidates:De,filterCategory:M,filterAttributes:b,onSelectFilterCategory:U,onToggleFilterAttribute:ge,onClearFilters:je,listFilter:Re,intelligenceOpen:d,onToggleIntelligence:f,handleDeselectIfRemoved:re,searchPredicate:S&&D.length===0?O:void 0,onDeleteMessages:X,onMoveMessages:be,isDeleting:ue,isMoving:ot,onLoadMore:$e,hasMore:ae,isLoadingMore:T,onTriageContextChange:We,listCommandsRef:le,onRetry:()=>q(),toolbarComposeRequest:he.composeRequest,onToolbarReply:Oe,onToolbarReplyAll:Ae,onToolbarForward:dt,onClearComposeRequest:he.clearComposeRequest,onToolbarDelete:he.deleteThread,onToolbarStar:he.toggleStar,onToolbarDiscardDraft:ut,onToolbarMove:he.moveThread,composeState:Z,closeCompose:$,hasRemitDraftOpen:Mt,onBack:Tt,nextThread:ft(Rt),previousThread:ft(Ze)};return r.jsx(Ss.Provider,{value:Et,children:t})}function ys(){const{mailboxId:e,selectedMessageId:n,threads:t,isLoading:s,isError:o,error:i,onDeleteMessages:l,onMoveMessages:a,isDeleting:u,isMoving:d,onLoadMore:f,hasMore:p,isLoadingMore:m,mailboxAccountId:S,mailboxName:y,unreadCount:k,isDraftsMailbox:M,isSpamFolder:x,rescueCandidates:b,onTriageContextChange:C,listCommandsRef:I,onRetry:j,filterCategory:E,filterAttributes:A,onSelectFilterCategory:D,onToggleFilterAttribute:O,onClearFilters:W,listFilter:K,searchPredicate:L}=bt(),{searchQuery:V,searchInput:oe,accounts:Ie,resultFolderIndex:q}=es(),$e=So(),ae=st(),T=y??"Inbox",H=c.useMemo(()=>us(),[]),we=c.useMemo(()=>S?[S]:[],[S]),{hasNewMail:P}=on(),{state:U,errorMessage:ge,refresh:je}=rn(we,{onSettled:j}),ke=c.useMemo(()=>r.jsx(an,{state:U,onRefresh:je,label:`Refresh ${T}`,errorMessage:ge,hasUpdate:P(we)}),[U,je,T,ge,P,we]),Re=c.useMemo(()=>t.map(X=>Qn(X,q)),[t,q]),{hits:pe,isLoading:Be}=ao({mailboxId:e,filterCategory:E}),R=c.useMemo(()=>Jn(pe,t.map(X=>X.threadId),q),[pe,t,q]),N=c.useCallback(X=>{const ue=X.threadId??t.find(be=>be.messageId===X.id)?.threadId;ue&&ae({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:X.mailboxId??e,threadId:ue,messageId:X.id},search:be=>({...be,q:oe||void 0}),hash:Pe})},[e,ae,oe,t]);if(M&&S)return r.jsx(Uo,{mailboxId:e,accountId:S,selectedMessageId:n,imapThreads:t,title:y??"Drafts",unreadCount:k??void 0});const ie=r.jsx(ji,{mailboxId:e,threads:t,selectedMessageId:n,isLoading:s,isError:o,error:i,onRetry:j,searchQuery:V,searchPredicate:L,onDeleteMessages:l,isDeleting:u,isMoving:d,onLoadMore:f,hasMore:p,isLoadingMore:m,accountId:S,listTitle:T,listFilter:K,listScopeLabel:T,hideHeader:!0,onTriageContextChange:C,commandsRef:I}),xe=Ie[0]?.accountId,G=$e==="phone"&&xe?r.jsx(Ti,{accountId:xe,children:ie}):ie,re=x&&b.length>0&&S?r.jsx(Ri,{accountId:S,currentMailboxId:e,candidates:b,onMove:a,children:G}):G;return r.jsx(eo,{title:T,unreadCount:k,preset:H,selectedCategory:E,activeFilters:A,onSelectCategory:D,onToggleFilter:O,onClearFilters:W,searchResults:Re,searchLoading:s,relatedResults:R,relatedLoading:Be,onSelectSearchResult:N,searchResultsInBody:!0,refreshControl:ke,children:re})}function Qi(){const{mailboxId:e,mailboxAccountId:n,selectedThread:t,conversation:s,hasRemitDraftOpen:o,intelligenceOpen:i,onToggleIntelligence:l,toolbarComposeRequest:a,onToolbarReply:u,onToolbarReplyAll:d,onToolbarForward:f,onClearComposeRequest:p,onToolbarDelete:m,onToolbarStar:S,onToolbarDiscardDraft:y,onToolbarMove:k,composeState:M,handleDeselectIfRemoved:x}=bt(),b=Xs()?.showIntelligencePane??!1,C=!!s,[I,j]=c.useState(null),E=s?.threadId??null,A=!b&&E!==null&&I===E,D=c.useCallback(()=>j(null),[]),O=c.useCallback(()=>j(E),[E]),W=b?l:O,K=c.useCallback(()=>{if(b){l();return}j(A?null:E)},[b,l,A,E]),L=C&&(b?i:A),V=M.isOpen&&!s?r.jsx(ps,{}):s?r.jsx(cs,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onOpenIntelligence:s.authenticity?.dkimMismatch?W:void 0,composeRequest:a,onComposeClose:p}):r.jsx(nn,{});return r.jsxs(r.Fragment,{children:[r.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[r.jsx(Un,{hasThread:C,intelligenceOpen:L,canToggleIntelligence:C,onToggleIntelligence:K,onReply:C?u:void 0,onReplyAll:C?d:void 0,onForward:C?f:void 0,canDelete:C||o,onDelete:C?m:o?y:void 0,onToggleStar:C?S:void 0,isStarred:t?.hasStars,moveContext:C&&n?{accountId:n,currentMailboxId:e,onMove:k}:void 0}),r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:V})]}),r.jsx(ds,{isOpen:A,onClose:D,ariaLabel:"Message details",side:"right",children:r.jsx(Lt,{onClose:D,thread:t,mailboxId:e,accountId:n,hideCloseButton:!0,onAfterOptimisticRemove:x})})]})}function Ji(){const{mailboxId:e,mailboxAccountId:n,selectedThread:t,onToggleIntelligence:s,handleDeselectIfRemoved:o}=bt();return r.jsx(Lt,{onClose:s,thread:t,mailboxId:e,accountId:n,onAfterOptimisticRemove:o})}function Gi(){const{mailboxId:e,mailboxAccountId:n,selectedThread:t,conversation:s,onOpenThread:o,intelligenceOpen:i,onToggleIntelligence:l,onBack:a,nextThread:u,previousThread:d,composeState:f,handleDeselectIfRemoved:p}=bt();return s?r.jsxs(r.Fragment,{children:[r.jsx(cs,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onBack:a,onOpenIntelligence:l,onSwipeNext:u?()=>o(u):void 0,onSwipePrevious:d?()=>o(d):void 0,mobileIntelligenceOpen:i}),r.jsx(ds,{isOpen:i,onClose:l,ariaLabel:"Message details",side:"right",children:r.jsx(Lt,{onClose:l,thread:t,mailboxId:e,accountId:n,hideCloseButton:!0,onAfterOptimisticRemove:p})})]}):f.isOpen?r.jsx("div",{className:"h-full",children:r.jsx(ps,{})}):r.jsx(ys,{})}const Cr=Object.assign(Ui,{List:ys,Reading:Qi,Intelligence:Ji,Phone:Gi});export{Cr as M};
1
+ import{j as r,bf as Ts,aA as zt,B as de,S as Rs,b as Le,aB as Jt,r as c,C as Es,d as Os,b0 as As,k as pt,x as tt,Z as Gt,X as Ns,p as st,s as Dt,y as zs,af as Ft,bg as Yt,bh as Xt,I as Ds,h as Fs,T as _s,bi as Ls,bj as Ps,bk as $s,ad as Zt,aN as Bs,aO as Ws,K as Ks,g as Vs,a2 as _t,bl as qs,Q as Hs,w as Us,bm as Qs,o as es,bn as Js,H as Gs,ag as Ys,i as Xs,bo as Zs,b5 as en}from"./index-Bo-p3LpF.js";import{u as tn,p as sn,R as nn}from"./useSearchTokenContext-Bb3YnI52.js";import{u as on,a as rn,R as an}from"./useRefreshControl-hxsw2pLp.js";import{C as ts,D as Fe,a as ss,b as ns,c as os,j as ln,M as cn,t as is,u as dn,d as un,e as rs,f as as,g as hn,h as fn,i as mn,k as gn,l as Wt,n as pn,m as xn,o as bn,p as vn,q as Sn,S as yn,r as Cn,s as In,v as wn,w as ls,x as jn,y as kn,z as Mn,A as Tn,B as Rn,E as En,F as On,G as An,H as Nn,I as zn,J as Dn,K as Kt,L as Vt,N as Fn,O as _n,P as Ln,Q as Pn,R as $n,T as Bn,U as Wn,V as Kn,W as Vn,X as qn,Y as Hn,Z as cs,_ as ds,$ as Lt,a0 as Un,a1 as us,a2 as Qn,a3 as Jn}from"./MailListHeader-BJ9doZxm.js";import{S as Gn,M as Yn,a as Xn,u as Zn,b as eo}from"./MailViewChrome-wpRug1Q0.js";import{E as hs,f as to}from"./ErrorState-DrA1RdFM.js";import{d as fs}from"./useFilters-D_O09QB6.js";import{C as ms}from"./confirm-dialog-DZ3dfzvC.js";import{A as Pt}from"./avatar-lbydjrIt.js";import{b as nt,c as so,d as no}from"./format-De9HZKjg.js";import{r as Pe}from"./nav-link-BC-lpJt4.js";import{N as oo}from"./NavMenuButton-Dy0q8FiJ.js";import{a as io}from"./useLabels-wgL9c4lv.js";import{L as ro,u as ao}from"./useSemanticSearch-BXCI_0Rt.js";import{u as lo,D as co}from"./use-match-media-jqJ95ElE.js";import{S as xt}from"./shield-check-C48_fmzW.js";import{B as uo}from"./bottom-sheet-BZM-qnW9.js";import{C as ho}from"./circle-help-D-5uStGy.js";import{C as fo}from"./circle-check-BO9xAEiG.js";import{a as mo,b as go,f as po}from"./move-options-_eZlt0v0.js";import{j as xo,k as bo,f as vo,d as So}from"./search-token-index-sLIcvT6p.js";import{M as yo}from"./enums-CCxx0t2v.js";import{n as Co}from"./search-query-Cr_ZXBCp.js";const Io=({children:e,onRefresh:n,isRefreshing:t})=>lo(co)?e:r.jsx(Ts,{onRefresh:n,isPullable:!t,children:e}),wo=e=>e===1?"message":"messages";function jo({count:e,onReview:n,onDismiss:t,actionLabel:s="Review & rescue"}){return r.jsx(zt,{tone:"info",variant:"soft",onDismiss:t,children:r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsxs("p",{className:"flex items-start gap-2 text-sm text-fg",children:[r.jsx(xt,{className:"mt-0.5 size-4 shrink-0 text-positive","aria-hidden":!0}),r.jsxs("span",{children:[r.jsx("span",{className:"font-semibold text-fg",children:`${e} ${wo(e)} here`})," ","may not be spam — they're from senders we can verify."]})]}),r.jsx(de,{variant:"primary",size:"sm",onClick:n,className:"self-start",children:s})]})})}const ko=(e,n)=>e==="vip"?"vip":e==="unknown"&&n==="md"?"unknown-pill":"hidden",gs=({senderTrust:e,size:n="sm",className:t})=>{const s=ko(e,n);return s==="vip"?r.jsx(Rs,{className:Le("text-warning shrink-0",n==="sm"&&"size-3.5",n==="md"&&"size-4",t),"aria-label":"VIP sender","data-testid":"sender-trust-vip"}):s==="unknown-pill"?r.jsx("span",{className:Le("inline-flex items-center rounded border border-dashed border-fg-subtle/40 font-medium uppercase tracking-wide text-fg-muted/80 shrink-0","px-2 py-0.5 text-xs",t),title:"First message from this sender","aria-label":"First message from this sender","data-testid":"sender-trust-unknown",children:"new"}):null};function Mo({candidate:e,selected:n,onToggle:t,hideSender:s=!1}){const{senderName:o,senderAddress:i,subject:l,snippet:a,trustReason:u,trustSubReason:d,senderTrust:f}=e;return r.jsxs("label",{className:Le("flex w-full cursor-pointer items-start gap-3 px-3 py-2.5 text-left transition-colors",s&&"pl-11",n?"bg-positive/10":"bg-surface hover:bg-surface-sunken"),children:[r.jsx(ts,{className:"mt-0.5",checked:n,onChange:t,"aria-label":`${n?"Deselect":"Select"} ${s?l:`message from ${o}`}`}),!s&&r.jsx(Pt,{name:o,email:i,size:"sm"}),r.jsxs("span",{className:"min-w-0 flex-1",children:[!s&&r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"truncate text-sm font-medium text-fg",children:o}),f&&r.jsx(gs,{senderTrust:f,size:"sm"}),r.jsx("span",{className:"truncate text-2xs text-fg-subtle",children:i})]}),r.jsx("span",{className:"block truncate text-sm text-fg-muted",children:l}),r.jsx("span",{className:"block line-clamp-1 text-xs text-fg-subtle",children:a}),!s&&r.jsxs("span",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[r.jsxs(Jt,{tone:"positive",children:[r.jsx(xt,{className:"size-3","aria-hidden":!0}),u]}),r.jsx("span",{className:"text-2xs text-fg-subtle",children:d})]})]})]})}const To=e=>{const n=new Map,t=[];for(const s of e){const o=(s.senderAddress||s.senderName).toLowerCase(),i=n.get(o);if(i){i.messages.push(s);continue}n.set(o,{key:o,senderName:s.senderName,senderAddress:s.senderAddress,trustReason:s.trustReason,trustSubReason:s.trustSubReason,senderTrust:s.senderTrust,messages:[s]}),t.push(o)}return t.map(s=>n.get(s)).sort((s,o)=>o.messages.length-s.messages.length)},Ro=(e,n)=>{const t=e.messages.filter(s=>n.has(s.id)).length;return t===0?"none":t===e.messages.length?"all":"some"},qt=e=>e===1?"message":"messages";function Eo({group:e,selected:n,onToggleGroup:t,onToggleMessage:s}){const[o,i]=c.useState(!1),l=Ro(e,n),a=e.messages.length,u=o?Es:Os;return r.jsxs("div",{className:Le(l!=="none"?"bg-positive/10":"bg-surface"),children:[r.jsxs("div",{className:"flex w-full items-start gap-3 px-3 py-2.5",children:[r.jsx(ts,{className:"mt-0.5",checked:l==="all",indeterminate:l==="some",onChange:()=>t(e,l!=="all"),"aria-label":`${l==="all"?"Deselect":"Select"} all ${a} ${qt(a)} from ${e.senderName}`}),r.jsx(Pt,{name:e.senderName,email:e.senderAddress,size:"sm"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"truncate text-sm font-medium text-fg",children:e.senderName}),e.senderTrust&&r.jsx(gs,{senderTrust:e.senderTrust,size:"sm"}),r.jsx("span",{className:"truncate text-2xs text-fg-subtle",children:e.senderAddress})]}),r.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[r.jsxs(Jt,{tone:"positive",children:[r.jsx(xt,{className:"size-3","aria-hidden":!0}),e.trustReason]}),r.jsx("span",{className:"text-2xs text-fg-subtle",children:e.trustSubReason})]})]}),r.jsxs("button",{type:"button",onClick:()=>i(d=>!d),"aria-expanded":o,className:"flex shrink-0 items-center gap-1 rounded-md px-1.5 py-1 text-2xs text-fg-muted transition-colors hover:bg-surface-sunken hover:text-fg",children:[`${a} ${qt(a)}`,r.jsx(u,{className:"size-3.5","aria-hidden":!0})]})]}),o&&r.jsx("div",{className:"divide-y divide-line border-t border-line",children:e.messages.map(d=>r.jsx(Mo,{candidate:d,selected:n.has(d.id),onToggle:()=>s(d.id),hideSender:!0},d.id))})]})}const $t=e=>e===1?"message":"messages",Oo=(e,n)=>`Moves ${e===1?"this message":`these ${e} ${$t(e)}`} out of Spam to ${n} now. Nothing later.`,Nt=(e,n)=>e.find(t=>t.id===n)?.label??"Inbox";function Ao(){return r.jsx(zt,{tone:"info",variant:"soft",children:r.jsx("p",{className:"text-2xs text-fg-muted",children:"We list a message here only when we can confirm the sender is who they say — usually someone you've emailed before, write to often, or a service that consistently checks out. We never guess from words in the subject. Anything we can't confirm stays in Spam."})})}function No({candidates:e,selected:n,onToggle:t,onToggleGroup:s,onSelectAll:o,onSelectNone:i,onContinue:l,onCancel:a}){const[u,d]=c.useState(!1),f=n.size,p=c.useMemo(()=>To(e),[e]);return r.jsxs("div",{className:"flex min-h-0 flex-col",children:[r.jsxs("div",{className:"px-row-inset pb-2 pt-1",children:[r.jsxs("div",{className:"flex items-start justify-between gap-2",children:[r.jsxs("h2",{className:"flex items-center gap-2 text-sm font-semibold text-fg",children:[r.jsx(xt,{className:"size-4 text-positive","aria-hidden":!0}),"Rescue from Spam"]}),r.jsx(de,{variant:"ghost",size:"sm",icon:r.jsx(ho,{className:"size-3.5"}),onClick:()=>d(m=>!m),className:"-mr-1.5 -mt-0.5",children:"Why these?"})]}),r.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:"These look safe — from senders we can verify. Uncheck any sender that belongs in Spam, or open a sender to pick individual messages."}),u&&r.jsx("div",{className:"mt-2",children:r.jsx(Ao,{})})]}),r.jsxs("div",{className:"flex items-center justify-between px-row-inset pb-1.5",children:[r.jsx("span",{className:"text-2xs font-medium text-fg-muted",children:`${f} of ${e.length} selected · ${p.length} ${p.length===1?"sender":"senders"}`}),r.jsxs("span",{className:"flex gap-1",children:[r.jsx(de,{variant:"ghost",size:"sm",onClick:o,children:"Select all"}),r.jsx(de,{variant:"ghost",size:"sm",onClick:i,children:"Select none"})]})]}),r.jsx("div",{className:"min-h-0 flex-1 divide-y divide-line overflow-y-auto border-y border-line",children:p.map(m=>r.jsx(Eo,{group:m,selected:n,onToggleGroup:s,onToggleMessage:t},m.key))}),r.jsxs("div",{className:"space-y-2 border-t border-line bg-surface px-row-inset py-3",children:[r.jsx(de,{variant:"primary",onClick:l,className:"h-11 w-full font-semibold",children:`Continue with ${f} ${$t(f)}`}),r.jsx(de,{variant:"ghost",onClick:a,className:"h-11 w-full",children:"Cancel"})]})]})}function zo({count:e,folders:n,delimiter:t,destination:s,onPick:o,onMove:i,onBack:l}){const[a,u]=c.useState(!1);return r.jsxs("div",{className:"flex min-h-0 flex-col",children:[r.jsxs("div",{className:"px-row-inset pb-2 pt-1",children:[r.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Where should they go?"}),r.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:"Pick a folder, then we move them out of Spam."})]}),r.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-y-auto px-row-inset py-2",children:a?r.jsx("div",{className:"flex min-h-0 flex-1 overflow-hidden rounded-xl border border-line bg-surface",children:r.jsx(As,{folders:n,selectedId:s,delimiter:t,onSelect:o,onCancel:()=>u(!1)})}):r.jsxs("div",{className:"rounded-xl border border-line bg-surface-sunken p-3",children:[r.jsx("p",{className:"text-2xs text-fg-subtle",children:"Destination"}),r.jsx("p",{className:"mt-0.5 text-sm font-medium text-fg",children:Nt(n,s)}),r.jsx(de,{variant:"ghost",size:"sm",onClick:()=>u(!0),className:"mt-2 px-0",children:"Move to a different folder"})]})}),r.jsxs("div",{className:"space-y-2 border-t border-line bg-surface px-row-inset py-3",children:[r.jsx("p",{className:"text-2xs text-fg-subtle",children:Oo(e,Nt(n,s))}),r.jsx(de,{variant:"primary",onClick:i,className:"h-11 w-full font-semibold",children:`Move ${e} out of Spam`}),r.jsx(de,{variant:"ghost",onClick:l,className:"h-11 w-full",children:"Back"})]})]})}function Do({count:e,destinationLabel:n,onClose:t}){return r.jsxs("div",{className:"flex min-h-0 flex-col",children:[r.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-row-inset py-10 text-center",children:[r.jsx(fo,{className:"size-10 text-positive","aria-hidden":!0}),r.jsx("p",{className:"text-base font-semibold text-fg",children:`Moved ${e} ${$t(e)} out of Spam.`}),r.jsx("p",{className:"text-2xs text-fg-subtle",children:`You'll find them in ${n}.`})]}),r.jsx("div",{className:"border-t border-line bg-surface px-row-inset py-3",children:r.jsx(de,{variant:"primary",onClick:t,className:"h-11 w-full font-semibold",children:"Done"})})]})}function Fo({open:e,candidates:n,defaultDestinationId:t,availableFolders:s,delimiter:o,onConfirmMove:i,onCancel:l}){const[a,u]=c.useState("review"),[d,f]=c.useState(()=>e?new Set(n.map(I=>I.id)):new Set),[p,m]=c.useState(t),[S,y]=c.useState(0),k=c.useRef(!1);c.useEffect(()=>{e&&!k.current&&(u("review"),f(new Set(n.map(I=>I.id))),m(t),y(0)),k.current=e},[e,n,t]);const M=d.size,x=I=>{f(j=>{const E=new Set(j);return E.has(I)?E.delete(I):E.add(I),E})},b=(I,j)=>{f(E=>{const A=new Set(E);for(const D of I.messages)j?A.add(D.id):A.delete(D.id);return A})},C=()=>{const I=Array.from(d);y(I.length),i(I,p),u("done")};return r.jsxs(uo,{open:e,onClose:l,dismissLabel:"Close rescue",children:[a==="review"&&r.jsx(No,{candidates:n,selected:d,onToggle:x,onToggleGroup:b,onSelectAll:()=>f(new Set(n.map(I=>I.id))),onSelectNone:()=>f(new Set),onContinue:()=>u("destination"),onCancel:l}),a==="destination"&&r.jsx(zo,{count:M,folders:s,delimiter:o,destination:p,onPick:m,onMove:C,onBack:()=>u("review")}),a==="done"&&r.jsx(Do,{count:S,destinationLabel:Nt(s,p),onClose:l})]})}const _o={reply:"Reply",reply_all:"Reply All",forward:"Forward",new:"New Message"},Lo=()=>{const e=c.useRef(!1);return c.useCallback(()=>{const t=document.querySelector("[data-subject-field]")?.value??"",i=(document.querySelector('[data-testid="compose-body"]')?.textContent??"").replace(/--\s*/g,"").trim();return e.current=t.trim().length>0||i.length>0,e.current},[])},Po=()=>{const{state:e,closeCompose:n}=pt(),t=Lo(),[s,o]=c.useState(!1),{isError:i,error:l,refetch:a}=tt({...Gt(),staleTime:1/0}),u=c.useCallback(m=>{m||(t()?o(!0):n())},[n,t]),d=c.useCallback(()=>{o(!1),n()},[n]),f=c.useCallback(()=>{o(!1)},[]);if(!e.isOpen)return null;const p=_o[e.mode]??"New Message";return r.jsxs(Fe.Root,{open:e.isOpen,onOpenChange:u,children:[r.jsxs(Fe.Portal,{children:[r.jsx(Fe.Overlay,{className:"fixed inset-0 z-40 bg-black/40"}),r.jsxs(Fe.Content,{className:"fixed inset-x-0 bottom-0 z-50 flex flex-col rounded-t-lg bg-canvas pb-[env(safe-area-inset-bottom,0px)]",style:{height:"95dvh"},children:[r.jsx(Fe.Handle,{className:"mx-auto mt-2 mb-1 h-1.5 w-12 rounded-full bg-fg-muted/30"}),r.jsx(Fe.Title,{className:"px-4 py-2 text-base font-semibold border-b border-line",children:p}),i?r.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:r.jsx(hs,{title:"Couldn't load compose",error:l,onRetry:()=>{a()}})}):r.jsx("div",{className:"flex-1 overflow-hidden",children:r.jsx(ss,{mode:e.mode,account:e.account,sourceMessage:e.sourceMessage,onClose:n})})]})]}),r.jsx(ms,{isOpen:s,title:"Discard draft?",description:"Your message has unsaved content. Are you sure you want to discard it?",confirmLabel:"Discard",cancelLabel:"Keep editing",destructive:!0,onConfirm:d,onCancel:f})]})},$o={reply:"Reply",reply_all:"Reply All",forward:"Forward",new:"New Message"},ps=()=>{const{state:e,closeCompose:n}=pt(),t=fs(),{isError:s,error:o,refetch:i}=tt({...Gt(),staleTime:1/0});if(!t)return r.jsx(Po,{});if(!e.isOpen)return null;const l=$o[e.mode]??"New Message",a=r.jsxs("header",{className:"flex items-center justify-between gap-2 px-4 py-3 border-b border-line shrink-0",children:[r.jsx("div",{className:"flex items-center gap-2 min-w-0",children:r.jsx("h2",{className:"text-lg font-semibold truncate",children:l})}),r.jsx("button",{type:"button",onClick:n,className:"p-2 rounded-md hover:bg-surface-raised transition-colors min-h-11 min-w-11 inline-flex items-center justify-center","aria-label":"Close",children:r.jsx(Ns,{className:"size-5"})})]});return s?r.jsxs("div",{className:"h-full flex flex-col bg-canvas",children:[a,r.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:r.jsx(hs,{title:"Couldn't load compose",error:o,onRetry:()=>{i()}})})]}):r.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-canvas",children:[a,r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:r.jsx(ss,{mode:e.mode,account:e.account,sourceMessage:e.sourceMessage,onClose:n},e.outboxMessageId??"new")})]})};function Bo(e){const n=e.toAddresses.join(", ");return{id:e.outboxMessageId,accountId:e.accountId,fromName:e.fromName??e.fromAddress??"Me",fromEmail:e.fromAddress??"",subject:e.subject??"(No subject)",snippet:n?`To: ${n}`:"(No recipients)",timeLabel:nt(e.updatedAt),isRead:!0}}function Wo(e){return{id:e.messageId,accountId:e.accountId,fromName:e.fromName??e.fromEmail??"Unknown",fromEmail:e.fromEmail??"",subject:e.subject??"(No subject)",snippet:e.snippet??"",timeLabel:nt(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0}}function Ko({outboxMessages:e,accountId:n,imapThreads:t}){const s=e.filter(l=>l.status==="draft"&&l.accountId===n).map(Bo),o=t.map(Wo),i=[];return s.length>0&&i.push({id:"remit-drafts",label:"Not yet sent (Remit)",threads:s}),o.length>0&&i.push({id:"imap-drafts",label:"On the server",threads:o}),i}const Vo=({label:e,count:n})=>r.jsxs("div",{className:"sticky top-0 z-10 flex items-baseline justify-between border-b border-line bg-surface-sunken px-row-inset py-1",children:[r.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:e}),r.jsx("span",{className:"text-2xs text-fg-subtle tabular-nums",children:n})]}),qo=({row:e,isSelected:n,onOpen:t,onDelete:s,isDeleting:o})=>r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:Le("group",os({active:n})),children:[r.jsx(Fs,{className:"size-7 shrink-0 text-fg-muted mt-0.5"}),r.jsx(ns,{thread:e}),r.jsx("div",{className:"flex items-center gap-1 shrink-0",children:r.jsx("button",{type:"button",onClick:i=>{i.stopPropagation(),s(e.id)},disabled:o,className:"p-1.5 rounded-md text-fg-muted hover:text-danger hover:bg-surface-raised transition-colors opacity-0 group-hover:opacity-100 focus:opacity-100",title:"Delete draft",children:r.jsx(_s,{className:"size-3.5"})})})]}),Ho=({row:e,isSelected:n,onOpen:t})=>{const s=!e.isRead;return r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:Le("group",os({active:n})),children:[s&&r.jsx("span",{className:"absolute left-1.5 top-1/2 size-1.5 -translate-y-1/2 rounded-full bg-accent"}),r.jsx(Pt,{name:e.fromName,email:e.fromEmail,size:"sm"}),r.jsx(ns,{thread:e})]})};function Uo({mailboxId:e,accountId:n,selectedMessageId:t,imapThreads:s,title:o,unreadCount:i}){const{openCompose:l,state:a}=pt(),u=st(),d=Dt(),{data:f}=tt(zs()),p=c.useMemo(()=>Ko({outboxMessages:f?.items??[],accountId:n,imapThreads:s}),[f?.items,n,s]),m=Ft({...Xt(),onSuccess:()=>{d.invalidateQueries({queryKey:Yt()})}}),S=x=>{m.mutate({path:{outboxMessageId:x}})},y=x=>{l({mode:"new",outboxMessageId:x})},k=x=>{const b=s.find(C=>C.messageId===x)?.threadId;b&&u({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:e,threadId:b,messageId:x},search:C=>C,hash:Pe})},M=p.length===0;return r.jsxs("section",{className:"flex h-full w-full flex-col bg-surface",children:[r.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[r.jsx(oo,{}),r.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:o}),(i??0)>0&&r.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:[i," unread"]})]}),r.jsx("div",{className:"flex-1 overflow-y-auto",children:M?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 text-center px-4",children:[r.jsx(Ds,{className:"size-8 text-fg-subtle"}),r.jsx("p",{className:"text-sm font-medium text-fg",children:"No drafts"}),r.jsx("p",{className:"text-xs text-fg-subtle",children:"Messages you start composing will appear here."})]}):p.map(x=>r.jsxs("div",{children:[x.label&&r.jsx(Vo,{label:x.label,count:x.threads.length}),r.jsx("div",{className:"divide-y divide-line",children:x.threads.map(b=>x.id==="remit-drafts"?r.jsx(qo,{row:b,isSelected:a.isOpen&&b.id===a.outboxMessageId,onOpen:y,onDelete:S,isDeleting:m.isPending},b.id):r.jsx(Ho,{row:b,isSelected:b.id===t,onOpen:k},b.id))})]},x.id))})]})}function Qo(e,n,t){const s=new Array(e);return new Proxy(s,{get(o,i,l){if(typeof i=="string"){const a=i.charCodeAt(0);if(a>=48&&a<=57){const u=+i;if(Number.isInteger(u)&&u>=0&&u<e){let d=o[u];if(!d){const f=n[u*2];d=o[u]={index:u,key:t(u),start:f,size:n[u*2+1],end:f+n[u*2+1],lane:0}}return d}}if(i==="length")return e}return Reflect.get(o,i,l)}})}function _e(e,n,t){let s=t.initialDeps??[],o,i=!0;function l(){const a=e();return(a.length!==s.length||a.some((d,f)=>s[f]!==d))&&(s=a,o=n(...a),t?.onChange&&!(i&&t.skipInitialOnChange)&&t.onChange(o),i=!1),o}return l.updateDeps=a=>{s=a},l}function Ht(e,n){if(e===void 0)throw new Error("Unexpected undefined");return e}const Jo=(e,n)=>Math.abs(e-n)<1.01,Go=(e,n,t)=>{let s;return function(...o){e.clearTimeout(s),s=e.setTimeout(()=>n.apply(this,o),t)}};let et;const Ot=()=>{if(et!==void 0)return et;if(typeof navigator>"u")return et=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return et=!0;const e=navigator.maxTouchPoints;return et=navigator.platform==="MacIntel"&&e!==void 0&&e>0},Ut=e=>{const{offsetWidth:n,offsetHeight:t}=e;return{width:n,height:t}},Yo=e=>e,Xo=e=>{const n=Math.max(e.startIndex-e.overscan,0),s=Math.min(e.endIndex+e.overscan,e.count-1)-n+1,o=new Array(s);for(let i=0;i<s;i++)o[i]=n+i;return o},Zo=(e,n)=>{const t=e.scrollElement;if(!t)return;const s=e.targetWindow;if(!s)return;const o=l=>{const{width:a,height:u}=l;n({width:Math.round(a),height:Math.round(u)})};if(o(Ut(t)),!s.ResizeObserver)return()=>{};const i=new s.ResizeObserver(l=>{const a=()=>{const u=l[0];if(u?.borderBoxSize){const d=u.borderBoxSize[0];if(d){o({width:d.inlineSize,height:d.blockSize});return}}o(Ut(t))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return i.observe(t,{box:"border-box"}),()=>{i.unobserve(t)}},gt={passive:!0},ei=typeof window>"u"?!0:"onscrollend"in window,ti=(e,n,t)=>{const s=e.scrollElement;if(!s)return;const o=e.targetWindow;if(!o)return;const i=e.options.useScrollendEvent&&ei;let l=0;const a=i?null:Go(o,()=>n(l,!1),e.options.isScrollingResetDelay),u=p=>()=>{l=t(s),a?.(),n(l,p)},d=u(!0),f=u(!1);return s.addEventListener("scroll",d,gt),i&&s.addEventListener("scrollend",f,gt),()=>{s.removeEventListener("scroll",d),i&&s.removeEventListener("scrollend",f)}},si=(e,n)=>ti(e,n,t=>{const{horizontal:s,isRtl:o}=e.options;return s?t.scrollLeft*(o&&-1||1):t.scrollTop}),ni=(e,n,t)=>{if(t.options.useCachedMeasurements){const s=t.indexFromElement(e),o=t.options.getItemKey(s);return t.itemSizeCache.get(o)??t.options.estimateSize(s)}if(n?.borderBoxSize){const s=n.borderBoxSize[0];if(s)return Math.round(s[t.options.horizontal?"inlineSize":"blockSize"])}if(!n){const s=t.indexFromElement(e),o=t.options.getItemKey(s),i=t.itemSizeCache.get(o);if(i!==void 0)return i}return e[t.options.horizontal?"offsetWidth":"offsetHeight"]},oi=(e,{adjustments:n=0,behavior:t},s)=>{var o,i;(i=(o=s.scrollElement)==null?void 0:o.scrollTo)==null||i.call(o,{[s.options.horizontal?"left":"top"]:e+n,behavior:t})},ii=oi;class ri{constructor(n){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var t,s,o;return((o=(s=(t=this.targetWindow)==null?void 0:t.performance)==null?void 0:s.now)==null?void 0:o.call(s))??Date.now()},this.observer=(()=>{let t=null;const s=()=>t||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:t=new this.targetWindow.ResizeObserver(o=>{o.forEach(i=>{const l=()=>{const a=i.target,u=this.indexFromElement(a);if(!a.isConnected){this.observer.unobserve(a);for(const[d,f]of this.elementsCache)if(f===a){this.elementsCache.delete(d);break}return}this.shouldMeasureDuringScroll(u)&&this.resizeItem(u,this.options.measureElement(a,i,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()})}));return{disconnect:()=>{var o;(o=s())==null||o.disconnect(),t=null},observe:o=>{var i;return(i=s())==null?void 0:i.observe(o,{box:"border-box"})},unobserve:o=>{var i;return(i=s())==null?void 0:i.unobserve(o)}}})(),this.range=null,this.setOptions=t=>{var s,o;const i={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Yo,rangeExtractor:Xo,onChange:()=>{},measureElement:ni,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const m in t){const S=t[m];S!==void 0&&(i[m]=S)}const l=this.options;let a=null,u=null,d=!1;if(l!==void 0&&l.enabled&&i.enabled&&i.anchorTo==="end"&&this.scrollElement!==null){const m=l.count,S=i.count,y=this.getMeasurements(),k=m>0?((s=y[0])==null?void 0:s.key)??l.getItemKey(0):null,M=m>0?((o=y[m-1])==null?void 0:o.key)??l.getItemKey(m-1):null;if(S!==m||m>0&&S>0&&(i.getItemKey(0)!==k||i.getItemKey(S-1)!==M)){d=!0;const C=m>0?this.getVirtualItemForOffset(this.getScrollOffset())??y[0]:null;C&&(a=[C.key,this.getScrollOffset()-C.start]);const I=i.followOnAppend===!0?"auto":i.followOnAppend||null;I&&S>m&&this.isAtEnd(l.scrollEndThreshold)&&(m===0||i.getItemKey(S-1)!==M)&&(u=I)}}this.options=i,d&&(this.pendingMin=0,this.itemSizeCacheVersion++);let f=!1,p=0;if(a&&this.scrollOffset!==null){const[m,S]=a,y=this.getMeasurements(),{count:k,getItemKey:M}=this.options;let x=0;for(;x<k&&M(x)!==m;)x++;if(x<k){const b=y[x];if(b){const C=b.start+S;C!==this.scrollOffset&&(p=C-this.scrollOffset,this.scrollOffset=C,f=!0)}}}(f||u)&&(this.pendingScrollAnchor=[f?a[0]:null,f?a[1]:0,u,p])},this.notify=t=>{var s,o;(o=(s=this.options).onChange)==null||o.call(s,this,t)},this.maybeNotify=_e(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),t=>{this.notify(t)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(t=>t()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var t;const s=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==s){if(this.cleanup(),!s){this.maybeNotify();return}if(this.scrollElement=s,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((t=this.scrollElement)==null?void 0:t.window)??null,this.elementsCache.forEach(i=>{this.observer.observe(i)}),this.unsubs.push(this.options.observeElementRect(this,i=>{this.scrollRect=i,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(i,l)=>{if(l&&this._intendedScrollOffset===null&&i===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(i-this._intendedScrollOffset)<1.5&&(i=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;const a=this.getScrollOffset();this.scrollDirection=l?a===i?this.scrollDirection:a<i?"forward":"backward":null,this.scrollOffset=i,this.isScrolling=l,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const i=this.scrollElement,l=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},a=()=>{this._iosTouching=!1,!(!Ot()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};i.addEventListener("touchstart",l,gt),i.addEventListener("touchend",a,gt),this.unsubs.push(()=>{i.removeEventListener("touchstart",l),i.removeEventListener("touchend",a),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const o=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,o&&this.scrollElement&&this.options.enabled){const[i,l,a,u]=o;i!==null&&!a&&(Ot()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?u!==0&&(this._iosDeferredAdjustment+=u):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),a&&this.scrollToEnd({behavior:a})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const t=this.getScrollOffset(),s=this.getMaxScrollOffset();if(t<0||t>s)return;const o=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(t,{adjustments:this.scrollAdjustments+=o,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=_e(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(t,s,o,i,l,a,u,d)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:t,paddingStart:s,scrollMargin:o,getItemKey:i,enabled:l,lanes:a,laneAssignmentMode:u,gap:d}),{key:!1}),this.getMeasurements=_e(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:t,paddingStart:s,scrollMargin:o,getItemKey:i,enabled:l,lanes:a,laneAssignmentMode:u,gap:d},f)=>{const p=this.itemSizeCache;if(!l)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>t)for(const x of this.laneAssignments.keys())x>=t&&this.laneAssignments.delete(x);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(x=>{this.itemSizeCache.set(x.key,x.size)}));const m=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===t&&(this.lanesSettling=!1),a===1){const x=t*2;let b=this._flatMeasurements;if(!b||b.length<x){const j=new Float64Array(x);b&&m>0&&j.set(b.subarray(0,m*2)),b=j,this._flatMeasurements=b}let C;if(m===0)C=s+o;else{const j=m-1;C=b[j*2]+b[j*2+1]+d}for(let j=m;j<t;j++){const E=i(j),A=p.get(E),D=typeof A=="number"?A:this.options.estimateSize(j);b[j*2]=C,b[j*2+1]=D,C+=D+d}const I=Qo(t,b,i);return this.measurementsCache=I,I}const S=this.measurementsCache.slice(0,m),y=new Array(a).fill(void 0),k=new Float64Array(a);let M=0;for(let x=0;x<m;x++){const b=S[x];b&&(y[b.lane]===void 0&&M++,y[b.lane]=x,k[b.lane]=b.end)}for(let x=m;x<t;x++){const b=i(x),C=this.laneAssignments.get(x);let I,j;const E=u==="estimate"||p.has(b);if(C!==void 0&&this.options.lanes>1){I=C;const W=y[I],K=W!==void 0?S[W]:void 0;j=K?K.end+d:s+o}else if(M===a){let W=0,K=k[0],L=y[0];for(let V=1;V<a;V++){const oe=k[V];(oe<K||oe===K&&y[V]<L)&&(W=V,K=oe,L=y[V])}I=W,j=K+d,E&&this.laneAssignments.set(x,I)}else I=x%this.options.lanes,j=s+o,E&&this.laneAssignments.set(x,I);const A=p.get(b),D=typeof A=="number"?A:this.options.estimateSize(x),O=j+D;S[x]={index:x,start:j,size:D,end:O,key:b,lane:I},y[I]===void 0&&M++,y[I]=x,k[I]=O}return this.measurementsCache=S,S},{key:!1,debug:()=>this.options.debug}),this.calculateRange=_e(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,s,o,i)=>t.length===0||s===0?(this.range=null,null):(this.range=li(t,s,o,i,i===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=_e(()=>{let t=null,s=null;const o=this.calculateRange();return o&&(t=o.startIndex,s=o.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,s]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,s]},(t,s,o,i,l)=>i===null||l===null?[]:t({startIndex:i,endIndex:l,overscan:s,count:o}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=t=>{const s=this.options.indexAttribute,o=t.getAttribute(s);return o?parseInt(o,10):(console.warn(`Missing attribute name '${s}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=t=>{var s;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const o=this.scrollState.index??((s=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:s.index);if(o!==void 0&&this.range){const i=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),l=Math.max(0,o-i),a=Math.min(this.options.count-1,o+i);return t>=l&&t<=a}return!0},this.measureElement=t=>{if(!t){this.elementsCache.forEach((l,a)=>{l.isConnected||(this.observer.unobserve(l),this.elementsCache.delete(a))});return}const s=this.indexFromElement(t),o=this.options.getItemKey(s),i=this.elementsCache.get(o);i!==t&&(i&&this.observer.unobserve(i),this.observer.observe(t),this.elementsCache.set(o,t)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(s)&&this.resizeItem(s,this.options.measureElement(t,void 0,this))},this.resizeItem=(t,s)=>{var o,i;if(t<0||t>=this.options.count)return;let l,a,u;const d=this._flatMeasurements;if(this.options.lanes===1&&d!==null)u=this.options.getItemKey(t),a=d[t*2],l=d[t*2+1];else{const m=this.measurementsCache[t];if(!m)return;u=m.key,a=m.start,l=m.size}const f=this.itemSizeCache.get(u)??l,p=s-f;if(p!==0){const m=this.options.anchorTo==="end"&&((o=this.scrollState)==null?void 0:o.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,S=m?this.getTotalSize():0,y=((i=this.scrollState)==null?void 0:i.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[t]??{index:t,key:u,start:a,size:l,end:a+l,lane:0},p,this):a<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(u)||this.scrollDirection!=="backward"));(this.pendingMin===null||t<this.pendingMin)&&(this.pendingMin=t),this.itemSizeCache.set(u,s),this.itemSizeCacheVersion++,m?this.applyScrollAdjustment(this.getTotalSize()-S):y&&this.applyScrollAdjustment(p),this.notify(!1)}},this.getVirtualItems=_e(()=>[this.getVirtualIndexes(),this.getMeasurements()],(t,s)=>{const o=[];for(let i=0,l=t.length;i<l;i++){const a=t[i],u=s[a];o.push(u)}return o},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=t=>{const s=this.getMeasurements();if(s.length===0)return;const o=this._flatMeasurements,i=this.options.lanes===1&&o!=null,l=xs(0,s.length-1,i?a=>o[a*2]:a=>Ht(s[a]).start,t);return Ht(s[l])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const t=this.scrollElement.document.documentElement;return this.options.horizontal?t.scrollWidth-this.scrollElement.innerWidth:t.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(t=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=t,this.getOffsetForAlignment=(t,s,o=0)=>{if(!this.scrollElement)return 0;const i=this.getSize(),l=this.getScrollOffset();s==="auto"&&(s=t>=l+i?"end":"start"),s==="center"?t+=(o-i)/2:s==="end"&&(t-=i);const a=this.getMaxScrollOffset();return Math.max(Math.min(a,t),0)},this.getOffsetForIndex=(t,s="auto")=>{t=Math.max(0,Math.min(t,this.options.count-1));const o=this.getSize(),i=this.getScrollOffset(),l=this.measurementsCache[t];if(!l)return;if(s==="auto")if(l.end>=i+o-this.options.scrollPaddingEnd)s="end";else if(l.start<=i+this.options.scrollPaddingStart)s="start";else return[i,s];if(s==="end"&&t===this.options.count-1)return[this.getMaxScrollOffset(),s];const a=s==="end"?l.end+this.options.scrollPaddingEnd:l.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,s,l.size),s]},this.scrollToOffset=(t,{align:s="start",behavior:o="auto"}={})=>{const i=this.getOffsetForAlignment(t,s),l=this.now();this.scrollState={index:null,align:s,behavior:o,startedAt:l,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollToIndex=(t,{align:s="auto",behavior:o="auto"}={})=>{t=Math.max(0,Math.min(t,this.options.count-1));const i=this.getOffsetForIndex(t,s);if(!i)return;const[l,a]=i,u=this.now();this.scrollState={index:t,align:a,behavior:o,startedAt:u,lastTargetOffset:l,stableFrames:0},this._scrollToOffset(l,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollBy=(t,{behavior:s="auto"}={})=>{const o=this.getScrollOffset()+t,i=this.now();this.scrollState={index:null,align:"start",behavior:s,startedAt:i,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:s}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:t="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:t});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:t})},this.getTotalSize=()=>{var t;const s=this.getMeasurements();let o;if(s.length===0)o=this.options.paddingStart;else if(this.options.lanes===1){const i=s.length-1,l=this._flatMeasurements;l!=null?o=l[i*2]+l[i*2+1]:o=((t=s[i])==null?void 0:t.end)??0}else{const i=Array(this.options.lanes).fill(null);let l=s.length-1;for(;l>=0&&i.some(a=>a===null);){const a=s[l];i[a.lane]===null&&(i[a.lane]=a.end),l--}o=Math.max(...i.filter(a=>a!==null))}return Math.max(o-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const t=[];if(this.itemSizeCache.size===0)return t;const s=this.getMeasurements();for(const o of s)o&&this.itemSizeCache.has(o.key)&&t.push({index:o.index,key:o.key,start:o.start,size:o.size,end:o.end,lane:o.lane});return t},this._scrollToOffset=(t,{adjustments:s,behavior:o})=>{this._intendedScrollOffset=t+(s??0),this.options.scrollToFn(t,{behavior:o,adjustments:s},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(n)}applyScrollAdjustment(n,t){n!==0&&(Ot()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=n:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=n,behavior:t}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollAdjustments=0)))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const s=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,o=s?s[0]:this.scrollState.lastTargetOffset,i=1,l=o!==this.scrollState.lastTargetOffset;if(!l&&Jo(o,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=i){this.getScrollOffset()!==o&&this._scrollToOffset(o,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,l){const a=this.getSize()||600,u=Math.abs(o-this.getScrollOffset()),d=this.scrollState.behavior==="smooth"&&u>a;this.scrollState.lastTargetOffset=o,d||(this.scrollState.behavior="auto"),this._scrollToOffset(o,{adjustments:void 0,behavior:d?"smooth":"auto"})}this.scheduleScrollReconcile()}}const xs=(e,n,t,s)=>{for(;e<=n;){const o=(e+n)/2|0,i=t(o);if(i<s)e=o+1;else if(i>s)n=o-1;else return o}return e>0?e-1:0};function ai(e,n,t){let s=0;for(;s<=n;){const o=(s+n)/2|0,i=e[o*2];if(i<t)s=o+1;else if(i>t)n=o-1;else return o}return s>0?s-1:0}function li(e,n,t,s,o){const i=e.length-1;if(e.length<=s)return{startIndex:0,endIndex:i};if(s===1&&o!==null){const d=ai(o,i,t);let f=d;const p=t+n;for(;f<i&&o[f*2]+o[f*2+1]<p;)f++;return{startIndex:d,endIndex:f}}let a=xs(0,i,d=>e[d].start,t),u=a;if(s===1)for(;u<i&&e[u].end<t+n;)u++;else if(s>1){const d=Array(s).fill(0);for(;u<i&&d.some(p=>p<t+n);){const p=e[u];d[p.lane]=p.end,u++}const f=Array(s).fill(t+n);for(;a>=0&&f.some(p=>p>=t);){const p=e[a];f[p.lane]=p.start,a--}a=Math.max(0,a-a%s),u=Math.min(i,u+(s-1-u%s))}return{startIndex:a,endIndex:u}}const At=typeof document<"u"?c.useLayoutEffect:c.useEffect;function ci({useFlushSync:e=!0,directDomUpdates:n=!1,directDomUpdatesMode:t="transform",...s}){const o=c.useReducer(d=>d+1,0)[1],i=c.useRef({enabled:n,mode:t,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});i.current.enabled=n,i.current.mode=t;const l=d=>{const f=i.current;if(!f.enabled||!f.container)return;const p=d.getTotalSize();if(p!==f.lastSize){f.lastSize=p;const x=d.options.horizontal?"width":"height";f.container.style[x]=`${p}px`}const m=!!d.options.horizontal,S=f.mode==="transform",y=m?"left":"top",k=d.options.scrollMargin,M=d.getVirtualItems();for(const x of M){const b=x.start-k,C=d.elementsCache.get(x.key);C&&f.lastPositions.get(C)!==b&&(f.lastPositions.set(C,b),S?C.style.transform=m?`translate3d(${b}px, 0, 0)`:`translate3d(0, ${b}px, 0)`:C.style[y]=`${b}px`)}},a={...s,onChange:(d,f)=>{var p;const m=i.current;let S=!0;if(m.enabled){l(d);const y=d.range,k=m.prevRange;S=!k||k.isScrolling!==d.isScrolling||k.startIndex!==y?.startIndex||k.endIndex!==y?.endIndex,S&&(m.prevRange=y?{startIndex:y.startIndex,endIndex:y.endIndex,isScrolling:d.isScrolling}:null)}S&&(e&&f?Ls.flushSync(o):o()),(p=s.onChange)==null||p.call(s,d,f)}},[u]=c.useState(()=>{const d=new ri(a);return Object.assign(d,{containerRef:f=>{const p=i.current;if(p.container=f,p.lastSize=null,f&&p.enabled){const m=d.getTotalSize();p.lastSize=m;const S=d.options.horizontal?"width":"height";f.style[S]=`${m}px`}}})});return u.setOptions(a),At(()=>u._didMount(),[]),At(()=>u._willUpdate()),At(()=>{l(u)}),u}function di(e){return ci({observeElementRect:Zo,observeElementOffset:si,scrollToFn:ii,...e})}const Bt=e=>e.query?`matching "${e.query}"`:e.from?`from "${e.from}"`:"matching your search",ui=e=>`Select all ${Bt(e)}`,hi=(e,n)=>`All ${so(n)} ${Bt(e)} selected`,fi=({verb:e,confirmingDelete:n,hasSelection:t,junkMailboxId:s,currentMailboxId:o,deletableMessageId:i})=>{if(n)return{kind:"withheld"};if(e==="junk"){const l=ln(s,o);if(l!==void 0)return{kind:"unavailable",reason:l}}return t?{kind:"openWizard"}:e!=="delete"||i===void 0?{kind:"declined"}:{kind:"confirmDelete",messageId:i}},mi=(e,n,t)=>e==="BACK"&&n&&t===void 0,gi=(e,n)=>({id:e.messageId,accountId:e.accountId,mailboxId:e.mailboxId,threadId:e.threadId,fromName:e.fromName??e.fromEmail??"Unknown",fromEmail:e.fromEmail??"",subject:e.subject??"(No subject)",snippet:e.snippet??"",timeLabel:nt(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:is(e.category),messageCount:n,suspicious:e.authenticity?.dkimMismatch===!0,labels:e.labels}),pi=({thread:e,mailboxId:n,isSelected:t,isFocused:s,isTabStop:o,onFocusRow:i,isChecked:l,onToggleCheck:a,onRowSelect:u,messageCount:d,isMultiSelectMode:f,onLongPress:p,isDesktop:m,density:S})=>r.jsx(cn,{thread:gi(e,d),link:{mailboxId:n,threadId:e.threadId},inListbox:!0,active:t,focused:s,isTabStop:o,density:S,isDesktop:m,onFocusRow:i,selection:{isChecked:l,onToggleCheck:a,onRowSelect:u,isMultiSelectMode:f,onLongPress:p}}),xi=c.memo(pi),bi=e=>{const n=e.authenticity?.dkimMismatch===!0;return{id:e.messageId,accountId:e.accountId,fromName:e.fromName??e.fromEmail??"Unknown",fromEmail:e.fromEmail??"",subject:e.subject??"(No subject)",snippet:e.snippet??"",timeLabel:nt(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:is(e.category),suspicious:n}},vi=({thread:e,mailboxId:n,isSelected:t,isFocused:s,isTabStop:o,onFocusRow:i,isChecked:l,onToggleCheck:a,onRowSelect:u,isMultiSelectMode:d,onLongPress:f,isDesktop:p,onDelete:m,onToggleRead:S,density:y})=>{const[k,M]=c.useState("none"),x=st(),b=c.useCallback(A=>{navigator.vibrate?.(10),A==="trailing"?m(e.messageId):S(e.messageId,e.isRead),M("none")},[m,S,e.messageId,e.isRead]),C=c.useCallback(()=>{f(e.messageId)},[f,e.messageId]),I=c.useCallback(()=>{a(e.messageId)},[a,e.messageId]),j=c.useCallback(()=>{x({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:n,threadId:e.threadId,messageId:e.messageId},search:A=>A,hash:Pe})},[x,n,e.threadId,e.messageId]),E=dn(e.messageId,u);return p||d?r.jsx(xi,{thread:e,mailboxId:n,isSelected:t,isFocused:s,isTabStop:o,onFocusRow:i,isChecked:l,onToggleCheck:a,onRowSelect:u,isMultiSelectMode:d,onLongPress:f,isDesktop:p,density:y}):r.jsx("div",{role:"presentation",onPointerDownCapture:E.onMouseDown,onClickCapture:E.claimClick,onContextMenu:E.onContextMenu,children:r.jsx(Gn,{thread:bi(e),selectionMode:!1,checked:!1,active:t,peek:k,onPeek:M,onToggleCheck:I,onLongPress:C,onOpen:j,onAct:b})})},Si=72,yi=32,Ci=5,bs="remit:list-density",Ii=()=>{try{const e=localStorage.getItem(bs);if(e==="compact"||e==="comfortable")return e}catch{}return"comfortable"},wi=({query:e})=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-line bg-surface-sunken/30",children:[r.jsx(Vs,{className:"size-4 text-fg-muted"}),r.jsxs("span",{className:"text-sm text-fg-muted",children:["Results for “",e,"”"]})]}),ji=({mailboxId:e,threads:n,selectedMessageId:t,isLoading:s,isError:o=!1,error:i,onRetry:l,searchQuery:a,searchPredicate:u,onDeleteMessages:d,isDeleting:f=!1,isMoving:p=!1,onLoadMore:m,hasMore:S=!1,isLoadingMore:y=!1,accountId:k,listTitle:M,listMeta:x,listFilter:b,listScopeLabel:C,onTriageContextChange:I,commandsRef:j,hideHeader:E=!1})=>{const A=c.useRef(null),D=st(),O=fs(),W=Ps(),{verb:K,start:L,startFromSearch:V}=W,oe=$s(),Ie=!!a?.trim(),q=un(),{labels:$e}=io(k),{pushError:ae}=Zt(),[T,H]=c.useState(t),[we,P]=c.useState(),U=c.useCallback(h=>{P(v=>v===h?v:void 0),H(h)},[]),[ge,je]=c.useState(Ii),ke=c.useCallback(()=>{je(h=>{const v=h==="comfortable"?"compact":"comfortable";try{localStorage.setItem(bs,v)}catch{}return v})},[]),{toggleReadFor:Re}=rs({mailboxId:e}),{junkMailboxId:pe}=as(k),Be=ls(pe,e),{selectedIds:R,selectedCount:N,hasSelection:ie,isSelected:xe,toggle:G,select:re,clearSelection:X,selectRange:ue,setAnchor:be,selectAll:ot,toggleAll:it,intersectWith:le}=hn(),We=wn(N,O),[Y,ve]=c.useState(null),z=Ie&&!!u,rt=`${e}|${JSON.stringify(u??{})}`,w=fn({mailboxId:e,accountId:k,enabled:z,predicateKey:rt,searchQuery:u??{}}),at=c.useCallback((h,v,ee)=>{if(ee.error===void 0){if(ee.cancelled){ae({severity:"warning",title:gn(ee.done),detail:mn(h,ee.done,v)});return}ae({severity:"info",title:Wt(h,ee.done)})}},[ae]),lt=w.phase.kind,he=w.clear,Q=c.useCallback(()=>{lt==="escalated"&&he(),X()},[X,he,lt]),[Ee,ct]=c.useState(null),fe=c.useRef(null),F=c.useRef(!1),Oe=c.useRef(null),Ae=!s&&n.length>0,dt=Y!==null,Z=di({count:n.length,getScrollElement:()=>A.current,estimateSize:()=>ge==="compact"?yi:Si,overscan:Ci}),Ke=t?n.findIndex(h=>h.messageId===t):-1,$=T?n.findIndex(h=>h.messageId===T):-1,ce=c.useCallback(h=>{if(h<0||h>=n.length)return;const v=n[h];if(We){G(v.messageId);return}fe.current=v.messageId,F.current=!1,P(v.messageId),H(v.messageId)},[n,We,G]),Ve=c.useCallback(()=>{if(n.length===0)return;const h=$<0?0:Math.min($+1,n.length-1);ce(h)},[n.length,$,ce]),qe=c.useCallback(()=>{if(n.length===0)return;const h=$<=0?0:$-1;ce(h)},[n.length,$,ce]),ut=c.useCallback(()=>ce(0),[ce]),He=c.useCallback(()=>ce(n.length-1),[ce,n.length]),Ne=c.useCallback(()=>{T&&G(T)},[T,G]),B=c.useMemo(()=>n.map(h=>h.messageId),[n]),Me=c.useMemo(()=>{const h=[];for(const v of n)R.has(v.messageId)&&h.push({id:v.messageId,sender:v.fromName??v.fromEmail??"Unknown",email:v.fromEmail??"",subject:v.subject??"(No subject)",date:nt(v.sentDate)});return h},[n,R]),ht=c.useCallback((h,v)=>v.shiftKey?(ue(B,h,T),!0):v.metaKey||v.ctrlKey?(G(h),!0):(Q(),be(h),!1),[B,T,ue,G,Q,be]),ze=c.useCallback(h=>{!d||h.length===0||(Oe.current=T??null,ve(h))},[d,T]),De=c.useCallback(h=>{const v=pn(B,T,h);v!==void 0&&(ue(B,v),fe.current=v,F.current=!1,P(void 0),H(v))},[B,T,ue]),Ue=c.useCallback(()=>De(-1),[De]),Qe=c.useCallback(()=>De(1),[De]),Se=c.useCallback(()=>{B.length>0&&ot(B)},[B,ot]),Te=c.useCallback(h=>{const v=fi({verb:h,confirmingDelete:Y!==null,hasSelection:ie,junkMailboxId:pe,currentMailboxId:e,deletableMessageId:d?T:void 0});return v.kind==="openWizard"?(L(h),!0):v.kind==="confirmDelete"?(ze([v.messageId]),!0):v.kind==="unavailable"?(ae({severity:"warning",title:v.reason}),!0):v.kind==="withheld"},[Y,d,ie,pe,e,L,T,ze,ae]),ne=c.useCallback((h,v)=>{const ee=n.find(te=>te.messageId===h)?.threadId;ee&&D({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:e,threadId:ee,messageId:h},search:te=>te,hash:Pe,replace:v?.replace})},[D,e,n]),me=c.useCallback(()=>{T&&ne(T)},[T,ne]),vt=c.useCallback(h=>ne(h,{replace:!0}),[ne]);xn({keyboardFocusedMessageId:we,openMessageId:t,enabled:O&&N===0,open:vt});const Je=w.phase.kind==="escalated"?{scope:Bt(u??{}),total:w.phase.total,searchQuery:u??{},run:h=>w.runAction(h),stop:w.stop}:void 0,St=c.useCallback(()=>{if(!Y)return;const h=Y;if(h.length===0){ve(null);return}const v=new Set(h),ee=n.findIndex(se=>v.has(se.messageId));let te;for(let se=ee+1;se<n.length;se++)if(!v.has(n[se].messageId)){te=n[se].messageId;break}if(te===void 0){for(let se=ee-1;se>=0;se--)if(!v.has(n[se].messageId)){te=n[se].messageId;break}}d?.(h),Q(),Oe.current=null,ve(null),te!==void 0&&(fe.current=te,F.current=!1,U(te),O&&ne(te,{replace:!0})),O||ct(Wt("delete",h.length))},[Y,n,d,Q,ne,O,U]),ye=c.useCallback(()=>{const h=Oe.current;Oe.current=null,ve(null),h!==null&&(fe.current=h,F.current=!1,U(h))},[U]),Ge=c.useMemo(()=>{if(N===0)return;const h=new Set;for(const v of n)R.has(v.messageId)&&h.add(v.accountConfigId);if(h.size>1)return"Move only works within one account — clear selection or pick messages from a single account"},[N,R,n]),yt=c.useCallback(()=>{if(Je){V();return}L("organize")},[Je,V,L]),Ct=c.useCallback(h=>{d?.([h])},[d]),It=c.useCallback((h,v)=>{Re([h],!v)},[Re]),wt=c.useCallback(h=>{O||re(h)},[O,re]),jt=c.useCallback(()=>{if(w.isRunning||w.phase.kind==="counting"){w.stop();return}Q()},[w,Q]),kt=c.useCallback(()=>{w.clear()},[w]);c.useEffect(()=>{if(F.current||!O&&t)return;const h=$>=0?$:Ke;h>=0&&Z.scrollToIndex(h,{align:"auto"})},[$,Ke,Z,O,t]),c.useEffect(()=>{t&&(F.current=!1,U(t))},[t,U]),c.useEffect(()=>{T&&(n.some(h=>h.messageId===T)||U(n[0]?.messageId))},[n,T,U]),c.useEffect(()=>{I?.({focusedMessageId:T,selectedIds:Array.from(R),hasList:Ae,blocksKeyboard:dt||W.isOpen})},[T,R,Ae,dt,W.isOpen,I]);const Ce=c.useRef(I);Ce.current=I,c.useEffect(()=>()=>Ce.current?.({focusedMessageId:void 0,selectedIds:[],hasList:!1,blocksKeyboard:!1}),[]),c.useEffect(()=>{w.phase.kind!=="idle"||w.isRunning||le(n.map(h=>h.messageId))},[n,le,w.phase,w.isRunning]);const Ye=c.useRef(e);c.useEffect(()=>{Ye.current!==e&&(Ye.current=e,Q())},[e,Q]),bn({shouldBlockFn:({action:h})=>mi(h,ie,oe)?(Q(),!0):!1,enableBeforeUnload:!1,disabled:!ie||oe!==void 0}),c.useEffect(()=>{const h=A.current;if(!h||!S||!m)return;const v=()=>{if(y)return;const{scrollTop:ee,scrollHeight:te,clientHeight:se}=h;ee+se>=te-200&&m()};return h.addEventListener("scroll",v,{passive:!0}),v(),()=>h.removeEventListener("scroll",v)},[S,y,m]),c.useEffect(()=>{const h=fe.current;if(!h)return;const v=A.current?.querySelector(`[data-message-id="${h}"]`);v&&(fe.current=null,v.focus({preventScroll:!0}))}),c.useEffect(()=>{if(j){if(!Ae){j.current=null;return}return j.current={focusNext:Ve,focusPrevious:qe,focusFirst:ut,focusLast:He,openFocused:me,toggleSelect:Ne,extendSelectDown:Qe,extendSelectUp:Ue,selectAll:Se,clearSelection:()=>ie?(Q(),!0):!1,requestVerb:Te,toggleDensity:ke},()=>{j.current=null}}},[j,Ae,Ve,qe,ut,He,me,Ne,Qe,Ue,Se,ie,Q,Te,ke]);const Xe=s?"loading":o?"error":n.length===0?"empty":"ready",Mt=o?to(i):void 0,Tt=c.useCallback(()=>{const h=Bs(Ws());window.open(h,"_blank","noopener,noreferrer")},[]),Rt=[{id:"inbox",threads:[]}],Ze=B.length>0&&B.every(h=>R.has(h)),ft=z&&S&&Ze&&!f&&!p&&w.phase.kind==="idle"&&!w.isRunning,Et=f||p||w.isRunning,g=w.phase.kind==="escalated"?w.phase.total:N,_=w.runningAction?vn(w.runningAction.kind,w.progress?.done??0,w.progress?.total??g):w.phase.kind==="counting"?"Counting matches…":w.phase.kind==="escalated"?hi(u??{},w.phase.total):void 0,J=w.phase.kind!=="escalated"&&B.length>0?{checked:Ze,indeterminate:N>0&&!Ze,onChange:()=>it(B)}:void 0,Cs=w.runningAction?{value:w.progress?.done??0,max:w.progress?.total??g,tone:Sn(w.runningAction.kind)}:void 0,Is=(w.phase.kind==="counting"?{tone:"info",text:"",action:{label:"Stop",onClick:w.stop}}:w.phase.kind==="escalated"&&!w.isRunning?{tone:"info",text:"",action:{label:"Clear selection",onClick:kt}}:ft?{tone:"info",text:"",action:{label:ui(u??{}),onClick:w.escalate}}:void 0)??(Ge?{tone:"warning",text:Ge}:void 0),ws=r.jsx(yn,{title:q.title||M,navSlot:q.navSlot,titleMeta:q.titleMeta,searchSlot:q.searchSlot,searchField:q.searchField,idleSlot:q.makeFilterSlot,count:g,onCancel:jt,onDelete:()=>L("delete"),onMove:()=>L("move"),onOrganize:yt,onJunk:Be?()=>L("junk"):void 0,onMarkRead:()=>L("markRead"),overflowSlot:k&&e&&N>0&&$e.length>0?r.jsx(ro,{accountId:k,mailboxId:e,messageIds:Array.from(R)}):void 0,isBusy:Et,isCounting:w.phase.kind==="counting",selectAll:J,statusLabel:_,progress:Cs,notice:Is}),js=Cn(B,T),ks=c.useCallback(h=>{F.current=!0,U(h)},[U]),Ms=r.jsxs(r.Fragment,{children:[Ie&&a&&r.jsx(wi,{query:a}),r.jsxs("div",{ref:A,role:"listbox","aria-multiselectable":!0,"aria-label":M,className:"flex-1 overflow-y-auto",children:[r.jsx("div",{role:"presentation",className:"relative w-full",style:{height:`${Z.getTotalSize()}px`},children:Z.getVirtualItems().map(h=>{const v=n[h.index];return r.jsx("div",{role:"presentation","data-index":h.index,ref:Z.measureElement,className:Ks("absolute left-0 top-0 w-full border-b border-line",w.isRunning&&"pointer-events-none opacity-50"),style:{transform:`translateY(${h.start}px)`},children:r.jsx(vi,{thread:v,mailboxId:e,isSelected:t===v.messageId,isFocused:T===v.messageId,isTabStop:js===v.messageId,onFocusRow:ks,isChecked:xe(v.messageId),onToggleCheck:G,onRowSelect:ht,isMultiSelectMode:We,onLongPress:wt,isDesktop:O,onDelete:Ct,onToggleRead:It,density:ge})},h.key)})}),y&&r.jsx(Yn,{})]})]});return r.jsxs(r.Fragment,{children:[Ee&&!O&&r.jsx(zt,{tone:"success",variant:"soft",className:"m-2 rounded-md",onDismiss:()=>ct(null),children:Ee}),r.jsx(Xn,{listTitle:M,listMeta:x,sections:Rt,flatList:!0,listState:q.searchResults?"ready":Xe,searchQuery:Ie?a:void 0,listFilter:b,listScopeLabel:C,errorMessage:Mt,onRetry:l,onReportError:Tt,density:ge,selectedThreadId:t,onSelectThread:h=>ne(h),isDesktop:O,hideHeader:E,selectionBar:ws,listBody:q.searchResults??(Xe==="ready"?Ms:void 0)}),r.jsx(ms,{isOpen:Y!==null,title:no(Y?.length??0),description:"You can restore them from Trash later.",confirmLabel:"Move to Trash",destructive:!0,isBusy:f,onConfirm:St,onCancel:ye}),r.jsx(In,{verb:K,accountId:k,mailboxId:e,selection:Me,selectionRestriction:Ge?"spansAccounts":void 0,escalated:Je,escalatedProgress:w.progress,onFinished:Q,onRunEnded:at})]})},ki=e=>Hs({path:{accountId:e}}),Mi=e=>{const n=Dt(),t=_t(),s=Ft({...qs(),onSuccess:()=>{t.recordEvent("sync.triggered"),n.invalidateQueries({queryKey:ki(e)})}});return{trigger:()=>{s.mutate({path:{accountId:e}})},triggerAsync:()=>s.mutateAsync({path:{accountId:e}}),isPending:s.isPending,error:s.error,reset:s.reset}},Ti=({accountId:e,children:n})=>{const{triggerAsync:t,isPending:s}=Mi(e);return r.jsx(Io,{onRefresh:t,isRefreshing:s,children:n})};function Ri({accountId:e,currentMailboxId:n,candidates:t,onMove:s,children:o}){const[i,l]=c.useState(!1),a=_t(),u=mo(),{inboxMailboxId:d}=jn(e),f=kn(e),{data:p}=tt({...Us({path:{accountId:e}}),staleTime:1/0}),m=c.useMemo(()=>go({mailboxes:p?.items??[],folderAppointments:f,currentMailboxId:n,translator:u}),[p?.items,f,n,u]),S=c.useMemo(()=>d||(m.find(b=>b.label.toLowerCase()==="inbox")?.id??m.find(b=>!b.isCurrent)?.id??""),[d,m]),y=c.useRef(!1);c.useEffect(()=>{y.current||(y.current=!0,Mn(a,t.length))},[a,t.length]);const k=c.useCallback(()=>{Tn(a,t.length),l(!0)},[a,t.length]),M=c.useCallback((x,b)=>{Rn(a,{selected:x.length,total:t.length,toInbox:b===d}),s(x,b)},[a,t.length,d,s]);return r.jsxs("div",{className:"relative flex h-full min-h-0 flex-col",children:[r.jsx("div",{className:"shrink-0 px-row-inset pt-2",children:r.jsx(jo,{count:t.length,onReview:k})}),r.jsx("div",{className:"min-h-0 flex-1",children:o}),r.jsx(Fo,{open:i,candidates:t,defaultDestinationId:S,availableFolders:m,delimiter:po(p?.items??[]),onConfirmMove:M,onCancel:()=>l(!1)})]})}const Ei="We can verify this sender";function Oi(e){const{data:n}=tt({...Qs({path:{mailboxId:e??""},query:{senderTrust:["vip","wellknown"],dkimMismatch:!1,results:!0,limit:500}}),enabled:!!e,staleTime:6e4});return{candidates:(n?.items??[]).map(s=>({id:s.messageId,senderName:s.fromName||s.fromEmail||"Unknown sender",senderAddress:s.fromEmail??"",subject:s.subject||"(no subject)",snippet:s.snippet??"",trustReason:Ei,trustSubReason:En(s.senderTrust),senderTrust:s.senderTrust}))}}const Ai=e=>{const n=new Set,t=[];for(const s of e)n.has(s.threadMessageId)||(n.add(s.threadMessageId),t.push(s));return t},Ni={unread:"unread",flagged:"starred",attachment:"attachments"},zi=new Set(Object.values(yo)),vs=e=>zi.has(e),Di=e=>vs(e.category)||e.attributes.size>0,Fi=e=>{const n={};vs(e.category)&&(n.category=[e.category]);for(const t of e.attributes){const s=Ni[t];s&&(n[s]=!0)}return n},_i=e=>(e.senderTrust?.length??0)>0||e.dkimMismatch!==void 0?"loaded-pages":"whole-folder",Li=["category","unread","starred","attachments"],Qt=e=>JSON.stringify(Li.map(n=>e?.[n]??null)),Pi=e=>{if(!Array.isArray(e))return;const[n]=e;if(typeof n!="object"||n===null)return;const t=n.query;if(!(typeof t!="object"||t===null))return t},$i=(e,n)=>{const t=Pi(e);return t?Qt(t)===Qt(n):!1},mt=e=>e[0],Bi=e=>{const n=mt(e.filter(a=>a.type==="from").map(a=>a.value)),t=mt(e.filter(a=>a.type==="subject").map(a=>a.value)),s=mt(e.filter(a=>a.type==="category").map(a=>a.category)),o=mt(e.filter(a=>a.type==="isUnread"||a.type==="isRead").map(a=>a.type==="isUnread")),i=e.some(a=>a.type==="isStarred")?!0:void 0,l=e.some(a=>a.type==="hasAttachment")?!0:void 0;return{...n!==void 0?{from:n}:{},...t!==void 0?{subject:t}:{},...s!==void 0?{category:[s]}:{},...o!==void 0?{unread:o}:{},...i!==void 0?{starred:i}:{},...l!==void 0?{attachments:l}:{}}},Wi=(e,n)=>{switch(n.type){case"from":return e.from?.toLowerCase()===n.value.toLowerCase();case"subject":return e.subject?.toLowerCase()===n.value.toLowerCase();case"category":return e.category?.length===1&&e.category[0]===n.category;case"isUnread":return e.unread===!0;case"isRead":return e.unread===!1;case"isStarred":return e.starred===!0;case"hasAttachment":return e.attachments===!0;case"before":case"after":case"in":case"account":return!1}};function Ki(e,n={}){const t=Bi(e),s={...t,...n};return{params:t,residual:e.filter(o=>!Wi(s,o))}}function Vi(e,n,t){if(n.length===0)return e;const s=[...n];return e.filter(o=>{const i=On(o);return An({...i,accountId:i.accountId??t},s)})}const qi=50,Hi=new Map(us().categories.filter(e=>e.id!=="all").map(e=>[e.id,e.label])),Ss=c.createContext(null);function bt(){const e=c.useContext(Ss);if(!e)throw new Error("MailboxPane.* must be used inside <MailboxPane>");return e}function Ui({mailboxId:e,thread:n,children:t}){const s=st(),o=n?.threadId,i=n?.messageId,l=_t(),{accounts:a,searchQuery:u,intelligenceOpen:d,onToggleIntelligence:f}=es(),p=tn(),m=Co(u),S=m.length>0,{freeText:y,tokens:k}=sn(m,p),[M,x]=c.useState("all"),[b,C]=c.useState(new Set),I=c.useMemo(()=>({category:M,attributes:b}),[M,b]),j=c.useMemo(()=>Fi(I),[I]),E=S||Di(I),{params:A,residual:D}=Ki(k,j),O={order:"desc",limit:qi,...y?{query:y}:{},...A,...j},W={category:O.category,unread:O.unread,starred:O.starred,attachments:O.attachments},K=E?Js({path:{mailboxId:e},query:O}):Gs({path:{mailboxId:e},query:{order:"desc"}}),{data:L,isLoading:V,isError:oe,error:Ie,refetch:q,fetchNextPage:$e,hasNextPage:ae,isFetchingNextPage:T}=Zn({queryKey:K,queryFn:async({pageParam:g})=>{if(E){const{data:J}=await Zs({path:{mailboxId:e},query:{...O,continuationToken:g},throwOnError:!0});return J}const{data:_}=await en({path:{mailboxId:e},query:{order:"desc",continuationToken:g},throwOnError:!0});return _},initialPageParam:void 0,getNextPageParam:g=>g.continuationToken,placeholderData:(g,_)=>$i(_?.queryKey,W)?g:void 0}),{accountId:H}=Nn(e),we=xo({accounts:a}),P=Vi(zn(Ai(L?.pages.flatMap(g=>g.items??[])??[])),D,H),U=c.useCallback(g=>{x(g)},[]),ge=c.useCallback(g=>{C(_=>{const J=new Set(_);return J.has(g)?J.delete(g):J.add(g),J})},[]),je=c.useCallback(()=>{x("all"),C(new Set)},[]),ke=Hi.get(M),Re=ke?{label:ke,reach:D.length>0?"loaded-pages":_i(O),onClear:je}:void 0,pe=o?P.find(g=>g.messageId===i)??P.find(g=>g.threadId===o):void 0,Be=Dn(o,i),R=pe??Be,N=i??R?.messageId,ie=c.useMemo(()=>{if(o)return{threadId:o,mailboxId:R?.mailboxId??e,subject:R?.subject,messageId:N,authenticity:R?.authenticity}},[o,R,N,e]),xe=c.useCallback(()=>{s({to:"/mail/$mailboxId",params:{mailboxId:e},search:g=>g,hash:Pe})},[e,s]),G=c.useCallback(g=>{s({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:e,...g},search:_=>_,hash:Pe})},[e,s]),re=c.useCallback(g=>{N&&g.includes(N)&&xe()},[N,xe]),{deleteMessages:X,isPending:ue}=Kt({mailboxId:e,onAfterOptimisticRemove:re}),{moveMessages:be,isPending:ot}=Vt({mailboxId:e,accountId:H,onAfterOptimisticRemove:re}),it=Fn(),{listCommandsRef:le,onTriageContextChange:We,focusedMessageId:Y,selectedIds:ve}=it,z=P.find(g=>g.messageId===Y)??R,rt=c.useRef(null);c.useEffect(()=>{const g=R?.messageId??null;g&&rt.current!==g&&R?.authenticity?.dkimMismatch&&(rt.current=g,d||f())},[R?.messageId,R?.authenticity?.dkimMismatch,d,f]);const w=bo({accounts:a})??0,at=Dt(),{pushError:lt}=Zt(),he=_n({thread:R,mailboxId:e,accountId:H,onAfterOptimisticRemove:re}),{draftsMailboxId:Q}=Ln(H),Ee=Q!==void 0&&Q===e,{archiveMailboxId:ct}=Pn(H),fe=$n(),{requestCompose:F}=he,Oe=c.useCallback(()=>{F("reply")},[F]),Ae=c.useCallback(()=>{F("reply_all")},[F]),dt=c.useCallback(()=>{F("forward")},[F]),{state:Z,openCompose:Ke,closeCompose:$}=pt(),ce=c.useCallback(()=>{Ke({mode:"new"})},[Ke]),Ve=c.useRef(N);c.useEffect(()=>{const g=Ve.current;Ve.current=N,!(!N||N===g)&&$()},[N,$]);const qe=Ft({...Xt(),onError:g=>{lt(Ys("Couldn't discard draft","The draft wasn't deleted.",g))}}),ut=c.useCallback(()=>{const g=Z.outboxMessageId;g&&(qe.mutate({path:{outboxMessageId:g}}),at.invalidateQueries({queryKey:Yt()}),$())},[Z.outboxMessageId,qe,at,$]),He=c.useCallback(g=>g?fe(g):[],[fe]),{toggleStar:Ne}=Bn({threadId:z?.threadId??"",mailboxId:e}),{toggleReadFor:B}=rs({mailboxId:e,accountId:H}),{junkMailboxId:Me}=as(H),ht=Me!=null&&Me===e,ze=ls(Me,e),{candidates:De}=Oi(ht?Me:void 0),{moveMessages:Ue}=Vt({mailboxId:e,threadId:z?.threadId,accountId:H,onAfterOptimisticRemove:re}),{deleteMessages:Qe}=Kt({mailboxId:e,threadId:z?.threadId,onAfterOptimisticRemove:re}),{addressId:Se,address:Te}=Wn(z),{updateFlags:ne}=Kn({addressId:Se,senderEmail:z?.fromEmail??void 0}),me=c.useCallback(()=>{if(N||!Y)return!1;const g=P.find(_=>_.messageId===Y);return g?(G({threadId:g.threadId,messageId:Y}),!0):!1},[N,Y,P,G]),vt=c.useCallback(()=>{me()||R&&F("reply")},[me,R,F]),Je=c.useCallback(()=>{me()||R&&F("reply_all")},[me,R,F]),St=c.useCallback(()=>{me()||R&&F("forward")},[me,R,F]),ye=c.useCallback(()=>He(z),[He,z]),Ge=c.useCallback(()=>{if(le.current?.requestVerb("delete"))return;const g=ye();g.length>0&&Qe(g)},[le,ye,Qe]),yt=c.useCallback(()=>{if(le.current?.requestVerb("junk")||!ze)return;const g=ye();g.length!==0&&(Vn(l,{count:g.length,senderTrust:z?.senderTrust??"unknown",wasRescuable:z?qn(z):!1}),Ue(g,ze))},[le,ze,ye,Ue,l,z]),Ct=c.useCallback(()=>{if(ve.length>0){const g=!(z?.hasStars??!1),_=new Set(ve);for(const J of P)_.has(J.messageId)&&J.hasStars!==g&&Ne(J.messageId,J.hasStars);return}z&&Ne(z.messageId,z.hasStars)},[ve,P,z,Ne]),It=c.useCallback(()=>{if(le.current?.requestVerb("markRead"))return;const g=ye();if(g.length===0)return;const _=!(z?.isRead??!1);B(g,_)},[le,ye,z,B]),wt=c.useCallback(()=>{if(!Se)return;const g=Te?.flags?.muted?.value!==!0;ne({muted:{value:g}})},[Se,Te,ne]),jt=c.useCallback(()=>{if(!Se)return;const g=Te?.flags?.vip?.value!==!0;ne({vip:{value:g}})},[Se,Te,ne]),kt=c.useCallback(()=>{d||f()},[d,f]),Ce=c.useCallback(g=>{s({to:g})},[s]),Ye=Ee?"drafts":ct===e?"archive":Me===e?"junk":"inbox",Xe=c.useRef("");c.useEffect(()=>{const g=Xe.current;Xe.current=m,m.length>0&&g.length===0&&l.recordEvent("search.submitted",{mailboxType:Ye})},[m,Ye,l]);const Mt=Ee&&Z.isOpen&&!!Z.outboxMessageId&&!R,{goBack:Tt,nextMessageId:Rt,previousMessageId:Ze}=Hn({context:it,orderedIds:P.map(g=>g.messageId),selectedMessageId:N,enabled:!Z.isOpen,onClose:xe,handlers:{reply:vt,replyAll:Je,forward:St,delete:Ge,toggleStar:Ct,toggleRead:It,muteSender:wt,blockSender:kt,vipSender:jt,markJunk:yt,toggleIntelligence:R?f:void 0,compose:ce,goBrief:()=>Ce("/mail/brief"),goInbox:()=>Ce("/mail/brief"),goSent:()=>Ce("/mail/brief"),goFlagged:()=>Ce("/mail/flagged"),goSettings:()=>Ce("/settings")}});vo({enabled:Z.isOpen,bindings:[{key:"Escape",handler:$,preventDefault:!0}]});const ft=g=>{if(!g)return;const _=P.find(J=>J.messageId===g);return _?{threadId:_.threadId,messageId:g}:void 0},Et={mailboxId:e,selectedMessageId:N,selectedThread:R,conversation:ie,onOpenThread:G,threads:P,isLoading:V,isError:oe,error:Ie,mailboxAccountId:H,mailboxName:we,unreadCount:w,isDraftsMailbox:Ee,isSpamFolder:ht,rescueCandidates:De,filterCategory:M,filterAttributes:b,onSelectFilterCategory:U,onToggleFilterAttribute:ge,onClearFilters:je,listFilter:Re,intelligenceOpen:d,onToggleIntelligence:f,handleDeselectIfRemoved:re,searchPredicate:S&&D.length===0?O:void 0,onDeleteMessages:X,onMoveMessages:be,isDeleting:ue,isMoving:ot,onLoadMore:$e,hasMore:ae,isLoadingMore:T,onTriageContextChange:We,listCommandsRef:le,onRetry:()=>q(),toolbarComposeRequest:he.composeRequest,onToolbarReply:Oe,onToolbarReplyAll:Ae,onToolbarForward:dt,onClearComposeRequest:he.clearComposeRequest,onToolbarDelete:he.deleteThread,onToolbarStar:he.toggleStar,onToolbarDiscardDraft:ut,onToolbarMove:he.moveThread,composeState:Z,closeCompose:$,hasRemitDraftOpen:Mt,onBack:Tt,nextThread:ft(Rt),previousThread:ft(Ze)};return r.jsx(Ss.Provider,{value:Et,children:t})}function ys(){const{mailboxId:e,selectedMessageId:n,threads:t,isLoading:s,isError:o,error:i,onDeleteMessages:l,onMoveMessages:a,isDeleting:u,isMoving:d,onLoadMore:f,hasMore:p,isLoadingMore:m,mailboxAccountId:S,mailboxName:y,unreadCount:k,isDraftsMailbox:M,isSpamFolder:x,rescueCandidates:b,onTriageContextChange:C,listCommandsRef:I,onRetry:j,filterCategory:E,filterAttributes:A,onSelectFilterCategory:D,onToggleFilterAttribute:O,onClearFilters:W,listFilter:K,searchPredicate:L}=bt(),{searchQuery:V,searchInput:oe,accounts:Ie,resultFolderIndex:q}=es(),$e=So(),ae=st(),T=y??"Inbox",H=c.useMemo(()=>us(),[]),we=c.useMemo(()=>S?[S]:[],[S]),{hasNewMail:P}=on(),{state:U,errorMessage:ge,refresh:je}=rn(we,{onSettled:j}),ke=c.useMemo(()=>r.jsx(an,{state:U,onRefresh:je,label:`Refresh ${T}`,errorMessage:ge,hasUpdate:P(we)}),[U,je,T,ge,P,we]),Re=c.useMemo(()=>t.map(X=>Qn(X,q)),[t,q]),{hits:pe,isLoading:Be}=ao({mailboxId:e,filterCategory:E}),R=c.useMemo(()=>Jn(pe,t.map(X=>X.threadId),q),[pe,t,q]),N=c.useCallback(X=>{const ue=X.threadId??t.find(be=>be.messageId===X.id)?.threadId;ue&&ae({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:X.mailboxId??e,threadId:ue,messageId:X.id},search:be=>({...be,q:oe||void 0}),hash:Pe})},[e,ae,oe,t]);if(M&&S)return r.jsx(Uo,{mailboxId:e,accountId:S,selectedMessageId:n,imapThreads:t,title:y??"Drafts",unreadCount:k??void 0});const ie=r.jsx(ji,{mailboxId:e,threads:t,selectedMessageId:n,isLoading:s,isError:o,error:i,onRetry:j,searchQuery:V,searchPredicate:L,onDeleteMessages:l,isDeleting:u,isMoving:d,onLoadMore:f,hasMore:p,isLoadingMore:m,accountId:S,listTitle:T,listFilter:K,listScopeLabel:T,hideHeader:!0,onTriageContextChange:C,commandsRef:I}),xe=Ie[0]?.accountId,G=$e==="phone"&&xe?r.jsx(Ti,{accountId:xe,children:ie}):ie,re=x&&b.length>0&&S?r.jsx(Ri,{accountId:S,currentMailboxId:e,candidates:b,onMove:a,children:G}):G;return r.jsx(eo,{title:T,unreadCount:k,preset:H,selectedCategory:E,activeFilters:A,onSelectCategory:D,onToggleFilter:O,onClearFilters:W,searchResults:Re,searchLoading:s,relatedResults:R,relatedLoading:Be,onSelectSearchResult:N,searchResultsInBody:!0,refreshControl:ke,children:re})}function Qi(){const{mailboxId:e,mailboxAccountId:n,selectedThread:t,conversation:s,hasRemitDraftOpen:o,intelligenceOpen:i,onToggleIntelligence:l,toolbarComposeRequest:a,onToolbarReply:u,onToolbarReplyAll:d,onToolbarForward:f,onClearComposeRequest:p,onToolbarDelete:m,onToolbarStar:S,onToolbarDiscardDraft:y,onToolbarMove:k,composeState:M,handleDeselectIfRemoved:x}=bt(),b=Xs()?.showIntelligencePane??!1,C=!!s,[I,j]=c.useState(null),E=s?.threadId??null,A=!b&&E!==null&&I===E,D=c.useCallback(()=>j(null),[]),O=c.useCallback(()=>j(E),[E]),W=b?l:O,K=c.useCallback(()=>{if(b){l();return}j(A?null:E)},[b,l,A,E]),L=C&&(b?i:A),V=M.isOpen&&!s?r.jsx(ps,{}):s?r.jsx(cs,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onOpenIntelligence:s.authenticity?.dkimMismatch?W:void 0,composeRequest:a,onComposeClose:p}):r.jsx(nn,{});return r.jsxs(r.Fragment,{children:[r.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[r.jsx(Un,{hasThread:C,intelligenceOpen:L,canToggleIntelligence:C,onToggleIntelligence:K,onReply:C?u:void 0,onReplyAll:C?d:void 0,onForward:C?f:void 0,canDelete:C||o,onDelete:C?m:o?y:void 0,onToggleStar:C?S:void 0,isStarred:t?.hasStars,moveContext:C&&n?{accountId:n,currentMailboxId:e,onMove:k}:void 0}),r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:V})]}),r.jsx(ds,{isOpen:A,onClose:D,ariaLabel:"Message details",side:"right",children:r.jsx(Lt,{onClose:D,thread:t,mailboxId:e,accountId:n,hideCloseButton:!0,onAfterOptimisticRemove:x})})]})}function Ji(){const{mailboxId:e,mailboxAccountId:n,selectedThread:t,onToggleIntelligence:s,handleDeselectIfRemoved:o}=bt();return r.jsx(Lt,{onClose:s,thread:t,mailboxId:e,accountId:n,onAfterOptimisticRemove:o})}function Gi(){const{mailboxId:e,mailboxAccountId:n,selectedThread:t,conversation:s,onOpenThread:o,intelligenceOpen:i,onToggleIntelligence:l,onBack:a,nextThread:u,previousThread:d,composeState:f,handleDeselectIfRemoved:p}=bt();return s?r.jsxs(r.Fragment,{children:[r.jsx(cs,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onBack:a,onOpenIntelligence:l,onSwipeNext:u?()=>o(u):void 0,onSwipePrevious:d?()=>o(d):void 0,mobileIntelligenceOpen:i}),r.jsx(ds,{isOpen:i,onClose:l,ariaLabel:"Message details",side:"right",children:r.jsx(Lt,{onClose:l,thread:t,mailboxId:e,accountId:n,hideCloseButton:!0,onAfterOptimisticRemove:p})})]}):f.isOpen?r.jsx("div",{className:"h-full",children:r.jsx(ps,{})}):r.jsx(ys,{})}const Cr=Object.assign(Ui,{List:ys,Reading:Qi,Intelligence:Ji,Phone:Gi});export{Cr as M};
@@ -1 +1 @@
1
- import{i as n,j as a,B as o}from"./index-DKG1l4OE.js";import{M as e}from"./menu-DdqPoHXZ.js";function i(){const s=n();return!s||s.showNavPane?null:a.jsx(o,{variant:"ghost",size:"sm",icon:a.jsx(e,{className:"size-4"}),onClick:s.openNav,"aria-label":"Open folders",className:"-ml-1 shrink-0"})}export{i as N};
1
+ import{i as n,j as a,B as o}from"./index-Bo-p3LpF.js";import{M as e}from"./menu-vnrvhz9W.js";function i(){const s=n();return!s||s.showNavPane?null:a.jsx(o,{variant:"ghost",size:"sm",icon:a.jsx(e,{className:"size-4"}),onClick:s.openNav,"aria-label":"Open folders",className:"-ml-1 shrink-0"})}export{i as N};