@remit/web-client-dist 0.0.499 → 0.0.500

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/assets/{BriefPane-CKtXwVBp.js → BriefPane-fgglnatY.js} +1 -1
  2. package/assets/CalendarComposePane-BEhXFRNY.js +1 -0
  3. package/assets/{CalendarComposeSeed-BleJnybX.js → CalendarComposeSeed-1o7cctlZ.js} +1 -1
  4. package/assets/{CalendarShell-zof5eCQ2.js → CalendarShell-BR_H2gZU.js} +1 -1
  5. package/assets/{EmptyState-DvQRX_aF.js → EmptyState-DVYgX544.js} +1 -1
  6. package/assets/{ErrorState-BTKMU75C.js → ErrorState-BleXKJHk.js} +1 -1
  7. package/assets/{FlaggedPane-ByJlETic.js → FlaggedPane-Bu364oKX.js} +1 -1
  8. package/assets/{FullCompose-d06QLAHp.js → FullCompose-BymaWkcy.js} +1 -1
  9. package/assets/MailListHeader-DNNQqKng.js +7 -0
  10. package/assets/{MailNav-BNTkiu_q.js → MailNav-Cbp-4SQL.js} +1 -1
  11. package/assets/{MailShell-CTZPp0Re.js → MailShell-zsMkXesR.js} +1 -1
  12. package/assets/{MailViewChrome-D6dp5o8D.js → MailViewChrome-fZj0ArTU.js} +1 -1
  13. package/assets/{MailboxPane-FCYdo4UF.js → MailboxPane-BCpSAQxz.js} +1 -1
  14. package/assets/{NavMenuButton-BBgEotre.js → NavMenuButton-Cy3wfV_4.js} +1 -1
  15. package/assets/{OnboardingWizard-O7uOuS4V.js → OnboardingWizard-C0enCuWZ.js} +1 -1
  16. package/assets/OpenCalendarEvent-C5lxHgzW.js +2 -0
  17. package/assets/{OutboxPane-BMASiNu4.js → OutboxPane-CPuri_-t.js} +1 -1
  18. package/assets/_calendarObjectId-C9igvssD.js +1 -0
  19. package/assets/_mailboxId-DhisJD-h.js +1 -0
  20. package/assets/_messageId-B-3UkoxD.js +1 -0
  21. package/assets/_messageId-C7xHbVCJ.js +1 -0
  22. package/assets/_messageId-qEGIcpzX.js +1 -0
  23. package/assets/_outboxMessageId-vzU_xU-x.js +1 -0
  24. package/assets/_recurrenceId-C8DQ9zEj.js +1 -0
  25. package/assets/_threadId-BCwDTsoq.js +1 -0
  26. package/assets/_threadId-UD63TK5q.js +1 -0
  27. package/assets/_threadId-cd-01Yw7.js +1 -0
  28. package/assets/_view._date-Cw4OQJQA.js +1 -0
  29. package/assets/{accounts-C6uEuF_p.js → accounts-JPU6qeqr.js} +1 -1
  30. package/assets/{advanced-BvZ3tR29.js → advanced-CRstRXZC.js} +1 -1
  31. package/assets/{appearance-BnEqTkyA.js → appearance-B3mo-Efk.js} +1 -1
  32. package/assets/{attachment-file-oJZ9yins.js → attachment-file-CpL7m-pT.js} +1 -1
  33. package/assets/attendee-row-CoHhwyac.js +1 -0
  34. package/assets/{avatar-CqkxkswH.js → avatar-Dhuh2LQT.js} +1 -1
  35. package/assets/{bottom-sheet-fs9OBYtF.js → bottom-sheet-BjcZ6YFL.js} +1 -1
  36. package/assets/brief-BdF7_3E8.js +1 -0
  37. package/assets/{brief-774l0uSF.js → brief-UpC-QlQw.js} +1 -1
  38. package/assets/{browser-ponyfill-BlLsKXkK.js → browser-ponyfill-CN2_bARG.js} +1 -1
  39. package/assets/{bug-Tu7riTlE.js → bug-HZTqaNXE.js} +1 -1
  40. package/assets/{calendar-Cl2W2o0S.js → calendar-PvhEdckc.js} +1 -1
  41. package/assets/calendar-color-Y2I90IzB.js +1 -0
  42. package/assets/{calendar-days-DpqXNRgw.js → calendar-days-BMxBKGfl.js} +1 -1
  43. package/assets/calendar-event-chip-DJvqkldG.js +1 -0
  44. package/assets/{card-BreoBwsv.js → card-BPmZMUc_.js} +1 -1
  45. package/assets/chevron-left-CvcXjrrZ.js +1 -0
  46. package/assets/{circle-check-DPOAEaWy.js → circle-check-9A8XPDHY.js} +1 -1
  47. package/assets/{circle-check-big-BNnaBoH4.js → circle-check-big-CynPyNzi.js} +1 -1
  48. package/assets/{circle-help-CowAqERz.js → circle-help-DRU9tw8o.js} +1 -1
  49. package/assets/{clock-CdKU6IY6.js → clock-BcxpC4rD.js} +1 -1
  50. package/assets/compose._-_outboxMessageId_-BvjQtrB7.js +1 -0
  51. package/assets/compose._-_outboxMessageId_-CvtIn52r.js +1 -0
  52. package/assets/compose._-_outboxMessageId_-KeqZ55CW.js +1 -0
  53. package/assets/compose._-_outboxMessageId_-USx36hWa.js +1 -0
  54. package/assets/{config-import-CkHvk2di.js → config-import-DY-fa3Wg.js} +1 -1
  55. package/assets/{confirm-dialog-LUxfOOQz.js → confirm-dialog-CvHdDHI1.js} +1 -1
  56. package/assets/{credential-steps-wwxPJSpS.js → credential-steps-BFAlwe5j.js} +1 -1
  57. package/assets/{download-ztZlV0rg.js → download-Cb1Lq4p9.js} +1 -1
  58. package/assets/{filters-CwouDGRw.js → filters-BC-I-EMK.js} +1 -1
  59. package/assets/flagged-Ch2hL1E2.js +1 -0
  60. package/assets/{flagged-U9VY8i5m.js → flagged-SOzARpj9.js} +1 -1
  61. package/assets/{folders-Dn-yY_8K.js → folders-CDmAUHJ7.js} +1 -1
  62. package/assets/{format-D7BNbMxD.js → format-ClD_KeSQ.js} +1 -1
  63. package/assets/{help-copy-CpTWYJnl.js → help-copy-B914q2iU.js} +1 -1
  64. package/assets/{import-BzbFPhHH.js → import-dqy7PmVM.js} +1 -1
  65. package/assets/index-B-3UkoxD.js +1 -0
  66. package/assets/{index-DpaL-MoP.css → index-B67qXWbU.css} +1 -1
  67. package/assets/index-BJS9zkur.js +1 -0
  68. package/assets/{index-BlUbXH1P.js → index-Bi29Egwz.js} +1 -1
  69. package/assets/index-BrvjAUX8.js +1 -0
  70. package/assets/{index-6e6pvyaQ.js → index-BxyGxp9T.js} +8 -8
  71. package/assets/index-C7xHbVCJ.js +1 -0
  72. package/assets/index-Cu6zSgg5.js +1 -0
  73. package/assets/index-D69bNM2X.js +1 -0
  74. package/assets/{index-DgEAInjF.js → index-D9SkFw5L.js} +4 -4
  75. package/assets/index-DDTXgI5K.js +1 -0
  76. package/assets/index-WT6HtGiJ.js +1 -0
  77. package/assets/index-iI-5UHW_.js +1 -0
  78. package/assets/{kbd-DImnxOni.js → kbd-BJjAWQtV.js} +1 -1
  79. package/assets/{labels-Ae3B6-Wa.js → labels-ByaHqZqE.js} +1 -1
  80. package/assets/{mail-DPzNtmsN.js → mail-BkxCAvSO.js} +1 -1
  81. package/assets/{mail-BqpimJgY.js → mail-Bw8uQezm.js} +1 -1
  82. package/assets/map-pin-DzWt5q3h.js +1 -0
  83. package/assets/{menu-Cie-OPPc.js → menu-DAXrok1v.js} +1 -1
  84. package/assets/new-CJGlbe3x.js +1 -0
  85. package/assets/{onboarding-completion-DhVPTUYn.js → onboarding-completion-B9t7Z_cw.js} +1 -1
  86. package/assets/onboarding-p26Z-pCk.js +1 -0
  87. package/assets/outbox-BFvm16x5.js +1 -0
  88. package/assets/{pencil-DFGsLvM-.js → pencil-BJyxAWfp.js} +1 -1
  89. package/assets/{rich-text-qSdpJ23L.js → rich-text-BygjcKYc.js} +1 -1
  90. package/assets/{rich-text-spellcheck-worker-provider-CpsZGtJA.js → rich-text-spellcheck-worker-provider-CVj6U0hx.js} +1 -1
  91. package/assets/{rotate-ccw-DcEcrvaC.js → rotate-ccw-iKiYuqVl.js} +1 -1
  92. package/assets/{row-actions-BeiZetAb.js → row-actions-BydlpOSA.js} +1 -1
  93. package/assets/{search-mirror-jo7pXQAU.js → search-mirror-Dzs5PVYg.js} +1 -1
  94. package/assets/{search-token-index-PUrvPC5c.js → search-token-index-D6wYFkn5.js} +1 -1
  95. package/assets/{sections-BjISOtZ0.js → sections-cpENMndA.js} +1 -1
  96. package/assets/{senders-CpzFFNN8.js → senders-CREMrl6w.js} +1 -1
  97. package/assets/settings-Da5iP_0y.js +1 -0
  98. package/assets/{settings-screen-BUs_y6AL.js → settings-screen-CcOj8iDi.js} +1 -1
  99. package/assets/{shield-check-BhkZhdgI.js → shield-check-9WhoBx4E.js} +1 -1
  100. package/assets/{suggested-vips-zIG-affI.js → suggested-vips-D4dGaBL3.js} +1 -1
  101. package/assets/useCalendarData-js63-ghZ.js +1 -0
  102. package/assets/useCalendars-LjqNzp-x.js +1 -0
  103. package/assets/{useDebouncedValue-CMSCN4-w.js → useDebouncedValue-8pq7LTHi.js} +1 -1
  104. package/assets/{useFilters-C6fHNH70.js → useFilters-CMj6eOER.js} +1 -1
  105. package/assets/{useLabels-Bxx6k_V0.js → useLabels-D5B1kGoe.js} +1 -1
  106. package/assets/{useLayoutTier-Dt8oqQrp.js → useLayoutTier-OpSw01yi.js} +1 -1
  107. package/assets/{useMessageBodyContent-C_a1YUsw.js → useMessageBodyContent-BwehRiRr.js} +1 -1
  108. package/assets/{useQueries-vQUSXdj9.js → useQueries-DPC6qFPY.js} +1 -1
  109. package/assets/{useRefreshControl-jZsIHsQQ.js → useRefreshControl-6jW6ppBV.js} +1 -1
  110. package/assets/{useSearchTokenContext-BA6iRf3_.js → useSearchTokenContext-DFl6G6vt.js} +1 -1
  111. package/assets/{useSemanticSearch-IhTOP1CS.js → useSemanticSearch-B5u3vh1m.js} +1 -1
  112. package/assets/{useSignature-CK6IfoD-.js → useSignature-F-avuinE.js} +1 -1
  113. package/index.html +2 -2
  114. package/package.json +1 -1
  115. package/assets/CalendarComposePane-D6oYPLg8.js +0 -1
  116. package/assets/MailListHeader-hyJQ5XSq.js +0 -7
  117. package/assets/OpenCalendarEvent-Ga_JE-Ds.js +0 -2
  118. package/assets/_calendarObjectId-DypXEFh8.js +0 -1
  119. package/assets/_mailboxId-B3KQlf87.js +0 -1
  120. package/assets/_messageId-C2DpVc4o.js +0 -1
  121. package/assets/_messageId-TSUWebnL.js +0 -1
  122. package/assets/_messageId-quXgQa4n.js +0 -1
  123. package/assets/_outboxMessageId-D6mViyPk.js +0 -1
  124. package/assets/_recurrenceId-r_3FzaJY.js +0 -1
  125. package/assets/_threadId-B4qMLjkm.js +0 -1
  126. package/assets/_threadId-Dv9QcHvC.js +0 -1
  127. package/assets/_threadId-eatYrgrE.js +0 -1
  128. package/assets/_view._date-BqgN6EPL.js +0 -1
  129. package/assets/brief-DgAJrIee.js +0 -1
  130. package/assets/chevron-left-KzEmBaJU.js +0 -1
  131. package/assets/compose._-_outboxMessageId_-387eVRCR.js +0 -1
  132. package/assets/compose._-_outboxMessageId_-B2rYeQhs.js +0 -1
  133. package/assets/compose._-_outboxMessageId_-BdGFYLo7.js +0 -1
  134. package/assets/compose._-_outboxMessageId_-BjXoJi2a.js +0 -1
  135. package/assets/flagged-AINemQFC.js +0 -1
  136. package/assets/index-5RUeCT6r.js +0 -1
  137. package/assets/index-BG6i2W8n.js +0 -1
  138. package/assets/index-BPK58Y5u.js +0 -1
  139. package/assets/index-C2DpVc4o.js +0 -1
  140. package/assets/index-CGL9Ok3T.js +0 -1
  141. package/assets/index-Cdbj0N-E.js +0 -1
  142. package/assets/index-IrGrWaW5.js +0 -1
  143. package/assets/index-TSUWebnL.js +0 -1
  144. package/assets/index-_fW6jWW8.js +0 -1
  145. package/assets/minus-of4tlDqs.js +0 -1
  146. package/assets/new-C9ECYxGJ.js +0 -1
  147. package/assets/onboarding-DZS1dz2F.js +0 -1
  148. package/assets/outbox-nfiPWtDd.js +0 -1
  149. package/assets/settings-BDRT-sfq.js +0 -1
  150. package/assets/useCalendarData-gwYD8mQr.js +0 -1
  151. package/assets/useCalendars-T2P2WC-i.js +0 -1
