@remit/web-client-dist 0.0.603 → 0.0.605
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/{BriefPane-PoCwW_rw.js → BriefPane-CQwM0Sok.js} +1 -1
- package/assets/CalendarComposePane-DysR2r25.js +1 -0
- package/assets/{CalendarComposeSeed-BNxq0PPg.js → CalendarComposeSeed-BpzHgcqA.js} +1 -1
- package/assets/{CalendarShell-D_NxjO1T.js → CalendarShell-BIKuX-jS.js} +1 -1
- package/assets/{EmptyState-6r0r5FVG.js → EmptyState-BgIV5l66.js} +1 -1
- package/assets/{ErrorState-Cjdi1Pbp.js → ErrorState-Crk7VNBz.js} +1 -1
- package/assets/{FlaggedPane-D2_45Zph.js → FlaggedPane-DuFdOMBr.js} +1 -1
- package/assets/{FullCompose-ZmZmBukk.js → FullCompose-dOSiw6mn.js} +1 -1
- package/assets/{MailListHeader-D2YY1oCj.js → MailListHeader-E9QEtmIA.js} +2 -2
- package/assets/MailNav-uvD98Dgu.js +1 -0
- package/assets/{MailShell-D8B5KgJY.js → MailShell-DmHcjagS.js} +1 -1
- package/assets/{MailViewChrome-Ca_PpFLh.js → MailViewChrome-CqwrrISL.js} +1 -1
- package/assets/{MailboxPane-D0KDT0nA.js → MailboxPane-BBQp6gbV.js} +1 -1
- package/assets/{NavMenuButton-UuS12b8o.js → NavMenuButton-D_SvQiP3.js} +1 -1
- package/assets/{OnboardingWizard-Bg0oMi5d.js → OnboardingWizard--ImZI0gi.js} +1 -1
- package/assets/{OpenCalendarEvent-eXphsQkd.js → OpenCalendarEvent-DoSRveQi.js} +1 -1
- package/assets/{OutboxPane-KyfD-xAT.js → OutboxPane-BJK_kB5B.js} +1 -1
- package/assets/_calendarObjectId-C63_aKiU.js +1 -0
- package/assets/_mailboxId-XGh757e6.js +1 -0
- package/assets/_messageId-DWmV_jTx.js +1 -0
- package/assets/_messageId-DXwkhdHb.js +1 -0
- package/assets/_messageId-Gpf8VkTa.js +1 -0
- package/assets/_outboxMessageId-C_G7GDw_.js +1 -0
- package/assets/_recurrenceId-OctuqYMY.js +1 -0
- package/assets/_threadId-CG04gKnp.js +1 -0
- package/assets/_threadId-DuZaDe6H.js +1 -0
- package/assets/_threadId-ROlcDtyO.js +1 -0
- package/assets/_view._date-BXH6wPWy.js +1 -0
- package/assets/{accounts-slqMhpwq.js → accounts--BnzjC4-.js} +1 -1
- package/assets/{advanced-DJYUnJcM.js → advanced-C5_T3RXw.js} +1 -1
- package/assets/{appearance-B9Zd5MxX.js → appearance-C8MIGpEN.js} +1 -1
- package/assets/{attachment-file-bw6jpX2a.js → attachment-file-BIIJQJ40.js} +1 -1
- package/assets/{attendee-row-y73RSxi6.js → attendee-row-DpyCf-in.js} +1 -1
- package/assets/{avatar-C5DZJDZl.js → avatar-DWygq3JL.js} +1 -1
- package/assets/bell-off-Cp4zPd95.js +1 -0
- package/assets/{bottom-sheet-BMfA1os-.js → bottom-sheet-B7GLlYre.js} +1 -1
- package/assets/{brief-CWpVPlag.js → brief-7w0qXrpq.js} +1 -1
- package/assets/brief-DgE9HTy9.js +1 -0
- package/assets/{browser-ponyfill-BtE6DJaU.js → browser-ponyfill-97SHVWVb.js} +1 -1
- package/assets/{bug-XlVUpJy1.js → bug-CtoynkW6.js} +1 -1
- package/assets/calendar-Bzl_FjGH.js +1 -0
- package/assets/{calendar-color-DgHc36b7.js → calendar-color-CYkJhzbu.js} +1 -1
- package/assets/{calendar-event-chip-C1T8fqpx.js → calendar-event-chip-B4GnGJnZ.js} +1 -1
- package/assets/{calendars-BLCqhIG7.js → calendars-CvCOaNx1.js} +1 -1
- package/assets/{card-k-jKWhR7.js → card-bXfLFK1d.js} +1 -1
- package/assets/chevron-left-DD2PjhiL.js +1 -0
- package/assets/{circle-check-big-DJeT115E.js → circle-check-big-CxKkpPun.js} +1 -1
- package/assets/{circle-check-DsecdMli.js → circle-check-jWc2VLKl.js} +1 -1
- package/assets/{circle-help-PfoCuRx4.js → circle-help-CEBs72a-.js} +1 -1
- package/assets/{clock-BoxKHt-D.js → clock-Cx9Teo9C.js} +1 -1
- package/assets/compose._-_outboxMessageId_-BkezF3WB.js +1 -0
- package/assets/compose._-_outboxMessageId_-DFetL1XL.js +1 -0
- package/assets/compose._-_outboxMessageId_-DJ8offqg.js +1 -0
- package/assets/compose._-_outboxMessageId_-DkuOX6g4.js +1 -0
- package/assets/{config-import-Cob6KRxW.js → config-import-J-5jtWEq.js} +1 -1
- package/assets/{confirm-dialog-BV8yPk0Z.js → confirm-dialog-C2U7srZg.js} +1 -1
- package/assets/{copy-dsQZ9_Tq.js → copy-B5OXDrT4.js} +1 -1
- package/assets/{credential-steps-BSDUae-c.js → credential-steps-BByezUGt.js} +1 -1
- package/assets/{download-pgJibm8f.js → download-CxnLsCzP.js} +1 -1
- package/assets/{file-json-BaQxcYdZ.js → file-json-BgIhH1Xe.js} +1 -1
- package/assets/{filters-CpRRg5mW.js → filters-D7UDfICG.js} +1 -1
- package/assets/{flagged-6pOoeZxm.js → flagged-4p5G7fEk.js} +1 -1
- package/assets/flagged-CTQmeG1C.js +1 -0
- package/assets/{folders-Bu7Ke42f.js → folders-DCBzQFwu.js} +1 -1
- package/assets/{help-copy-DlRaQ3-c.js → help-copy-D5-s2V7P.js} +1 -1
- package/assets/{import-CLgzHXP3.js → import-RwKchtKQ.js} +1 -1
- package/assets/index-9R0wIocc.js +1 -0
- package/assets/index-B2bWITm8.js +1 -0
- package/assets/index-BhUW2hnW.js +1 -0
- package/assets/index-BoERECrD.js +1 -0
- package/assets/index-Bp_8diWD.js +1 -0
- package/assets/index-BzAFrY3-.js +1 -0
- package/assets/{index-88kWC0mY.js → index-CEAhuChV.js} +1 -1
- package/assets/{index-DembAj_D.js → index-CHt2XLwE.js} +4 -4
- package/assets/index-CkpCRlIU.js +1 -0
- package/assets/index-D3IIXT2Z.js +1 -0
- package/assets/{index-YYH_p-Ox.js → index-D5g4bLbz.js} +4 -4
- package/assets/index-DWmV_jTx.js +1 -0
- package/assets/{kbd-BHWNGlF5.js → kbd-JM0p5E1b.js} +1 -1
- package/assets/{labels-BEzmtjRK.js → labels-CPrOJJt0.js} +1 -1
- package/assets/{mail-D_9uR_xf.js → mail-BQpDNW0S.js} +1 -1
- package/assets/mail-D6EwPlCl.js +1 -0
- package/assets/{map-pin-C7QrVAH3.js → map-pin--rLcjFwi.js} +1 -1
- package/assets/{menu-DPopx5EJ.js → menu-BpzHKPjy.js} +1 -1
- package/assets/{new-7ha2oCKa.js → new-CVYs2LtX.js} +1 -1
- package/assets/onboarding-DdxZjT18.js +1 -0
- package/assets/{onboarding-completion-gdz3-ZZG.js → onboarding-completion-tw9M2yKa.js} +1 -1
- package/assets/outbox-d0DAUI7x.js +1 -0
- package/assets/{pencil-701ohwSi.js → pencil-Bw83xivX.js} +1 -1
- package/assets/{refresh-cw-Di3kvivg.js → refresh-cw-BVmX77aQ.js} +1 -1
- package/assets/{rich-text-C4evizno.js → rich-text-B9YsMmF5.js} +1 -1
- package/assets/{rich-text-spellcheck-worker-provider-BI4F1onx.js → rich-text-spellcheck-worker-provider-DxvEN-cI.js} +1 -1
- package/assets/{rotate-ccw-CY4_PNoH.js → rotate-ccw-Bv6m9CuX.js} +1 -1
- package/assets/{roving-focus-CFhWtHQV.js → roving-focus-CYv4I8cF.js} +1 -1
- package/assets/{row-actions-e8dcmEFt.js → row-actions-BZVua7dw.js} +1 -1
- package/assets/{search-mirror-C4Q_FmCR.js → search-mirror-COlm1PCn.js} +1 -1
- package/assets/{search-token-index-CF-eJ9n9.js → search-token-index-C7IV79h1.js} +1 -1
- package/assets/{sections-BZ0O_NV5.js → sections-Dp7hJCpX.js} +1 -1
- package/assets/{senders-RmiQhHZD.js → senders-DNU-lxEl.js} +1 -1
- package/assets/settings-WV6xBMDS.js +1 -0
- package/assets/{settings-screen-ClyspzuZ.js → settings-screen-D4ZZ_7yA.js} +1 -1
- package/assets/{shield-check-D9zGpyyh.js → shield-check-Ct41yuh3.js} +1 -1
- package/assets/{suggested-vips-sI4H9GLc.js → suggested-vips-BJGpfYGa.js} +1 -1
- package/assets/{useCalendarData-B6t-M5Ly.js → useCalendarData-DY8pbiPJ.js} +1 -1
- package/assets/{useCalendars-BIBQT7Wk.js → useCalendars-DTf-a8_0.js} +1 -1
- package/assets/{useDebouncedValue-BMYHRqha.js → useDebouncedValue-BELDOxTU.js} +1 -1
- package/assets/{useFilters-DXXBrpPW.js → useFilters-B_vFCX27.js} +1 -1
- package/assets/{useLabels-D8sluUEk.js → useLabels-CUzYbhl8.js} +1 -1
- package/assets/useLayoutTier-wQkod_ZW.js +1 -0
- package/assets/{useMessageBodyContent-D-lqah5s.js → useMessageBodyContent-t6jq86nw.js} +1 -1
- package/assets/{useQueries-Dm82vk6v.js → useQueries-B_l_mKrJ.js} +1 -1
- package/assets/{useRefreshControl-B9v4eUjG.js → useRefreshControl-BPgFT5xG.js} +1 -1
- package/assets/{useResultFolderIndex-D6xs6h1E.js → useResultFolderIndex-Co8QObgd.js} +1 -1
- package/assets/{useSearchTokenContext-DMTmSJiu.js → useSearchTokenContext-fxNd6lN7.js} +1 -1
- package/assets/{useSemanticSearch-zOQZMrAG.js → useSemanticSearch-DLqfhhCH.js} +1 -1
- package/assets/{useSignature-15aE8XaV.js → useSignature-aAe6FU9P.js} +1 -1
- package/assets/{window-DNm0-rvw.js → window-C6UMjwqh.js} +1 -1
- package/index.html +1 -1
- package/package.json +1 -1
- package/assets/CalendarComposePane-CPgvMuhs.js +0 -1
- package/assets/MailNav-dXSXwtSS.js +0 -1
- package/assets/_calendarObjectId-bOBkPp1e.js +0 -1
- package/assets/_mailboxId-CBnetBDe.js +0 -1
- package/assets/_messageId-CC7P0NKV.js +0 -1
- package/assets/_messageId-CyzEwcHf.js +0 -1
- package/assets/_messageId-D9ErNE0i.js +0 -1
- package/assets/_outboxMessageId-BAuSfwjW.js +0 -1
- package/assets/_recurrenceId-BYVaWJco.js +0 -1
- package/assets/_threadId-Bf_hxH8H.js +0 -1
- package/assets/_threadId-DGaPE-UV.js +0 -1
- package/assets/_threadId-DNmbMRxQ.js +0 -1
- package/assets/_view._date-Buy6VJ4Y.js +0 -1
- package/assets/brief-BSP8cSU6.js +0 -1
- package/assets/calendar-u1hgf3tg.js +0 -1
- package/assets/chevron-left-CrajKg1c.js +0 -1
- package/assets/compose._-_outboxMessageId_-B4Esrx1s.js +0 -1
- package/assets/compose._-_outboxMessageId_-Bkav_--V.js +0 -1
- package/assets/compose._-_outboxMessageId_-DKmOtVWX.js +0 -1
- package/assets/compose._-_outboxMessageId_-Eu5BpvJ5.js +0 -1
- package/assets/flagged-BFSPdfnJ.js +0 -1
- package/assets/index-3zQFhWS_.js +0 -1
- package/assets/index-BHFrxX5A.js +0 -1
- package/assets/index-BRJl-vWl.js +0 -1
- package/assets/index-Bh1nz_PB.js +0 -1
- package/assets/index-BoTmstF8.js +0 -1
- package/assets/index-CyzEwcHf.js +0 -1
- package/assets/index-D9ErNE0i.js +0 -1
- package/assets/index-Z8mU620o.js +0 -1
- package/assets/index-d-DkNljh.js +0 -1
- package/assets/mail-Bw_opxSY.js +0 -1
- package/assets/onboarding-DVkSteAy.js +0 -1
- package/assets/outbox-Chk8Sk4b.js +0 -1
- package/assets/settings-BtStj6GW.js +0 -1
- package/assets/useLayoutTier-MqmqPhVY.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{e as L,r as v,j as e,W,Y as $,Z as Q,_ as A,$ as I,t as k,a0 as H,a1 as V,a2 as Y,a3 as G,a4 as Z,a5 as J,a6 as X,a7 as ee,I as se,a8 as te,a9 as ae,aa as O,ab as ne,h as re,C as ie,ac as le,K as oe,c as ce,ad as ue,ae as de,af as R,ag as xe,ah as y,ai as fe,D as me,v as he}from"./index-D5g4bLbz.js";import{u as ge}from"./roving-focus-CYv4I8cF.js";import{B as pe}from"./bell-off-Cp4zPd95.js";import{u as be}from"./useQueries-B_l_mKrJ.js";import{i as je}from"./outbox-status-BlKn6P0x.js";import{B as ye}from"./bug-CtoynkW6.js";const ve=L("CirclePause",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]);const Ne=L("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);const ke=L("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),Ce={Mail:"mail sync off"},Oe="button:not([disabled]), a[href]",w="outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-surface-sunken";function Se({active:s,dimmed:a,indent:n}){return k("flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-sm transition-colors",w,n&&"pl-7",s?"bg-accent-2-soft font-medium text-accent-2":"text-fg-muted hover:bg-surface hover:text-fg",a&&"opacity-55")}function we({icon:s,label:a,count:n,active:r}){return e.jsxs(e.Fragment,{children:[s&&e.jsx("span",{className:k("shrink-0",r?"text-accent-2":"text-fg-subtle"),children:s}),e.jsx("span",{className:"flex-1 truncate",children:a}),n!=null&&n>0&&e.jsx("span",{className:k("text-2xs tabular-nums",r?"text-accent-2":"text-fg-subtle"),children:n})]})}function C({icon:s,label:a,count:n,active:r,dimmed:c,indent:l,navId:d,linkComponent:m,ariaLabel:x,title:g,onClick:p}){const N=Se({active:r,dimmed:c,indent:l}),j=e.jsx(we,{icon:s,label:a,count:n,active:r});return d&&m?m({navId:d,className:N,ariaLabel:x??a,title:g,onClick:p,children:j}):e.jsx("button",{type:"button",onClick:p,className:N,"aria-label":x,title:g,children:j})}const M={inbox:0,flagged:1,drafts:2,sent:3,archive:4,all:5,junk:6,trash:7};function ze(s){switch(s){case"inbox":return e.jsx(se,{className:"size-4"});case"flagged":return e.jsx(Q,{className:"size-4"});case"drafts":return e.jsx(ee,{className:"size-4"});case"sent":return e.jsx(V,{className:"size-4"});case"archive":return e.jsx(X,{className:"size-4"});case"all":return e.jsx(J,{className:"size-4"});case"junk":return e.jsx(Z,{className:"size-4"});case"trash":return e.jsx(G,{className:"size-4"})}}const E=s=>s.role!=null,z=8,P="remit.nav.folders.open.",_="remit.nav.account.open.";function D(s,a,n){if(typeof localStorage>"u")return n;const r=localStorage.getItem(s+a);return r===null?n:r!=="0"}function B(s,a,n){typeof localStorage>"u"||localStorage.setItem(s+a,n?"1":"0")}function Re({account:s,selectedNavId:a,onSelectNav:n,linkComponent:r}){const[c,l]=v.useState(()=>D(_,s.id,!0)),[d,m]=v.useState(()=>D(P,s.id,!0)),[x,g]=v.useState(!1),p=()=>{l(t=>{const o=!t;return B(_,s.id,o),o})},N=()=>{m(t=>{const o=!t;return B(P,s.id,o),o})},j=s.mailboxes.filter(E).sort((t,o)=>M[t.role]-M[o.role]),h=s.mailboxes.filter(t=>!E(t)),S=x||h.length<=z?h:h.slice(0,z),i=h.length-S.length,u=s.status??"ready",f=s.syncedServices!==void 0&&!s.syncedServices.includes("Mail"),b=u==="ready"&&j.length===0&&h.length===0;return e.jsxs("div",{className:"mt-3",children:[e.jsxs("button",{type:"button",onClick:p,"aria-expanded":c,className:k("flex w-full items-center gap-1.5 px-2 pb-1 text-left transition-colors hover:text-fg",w,s.muted&&"opacity-55"),children:[c?e.jsx(A,{className:"size-3 shrink-0 text-fg-subtle"}):e.jsx(I,{className:"size-3 shrink-0 text-fg-subtle"}),e.jsx("span",{className:"truncate text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:s.label}),s.muted&&e.jsxs(e.Fragment,{children:[e.jsx(pe,{className:"size-3 shrink-0 text-fg-subtle"}),e.jsx("span",{className:"text-2xs text-fg-subtle",children:"muted"})]}),f&&e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"size-3 shrink-0 text-fg-subtle"}),e.jsx("span",{className:"text-2xs text-fg-subtle",children:Ce.Mail})]})]}),c&&e.jsxs(e.Fragment,{children:[u==="loading"&&e.jsx("div",{className:"px-2 py-1 text-sm text-fg-muted",children:"Loading…"}),u==="error"&&e.jsxs("div",{role:"alert",className:"mx-2 my-1 flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-2 py-1.5 text-sm",children:[e.jsx(H,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":"true"}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("p",{className:"font-medium text-danger",children:"Couldn't load mailboxes"})}),s.onRetry&&e.jsx("button",{type:"button",onClick:s.onRetry,className:"shrink-0 text-sm font-medium text-accent hover:underline",children:"Retry"})]}),b&&e.jsx("div",{className:"px-2 py-1 text-sm text-fg-muted",children:"No mailboxes"}),u==="ready"&&e.jsxs(e.Fragment,{children:[j.map(t=>e.jsx(C,{navId:t.id,linkComponent:r,icon:ze(t.role),label:t.name,ariaLabel:t.name,title:t.fullPath??t.name,count:t.unseen,active:a===t.id,dimmed:s.muted,onClick:()=>n?.(t.id)},t.id)),s.outboxPending!==void 0&&e.jsx(C,{navId:"outbox",linkComponent:r,icon:e.jsx(V,{className:"size-4"}),label:"Outbox",ariaLabel:"Outbox",count:s.outboxPending>0?s.outboxPending:void 0,active:a==="outbox",dimmed:s.muted,onClick:()=>n?.("outbox")}),h.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:N,"aria-expanded":d,className:k("mt-1 flex w-full items-center gap-1 px-2 py-1 text-left text-2xs font-semibold uppercase tracking-wider text-fg-subtle transition-colors hover:text-fg",w),children:[d?e.jsx(A,{className:"size-3 shrink-0"}):e.jsx(I,{className:"size-3 shrink-0"}),e.jsx("span",{className:"flex-1",children:"Folders"}),e.jsx("span",{className:"tabular-nums opacity-70",children:h.length})]}),d&&e.jsxs(e.Fragment,{children:[S.map(t=>e.jsx(C,{navId:t.id,linkComponent:r,icon:e.jsx(Y,{className:"size-4"}),label:t.name,ariaLabel:t.name,title:t.fullPath??t.name,count:t.unseen,active:a===t.id,dimmed:s.muted,onClick:()=>n?.(t.id)},t.id)),(i>0||x)&&h.length>z&&e.jsx("button",{type:"button",onClick:()=>g(t=>!t),className:k("ml-7 flex items-center px-2 py-1 text-2xs font-medium text-accent transition-colors hover:underline",w),children:x?"Show less":`Show all (${h.length})`})]})]})]})]})]})}function Le({accounts:s,selectedNavId:a,briefUnseen:n,onSelectNav:r,variant:c="desktop",linkComponent:l,calendarNav:d="hidden"}){const m=v.useRef(null);ge({containerRef:m,itemSelector:Oe});const x=c==="drawer",g=e.jsxs("nav",{ref:x?m:void 0,className:x?"px-2 py-2":"flex-1 overflow-y-auto px-2 py-2","aria-label":"Mailboxes",children:[e.jsx(C,{navId:"brief",linkComponent:l,icon:e.jsx(W,{className:"size-4"}),label:"Daily brief",ariaLabel:"Daily brief",count:n,active:a==="brief",onClick:()=>r?.("brief")}),d==="shown"&&e.jsx(C,{navId:"calendar",linkComponent:l,icon:e.jsx($,{className:"size-4"}),label:"Calendar",ariaLabel:"Calendar",active:a==="calendar",onClick:()=>r?.("calendar")}),e.jsx(C,{navId:"flagged",linkComponent:l,icon:e.jsx(Q,{className:"size-4"}),label:"Starred",ariaLabel:"Starred",active:a==="flagged",onClick:()=>r?.("flagged")}),s.length===0?e.jsx("div",{className:"px-2 py-4 text-center text-sm text-fg-muted",children:"No accounts configured"}):s.map(p=>e.jsx(Re,{account:p,selectedNavId:a,onSelectNav:r,linkComponent:l},p.id))]});return x?g:e.jsx("aside",{ref:m,className:"flex h-full w-full flex-col bg-surface-sunken",children:g})}function Fe(){const{pathname:s}=te(),a=ae({from:"/mail/$mailboxId",shouldThrow:!1});return O(s,"/settings")?"settings":O(s,"/calendar")?"calendar":O(s,"/mail/outbox")?"outbox":O(s,"/mail/flagged")?"flagged":O(s,"/mail/brief")?"brief":a?.mailboxId??""}const Ae=({children:s})=>{const{Account:a}=ne();return e.jsx(a,{children:s})},T=s=>/^\d/.test(s),Ie=(s,a)=>{const n=T(s),r=T(a);return n&&!r?-1:!n&&r?1:s.localeCompare(a,void 0,{sensitivity:"base",numeric:!0})};function Me(s,a,n){const r=[],c=[];for(const l of s)a.has(l.mailboxId)?r.push(l):c.push(l);return c.sort((l,d)=>Ie(R(l,void 0,n),R(d,void 0,n))),{system:r,labels:c}}function Ee(s,a,n){const r=xe(a)&&s.unseenCount>0;return{id:s.mailboxId,name:R(s,a,n),unseen:r?s.unseenCount:void 0,role:a,fullPath:s.fullPath}}function q({accounts:s,onMailboxSelect:a,variant:n="desktop"}){const r=re(),c=Fe(),{onSearchChange:l}=ie(),{t:d}=le("mail",{useSuspense:!1}),m=v.useCallback((i,u)=>d(i,{defaultValue:u}),[d]),x=be({queries:s.map(i=>({...oe({path:{accountId:i.accountId}}),staleTime:1/0}))}),{data:g}=ce(ue()),p=v.useMemo(()=>(g?.items??[]).filter(i=>je(i.status)).length,[g?.items]),N=v.useMemo(()=>s.map((i,u)=>{const f=x[u],b=f?.data?.items??[],t=de(i.folderAppointments),{system:o,labels:K}=Me(b,t,m),U=f?.isError?"error":f?.isLoading?"loading":"ready";return{id:i.accountId,label:i.email,email:i.email,muted:!!i.muted,outboxPending:p,status:U,onRetry:()=>f?.refetch(),mailboxes:[...o,...K].map(F=>Ee(F,t.get(F.mailboxId),m))}}),[s,x,p,m]),j=i=>{r.invalidateQueries({queryKey:fe({path:{mailboxId:i},query:{order:"desc"}})})},h=({navId:i,className:u,ariaLabel:f,title:b,children:t,onClick:o})=>i==="brief"?e.jsx(y,{to:"/mail/brief",search:{q:void 0},activeOptions:{includeSearch:!1},onClick:()=>o?.(),className:u,"aria-label":f,title:b,children:t}):i==="calendar"?e.jsx(y,{to:"/calendar",onClick:()=>o?.(),className:u,"aria-label":f,title:b,children:t}):i==="outbox"?e.jsx(y,{to:"/mail/outbox",search:{q:void 0},onClick:()=>o?.(),className:u,"aria-label":f,title:b,children:t}):i==="flagged"?e.jsx(y,{to:"/mail/flagged",search:{q:void 0},onClick:()=>o?.(),className:u,"aria-label":f,title:b,children:t}):i==="settings"?e.jsx(y,{to:"/settings/accounts",onClick:()=>o?.(),className:u,"aria-label":f,title:b,children:t}):e.jsx(y,{to:"/mail/$mailboxId",params:{mailboxId:i},search:{q:void 0},onClick:()=>{j(i),o?.()},className:u,"aria-label":f,title:b,children:t}),S=()=>{l(""),a?.()};return e.jsx(Le,{accounts:N,selectedNavId:c,onSelectNav:S,linkComponent:h,calendarNav:"shown",variant:n})}function Pe(){return e.jsxs("button",{type:"button",onClick:me,className:"flex w-full items-center gap-2 rounded-md px-2 py-1 text-sm text-fg-muted transition-colors hover:bg-surface hover:text-fg",children:[e.jsx(ye,{className:"size-4 shrink-0"}),e.jsx("span",{className:"flex-1 truncate text-left",children:"Report a bug"})]})}function Ve({accounts:s,onMailboxSelect:a}){return he()?.showNavPane??!0?e.jsx(q,{accounts:s}):e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsx(q,{accounts:s,onMailboxSelect:a,variant:"drawer"})}),e.jsxs("div",{className:"border-t border-line px-2 py-2",children:[e.jsxs(y,{to:"/settings/accounts",onClick:a,children:[e.jsx(ke,{className:"size-4 shrink-0"}),e.jsx("span",{className:"flex-1 truncate text-left",children:"Settings"})]}),e.jsx(Pe,{}),e.jsx(Ae,{children:({signOut:c})=>e.jsxs("button",{type:"button",onClick:()=>{a?.(),c()},className:"flex min-h-11 w-full items-center gap-2 rounded-md px-2 py-1 text-sm text-fg-muted transition-colors hover:bg-surface hover:text-fg","data-testid":"sign-out-button",children:[e.jsx(Ne,{className:"size-4 shrink-0"}),e.jsx("span",{className:"flex-1 truncate text-left",children:"Sign out"})]})})]})]})}export{Ae as A,Ne as L,Ve as M,ke as S};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{aa as v,j as s,r as u,al as l,am as p}from"./index-
|
|
1
|
+
import{aa as v,j as s,r as u,al as l,am as p}from"./index-D5g4bLbz.js";import{F as x}from"./FullCompose-dOSiw6mn.js";import{a as m}from"./useMessageBodyContent-t6jq86nw.js";function S(o,n,r){if(o!==n)return r}function d(o,n){return o===""?"":n}function j({searchInput:o,committedQuery:n,urlQuery:r,pathname:a,listPath:t}){return!v(a,t)||n!==o?!1:n!==r}const c=u.createContext(null),C=({chrome:o,children:n})=>s.jsx(c.Provider,{value:o,children:n});function M({phone:o,list:n,reading:r,intelligence:a,hasThread:t=!1}){const e=u.useContext(c),f=m();if(!e)return s.jsx(l,{});const i={nav:e.nav,overlay:e.overlay,skeleton:s.jsx(l,{}),isLoading:e.isLoading,navOpen:e.navOpen,onOpenNav:e.onOpenNav,onCloseNav:e.onCloseNav};return e.isSinglePane?s.jsx(p,{...i,list:f?s.jsx(x,{}):o,intelligenceOpen:e.intelligenceOpen}):s.jsx(p,{...i,topBar:e.topBar,list:n,reading:r,intelligence:a,intelligenceOpen:e.intelligenceOpen,hasThread:t})}export{C as M,M as a,j as b,d as c,S as s};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s,L as le,f as $,a0 as ue,r as g,t as K,aB as de,a3 as fe,d7 as me,c3 as xe,eb as ge,ec as he,ed as pe,C as be,ee as ve,d8 as je}from"./index-YYH_p-Ox.js";import{l as we,p as Ne}from"./search-token-index-CF-eJ9n9.js";import{u as ye,L as Q}from"./roving-focus-CFhWtHQV.js";import{a9 as Pe,aa as Re,c as Ce,a as G,ab as Se,o as Ee,ac as Me,ad as ke,ae as Ie,af as Le,ag as Te,ah as ee,ai as ze}from"./MailListHeader-D2YY1oCj.js";import{A as Ae}from"./avatar-C5DZJDZl.js";import{M as Oe}from"./mail-D_9uR_xf.js";import{R as De}from"./refresh-cw-Di3kvivg.js";import{M as $e}from"./menu-DPopx5EJ.js";function _e(){return s.jsx("div",{className:"space-y-0",role:"status","aria-busy":"true","aria-label":"Loading messages",children:Array.from({length:8}).map((e,t)=>s.jsxs("div",{className:"animate-pulse border-b border-line px-3 py-2",children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[s.jsx("div",{className:"h-4 w-32 rounded bg-surface-sunken"}),s.jsx("div",{className:"h-3 w-16 rounded bg-surface-sunken"})]}),s.jsx("div",{className:"mb-2 h-4 w-48 rounded bg-surface-sunken"}),s.jsx("div",{className:"h-3 w-full rounded bg-surface-sunken"})]},t))})}function Fe({filter:e,scopeLabel:t,searchQuery:n}){const u=n?.trim();return e?s.jsxs(q,{children:[s.jsx("p",{className:"font-medium text-fg",children:Be(e.label,t,u)}),s.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:He[e.reach]}),s.jsx($,{variant:"secondary",size:"sm",className:"mt-4",onClick:e.onClear,children:"Clear filter"})]}):s.jsx(q,{children:s.jsx("p",{className:"text-fg-muted",children:Xe(u,t)})})}const He={"whole-folder":"Every message in this folder was checked.","loaded-pages":"Only the messages loaded so far were checked."};function Xe(e,t){return e?"No messages match your search":t?`No messages in ${t}`:"No messages in this mailbox"}function Be(e,t,n){return n?`No results for “${n}” in ${e}`:t?`No ${e} in ${t}`:`No ${e}`}function q({children:e}){return s.jsx("div",{className:"flex h-full flex-1 items-center justify-center",children:s.jsx("div",{className:"flex max-w-sm flex-col items-center justify-center p-8 text-center",children:e})})}function us(){return s.jsxs("div",{className:"flex items-center justify-center gap-2 py-4 text-sm text-fg-muted",role:"status","aria-live":"polite",children:[s.jsx(le,{className:"size-4 animate-spin","aria-hidden":"true"}),s.jsx("span",{children:"Loading more…"})]})}function Ue({message:e="Something went wrong loading this mailbox.",onRetry:t,onReport:n}){return s.jsx("div",{className:"flex h-full flex-1 items-center justify-center p-4",children:s.jsxs("div",{role:"alert",className:"flex max-w-sm flex-col items-center justify-center gap-3 text-center",children:[s.jsx(ue,{className:"size-8 text-danger","aria-hidden":"true"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium text-danger",children:"Couldn't load messages"}),s.jsx("p",{className:"mt-1 break-words text-sm text-fg-muted",children:e})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[t&&s.jsx($,{variant:"secondary",size:"sm",onClick:t,children:"Retry"}),n&&s.jsx($,{variant:"ghost",size:"sm",onClick:n,children:"Report a problem"})]})]})})}const L=72,V=10,We=L/2,J="__swipeableRowAxisCancel";function Z(e){return e==="leading"?L:e==="trailing"?-L:0}function Ye(e){return e>=L/2?"leading":e<=-L/2?"trailing":"none"}function Ke({thread:e,selectionMode:t,checked:n,active:u,peek:f,onPeek:c,onToggleCheck:p,onLongPress:w,onOpen:b,onAct:v}){const x=g.useRef(null),[j,h]=g.useState(null),{longPressProps:P}=Pe({onLongPress:w,isDisabled:t,accessibilityDescription:"Select message"}),S=i=>{const o=new PointerEvent("pointercancel",{bubbles:!0});o[J]=!0,i.currentTarget.dispatchEvent(o)},r=Re(P,{onPointerDown:i=>{x.current={startX:i.clientX,startY:i.clientY,axis:"none",escaped:!1}},onPointerMove:i=>{if(t)return;const o=x.current;if(!o)return;const m=i.clientX-o.startX,M=i.clientY-o.startY;if(o.axis==="none"&&(Math.abs(M)>V&&Math.abs(M)>Math.abs(m)?o.axis="vertical":Math.abs(m)>V&&Math.abs(m)>Math.abs(M)&&(o.axis="horizontal",i.currentTarget.setPointerCapture(i.pointerId))),o.axis==="none")return;const T=o.axis==="horizontal"?Math.abs(m):Math.abs(M);if(!o.escaped&&T>We&&(o.escaped=!0,S(i)),o.axis!=="horizontal")return;const F=Z(f),H=Math.max(-L,Math.min(L,F+m));h(H)},onPointerUp:i=>{const o=x.current;x.current=null;const m=j;if(h(null),!!o){if(o.axis!=="none"&&!o.escaped&&S(i),o.axis==="horizontal"){m!==null&&c(Ye(m));return}if(o.axis!=="vertical"){if(t){p();return}if(f!=="none"){c("none");return}b()}}},onPointerCancel:i=>{i.nativeEvent[J]||(x.current=null,h(null))}}),d=j??Z(f),y=d>0?"leading":d<0?"trailing":"none",R=K("relative touch-pan-y bg-surface","select-none",Ce({active:n||u})),A={transform:d!==0?`translateX(${d}px)`:void 0,transition:j===null?"transform 150ms ease":"none",minHeight:44},_=!e.isRead,I=i=>i.stopPropagation(),O=t?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:K("inline-flex size-7 shrink-0 items-center justify-center rounded-full border",n?"border-accent bg-accent text-accent-fg":"border-line-strong bg-canvas"),children:n&&s.jsx(de,{className:"size-3.5"})}),s.jsx(G,{thread:e})]}):s.jsxs(s.Fragment,{children:[_&&s.jsx("span",{className:"absolute left-1.5 top-1/2 size-1.5 -translate-y-1/2 rounded-full bg-accent"}),s.jsx("span",{role:"checkbox",tabIndex:0,"aria-checked":n,"aria-label":`Select message from ${e.fromName}`,onPointerDown:I,onPointerMove:I,onPointerUp:I,onClick:i=>{i.preventDefault(),i.stopPropagation(),w()},onKeyDown:i=>{i.key!=="Enter"&&i.key!==" "||(i.preventDefault(),i.stopPropagation(),w())},className:"-m-2 inline-flex size-11 shrink-0 items-center justify-center rounded-full",children:s.jsx(Ae,{name:e.fromName,email:e.fromEmail,size:"sm"})}),s.jsx(G,{thread:e})]});return s.jsxs("div",{className:"relative overflow-hidden",children:[y==="leading"&&s.jsx("button",{type:"button",onClick:()=>v("leading"),"aria-label":e.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:e.isRead?s.jsx(Oe,{className:"size-6"}):s.jsx(Se,{className:"size-6"})}),y==="trailing"&&s.jsx("button",{type:"button",onClick:()=>v("trailing"),"aria-label":"Delete message",className:"absolute inset-y-0 right-0 flex items-center justify-end bg-danger px-6 text-canvas",children:s.jsx(fe,{className:"size-6"})}),s.jsx("button",{type:"button",role:t?"checkbox":void 0,"aria-checked":t?n:void 0,"data-message-row":!0,"data-message-id":e.id,...r,className:R,style:A,children:O})]})}function Qe({sections:e,selectedThreadId:t,selectionMode:n,checkedIds:u,initialPeek:f,onToggleCheck:c,onEnterSelection:p,onOpenThread:w,onRefresh:b,refreshing:v,busy:x=!1}){const[j,h]=g.useState(new Set),[P,S]=g.useState(new Map),N=e.flatMap(r=>r.threads).filter(r=>!j.has(r.id)).map(r=>{const d=P.get(r.id);return d===void 0?r:{...r,isRead:d}}),[E,C]=g.useState(f&&f!=="none"&&N[1]?{id:N[1].id,side:f}:null),k=(r,d)=>{if(d==="trailing")h(y=>new Set(y).add(r));else{const y=N.find(R=>R.id===r);S(R=>new Map(R).set(r,!y?.isRead))}C(null)};return s.jsxs("div",{className:"flex-1 overflow-y-auto",children:[v&&s.jsxs("div",{className:"flex items-center justify-center gap-2 border-b border-line py-3 text-fg-muted",children:[s.jsx(De,{className:"size-4 animate-spin"}),s.jsx("span",{className:"text-xs",children:"Checking for new mail…"})]}),s.jsx("div",{className:"divide-y divide-line",children:N.map(r=>s.jsx("div",{className:x?"pointer-events-none opacity-50":void 0,children:s.jsx(Ke,{thread:r,selectionMode:n,checked:u.has(r.id),active:r.id===t,peek:E?.id===r.id?E.side:"none",onPeek:d=>C(d==="none"?null:{id:r.id,side:d}),onToggleCheck:()=>c(r.id),onLongPress:()=>p(r.id),onOpen:()=>w(r.id),onAct:d=>k(r.id,d)})},r.id))}),!n&&!v&&!x&&s.jsx("button",{type:"button",onClick:b,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 Ge=new Set;function ds({listTitle:e,listMeta:t,sections:n,briefFilters:u,flatList:f,listState:c="ready",searchQuery:p,listFilter:w,listScopeLabel:b,errorMessage:v,onRetry:x,onReportError:j,briefFilter:h,selectedThreadId:P,density:S="comfortable",onSelectThread:N,onOpenNav:E,isDesktop:C,initialTouchState:k,selection:r,keyboard:d,selectionBar:y,paneOverlay:R,listBody:A,hideHeader:_=!1}){const I=S==="compact"?ke:Ie,O=g.useRef(null),i=g.useRef(null),o=me(d);ye({containerRef:O,itemSelector:Q,enabled:!o});const m=o?d.focusedId:void 0,M=o?m??n[0]?.threads[0]?.id:void 0,T=g.useCallback(a=>M===void 0?void 0:a===M?0:-1,[M]);g.useEffect(()=>{if(m===void 0)return;const a=i.current;if(!a)return;const l=a.querySelector(`${Q}[data-message-id="${m}"]`);!l||l===a.ownerDocument.activeElement||l.focus({preventScroll:!1})},[m]),g.useEffect(()=>{if(!o)return;const a=i.current;if(!a)return;const l=a.ownerDocument.activeElement;l!==null&&l!==a.ownerDocument.body||a.focus({preventScroll:!0})},[o]);const F=!C&&!u&&c==="ready",[H,W]=g.useState(!1),ae=k==="peek-trailing"?"trailing":k==="peek-leading"?"leading":void 0,re=()=>{W(!0),setTimeout(()=>W(!1),1400)},D=r?.selectedIds??Ge,z=r?.onToggle,Y=r?.onRowSelect,ie=Ee(D.size,C),X=g.useCallback(a=>{if(z)return{checked:D.has(a),onToggle:l=>{l.preventDefault(),l.stopPropagation(),z(a)}}},[D,z]),B=g.useCallback((a,l)=>Y?.(a,Me(l))?(l.preventDefault(),l.shiftKey&&window.getSelection()?.removeAllRanges(),!0):!1,[Y]),oe=g.useCallback(({thread:a,active:l,onClick:U})=>s.jsx(I,{thread:a,active:l,focused:a.id===m,tabIndex:T(a.id),selection:X(a.id),onClick:ce=>{B(a.id,ce)||U?.()}}),[I,X,B,m,T]);return s.jsxs("section",{ref:a=>{i.current=a,d?.ref(a)},tabIndex:o?-1:void 0,className:"relative flex h-full w-full flex-col bg-surface outline-none",children:[y??(_?null:s.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[E&&s.jsx($,{variant:"ghost",size:"sm",icon:s.jsx($e,{className:"size-4"}),onClick:E,"aria-label":"Open folders",className:"-ml-1 shrink-0"}),s.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:e}),t&&s.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle",children:t})]})),c==="loading"?s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsx(_e,{})}):c==="empty"?s.jsx(Fe,{filter:w,scopeLabel:b,searchQuery:p}):c==="error"?s.jsx(Ue,{message:v,onRetry:x,onReport:j}):u&&h?s.jsx(Le,{...h,sections:n,selectedThreadId:P,Row:oe,keyboard:d,onSelectThread:N}):A??(F?s.jsx(Qe,{sections:n,selectedThreadId:P,selectionMode:ie,checkedIds:D,initialPeek:ae,onToggleCheck:a=>z?.(a),onEnterSelection:a=>z?.(a),onOpenThread:a=>N?.(a),onRefresh:re,refreshing:H}):s.jsx("div",{ref:O,className:"flex-1 overflow-y-auto",children:n.map(a=>s.jsxs("div",{children:[!f&&a.label&&s.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:[s.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:a.label}),s.jsx("span",{className:"text-2xs text-fg-subtle tabular-nums",children:a.threads.length})]}),s.jsx("div",{className:"divide-y divide-line",children:a.threads.map(l=>s.jsx(I,{thread:l,active:l.id===P,focused:l.id===m,tabIndex:T(l.id),selection:X(l.id),onClick:U=>{B(l.id,U)||N?.(l.id)}},l.id))})]},a.id))})),C&&s.jsx(Te,{hints:d?Ne(d.handlers):we}),R]})}var qe=class extends xe{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type="infinite",super.setOptions(e)}getOptimisticResult(e){return e._type="infinite",super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){const{state:n}=e,u=super.createResult(e,t),{isFetching:f,isRefetching:c,isError:p,isRefetchError:w}=u,b=n.fetchMeta?.fetchMore?.direction,v=p&&b==="forward",x=f&&b==="forward",j=p&&b==="backward",h=f&&b==="backward";return{...u,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:he(t,n.data),hasPreviousPage:ge(t,n.data),isFetchNextPageError:v,isFetchingNextPage:x,isFetchPreviousPageError:j,isFetchingPreviousPage:h,isRefetchError:w&&!v&&!j,isRefetching:c&&!x&&!h}}};function fs(e,t){return pe(e,qe)}const se={dimension:"read",position:"pre",text:"unread"},Ve={dimension:"read",position:"pre",text:"read"},te={dimension:"starred",position:"pre",text:"starred"},ne={dimension:"attachment",position:"post",text:"with an attachment"},Je=[["unread",se],["flagged",te],["attachment",ne]],Ze=e=>{switch(e.type){case"category":return{dimension:"category",position:"pre",text:ee(e.category)??e.value};case"isUnread":return se;case"isRead":return Ve;case"isStarred":return te;case"hasAttachment":return ne;case"from":return{dimension:e.raw,position:"post",text:`from ${e.value}`};case"subject":return{dimension:e.raw,position:"post",text:`about “${e.value}”`};case"before":return{dimension:e.raw,position:"post",text:`sent before ${e.value}`};case"after":return{dimension:e.raw,position:"post",text:`sent on or after ${e.value}`};case"in":return{dimension:e.raw,position:"post",text:`in ${e.value}`};case"account":return{dimension:e.raw,position:"post",text:`in the ${e.value} account`}}},es=(e,t)=>{const n=new Map,u=c=>{n.has(c.dimension)||n.set(c.dimension,c)},f=ee(e.category);f&&u({dimension:"category",position:"pre",text:f});for(const[c,p]of Je)e.attributes.has(c)&&u(p);for(const c of t)u(Ze(c));return[...n.values()]},ss=(e,t)=>{const n=es(e,t);if(n.length===0)return;const u=f=>n.filter(c=>c.position===f).map(c=>c.text);return[...u("pre"),"mail",...u("post")].join(" ")},ms=({chips:e,tokens:t,reach:n,onClear:u})=>{const f=ss(e,t);if(f)return{label:f,reach:n,onClear:u}};function xs({title:e,unreadCount:t,preset:n,selectedCategory:u,activeFilters:f,onSelectCategory:c,onToggleFilter:p,onSelectSource:w,onClearFilters:b,children:v,footer:x,searchResults:j,searchLoading:h,relatedResults:P,relatedLoading:S,onSelectSearchResult:N,searchResultsLabel:E,relatedResultsLabel:C,searchResultsInBody:k,refreshControl:r}){const{searchInput:d}=be(),y=d.trim().length>0,R={categories:n.categories,filters:n.filters,sources:n.sources,selectedCategory:u,activeFilters:f,onSelectCategory:c,onSelectSource:w,onToggleFilter:p,onClear:b};return s.jsx(ve,{hasSheet:!y,children:s.jsx(ze,{title:e,unreadCount:t,footer:x,searchFilter:R,searchResults:j,searchLoading:h,relatedResults:P,relatedLoading:S,onSelectSearchResult:N,searchResultsLabel:E,relatedResultsLabel:C,searchResultsInBody:k,refreshControl:r,children:s.jsx(je,{...R,hideChrome:y,children:v})})})}export{us as M,Ke as S,ds as a,xs as b,ms as l,fs as u};
|
|
1
|
+
import{j as s,L as le,f as $,a0 as ue,r as g,t as K,aB as de,a3 as fe,d7 as me,c3 as xe,eb as ge,ec as he,ed as pe,C as be,ee as ve,d8 as je}from"./index-D5g4bLbz.js";import{l as we,p as Ne}from"./search-token-index-C7IV79h1.js";import{u as ye,L as Q}from"./roving-focus-CYv4I8cF.js";import{a9 as Pe,aa as Re,c as Ce,a as G,ab as Se,o as Ee,ac as Me,ad as ke,ae as Ie,af as Le,ag as Te,ah as ee,ai as ze}from"./MailListHeader-E9QEtmIA.js";import{A as Ae}from"./avatar-DWygq3JL.js";import{M as Oe}from"./mail-BQpDNW0S.js";import{R as De}from"./refresh-cw-BVmX77aQ.js";import{M as $e}from"./menu-BpzHKPjy.js";function _e(){return s.jsx("div",{className:"space-y-0",role:"status","aria-busy":"true","aria-label":"Loading messages",children:Array.from({length:8}).map((e,t)=>s.jsxs("div",{className:"animate-pulse border-b border-line px-3 py-2",children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[s.jsx("div",{className:"h-4 w-32 rounded bg-surface-sunken"}),s.jsx("div",{className:"h-3 w-16 rounded bg-surface-sunken"})]}),s.jsx("div",{className:"mb-2 h-4 w-48 rounded bg-surface-sunken"}),s.jsx("div",{className:"h-3 w-full rounded bg-surface-sunken"})]},t))})}function Fe({filter:e,scopeLabel:t,searchQuery:n}){const u=n?.trim();return e?s.jsxs(q,{children:[s.jsx("p",{className:"font-medium text-fg",children:Be(e.label,t,u)}),s.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:He[e.reach]}),s.jsx($,{variant:"secondary",size:"sm",className:"mt-4",onClick:e.onClear,children:"Clear filter"})]}):s.jsx(q,{children:s.jsx("p",{className:"text-fg-muted",children:Xe(u,t)})})}const He={"whole-folder":"Every message in this folder was checked.","loaded-pages":"Only the messages loaded so far were checked."};function Xe(e,t){return e?"No messages match your search":t?`No messages in ${t}`:"No messages in this mailbox"}function Be(e,t,n){return n?`No results for “${n}” in ${e}`:t?`No ${e} in ${t}`:`No ${e}`}function q({children:e}){return s.jsx("div",{className:"flex h-full flex-1 items-center justify-center",children:s.jsx("div",{className:"flex max-w-sm flex-col items-center justify-center p-8 text-center",children:e})})}function us(){return s.jsxs("div",{className:"flex items-center justify-center gap-2 py-4 text-sm text-fg-muted",role:"status","aria-live":"polite",children:[s.jsx(le,{className:"size-4 animate-spin","aria-hidden":"true"}),s.jsx("span",{children:"Loading more…"})]})}function Ue({message:e="Something went wrong loading this mailbox.",onRetry:t,onReport:n}){return s.jsx("div",{className:"flex h-full flex-1 items-center justify-center p-4",children:s.jsxs("div",{role:"alert",className:"flex max-w-sm flex-col items-center justify-center gap-3 text-center",children:[s.jsx(ue,{className:"size-8 text-danger","aria-hidden":"true"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium text-danger",children:"Couldn't load messages"}),s.jsx("p",{className:"mt-1 break-words text-sm text-fg-muted",children:e})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[t&&s.jsx($,{variant:"secondary",size:"sm",onClick:t,children:"Retry"}),n&&s.jsx($,{variant:"ghost",size:"sm",onClick:n,children:"Report a problem"})]})]})})}const L=72,V=10,We=L/2,J="__swipeableRowAxisCancel";function Z(e){return e==="leading"?L:e==="trailing"?-L:0}function Ye(e){return e>=L/2?"leading":e<=-L/2?"trailing":"none"}function Ke({thread:e,selectionMode:t,checked:n,active:u,peek:f,onPeek:c,onToggleCheck:p,onLongPress:w,onOpen:b,onAct:v}){const x=g.useRef(null),[j,h]=g.useState(null),{longPressProps:P}=Pe({onLongPress:w,isDisabled:t,accessibilityDescription:"Select message"}),S=i=>{const o=new PointerEvent("pointercancel",{bubbles:!0});o[J]=!0,i.currentTarget.dispatchEvent(o)},r=Re(P,{onPointerDown:i=>{x.current={startX:i.clientX,startY:i.clientY,axis:"none",escaped:!1}},onPointerMove:i=>{if(t)return;const o=x.current;if(!o)return;const m=i.clientX-o.startX,M=i.clientY-o.startY;if(o.axis==="none"&&(Math.abs(M)>V&&Math.abs(M)>Math.abs(m)?o.axis="vertical":Math.abs(m)>V&&Math.abs(m)>Math.abs(M)&&(o.axis="horizontal",i.currentTarget.setPointerCapture(i.pointerId))),o.axis==="none")return;const T=o.axis==="horizontal"?Math.abs(m):Math.abs(M);if(!o.escaped&&T>We&&(o.escaped=!0,S(i)),o.axis!=="horizontal")return;const F=Z(f),H=Math.max(-L,Math.min(L,F+m));h(H)},onPointerUp:i=>{const o=x.current;x.current=null;const m=j;if(h(null),!!o){if(o.axis!=="none"&&!o.escaped&&S(i),o.axis==="horizontal"){m!==null&&c(Ye(m));return}if(o.axis!=="vertical"){if(t){p();return}if(f!=="none"){c("none");return}b()}}},onPointerCancel:i=>{i.nativeEvent[J]||(x.current=null,h(null))}}),d=j??Z(f),y=d>0?"leading":d<0?"trailing":"none",R=K("relative touch-pan-y bg-surface","select-none",Ce({active:n||u})),A={transform:d!==0?`translateX(${d}px)`:void 0,transition:j===null?"transform 150ms ease":"none",minHeight:44},_=!e.isRead,I=i=>i.stopPropagation(),O=t?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:K("inline-flex size-7 shrink-0 items-center justify-center rounded-full border",n?"border-accent bg-accent text-accent-fg":"border-line-strong bg-canvas"),children:n&&s.jsx(de,{className:"size-3.5"})}),s.jsx(G,{thread:e})]}):s.jsxs(s.Fragment,{children:[_&&s.jsx("span",{className:"absolute left-1.5 top-1/2 size-1.5 -translate-y-1/2 rounded-full bg-accent"}),s.jsx("span",{role:"checkbox",tabIndex:0,"aria-checked":n,"aria-label":`Select message from ${e.fromName}`,onPointerDown:I,onPointerMove:I,onPointerUp:I,onClick:i=>{i.preventDefault(),i.stopPropagation(),w()},onKeyDown:i=>{i.key!=="Enter"&&i.key!==" "||(i.preventDefault(),i.stopPropagation(),w())},className:"-m-2 inline-flex size-11 shrink-0 items-center justify-center rounded-full",children:s.jsx(Ae,{name:e.fromName,email:e.fromEmail,size:"sm"})}),s.jsx(G,{thread:e})]});return s.jsxs("div",{className:"relative overflow-hidden",children:[y==="leading"&&s.jsx("button",{type:"button",onClick:()=>v("leading"),"aria-label":e.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:e.isRead?s.jsx(Oe,{className:"size-6"}):s.jsx(Se,{className:"size-6"})}),y==="trailing"&&s.jsx("button",{type:"button",onClick:()=>v("trailing"),"aria-label":"Delete message",className:"absolute inset-y-0 right-0 flex items-center justify-end bg-danger px-6 text-canvas",children:s.jsx(fe,{className:"size-6"})}),s.jsx("button",{type:"button",role:t?"checkbox":void 0,"aria-checked":t?n:void 0,"data-message-row":!0,"data-message-id":e.id,...r,className:R,style:A,children:O})]})}function Qe({sections:e,selectedThreadId:t,selectionMode:n,checkedIds:u,initialPeek:f,onToggleCheck:c,onEnterSelection:p,onOpenThread:w,onRefresh:b,refreshing:v,busy:x=!1}){const[j,h]=g.useState(new Set),[P,S]=g.useState(new Map),N=e.flatMap(r=>r.threads).filter(r=>!j.has(r.id)).map(r=>{const d=P.get(r.id);return d===void 0?r:{...r,isRead:d}}),[E,C]=g.useState(f&&f!=="none"&&N[1]?{id:N[1].id,side:f}:null),k=(r,d)=>{if(d==="trailing")h(y=>new Set(y).add(r));else{const y=N.find(R=>R.id===r);S(R=>new Map(R).set(r,!y?.isRead))}C(null)};return s.jsxs("div",{className:"flex-1 overflow-y-auto",children:[v&&s.jsxs("div",{className:"flex items-center justify-center gap-2 border-b border-line py-3 text-fg-muted",children:[s.jsx(De,{className:"size-4 animate-spin"}),s.jsx("span",{className:"text-xs",children:"Checking for new mail…"})]}),s.jsx("div",{className:"divide-y divide-line",children:N.map(r=>s.jsx("div",{className:x?"pointer-events-none opacity-50":void 0,children:s.jsx(Ke,{thread:r,selectionMode:n,checked:u.has(r.id),active:r.id===t,peek:E?.id===r.id?E.side:"none",onPeek:d=>C(d==="none"?null:{id:r.id,side:d}),onToggleCheck:()=>c(r.id),onLongPress:()=>p(r.id),onOpen:()=>w(r.id),onAct:d=>k(r.id,d)})},r.id))}),!n&&!v&&!x&&s.jsx("button",{type:"button",onClick:b,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 Ge=new Set;function ds({listTitle:e,listMeta:t,sections:n,briefFilters:u,flatList:f,listState:c="ready",searchQuery:p,listFilter:w,listScopeLabel:b,errorMessage:v,onRetry:x,onReportError:j,briefFilter:h,selectedThreadId:P,density:S="comfortable",onSelectThread:N,onOpenNav:E,isDesktop:C,initialTouchState:k,selection:r,keyboard:d,selectionBar:y,paneOverlay:R,listBody:A,hideHeader:_=!1}){const I=S==="compact"?ke:Ie,O=g.useRef(null),i=g.useRef(null),o=me(d);ye({containerRef:O,itemSelector:Q,enabled:!o});const m=o?d.focusedId:void 0,M=o?m??n[0]?.threads[0]?.id:void 0,T=g.useCallback(a=>M===void 0?void 0:a===M?0:-1,[M]);g.useEffect(()=>{if(m===void 0)return;const a=i.current;if(!a)return;const l=a.querySelector(`${Q}[data-message-id="${m}"]`);!l||l===a.ownerDocument.activeElement||l.focus({preventScroll:!1})},[m]),g.useEffect(()=>{if(!o)return;const a=i.current;if(!a)return;const l=a.ownerDocument.activeElement;l!==null&&l!==a.ownerDocument.body||a.focus({preventScroll:!0})},[o]);const F=!C&&!u&&c==="ready",[H,W]=g.useState(!1),ae=k==="peek-trailing"?"trailing":k==="peek-leading"?"leading":void 0,re=()=>{W(!0),setTimeout(()=>W(!1),1400)},D=r?.selectedIds??Ge,z=r?.onToggle,Y=r?.onRowSelect,ie=Ee(D.size,C),X=g.useCallback(a=>{if(z)return{checked:D.has(a),onToggle:l=>{l.preventDefault(),l.stopPropagation(),z(a)}}},[D,z]),B=g.useCallback((a,l)=>Y?.(a,Me(l))?(l.preventDefault(),l.shiftKey&&window.getSelection()?.removeAllRanges(),!0):!1,[Y]),oe=g.useCallback(({thread:a,active:l,onClick:U})=>s.jsx(I,{thread:a,active:l,focused:a.id===m,tabIndex:T(a.id),selection:X(a.id),onClick:ce=>{B(a.id,ce)||U?.()}}),[I,X,B,m,T]);return s.jsxs("section",{ref:a=>{i.current=a,d?.ref(a)},tabIndex:o?-1:void 0,className:"relative flex h-full w-full flex-col bg-surface outline-none",children:[y??(_?null:s.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[E&&s.jsx($,{variant:"ghost",size:"sm",icon:s.jsx($e,{className:"size-4"}),onClick:E,"aria-label":"Open folders",className:"-ml-1 shrink-0"}),s.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:e}),t&&s.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle",children:t})]})),c==="loading"?s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsx(_e,{})}):c==="empty"?s.jsx(Fe,{filter:w,scopeLabel:b,searchQuery:p}):c==="error"?s.jsx(Ue,{message:v,onRetry:x,onReport:j}):u&&h?s.jsx(Le,{...h,sections:n,selectedThreadId:P,Row:oe,keyboard:d,onSelectThread:N}):A??(F?s.jsx(Qe,{sections:n,selectedThreadId:P,selectionMode:ie,checkedIds:D,initialPeek:ae,onToggleCheck:a=>z?.(a),onEnterSelection:a=>z?.(a),onOpenThread:a=>N?.(a),onRefresh:re,refreshing:H}):s.jsx("div",{ref:O,className:"flex-1 overflow-y-auto",children:n.map(a=>s.jsxs("div",{children:[!f&&a.label&&s.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:[s.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:a.label}),s.jsx("span",{className:"text-2xs text-fg-subtle tabular-nums",children:a.threads.length})]}),s.jsx("div",{className:"divide-y divide-line",children:a.threads.map(l=>s.jsx(I,{thread:l,active:l.id===P,focused:l.id===m,tabIndex:T(l.id),selection:X(l.id),onClick:U=>{B(l.id,U)||N?.(l.id)}},l.id))})]},a.id))})),C&&s.jsx(Te,{hints:d?Ne(d.handlers):we}),R]})}var qe=class extends xe{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type="infinite",super.setOptions(e)}getOptimisticResult(e){return e._type="infinite",super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){const{state:n}=e,u=super.createResult(e,t),{isFetching:f,isRefetching:c,isError:p,isRefetchError:w}=u,b=n.fetchMeta?.fetchMore?.direction,v=p&&b==="forward",x=f&&b==="forward",j=p&&b==="backward",h=f&&b==="backward";return{...u,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:he(t,n.data),hasPreviousPage:ge(t,n.data),isFetchNextPageError:v,isFetchingNextPage:x,isFetchPreviousPageError:j,isFetchingPreviousPage:h,isRefetchError:w&&!v&&!j,isRefetching:c&&!x&&!h}}};function fs(e,t){return pe(e,qe)}const se={dimension:"read",position:"pre",text:"unread"},Ve={dimension:"read",position:"pre",text:"read"},te={dimension:"starred",position:"pre",text:"starred"},ne={dimension:"attachment",position:"post",text:"with an attachment"},Je=[["unread",se],["flagged",te],["attachment",ne]],Ze=e=>{switch(e.type){case"category":return{dimension:"category",position:"pre",text:ee(e.category)??e.value};case"isUnread":return se;case"isRead":return Ve;case"isStarred":return te;case"hasAttachment":return ne;case"from":return{dimension:e.raw,position:"post",text:`from ${e.value}`};case"subject":return{dimension:e.raw,position:"post",text:`about “${e.value}”`};case"before":return{dimension:e.raw,position:"post",text:`sent before ${e.value}`};case"after":return{dimension:e.raw,position:"post",text:`sent on or after ${e.value}`};case"in":return{dimension:e.raw,position:"post",text:`in ${e.value}`};case"account":return{dimension:e.raw,position:"post",text:`in the ${e.value} account`}}},es=(e,t)=>{const n=new Map,u=c=>{n.has(c.dimension)||n.set(c.dimension,c)},f=ee(e.category);f&&u({dimension:"category",position:"pre",text:f});for(const[c,p]of Je)e.attributes.has(c)&&u(p);for(const c of t)u(Ze(c));return[...n.values()]},ss=(e,t)=>{const n=es(e,t);if(n.length===0)return;const u=f=>n.filter(c=>c.position===f).map(c=>c.text);return[...u("pre"),"mail",...u("post")].join(" ")},ms=({chips:e,tokens:t,reach:n,onClear:u})=>{const f=ss(e,t);if(f)return{label:f,reach:n,onClear:u}};function xs({title:e,unreadCount:t,preset:n,selectedCategory:u,activeFilters:f,onSelectCategory:c,onToggleFilter:p,onSelectSource:w,onClearFilters:b,children:v,footer:x,searchResults:j,searchLoading:h,relatedResults:P,relatedLoading:S,onSelectSearchResult:N,searchResultsLabel:E,relatedResultsLabel:C,searchResultsInBody:k,refreshControl:r}){const{searchInput:d}=be(),y=d.trim().length>0,R={categories:n.categories,filters:n.filters,sources:n.sources,selectedCategory:u,activeFilters:f,onSelectCategory:c,onSelectSource:w,onToggleFilter:p,onClear:b};return s.jsx(ve,{hasSheet:!y,children:s.jsx(ze,{title:e,unreadCount:t,footer:x,searchFilter:R,searchResults:j,searchLoading:h,relatedResults:P,relatedLoading:S,onSelectSearchResult:N,searchResultsLabel:E,relatedResultsLabel:C,searchResultsInBody:k,refreshControl:r,children:s.jsx(je,{...R,hideChrome:y,children:v})})})}export{us as M,Ke as S,ds as a,xs as b,ms as l,fs as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as r,bP as js,bZ as ws,b_ as Ms,cI as Rs,B as ft,f as Z,W as Es,t as Re,g as Wt,r as c,_ as Os,$ as As,br as Ns,cJ as Ge,h as wt,c as mt,ad as zs,i as Mt,cK as Fs,cE as Ds,I as _s,a7 as Ls,a3 as Kt,cL as Ps,cM as Vt,bT as $s,bl as Bs,cN as Ws,cO as Ks,at as qt,cP as Vs,cQ as qs,aZ as Hs,a_ as Qs,cR as Us,cS as Js,q as Rt,m as Gs,Q as Ht,bo as Ys,K as Zs,bp as Xs,bq as en,cT as tn,o as sn,E as nn,F as on,cU as rn,cC as an,s as ln,cV as cn,cW as un,cX as Qt,cY as Ut,C as Jt,ai as dn,cZ as hn,c_ as fn,ak as mn,bA as gn}from"./index-YYH_p-Ox.js";import{u as pn,p as Dt,R as xn}from"./useSearchTokenContext-DMTmSJiu.js";import{u as bn,a as vn,R as Sn}from"./useRefreshControl-B9v4eUjG.js";import{C as Gt,r as Et,a as Yt,c as Zt,j as yn,M as Cn,t as Xt,u as In,b as kn,d as es,e as ts,f as Tn,g as jn,h as wn,n as Mn,i as Rn,k as En,S as On,l as An,D as Nn,m as zn,o as Fn,p as ss,q as Dn,s as _n,v as Ln,w as Pn,x as $n,y as ns,z as Bn,A as Wn,B as Kn,E as Vn,F as qn,G as Hn,H as Qn,I as Un,J as Jn,K as _t,L as Lt,N as Gn,O as Yn,P as Zn,Q as Xn,R as eo,T as to,U as so,V as no,W as oo,X as io,Y as ro,Z as ao,_ as os,$ as is,a0 as rs,a1 as lo,a2 as co,a3 as uo,a4 as ho,a5 as fo,a6 as mo,a7 as go,a8 as po}from"./MailListHeader-D2YY1oCj.js";import{S as xo,M as bo,a as vo,u as So,l as yo,b as Co}from"./MailViewChrome-Ca_PpFLh.js";import{A as Ot}from"./avatar-C5DZJDZl.js";import{c as Io,f as ko,a as To,u as jo}from"./useMessageBodyContent-D-lqah5s.js";import{g as Ye,h as wo,i as Mo,j as Ro,k as Eo}from"./search-token-index-CF-eJ9n9.js";import{N as Oo}from"./NavMenuButton-UuS12b8o.js";import{C as Ao}from"./confirm-dialog-BV8yPk0Z.js";import{f as No}from"./ErrorState-Cjdi1Pbp.js";import{a as zo}from"./useLabels-D8sluUEk.js";import{L as Fo,r as Do,t as _o,s as Lo,u as Po}from"./useSemanticSearch-zOQZMrAG.js";import{S as gt}from"./shield-check-D9zGpyyh.js";import{B as $o}from"./bottom-sheet-BMfA1os-.js";import{C as Bo}from"./circle-help-PfoCuRx4.js";import{C as Wo}from"./circle-check-DsecdMli.js";import{u as Ko}from"./useLayoutTier-MqmqPhVY.js";import{n as Vo}from"./search-query-Cr_ZXBCp.js";import{u as qo}from"./sections-BZ0O_NV5.js";const Ho=e=>e.toLocaleString(),Qo=(e,o)=>{if(e.kind==="unknown")return`Results for “${o}”`;const t=e.value===1?"result":"results";return`${Ho(e.value)} ${t} for “${o}”`};function Uo({query:e,count:o}){return r.jsxs("div",{className:"flex items-center gap-2 border-b border-line bg-surface-sunken/30 px-3 py-2",children:[r.jsx(js,{className:"size-4 text-fg-muted","aria-hidden":"true"}),r.jsx("span",{className:"text-sm text-fg-muted",children:Qo(o,e)})]})}const Jo=({children:e,onRefresh:o,isRefreshing:t})=>ws(Ms)?e:r.jsx(Rs,{onRefresh:o,isPullable:!t,children:e}),Go=e=>e===1?"message":"messages";function Yo({count:e,onReview:o,onDismiss:t,actionLabel:s="Review & rescue"}){return r.jsx(ft,{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(gt,{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} ${Go(e)} here`})," ","may not be spam — they're from senders we can verify."]})]}),r.jsx(Z,{variant:"primary",size:"sm",onClick:o,className:"self-start",children:s})]})})}const Zo=(e,o)=>e==="vip"?"vip":e==="unknown"&&o==="md"?"unknown-pill":"hidden",as=({senderTrust:e,size:o="sm",className:t})=>{const s=Zo(e,o);return s==="vip"?r.jsx(Es,{className:Re("text-warning shrink-0",o==="sm"&&"size-3.5",o==="md"&&"size-4",t),"aria-label":"VIP sender","data-testid":"sender-trust-vip"}):s==="unknown-pill"?r.jsx("span",{className:Re("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 Xo({candidate:e,selected:o,onToggle:t,hideSender:s=!1}){const{senderName:n,senderAddress:i,subject:l,snippet:a,trustReason:u,trustSubReason:d,senderTrust:h}=e;return r.jsxs("label",{className:Re("flex w-full cursor-pointer items-start gap-3 px-3 py-2.5 text-left transition-colors",s&&"pl-11",o?"bg-positive/10":"bg-surface hover:bg-surface-sunken"),children:[r.jsx(Gt,{className:"mt-0.5",checked:o,onChange:t,"aria-label":`${o?"Deselect":"Select"} ${s?l:`message from ${n}`}`}),!s&&r.jsx(Ot,{name:n,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:n}),h&&r.jsx(as,{senderTrust:h,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(Wt,{tone:"positive",children:[r.jsx(gt,{className:"size-3","aria-hidden":!0}),u]}),r.jsx("span",{className:"text-2xs text-fg-subtle",children:d})]})]})]})}const ei=e=>{const o=new Map,t=[];for(const s of e){const n=(s.senderAddress||s.senderName).toLowerCase(),i=o.get(n);if(i){i.messages.push(s);continue}o.set(n,{key:n,senderName:s.senderName,senderAddress:s.senderAddress,trustReason:s.trustReason,trustSubReason:s.trustSubReason,senderTrust:s.senderTrust,messages:[s]}),t.push(n)}return t.map(s=>o.get(s)).sort((s,n)=>n.messages.length-s.messages.length)},ti=(e,o)=>{const t=e.messages.filter(s=>o.has(s.id)).length;return t===0?"none":t===e.messages.length?"all":"some"},Pt=e=>e===1?"message":"messages";function si({group:e,selected:o,onToggleGroup:t,onToggleMessage:s}){const[n,i]=c.useState(!1),l=ti(e,o),a=e.messages.length,u=n?Os:As;return r.jsxs("div",{className:Re(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(Gt,{className:"mt-0.5",checked:l==="all",indeterminate:l==="some",onChange:()=>t(e,l!=="all"),"aria-label":`${l==="all"?"Deselect":"Select"} all ${a} ${Pt(a)} from ${e.senderName}`}),r.jsx(Ot,{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(as,{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(Wt,{tone:"positive",children:[r.jsx(gt,{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":n,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} ${Pt(a)}`,r.jsx(u,{className:"size-3.5","aria-hidden":!0})]})]}),n&&r.jsx("div",{className:"divide-y divide-line border-t border-line",children:e.messages.map(d=>r.jsx(Xo,{candidate:d,selected:o.has(d.id),onToggle:()=>s(d.id),hideSender:!0},d.id))})]})}const At=e=>e===1?"message":"messages",ni=(e,o)=>`Moves ${e===1?"this message":`these ${e} ${At(e)}`} out of Spam to ${o} now. Nothing later.`,jt=(e,o)=>e.find(t=>t.id===o)?.label??"Inbox";function oi(){return r.jsx(ft,{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 ii({candidates:e,selected:o,onToggle:t,onToggleGroup:s,onSelectAll:n,onSelectNone:i,onContinue:l,onCancel:a}){const[u,d]=c.useState(!1),h=o.size,g=c.useMemo(()=>ei(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(gt,{className:"size-4 text-positive","aria-hidden":!0}),"Rescue from Spam"]}),r.jsx(Z,{variant:"ghost",size:"sm",icon:r.jsx(Bo,{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(oi,{})})]}),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:`${h} of ${e.length} selected · ${g.length} ${g.length===1?"sender":"senders"}`}),r.jsxs("span",{className:"flex gap-1",children:[r.jsx(Z,{variant:"ghost",size:"sm",onClick:n,children:"Select all"}),r.jsx(Z,{variant:"ghost",size:"sm",onClick:i,children:"Select none"})]})]}),r.jsx("div",{className:"min-h-0 flex-1 divide-y divide-line overflow-y-auto border-y border-line",children:g.map(m=>r.jsx(si,{group:m,selected:o,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(Z,{variant:"primary",onClick:l,className:"h-11 w-full font-semibold",children:`Continue with ${h} ${At(h)}`}),r.jsx(Z,{variant:"ghost",onClick:a,className:"h-11 w-full",children:"Cancel"})]})]})}function ri({count:e,folders:o,delimiter:t,destination:s,onPick:n,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(Ns,{folders:o,selectedId:s,delimiter:t,onSelect:n,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:jt(o,s)}),r.jsx(Z,{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:ni(e,jt(o,s))}),r.jsx(Z,{variant:"primary",onClick:i,className:"h-11 w-full font-semibold",children:`Move ${e} out of Spam`}),r.jsx(Z,{variant:"ghost",onClick:l,className:"h-11 w-full",children:"Back"})]})]})}function ai({count:e,destinationLabel:o,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(Wo,{className:"size-10 text-positive","aria-hidden":!0}),r.jsx("p",{className:"text-base font-semibold text-fg",children:`Moved ${e} ${At(e)} out of Spam.`}),r.jsx("p",{className:"text-2xs text-fg-subtle",children:`You'll find them in ${o}.`})]}),r.jsx("div",{className:"border-t border-line bg-surface px-row-inset py-3",children:r.jsx(Z,{variant:"primary",onClick:t,className:"h-11 w-full font-semibold",children:"Done"})})]})}function li({open:e,candidates:o,defaultDestinationId:t,availableFolders:s,delimiter:n,onConfirmMove:i,onCancel:l}){const[a,u]=c.useState("review"),[d,h]=c.useState(()=>e?new Set(o.map(k=>k.id)):new Set),[g,m]=c.useState(t),[p,S]=c.useState(0),y=c.useRef(!1);c.useEffect(()=>{e&&!y.current&&(u("review"),h(new Set(o.map(k=>k.id))),m(t),S(0)),y.current=e},[e,o,t]);const I=d.size,b=k=>{h(j=>{const O=new Set(j);return O.has(k)?O.delete(k):O.add(k),O})},x=(k,j)=>{h(O=>{const A=new Set(O);for(const B of k.messages)j?A.add(B.id):A.delete(B.id);return A})},w=()=>{const k=Array.from(d);S(k.length),i(k,g),u("done")};return r.jsxs($o,{open:e,onClose:l,label:"Rescue from spam",dismissLabel:"Close rescue",children:[a==="review"&&r.jsx(ii,{candidates:o,selected:d,onToggle:b,onToggleGroup:x,onSelectAll:()=>h(new Set(o.map(k=>k.id))),onSelectNone:()=>h(new Set),onContinue:()=>u("destination"),onCancel:l}),a==="destination"&&r.jsx(ri,{count:I,folders:s,delimiter:n,destination:g,onPick:m,onMove:w,onBack:()=>u("review")}),a==="done"&&r.jsx(ai,{count:p,destinationLabel:jt(s,g),onClose:l})]})}function ci(e){const o=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:o?`To: ${o}`:"(No recipients)",timeLabel:Ge(e.updatedAt),isRead:!0}}function ui(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:Ge(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,...Et(e)}}function di({outboxMessages:e,accountId:o,imapThreads:t}){const s=e.filter(l=>l.status==="draft"&&l.accountId===o).map(ci),n=t.map(ui),i=[];return s.length>0&&i.push({id:"remit-drafts",label:"Not yet sent (Remit)",threads:s}),n.length>0&&i.push({id:"imap-drafts",label:"On the server",threads:n}),i}const hi=({label:e,count:o})=>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:o})]}),fi=({row:e,isSelected:o,onOpen:t,onDelete:s,isDeleting:n})=>r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:Re("group",Zt({active:o})),children:[r.jsx(Ls,{className:"size-7 shrink-0 text-fg-muted mt-0.5"}),r.jsx(Yt,{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:n,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(Kt,{className:"size-3.5"})})})]}),mi=({row:e,isSelected:o,onOpen:t})=>{const s=!e.isRead;return r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:Re("group",Zt({active:o})),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(Ot,{name:e.fromName,email:e.fromEmail,size:"sm"}),r.jsx(Yt,{thread:e})]})};function gi({accountId:e,selectedMessageId:o,imapThreads:t,title:s,unreadCount:n}){const i=Io(),l=ko(),a=Ye(),u=wt(),{data:d}=mt(zs()),h=c.useMemo(()=>di({outboxMessages:d?.items??[],accountId:e,imapThreads:t}),[d?.items,e,t]),g=Mt({...Ds(),onSuccess:()=>{u.invalidateQueries({queryKey:Fs()})}}),m=y=>{g.mutate({path:{outboxMessageId:y}})},p=y=>{const I=t.find(b=>b.messageId===y)?.threadId;I&&a({threadId:I,messageId:y})},S=h.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:s}),(n??0)>0&&r.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:[n," unread"]})]}),r.jsx("div",{className:"flex-1 overflow-y-auto",children:S?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 text-center px-4",children:[r.jsx(_s,{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."})]}):h.map(y=>r.jsxs("div",{children:[y.label&&r.jsx(hi,{label:y.label,count:y.threads.length}),r.jsx("div",{className:"divide-y divide-line",children:y.threads.map(I=>y.id==="remit-drafts"?r.jsx(fi,{row:I,isSelected:I.id===i,onOpen:l,onDelete:m,isDeleting:g.isPending},I.id):r.jsx(mi,{row:I,isSelected:I.id===o,onOpen:p},I.id))})]},y.id))})]})}const ls=e=>e===1?"1 message":`${Vt(e)} messages`,pi=e=>({title:"Empty Trash?",description:`${ls(e)} ${e===1?"is":"are"} erased from the mail server and cannot be restored.`,confirmLabel:"Empty Trash"}),xi=(e,o={})=>{const{trashFolderLabel:t,staleFolderLabel:s}=o;if(e==="unconfirmed"){const n=Ps(0,"unconfirmed",{trashFolderLabel:t});return{headline:n.title,body:n.description,actionLabel:n.confirmLabel}}return e==="stale"?{headline:"Nothing was emptied.",body:s?`The folder you chose for Trash — ${s} — is gone from the mail server.`:"The folder you chose for Trash is gone from the mail server.",actionLabel:"Pick another folder"}:{headline:"Nothing was emptied.",body:"No folder on this account is set as Trash.",actionLabel:"Pick a folder"}};function bi({messageCount:e,isEmptying:o,deletedCount:t,refusalReason:s,trashFolderLabel:n,staleFolderLabel:i,onEmpty:l,onRepair:a,children:u}){const[d,h]=c.useState(!1);if(e<1&&s===void 0&&t===void 0)return r.jsx(r.Fragment,{children:u});const g=s?xi(s,{trashFolderLabel:n,staleFolderLabel:i}):void 0,m=pi(e);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.jsxs("div",{className:"flex flex-col gap-2 rounded-md border border-line px-3 py-2",children:[r.jsxs("div",{className:"flex items-center justify-end gap-2",children:[t!==void 0&&r.jsx("p",{className:"mr-auto text-2xs text-fg-subtle",role:"status",children:`${ls(t)} erased from the mail server.`}),r.jsx(Z,{variant:"ghost",size:"sm",icon:r.jsx(Kt,{className:"size-3.5","aria-hidden":!0}),disabled:o||e<1,"aria-busy":o,onClick:()=>h(!0),children:o?"Emptying…":"Empty Trash"})]}),g&&r.jsx(ft,{tone:"warning",variant:"soft",children:r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx("p",{className:"font-semibold text-fg",children:g.headline}),r.jsx("p",{className:"text-sm",children:g.body}),r.jsx(Z,{variant:"primary",size:"sm",className:"self-start",onClick:a,children:g.actionLabel})]})})]})}),r.jsx("div",{className:"min-h-0 flex-1",children:u}),r.jsx(Ao,{isOpen:d,title:m.title,description:m.description,confirmLabel:m.confirmLabel,destructive:!0,onConfirm:()=>{h(!1),l()},onCancel:()=>h(!1)})]})}function vi(e,o,t){const s=new Array(e);return new Proxy(s,{get(n,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=n[u];if(!d){const h=o[u*2];d=n[u]={index:u,key:t(u),start:h,size:o[u*2+1],end:h+o[u*2+1],lane:0}}return d}}if(i==="length")return e}return Reflect.get(n,i,l)}})}function Le(e,o,t){let s=t.initialDeps??[],n,i=!0;function l(){const a=e();return(a.length!==s.length||a.some((d,h)=>s[h]!==d))&&(s=a,n=o(...a),t?.onChange&&!(i&&t.skipInitialOnChange)&&t.onChange(n),i=!1),n}return l.updateDeps=a=>{s=a},l}function $t(e,o){if(e===void 0)throw new Error("Unexpected undefined");return e}const Si=(e,o)=>Math.abs(e-o)<1.01,yi=(e,o,t)=>{let s;return function(...n){e.clearTimeout(s),s=e.setTimeout(()=>o.apply(this,n),t)}};let Je;const kt=()=>{if(Je!==void 0)return Je;if(typeof navigator>"u")return Je=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Je=!0;const e=navigator.maxTouchPoints;return Je=navigator.platform==="MacIntel"&&e!==void 0&&e>0},Bt=e=>{const{offsetWidth:o,offsetHeight:t}=e;return{width:o,height:t}},Ci=e=>e,Ii=e=>{const o=Math.max(e.startIndex-e.overscan,0),s=Math.min(e.endIndex+e.overscan,e.count-1)-o+1,n=new Array(s);for(let i=0;i<s;i++)n[i]=o+i;return n},ki=(e,o)=>{const t=e.scrollElement;if(!t)return;const s=e.targetWindow;if(!s)return;const n=l=>{const{width:a,height:u}=l;o({width:Math.round(a),height:Math.round(u)})};if(n(Bt(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){n({width:d.inlineSize,height:d.blockSize});return}}n(Bt(t))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return i.observe(t,{box:"border-box"}),()=>{i.unobserve(t)}},ht={passive:!0},Ti=typeof window>"u"?!0:"onscrollend"in window,ji=(e,o,t)=>{const s=e.scrollElement;if(!s)return;const n=e.targetWindow;if(!n)return;const i=e.options.useScrollendEvent&&Ti;let l=0;const a=i?null:yi(n,()=>o(l,!1),e.options.isScrollingResetDelay),u=g=>()=>{l=t(s),a?.(),o(l,g)},d=u(!0),h=u(!1);return s.addEventListener("scroll",d,ht),i&&s.addEventListener("scrollend",h,ht),()=>{s.removeEventListener("scroll",d),i&&s.removeEventListener("scrollend",h)}},wi=(e,o)=>ji(e,o,t=>{const{horizontal:s,isRtl:n}=e.options;return s?t.scrollLeft*(n&&-1||1):t.scrollTop}),Mi=(e,o,t)=>{if(t.options.useCachedMeasurements){const s=t.indexFromElement(e),n=t.options.getItemKey(s);return t.itemSizeCache.get(n)??t.options.estimateSize(s)}if(o?.borderBoxSize){const s=o.borderBoxSize[0];if(s)return Math.round(s[t.options.horizontal?"inlineSize":"blockSize"])}if(!o){const s=t.indexFromElement(e),n=t.options.getItemKey(s),i=t.itemSizeCache.get(n);if(i!==void 0)return i}return e[t.options.horizontal?"offsetWidth":"offsetHeight"]},Ri=(e,{adjustments:o=0,behavior:t},s)=>{var n,i;(i=(n=s.scrollElement)==null?void 0:n.scrollTo)==null||i.call(n,{[s.options.horizontal?"left":"top"]:e+o,behavior:t})},Ei=Ri;class Oi{constructor(o){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,n;return((n=(s=(t=this.targetWindow)==null?void 0:t.performance)==null?void 0:s.now)==null?void 0:n.call(s))??Date.now()},this.observer=(()=>{let t=null;const s=()=>t||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:t=new this.targetWindow.ResizeObserver(n=>{n.forEach(i=>{const l=()=>{const a=i.target,u=this.indexFromElement(a);if(!a.isConnected){this.observer.unobserve(a);for(const[d,h]of this.elementsCache)if(h===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 n;(n=s())==null||n.disconnect(),t=null},observe:n=>{var i;return(i=s())==null?void 0:i.observe(n,{box:"border-box"})},unobserve:n=>{var i;return(i=s())==null?void 0:i.unobserve(n)}}})(),this.range=null,this.setOptions=t=>{var s,n;const i={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Ci,rangeExtractor:Ii,onChange:()=>{},measureElement:Mi,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 p=t[m];p!==void 0&&(i[m]=p)}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,p=i.count,S=this.getMeasurements(),y=m>0?((s=S[0])==null?void 0:s.key)??l.getItemKey(0):null,I=m>0?((n=S[m-1])==null?void 0:n.key)??l.getItemKey(m-1):null;if(p!==m||m>0&&p>0&&(i.getItemKey(0)!==y||i.getItemKey(p-1)!==I)){d=!0;const w=m>0?this.getVirtualItemForOffset(this.getScrollOffset())??S[0]:null;w&&(a=[w.key,this.getScrollOffset()-w.start]);const k=i.followOnAppend===!0?"auto":i.followOnAppend||null;k&&p>m&&this.isAtEnd(l.scrollEndThreshold)&&(m===0||i.getItemKey(p-1)!==I)&&(u=k)}}this.options=i,d&&(this.pendingMin=0,this.itemSizeCacheVersion++);let h=!1,g=0;if(a&&this.scrollOffset!==null){const[m,p]=a,S=this.getMeasurements(),{count:y,getItemKey:I}=this.options;let b=0;for(;b<y&&I(b)!==m;)b++;if(b<y){const x=S[b];if(x){const w=x.start+p;w!==this.scrollOffset&&(g=w-this.scrollOffset,this.scrollOffset=w,h=!0)}}}(h||u)&&(this.pendingScrollAnchor=[h?a[0]:null,h?a[1]:0,u,g])},this.notify=t=>{var s,n;(n=(s=this.options).onChange)==null||n.call(s,this,t)},this.maybeNotify=Le(()=>(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,!(!kt()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};i.addEventListener("touchstart",l,ht),i.addEventListener("touchend",a,ht),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 n=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,n&&this.scrollElement&&this.options.enabled){const[i,l,a,u]=n;i!==null&&!a&&(kt()&&(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 n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(t,{adjustments:this.scrollAdjustments+=n,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=Le(()=>[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,n,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:n,getItemKey:i,enabled:l,lanes:a,laneAssignmentMode:u,gap:d}),{key:!1}),this.getMeasurements=Le(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:t,paddingStart:s,scrollMargin:n,getItemKey:i,enabled:l,lanes:a,laneAssignmentMode:u,gap:d},h)=>{const g=this.itemSizeCache;if(!l)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>t)for(const b of this.laneAssignments.keys())b>=t&&this.laneAssignments.delete(b);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(b=>{this.itemSizeCache.set(b.key,b.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 b=t*2;let x=this._flatMeasurements;if(!x||x.length<b){const j=new Float64Array(b);x&&m>0&&j.set(x.subarray(0,m*2)),x=j,this._flatMeasurements=x}let w;if(m===0)w=s+n;else{const j=m-1;w=x[j*2]+x[j*2+1]+d}for(let j=m;j<t;j++){const O=i(j),A=g.get(O),B=typeof A=="number"?A:this.options.estimateSize(j);x[j*2]=w,x[j*2+1]=B,w+=B+d}const k=vi(t,x,i);return this.measurementsCache=k,k}const p=this.measurementsCache.slice(0,m),S=new Array(a).fill(void 0),y=new Float64Array(a);let I=0;for(let b=0;b<m;b++){const x=p[b];x&&(S[x.lane]===void 0&&I++,S[x.lane]=b,y[x.lane]=x.end)}for(let b=m;b<t;b++){const x=i(b),w=this.laneAssignments.get(b);let k,j;const O=u==="estimate"||g.has(x);if(w!==void 0&&this.options.lanes>1){k=w;const G=S[k],R=G!==void 0?p[G]:void 0;j=R?R.end+d:s+n}else if(I===a){let G=0,R=y[0],oe=S[0];for(let F=1;F<a;F++){const P=y[F];(P<R||P===R&&S[F]<oe)&&(G=F,R=P,oe=S[F])}k=G,j=R+d,O&&this.laneAssignments.set(b,k)}else k=b%this.options.lanes,j=s+n,O&&this.laneAssignments.set(b,k);const A=g.get(x),B=typeof A=="number"?A:this.options.estimateSize(b),J=j+B;p[b]={index:b,start:j,size:B,end:J,key:x,lane:k},S[k]===void 0&&I++,S[k]=b,y[k]=J}return this.measurementsCache=p,p},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Le(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,s,n,i)=>t.length===0||s===0?(this.range=null,null):(this.range=Ni(t,s,n,i,i===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Le(()=>{let t=null,s=null;const n=this.calculateRange();return n&&(t=n.startIndex,s=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,s]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,s]},(t,s,n,i,l)=>i===null||l===null?[]:t({startIndex:i,endIndex:l,overscan:s,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=t=>{const s=this.options.indexAttribute,n=t.getAttribute(s);return n?parseInt(n,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 n=this.scrollState.index??((s=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:s.index);if(n!==void 0&&this.range){const i=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),l=Math.max(0,n-i),a=Math.min(this.options.count-1,n+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),n=this.options.getItemKey(s),i=this.elementsCache.get(n);i!==t&&(i&&this.observer.unobserve(i),this.observer.observe(t),this.elementsCache.set(n,t)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(s)&&this.resizeItem(s,this.options.measureElement(t,void 0,this))},this.resizeItem=(t,s)=>{var n,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 h=this.itemSizeCache.get(u)??l,g=s-h;if(g!==0){const m=this.options.anchorTo==="end"&&((n=this.scrollState)==null?void 0:n.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,p=m?this.getTotalSize():0,S=((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},g,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()-p):S&&this.applyScrollAdjustment(g),this.notify(!1)}},this.getVirtualItems=Le(()=>[this.getVirtualIndexes(),this.getMeasurements()],(t,s)=>{const n=[];for(let i=0,l=t.length;i<l;i++){const a=t[i],u=s[a];n.push(u)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=t=>{const s=this.getMeasurements();if(s.length===0)return;const n=this._flatMeasurements,i=this.options.lanes===1&&n!=null,l=cs(0,s.length-1,i?a=>n[a*2]:a=>$t(s[a]).start,t);return $t(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,n=0)=>{if(!this.scrollElement)return 0;const i=this.getSize(),l=this.getScrollOffset();s==="auto"&&(s=t>=l+i?"end":"start"),s==="center"?t+=(n-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 n=this.getSize(),i=this.getScrollOffset(),l=this.measurementsCache[t];if(!l)return;if(s==="auto")if(l.end>=i+n-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:n="auto"}={})=>{const i=this.getOffsetForAlignment(t,s),l=this.now();this.scrollState={index:null,align:s,behavior:n,startedAt:l,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(t,{align:s="auto",behavior:n="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:n,startedAt:u,lastTargetOffset:l,stableFrames:0},this._scrollToOffset(l,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(t,{behavior:s="auto"}={})=>{const n=this.getScrollOffset()+t,i=this.now();this.scrollState={index:null,align:"start",behavior:s,startedAt:i,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{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 n;if(s.length===0)n=this.options.paddingStart;else if(this.options.lanes===1){const i=s.length-1,l=this._flatMeasurements;l!=null?n=l[i*2]+l[i*2+1]:n=((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--}n=Math.max(...i.filter(a=>a!==null))}return Math.max(n-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const t=[];if(this.itemSizeCache.size===0)return t;const s=this.getMeasurements();for(const n of s)n&&this.itemSizeCache.has(n.key)&&t.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return t},this._scrollToOffset=(t,{adjustments:s,behavior:n})=>{this._intendedScrollOffset=t+(s??0),this.options.scrollToFn(t,{behavior:n,adjustments:s},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(o)}applyScrollAdjustment(o,t){o!==0&&(kt()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=o:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=o,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,n=s?s[0]:this.scrollState.lastTargetOffset,i=1,l=n!==this.scrollState.lastTargetOffset;if(!l&&Si(n,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=i){this.getScrollOffset()!==n&&this._scrollToOffset(n,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,l){const a=this.getSize()||600,u=Math.abs(n-this.getScrollOffset()),d=this.scrollState.behavior==="smooth"&&u>a;this.scrollState.lastTargetOffset=n,d||(this.scrollState.behavior="auto"),this._scrollToOffset(n,{adjustments:void 0,behavior:d?"smooth":"auto"})}this.scheduleScrollReconcile()}}const cs=(e,o,t,s)=>{for(;e<=o;){const n=(e+o)/2|0,i=t(n);if(i<s)e=n+1;else if(i>s)o=n-1;else return n}return e>0?e-1:0};function Ai(e,o,t){let s=0;for(;s<=o;){const n=(s+o)/2|0,i=e[n*2];if(i<t)s=n+1;else if(i>t)o=n-1;else return n}return s>0?s-1:0}function Ni(e,o,t,s,n){const i=e.length-1;if(e.length<=s)return{startIndex:0,endIndex:i};if(s===1&&n!==null){const d=Ai(n,i,t);let h=d;const g=t+o;for(;h<i&&n[h*2]+n[h*2+1]<g;)h++;return{startIndex:d,endIndex:h}}let a=cs(0,i,d=>e[d].start,t),u=a;if(s===1)for(;u<i&&e[u].end<t+o;)u++;else if(s>1){const d=Array(s).fill(0);for(;u<i&&d.some(g=>g<t+o);){const g=e[u];d[g.lane]=g.end,u++}const h=Array(s).fill(t+o);for(;a>=0&&h.some(g=>g>=t);){const g=e[a];h[g.lane]=g.start,a--}a=Math.max(0,a-a%s),u=Math.min(i,u+(s-1-u%s))}return{startIndex:a,endIndex:u}}const Tt=typeof document<"u"?c.useLayoutEffect:c.useEffect;function zi({useFlushSync:e=!0,directDomUpdates:o=!1,directDomUpdatesMode:t="transform",...s}){const n=c.useReducer(d=>d+1,0)[1],i=c.useRef({enabled:o,mode:t,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});i.current.enabled=o,i.current.mode=t;const l=d=>{const h=i.current;if(!h.enabled||!h.container)return;const g=d.getTotalSize();if(g!==h.lastSize){h.lastSize=g;const b=d.options.horizontal?"width":"height";h.container.style[b]=`${g}px`}const m=!!d.options.horizontal,p=h.mode==="transform",S=m?"left":"top",y=d.options.scrollMargin,I=d.getVirtualItems();for(const b of I){const x=b.start-y,w=d.elementsCache.get(b.key);w&&h.lastPositions.get(w)!==x&&(h.lastPositions.set(w,x),p?w.style.transform=m?`translate3d(${x}px, 0, 0)`:`translate3d(0, ${x}px, 0)`:w.style[S]=`${x}px`)}},a={...s,onChange:(d,h)=>{var g;const m=i.current;let p=!0;if(m.enabled){l(d);const S=d.range,y=m.prevRange;p=!y||y.isScrolling!==d.isScrolling||y.startIndex!==S?.startIndex||y.endIndex!==S?.endIndex,p&&(m.prevRange=S?{startIndex:S.startIndex,endIndex:S.endIndex,isScrolling:d.isScrolling}:null)}p&&(e&&h?$s.flushSync(n):n()),(g=s.onChange)==null||g.call(s,d,h)}},[u]=c.useState(()=>{const d=new Oi(a);return Object.assign(d,{containerRef:h=>{const g=i.current;if(g.container=h,g.lastSize=null,h&&g.enabled){const m=d.getTotalSize();g.lastSize=m;const p=d.options.horizontal?"width":"height";h.style[p]=`${m}px`}}})});return u.setOptions(a),Tt(()=>u._didMount(),[]),Tt(()=>u._willUpdate()),Tt(()=>{l(u)}),u}function Fi(e){return zi({observeElementRect:ki,observeElementOffset:wi,scrollToFn:Ei,...e})}const Nt=e=>e.query?`matching "${e.query}"`:e.from?`from "${e.from}"`:"matching your search",Di=e=>`Select all ${Nt(e)}`,_i=(e,o)=>`All ${Vt(o)} ${Nt(e)} selected`,Li=({verb:e,confirmingDelete:o,hasSelection:t,junkMailboxId:s,currentMailboxId:n,deletableMessageId:i})=>{if(o)return{kind:"withheld"};if(e==="junk"){const l=yn(s,n);if(l!==void 0)return{kind:"unavailable",reason:l}}return t?{kind:"openWizard"}:e!=="delete"||i===void 0?{kind:"declined"}:{kind:"confirmDelete",messageId:i}},Pi=(e,o,t)=>e==="BACK"&&o&&t===void 0,$i=(e,o)=>({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:Ge(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:Xt(e.category),messageCount:o,suspicious:e.authenticity?.dkimMismatch===!0,labels:e.labels,...Et(e)}),Bi=({thread:e,mailboxId:o,isSelected:t,isFocused:s,isTabStop:n,onFocusRow:i,isChecked:l,onToggleCheck:a,onRowSelect:u,messageCount:d,isMultiSelectMode:h,onLongPress:g,isDesktop:m,density:p})=>r.jsx(Cn,{thread:$i(e,d),link:{mailboxId:o,threadId:e.threadId},inListbox:!0,active:t,focused:s,isTabStop:n,density:p,isDesktop:m,onFocusRow:i,selection:{isChecked:l,onToggleCheck:a,onRowSelect:u,isMultiSelectMode:h,onLongPress:g}}),Wi=c.memo(Bi),Ki=e=>{const o=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:Ge(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:Xt(e.category),suspicious:o,...Et(e)}},Vi=({thread:e,mailboxId:o,isSelected:t,isFocused:s,isTabStop:n,onFocusRow:i,isChecked:l,onToggleCheck:a,onRowSelect:u,isMultiSelectMode:d,onLongPress:h,isDesktop:g,onDelete:m,onToggleRead:p,density:S})=>{const[y,I]=c.useState("none"),b=Ye(),x=c.useCallback(A=>{navigator.vibrate?.(10),A==="trailing"?m(e.messageId):p(e.messageId,e.isRead),I("none")},[m,p,e.messageId,e.isRead]),w=c.useCallback(()=>{h(e.messageId)},[h,e.messageId]),k=c.useCallback(()=>{a(e.messageId)},[a,e.messageId]),j=c.useCallback(()=>{b({threadId:e.threadId,messageId:e.messageId})},[b,e.threadId,e.messageId]),O=In(e.messageId,u);return g||d?r.jsx(Wi,{thread:e,mailboxId:o,isSelected:t,isFocused:s,isTabStop:n,onFocusRow:i,isChecked:l,onToggleCheck:a,onRowSelect:u,isMultiSelectMode:d,onLongPress:h,isDesktop:g,density:S}):r.jsx("div",{role:"presentation",onPointerDownCapture:O.onMouseDown,onClickCapture:O.claimClick,onContextMenu:O.onContextMenu,children:r.jsx(xo,{thread:Ki(e),selectionMode:!1,checked:!1,active:t,peek:y,onPeek:I,onToggleCheck:k,onLongPress:w,onOpen:j,onAct:x})})},qi=72,Hi=32,Qi=5,us="remit:list-density",Ui=()=>{try{const e=localStorage.getItem(us);if(e==="compact"||e==="comfortable")return e}catch{}return"comfortable"},Ji=(e,o,t)=>Do(e.filter(s=>o.has(s.messageId)).map(s=>s.accountId??t)).moveDisabledHint,Gi=({mailboxId:e,threads:o,selectedMessageId:t,isLoading:s,isError:n=!1,error:i,onRetry:l,searchQuery:a,searchPredicate:u,resultCount:d={kind:"unknown"},onDeleteMessages:h,isDeleting:g=!1,isMoving:m=!1,onLoadMore:p,hasMore:S=!1,isLoadingMore:y=!1,accountId:I,listTitle:b,listMeta:x,listFilter:w,listSearchText:k,listScopeLabel:j,onTriageContextChange:O,commandsRef:A,hideHeader:B=!1})=>{const J=c.useRef(null),G=Ye(),R=Bs(),oe=Ws(),{verb:F,start:P,startFromSearch:Ee}=oe,Se=Ks(),ye=!!a?.trim(),W=kn(),{labels:Pe}=zo(I),{pushError:ie}=qt(),[M,Ce]=c.useState(t),[Oe,Ie]=c.useState(),N=c.useCallback(f=>{Ie(v=>v===f?v:void 0),Ce(f)},[]),[X,$e]=c.useState(Ui),K=c.useCallback(()=>{$e(f=>{const v=f==="comfortable"?"compact":"comfortable";try{localStorage.setItem(us,v)}catch{}return v})},[]),{toggleReadFor:ke}=es({mailboxId:e}),{junkMailboxId:fe}=ts(I),me=ss(fe,e),Ae=c.useMemo(()=>[{accountId:I,mailboxId:e}],[I,e]),{outcome:re,staleFolderLabel:Be,guessedMailboxId:Ne}=Tn(Ae),{selectedIds:z,selectedCount:_,hasSelection:ne,isSelected:ee,toggle:Y,select:Te,clearSelection:je,selectRange:ge,setAnchor:V,selectAll:pe,toggleAll:te,intersectWith:Ze}=jn(),We=Fn(_,R),[xe,E]=c.useState(null),Xe=c.useCallback((f,v,he)=>{const Q=Vs(f,v,he,re);Q&&ie(Q)},[ie,re]),we=ye&&!!u,et=`${e}|${JSON.stringify(u??{})}`,T=wn({mailboxId:e,mailboxLabel:b,accountId:I,enabled:we,predicateKey:et,searchQuery:u??{},reportEnding:Xe}),tt=T.phase.kind,Ke=T.clear,L=c.useCallback(()=>{tt==="escalated"&&Ke(),je()},[je,Ke,tt]),[st,ae]=c.useState(null),be=c.useRef(null),le=c.useRef(!1),ze=c.useRef(null),Me=!s&&o.length>0,ce=Fi({count:o.length,getScrollElement:()=>J.current,estimateSize:()=>X==="compact"?Hi:qi,overscan:Qi}),Ve=t?o.findIndex(f=>f.messageId===t):-1,q=M?o.findIndex(f=>f.messageId===M):-1,se=c.useCallback(f=>{if(f<0||f>=o.length)return;const v=o[f];if(We){Y(v.messageId);return}be.current=v.messageId,le.current=!1,Ie(v.messageId),Ce(v.messageId)},[o,We,Y]),Fe=c.useCallback(()=>{if(o.length===0)return;const f=q<0?0:Math.min(q+1,o.length-1);se(f)},[o.length,q,se]),nt=c.useCallback(()=>{if(o.length===0)return;const f=q<=0?0:q-1;se(f)},[o.length,q,se]),qe=c.useCallback(()=>se(0),[se]),He=c.useCallback(()=>se(o.length-1),[se,o.length]),ve=c.useCallback(()=>{M&&Y(M)},[M,Y]),D=c.useMemo(()=>o.map(f=>f.messageId),[o]),De=c.useMemo(()=>{const f=[];for(const v of o)z.has(v.messageId)&&f.push({id:v.messageId,sender:v.fromName??v.fromEmail??"Unknown",email:v.fromEmail??"",subject:v.subject??"(No subject)",date:Ge(v.sentDate),accountId:I});return f},[o,z,I]),xt=c.useCallback((f,v)=>v.shiftKey?(ge(D,f,M),!0):v.metaKey||v.ctrlKey?(Y(f),!0):(L(),V(f),!1),[D,M,ge,Y,L,V]),ot=c.useCallback(f=>{!h||f.length===0||(ze.current=M??null,E(f))},[h,M]),_e=c.useCallback(f=>{const v=Mn(D,M,f);v!==void 0&&(ge(D,v),be.current=v,le.current=!1,Ie(void 0),Ce(v))},[D,M,ge]),ue=c.useCallback(()=>_e(-1),[_e]),it=c.useCallback(()=>_e(1),[_e]),rt=c.useCallback(()=>{D.length>0&&pe(D)},[D,pe]),at=c.useCallback(f=>{const v=Li({verb:f,confirmingDelete:xe!==null,hasSelection:ne,junkMailboxId:fe,currentMailboxId:e,deletableMessageId:h?M:void 0});return v.kind==="openWizard"?(P(f),!0):v.kind==="confirmDelete"?(ot([v.messageId]),!0):v.kind==="unavailable"?(ie({severity:"warning",title:v.reason}),!0):v.kind==="withheld"},[xe,h,ne,fe,e,P,M,ot,ie]),de=c.useCallback((f,v)=>{const he=o.find(Q=>Q.messageId===f)?.threadId;he&&G({threadId:he,messageId:f},{replace:v?.replace})},[G,o]),lt=c.useCallback(()=>{M&&de(M)},[M,de]),bt=c.useCallback(f=>de(f,{replace:!0}),[de]);Rn({keyboardFocusedMessageId:Oe,openMessageId:t,enabled:R&&_===0,open:bt});const Qe=T.phase.kind==="escalated"?{scope:Nt(u??{}),total:T.phase.total,searchQuery:u??{},run:(f,v)=>T.runAction(f,void 0,v),stop:T.stop}:void 0,ct=c.useCallback(f=>{if(f.length===0){E(null);return}const v=new Set(f),he=o.findIndex(U=>v.has(U.messageId));let Q;for(let U=he+1;U<o.length;U++)if(!v.has(o[U].messageId)){Q=o[U].messageId;break}if(Q===void 0){for(let U=he-1;U>=0;U--)if(!v.has(o[U].messageId)){Q=o[U].messageId;break}}h?.(f),L(),ze.current=null,E(null),Q!==void 0&&(be.current=Q,le.current=!1,N(Q),R&&de(Q,{replace:!0})),R||ae(qs("delete",f.length,re))},[o,h,L,de,R,N,re]),ut=c.useCallback(()=>{const f=ze.current;ze.current=null,E(null),f!==null&&(be.current=f,le.current=!1,N(f))},[N]),Ue=c.useMemo(()=>Ji(o,z,I),[I,z,o]),vt=c.useCallback(()=>{if(Qe){Ee();return}P("organize")},[Qe,Ee,P]),St=c.useCallback(f=>{h?.([f])},[h]),dt=c.useCallback((f,v)=>{ke([f],!v)},[ke]),yt=c.useCallback(f=>{R||Te(f)},[R,Te]),C=c.useCallback(()=>{if(T.isRunning||T.phase.kind==="counting"){T.stop();return}L()},[T,L]),H=c.useCallback(()=>{T.clear()},[T]);c.useEffect(()=>{if(le.current||!R&&t)return;const f=q>=0?q:Ve;f>=0&&ce.scrollToIndex(f,{align:"auto"})},[q,Ve,ce,R,t]),c.useEffect(()=>{t&&(le.current=!1,N(t))},[t,N]),c.useEffect(()=>{M&&(o.some(f=>f.messageId===M)||N(o[0]?.messageId))},[o,M,N]),c.useEffect(()=>{O?.({focusedMessageId:M,selectedIds:Array.from(z),hasList:Me})},[M,z,Me,O]);const $=c.useRef(O);$.current=O,c.useEffect(()=>()=>$.current?.({focusedMessageId:void 0,selectedIds:[],hasList:!1}),[]),c.useEffect(()=>{T.phase.kind!=="idle"||T.isRunning||Ze(o.map(f=>f.messageId))},[o,Ze,T.phase,T.isRunning]);const zt=c.useRef(e);c.useEffect(()=>{zt.current!==e&&(zt.current=e,L())},[e,L]),En({shouldBlockFn:({action:f})=>Pi(f,ne,Se)?(L(),!0):!1,enableBeforeUnload:!1,disabled:!ne||Se!==void 0}),c.useEffect(()=>{const f=J.current;if(!f||!S||!p)return;const v=()=>{if(y)return;const{scrollTop:he,scrollHeight:Q,clientHeight:U}=f;he+U>=Q-200&&p()};return f.addEventListener("scroll",v,{passive:!0}),v(),()=>f.removeEventListener("scroll",v)},[S,y,p]),c.useEffect(()=>{const f=be.current;if(!f)return;const v=J.current?.querySelector(`[data-message-id="${f}"]`);v&&(be.current=null,v.focus({preventScroll:!0}))}),c.useEffect(()=>{if(A){if(!Me){A.current=null;return}return A.current={focusNext:Fe,focusPrevious:nt,focusFirst:qe,focusLast:He,openFocused:lt,toggleSelect:ve,extendSelectDown:it,extendSelectUp:ue,selectAll:rt,clearSelection:()=>ne?(L(),!0):!1,requestVerb:at,toggleDensity:K},()=>{A.current=null}}},[A,Me,Fe,nt,qe,He,lt,ve,it,ue,rt,ne,L,at,K]);const Ft=s?"loading":n?"error":o.length===0?"empty":"ready",fs=n?No(i):void 0,ms=c.useCallback(()=>{const f=Hs(Qs());window.open(f,"_blank","noopener,noreferrer")},[]),gs=[{id:"inbox",threads:[]}],Ct=D.length>0&&D.every(f=>z.has(f)),ps=we&&S&&Ct&&!g&&!m&&T.phase.kind==="idle"&&!T.isRunning,xs=g||m||T.isRunning,It=T.phase.kind==="escalated"?T.phase.total:T.progress?T.progress.total:_,bs=T.runningAction?Us(T.runningAction.kind,T.progress?.done??0,T.progress?.total??It):T.phase.kind==="counting"?"Counting matches…":T.phase.kind==="escalated"?_i(u??{},T.phase.total):void 0,vs=T.phase.kind!=="escalated"&&D.length>0?{checked:Ct,indeterminate:_>0&&!Ct,onChange:()=>te(D)}:void 0,Ss=T.runningAction?{value:T.progress?.done??0,max:T.progress?.total??It,tone:Js(T.runningAction.kind)}:void 0,ys=(T.isRunning||T.phase.kind==="counting"?{tone:"info",text:"",action:{label:"Stop",onClick:T.stop}}:T.phase.kind==="escalated"?{tone:"info",text:"",action:{label:"Clear selection",onClick:H}}:ps?{tone:"info",text:"",action:{label:Di(u??{}),onClick:T.escalate}}:void 0)??(Ue?{tone:"warning",text:Ue}:void 0),Cs=r.jsx(On,{title:W.title||b,navSlot:W.navSlot,titleMeta:W.titleMeta,searchSlot:W.searchSlot,searchField:W.searchField,idleSlot:W.makeFilterSlot,count:It,onCancel:C,onDelete:()=>P("delete"),onMove:()=>P("move"),onOrganize:vt,onJunk:me?()=>P("junk"):void 0,onMarkRead:()=>P("markRead"),overflowSlot:I&&e&&_>0&&Pe.length>0?r.jsx(Fo,{accountId:I,mailboxId:e,messageIds:Array.from(z)}):void 0,isBusy:xs,isCounting:T.phase.kind==="counting",selectAll:vs,statusLabel:bs,progress:Ss,notice:ys}),Is=An(D,M),ks=c.useCallback(f=>{le.current=!0,N(f)},[N]),Ts=r.jsxs(r.Fragment,{children:[ye&&a&&r.jsx(Uo,{query:a,count:d}),r.jsxs("div",{ref:J,role:"listbox","aria-multiselectable":!0,"aria-label":b,className:"flex-1 overflow-y-auto",children:[r.jsx("div",{role:"presentation",className:"relative w-full",style:{height:`${ce.getTotalSize()}px`},children:ce.getVirtualItems().map(f=>{const v=o[f.index];return r.jsx("div",{role:"presentation","data-index":f.index,ref:ce.measureElement,className:Re("absolute left-0 top-0 w-full border-b border-line",T.isRunning&&"pointer-events-none opacity-50"),style:{transform:`translateY(${f.start}px)`},children:r.jsx(Vi,{thread:v,mailboxId:e,isSelected:t===v.messageId,isFocused:M===v.messageId,isTabStop:Is===v.messageId,onFocusRow:ks,isChecked:ee(v.messageId),onToggleCheck:Y,onRowSelect:xt,isMultiSelectMode:We,onLongPress:yt,isDesktop:R,onDelete:St,onToggleRead:dt,density:X})},f.key)})}),y&&r.jsx(bo,{})]})]});return r.jsxs(r.Fragment,{children:[st&&!R&&r.jsx(ft,{tone:"success",variant:"soft",className:"m-2 rounded-md",onDismiss:()=>ae(null),children:st}),r.jsx(vo,{listTitle:b,listMeta:x,sections:gs,flatList:!0,listState:W.searchResults?"ready":Ft,searchQuery:k,listFilter:w,listScopeLabel:j,errorMessage:fs,onRetry:l,onReportError:ms,density:X,selectedThreadId:t,onSelectThread:f=>de(f),isDesktop:R,hideHeader:B,selectionBar:Cs,listBody:W.searchResults??(Ft==="ready"?Ts:void 0)}),r.jsx(Nn,{isOpen:xe!==null,messageIds:xe??[],outcome:re,accountId:I,trashFolderLabel:b,staleFolderLabel:Be,guessedMailboxId:Ne,isDeleting:g,onConfirm:ct,onCancel:ut}),r.jsx(zn,{verb:F,accountId:I,mailboxId:e,mailboxLabel:b,selection:De,selectionRestriction:Ue?"spansAccounts":void 0,escalated:Qe,escalatedProgress:T.progress,onFinished:L,onRunEnded:Xe})]})},Yi=e=>Ht({path:{accountId:e}}),Zi=e=>{const o=wt(),t=Rt(),s=Mt({...Gs(),onSuccess:()=>{t.recordEvent("sync.triggered"),o.invalidateQueries({queryKey:Yi(e)})}});return{trigger:()=>{s.mutate({path:{accountId:e}})},triggerAsync:()=>s.mutateAsync({path:{accountId:e}}),isPending:s.isPending,error:s.error,reset:s.reset}},Xi=({accountId:e,children:o})=>{const{triggerAsync:t,isPending:s}=Zi(e);return r.jsx(Jo,{onRefresh:t,isRefreshing:s,children:o})};function er({accountId:e,currentMailboxId:o,candidates:t,onMove:s,children:n}){const[i,l]=c.useState(!1),a=Rt(),u=Ys(),{inboxMailboxId:d}=Dn(e),h=_n(e),{data:g}=mt({...Zs({path:{accountId:e}}),staleTime:1/0}),m=c.useMemo(()=>Xs({mailboxes:g?.items??[],folderAppointments:h,currentMailboxId:o,translator:u}),[g?.items,h,o,u]),p=c.useMemo(()=>d||(m.find(x=>x.label.toLowerCase()==="inbox")?.id??m.find(x=>!x.isCurrent)?.id??""),[d,m]),S=c.useRef(!1);c.useEffect(()=>{S.current||(S.current=!0,Ln(a,t.length))},[a,t.length]);const y=c.useCallback(()=>{Pn(a,t.length),l(!0)},[a,t.length]),I=c.useCallback((b,x)=>{$n(a,{selected:b.length,total:t.length,toInbox:x===d}),s(b,x)},[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(Yo,{count:t.length,onReview:y})}),r.jsx("div",{className:"min-h-0 flex-1",children:n}),r.jsx(li,{open:i,candidates:t,defaultDestinationId:p,availableFolders:m,delimiter:en(g?.items??[]),onConfirmMove:I,onCancel:()=>l(!1)})]})}const tr=(e,o,t,s)=>`${e??""}|${o}|${t??""}|${s??""}`,sr=({accountId:e,mailboxId:o})=>{const t=wt(),{pushError:s}=qt(),{requestAppointment:n}=tn(),{trashByAccount:i}=ns(),l=e?i.get(e):void 0,a=tr(e,o,l?.mailboxId,l?.source),[u,d]=c.useState({scope:a});u.scope!==a&&d({scope:a});const h=u.scope===a?u:void 0,g=c.useCallback(()=>t.getQueryData(sn())?.accounts.find(j=>j.accountId===e)?.folderAppointments.find(j=>j.role==="Trash")?.mailboxId??o,[t,e,o]),m=c.useRef(void 0),{mutateAsync:p,isPending:S}=Mt({...cn(),meta:ln(409),onMutate:()=>(m.current=a,{scope:a,listMailboxId:g()}),onSuccess:(x,w,k)=>{k.scope===a&&d({scope:a,deletedCount:x.deletedCount})},onError:(x,w,k)=>{const j=rn(x);if(!j){s({title:"Couldn't empty Trash",detail:an(x),error:x});return}k?.scope===a&&d({scope:a,refusal:j})},onSettled:(x,w,k,j)=>{m.current===j?.scope&&(m.current=void 0),nn(t,on([j?.listMailboxId??o])),e&&t.invalidateQueries({queryKey:Ht({path:{accountId:e}})})}}),y=c.useCallback(()=>e?(d({scope:a}),p({path:{accountId:e}}).then(()=>{},()=>{})):Promise.resolve(),[e,a,p]),I=c.useCallback(()=>{y()},[y]),b=c.useCallback(()=>{const x=h?.refusal;x&&n({accountId:x.accountId,role:x.role,reason:x.reason,action:{kind:"emptyTrash"},onAppointed:y})},[h,n,y]);return{emptyTrash:I,isEmptying:S&&m.current===a,deletedCount:h?.deletedCount,refusal:h?.refusal,repair:b}},nr="We can verify this sender";function or(e){const{data:o}=mt({...un({path:{mailboxId:e??""},query:{senderTrust:["vip","wellknown"],dkimMismatch:!1,results:!0,limit:500}}),enabled:!!e,staleTime:6e4});return{candidates:(o?.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:nr,trustSubReason:Bn(s.senderTrust),senderTrust:s.senderTrust}))}}const ir=6e4,rr=({mailboxId:e,criteria:o,enabled:t})=>{const s={...o,count:!0,results:!1},{data:n}=mt({queryKey:Qt({path:{mailboxId:e},query:s}),queryFn:async()=>{const{data:i}=await Ut({path:{mailboxId:e},query:s,throwOnError:!0});return i},enabled:t,staleTime:ir});return t?_o(n?.count):{kind:"unknown"}},ar=e=>{const o=new Set,t=[];for(const s of e)o.has(s.threadMessageId)||(o.add(s.threadMessageId),t.push(s));return t},lr=50,ds=c.createContext(null);function pt(){const e=c.useContext(ds);if(!e)throw new Error("MailboxPane.* must be used inside <MailboxPane>");return e}function cr({mailboxId:e,thread:o,children:t}){const s=Ye(),n=wo(),i=qo(),l=o?.threadId,a=o?.messageId,u=Rt(),{accounts:d,searchQuery:h,onToggleIntelligence:g,onSearchClearQuery:m}=Jt(),p=pn(),S=Vo(h),y=S.length>0,{freeText:I,tokens:b}=Dt(S,p),x=Dt(h.trim(),p).freeText,[w,k]=c.useState("all"),[j,O]=c.useState(new Set),A=c.useMemo(()=>({category:w,attributes:j}),[w,j]),B=c.useMemo(()=>Wn(A),[A]),J=y||Kn(A),{params:G,residual:R}=Vn(b,B),oe={order:"desc",...I?{query:I}:{},...G,...B},F={...oe,limit:lr},P={category:F.category,unread:F.unread,starred:F.starred,attachments:F.attachments},Ee=J?Qt({path:{mailboxId:e},query:F}):dn({path:{mailboxId:e},query:{order:"desc"}}),{data:Se,isLoading:ye,isError:W,error:Pe,refetch:ie,fetchNextPage:M,hasNextPage:Ce,isFetchingNextPage:Oe}=So({queryKey:Ee,queryFn:async({pageParam:C})=>{if(J){const{data:$}=await Ut({path:{mailboxId:e},query:{...F,continuationToken:C},throwOnError:!0});return $}const{data:H}=await gn({path:{mailboxId:e},query:{order:"desc",continuationToken:C},throwOnError:!0});return H},initialPageParam:void 0,getNextPageParam:C=>C.continuationToken,placeholderData:(C,H)=>po(H?.queryKey,P)?C:void 0}),Ie=rr({mailboxId:e,criteria:oe,enabled:Lo({hasSearchQuery:y,freeText:I,residualTokenCount:R.length})}),{accountId:N,isLoading:X}=qn(e),$e=Mo({accounts:d}),K=Hn(Qn(ar(Se?.pages.flatMap(C=>C.items??[])??[])),R,N),ke=c.useCallback(C=>{k(C)},[]),fe=c.useCallback(C=>{O(H=>{const $=new Set(H);return $.has(C)?$.delete(C):$.add(C),$})},[]),me=c.useCallback(()=>{k("all"),O(new Set)},[]),Ae=c.useCallback(()=>{me(),m()},[me,m]),re=yo({chips:A,tokens:b,reach:R.length>0?"loaded-pages":Un(F),onClear:Ae}),Be=l?K.find(C=>C.messageId===a)??K.find(C=>C.threadId===l):void 0,Ne=Jn(l,a),z=Be??Ne,_=a??z?.messageId,ne=c.useMemo(()=>{if(l)return{threadId:l,mailboxId:z?.mailboxId??e,subject:z?.subject,messageId:_,authenticity:z?.authenticity}},[l,z,_,e]),ee=c.useCallback(C=>{_&&C.includes(_)&&n()},[_,n]),{deleteMessages:Y,isPending:Te}=_t({mailboxId:e,onAfterOptimisticRemove:ee}),{moveMessages:je,isPending:ge}=Lt({mailboxId:e,accountId:N,onAfterOptimisticRemove:ee}),V=c.useRef(null),pe=Gn(),{listCommandsRef:te,onTriageContextChange:Ze,focusedMessageId:We,selectedIds:xe}=pe,E=K.find(C=>C.messageId===We)??z,Xe=Ro({accounts:d})??null,we=Yn({thread:z,isOpen:!0,mailboxId:e,accountId:N,onAfterOptimisticRemove:ee}),{draftsMailboxId:et}=Zn(N),T=et!==void 0&&et===e,{archiveMailboxId:tt}=Xn(N),Ke=eo(),L=hn(),st=c.useMemo(()=>fn(L,l,_),[L,l,_]),ae=c.useMemo(()=>{if(E)return C=>L({threadId:E.threadId,messageId:E.messageId,mode:C})},[L,E]),be=To(),le=mn(),ze=jo(),Me=c.useCallback(C=>C?Ke(C):[],[Ke]),{toggleStar:ce}=to({threadId:E?.threadId??"",mailboxId:e}),{toggleReadFor:Ve}=es({mailboxId:e,accountId:N}),{junkMailboxId:q}=ts(N),se=q!=null&&q===e,Fe=ss(q,e),{candidates:nt}=or(se?q:void 0),{moveMessages:qe}=Lt({mailboxId:e,threadId:E?.threadId,accountId:N,onAfterOptimisticRemove:ee}),{deleteMessages:He}=_t({mailboxId:e,threadId:E?.threadId,onAfterOptimisticRemove:ee}),{addressId:ve,address:D}=so(E),{updateFlags:De}=no({addressId:ve,senderEmail:E?.fromEmail??void 0}),xt=c.useCallback(()=>ae?.("reply"),[ae]),ot=c.useCallback(()=>ae?.("reply-all"),[ae]),_e=c.useCallback(()=>ae?.("forward"),[ae]),ue=c.useCallback(()=>Me(E),[Me,E]),it=c.useCallback(()=>{if(te.current?.requestVerb("delete"))return;const C=ue();C.length>0&&He(C)},[te,ue,He]),rt=c.useCallback(()=>{if(te.current?.requestVerb("junk")||!Fe)return;const C=ue();C.length!==0&&(oo(u,{count:C.length,senderTrust:E?.senderTrust??"unknown",wasRescuable:E?io(E):!1}),qe(C,Fe))},[te,Fe,ue,qe,u,E]),at=c.useCallback(()=>{if(xe.length>0){const C=!(E?.hasStars??!1),H=new Set(xe);for(const $ of K)H.has($.messageId)&&$.hasStars!==C&&ce($.messageId,$.hasStars);return}E&&ce(E.messageId,E.hasStars)},[xe,K,E,ce]),de=c.useCallback(()=>{if(te.current?.requestVerb("markRead"))return;const C=ue();if(C.length===0)return;const H=!(E?.isRead??!1);Ve(C,H)},[te,ue,E,Ve]),lt=c.useCallback(()=>{if(!ve)return;const C=D?.flags?.muted?.value!==!0;De({muted:{value:C}})},[ve,D,De]),bt=c.useCallback(()=>{if(!ve)return;const C=D?.flags?.vip?.value!==!0;De({vip:{value:C}})},[ve,D,De]),Qe=c.useCallback(()=>{V.current?.open()},[]),ct=T?"drafts":tt===e?"archive":q===e?"junk":"inbox",ut=c.useRef("");c.useEffect(()=>{const C=ut.current;ut.current=S,S.length>0&&C.length===0&&u.recordEvent("search.submitted",{mailboxType:ct})},[S,ct,u]);const{goBack:Ue,nextMessageId:vt,previousMessageId:St}=ro({context:pe,orderedIds:K.map(C=>C.messageId),selectedMessageId:_,enabled:!be&&!le,hasOpenThread:l!==void 0,onClose:n,handlers:{reply:xt,replyAll:ot,forward:_e,delete:it,toggleStar:at,toggleRead:de,muteSender:lt,blockSender:z?Qe:void 0,vipSender:bt,markJunk:rt,toggleIntelligence:z?()=>V.current?.toggle():void 0,compose:ze,goBrief:()=>i("brief"),goInbox:()=>i("brief"),goSent:()=>i("brief"),goFlagged:()=>i("flagged"),goSettings:()=>i("settings")}}),dt=C=>{if(!C)return;const H=K.find($=>$.messageId===C);return H?{threadId:H.threadId,messageId:C}:void 0},yt={mailboxId:e,selectedMessageId:_,selectedThread:z,conversation:ne,onOpenThread:s,threads:K,isLoading:ye,isError:W,error:Pe,mailboxAccountId:N,mailboxAccountLoading:X,mailboxName:$e,unreadCount:Xe,isDraftsMailbox:T,isSpamFolder:se,rescueCandidates:nt,filterCategory:w,filterAttributes:j,onSelectFilterCategory:ke,onToggleFilterAttribute:fe,onClearFilters:me,listFilter:re,listSearchText:x||void 0,onToggleIntelligence:g,intelligenceRef:V,handleDeselectIfRemoved:ee,searchPredicate:y&&R.length===0?F:void 0,resultCount:Ie,onDeleteMessages:Y,onMoveMessages:je,isDeleting:Te,isMoving:ge,onLoadMore:M,hasMore:Ce,isLoadingMore:Oe,onTriageContextChange:Ze,listCommandsRef:te,onRetry:()=>ie(),onReply:st,onToolbarDelete:we.deleteThread,onToolbarStar:we.toggleStar,isStarred:we.isStarred,onToolbarMove:we.moveThread,onBack:Ue,nextThread:dt(vt),previousThread:dt(St)};return r.jsx(ds.Provider,{value:yt,children:t})}function hs(){const{mailboxId:e,selectedMessageId:o,threads:t,isLoading:s,isError:n,error:i,onDeleteMessages:l,onMoveMessages:a,isDeleting:u,isMoving:d,onLoadMore:h,hasMore:g,isLoadingMore:m,mailboxAccountId:p,mailboxName:S,unreadCount:y,isDraftsMailbox:I,isSpamFolder:b,rescueCandidates:x,onTriageContextChange:w,listCommandsRef:k,onRetry:j,filterCategory:O,filterAttributes:A,onSelectFilterCategory:B,onToggleFilterAttribute:J,onClearFilters:G,listFilter:R,listSearchText:oe,searchPredicate:F,resultCount:P}=pt(),{searchQuery:Ee,searchInput:Se,accounts:ye,resultFolderIndex:W}=Jt(),Pe=Ko(),ie=Ye(),M=S??"Inbox",Ce=c.useMemo(()=>ho(),[]),{trashMailboxId:Oe}=fo(p),Ie=Eo({accounts:ye}),{trashByAccount:N}=ns(),X=sr({accountId:p,mailboxId:e}),$e=Oe!=null&&Oe===e,K=c.useMemo(()=>p?[p]:[],[p]),{hasNewMail:ke}=bn(),{state:fe,errorMessage:me,refresh:Ae}=vn(K,{onSettled:j}),re=c.useMemo(()=>r.jsx(Sn,{state:fe,onRefresh:Ae,label:`Refresh ${M}`,errorMessage:me,hasUpdate:ke(K)}),[fe,Ae,M,me,ke,K]),Be=c.useMemo(()=>t.map(V=>mo(V,W)),[t,W]),{hits:Ne,isLoading:z}=Po({mailboxId:e,filterCategory:O}),_=c.useMemo(()=>go(Ne,t.map(V=>V.threadId),W),[Ne,t,W]),ne=c.useCallback(V=>{const pe=V.threadId??t.find(te=>te.messageId===V.id)?.threadId;pe&&ie({threadId:pe,messageId:V.id},{mailboxId:V.mailboxId??e,query:Se})},[e,ie,Se,t]);if(I&&p)return r.jsx(gi,{accountId:p,selectedMessageId:o,imapThreads:t,title:S??"Drafts",unreadCount:y??void 0});const ee=r.jsx(Gi,{mailboxId:e,threads:t,selectedMessageId:o,isLoading:s,isError:n,error:i,onRetry:j,searchQuery:Ee,searchPredicate:F,resultCount:P,onDeleteMessages:l,isDeleting:u,isMoving:d,onLoadMore:h,hasMore:g,isLoadingMore:m,accountId:p,listTitle:M,listFilter:R,listSearchText:oe,listScopeLabel:M,hideHeader:!0,onTriageContextChange:w,commandsRef:k}),Y=ye[0]?.accountId,Te=Pe==="phone"&&Y?r.jsx(Xi,{accountId:Y,children:ee}):ee,je=b&&x.length>0&&p?r.jsx(er,{accountId:p,currentMailboxId:e,candidates:x,onMove:a,children:Te}):Te,ge=$e?r.jsx(bi,{messageCount:Ie,isEmptying:X.isEmptying,deletedCount:X.deletedCount,refusalReason:X.refusal?.reason,trashFolderLabel:S??void 0,staleFolderLabel:p?N.get(p)?.staleFolderPath:void 0,onEmpty:X.emptyTrash,onRepair:X.repair,children:je}):je;return r.jsx(Co,{title:M,unreadCount:y,preset:Ce,selectedCategory:O,activeFilters:A,onSelectCategory:B,onToggleFilter:J,onClearFilters:G,searchResults:Be,searchLoading:s,relatedResults:_,relatedLoading:z,onSelectSearchResult:ne,searchResultsInBody:!0,refreshControl:re,children:ge})}function ur(){const{mailboxId:e,mailboxAccountId:o,mailboxAccountLoading:t,selectedThread:s,conversation:n,onReply:i,onToolbarDelete:l,onToolbarStar:a,isStarred:u,onToolbarMove:d,handleDeselectIfRemoved:h,intelligenceRef:g}=pt(),m=!!n,p=co(n?.threadId);os(g,p);const S=c.useRef(null),{railFits:y,openRail:I}=p;c.useEffect(()=>{if(!y)return;const x=s?.messageId??null;x&&S.current!==x&&s?.authenticity?.dkimMismatch&&(S.current=x,I())},[y,I,s?.messageId,s?.authenticity?.dkimMismatch]);const b=n?r.jsx(is,{threadId:n.threadId,mailboxId:n.mailboxId,subject:n.subject,selectedMessageId:n.messageId,authenticity:n.authenticity,onOpenIntelligence:p.open,listOnScreen:!0}):r.jsx(xn,{});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(uo,{hasThread:m,messageId:n?.messageId,intelligenceOpen:p.isShowing,canToggleIntelligence:p.canToggle,onToggleIntelligence:p.toggle,onReply:i?()=>i("reply"):void 0,onReplyAll:i?()=>i("reply-all"):void 0,onForward:i?()=>i("forward"):void 0,onDelete:m?l:void 0,onToggleStar:m?a:void 0,isStarred:u,moveContext:m&&o?{accountId:o,currentMailboxId:e,onMove:d}:void 0,moveContextLoading:t}),r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:b})]}),r.jsx(rs,{isOpen:p.drawerOpen,onClose:p.closeDrawer,thread:s,mailboxId:e,accountId:o,onAfterOptimisticRemove:h})]})}function dr(){const{mailboxId:e,mailboxAccountId:o,selectedThread:t,onToggleIntelligence:s,handleDeselectIfRemoved:n}=pt();return r.jsx(lo,{onClose:s,thread:t,mailboxId:e,accountId:o,onAfterOptimisticRemove:n})}function hr(){const{mailboxId:e,mailboxAccountId:o,selectedThread:t,conversation:s,onOpenThread:n,onBack:i,nextThread:l,previousThread:a,handleDeselectIfRemoved:u,intelligenceRef:d}=pt(),h=ao(s?.threadId??null);return os(d,h),s?r.jsxs(r.Fragment,{children:[r.jsx(is,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onBack:i,onOpenIntelligence:h.toggle,onSwipeNext:l?()=>n(l):void 0,onSwipePrevious:a?()=>n(a):void 0,mobileIntelligenceOpen:h.isOpen}),r.jsx(rs,{isOpen:h.isOpen,onClose:h.close,thread:t,mailboxId:e,accountId:o,onAfterOptimisticRemove:u})]}):r.jsx(hs,{})}const Fr=Object.assign(cr,{List:hs,Reading:ur,Intelligence:dr,Phone:hr});export{Fr as M};
|
|
1
|
+
import{j as r,bP as js,bZ as ws,b_ as Ms,cI as Rs,B as ft,f as Z,W as Es,t as Re,g as Wt,r as c,_ as Os,$ as As,br as Ns,cJ as Ge,h as wt,c as mt,ad as zs,i as Mt,cK as Fs,cE as Ds,I as _s,a7 as Ls,a3 as Kt,cL as Ps,cM as Vt,bT as $s,bl as Bs,cN as Ws,cO as Ks,at as qt,cP as Vs,cQ as qs,aZ as Hs,a_ as Qs,cR as Us,cS as Js,q as Rt,m as Gs,Q as Ht,bo as Ys,K as Zs,bp as Xs,bq as en,cT as tn,o as sn,E as nn,F as on,cU as rn,cC as an,s as ln,cV as cn,cW as un,cX as Qt,cY as Ut,C as Jt,ai as dn,cZ as hn,c_ as fn,ak as mn,bA as gn}from"./index-D5g4bLbz.js";import{u as pn,p as Dt,R as xn}from"./useSearchTokenContext-fxNd6lN7.js";import{u as bn,a as vn,R as Sn}from"./useRefreshControl-BPgFT5xG.js";import{C as Gt,r as Et,a as Yt,c as Zt,j as yn,M as Cn,t as Xt,u as In,b as kn,d as es,e as ts,f as Tn,g as jn,h as wn,n as Mn,i as Rn,k as En,S as On,l as An,D as Nn,m as zn,o as Fn,p as ss,q as Dn,s as _n,v as Ln,w as Pn,x as $n,y as ns,z as Bn,A as Wn,B as Kn,E as Vn,F as qn,G as Hn,H as Qn,I as Un,J as Jn,K as _t,L as Lt,N as Gn,O as Yn,P as Zn,Q as Xn,R as eo,T as to,U as so,V as no,W as oo,X as io,Y as ro,Z as ao,_ as os,$ as is,a0 as rs,a1 as lo,a2 as co,a3 as uo,a4 as ho,a5 as fo,a6 as mo,a7 as go,a8 as po}from"./MailListHeader-E9QEtmIA.js";import{S as xo,M as bo,a as vo,u as So,l as yo,b as Co}from"./MailViewChrome-CqwrrISL.js";import{A as Ot}from"./avatar-DWygq3JL.js";import{c as Io,f as ko,a as To,u as jo}from"./useMessageBodyContent-t6jq86nw.js";import{g as Ye,h as wo,i as Mo,j as Ro,k as Eo}from"./search-token-index-C7IV79h1.js";import{N as Oo}from"./NavMenuButton-D_SvQiP3.js";import{C as Ao}from"./confirm-dialog-C2U7srZg.js";import{f as No}from"./ErrorState-Crk7VNBz.js";import{a as zo}from"./useLabels-CUzYbhl8.js";import{L as Fo,r as Do,t as _o,s as Lo,u as Po}from"./useSemanticSearch-DLqfhhCH.js";import{S as gt}from"./shield-check-Ct41yuh3.js";import{B as $o}from"./bottom-sheet-B7GLlYre.js";import{C as Bo}from"./circle-help-CEBs72a-.js";import{C as Wo}from"./circle-check-jWc2VLKl.js";import{u as Ko}from"./useLayoutTier-wQkod_ZW.js";import{n as Vo}from"./search-query-Cr_ZXBCp.js";import{u as qo}from"./sections-Dp7hJCpX.js";const Ho=e=>e.toLocaleString(),Qo=(e,o)=>{if(e.kind==="unknown")return`Results for “${o}”`;const t=e.value===1?"result":"results";return`${Ho(e.value)} ${t} for “${o}”`};function Uo({query:e,count:o}){return r.jsxs("div",{className:"flex items-center gap-2 border-b border-line bg-surface-sunken/30 px-3 py-2",children:[r.jsx(js,{className:"size-4 text-fg-muted","aria-hidden":"true"}),r.jsx("span",{className:"text-sm text-fg-muted",children:Qo(o,e)})]})}const Jo=({children:e,onRefresh:o,isRefreshing:t})=>ws(Ms)?e:r.jsx(Rs,{onRefresh:o,isPullable:!t,children:e}),Go=e=>e===1?"message":"messages";function Yo({count:e,onReview:o,onDismiss:t,actionLabel:s="Review & rescue"}){return r.jsx(ft,{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(gt,{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} ${Go(e)} here`})," ","may not be spam — they're from senders we can verify."]})]}),r.jsx(Z,{variant:"primary",size:"sm",onClick:o,className:"self-start",children:s})]})})}const Zo=(e,o)=>e==="vip"?"vip":e==="unknown"&&o==="md"?"unknown-pill":"hidden",as=({senderTrust:e,size:o="sm",className:t})=>{const s=Zo(e,o);return s==="vip"?r.jsx(Es,{className:Re("text-warning shrink-0",o==="sm"&&"size-3.5",o==="md"&&"size-4",t),"aria-label":"VIP sender","data-testid":"sender-trust-vip"}):s==="unknown-pill"?r.jsx("span",{className:Re("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 Xo({candidate:e,selected:o,onToggle:t,hideSender:s=!1}){const{senderName:n,senderAddress:i,subject:l,snippet:a,trustReason:u,trustSubReason:d,senderTrust:h}=e;return r.jsxs("label",{className:Re("flex w-full cursor-pointer items-start gap-3 px-3 py-2.5 text-left transition-colors",s&&"pl-11",o?"bg-positive/10":"bg-surface hover:bg-surface-sunken"),children:[r.jsx(Gt,{className:"mt-0.5",checked:o,onChange:t,"aria-label":`${o?"Deselect":"Select"} ${s?l:`message from ${n}`}`}),!s&&r.jsx(Ot,{name:n,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:n}),h&&r.jsx(as,{senderTrust:h,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(Wt,{tone:"positive",children:[r.jsx(gt,{className:"size-3","aria-hidden":!0}),u]}),r.jsx("span",{className:"text-2xs text-fg-subtle",children:d})]})]})]})}const ei=e=>{const o=new Map,t=[];for(const s of e){const n=(s.senderAddress||s.senderName).toLowerCase(),i=o.get(n);if(i){i.messages.push(s);continue}o.set(n,{key:n,senderName:s.senderName,senderAddress:s.senderAddress,trustReason:s.trustReason,trustSubReason:s.trustSubReason,senderTrust:s.senderTrust,messages:[s]}),t.push(n)}return t.map(s=>o.get(s)).sort((s,n)=>n.messages.length-s.messages.length)},ti=(e,o)=>{const t=e.messages.filter(s=>o.has(s.id)).length;return t===0?"none":t===e.messages.length?"all":"some"},Pt=e=>e===1?"message":"messages";function si({group:e,selected:o,onToggleGroup:t,onToggleMessage:s}){const[n,i]=c.useState(!1),l=ti(e,o),a=e.messages.length,u=n?Os:As;return r.jsxs("div",{className:Re(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(Gt,{className:"mt-0.5",checked:l==="all",indeterminate:l==="some",onChange:()=>t(e,l!=="all"),"aria-label":`${l==="all"?"Deselect":"Select"} all ${a} ${Pt(a)} from ${e.senderName}`}),r.jsx(Ot,{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(as,{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(Wt,{tone:"positive",children:[r.jsx(gt,{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":n,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} ${Pt(a)}`,r.jsx(u,{className:"size-3.5","aria-hidden":!0})]})]}),n&&r.jsx("div",{className:"divide-y divide-line border-t border-line",children:e.messages.map(d=>r.jsx(Xo,{candidate:d,selected:o.has(d.id),onToggle:()=>s(d.id),hideSender:!0},d.id))})]})}const At=e=>e===1?"message":"messages",ni=(e,o)=>`Moves ${e===1?"this message":`these ${e} ${At(e)}`} out of Spam to ${o} now. Nothing later.`,jt=(e,o)=>e.find(t=>t.id===o)?.label??"Inbox";function oi(){return r.jsx(ft,{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 ii({candidates:e,selected:o,onToggle:t,onToggleGroup:s,onSelectAll:n,onSelectNone:i,onContinue:l,onCancel:a}){const[u,d]=c.useState(!1),h=o.size,g=c.useMemo(()=>ei(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(gt,{className:"size-4 text-positive","aria-hidden":!0}),"Rescue from Spam"]}),r.jsx(Z,{variant:"ghost",size:"sm",icon:r.jsx(Bo,{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(oi,{})})]}),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:`${h} of ${e.length} selected · ${g.length} ${g.length===1?"sender":"senders"}`}),r.jsxs("span",{className:"flex gap-1",children:[r.jsx(Z,{variant:"ghost",size:"sm",onClick:n,children:"Select all"}),r.jsx(Z,{variant:"ghost",size:"sm",onClick:i,children:"Select none"})]})]}),r.jsx("div",{className:"min-h-0 flex-1 divide-y divide-line overflow-y-auto border-y border-line",children:g.map(m=>r.jsx(si,{group:m,selected:o,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(Z,{variant:"primary",onClick:l,className:"h-11 w-full font-semibold",children:`Continue with ${h} ${At(h)}`}),r.jsx(Z,{variant:"ghost",onClick:a,className:"h-11 w-full",children:"Cancel"})]})]})}function ri({count:e,folders:o,delimiter:t,destination:s,onPick:n,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(Ns,{folders:o,selectedId:s,delimiter:t,onSelect:n,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:jt(o,s)}),r.jsx(Z,{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:ni(e,jt(o,s))}),r.jsx(Z,{variant:"primary",onClick:i,className:"h-11 w-full font-semibold",children:`Move ${e} out of Spam`}),r.jsx(Z,{variant:"ghost",onClick:l,className:"h-11 w-full",children:"Back"})]})]})}function ai({count:e,destinationLabel:o,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(Wo,{className:"size-10 text-positive","aria-hidden":!0}),r.jsx("p",{className:"text-base font-semibold text-fg",children:`Moved ${e} ${At(e)} out of Spam.`}),r.jsx("p",{className:"text-2xs text-fg-subtle",children:`You'll find them in ${o}.`})]}),r.jsx("div",{className:"border-t border-line bg-surface px-row-inset py-3",children:r.jsx(Z,{variant:"primary",onClick:t,className:"h-11 w-full font-semibold",children:"Done"})})]})}function li({open:e,candidates:o,defaultDestinationId:t,availableFolders:s,delimiter:n,onConfirmMove:i,onCancel:l}){const[a,u]=c.useState("review"),[d,h]=c.useState(()=>e?new Set(o.map(k=>k.id)):new Set),[g,m]=c.useState(t),[p,S]=c.useState(0),y=c.useRef(!1);c.useEffect(()=>{e&&!y.current&&(u("review"),h(new Set(o.map(k=>k.id))),m(t),S(0)),y.current=e},[e,o,t]);const I=d.size,b=k=>{h(j=>{const O=new Set(j);return O.has(k)?O.delete(k):O.add(k),O})},x=(k,j)=>{h(O=>{const A=new Set(O);for(const B of k.messages)j?A.add(B.id):A.delete(B.id);return A})},w=()=>{const k=Array.from(d);S(k.length),i(k,g),u("done")};return r.jsxs($o,{open:e,onClose:l,label:"Rescue from spam",dismissLabel:"Close rescue",children:[a==="review"&&r.jsx(ii,{candidates:o,selected:d,onToggle:b,onToggleGroup:x,onSelectAll:()=>h(new Set(o.map(k=>k.id))),onSelectNone:()=>h(new Set),onContinue:()=>u("destination"),onCancel:l}),a==="destination"&&r.jsx(ri,{count:I,folders:s,delimiter:n,destination:g,onPick:m,onMove:w,onBack:()=>u("review")}),a==="done"&&r.jsx(ai,{count:p,destinationLabel:jt(s,g),onClose:l})]})}function ci(e){const o=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:o?`To: ${o}`:"(No recipients)",timeLabel:Ge(e.updatedAt),isRead:!0}}function ui(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:Ge(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,...Et(e)}}function di({outboxMessages:e,accountId:o,imapThreads:t}){const s=e.filter(l=>l.status==="draft"&&l.accountId===o).map(ci),n=t.map(ui),i=[];return s.length>0&&i.push({id:"remit-drafts",label:"Not yet sent (Remit)",threads:s}),n.length>0&&i.push({id:"imap-drafts",label:"On the server",threads:n}),i}const hi=({label:e,count:o})=>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:o})]}),fi=({row:e,isSelected:o,onOpen:t,onDelete:s,isDeleting:n})=>r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:Re("group",Zt({active:o})),children:[r.jsx(Ls,{className:"size-7 shrink-0 text-fg-muted mt-0.5"}),r.jsx(Yt,{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:n,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(Kt,{className:"size-3.5"})})})]}),mi=({row:e,isSelected:o,onOpen:t})=>{const s=!e.isRead;return r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:Re("group",Zt({active:o})),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(Ot,{name:e.fromName,email:e.fromEmail,size:"sm"}),r.jsx(Yt,{thread:e})]})};function gi({accountId:e,selectedMessageId:o,imapThreads:t,title:s,unreadCount:n}){const i=Io(),l=ko(),a=Ye(),u=wt(),{data:d}=mt(zs()),h=c.useMemo(()=>di({outboxMessages:d?.items??[],accountId:e,imapThreads:t}),[d?.items,e,t]),g=Mt({...Ds(),onSuccess:()=>{u.invalidateQueries({queryKey:Fs()})}}),m=y=>{g.mutate({path:{outboxMessageId:y}})},p=y=>{const I=t.find(b=>b.messageId===y)?.threadId;I&&a({threadId:I,messageId:y})},S=h.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:s}),(n??0)>0&&r.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:[n," unread"]})]}),r.jsx("div",{className:"flex-1 overflow-y-auto",children:S?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 text-center px-4",children:[r.jsx(_s,{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."})]}):h.map(y=>r.jsxs("div",{children:[y.label&&r.jsx(hi,{label:y.label,count:y.threads.length}),r.jsx("div",{className:"divide-y divide-line",children:y.threads.map(I=>y.id==="remit-drafts"?r.jsx(fi,{row:I,isSelected:I.id===i,onOpen:l,onDelete:m,isDeleting:g.isPending},I.id):r.jsx(mi,{row:I,isSelected:I.id===o,onOpen:p},I.id))})]},y.id))})]})}const ls=e=>e===1?"1 message":`${Vt(e)} messages`,pi=e=>({title:"Empty Trash?",description:`${ls(e)} ${e===1?"is":"are"} erased from the mail server and cannot be restored.`,confirmLabel:"Empty Trash"}),xi=(e,o={})=>{const{trashFolderLabel:t,staleFolderLabel:s}=o;if(e==="unconfirmed"){const n=Ps(0,"unconfirmed",{trashFolderLabel:t});return{headline:n.title,body:n.description,actionLabel:n.confirmLabel}}return e==="stale"?{headline:"Nothing was emptied.",body:s?`The folder you chose for Trash — ${s} — is gone from the mail server.`:"The folder you chose for Trash is gone from the mail server.",actionLabel:"Pick another folder"}:{headline:"Nothing was emptied.",body:"No folder on this account is set as Trash.",actionLabel:"Pick a folder"}};function bi({messageCount:e,isEmptying:o,deletedCount:t,refusalReason:s,trashFolderLabel:n,staleFolderLabel:i,onEmpty:l,onRepair:a,children:u}){const[d,h]=c.useState(!1);if(e<1&&s===void 0&&t===void 0)return r.jsx(r.Fragment,{children:u});const g=s?xi(s,{trashFolderLabel:n,staleFolderLabel:i}):void 0,m=pi(e);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.jsxs("div",{className:"flex flex-col gap-2 rounded-md border border-line px-3 py-2",children:[r.jsxs("div",{className:"flex items-center justify-end gap-2",children:[t!==void 0&&r.jsx("p",{className:"mr-auto text-2xs text-fg-subtle",role:"status",children:`${ls(t)} erased from the mail server.`}),r.jsx(Z,{variant:"ghost",size:"sm",icon:r.jsx(Kt,{className:"size-3.5","aria-hidden":!0}),disabled:o||e<1,"aria-busy":o,onClick:()=>h(!0),children:o?"Emptying…":"Empty Trash"})]}),g&&r.jsx(ft,{tone:"warning",variant:"soft",children:r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx("p",{className:"font-semibold text-fg",children:g.headline}),r.jsx("p",{className:"text-sm",children:g.body}),r.jsx(Z,{variant:"primary",size:"sm",className:"self-start",onClick:a,children:g.actionLabel})]})})]})}),r.jsx("div",{className:"min-h-0 flex-1",children:u}),r.jsx(Ao,{isOpen:d,title:m.title,description:m.description,confirmLabel:m.confirmLabel,destructive:!0,onConfirm:()=>{h(!1),l()},onCancel:()=>h(!1)})]})}function vi(e,o,t){const s=new Array(e);return new Proxy(s,{get(n,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=n[u];if(!d){const h=o[u*2];d=n[u]={index:u,key:t(u),start:h,size:o[u*2+1],end:h+o[u*2+1],lane:0}}return d}}if(i==="length")return e}return Reflect.get(n,i,l)}})}function Le(e,o,t){let s=t.initialDeps??[],n,i=!0;function l(){const a=e();return(a.length!==s.length||a.some((d,h)=>s[h]!==d))&&(s=a,n=o(...a),t?.onChange&&!(i&&t.skipInitialOnChange)&&t.onChange(n),i=!1),n}return l.updateDeps=a=>{s=a},l}function $t(e,o){if(e===void 0)throw new Error("Unexpected undefined");return e}const Si=(e,o)=>Math.abs(e-o)<1.01,yi=(e,o,t)=>{let s;return function(...n){e.clearTimeout(s),s=e.setTimeout(()=>o.apply(this,n),t)}};let Je;const kt=()=>{if(Je!==void 0)return Je;if(typeof navigator>"u")return Je=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Je=!0;const e=navigator.maxTouchPoints;return Je=navigator.platform==="MacIntel"&&e!==void 0&&e>0},Bt=e=>{const{offsetWidth:o,offsetHeight:t}=e;return{width:o,height:t}},Ci=e=>e,Ii=e=>{const o=Math.max(e.startIndex-e.overscan,0),s=Math.min(e.endIndex+e.overscan,e.count-1)-o+1,n=new Array(s);for(let i=0;i<s;i++)n[i]=o+i;return n},ki=(e,o)=>{const t=e.scrollElement;if(!t)return;const s=e.targetWindow;if(!s)return;const n=l=>{const{width:a,height:u}=l;o({width:Math.round(a),height:Math.round(u)})};if(n(Bt(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){n({width:d.inlineSize,height:d.blockSize});return}}n(Bt(t))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return i.observe(t,{box:"border-box"}),()=>{i.unobserve(t)}},ht={passive:!0},Ti=typeof window>"u"?!0:"onscrollend"in window,ji=(e,o,t)=>{const s=e.scrollElement;if(!s)return;const n=e.targetWindow;if(!n)return;const i=e.options.useScrollendEvent&&Ti;let l=0;const a=i?null:yi(n,()=>o(l,!1),e.options.isScrollingResetDelay),u=g=>()=>{l=t(s),a?.(),o(l,g)},d=u(!0),h=u(!1);return s.addEventListener("scroll",d,ht),i&&s.addEventListener("scrollend",h,ht),()=>{s.removeEventListener("scroll",d),i&&s.removeEventListener("scrollend",h)}},wi=(e,o)=>ji(e,o,t=>{const{horizontal:s,isRtl:n}=e.options;return s?t.scrollLeft*(n&&-1||1):t.scrollTop}),Mi=(e,o,t)=>{if(t.options.useCachedMeasurements){const s=t.indexFromElement(e),n=t.options.getItemKey(s);return t.itemSizeCache.get(n)??t.options.estimateSize(s)}if(o?.borderBoxSize){const s=o.borderBoxSize[0];if(s)return Math.round(s[t.options.horizontal?"inlineSize":"blockSize"])}if(!o){const s=t.indexFromElement(e),n=t.options.getItemKey(s),i=t.itemSizeCache.get(n);if(i!==void 0)return i}return e[t.options.horizontal?"offsetWidth":"offsetHeight"]},Ri=(e,{adjustments:o=0,behavior:t},s)=>{var n,i;(i=(n=s.scrollElement)==null?void 0:n.scrollTo)==null||i.call(n,{[s.options.horizontal?"left":"top"]:e+o,behavior:t})},Ei=Ri;class Oi{constructor(o){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,n;return((n=(s=(t=this.targetWindow)==null?void 0:t.performance)==null?void 0:s.now)==null?void 0:n.call(s))??Date.now()},this.observer=(()=>{let t=null;const s=()=>t||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:t=new this.targetWindow.ResizeObserver(n=>{n.forEach(i=>{const l=()=>{const a=i.target,u=this.indexFromElement(a);if(!a.isConnected){this.observer.unobserve(a);for(const[d,h]of this.elementsCache)if(h===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 n;(n=s())==null||n.disconnect(),t=null},observe:n=>{var i;return(i=s())==null?void 0:i.observe(n,{box:"border-box"})},unobserve:n=>{var i;return(i=s())==null?void 0:i.unobserve(n)}}})(),this.range=null,this.setOptions=t=>{var s,n;const i={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Ci,rangeExtractor:Ii,onChange:()=>{},measureElement:Mi,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 p=t[m];p!==void 0&&(i[m]=p)}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,p=i.count,S=this.getMeasurements(),y=m>0?((s=S[0])==null?void 0:s.key)??l.getItemKey(0):null,I=m>0?((n=S[m-1])==null?void 0:n.key)??l.getItemKey(m-1):null;if(p!==m||m>0&&p>0&&(i.getItemKey(0)!==y||i.getItemKey(p-1)!==I)){d=!0;const w=m>0?this.getVirtualItemForOffset(this.getScrollOffset())??S[0]:null;w&&(a=[w.key,this.getScrollOffset()-w.start]);const k=i.followOnAppend===!0?"auto":i.followOnAppend||null;k&&p>m&&this.isAtEnd(l.scrollEndThreshold)&&(m===0||i.getItemKey(p-1)!==I)&&(u=k)}}this.options=i,d&&(this.pendingMin=0,this.itemSizeCacheVersion++);let h=!1,g=0;if(a&&this.scrollOffset!==null){const[m,p]=a,S=this.getMeasurements(),{count:y,getItemKey:I}=this.options;let b=0;for(;b<y&&I(b)!==m;)b++;if(b<y){const x=S[b];if(x){const w=x.start+p;w!==this.scrollOffset&&(g=w-this.scrollOffset,this.scrollOffset=w,h=!0)}}}(h||u)&&(this.pendingScrollAnchor=[h?a[0]:null,h?a[1]:0,u,g])},this.notify=t=>{var s,n;(n=(s=this.options).onChange)==null||n.call(s,this,t)},this.maybeNotify=Le(()=>(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,!(!kt()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};i.addEventListener("touchstart",l,ht),i.addEventListener("touchend",a,ht),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 n=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,n&&this.scrollElement&&this.options.enabled){const[i,l,a,u]=n;i!==null&&!a&&(kt()&&(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 n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(t,{adjustments:this.scrollAdjustments+=n,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=Le(()=>[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,n,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:n,getItemKey:i,enabled:l,lanes:a,laneAssignmentMode:u,gap:d}),{key:!1}),this.getMeasurements=Le(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:t,paddingStart:s,scrollMargin:n,getItemKey:i,enabled:l,lanes:a,laneAssignmentMode:u,gap:d},h)=>{const g=this.itemSizeCache;if(!l)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>t)for(const b of this.laneAssignments.keys())b>=t&&this.laneAssignments.delete(b);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(b=>{this.itemSizeCache.set(b.key,b.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 b=t*2;let x=this._flatMeasurements;if(!x||x.length<b){const j=new Float64Array(b);x&&m>0&&j.set(x.subarray(0,m*2)),x=j,this._flatMeasurements=x}let w;if(m===0)w=s+n;else{const j=m-1;w=x[j*2]+x[j*2+1]+d}for(let j=m;j<t;j++){const O=i(j),A=g.get(O),B=typeof A=="number"?A:this.options.estimateSize(j);x[j*2]=w,x[j*2+1]=B,w+=B+d}const k=vi(t,x,i);return this.measurementsCache=k,k}const p=this.measurementsCache.slice(0,m),S=new Array(a).fill(void 0),y=new Float64Array(a);let I=0;for(let b=0;b<m;b++){const x=p[b];x&&(S[x.lane]===void 0&&I++,S[x.lane]=b,y[x.lane]=x.end)}for(let b=m;b<t;b++){const x=i(b),w=this.laneAssignments.get(b);let k,j;const O=u==="estimate"||g.has(x);if(w!==void 0&&this.options.lanes>1){k=w;const G=S[k],R=G!==void 0?p[G]:void 0;j=R?R.end+d:s+n}else if(I===a){let G=0,R=y[0],oe=S[0];for(let F=1;F<a;F++){const P=y[F];(P<R||P===R&&S[F]<oe)&&(G=F,R=P,oe=S[F])}k=G,j=R+d,O&&this.laneAssignments.set(b,k)}else k=b%this.options.lanes,j=s+n,O&&this.laneAssignments.set(b,k);const A=g.get(x),B=typeof A=="number"?A:this.options.estimateSize(b),J=j+B;p[b]={index:b,start:j,size:B,end:J,key:x,lane:k},S[k]===void 0&&I++,S[k]=b,y[k]=J}return this.measurementsCache=p,p},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Le(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,s,n,i)=>t.length===0||s===0?(this.range=null,null):(this.range=Ni(t,s,n,i,i===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Le(()=>{let t=null,s=null;const n=this.calculateRange();return n&&(t=n.startIndex,s=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,s]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,s]},(t,s,n,i,l)=>i===null||l===null?[]:t({startIndex:i,endIndex:l,overscan:s,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=t=>{const s=this.options.indexAttribute,n=t.getAttribute(s);return n?parseInt(n,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 n=this.scrollState.index??((s=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:s.index);if(n!==void 0&&this.range){const i=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),l=Math.max(0,n-i),a=Math.min(this.options.count-1,n+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),n=this.options.getItemKey(s),i=this.elementsCache.get(n);i!==t&&(i&&this.observer.unobserve(i),this.observer.observe(t),this.elementsCache.set(n,t)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(s)&&this.resizeItem(s,this.options.measureElement(t,void 0,this))},this.resizeItem=(t,s)=>{var n,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 h=this.itemSizeCache.get(u)??l,g=s-h;if(g!==0){const m=this.options.anchorTo==="end"&&((n=this.scrollState)==null?void 0:n.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,p=m?this.getTotalSize():0,S=((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},g,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()-p):S&&this.applyScrollAdjustment(g),this.notify(!1)}},this.getVirtualItems=Le(()=>[this.getVirtualIndexes(),this.getMeasurements()],(t,s)=>{const n=[];for(let i=0,l=t.length;i<l;i++){const a=t[i],u=s[a];n.push(u)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=t=>{const s=this.getMeasurements();if(s.length===0)return;const n=this._flatMeasurements,i=this.options.lanes===1&&n!=null,l=cs(0,s.length-1,i?a=>n[a*2]:a=>$t(s[a]).start,t);return $t(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,n=0)=>{if(!this.scrollElement)return 0;const i=this.getSize(),l=this.getScrollOffset();s==="auto"&&(s=t>=l+i?"end":"start"),s==="center"?t+=(n-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 n=this.getSize(),i=this.getScrollOffset(),l=this.measurementsCache[t];if(!l)return;if(s==="auto")if(l.end>=i+n-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:n="auto"}={})=>{const i=this.getOffsetForAlignment(t,s),l=this.now();this.scrollState={index:null,align:s,behavior:n,startedAt:l,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(t,{align:s="auto",behavior:n="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:n,startedAt:u,lastTargetOffset:l,stableFrames:0},this._scrollToOffset(l,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(t,{behavior:s="auto"}={})=>{const n=this.getScrollOffset()+t,i=this.now();this.scrollState={index:null,align:"start",behavior:s,startedAt:i,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{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 n;if(s.length===0)n=this.options.paddingStart;else if(this.options.lanes===1){const i=s.length-1,l=this._flatMeasurements;l!=null?n=l[i*2]+l[i*2+1]:n=((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--}n=Math.max(...i.filter(a=>a!==null))}return Math.max(n-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const t=[];if(this.itemSizeCache.size===0)return t;const s=this.getMeasurements();for(const n of s)n&&this.itemSizeCache.has(n.key)&&t.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return t},this._scrollToOffset=(t,{adjustments:s,behavior:n})=>{this._intendedScrollOffset=t+(s??0),this.options.scrollToFn(t,{behavior:n,adjustments:s},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(o)}applyScrollAdjustment(o,t){o!==0&&(kt()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=o:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=o,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,n=s?s[0]:this.scrollState.lastTargetOffset,i=1,l=n!==this.scrollState.lastTargetOffset;if(!l&&Si(n,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=i){this.getScrollOffset()!==n&&this._scrollToOffset(n,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,l){const a=this.getSize()||600,u=Math.abs(n-this.getScrollOffset()),d=this.scrollState.behavior==="smooth"&&u>a;this.scrollState.lastTargetOffset=n,d||(this.scrollState.behavior="auto"),this._scrollToOffset(n,{adjustments:void 0,behavior:d?"smooth":"auto"})}this.scheduleScrollReconcile()}}const cs=(e,o,t,s)=>{for(;e<=o;){const n=(e+o)/2|0,i=t(n);if(i<s)e=n+1;else if(i>s)o=n-1;else return n}return e>0?e-1:0};function Ai(e,o,t){let s=0;for(;s<=o;){const n=(s+o)/2|0,i=e[n*2];if(i<t)s=n+1;else if(i>t)o=n-1;else return n}return s>0?s-1:0}function Ni(e,o,t,s,n){const i=e.length-1;if(e.length<=s)return{startIndex:0,endIndex:i};if(s===1&&n!==null){const d=Ai(n,i,t);let h=d;const g=t+o;for(;h<i&&n[h*2]+n[h*2+1]<g;)h++;return{startIndex:d,endIndex:h}}let a=cs(0,i,d=>e[d].start,t),u=a;if(s===1)for(;u<i&&e[u].end<t+o;)u++;else if(s>1){const d=Array(s).fill(0);for(;u<i&&d.some(g=>g<t+o);){const g=e[u];d[g.lane]=g.end,u++}const h=Array(s).fill(t+o);for(;a>=0&&h.some(g=>g>=t);){const g=e[a];h[g.lane]=g.start,a--}a=Math.max(0,a-a%s),u=Math.min(i,u+(s-1-u%s))}return{startIndex:a,endIndex:u}}const Tt=typeof document<"u"?c.useLayoutEffect:c.useEffect;function zi({useFlushSync:e=!0,directDomUpdates:o=!1,directDomUpdatesMode:t="transform",...s}){const n=c.useReducer(d=>d+1,0)[1],i=c.useRef({enabled:o,mode:t,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});i.current.enabled=o,i.current.mode=t;const l=d=>{const h=i.current;if(!h.enabled||!h.container)return;const g=d.getTotalSize();if(g!==h.lastSize){h.lastSize=g;const b=d.options.horizontal?"width":"height";h.container.style[b]=`${g}px`}const m=!!d.options.horizontal,p=h.mode==="transform",S=m?"left":"top",y=d.options.scrollMargin,I=d.getVirtualItems();for(const b of I){const x=b.start-y,w=d.elementsCache.get(b.key);w&&h.lastPositions.get(w)!==x&&(h.lastPositions.set(w,x),p?w.style.transform=m?`translate3d(${x}px, 0, 0)`:`translate3d(0, ${x}px, 0)`:w.style[S]=`${x}px`)}},a={...s,onChange:(d,h)=>{var g;const m=i.current;let p=!0;if(m.enabled){l(d);const S=d.range,y=m.prevRange;p=!y||y.isScrolling!==d.isScrolling||y.startIndex!==S?.startIndex||y.endIndex!==S?.endIndex,p&&(m.prevRange=S?{startIndex:S.startIndex,endIndex:S.endIndex,isScrolling:d.isScrolling}:null)}p&&(e&&h?$s.flushSync(n):n()),(g=s.onChange)==null||g.call(s,d,h)}},[u]=c.useState(()=>{const d=new Oi(a);return Object.assign(d,{containerRef:h=>{const g=i.current;if(g.container=h,g.lastSize=null,h&&g.enabled){const m=d.getTotalSize();g.lastSize=m;const p=d.options.horizontal?"width":"height";h.style[p]=`${m}px`}}})});return u.setOptions(a),Tt(()=>u._didMount(),[]),Tt(()=>u._willUpdate()),Tt(()=>{l(u)}),u}function Fi(e){return zi({observeElementRect:ki,observeElementOffset:wi,scrollToFn:Ei,...e})}const Nt=e=>e.query?`matching "${e.query}"`:e.from?`from "${e.from}"`:"matching your search",Di=e=>`Select all ${Nt(e)}`,_i=(e,o)=>`All ${Vt(o)} ${Nt(e)} selected`,Li=({verb:e,confirmingDelete:o,hasSelection:t,junkMailboxId:s,currentMailboxId:n,deletableMessageId:i})=>{if(o)return{kind:"withheld"};if(e==="junk"){const l=yn(s,n);if(l!==void 0)return{kind:"unavailable",reason:l}}return t?{kind:"openWizard"}:e!=="delete"||i===void 0?{kind:"declined"}:{kind:"confirmDelete",messageId:i}},Pi=(e,o,t)=>e==="BACK"&&o&&t===void 0,$i=(e,o)=>({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:Ge(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:Xt(e.category),messageCount:o,suspicious:e.authenticity?.dkimMismatch===!0,labels:e.labels,...Et(e)}),Bi=({thread:e,mailboxId:o,isSelected:t,isFocused:s,isTabStop:n,onFocusRow:i,isChecked:l,onToggleCheck:a,onRowSelect:u,messageCount:d,isMultiSelectMode:h,onLongPress:g,isDesktop:m,density:p})=>r.jsx(Cn,{thread:$i(e,d),link:{mailboxId:o,threadId:e.threadId},inListbox:!0,active:t,focused:s,isTabStop:n,density:p,isDesktop:m,onFocusRow:i,selection:{isChecked:l,onToggleCheck:a,onRowSelect:u,isMultiSelectMode:h,onLongPress:g}}),Wi=c.memo(Bi),Ki=e=>{const o=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:Ge(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:Xt(e.category),suspicious:o,...Et(e)}},Vi=({thread:e,mailboxId:o,isSelected:t,isFocused:s,isTabStop:n,onFocusRow:i,isChecked:l,onToggleCheck:a,onRowSelect:u,isMultiSelectMode:d,onLongPress:h,isDesktop:g,onDelete:m,onToggleRead:p,density:S})=>{const[y,I]=c.useState("none"),b=Ye(),x=c.useCallback(A=>{navigator.vibrate?.(10),A==="trailing"?m(e.messageId):p(e.messageId,e.isRead),I("none")},[m,p,e.messageId,e.isRead]),w=c.useCallback(()=>{h(e.messageId)},[h,e.messageId]),k=c.useCallback(()=>{a(e.messageId)},[a,e.messageId]),j=c.useCallback(()=>{b({threadId:e.threadId,messageId:e.messageId})},[b,e.threadId,e.messageId]),O=In(e.messageId,u);return g||d?r.jsx(Wi,{thread:e,mailboxId:o,isSelected:t,isFocused:s,isTabStop:n,onFocusRow:i,isChecked:l,onToggleCheck:a,onRowSelect:u,isMultiSelectMode:d,onLongPress:h,isDesktop:g,density:S}):r.jsx("div",{role:"presentation",onPointerDownCapture:O.onMouseDown,onClickCapture:O.claimClick,onContextMenu:O.onContextMenu,children:r.jsx(xo,{thread:Ki(e),selectionMode:!1,checked:!1,active:t,peek:y,onPeek:I,onToggleCheck:k,onLongPress:w,onOpen:j,onAct:x})})},qi=72,Hi=32,Qi=5,us="remit:list-density",Ui=()=>{try{const e=localStorage.getItem(us);if(e==="compact"||e==="comfortable")return e}catch{}return"comfortable"},Ji=(e,o,t)=>Do(e.filter(s=>o.has(s.messageId)).map(s=>s.accountId??t)).moveDisabledHint,Gi=({mailboxId:e,threads:o,selectedMessageId:t,isLoading:s,isError:n=!1,error:i,onRetry:l,searchQuery:a,searchPredicate:u,resultCount:d={kind:"unknown"},onDeleteMessages:h,isDeleting:g=!1,isMoving:m=!1,onLoadMore:p,hasMore:S=!1,isLoadingMore:y=!1,accountId:I,listTitle:b,listMeta:x,listFilter:w,listSearchText:k,listScopeLabel:j,onTriageContextChange:O,commandsRef:A,hideHeader:B=!1})=>{const J=c.useRef(null),G=Ye(),R=Bs(),oe=Ws(),{verb:F,start:P,startFromSearch:Ee}=oe,Se=Ks(),ye=!!a?.trim(),W=kn(),{labels:Pe}=zo(I),{pushError:ie}=qt(),[M,Ce]=c.useState(t),[Oe,Ie]=c.useState(),N=c.useCallback(f=>{Ie(v=>v===f?v:void 0),Ce(f)},[]),[X,$e]=c.useState(Ui),K=c.useCallback(()=>{$e(f=>{const v=f==="comfortable"?"compact":"comfortable";try{localStorage.setItem(us,v)}catch{}return v})},[]),{toggleReadFor:ke}=es({mailboxId:e}),{junkMailboxId:fe}=ts(I),me=ss(fe,e),Ae=c.useMemo(()=>[{accountId:I,mailboxId:e}],[I,e]),{outcome:re,staleFolderLabel:Be,guessedMailboxId:Ne}=Tn(Ae),{selectedIds:z,selectedCount:_,hasSelection:ne,isSelected:ee,toggle:Y,select:Te,clearSelection:je,selectRange:ge,setAnchor:V,selectAll:pe,toggleAll:te,intersectWith:Ze}=jn(),We=Fn(_,R),[xe,E]=c.useState(null),Xe=c.useCallback((f,v,he)=>{const Q=Vs(f,v,he,re);Q&&ie(Q)},[ie,re]),we=ye&&!!u,et=`${e}|${JSON.stringify(u??{})}`,T=wn({mailboxId:e,mailboxLabel:b,accountId:I,enabled:we,predicateKey:et,searchQuery:u??{},reportEnding:Xe}),tt=T.phase.kind,Ke=T.clear,L=c.useCallback(()=>{tt==="escalated"&&Ke(),je()},[je,Ke,tt]),[st,ae]=c.useState(null),be=c.useRef(null),le=c.useRef(!1),ze=c.useRef(null),Me=!s&&o.length>0,ce=Fi({count:o.length,getScrollElement:()=>J.current,estimateSize:()=>X==="compact"?Hi:qi,overscan:Qi}),Ve=t?o.findIndex(f=>f.messageId===t):-1,q=M?o.findIndex(f=>f.messageId===M):-1,se=c.useCallback(f=>{if(f<0||f>=o.length)return;const v=o[f];if(We){Y(v.messageId);return}be.current=v.messageId,le.current=!1,Ie(v.messageId),Ce(v.messageId)},[o,We,Y]),Fe=c.useCallback(()=>{if(o.length===0)return;const f=q<0?0:Math.min(q+1,o.length-1);se(f)},[o.length,q,se]),nt=c.useCallback(()=>{if(o.length===0)return;const f=q<=0?0:q-1;se(f)},[o.length,q,se]),qe=c.useCallback(()=>se(0),[se]),He=c.useCallback(()=>se(o.length-1),[se,o.length]),ve=c.useCallback(()=>{M&&Y(M)},[M,Y]),D=c.useMemo(()=>o.map(f=>f.messageId),[o]),De=c.useMemo(()=>{const f=[];for(const v of o)z.has(v.messageId)&&f.push({id:v.messageId,sender:v.fromName??v.fromEmail??"Unknown",email:v.fromEmail??"",subject:v.subject??"(No subject)",date:Ge(v.sentDate),accountId:I});return f},[o,z,I]),xt=c.useCallback((f,v)=>v.shiftKey?(ge(D,f,M),!0):v.metaKey||v.ctrlKey?(Y(f),!0):(L(),V(f),!1),[D,M,ge,Y,L,V]),ot=c.useCallback(f=>{!h||f.length===0||(ze.current=M??null,E(f))},[h,M]),_e=c.useCallback(f=>{const v=Mn(D,M,f);v!==void 0&&(ge(D,v),be.current=v,le.current=!1,Ie(void 0),Ce(v))},[D,M,ge]),ue=c.useCallback(()=>_e(-1),[_e]),it=c.useCallback(()=>_e(1),[_e]),rt=c.useCallback(()=>{D.length>0&&pe(D)},[D,pe]),at=c.useCallback(f=>{const v=Li({verb:f,confirmingDelete:xe!==null,hasSelection:ne,junkMailboxId:fe,currentMailboxId:e,deletableMessageId:h?M:void 0});return v.kind==="openWizard"?(P(f),!0):v.kind==="confirmDelete"?(ot([v.messageId]),!0):v.kind==="unavailable"?(ie({severity:"warning",title:v.reason}),!0):v.kind==="withheld"},[xe,h,ne,fe,e,P,M,ot,ie]),de=c.useCallback((f,v)=>{const he=o.find(Q=>Q.messageId===f)?.threadId;he&&G({threadId:he,messageId:f},{replace:v?.replace})},[G,o]),lt=c.useCallback(()=>{M&&de(M)},[M,de]),bt=c.useCallback(f=>de(f,{replace:!0}),[de]);Rn({keyboardFocusedMessageId:Oe,openMessageId:t,enabled:R&&_===0,open:bt});const Qe=T.phase.kind==="escalated"?{scope:Nt(u??{}),total:T.phase.total,searchQuery:u??{},run:(f,v)=>T.runAction(f,void 0,v),stop:T.stop}:void 0,ct=c.useCallback(f=>{if(f.length===0){E(null);return}const v=new Set(f),he=o.findIndex(U=>v.has(U.messageId));let Q;for(let U=he+1;U<o.length;U++)if(!v.has(o[U].messageId)){Q=o[U].messageId;break}if(Q===void 0){for(let U=he-1;U>=0;U--)if(!v.has(o[U].messageId)){Q=o[U].messageId;break}}h?.(f),L(),ze.current=null,E(null),Q!==void 0&&(be.current=Q,le.current=!1,N(Q),R&&de(Q,{replace:!0})),R||ae(qs("delete",f.length,re))},[o,h,L,de,R,N,re]),ut=c.useCallback(()=>{const f=ze.current;ze.current=null,E(null),f!==null&&(be.current=f,le.current=!1,N(f))},[N]),Ue=c.useMemo(()=>Ji(o,z,I),[I,z,o]),vt=c.useCallback(()=>{if(Qe){Ee();return}P("organize")},[Qe,Ee,P]),St=c.useCallback(f=>{h?.([f])},[h]),dt=c.useCallback((f,v)=>{ke([f],!v)},[ke]),yt=c.useCallback(f=>{R||Te(f)},[R,Te]),C=c.useCallback(()=>{if(T.isRunning||T.phase.kind==="counting"){T.stop();return}L()},[T,L]),H=c.useCallback(()=>{T.clear()},[T]);c.useEffect(()=>{if(le.current||!R&&t)return;const f=q>=0?q:Ve;f>=0&&ce.scrollToIndex(f,{align:"auto"})},[q,Ve,ce,R,t]),c.useEffect(()=>{t&&(le.current=!1,N(t))},[t,N]),c.useEffect(()=>{M&&(o.some(f=>f.messageId===M)||N(o[0]?.messageId))},[o,M,N]),c.useEffect(()=>{O?.({focusedMessageId:M,selectedIds:Array.from(z),hasList:Me})},[M,z,Me,O]);const $=c.useRef(O);$.current=O,c.useEffect(()=>()=>$.current?.({focusedMessageId:void 0,selectedIds:[],hasList:!1}),[]),c.useEffect(()=>{T.phase.kind!=="idle"||T.isRunning||Ze(o.map(f=>f.messageId))},[o,Ze,T.phase,T.isRunning]);const zt=c.useRef(e);c.useEffect(()=>{zt.current!==e&&(zt.current=e,L())},[e,L]),En({shouldBlockFn:({action:f})=>Pi(f,ne,Se)?(L(),!0):!1,enableBeforeUnload:!1,disabled:!ne||Se!==void 0}),c.useEffect(()=>{const f=J.current;if(!f||!S||!p)return;const v=()=>{if(y)return;const{scrollTop:he,scrollHeight:Q,clientHeight:U}=f;he+U>=Q-200&&p()};return f.addEventListener("scroll",v,{passive:!0}),v(),()=>f.removeEventListener("scroll",v)},[S,y,p]),c.useEffect(()=>{const f=be.current;if(!f)return;const v=J.current?.querySelector(`[data-message-id="${f}"]`);v&&(be.current=null,v.focus({preventScroll:!0}))}),c.useEffect(()=>{if(A){if(!Me){A.current=null;return}return A.current={focusNext:Fe,focusPrevious:nt,focusFirst:qe,focusLast:He,openFocused:lt,toggleSelect:ve,extendSelectDown:it,extendSelectUp:ue,selectAll:rt,clearSelection:()=>ne?(L(),!0):!1,requestVerb:at,toggleDensity:K},()=>{A.current=null}}},[A,Me,Fe,nt,qe,He,lt,ve,it,ue,rt,ne,L,at,K]);const Ft=s?"loading":n?"error":o.length===0?"empty":"ready",fs=n?No(i):void 0,ms=c.useCallback(()=>{const f=Hs(Qs());window.open(f,"_blank","noopener,noreferrer")},[]),gs=[{id:"inbox",threads:[]}],Ct=D.length>0&&D.every(f=>z.has(f)),ps=we&&S&&Ct&&!g&&!m&&T.phase.kind==="idle"&&!T.isRunning,xs=g||m||T.isRunning,It=T.phase.kind==="escalated"?T.phase.total:T.progress?T.progress.total:_,bs=T.runningAction?Us(T.runningAction.kind,T.progress?.done??0,T.progress?.total??It):T.phase.kind==="counting"?"Counting matches…":T.phase.kind==="escalated"?_i(u??{},T.phase.total):void 0,vs=T.phase.kind!=="escalated"&&D.length>0?{checked:Ct,indeterminate:_>0&&!Ct,onChange:()=>te(D)}:void 0,Ss=T.runningAction?{value:T.progress?.done??0,max:T.progress?.total??It,tone:Js(T.runningAction.kind)}:void 0,ys=(T.isRunning||T.phase.kind==="counting"?{tone:"info",text:"",action:{label:"Stop",onClick:T.stop}}:T.phase.kind==="escalated"?{tone:"info",text:"",action:{label:"Clear selection",onClick:H}}:ps?{tone:"info",text:"",action:{label:Di(u??{}),onClick:T.escalate}}:void 0)??(Ue?{tone:"warning",text:Ue}:void 0),Cs=r.jsx(On,{title:W.title||b,navSlot:W.navSlot,titleMeta:W.titleMeta,searchSlot:W.searchSlot,searchField:W.searchField,idleSlot:W.makeFilterSlot,count:It,onCancel:C,onDelete:()=>P("delete"),onMove:()=>P("move"),onOrganize:vt,onJunk:me?()=>P("junk"):void 0,onMarkRead:()=>P("markRead"),overflowSlot:I&&e&&_>0&&Pe.length>0?r.jsx(Fo,{accountId:I,mailboxId:e,messageIds:Array.from(z)}):void 0,isBusy:xs,isCounting:T.phase.kind==="counting",selectAll:vs,statusLabel:bs,progress:Ss,notice:ys}),Is=An(D,M),ks=c.useCallback(f=>{le.current=!0,N(f)},[N]),Ts=r.jsxs(r.Fragment,{children:[ye&&a&&r.jsx(Uo,{query:a,count:d}),r.jsxs("div",{ref:J,role:"listbox","aria-multiselectable":!0,"aria-label":b,className:"flex-1 overflow-y-auto",children:[r.jsx("div",{role:"presentation",className:"relative w-full",style:{height:`${ce.getTotalSize()}px`},children:ce.getVirtualItems().map(f=>{const v=o[f.index];return r.jsx("div",{role:"presentation","data-index":f.index,ref:ce.measureElement,className:Re("absolute left-0 top-0 w-full border-b border-line",T.isRunning&&"pointer-events-none opacity-50"),style:{transform:`translateY(${f.start}px)`},children:r.jsx(Vi,{thread:v,mailboxId:e,isSelected:t===v.messageId,isFocused:M===v.messageId,isTabStop:Is===v.messageId,onFocusRow:ks,isChecked:ee(v.messageId),onToggleCheck:Y,onRowSelect:xt,isMultiSelectMode:We,onLongPress:yt,isDesktop:R,onDelete:St,onToggleRead:dt,density:X})},f.key)})}),y&&r.jsx(bo,{})]})]});return r.jsxs(r.Fragment,{children:[st&&!R&&r.jsx(ft,{tone:"success",variant:"soft",className:"m-2 rounded-md",onDismiss:()=>ae(null),children:st}),r.jsx(vo,{listTitle:b,listMeta:x,sections:gs,flatList:!0,listState:W.searchResults?"ready":Ft,searchQuery:k,listFilter:w,listScopeLabel:j,errorMessage:fs,onRetry:l,onReportError:ms,density:X,selectedThreadId:t,onSelectThread:f=>de(f),isDesktop:R,hideHeader:B,selectionBar:Cs,listBody:W.searchResults??(Ft==="ready"?Ts:void 0)}),r.jsx(Nn,{isOpen:xe!==null,messageIds:xe??[],outcome:re,accountId:I,trashFolderLabel:b,staleFolderLabel:Be,guessedMailboxId:Ne,isDeleting:g,onConfirm:ct,onCancel:ut}),r.jsx(zn,{verb:F,accountId:I,mailboxId:e,mailboxLabel:b,selection:De,selectionRestriction:Ue?"spansAccounts":void 0,escalated:Qe,escalatedProgress:T.progress,onFinished:L,onRunEnded:Xe})]})},Yi=e=>Ht({path:{accountId:e}}),Zi=e=>{const o=wt(),t=Rt(),s=Mt({...Gs(),onSuccess:()=>{t.recordEvent("sync.triggered"),o.invalidateQueries({queryKey:Yi(e)})}});return{trigger:()=>{s.mutate({path:{accountId:e}})},triggerAsync:()=>s.mutateAsync({path:{accountId:e}}),isPending:s.isPending,error:s.error,reset:s.reset}},Xi=({accountId:e,children:o})=>{const{triggerAsync:t,isPending:s}=Zi(e);return r.jsx(Jo,{onRefresh:t,isRefreshing:s,children:o})};function er({accountId:e,currentMailboxId:o,candidates:t,onMove:s,children:n}){const[i,l]=c.useState(!1),a=Rt(),u=Ys(),{inboxMailboxId:d}=Dn(e),h=_n(e),{data:g}=mt({...Zs({path:{accountId:e}}),staleTime:1/0}),m=c.useMemo(()=>Xs({mailboxes:g?.items??[],folderAppointments:h,currentMailboxId:o,translator:u}),[g?.items,h,o,u]),p=c.useMemo(()=>d||(m.find(x=>x.label.toLowerCase()==="inbox")?.id??m.find(x=>!x.isCurrent)?.id??""),[d,m]),S=c.useRef(!1);c.useEffect(()=>{S.current||(S.current=!0,Ln(a,t.length))},[a,t.length]);const y=c.useCallback(()=>{Pn(a,t.length),l(!0)},[a,t.length]),I=c.useCallback((b,x)=>{$n(a,{selected:b.length,total:t.length,toInbox:x===d}),s(b,x)},[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(Yo,{count:t.length,onReview:y})}),r.jsx("div",{className:"min-h-0 flex-1",children:n}),r.jsx(li,{open:i,candidates:t,defaultDestinationId:p,availableFolders:m,delimiter:en(g?.items??[]),onConfirmMove:I,onCancel:()=>l(!1)})]})}const tr=(e,o,t,s)=>`${e??""}|${o}|${t??""}|${s??""}`,sr=({accountId:e,mailboxId:o})=>{const t=wt(),{pushError:s}=qt(),{requestAppointment:n}=tn(),{trashByAccount:i}=ns(),l=e?i.get(e):void 0,a=tr(e,o,l?.mailboxId,l?.source),[u,d]=c.useState({scope:a});u.scope!==a&&d({scope:a});const h=u.scope===a?u:void 0,g=c.useCallback(()=>t.getQueryData(sn())?.accounts.find(j=>j.accountId===e)?.folderAppointments.find(j=>j.role==="Trash")?.mailboxId??o,[t,e,o]),m=c.useRef(void 0),{mutateAsync:p,isPending:S}=Mt({...cn(),meta:ln(409),onMutate:()=>(m.current=a,{scope:a,listMailboxId:g()}),onSuccess:(x,w,k)=>{k.scope===a&&d({scope:a,deletedCount:x.deletedCount})},onError:(x,w,k)=>{const j=rn(x);if(!j){s({title:"Couldn't empty Trash",detail:an(x),error:x});return}k?.scope===a&&d({scope:a,refusal:j})},onSettled:(x,w,k,j)=>{m.current===j?.scope&&(m.current=void 0),nn(t,on([j?.listMailboxId??o])),e&&t.invalidateQueries({queryKey:Ht({path:{accountId:e}})})}}),y=c.useCallback(()=>e?(d({scope:a}),p({path:{accountId:e}}).then(()=>{},()=>{})):Promise.resolve(),[e,a,p]),I=c.useCallback(()=>{y()},[y]),b=c.useCallback(()=>{const x=h?.refusal;x&&n({accountId:x.accountId,role:x.role,reason:x.reason,action:{kind:"emptyTrash"},onAppointed:y})},[h,n,y]);return{emptyTrash:I,isEmptying:S&&m.current===a,deletedCount:h?.deletedCount,refusal:h?.refusal,repair:b}},nr="We can verify this sender";function or(e){const{data:o}=mt({...un({path:{mailboxId:e??""},query:{senderTrust:["vip","wellknown"],dkimMismatch:!1,results:!0,limit:500}}),enabled:!!e,staleTime:6e4});return{candidates:(o?.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:nr,trustSubReason:Bn(s.senderTrust),senderTrust:s.senderTrust}))}}const ir=6e4,rr=({mailboxId:e,criteria:o,enabled:t})=>{const s={...o,count:!0,results:!1},{data:n}=mt({queryKey:Qt({path:{mailboxId:e},query:s}),queryFn:async()=>{const{data:i}=await Ut({path:{mailboxId:e},query:s,throwOnError:!0});return i},enabled:t,staleTime:ir});return t?_o(n?.count):{kind:"unknown"}},ar=e=>{const o=new Set,t=[];for(const s of e)o.has(s.threadMessageId)||(o.add(s.threadMessageId),t.push(s));return t},lr=50,ds=c.createContext(null);function pt(){const e=c.useContext(ds);if(!e)throw new Error("MailboxPane.* must be used inside <MailboxPane>");return e}function cr({mailboxId:e,thread:o,children:t}){const s=Ye(),n=wo(),i=qo(),l=o?.threadId,a=o?.messageId,u=Rt(),{accounts:d,searchQuery:h,onToggleIntelligence:g,onSearchClearQuery:m}=Jt(),p=pn(),S=Vo(h),y=S.length>0,{freeText:I,tokens:b}=Dt(S,p),x=Dt(h.trim(),p).freeText,[w,k]=c.useState("all"),[j,O]=c.useState(new Set),A=c.useMemo(()=>({category:w,attributes:j}),[w,j]),B=c.useMemo(()=>Wn(A),[A]),J=y||Kn(A),{params:G,residual:R}=Vn(b,B),oe={order:"desc",...I?{query:I}:{},...G,...B},F={...oe,limit:lr},P={category:F.category,unread:F.unread,starred:F.starred,attachments:F.attachments},Ee=J?Qt({path:{mailboxId:e},query:F}):dn({path:{mailboxId:e},query:{order:"desc"}}),{data:Se,isLoading:ye,isError:W,error:Pe,refetch:ie,fetchNextPage:M,hasNextPage:Ce,isFetchingNextPage:Oe}=So({queryKey:Ee,queryFn:async({pageParam:C})=>{if(J){const{data:$}=await Ut({path:{mailboxId:e},query:{...F,continuationToken:C},throwOnError:!0});return $}const{data:H}=await gn({path:{mailboxId:e},query:{order:"desc",continuationToken:C},throwOnError:!0});return H},initialPageParam:void 0,getNextPageParam:C=>C.continuationToken,placeholderData:(C,H)=>po(H?.queryKey,P)?C:void 0}),Ie=rr({mailboxId:e,criteria:oe,enabled:Lo({hasSearchQuery:y,freeText:I,residualTokenCount:R.length})}),{accountId:N,isLoading:X}=qn(e),$e=Mo({accounts:d}),K=Hn(Qn(ar(Se?.pages.flatMap(C=>C.items??[])??[])),R,N),ke=c.useCallback(C=>{k(C)},[]),fe=c.useCallback(C=>{O(H=>{const $=new Set(H);return $.has(C)?$.delete(C):$.add(C),$})},[]),me=c.useCallback(()=>{k("all"),O(new Set)},[]),Ae=c.useCallback(()=>{me(),m()},[me,m]),re=yo({chips:A,tokens:b,reach:R.length>0?"loaded-pages":Un(F),onClear:Ae}),Be=l?K.find(C=>C.messageId===a)??K.find(C=>C.threadId===l):void 0,Ne=Jn(l,a),z=Be??Ne,_=a??z?.messageId,ne=c.useMemo(()=>{if(l)return{threadId:l,mailboxId:z?.mailboxId??e,subject:z?.subject,messageId:_,authenticity:z?.authenticity}},[l,z,_,e]),ee=c.useCallback(C=>{_&&C.includes(_)&&n()},[_,n]),{deleteMessages:Y,isPending:Te}=_t({mailboxId:e,onAfterOptimisticRemove:ee}),{moveMessages:je,isPending:ge}=Lt({mailboxId:e,accountId:N,onAfterOptimisticRemove:ee}),V=c.useRef(null),pe=Gn(),{listCommandsRef:te,onTriageContextChange:Ze,focusedMessageId:We,selectedIds:xe}=pe,E=K.find(C=>C.messageId===We)??z,Xe=Ro({accounts:d})??null,we=Yn({thread:z,isOpen:!0,mailboxId:e,accountId:N,onAfterOptimisticRemove:ee}),{draftsMailboxId:et}=Zn(N),T=et!==void 0&&et===e,{archiveMailboxId:tt}=Xn(N),Ke=eo(),L=hn(),st=c.useMemo(()=>fn(L,l,_),[L,l,_]),ae=c.useMemo(()=>{if(E)return C=>L({threadId:E.threadId,messageId:E.messageId,mode:C})},[L,E]),be=To(),le=mn(),ze=jo(),Me=c.useCallback(C=>C?Ke(C):[],[Ke]),{toggleStar:ce}=to({threadId:E?.threadId??"",mailboxId:e}),{toggleReadFor:Ve}=es({mailboxId:e,accountId:N}),{junkMailboxId:q}=ts(N),se=q!=null&&q===e,Fe=ss(q,e),{candidates:nt}=or(se?q:void 0),{moveMessages:qe}=Lt({mailboxId:e,threadId:E?.threadId,accountId:N,onAfterOptimisticRemove:ee}),{deleteMessages:He}=_t({mailboxId:e,threadId:E?.threadId,onAfterOptimisticRemove:ee}),{addressId:ve,address:D}=so(E),{updateFlags:De}=no({addressId:ve,senderEmail:E?.fromEmail??void 0}),xt=c.useCallback(()=>ae?.("reply"),[ae]),ot=c.useCallback(()=>ae?.("reply-all"),[ae]),_e=c.useCallback(()=>ae?.("forward"),[ae]),ue=c.useCallback(()=>Me(E),[Me,E]),it=c.useCallback(()=>{if(te.current?.requestVerb("delete"))return;const C=ue();C.length>0&&He(C)},[te,ue,He]),rt=c.useCallback(()=>{if(te.current?.requestVerb("junk")||!Fe)return;const C=ue();C.length!==0&&(oo(u,{count:C.length,senderTrust:E?.senderTrust??"unknown",wasRescuable:E?io(E):!1}),qe(C,Fe))},[te,Fe,ue,qe,u,E]),at=c.useCallback(()=>{if(xe.length>0){const C=!(E?.hasStars??!1),H=new Set(xe);for(const $ of K)H.has($.messageId)&&$.hasStars!==C&&ce($.messageId,$.hasStars);return}E&&ce(E.messageId,E.hasStars)},[xe,K,E,ce]),de=c.useCallback(()=>{if(te.current?.requestVerb("markRead"))return;const C=ue();if(C.length===0)return;const H=!(E?.isRead??!1);Ve(C,H)},[te,ue,E,Ve]),lt=c.useCallback(()=>{if(!ve)return;const C=D?.flags?.muted?.value!==!0;De({muted:{value:C}})},[ve,D,De]),bt=c.useCallback(()=>{if(!ve)return;const C=D?.flags?.vip?.value!==!0;De({vip:{value:C}})},[ve,D,De]),Qe=c.useCallback(()=>{V.current?.open()},[]),ct=T?"drafts":tt===e?"archive":q===e?"junk":"inbox",ut=c.useRef("");c.useEffect(()=>{const C=ut.current;ut.current=S,S.length>0&&C.length===0&&u.recordEvent("search.submitted",{mailboxType:ct})},[S,ct,u]);const{goBack:Ue,nextMessageId:vt,previousMessageId:St}=ro({context:pe,orderedIds:K.map(C=>C.messageId),selectedMessageId:_,enabled:!be&&!le,hasOpenThread:l!==void 0,onClose:n,handlers:{reply:xt,replyAll:ot,forward:_e,delete:it,toggleStar:at,toggleRead:de,muteSender:lt,blockSender:z?Qe:void 0,vipSender:bt,markJunk:rt,toggleIntelligence:z?()=>V.current?.toggle():void 0,compose:ze,goBrief:()=>i("brief"),goInbox:()=>i("brief"),goSent:()=>i("brief"),goFlagged:()=>i("flagged"),goSettings:()=>i("settings")}}),dt=C=>{if(!C)return;const H=K.find($=>$.messageId===C);return H?{threadId:H.threadId,messageId:C}:void 0},yt={mailboxId:e,selectedMessageId:_,selectedThread:z,conversation:ne,onOpenThread:s,threads:K,isLoading:ye,isError:W,error:Pe,mailboxAccountId:N,mailboxAccountLoading:X,mailboxName:$e,unreadCount:Xe,isDraftsMailbox:T,isSpamFolder:se,rescueCandidates:nt,filterCategory:w,filterAttributes:j,onSelectFilterCategory:ke,onToggleFilterAttribute:fe,onClearFilters:me,listFilter:re,listSearchText:x||void 0,onToggleIntelligence:g,intelligenceRef:V,handleDeselectIfRemoved:ee,searchPredicate:y&&R.length===0?F:void 0,resultCount:Ie,onDeleteMessages:Y,onMoveMessages:je,isDeleting:Te,isMoving:ge,onLoadMore:M,hasMore:Ce,isLoadingMore:Oe,onTriageContextChange:Ze,listCommandsRef:te,onRetry:()=>ie(),onReply:st,onToolbarDelete:we.deleteThread,onToolbarStar:we.toggleStar,isStarred:we.isStarred,onToolbarMove:we.moveThread,onBack:Ue,nextThread:dt(vt),previousThread:dt(St)};return r.jsx(ds.Provider,{value:yt,children:t})}function hs(){const{mailboxId:e,selectedMessageId:o,threads:t,isLoading:s,isError:n,error:i,onDeleteMessages:l,onMoveMessages:a,isDeleting:u,isMoving:d,onLoadMore:h,hasMore:g,isLoadingMore:m,mailboxAccountId:p,mailboxName:S,unreadCount:y,isDraftsMailbox:I,isSpamFolder:b,rescueCandidates:x,onTriageContextChange:w,listCommandsRef:k,onRetry:j,filterCategory:O,filterAttributes:A,onSelectFilterCategory:B,onToggleFilterAttribute:J,onClearFilters:G,listFilter:R,listSearchText:oe,searchPredicate:F,resultCount:P}=pt(),{searchQuery:Ee,searchInput:Se,accounts:ye,resultFolderIndex:W}=Jt(),Pe=Ko(),ie=Ye(),M=S??"Inbox",Ce=c.useMemo(()=>ho(),[]),{trashMailboxId:Oe}=fo(p),Ie=Eo({accounts:ye}),{trashByAccount:N}=ns(),X=sr({accountId:p,mailboxId:e}),$e=Oe!=null&&Oe===e,K=c.useMemo(()=>p?[p]:[],[p]),{hasNewMail:ke}=bn(),{state:fe,errorMessage:me,refresh:Ae}=vn(K,{onSettled:j}),re=c.useMemo(()=>r.jsx(Sn,{state:fe,onRefresh:Ae,label:`Refresh ${M}`,errorMessage:me,hasUpdate:ke(K)}),[fe,Ae,M,me,ke,K]),Be=c.useMemo(()=>t.map(V=>mo(V,W)),[t,W]),{hits:Ne,isLoading:z}=Po({mailboxId:e,filterCategory:O}),_=c.useMemo(()=>go(Ne,t.map(V=>V.threadId),W),[Ne,t,W]),ne=c.useCallback(V=>{const pe=V.threadId??t.find(te=>te.messageId===V.id)?.threadId;pe&&ie({threadId:pe,messageId:V.id},{mailboxId:V.mailboxId??e,query:Se})},[e,ie,Se,t]);if(I&&p)return r.jsx(gi,{accountId:p,selectedMessageId:o,imapThreads:t,title:S??"Drafts",unreadCount:y??void 0});const ee=r.jsx(Gi,{mailboxId:e,threads:t,selectedMessageId:o,isLoading:s,isError:n,error:i,onRetry:j,searchQuery:Ee,searchPredicate:F,resultCount:P,onDeleteMessages:l,isDeleting:u,isMoving:d,onLoadMore:h,hasMore:g,isLoadingMore:m,accountId:p,listTitle:M,listFilter:R,listSearchText:oe,listScopeLabel:M,hideHeader:!0,onTriageContextChange:w,commandsRef:k}),Y=ye[0]?.accountId,Te=Pe==="phone"&&Y?r.jsx(Xi,{accountId:Y,children:ee}):ee,je=b&&x.length>0&&p?r.jsx(er,{accountId:p,currentMailboxId:e,candidates:x,onMove:a,children:Te}):Te,ge=$e?r.jsx(bi,{messageCount:Ie,isEmptying:X.isEmptying,deletedCount:X.deletedCount,refusalReason:X.refusal?.reason,trashFolderLabel:S??void 0,staleFolderLabel:p?N.get(p)?.staleFolderPath:void 0,onEmpty:X.emptyTrash,onRepair:X.repair,children:je}):je;return r.jsx(Co,{title:M,unreadCount:y,preset:Ce,selectedCategory:O,activeFilters:A,onSelectCategory:B,onToggleFilter:J,onClearFilters:G,searchResults:Be,searchLoading:s,relatedResults:_,relatedLoading:z,onSelectSearchResult:ne,searchResultsInBody:!0,refreshControl:re,children:ge})}function ur(){const{mailboxId:e,mailboxAccountId:o,mailboxAccountLoading:t,selectedThread:s,conversation:n,onReply:i,onToolbarDelete:l,onToolbarStar:a,isStarred:u,onToolbarMove:d,handleDeselectIfRemoved:h,intelligenceRef:g}=pt(),m=!!n,p=co(n?.threadId);os(g,p);const S=c.useRef(null),{railFits:y,openRail:I}=p;c.useEffect(()=>{if(!y)return;const x=s?.messageId??null;x&&S.current!==x&&s?.authenticity?.dkimMismatch&&(S.current=x,I())},[y,I,s?.messageId,s?.authenticity?.dkimMismatch]);const b=n?r.jsx(is,{threadId:n.threadId,mailboxId:n.mailboxId,subject:n.subject,selectedMessageId:n.messageId,authenticity:n.authenticity,onOpenIntelligence:p.open,listOnScreen:!0}):r.jsx(xn,{});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(uo,{hasThread:m,messageId:n?.messageId,intelligenceOpen:p.isShowing,canToggleIntelligence:p.canToggle,onToggleIntelligence:p.toggle,onReply:i?()=>i("reply"):void 0,onReplyAll:i?()=>i("reply-all"):void 0,onForward:i?()=>i("forward"):void 0,onDelete:m?l:void 0,onToggleStar:m?a:void 0,isStarred:u,moveContext:m&&o?{accountId:o,currentMailboxId:e,onMove:d}:void 0,moveContextLoading:t}),r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:b})]}),r.jsx(rs,{isOpen:p.drawerOpen,onClose:p.closeDrawer,thread:s,mailboxId:e,accountId:o,onAfterOptimisticRemove:h})]})}function dr(){const{mailboxId:e,mailboxAccountId:o,selectedThread:t,onToggleIntelligence:s,handleDeselectIfRemoved:n}=pt();return r.jsx(lo,{onClose:s,thread:t,mailboxId:e,accountId:o,onAfterOptimisticRemove:n})}function hr(){const{mailboxId:e,mailboxAccountId:o,selectedThread:t,conversation:s,onOpenThread:n,onBack:i,nextThread:l,previousThread:a,handleDeselectIfRemoved:u,intelligenceRef:d}=pt(),h=ao(s?.threadId??null);return os(d,h),s?r.jsxs(r.Fragment,{children:[r.jsx(is,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onBack:i,onOpenIntelligence:h.toggle,onSwipeNext:l?()=>n(l):void 0,onSwipePrevious:a?()=>n(a):void 0,mobileIntelligenceOpen:h.isOpen}),r.jsx(rs,{isOpen:h.isOpen,onClose:h.close,thread:t,mailboxId:e,accountId:o,onAfterOptimisticRemove:u})]}):r.jsx(hs,{})}const Fr=Object.assign(cr,{List:hs,Reading:ur,Intelligence:dr,Phone:hr});export{Fr as M};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{v as n,j as a,f as o}from"./index-
|
|
1
|
+
import{v as n,j as a,f as o}from"./index-D5g4bLbz.js";import{M as e}from"./menu-BpzHKPjy.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};
|