@@ -1 +0,0 @@
1
- import{R as z,c as ee,a as te,k as _}from"./useCalendars-T2P2WC-i.js";import{j as n,f as j,t as d,Y as ne,Z as ae,ay as y,r as p,ax as se,X as re,i as T,e9 as ie,ea as le,eb as oe,h as ce,s as de,b2 as ue,_ as me}from"./index-6e6pvyaQ.js";import{f as he}from"./ErrorState-BTKMU75C.js";const xe=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],pe=["January","February","March","April","May","June","July","August","September","October","November","December"],ye=["first","second","third","fourth","last"],A="";function fe(e,t){if(!/^\d{4}-\d{2}-\d{2}$/.test(e))return[];const[a,s,i]=e.split("-").map(Number),r=new Date(Date.UTC(a,s-1,i)),l=xe[r.getUTCDay()],o=ye[Math.min(Math.floor((i-1)/7),4)],c=t===""?"":`, ${t}`,f=r.getUTCDay()>=1&&r.getUTCDay()<=5;return[`Every day${c}`,...f?[`Every weekday${c}`]:[],`Every week on ${l}${c}`,`Every month on the ${o} ${l}${c}`,`Every year on ${i} ${pe[s-1]}${c}`]}const ve="w-full rounded-md border border-line bg-surface-sunken px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus-visible:border-line-strong focus-visible:ring-2 focus-visible:ring-ring/30",u=({draft:e,onChange:t},a,s)=>t({...e,[a]:s});function x({label:e,children:t}){return n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:e}),t]})}function ge({draft:e,onChange:t,layout:a="compact",touch:s}){const i=a==="pane";return n.jsx(y,{value:e.title,placeholder:"Title","aria-label":"Title",onChange:r=>u({draft:e,onChange:t},"title",r.target.value),className:d(i?"text-lg font-medium":"text-md font-medium",i?"h-11":s?"min-h-11":"")})}function H(e){return e.allDay||e.startTime===""||e.endTime===""?!1:e.endTime<e.startTime}function be({draft:e,onChange:t,touch:a}){const s=a?"min-h-11":"",i=H(e),r=p.useId();return n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx(y,{type:"date",value:e.date,"aria-label":"Date",onChange:l=>u({draft:e,onChange:t},"date",l.target.value),className:d("w-40",s)}),e.allDay?n.jsx("span",{className:"text-sm text-fg-muted",children:"All day"}):n.jsxs(n.Fragment,{children:[n.jsx(y,{type:"time",value:e.startTime,"aria-label":"Start time",max:e.endTime===""?void 0:e.endTime,"aria-invalid":i,"aria-describedby":i?r:void 0,onChange:l=>u({draft:e,onChange:t},"startTime",l.target.value),className:d("w-28",s,i&&"border-danger/60")}),n.jsx("span",{className:"text-sm text-fg-subtle",children:"to"}),n.jsx(y,{type:"time",value:e.endTime,"aria-label":"End time",min:e.startTime===""?void 0:e.startTime,"aria-invalid":i,"aria-describedby":i?r:void 0,onChange:l=>u({draft:e,onChange:t},"endTime",l.target.value),className:d("w-28",s,i&&"border-danger/60")})]}),n.jsxs("label",{className:"flex items-center gap-2 text-sm text-fg-muted",children:[n.jsx("input",{type:"checkbox",checked:e.allDay,onChange:l=>u({draft:e,onChange:t},"allDay",l.target.checked),className:"size-4 accent-current"}),"All day"]})]}),i&&n.jsxs("p",{id:r,className:"text-xs text-danger",role:"alert",children:["Ends before it starts. Move the end past ",e.startTime,", or start earlier."]})]})}function Ee({draft:e,onChange:t,calendars:a,touch:s}){return n.jsx(Ae,{calendars:a,value:e.calendarId,onChange:i=>u({draft:e,onChange:t},"calendarId",i),touch:s})}function Ne({draft:e,onChange:t,touch:a,repeatEditable:s=!0,onCustom:i}){return s?n.jsx(ke,{value:e.repeat,date:e.date,startTime:e.startTime,onChange:r=>u({draft:e,onChange:t},"repeat",r),onCustom:i,className:a?"min-h-11":""}):n.jsxs("p",{className:"flex items-center gap-2 text-sm text-fg-muted",children:[n.jsx(z,{className:"size-4 shrink-0 text-fg-subtle","aria-hidden":!0}),e.repeat===A?"Does not repeat":e.repeat]})}function je({draft:e,onChange:t,touch:a}){return n.jsx(y,{value:e.location,placeholder:"Location","aria-label":"Location",onChange:s=>u({draft:e,onChange:t},"location",s.target.value),className:a?"min-h-11":""})}function Te({draft:e,onChange:t,touch:a}){return n.jsx(y,{value:e.guests,placeholder:"Guests, comma separated","aria-label":"Guests",onChange:s=>u({draft:e,onChange:t},"guests",s.target.value),className:a?"min-h-11":""})}function Ce({draft:e,onChange:t,layout:a="compact"}){return n.jsx("textarea",{value:e.notes,placeholder:"Notes","aria-label":"Notes",onChange:s=>u({draft:e,onChange:t},"notes",s.target.value),rows:a==="pane"?6:3,className:ve})}function De({draft:e,onChange:t,calendars:a,layout:s="compact",expanded:i=!1,onToggleExpanded:r,onSave:l,onCancel:o,onDelete:c,saveLabel:f="Add",header:g,repeatEditable:b=!0,guestsEditable:I=!1,calendarEditable:M=!0,onCustomRepeat:X,touch:m,className:w}){const v=s==="pane",h={draft:e,onChange:t,layout:s,touch:m},S=n.jsx(ge,{...h}),$=n.jsx(be,{...h}),R=n.jsx(Ee,{...h,calendars:a}),F=n.jsx(Ne,{...h,repeatEditable:b,onCustom:X}),Y=n.jsx(je,{...h}),L=n.jsx(Te,{...h}),P=n.jsx(Ce,{...h}),W=n.jsxs("div",{className:d("flex items-center gap-2",v?"pt-2":"pt-1"),children:[n.jsx(j,{variant:"primary",size:m||v?"md":"sm",onClick:l,disabled:H(e),className:m?"min-h-11 flex-1":"",children:f}),n.jsx(j,{variant:"ghost",size:m||v?"md":"sm",onClick:o,className:m?"min-h-11":"",children:"Cancel"}),c&&n.jsx(j,{variant:"ghost",size:m||v?"md":"sm",onClick:c,className:d("ml-auto text-danger",m&&"min-h-11"),children:"Delete"})]});if(v)return n.jsxs("div",{className:d("flex flex-col gap-5",w),children:[g,n.jsx(x,{label:"Title",children:S}),n.jsx(x,{label:"When",children:$}),M&&n.jsx(x,{label:"Calendar",children:R}),n.jsx(x,{label:"Repeat",children:F}),n.jsx(x,{label:"Location",children:Y}),I&&n.jsx(x,{label:"Guests",children:L}),n.jsx(x,{label:"Notes",children:P}),W]});const Z=r!==void 0&&!i;return n.jsxs("div",{className:d("flex flex-col gap-3",w),children:[g,S,$,M&&R,r&&n.jsxs("button",{type:"button",onClick:r,"aria-expanded":i,className:d("flex items-center gap-1 self-start rounded-sm text-xs font-medium text-fg-muted outline-none hover:text-fg focus-visible:ring-2 focus-visible:ring-ring",m&&"min-h-11"),children:[i?n.jsx(ne,{className:"size-3.5"}):n.jsx(ae,{className:"size-3.5"}),i?"Fewer details":"More details"]}),!Z&&n.jsxs("div",{className:"flex flex-col gap-2 border-t border-line pt-3",children:[Y,I&&L,F,P]}),W]})}const U="__custom__";function ke({value:e,date:t,startTime:a,onChange:s,onCustom:i,className:r}){const l=fe(t,a),o=e===A||l.includes(e)?l:[e,...l];return n.jsxs(se,{icon:n.jsx(z,{className:"size-4"}),"aria-label":"Repeat",value:e,onChange:c=>{if(c.target.value===U){i?.();return}s(c.target.value)},className:r,children:[n.jsx("option",{value:A,children:"Does not repeat"}),o.map(c=>n.jsx("option",{value:c,children:c},c)),i&&n.jsx("option",{value:U,children:"Custom…"})]})}function Ae({calendars:e,value:t,onChange:a,touch:s}){const i=p.useId();return n.jsxs("fieldset",{className:"flex flex-wrap gap-1.5",children:[n.jsx("legend",{className:"sr-only",children:"Calendar"}),e.map(r=>{const l=ee(r.color),o=r.id===t;return n.jsxs("label",{className:d("inline-flex cursor-pointer items-center gap-1.5 rounded-full border px-2.5 text-xs transition-colors","has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-ring",s?"min-h-11":"h-7",o?d(l.soft,l.text,l.border):"border-line text-fg-muted hover:bg-surface-sunken"),children:[n.jsx("input",{type:"radio",name:i,value:r.id,checked:o,onChange:()=>a(r.id),className:"sr-only"}),n.jsx("span",{className:d("size-2 rounded-full",l.solid)}),r.name]},r.id)})]})}function Oe({title:e,subtitle:t,onClose:a,children:s,className:i}){return n.jsxs("section",{className:d("flex h-full w-full flex-col bg-surface",i),children:[n.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[n.jsx("h2",{className:"shrink-0 text-xs font-medium text-fg",children:e}),t!==void 0&&t!==""&&n.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-fg-muted",children:t}),n.jsx("button",{type:"button","aria-label":"Close editor",onClick:a,className:"ml-auto flex size-7 shrink-0 items-center justify-center rounded-md text-fg-subtle outline-none hover:bg-surface-sunken hover:text-fg focus-visible:ring-2 focus-visible:ring-ring",children:n.jsx(re,{className:"size-4"})})]}),n.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-row-inset py-5",children:n.jsx("div",{className:"mx-auto w-full max-w-2xl",children:s})})]})}const E=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],N=["SU","MO","TU","WE","TH","FR","SA"],Q=["January","February","March","April","May","June","July","August","September","October","November","December"],K=["first","second","third","fourth","last"],G=[1,2,3,4,-1],J="MO,TU,WE,TH,FR",Ie=e=>e.replace(/,\s*\d{2}:\d{2}$/,"").trim();function O(e){const t=Ie(e);if(t==="")return"";if(t==="Every day")return"FREQ=DAILY";if(t==="Every weekday")return`FREQ=WEEKLY;BYDAY=${J}`;const a=t.match(/^Every week on (\w+)$/);if(a){const r=E.indexOf(a[1]);return r===-1?void 0:`FREQ=WEEKLY;BYDAY=${N[r]}`}const s=t.match(/^Every month on the (\w+) (\w+)$/);if(s){const r=K.indexOf(s[1]),l=E.indexOf(s[2]);return r===-1||l===-1?void 0:`FREQ=MONTHLY;BYDAY=${G[r]}${N[l]}`}const i=t.match(/^Every year on (\d{1,2}) (\w+)$/);if(i){const r=Q.indexOf(i[2]);return r===-1?void 0:`FREQ=YEARLY;BYMONTH=${r+1};BYMONTHDAY=${Number(i[1])}`}}const Me=e=>e===""?"":`, ${e}`;function Le(e,t){const a=new Map(e.split(";").map(l=>l.split("=")).filter(l=>l.length===2).map(([l,o])=>[l.toUpperCase(),o.toUpperCase()])),s=Me(t),i=a.get("FREQ"),r=a.get("BYDAY");if(!(a.has("INTERVAL")&&a.get("INTERVAL")!=="1")&&!(a.has("UNTIL")||a.has("COUNT"))){if(i==="DAILY")return`Every day${s}`;if(i==="WEEKLY"){if(r===void 0)return;if(r===J)return`Every weekday${s}`;const l=N.indexOf(r);return l===-1?void 0:`Every week on ${E[l]}${s}`}if(i==="MONTHLY"){const l=r?.match(/^(-?\d)([A-Z]{2})$/);if(!l)return;const o=G.indexOf(Number(l[1])),c=N.indexOf(l[2]);return o===-1||c===-1?void 0:`Every month on the ${K[o]} ${E[c]}${s}`}if(i==="YEARLY"){const l=Number(a.get("BYMONTH")),o=Number(a.get("BYMONTHDAY"));return!l||!o||l>12?void 0:`Every year on ${o} ${Q[l-1]}${s}`}}}function Pe(e,t){return{title:"",date:e,startTime:"09:00",endTime:"10:00",allDay:!1,calendarId:t,location:"",guests:"",notes:"",repeat:""}}function We(e,t){return{title:e.title,date:e.start.slice(0,10),startTime:e.allDay?"":e.start.slice(11,16),endTime:e.allDay?"":e.end.slice(11,16),allDay:e.allDay,calendarId:e.calendarId,location:t.location,guests:"",notes:t.notes,repeat:t.repeat}}function q(e,t){return e.allDay?{start:e.date,end:te(e.date,1)}:{start:_(e.date,e.startTime,t),end:_(e.date,e.endTime,t)}}function V(e,t){return e.title.trim()===""?"Give the event a title before saving it.":e.date===""?"Pick the day the event is on.":e.calendarId===""?"Pick the calendar to save the event in.":!e.allDay&&(e.startTime===""||e.endTime==="")?"Set a start and an end time, or mark the event all day.":!e.allDay&&e.endTime<=e.startTime?"The end time is not after the start time. Move one of them.":t&&O(e.repeat)===void 0?"This calendar can't store that repeat rule. Pick one of the offered rules, or turn the repeat off.":""}function _e(e,t){const a=V(e,!0);if(a!=="")return{ok:!1,problem:a};const{start:s,end:i}=q(e,t);return{ok:!0,input:{calendarId:e.calendarId,summary:e.title.trim(),description:e.notes,location:e.location,start:s,end:i,allDay:e.allDay,...t===""?{}:{timeZone:t},recurrenceRule:O(e.repeat)??""}}}function Ue(e,t,a){const s=t.repeat!==e.repeat,i=V(t,s);if(i!=="")return{ok:!1,problem:i};const r={};if(t.title.trim()!==e.title.trim()&&(r.summary=t.title.trim()),t.location!==e.location&&(r.location=t.location),t.notes!==e.notes&&(r.description=t.notes),t.date!==e.date||t.startTime!==e.startTime||t.endTime!==e.endTime||t.allDay!==e.allDay){const{start:o,end:c}=q(t,a);r.start=o,r.end=c,r.allDay=t.allDay,a!==""&&(r.timeZone=a)}return s&&(r.recurrenceRule=O(t.repeat)??""),{ok:!0,patch:r}}const C=de(400,404,412),we=new Set(["calendarEventOperationsListCalendarEvents","calendarEventDetailOperationsGetCalendarEvent","calendarFreeBusyOperationsListCalendarFreeBusy"]),D={kind:"written"},k=e=>ue(e)===412?{kind:"conflict"}:{kind:"refused",message:he(e)},Se={this:"This",following:"Following",all:"All"};function $e(){const e=ce();return p.useCallback(()=>{e.invalidateQueries({predicate:t=>{const a=t.queryKey[0];if(typeof a!="object"||a===null)return!1;const s=a._id;return typeof s=="string"&&we.has(s)}})},[e])}const B=({scope:e,recurrenceId:t})=>e===void 0||e==="all"?{}:{scope:Se[e],recurrenceId:t};function Be(){const e=$e(),t=T({...ie(),meta:C,onSuccess:e}),a=T({...le(),meta:C,onSuccess:e}),s=T({...oe(),meta:C,onSuccess:e}),i=p.useCallback(o=>t.mutateAsync({body:o}).then(()=>D).catch(k),[t]),r=p.useCallback((o,c)=>a.mutateAsync({path:{calendarObjectId:o.calendarObjectId},query:{calendarId:o.calendarId,...B(o)},headers:{"If-Match":o.etag},body:c}).then(()=>D).catch(k),[a]),l=p.useCallback(o=>s.mutateAsync({path:{calendarObjectId:o.calendarObjectId},query:{calendarId:o.calendarId,...B(o)},headers:{"If-Match":o.etag}}).then(()=>D).catch(k),[s]);return p.useMemo(()=>({createEvent:i,updateEvent:r,deleteEvent:l,isWriting:t.isPending||a.isPending||s.isPending}),[i,r,l,t.isPending,a.isPending,s.isPending])}function ze({title:e,subtitle:t,calendars:a,draft:s,onChange:i,problem:r,saveLabel:l,isSaving:o,repeatEditable:c=!0,calendarEditable:f=!0,onSave:g,onCancel:b}){return n.jsx(Oe,{title:e,subtitle:t,onClose:b,children:n.jsx(De,{draft:s,onChange:i,calendars:a,layout:"pane",repeatEditable:c,calendarEditable:f,saveLabel:o?"Saving…":l,onSave:g,onCancel:b,header:r===""?void 0:n.jsxs("div",{role:"alert",className:"flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-sm",children:[n.jsx(me,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":"true"}),n.jsx("p",{className:"min-w-0 flex-1 break-words text-fg",children:r})]})})})}export{ze as C,_e as c,We as d,Pe as e,Ue as p,Le as t,Be as u};
@@ -1,7 +0,0 @@
1
- import{ar as ys,cR as xr,r as l,e as de,j as a,Y as ft,Z as Bn,f as V,X as Dt,g as Ie,cS as Kn,t as _,W as Je,V as Ye,be as vr,cT as yr,cU as kr,aA as Ft,a2 as Ot,cV as qn,bu as ks,cW as wr,cX as Qn,aH as jr,L as Hn,_ as Cr,cY as Sr,B as Gn,cZ as Nr,c_ as Tr,c$ as Ir,d0 as Er,d1 as Rr,d2 as Mr,d3 as Ar,d4 as $r,w as Lr,c as ee,d as bt,G as xt,d5 as Pr,d6 as Dr,d7 as zt,h as ie,as as xe,i as me,N as Xe,cu as Re,d8 as _t,cl as Fr,d9 as Me,da as Or,db as Ws,dc as zr,dd as _r,de as Ur,b3 as Br,cc as Kr,cJ as ws,cK as Vn,df as qr,bc as js,ab as Qr,bf as Wn,b9 as Yn,bg as Jn,aV as Xn,E as Cs,bh as Hr,aY as Gr,aZ as Vr,cz as Wr,dg as Yr,aa as Zn,cy as Jr,dh as Xr,di as Zr,dj as ea,dk as eo,cO as to,bF as Ss,dl as so,dm as Ys,dn as no,dp as es,dq as ao,bE as ro,Q as oo,q as io,ag as ta,F as lo,cQ as Js,bo as co,dr as uo,ds as fo,au as Xs,cM as mo,dt as po,ah as ho,ca as go,cb as bo,du as xo,C as Ut,dv as vo,dw as yo,dx as Zs,dy as ko,dz as wo,dA as jo,v as sa,dB as Ns,cN as ke,dC as Co,cd as So,c8 as No,dD as To,dE as en,a1 as Io,ce as Eo}from"./index-6e6pvyaQ.js";import{m as Ro,S as na,i as we,t as je,r as vt,n as yt,o as kt,p as wt,q as Mo,h as Ao,d as $o,D as Lo,b as It,a as Po,v as Do,w as Fo,x as lt,e as Oo,y as zo,z as _o,u as Uo}from"./search-token-index-PUrvPC5c.js";import{K as Bo}from"./kbd-DImnxOni.js";import{P as aa,f as Ko,U as qo,a as Qo,E as Ho,s as Go}from"./attachment-file-oJZ9yins.js";import{M as Vo}from"./mail-DPzNtmsN.js";import{A as mt}from"./avatar-CqkxkswH.js";import{M as Wo,a as Yo,b as ra,c as Jo,s as oa,d as ia,e as Xo,f as Zo,S as tn,g as la,u as ca,p as ei,r as ti}from"./useSearchTokenContext-BA6iRf3_.js";import{C as si,D as He,u as ni}from"./index-DgEAInjF.js";import{E as da}from"./EmptyState-DvQRX_aF.js";import{E as Oe}from"./ErrorState-BTKMU75C.js";import{e as ua,b as Ze,a as ai,g as ri,c as ze,h as oi,d as ii}from"./format-D7BNbMxD.js";import{D as li}from"./download-ztZlV0rg.js";import{g as ci}from"./useMessageBodyContent-C_a1YUsw.js";import{B as di,b as ui,u as fi,i as mi}from"./useLayoutTier-Dt8oqQrp.js";import{S as pi}from"./shield-check-BhkZhdgI.js";import{u as fa}from"./useDebouncedValue-CMSCN4-w.js";import{h as sn,u as hi,a as gi,i as bi,n as xi,o as vi,j as yi,k as ki,S as wi}from"./useFilters-C6fHNH70.js";import{u as Ts}from"./useQueries-vQUSXdj9.js";import{M as ji}from"./minus-of4tlDqs.js";import{C as Et}from"./confirm-dialog-LUxfOOQz.js";import{C as Ci}from"./clock-CdKU6IY6.js";import{r as Si,a as Ni}from"./search-scope-B5-OK3Cq.js";import{M as Ti}from"./menu-Cie-OPPc.js";function pt(e){if(Ii())e.focus({preventScroll:!0});else{let t=Ei(e);e.focus(),Ri(t)}}let Rt=null;function Ii(){if(Rt==null){Rt=!1;try{document.createElement("div").focus({get preventScroll(){return Rt=!0,!0}})}catch{}}return Rt}function Ei(e){let t=e.parentNode,s=[],n=document.scrollingElement||document.documentElement;for(;t instanceof HTMLElement&&t!==n;)(t.offsetHeight<t.scrollHeight||t.offsetWidth<t.scrollWidth)&&s.push({element:t,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft}),t=t.parentNode;return n instanceof HTMLElement&&s.push({element:n,scrollTop:n.scrollTop,scrollLeft:n.scrollLeft}),s}function Ri(e){for(let{element:t,scrollTop:s,scrollLeft:n}of e)t.scrollTop=s,t.scrollLeft=n}const Te=e=>e?.ownerDocument??document,Ee=e=>e&&"window"in e&&e.window===e?e:Te(e).defaultView||window;function Mi(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&typeof e.nodeType=="number"}function Ai(e){return Mi(e)&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in e}let $i=!1;function ma(){return $i}function be(e,t){if(!ma())return t&&e?e.contains(t):!1;if(!e||!t)return!1;let s=t;for(;s!==null;){if(s===e)return!0;s.tagName==="SLOT"&&s.assignedSlot?s=s.assignedSlot.parentNode:Ai(s)?s=s.host:s=s.parentNode}return!1}function Z(e){if(ma()&&e.target instanceof Element&&e.target.shadowRoot){if("composedPath"in e)return e.composedPath()[0]??null;if("composedPath"in e.nativeEvent)return e.nativeEvent.composedPath()[0]??null}return e.target}const Li=typeof Element<"u"&&"checkVisibility"in Element.prototype;function Pi(e){const t=Ee(e);if(!(e instanceof t.HTMLElement)&&!(e instanceof t.SVGElement))return!1;let{display:s,visibility:n}=e.style,r=s!=="none"&&n!=="hidden"&&n!=="collapse";if(r){const{getComputedStyle:o}=Ee(e);let{display:i,visibility:c}=o(e);r=i!=="none"&&c!=="hidden"&&c!=="collapse"}return r}function Di(e,t){return!e.hasAttribute("hidden")&&!e.hasAttribute("data-react-aria-prevent-focus")&&(e.nodeName==="DETAILS"&&t&&t.nodeName!=="SUMMARY"?e.hasAttribute("open"):!0)}function pa(e,t){return Li?e.checkVisibility({visibilityProperty:!0})&&!e.closest("[data-react-aria-prevent-focus]"):e.nodeName!=="#comment"&&Pi(e)&&Di(e,t)&&(!e.parentElement||pa(e.parentElement,e))}const ha=["input:not([disabled]):not([type=hidden])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","a[href]","area[href]","summary","iframe","object","embed","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable^="false"])',"permission"],Fi=ha.join(":not([hidden]),")+",[tabindex]:not([disabled]):not([hidden])";ha.push('[tabindex]:not([tabindex="-1"]):not([disabled])');function Oi(e,t){return e.matches(Fi)&&!zi(e)&&(t?.skipVisibilityCheck||pa(e))}function zi(e){let t=e;for(;t!=null;){if(t instanceof Ee(t).HTMLElement&&t.inert)return!0;t=t.parentElement}return!1}const Is=typeof document<"u"?ys.useLayoutEffect:()=>{};function _i(e){let t=e;return t.nativeEvent=e,t.isDefaultPrevented=()=>t.defaultPrevented,t.isPropagationStopped=()=>t.cancelBubble,t.persist=()=>{},t}function Ui(e,t){Object.defineProperty(e,"target",{value:t}),Object.defineProperty(e,"currentTarget",{value:t})}function Bi(e){for(;e&&!Oi(e,{skipVisibilityCheck:!0});)e=e.parentElement;let t=Ee(e),s=t.document.activeElement;if(!s||s===e)return;let n=!1,r=g=>{(Z(g)===s||n)&&g.stopImmediatePropagation()},o=g=>{(Z(g)===s||n)&&(g.stopImmediatePropagation(),!e&&!n&&(n=!0,pt(s),d()))},i=g=>{(Z(g)===e||n)&&g.stopImmediatePropagation()},c=g=>{(Z(g)===e||n)&&(g.stopImmediatePropagation(),n||(n=!0,pt(s),d()))};t.addEventListener("blur",r,!0),t.addEventListener("focusout",o,!0),t.addEventListener("focusin",c,!0),t.addEventListener("focus",i,!0);let d=()=>{cancelAnimationFrame(b),t.removeEventListener("blur",r,!0),t.removeEventListener("focusout",o,!0),t.removeEventListener("focusin",c,!0),t.removeEventListener("focus",i,!0),n=!1},b=requestAnimationFrame(d);return d}function Bt(e){if(typeof window>"u"||window.navigator==null)return!1;let t=window.navigator.userAgentData?.brands;return Array.isArray(t)&&t.some(s=>e.test(s.brand))||e.test(window.navigator.userAgent)}function Es(e){return typeof window<"u"&&window.navigator!=null?e.test(window.navigator.userAgentData?.platform||window.navigator.platform):!1}function Ae(e){let t=null;return()=>(t==null&&(t=e()),t)}const $t=Ae(function(){return Es(/^Mac/i)}),Ki=Ae(function(){return Es(/^iPhone/i)}),ga=Ae(function(){return Es(/^iPad/i)||$t()&&navigator.maxTouchPoints>1}),ba=Ae(function(){return Ki()||ga()}),qi=Ae(function(){return Bt(/AppleWebKit/i)&&!Qi()}),Qi=Ae(function(){return Bt(/Chrome/i)}),xa=Ae(function(){return Bt(/Android/i)}),Hi=Ae(function(){return Bt(/Firefox/i)});function Gi(e){return e.pointerType===""&&e.isTrusted?!0:xa()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function Vi(e){return!xa()&&e.width===0&&e.height===0||e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType==="mouse"}function ht(e,t,s=!0){let{metaKey:n,ctrlKey:r,altKey:o,shiftKey:i}=t;Hi()&&window.event?.type?.startsWith("key")&&e.target==="_blank"&&($t()?n=!0:r=!0);let c=qi()&&$t()&&!ga()?new KeyboardEvent("keydown",{keyIdentifier:"Enter",metaKey:n,ctrlKey:r,altKey:o,shiftKey:i}):new MouseEvent("click",{metaKey:n,ctrlKey:r,altKey:o,shiftKey:i,detail:1,bubbles:!0,cancelable:!0});ht.isOpening=s,pt(e),e.dispatchEvent(c),ht.isOpening=!1}ht.isOpening=!1;let Ne=new Map,ds=new Set;function nn(){if(typeof window>"u")return;function e(n){return"propertyName"in n}let t=n=>{let r=Z(n);if(!e(n)||!r)return;let o=Ne.get(r);o||(o=new Set,Ne.set(r,o),r.addEventListener("transitioncancel",s,{once:!0})),o.add(n.propertyName)},s=n=>{let r=Z(n);if(!e(n)||!r)return;let o=Ne.get(r);if(o&&(o.delete(n.propertyName),o.size===0&&(r.removeEventListener("transitioncancel",s),Ne.delete(r)),Ne.size===0)){for(let i of ds)i();ds.clear()}};document.body.addEventListener("transitionrun",t),document.body.addEventListener("transitionend",s)}typeof document<"u"&&(document.readyState!=="loading"?nn():document.addEventListener("DOMContentLoaded",nn));function Wi(){for(const[e]of Ne)"isConnected"in e&&!e.isConnected&&Ne.delete(e)}function Yi(e){requestAnimationFrame(()=>{Wi(),Ne.size===0?e():ds.add(e)})}function va(...e){return(...t)=>{for(let s of e)typeof s=="function"&&s(...t)}}let us=new Map;typeof FinalizationRegistry<"u"&&new FinalizationRegistry(e=>{us.delete(e)});function Ji(e,t){if(e===t)return e;let s=us.get(e);if(s)return s.forEach(r=>r.current=t),t;let n=us.get(t);return n?(n.forEach(r=>r.current=e),e):t}function Xi(...e){return e.length===1&&e[0]?e[0]:t=>{let s=!1;const n=e.map(r=>{const o=an(r,t);return s||=typeof o=="function",o});if(s)return()=>{n.forEach((r,o)=>{typeof r=="function"?r():an(e[o],null)})}}}function an(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function jt(...e){let t={...e[0]};for(let s=1;s<e.length;s++){let n=e[s];for(let r in n){let o=t[r],i=n[r];typeof o=="function"&&typeof i=="function"&&r[0]==="o"&&r[1]==="n"&&r.charCodeAt(2)>=65&&r.charCodeAt(2)<=90?t[r]=va(o,i):(r==="className"||r==="UNSAFE_className")&&typeof o=="string"&&typeof i=="string"?t[r]=xr(o,i):r==="id"&&o&&i?t.id=Ji(o,i):r==="ref"&&o&&i?t.ref=Xi(o,i):t[r]=i!==void 0?i:o}}return t}function Zi(e,t){Is(()=>{if(e&&e.ref&&t)return e.ref.current=t.current,()=>{e.ref&&(e.ref.current=null)}})}const el=ys.useInsertionEffect??Is;function ts(e){const t=l.useRef(null);return el(()=>{t.current=e},[e]),l.useCallback((...s)=>{const n=t.current;return n?.(...s)},[])}let Ve="default",fs="",At=new WeakMap;function tl(e){if(ba()){if(Ve==="default"){const t=Te(e);fs=t.documentElement.style.webkitUserSelect,t.documentElement.style.webkitUserSelect="none"}Ve="disabled"}else if(e instanceof HTMLElement||e instanceof SVGElement){let t="userSelect"in e.style?"userSelect":"webkitUserSelect";At.set(e,e.style[t]),e.style[t]="none"}}function rn(e){if(ba()){if(Ve!=="disabled")return;Ve="restoring",setTimeout(()=>{Yi(()=>{if(Ve==="restoring"){const t=Te(e);t.documentElement.style.webkitUserSelect==="none"&&(t.documentElement.style.webkitUserSelect=fs||""),fs="",Ve="default"}})},300)}else if((e instanceof HTMLElement||e instanceof SVGElement)&&e&&At.has(e)){let t=At.get(e),s="userSelect"in e.style?"userSelect":"webkitUserSelect";e.style[s]==="none"&&(e.style[s]=t),e.getAttribute("style")===""&&e.removeAttribute("style"),At.delete(e)}}function on(e){return e?.defaultView?.__webpack_nonce__||globalThis.__webpack_nonce__||void 0}let ss=new WeakMap;function sl(e){let t=e??(typeof document<"u"?document:void 0);if(!t)return on(t);if(ss.has(t))return ss.get(t);let s=t.querySelector('meta[property="csp-nonce"]'),n=s&&s instanceof Ee(s).HTMLMetaElement&&(s.nonce||s.content)||on(t)||void 0;return n!==void 0&&ss.set(t,n),n}const ya=ys.createContext({register:()=>{}});ya.displayName="PressResponderContext";function ka(){let e=l.useRef(new Map),t=l.useCallback((r,o,i,c)=>{let d=c?.once?(...b)=>{e.current.delete(i),i(...b)}:i;e.current.set(i,{type:o,eventTarget:r,fn:d,options:c}),r.addEventListener(o,d,c)},[]),s=l.useCallback((r,o,i,c)=>{let d=e.current.get(i)?.fn||i;r.removeEventListener(o,d,c),e.current.delete(i)},[]),n=l.useCallback(()=>{e.current.forEach((r,o)=>{s(r.eventTarget,r.type,o,r.options)})},[s]);return l.useEffect(()=>n,[n]),{addGlobalListener:t,removeGlobalListener:s,removeAllGlobalListeners:n}}function nl(e){let t=l.useContext(ya);if(t){let{register:s,ref:n,...r}=t;e=jt(r,e),s()}return Zi(t,e.ref),e}class Mt{#e;constructor(t,s,n,r){this.#e=!0;const i=(r?.target??n.currentTarget)?.getBoundingClientRect();let c,d=0,b,g=null;n.clientX!=null&&n.clientY!=null&&(b=n.clientX,g=n.clientY),i&&(b!=null&&g!=null?(c=b-i.left,d=g-i.top):(c=i.width/2,d=i.height/2)),this.type=t,this.pointerType=s,this.target=n.currentTarget,this.shiftKey=n.shiftKey,this.metaKey=n.metaKey,this.ctrlKey=n.ctrlKey,this.altKey=n.altKey,this.x=c,this.y=d,this.key=n.key}continuePropagation(){this.#e=!1}get shouldStopPropagation(){return this.#e}}const ln=Symbol("linkClicked"),cn="react-aria-pressable-style",dn="data-react-aria-pressable";function al(e){let{onPress:t,onPressChange:s,onPressStart:n,onPressEnd:r,onPressUp:o,onClick:i,isDisabled:c,isPressed:d,preventFocusOnPress:b,shouldCancelOnPointerExit:g,allowTextSelectionOnPress:v,ref:p,...x}=nl(e),[f,u]=l.useState(!1),m=l.useRef({isPressed:!1,ignoreEmulatedMouseEvents:!1,didFirePressStart:!1,isTriggeringEvent:!1,activePointerId:null,target:null,isOverTarget:!1,pointerType:null,disposables:[]}),{addGlobalListener:h,removeAllGlobalListeners:S}=ka(),y=l.useCallback((k,I)=>{let R=m.current;if(c||R.didFirePressStart)return!1;let j=!0;if(R.isTriggeringEvent=!0,n){let M=new Mt("pressstart",I,k);n(M),j=M.shouldStopPropagation}return s&&s(!0),R.isTriggeringEvent=!1,R.didFirePressStart=!0,u(!0),j},[c,n,s]),w=l.useCallback((k,I,R=!0)=>{let j=m.current;if(!j.didFirePressStart)return!1;j.didFirePressStart=!1,j.isTriggeringEvent=!0;let M=!0;if(r){let C=new Mt("pressend",I,k);r(C),M=C.shouldStopPropagation}if(s&&s(!1),u(!1),t&&R&&!c){let C=new Mt("press",I,k);t(C),M&&=C.shouldStopPropagation}return j.isTriggeringEvent=!1,M},[c,r,s,t]),N=ts(w),E=l.useCallback((k,I)=>{let R=m.current;if(c)return!1;if(o){R.isTriggeringEvent=!0;let j=new Mt("pressup",I,k);return o(j),R.isTriggeringEvent=!1,j.shouldStopPropagation}return!0},[c,o]),P=ts(E),z=l.useCallback(k=>{let I=m.current;if(I.isPressed&&I.target){I.didFirePressStart&&I.pointerType!=null&&w(De(I.target,k),I.pointerType,!1),I.isPressed=!1,I.isOverTarget=!1,I.activePointerId=null,I.pointerType=null,S(),v||rn(I.target);for(let R of I.disposables)R();I.disposables=[]}},[v,S,w]),U=ts(z);l.useEffect(()=>{c&&m.current.isPressed&&U({currentTarget:m.current.target,shiftKey:!1,ctrlKey:!1,metaKey:!1,altKey:!1})},[c]);let L=l.useCallback(k=>{g&&z(k)},[g,z]),D=l.useCallback(k=>{c||i?.(k)},[c,i]),F=l.useCallback((k,I)=>{if(!c&&i){let R=new MouseEvent("click",k);Ui(R,I),i(_i(R))}},[c,i]),O=l.useMemo(()=>{let k=m.current,I={onKeyDown(j){if(ns(j.nativeEvent,j.currentTarget)&&be(j.currentTarget,Z(j))){un(Z(j),j.key)&&j.preventDefault();let M=!0;!k.isPressed&&!j.repeat&&(k.target=j.currentTarget,k.isPressed=!0,k.pointerType="keyboard",M=y(j,"keyboard"));let C=j.currentTarget,K=$=>{ns($,C)&&!$.repeat&&be(C,Z($))&&k.target&&P(De(k.target,$),"keyboard")};h(Te(j.currentTarget),"keyup",va(K,R),!0),M&&j.stopPropagation(),j.metaKey&&$t()&&k.metaKeyEvents?.set(j.key,j.nativeEvent)}else j.key==="Meta"&&(k.metaKeyEvents=new Map)},onClick(j){if(!(j&&!be(j.currentTarget,Z(j)))&&j&&j.button===0&&!k.isTriggeringEvent&&!ht.isOpening){let M=!0;if(c&&j.preventDefault(),!k.ignoreEmulatedMouseEvents&&!k.isPressed&&(k.pointerType==="virtual"||Gi(j.nativeEvent))){let C=y(j,"virtual"),K=P(j,"virtual"),$=N(j,"virtual");D(j),M=C&&K&&$}else if(k.isPressed&&k.pointerType!=="keyboard"){let C=k.pointerType||j.nativeEvent.pointerType||"virtual",K=P(De(j.currentTarget,j),C),$=N(De(j.currentTarget,j),C,!0);M=K&&$,k.isOverTarget=!1,D(j),U(j)}k.ignoreEmulatedMouseEvents=!1,M&&j.stopPropagation()}}},R=j=>{if(k.isPressed&&k.target&&ns(j,k.target)){un(Z(j),j.key)&&j.preventDefault();let M=Z(j),C=be(k.target,M);N(De(k.target,j),"keyboard",C),C&&F(j,k.target),S(),j.key!=="Enter"&&Rs(k.target)&&be(k.target,M)&&!j[ln]&&(j[ln]=!0,ht(k.target,j,!1)),k.isPressed=!1,k.metaKeyEvents?.delete(j.key)}else if(j.key==="Meta"&&k.metaKeyEvents?.size){let M=k.metaKeyEvents;k.metaKeyEvents=void 0;for(let C of M.values())k.target?.dispatchEvent(new KeyboardEvent("keyup",C))}};if(typeof PointerEvent<"u"){I.onPointerDown=C=>{if(C.button!==0||!be(C.currentTarget,Z(C)))return;if(Vi(C.nativeEvent)){k.pointerType="virtual";return}k.pointerType=C.pointerType;let K=!0;if(!k.isPressed){k.isPressed=!0,k.isOverTarget=!0,k.activePointerId=C.pointerId,k.target=C.currentTarget,v||tl(k.target),K=y(C,k.pointerType);let $=Z(C);"releasePointerCapture"in $&&("hasPointerCapture"in $?$.hasPointerCapture(C.pointerId)&&$.releasePointerCapture(C.pointerId):$.releasePointerCapture(C.pointerId)),h(Te(C.currentTarget),"pointerup",j,!1),h(Te(C.currentTarget),"pointercancel",M,!1)}K&&C.stopPropagation()},I.onMouseDown=C=>{if(be(C.currentTarget,Z(C))&&C.button===0){if(b){let K=Bi(C.target);K&&k.disposables.push(K)}C.stopPropagation()}},I.onPointerUp=C=>{!be(C.currentTarget,Z(C))||k.pointerType==="virtual"||C.button===0&&!k.isPressed&&P(C,k.pointerType||C.pointerType)},I.onPointerEnter=C=>{C.pointerId===k.activePointerId&&k.target&&!k.isOverTarget&&k.pointerType!=null&&(k.isOverTarget=!0,y(De(k.target,C),k.pointerType))},I.onPointerLeave=C=>{C.pointerId===k.activePointerId&&k.target&&k.isOverTarget&&k.pointerType!=null&&(k.isOverTarget=!1,N(De(k.target,C),k.pointerType,!1),L(C))};let j=C=>{if(C.pointerId===k.activePointerId&&k.isPressed&&C.button===0&&k.target){if(be(k.target,Z(C))&&k.pointerType!=null){let K=!1,$=setTimeout(()=>{k.isPressed&&k.target instanceof HTMLElement&&(K?U(C):(pt(k.target),k.target.click()))},80);h(C.currentTarget,"click",()=>K=!0,!0),k.disposables.push(()=>clearTimeout($))}else U(C);k.isOverTarget=!1}},M=C=>{U(C)};I.onDragStart=C=>{be(C.currentTarget,Z(C))&&U(C)}}return I},[h,c,b,S,v,L,y,D,F]);return l.useEffect(()=>{if(!p)return;const k=Te(p.current);if(!k||!k.head||k.getElementById(cn))return;const I=k.createElement("style");I.id=cn;let R=sl(k);R&&(I.nonce=R),I.textContent=`
2
- @layer {
3
- [${dn}] {
4
- touch-action: pan-x pan-y pinch-zoom;
5
- }
6
- }
7
- `.trim(),k.head.prepend(I)},[p]),l.useEffect(()=>{let k=m.current;return()=>{v||rn(k.target??void 0);for(let I of k.disposables)I();k.disposables=[]}},[v]),{isPressed:d||f,pressProps:jt(x,O,{[dn]:!0})}}function Rs(e){return e.tagName==="A"&&e.hasAttribute("href")}function ns(e,t){const{key:s,code:n}=e,r=t,o=r.getAttribute("role");return(s==="Enter"||s===" "||s==="Spacebar"||n==="Space")&&!(r instanceof Ee(r).HTMLInputElement&&!wa(r,s)||r instanceof Ee(r).HTMLTextAreaElement||r.isContentEditable)&&!((o==="link"||!o&&Rs(r))&&s!=="Enter")}function De(e,t){let s=t.clientX,n=t.clientY;return{currentTarget:e,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,metaKey:t.metaKey,altKey:t.altKey,clientX:s,clientY:n,key:t.key}}function rl(e){return e instanceof HTMLInputElement?!1:e instanceof HTMLButtonElement?e.type!=="submit"&&e.type!=="reset":!Rs(e)}function un(e,t){return e instanceof HTMLInputElement?!wa(e,t):rl(e)}const ol=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function wa(e,t){return e.type==="checkbox"||e.type==="radio"?t===" ":ol.has(e.type)}let il=0;const as=new Map;function ll(e){let[t,s]=l.useState();return Is(()=>{if(!e)return;let n=as.get(e);if(n)s(n.element.id);else{let r=`react-aria-description-${il++}`;s(r);let o=document.createElement("div");o.id=r,o.style.display="none",o.textContent=e,document.body.appendChild(o),n={refCount:0,element:o},as.set(e,n)}return n.refCount++,()=>{n&&--n.refCount===0&&(n.element.remove(),as.delete(e))}},[e]),{"aria-describedby":e?t:void 0}}const cl=500;function dl(e){let{isDisabled:t,onLongPressStart:s,onLongPressEnd:n,onLongPress:r,threshold:o=cl,accessibilityDescription:i}=e;const c=l.useRef(void 0);let{addGlobalListener:d,removeGlobalListener:b}=ka(),{pressProps:g}=al({isDisabled:t,onPressStart(p){if(p.continuePropagation(),(p.pointerType==="mouse"||p.pointerType==="touch")&&(s&&s({...p,type:"longpressstart"}),c.current=setTimeout(()=>{p.target.dispatchEvent(new PointerEvent("pointercancel",{bubbles:!0})),Te(p.target).activeElement!==p.target&&pt(p.target),r&&r({...p,type:"longpress"}),c.current=void 0},o),p.pointerType==="touch")){let x=u=>{u.preventDefault()},f=Ee(p.target);d(p.target,"contextmenu",x,{once:!0}),d(f,"pointerup",()=>{setTimeout(()=>{b(p.target,"contextmenu",x)},30)},{once:!0})}},onPressEnd(p){c.current&&clearTimeout(c.current),n&&(p.pointerType==="mouse"||p.pointerType==="touch")&&n({...p,type:"longpressend"})}}),v=ll(r&&!t?i:void 0);return{longPressProps:jt(g,v)}}const Kt=de("BadgeCheck",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const ja=de("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);const Ca=de("Forward",[["polyline",{points:"15 17 20 12 15 7",key:"1w3sku"}],["path",{d:"M4 18v-2a4 4 0 0 1 4-4h12",key:"jmiej9"}]]);const ul=de("MailCheck",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8",key:"12jkf8"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}]]);const Ms=de("MailOpen",[["path",{d:"M21.2 8.4c.5.38.8.97.8 1.6v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V10a2 2 0 0 1 .8-1.6l8-6a2 2 0 0 1 2.4 0l8 6Z",key:"1jhwl8"}],["path",{d:"m22 10-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 10",key:"1qfld7"}]]);const fl=de("MailX",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h9",key:"1j9vog"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"m17 17 4 4",key:"1b3523"}],["path",{d:"m21 17-4 4",key:"uinynz"}]]);const qt=de("Paperclip",[["path",{d:"M13.234 20.252 21 12.3",key:"1cbrk9"}],["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 0 2.828 2 2 0 0 0 2.828 0l8.414-8.586a4 4 0 0 0 0-5.656 4 4 0 0 0-5.656 0l-8.415 8.585a6 6 0 1 0 8.486 8.486",key:"1pkts6"}]]);const Sa=de("ReplyAll",[["polyline",{points:"7 17 2 12 7 7",key:"t83bqg"}],["polyline",{points:"12 17 7 12 12 7",key:"1g4ajm"}],["path",{d:"M22 18v-2a4 4 0 0 0-4-4H7",key:"1fcyog"}]]);const Na=de("Reply",[["polyline",{points:"9 17 4 12 9 7",key:"hvgpf2"}],["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}]]);const et=de("ShieldAlert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);const ml=de("ShieldQuestion",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const pl=de("ShieldX",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]),hl=({address:e,showTrustedBadge:t=!1})=>{const s=t?a.jsx(Kt,{className:"inline-block size-4 ml-1 -mt-0.5 text-positive","aria-label":"Trusted sender","data-testid":"trusted-sender-badge"}):null;return e.displayName?a.jsxs("span",{children:[a.jsx("span",{className:"text-fg",children:e.displayName}),a.jsxs("span",{className:"text-fg-muted",children:[" ","<",e.normalizedEmail,">"]}),s]}):a.jsxs("span",{className:"text-fg",children:[e.normalizedEmail,s]})},gl=({label:e,addresses:t,showTrustedBadge:s=!1})=>{const[n,r]=l.useState(!1);if(t.length===0)return null;const o=t.length>3,i=c=>{const d=s&&c.flags?.trusted?.value===!0;return a.jsx(hl,{address:c,showTrustedBadge:d})};return a.jsxs("div",{className:"flex gap-2 text-sm",children:[a.jsxs("span",{className:"text-fg-muted shrink-0 w-12",children:[e,":"]}),a.jsx("div",{className:"flex-1 min-w-0",children:n?a.jsx("div",{className:"flex flex-wrap gap-1",children:t.map((c,d)=>a.jsxs("span",{children:[i(c),d<t.length-1&&", "]},d))}):a.jsx("div",{className:"truncate",children:t.map((c,d)=>a.jsxs("span",{children:[i(c),d<t.length-1&&", "]},d))})}),o&&a.jsx("button",{type:"button",onClick:c=>{c.stopPropagation(),r(!n)},className:"shrink-0 text-fg-muted hover:text-fg transition-colors","aria-label":n?"Collapse":"Expand",children:n?a.jsx(ft,{className:"h-4 w-4"}):a.jsx(Bn,{className:"h-4 w-4"})})]})},bl={unknown:{label:"Unknown sender",tone:"neutral"},wellknown:{label:"Known sender",tone:"positive"},vip:{label:"VIP",tone:"accent"}};function Ge({label:e,children:t,className:s}){return a.jsxs("section",{className:_("border-b border-line px-row-inset py-3",s),children:[a.jsx("h3",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:e}),a.jsx("div",{className:"mt-2",children:t})]})}function xl({sender:e}){const t=bl[e.trust],s=e.inboundCount==null?null:(e.replyCount??0)>0?`${e.inboundCount} received · you replied ${e.replyCount}×`:`${e.inboundCount} received · you've never replied`;return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(mt,{name:e.name,email:e.email,size:"md"}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"truncate text-sm font-semibold text-fg",children:e.name}),a.jsx("div",{className:"truncate text-2xs text-fg-subtle",children:e.email})]})]}),a.jsx("div",{className:"mt-2 flex items-center gap-2",children:e.addressUnverified?a.jsx(Ie,{tone:"danger",dot:!0,children:"Address couldn't be verified"}):a.jsx(Ie,{tone:t.tone,dot:!0,children:t.label})}),a.jsxs("p",{className:"mt-2 text-xs text-fg-muted",children:["First seen ",e.firstSeenLabel,s?` · ${s}`:""]})]})}function vl({auth:e,onShowSimilar:t}){if(e.verdict==="aligned")return a.jsxs("div",{className:"flex items-start gap-2 text-xs text-fg-muted",children:[a.jsx(pi,{className:"mt-0.5 size-3.5 shrink-0 text-positive"}),a.jsx("span",{children:e.summary})]});if(e.verdict==="caution")return a.jsxs("div",{className:"flex items-start gap-2 rounded-md bg-warning/10 p-3 text-warning",children:[a.jsx(ml,{className:"mt-0.5 size-4 shrink-0"}),a.jsx("p",{className:"text-xs leading-relaxed",children:e.summary})]});const s=e.addressUnreadable?"This sender can't be verified":"This message may be impersonating someone";return a.jsxs("div",{className:"rounded-md bg-danger-soft p-3",children:[a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx(et,{className:"mt-0.5 size-4 shrink-0 text-danger"}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-sm font-semibold text-danger",children:s}),a.jsx("p",{className:"mt-1 text-xs leading-relaxed text-fg",children:e.summary}),!e.addressUnreadable&&e.dkimDomain&&a.jsxs("p",{className:"mt-1 text-2xs text-fg-muted",children:["Sent from"," ",a.jsx("code",{className:"rounded bg-surface px-1 py-0.5",children:e.dkimDomain}),", claims to be"," ",a.jsx("code",{className:"rounded bg-surface px-1 py-0.5",children:e.fromDomain})]})]})]}),e.similarCount!=null&&e.similarCount>0&&a.jsxs(V,{variant:"secondary",size:"sm",className:"mt-2 w-full border-danger/30 text-danger hover:bg-danger-soft",onClick:t,children:[e.similarCount," similar messages"]})]})}function ct({icon:e,label:t,active:s,danger:n,onClick:r,pending:o}){const i=r===void 0||o===!0;return a.jsxs("button",{type:"button",onClick:r,disabled:i,className:_("flex items-center gap-2 rounded-md border px-2 py-1 text-xs transition-colors",s?"border-accent-2 bg-accent-2-soft text-accent-2":"border-line text-fg-muted hover:border-line-strong hover:text-fg",n&&!s&&"text-danger hover:bg-danger-soft",i&&"cursor-not-allowed opacity-50 hover:border-line"),children:[e,t]})}const yl={sender:"matched: sender",recipient:"matched: recipient",subject:"matched: subject",attachment:"matched: attachment",body:"matched: body",entities:"matched: entities"};function Ta({data:e,onClose:t,onShowSimilar:s,actions:n,similarState:r="ready",similarLinkComponent:o,className:i,hideCloseButton:c=!1,reportSpamPending:d=!1,notSpamPending:b=!1}){const{sender:g,authenticity:v,category:p,flags:x={},similar:f}=e;return a.jsxs("aside",{className:_("flex w-76 shrink-0 flex-col overflow-y-auto border-l border-line bg-surface",i),children:[a.jsxs("header",{className:"flex h-pane-header shrink-0 items-center justify-between border-b border-line px-row-inset",children:[a.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Intelligence"}),!c&&a.jsx(V,{variant:"ghost",size:"sm",icon:a.jsx(Dt,{className:"size-3.5"}),onClick:t,"aria-label":"Collapse intelligence sidebar"})]}),a.jsx(Ge,{label:"Sender",children:a.jsx(xl,{sender:g})}),a.jsx(Ge,{label:"Authenticity",children:a.jsx(vl,{auth:v,onShowSimilar:s})}),a.jsx(Ge,{label:"Category",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ie,{tone:Kn[p.value],children:p.value}),p.overridden&&a.jsx("span",{className:"text-2xs text-fg-subtle",children:"your override"}),a.jsx("button",{type:"button",className:_("ml-auto text-2xs text-accent hover:underline",!n?.onReclassify&&"cursor-not-allowed opacity-50 hover:no-underline"),disabled:!n?.onReclassify,onClick:n?.onReclassify,children:"reclassify"})]})}),a.jsxs(Ge,{label:"Quick actions",children:[a.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[a.jsx(ct,{icon:a.jsx(Je,{className:"size-3.5"}),label:"VIP",active:x.vip,onClick:n?.onToggleVip}),a.jsx(ct,{icon:a.jsx(di,{className:"size-3.5"}),label:"Mute",active:x.muted,onClick:n?.onToggleMute}),n?.onNotSpam&&a.jsx(ct,{icon:a.jsx(ul,{className:"size-3.5"}),label:b?"Undoing…":"Not spam",active:!0,onClick:n.onNotSpam,pending:b}),n?.onReportSpam&&a.jsx(ct,{icon:a.jsx(pl,{className:"size-3.5"}),label:d?"Reporting…":"Report spam",danger:!0,onClick:n.onReportSpam,pending:d}),a.jsx(ct,{icon:a.jsx(fl,{className:"size-3.5"}),label:"Unsubscribe",active:x.unsubscribed,onClick:n?.onToggleUnsubscribe})]}),n?.onNotSpam&&a.jsx("p",{className:"mt-1.5 text-2xs text-fg-subtle",children:"You reported this message as spam"})]}),(r!=="ready"||f.length>0)&&a.jsx(Ge,{label:"Similar messages",children:r==="loading"?a.jsx("div",{className:"animate-pulse space-y-2",children:Array.from({length:3}).map((u,m)=>a.jsxs("div",{className:"space-y-1",children:[a.jsx("div",{className:"h-3 w-3/4 rounded bg-surface-sunken"}),a.jsx("div",{className:"h-2.5 w-1/2 rounded bg-surface-sunken"})]},m))}):r==="error"?a.jsx("p",{className:"text-xs text-fg-subtle",children:"Similarity search unavailable"}):a.jsx("ul",{className:"-mx-1 space-y-1",children:f.map(u=>{const m="block w-full rounded-md px-1 py-1 text-left hover:bg-surface-sunken",h=`Open message from ${u.fromName||"unknown sender"}: ${u.subject}`,S=a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[a.jsx("span",{className:"truncate text-xs font-medium text-fg",children:u.fromName}),a.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:u.timeLabel})]}),a.jsx("div",{className:"truncate text-xs text-fg-muted",children:u.subject}),a.jsx("span",{className:"mt-1 inline-block rounded-full bg-surface-sunken px-1.5 py-px text-2xs text-fg-subtle",children:yl[u.matched]})]});return a.jsx("li",{children:o?o({mailboxId:u.mailboxId,threadId:u.threadId,messageId:u.id,className:m,ariaLabel:h,children:S}):a.jsx("div",{className:m,children:S})},u.id)})})}),a.jsx(Ge,{label:"Coming soon",className:"border-b-0 opacity-70",children:a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-dashed border-line p-2",children:[a.jsx(Ye,{className:"mt-0.5 size-3.5 shrink-0 text-fg-subtle"}),a.jsxs("div",{children:[a.jsx("div",{className:"text-xs font-medium text-fg-muted",children:"Suggested actions"}),a.jsx("div",{className:"text-2xs text-fg-subtle",children:'"Create a filter for messages like this" — on-device model'})]})]}),a.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-dashed border-line p-2",children:[a.jsx(Ye,{className:"mt-0.5 size-3.5 shrink-0 text-fg-subtle"}),a.jsxs("div",{children:[a.jsx("div",{className:"text-xs font-medium text-fg-muted",children:"Thread summary"}),a.jsx("div",{className:"text-2xs text-fg-subtle",children:"One-paragraph digest — Bedrock"})]})]})]})})]})}const ms=e=>({shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey}),fn=e=>e.shiftKey||e.metaKey||e.ctrlKey,kl=e=>e.shiftKey?"range":e.metaKey||e.ctrlKey?"toggle":"open",wl=(e,t)=>!t&&e>0,jl=(e,t,s)=>{const n=e.indexOf(s);if(n===-1)return[];const r=t===void 0?-1:e.indexOf(t);if(r===-1)return[s];const o=Math.min(r,n),i=Math.max(r,n);return e.slice(o,i+1)},Cl=(e,t,s,n)=>t!==void 0&&e.includes(t)?t:s!==void 0&&e.includes(s)?s:n,Sl=(e,t)=>{const s=new Set(t),n=new Set;for(const r of e)s.has(r)&&n.add(r);return n},Nl=(e,t,s)=>{if(e.length===0)return;const n=t===void 0?-1:e.indexOf(t);if(n===-1)return s>0?e[0]:e[e.length-1];const r=Math.min(Math.max(n+s,0),e.length-1);return e[r]},Tl=e=>{const[t,s]=l.useState(()=>new Set(e?.initialSelectedIds)),[n,r]=l.useState(void 0),o=l.useCallback(u=>t.has(u),[t]),i=l.useCallback(u=>{r(u),s(m=>{const h=new Set(m);return h.has(u)?h.delete(u):h.add(u),h})},[]),c=l.useCallback(u=>{r(u),s(m=>{if(m.has(u))return m;const h=new Set(m);return h.add(u),h})},[]),d=l.useCallback(u=>{s(m=>{if(!m.has(u))return m;const h=new Set(m);return h.delete(u),h})},[]),b=l.useCallback(u=>{s(new Set(u))},[]),g=l.useCallback(()=>{r(void 0),s(new Set)},[]),v=l.useCallback(u=>{s(m=>u.every(S=>m.has(S))?new Set:new Set(u))},[]),p=l.useCallback(u=>{r(u)},[]),x=l.useCallback(u=>{s(m=>{if(m.size===0)return m;const h=Sl(m,u);return h.size===m.size?m:h})},[]),f=l.useCallback((u,m,h)=>{const S=Cl(u,n,h,m);s(y=>{const w=jl(u,S,m);if(w.length===0)return y;const N=new Set(y);for(const E of w)N.add(E);return N}),r(S)},[n]);return{selectedIds:t,selectedCount:t.size,hasSelection:t.size>0,isSelected:o,toggle:i,select:c,deselect:d,selectAll:b,clearSelection:g,toggleAll:v,selectRange:f,setAnchor:p,anchorId:n,intersectWith:x}};function om({hints:e=Ro,className:t}){return e.length===0?null:a.jsx("footer",{className:_("flex items-center gap-2 border-t border-line px-row-inset py-1 text-2xs text-fg-subtle",t),children:e.map(s=>a.jsx(Il,{hint:s},s.label))})}function Il({hint:e}){return a.jsxs("span",{className:"flex items-center gap-1",children:[e.keys.map(t=>a.jsx(Bo,{children:t},t)),a.jsx("span",{children:e.label})]})}const Ia="outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",Ea=({active:e,focused:t})=>_("relative flex h-8 w-full items-center gap-2 px-row-inset text-left",Ia,e?"bg-accent-2-soft":t?"bg-surface-sunken":"hover:bg-surface-sunken",t&&!e&&"before:absolute before:inset-y-0 before:left-0 before:w-0.5 before:bg-accent-2"),As=({active:e,focused:t})=>_("relative flex w-full items-start gap-3 py-2 pl-5 pr-row-inset text-left transition-colors",Ia,e?"bg-accent-2-soft":t?"bg-surface-sunken":"hover:bg-surface-sunken",t&&!e&&"before:absolute before:inset-y-0 before:left-0 before:w-0.5 before:bg-accent-2");function Ra({thread:e}){const t=!e.isRead;return a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"flex w-4 shrink-0 items-center justify-center",children:e.suspicious?a.jsx(et,{className:"size-3.5 text-danger"}):e.starred?a.jsx(Je,{className:"size-3 fill-warning text-warning"}):t?a.jsx("span",{className:"size-1.5 rounded-full bg-accent"}):null}),a.jsx("span",{className:_("w-36 shrink-0 truncate text-xs",t?"font-semibold text-fg":"text-fg-muted"),children:e.fromName}),a.jsxs("span",{className:"min-w-0 flex-1 truncate text-xs",children:[a.jsx("span",{className:_(t?"font-medium text-fg":"text-fg-muted"),children:e.subject}),a.jsxs("span",{className:"text-fg-subtle",children:[" — ",e.snippet]})]}),e.hasAttachment&&a.jsx(qt,{className:"size-3 shrink-0 text-fg-subtle",role:"img","aria-label":"Has an attachment"}),a.jsx("span",{className:"w-11 shrink-0 text-right text-2xs text-fg-subtle tabular-nums",children:e.timeLabel})]})}function mn(e,t){const s=t?.trim();if(!s)return e;const n=e.toLowerCase(),r=s.toLowerCase(),o=[];let i=0,c=n.indexOf(r,i),d=0;for(;c!==-1;)c>i&&o.push(e.slice(i,c)),o.push(a.jsx("mark",{className:"bg-transparent font-semibold text-fg",children:e.slice(c,c+r.length)},d++)),i=c+r.length,c=n.indexOf(r,i);return i<e.length&&o.push(e.slice(i)),o}function El({thread:e,badge:t,highlightQuery:s}){const n=!e.isRead;return a.jsxs("span",{className:"min-w-0 flex-1",children:[a.jsxs("span",{className:"flex items-baseline justify-between gap-2",children:[a.jsxs("span",{className:_("flex min-w-0 items-center gap-1.5 truncate text-sm",n?"font-semibold text-fg":"font-medium text-fg-muted"),children:[e.trust==="vip"&&a.jsx("span",{className:"size-1.5 shrink-0 rounded-full bg-accent-2"}),a.jsx("span",{className:"truncate",children:e.fromName}),e.messageCount!=null&&e.messageCount>1&&a.jsx("span",{className:"shrink-0 text-2xs font-normal text-fg-subtle",children:e.messageCount})]}),a.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:e.timeLabel})]}),a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx("span",{className:_("truncate text-sm",n?"text-fg":"text-fg-muted"),children:mn(e.subject,s)}),e.suspicious&&a.jsx(et,{className:"size-3.5 shrink-0 text-danger"}),e.starred&&a.jsx(Je,{className:"size-3 shrink-0 fill-warning text-warning"}),e.hasAttachment&&a.jsx(qt,{className:"size-3 shrink-0 text-fg-subtle",role:"img","aria-label":"Has an attachment"})]}),a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx("span",{className:"line-clamp-1 min-w-0 flex-1 text-xs text-fg-subtle",children:mn(e.snippet,s)}),e.category&&e.category!=="personal"&&a.jsx(Ie,{tone:Kn[e.category],className:"shrink-0",children:e.category}),e.labels?.map(r=>a.jsx(vr,{label:r,className:"max-w-20"},r.labelId)),t]})]})}function Rl({thread:e,selection:t}){if(!t)return a.jsx(mt,{name:e.fromName,email:e.fromEmail,size:"sm"});const{checked:s,alwaysVisible:n}=t;return a.jsxs("span",{className:"relative size-7 shrink-0",children:[a.jsx(mt,{name:e.fromName,email:e.fromEmail,size:"sm",className:_("absolute inset-0 transition-opacity sm:group-hover:opacity-0",(s||n)&&"opacity-0")}),a.jsx("span",{role:"button",tabIndex:-1,onClick:t.onToggle,onKeyDown:r=>{r.key!=="Enter"&&r.key!==" "||(r.preventDefault(),r.stopPropagation(),t.onToggle(r))},className:_("absolute inset-0 size-7 items-center justify-center rounded-full border transition-opacity",n?"flex":"hidden sm:flex",s?"bg-accent border-accent text-accent-fg opacity-100":n?"border-fg-subtle/40 bg-canvas opacity-100":"border-fg-subtle/40 bg-canvas opacity-0 group-hover:opacity-100"),"aria-label":s?"Deselect message":"Select message",children:s&&a.jsx(Ft,{className:"size-3"})})]})}function $s({thread:e,selection:t,badge:s,highlightQuery:n}){const r=!e.isRead;return a.jsxs(a.Fragment,{children:[r&&a.jsx("span",{className:"absolute left-1.5 top-1/2 size-1.5 -translate-y-1/2 rounded-full bg-accent"}),a.jsx(Rl,{thread:e,selection:t}),a.jsx(El,{thread:e,badge:s,highlightQuery:n})]})}const Ma=e=>({...yr,[kr]:"","data-message-id":e.id});function im({thread:e,active:t,focused:s,tabIndex:n,onClick:r}){return a.jsx("button",{type:"button",...Ma(e),tabIndex:n,onClick:r,className:Ea({active:t,focused:s}),children:a.jsx(Ra,{thread:e})})}function lm({thread:e,active:t,focused:s,tabIndex:n,selection:r,onClick:o}){return a.jsx("button",{type:"button",...Ma(e),tabIndex:n,onClick:o,className:_("group",As({active:t,focused:s})),children:a.jsx($s,{thread:e,selection:r})})}let We;const Ml=5e3;function Aa(e){e.preventDefault(),Lt()}function Lt(){We!==void 0&&(clearTimeout(We),We=void 0,document.removeEventListener("contextmenu",Aa,!0),document.removeEventListener("pointerup",Lt,!0))}function Al(){We===void 0?(document.addEventListener("contextmenu",Aa,!0),document.addEventListener("pointerup",Lt,!0)):clearTimeout(We),We=setTimeout(Lt,Ml)}function $l({onLongPress:e,isDisabled:t,delayMs:s=500,accessibilityDescription:n}){const{longPressProps:r}=dl({isDisabled:t,threshold:s,accessibilityDescription:n,onLongPress:e}),o=l.useCallback(i=>{i.pointerType!=="touch"&&i.pointerType!=="pen"||Al()},[]);return{longPressProps:jt(r,{onPointerDown:o})}}const dt="min-h-11 min-w-11 px-0";function $a({hasThread:e,onReply:t,onReplyAll:s,onForward:n,isStarred:r,onToggleStar:o,onDelete:i,isRead:c,onToggleRead:d,moveSlot:b,overflowItems:g=[],onUnavailable:v,unavailableHint:p,className:x}){const f=(m,h)=>()=>{if(!e){v?.(m);return}h?.()},u=d?[{key:"toggle-read",label:c?"Mark as unread":"Mark as read",icon:c?a.jsx(Vo,{className:"size-4"}):a.jsx(Ms,{className:"size-4"}),onSelect:f("toggleRead",d)}]:[];return a.jsxs("div",{className:_("relative",x),children:[a.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-0.5 bg-canvas px-1",children:[t&&a.jsx(V,{variant:"ghost",size:"sm",icon:a.jsx(Na,{className:"size-5"}),onClick:f("reply",t),"aria-label":"Reply",title:"Reply",className:dt}),s&&a.jsx(V,{variant:"ghost",size:"sm",icon:a.jsx(Sa,{className:"size-5"}),onClick:f("replyAll",s),"aria-label":"Reply all",title:"Reply all",className:dt}),n&&a.jsx(V,{variant:"ghost",size:"sm",icon:a.jsx(Ca,{className:"size-5"}),onClick:f("forward",n),"aria-label":"Forward",title:"Forward",className:dt}),a.jsx("div",{className:"flex-1"}),o&&a.jsx(V,{variant:"ghost",size:"sm",icon:a.jsx(Je,{className:_("size-5",r&&"fill-warning text-warning")}),onClick:f("star",o),"aria-label":r?"Unstar":"Star","aria-pressed":r,title:r?"Unstar":"Star",className:dt}),b,i&&a.jsx(V,{variant:"ghost",size:"sm",icon:a.jsx(Ot,{className:"size-5"}),onClick:f("delete",i),"aria-label":"Move to Trash",title:"Move to Trash",className:dt}),a.jsx(aa,{triggerLabel:"More actions",items:[...u,...g]})]}),!e&&p&&a.jsx("p",{role:"status",className:"bg-surface-sunken px-3 py-1 text-2xs text-fg-subtle",children:p})]})}function Ll({open:e=!1,enabled:t=!0,onToggle:s,className:n}){return a.jsx(V,{variant:"ghost",size:"sm",icon:a.jsx(qn,{className:"size-4"}),title:"Intelligence","aria-label":e?"Hide intelligence sidebar":"Show intelligence sidebar","aria-pressed":e,disabled:!t,onClick:s,className:_(e&&"bg-accent-2-soft text-accent-2",n)})}function Pl({hasThread:e,onUnavailable:t,unavailableHint:s,isStarred:n,showTriage:r=!0,onReply:o,onReplyAll:i,onForward:c,onDelete:d,onToggleStar:b,moveSlot:g,onMove:v,replyTitle:p="Reply (r)",replyAllTitle:x="Reply all (a)",forwardTitle:f="Forward (f)",deleteTitle:u="Move to Trash (#)",flagTitle:m="Star (s)",children:h,className:S}){const y=(w,N)=>()=>{if(!e||!N){t?.(w);return}N()};return a.jsxs("div",{className:"relative",children:[a.jsxs("header",{className:_("flex h-pane-header shrink-0 items-center gap-1 border-b border-line bg-surface px-3",S),children:[a.jsx(V,{variant:"ghost",size:"sm",icon:a.jsx(Na,{className:"size-4"}),title:p,"aria-label":"Reply",onClick:y("reply",o)}),a.jsx(V,{variant:"ghost",size:"sm",icon:a.jsx(Sa,{className:"size-4"}),title:x,"aria-label":"Reply all",onClick:y("replyAll",i)}),a.jsx(V,{variant:"ghost",size:"sm",icon:a.jsx(Ca,{className:"size-4"}),title:f,"aria-label":"Forward",onClick:y("forward",c)}),r&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"mx-1 h-4 w-px bg-line","aria-hidden":!0}),a.jsx(V,{variant:"ghost",size:"sm",icon:a.jsx(Ot,{className:"size-4"}),title:u,"aria-label":"Move to Trash",onClick:y("delete",d)}),g??a.jsx(V,{variant:"ghost",size:"sm",icon:a.jsx(ks,{className:"size-4"}),title:"Move to mailbox","aria-label":"Move to mailbox",onClick:y("move",v)}),a.jsx(V,{variant:"ghost",size:"sm",icon:a.jsx(Je,{className:_("size-4",n&&"fill-warning text-warning")}),title:m,"aria-label":"Star","aria-pressed":n,onClick:y("flag",b)})]}),a.jsx("div",{className:"flex-1"}),h]}),s&&a.jsx("p",{role:"status",className:"border-b border-line bg-surface-sunken px-3 py-1 text-2xs text-fg-subtle",children:s})]})}function La({message:e,onClick:t,isFocused:s,isUnread:n,trailing:r}){const o=a.jsxs(a.Fragment,{children:[a.jsx(Bn,{className:"size-3.5 shrink-0 text-fg-subtle"}),a.jsxs("div",{className:"relative shrink-0",children:[a.jsx(mt,{name:e.fromName,email:e.fromEmail,size:"md"}),n&&a.jsx("span",{className:"absolute -top-0.5 -right-0.5 size-2 rounded-full border border-canvas bg-accent"})]}),a.jsx("span",{className:_("w-36 shrink-0 truncate text-sm",n?"font-semibold text-fg":"font-medium text-fg-muted"),children:e.fromName}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-fg-subtle",children:e.snippet}),r??a.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:e.dateLabel})]}),i=_("group flex h-section-row w-full items-center gap-3 border-b border-line px-2 text-left transition-colors hover:bg-surface-sunken lg:px-4",s&&"bg-surface-sunken ring-1 ring-inset ring-accent/30");return t?a.jsx("div",{role:"button",tabIndex:0,"aria-expanded":!1,onClick:t,onKeyDown:c=>{wr(c)&&(c.preventDefault(),t())},className:_(i,"cursor-pointer"),children:o}):a.jsx("div",{className:i,children:o})}function Pa({message:e,warning:t,onHeaderClick:s,isFocused:n,senderBadge:r,trailing:o,to:i,indicators:c,actionMenu:d,actionBar:b,body:g}){const v=a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[a.jsxs("span",{className:"text-sm font-semibold text-fg",children:[e.fromName,r]}),o??a.jsx("span",{className:"text-2xs text-fg-subtle",children:e.dateLabel})]}),a.jsx("div",{className:"text-xs text-fg-subtle",children:e.fromEmail}),i!==null&&a.jsx("div",{className:"text-xs text-fg-subtle",children:i??a.jsxs(a.Fragment,{children:["to ",e.toLabel]})})]});return a.jsxs("div",{className:"px-2 py-3 lg:px-4",children:[a.jsxs("div",{className:_("-mx-2 -my-1 flex items-start gap-3 rounded-sm px-2 py-1",n&&"ring-1 ring-inset ring-accent/30"),children:[s?a.jsx("button",{type:"button",onClick:s,"aria-expanded":!0,"aria-label":"Collapse message",className:"mt-1 shrink-0 text-fg-subtle transition-colors hover:text-fg",children:a.jsx(ft,{className:"size-3.5"})}):a.jsx(ft,{className:"mt-1 size-3.5 shrink-0 text-fg-subtle"}),a.jsx(mt,{name:e.fromName,email:e.fromEmail,size:"md"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[s?a.jsx("button",{type:"button",onClick:s,className:"w-full text-left",children:v}):v,c]}),d&&a.jsx("div",{className:"shrink-0",children:d})]}),t&&a.jsxs("div",{className:"mt-3 flex items-start gap-3 rounded-md bg-danger-soft p-3",children:[a.jsx(et,{className:"mt-0.5 size-4 shrink-0 text-danger"}),a.jsxs("div",{className:"text-sm text-fg",children:[a.jsx("span",{className:"font-semibold text-danger",children:"Caution: "}),t," ",a.jsx("button",{type:"button",className:"text-accent underline",children:"Why?"})]})]}),b&&a.jsx("div",{className:"mt-3 -mx-2 lg:-mx-4",children:b}),a.jsx(Wo,{children:g??a.jsx(Yo,{className:"mt-3",html:e.bodyHtml,category:e.framed?"newsletter":"personal",allowImages:!0})})]})}function Dl({thread:e,onBack:t,intelligence:s,intelligenceOpen:n,onToggleIntelligence:r,actions:o,children:i,touchHandlers:c}){const[d,b]=l.useState(!1),g=r!==void 0,v=g?n??!1:d,p=!!s||g,x=()=>{if(g){r?.();return}b(u=>!u)},f=()=>{if(g){v&&r?.();return}b(!1)};return a.jsxs("article",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[a.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line bg-surface px-row-inset",children:[a.jsx(V,{variant:"ghost",size:"sm",icon:a.jsx(Qn,{className:"size-4"}),onClick:t,"aria-label":"Back to messages",className:"-ml-1 shrink-0"}),a.jsx("h2",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:e.subject}),p&&a.jsx(V,{variant:"ghost",size:"sm",icon:a.jsx(qn,{className:"size-4"}),onClick:x,"aria-label":v?"Hide intelligence panel":"Show intelligence panel","aria-pressed":v,title:"Intelligence",className:_("shrink-0",v&&"bg-accent-2-soft text-accent-2")})]}),a.jsx("div",{className:"flex-1 overflow-y-auto",style:c?{touchAction:"pan-y"}:void 0,...c,children:i??[...e.messages].reverse().map(u=>{const m=h=>h?()=>h(u.id):void 0;return u.expanded?a.jsx(Pa,{message:u,warning:e.warning,onHeaderClick:m(o?.onToggleExpand),actionBar:a.jsx($a,{hasThread:!0,onReply:m(o?.onReply),onReplyAll:m(o?.onReplyAll),onForward:m(o?.onForward),onToggleStar:m(o?.onToggleStar),onDelete:m(o?.onDelete),onToggleRead:m(o?.onToggleRead),moveSlot:o?.moveSlot?.(u.id)})},u.id):a.jsx(La,{message:u,onClick:m(o?.onToggleExpand)},u.id)})}),s&&!g&&a.jsx(jr,{open:v,onClose:f,title:"Intelligence",anchor:"right",className:"p-0",children:a.jsx(Ta,{data:s,onClose:f,className:"h-full w-full border-l-0"})})]})}function Fl({state:e,onRetry:t}){return a.jsxs("div",{role:"alert","data-testid":"attachment-error",className:"flex items-start gap-2 border-t border-danger/30 bg-danger-soft px-2 py-2 text-xs",children:[a.jsx(Cr,{className:"mt-0.5 size-3.5 shrink-0 text-danger","aria-hidden":!0}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"font-medium text-danger",children:e.title}),a.jsx("p",{className:"mt-0.5 text-fg-muted",children:e.detail})]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-3",children:[a.jsx("button",{type:"button",onClick:t,className:"font-medium text-accent hover:underline",children:"Try again"}),e.reportUrl&&a.jsx("a",{href:e.reportUrl,target:"_blank",rel:"noreferrer",className:"font-medium text-accent hover:underline",children:"Report this"})]})]})}function Ol({attachments:e,onDownload:t,hasUnlistedAttachment:s=!1,className:n}){return e.length===0&&!s?null:a.jsxs("section",{"aria-label":"Attachments","data-testid":"attachment-list",className:_("space-y-1.5",n),children:[a.jsxs("h3",{className:"flex items-center gap-1.5 text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:[a.jsx(qt,{className:"size-3","aria-hidden":!0}),e.length===0?"Attachment":e.length===1?"1 attachment":`${e.length} attachments`]}),e.length>0&&a.jsx("ul",{className:"overflow-hidden rounded-sm border border-line bg-surface",children:e.map(r=>{const o=r.download.status==="downloading";return a.jsxs("li",{className:"border-t border-line first:border-t-0",children:[a.jsxs("button",{type:"button",onClick:()=>t(r.attachmentId),disabled:o,"data-testid":"attachment-download","aria-label":`Download ${r.filename}`,className:"flex w-full items-center gap-2 px-2 py-2 text-left transition-colors hover:bg-surface-sunken disabled:cursor-progress disabled:opacity-60",children:[a.jsxs("span",{className:"min-w-0 flex-1",children:[a.jsx("bdi",{className:"block truncate text-sm text-fg",title:r.filename,children:r.filename}),a.jsxs("span",{className:"block truncate text-2xs text-fg-subtle",children:[r.typeLabel," ·"," ",Ko(r.sizeOctets)]})]}),o?a.jsx(Hn,{className:"size-4 shrink-0 animate-spin text-fg-subtle","aria-hidden":!0}):a.jsx(li,{className:"size-4 shrink-0 text-fg-subtle","aria-hidden":!0})]}),r.download.status==="failed"&&a.jsx(Fl,{state:r.download,onRetry:()=>t(r.attachmentId)})]},r.attachmentId)})}),s&&a.jsx("p",{role:"alert","data-testid":"attachment-unlisted",className:"rounded-sm border border-line bg-surface px-2 py-2 text-xs text-fg-muted",children:"The mail server says this message carries an attachment, but none of its parts describe one. Re-sync the account from Settings; if the attachment still does not appear, the message is worth reporting."})]})}function zl({label:e,onUndo:t,undoLabel:s="Undo",filtersHref:n,className:r}){return a.jsxs(Ie,{tone:"accent",className:_("py-1 text-xs",r),children:[a.jsx(qo,{className:"size-3.5 shrink-0","aria-hidden":!0}),a.jsx("span",{children:e}),t&&a.jsx("button",{type:"button",onClick:o=>{o.stopPropagation(),t()},className:"font-semibold underline decoration-dotted underline-offset-2 hover:decoration-solid",children:s}),n&&a.jsx("a",{href:n,onClick:o=>{o.stopPropagation()},className:"font-semibold underline decoration-dotted underline-offset-2 hover:decoration-solid",children:"Manage filter"})]})}const _l="peer relative size-5 shrink-0 cursor-pointer appearance-none rounded-md border border-line-strong bg-surface outline-none transition-colors checked:border-positive checked:bg-positive indeterminate:border-positive indeterminate:bg-positive focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-surface",pn="pointer-events-none absolute inset-0 m-auto size-3.5 text-accent-fg";function Ul({label:e,description:t,indeterminate:s=!1,checked:n,onChange:r,className:o,...i}){const c=l.useRef(null);l.useEffect(()=>{c.current&&(c.current.indeterminate=s)},[s]);const d=a.jsxs("span",{className:"relative inline-flex",children:[a.jsx("input",{ref:c,type:"checkbox",checked:n,onChange:r,className:_l,...i}),a.jsx(Ft,{className:_(pn,"hidden peer-checked:block"),"aria-hidden":!0}),a.jsx(ji,{className:_(pn,"hidden peer-indeterminate:block"),"aria-hidden":!0})]});return e===void 0&&t===void 0?a.jsx("span",{className:o,children:d}):a.jsxs("label",{className:_("flex min-h-11 cursor-pointer items-center gap-3 text-left",o),children:[d,a.jsxs("span",{className:"flex min-w-0 flex-col",children:[e!==void 0&&a.jsx("span",{className:"text-sm text-fg",children:e}),t!==void 0&&a.jsx("span",{className:"text-xs text-fg-subtle",children:t})]})]})}function Bl(e){return{id:e.id,fromName:e.sender,fromEmail:e.senderEmail??e.sender,subject:e.subject,snippet:e.snippet,timeLabel:e.date,isRead:!e.unread,starred:e.flagged,...e.mailboxId?{mailboxId:e.mailboxId}:{}}}function Kl({result:e,onClick:t,query:s,showFolder:n=!0}){const r=n&&e.folder?Sr(e.folder):void 0;return a.jsx("button",{type:"button",onClick:t,className:_("group",As({}),"border-b border-line"),children:a.jsx($s,{thread:Bl(e),highlightQuery:s,badge:a.jsxs(a.Fragment,{children:[r&&a.jsx(Ie,{tone:"neutral",className:"shrink-0",children:r}),e.category&&a.jsx(Ie,{tone:e.category.tone??"neutral",className:"shrink-0",children:e.category.label}),e.matchedChunkLabel&&a.jsx(Ie,{tone:"neutral",className:"shrink-0",children:`matched: ${e.matchedChunkLabel}`}),e.score!=null&&a.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:e.score.toFixed(2)})]})})})}const ql=e=>e===1?"result":"results";function Ql({count:e,onScopeToSpam:t}){return a.jsx(Gn,{tone:"info",variant:"soft",className:"items-center justify-between gap-3 rounded-none border-b border-line",children:a.jsxs("div",{className:"flex items-center justify-between gap-3",children:[a.jsxs("p",{className:"min-w-0 text-xs text-fg-muted",children:[a.jsx("span",{className:"font-semibold text-fg tabular-nums",children:e})," ",`${ql(e)} from Spam`]}),a.jsx(V,{variant:"ghost",size:"sm",onClick:t,className:"shrink-0 text-accent",children:"Go to Spam"})]})})}const hn=6,Hl={kind:"global"},Gl=e=>e.kind==="folder"&&e.role==="junk",Vl=e=>e.folder?.role==="junk";function Da(e){const t=[],s=[];for(const n of e)Vl(n)?s.push(n):t.push(n);return{kept:t,spam:s}}function Fa({onClick:e,blockedReason:t}){const s=l.useId(),[n,r]=l.useState(!1);return a.jsxs("div",{className:"border-b border-line px-row-inset py-1.5",children:[a.jsxs("button",{type:"button",onClick:()=>{if(t){r(!0);return}e()},"aria-describedby":t?s:void 0,className:_("flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium transition-colors",t?"text-fg-subtle opacity-55":"text-accent hover:bg-surface-sunken"),children:[a.jsx(Nr,{className:"size-3.5 shrink-0","aria-hidden":"true"}),a.jsx("span",{children:"Make this a filter"})]}),t&&a.jsx(Tr,{id:s,reason:t,nudged:n,className:"px-2 pt-1 text-2xs text-warning"})]})}function Wl({section:e,query:t,onSelectResult:s,showFolder:n}){const[r,o]=l.useState(e.initialCollapsed??!1),[i,c]=l.useState(!1),d=e.results.length>hn,g=!i&&d?e.results.slice(0,hn):e.results,v=e.results.length-g.length;return a.jsxs("div",{children:[a.jsxs("button",{type:"button","aria-expanded":!r,onClick:()=>o(p=>!p),className:"sticky top-0 z-10 flex h-section-row w-full items-center gap-1.5 border-b border-line bg-surface-sunken px-row-inset text-left transition-colors hover:bg-surface",children:[a.jsx("span",{className:"flex-1 text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:e.label}),a.jsx("span",{className:"text-2xs text-fg-subtle tabular-nums",children:e.results.length}),a.jsx(ft,{className:_("size-3 shrink-0 text-fg-subtle transition-transform duration-200",r?"rotate-0":"rotate-180")})]}),!r&&a.jsxs(a.Fragment,{children:[g.map(p=>a.jsx(Kl,{result:p,query:t,showFolder:n,onClick:s?()=>s(p):void 0},p.id)),d&&a.jsxs("button",{type:"button",onClick:()=>c(p=>!p),className:"flex w-full items-center justify-center border-b border-line px-row-inset py-1.5 text-2xs font-medium text-accent transition-colors hover:bg-surface",children:[i?"Show less":`Show ${v} more`,!i&&a.jsx(ft,{className:"ml-1 size-3"})]})]})]})}function Oa({value:e,recentSearches:t,onPickRecent:s,sections:n,loading:r,onSelectResult:o,tokens:i,scope:c=Hl,makeFilter:d}){if(!(e.trim().length>0))return t&&t.length>0?a.jsxs("div",{className:"flex flex-col",children:[a.jsx("h3",{className:"px-row-inset pb-1 pt-3 text-2xs font-semibold uppercase tracking-wide text-fg-subtle",children:"Recent searches"}),t.map(w=>a.jsxs("button",{type:"button",onClick:()=>s?.(w),className:"flex w-full items-center gap-2.5 border-b border-line px-row-inset py-2.5 text-left transition-colors hover:bg-surface-sunken",children:[a.jsx(Ci,{className:"size-4 shrink-0 text-fg-subtle"}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-fg-muted",children:w})]},w))]}):a.jsx("p",{className:"px-row-inset py-6 text-center text-sm text-fg-subtle",children:"Search across your mail by sender, subject or words in the message."});const g=i&&i.length>0&&a.jsx(Ir,{tokens:i}),v=d&&a.jsx(Fa,{...d});if(r)return a.jsxs("div",{className:"flex flex-col",children:[v,g,a.jsx("div",{className:"flex flex-col gap-3 px-row-inset py-4",children:[0,1,2,3].map(w=>a.jsxs("div",{className:"flex flex-col gap-1.5",children:[a.jsx("div",{className:"h-3 w-1/3 animate-pulse rounded bg-surface-sunken"}),a.jsx("div",{className:"h-3 w-2/3 animate-pulse rounded bg-surface-sunken"}),a.jsx("div",{className:"h-2.5 w-1/2 animate-pulse rounded bg-surface-sunken"})]},w))})]});const p=c.kind==="global",x=Gl(c)||c.kind==="collection",f=p||c.kind==="collection",u=(n??[]).map(w=>{if(x)return{section:w,spam:[]};const{kept:N,spam:E}=Da(w.results);return{section:{...w,results:N},spam:E}}),m=u.map(w=>w.section),h=u.reduce((w,N)=>w+N.spam.length,0),S=c.kind==="global"&&h>0&&c.onScopeToSpam!==void 0?a.jsx(Ql,{count:h,onScopeToSpam:c.onScopeToSpam}):void 0;return m.some(w=>w.results.length>0)?a.jsxs("div",{className:"flex flex-col",children:[v,g,S,m.filter(w=>w.results.length>0).map(w=>a.jsx(Wl,{section:w,query:e,showFolder:f,onSelectResult:o},w.id))]}):a.jsxs("div",{className:"flex flex-col",children:[v,g,S,a.jsxs("div",{className:"px-row-inset py-10 text-center",children:[a.jsxs("p",{className:"text-sm font-medium text-fg",children:["No matches for “",e,"”"]}),a.jsx("p",{className:"mt-1 text-xs text-fg-subtle",children:"Try a different word, or adjust the filters above."})]})]})}function Yl({value:e,onChange:t,onClear:s,onCancel:n,filter:r,recentSearches:o,onPickRecent:i,sections:c,loading:d,onSelectResult:b,tokens:g,chips:v,onRemoveChip:p,scope:x,makeFilter:f,suggest:u,suggestList:m}){const h=a.jsx(Oa,{value:e,recentSearches:o,onPickRecent:i,sections:c,loading:d,onSelectResult:b,tokens:g,scope:x,makeFilter:f});return a.jsxs("article",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[a.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line bg-surface px-row-inset",children:[a.jsx("div",{className:"min-w-0 flex-1",children:a.jsx(na,{value:e,onChange:t,onClear:s,chips:v,onRemoveChip:p,globalFocusKey:!1,showClearButton:!1,suggest:u})}),a.jsx(V,{variant:"ghost",size:"sm",icon:a.jsx(Dt,{className:"size-4"}),onClick:n,"aria-label":"Clear and close search",className:"-mr-1 shrink-0"})]}),m,r&&e.trim().length===0?a.jsx(Er,{children:a.jsx(Rr,{...r,children:h})}):a.jsx("div",{className:"flex-1 overflow-y-auto",children:h})]})}const gn=e=>e.toLocaleString();function bn({selectAll:e,selecting:t,className:s}){return a.jsx(Ul,{className:s,checked:e.checked,indeterminate:e.indeterminate,onChange:e.onChange,label:a.jsx("span",{className:"font-medium text-accent",children:e.checked&&t?"Deselect all":"Select all"})})}function Jl({title:e,count:t,onCancel:s,onDelete:n,onMove:r,onOrganize:o,onJunk:i,onMarkRead:c,navSlot:d,titleMeta:b,searchSlot:g,searchField:v,idleSlot:p,overflowSlot:x,isBusy:f=!1,isCounting:u=!1,selectAll:m,statusLabel:h,progress:S,notice:y}){const w=t>0||u,N=m?.checked?`All ${gn(t)} loaded selected`:`${gn(t)} ${t===1?"message":"messages"} selected`,E=[];return i&&!f&&!u&&E.push({key:"junk",label:"Junk",icon:a.jsx(et,{className:"size-4"}),onSelect:i}),c&&!f&&!u&&E.push({key:"mark-read",label:"Mark read",icon:a.jsx(Ms,{className:"size-4"}),onSelect:c}),a.jsxs("header",{"data-selection-bar":"",className:"flex shrink-0 flex-col border-b border-line bg-surface-sunken",children:[a.jsxs("div",{"data-selection-bar-row":"actions",className:"flex h-pane-header items-center gap-1 px-row-inset",children:[w?a.jsx(V,{variant:"ghost",size:"touch",icon:a.jsx(Qn,{className:"size-5"}),onClick:s,"aria-label":"Cancel selection",className:"-ml-2 shrink-0"}):d,m&&a.jsx(bn,{selectAll:m,selecting:w,className:"hidden shrink-0 pr-2 md:flex"}),w?a.jsx("span",{"data-selection-count":"",className:"min-w-0 flex-1 truncate px-1 text-sm font-medium text-fg",role:"status","aria-live":"polite",children:h??N}):v?a.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1",children:v}):a.jsxs(a.Fragment,{children:[a.jsx("h1",{className:"min-w-0 flex-1 truncate px-1 text-sm font-semibold text-fg",children:e}),b,g]}),w&&!u&&a.jsxs(a.Fragment,{children:[a.jsx(V,{variant:"ghost",size:"touch",icon:f?a.jsx(Hn,{className:"size-5 animate-spin"}):a.jsx(Ot,{className:"size-5 text-danger"}),onClick:f?void 0:n,"aria-label":"Move selected messages to Trash","aria-busy":f||void 0,className:"shrink-0"}),!f&&r&&a.jsx(V,{variant:"ghost",size:"touch",icon:a.jsx(ks,{className:"size-5"}),onClick:r,"aria-label":"Move selected messages",className:"shrink-0"}),!f&&o&&a.jsx(V,{variant:"ghost",size:"touch",icon:a.jsx(Ye,{className:"size-5"}),onClick:o,"aria-label":"Organize selected messages",className:"shrink-0"})]}),w&&a.jsx(aa,{triggerLabel:"More actions",items:E,className:"shrink-0",children:!f&&!u&&x})]}),!w&&p,w&&m&&a.jsx("div",{"data-selection-bar-row":"select-all",className:"px-row-inset pb-2 md:hidden",children:a.jsx(bn,{selectAll:m,selecting:w,className:"w-full"})}),S&&a.jsx("div",{className:"px-row-inset pb-2",children:a.jsx(Mr,{value:S.value,max:S.max,tone:S.tone})}),y&&a.jsx(Gn,{"data-selection-notice":"",tone:y.tone,variant:"soft",role:"status","aria-live":"polite",className:"mx-row-inset mb-2",children:a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[y.text&&a.jsx("span",{children:y.text}),y.action&&a.jsx(V,{variant:"ghost",size:"md",onClick:y.action.onClick,className:"-my-1 min-h-11 shrink-0",children:y.action.label})]})})]})}const Ls=[{id:"all",label:"All",tone:"neutral"},{id:"personal",label:"Personal",tone:"accent"},{id:"uncategorized",label:"Unclassified",tone:"neutral"},{id:"transactional",label:"Transactional",tone:"positive"},{id:"newsletter",label:"Newsletter",tone:"neutral"},{id:"marketing",label:"Marketing",tone:"warning"},{id:"social",label:"Social",tone:"warning"},{id:"automated",label:"Automated",tone:"neutral"}],za={id:"unread",label:"Unread"},Xl={id:"flagged",label:"Starred"},_a={id:"attachment",label:"Has attachment"};function Zl(e){if(!(e.length<=1))return e.map(t=>({id:t.id,label:t.label,count:t.count,active:t.active}))}function cm(e=[]){return{categories:[...Ls],filters:Ar,sources:Zl(e)}}function dm(){return{categories:[...Ls],filters:[za,Xl,_a]}}function um(){return{categories:[...Ls],filters:[za,_a]}}function ec(e,t){return e.endsWith(t)?e.length===t.length||e[e.length-t.length-1]===".":!1}function tc(e,t){const s=e.length-t.length-2,n=e.lastIndexOf(".",s);return n===-1?e:e.slice(n+1)}function sc(e,t,s){if(s.validHosts!==null){const r=s.validHosts;for(const o of r)if(ec(t,o))return o}let n=0;if(t.startsWith("."))for(;n<t.length&&t[n]===".";)n+=1;return e.length===t.length-n?null:tc(t,e)}const rs=/[\t\n\r]/g;let ps=!1;function xn(e){return e>=97&&e<=122||e>=48&&e<=57||e>127||e>=65&&e<=90||e===45||e===95}function vn(e,t,s){const n=s-t,r=e.charCodeAt(t)|32;if(n===2)return r===119&&(e.charCodeAt(t+1)|32)===115?1:0;if(n===3){const o=e.charCodeAt(t+1)|32,i=e.charCodeAt(t+2)|32;return r===119&&o===115&&i===115||r===102&&o===116&&i===112?1:0}else if(n===4){const o=e.charCodeAt(t+1)|32,i=e.charCodeAt(t+2)|32,c=e.charCodeAt(t+3)|32;return r===104&&o===116&&i===116&&c===112?1:r===102&&o===105&&i===108&&c===101?2:0}else if(n===5)return r===104&&(e.charCodeAt(t+1)|32)===116&&(e.charCodeAt(t+2)|32)===116&&(e.charCodeAt(t+3)|32)===112&&(e.charCodeAt(t+4)|32)===115?1:0;return 0}function ut(e,t,s=!1){let n=0,r=e.length,o=!1,i=!1;if(ps=!1,!t){if(e.startsWith("data:"))return null;for(;n<e.length&&e.charCodeAt(n)<=32;)n+=1;for(;r>n+1&&e.charCodeAt(r-1)<=32;)r-=1;if(e.charCodeAt(n)===47&&e.charCodeAt(n+1)===47)n+=2;else{const m=e.indexOf(":/",n);if(m!==-1){const h=vn(e,n,m);if(h===1)for(i=!0,n=m+2;e.charCodeAt(n)===47||e.charCodeAt(n)===92;)n+=1;else if(h===2){i=!0,n=m+1;let S=0;for(;(e.charCodeAt(n)===47||e.charCodeAt(n)===92)&&S<2;)n+=1,S+=1;if(S<2)return null}else{for(let S=n;S<m;S+=1){const y=e.charCodeAt(S)|32;if(!(y>=97&&y<=122||y>=48&&y<=57||y===46||y===45||y===43)){const w=e.charCodeAt(S);return w===9||w===10||w===13?ut(e.replace(rs,""),t,s):null}}if(e.charCodeAt(m+2)===47)n=m+3;else return null}}else if(e.charCodeAt(n)!==91){let h=-1;for(let S=n;S<r;S+=1){const y=e.charCodeAt(S);if(y===9||y===10||y===13)return ut(e.replace(rs,""),t,s);if(y===58){h=S;break}if(y===47||y===92||y===63||y===35)break}if(h!==-1){let S=!1;for(let y=h+1;y<r;y+=1){const w=e.charCodeAt(y);if(w===47||w===92||w===63||w===35)break;if(w===64){S=!0;break}}if(!S){let y=!0,w=h+1;for(;w<r;w+=1){const N=e.charCodeAt(w);if(N===47||N===92||N===63||N===35)break;if(N<48||N>57){y=!1;break}}if(w===h+1&&(y=!1),!y){const N=vn(e,n,h);if(N===0){let E=!1;for(let P=h+1;P<r;P+=1){const z=e.charCodeAt(P);if(z===47||z===92||z===63||z===35)break;if(z===58){E=!0;break}}if(!E)return null}else if(i=!0,n=h+1,N===2){let E=0;for(;(e.charCodeAt(n)===47||e.charCodeAt(n)===92)&&E<2;)n+=1,E+=1;if(E<2)return null}else for(;e.charCodeAt(n)===47||e.charCodeAt(n)===92;)n+=1}}}}}let d=-1,b=-1,g=-1,v=-1,p=!1,x=s,f=n-1,u=-1;if(s&&n<r){const m=e.charCodeAt(n);(!(xn(m)||m===46||m===95)||m===45)&&(x=!1)}for(let m=n;m<r;m+=1){const h=e.charCodeAt(m);if(h<64)if(h===47||h===35||h===63){r=m;break}else h===58?(v===-1&&(v=m),g=m):h===9||h===10||h===13?p=!0:s&&(h===46?((m-f>64||u===46||u===45)&&(x=!1),f=m):(h<48||h>57)&&(h!==45||u===46)&&(x=!1));else if(i&&h===92){r=m;break}else h===64?(d=m,v=-1):h===93?b=m:h>=65&&h<=90?o=!0:s&&!xn(h)&&(x=!1);s&&(u=h)}if(p)return ut(e.replace(rs,""),t,s);if(d!==-1&&d>=n&&d<r&&(n=d+1),e.charCodeAt(n)===91)return b!==-1?e.slice(n+1,b).toLowerCase():null;if(g!==-1&&g>n&&g<r&&v===g&&(r=g),n>=r)return null;s&&x&&d===-1&&g===-1&&b===-1&&e.charCodeAt(r-1)!==46&&r-n<=255&&r-f-1<=63&&u!==45&&(ps=!0)}for(;r>n+1&&e.charCodeAt(r-1)===46;)r-=1;const c=n!==0||r!==e.length?e.slice(n,r):e;return o?c.toLowerCase():c}function nc(e){if(e.length<7||e.length>15)return!1;let t=0;for(let s=0;s<e.length;s+=1){const n=e.charCodeAt(s);if(n===46)t+=1;else if(n<48||n>57)return!1}return t===3&&e.charCodeAt(0)!==46&&e.charCodeAt(e.length-1)!==46}function ac(e){if(e.length<3)return!1;let t=e.startsWith("[")?1:0,s=e.length;if(e[s-1]==="]"&&(s-=1),s-t>39)return!1;let n=!1;for(;t<s;t+=1){const r=e.charCodeAt(t);if(r===58)n=!0;else if(!(r>=48&&r<=57||r>=97&&r<=102||r>=65&&r<=70))return!1}return n}function rc(e){return ac(e)||nc(e)}function yn(e){return e>=97&&e<=122||e>=48&&e<=57||e>127}function kn(e){if(e.length>255||e.length===0||!yn(e.charCodeAt(0))&&e.charCodeAt(0)!==46&&e.charCodeAt(0)!==95)return!1;let t=-1,s=-1;const n=e.length;for(let r=0;r<n;r+=1){const o=e.charCodeAt(r);if(o===46){if(r-t>64||s===46||s===45)return!1;t=r}else if(!(yn(o)||o===45||o===95)||o===45&&s===46)return!1;s=o}return n-t-1<=63&&s!==45}function oc({allowIcannDomains:e=!0,allowPrivateDomains:t=!1,detectIp:s=!0,detectSpecialUse:n=!1,extractHostname:r=!0,mixedInputs:o=!0,validHosts:i=null,validateHostname:c=!0}){return{allowIcannDomains:e,allowPrivateDomains:t,detectIp:s,detectSpecialUse:n,extractHostname:r,mixedInputs:o,validHosts:i,validateHostname:c}}const ic=oc({});function lc(e){return ic}function cc(){return{domain:null,domainWithoutSuffix:null,hostname:null,isIcann:null,isIp:null,isPrivate:null,isSpecialUse:null,publicSuffix:null,subdomain:null}}function dc(e){e.domain=null,e.domainWithoutSuffix=null,e.hostname=null,e.isIcann=null,e.isIp=null,e.isPrivate=null,e.isSpecialUse=null,e.publicSuffix=null,e.subdomain=null}function uc(e,t,s,n,r){const o=lc();if(typeof e!="string")return r;let i=!1;return o.extractHostname?o.mixedInputs?(i=kn(e),r.hostname=ut(e,i,o.validateHostname)):r.hostname=ut(e,!1,o.validateHostname):r.hostname=e,o.detectIp&&r.hostname!==null&&(r.isIp=rc(r.hostname),r.isIp)?r:o.validateHostname&&o.extractHostname&&r.hostname!==null&&!(i&&r.hostname===e)&&!ps&&!kn(r.hostname)?(r.hostname=null,r):(r.hostname===null||(s(r.hostname,o,r),r.publicSuffix===null)||(r.domain=sc(r.publicSuffix,r.hostname,o)),r)}const wn=cc();function fc(e,t){return dc(wn),uc(e,3,$r,t,wn).domain}const Qt=e=>{const t=new Set,s=[];for(const n of e){const r=n.trim();if(r==="")continue;const o=r.toLowerCase();t.has(o)||(t.add(o),s.push(r))}return s},mc=e=>{const t=e.lastIndexOf("@");return t>=0?e.slice(t+1):e},Ua=e=>fc(mc(e.trim())),pc=e=>{const t=Qt(e);if(t.length<2)return null;let s=null;for(const n of t){const r=Ua(n);if(r===null)return null;if(s===null)s=r;else if(s!==r)return null}return s},Ht=e=>{const t=pc(e);return t!==null?[{field:"FromDomain",value:t}]:Qt(e).map(s=>({field:"From",value:s}))},hc=e=>{const t=new Map;for(const r of e){const o=r.normalizedEmail.trim().toLowerCase();if(o==="")continue;const i=t.get(o);i?i.count+=1:t.set(o,{sender:r,count:1})}let s,n=0;for(const{sender:r,count:o}of t.values())o<=n||(s=r,n=o);return s},Ba=e=>e.displayName?.trim()||e.normalizedEmail,gc=/^\s*(?:(?:re|aw|fwd?|vs|sv|antw|res|enc|tr)\s*(?:\[\d+\])?\s*:|\[[^\]]{1,32}\])\s*/i,bc=e=>{let t=e.replace(/\s+/g," ").trim();for(;;){const s=t.replace(gc,"");if(s===t)return t.trim();t=s}},xc=new Set(["a","an","and","are","as","at","be","by","for","from","has","have","in","is","it","me","my","new","of","on","or","our","the","this","to","was","we","with","you","your"]),vc=3,os=e=>e.split(" ").filter(t=>t!==""),jn=e=>e.length===0||e.join(" ").length<vc?!1:e.some(t=>!xc.has(t.toLowerCase())),yc=(e,t)=>e.findIndex((s,n)=>t.every((r,o)=>e[n+o]?.toLowerCase()===r.toLowerCase())),kc=e=>{const t=e.map(bc).filter(o=>o!=="");if(t.length===0)return;const[s,...n]=t;if(n.length===0)return jn(os(s))?s:void 0;const r=os(s);for(let o=r.length;o>0;o-=1)for(let i=0;i+o<=r.length;i+=1){const c=r.slice(i,i+o);if(jn(c)&&n.every(d=>yc(os(d),c)>=0))return c.join(" ")}},wc=(e,t)=>{const s=Ht(e);if(Qt(e).length===1||s.length===1&&s[0].field==="FromDomain")return s;const n=kc(t);return n!==void 0?[{field:"Subject",value:n}]:s},jc=({match:e,sender:t,folder:s})=>{const n=e??t;return n?s?`${n} → ${s}`:e?`Mail matching ${e}`:`Mail from ${n}`:s?`Mail to ${s}`:""},Cc=e=>e.clauses.length>0,Sc=e=>({scopedOutFolder:e.scopedOut?.label,droppedFacets:e.droppedFacets.map(t=>t.label),droppedSemantic:e.droppedSemantic}),Nc=({orderedIds:e,isDesktop:t,initialFocusedId:s,initialSelectedIds:n,onExitSelection:r})=>{const[o,i]=l.useState(s),[c,d]=l.useState(),b=l.useCallback(j=>{d(M=>M===j?M:void 0),i(j)},[]),g=Tl({initialSelectedIds:n}),{selectedCount:v,toggle:p,clearSelection:x,selectRange:f,setAnchor:u,selectAll:m}=g,h=wl(v,t),S=l.useRef(null),y=l.useRef(!1),w=l.useCallback(()=>{r?.(),x()},[x,r]),N=l.useMemo(()=>o?e.indexOf(o):-1,[e,o]),E=l.useCallback(j=>{if(j<0||j>=e.length)return;const M=e[j];if(h){p(M);return}S.current=M,y.current=!1,d(M),i(M)},[e,h,p]),P=l.useCallback(()=>{e.length!==0&&E(N<0?0:Math.min(N+1,e.length-1))},[e.length,N,E]),z=l.useCallback(()=>{e.length!==0&&E(N<=0?0:N-1)},[e.length,N,E]),U=l.useCallback(()=>E(0),[E]),L=l.useCallback(()=>E(e.length-1),[E,e.length]),D=l.useCallback(()=>{o&&p(o)},[o,p]),F=l.useCallback((j,M)=>{const C=kl(M);return C==="range"?(f(e,j,o),!0):C==="toggle"?(p(j),!0):(w(),u(j),!1)},[e,o,f,p,w,u]),O=l.useCallback(j=>{const M=Nl(e,o,j);M!==void 0&&(f(e,M),S.current=M,y.current=!1,d(void 0),i(M))},[e,o,f]),k=l.useCallback(()=>O(-1),[O]),I=l.useCallback(()=>O(1),[O]),R=l.useCallback(()=>{e.length>0&&m(e)},[e,m]);return{focusedMessageId:o,setFocusedMessageId:b,keyboardFocusedMessageId:c,focusIndex:N,pendingDomFocusRef:S,cursorMovedByPointerRef:y,selection:g,isMultiSelectMode:h,exitSelection:w,moveFocusToIndex:E,focusNext:P,focusPrevious:z,focusFirst:U,focusLast:L,toggleFocusedSelection:D,extendRangeUp:k,extendRangeDown:I,selectAllLoaded:R,handleRowSelect:F}};function Tc(e,t){if(e===void 0)return{shouldBlockFn:()=>!0,withResolver:!1};if("shouldBlockFn"in e)return e;if(typeof e=="function")return{shouldBlockFn:async()=>await e(),enableBeforeUnload:!0,withResolver:!1};const s=!!(e.condition??!0),n=e.blockerFn;return{shouldBlockFn:async()=>s&&n!==void 0?await n():s,enableBeforeUnload:s,withResolver:n===void 0}}function Ic(e,t){const{shouldBlockFn:s,enableBeforeUnload:n=!0,disabled:r=!1,withResolver:o=!1}=Tc(e),i=Lr(),{history:c}=i,[d,b]=l.useState({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0});return l.useEffect(()=>{const g=async v=>{function p(h){const S=i.parseLocation(h),y=i.getMatchedRoutes(S.pathname);return y.foundRoute===void 0?{routeId:"__notFound__",fullPath:S.pathname,pathname:S.pathname,params:y.routeParams,search:i.options.parseSearch(h.search)}:{routeId:y.foundRoute.id,fullPath:y.foundRoute.fullPath,pathname:S.pathname,params:y.routeParams,search:i.options.parseSearch(h.search)}}const x=p(v.currentLocation),f=p(v.nextLocation);if(x.routeId==="__notFound__"&&f.routeId!=="__notFound__")return!1;const u=await s({action:v.action,current:x,next:f});if(!o)return u;if(!u)return!1;const m=await new Promise(h=>{b({status:"blocked",current:x,next:f,action:v.action,proceed:()=>h(!1),reset:()=>h(!0)})});return b({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0}),m};return r?void 0:c.block({blockerFn:g,enableBeforeUnload:n})},[s,n,r,o,c,i]),d}const Ps=e=>{const{data:t,isLoading:s}=ee({...bt(),staleTime:1/0}),n=l.useMemo(()=>(t?.accounts??[]).map(c=>c.accountId),[t?.accounts]),r=Ts({queries:n.map(c=>({...xt({path:{accountId:c}}),staleTime:1/0,enabled:!!e}))}),o=s||r.some(c=>c.isLoading);return{accountId:l.useMemo(()=>{if(e){for(let c=0;c<n.length;c++)if((r[c].data?.items??[]).some(g=>g.mailboxId===e))return n[c]}},[e,n,r]),isLoading:o}},Ec=({surface:e})=>{const t=Pr(),s=Dr(),{data:n}=ee({...zt({path:{messageId:e.sourceMessageId}})}),{data:r}=ee({...bt(),staleTime:1/0}),{accountId:o}=Ps(n?.message.mailboxId),i=r?.accounts?.find(c=>c.accountId===o);return a.jsx("div",{className:"border-b border-line bg-canvas",children:a.jsx(si,{layout:"flow",mode:e.mode,account:i,sourceMessage:n,outboxMessageId:e.outboxMessageId,onDraftCreated:t,onClose:s})})},Ka=100,hs=async e=>e.then(t=>({ok:!0,value:t}),t=>({ok:!1,error:t})),Rc=(e,t=Ka)=>{if(e.length===0)return[];const s=[];for(let n=0;n<e.length;n+=t)s.push(e.slice(n,n+t));return s},Mc=(e,t=Ka)=>{const s=new Map;for(const n of e){const r=s.get(n.accountId);if(r){r.push(n.id);continue}s.set(n.accountId,[n.id])}return[...s.values()].flatMap(n=>Rc(n,t))},qa=async(e,t,s,n)=>{const r=Mc(e),o=e.length;let i=0;const c=[];for(let d=0;d<r.length;d++){if(n())return c.push(...r.slice(d).flat()),{done:i,failedIds:c,cancelled:!0};const b=r[d],g=await hs(t(b));if(!g.ok)return c.push(...r.slice(d).flat()),s({done:i,total:o}),{done:i,failedIds:c,cancelled:!1,error:g.error};i+=b.length,s({done:i,total:o})}return{done:i,failedIds:c,cancelled:!1}},gt=async(e,t)=>{await qa(e.map(s=>({id:s,accountId:void 0})),async s=>(await t(s),{successCount:s.length,failureCount:0}),()=>{},()=>!1)},Ac=async(e,t,s,n,r)=>{let o=0;const i=[];let c;do{if(r())return{done:o,failedIds:i,cancelled:!0};const d=await hs(e(c));if(!d.ok)return{done:o,failedIds:i,cancelled:!1,error:d.error};const b=d.value;if(b.ids.length>0){const g=await hs(s(b.ids));if(!g.ok)return{done:o,failedIds:i,cancelled:!1,error:g.error};o+=b.ids.length,n({done:o,total:t})}c=b.continuationToken}while(c);return{done:o,failedIds:i,cancelled:!1}},$c=e=>({done:e.done,total:Math.max(e.total,e.done)}),Lc=3e3,Pc=(e,t,s)=>{if(e.length===0)return()=>{};const n=setTimeout(()=>s(e),t);return()=>clearTimeout(n)},Ds=(e,t,s)=>{const n=new Map(t.map(o=>[o.messageId,o.mailboxId])),r=new Set;for(const o of e)r.add(n.get(o)??s);return[...r]},Pt=(e,t,s)=>e.map(n=>t.has(n.messageId)?{...n,isRead:s}:n),Dc=(e,t,s,n)=>e.filter(r=>!r.isRead&&t.has(r.threadMessageId)&&!s.has(r.messageId)&&!n.has(r.messageId)).map(r=>r.messageId),Fc=({messages:e,expandedIds:t,threadId:s,mailboxId:n,accountId:r})=>{const o=ie(),{pushError:i}=xe(),c=l.useRef(new Set),d=l.useRef(new Set),{mutate:b}=me({..._t(),meta:Fr,onMutate:async p=>{const x=new Set(p.body.messageIds??[]),f=p.body.isRead??!0,u=Me({path:{threadId:s}}),m=je(Ds(x,e,n));await Promise.all([o.cancelQueries({queryKey:u}),yt(o,m)]);const h=o.getQueriesData({queryKey:u}).filter(y=>y[1]!==void 0).map(([y,w])=>({queryKey:y,data:w})),S=kt(o,m);return o.setQueriesData({queryKey:u},y=>y&&{...y,items:Pt(y.items,x,f)}),wt(o,m,y=>Pt(y,x,f)),{threadMessagesPrefix:u,listPrefixes:m,previousThreadMessages:h,previousThreadsList:S}},onSuccess:(p,x)=>{const f=x.body.messageIds??[];for(const u of f)c.current.add(u),d.current.delete(u)},onError:(p,x,f)=>{const u=x.body.messageIds??[];for(const h of u)d.current.delete(h);if(f){for(const h of f.previousThreadMessages)o.setQueryData(h.queryKey,h.data);vt(o,f.previousThreadsList)}const m=x.body.isRead??!0;i({title:m?"Couldn't mark as read":"Couldn't mark as unread",detail:Re(p),error:p})},onSettled:(p,x,f,u)=>{u&&(o.invalidateQueries({queryKey:u.threadMessagesPrefix}),we(o,u.listPrefixes),r&&o.invalidateQueries({queryKey:Xe({path:{accountId:r}})}))}}),g=l.useCallback(p=>{const x=p.filter(f=>!c.current.has(f)&&!d.current.has(f));if(x.length!==0){for(const f of x)d.current.add(f);b({body:{messageIds:x,isRead:!0}})}},[b]),v=l.useMemo(()=>Dc(e,t,c.current,d.current),[e,t]);l.useEffect(()=>Pc(v,Lc,g),[v,g]),l.useEffect(()=>{c.current.clear(),d.current.clear()},[s])},fm=e=>{const{mailboxId:t,accountId:s,messages:n}=e,r=ie(),{pushError:o}=xe(),{mutateAsync:i,isPending:c}=me({..._t(),onError:(b,g)=>{const v=g.body.isRead??!0;o({title:v?"Couldn't mark as read":"Couldn't mark as unread",detail:Re(b),error:b})},onSettled:(b,g,v)=>{we(r,je(Ds(v.body.messageIds??[],n??[],t))),s&&r.invalidateQueries({queryKey:Xe({path:{accountId:s}})})}});return{toggleReadFor:l.useCallback((b,g)=>{b.length!==0&&gt(b,v=>i({body:{messageIds:v,isRead:g}}))},[i]),isPending:c}},Oc=60,zc=1.5,_c=(e,t,s)=>{const n=Math.abs(e),r=Math.abs(t);return n<s?{direction:null}:n<r*zc?{direction:null}:{direction:e<0?"left":"right"}},Uc=({onSwipeLeft:e,onSwipeRight:t,thresholdPx:s=Oc})=>{const n=l.useRef(null),r=l.useCallback(d=>{if(d.pointerType==="mouse"){n.current=null;return}n.current={x:d.clientX,y:d.clientY}},[]),o=l.useCallback(()=>{},[]),i=l.useCallback(d=>{const b=n.current;if(n.current=null,!b)return;const{direction:g}=_c(d.clientX-b.x,d.clientY-b.y,s);g==="left"&&e?.(),g==="right"&&t?.()},[e,t,s]),c=l.useCallback(()=>{n.current=null},[]);return{handlers:{onPointerDown:r,onPointerMove:o,onPointerUp:i,onPointerCancel:c}}},Bc=(e,t,s)=>t?.find(n=>n.messageId===e)?.mailboxId??s,Cn=(e,t,s)=>e.map(n=>n.messageId===t?{...n,hasStars:s}:n),Qa=({threadId:e,mailboxId:t,messages:s})=>{const n=ie(),{pushError:r}=xe(),{mutate:o,isPending:i,variables:c}=me({...Or(),onMutate:async b=>{const g=b.path.messageId,v=b.body.isStarred??!1,p=Me({path:{threadId:e}}),x=je([Bc(g,s,t)]);await Promise.all([n.cancelQueries({queryKey:p}),yt(n,x)]);const f=n.getQueriesData({queryKey:p}).filter(m=>m[1]!==void 0).map(([m,h])=>({queryKey:m,data:h})),u=kt(n,x);return n.setQueriesData({queryKey:p},m=>Mo(m,h=>Cn(h,g,v))),wt(n,x,m=>Cn(m,g,v)),{threadMessagesPrefix:p,listPrefixes:x,previousThreadMessages:f,previousThreadsList:u}},onError:(b,g,v)=>{if(v){for(const x of v.previousThreadMessages)n.setQueryData(x.queryKey,x.data);vt(n,v.previousThreadsList)}const p=g.body.isStarred??!1;r({title:p?"Couldn't star message":"Couldn't unstar message",detail:Re(b),error:b})},onSettled:(b,g,v,p)=>{p&&(n.invalidateQueries({queryKey:p.threadMessagesPrefix}),we(n,p.listPrefixes))}});return{toggleStar:(b,g)=>{o({path:{messageId:b},body:{isStarred:!g}})},isPending:i,pendingMessageId:i?c?.path.messageId:void 0}};function Sn({authenticity:e,onOpenIntelligence:t}){return e.dkimMismatch?a.jsxs("div",{className:"flex items-start gap-2 rounded-none border-b border-danger/20 bg-danger-soft px-5 py-2.5 text-sm",children:[a.jsx(et,{className:"mt-0.5 size-4 shrink-0 text-danger"}),a.jsxs("p",{className:"flex-1 leading-snug text-fg",children:["This message claims to be from"," ",a.jsx("span",{className:"font-semibold",children:e.fromDomain})," but was sent",e.dkimDomain?` via ${e.dkimDomain}`:" from a different domain","."," ",t&&a.jsx("button",{type:"button",onClick:t,className:"font-medium text-danger hover:underline",children:"Why?"})]})]}):null}function Ha(e){return e===void 0?"uncategorized":e}const Kc={inbox:"Inbox",junk:"Junk"},Fs=e=>e.destinationMailboxId!==void 0,qc=(e,t)=>{if(Fs(e))return`Moved from ${t??"another folder"} by Remit`;const s=e.fromPlacement??"";return`Moved from ${Kc[s]??"another folder"} by Remit`},Qc=(e,t)=>{if(e===Ws.MoveToInbox)return t.inboxMailboxId;if(e===Ws.MoveToJunk)return t.junkMailboxId},Hc=(e,t,s)=>{if(!e||!t)return!1;const n=Fs(e)?e.destinationMailboxId:Qc(e.action,s);return n!==void 0&&n===t},Gc="Reported as spam",Vc=(e,t)=>{if(e){if(Fs(e))return e.fromMailboxId;if(e.fromPlacement==="inbox")return t.inboxMailboxId;if(e.fromPlacement==="junk")return t.junkMailboxId}},Ct=(e,t)=>{const{data:s,isLoading:n}=ee({...bt(),staleTime:1/0,enabled:!!e});return{mailboxId:l.useMemo(()=>e?s?.accounts.find(i=>i.accountId===e)?.folderAppointments.find(i=>i.role===t)?.mailboxId:void 0,[s,e,t]),isLoading:n}},mm=e=>{const{mailboxId:t,isLoading:s}=Ct(e,"Archive");return{archiveMailboxId:t,isLoading:s}},pm=e=>{const{mailboxId:t,isLoading:s}=Ct(e,"Drafts");return{draftsMailboxId:t,isLoading:s}},Wc=e=>{const{mailboxId:t,isLoading:s}=Ct(e,"Inbox");return{inboxMailboxId:t,isLoading:s}},Ga=e=>{const{mailboxId:t,isLoading:s}=Ct(e,"Junk");return{junkMailboxId:t,isLoading:s}},hm=e=>{const{mailboxId:t,isLoading:s}=Ct(e,"Trash");return{trashMailboxId:t,isLoading:s}},Yc=()=>{const{data:e,isError:t}=ee({...bt(),staleTime:1/0});return{trashByAccount:l.useMemo(()=>{const n=new Map;for(const r of e?.accounts??[]){const o=r.folderAppointments.find(i=>i.role==="Trash");n.set(r.accountId,{mailboxId:o?.mailboxId,source:o?.source??"None",staleFolderPath:o?.staleAppointmentPath})}return n},[e]),hasAppointments:e!==void 0,isError:t}},Va=e=>{const{data:t}=ee({...bt(),staleTime:1/0,enabled:!!e});return l.useMemo(()=>t?.accounts.find(s=>s.accountId===e)?.folderAppointments??[],[t,e])},Nn=(e,t)=>e.filter(s=>!t.has(s.messageId)),Gt=({mailboxId:e,threadId:t,accountId:s,onAfterOptimisticRemove:n})=>{const r=ie(),{pushError:o}=xe(),{mutateAsync:i,isPending:c,isError:d}=me({...zr(),onMutate:async g=>{const v=new Set(g.body.messageIds??[]),p=t?Me({path:{threadId:t}}):[],x=je([e,g.body.destinationMailboxId]);await Promise.all([...t?[r.cancelQueries({queryKey:p})]:[],yt(r,x)]);const f=t?r.getQueriesData({queryKey:p}).filter(m=>m[1]!==void 0).map(([m,h])=>({queryKey:m,data:h})):[],u=kt(r,x);return t&&r.setQueriesData({queryKey:p},m=>m&&{...m,items:Nn(m.items,v)}),wt(r,x,m=>Nn(m,v)),n?.(Array.from(v)),{threadMessagesPrefix:p,listPrefixes:x,previousThreadMessages:f,previousThreadsList:u}},onError:(g,v,p)=>{if(p){for(const f of p.previousThreadMessages)r.setQueryData(f.queryKey,f.data);vt(r,p.previousThreadsList)}const x=v.body.messageIds?.length??0;o({title:x>1?`Couldn't move ${x} messages`:"Couldn't move this message",detail:Re(g),error:g})},onSettled:(g,v,p,x)=>{x&&(t&&r.invalidateQueries({queryKey:x.threadMessagesPrefix}),we(r,x.listPrefixes),s&&r.invalidateQueries({queryKey:Xe({path:{accountId:s}})}))}});return{moveMessages:l.useCallback((g,v)=>{g.length!==0&&gt(g,p=>i({body:{messageIds:p,destinationMailboxId:v}}))},[i]),isPending:c,isError:d}},Jc="This message could not be processed. Please try again. If it keeps failing, report it.",Xc=(e,t)=>e.replace(`Message ${t}'s`,"This message's"),Tn=e=>{if(e.failureCount===0)return;const t=e.failures?.[0],s=t?.reason??Jc,n=t?Xc(s,t.messageId):s;throw new Br(n,422)};function Wa({mailboxId:e,threadId:t,accountId:s,onAfterOptimisticRemove:n}){const r=ie(),{pushError:o}=xe(),i=je([e]),c=t?Me({path:{threadId:t}}):[],d=()=>{t&&r.invalidateQueries({queryKey:c}),we(r,i),s&&r.invalidateQueries({queryKey:Xe({path:{accountId:s}})})},b=()=>(u,m)=>{d(),n?.(m.body.messageIds)},g=u=>(m,h)=>{o({title:u(h.body.messageIds.length),detail:Re(m),error:m})},v=me({mutationFn:async u=>{const{data:m}=await _r({...u,throwOnError:!0});return Tn(m),m},meta:{softError:!0},onSuccess:b(),onError:g(u=>u>1?`Couldn't report ${u} messages as spam`:"Couldn't report this message as spam")}),p=me({mutationFn:async u=>{const{data:m}=await Ur({...u,throwOnError:!0});return Tn(m),m},meta:{softError:!0},onSuccess:b(),onError:g(u=>u>1?`Couldn't undo the spam report for ${u} messages`:"Couldn't undo the spam report")}),x=l.useCallback(u=>{u.length!==0&&gt(u,m=>v.mutateAsync({body:{messageIds:m}}))},[v.mutateAsync]),f=l.useCallback(u=>{u.length!==0&&gt(u,m=>p.mutateAsync({body:{messageIds:m}}))},[p.mutateAsync]);return{reportSpam:x,notSpam:f,isReporting:v.isPending,isRestoring:p.isPending}}const Zc=({accountId:e,messageId:t,threadId:s,mailboxId:n,autoMoved:r,spamReport:o})=>{const{inboxMailboxId:i}=Wc(e),{junkMailboxId:c}=Ga(e),{moveMessages:d,isPending:b}=Gt({mailboxId:n,threadId:s,accountId:e}),{notSpam:g,isRestoring:v}=Wa({mailboxId:n,threadId:s,accountId:e}),{data:p}=ee({...xt({path:{accountId:e??""}}),staleTime:1/0,enabled:!!e&&r?.fromMailboxId!==void 0}),x={inboxMailboxId:i,junkMailboxId:c},f=Vc(r,x),u=l.useCallback(()=>{f&&d([t],f)},[d,t,f]),m=l.useCallback(()=>{g([t])},[g,t]);if(o)return{show:!0,label:Gc,onUndo:m,isUndoing:v};if(!Hc(r,n,x)||!r)return{show:!1,label:"",isUndoing:!1};const S=r.fromMailboxId?p?.items.filter(y=>y.mailboxId===r.fromMailboxId).map(y=>Kr(y))[0]:void 0;return{show:!0,label:qc(r,S),onUndo:f?u:void 0,isUndoing:b,...r.filterId?{filtersHref:"/settings/filters"}:{}}};function ed({accountId:e,messageId:t,threadId:s,mailboxId:n,autoMoved:r,spamReport:o}){const i=Zc({accountId:e,messageId:t,threadId:s,mailboxId:n,autoMoved:r,spamReport:o});return i.show?a.jsx(zl,{label:i.label,onUndo:i.onUndo,undoLabel:i.isUndoing?"Undoing…":"Undo",filtersHref:i.filtersHref}):null}const td=new Set(["in_flight","unverified"]),In=(e,t)=>{const s=e?.[t];return typeof s=="string"?s:void 0},sd=e=>{if(typeof e!="object"||e===null)return;const t=e;if(t.code!=="message_placement_unsettled")return;const{details:s}=t;if(typeof s!="object"||s===null)return;const n=In(s,"reason"),r=In(s,"messageId");if(!(!n||!td.has(n)||!r))return{reason:n,messageId:r}},nd=(e,t)=>({severity:"warning",title:t>1?`Couldn't delete ${t} messages yet`:"Couldn't delete this message yet",detail:e.reason==="in_flight"?"It is still being moved on the mail server. Try again in a moment.":"An earlier move never finished, so where this message sits is unknown. Sync the folder, then delete it again."}),En=(e,t)=>e.filter(s=>!t.has(s.messageId)),gm=e=>e.filter(t=>t.isDeleted!==!0),Os=({mailboxId:e,threadId:t,accountId:s,messages:n,onAfterOptimisticRemove:r})=>{const o=ie(),{pushError:i}=xe(),{requestAppointment:c}=ws(),d=l.useRef([]),b=l.useRef(async()=>{}),{mutateAsync:g,isPending:v}=me({...qr(),onMutate:async f=>{const u=new Set(f.body.messageIds??[]),m=t?Me({path:{threadId:t}}):[],h=je(Ds(u,n??[],e));await Promise.all([o.cancelQueries({queryKey:m}),yt(o,h)]);const S=t?o.getQueriesData({queryKey:m}).filter(w=>w[1]!==void 0).map(([w,N])=>({queryKey:w,data:N})):[],y=kt(o,h);return t&&o.setQueriesData({queryKey:m},w=>w&&{...w,items:En(w.items,u)}),wt(o,h,w=>En(w,u)),r?.(Array.from(u)),{threadMessagesPrefix:m,listPrefixes:h,previousThreadMessages:S,previousThreadsList:y}},onError:(f,u,m)=>{if(m){for(const w of m.previousThreadMessages)o.setQueryData(w.queryKey,w.data);vt(o,m.previousThreadsList)}const h=Vn(f);if(h){const w=d.current;c({accountId:h.accountId,role:h.role,reason:h.reason,action:{kind:"delete",count:w.length},onAppointed:()=>b.current(w)});return}const S=u.body.messageIds?.length??0,y=sd(f);if(y){i(nd(y,S));return}i({title:S>1?`Couldn't delete ${S} messages`:"Couldn't delete this message",detail:Re(f),error:f})},onSettled:(f,u,m,h)=>{h&&(t&&o.invalidateQueries({queryKey:h.threadMessagesPrefix}),we(o,h.listPrefixes),s&&o.invalidateQueries({queryKey:Xe({path:{accountId:s}})}))}}),p=l.useCallback(f=>gt(f,u=>g({body:{messageIds:u}})),[g]);return l.useEffect(()=>{b.current=p},[p]),{deleteMessages:l.useCallback(f=>{f.length!==0&&(d.current=f,p(f))},[p]),isPending:v}},Ya="inline-flex items-center justify-center transition-colors",ad=_(Ya,"min-h-11 min-w-11 rounded hover:bg-surface-raised"),rd=_(Ya,"min-h-11 gap-1.5 px-3 rounded text-sm font-medium hover:bg-surface-raised"),zs=({accountId:e,currentMailboxId:t,onMove:s,disabled:n=!1,disabledHint:r,variant:o="icon-only",label:i,defaultOpen:c=!1})=>{const[d,b]=l.useState(c),[g,v]=l.useState(),p=js(),x=l.useRef(null),f=l.useRef(null),u=l.useRef(null),m=i??"Move to folder",h=l.useId(),{t:S}=Qr("mail",{useSuspense:!1}),y=Wn(),{data:w,isLoading:N,isError:E,error:P,refetch:z}=ee({...xt({path:{accountId:e}}),staleTime:1/0,enabled:d}),U=Va(e),{createFolderIn:L}=Yn(e),D=l.useMemo(()=>Jn({mailboxes:w?.items??[],folderAppointments:U,currentMailboxId:t,translator:y}),[w?.items,U,t,y]),F=Xn(w?.items??[]),O=D.find($=>$.id===g),k=l.useCallback(()=>{b(!1),v(void 0);const $=document.activeElement;$&&f.current?.contains($)&&u.current?.focus()},[]),I=l.useCallback(()=>{O&&(k(),s(O.id))},[O,k,s]);Cs({id:"move-to",open:d,answers:{back:k}}),l.useEffect(()=>{if(!d||!p)return;const $=H=>{const Y=H.target;x.current?.contains(Y)||f.current?.contains(Y)||k()};return document.addEventListener("mousedown",$),()=>document.removeEventListener("mousedown",$)},[d,p,k]);const R=()=>x.current?.getBoundingClientRect()??null,j=n||!!r,M=a.jsxs("button",{type:"button",ref:u,onClick:$=>{$.stopPropagation(),!j&&b(H=>!H)},"aria-label":m,"aria-haspopup":p?"tree":"dialog","aria-expanded":d,"aria-controls":d?h:void 0,title:r,className:o==="icon-only"?ad:rd,children:[a.jsx(ks,{className:o==="icon-only"?"size-5":"size-4"}),o==="compact"&&a.jsx("span",{className:"hidden sm:inline",children:"Move"})]}),C=N?a.jsx("div",{className:"px-3 py-5 text-sm text-fg-muted",children:"Loading folders…"}):E?a.jsx("div",{className:"p-3",children:a.jsx(Oe,{variant:"inline",title:"Couldn't load folders",error:P,onRetry:()=>z()})}):a.jsx(Hr,{folders:D,selectedId:g,delimiter:F,onSelect:v,onCreateFolder:L,onCancel:k,autoFocusFilter:p,labels:{filterPlaceholder:S("move_picker_filter_placeholder",{defaultValue:"Filter folders…"}),filterAriaLabel:S("move_picker_filter_label",{defaultValue:"Filter folders"})}}),K=O&&a.jsx("div",{className:"shrink-0 border-t border-line p-2",children:a.jsx(V,{variant:"primary",onClick:I,className:"h-11 w-full font-semibold",children:`Move to ${O.label}`})});return p?a.jsxs("div",{ref:x,className:"relative inline-block",children:[M,a.jsx(Qo,{open:d,align:"end",panelRef:f,getAnchor:R,children:a.jsxs("div",{id:h,ref:f,className:_("w-72 max-h-96 flex flex-col","bg-surface border border-line rounded-md shadow-lg"),children:[C,K]})})]}):a.jsxs(a.Fragment,{children:[M,a.jsx(He.Root,{open:d,onOpenChange:$=>$?b(!0):k(),children:a.jsxs(He.Portal,{children:[a.jsx(He.Overlay,{className:"fixed inset-0 z-40 bg-black/40"}),a.jsxs(He.Content,{className:"fixed inset-x-0 bottom-0 z-50 flex flex-col rounded-t-lg bg-canvas pb-[env(safe-area-inset-bottom,0px)]",style:{maxHeight:"85dvh"},id:h,children:[a.jsx(He.Handle,{className:"mx-auto mt-2 mb-1 h-1.5 w-12 rounded-full bg-fg-subtle/30"}),a.jsx(He.Title,{className:"px-4 py-2 text-base font-semibold border-b border-line",children:"Move to folder"}),a.jsx("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:C}),K]})]})})]})},od=({messageId:e,threadId:t,mailboxId:s,isRead:n,accountId:r,fromAddressId:o,isTrusted:i=!1,showRaw:c=!1,onToggleRaw:d})=>{const b=ie(),g=Ao(),{pushError:v}=xe(),p=$o()?.messageId,{mutate:x,isPending:f}=me({..._t(),onMutate:async I=>{const R=I.body.isRead??!0,j=new Set(I.body.messageIds??[]),M=Me({path:{threadId:t}}),C=je([s]);await Promise.all([b.cancelQueries({queryKey:M}),yt(b,C)]);const K=b.getQueriesData({queryKey:M}).filter(H=>H[1]!==void 0).map(([H,Y])=>({queryKey:H,data:Y})),$=kt(b,C);return b.setQueriesData({queryKey:M},H=>H&&{...H,items:Pt(H.items,j,R)}),wt(b,C,H=>Pt(H,j,R)),{threadMessagesPrefix:M,listPrefixes:C,previousThreadMessages:K,previousThreadsList:$}},onError:(I,R,j)=>{if(j){for(const C of j.previousThreadMessages)b.setQueryData(C.queryKey,C.data);vt(b,j.previousThreadsList)}const M=R.body.isRead??!0;v({title:M?"Couldn't mark as read":"Couldn't mark as unread",detail:Re(I),error:I})},onSettled:(I,R,j,M)=>{M&&(b.invalidateQueries({queryKey:M.threadMessagesPrefix}),we(b,M.listPrefixes))}}),u=l.useCallback(I=>{p&&I.includes(p)&&g()},[p,g]),{deleteMessages:m,isPending:h}=Os({mailboxId:s,threadId:t,onAfterOptimisticRemove:u}),{moveMessages:S,isPending:y}=Gt({mailboxId:s,threadId:t,accountId:r,onAfterOptimisticRemove:u}),{toggleTrusted:w,isPending:N,error:E,reset:P}=ra({messageId:e}),z=()=>{x({body:{messageIds:[e],isRead:!1}})},U=()=>{m([e])},L=()=>{o&&w(o,i)},D=f||h||y||N,F=D||!o,O=l.useCallback(I=>{S([e],I)},[S,e]),k=o?void 0:"Sender has no parseable address";return a.jsxs("div",{className:"flex flex-col items-end gap-1",children:[a.jsxs("div",{className:"flex items-center gap-1",children:[r&&a.jsx(zs,{accountId:r,currentMailboxId:s,onMove:O,disabled:D,label:"Move this message"}),a.jsxs(Lo,{trigger:a.jsx(Ho,{className:"size-4"}),children:[a.jsxs(It,{onClick:L,disabled:F,children:[i?a.jsx(Kt,{className:"size-4 text-positive"}):a.jsx(Ft,{className:"size-4 opacity-0"}),a.jsx("span",{title:k,children:"Trusted sender"})]}),n&&a.jsxs(It,{onClick:z,disabled:D,children:[a.jsx(Ms,{className:"size-4"}),"Mark as unread"]}),d&&a.jsxs(It,{onClick:d,children:[a.jsx(ja,{className:"size-4"}),c?"Show formatted":"Show raw email"]}),a.jsx(Po,{}),a.jsxs(It,{onClick:U,disabled:D,destructive:!0,children:[a.jsx(Ot,{className:"size-4"}),"Delete"]})]})]}),E&&a.jsx("div",{className:"w-64",children:a.jsx(Oe,{variant:"inline",title:"Couldn't update trust",error:E,onRetry:()=>{P(),L()}})})]})},id=e=>e==="link-expired"||e==="not-ready";class gs extends Error{reason;status;constructor(t,s,n){super(s),this.name="AttachmentFetchError",this.reason=t,this.status=n}}const ld="x-remit-403-reason",cd="expired",dd=(e,t)=>{if(t?.trim()===cd)return"link-expired";const s=ci(e,t);return s==="auth"?"auth":s==="body-missing"?"missing":"generic"},ud=300*1e3,Rn=async(e,t)=>{const s={},n=await t();n&&(s.Authorization=`Bearer ${n}`);const r=await Wr(e,{headers:s,signal:AbortSignal.timeout(ud)});if(r.status===202)throw new gs("not-ready","Attachment is still being fetched from the mail server",202);if(!r.ok)throw new gs(dd(r.status,r.headers.get(ld)),`Failed to download attachment (${r.status} ${r.statusText})`,r.status);return r.blob()},fd=(e,t,s)=>{switch(e){case"auth":return{title:"Your session expired",detail:`Sign in again, then download ${t} once more. Other parts of the app may also stop responding until you do.`};case"link-expired":return{title:"This download link expired and could not be renewed",detail:`Reload the page, then download ${t} again. If that keeps failing, this is worth reporting.`};case"missing":return{title:"This attachment is missing from storage",detail:"Remit has the message but not the file. Re-sync the account from Settings, then try again."};case"not-ready":return{title:"Still fetching this attachment",detail:"Remit is downloading it from the mail server now. Try again in a few seconds."};default:return{title:"Couldn't download this attachment",detail:s}}},Mn=e=>e instanceof gs?e.reason:"generic",md=e=>e instanceof Error?e.message:typeof e=="string"?e:"An unexpected error occurred while downloading this attachment.",pd=(e,t,s)=>{if(e!=="auth")return Gr(Vr({title:`Bug: attachment download failed (${e})`,errorMessage:`Downloading "${t}" failed: ${s}`}))},hd=(e,t)=>{const s=URL.createObjectURL(e),n=document.createElement("a");n.href=s,n.download=t,n.rel="noopener",document.body.append(n),n.click(),n.remove(),setTimeout(()=>URL.revokeObjectURL(s),0)},gd=e=>{const t=e.toUpperCase();return t==="OCTET-STREAM"?"FILE":t},bd=e=>{const t=e.toLowerCase().replace(/[^a-z0-9]/g,"");return t.length>0?`attachment.${t}`:"attachment"},An=e=>e.filter(t=>!t.isMultipart&&t.disposition===Yr.Attachment&&t.contentUrl.length>0).map(t=>({bodyPartId:t.bodyPartId,filename:Go(t.dispositionFilename??"",bd(t.mediaSubtype)),typeLabel:gd(t.mediaSubtype),sizeOctets:t.sizeOctets,contentUrl:t.contentUrl})),$n={status:"idle"},xd=({messageId:e,bodyParts:t,hasAttachment:s=!1,className:n})=>{const{getToken:r}=Zn(),o=ie(),[i,c]=l.useState({}),d=l.useMemo(()=>An(t??[]),[t]),b=Jr({path:{messageId:e}}),g=f=>Rn(f.contentUrl,r).catch(u=>{if(!id(Mn(u)))throw u;return o.refetchQueries({queryKey:b}).then(()=>{const m=o.getQueryData(b),h=m?An(m.bodyParts).find(S=>S.bodyPartId===f.bodyPartId):void 0;return Rn(h?.contentUrl??f.contentUrl,r)})}),v=(f,u)=>c(m=>({...m,[f]:u})),p=f=>{const u=d.find(m=>m.bodyPartId===f);if(!u)throw new Error(`No attachment part ${f} on message ${e}`);v(f,{status:"downloading"}),g(u).then(m=>{hd(m,u.filename),v(f,$n)}).catch(m=>{const h=Mn(m),S=md(m),{title:y,detail:w}=fd(h,u.filename,S);v(f,{status:"failed",title:y,detail:w,reportUrl:pd(h,u.filename,S)})})},x=s&&t!==void 0&&d.length===0;return a.jsx(Ol,{className:n,attachments:d.map(f=>({attachmentId:f.bodyPartId,filename:f.filename,typeLabel:f.typeLabel,sizeOctets:f.sizeOctets,download:i[f.bodyPartId]??$n})),onDownload:p,hasUnlistedAttachment:x})},vd=({messageId:e,threadId:t,mailboxId:s,accountId:n,isRead:r,isStarred:o,onToggleStar:i,fromAddressId:c,isTrusted:d,showRaw:b,onToggleRaw:g,onReply:v,onReplyAll:p,onForward:x})=>{const f=ie(),{deleteMessages:u}=Os({mailboxId:s,threadId:t}),{moveMessages:m}=Gt({mailboxId:s,threadId:t,accountId:n}),{toggleTrusted:h}=ra({messageId:e}),{mutate:S}=me({..._t(),onSettled:()=>{f.invalidateQueries({queryKey:Me({path:{threadId:t}})}),we(f,je([s]))}}),y=l.useCallback(P=>{m([e],P)},[m,e]),w=l.useCallback(()=>{u([e])},[u,e]),N=l.useCallback(()=>{S({body:{messageIds:[e],isRead:!r}})},[S,e,r]),E=[];return c&&E.push({key:"trusted",label:d?"Trusted sender":"Mark sender trusted",icon:d?a.jsx(Kt,{className:"size-4 text-positive"}):a.jsx(Ft,{className:"size-4"}),onSelect:()=>h(c,d)}),g&&E.push({key:"raw",label:b?"Show formatted":"Show raw email",icon:a.jsx(ja,{className:"size-4"}),onSelect:g}),a.jsx($a,{hasThread:!0,onReply:v,onReplyAll:p,onForward:x,isStarred:o,onToggleStar:i,onDelete:w,isRead:r,onToggleRead:N,overflowItems:E,moveSlot:n?a.jsx(zs,{accountId:n,currentMailboxId:s,onMove:y,label:"Move this message"}):void 0})},yd=()=>a.jsxs("div",{className:"animate-pulse space-y-2",role:"status","aria-label":"Loading raw email",children:[a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-full"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-11/12"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-5/6"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-3/4"})]}),kd=({messageId:e,enabled:t=!0})=>{const{data:s,isLoading:n,isError:r,error:o,refetch:i}=ee({...Xr({path:{messageId:e}}),enabled:t});if(n)return a.jsx("div",{className:"message-body",children:a.jsx(yd,{})});if(r)return a.jsx("div",{className:"message-body",children:a.jsx(Oe,{variant:"inline",title:"Couldn't load the raw email",error:o,onRetry:()=>i()})});const c=s?.raw??"";return c===""?a.jsx("div",{className:"message-body",children:a.jsx("p",{className:"text-fg-muted text-sm italic",children:"No raw source available for this message."})}):a.jsx("div",{className:"message-body",children:a.jsx("pre",{className:"email-text whitespace-pre-wrap break-words text-sm leading-relaxed bg-surface-sunken rounded-md p-3 max-h-[32rem] overflow-auto",children:c})})},wd=()=>a.jsx(Kt,{className:"inline-block size-4 ml-1 -mt-0.5 text-positive align-middle","aria-label":"Trusted sender","data-testid":"trusted-sender-badge"}),Ja=(e,t)=>({id:e.messageId,fromName:e.fromName??e.fromEmail??"?",fromEmail:e.fromEmail??"",toLabel:"",dateLabel:t,snippet:e.snippet||"",bodyHtml:""}),Xa=({isStarred:e,onToggleStar:t,isStarPending:s,hoverReveal:n})=>a.jsx("button",{type:"button",onClick:r=>{r.stopPropagation(),t()},disabled:s,"aria-label":e?"Remove star":"Add star",className:_("shrink-0 p-0.5 rounded transition-colors",e?"text-warning":_("text-fg-subtle hover:text-warning",n&&"opacity-0 group-hover:opacity-100 focus:opacity-100"),s&&"opacity-50"),children:a.jsx(Je,{className:_("size-3.5",e&&"fill-current")})}),jd=({threadMessage:e,isFocused:t,onToggle:s,onToggleStar:n,isStarPending:r})=>{const o=ua(e.sentDate,"datetime"),i=Ja(e,o);return a.jsx(La,{message:i,onClick:s,isFocused:t,isUnread:!e.isRead,trailing:a.jsxs(a.Fragment,{children:[e.hasAttachment&&a.jsx(qt,{className:"size-3 shrink-0 text-fg-subtle",role:"img","aria-label":"Has an attachment"}),a.jsx(Xa,{isStarred:e.hasStars,onToggleStar:n,isStarPending:r,hoverReveal:!0}),a.jsx("span",{"data-testid":"message-date",className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:o})]})})},Cd=({threadMessage:e,messageData:t,isLoading:s,isError:n,error:r,onRetry:o,isFocused:i,onToggle:c,onToggleStar:d,isStarPending:b,accountId:g,showRaw:v,onToggleRaw:p,mobile:x,onReply:f,onReplyAll:u,onForward:m})=>{const h=ua(e.sentDate,"long"),S=!e.isRead,y=t?.envelope.from[0]?.flags?.trusted?.value===!0,w=t?.envelope.from[0]?.addressId,N=Ja(e,h),E=e.autoMoved||e.spamReport?a.jsx(ed,{accountId:g,messageId:e.messageId,threadId:e.threadId,mailboxId:e.mailboxId,autoMoved:e.autoMoved,spamReport:e.spamReport}):null;return a.jsx(Pa,{message:N,isFocused:x?!1:i,onHeaderClick:c,senderBadge:y?a.jsx(wd,{}):void 0,trailing:a.jsx("span",{"data-testid":"message-date",className:"text-2xs text-fg-subtle",children:h}),to:t?a.jsx(gl,{label:"To",addresses:t.envelope.to}):null,indicators:E||!x?a.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mt-0.5",children:[E,!x&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"flex items-center justify-end gap-1",children:a.jsx(Xa,{isStarred:e.hasStars,onToggleStar:d,isStarPending:b})}),S&&a.jsx("span",{className:"size-1.5 rounded-full bg-accent","aria-label":"Unread"})]})]}):void 0,actionMenu:x?void 0:a.jsx(od,{messageId:e.messageId,threadId:e.threadId,mailboxId:e.mailboxId,isRead:e.isRead,accountId:g,fromAddressId:w,isTrusted:y,showRaw:v,onToggleRaw:p}),actionBar:x?a.jsx(vd,{messageId:e.messageId,threadId:e.threadId,mailboxId:e.mailboxId,accountId:g,isRead:e.isRead,isStarred:e.hasStars,onToggleStar:d,fromAddressId:w,isTrusted:y,showRaw:v,onToggleRaw:p,onReply:f,onReplyAll:u,onForward:m}):void 0,body:s?a.jsxs("div",{className:"mt-3 animate-pulse space-y-2",children:[a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-full"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-3/4"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-1/2"})]}):n&&Zr(r)?a.jsx("div",{className:"mt-3",children:a.jsx(da,{message:"This message has been deleted"})}):n?a.jsx("div",{className:"mt-3",children:a.jsx(Oe,{variant:"inline",title:"Couldn't load this message",error:r,onRetry:o})}):v?a.jsx("div",{className:"mt-3",children:a.jsx(kd,{messageId:e.messageId})}):a.jsxs("div",{className:"mt-3",children:[a.jsx(Jo,{bodyParts:t?.bodyParts,messageId:e.messageId,fromAddressId:t?.envelope.from[0]?.addressId,isTrusted:y,category:Ha(e.category)}),a.jsx(xd,{messageId:e.messageId,bodyParts:t?.bodyParts,hasAttachment:e.hasAttachment,className:"mt-4"})]})})},Sd=({threadMessage:e,isExpanded:t,isFocused:s,onToggle:n,onToggleStar:r,isStarPending:o,accountId:i,mobile:c,onReply:d,onReplyAll:b,onForward:g})=>{const[v,p]=l.useState(!1),{data:x,isLoading:f,isError:u,error:m,refetch:h}=ee({...zt({path:{messageId:e.messageId}}),enabled:t,meta:{softError:!0}});return t?a.jsx(Cd,{threadMessage:e,messageData:x,isLoading:f,isError:u,error:m,onRetry:()=>h(),isFocused:s,onToggle:n,onToggleStar:r,isStarPending:o,accountId:i,showRaw:v,onToggleRaw:()=>p(S=>!S),mobile:c,onReply:d,onReplyAll:b,onForward:g}):a.jsx(jd,{threadMessage:e,isFocused:s,onToggle:n,onToggleStar:r,isStarPending:o})},Nd=()=>a.jsxs("div",{className:"animate-pulse p-4",children:[a.jsx("div",{className:"h-6 bg-surface-sunken rounded w-3/4 mb-5"}),a.jsx("div",{className:"space-y-4",children:Array.from({length:2}).map((e,t)=>a.jsxs("div",{className:"flex gap-3 py-3",children:[a.jsx("div",{className:"size-10 bg-surface-sunken rounded-full shrink-0"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-32 mb-2"}),a.jsx("div",{className:"h-3 bg-surface-sunken rounded w-48"})]})]},t))})]}),bm=({threadId:e,mailboxId:t,subject:s,selectedMessageId:n,authenticity:r,onOpenIntelligence:o,onBack:i,onSwipeNext:c,onSwipePrevious:d,mobileIntelligenceOpen:b,listOnScreen:g=!1})=>{const v=js(),{handlers:p}=Uc({onSwipeLeft:c,onSwipeRight:d}),{accountId:x}=Ps(t),{data:f,isLoading:u,isError:m,error:h,refetch:S}=ee({...ea({path:{threadId:e}})}),y=l.useMemo(()=>f?.items??[],[f?.items]),w=y[y.length-1],N=l.useMemo(()=>[...y].reverse(),[y]),E=l.useRef(new Map),[P,z]=l.useState(new Set),[U,L]=l.useState(null),[D,F]=l.useState(0);l.useEffect(()=>{if(y.length>0&&e!==U){L(e);const B=new Set([y[y.length-1].threadMessageId]);if(n){const Q=y.find(ne=>ne.messageId===n);Q&&B.add(Q.threadMessageId)}z(B),F(0)}},[e,y,U,n]);const O=l.useCallback(B=>{z(Q=>{const ne=new Set(Q);return ne.has(B)?ne.delete(B):ne.add(B),ne})},[]),k=l.useCallback(B=>{const Q=N[B];if(!Q)return;E.current.get(Q.threadMessageId)?.scrollIntoView({behavior:"smooth",block:"nearest"})},[N]),I=l.useCallback(()=>{if(N.length===0)return;const B=Math.min(D+1,N.length-1);F(B),k(B)},[N.length,D,k]),R=l.useCallback(()=>{if(N.length===0)return;const B=Math.max(D-1,0);F(B),k(B)},[N.length,D,k]),j=l.useCallback(()=>{const B=N[D];B&&O(B.threadMessageId)},[N,D,O]);Fc({messages:y,expandedIds:P,threadId:e,mailboxId:t,accountId:x});const{toggleStar:M,isPending:C,pendingMessageId:K}=Qa({threadId:e,mailboxId:t,messages:y}),$=eo(),H=to(),Y=n??w?.messageId,X=l.useCallback((B,Q)=>{Q&&H({threadId:e,messageId:Q,mode:B})},[H,e]),se=l.useCallback(()=>X("reply",Y),[X,Y]),le=l.useCallback(()=>X("reply-all",Y),[X,Y]),pe=l.useCallback(()=>X("forward",Y),[X,Y]),te=l.useRef(null),he=$?.kind==="reply"?`${$.mode}:${$.sourceMessageId}`:void 0;if(l.useEffect(()=>{he&&te.current?.scrollIntoView({behavior:"smooth",block:"start"})},[he]),ni({enabled:!u&&y.length>0&&$===void 0,bindings:[...g?[]:[{key:"j",action:"focusNext",handler:I,preventDefault:!0},{key:"ArrowDown",action:"focusNext",handler:I,preventDefault:!0},{key:"k",action:"focusPrevious",handler:R,preventDefault:!0},{key:"ArrowUp",action:"focusPrevious",handler:R,preventDefault:!0},{key:"Enter",action:"openFocused",handler:j,preventDefault:!0},{key:"o",action:"openFocused",handler:j,preventDefault:!0}],{key:"r",action:"reply",handler:se,preventDefault:!0},{key:"R",action:"replyAll",handler:le,noModifiers:!1,preventDefault:!0},{key:"f",action:"forward",handler:pe,preventDefault:!0}]}),u)return a.jsx(Nd,{});if(m)return a.jsx("div",{className:"flex h-full items-center justify-center",children:a.jsx(Oe,{title:$?"Couldn't load this conversation, so there is nothing to answer":"Couldn't load this conversation",error:h,onRetry:()=>S()})});if(y.length===0)return a.jsx("div",{className:"flex h-full items-center justify-center p-4",children:$?a.jsx(Oe,{variant:"inline",title:"There is nothing here to answer",error:"This conversation has no messages left. Another mail client may have moved or deleted them."}):a.jsx(da,{message:"No messages in this thread"})});const ce=s||y[0]?.subject||"(No subject)",ge=y.length,ue=B=>a.jsx("div",{"data-testid":"conversation-messages",children:N.map((Q,ne)=>a.jsx("div",{ref:_e=>{_e&&E.current.set(Q.threadMessageId,_e)},children:a.jsx(Sd,{threadMessage:Q,isExpanded:P.has(Q.threadMessageId),isFocused:ne===D,onToggle:()=>O(Q.threadMessageId),onToggleStar:()=>M(Q.messageId,Q.hasStars),isStarPending:C&&K===Q.messageId,accountId:x,mobile:B,onReply:B?()=>X("reply",Q.messageId):void 0,onReplyAll:B?()=>X("reply-all",Q.messageId):void 0,onForward:B?()=>X("forward",Q.messageId):void 0})},Q.threadMessageId))}),q=$&&a.jsx("div",{ref:te,children:$.kind==="reply"?a.jsx(Ec,{surface:$}):a.jsx("div",{className:"border-b border-line bg-canvas p-4",children:a.jsx(Oe,{variant:"inline",title:"That is not a way to answer a message",error:`"${$.segment}" is not reply, reply-all or forward.`})})}),ae=a.jsxs("header",{className:"border-b border-line px-5 pt-5 pb-3",children:[a.jsx("h1",{className:"max-w-2xl text-lg font-semibold leading-snug text-fg",children:ce}),a.jsxs("p",{className:"mt-1 text-2xs text-fg-subtle",children:[ge," ",ge===1?"message":"messages"]})]});return v?a.jsxs("article",{className:"h-full flex flex-col",children:[ae,r?.dkimMismatch&&a.jsx(Sn,{authenticity:r,onOpenIntelligence:o}),a.jsxs("div",{className:"min-h-0 flex-1 overflow-auto",children:[q,ue(!1)]})]}):a.jsxs(Dl,{thread:{subject:ce,messages:[]},onBack:i??(()=>{}),intelligenceOpen:b,onToggleIntelligence:o,touchHandlers:p,children:[r?.dkimMismatch&&a.jsx(Sn,{authenticity:r,onOpenIntelligence:o}),q,ue(!0)]})},Td="a[href], button, input, select, textarea, [tabindex]",Id=e=>{if(e.tabIndex<0||e.hasAttribute("disabled")||e.getAttribute("aria-disabled")==="true"||e.closest("[inert], [hidden], [aria-hidden='true']"))return!1;const t=getComputedStyle(e);return t.display!=="none"&&t.visibility!=="hidden"},Ln=e=>{const t=e.querySelectorAll('[role="dialog"][aria-modal="true"]');return[...(t[t.length-1]??e).querySelectorAll(Td)].filter(Id)},Ed=({isOpen:e,onClose:t,children:s,ariaLabel:n="Navigation",side:r="left",widthClassName:o="w-[80vw] max-w-[320px]",answers:i})=>{const c=l.useRef(null),d=l.useRef(null);if(Cs({id:"drawer",open:e,answers:{back:t,...i}}),l.useEffect(()=>{if(!e)return;d.current=document.activeElement;const g=p=>{if(p.key!=="Tab"||!c.current)return;const x=document.activeElement;if(!(x instanceof HTMLElement)||!c.current.contains(x))return;const f=Ln(c.current);if(f.length===0)return;const u=f[0],m=f[f.length-1],h=f.includes(x);if(p.shiftKey){(!h||x===u)&&(p.preventDefault(),m.focus());return}(!h||x===m)&&(p.preventDefault(),u.focus())};document.addEventListener("keydown",g),c.current&&Ln(c.current)[0]?.focus();const v=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",g),document.body.style.overflow=v,d.current?.focus()}},[e]),!e)return null;const b=r==="left"?"left-0 border-r animate-in slide-in-from-left duration-150":"right-0 border-l animate-in slide-in-from-right duration-150";return a.jsxs("div",{className:"fixed inset-0 z-50",role:"dialog","aria-modal":"true","aria-label":n,children:[a.jsx("button",{type:"button","aria-label":"Close menu",onClick:t,className:"absolute inset-0 bg-black/40 animate-in fade-in duration-150 cursor-default"}),a.jsxs("div",{ref:c,className:_("safe-area-frame absolute top-0 bottom-0 bg-canvas border-line shadow-xl flex flex-col",o,b),children:[a.jsx("div",{className:"flex items-center justify-end h-12 px-2 border-b border-line shrink-0",children:a.jsx("button",{type:"button",onClick:t,className:"p-2 rounded-md hover:bg-surface-raised transition-colors min-h-11 min-w-11 inline-flex items-center justify-center","aria-label":"Close menu",children:a.jsx(Dt,{className:"size-5"})})}),a.jsx("div",{className:"flex-1 overflow-y-auto",children:s})]})]})},Rd=10,Za=e=>({q:e?.toLowerCase()??"",limit:Rd}),Md=(e,t)=>{if(!t)return;const s=t.toLowerCase();return e?.find(n=>n.normalizedEmail===s)};function Ad(e){const t=new Date(e),s=new Date;return t.toDateString()===s.toDateString()?"today":ai(t,{month:"short",year:"numeric"})}function er(e){if(!e)return!0;const[,t]=e.split("@");return t?!t.includes("."):!0}const $d="We can't verify the sender of this email, which could mean it's from an insecure source.",Ld="We couldn't read this sender's address, so we can't confirm who really sent this message.";function Pd(e,t){const s=e.category??"personal";return{value:no(s)?s:"uncategorized",overridden:t?.flags?.category?.value!=null&&t.flags.category.value!==e.category}}function Dd(e,t){return{name:e.fromName??e.fromEmail??"Unknown",email:e.fromEmail??"",trust:e.senderTrust,firstSeenLabel:t?Ad(t.createdAt):"unknown",inboundCount:t?.inboundCount,replyCount:t?.replyCount,addressUnverified:er(e.fromEmail)}}function Fd(e){return e?.flags?{vip:e.flags.vip?.value===!0,muted:e.flags.muted?.value===!0,blocked:e.flags.blocked?.value===!0,unsubscribed:e.flags.unsubscribed?.value===!0}:{}}function Pn(e){if(e.fromName&&e.fromName!==e.fromEmail)return e.fromName}function Od(e){return e.length===1?e[0]:`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function zd(e,t){const s=[],n=e.displayNameCorrespondence;t&&(n===es.Unrelated?s.push(`The name it shows, "${t}", has nothing to do with ${e.fromDomain}.`):n===es.Lookalike?s.push(`The name it shows, "${t}", only looks like ${e.fromDomain}.`):n===es.ForeignAddress&&s.push(`The name it shows, "${t}", is an address ${e.fromDomain} cannot send from.`));const r=_d(e.offDomainLinkDomains);return r.length>0&&s.push(`Its links go to ${Od(r.slice(0,3))}.`),s}function _d(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function Ud(e,t){const s=t>0?t:void 0;if(er(e.fromEmail))return{verdict:"mismatch",fromDomain:"",addressUnreadable:!0,summary:Ld,similarCount:s};const n=e.authenticity;if(!n)return{verdict:"caution",fromDomain:e.fromEmail?.split("@")[1]??"",summary:$d};if(!n.dkimMismatch){const b=Pn(e),g=zd(n,b);return g.length>0?{verdict:"caution",fromDomain:n.fromDomain,dkimDomain:n.dkimDomain,claimedBrand:b,summary:g.join(" ")}:{verdict:"aligned",fromDomain:n.fromDomain,dkimDomain:n.dkimDomain,summary:n.dkimDomain?`This message was signed by ${n.dkimDomain}.`:"Nothing looks unusual about this sender."}}const r=n.fromDomain,o=n.dkimDomain,i=Pn(e),c=o?`it was actually sent from ${o}`:"its signature failed to verify",d=i?`The display name claims "${i}", but ${c}${o?` — not ${r}`:""}. Real senders use their own address.`:`This message claims to be from ${r}, but ${c}.`;return{verdict:"mismatch",fromDomain:r,dkimDomain:o,claimedBrand:i,summary:d,similarCount:s}}function Bd(e,t){const s=e?.fromEmail??null,n=e?.subject??"",{data:r,error:o}=ee({...Ss({query:Za(s??void 0)}),enabled:!!s,staleTime:3e4}),i=Md(r?.items,s??void 0),c=[n,s].filter(Boolean).join(" "),{data:d,isLoading:b,error:g}=ee({...so({query:{query:c,limit:5}}),enabled:!!(e&&c.length>3),staleTime:6e4,retry:1});return{data:l.useMemo(()=>{if(!e)return null;const p=(d?.items??[]).filter(h=>h.messageId!==e.messageId).map(h=>({id:h.messageId,threadId:h.threadId,mailboxId:t!=null&&h.mailboxIds.includes(t)?t:h.mailboxIds[0]??"",fromName:h.fromName??"",subject:h.subject??"(No subject)",timeLabel:h.sentDate!=null?Ze(h.sentDate*1e3):"",matched:h.matchedChunkType})),x=Dd(e,i),f=Ud(e,p.length),u=Pd(e,i),m=Fd(i);return{sender:x,authenticity:f,category:u,flags:m,similar:p}},[e,i,d,t]),isSimilarLoading:b,similarError:g,similarErrorIsFatal:Ys(g),addressErrorIsFatal:Ys(o),addressId:i?.addressId,address:i}}function Kd(e,t){const s={...e??{}};for(const[n,r]of Object.entries(t))r==null?delete s[n]:s[n]={...r,setAt:r.setAt??Date.now()};return s}function qd({addressId:e,senderEmail:t}){const s=ie(),{pushError:n}=xe(),r=ao({query:Za(t)}),{mutate:o,isPending:i}=me({...ro(),onMutate:async d=>{const b=d.body.flags??{};await s.cancelQueries({queryKey:r});const g=s.getQueryData(r);return s.setQueryData(r,v=>v&&{...v,items:v.items.map(p=>p.addressId===d.path.addressId?{...p,flags:Kd(p.flags,b)}:p)}),{previous:g}},onError:(d,b,g)=>{g?.previous!==void 0&&s.setQueryData(r,g.previous),n({title:"Couldn't update sender preference",detail:Re(d),error:d})},onSettled:()=>{s.invalidateQueries({queryKey:r})}});return{updateFlags:l.useCallback(d=>{if(!e){oo(new Error(`Quick action fired but the sender's address record did not resolve (sender: ${t??"unknown"}). This should never happen — the address row exists.`));return}o({path:{addressId:e},body:{flags:d}})},[e,o,t]),isPending:i}}const xm=e=>e==="vip"?"A sender you know":e==="wellknown"?"You've emailed them before":"Passed authentication",Qd=e=>e.senderTrust!=="vip"&&e.senderTrust!=="wellknown"?!1:e.authenticity?.dkimMismatch!==!0;function vm(e,t){e.recordEvent("rescue.candidates_surfaced",{count:String(t)})}function ym(e,t){e.recordEvent("rescue.flow_opened",{count:String(t)})}function km(e,t){e.recordEvent("rescue.committed",{selected:String(t.selected),total:String(t.total),destination:t.toInbox?"inbox":"other"})}function Hd(e,t){e.recordEvent("rescue.sent_to_junk",{count:String(t.count),senderTrust:t.senderTrust,wasRescuable:String(t.wasRescuable)})}const Gd=["personal","newsletter","marketing","automated","transactional","social"],Vd=e=>e.spamReport?"notSpam":"reportSpam",Wd=e=>{const{similarError:t,similarErrorIsFatal:s,isSimilarLoading:n}=e;return t&&!s?"error":n?"loading":"ready"};function Yd(){return a.jsxs("aside",{className:"flex h-full w-full flex-col bg-surface-sunken",children:[a.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-1.5 border-b border-line px-row-inset",children:[a.jsx(Ye,{className:"size-3.5 text-fg-subtle"}),a.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Intelligence"})]}),a.jsxs("div",{className:"flex-1 animate-pulse space-y-4 p-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{className:"h-2.5 rounded bg-surface w-1/4"}),a.jsxs("div",{className:"flex gap-3",children:[a.jsx("div",{className:"size-10 rounded-full bg-surface shrink-0"}),a.jsxs("div",{className:"flex-1 space-y-1.5",children:[a.jsx("div",{className:"h-3 rounded bg-surface w-3/4"}),a.jsx("div",{className:"h-2.5 rounded bg-surface w-1/2"})]})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{className:"h-2.5 rounded bg-surface w-1/4"}),a.jsx("div",{className:"h-8 rounded bg-surface"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{className:"h-2.5 rounded bg-surface w-1/4"}),a.jsx("div",{className:"flex gap-1.5 flex-wrap",children:Array.from({length:5}).map((e,t)=>a.jsx("div",{className:"h-6 w-16 rounded bg-surface"},t))})]})]})]})}function Jd({isOpen:e,current:t,onSelect:s,onCancel:n}){return e?a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[a.jsx(lo,{label:"Dismiss reclassify sender",onDismiss:n,className:"backdrop-blur-sm"}),a.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Reclassify sender",className:"relative z-10 w-full max-w-sm rounded-sm border border-line bg-surface p-6 shadow-lg",children:[a.jsx("h2",{className:"text-lg font-semibold",children:"Reclassify this sender"}),a.jsx("p",{className:"mt-2 text-sm text-fg-muted",children:"Set a category override for future messages from this sender."}),a.jsx("div",{className:"mt-4 flex flex-col gap-1",children:Gd.map(r=>a.jsxs("button",{type:"button",onClick:()=>s(r),className:`flex min-h-11 items-center justify-between rounded px-3 text-left text-sm capitalize transition-colors hover:bg-surface-raised ${r===t?"font-semibold text-accent":"text-fg"}`,children:[r,r===t&&a.jsx("span",{className:"text-2xs text-fg-subtle",children:"current"})]},r))}),a.jsx("div",{className:"mt-6 flex justify-end",children:a.jsx("button",{type:"button",onClick:n,className:"inline-flex min-h-11 items-center justify-center rounded border border-line px-4 text-sm font-medium transition-colors hover:bg-surface-raised",children:"Cancel"})})]})]}):null}function Xd({thread:e,onClose:t,mailboxId:s,accountId:n,hideCloseButton:r,onAfterOptimisticRemove:o}){const{data:i,addressId:c,isSimilarLoading:d,similarError:b,similarErrorIsFatal:g}=Bd(e,s),[v,p]=l.useState(!1),x=e.fromEmail??void 0,{updateFlags:f}=qd({addressId:c,senderEmail:x}),{reportSpam:u,notSpam:m,isReporting:h,isRestoring:S}=Wa({mailboxId:e.mailboxId,threadId:e.threadId,accountId:n,onAfterOptimisticRemove:o}),y=io(),w=Vd(e),N=l.useCallback(()=>{m([e.messageId])},[m,e.messageId]),E=l.useCallback(()=>{Hd(y,{count:1,senderTrust:e.senderTrust,wasRescuable:Qd(e)}),u([e.messageId])},[u,e,y]),P=l.useCallback(()=>{},[]),z=l.useCallback(()=>{const R=i?.flags?.vip!==!0;f({vip:{value:R}})},[i?.flags?.vip,f]),U=l.useCallback(()=>{const R=i?.flags?.muted!==!0;f({muted:{value:R}})},[i?.flags?.muted,f]),L=l.useCallback(()=>{const R=i?.flags?.unsubscribed!==!0;f({unsubscribed:{value:R}})},[i?.flags?.unsubscribed,f]),D=l.useCallback(R=>{p(!1),f({category:{value:R}})},[f]),F=c!==void 0,O={onToggleVip:F?z:void 0,onToggleMute:F?U:void 0,onToggleUnsubscribe:F?L:void 0,onReclassify:F?()=>p(!0):void 0,onNotSpam:w==="notSpam"?N:void 0,onReportSpam:w==="reportSpam"?E:void 0},k=({mailboxId:R,threadId:j,messageId:M,className:C,ariaLabel:K,children:$})=>a.jsx(ta,{to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:R,threadId:j,messageId:M},search:H=>H,variant:"row",className:C,"aria-label":K,children:$});if(!i)return a.jsx(Yd,{});const I=Wd({similarError:b,similarErrorIsFatal:g,isSimilarLoading:d});return a.jsxs(a.Fragment,{children:[a.jsx(Ta,{data:i,onClose:t,hideCloseButton:r,onShowSimilar:P,actions:O,similarState:I,similarLinkComponent:k,reportSpamPending:h,notSpamPending:S,className:"border-l-0 h-full w-full"}),a.jsx(Jd,{isOpen:v,current:i.category.value,onSelect:D,onCancel:()=>p(!1)})]})}const Zd=({onClose:e,thread:t,mailboxId:s,accountId:n,hideCloseButton:r,onAfterOptimisticRemove:o})=>t?a.jsx(Xd,{thread:t,onClose:e,mailboxId:s,accountId:n,hideCloseButton:r,onAfterOptimisticRemove:o}):a.jsxs("aside",{className:"flex h-full w-full flex-col bg-surface-sunken",children:[a.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-1.5 border-b border-line px-row-inset",children:[a.jsx(Ye,{className:"size-3.5 text-fg-subtle"}),a.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Intelligence"})]}),a.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center px-row-inset text-center",children:[a.jsx(Ye,{className:"size-8 text-fg-subtle"}),a.jsx("p",{className:"mt-3 text-sm text-fg-muted",children:"Intelligence"}),a.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:"Sender trust, authenticity and similar messages will appear here."})]})]});function wm({isOpen:e,onClose:t,thread:s,mailboxId:n,accountId:r,onAfterOptimisticRemove:o}){return a.jsx(Ed,{isOpen:e,onClose:t,ariaLabel:"Message details",side:"right",answers:{toggleIntelligence:t},children:a.jsx(Zd,{onClose:t,thread:s,mailboxId:n,accountId:r,hideCloseButton:!0,onAfterOptimisticRemove:o})})}const eu=e=>{const{trashByAccount:t,hasAppointments:s,isError:n}=Yc();return l.useMemo(()=>{const r=ri({targets:e,trashByAccount:t,hasAppointments:s,isError:n}),o=i=>i.accountId?t.get(i.accountId):void 0;return{outcome:r,staleFolderLabel:e.map(o).find(i=>i?.source==="Stale")?.staleFolderPath,guessedMailboxId:r==="unconfirmed"?e.find(i=>o(i)?.mailboxId===i.mailboxId)?.mailboxId:void 0}},[e,t,s,n])},tu={delete:(e,t)=>`Deleting ${e} of ${t}…`,move:(e,t)=>`Moving ${e} of ${t}…`,markRead:(e,t)=>`Marking ${e} of ${t} as read…`},su={delete:"moved to Trash",move:"moved",markRead:"marked as read"},tr=(e,t)=>e==="delete"&&oi(t)?"permanently deleted":su[e],nu={delete:"couldn't be deleted",move:"couldn't be moved",markRead:"couldn't be marked as read"},au={delete:"Couldn't delete these messages",move:"Couldn't move these messages",markRead:"Couldn't mark these messages as read"},ru={delete:"The delete didn't finish.",move:"The move didn't finish.",markRead:"The update didn't finish."},jm=(e,t,s)=>tu[e](ze(t),ze(s)),ou=(e,t,s="trash")=>`${ze(t)} ${tr(e,s)}. Your mail server is still catching up.`,iu=e=>`Stopped after ${ze(e)}`,lu=(e,t,s,n="trash")=>`${ze(t)} of ${ze(s)} ${tr(e,n)}. Nothing was sent for the rest, so they are untouched.`,cu=(e,t)=>t>0?`Stopped after ${ze(t)} — some messages ${nu[e]}`:au[e],du=e=>ru[e],Cm=e=>e==="delete"?"danger":"info",Sm=(e,t,s,n)=>s.error!==void 0?null:s.cancelled?{severity:"warning",title:iu(s.done),detail:lu(e,s.done,t,n)}:{severity:"info",title:ou(e,s.done,n)},uu=100,fu=(e,t)=>e.kind==="move"?[t,e.destinationMailboxId]:[t],mu=({mailboxId:e,accountId:t,enabled:s,predicateKey:n,searchQuery:r})=>{const[o,i]=l.useState({kind:"idle"}),[c,d]=l.useState(void 0),[b,g]=l.useState(void 0),v=l.useRef(!1),p=l.useRef(!1),x=ie(),{pushError:f}=xe(),{requestAppointment:u}=ws(),m=l.useRef(async()=>({done:0,failedIds:[],cancelled:!1}));l.useEffect(()=>{p.current||(v.current=!0),i({kind:"idle"})},[s,n]);const h=l.useRef(r);h.current=r;const S=l.useCallback(L=>async D=>{const{data:F}=await Js({path:{mailboxId:e},query:{...L,continuationToken:D,limit:uu},throwOnError:!0});return{ids:(F.items??[]).map(O=>O.messageId),continuationToken:F.continuationToken}},[e]),y=l.useCallback(async()=>{const{data:L}=await Js({path:{mailboxId:e},query:{...h.current,count:!0,results:!1},throwOnError:!0});if(L.count===void 0)throw new Error("the search returned no count for the selection");return L.count},[e]),w=l.useCallback(L=>async D=>{if(L.kind==="move"){const{data:O}=await co({body:{messageIds:D,destinationMailboxId:L.destinationMailboxId},throwOnError:!0});return O}if(L.kind==="markRead"){const{data:O}=await uo({body:{messageIds:D,isRead:!0},throwOnError:!0});return O}const{data:F}=await fo({body:{messageIds:D},throwOnError:!0});return F},[]),N=l.useCallback((L,D)=>{we(x,je(fu(L,e)));const F=new Set;t&&F.add(t);for(const O of D)O.accountId&&F.add(O.accountId);for(const O of F)x.invalidateQueries({queryKey:Xe({path:{accountId:O}})})},[x,e,t]),E=l.useCallback(()=>{v.current=!1,i({kind:"counting"}),y().then(L=>{if(v.current){i({kind:"idle"});return}i({kind:"escalated",total:L})},L=>{f(Xs("Couldn't count matching messages","The count didn't finish.",L)),i({kind:"idle"})})},[y,f]),P=l.useCallback(()=>{v.current=!0},[]),z=l.useCallback(()=>{p.current||(v.current=!0,i({kind:"idle"}))},[]),U=l.useCallback(async(L,D)=>{v.current=!1,p.current=!0,d(L);const F=D?.length??(o.kind==="escalated"?o.total:0),O=M=>g($c(M)),k=w(L),I=S(h.current);let R;try{R=D!==void 0?await qa(D,k,O,()=>v.current):await Ac(I,o.kind==="escalated"?o.total:0,k,O,()=>v.current)}finally{p.current=!1}d(void 0),g(void 0),i({kind:"idle"});const j=R.error?Vn(R.error):void 0;return j?u({accountId:j.accountId,role:j.role,reason:j.reason,action:{kind:"delete",count:F},onAppointed:async()=>{await m.current(L,D)}}):R.error&&f(Xs(cu(L.kind,R.done),du(L.kind),R.error)),R.done>0&&N(L,D??[]),R},[w,S,o,f,N,u]);return m.current=U,{phase:o,escalate:E,stop:P,clear:z,isRunning:c!==void 0,runningAction:c,progress:b,runAction:U}},pu=120,hu=({keyboardFocusedMessageId:e,openMessageId:t,enabled:s,open:n,delayMs:r=pu})=>{const o=l.useRef(n);o.current=n;const i=l.useRef(void 0);l.useEffect(()=>{const c=e;if(!s){i.current=c;return}if(c===void 0||c===t)return;if(c===i.current){i.current=void 0;return}const d=setTimeout(()=>o.current(c),r);return()=>clearTimeout(d)},[s,e,t,r])},sr="This account has no Junk folder appointed, so there is nowhere to file these. Appoint one under Settings › Folder roles.",gu="These are already in Junk, so there is nowhere to file them.",bu=(e,t)=>e!==void 0&&e!==t?e:void 0,Nm=(e,t)=>{if(bu(e,t)===void 0)return e===void 0?sr:gu};function xu(e,t){if(e.length!==0)return t!==void 0&&e.includes(t)?t:e[0]}const vu={title:"",navSlot:null,titleMeta:null,searchSlot:null,searchField:null,searchResults:null,makeFilterSlot:null},bs=l.createContext(vu),nr=()=>l.useContext(bs),yu=({isOpen:e,messageIds:t,outcome:s,accountId:n,trashFolderLabel:r,staleFolderLabel:o,guessedMailboxId:i,isDeleting:c=!1,onConfirm:d,onCancel:b})=>{const{Account:g}=Zn(),{requestAppointment:v}=ws(),p=t.length,x=()=>d([...t]),f=ii(p,s,{trashFolderLabel:r,staleFolderLabel:o});if(s==="noTrash"||s==="staleTrash"||s==="unconfirmed"){const u=s==="noTrash"?"none":s==="staleTrash"?"stale":"unconfirmed";return a.jsx(Et,{isOpen:e,...f,onConfirm:()=>{if(!n)return x();const m=[...t];b(),v({accountId:n,role:"Trash",reason:u,action:{kind:"delete",count:p},staleFolderLabel:o,trashFolderLabel:r,guessedMailboxId:i,onAppointed:async()=>d(m)})},onCancel:b})}return s==="unavailable"?a.jsx(g,{fallback:a.jsx(Et,{isOpen:e,...f,confirmLabel:"Reload reader",onConfirm:()=>window.location.reload(),onCancel:b}),children:({signOut:u})=>a.jsx(Et,{isOpen:e,...f,onConfirm:()=>u(),onCancel:b})}):a.jsx(Et,{isOpen:e,...f,destructive:!0,isBusy:c||s==="unknown",onConfirm:x,onCancel:b})},ar=8,rr=e=>e==="From"||e==="FromDomain",ku=e=>({value:e.email,label:e.displayName??e.email,...e.displayName?{hint:e.email}:{},...e.fromSelection?{source:"selected"}:{}}),wu=e=>{const t=Ua(e.email);if(t!==null)return{value:t,...e.fromSelection?{source:"selected"}:{}}},ju=(e,t)=>e.value.toLowerCase().includes(t)||(e.label??"").toLowerCase().includes(t),Cu=(e,t,s)=>{if(!rr(e))return[];const n=t.trim().toLowerCase(),r=new Set,o=[];for(const i of s){if(i.email.trim()==="")continue;const c=e==="From"?ku(i):wu(i);if(!c)continue;const d=c.value.toLowerCase();if(!(d===""||r.has(d))&&(r.add(d),d!==n&&!(n!==""&&!ju(c,n))&&(o.push(c),o.length===ar)))break}return o},Su=250,Nu=2,Tu=(e,t,s)=>{const n=t.trim(),r=fa(n,Su),o=e!==void 0&&rr(e),{data:i}=ee({...Ss({query:{q:r,limit:ar}}),enabled:o&&r.length>=Nu});if(!o||e===void 0)return[];const c=[...s.map(d=>({email:d,fromSelection:!0})),...(i?.items??[]).map(d=>({email:d.normalizedEmail,...d.displayName?{displayName:d.displayName}:{}}))];return Cu(e,n,c)},or=12,Iu=e=>{const{envelope:t}=e,s=t.from[0];return{id:t.messageId,sender:s?Ba({normalizedEmail:s.normalizedEmail,displayName:s.displayName}):"Unknown",subject:t.subject??"(No subject)",date:Ze(t.date)}},Eu=(e,t)=>{const s=e!==void 0&&t!==void 0,{data:n,isLoading:r}=ee({...mo({path:{mailboxId:e??""},query:{...t,limit:or}}),enabled:s,staleTime:3e4});return{messages:(n?.items??[]).map(Ru),isPending:s&&r}},Ru=e=>({id:e.messageId,sender:e.fromName||e.fromEmail||"Unknown",subject:e.subject??"(No subject)",date:Ze(e.sentDate)}),Mu=e=>Ts({queries:e.slice(0,or).map(t=>({...zt({path:{messageId:t}}),staleTime:Number.POSITIVE_INFINITY})),combine:t=>({messages:t.map(s=>s.data).filter(s=>s!==void 0).map(Iu),isPending:t.some(s=>s.isPending)})}),Au=e=>({matchOperator:"Or",literalClauses:Ht(e)}),$u=(e,t,s)=>{const n=me(po()),{mutate:r,reset:o}=n,[i,c]=l.useState(!1),d=l.useMemo(()=>Qt(s),[s]),b=l.useCallback(()=>{!e||!t||(c(!1),r({path:{accountId:e},body:sn({anchorMessageId:t,matchOperator:"And",literalClauses:[]})}))},[e,t,r]),g=l.useCallback(()=>{c(!1),o()},[o]),v=n.data,p=v?.semanticUnavailable===!0&&!i&&d.length>0;l.useEffect(()=>{!p||!e||(c(!0),r({path:{accountId:e},body:sn(Au(d))}))},[p,e,d,r]);const x=i||(v?.semanticUnavailable??!1),f=n.isPending||p,u=i?{matchOperator:"Or",literalClauses:Ht(d)}:{...t?{anchorMessageId:t}:{},matchOperator:"And",literalClauses:[]};return{preview:b,reset:g,matchedCount:f?void 0:v?.matchedCount,messageIds:f?void 0:v?.messageIds,semanticUnavailable:x,senderFallback:i,senders:d,matchPredicate:u,isPending:f,isError:n.isError,error:n.error}},Lu=()=>[ho({path:{mailboxId:""}}),go({path:{mailboxId:""}}),bo()].map(e=>[{_id:e[0]._id}]),Pu=e=>Do(e)?e.pages:Fo(e)?[e]:[],Du=e=>typeof e=="object"&&e!==null&&typeof e.messageId=="string",Fu=(e,t)=>{const s=new Set(t),n=new Map;for(const r of e)for(const o of Pu(r))for(const i of o.items){if(!Du(i)||!s.has(i.messageId))continue;const c=i.subject?.trim();c&&n.set(i.messageId,c)}return t.map(r=>n.get(r)).filter(r=>r!==void 0)},Ou=e=>{const t=ie(),s=e.join("\0");return l.useMemo(()=>{const n=Lu().flatMap(r=>t.getQueriesData({queryKey:r}).map(([,o])=>o));return Fu(n,e)},[t,s])},zu=new Set(["hasAttachment","isUnread","isRead","isStarred","category","before","after"]),_u=e=>zu.has(e),Uu=(e,{searchHadSemanticReach:t})=>{const s=[],n=[];let r,o;for(const d of e.tokens){if(d.type==="from"){s.push({field:"From",value:d.value});continue}if(d.type==="subject"){s.push({field:"Subject",value:d.value});continue}if(d.type==="in"){r={mailboxId:d.mailboxId,label:d.value};continue}if(d.type==="account"){o=d.accountId;continue}_u(d.type)&&n.push({type:d.type,label:oa(d)})}const i=e.freeText.trim(),c=i.length>0;return c&&s.push({field:"HasWords",value:i}),{clauses:s,matchOperator:"all",scopedOut:r,droppedFacets:n,targetAccountId:o,keptTerms:c,droppedSemantic:c&&t}},Bu=(e,t,s)=>e.targetAccountId??t??s[0]?.accountId,Ku=({failure:e,isStarting:t,isRunning:s,isDone:n,failedCount:r,ruleSaved:o})=>e?.kind==="restartFailed"?"backApplyRestartFailed":e?.kind==="startFailed"?o?"backApplyStartFailed":"commitFailed":n?r>0?"backApplyFailed":"backApplyComplete":e?.kind==="statusUnreadable"?"statusUnknown":t||s?"backApplyRunning":"saving",qu=e=>{if(e.runState==="statusUnknown")return{kind:"refreshStatus"};if(e.isEscalated)return{kind:"rerunEscalated"};if(e.committedScope==="standing"||e.committedScope==="temporary")return e.createFilterFailed?{kind:"resetAndResend"}:e.backApplyPending?{kind:"startBackApply"}:{kind:"waitOnJob"};if(e.committedScope==="all-like-these"&&e.widenRunsAsJob)return{kind:"resend"};const t=new Set(e.failedIds);return{kind:"rerunBulk",targets:t.size>0?e.sent.filter(s=>t.has(s.id)):e.sent}},Qu=e=>e!==void 0&&e.outcome===void 0&&e.failureReason===void 0,Hu=(e,t)=>{if(e){e.stop();return}t()},Gu=(e,t)=>e==="run"?t.dismiss:t.cancel,Vu={clauses:[],matchOperator:"any"},Wu={clauses:[],matchOperator:"all",droppedFacets:[],keptTerms:!1,droppedSemantic:!1},Yu=[],Ju=(e,t,s)=>({verb:"organize",accountId:Bu(e,t.accountId,s),selection:Yu,selectionRestriction:void 0,escalated:void 0,searchConversion:e}),Fe={state:"saving",matched:0,applied:0,failed:0,failures:[]},is=(e,t)=>e.map((s,n)=>({...s,id:`${t}-${n}`})),Dn=(e,t,s)=>{if(e==="delete")return{kind:"delete"};if(e==="markRead")return{kind:"markRead"};const n=e==="junk"?s:t;return n?{kind:"move",destinationMailboxId:n}:void 0},ls=e=>e==="move"||e==="junk"||e==="organize",Fn=e=>e==="junk"?sr:"No destination was chosen, so there is nowhere to file these. Go back and pick a folder.";function Xu({verb:e,accountId:t,mailboxId:s,selection:n,selectionRestriction:r,escalated:o,escalatedProgress:i,searchConversion:c,onFinished:d,onRunEnded:b,step:g,goToStep:v,goBack:p,closeWizard:x}){const[f]=l.useState(()=>c),[u]=l.useState(()=>o),m=f!==void 0,[h,S]=l.useState(m?"properties":"selected"),y=u?"escalated":h,[w,N]=l.useState(()=>f?{clauses:is(f.clauses,"search"),matchOperator:f.matchOperator}:Vu),[E,P]=l.useState(void 0),[z,U]=l.useState(void 0),[L,D]=l.useState(!1),[F,O]=l.useState(void 0),[k,I]=l.useState(void 0),[R,j]=l.useState(),M=l.useRef(!1),C=l.useRef(!1),K=l.useMemo(()=>n.map(T=>T.id),[n]),$=l.useMemo(()=>n.map(T=>({id:T.id,accountId:T.accountId})),[n]),H=l.useMemo(()=>n.map(T=>T.email).filter(Boolean),[n]),Y=K[0],X=Ou(K),{junkMailboxId:se}=Ga(t),le=$u(u?void 0:t,Y,H),{preview:pe}=le;l.useEffect(()=>{pe()},[pe]);const te=y==="similar"||y==="properties",he=l.useMemo(()=>({matchOperator:w.matchOperator==="all"?"And":"Or",literalClauses:w.clauses.map(T=>({field:T.field,value:T.value}))}),[w.clauses,w.matchOperator]),ce=y==="similar"?le.matchPredicate:he,{count:ge,matchedIds:ue}=hi(te?t:void 0,ce),q=Mu(te?ue:[]),ae=Eu(u?s:void 0,u?.searchQuery),B=u?{status:"ready",count:u.total}:te?ge:{status:"ready",count:n.length},{data:Q}=ee({...xt({path:{accountId:t??""}}),enabled:!!t,staleTime:Number.POSITIVE_INFINITY}),ne=Va(t),_e=Wn(),tt=l.useMemo(()=>Jn({mailboxes:Q?.items??[],folderAppointments:ne,currentMailboxId:s,translator:_e}),[Q?.items,ne,s,_e]),{createFolderIn:Vt}=Yn(t),st=tt.find(T=>T.id===w.moveMailboxId)?.label,nt=hc(n.map(T=>({normalizedEmail:T.email,displayName:T.sender}))),at=jc({match:y==="properties"&&w.clauses[0]?.value.trim()||void 0,sender:nt?Ba(nt):void 0,folder:st}),G=l.useMemo(()=>({...w,name:w.name??at}),[w,at]),St=Tu(E?.draft.field,E?.draft.value??"",H),fe=gi(t),ve=bi(t),Ue=mu({mailboxId:s??"",accountId:t,enabled:!1,predicateKey:"selection-wizard",searchQuery:{}}),{runAction:Be}=Ue,re=yo({verb:e,mode:y,scope:w.scope,fromSearch:m}),J=re[Zs(re,g)],$e=ko(t,r),Ce=(T=>{if(T==="folder")return $e.destination;if(T==="rule")return G.scope==="standing"||G.scope==="until"?$e.rule:void 0})(J)??wo(J,G,B),Le=l.useCallback(()=>is(wc(H,X),"seed"),[H,X]),Wt=l.useCallback(T=>{S(T),N(A=>({...A,widen:T==="similar"&&Y?{anchorCount:Math.max(n.length,1)}:void 0,...T==="properties"&&A.clauses.length===0?{clauses:Le()}:{}}))},[Y,n.length,Le]),Ke=l.useCallback(()=>{D(!0),S("properties"),N(T=>({...T,widen:void 0,clauses:is(Ht(H),"sender"),matchOperator:"any"})),v("properties")},[H,v]),Se=le.semanticUnavailable||le.isError;l.useEffect(()=>{J==="match"&&(y!=="similar"||!Se||L||Ke())},[J,y,Se,L,Ke]);const rt=l.useCallback(()=>{P({mode:"add",draft:{field:"From",value:""}})},[]),ot=l.useCallback(T=>{const A=w.clauses.find(W=>W.id===T);A&&P({mode:"edit",clauseId:T,draft:{field:A.field,value:A.value}})},[w.clauses]),oe=l.useCallback(T=>{N(A=>({...A,clauses:A.clauses.filter(W=>W.id!==T)}))},[]),ye=l.useCallback(T=>{P(A=>A&&{...A,draft:T})},[]),ur=l.useCallback(()=>{P(T=>{if(!T)return;const A=xi(T.draft.field,T.draft.value),W={...T.draft,value:A};N(qe=>({...qe,clauses:T.clauseId?qe.clauses.map(it=>it.id===T.clauseId?{...it,...W}:it):[...qe.clauses,{id:crypto.randomUUID(),...W}]}))})},[]),fr=l.useCallback(()=>{if(Ce){U(J);return}U(void 0);const T=re[Zs(re,J)+1];T&&v(T)},[Ce,J,re,v]),Yt=l.useCallback(async T=>{const A=Dn(e,G.moveMailboxId,se);if(!A){I({matched:T.length,sent:T,failureReason:Fn(e)});return}I({matched:T.length,sent:T});const W=await Be(A,T);I({matched:T.length,sent:T,outcome:W}),C.current&&b?.(A.kind,T.length,W)},[e,G.moveMailboxId,se,Be,b]),Jt=l.useCallback(async()=>{if(!u)return;const T=Dn(e,G.moveMailboxId,se);if(!T){I({matched:u.total,sent:[],failureReason:Fn(e)});return}I({matched:u.total,sent:[]});const A=await u.run(T);I({matched:u.total,sent:[],outcome:A}),C.current&&b?.(T.kind,u.total,A)},[u,e,G.moveMailboxId,se,b]),{start:Nt}=fe,{createFilterAsync:Ks}=ve,Tt=l.useCallback(()=>{if(u){Jt();return}const T=vi({mode:h,ruleScope:G.scope}),A=yi({mode:h,ruleScope:G.scope,anchorMessageId:Y,clauses:G.clauses,matchOperator:G.matchOperator,moveMailboxId:G.moveMailboxId,until:G.until});if(O(T),T==="standing"||T==="temporary"){const W=ki(A)?A:void 0;j(W),Ks(A,T,(G.name??"").trim()).then(qe=>{qe&&W&&Nt(W)});return}if(T==="all-like-these"&&ls(e)){Nt(A);return}Yt(T==="just-these"?$:ue.map(W=>({id:W,accountId:t})))},[u,Jt,h,G,Y,e,t,$,ue,Ks,Nt,Yt]),mr=l.useCallback(()=>{if(Ce){U(J);return}M.current||(M.current=!0,v("run"),Tt())},[Ce,J,v,Tt]),qs=l.useCallback(T=>{const A=fe.progress,W=Ku({failure:fe.failure,isStarting:fe.isStarting,isRunning:fe.isRunning,isDone:fe.isDone,failedCount:A.failedCount,ruleSaved:T});return W==="saving"||W==="commitFailed"||W==="backApplyStartFailed"?{...Fe,state:W}:{state:W,matched:A.matchedCount,applied:A.appliedCount,failed:W==="backApplyFailed"||W==="backApplyRestartFailed"?A.failedCount:0,failures:[]}},[fe]),Qs=l.useMemo(()=>{const T=new Map;for(const A of[...n,...q.messages,...ae.messages])T.set(A.id,A);return T},[n,q.messages,ae.messages]),Hs=u?i:Ue.progress,Gs=l.useCallback(()=>{if(!k)return Fe;const{matched:T,outcome:A,failureReason:W}=k;if(W!==void 0)return{...Fe,state:"commitFailed",failureReason:W};if(!A){const Qe=Hs?.done??0;return{state:"backApplyRunning",matched:Math.max(T,Qe),applied:Qe,failed:0,failures:[]}}if(!(A.cancelled||A.error!==void 0))return{state:"backApplyComplete",matched:Math.max(T,A.done),applied:A.done,failed:0,failures:[]};if(A.done===0)return{...Fe,state:"commitFailed"};const it=A.failedIds.map(Qe=>Qs.get(Qe)).filter(Qe=>Qe!==void 0),br=A.failedIds.length>0?A.failedIds.length:Math.max(T-A.done,1);return{state:"runStopped",matched:Math.max(T,A.done),applied:A.done,failed:br,failures:it}},[k,Hs,Qs]),Pe=u?Gs():F==="standing"||F==="temporary"?ve.isError?{...Fe,state:"commitFailed"}:ve.isSuccess?R?qs(!0):{...Fe,state:"filterSaved"}:Fe:F==="all-like-these"&&ls(e)?qs(!1):Gs(),pr=()=>{const T=qu({runState:Pe.state,isEscalated:u!==void 0,committedScope:F,createFilterFailed:ve.isError,backApplyPending:R!==void 0,widenRunsAsJob:ls(e),failedIds:k?.outcome?.failedIds??[],sent:k?.sent??$});switch(T.kind){case"refreshStatus":fe.refreshStatus();return;case"rerunEscalated":Jt();return;case"resetAndResend":ve.reset(),Tt();return;case"resend":Tt();return;case"startBackApply":R&&Nt(R);return;case"waitOnJob":return;case"rerunBulk":Yt(T.targets);return}},hr=l.useCallback(()=>{x(re,J)},[x,re,J]),Xt=l.useCallback(()=>{C.current=!0,x(re,J),d()},[x,re,J,d]),{stop:Vs}=Ue,gr=l.useCallback(()=>{Hu(u,Vs)},[u,Vs]);Ic({shouldBlockFn:({action:T})=>T!=="BACK"?!1:(Xt(),!0),enableBeforeUnload:!1,disabled:J!=="run"});const Zt={messages:u?ae.messages:te?q.messages:n,count:B,label:y==="selected"?"Your selection":"A sample of what matches",emptyReason:y==="similar"&&Se?"notIndexed":"noMatch",loading:u?ae.isPending:te&&(B.status==="loading"||q.isPending)};return a.jsx(jo,{verb:e,steps:re,step:J,blockedReason:Ce,nudged:z===J,onBack:p,onExit:Gu(J,{dismiss:Xt,cancel:hr}),onContinue:fr,onCommit:mr,match:{selectedCount:n.length,mode:y,accountId:$e.accountId,onModeChange:Wt,semanticUnavailable:Se,semanticErrorDetail:le.error instanceof Error?le.error.message:void 0,semanticFallbackTaken:L,onSemanticFallback:Ke,escalatedScope:u?.scope,sample:Zt},properties:{clauses:G.clauses,matchOperator:G.matchOperator,onMatchOperatorChange:T=>N(A=>({...A,matchOperator:T})),clauseEdit:E,onStartAddClause:rt,onStartEditClause:ot,onRemoveClause:oe,onChangeDraft:ye,onSubmitClause:ur,onCancelClause:()=>P(void 0),clauseFields:wi,clauseSuggestions:St,conversionNotice:f?Sc(f):void 0,semanticFallbackTaken:L,sample:{...Zt,label:"What this matches"}},folder:{folders:tt,mailboxId:G.moveMailboxId,delimiter:Xn(Q?.items??[]),onSelect:T=>N(A=>({...A,moveMailboxId:T})),onCreateFolder:t?Vt:void 0,restriction:$e.destination},rule:{draft:G,onScopeChange:T=>N(A=>({...A,scope:T})),onUntilChange:T=>N(A=>({...A,until:T})),restriction:$e.rule},name:{name:G.name??"",onNameChange:T=>N(A=>({...A,name:T})),nudged:z===J},review:{verb:e,mode:y,selectedCount:n.length,clauses:G.clauses,matchOperator:G.matchOperator,folder:st,scope:G.scope,until:G.until,ruleName:re.includes("name")?G.name:void 0,escalatedScope:u?.scope,sample:Zt},run:{state:Pe.state,verb:e,scope:G.scope,matched:Pe.matched,applied:Pe.applied,failedCount:Pe.failed,failures:Pe.failures,failureReason:Pe.failureReason,onRetry:pr,onDismiss:Xt,onCancelRun:Qu(k)?gr:void 0}})}function Tm(e){const t=xo()==="search",{searchConversion:s}=nr(),{accounts:n}=Ut(),{step:r,goToStep:o,goBack:i,closeWizard:c}=vo(t?"properties":"match");if(Cs({id:"selection-wizard",open:r!==void 0}),!r)return null;const d=t?s??Wu:void 0;return a.jsx(Xu,{...e,...d?Ju(d,e,n):{},step:r,goToStep:o,goBack:i,closeWizard:c})}const Zu=[],_s=l.createContext(null),ef=e=>{const t=l.useContext(_s);return t?t.rowInteraction(e):null},tf=()=>{const e=l.useContext(_s);if(!e)throw new Error("useThreadListSelection must be used inside <ThreadListInteraction>");return e},sf="[data-message-id]",nf=e=>Array.from(e.querySelectorAll(sf)).map(t=>t.dataset.messageId).filter(t=>t!==void 0),af=(e,t)=>e.length===t.length&&e.every((s,n)=>s===t[n]),rf=e=>{const[t,s]=l.useState([]);return l.useEffect(()=>{const n=e.current;if(!n)return;const r=()=>{const i=nf(n);s(c=>af(c,i)?c:i)};r();const o=new MutationObserver(r);return o.observe(n,{childList:!0,subtree:!0}),()=>o.disconnect()},[e]),t};function Im({selectedMessageId:e,rows:t,onOpen:s,onDeleteMessages:n,onSelectionVerb:r,isDeleting:o=!1,commandsRef:i,onTriageContextChange:c,children:d}){const b=js(),{pushError:g}=xe(),v=l.useRef(null),p=rf(v),x=Nc({orderedIds:p,isDesktop:b,initialFocusedId:e}),{focusedMessageId:f,setFocusedMessageId:u,pendingDomFocusRef:m,cursorMovedByPointerRef:h,selection:S,isMultiSelectMode:y,exitSelection:w,handleRowSelect:N}=x,{selectedIds:E,selectedCount:P,isSelected:z,toggle:U,select:L,toggleAll:D}=S,F=p.length>0&&p.every(q=>E.has(q)),O=l.useCallback(()=>{p.length>0&&D(p)},[p,D]),{intersectWith:k}=S;l.useEffect(()=>{k(p)},[k,p]),l.useEffect(()=>{const q=m.current;q!==null&&(m.current=null,v.current?.querySelector(`[data-message-id="${q}"]`)?.focus())});const I=l.useCallback(q=>{h.current=!0,u(q)},[h,u]),R=l.useCallback(q=>{b||L(q)},[b,L]),j=l.useCallback(()=>{f&&s(f)},[f,s]),M=l.useCallback(q=>s(q,{replace:!0}),[s]);hu({keyboardFocusedMessageId:x.keyboardFocusedMessageId,openMessageId:e,enabled:b&&P===0,open:M});const[C,K]=l.useState(null),{outcome:$,staleFolderLabel:H,guessedMailboxId:Y}=eu(C?.targets??Zu),X=l.useCallback(q=>{if(C!==null)return!0;if(P>0)return r(q),!0;if(q!=="delete"||!f)return!1;const ae=t.find(B=>B.id===f);return!ae?.mailboxId||!ae.accountId?(g({title:"Couldn't delete this message",detail:"This list has lost track of which account and folder it is in, so reader can't tell whether deleting it would move it to Trash or erase it. Nothing was deleted.",action:{label:"Reload the list",href:window.location.href}}),!0):(K({ids:[f],targets:[{accountId:ae.accountId,mailboxId:ae.mailboxId}]}),!0)},[C,P,r,f,t,g]),se=l.useCallback(q=>{q.length!==0&&(n(q),K(null),w())},[n,w]),le=l.useCallback(()=>K(null),[]),pe=l.useCallback(()=>P===0?!1:(w(),!0),[P,w]),te=p.length>0;l.useEffect(()=>{if(i){if(!te){i.current=null;return}return i.current={focusNext:x.focusNext,focusPrevious:x.focusPrevious,focusFirst:x.focusFirst,focusLast:x.focusLast,openFocused:j,toggleSelect:x.toggleFocusedSelection,extendSelectDown:x.extendRangeDown,extendSelectUp:x.extendRangeUp,selectAll:x.selectAllLoaded,clearSelection:pe,requestVerb:X,toggleDensity:()=>{}},()=>{i.current=null}}},[i,te,x.focusNext,x.focusPrevious,x.focusFirst,x.focusLast,x.toggleFocusedSelection,x.extendRangeDown,x.extendRangeUp,x.selectAllLoaded,j,pe,X]);const he=l.useMemo(()=>Array.from(E),[E]),ce=C!==null;l.useEffect(()=>{c?.({focusedMessageId:f,selectedIds:he,orderedIds:p,hasList:te})},[c,f,he,p,te]);const ge=xu(p,f),ue=l.useMemo(()=>({selectedIds:E,selectedCount:P,exitSelection:w,startSelectionVerb:r,orderedIds:p,allSelected:F,toggleAllLoaded:O,rowInteraction:q=>({focused:q===f,isTabStop:q===ge,isDesktop:b,onFocusRow:I,selection:{isChecked:z(q),onToggleCheck:U,onRowSelect:N,isMultiSelectMode:y,onLongPress:R}})}),[E,P,w,r,p,F,O,f,ge,b,I,z,U,N,y,R]);return a.jsxs(_s.Provider,{value:ue,children:[a.jsx("div",{ref:v,className:"contents",children:d}),a.jsx(yu,{isOpen:ce,messageIds:C?.ids??[],outcome:$,accountId:C?.targets[0]?.accountId,staleFolderLabel:H,guessedMailboxId:Y,isDeleting:o,onConfirm:se,onCancel:le})]})}function Em({title:e,isDeleting:t}){const s=nr(),{selectedCount:n,exitSelection:r,startSelectionVerb:o,orderedIds:i,allSelected:c,toggleAllLoaded:d}=tf();return a.jsx(Jl,{title:s.title||e,navSlot:s.navSlot,titleMeta:s.titleMeta,searchSlot:s.searchSlot,searchField:s.searchField,idleSlot:s.makeFilterSlot,count:n,onCancel:r,onDelete:()=>o("delete"),onMarkRead:()=>o("markRead"),isBusy:t,selectAll:i.length>0?{checked:c,indeterminate:n>0&&!c,onChange:d}:void 0})}const cs=e=>{e.preventDefault(),e.stopPropagation()},of=(e,t)=>{const s=l.useRef(!1),n=l.useCallback(i=>{if(s.current=!1,i.button!==0)return;const c=ms(i);fn(c)&&t?.(e,c)&&(cs(i),s.current=!0,i.currentTarget.focus(),c.shiftKey&&window.getSelection()?.removeAllRanges())},[t,e]),r=l.useCallback(i=>{!i.ctrlKey||!t||i.preventDefault()},[t]),o=l.useCallback(i=>{if(s.current)return s.current=!1,cs(i),!0;const c=ms(i);return!fn(c)||!t?.(e,c)?!1:(cs(i),c.shiftKey&&window.getSelection()?.removeAllRanges(),!0)},[t,e]);return{onMouseDown:n,onContextMenu:r,claimClick:o}},lf=({thread:e,active:t=!1,focused:s,isTabStop:n,density:r="comfortable",isDesktop:o,badge:i,selection:c,inListbox:d=!1,link:b,onClick:g,onFocusRow:v})=>{const p=ie(),x=e.id,f=ef(x),u=s??f?.focused??!1,m=n??f?.isTabStop??!1,h=c??f?.selection,S=v??f?.onFocusRow,y=o??f?.isDesktop??!0,w=h?.isChecked??!1,N=h?.isMultiSelectMode??!1,E=h?.onToggleCheck,P=h?.onRowSelect,z=h?.onLongPress,U=l.useCallback(C=>{C.preventDefault(),C.stopPropagation(),E?.(x)},[E,x]),L=of(x,P),D=l.useCallback(C=>{if(!L.claimClick(C)){if(!y){if(N){C.preventDefault(),C.stopPropagation(),E?.(x);return}g?.();return}P?.(x,ms(C)),g?.()}},[L,y,N,E,P,g,x]),F=l.useCallback(()=>{z?.(x)},[z,x]),{longPressProps:O}=$l({onLongPress:F,accessibilityDescription:w?"Deselect message":"Select message"}),k=l.useCallback(()=>{p.prefetchQuery(zt({path:{messageId:x}}))},[p,x]),I=l.useCallback(()=>{k(),S?.(x)},[k,S,x]),R=jt({"data-list-row":"","data-message-row":!0,"data-message-id":x,...d?{role:"option","aria-selected":w}:{},tabIndex:m?0:-1,onClick:D,onMouseDown:L.onMouseDown,onContextMenu:L.onContextMenu,onMouseEnter:k,onFocus:I},y||!h?{}:O),j=_(r==="compact"?Ea({active:t,focused:u}):_("group",As({active:t,focused:u})),"outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-inset",w&&"bg-accent-soft",!y&&"min-h-11 select-none [-webkit-touch-callout:none]"),M=r==="compact"?a.jsx(Ra,{thread:e}):a.jsx($s,{thread:e,badge:i,selection:h?{checked:w,alwaysVisible:N,onToggle:U}:void 0});return b===void 0?a.jsx("button",{type:"button",...R,className:j,children:M}):a.jsx(ta,{to:"/mail/$mailboxId/$threadId/$messageId",params:{...b,messageId:x},search:C=>C,variant:"row",...R,className:j,children:M})},Rm=l.memo(lf),cf="Open a message first",df="This conversation hasn't loaded yet",uf="The mailbox list hasn't loaded yet",ff="Couldn't find this mailbox's account — reload to try again",mf={reply:"Reply",replyAll:"Reply all",forward:"Forward",delete:"Move to Trash",move:"Move to mailbox",flag:"Star"},Mm=({hasThread:e,messageId:t,intelligenceOpen:s,canToggleIntelligence:n,onToggleIntelligence:r,onReply:o,onReplyAll:i,onForward:c,onDelete:d,onToggleStar:b,isStarred:g,moveContext:v,moveContextLoading:p})=>{const[x,f]=l.useState(null),u=t??null,m=z=>e?z==="move"?v?null:p?uf:ff:{reply:o,replyAll:i,forward:c,delete:d,flag:b}[z]?null:df:cf,h=x&&x.messageId===u?x:null,S=h?m(h.action):null,y=h?.action==="move"&&h.overThread&&!!v,w=S??(h&&!y?`${mf[h.action]} is ready — press it again`:null),N=z=>f({action:z,messageId:u,overThread:e}),E=z=>()=>N(z),P=(z,U)=>U?()=>{f(null),U()}:E(z);return a.jsx(Pl,{hasThread:e,isStarred:g,onUnavailable:N,unavailableHint:w,replyTitle:`Reply ${lt("reply")}`,replyAllTitle:`Reply all ${lt("replyAll")}`,forwardTitle:`Forward ${lt("forward")}`,deleteTitle:`Move to Trash ${lt("delete")}`,flagTitle:`Star ${lt("toggleStar")}`,onReply:P("reply",o),onReplyAll:P("replyAll",i),onForward:P("forward",c),onDelete:P("delete",d),onToggleStar:P("flag",b),onMove:E("move"),moveSlot:v?a.jsx(zs,{accountId:v.accountId,currentMailboxId:v.currentMailboxId,onMove:v.onMove,label:"Move to mailbox",defaultOpen:y}):void 0,children:a.jsx(Ll,{open:s,enabled:n,onToggle:r})})};function pf(e){const[t,s]=l.useState(null);t!==null&&t!==e&&s(null);const n=e!==null&&t===e,r=l.useCallback(()=>s(null),[]),o=l.useCallback(()=>s(e),[e]),i=l.useCallback(()=>s(n?null:e),[n,e]);return{isOpen:n,open:o,close:r,toggle:i}}const Am=e=>{const{intelligenceOpen:t,onToggleIntelligence:s,onRaiseIntelligence:n}=Ut(),r=sa()?.showIntelligencePane??!1,o=e??null,i=pf(o),c=!r&&i.isOpen,{open:d,toggle:b}=i,g=l.useCallback(()=>{if(r){s();return}b()},[r,s,b]),v=l.useCallback(()=>{!r||t||n()},[r,t,n]),p=l.useCallback(()=>{if(!r){d();return}v()},[r,d,v]);return{canToggle:o!==null,isShowing:o!==null&&(r?t:c),toggle:g,open:p,drawerOpen:c,closeDrawer:i.close,railFits:r,openRail:v}},$m=(e,{toggle:t,open:s})=>{l.useEffect(()=>(e.current={toggle:t,open:s},()=>{e.current=null}),[e,t,s])},hf=()=>{const e=ie();return l.useCallback(t=>{const s=Me({path:{threadId:t.threadId}}),r=e.getQueriesData({queryKey:s}).flatMap(([,o])=>o?.items.map(i=>i.messageId)??[]);return r.length>0?r:[t.messageId]},[e])},gf=[],ir=e=>{const{data:t}=ee({...ea({path:{threadId:e??""}}),enabled:!!e});return t?.items??gf},Lm=(e,t)=>{const s=ir(e),n=t?s.find(o=>o.messageId===t):void 0,r=s.length>0?s[s.length-1]:void 0;return n??r},Pm=({thread:e,isOpen:t=!1,mailboxId:s,accountId:n,onAfterOptimisticRemove:r})=>{const o=s??e?.mailboxId,i=n??e?.accountId,{accountId:c}=Ps(i?void 0:o),d=i??c,b=hf(),{deleteMessages:g}=Os({mailboxId:o??"",threadId:e?.threadId,accountId:d,onAfterOptimisticRemove:r}),{moveMessages:v}=Gt({mailboxId:o??"",threadId:e?.threadId,accountId:d,onAfterOptimisticRemove:r}),p=ir(t?e?.threadId:void 0),f=p.find(y=>y.messageId===e?.messageId)?.hasStars??e?.hasStars,{toggleStar:u}=Qa({threadId:e?.threadId??"",mailboxId:o??"",messages:p}),m=l.useCallback(()=>{e&&g(b(e))},[e,b,g]),h=l.useCallback(y=>{e&&v(b(e),y)},[e,b,v]),S=l.useCallback(()=>{e&&u(e.messageId,f??!1)},[e,f,u]);return{mailboxId:o,accountId:d,isStarred:f,deleteThread:m,moveThread:h,toggleStar:S}},On=(e,t,s)=>{if(!t)return null;const n=e.indexOf(t);if(n===-1)return null;const r=s==="next"?n+1:n-1;return r<0||r>=e.length?null:e[r]},Dm=()=>{const[e,t]=l.useState(void 0),[s,n]=l.useState([]),[r,o]=l.useState([]),i=l.useRef(null),[c,d]=l.useState(!1),b=l.useCallback(g=>{t(g.focusedMessageId),n(g.selectedIds),g.orderedIds&&o(g.orderedIds),d(g.hasList)},[]);return{listCommandsRef:i,onTriageContextChange:b,focusedMessageId:e,selectedIds:s,orderedIds:r,hasList:c}},Fm=({context:e,orderedIds:t,selectedMessageId:s,enabled:n=!0,onClose:r,handlers:o,hasOpenThread:i=!1})=>{const{listCommandsRef:c,hasList:d}=e,b=l.useCallback(()=>{c.current?.clearSelection()||s&&r()},[c,s,r]),{reply:g,replyAll:v,forward:p,...x}=o;return Oo({enabled:n,handlers:{...d?{focusNext:()=>c.current?.focusNext(),focusPrevious:()=>c.current?.focusPrevious(),focusFirst:()=>c.current?.focusFirst(),focusLast:()=>c.current?.focusLast(),openFocused:()=>c.current?.openFocused(),toggleSelect:()=>c.current?.toggleSelect(),extendSelectDown:()=>c.current?.extendSelectDown(),extendSelectUp:()=>c.current?.extendSelectUp(),selectAll:()=>c.current?.selectAll(),toggleDensity:()=>c.current?.toggleDensity()}:{},back:b,...x,...i?{}:{reply:g,replyAll:v,forward:p}}}),{goBack:b,nextMessageId:On(t,s,"next")??void 0,previousMessageId:On(t,s,"previous")??void 0}},bf={sender:"sender",recipient:"recipient",subject:"subject",attachment:"attachment",body:"body",entities:"entities"};function xf(e){return bf[e]??e}function Om(e,t){const{folder:s}=Ns(t,[e.mailboxId]);return{id:e.messageId,sender:e.fromName??e.fromEmail??"Unknown",...e.fromEmail?{senderEmail:e.fromEmail}:{},subject:e.subject??"(No subject)",snippet:e.snippet??"",date:Ze(e.sentDate),unread:!e.isRead,flagged:e.hasStars===!0,threadId:e.threadId,mailboxId:e.mailboxId,...s?{folder:s}:{}}}function zm(e,t){const{folder:s}=Ns(t,e.mailboxId?[e.mailboxId]:[]);return{id:e.id,sender:e.fromName,...e.fromEmail?{senderEmail:e.fromEmail}:{},subject:e.subject,snippet:e.snippet,date:e.timeLabel,unread:!e.isRead,flagged:e.starred===!0,...e.threadId?{threadId:e.threadId}:{},...e.mailboxId?{mailboxId:e.mailboxId}:{},...s?{folder:s}:{}}}function vf(e,t){const{mailboxId:s,folder:n}=Ns(t,e.mailboxIds);return{id:e.messageId,sender:e.fromName??"Unknown",subject:e.subject??"(No subject)",snippet:"",date:e.sentDate!=null?Ze(e.sentDate*1e3):"",threadId:e.threadId,matchedChunkLabel:xf(e.matchedChunkType),score:e.score,...s?{mailboxId:s}:{},...n?{folder:n}:{}}}function _m(e,t,s){const n=new Set(t),r=[];for(const o of[...e].sort((i,c)=>c.score-i.score))n.has(o.threadId)||(n.add(o.threadId),r.push(vf(o,s)));return r}function Um(e){const t=e.authenticity?.dkimMismatch===!0;return{id:e.messageId,accountId:e.accountId,mailboxId:e.mailboxId,threadId:e.threadId,fromName:e.fromName??e.fromEmail??"Unknown",fromEmail:e.fromEmail??"",subject:e.subject??"(No subject)",snippet:e.snippet??"",timeLabel:Ze(e.sentDate),sentDate:e.sentDate,isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:Ha(e.category),suspicious:t}}function Bm(e){return e.filter(t=>t.muted!==!0)}function Km(e,t){const s=new Set,n=[];for(const r of[...e,...t])s.has(r.id)||(s.add(r.id),n.push(r));return n.sort((r,o)=>(o.sentDate??0)-(r.sentDate??0))}const zn=[{id:"personal",label:"Personal",category:ke.personal},{id:"transactional",label:"Transactional",category:ke.transactional},{id:"newsletter",label:"Newsletter",category:ke.newsletter},{id:"marketing",label:"Marketing",category:ke.marketing},{id:"social",label:"Social",category:ke.social},{id:"automated",label:"Automated",category:ke.automated},{id:"uncategorized",label:"Unclassified",category:ke.uncategorized}];function qm(e){const t=new Map(zn.map(n=>[n.category,[]]));for(const n of e){const r=n.category??ke.uncategorized;(t.get(r)??t.get(ke.uncategorized))?.push(n)}const s=[];for(const n of zn){const r=t.get(n.category);r&&r.length>0&&s.push({id:n.id,label:n.label,threads:r})}return s}function Qm(e,t){return e.fromName.toLowerCase().includes(t)||e.fromEmail.toLowerCase().includes(t)||e.subject.toLowerCase().includes(t)||e.snippet.toLowerCase().includes(t)}function Hm(e,t){return t.every(s=>{switch(s.type){case"from":{const n=s.value.toLowerCase();return e.fromEmail.toLowerCase().includes(n)||e.fromName.toLowerCase().includes(n)}case"subject":return e.subject.toLowerCase().includes(s.value.toLowerCase());case"category":return(e.category??"uncategorized")===s.category;case"hasAttachment":return e.hasAttachment===!0;case"isUnread":return!e.isRead;case"isRead":return e.isRead===!0;case"isStarred":return e.starred===!0;case"after":return e.sentDate!=null&&e.sentDate>=s.epochSeconds*1e3;case"before":return e.sentDate!=null&&e.sentDate<s.epochSeconds*1e3;case"in":return e.mailboxId===s.mailboxId;case"account":return e.accountId===s.accountId;default:return!1}})}const lr=8;function Us(e,t){const s=Math.max(0,Math.min(t,e.length)),n=Xo(e).find(o=>s>=o.start&&s<=o.end);if(!n)return{start:s,end:s,raw:""};const r=Zo(n.raw);return r?{start:n.start,end:n.end,raw:n.raw,name:r.name,value:r.value}:{start:n.start,end:n.end,raw:n.raw}}function yf(e,t){const s=Us(e,t);if(s.name===void 0)return{kind:"token",query:s.raw};const n=ia(s.name);if(n)return{kind:"value",token:n.name,source:n.values,query:s.value??""}}const kf={mailbox:"mailboxes",account:"accounts",contact:"contacts"},wf=(e,t)=>{if(e.values==="fixed")return e.options??[];const s=kf[e.values];return s?t[s]??[]:[]},jf=(e,t)=>{if(t==="")return 1;const s=e.toLowerCase();return s.startsWith(t)?0:s.includes(t)?1:-1},xs=(e,...t)=>{let s=-1;for(const n of t){if(n===void 0)continue;const r=jf(n,e);r<0||(s<0||r<s)&&(s=r)}return s},cr=e=>{const t=new Set;return e.filter(s=>s.rank>=0).sort((s,n)=>s.rank-n.rank).filter(s=>{const n=s.suggestion.value.toLowerCase();return t.has(n)?!1:(t.add(n),!0)}).slice(0,lr).map(s=>s.suggestion)},_n=e=>({value:`${e.name}:`,label:`${e.name}:`,hint:e.label});function Cf(e){const t=e.trim().toLowerCase();if(t==="")return tn.map(_n);const s=[];for(const n of tn)if(s.push({rank:xs(t,`${n.name}:`,n.label),suggestion:_n(n)}),n.values==="fixed")for(const r of n.options??[]){const o=la(n.name,r.value);s.push({rank:xs(t,o,r.label),suggestion:{value:o,label:r.label??o,hint:o}})}return cr(s)}function Sf(e,t,s){const n=t.trim().toLowerCase(),r=wf(e,s).map(o=>({rank:xs(n,o.value,o.label),suggestion:{value:la(e.name,o.value),label:o.label??o.value,...o.hint?{hint:o.hint}:{}}}));return cr(r)}function Nf(e,t,s={}){const n=Us(e,t);if(n.name===void 0)return Cf(n.raw);const r=ia(n.name);return r?Sf(r,n.value??"",s):[]}function Tf(e,t,s){const n=Us(e,t),r=!s.value.endsWith(":"),o=/\s/.test(e.slice(n.end,n.end+1)),i=r&&!o?`${s.value} `:s.value;return{query:e.slice(0,n.start)+i+e.slice(n.end),cursor:n.start+i.length+(r&&o?1:0)}}const If=e=>({value:e.normalizedEmail,...e.displayName?{label:e.displayName,hint:e.normalizedEmail}:{}}),Ef=250,Rf=2;function Mf({query:e,cursor:t,enabled:s}){const{accounts:n}=Ut(),{mailboxesByName:r}=ca(),o=r!==void 0,i=s?yf(e,t):void 0,c=i?.source==="contact"?i.query.trim():"",d=fa(c,Ef),{data:b}=ee({...Ss({query:{q:d,limit:lr}}),enabled:d.length>=Rf}),g=Ts({queries:n.map(f=>({...xt({path:{accountId:f.accountId}}),staleTime:1/0}))}),v=l.useMemo(()=>o?zo(g.map(f=>f.data?.items??[]),n):[],[o,g,n]),p=l.useMemo(()=>_o(n),[n]),x=l.useMemo(()=>(b?.items??[]).map(If),[b]);return l.useMemo(()=>{if(!s)return[];const f=Nf(e,t,{mailboxes:v,accounts:p,contacts:x});return o?f:f.filter(u=>u.value!=="in:")},[s,e,t,v,p,x,o])}const dr="remit.recentSearches",Af=5;function vs(){try{const e=localStorage.getItem(dr);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.filter(s=>typeof s=="string"):[]}catch{return[]}}function Un(e){const t=e.trim();if(!t)return vs();const s=[t,...vs().filter(n=>n!==t)].slice(0,Af);try{localStorage.setItem(dr,JSON.stringify(s))}catch{return s}return s}const $f=e=>e.tier!=="phone"&&e.hasLiveInput&&!(e.bodyRendersCommittedResults&&e.hasCommittedQuery);function Lf(e){const{spam:t}=Da([...e]),s=new Map;for(const r of t)r.mailboxId&&s.set(r.mailboxId,(s.get(r.mailboxId)??0)+1);let n;for(const[r,o]of s)(!n||o>n.count)&&(n={mailboxId:r,count:o});return n}function Gm({title:e,unreadCount:t,children:s,selectionBar:n,paneOverlay:r,footer:o,searchFilter:i,searchResults:c,searchLoading:d,relatedResults:b,relatedLoading:g,onSelectSearchResult:v,searchResultsLabel:p="Top matches",relatedResultsLabel:x="Related",searchResultsInBody:f=!1,refreshControl:u}){const{accounts:m,resultFolderIndex:h,searchQuery:S,searchInput:y,onSearchChange:w,onSearchClear:N,searchViewKey:E}=Ut(),P=ca(),z=ui(),U=sa(),L=fi(),[D,F]=l.useState(!1),[O,k]=l.useState(vs),I=Co(),R=l.useRef(E);l.useEffect(()=>{R.current!==E&&(R.current=E,F(!1))},[E]);const[j,M]=l.useState(0),[C,K]=l.useState(!1),[$,H]=l.useState(void 0),Y=Mf({query:y,cursor:j,enabled:C&&y.trim().length>0}),X=l.useCallback(oe=>{const ye=Tf(y,j,oe);w(ye.query),H({cursor:ye.cursor})},[y,j,w]),se=So({count:Y.length,onAccept:oe=>{const ye=Y[oe];ye&&X(ye)}}),{comboboxProps:le,handleKeyDown:pe}=se,te=l.useMemo(()=>({comboboxProps:le,onKeyDown:pe,onCaretChange:M,onFocusChange:K,...$?{caret:$}:{}}),[le,pe,$]),he=se.open?a.jsx(Eo,{id:se.listId,suggestions:Y,activeIndex:se.activeIndex,optionId:se.optionId,onPick:X,onHighlight:se.setActiveIndex,label:"Search suggestions",className:"mx-row-inset mt-1 shrink-0"}):null,ce=y.trim().length>0,{mailboxesByName:ge,accountsByName:ue}=P,q=l.useMemo(()=>ei(y,{mailboxesByName:ge,accountsByName:ue}),[y,ge,ue]),ae=q.tokens.map(oe=>({label:oa(oe),onRemove:()=>w(ti(y,oe))})),B=c??[],Q=b??[],ne=ce?[{id:"top",label:p,results:B},{id:"related",label:x,results:Q}]:[],tt=!(B.length+Q.length>0)&&(d===!0||g===!0),{scope:Vt}=Uo(m),st=No(),nt=Si(st),at=Ni(st,Vt,nt?h.get(nt)?.role:void 0),G=at.kind==="global"?Lf([...B,...Q]):void 0,St=G?{kind:"global",onScopeToSpam:()=>z(G.mailboxId,S)}:at,fe=Q.length>0,ve=l.useMemo(()=>Uu(q,{searchHadSemanticReach:fe}),[q,fe]),Ue=ce?ve:void 0,Be=ce?{onClick:()=>{F(!1),I("properties","search")},blockedReason:Cc(ve)?void 0:To(ve.droppedFacets.map(oe=>oe.label))}:void 0,re=Be?a.jsx(Fa,{...Be}):null,J=$f({tier:L,hasLiveInput:ce,hasCommittedQuery:S.trim().length>0,bodyRendersCommittedResults:f}),$e=oe=>{k(Un(y)),v?.(oe)},Bs=a.jsx(Oa,{value:y,sections:ne,loading:tt,onSelectResult:$e,tokens:ae,scope:St}),Ce=n===void 0,Le=J?a.jsx("div",{className:"h-full overflow-y-auto",children:Bs}):null,Wt=Le&&!Ce?Le:s,Ke=Le&&Ce?Le:null,Se=mi(L),rt=Se&&(D||ce),ot=l.useMemo(()=>({title:e,searchResults:Ke,makeFilterSlot:re,searchConversion:Ue,navSlot:U&&!U.showNavPane&&a.jsx(V,{variant:"ghost",size:"touch",icon:a.jsx(Ti,{className:"size-5"}),onClick:()=>U.openNav(),"aria-label":"Menu",className:"-ml-2 shrink-0"}),titleMeta:a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle",children:[t.toLocaleString()," unread"]}),a.jsx(en,{}),u]}),searchSlot:Se&&!rt&&a.jsx(V,{variant:"ghost",size:"touch",icon:a.jsx(Io,{className:"size-5"}),onClick:()=>F(!0),"aria-label":"Search",className:"shrink-0"}),searchField:rt&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"min-w-0 flex-1",children:a.jsx(na,{value:y,onChange:w,onClear:N,globalFocusKey:!1,showClearButton:!1,suggest:te})}),a.jsx(V,{variant:"ghost",size:"touch",icon:a.jsx(Dt,{className:"size-5"}),onClick:()=>{N(),F(!1)},"aria-label":"Close search",className:"shrink-0"}),a.jsx(en,{})]})}),[e,t,U,Se,rt,y,w,N,te,Ke,re,Ue,u]);if(L==="phone"&&D){const oe=ye=>{k(Un(y)),F(!1),v?.(ye)};return a.jsxs(bs.Provider,{value:ot,children:[a.jsx(Yl,{value:y,onChange:w,onClear:N,onCancel:()=>{F(!1),N()},filter:i,recentSearches:O,onPickRecent:w,makeFilter:Be,sections:ne,loading:tt,onSelectResult:oe,tokens:ae,scope:St,suggest:te,suggestList:he}),r]})}return a.jsx(bs.Provider,{value:ot,children:a.jsxs("section",{className:"relative flex h-full w-full flex-col bg-surface",children:[n?.(ot),he,a.jsx("div",{className:"min-h-0 flex-1",children:Wt}),o,r]})})}export{bm as $,km as A,Yc as B,Ul as C,yu as D,xm as E,Um as F,Hm as G,Ps as H,gm as I,Lm as J,Os as K,Gt as L,Rm as M,Dm as N,Pm as O,pm as P,mm as Q,hf as R,Jl as S,Qa as T,Bd as U,qd as V,Hd as W,Qd as X,Fm as Y,pf as Z,$m as _,El as a,wm as a0,Zd as a1,Am as a2,Mm as a3,dm as a4,hm as a5,Om as a6,_m as a7,$l as a8,jt as a9,Ms as aa,ms as ab,im as ac,lm as ad,om as ae,Gm as af,Ds as ag,gt as ah,Bm as ai,Km as aj,Qm as ak,zm as al,Da as am,Lf as an,qm as ao,cm as ap,$f as aq,Ql as ar,Im as as,tf as at,um as au,Em as av,nr as b,As as c,fm as d,Ga as e,eu as f,Tl as g,mu as h,hu as i,Nm as j,ou as k,Ic as l,jm as m,Nl as n,Cm as o,xu as p,Tm as q,Sm as r,wl as s,Ha as t,of as u,bu as v,Wc as w,Va as x,vm as y,ym as z};
@@ -1,2 +0,0 @@
1
- import{j as e,X as G,aA as X,t as m,r as j,f as I,a2 as H,c as J,ed as ee,s as se,_ as te}from"./index-6e6pvyaQ.js";import{u as ne,t as ae,C as re,d as ie,p as le}from"./CalendarComposePane-D6oYPLg8.js";import{c as oe,R as ce,u as de,i as xe,d as me,f as fe,U as ue}from"./useCalendars-T2P2WC-i.js";import{A as he}from"./avatar-CqkxkswH.js";import{M as pe}from"./minus-of4tlDqs.js";import{C as _}from"./clock-CdKU6IY6.js";import{G as U,M as ge,c as ve}from"./useCalendarData-gwYD8mQr.js";import{M as be}from"./mail-DPzNtmsN.js";import{P as je}from"./pencil-DFGsLvM-.js";import{C as Ne}from"./calendar-days-DpqXNRgw.js";const q={accepted:"Coming",tentative:"Maybe",declined:"Not coming",noReply:"No reply"},we={accepted:"text-positive",tentative:"text-warning",declined:"text-danger",noReply:"text-fg-subtle"},ye={accepted:X,tentative:_,declined:G,noReply:pe};function K({rsvp:s,className:t}){const a=ye[s];return e.jsxs("span",{className:m("inline-flex items-center gap-1 text-2xs font-medium",we[s],t),children:[e.jsx(a,{className:"size-3"}),q[s]]})}function Ce({attendee:s,active:t=!1,onActivate:a,contextId:n,touch:i=!1,className:o}){const x=e.jsxs(e.Fragment,{children:[e.jsx(he,{name:s.name,email:s.email,size:"sm"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-sm text-fg",children:s.name}),s.role==="organizer"&&e.jsx("span",{className:"block text-2xs text-fg-subtle",children:"Organiser"})]}),e.jsx(K,{rsvp:s.rsvp})]});return a?e.jsx("button",{type:"button","aria-expanded":t,"aria-controls":t&&n!==void 0?n:void 0,onClick:()=>a(t?"":s.email),onKeyDown:d=>{d.key==="Escape"&&a("")},onBlur:d=>{t&&d.relatedTarget!==null&&(d.currentTarget.parentElement?.contains(d.relatedTarget)||a(""))},className:m("flex w-full items-center gap-2.5 rounded-md px-1.5 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",i?"min-h-11":"min-h-9",t?"bg-accent-2-soft":"hover:bg-surface-sunken",o),children:x}):e.jsx("div",{className:m("flex min-h-9 items-center gap-2.5",o),children:x})}function ke({attendees:s,activeEmail:t="",onActivate:a,renderContext:n,touch:i=!1,className:o}){const x=j.useId();if(s.length===0)return null;const d=["accepted","tentative","declined","noReply"].map(l=>({state:l,count:s.filter(h=>h.rsvp===l).length})).filter(l=>l.count>0).map(l=>`${l.count} ${q[l.state].toLowerCase()}`).join(" · ");return e.jsxs("div",{className:m("flex flex-col",o),children:[e.jsx("p",{className:"pb-1 text-2xs uppercase tracking-wider text-fg-subtle",children:`${s.length} guests · ${d}`}),s.map((l,h)=>{const g=l.email===t,v=`${x}-guest-${h}`,r=e.jsx(Ce,{attendee:l,active:g,onActivate:a,contextId:n?v:void 0,touch:i});return a?e.jsxs("div",{children:[r,g&&n&&e.jsx("div",{id:v,className:"py-1",children:n(l)})]},l.email):e.jsx(j.Fragment,{children:r},l.email)})]})}function y({icon:s,children:t}){return e.jsxs("div",{className:"flex items-start gap-2.5 py-1",children:[e.jsx("span",{className:"mt-0.5 shrink-0 text-fg-subtle",children:s}),e.jsx("div",{className:"min-w-0 flex-1 text-sm text-fg",children:t})]})}function Ee({event:s,calendar:t,whenText:a,onEdit:n,onDelete:i,onOpenThread:o,onClose:x,activeAttendee:d="",onActivateAttendee:l,renderAttendeeContext:h,touch:g=!1,chrome:v="header",className:r}){const R=oe(t.color),f=e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-xl font-semibold text-fg",children:s.title}),e.jsxs("div",{className:"mt-3 flex flex-col border-b border-line pb-3",children:[e.jsx(y,{icon:e.jsx(_,{className:"size-4"}),children:e.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[a,s.attendees.length>0&&e.jsx(K,{rsvp:s.myRsvp})]})}),s.zoneCertainty==="ambiguous"?e.jsx(y,{icon:e.jsx(U,{className:"size-4 text-warning"}),children:e.jsx("span",{className:"text-warning",children:"The mail said a time but never a zone. Shown in your own; confirm before you travel for it."})}):s.timeZone!==""&&e.jsx(y,{icon:e.jsx(U,{className:"size-4"}),children:s.timeZone}),s.recurrenceRule!==""&&e.jsx(y,{icon:e.jsx(ce,{className:"size-4"}),children:e.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[s.recurrenceRule,s.seriesException&&e.jsx("span",{className:"rounded-xs bg-warning-soft px-1.5 py-0.5 text-2xs text-warning",children:"Moved out of the series"})]})}),s.location!==""&&e.jsx(y,{icon:e.jsx(ge,{className:"size-4"}),children:s.location})]}),s.threadId!==""&&o&&e.jsxs("button",{type:"button",onClick:o,className:"mt-3 flex w-full items-center gap-2.5 rounded-md border border-line bg-surface-sunken px-3 py-2 text-left outline-none hover:border-line-strong focus-visible:ring-2 focus-visible:ring-ring",children:[e.jsx(be,{className:"size-4 shrink-0 text-accent-2"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block text-2xs uppercase tracking-wider text-fg-subtle",children:"From this thread"}),e.jsx("span",{className:"block truncate text-sm text-fg",children:s.threadSubject})]})]}),s.attendees.length>0&&e.jsx(ke,{attendees:s.attendees,activeEmail:d,onActivate:l,renderContext:h,touch:g,className:"mt-3"}),s.notes!==""&&e.jsx("p",{className:"mt-3 whitespace-pre-wrap text-sm text-fg-muted",children:s.notes})]});return v==="bare"?e.jsx("div",{className:m("flex flex-col",r),children:f}):e.jsxs("article",{className:m("flex h-full w-full flex-col bg-surface",r),children:[e.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[e.jsx("span",{className:m("size-2.5 shrink-0 rounded-full",R.solid)}),e.jsxs("span",{className:"min-w-0 flex-1 truncate text-xs text-fg-muted",children:[t.name," · ",t.accountLabel]}),n&&e.jsx(I,{variant:"ghost",size:"sm",icon:e.jsx(je,{className:"size-3.5"}),onClick:n,children:"Edit"}),i&&e.jsx(I,{variant:"ghost",size:"sm",icon:e.jsx(H,{className:"size-3.5"}),onClick:i,className:"text-danger",children:"Delete"}),x&&e.jsx("button",{type:"button","aria-label":"Close event",onClick:x,className:"flex size-7 items-center justify-center rounded-md text-fg-subtle outline-none hover:bg-surface-sunken hover:text-fg focus-visible:ring-2 focus-visible:ring-ring",children:e.jsx(G,{className:"size-4"})})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-row-inset py-3",children:f})]})}const De=[{scope:"this",label:"This event",note:"Leaves the rest of the series alone"},{scope:"following",label:"This and everything after",note:"Splits the series here"},{scope:"all",label:"The whole series",note:"Rewrites the rule itself"}];function Re({title:s,ruleText:t,instanceText:a,onChoose:n,onCancel:i,touch:o,className:x}){return e.jsxs("div",{className:m("flex flex-col gap-3",x),children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-md font-semibold text-fg",children:[s," repeats"]}),e.jsx("p",{className:"text-xs text-fg-muted",children:t}),e.jsxs("p",{className:"text-xs text-fg-subtle",children:["You clicked ",a,"."]})]}),e.jsx("p",{className:"text-sm text-fg",children:"What should the change apply to?"}),e.jsx("div",{className:"flex flex-col gap-1.5",children:De.map(d=>e.jsxs("button",{type:"button",onClick:()=>n(d.scope),className:m("flex flex-col rounded-md border border-line bg-surface px-3 py-2 text-left outline-none transition-colors hover:border-line-strong hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring",o&&"min-h-11 justify-center"),children:[e.jsx("span",{className:"text-sm font-medium text-fg",children:d.label}),e.jsx("span",{className:"text-2xs text-fg-subtle",children:d.note})]},d.scope))}),e.jsx(I,{variant:"ghost",size:o?"md":"sm",onClick:i,className:m("self-start",o&&"min-h-11"),children:"Cancel"})]})}const Te=s=>s.replace(/\r?\n[ \t]/g,""),Z=s=>s.replace(/\\n/gi,`
2
- `).replace(/\\,/g,",").replace(/\\;/g,";").replace(/\\\\/g,"\\");function ze(s,t){let a=!1;for(let n=t.length;n<s.length;n+=1){const i=s[n];if(n===t.length&&i!==";"&&i!==":")return;if(i==='"'){a=!a;continue}if(!a&&i===":")return s.slice(n+1).trim()}}function S(s,t){for(const a of Te(s).split(/\r?\n/)){if(!a.startsWith(t))continue;const n=ze(a,t);if(n!==void 0)return n}return""}const Ie=s=>S(s,"RRULE"),Se=s=>({location:Z(S(s,"LOCATION")),description:Z(S(s,"DESCRIPTION"))}),$e=se(404);function Le(s,t){const{data:a,isLoading:n,error:i,refetch:o}=J({...ee({path:{calendarObjectId:s},query:{calendarId:t}}),meta:$e,enabled:s!==""&&t!==""});return{resource:a,isLoading:n,error:i,refetch:()=>{o()}}}const z=new Intl.DateTimeFormat(void 0,{weekday:"short",day:"numeric",month:"long"}),D=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1});function Y(s){const t=new Date(s.start),a=new Date(s.end),n=z.format(t);return s.allDay?`${n}, all day`:z.format(a)===n?`${n}, ${D.format(t)} – ${D.format(a)}`:`${n}, ${D.format(t)} – ${z.format(a)}, ${D.format(a)}`}function Ae({event:s,calendar:t,isOccurrence:a,problem:n="",onEdit:i,onDelete:o,onClose:x}){return!s||!t?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 bg-surface p-8 text-center",children:[e.jsx(Ne,{className:"size-8 text-fg-subtle","aria-hidden":"true"}),e.jsx("p",{className:"text-sm font-medium text-fg",children:"That event isn't on this week"}),e.jsx("p",{className:"max-w-xs text-sm text-fg-muted",children:"The address names an event the calendar doesn't have here."}),e.jsx("button",{type:"button",onClick:x,className:"rounded-md border border-line px-2.5 py-1 text-sm font-medium text-fg outline-none hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring",children:"Back to the calendar"})]}):e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-surface",children:[a&&e.jsx("p",{className:"shrink-0 border-b border-line bg-surface-sunken px-row-inset py-1.5 text-2xs uppercase tracking-wider text-fg-subtle",children:"One occurrence of a repeating event"}),n!==""&&e.jsxs("div",{role:"alert",className:"flex shrink-0 items-start gap-2 border-b border-danger/40 bg-danger-soft px-row-inset py-2 text-sm",children:[e.jsx(te,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":"true"}),e.jsx("p",{className:"min-w-0 flex-1 break-words text-fg",children:n})]}),e.jsx(Ee,{event:s,calendar:t,whenText:Y(s),onEdit:i,onDelete:o,onClose:x,className:"min-h-0 flex-1"})]})}const Fe="This event changed somewhere else — over CalDAV, or in another tab. Nothing was saved. Close it and open it again to see the version that's stored now.";function Ke({calendarObjectId:s,recurrenceId:t}){const{view:a,date:n,calendarIds:i}=de(),{events:o}=ve({view:a,date:n,calendarIds:i}),{calendars:x,timeZoneByCalendarId:d}=xe(),{closeEvent:l}=me(),{updateEvent:h,deleteEvent:g,isWriting:v}=ne(),r=o.find(c=>c.id===fe(s,t??"")),R=x.find(c=>c.id===r?.calendarId),{resource:f}=Le(s,r?.calendarId??""),[$,N]=j.useState(void 0),[p,T]=j.useState(void 0),[b,C]=j.useState(void 0),[L,w]=j.useState(""),k=f?Se(f.icalData):void 0,A=f?Ie(f.icalData):"",Q=r&&!r.allDay?r.start.slice(11,16):"",E=A===""?"":ae(A,Q)??"Repeats",F=r!==void 0&&r.seriesId!==""&&t!==void 0&&t!=="",O=r!==void 0&&f!==void 0,M=(c,u)=>{if(c.kind==="written"){w(""),u();return}w(c.kind==="conflict"?Fe:c.message)},P=c=>({calendarObjectId:s,calendarId:r?.calendarId??"",recurrenceId:t??"",scope:c,etag:f?.etag??""}),B=c=>{if(!r)return;const u=ie(r,{repeat:E,location:k?.location??"",notes:k?.description??""});N(void 0),T({before:u,scope:c}),C(u),w("")},W=c=>{N(void 0),g(P(c)).then(u=>M(u,l))},V=()=>{if(!p||!b)return;const c=le(p.before,b,d[b.calendarId]??ue);if(!c.ok){w(c.problem);return}h(P(p.scope),c.patch).then(u=>M(u,()=>{T(void 0),C(void 0)}))};return $!==void 0&&r?e.jsx("div",{className:"flex h-full flex-col justify-center bg-surface px-row-inset",children:e.jsx(Re,{className:"mx-auto w-full max-w-md",title:r.title,ruleText:E===""?"It repeats":E,instanceText:Y(r),onChoose:$==="edit"?B:W,onCancel:()=>N(void 0)})}):p&&b?e.jsx(re,{title:"Edit event",subtitle:p.scope==="this"?"This occurrence only":b.date,calendars:x,draft:b,onChange:C,problem:L,saveLabel:"Save",isSaving:v,repeatEditable:p.scope===void 0||p.scope==="all",calendarEditable:!1,onSave:V,onCancel:()=>{T(void 0),C(void 0),w("")}}):e.jsx(Ae,{event:r&&{...r,location:k?.location??"",notes:k?.description??"",recurrenceRule:E},calendar:R,isOccurrence:t!==void 0,problem:L,onEdit:O?()=>F?N("edit"):B(void 0):void 0,onDelete:O?()=>F?N("delete"):W(void 0):void 0,onClose:l})}export{Ke as O};
@@ -1 +0,0 @@
1
- import{O as o}from"./index-6e6pvyaQ.js";const n=o;export{n as component};
@@ -1 +0,0 @@
1
- import{ai as m,j as o,O as p}from"./index-6e6pvyaQ.js";import{a}from"./MailShell-CTZPp0Re.js";import{M as r}from"./MailboxPane-FCYdo4UF.js";import{d as e}from"./search-token-index-PUrvPC5c.js";import{u as s}from"./search-mirror-jo7pXQAU.js";import"./FullCompose-d06QLAHp.js";import"./ErrorState-BTKMU75C.js";import"./index-DgEAInjF.js";import"./useMessageBodyContent-C_a1YUsw.js";import"./useSignature-CK6IfoD-.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-CMSCN4-w.js";import"./sections-BjISOtZ0.js";import"./format-D7BNbMxD.js";import"./confirm-dialog-LUxfOOQz.js";import"./useSearchTokenContext-BA6iRf3_.js";import"./kbd-DImnxOni.js";import"./search-scope-B5-OK3Cq.js";import"./useRefreshControl-jZsIHsQQ.js";import"./circle-check-big-BNnaBoH4.js";import"./useQueries-vQUSXdj9.js";import"./MailListHeader-hyJQ5XSq.js";import"./attachment-file-oJZ9yins.js";import"./mail-DPzNtmsN.js";import"./avatar-CqkxkswH.js";import"./EmptyState-DvQRX_aF.js";import"./download-ztZlV0rg.js";import"./useLayoutTier-Dt8oqQrp.js";import"./shield-check-BhkZhdgI.js";import"./useFilters-C6fHNH70.js";import"./minus-of4tlDqs.js";import"./clock-CdKU6IY6.js";import"./menu-Cie-OPPc.js";import"./MailViewChrome-D6dp5o8D.js";import"./NavMenuButton-BBgEotre.js";import"./useLabels-Bxx6k_V0.js";import"./useSemanticSearch-IhTOP1CS.js";import"./search-query-Cr_ZXBCp.js";import"./bottom-sheet-fs9OBYtF.js";import"./circle-help-CowAqERz.js";import"./circle-check-DPOAEaWy.js";function X(){const{mailboxId:t}=m.useParams(),i=e();return s({to:"/mail/$mailboxId",params:{mailboxId:t}}),o.jsx(r,{mailboxId:t,thread:i,children:o.jsx(a,{phone:o.jsx(r.Phone,{}),list:o.jsx(r.List,{}),reading:o.jsx(p,{}),intelligence:o.jsx(r.Intelligence,{}),hasThread:!!i})})}export{X as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-6e6pvyaQ.js";import{F as r}from"./FlaggedPane-ByJlETic.js";import"./useSearchTokenContext-BA6iRf3_.js";import"./kbd-DImnxOni.js";import"./useMessageBodyContent-C_a1YUsw.js";import"./search-scope-B5-OK3Cq.js";import"./MailListHeader-hyJQ5XSq.js";import"./search-token-index-PUrvPC5c.js";import"./useLayoutTier-Dt8oqQrp.js";import"./useQueries-vQUSXdj9.js";import"./attachment-file-oJZ9yins.js";import"./mail-DPzNtmsN.js";import"./avatar-CqkxkswH.js";import"./index-DgEAInjF.js";import"./useSignature-CK6IfoD-.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-CMSCN4-w.js";import"./sections-BjISOtZ0.js";import"./format-D7BNbMxD.js";import"./EmptyState-DvQRX_aF.js";import"./ErrorState-BTKMU75C.js";import"./download-ztZlV0rg.js";import"./shield-check-BhkZhdgI.js";import"./useFilters-C6fHNH70.js";import"./minus-of4tlDqs.js";import"./confirm-dialog-LUxfOOQz.js";import"./clock-CdKU6IY6.js";import"./menu-Cie-OPPc.js";import"./MailViewChrome-D6dp5o8D.js";import"./wizard-selection-B1bng5Jq.js";function B(){return o.jsx(r.Reading,{})}export{B as component};
@@ -1 +0,0 @@
1
- import{j as r}from"./index-6e6pvyaQ.js";import{B as o}from"./BriefPane-CKtXwVBp.js";import"./useSearchTokenContext-BA6iRf3_.js";import"./kbd-DImnxOni.js";import"./useMessageBodyContent-C_a1YUsw.js";import"./search-scope-B5-OK3Cq.js";import"./MailListHeader-hyJQ5XSq.js";import"./search-token-index-PUrvPC5c.js";import"./useLayoutTier-Dt8oqQrp.js";import"./useQueries-vQUSXdj9.js";import"./attachment-file-oJZ9yins.js";import"./mail-DPzNtmsN.js";import"./avatar-CqkxkswH.js";import"./index-DgEAInjF.js";import"./useSignature-CK6IfoD-.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-CMSCN4-w.js";import"./sections-BjISOtZ0.js";import"./format-D7BNbMxD.js";import"./EmptyState-DvQRX_aF.js";import"./ErrorState-BTKMU75C.js";import"./download-ztZlV0rg.js";import"./shield-check-BhkZhdgI.js";import"./useFilters-C6fHNH70.js";import"./minus-of4tlDqs.js";import"./confirm-dialog-LUxfOOQz.js";import"./clock-CdKU6IY6.js";import"./menu-Cie-OPPc.js";import"./useRefreshControl-jZsIHsQQ.js";import"./circle-check-big-BNnaBoH4.js";import"./useLabels-Bxx6k_V0.js";import"./useSemanticSearch-IhTOP1CS.js";import"./search-query-Cr_ZXBCp.js";import"./wizard-selection-B1bng5Jq.js";function H(){return r.jsx(o.Reading,{})}export{H as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-6e6pvyaQ.js";import{M as r}from"./MailboxPane-FCYdo4UF.js";import"./useSearchTokenContext-BA6iRf3_.js";import"./kbd-DImnxOni.js";import"./useMessageBodyContent-C_a1YUsw.js";import"./search-scope-B5-OK3Cq.js";import"./useRefreshControl-jZsIHsQQ.js";import"./circle-check-big-BNnaBoH4.js";import"./search-token-index-PUrvPC5c.js";import"./useLayoutTier-Dt8oqQrp.js";import"./useQueries-vQUSXdj9.js";import"./MailListHeader-hyJQ5XSq.js";import"./attachment-file-oJZ9yins.js";import"./mail-DPzNtmsN.js";import"./avatar-CqkxkswH.js";import"./index-DgEAInjF.js";import"./useSignature-CK6IfoD-.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-CMSCN4-w.js";import"./sections-BjISOtZ0.js";import"./format-D7BNbMxD.js";import"./EmptyState-DvQRX_aF.js";import"./ErrorState-BTKMU75C.js";import"./download-ztZlV0rg.js";import"./shield-check-BhkZhdgI.js";import"./useFilters-C6fHNH70.js";import"./minus-of4tlDqs.js";import"./confirm-dialog-LUxfOOQz.js";import"./clock-CdKU6IY6.js";import"./menu-Cie-OPPc.js";import"./MailViewChrome-D6dp5o8D.js";import"./NavMenuButton-BBgEotre.js";import"./useLabels-Bxx6k_V0.js";import"./useSemanticSearch-IhTOP1CS.js";import"./search-query-Cr_ZXBCp.js";import"./bottom-sheet-fs9OBYtF.js";import"./circle-help-CowAqERz.js";import"./circle-check-DPOAEaWy.js";function L(){return o.jsx(r.Reading,{})}export{L as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-6e6pvyaQ.js";import{O as t}from"./OutboxPane-BMASiNu4.js";import"./useSearchTokenContext-BA6iRf3_.js";import"./kbd-DImnxOni.js";import"./useMessageBodyContent-C_a1YUsw.js";import"./search-scope-B5-OK3Cq.js";import"./circle-check-big-BNnaBoH4.js";import"./clock-CdKU6IY6.js";import"./row-actions-BeiZetAb.js";import"./rotate-ccw-DcEcrvaC.js";import"./NavMenuButton-BBgEotre.js";import"./menu-Cie-OPPc.js";import"./format-D7BNbMxD.js";import"./outbox-status-BlKn6P0x.js";import"./search-query-Cr_ZXBCp.js";function P(){return o.jsx(t.Reading,{})}export{P as component};
@@ -1 +0,0 @@
1
- import{ee as o,j as e}from"./index-6e6pvyaQ.js";import{O as m}from"./OpenCalendarEvent-Ga_JE-Ds.js";import"./CalendarComposePane-D6oYPLg8.js";import"./useCalendars-T2P2WC-i.js";import"./ErrorState-BTKMU75C.js";import"./avatar-CqkxkswH.js";import"./minus-of4tlDqs.js";import"./clock-CdKU6IY6.js";import"./useCalendarData-gwYD8mQr.js";import"./useQueries-vQUSXdj9.js";import"./mail-DPzNtmsN.js";import"./pencil-DFGsLvM-.js";import"./calendar-days-DpqXNRgw.js";function R(){const{calendarObjectId:r,recurrenceId:t}=o.useParams();return e.jsx(m,{calendarObjectId:r,recurrenceId:t})}export{R as component};
@@ -1 +0,0 @@
1
- import{O as o}from"./index-6e6pvyaQ.js";const n=o;export{n as component};
@@ -1 +0,0 @@
1
- import{O as o}from"./index-6e6pvyaQ.js";const n=o;export{n as component};
@@ -1 +0,0 @@
1
- import{O as o}from"./index-6e6pvyaQ.js";const n=o;export{n as component};