@remit/web-client-dist 0.0.430 → 0.0.431

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 (107) hide show
  1. package/assets/{BriefPane-CytP3J7O.js → BriefPane-B_43XrIX.js} +1 -1
  2. package/assets/{ErrorState-B_pp6XjY.js → ErrorState-D5cn-r_g.js} +1 -1
  3. package/assets/{FlaggedPane-BTGAqs21.js → FlaggedPane-BmNKHLJP.js} +1 -1
  4. package/assets/{FullCompose-D8BBZrtI.js → FullCompose-CTBUQaxT.js} +1 -1
  5. package/assets/{MailListHeader-BjsRsJYI.js → MailListHeader-DzjUH8L0.js} +1 -1
  6. package/assets/{MailShell-CvPQWjl1.js → MailShell-8jHD0muk.js} +1 -1
  7. package/assets/{MailViewChrome-ZN5UsScT.js → MailViewChrome-QVpYFxJf.js} +1 -1
  8. package/assets/{MailboxPane-Bca57rKs.js → MailboxPane-DacSDALK.js} +1 -1
  9. package/assets/{NavMenuButton-_aiK1QXb.js → NavMenuButton-C6jexGVY.js} +1 -1
  10. package/assets/{OnboardingWizard-BdBknD3m.js → OnboardingWizard-BLAdynjS.js} +1 -1
  11. package/assets/{OutboxPane-3nlNVjx6.js → OutboxPane-BWql0oaX.js} +1 -1
  12. package/assets/_mailboxId-jkUpvxl1.js +1 -0
  13. package/assets/_messageId-BVpg5Tz8.js +1 -0
  14. package/assets/_messageId-DChgNaxv.js +1 -0
  15. package/assets/_messageId-DCwFpPS8.js +1 -0
  16. package/assets/_outboxMessageId-BYSL9Fet.js +1 -0
  17. package/assets/_threadId-BRDhMSWj.js +1 -0
  18. package/assets/_threadId-CX4aUOdM.js +1 -0
  19. package/assets/_threadId-YwJI-X6V.js +1 -0
  20. package/assets/{accounts-Cji9zFqV.js → accounts-DjxACMQo.js} +1 -1
  21. package/assets/{advanced-BXCAioJN.js → advanced-jOMMCPwe.js} +1 -1
  22. package/assets/{appearance-Dg7qROVT.js → appearance-CJ03-RKV.js} +1 -1
  23. package/assets/{attachment-file-CLrI3kMw.js → attachment-file-C1JZr27N.js} +1 -1
  24. package/assets/{avatar-C8lpjlQO.js → avatar-DVEp71DP.js} +1 -1
  25. package/assets/{bottom-sheet-BuEgZWXh.js → bottom-sheet-RK-XvYz2.js} +1 -1
  26. package/assets/brief-BXf0e4LI.js +1 -0
  27. package/assets/{brief-Dt7lMB8R.js → brief-CyZkzbIP.js} +1 -1
  28. package/assets/{browser-ponyfill-g58jgFl_.js → browser-ponyfill-D2WuVPYo.js} +1 -1
  29. package/assets/{bug-CDU4oK_3.js → bug-DET_KgV6.js} +1 -1
  30. package/assets/{circle-check-BhMyR8BA.js → circle-check-B3vjKaD1.js} +1 -1
  31. package/assets/{circle-check-big-5NMrNFUI.js → circle-check-big-CTk0kr4F.js} +1 -1
  32. package/assets/{circle-help-BAup3nOG.js → circle-help-KBbSqlpB.js} +1 -1
  33. package/assets/{clock-DCdX5E4T.js → clock-sbv7ILkY.js} +1 -1
  34. package/assets/compose._-_outboxMessageId_-BDYHCPIg.js +1 -0
  35. package/assets/compose._-_outboxMessageId_-CLvF9Fqr.js +1 -0
  36. package/assets/compose._-_outboxMessageId_-D3NortXQ.js +1 -0
  37. package/assets/compose._-_outboxMessageId_-vZgnB5-N.js +1 -0
  38. package/assets/{confirm-dialog-BxXd7BDT.js → confirm-dialog-DoFwvjx5.js} +1 -1
  39. package/assets/{download-Br1uSntK.js → download-fhBgd0nR.js} +1 -1
  40. package/assets/{filters-snY8U8V2.js → filters-DYWqI6eB.js} +1 -1
  41. package/assets/{flagged-DBt5871J.js → flagged-3YyL4YcX.js} +1 -1
  42. package/assets/flagged-DAMA5iLe.js +1 -0
  43. package/assets/{folders-BzRKidwZ.js → folders-Doj5qCfC.js} +1 -1
  44. package/assets/{help-copy-D1mikTkH.js → help-copy-sfmab4Nc.js} +1 -1
  45. package/assets/{index-DX5RhVmh.js → index-04bqfNgp.js} +3 -3
  46. package/assets/index-Bp3jNjAb.js +1 -0
  47. package/assets/index-BqjXNy5A.js +1 -0
  48. package/assets/index-CRYLSnkT.js +1 -0
  49. package/assets/index-CkRd65CK.js +1 -0
  50. package/assets/{index-idulIG65.js → index-CrStk0va.js} +4 -4
  51. package/assets/index-DChgNaxv.js +1 -0
  52. package/assets/index-DCwFpPS8.js +1 -0
  53. package/assets/index-DiWdTWAy.js +1 -0
  54. package/assets/index-GQwosZoW.js +1 -0
  55. package/assets/{kbd-eZWvlfcb.js → kbd-CIM88W-i.js} +1 -1
  56. package/assets/{labels-DFa210V0.js → labels-BcDR_MmB.js} +1 -1
  57. package/assets/{mail-Ba7j-n-X.js → mail-CM0Ox199.js} +1 -1
  58. package/assets/{mail-lLnBwPN-.js → mail-LpK0kRr6.js} +1 -1
  59. package/assets/{menu-MXmFQ7m-.js → menu-CVMIxRRy.js} +1 -1
  60. package/assets/{onboarding-BQv4jg_d.js → onboarding-C52bKclx.js} +1 -1
  61. package/assets/outbox-CaV85SHn.js +1 -0
  62. package/assets/{pencil-CFys2EU7.js → pencil-Dwwmy-LK.js} +1 -1
  63. package/assets/{rich-text-DUWqcHC5.js → rich-text-DTviXfBN.js} +1 -1
  64. package/assets/{rich-text-spellcheck-worker-provider-DTxcyJ9W.js → rich-text-spellcheck-worker-provider-CXOEqFHn.js} +1 -1
  65. package/assets/{rotate-ccw-DfGOnKhE.js → rotate-ccw-BdyunlX_.js} +1 -1
  66. package/assets/{row-actions-zVghhE3a.js → row-actions-YLjTr0Pe.js} +1 -1
  67. package/assets/{search-mirror-_pK4jqc8.js → search-mirror-DxvFKHd5.js} +1 -1
  68. package/assets/{search-token-index-C-cpQFN3.js → search-token-index-CRfarw2N.js} +1 -1
  69. package/assets/{senders-Gj8Yentl.js → senders-Cec3QyOb.js} +1 -1
  70. package/assets/settings-DJui7dAr.js +1 -0
  71. package/assets/{settings-screen-B17eDLDl.js → settings-screen-YvTik_VI.js} +1 -1
  72. package/assets/{shield-check-DG9twqa-.js → shield-check-CmdMSuok.js} +1 -1
  73. package/assets/{suggested-vips--KmGV5np.js → suggested-vips-sMNKttKk.js} +1 -1
  74. package/assets/{useDebouncedValue-CntZIoMR.js → useDebouncedValue-DBe8RTdD.js} +1 -1
  75. package/assets/{useFilters-DaiBln2b.js → useFilters-BV7Ur6sx.js} +1 -1
  76. package/assets/{useLabels-amyS-Wph.js → useLabels-77azHAmW.js} +1 -1
  77. package/assets/{useMessageBodyContent-5kw10g9a.js → useMessageBodyContent-D2ppLfqI.js} +1 -1
  78. package/assets/{useRefreshControl-CUTMAyIA.js → useRefreshControl-B_HOBKw6.js} +1 -1
  79. package/assets/{useSearchTokenContext-BxDapNdu.js → useSearchTokenContext-BFF5PFp_.js} +1 -1
  80. package/assets/{useSemanticSearch-BDxoAQSc.js → useSemanticSearch-DVz20iAO.js} +1 -1
  81. package/assets/{useSignature-osTmnWZe.js → useSignature-CZIvmo45.js} +1 -1
  82. package/index.html +1 -1
  83. package/package.json +1 -1
  84. package/assets/_mailboxId-ByYUZV2Y.js +0 -1
  85. package/assets/_messageId-DLU18Mnl.js +0 -1
  86. package/assets/_messageId-DzC6VHu2.js +0 -1
  87. package/assets/_messageId-yJtPeY_Z.js +0 -1
  88. package/assets/_outboxMessageId-AEnONMiY.js +0 -1
  89. package/assets/_threadId-BdblixoD.js +0 -1
  90. package/assets/_threadId-CC5eBVBw.js +0 -1
  91. package/assets/_threadId-Cb8ALPnU.js +0 -1
  92. package/assets/brief-06HoE0GS.js +0 -1
  93. package/assets/compose._-_outboxMessageId_-CyN4sUxa.js +0 -1
  94. package/assets/compose._-_outboxMessageId_-D5_JMiLJ.js +0 -1
  95. package/assets/compose._-_outboxMessageId_-Db3_5Bzx.js +0 -1
  96. package/assets/compose._-_outboxMessageId_-YqQysly2.js +0 -1
  97. package/assets/flagged-DErOl3l4.js +0 -1
  98. package/assets/index--TsBKY5T.js +0 -1
  99. package/assets/index-BG1B897N.js +0 -1
  100. package/assets/index-BIcRfpbR.js +0 -1
  101. package/assets/index-DLU18Mnl.js +0 -1
  102. package/assets/index-DqLBbxu3.js +0 -1
  103. package/assets/index-DwKeNLeB.js +0 -1
  104. package/assets/index-yJtPeY_Z.js +0 -1
  105. package/assets/index-zNCEv1vY.js +0 -1
  106. package/assets/outbox-Dye6uwnb.js +0 -1
  107. package/assets/settings-D96it8Kf.js +0 -1
@@ -1 +1 @@
1
- import{c}from"./index-idulIG65.js";const r=c("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);export{r as C};
1
+ import{c}from"./index-CrStk0va.js";const r=c("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);export{r as C};
@@ -1 +1 @@
1
- import{c}from"./index-idulIG65.js";const t=c("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);export{t as C};
1
+ import{c}from"./index-CrStk0va.js";const t=c("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);export{t as C};
@@ -1 +1 @@
1
- import{c}from"./index-idulIG65.js";const p=c("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);export{p as C};
1
+ import{c}from"./index-CrStk0va.js";const p=c("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);export{p as C};
@@ -1 +1 @@
1
- import{c}from"./index-idulIG65.js";const o=c("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);export{o as C};
1
+ import{c}from"./index-CrStk0va.js";const o=c("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);export{o as C};
@@ -0,0 +1 @@
1
+ import{F as o}from"./FullCompose-CTBUQaxT.js";import"./index-CrStk0va.js";import"./ErrorState-D5cn-r_g.js";import"./index-04bqfNgp.js";import"./useMessageBodyContent-D2ppLfqI.js";import"./useSignature-CZIvmo45.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-DBe8RTdD.js";import"./confirm-dialog-DoFwvjx5.js";const a=o;export{a as component};
@@ -0,0 +1 @@
1
+ import{F as o}from"./FullCompose-CTBUQaxT.js";import"./index-CrStk0va.js";import"./ErrorState-D5cn-r_g.js";import"./index-04bqfNgp.js";import"./useMessageBodyContent-D2ppLfqI.js";import"./useSignature-CZIvmo45.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-DBe8RTdD.js";import"./confirm-dialog-DoFwvjx5.js";const a=o;export{a as component};
@@ -0,0 +1 @@
1
+ import{F as o}from"./FullCompose-CTBUQaxT.js";import"./index-CrStk0va.js";import"./ErrorState-D5cn-r_g.js";import"./index-04bqfNgp.js";import"./useMessageBodyContent-D2ppLfqI.js";import"./useSignature-CZIvmo45.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-DBe8RTdD.js";import"./confirm-dialog-DoFwvjx5.js";const a=o;export{a as component};
@@ -0,0 +1 @@
1
+ import{F as o}from"./FullCompose-CTBUQaxT.js";import"./index-CrStk0va.js";import"./ErrorState-D5cn-r_g.js";import"./index-04bqfNgp.js";import"./useMessageBodyContent-D2ppLfqI.js";import"./useSignature-CZIvmo45.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-DBe8RTdD.js";import"./confirm-dialog-DoFwvjx5.js";const a=o;export{a as component};
@@ -1 +1 @@
1
- import{r as n,j as e,L as b,b as o}from"./index-idulIG65.js";const h=({isOpen:s,title:i,description:l,confirmLabel:d,cancelLabel:m="Cancel",destructive:u=!1,isBusy:f=!1,onConfirm:x,onCancel:r})=>{const c=n.useRef(null),a=n.useCallback(t=>{t.key==="Escape"&&(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),r())},[r]);return n.useEffect(()=>{if(s)return window.addEventListener("keydown",a,!0),()=>window.removeEventListener("keydown",a,!0)},[s,a]),n.useEffect(()=>{if(!s)return;const t=document.activeElement instanceof HTMLElement?document.activeElement:null;return c.current?.focus(),()=>{t?.isConnected&&t.focus()}},[s]),s?e.jsxs("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",children:[e.jsx(b,{label:"Dismiss confirmation",onDismiss:r,className:"backdrop-blur-sm"}),e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":i,className:o("relative z-10 w-full max-w-sm","bg-surface border border-line rounded-sm shadow-lg","p-6"),children:[e.jsx("h2",{className:"text-lg font-semibold",children:i}),l&&e.jsx("p",{className:"mt-2 text-sm text-fg-muted",children:l}),e.jsxs("div",{className:"mt-6 flex items-center justify-end gap-2",children:[e.jsx("button",{ref:c,type:"button",onClick:r,className:o("min-h-11 inline-flex items-center justify-center px-4 rounded text-sm font-medium transition-colors","border border-line hover:bg-surface-raised"),children:m}),e.jsx("button",{type:"button",onClick:x,disabled:f,className:o("min-h-11 inline-flex items-center justify-center px-4 rounded text-sm font-medium transition-colors",u?"bg-danger text-canvas hover:bg-danger/90":"bg-accent text-accent-fg hover:bg-accent-hover","disabled:opacity-50 disabled:cursor-not-allowed"),children:d})]})]})]}):null};export{h as C};
1
+ import{r as n,j as e,L as b,b as o}from"./index-CrStk0va.js";const h=({isOpen:s,title:i,description:l,confirmLabel:d,cancelLabel:m="Cancel",destructive:u=!1,isBusy:f=!1,onConfirm:x,onCancel:r})=>{const c=n.useRef(null),a=n.useCallback(t=>{t.key==="Escape"&&(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),r())},[r]);return n.useEffect(()=>{if(s)return window.addEventListener("keydown",a,!0),()=>window.removeEventListener("keydown",a,!0)},[s,a]),n.useEffect(()=>{if(!s)return;const t=document.activeElement instanceof HTMLElement?document.activeElement:null;return c.current?.focus(),()=>{t?.isConnected&&t.focus()}},[s]),s?e.jsxs("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",children:[e.jsx(b,{label:"Dismiss confirmation",onDismiss:r,className:"backdrop-blur-sm"}),e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":i,className:o("relative z-10 w-full max-w-sm","bg-surface border border-line rounded-sm shadow-lg","p-6"),children:[e.jsx("h2",{className:"text-lg font-semibold",children:i}),l&&e.jsx("p",{className:"mt-2 text-sm text-fg-muted",children:l}),e.jsxs("div",{className:"mt-6 flex items-center justify-end gap-2",children:[e.jsx("button",{ref:c,type:"button",onClick:r,className:o("min-h-11 inline-flex items-center justify-center px-4 rounded text-sm font-medium transition-colors","border border-line hover:bg-surface-raised"),children:m}),e.jsx("button",{type:"button",onClick:x,disabled:f,className:o("min-h-11 inline-flex items-center justify-center px-4 rounded text-sm font-medium transition-colors",u?"bg-danger text-canvas hover:bg-danger/90":"bg-accent text-accent-fg hover:bg-accent-hover","disabled:opacity-50 disabled:cursor-not-allowed"),children:d})]})]})]}):null};export{h as C};
@@ -1 +1 @@
1
- import{c as o}from"./index-idulIG65.js";const a=o("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);export{a as D};
1
+ import{c as o}from"./index-CrStk0va.js";const a=o("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);export{a as D};
@@ -1 +1 @@
1
- import{x as X,aj as Z,a_ as ee,a$ as te,r as x,b0 as se,j as t,b1 as ae,b2 as ie,ar as R,B as N,b3 as ne,az as re,aF as oe,b4 as le,b5 as ce,T as de,D as z,z as me,b6 as ue,G as pe,H as xe,b7 as fe,b8 as he,a0 as ge,a1 as be,aD as ve,aH as je}from"./index-idulIG65.js";import{S as ye}from"./settings-screen-B17eDLDl.js";import{B as Ne}from"./bottom-sheet-BuEgZWXh.js";import{u as Ce,a as Se}from"./useLabels-amyS-Wph.js";import{b as Fe,N as S,p as Me,u as Ie,r as we,a as Ee,S as L,c as Oe,n as De,f as Ae,d as Le,e as Te,g as ke}from"./useFilters-DaiBln2b.js";import{C as A}from"./circle-check-BhMyR8BA.js";import{E as P}from"./ErrorState-B_pp6XjY.js";import"./avatar-C8lpjlQO.js";import"./menu-MXmFQ7m-.js";import"./circle-help-BAup3nOG.js";const Re=(e,s)=>{const r=X(),i=Z({...te(),onSuccess:()=>{e&&(r.invalidateQueries({queryKey:Fe(e)}),s&&r.invalidateQueries({queryKey:ee({path:{accountId:e,filterId:s}})}))}}),{mutate:c}=i;return{updateFilter:x.useCallback(d=>{!e||!s||c({path:{accountId:e,filterId:s},body:d})},[e,s,c]),isPending:i.isPending,isSuccess:i.isSuccess,isError:i.isError,error:i.error,reset:i.reset}},ze=(e,s=!1)=>({clauses:e.literalClauses.map((i,c)=>({id:`clause-${c}`,field:i.field,value:i.value})),matchOperator:e.matchOperator==="And"?"all":"any",widen:e.hasAnchor?{anchorCount:1,...s?{inactive:!0}:{}}:void 0,moveMailboxId:e.actionMailboxId!==S?e.actionMailboxId:void 0,labelId:e.actionLabelId!==S?e.actionLabelId:void 0,scope:e.scope==="Temporary"?"until":"standing",until:e.scope==="Temporary"?Pe(e.expiresAt):void 0,name:e.name}),Pe=e=>{if(!e)return"";const s=Date.parse(e);if(Number.isNaN(s))return"";const r=new Date(s),i=c=>String(c).padStart(2,"0");return`${r.getFullYear()}-${i(r.getMonth()+1)}-${i(r.getDate())}`},T=e=>JSON.stringify({clauses:e.clauses.map(s=>[s.field,s.value]),operator:e.matchOperator,move:e.moveMailboxId??null,label:e.labelId??null,widen:e.widen?e.widen.inactive?"inactive":"active":"none"}),$=(e,s)=>T(e)!==T(s),k=e=>JSON.stringify({scope:e.scope==="until"?"until":"standing",until:e.scope==="until"?e.until??"":""}),_=(e,s)=>k(e)!==k(s),$e=(e,s)=>{const r={},i=(e.name??"").trim();return i!==(s.name??"").trim()&&(r.name=i),$(e,s)&&(r.matchOperator=e.matchOperator==="all"?"And":"Or",r.literalClauses=e.clauses.map(c=>({field:c.field,value:c.value})),r.actionMailboxId=e.moveMailboxId??S,r.actionLabelId=e.labelId??S),_(e,s)&&(r.scope=e.scope==="until"?"Temporary":"Standing",e.scope==="until"&&(r.expiresAt=Me(e.until??""))),r};function _e({accountId:e,filter:s,folders:r,delimiter:i,labels:c,semanticUnavailable:g=!1,onClose:d}){const f=x.useMemo(()=>ze(s,g),[s,g]),[n,l]=x.useState(f),[m,u]=x.useState(),[h,v]=x.useState(!1),M=x.useRef(0),{count:C}=Ie(e,we(n)),y=Re(e,s.filterId),b=Ee(e),{createFolderIn:F}=se(e),{createLabel:E}=Ce(e),I=async o=>{const a=await E(o);return{id:a.labelId,name:a.name,color:a.color}},p=()=>u({mode:"add",draft:{field:L[0],value:""}}),w=o=>{const a=n.clauses.find(j=>j.id===o);a&&u({mode:"edit",clauseId:o,draft:{field:a.field,value:a.value}})},O=o=>u(a=>a&&{...a,draft:{...a.draft,field:o}}),B=o=>u(a=>a&&{...a,draft:{...a.draft,value:o}}),U=()=>{if(!m)return;const o=m.draft.field,a=De(o,m.draft.value);a!==""&&(l(j=>m.mode==="edit"&&m.clauseId?{...j,clauses:j.clauses.map(D=>D.id===m.clauseId?{id:D.id,field:o,value:a}:D)}:(M.current+=1,{...j,clauses:[...j.clauses,{id:`new-${M.current}`,field:o,value:a}]})),u(void 0))},H=o=>l(a=>({...a,clauses:a.clauses.filter(j=>j.id!==o)})),K=o=>l(a=>({...a,matchOperator:o})),G=o=>l(a=>({...a,moveMailboxId:o||void 0})),Q=o=>l(a=>({...a,labelId:o||void 0})),J=o=>l(a=>({...a,name:o})),V=o=>l(a=>({...a,scope:o,until:o==="until"?a.until:void 0})),q=o=>l(a=>({...a,until:o})),W=()=>{const o=$(n,f)||_(n,f),a=$e(n,f);if(Object.keys(a).length===0){d();return}v(o),y.updateFilter(a)},Y=()=>b.start(Oe(n));return b.isStarting||b.isRunning||b.isDone?t.jsx(Ke,{progress:b.progress,isDone:b.isDone,onClose:d}):y.isPending?t.jsx(Be,{}):y.isError?t.jsx(Ge,{onRetry:y.reset,onClose:d}):y.isSuccess?h?t.jsx(He,{preview:ae(C),blocked:C.status!=="ready"||C.stale===!0,onReapply:Y,onClose:d}):t.jsx(Ue,{onClose:d}):t.jsx(ie,{rule:n,folders:r,delimiter:i,labels:c,preview:C,semanticAvailable:!1,clauseFields:L,anchorLocked:!0,clauseEdit:m,onStartAddClause:p,onStartEditClause:w,onRemoveClause:H,onChangeDraftField:O,onChangeDraftValue:B,onSubmitClause:U,onCancelClause:()=>u(void 0),onChangeMatchOperator:K,onChangeMove:G,onCreateFolder:F,onChangeLabel:Q,onCreateLabel:I,onChangeName:J,onChangeScope:V,onChangeUntil:q,onCommit:W,onCancel:d})}function Be(){return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[t.jsx(R,{className:"size-8 animate-spin text-accent-2"}),t.jsx("p",{className:"text-sm font-medium text-fg",children:"Saving changes…"})]})}function Ue({onClose:e}){return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[t.jsx(A,{className:"size-8 text-positive"}),t.jsx("p",{className:"text-sm font-medium text-fg",children:"Filter updated"}),t.jsx(N,{variant:"primary",onClick:e,className:"mt-2",children:"Done"})]})}function He({preview:e,blocked:s,onReapply:r,onClose:i}){return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[t.jsx(A,{className:"size-8 text-positive"}),t.jsx("p",{className:"text-sm font-medium text-fg",children:"Rule saved"}),t.jsxs("p",{className:"max-w-xs text-xs text-fg-muted",children:["New mail follows the rule automatically. ",e," — move the mail already in your mailbox too?"]}),t.jsxs("div",{className:"mt-2 flex gap-2",children:[t.jsx(N,{variant:"primary",onClick:r,disabled:s,children:"Move existing mail"}),t.jsx(N,{variant:"ghost",onClick:i,children:"Not now"})]})]})}function Ke({progress:e,isDone:s,onClose:r}){const i=e.state==="Failed";return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[s?i?t.jsx("span",{className:"text-sm font-semibold text-danger",children:"Move failed"}):t.jsx(A,{className:"size-8 text-positive"}):t.jsx(R,{className:"size-8 animate-spin text-accent-2"}),!s&&t.jsx("p",{className:"text-sm font-medium text-fg",children:"Moving existing mail…"}),s&&!i&&t.jsxs("div",{className:"text-sm text-fg",children:[t.jsx("p",{className:"font-medium",children:"Done"}),t.jsxs("p",{className:"mt-1 text-xs text-fg-muted",children:[e.appliedCount," of ",e.matchedCount," moved",e.failedCount>0?` · ${e.failedCount} failed`:"","."]})]}),s&&i&&t.jsx("p",{className:"max-w-xs text-xs text-fg-muted",children:e.errorMessage||"Something went wrong. Please try again."}),s&&t.jsx(N,{variant:"primary",onClick:r,className:"mt-2",children:"Done"})]})}function Ge({onRetry:e,onClose:s}){return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[t.jsx("p",{className:"text-sm font-medium text-danger",children:"Couldn't save changes"}),t.jsx("p",{className:"max-w-xs text-xs text-fg-muted",children:"Please try again."}),t.jsxs("div",{className:"mt-2 flex gap-2",children:[t.jsx(N,{variant:"primary",onClick:e,children:"Try again"}),t.jsx(N,{variant:"ghost",onClick:s,children:"Not now"})]})]})}function Qe({accountId:e,filter:s,folders:r,delimiter:i,labels:c,semanticUnavailable:g,onClose:d}){const f=ne(),n=t.jsx(_e,{accountId:e,filter:s,folders:r,delimiter:i,labels:c,semanticUnavailable:g,onClose:d});return f?t.jsx(re,{open:!0,onClose:d,title:"Filter rule",children:n}):t.jsx(Ne,{open:!0,onClose:d,dismissLabel:"Dismiss filter rule",children:n})}function Je({filters:e,mailboxName:s,labelById:r,onEdit:i,onDelete:c,deletingFilterId:g,semanticUnavailable:d=!1,now:f=Date.now()}){return e.length===0?t.jsx("p",{className:"py-6 text-sm text-fg-muted",children:"No filters yet. Select a few messages in the inbox and choose Organize to make one."}):t.jsx("ul",{className:"divide-y divide-line rounded-md border border-line",children:e.map(n=>{const l=Ae(n,f),m=l==="Expired",u=n.actionMailboxId!==S?s(n.actionMailboxId):void 0,h=n.actionLabelId!==S?r.get(n.actionLabelId):void 0,v=Le(n.expiresAt);return t.jsxs("li",{className:"flex items-start gap-3 px-3 py-2.5",children:[t.jsxs("button",{type:"button",onClick:()=>i(n.filterId),"aria-label":`Edit filter ${n.name}`,className:"min-w-0 flex-1 rounded-sm text-left hover:opacity-80",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`truncate text-sm font-medium ${m?"text-fg-muted":"text-fg"}`,children:n.name}),t.jsx(oe,{tone:m?"neutral":"positive",dot:!0,children:l})]}),t.jsxs("p",{className:"mt-0.5 text-xs text-fg-subtle",children:[u?`Moves matches to ${u}`:"No move action",n.scope==="Temporary"&&v?m?` · expired ${v}`:` · until ${v}`:n.scope==="Standing"?" · always":""]}),(n.hasAnchor||h)&&t.jsxs("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:[n.hasAnchor&&t.jsx(le,{widen:{anchorCount:1,...d?{inactive:!0}:{}}}),h&&t.jsx(ce,{label:{labelId:h.id,name:h.name,color:h.color}})]})]}),t.jsx(N,{variant:"ghost",size:"sm",icon:t.jsx(de,{className:"size-4 text-danger"}),onClick:()=>c(n.filterId),disabled:g===n.filterId,"aria-label":`Delete filter ${n.name}`})]},n.filterId)})})}const Ve=t.jsxs("div",{className:"space-y-3",children:[t.jsxs("p",{children:["Filters are the standing rules Organize creates. A"," ",t.jsx("strong",{children:"Standing"})," filter keeps working on new mail; a"," ",t.jsx("strong",{children:"Temporary"})," one stops on its own at the date you picked."]}),t.jsx("p",{children:"An expired filter isn't deleted the instant it lapses — it stays here, marked Expired, so you can see what it did and when it stopped."})]});function qe({account:e}){const s=e.accountId,{filters:r,isPending:i,isError:c,error:g,refetch:d}=Te(s),{deleteFilter:f,deletingFilterId:n}=ke(s),[l,m]=x.useState(),{data:u}=z({...me({path:{accountId:s}}),staleTime:1/0}),h=ue(),v=x.useMemo(()=>pe(e.folderAppointments),[e.folderAppointments]),M=x.useCallback(p=>{const w=u?.items.find(O=>O.mailboxId===p);if(w)return xe(w,v.get(p),h)},[u?.items,v,h]),C=x.useMemo(()=>fe({mailboxes:u?.items??[],folderAppointments:e.folderAppointments,translator:h}),[u?.items,e.folderAppointments,h]),y=he(u?.items??[]),{labels:b}=Se(s),F=x.useMemo(()=>b.map(p=>({id:p.labelId,name:p.name,color:p.color})),[b]),E=x.useMemo(()=>new Map(F.map(p=>[p.id,p])),[F]),I=r.find(p=>p.filterId===l);return t.jsxs("section",{className:"space-y-2",children:[t.jsx("h2",{className:"text-sm font-semibold text-fg",children:e.email}),I&&t.jsx(Qe,{accountId:s,filter:I,folders:C,delimiter:y,labels:F,onClose:()=>m(void 0)}),i?t.jsx("div",{className:"h-16 animate-pulse rounded-md border border-line bg-surface","aria-busy":"true","aria-label":`Loading filters for ${e.email}`}):c?t.jsx(P,{variant:"inline",title:`Couldn't load filters for ${e.email}`,error:g,onRetry:()=>{d()}}):t.jsx(Je,{filters:r,mailboxName:M,labelById:E,onEdit:m,onDelete:f,deletingFilterId:n})]})}function rt(){const e=ge(),[s,r]=x.useState(!0),{data:i,isPending:c,isError:g,error:d,refetch:f}=z(be()),n=l=>{const m=je[l];m&&e({to:m})};return t.jsx(ye,{items:ve,activeId:"filters",title:"Filters",description:"Standing and temporary rules created by Organize, per account.",help:Ve,helpOpen:s,onToggleHelp:()=>r(l=>!l),onSelect:n,onBackToMail:()=>{e({to:"/mail"})},children:c?t.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":"Loading accounts"}):g?t.jsx(P,{title:"Couldn't load accounts",error:d,onRetry:()=>{f()}}):i.accounts.length===0?t.jsx("p",{className:"py-12 text-sm text-fg-muted",children:"No accounts configured."}):t.jsx("div",{className:"space-y-8",children:i.accounts.map(l=>t.jsx(qe,{account:l},l.accountId))})})}export{qe as AccountFilters,rt as component};
1
+ import{x as X,aj as Z,a_ as ee,a$ as te,r as x,b0 as se,j as t,b1 as ae,b2 as ie,ar as R,B as N,b3 as ne,az as re,aF as oe,b4 as le,b5 as ce,T as de,D as z,z as me,b6 as ue,G as pe,H as xe,b7 as fe,b8 as he,a0 as ge,a1 as be,aD as ve,aH as je}from"./index-CrStk0va.js";import{S as ye}from"./settings-screen-YvTik_VI.js";import{B as Ne}from"./bottom-sheet-RK-XvYz2.js";import{u as Ce,a as Se}from"./useLabels-77azHAmW.js";import{b as Fe,N as S,p as Me,u as Ie,r as we,a as Ee,S as L,c as Oe,n as De,f as Ae,d as Le,e as Te,g as ke}from"./useFilters-BV7Ur6sx.js";import{C as A}from"./circle-check-B3vjKaD1.js";import{E as P}from"./ErrorState-D5cn-r_g.js";import"./avatar-DVEp71DP.js";import"./menu-CVMIxRRy.js";import"./circle-help-KBbSqlpB.js";const Re=(e,s)=>{const r=X(),i=Z({...te(),onSuccess:()=>{e&&(r.invalidateQueries({queryKey:Fe(e)}),s&&r.invalidateQueries({queryKey:ee({path:{accountId:e,filterId:s}})}))}}),{mutate:c}=i;return{updateFilter:x.useCallback(d=>{!e||!s||c({path:{accountId:e,filterId:s},body:d})},[e,s,c]),isPending:i.isPending,isSuccess:i.isSuccess,isError:i.isError,error:i.error,reset:i.reset}},ze=(e,s=!1)=>({clauses:e.literalClauses.map((i,c)=>({id:`clause-${c}`,field:i.field,value:i.value})),matchOperator:e.matchOperator==="And"?"all":"any",widen:e.hasAnchor?{anchorCount:1,...s?{inactive:!0}:{}}:void 0,moveMailboxId:e.actionMailboxId!==S?e.actionMailboxId:void 0,labelId:e.actionLabelId!==S?e.actionLabelId:void 0,scope:e.scope==="Temporary"?"until":"standing",until:e.scope==="Temporary"?Pe(e.expiresAt):void 0,name:e.name}),Pe=e=>{if(!e)return"";const s=Date.parse(e);if(Number.isNaN(s))return"";const r=new Date(s),i=c=>String(c).padStart(2,"0");return`${r.getFullYear()}-${i(r.getMonth()+1)}-${i(r.getDate())}`},T=e=>JSON.stringify({clauses:e.clauses.map(s=>[s.field,s.value]),operator:e.matchOperator,move:e.moveMailboxId??null,label:e.labelId??null,widen:e.widen?e.widen.inactive?"inactive":"active":"none"}),$=(e,s)=>T(e)!==T(s),k=e=>JSON.stringify({scope:e.scope==="until"?"until":"standing",until:e.scope==="until"?e.until??"":""}),_=(e,s)=>k(e)!==k(s),$e=(e,s)=>{const r={},i=(e.name??"").trim();return i!==(s.name??"").trim()&&(r.name=i),$(e,s)&&(r.matchOperator=e.matchOperator==="all"?"And":"Or",r.literalClauses=e.clauses.map(c=>({field:c.field,value:c.value})),r.actionMailboxId=e.moveMailboxId??S,r.actionLabelId=e.labelId??S),_(e,s)&&(r.scope=e.scope==="until"?"Temporary":"Standing",e.scope==="until"&&(r.expiresAt=Me(e.until??""))),r};function _e({accountId:e,filter:s,folders:r,delimiter:i,labels:c,semanticUnavailable:g=!1,onClose:d}){const f=x.useMemo(()=>ze(s,g),[s,g]),[n,l]=x.useState(f),[m,u]=x.useState(),[h,v]=x.useState(!1),M=x.useRef(0),{count:C}=Ie(e,we(n)),y=Re(e,s.filterId),b=Ee(e),{createFolderIn:F}=se(e),{createLabel:E}=Ce(e),I=async o=>{const a=await E(o);return{id:a.labelId,name:a.name,color:a.color}},p=()=>u({mode:"add",draft:{field:L[0],value:""}}),w=o=>{const a=n.clauses.find(j=>j.id===o);a&&u({mode:"edit",clauseId:o,draft:{field:a.field,value:a.value}})},O=o=>u(a=>a&&{...a,draft:{...a.draft,field:o}}),B=o=>u(a=>a&&{...a,draft:{...a.draft,value:o}}),U=()=>{if(!m)return;const o=m.draft.field,a=De(o,m.draft.value);a!==""&&(l(j=>m.mode==="edit"&&m.clauseId?{...j,clauses:j.clauses.map(D=>D.id===m.clauseId?{id:D.id,field:o,value:a}:D)}:(M.current+=1,{...j,clauses:[...j.clauses,{id:`new-${M.current}`,field:o,value:a}]})),u(void 0))},H=o=>l(a=>({...a,clauses:a.clauses.filter(j=>j.id!==o)})),K=o=>l(a=>({...a,matchOperator:o})),G=o=>l(a=>({...a,moveMailboxId:o||void 0})),Q=o=>l(a=>({...a,labelId:o||void 0})),J=o=>l(a=>({...a,name:o})),V=o=>l(a=>({...a,scope:o,until:o==="until"?a.until:void 0})),q=o=>l(a=>({...a,until:o})),W=()=>{const o=$(n,f)||_(n,f),a=$e(n,f);if(Object.keys(a).length===0){d();return}v(o),y.updateFilter(a)},Y=()=>b.start(Oe(n));return b.isStarting||b.isRunning||b.isDone?t.jsx(Ke,{progress:b.progress,isDone:b.isDone,onClose:d}):y.isPending?t.jsx(Be,{}):y.isError?t.jsx(Ge,{onRetry:y.reset,onClose:d}):y.isSuccess?h?t.jsx(He,{preview:ae(C),blocked:C.status!=="ready"||C.stale===!0,onReapply:Y,onClose:d}):t.jsx(Ue,{onClose:d}):t.jsx(ie,{rule:n,folders:r,delimiter:i,labels:c,preview:C,semanticAvailable:!1,clauseFields:L,anchorLocked:!0,clauseEdit:m,onStartAddClause:p,onStartEditClause:w,onRemoveClause:H,onChangeDraftField:O,onChangeDraftValue:B,onSubmitClause:U,onCancelClause:()=>u(void 0),onChangeMatchOperator:K,onChangeMove:G,onCreateFolder:F,onChangeLabel:Q,onCreateLabel:I,onChangeName:J,onChangeScope:V,onChangeUntil:q,onCommit:W,onCancel:d})}function Be(){return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[t.jsx(R,{className:"size-8 animate-spin text-accent-2"}),t.jsx("p",{className:"text-sm font-medium text-fg",children:"Saving changes…"})]})}function Ue({onClose:e}){return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[t.jsx(A,{className:"size-8 text-positive"}),t.jsx("p",{className:"text-sm font-medium text-fg",children:"Filter updated"}),t.jsx(N,{variant:"primary",onClick:e,className:"mt-2",children:"Done"})]})}function He({preview:e,blocked:s,onReapply:r,onClose:i}){return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[t.jsx(A,{className:"size-8 text-positive"}),t.jsx("p",{className:"text-sm font-medium text-fg",children:"Rule saved"}),t.jsxs("p",{className:"max-w-xs text-xs text-fg-muted",children:["New mail follows the rule automatically. ",e," — move the mail already in your mailbox too?"]}),t.jsxs("div",{className:"mt-2 flex gap-2",children:[t.jsx(N,{variant:"primary",onClick:r,disabled:s,children:"Move existing mail"}),t.jsx(N,{variant:"ghost",onClick:i,children:"Not now"})]})]})}function Ke({progress:e,isDone:s,onClose:r}){const i=e.state==="Failed";return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[s?i?t.jsx("span",{className:"text-sm font-semibold text-danger",children:"Move failed"}):t.jsx(A,{className:"size-8 text-positive"}):t.jsx(R,{className:"size-8 animate-spin text-accent-2"}),!s&&t.jsx("p",{className:"text-sm font-medium text-fg",children:"Moving existing mail…"}),s&&!i&&t.jsxs("div",{className:"text-sm text-fg",children:[t.jsx("p",{className:"font-medium",children:"Done"}),t.jsxs("p",{className:"mt-1 text-xs text-fg-muted",children:[e.appliedCount," of ",e.matchedCount," moved",e.failedCount>0?` · ${e.failedCount} failed`:"","."]})]}),s&&i&&t.jsx("p",{className:"max-w-xs text-xs text-fg-muted",children:e.errorMessage||"Something went wrong. Please try again."}),s&&t.jsx(N,{variant:"primary",onClick:r,className:"mt-2",children:"Done"})]})}function Ge({onRetry:e,onClose:s}){return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[t.jsx("p",{className:"text-sm font-medium text-danger",children:"Couldn't save changes"}),t.jsx("p",{className:"max-w-xs text-xs text-fg-muted",children:"Please try again."}),t.jsxs("div",{className:"mt-2 flex gap-2",children:[t.jsx(N,{variant:"primary",onClick:e,children:"Try again"}),t.jsx(N,{variant:"ghost",onClick:s,children:"Not now"})]})]})}function Qe({accountId:e,filter:s,folders:r,delimiter:i,labels:c,semanticUnavailable:g,onClose:d}){const f=ne(),n=t.jsx(_e,{accountId:e,filter:s,folders:r,delimiter:i,labels:c,semanticUnavailable:g,onClose:d});return f?t.jsx(re,{open:!0,onClose:d,title:"Filter rule",children:n}):t.jsx(Ne,{open:!0,onClose:d,dismissLabel:"Dismiss filter rule",children:n})}function Je({filters:e,mailboxName:s,labelById:r,onEdit:i,onDelete:c,deletingFilterId:g,semanticUnavailable:d=!1,now:f=Date.now()}){return e.length===0?t.jsx("p",{className:"py-6 text-sm text-fg-muted",children:"No filters yet. Select a few messages in the inbox and choose Organize to make one."}):t.jsx("ul",{className:"divide-y divide-line rounded-md border border-line",children:e.map(n=>{const l=Ae(n,f),m=l==="Expired",u=n.actionMailboxId!==S?s(n.actionMailboxId):void 0,h=n.actionLabelId!==S?r.get(n.actionLabelId):void 0,v=Le(n.expiresAt);return t.jsxs("li",{className:"flex items-start gap-3 px-3 py-2.5",children:[t.jsxs("button",{type:"button",onClick:()=>i(n.filterId),"aria-label":`Edit filter ${n.name}`,className:"min-w-0 flex-1 rounded-sm text-left hover:opacity-80",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`truncate text-sm font-medium ${m?"text-fg-muted":"text-fg"}`,children:n.name}),t.jsx(oe,{tone:m?"neutral":"positive",dot:!0,children:l})]}),t.jsxs("p",{className:"mt-0.5 text-xs text-fg-subtle",children:[u?`Moves matches to ${u}`:"No move action",n.scope==="Temporary"&&v?m?` · expired ${v}`:` · until ${v}`:n.scope==="Standing"?" · always":""]}),(n.hasAnchor||h)&&t.jsxs("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:[n.hasAnchor&&t.jsx(le,{widen:{anchorCount:1,...d?{inactive:!0}:{}}}),h&&t.jsx(ce,{label:{labelId:h.id,name:h.name,color:h.color}})]})]}),t.jsx(N,{variant:"ghost",size:"sm",icon:t.jsx(de,{className:"size-4 text-danger"}),onClick:()=>c(n.filterId),disabled:g===n.filterId,"aria-label":`Delete filter ${n.name}`})]},n.filterId)})})}const Ve=t.jsxs("div",{className:"space-y-3",children:[t.jsxs("p",{children:["Filters are the standing rules Organize creates. A"," ",t.jsx("strong",{children:"Standing"})," filter keeps working on new mail; a"," ",t.jsx("strong",{children:"Temporary"})," one stops on its own at the date you picked."]}),t.jsx("p",{children:"An expired filter isn't deleted the instant it lapses — it stays here, marked Expired, so you can see what it did and when it stopped."})]});function qe({account:e}){const s=e.accountId,{filters:r,isPending:i,isError:c,error:g,refetch:d}=Te(s),{deleteFilter:f,deletingFilterId:n}=ke(s),[l,m]=x.useState(),{data:u}=z({...me({path:{accountId:s}}),staleTime:1/0}),h=ue(),v=x.useMemo(()=>pe(e.folderAppointments),[e.folderAppointments]),M=x.useCallback(p=>{const w=u?.items.find(O=>O.mailboxId===p);if(w)return xe(w,v.get(p),h)},[u?.items,v,h]),C=x.useMemo(()=>fe({mailboxes:u?.items??[],folderAppointments:e.folderAppointments,translator:h}),[u?.items,e.folderAppointments,h]),y=he(u?.items??[]),{labels:b}=Se(s),F=x.useMemo(()=>b.map(p=>({id:p.labelId,name:p.name,color:p.color})),[b]),E=x.useMemo(()=>new Map(F.map(p=>[p.id,p])),[F]),I=r.find(p=>p.filterId===l);return t.jsxs("section",{className:"space-y-2",children:[t.jsx("h2",{className:"text-sm font-semibold text-fg",children:e.email}),I&&t.jsx(Qe,{accountId:s,filter:I,folders:C,delimiter:y,labels:F,onClose:()=>m(void 0)}),i?t.jsx("div",{className:"h-16 animate-pulse rounded-md border border-line bg-surface","aria-busy":"true","aria-label":`Loading filters for ${e.email}`}):c?t.jsx(P,{variant:"inline",title:`Couldn't load filters for ${e.email}`,error:g,onRetry:()=>{d()}}):t.jsx(Je,{filters:r,mailboxName:M,labelById:E,onEdit:m,onDelete:f,deletingFilterId:n})]})}function rt(){const e=ge(),[s,r]=x.useState(!0),{data:i,isPending:c,isError:g,error:d,refetch:f}=z(be()),n=l=>{const m=je[l];m&&e({to:m})};return t.jsx(ye,{items:ve,activeId:"filters",title:"Filters",description:"Standing and temporary rules created by Organize, per account.",help:Ve,helpOpen:s,onToggleHelp:()=>r(l=>!l),onSelect:n,onBackToMail:()=>{e({to:"/mail"})},children:c?t.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":"Loading accounts"}):g?t.jsx(P,{title:"Couldn't load accounts",error:d,onRetry:()=>{f()}}):i.accounts.length===0?t.jsx("p",{className:"py-12 text-sm text-fg-muted",children:"No accounts configured."}):t.jsx("div",{className:"space-y-8",children:i.accounts.map(l=>t.jsx(qe,{account:l},l.accountId))})})}export{qe as AccountFilters,rt as component};
@@ -1 +1 @@
1
- import{j as r}from"./index-idulIG65.js";import{E as o}from"./ErrorState-B_pp6XjY.js";const l=({error:t,reset:e})=>r.jsx("div",{className:"flex h-full items-center justify-center bg-canvas p-4",children:r.jsx(o,{title:"Couldn't load your starred mail",error:t,onRetry:e})});export{l as errorComponent};
1
+ import{j as r}from"./index-CrStk0va.js";import{E as o}from"./ErrorState-D5cn-r_g.js";const l=({error:t,reset:e})=>r.jsx("div",{className:"flex h-full items-center justify-center bg-canvas p-4",children:r.jsx(o,{title:"Couldn't load your starred mail",error:t,onRetry:e})});export{l as errorComponent};
@@ -0,0 +1 @@
1
+ import{j as o,a4 as i}from"./index-CrStk0va.js";import{a as m}from"./MailShell-8jHD0muk.js";import{F as r}from"./FlaggedPane-BmNKHLJP.js";import{g as p}from"./search-token-index-CRfarw2N.js";import{u as e}from"./search-mirror-DxvFKHd5.js";import"./FullCompose-CTBUQaxT.js";import"./ErrorState-D5cn-r_g.js";import"./index-04bqfNgp.js";import"./useMessageBodyContent-D2ppLfqI.js";import"./useSignature-CZIvmo45.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-DBe8RTdD.js";import"./confirm-dialog-DoFwvjx5.js";import"./useSearchTokenContext-BFF5PFp_.js";import"./kbd-CIM88W-i.js";import"./search-scope-DTcpOp3S.js";import"./MailListHeader-DzjUH8L0.js";import"./attachment-file-C1JZr27N.js";import"./mail-CM0Ox199.js";import"./avatar-DVEp71DP.js";import"./format-23Av07Go.js";import"./download-fhBgd0nR.js";import"./shield-check-CmdMSuok.js";import"./useFilters-BV7Ur6sx.js";import"./clock-sbv7ILkY.js";import"./menu-CVMIxRRy.js";import"./MailViewChrome-QVpYFxJf.js";import"./wizard-selection-B1bng5Jq.js";function w(){const t=p();return e({to:"/mail/flagged"}),o.jsx(r,{thread:t,children:o.jsx(m,{phone:o.jsx(r.Phone,{}),list:o.jsx(r.List,{}),reading:o.jsx(i,{}),intelligence:o.jsx(r.Intelligence,{}),hasThread:!!t})})}export{w as component};
@@ -1 +1 @@
1
- import{j as e,B as N,T as B,b9 as Y,r as c,az as W,X,aI as he,ap as J,F as xe,ba as K,bb as fe,ao as pe,as as ge,aE as L,aL as be,bc as ve,x as Z,Y as ee,a5 as se,bd as ye,be as je,aJ as Ne,W as ke,bf as Ce,bg as _,bh as we,bi as Se,bj as te,bk as Ie,bl as Q,b0 as ae,b6 as re,b7 as Me,H as G,G as ne,ar as H,bm as V,bn as Ee,af as De,bo as Ae,a0 as Oe,D as ie,a1 as Te,aD as Re,aH as Pe,z as Fe,aj as U,bp as $e,bq as ze,br as Le,aP as _e,bs as Be,bt as Ge}from"./index-idulIG65.js";import{P as He}from"./pencil-CFys2EU7.js";import{S as qe}from"./settings-screen-B17eDLDl.js";import{E as oe}from"./ErrorState-B_pp6XjY.js";import"./avatar-C8lpjlQO.js";import"./menu-MXmFQ7m-.js";import"./circle-help-BAup3nOG.js";const Ke=({label:s,onRename:t,onDelete:a,deleteBlockedReason:o,renameLabel:m=u=>`Rename ${u}`,deleteLabel:r=u=>`Delete ${u}`})=>{const u=o?`${r(s)} — ${o}`:r(s);return e.jsxs("span",{className:"flex shrink-0 items-center gap-0.5 pr-2",children:[e.jsx(N,{variant:"ghost",size:"sm",icon:e.jsx(He,{className:"size-3.5"}),"aria-label":m(s),onClick:t}),e.jsx("span",{title:o,children:e.jsx(N,{variant:"ghost",size:"sm",icon:e.jsx(B,{className:"size-3.5"}),"aria-label":u,disabled:o!==void 0,onClick:a})})]})},Qe=({folders:s,onRename:t,onDelete:a,onCreateFolder:o,delimiter:m,labels:r})=>{const u=new Map(s.map(l=>[l.id,l]));return e.jsx(Y,{folders:s,onCreateFolder:o,delimiter:m,labels:{treeAriaLabel:"Your folders",optionLabel:l=>l.label,...r},rowActions:l=>{const i=u.get(l.id);return i?e.jsx(Ke,{label:i.label,deleteBlockedReason:i.deleteBlockedReason,renameLabel:r?.rename,deleteLabel:r?.remove,onRename:()=>t(i),onDelete:()=>a(i)}):null}})},Ve=({open:s,folderLabel:t,defaultLabel:a,name:o,onNameChange:m,onSubmit:r,onClose:u,pending:l=!1,error:i})=>{const d=c.useId(),g=`Rename ${t}`;return s?e.jsxs(W,{open:s,onClose:u,title:g,children:[e.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[e.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:g}),e.jsx(N,{variant:"ghost",size:"sm",icon:e.jsx(X,{className:"size-3.5"}),onClick:u,"aria-label":"Cancel"})]}),e.jsxs("div",{className:"space-y-3 px-5 py-4",children:[e.jsxs("div",{children:[e.jsx(he,{htmlFor:d,children:"Folder name"}),e.jsx(J,{id:d,value:o,placeholder:a,onChange:p=>m(p.target.value),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),r())}})]}),e.jsxs("p",{className:"text-xs text-fg-muted",children:["Shown everywhere in Remit. Leave it blank to use"," ",e.jsx("span",{className:"font-medium text-fg",children:a}),"."]}),i&&e.jsx("p",{className:"text-xs text-danger",role:"alert",children:i})]}),e.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[e.jsx(N,{variant:"secondary",size:"sm",onClick:u,children:"Cancel"}),e.jsx(N,{variant:"primary",size:"sm",onClick:r,disabled:l,children:l?"Saving…":"Save name"})]})]}):null},Ue=["inbox","drafts","sent","archive","junk","trash"],q="",Ye={mailboxId:null,source:"None"};function We(s){const t=s.messageCount===1?"msg":"msgs";return`${K(s.providerPath,s.hierarchyDelimiter)} · ${s.messageCount} ${t}`}const le=s=>`${s} ${s===1?"message":"messages"}`,Xe=(s,t)=>s==="Appointed"?"Chosen by you":s==="Flagged"?`The mail server marks it as ${t}`:s==="Reserved"?"The account's own INBOX":"Matched by name, not confirmed";function Je({role:s,folders:t,appointment:a,displayName:o,onAppoint:m,onRename:r}){const[u,l]=c.useState(o),i=c.useRef(null),d=c.useRef(!1),g=c.useId(),{mailboxId:p,source:v,staleFolderPath:y}=a,h=t.find(j=>j.mailboxId===p)??null,f=be(s),O=h!=null&&u.trim()!==o.trim();c.useEffect(()=>{!d.current||v==="Proposed"||(d.current=!1,i.current?.focus())},[v]);const M=(()=>{if(v==="None"){const j=s==="trash"?" Deleting mail needs one.":"";return e.jsx("span",{id:g,className:"pl-[7.5rem] text-xs text-fg-muted",children:`Not set — pick the folder this account uses for ${f}.${j}`})}return v==="Stale"||!h?null:e.jsx("span",{id:g,className:"truncate pl-[7.5rem] text-2xs text-fg-subtle",title:h.providerPath,children:`${Xe(v,f)} · ${h.providerPath} · ${le(h.messageCount)}`})})(),w=s==="trash"?" Deleting mail is stopped until you pick another one.":h?` reader is using ${K(h.providerPath,h.hierarchyDelimiter)} instead.`:"",A=`The folder you chose for ${f}${y?` — ${y} —`:""} is gone from the mail server.${w}`;return e.jsxs("div",{className:"flex flex-col gap-1 border-b border-line px-row-inset py-2.5 last:border-b-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"flex w-28 shrink-0 items-center gap-2 text-sm font-medium text-fg",children:[fe(s),f]}),e.jsxs(pe,{ref:i,className:"w-56 shrink-0",value:p??q,"aria-label":`Folder for ${f}`,"aria-describedby":M||v==="Stale"?g:void 0,onChange:j=>m(s,j.target.value===q?null:j.target.value),children:[e.jsx("option",{value:q,children:"None"}),t.map(j=>e.jsx("option",{value:j.mailboxId,children:We(j)},j.mailboxId))]}),v==="Proposed"&&h&&e.jsx(N,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>{d.current=!0,m(s,h.mailboxId)},children:`Set as ${f}`}),h&&e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"flex-1",value:u,placeholder:f,"aria-label":`Display name for ${f}`,onChange:j=>l(j.target.value)}),O&&e.jsx(N,{variant:"ghost",size:"sm",className:"shrink-0",icon:e.jsx(ge,{className:"size-4"}),"aria-label":"Save display name",onClick:()=>r(h.mailboxId,u)})]})]}),M,v==="Stale"&&e.jsx(L,{tone:"warning",variant:"soft",className:"ml-[7.5rem]",children:e.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{id:g,className:"flex-1",children:A}),e.jsx(N,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>i.current?.focus(),children:"Pick a folder"})]})})]})}function Ze({accountEmail:s,folders:t,appointments:a,displayNames:o={},onAppoint:m,onRename:r}){const u=new Set(Object.values(a).map(i=>i.mailboxId).filter(i=>i!=null)),l=t.filter(i=>!u.has(i.mailboxId));return e.jsxs("section",{className:"space-y-3",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsxs("h2",{className:"text-sm font-semibold text-fg",children:["Folder roles — ",s]}),e.jsx("p",{className:"text-xs text-fg-muted",children:"Each role points to one folder. Pick the folder that holds the mail — the counts help you tell real folders from empty look-alikes. Appointing a folder here removes it from any other role. Each row says where its answer came from — your choice, the mail server's own flag, or a name reader matched."})]}),e.jsx("div",{className:"rounded-sm border border-line bg-surface",children:Ue.map(i=>{const d=a[i]??Ye;return e.jsx(Je,{role:i,folders:t,appointment:d,displayName:d.mailboxId?o[d.mailboxId]??"":"",onAppoint:m,onRename:r},i)})}),l.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h3",{className:"text-xs font-medium text-fg-muted",children:"Other folders"}),e.jsx("ul",{className:"rounded-sm border border-line bg-surface",children:l.map(i=>e.jsxs("li",{className:"flex items-center gap-2 border-b border-line px-row-inset py-2 text-sm text-fg last:border-b-0",children:[e.jsx(xe,{className:"size-4 shrink-0 text-fg-subtle"}),e.jsx("span",{className:"truncate",children:K(i.providerPath,i.hierarchyDelimiter)}),e.jsx("span",{className:"ml-auto shrink-0 text-2xs text-fg-subtle",children:le(i.messageCount)})]},i.mailboxId))})]})]})}const es=12e4,ss=2e3,ts="This folder is no longer in the account's folder list, so nothing was deleted.",ce=(s,t)=>{const a=s.find(o=>o.mailboxId===t);if(!a)throw new Error(ts);return a},as=(s,t)=>ce(s,t).lastSyncedAt??0;async function rs({readMailboxes:s,mailboxId:t,since:a,signal:o,segmentMs:m=es,pollIntervalMs:r=ss,delay:u=ve,now:l=Date.now}){const i=l()+m;for(;;){o?.throwIfAborted();const d=ce(await s(),t);if((d.lastSyncedAt??0)>a)return{status:"fresh",messageCount:d.messagesTotal};if(l()>=i)return{status:"pending"};await u(r,o)}}const de=50,ns=s=>s instanceof Error?s.message:"Something went wrong.",$=s=>s.then(t=>({ok:!0,value:t}),t=>({ok:!1,error:ns(t)})),is=async(s,t,a,o)=>{const m=[];let r;for(let u=0;u<de;u+=1){if(o.aborted)return m;const{data:l}=await te({path:{mailboxId:s},query:{order:"desc",continuationToken:r},throwOnError:!0});for(const i of l.items)if(!i.isDeleted&&!t.has(i.messageId)&&!m.includes(i.messageId)&&(m.push(i.messageId),m.length>=a))return m;if(!l.continuationToken)break;r=l.continuationToken}return m},os=async(s,t)=>{let a=0,o;for(let m=0;m<de;m+=1){if(t.aborted)return a;const{data:r}=await te({path:{mailboxId:s},query:{order:"desc",continuationToken:o},throwOnError:!0});for(const u of r.items)u.isDeleted||(a+=1);if(!r.continuationToken)break;o=r.continuationToken}return a};function ls({accountId:s,mailboxId:t,onDeleted:a}){const o=Z(),[m,r]=c.useState("idle"),[u,l]=c.useState(null),[i,d]=c.useState(),[g,p]=c.useState(),v=c.useRef(null),y=c.useRef(void 0),h=c.useCallback(()=>{o.invalidateQueries({queryKey:ee({path:{accountId:s}})}),o.invalidateQueries({queryKey:se()})},[o,s]),f=c.useCallback(async()=>{r("deleting");const k=await $(ye({path:{accountId:s,mailboxId:t},throwOnError:!0}));if(!k.ok){d(k.error),r("error");return}h(),r("done"),a()},[s,t,h,a]),O=c.useCallback(()=>je({path:{accountId:s},throwOnError:!0}).then(({data:k})=>k.items.find(S=>S.mailboxId===t)?.messageCount??0),[s,t]),M=c.useCallback(()=>o.fetchQuery({...Ne({path:{accountId:s}}),staleTime:0}).then(k=>k.mailboxes??[]),[o,s]),w=c.useCallback(async()=>{const k=new AbortController;v.current=k;const{signal:S}=k;r("checking"),d(void 0);const I=y.current!==void 0,C=await $((async()=>(I||(S.throwIfAborted(),y.current=as(await M(),t),S.throwIfAborted(),p(Date.now()),await ke({path:{accountId:s},throwOnError:!0})),rs({readMailboxes:M,mailboxId:t,since:y.current??0,signal:S})))());return S.aborted?(r("idle"),y.current=void 0,{status:"failed"}):C.ok?C.value.status==="pending"?(r("check-stalled"),{status:"pending"}):(y.current=void 0,C.value.messageCount>0?(r("idle"),h(),{status:"blocked",messageCount:C.value.messageCount}):(await f(),{status:"deleted"})):(y.current=void 0,d(C.error),r("error"),{status:"failed"})},[s,t,M,f,h]),A=c.useCallback(()=>{v.current?.abort()},[]),j=c.useCallback(async k=>{const S=new AbortController;v.current=S;const{signal:I}=S;r("moving"),d(void 0);const C=await $(O());if(I.aborted)return;if(!C.ok){d(C.error),r("error");return}let x=Ce(C.value);l(x);const E=new Set;for(;;){if(I.aborted)return;const n=await $(is(t,E,Ie,I));if(I.aborted)return;if(!n.ok){x=_(x,n.error),l(x),d(n.error),r("error");return}const b=n.value;if(b.length===0)break;const T=await $(we({body:{messageIds:b,destinationMailboxId:k},throwOnError:!0}));if(I.aborted)return;if(!T.ok){x=_(x,T.error),l(x),d(T.error),r("error");return}for(const F of b)E.add(F);x=Se(x,b.length),l(x)}const D=await $(os(t,I));if(!I.aborted){if(!D.ok){x=_(x,D.error),l(x),d(D.error),r("error");return}if(D.value>0){const n=`${D.value} ${D.value===1?"email is":"emails are"} still syncing. Re-open delete to finish removing this folder.`;x=_(x,n),l(x),d(n),r("error"),h();return}await f()}},[t,O,f,h]),R=c.useCallback(()=>{v.current?.abort(),v.current=null,y.current=void 0,r("idle"),l(null),d(void 0),p(void 0)},[]);return{phase:m,progress:u,errorMessage:i,checkStartedAt:g,deleteMailbox:f,deleteIfEmpty:w,moveThenDelete:j,cancel:A,reset:R}}const z=s=>`${s} ${s===1?"email":"emails"}`;function cs({open:s,accountId:t,folder:a,mailboxes:o,appointments:m,onClose:r}){const[u,l]=c.useState(()=>Q(a.messageCount)),[i,d]=c.useState(),[g,p]=c.useState(),{createFolderIn:v}=ae(t),y=re(),{phase:h,progress:f,errorMessage:O,checkStartedAt:M,deleteMailbox:w,deleteIfEmpty:A,moveThenDelete:j,cancel:R,reset:k}=ls({accountId:t,mailboxId:a.mailboxId,onDeleted:r}),[S,I]=c.useState("0:00"),C=h==="checking"||h==="check-stalled";c.useEffect(()=>{if(!C||M===void 0)return;const P=()=>I(Ae(Date.now()-M));P();const ue=setInterval(P,1e3);return()=>clearInterval(ue)},[C,M]),c.useEffect(()=>{s&&(l(Q(a.messageCount)),d(void 0),k())},[s,k]),c.useEffect(()=>{s&&p(void 0)},[s]),c.useEffect(()=>R,[R]);const x=c.useCallback(()=>{R(),r()},[R,r]),E=c.useCallback(async()=>{const P=await A();P.status==="blocked"&&(d(P.messageCount),l("choose-fate"))},[A]),D=c.useMemo(()=>Me({mailboxes:o,folderAppointments:m,excludeMailboxId:a.mailboxId,translator:y}),[o,m,a.mailboxId,y]),n=D.find(P=>P.id===g),b=c.useMemo(()=>G(a,ne(m).get(a.mailboxId),y),[a,m,y]);if(!s)return null;const T=`Delete ${b}`,F=i??a.messageCount,me=h==="moving"?e.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[e.jsx(H,{className:"size-8 animate-spin text-accent-2"}),e.jsx("p",{className:"text-sm font-medium text-fg",children:"Moving emails…"}),e.jsx("p",{className:"text-xs text-fg-muted",role:"status","aria-live":"polite",children:f?V(f):"Moved 0 of 0"})]}):h==="checking"?e.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[e.jsx(H,{className:"size-8 animate-spin text-accent-2"}),e.jsx("p",{className:"text-sm font-medium text-fg",children:"Checking the folder on the mail server…"}),e.jsx("p",{className:"text-xs text-fg-muted",role:"status","aria-live":"polite",children:`Waiting ${S}. Nothing is deleted until the server answers.`})]}):h==="check-stalled"?e.jsxs("div",{className:"space-y-4 px-5 py-4",children:[e.jsx(L,{tone:"warning",variant:"soft",children:`The mail server hasn't reported back on this folder yet — ${S} so far. Nothing has been deleted.`}),e.jsx("p",{className:"text-xs text-fg-muted",children:"A sync covers the whole account, so a busy mailbox can take a while to come round to this folder."}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(N,{variant:"secondary",size:"sm",onClick:x,children:"Cancel"}),e.jsx(N,{size:"sm",onClick:()=>E(),children:"Keep waiting"})]})]}):h==="deleting"||h==="done"?e.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[e.jsx(H,{className:"size-8 animate-spin text-accent-2"}),e.jsx("p",{className:"text-sm font-medium text-fg",children:"Deleting folder…"})]}):h==="error"?e.jsxs("div",{className:"space-y-4 px-5 py-4",children:[e.jsx(L,{tone:"danger",variant:"soft",children:O??"Something went wrong. Please try again."}),f&&e.jsxs("p",{className:"text-xs text-fg-muted",children:[V(f),". Already-moved emails stay moved — re-open delete to continue with the rest."]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(N,{variant:"secondary",size:"sm",onClick:x,children:"Close"})})]}):u==="confirm-empty"?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-3 px-5 py-4 text-sm text-fg-muted",children:e.jsxs("p",{children:["Delete ",e.jsx("strong",{className:"text-fg",children:b}),"? This folder is empty and will be removed from the server."]})}),e.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[e.jsx(N,{variant:"secondary",size:"sm",onClick:x,children:"Cancel"}),e.jsx(N,{variant:"danger",size:"sm",icon:e.jsx(B,{className:"size-3.5"}),onClick:()=>E(),children:"Delete folder"})]})]}):u==="choose-fate"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-3 px-5 py-4 text-sm text-fg-muted",children:[i!==void 0&&e.jsx(L,{tone:"warning",variant:"soft",children:`This folder is not empty: the mail server reports ${z(i)} in it. Nothing was deleted.`}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:b})," holds"," ",z(F),". What should happen to them?"]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("button",{type:"button",onClick:()=>l("confirm-delete-all"),className:"flex w-full items-center gap-3 rounded-sm border border-line px-3 py-2.5 text-left hover:bg-surface-raised",children:[e.jsx(B,{className:"size-4 shrink-0 text-danger"}),e.jsxs("span",{className:"flex-1",children:[e.jsx("span",{className:"block text-sm font-medium text-fg",children:"Delete them with the folder"}),e.jsx("span",{className:"block text-xs text-fg-muted",children:"The emails are removed from the server and can't be recovered."})]})]}),e.jsxs("button",{type:"button",onClick:()=>l("pick-destination"),className:"flex w-full items-center gap-3 rounded-sm border border-line px-3 py-2.5 text-left hover:bg-surface-raised",children:[e.jsx(Ee,{className:"size-4 shrink-0 text-accent-2"}),e.jsxs("span",{className:"flex-1",children:[e.jsx("span",{className:"block text-sm font-medium text-fg",children:"Move them to another folder"}),e.jsx("span",{className:"block text-xs text-fg-muted",children:"Keep the emails, then delete the emptied folder."})]})]})]})]}),e.jsx("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:e.jsx(N,{variant:"secondary",size:"sm",onClick:x,children:"Cancel"})})]}):u==="confirm-delete-all"?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-3 px-5 py-4 text-sm text-fg-muted",children:e.jsxs("p",{children:["Delete ",e.jsx("strong",{className:"text-fg",children:b})," and its"," ",z(F),"? The messages are removed from the server with the folder and can't be recovered."]})}),e.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[e.jsx(N,{variant:"secondary",size:"sm",onClick:()=>l("choose-fate"),children:"Back"}),e.jsx(N,{variant:"danger",size:"sm",icon:e.jsx(B,{className:"size-3.5"}),onClick:()=>w(),children:"Delete folder and emails"})]})]}):e.jsxs("div",{className:"flex h-[26rem] flex-col",children:[e.jsxs("p",{className:"px-5 pt-4 text-sm text-fg-muted",children:["Move the ",z(F)," in"," ",e.jsx("strong",{className:"text-fg",children:b})," to:"]}),e.jsx("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:e.jsx(Y,{folders:D,selectedId:g,delimiter:o[0]?.hierarchyDelimiter??"/",onSelect:p,onCreateFolder:v,onCancel:()=>{p(void 0),l("choose-fate")},labels:{filterPlaceholder:"Move emails to…"}})}),n&&e.jsx("footer",{className:"shrink-0 border-t border-line p-2",children:e.jsx(N,{variant:"danger",onClick:()=>j(n.id),className:"h-11 w-full font-semibold",children:e.jsx("span",{className:"truncate",children:`Move ${z(F)} to ${n.label}`})})})]});return e.jsxs(W,{open:s,onClose:x,title:T,children:[e.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[e.jsx(De,{className:"size-4 shrink-0 text-danger"}),e.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:T}),e.jsx(N,{variant:"ghost",size:"sm",icon:e.jsx(X,{className:"size-3.5"}),onClick:x,"aria-label":"Cancel"})]}),me]})}const ds=e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{children:"Each canonical role — Inbox, Drafts, Sent, Archive, Spam, Trash — points at one of your account's real folders. Pick the one that actually holds the mail; the message counts tell real folders from empty look-alikes."}),e.jsx("p",{children:`Appointing a folder to a role here doesn't touch any other role, and doesn't move or rename anything on the server — it just tells Remit which folder to treat as e.g. "Drafts" everywhere (sidebar, unread badges, the compose flow).`}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Your folders"})," is the account's real hierarchy. Open a folder to see what's inside it, make a new one where you're looking, and rename or delete any of them from its row."]})]});function ms({account:s}){const t=Z(),a=s.accountId,o=re(),{data:m,isPending:r,isError:u,error:l,refetch:i}=ie(Fe({path:{accountId:a}})),{createFolderIn:d}=ae(a),g=U({...$e(),onSuccess:()=>{t.invalidateQueries({queryKey:se()})}}),p=U({...ze(),onSuccess:()=>{t.invalidateQueries({queryKey:ee({path:{accountId:a}})})}}),[v,y]=c.useState(),[h,f]=c.useState(),[O,M]=c.useState(""),w=c.useMemo(()=>m?.items??[],[m]),A=c.useMemo(()=>ne(s.folderAppointments),[s.folderAppointments]),j=c.useMemo(()=>w.map(n=>({id:n.mailboxId,label:G(n,A.get(n.mailboxId),o),path:n.fullPath,deleteBlockedReason:Le(n,w,s.folderAppointments).message})),[w,A,o,s.folderAppointments]),R=(n,b)=>{g.mutate({path:{accountId:a,role:Ge[n]},body:{mailboxId:b}})},k=(n,b)=>{const T=b.trim();p.mutate({path:{accountId:a,mailboxId:n},body:{displayNameOverride:T===""?null:T}})};if(r)return e.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":`Loading folders for ${s.email}`});if(u)return e.jsx(oe,{variant:"inline",title:`Couldn't load folders for ${s.email}`,error:l,onRetry:()=>{i()}});const S=w.map(n=>({mailboxId:n.mailboxId,providerPath:n.fullPath,hierarchyDelimiter:n.hierarchyDelimiter,messageCount:n.messageCount})),I={};for(const n of s.folderAppointments){const b=_e[n.role];b&&(I[b]={mailboxId:n.mailboxId??null,source:n.source,staleFolderPath:n.staleAppointmentPath})}const C={};for(const n of w)n.displayNameOverride&&(C[n.mailboxId]=n.displayNameOverride);const x=n=>w.find(b=>b.mailboxId===n),E=x(h),D=x(v);return e.jsxs("div",{className:"space-y-4",children:[(g.isError||p.isError)&&e.jsx(L,{tone:"danger",variant:"soft",children:Be(g.error)?"That folder is still being created on the mail server — wait for it to finish, then try again.":"Couldn't save that change. Please try again."}),e.jsx(Ze,{accountEmail:s.email,folders:S,appointments:I,displayNames:C,onAppoint:R,onRename:k}),e.jsxs("section",{className:"space-y-1.5",children:[e.jsxs("h3",{className:"text-sm font-semibold text-fg",children:["Your folders — ",s.email]}),e.jsx("div",{className:"flex h-[28rem] flex-col overflow-hidden rounded-sm border border-line bg-surface",children:e.jsx(Qe,{folders:j,delimiter:w[0]?.hierarchyDelimiter??"/",onCreateFolder:d,onRename:n=>{f(n.id),M(x(n.id)?.displayNameOverride?.trim()??"")},onDelete:n=>y(n.id),labels:{treeAriaLabel:`All folders for ${s.email}`}})})]}),E&&e.jsx(Ve,{open:!0,folderLabel:G(E,A.get(E.mailboxId),o),defaultLabel:G({fullPath:E.fullPath,hierarchyDelimiter:E.hierarchyDelimiter},A.get(E.mailboxId),o),name:O,onNameChange:M,pending:p.isPending,error:p.isError?"Couldn't save that name. Please try again.":void 0,onSubmit:()=>{const n=O.trim();p.mutate({path:{accountId:a,mailboxId:E.mailboxId},body:{displayNameOverride:n===""?null:n}},{onSuccess:()=>f(void 0)})},onClose:()=>f(void 0)}),D&&e.jsx(cs,{open:!0,accountId:a,folder:D,mailboxes:w,appointments:s.folderAppointments,onClose:()=>y(void 0)})]})}function vs(){const s=Oe(),[t,a]=c.useState(!0),{data:o,isPending:m,isError:r,error:u,refetch:l}=ie(Te()),i=d=>{const g=Pe[d];g&&s({to:g})};return e.jsx(qe,{items:Re,activeId:"folders",title:"Folder roles",description:"Appoint which real folder fills each canonical role, per account.",help:ds,helpOpen:t,onToggleHelp:()=>a(d=>!d),onSelect:i,onBackToMail:()=>{s({to:"/mail"})},children:m?e.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":"Loading accounts"}):r?e.jsx(oe,{title:"Couldn't load accounts",error:u,onRetry:()=>{l()}}):o.accounts.length===0?e.jsx("p",{className:"py-12 text-sm text-fg-muted",children:"No accounts configured."}):e.jsx("div",{className:"space-y-8",children:o.accounts.map(d=>e.jsx(ms,{account:d},d.accountId))})})}export{vs as component};
1
+ import{j as e,B as N,T as B,b9 as Y,r as c,az as W,X,aI as he,ap as J,F as xe,ba as K,bb as fe,ao as pe,as as ge,aE as L,aL as be,bc as ve,x as Z,Y as ee,a5 as se,bd as ye,be as je,aJ as Ne,W as ke,bf as Ce,bg as _,bh as we,bi as Se,bj as te,bk as Ie,bl as Q,b0 as ae,b6 as re,b7 as Me,H as G,G as ne,ar as H,bm as V,bn as Ee,af as De,bo as Ae,a0 as Oe,D as ie,a1 as Te,aD as Re,aH as Pe,z as Fe,aj as U,bp as $e,bq as ze,br as Le,aP as _e,bs as Be,bt as Ge}from"./index-CrStk0va.js";import{P as He}from"./pencil-Dwwmy-LK.js";import{S as qe}from"./settings-screen-YvTik_VI.js";import{E as oe}from"./ErrorState-D5cn-r_g.js";import"./avatar-DVEp71DP.js";import"./menu-CVMIxRRy.js";import"./circle-help-KBbSqlpB.js";const Ke=({label:s,onRename:t,onDelete:a,deleteBlockedReason:o,renameLabel:m=u=>`Rename ${u}`,deleteLabel:r=u=>`Delete ${u}`})=>{const u=o?`${r(s)} — ${o}`:r(s);return e.jsxs("span",{className:"flex shrink-0 items-center gap-0.5 pr-2",children:[e.jsx(N,{variant:"ghost",size:"sm",icon:e.jsx(He,{className:"size-3.5"}),"aria-label":m(s),onClick:t}),e.jsx("span",{title:o,children:e.jsx(N,{variant:"ghost",size:"sm",icon:e.jsx(B,{className:"size-3.5"}),"aria-label":u,disabled:o!==void 0,onClick:a})})]})},Qe=({folders:s,onRename:t,onDelete:a,onCreateFolder:o,delimiter:m,labels:r})=>{const u=new Map(s.map(l=>[l.id,l]));return e.jsx(Y,{folders:s,onCreateFolder:o,delimiter:m,labels:{treeAriaLabel:"Your folders",optionLabel:l=>l.label,...r},rowActions:l=>{const i=u.get(l.id);return i?e.jsx(Ke,{label:i.label,deleteBlockedReason:i.deleteBlockedReason,renameLabel:r?.rename,deleteLabel:r?.remove,onRename:()=>t(i),onDelete:()=>a(i)}):null}})},Ve=({open:s,folderLabel:t,defaultLabel:a,name:o,onNameChange:m,onSubmit:r,onClose:u,pending:l=!1,error:i})=>{const d=c.useId(),g=`Rename ${t}`;return s?e.jsxs(W,{open:s,onClose:u,title:g,children:[e.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[e.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:g}),e.jsx(N,{variant:"ghost",size:"sm",icon:e.jsx(X,{className:"size-3.5"}),onClick:u,"aria-label":"Cancel"})]}),e.jsxs("div",{className:"space-y-3 px-5 py-4",children:[e.jsxs("div",{children:[e.jsx(he,{htmlFor:d,children:"Folder name"}),e.jsx(J,{id:d,value:o,placeholder:a,onChange:p=>m(p.target.value),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),r())}})]}),e.jsxs("p",{className:"text-xs text-fg-muted",children:["Shown everywhere in Remit. Leave it blank to use"," ",e.jsx("span",{className:"font-medium text-fg",children:a}),"."]}),i&&e.jsx("p",{className:"text-xs text-danger",role:"alert",children:i})]}),e.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[e.jsx(N,{variant:"secondary",size:"sm",onClick:u,children:"Cancel"}),e.jsx(N,{variant:"primary",size:"sm",onClick:r,disabled:l,children:l?"Saving…":"Save name"})]})]}):null},Ue=["inbox","drafts","sent","archive","junk","trash"],q="",Ye={mailboxId:null,source:"None"};function We(s){const t=s.messageCount===1?"msg":"msgs";return`${K(s.providerPath,s.hierarchyDelimiter)} · ${s.messageCount} ${t}`}const le=s=>`${s} ${s===1?"message":"messages"}`,Xe=(s,t)=>s==="Appointed"?"Chosen by you":s==="Flagged"?`The mail server marks it as ${t}`:s==="Reserved"?"The account's own INBOX":"Matched by name, not confirmed";function Je({role:s,folders:t,appointment:a,displayName:o,onAppoint:m,onRename:r}){const[u,l]=c.useState(o),i=c.useRef(null),d=c.useRef(!1),g=c.useId(),{mailboxId:p,source:v,staleFolderPath:y}=a,h=t.find(j=>j.mailboxId===p)??null,f=be(s),O=h!=null&&u.trim()!==o.trim();c.useEffect(()=>{!d.current||v==="Proposed"||(d.current=!1,i.current?.focus())},[v]);const M=(()=>{if(v==="None"){const j=s==="trash"?" Deleting mail needs one.":"";return e.jsx("span",{id:g,className:"pl-[7.5rem] text-xs text-fg-muted",children:`Not set — pick the folder this account uses for ${f}.${j}`})}return v==="Stale"||!h?null:e.jsx("span",{id:g,className:"truncate pl-[7.5rem] text-2xs text-fg-subtle",title:h.providerPath,children:`${Xe(v,f)} · ${h.providerPath} · ${le(h.messageCount)}`})})(),w=s==="trash"?" Deleting mail is stopped until you pick another one.":h?` reader is using ${K(h.providerPath,h.hierarchyDelimiter)} instead.`:"",A=`The folder you chose for ${f}${y?` — ${y} —`:""} is gone from the mail server.${w}`;return e.jsxs("div",{className:"flex flex-col gap-1 border-b border-line px-row-inset py-2.5 last:border-b-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"flex w-28 shrink-0 items-center gap-2 text-sm font-medium text-fg",children:[fe(s),f]}),e.jsxs(pe,{ref:i,className:"w-56 shrink-0",value:p??q,"aria-label":`Folder for ${f}`,"aria-describedby":M||v==="Stale"?g:void 0,onChange:j=>m(s,j.target.value===q?null:j.target.value),children:[e.jsx("option",{value:q,children:"None"}),t.map(j=>e.jsx("option",{value:j.mailboxId,children:We(j)},j.mailboxId))]}),v==="Proposed"&&h&&e.jsx(N,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>{d.current=!0,m(s,h.mailboxId)},children:`Set as ${f}`}),h&&e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"flex-1",value:u,placeholder:f,"aria-label":`Display name for ${f}`,onChange:j=>l(j.target.value)}),O&&e.jsx(N,{variant:"ghost",size:"sm",className:"shrink-0",icon:e.jsx(ge,{className:"size-4"}),"aria-label":"Save display name",onClick:()=>r(h.mailboxId,u)})]})]}),M,v==="Stale"&&e.jsx(L,{tone:"warning",variant:"soft",className:"ml-[7.5rem]",children:e.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{id:g,className:"flex-1",children:A}),e.jsx(N,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>i.current?.focus(),children:"Pick a folder"})]})})]})}function Ze({accountEmail:s,folders:t,appointments:a,displayNames:o={},onAppoint:m,onRename:r}){const u=new Set(Object.values(a).map(i=>i.mailboxId).filter(i=>i!=null)),l=t.filter(i=>!u.has(i.mailboxId));return e.jsxs("section",{className:"space-y-3",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsxs("h2",{className:"text-sm font-semibold text-fg",children:["Folder roles — ",s]}),e.jsx("p",{className:"text-xs text-fg-muted",children:"Each role points to one folder. Pick the folder that holds the mail — the counts help you tell real folders from empty look-alikes. Appointing a folder here removes it from any other role. Each row says where its answer came from — your choice, the mail server's own flag, or a name reader matched."})]}),e.jsx("div",{className:"rounded-sm border border-line bg-surface",children:Ue.map(i=>{const d=a[i]??Ye;return e.jsx(Je,{role:i,folders:t,appointment:d,displayName:d.mailboxId?o[d.mailboxId]??"":"",onAppoint:m,onRename:r},i)})}),l.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h3",{className:"text-xs font-medium text-fg-muted",children:"Other folders"}),e.jsx("ul",{className:"rounded-sm border border-line bg-surface",children:l.map(i=>e.jsxs("li",{className:"flex items-center gap-2 border-b border-line px-row-inset py-2 text-sm text-fg last:border-b-0",children:[e.jsx(xe,{className:"size-4 shrink-0 text-fg-subtle"}),e.jsx("span",{className:"truncate",children:K(i.providerPath,i.hierarchyDelimiter)}),e.jsx("span",{className:"ml-auto shrink-0 text-2xs text-fg-subtle",children:le(i.messageCount)})]},i.mailboxId))})]})]})}const es=12e4,ss=2e3,ts="This folder is no longer in the account's folder list, so nothing was deleted.",ce=(s,t)=>{const a=s.find(o=>o.mailboxId===t);if(!a)throw new Error(ts);return a},as=(s,t)=>ce(s,t).lastSyncedAt??0;async function rs({readMailboxes:s,mailboxId:t,since:a,signal:o,segmentMs:m=es,pollIntervalMs:r=ss,delay:u=ve,now:l=Date.now}){const i=l()+m;for(;;){o?.throwIfAborted();const d=ce(await s(),t);if((d.lastSyncedAt??0)>a)return{status:"fresh",messageCount:d.messagesTotal};if(l()>=i)return{status:"pending"};await u(r,o)}}const de=50,ns=s=>s instanceof Error?s.message:"Something went wrong.",$=s=>s.then(t=>({ok:!0,value:t}),t=>({ok:!1,error:ns(t)})),is=async(s,t,a,o)=>{const m=[];let r;for(let u=0;u<de;u+=1){if(o.aborted)return m;const{data:l}=await te({path:{mailboxId:s},query:{order:"desc",continuationToken:r},throwOnError:!0});for(const i of l.items)if(!i.isDeleted&&!t.has(i.messageId)&&!m.includes(i.messageId)&&(m.push(i.messageId),m.length>=a))return m;if(!l.continuationToken)break;r=l.continuationToken}return m},os=async(s,t)=>{let a=0,o;for(let m=0;m<de;m+=1){if(t.aborted)return a;const{data:r}=await te({path:{mailboxId:s},query:{order:"desc",continuationToken:o},throwOnError:!0});for(const u of r.items)u.isDeleted||(a+=1);if(!r.continuationToken)break;o=r.continuationToken}return a};function ls({accountId:s,mailboxId:t,onDeleted:a}){const o=Z(),[m,r]=c.useState("idle"),[u,l]=c.useState(null),[i,d]=c.useState(),[g,p]=c.useState(),v=c.useRef(null),y=c.useRef(void 0),h=c.useCallback(()=>{o.invalidateQueries({queryKey:ee({path:{accountId:s}})}),o.invalidateQueries({queryKey:se()})},[o,s]),f=c.useCallback(async()=>{r("deleting");const k=await $(ye({path:{accountId:s,mailboxId:t},throwOnError:!0}));if(!k.ok){d(k.error),r("error");return}h(),r("done"),a()},[s,t,h,a]),O=c.useCallback(()=>je({path:{accountId:s},throwOnError:!0}).then(({data:k})=>k.items.find(S=>S.mailboxId===t)?.messageCount??0),[s,t]),M=c.useCallback(()=>o.fetchQuery({...Ne({path:{accountId:s}}),staleTime:0}).then(k=>k.mailboxes??[]),[o,s]),w=c.useCallback(async()=>{const k=new AbortController;v.current=k;const{signal:S}=k;r("checking"),d(void 0);const I=y.current!==void 0,C=await $((async()=>(I||(S.throwIfAborted(),y.current=as(await M(),t),S.throwIfAborted(),p(Date.now()),await ke({path:{accountId:s},throwOnError:!0})),rs({readMailboxes:M,mailboxId:t,since:y.current??0,signal:S})))());return S.aborted?(r("idle"),y.current=void 0,{status:"failed"}):C.ok?C.value.status==="pending"?(r("check-stalled"),{status:"pending"}):(y.current=void 0,C.value.messageCount>0?(r("idle"),h(),{status:"blocked",messageCount:C.value.messageCount}):(await f(),{status:"deleted"})):(y.current=void 0,d(C.error),r("error"),{status:"failed"})},[s,t,M,f,h]),A=c.useCallback(()=>{v.current?.abort()},[]),j=c.useCallback(async k=>{const S=new AbortController;v.current=S;const{signal:I}=S;r("moving"),d(void 0);const C=await $(O());if(I.aborted)return;if(!C.ok){d(C.error),r("error");return}let x=Ce(C.value);l(x);const E=new Set;for(;;){if(I.aborted)return;const n=await $(is(t,E,Ie,I));if(I.aborted)return;if(!n.ok){x=_(x,n.error),l(x),d(n.error),r("error");return}const b=n.value;if(b.length===0)break;const T=await $(we({body:{messageIds:b,destinationMailboxId:k},throwOnError:!0}));if(I.aborted)return;if(!T.ok){x=_(x,T.error),l(x),d(T.error),r("error");return}for(const F of b)E.add(F);x=Se(x,b.length),l(x)}const D=await $(os(t,I));if(!I.aborted){if(!D.ok){x=_(x,D.error),l(x),d(D.error),r("error");return}if(D.value>0){const n=`${D.value} ${D.value===1?"email is":"emails are"} still syncing. Re-open delete to finish removing this folder.`;x=_(x,n),l(x),d(n),r("error"),h();return}await f()}},[t,O,f,h]),R=c.useCallback(()=>{v.current?.abort(),v.current=null,y.current=void 0,r("idle"),l(null),d(void 0),p(void 0)},[]);return{phase:m,progress:u,errorMessage:i,checkStartedAt:g,deleteMailbox:f,deleteIfEmpty:w,moveThenDelete:j,cancel:A,reset:R}}const z=s=>`${s} ${s===1?"email":"emails"}`;function cs({open:s,accountId:t,folder:a,mailboxes:o,appointments:m,onClose:r}){const[u,l]=c.useState(()=>Q(a.messageCount)),[i,d]=c.useState(),[g,p]=c.useState(),{createFolderIn:v}=ae(t),y=re(),{phase:h,progress:f,errorMessage:O,checkStartedAt:M,deleteMailbox:w,deleteIfEmpty:A,moveThenDelete:j,cancel:R,reset:k}=ls({accountId:t,mailboxId:a.mailboxId,onDeleted:r}),[S,I]=c.useState("0:00"),C=h==="checking"||h==="check-stalled";c.useEffect(()=>{if(!C||M===void 0)return;const P=()=>I(Ae(Date.now()-M));P();const ue=setInterval(P,1e3);return()=>clearInterval(ue)},[C,M]),c.useEffect(()=>{s&&(l(Q(a.messageCount)),d(void 0),k())},[s,k]),c.useEffect(()=>{s&&p(void 0)},[s]),c.useEffect(()=>R,[R]);const x=c.useCallback(()=>{R(),r()},[R,r]),E=c.useCallback(async()=>{const P=await A();P.status==="blocked"&&(d(P.messageCount),l("choose-fate"))},[A]),D=c.useMemo(()=>Me({mailboxes:o,folderAppointments:m,excludeMailboxId:a.mailboxId,translator:y}),[o,m,a.mailboxId,y]),n=D.find(P=>P.id===g),b=c.useMemo(()=>G(a,ne(m).get(a.mailboxId),y),[a,m,y]);if(!s)return null;const T=`Delete ${b}`,F=i??a.messageCount,me=h==="moving"?e.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[e.jsx(H,{className:"size-8 animate-spin text-accent-2"}),e.jsx("p",{className:"text-sm font-medium text-fg",children:"Moving emails…"}),e.jsx("p",{className:"text-xs text-fg-muted",role:"status","aria-live":"polite",children:f?V(f):"Moved 0 of 0"})]}):h==="checking"?e.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[e.jsx(H,{className:"size-8 animate-spin text-accent-2"}),e.jsx("p",{className:"text-sm font-medium text-fg",children:"Checking the folder on the mail server…"}),e.jsx("p",{className:"text-xs text-fg-muted",role:"status","aria-live":"polite",children:`Waiting ${S}. Nothing is deleted until the server answers.`})]}):h==="check-stalled"?e.jsxs("div",{className:"space-y-4 px-5 py-4",children:[e.jsx(L,{tone:"warning",variant:"soft",children:`The mail server hasn't reported back on this folder yet — ${S} so far. Nothing has been deleted.`}),e.jsx("p",{className:"text-xs text-fg-muted",children:"A sync covers the whole account, so a busy mailbox can take a while to come round to this folder."}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(N,{variant:"secondary",size:"sm",onClick:x,children:"Cancel"}),e.jsx(N,{size:"sm",onClick:()=>E(),children:"Keep waiting"})]})]}):h==="deleting"||h==="done"?e.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[e.jsx(H,{className:"size-8 animate-spin text-accent-2"}),e.jsx("p",{className:"text-sm font-medium text-fg",children:"Deleting folder…"})]}):h==="error"?e.jsxs("div",{className:"space-y-4 px-5 py-4",children:[e.jsx(L,{tone:"danger",variant:"soft",children:O??"Something went wrong. Please try again."}),f&&e.jsxs("p",{className:"text-xs text-fg-muted",children:[V(f),". Already-moved emails stay moved — re-open delete to continue with the rest."]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(N,{variant:"secondary",size:"sm",onClick:x,children:"Close"})})]}):u==="confirm-empty"?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-3 px-5 py-4 text-sm text-fg-muted",children:e.jsxs("p",{children:["Delete ",e.jsx("strong",{className:"text-fg",children:b}),"? This folder is empty and will be removed from the server."]})}),e.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[e.jsx(N,{variant:"secondary",size:"sm",onClick:x,children:"Cancel"}),e.jsx(N,{variant:"danger",size:"sm",icon:e.jsx(B,{className:"size-3.5"}),onClick:()=>E(),children:"Delete folder"})]})]}):u==="choose-fate"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-3 px-5 py-4 text-sm text-fg-muted",children:[i!==void 0&&e.jsx(L,{tone:"warning",variant:"soft",children:`This folder is not empty: the mail server reports ${z(i)} in it. Nothing was deleted.`}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:b})," holds"," ",z(F),". What should happen to them?"]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("button",{type:"button",onClick:()=>l("confirm-delete-all"),className:"flex w-full items-center gap-3 rounded-sm border border-line px-3 py-2.5 text-left hover:bg-surface-raised",children:[e.jsx(B,{className:"size-4 shrink-0 text-danger"}),e.jsxs("span",{className:"flex-1",children:[e.jsx("span",{className:"block text-sm font-medium text-fg",children:"Delete them with the folder"}),e.jsx("span",{className:"block text-xs text-fg-muted",children:"The emails are removed from the server and can't be recovered."})]})]}),e.jsxs("button",{type:"button",onClick:()=>l("pick-destination"),className:"flex w-full items-center gap-3 rounded-sm border border-line px-3 py-2.5 text-left hover:bg-surface-raised",children:[e.jsx(Ee,{className:"size-4 shrink-0 text-accent-2"}),e.jsxs("span",{className:"flex-1",children:[e.jsx("span",{className:"block text-sm font-medium text-fg",children:"Move them to another folder"}),e.jsx("span",{className:"block text-xs text-fg-muted",children:"Keep the emails, then delete the emptied folder."})]})]})]})]}),e.jsx("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:e.jsx(N,{variant:"secondary",size:"sm",onClick:x,children:"Cancel"})})]}):u==="confirm-delete-all"?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-3 px-5 py-4 text-sm text-fg-muted",children:e.jsxs("p",{children:["Delete ",e.jsx("strong",{className:"text-fg",children:b})," and its"," ",z(F),"? The messages are removed from the server with the folder and can't be recovered."]})}),e.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[e.jsx(N,{variant:"secondary",size:"sm",onClick:()=>l("choose-fate"),children:"Back"}),e.jsx(N,{variant:"danger",size:"sm",icon:e.jsx(B,{className:"size-3.5"}),onClick:()=>w(),children:"Delete folder and emails"})]})]}):e.jsxs("div",{className:"flex h-[26rem] flex-col",children:[e.jsxs("p",{className:"px-5 pt-4 text-sm text-fg-muted",children:["Move the ",z(F)," in"," ",e.jsx("strong",{className:"text-fg",children:b})," to:"]}),e.jsx("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:e.jsx(Y,{folders:D,selectedId:g,delimiter:o[0]?.hierarchyDelimiter??"/",onSelect:p,onCreateFolder:v,onCancel:()=>{p(void 0),l("choose-fate")},labels:{filterPlaceholder:"Move emails to…"}})}),n&&e.jsx("footer",{className:"shrink-0 border-t border-line p-2",children:e.jsx(N,{variant:"danger",onClick:()=>j(n.id),className:"h-11 w-full font-semibold",children:e.jsx("span",{className:"truncate",children:`Move ${z(F)} to ${n.label}`})})})]});return e.jsxs(W,{open:s,onClose:x,title:T,children:[e.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[e.jsx(De,{className:"size-4 shrink-0 text-danger"}),e.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:T}),e.jsx(N,{variant:"ghost",size:"sm",icon:e.jsx(X,{className:"size-3.5"}),onClick:x,"aria-label":"Cancel"})]}),me]})}const ds=e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{children:"Each canonical role — Inbox, Drafts, Sent, Archive, Spam, Trash — points at one of your account's real folders. Pick the one that actually holds the mail; the message counts tell real folders from empty look-alikes."}),e.jsx("p",{children:`Appointing a folder to a role here doesn't touch any other role, and doesn't move or rename anything on the server — it just tells Remit which folder to treat as e.g. "Drafts" everywhere (sidebar, unread badges, the compose flow).`}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Your folders"})," is the account's real hierarchy. Open a folder to see what's inside it, make a new one where you're looking, and rename or delete any of them from its row."]})]});function ms({account:s}){const t=Z(),a=s.accountId,o=re(),{data:m,isPending:r,isError:u,error:l,refetch:i}=ie(Fe({path:{accountId:a}})),{createFolderIn:d}=ae(a),g=U({...$e(),onSuccess:()=>{t.invalidateQueries({queryKey:se()})}}),p=U({...ze(),onSuccess:()=>{t.invalidateQueries({queryKey:ee({path:{accountId:a}})})}}),[v,y]=c.useState(),[h,f]=c.useState(),[O,M]=c.useState(""),w=c.useMemo(()=>m?.items??[],[m]),A=c.useMemo(()=>ne(s.folderAppointments),[s.folderAppointments]),j=c.useMemo(()=>w.map(n=>({id:n.mailboxId,label:G(n,A.get(n.mailboxId),o),path:n.fullPath,deleteBlockedReason:Le(n,w,s.folderAppointments).message})),[w,A,o,s.folderAppointments]),R=(n,b)=>{g.mutate({path:{accountId:a,role:Ge[n]},body:{mailboxId:b}})},k=(n,b)=>{const T=b.trim();p.mutate({path:{accountId:a,mailboxId:n},body:{displayNameOverride:T===""?null:T}})};if(r)return e.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":`Loading folders for ${s.email}`});if(u)return e.jsx(oe,{variant:"inline",title:`Couldn't load folders for ${s.email}`,error:l,onRetry:()=>{i()}});const S=w.map(n=>({mailboxId:n.mailboxId,providerPath:n.fullPath,hierarchyDelimiter:n.hierarchyDelimiter,messageCount:n.messageCount})),I={};for(const n of s.folderAppointments){const b=_e[n.role];b&&(I[b]={mailboxId:n.mailboxId??null,source:n.source,staleFolderPath:n.staleAppointmentPath})}const C={};for(const n of w)n.displayNameOverride&&(C[n.mailboxId]=n.displayNameOverride);const x=n=>w.find(b=>b.mailboxId===n),E=x(h),D=x(v);return e.jsxs("div",{className:"space-y-4",children:[(g.isError||p.isError)&&e.jsx(L,{tone:"danger",variant:"soft",children:Be(g.error)?"That folder is still being created on the mail server — wait for it to finish, then try again.":"Couldn't save that change. Please try again."}),e.jsx(Ze,{accountEmail:s.email,folders:S,appointments:I,displayNames:C,onAppoint:R,onRename:k}),e.jsxs("section",{className:"space-y-1.5",children:[e.jsxs("h3",{className:"text-sm font-semibold text-fg",children:["Your folders — ",s.email]}),e.jsx("div",{className:"flex h-[28rem] flex-col overflow-hidden rounded-sm border border-line bg-surface",children:e.jsx(Qe,{folders:j,delimiter:w[0]?.hierarchyDelimiter??"/",onCreateFolder:d,onRename:n=>{f(n.id),M(x(n.id)?.displayNameOverride?.trim()??"")},onDelete:n=>y(n.id),labels:{treeAriaLabel:`All folders for ${s.email}`}})})]}),E&&e.jsx(Ve,{open:!0,folderLabel:G(E,A.get(E.mailboxId),o),defaultLabel:G({fullPath:E.fullPath,hierarchyDelimiter:E.hierarchyDelimiter},A.get(E.mailboxId),o),name:O,onNameChange:M,pending:p.isPending,error:p.isError?"Couldn't save that name. Please try again.":void 0,onSubmit:()=>{const n=O.trim();p.mutate({path:{accountId:a,mailboxId:E.mailboxId},body:{displayNameOverride:n===""?null:n}},{onSuccess:()=>f(void 0)})},onClose:()=>f(void 0)}),D&&e.jsx(cs,{open:!0,accountId:a,folder:D,mailboxes:w,appointments:s.folderAppointments,onClose:()=>y(void 0)})]})}function vs(){const s=Oe(),[t,a]=c.useState(!0),{data:o,isPending:m,isError:r,error:u,refetch:l}=ie(Te()),i=d=>{const g=Pe[d];g&&s({to:g})};return e.jsx(qe,{items:Re,activeId:"folders",title:"Folder roles",description:"Appoint which real folder fills each canonical role, per account.",help:ds,helpOpen:t,onToggleHelp:()=>a(d=>!d),onSelect:i,onBackToMail:()=>{s({to:"/mail"})},children:m?e.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":"Loading accounts"}):r?e.jsx(oe,{title:"Couldn't load accounts",error:u,onRetry:()=>{l()}}):o.accounts.length===0?e.jsx("p",{className:"py-12 text-sm text-fg-muted",children:"No accounts configured."}):e.jsx("div",{className:"space-y-8",children:o.accounts.map(d=>e.jsx(ms,{account:d},d.accountId))})})}export{vs as component};
@@ -1 +1 @@
1
- import{j as e}from"./index-idulIG65.js";import{K as s}from"./kbd-eZWvlfcb.js";const a=e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"VIP"})," senders get priority surface in the daily brief and notification escalation, even when an account is quiet."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Muted"})," senders never notify and stay out of the brief. Their mail still syncs and stays searchable."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Blocked"})," senders never load images and go straight to junk."]}),e.jsxs("p",{children:["Tip: flag from the keyboard on any message — ",e.jsx(s,{children:"v"})," VIP,"," ",e.jsx(s,{children:"m"})," mute, ",e.jsx(s,{children:"b"})," block. Every rule an automation creates shows up here and can be removed."]})]}),r=e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Sync health"})," shows the IMAP connection state and the last successful sync per account."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Error"})," means the last connection attempt failed — the raw server response is shown on the card. Reconnect re-runs the connection test from the add-account wizard."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Muted"})," accounts keep syncing but stay out of the daily brief and unified counts."]})]}),c=e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Density"})," controls how much information fits on screen. Compact is great on smaller displays; Comfortable gives each item more breathing room."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Theme"})," switches between light, dark, and system-preference modes instantly. The change takes effect across the whole app immediately."]}),e.jsx("p",{className:"text-2xs text-fg-subtle",children:"Preferences are stored locally in this browser. Server-side sync is coming soon."})]}),i=e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Notification rules"})," and data export are coming in a future release."]}),e.jsxs("p",{children:["A message Remit cannot read is"," ",e.jsx("strong",{className:"text-fg",children:"set aside"})," rather than skipped, and the folder keeps syncing. Setting one aside is a defect in Remit, so every entry can be reported with the diagnostics already attached."]})]});export{r as a,i as b,c,a as s};
1
+ import{j as e}from"./index-CrStk0va.js";import{K as s}from"./kbd-CIM88W-i.js";const a=e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"VIP"})," senders get priority surface in the daily brief and notification escalation, even when an account is quiet."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Muted"})," senders never notify and stay out of the brief. Their mail still syncs and stays searchable."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Blocked"})," senders never load images and go straight to junk."]}),e.jsxs("p",{children:["Tip: flag from the keyboard on any message — ",e.jsx(s,{children:"v"})," VIP,"," ",e.jsx(s,{children:"m"})," mute, ",e.jsx(s,{children:"b"})," block. Every rule an automation creates shows up here and can be removed."]})]}),r=e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Sync health"})," shows the IMAP connection state and the last successful sync per account."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Error"})," means the last connection attempt failed — the raw server response is shown on the card. Reconnect re-runs the connection test from the add-account wizard."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Muted"})," accounts keep syncing but stay out of the daily brief and unified counts."]})]}),c=e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Density"})," controls how much information fits on screen. Compact is great on smaller displays; Comfortable gives each item more breathing room."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Theme"})," switches between light, dark, and system-preference modes instantly. The change takes effect across the whole app immediately."]}),e.jsx("p",{className:"text-2xs text-fg-subtle",children:"Preferences are stored locally in this browser. Server-side sync is coming soon."})]}),i=e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Notification rules"})," and data export are coming in a future release."]}),e.jsxs("p",{children:["A message Remit cannot read is"," ",e.jsx("strong",{className:"text-fg",children:"set aside"})," rather than skipped, and the folder keeps syncing. Setting one aside is a defect in Remit, so every entry can be reported with the diagnostics already attached."]})]});export{r as a,i as b,c,a as s};
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/rich-text-spellcheck-worker-provider-DTxcyJ9W.js","assets/index-idulIG65.js","assets/index-OWhz0EKb.css","assets/rich-text-spellcheck-provider-J8m9wz6A.js","assets/rich-text-DUWqcHC5.js","assets/confirm-dialog-BxXd7BDT.js","assets/bottom-sheet-BuEgZWXh.js","assets/attachment-file-CLrI3kMw.js","assets/useMessageBodyContent-5kw10g9a.js","assets/useSignature-osTmnWZe.js","assets/account-form-helpers-DhckT_PN.js","assets/useDebouncedValue-CntZIoMR.js"])))=>i.map(i=>d[i]);
2
- import{j as m,X as Sr,b as xr,B as en,ar as Cr,f as Rr,T as Dr,r as s,cp as Tr,cq as Ar,C as Nn,af as Or,cr as Nr,d as kr,cs as Pr,ct as Gt,bE as kn,cu as ye,cv as Pn,cw as Ir,a0 as In,x as Lr,aj as gt,cx as wt,cy as Mr,cz as _r,E as jr,D as yt,by as Fr,cA as Ln,aR as $r,aS as Br,a1 as Mn,cB as Hr,ah as Wr,cC as Ur,cD as tn,cE as Vr,bK as Ot,cF as zr,ak as qr,bD as Kr,ai as Yr,cG as Gr,b3 as Xr,cH as Qr,ag as C}from"./index-idulIG65.js";import{d as Zr}from"./useMessageBodyContent-5kw10g9a.js";import{u as Jr}from"./useSignature-osTmnWZe.js";import{b as eo}from"./account-form-helpers-DhckT_PN.js";import{u as to}from"./useDebouncedValue-CntZIoMR.js";const no=({email:e,displayName:t,onRemove:n,className:r})=>m.jsxs("span",{className:xr("inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-accent-2-soft text-sm max-w-[200px]",r),children:[m.jsx("span",{className:"truncate",children:t||e}),m.jsx("button",{type:"button",onClick:n,className:"shrink-0 p-0.5 rounded-full hover:bg-fg-muted/20 transition-colors","aria-label":`Remove ${e}`,children:m.jsx(Sr,{className:"size-3"})})]}),ro=({save:e})=>e.status==="saving"?m.jsx("output",{className:"animate-pulse text-xs text-fg-muted",children:"Saving..."}):e.status==="saved"?m.jsx("output",{className:"text-xs text-fg-muted",children:"Draft saved"}):e.status==="error"?m.jsx("output",{className:"text-xs text-danger",children:"Save failed"}):e.status==="unsaved"?m.jsx("output",{className:"truncate text-xs text-warning",children:e.reason}):null;function oo({send:e,onSend:t,onBlocked:n,onDiscard:r,save:o={status:"idle"}}){const a=e.status==="sending",i=e.status==="blocked"?e.reason:void 0;return m.jsxs("div",{className:"flex items-center justify-between border-t border-line px-3 py-2",children:[m.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[m.jsx(en,{variant:"primary",size:"md","aria-busy":a,title:i,className:"min-h-11 shrink-0 rounded-full px-4","data-testid":"compose-send",icon:a?m.jsx(Cr,{className:"size-4 animate-spin"}):m.jsx(Rr,{className:"size-4"}),onClick:()=>{if(!a){if(i!==void 0){n(i);return}t()}},children:"Send"}),m.jsx(ro,{save:o})]}),m.jsx(en,{variant:"ghost",size:"md","aria-busy":a,"aria-label":"Discard",className:"min-h-11 min-w-11 px-2 hover:text-danger",icon:m.jsx(Dr,{className:"size-4"}),onClick:()=>{a||r()}})]})}const nn=e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim()),ao=e=>{const t=e.trim();if(!t)return;const n=t.match(/^(.+?)\s*<([^>]+)>$/);if(n){const r=n[1].trim().replace(/^"(.*)"$/,"$1"),o=n[2].trim();if(nn(o))return{email:o,displayName:r}}if(nn(t))return{email:t}},so=e=>{const t=[];let n="",r=!1,o=!1;for(const a of e){if(a==='"'&&(r=!r),a==="<"&&(o=!0),a===">"&&(o=!1),(a===","||a===";")&&!r&&!o){t.push(n),n="";continue}n+=a}return t.push(n),t},io=e=>{const t=[],n=[];for(const r of so(e)){const o=ao(r);if(o){t.push(o);continue}r.trim()&&n.push(r.trim())}return{entries:t,unparsed:n.join(", ")}},co=["Tab",","],uo=150,lo=({label:e,addresses:t,onChange:n,placeholder:r,suggestions:o=[],onQueryChange:a,onPendingChange:i,ref:c})=>{const[p,f]=s.useState(""),l=s.useRef(null),u=s.useMemo(()=>io(p),[p]);s.useEffect(()=>{i?.(u)},[u,i]);const h=s.useRef(void 0),w=s.useCallback(()=>{h.current!==void 0&&(clearTimeout(h.current),h.current=void 0)},[]);s.useEffect(()=>w,[w]);const x=new Set(t.map(y=>y.email.toLowerCase())),d=p.length>=2?o.filter(y=>!x.has(y.email.toLowerCase())):[],E=s.useCallback(y=>{f(y),a?.(y)},[a]),b=s.useCallback(y=>{w(),!x.has(y.email.toLowerCase())&&(n([...t,y]),E(""))},[t,x,n,E,w]),D=s.useCallback(y=>{n(t.filter((_,R)=>R!==y))},[t,n]),g=s.useCallback(y=>{b(y),l.current?.focus()},[b]),v=s.useCallback(()=>{if(w(),u.entries.length===0)return{addresses:t,unparsed:u.unparsed};const y=new Set(x),_=[...t];for(const R of u.entries){const W=R.email.toLowerCase();y.has(W)||(y.add(W),_.push(R))}return n(_),E(u.unparsed),{addresses:_,unparsed:u.unparsed}},[u,t,x,n,E,w]),T=s.useCallback(()=>{w(),E("")},[E,w]);s.useImperativeHandle(c,()=>({commitPending:v,clearPending:T}),[v,T]);const M=s.useRef(v);s.useEffect(()=>{M.current=v},[v]);const S=Tr({count:d.length,acceptKeys:co,onAccept:y=>g(d[y])}),O=s.useMemo(()=>d.map(y=>({value:y.email,label:y.displayName??y.email,...y.displayName?{hint:y.email}:{}})),[d]),N=s.useCallback(y=>{if(y.key==="Backspace"&&p===""&&t.length>0){D(t.length-1);return}S.handleKeyDown(y)||(y.key==="Enter"||y.key==="Tab"||y.key===",")&&p.trim()&&(y.preventDefault(),v())},[p,t.length,D,S.handleKeyDown,v]),F=s.useCallback(()=>{w(),h.current=setTimeout(()=>{h.current=void 0,M.current(),S.dismiss()},uo)},[w,S.dismiss]);return m.jsxs("div",{className:"relative","data-address-field":e,children:[m.jsxs("div",{className:"flex items-start gap-2",children:[m.jsxs("label",{htmlFor:`address-field-${e}`,className:"text-sm text-fg-muted shrink-0 w-12 pt-1.5",children:[e,":"]}),m.jsxs("div",{className:"flex-1 flex flex-wrap items-center gap-1 min-h-[36px] px-2 py-1 border rounded-md bg-canvas cursor-text",onClick:()=>l.current?.focus(),onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&l.current?.focus()},children:[t.map((y,_)=>m.jsx(no,{email:y.email,displayName:y.displayName,onRemove:()=>D(_)},y.email)),m.jsx("input",{ref:l,id:`address-field-${e}`,type:"text",value:p,onChange:y=>{S.reopen(),E(y.target.value)},onKeyDown:N,onBlur:F,placeholder:t.length===0?r:"",className:"flex-1 min-w-[120px] bg-transparent outline-none text-sm py-0.5",autoComplete:"off",...S.comboboxProps})]})]}),S.open&&m.jsx(Ar,{id:S.listId,suggestions:O,activeIndex:S.activeIndex,optionId:S.optionId,onPick:y=>{const _=d.find(R=>R.email===y.value);_&&g(_)},onHighlight:S.setActiveIndex,label:`${e} suggestions`,className:"absolute left-12 right-0 z-50 mt-1 max-h-[200px] shadow-lg"})]})},fo=()=>m.jsxs("div",{"aria-hidden":"true","data-testid":"compose-body-skeleton",className:"min-h-[120px] px-3 py-2",children:[m.jsx("div",{className:"mb-2 h-8 animate-pulse rounded bg-surface-sunken"}),m.jsx("div",{className:"min-h-[80px] animate-pulse rounded bg-surface-sunken/50"})]});function mo({banner:e,header:t,children:n,quoted:r,actionBar:o,layout:a="fill"}){const i=a==="fill";return m.jsxs("div",{className:i?"flex h-full min-h-0 flex-col":"flex flex-col",children:[e,t,m.jsxs("div",{className:i?"flex min-h-0 flex-1 flex-col overflow-auto":"flex flex-col","data-testid":"compose-body-area",children:[n,r&&m.jsx("div",{className:"shrink-0 px-3 pb-2",children:r})]}),i?o:m.jsx("div",{className:"sticky bottom-0 z-10 bg-canvas",children:o})]})}const Nt=({label:e,onClick:t})=>m.jsx("button",{type:"button",onClick:t,className:"text-xs text-fg-muted hover:text-fg transition-colors",children:e}),po=({to:e,cc:t,bcc:n,subject:r})=>{const o=[];return e.length>0&&o.push(`To: ${e.map(a=>a.displayName??a.email).join(", ")}`),t.length>0&&o.push(`Cc: ${t.length}`),n.length>0&&o.push(`Bcc: ${n.length}`),r&&o.push(r),o.join(" · ")},ho=({collapsed:e=!1,summary:t="",onExpand:n,from:r,to:o,cc:a,bcc:i,subject:c,onShowCc:p,onShowBcc:f})=>e?m.jsxs("button",{type:"button",onClick:n,"aria-label":"Show recipients and subject",className:"flex min-h-11 w-full items-center gap-2 overflow-hidden border-b border-line px-3 py-1.5 text-left transition-colors hover:bg-surface-sunken","data-testid":"compose-header-collapsed",children:[m.jsx("span",{className:"truncate text-xs text-fg-muted",children:t||"…"}),m.jsx(Nn,{className:"ml-auto size-4 shrink-0 text-fg-muted","aria-hidden":"true"})]}):m.jsxs("div",{className:"space-y-1 px-3 py-2 border-b border-line",children:[r,o,a??m.jsxs("div",{className:"flex gap-2 pl-14",children:[m.jsx(Nt,{label:"Cc",onClick:p}),m.jsx(Nt,{label:"Bcc",onClick:f})]}),a&&!i&&m.jsx("div",{className:"pl-14",children:m.jsx(Nt,{label:"Bcc",onClick:f})}),i,c]}),Vt="This account can't send mail until SMTP is configured.",vo=({onConfigure:e,configureRef:t})=>m.jsxs("div",{role:"alert","data-testid":"compose-smtp-missing-banner",className:"flex items-start gap-3 border-b border-warning/50 bg-warning/10 px-3 py-2",children:[m.jsx(Or,{className:"size-5 shrink-0 mt-0.5 text-warning","aria-hidden":"true"}),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("p",{className:"text-sm font-medium text-warning",children:Vt}),m.jsxs("button",{ref:t,type:"button",onClick:e,"data-testid":"compose-smtp-configure",className:"mt-1 inline-flex items-center gap-1 text-xs font-medium text-warning hover:underline",children:["Configure SMTP",m.jsx(Nr,{className:"size-3","aria-hidden":"true"})]})]})]}),go=({value:e,onChange:t})=>m.jsxs("div",{className:"flex items-start gap-2",children:[m.jsx("label",{className:"text-sm text-fg-muted shrink-0 w-12 pt-1.5",children:"Subj:"}),m.jsx("input",{type:"text",value:e,onChange:n=>t(n.target.value),className:"flex-1 px-2 py-1.5 border rounded-md bg-canvas text-sm",placeholder:"Subject","data-subject-field":!0})]}),wo=({text:e,html:t,senderName:n,date:r})=>{const[o,a]=s.useState(!1);if(!e&&!t)return null;const i=[n,r].filter(Boolean).join(" on ");return m.jsxs("div",{className:"mt-2 px-3 pb-2",children:[m.jsxs("button",{type:"button",onClick:()=>a(!o),"aria-expanded":o,className:"flex items-center gap-1 text-xs text-fg-muted hover:text-fg transition-colors",children:[o?m.jsx(Nn,{className:"size-3"}):m.jsx(kr,{className:"size-3"}),i?`${i} wrote:`:"Show quoted text"]}),o&&m.jsx("blockquote",{className:"mt-2 pl-3 border-l-2 border-fg-subtle/30 text-sm text-fg-muted [&_a]:text-accent [&_a]:underline [&_blockquote]:pl-3 [&_blockquote]:border-l-2 [&_blockquote]:border-fg-subtle/30",children:t?m.jsx("div",{dangerouslySetInnerHTML:{__html:t}}):e.split(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/rich-text-spellcheck-worker-provider-CXOEqFHn.js","assets/index-CrStk0va.js","assets/index-OWhz0EKb.css","assets/rich-text-spellcheck-provider-J8m9wz6A.js","assets/rich-text-DTviXfBN.js","assets/confirm-dialog-DoFwvjx5.js","assets/bottom-sheet-RK-XvYz2.js","assets/attachment-file-C1JZr27N.js","assets/useMessageBodyContent-D2ppLfqI.js","assets/useSignature-CZIvmo45.js","assets/account-form-helpers-DhckT_PN.js","assets/useDebouncedValue-DBe8RTdD.js"])))=>i.map(i=>d[i]);
2
+ import{j as m,X as Sr,b as xr,B as en,ar as Cr,f as Rr,T as Dr,r as s,cp as Tr,cq as Ar,C as Nn,af as Or,cr as Nr,d as kr,cs as Pr,ct as Gt,bE as kn,cu as ye,cv as Pn,cw as Ir,a0 as In,x as Lr,aj as gt,cx as wt,cy as Mr,cz as _r,E as jr,D as yt,by as Fr,cA as Ln,aR as $r,aS as Br,a1 as Mn,cB as Hr,ah as Wr,cC as Ur,cD as tn,cE as Vr,bK as Ot,cF as zr,ak as qr,bD as Kr,ai as Yr,cG as Gr,b3 as Xr,cH as Qr,ag as C}from"./index-CrStk0va.js";import{d as Zr}from"./useMessageBodyContent-D2ppLfqI.js";import{u as Jr}from"./useSignature-CZIvmo45.js";import{b as eo}from"./account-form-helpers-DhckT_PN.js";import{u as to}from"./useDebouncedValue-DBe8RTdD.js";const no=({email:e,displayName:t,onRemove:n,className:r})=>m.jsxs("span",{className:xr("inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-accent-2-soft text-sm max-w-[200px]",r),children:[m.jsx("span",{className:"truncate",children:t||e}),m.jsx("button",{type:"button",onClick:n,className:"shrink-0 p-0.5 rounded-full hover:bg-fg-muted/20 transition-colors","aria-label":`Remove ${e}`,children:m.jsx(Sr,{className:"size-3"})})]}),ro=({save:e})=>e.status==="saving"?m.jsx("output",{className:"animate-pulse text-xs text-fg-muted",children:"Saving..."}):e.status==="saved"?m.jsx("output",{className:"text-xs text-fg-muted",children:"Draft saved"}):e.status==="error"?m.jsx("output",{className:"text-xs text-danger",children:"Save failed"}):e.status==="unsaved"?m.jsx("output",{className:"truncate text-xs text-warning",children:e.reason}):null;function oo({send:e,onSend:t,onBlocked:n,onDiscard:r,save:o={status:"idle"}}){const a=e.status==="sending",i=e.status==="blocked"?e.reason:void 0;return m.jsxs("div",{className:"flex items-center justify-between border-t border-line px-3 py-2",children:[m.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[m.jsx(en,{variant:"primary",size:"md","aria-busy":a,title:i,className:"min-h-11 shrink-0 rounded-full px-4","data-testid":"compose-send",icon:a?m.jsx(Cr,{className:"size-4 animate-spin"}):m.jsx(Rr,{className:"size-4"}),onClick:()=>{if(!a){if(i!==void 0){n(i);return}t()}},children:"Send"}),m.jsx(ro,{save:o})]}),m.jsx(en,{variant:"ghost",size:"md","aria-busy":a,"aria-label":"Discard",className:"min-h-11 min-w-11 px-2 hover:text-danger",icon:m.jsx(Dr,{className:"size-4"}),onClick:()=>{a||r()}})]})}const nn=e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim()),ao=e=>{const t=e.trim();if(!t)return;const n=t.match(/^(.+?)\s*<([^>]+)>$/);if(n){const r=n[1].trim().replace(/^"(.*)"$/,"$1"),o=n[2].trim();if(nn(o))return{email:o,displayName:r}}if(nn(t))return{email:t}},so=e=>{const t=[];let n="",r=!1,o=!1;for(const a of e){if(a==='"'&&(r=!r),a==="<"&&(o=!0),a===">"&&(o=!1),(a===","||a===";")&&!r&&!o){t.push(n),n="";continue}n+=a}return t.push(n),t},io=e=>{const t=[],n=[];for(const r of so(e)){const o=ao(r);if(o){t.push(o);continue}r.trim()&&n.push(r.trim())}return{entries:t,unparsed:n.join(", ")}},co=["Tab",","],uo=150,lo=({label:e,addresses:t,onChange:n,placeholder:r,suggestions:o=[],onQueryChange:a,onPendingChange:i,ref:c})=>{const[p,f]=s.useState(""),l=s.useRef(null),u=s.useMemo(()=>io(p),[p]);s.useEffect(()=>{i?.(u)},[u,i]);const h=s.useRef(void 0),w=s.useCallback(()=>{h.current!==void 0&&(clearTimeout(h.current),h.current=void 0)},[]);s.useEffect(()=>w,[w]);const x=new Set(t.map(y=>y.email.toLowerCase())),d=p.length>=2?o.filter(y=>!x.has(y.email.toLowerCase())):[],E=s.useCallback(y=>{f(y),a?.(y)},[a]),b=s.useCallback(y=>{w(),!x.has(y.email.toLowerCase())&&(n([...t,y]),E(""))},[t,x,n,E,w]),D=s.useCallback(y=>{n(t.filter((_,R)=>R!==y))},[t,n]),g=s.useCallback(y=>{b(y),l.current?.focus()},[b]),v=s.useCallback(()=>{if(w(),u.entries.length===0)return{addresses:t,unparsed:u.unparsed};const y=new Set(x),_=[...t];for(const R of u.entries){const W=R.email.toLowerCase();y.has(W)||(y.add(W),_.push(R))}return n(_),E(u.unparsed),{addresses:_,unparsed:u.unparsed}},[u,t,x,n,E,w]),T=s.useCallback(()=>{w(),E("")},[E,w]);s.useImperativeHandle(c,()=>({commitPending:v,clearPending:T}),[v,T]);const M=s.useRef(v);s.useEffect(()=>{M.current=v},[v]);const S=Tr({count:d.length,acceptKeys:co,onAccept:y=>g(d[y])}),O=s.useMemo(()=>d.map(y=>({value:y.email,label:y.displayName??y.email,...y.displayName?{hint:y.email}:{}})),[d]),N=s.useCallback(y=>{if(y.key==="Backspace"&&p===""&&t.length>0){D(t.length-1);return}S.handleKeyDown(y)||(y.key==="Enter"||y.key==="Tab"||y.key===",")&&p.trim()&&(y.preventDefault(),v())},[p,t.length,D,S.handleKeyDown,v]),F=s.useCallback(()=>{w(),h.current=setTimeout(()=>{h.current=void 0,M.current(),S.dismiss()},uo)},[w,S.dismiss]);return m.jsxs("div",{className:"relative","data-address-field":e,children:[m.jsxs("div",{className:"flex items-start gap-2",children:[m.jsxs("label",{htmlFor:`address-field-${e}`,className:"text-sm text-fg-muted shrink-0 w-12 pt-1.5",children:[e,":"]}),m.jsxs("div",{className:"flex-1 flex flex-wrap items-center gap-1 min-h-[36px] px-2 py-1 border rounded-md bg-canvas cursor-text",onClick:()=>l.current?.focus(),onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&l.current?.focus()},children:[t.map((y,_)=>m.jsx(no,{email:y.email,displayName:y.displayName,onRemove:()=>D(_)},y.email)),m.jsx("input",{ref:l,id:`address-field-${e}`,type:"text",value:p,onChange:y=>{S.reopen(),E(y.target.value)},onKeyDown:N,onBlur:F,placeholder:t.length===0?r:"",className:"flex-1 min-w-[120px] bg-transparent outline-none text-sm py-0.5",autoComplete:"off",...S.comboboxProps})]})]}),S.open&&m.jsx(Ar,{id:S.listId,suggestions:O,activeIndex:S.activeIndex,optionId:S.optionId,onPick:y=>{const _=d.find(R=>R.email===y.value);_&&g(_)},onHighlight:S.setActiveIndex,label:`${e} suggestions`,className:"absolute left-12 right-0 z-50 mt-1 max-h-[200px] shadow-lg"})]})},fo=()=>m.jsxs("div",{"aria-hidden":"true","data-testid":"compose-body-skeleton",className:"min-h-[120px] px-3 py-2",children:[m.jsx("div",{className:"mb-2 h-8 animate-pulse rounded bg-surface-sunken"}),m.jsx("div",{className:"min-h-[80px] animate-pulse rounded bg-surface-sunken/50"})]});function mo({banner:e,header:t,children:n,quoted:r,actionBar:o,layout:a="fill"}){const i=a==="fill";return m.jsxs("div",{className:i?"flex h-full min-h-0 flex-col":"flex flex-col",children:[e,t,m.jsxs("div",{className:i?"flex min-h-0 flex-1 flex-col overflow-auto":"flex flex-col","data-testid":"compose-body-area",children:[n,r&&m.jsx("div",{className:"shrink-0 px-3 pb-2",children:r})]}),i?o:m.jsx("div",{className:"sticky bottom-0 z-10 bg-canvas",children:o})]})}const Nt=({label:e,onClick:t})=>m.jsx("button",{type:"button",onClick:t,className:"text-xs text-fg-muted hover:text-fg transition-colors",children:e}),po=({to:e,cc:t,bcc:n,subject:r})=>{const o=[];return e.length>0&&o.push(`To: ${e.map(a=>a.displayName??a.email).join(", ")}`),t.length>0&&o.push(`Cc: ${t.length}`),n.length>0&&o.push(`Bcc: ${n.length}`),r&&o.push(r),o.join(" · ")},ho=({collapsed:e=!1,summary:t="",onExpand:n,from:r,to:o,cc:a,bcc:i,subject:c,onShowCc:p,onShowBcc:f})=>e?m.jsxs("button",{type:"button",onClick:n,"aria-label":"Show recipients and subject",className:"flex min-h-11 w-full items-center gap-2 overflow-hidden border-b border-line px-3 py-1.5 text-left transition-colors hover:bg-surface-sunken","data-testid":"compose-header-collapsed",children:[m.jsx("span",{className:"truncate text-xs text-fg-muted",children:t||"…"}),m.jsx(Nn,{className:"ml-auto size-4 shrink-0 text-fg-muted","aria-hidden":"true"})]}):m.jsxs("div",{className:"space-y-1 px-3 py-2 border-b border-line",children:[r,o,a??m.jsxs("div",{className:"flex gap-2 pl-14",children:[m.jsx(Nt,{label:"Cc",onClick:p}),m.jsx(Nt,{label:"Bcc",onClick:f})]}),a&&!i&&m.jsx("div",{className:"pl-14",children:m.jsx(Nt,{label:"Bcc",onClick:f})}),i,c]}),Vt="This account can't send mail until SMTP is configured.",vo=({onConfigure:e,configureRef:t})=>m.jsxs("div",{role:"alert","data-testid":"compose-smtp-missing-banner",className:"flex items-start gap-3 border-b border-warning/50 bg-warning/10 px-3 py-2",children:[m.jsx(Or,{className:"size-5 shrink-0 mt-0.5 text-warning","aria-hidden":"true"}),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("p",{className:"text-sm font-medium text-warning",children:Vt}),m.jsxs("button",{ref:t,type:"button",onClick:e,"data-testid":"compose-smtp-configure",className:"mt-1 inline-flex items-center gap-1 text-xs font-medium text-warning hover:underline",children:["Configure SMTP",m.jsx(Nr,{className:"size-3","aria-hidden":"true"})]})]})]}),go=({value:e,onChange:t})=>m.jsxs("div",{className:"flex items-start gap-2",children:[m.jsx("label",{className:"text-sm text-fg-muted shrink-0 w-12 pt-1.5",children:"Subj:"}),m.jsx("input",{type:"text",value:e,onChange:n=>t(n.target.value),className:"flex-1 px-2 py-1.5 border rounded-md bg-canvas text-sm",placeholder:"Subject","data-subject-field":!0})]}),wo=({text:e,html:t,senderName:n,date:r})=>{const[o,a]=s.useState(!1);if(!e&&!t)return null;const i=[n,r].filter(Boolean).join(" on ");return m.jsxs("div",{className:"mt-2 px-3 pb-2",children:[m.jsxs("button",{type:"button",onClick:()=>a(!o),"aria-expanded":o,className:"flex items-center gap-1 text-xs text-fg-muted hover:text-fg transition-colors",children:[o?m.jsx(Nn,{className:"size-3"}):m.jsx(kr,{className:"size-3"}),i?`${i} wrote:`:"Show quoted text"]}),o&&m.jsx("blockquote",{className:"mt-2 pl-3 border-l-2 border-fg-subtle/30 text-sm text-fg-muted [&_a]:text-accent [&_a]:underline [&_blockquote]:pl-3 [&_blockquote]:border-l-2 [&_blockquote]:border-fg-subtle/30",children:t?m.jsx("div",{dangerouslySetInnerHTML:{__html:t}}):e.split(`
3
3
  `).map((c,p)=>m.jsx("p",{className:"min-h-[1.2em]",children:c},p))})]})},yo=["p","br","div","h1","h2","h3","h4","h5","h6","strong","b","em","i","u","s","ul","ol","li","blockquote","pre","code","hr","table","thead","tbody","tr","th","td","a","img"],bo=["href","src","alt","colspan","rowspan","lang","dir"],Eo=/^(?:https?:|mailto:)/i,So=/^(?:https:|data:image\/)/i,xo="max-width:100%;height:auto",Co=e=>{const t=Pr();if(!t.isSupported)throw new Error("adopted HTML cannot be sanitized: no DOM is available");return t.addHook("afterSanitizeAttributes",n=>{if(n.tagName==="A"){Eo.test(n.getAttribute("href")??"")||n.removeAttribute("href"),e==="quoted"&&(n.setAttribute("target","_blank"),n.setAttribute("rel","noopener noreferrer nofollow"));return}if(n.tagName==="IMG"){if(e==="quoted"){n.remove();return}if(!So.test(n.getAttribute("src")??"")){n.remove();return}n.setAttribute("style",xo)}}),t},rn=new Map,Ro=e=>{const t=rn.get(e);if(t)return t;const n=Co(e);return rn.set(e,n),n},_n=(e,t)=>Ro(t).sanitize(e,{ALLOWED_TAGS:yo,ALLOWED_ATTR:bo,ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!1}),wi=e=>_n(e,"outgoing"),Do=e=>_n(e,"quoted"),To=e=>typeof e=="string"&&e.length>0?"rich":"plain",yi=(e,t)=>t.length>0,Ao={plain:"Couldn't switch to plain text",rich:"Couldn't switch to rich text"},bi=(e,t,n)=>t.trim()===""||n.trim()!==""?{outcome:"switch"}:{outcome:"blocked",title:Ao[e],detail:"The conversion came back empty, so your message is unchanged."};function be(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e?.(o),n===!1||!o||!o.defaultPrevented)return t?.(o)}}function on(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Oo(...e){return t=>{let n=!1;const r=e.map(o=>{const a=on(o,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let o=0;o<r.length;o++){const a=r[o];typeof a=="function"?a():on(e[o],null)}}}}function Te(...e){return s.useCallback(Oo(...e),e)}function No(e,t=[]){let n=[];function r(a,i){const c=s.createContext(i);c.displayName=a+"Context";const p=n.length;n=[...n,i];const f=u=>{const{scope:h,children:w,...x}=u,d=h?.[e]?.[p]||c,E=s.useMemo(()=>x,Object.values(x));return m.jsx(d.Provider,{value:E,children:w})};f.displayName=a+"Provider";function l(u,h,w={}){const{optional:x=!1}=w,d=h?.[e]?.[p]||c,E=s.useContext(d);if(E)return E;if(i!==void 0)return i;if(!x)throw new Error(`\`${u}\` must be used within \`${a}\``)}return[f,l]}const o=()=>{const a=n.map(i=>s.createContext(i));return function(c){const p=c?.[e]||a;return s.useMemo(()=>({[`__scope${e}`]:{...c,[e]:p}}),[c,p])}};return o.scopeName=e,[r,ko(o,...t)]}function ko(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const i=r.reduce((c,{useScope:p,scopeName:f})=>{const u=p(a)[`__scope${f}`];return{...c,...u}},{});return s.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var Ze=globalThis?.document?s.useLayoutEffect:()=>{},Po=Gt[" useInsertionEffect ".trim().toString()]||Ze;function Io({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,a,i]=Lo({defaultProp:t,onChange:n}),c=e!==void 0,p=c?e:o;{const l=s.useRef(e!==void 0);s.useEffect(()=>{const u=l.current;u!==c&&console.warn(`${r} is changing from ${u?"controlled":"uncontrolled"} to ${c?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),l.current=c},[c,r])}const f=s.useCallback(l=>{if(c){const u=Mo(l)?l(e):l;u!==e&&i.current?.(u)}else a(l)},[c,e,a,i]);return[p,f]}function Lo({defaultProp:e,onChange:t}){const[n,r]=s.useState(e),o=s.useRef(n),a=s.useRef(t);return Po(()=>{a.current=t},[t]),s.useEffect(()=>{o.current!==n&&(a.current?.(n),o.current=n)},[n,o]),[n,r,a]}function Mo(e){return typeof e=="function"}function jn(e){const t=s.forwardRef((n,r)=>{let{children:o,...a}=n,i=null,c=!1;const p=[];an(o)&&typeof it=="function"&&(o=it(o._payload)),s.Children.forEach(o,h=>{if(Bo(h)){c=!0;const w=h;let x="child"in w.props?w.props.child:w.props.children;an(x)&&typeof it=="function"&&(x=it(x._payload)),i=jo(w,x),p.push(i?.props?.children)}else p.push(h)}),i?i=s.cloneElement(i,void 0,p):!c&&s.Children.count(o)===1&&s.isValidElement(o)&&(i=o);const f=i?$o(i):void 0,l=Te(r,f);if(!i){if(o||o===0)throw new Error(c?Vo(e):Uo(e));return o}const u=Fo(a,i.props??{});return i.type!==s.Fragment&&(u.ref=r?l:f),s.cloneElement(i,u)});return t.displayName=`${e}.Slot`,t}var _o=Symbol.for("radix.slottable"),jo=(e,t)=>{if("child"in e.props){const n=e.props.child;return s.isValidElement(n)?s.cloneElement(n,void 0,e.props.children(n.props.children)):null}return s.isValidElement(t)?t:null};function Fo(e,t){const n={...t};for(const r in t){const o=e[r],a=t[r];/^on[A-Z]/.test(r)?o&&a?n[r]=(...c)=>{const p=a(...c);return o(...c),p}:o&&(n[r]=o):r==="style"?n[r]={...o,...a}:r==="className"&&(n[r]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function $o(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function Bo(e){return s.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===_o}var Ho=Symbol.for("react.lazy");function an(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===Ho&&"_payload"in e&&Wo(e._payload)}function Wo(e){return typeof e=="object"&&e!==null&&"then"in e}var Uo=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,Vo=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,it=Gt[" use ".trim().toString()],zo=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],fe=zo.reduce((e,t)=>{const n=jn(`Primitive.${t}`),r=s.forwardRef((o,a)=>{const{asChild:i,...c}=o,p=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),m.jsx(p,{...c,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function qo(e,t){e&&kn.flushSync(()=>e.dispatchEvent(t))}function Je(e){const t=s.useRef(e);return s.useEffect(()=>{t.current=e}),s.useMemo(()=>((...n)=>t.current?.(...n)),[])}var Ko="DismissableLayer",zt="dismissableLayer.update",Yo="dismissableLayer.pointerDownOutside",Go="dismissableLayer.focusOutside",sn,Xt=s.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Fn=s.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:o,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:c,onDismiss:p,...f}=e,l=s.useContext(Xt),[u,h]=s.useState(null),w=u?.ownerDocument??globalThis?.document,[,x]=s.useState({}),d=Te(t,h),E=Array.from(l.layers),[b]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),D=b?E.indexOf(b):-1,g=u?E.indexOf(u):-1,v=l.layersWithOutsidePointerEventsDisabled.size>0,T=g>=D,M=s.useRef(!1),S=ea(y=>{a?.(y),c?.(y),y.defaultPrevented||p?.()},{ownerDocument:w,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:M,dismissableSurfaces:l.dismissableSurfaces,shouldHandlePointerDownOutside:s.useCallback(y=>{if(!(y instanceof Node))return!1;const _=[...l.branches].some(R=>R.contains(y));return T&&!_},[l.branches,T])}),O=ta(y=>{if(r&&M.current)return;const _=y.target;[...l.branches].some(W=>W.contains(_))||(i?.(y),c?.(y),y.defaultPrevented||p?.())},w),N=u?g===E.length-1:!1,F=Je(y=>{y.key==="Escape"&&(o?.(y),!y.defaultPrevented&&p&&(y.preventDefault(),p()))});return s.useEffect(()=>{if(N)return w.addEventListener("keydown",F,{capture:!0}),()=>w.removeEventListener("keydown",F,{capture:!0})},[w,N,F]),s.useEffect(()=>{if(u)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(sn=w.body.style.pointerEvents,w.body.style.pointerEvents="none"),l.layersWithOutsidePointerEventsDisabled.add(u)),l.layers.add(u),cn(),()=>{n&&(l.layersWithOutsidePointerEventsDisabled.delete(u),l.layersWithOutsidePointerEventsDisabled.size===0&&(w.body.style.pointerEvents=sn))}},[u,w,n,l]),s.useEffect(()=>()=>{u&&(l.layers.delete(u),l.layersWithOutsidePointerEventsDisabled.delete(u),cn())},[u,l]),s.useEffect(()=>{const y=()=>x({});return document.addEventListener(zt,y),()=>document.removeEventListener(zt,y)},[]),m.jsx(fe.div,{...f,ref:d,style:{pointerEvents:v?T?"auto":"none":void 0,...e.style},onFocusCapture:be(e.onFocusCapture,O.onFocusCapture),onBlurCapture:be(e.onBlurCapture,O.onBlurCapture),onPointerDownCapture:be(e.onPointerDownCapture,S.onPointerDownCapture)})});Fn.displayName=Ko;var Xo="DismissableLayerBranch",Qo=s.forwardRef((e,t)=>{const n=s.useContext(Xt),r=s.useRef(null),o=Te(t,r);return s.useEffect(()=>{const a=r.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),m.jsx(fe.div,{...e,ref:o})});Qo.displayName=Xo;function Zo(){const e=s.useContext(Xt),[t,n]=s.useState(null);return s.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}var Jo=()=>!0;function ea(e,t){const{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:o,dismissableSurfaces:a,shouldHandlePointerDownOutside:i=Jo}=t,c=Je(e),p=s.useRef(!1),f=s.useRef(!1),l=s.useRef(new Map),u=s.useRef(()=>{});return s.useEffect(()=>{function h(){f.current=!1,o.current=!1,l.current.clear()}function w(){return Array.from(l.current.values()).some(Boolean)}function x(g){if(!f.current)return;const v=g.target;v instanceof Node&&[...a].some(M=>M.contains(v))||l.current.set(g.type,!0),g.type==="click"&&window.setTimeout(()=>{f.current&&u.current()},0)}function d(g){f.current&&l.current.set(g.type,!1)}const E=g=>{if(g.target&&!p.current){let v=function(){n.removeEventListener("click",u.current);const M=w();h(),M||$n(Yo,c,T,{discrete:!0})};if(!i(g.target)){n.removeEventListener("click",u.current),h(),p.current=!1;return}const T={originalEvent:g};f.current=!0,o.current=r&&g.button===0,l.current.clear(),!r||g.button!==0?v():(n.removeEventListener("click",u.current),u.current=v,n.addEventListener("click",u.current,{once:!0}))}else n.removeEventListener("click",u.current),h();p.current=!1},b=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const g of b)n.addEventListener(g,x,!0),n.addEventListener(g,d);const D=window.setTimeout(()=>{n.addEventListener("pointerdown",E)},0);return()=>{window.clearTimeout(D),n.removeEventListener("pointerdown",E),n.removeEventListener("click",u.current);for(const g of b)n.removeEventListener(g,x,!0),n.removeEventListener(g,d)}},[n,c,r,o,a,i]),{onPointerDownCapture:()=>p.current=!0}}function ta(e,t=globalThis?.document){const n=Je(e),r=s.useRef(!1);return s.useEffect(()=>{const o=a=>{a.target&&!r.current&&$n(Go,n,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function cn(){const e=new CustomEvent(zt);document.dispatchEvent(e)}function $n(e,t,n,{discrete:r}){const o=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?qo(o,a):o.dispatchEvent(a)}var ct=0,Me=null;function na(){s.useEffect(()=>{Me||(Me={start:un(),end:un()});const{start:e,end:t}=Me;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),ct++,()=>{ct===1&&(Me?.start.remove(),Me?.end.remove(),Me=null),ct=Math.max(0,ct-1)}},[])}function un(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var kt="focusScope.autoFocusOnMount",Pt="focusScope.autoFocusOnUnmount",ln={bubbles:!1,cancelable:!0},ra="FocusScope",Bn=s.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...i}=e,[c,p]=s.useState(null),f=Je(o),l=Je(a),u=s.useRef(null),h=Te(t,p),w=s.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;s.useEffect(()=>{if(r){let d=function(g){if(w.paused||!c)return;const v=g.target;c.contains(v)?u.current=v:we(u.current,{select:!0})},E=function(g){if(w.paused||!c)return;const v=g.relatedTarget;v!==null&&(c.contains(v)||we(u.current,{select:!0}))},b=function(g){if(document.activeElement===document.body)for(const T of g)T.removedNodes.length>0&&we(c)};document.addEventListener("focusin",d),document.addEventListener("focusout",E);const D=new MutationObserver(b);return c&&D.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",d),document.removeEventListener("focusout",E),D.disconnect()}}},[r,c,w.paused]),s.useEffect(()=>{if(c){fn.add(w);const d=document.activeElement;if(!c.contains(d)){const b=new CustomEvent(kt,ln);c.addEventListener(kt,f),c.dispatchEvent(b),b.defaultPrevented||(oa(ua(Hn(c)),{select:!0}),document.activeElement===d&&we(c))}return()=>{c.removeEventListener(kt,f),setTimeout(()=>{const b=new CustomEvent(Pt,ln);c.addEventListener(Pt,l),c.dispatchEvent(b),b.defaultPrevented||we(d??document.body,{select:!0}),c.removeEventListener(Pt,l),fn.remove(w)},0)}}},[c,f,l,w]);const x=s.useCallback(d=>{if(!n&&!r||w.paused)return;const E=d.key==="Tab"&&!d.altKey&&!d.ctrlKey&&!d.metaKey,b=document.activeElement;if(E&&b){const D=d.currentTarget,[g,v]=aa(D);g&&v?!d.shiftKey&&b===v?(d.preventDefault(),n&&we(g,{select:!0})):d.shiftKey&&b===g&&(d.preventDefault(),n&&we(v,{select:!0})):b===D&&d.preventDefault()}},[n,r,w.paused]);return m.jsx(fe.div,{tabIndex:-1,...i,ref:h,onKeyDown:x})});Bn.displayName=ra;function oa(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(we(r,{select:t}),document.activeElement!==n)return}function aa(e){const t=Hn(e),n=dn(t,e),r=dn(t.reverse(),e);return[n,r]}function Hn(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function dn(e,t){const n=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):sa(r,{upTo:t})))return r}function sa(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function ia(e){return e instanceof HTMLInputElement&&"select"in e}function we(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&ia(e)&&t&&e.select()}}var fn=ca();function ca(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=mn(e,t),e.unshift(t)},remove(t){e=mn(e,t),e[0]?.resume()}}}function mn(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function ua(e){return e.filter(t=>t.tagName!=="A")}var la=Gt[" useId ".trim().toString()]||(()=>{}),da=0;function It(e){const[t,n]=s.useState(la());return Ze(()=>{n(r=>r??String(da++))},[e]),e||(t?`radix-${t}`:"")}var fa="Portal",Wn=s.forwardRef((e,t)=>{const{container:n,...r}=e,[o,a]=s.useState(!1);Ze(()=>a(!0),[]);const i=n||o&&globalThis?.document?.body;return i?kn.createPortal(m.jsx(fe.div,{...r,ref:t}),i):null});Wn.displayName=fa;function ma(e,t){return s.useReducer((n,r)=>t[n][r]??n,e)}var Et=e=>{const{present:t,children:n}=e,r=pa(t),o=typeof n=="function"?n({present:r.isPresent}):s.Children.only(n),a=ha(r.ref,va(o));return typeof n=="function"||r.isPresent?s.cloneElement(o,{ref:a}):null};Et.displayName="Presence";function pa(e){const[t,n]=s.useState(),r=s.useRef(null),o=s.useRef(e),a=s.useRef("none"),i=s.useRef(void 0),c=e?"mounted":"unmounted",[p,f]=ma(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return s.useEffect(()=>{p==="mounted"?(a.current=i.current??Ge(r.current),i.current=void 0):a.current="none"},[p]),Ze(()=>{const l=r.current,u=o.current;if(u!==e){const w=a.current,x=Ge(l);e?(i.current=x,f("MOUNT")):x==="none"||l?.display==="none"?f("UNMOUNT"):f(u&&w!==x?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,f]),Ze(()=>{if(t){let l;const u=t.ownerDocument.defaultView??window,h=x=>{const E=Ge(r.current).includes(CSS.escape(x.animationName));if(x.target===t&&E&&(f("ANIMATION_END"),!o.current)){const b=t.style.animationFillMode;t.style.animationFillMode="forwards",l=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=b)})}},w=x=>{x.target===t&&(a.current=Ge(r.current))};return t.addEventListener("animationstart",w),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{u.clearTimeout(l),t.removeEventListener("animationstart",w),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else f("ANIMATION_END")},[t,f]),{isPresent:["mounted","unmountSuspended"].includes(p),ref:s.useCallback(l=>{if(l){const u=getComputedStyle(l);r.current=u,i.current=Ge(u)}else r.current=null;n(l)},[])}}function pn(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function ha(...e){const t=s.useRef(e);return t.current=e,s.useCallback(n=>{const r=t.current;let o=!1;const a=r.map(i=>{const c=pn(i,n);return!o&&typeof c=="function"&&(o=!0),c});if(o)return()=>{for(let i=0;i<a.length;i++){const c=a[i];typeof c=="function"?c():pn(r[i],null)}}},[])}function Ge(e){return e?.animationName||"none"}function va(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var ga=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},_e=new WeakMap,ut=new WeakMap,lt={},Lt=0,Un=function(e){return e&&(e.host||Un(e.parentNode))},wa=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Un(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},ya=function(e,t,n,r){var o=wa(t,Array.isArray(e)?e:[e]);lt[n]||(lt[n]=new WeakMap);var a=lt[n],i=[],c=new Set,p=new Set(o),f=function(u){!u||c.has(u)||(c.add(u),f(u.parentNode))};o.forEach(f);var l=function(u){!u||p.has(u)||Array.prototype.forEach.call(u.children,function(h){if(c.has(h))l(h);else try{var w=h.getAttribute(r),x=w!==null&&w!=="false",d=(_e.get(h)||0)+1,E=(a.get(h)||0)+1;_e.set(h,d),a.set(h,E),i.push(h),d===1&&x&&ut.set(h,!0),E===1&&h.setAttribute(n,"true"),x||h.setAttribute(r,"true")}catch(b){console.error("aria-hidden: cannot operate on ",h,b)}})};return l(t),c.clear(),Lt++,function(){i.forEach(function(u){var h=_e.get(u)-1,w=a.get(u)-1;_e.set(u,h),a.set(u,w),h||(ut.has(u)||u.removeAttribute(r),ut.delete(u)),w||u.removeAttribute(n)}),Lt--,Lt||(_e=new WeakMap,_e=new WeakMap,ut=new WeakMap,lt={})}},ba=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=ga(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),ya(r,o,n,"aria-hidden")):function(){return null}},ht="right-scroll-bar-position",vt="width-before-scroll-bar",Ea="with-scroll-bars-hidden",Sa="--removed-body-scroll-bar-size";function Mt(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function xa(e,t){var n=s.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var Ca=typeof window<"u"?s.useLayoutEffect:s.useEffect,hn=new WeakMap;function Ra(e,t){var n=xa(null,function(r){return e.forEach(function(o){return Mt(o,r)})});return Ca(function(){var r=hn.get(n);if(r){var o=new Set(r),a=new Set(e),i=n.current;o.forEach(function(c){a.has(c)||Mt(c,null)}),a.forEach(function(c){o.has(c)||Mt(c,i)})}hn.set(n,e)},[e]),n}function Da(e){return e}function Ta(e,t){t===void 0&&(t=Da);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(a){var i=t(a,r);return n.push(i),function(){n=n.filter(function(c){return c!==i})}},assignSyncMedium:function(a){for(r=!0;n.length;){var i=n;n=[],i.forEach(a)}n={push:function(c){return a(c)},filter:function(){return n}}},assignMedium:function(a){r=!0;var i=[];if(n.length){var c=n;n=[],c.forEach(a),i=n}var p=function(){var l=i;i=[],l.forEach(a)},f=function(){return Promise.resolve().then(p)};f(),n={push:function(l){i.push(l),f()},filter:function(l){return i=i.filter(l),n}}}};return o}function Aa(e){e===void 0&&(e={});var t=Ta(null);return t.options=ye({async:!0,ssr:!1},e),t}var Vn=function(e){var t=e.sideCar,n=Pn(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return s.createElement(r,ye({},n))};Vn.isSideCarExport=!0;function Oa(e,t){return e.useMedium(t),Vn}var zn=Aa(),_t=function(){},St=s.forwardRef(function(e,t){var n=s.useRef(null),r=s.useState({onScrollCapture:_t,onWheelCapture:_t,onTouchMoveCapture:_t}),o=r[0],a=r[1],i=e.forwardProps,c=e.children,p=e.className,f=e.removeScrollBar,l=e.enabled,u=e.shards,h=e.sideCar,w=e.noRelative,x=e.noIsolation,d=e.inert,E=e.allowPinchZoom,b=e.as,D=b===void 0?"div":b,g=e.gapMode,v=Pn(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),T=h,M=Ra([n,t]),S=ye(ye({},v),o);return s.createElement(s.Fragment,null,l&&s.createElement(T,{sideCar:zn,removeScrollBar:f,shards:u,noRelative:w,noIsolation:x,inert:d,setCallbacks:a,allowPinchZoom:!!E,lockRef:n,gapMode:g}),i?s.cloneElement(s.Children.only(c),ye(ye({},S),{ref:M})):s.createElement(D,ye({},S,{className:p,ref:M}),c))});St.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};St.classNames={fullWidth:vt,zeroRight:ht};var Na=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function ka(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Na();return t&&e.setAttribute("nonce",t),e}function Pa(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Ia(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var La=function(){var e=0,t=null;return{add:function(n){e==0&&(t=ka())&&(Pa(t,n),Ia(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Ma=function(){var e=La();return function(t,n){s.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},qn=function(){var e=Ma(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},_a={left:0,top:0,right:0,gap:0},jt=function(e){return parseInt(e||"",10)||0},ja=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[jt(n),jt(r),jt(o)]},Fa=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return _a;var t=ja(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},$a=qn(),$e="data-scroll-locked",Ba=function(e,t,n,r){var o=e.left,a=e.top,i=e.right,c=e.gap;return n===void 0&&(n="margin"),`
4
4
  .`.concat(Ea,` {
5
5
  overflow: hidden `).concat(r,`;
@@ -40,7 +40,7 @@ import{j as m,X as Sr,b as xr,B as en,ar as Cr,f as Rr,T as Dr,r as s,cp as Tr,c
40
40
  `)},vn=function(){var e=parseInt(document.body.getAttribute($e)||"0",10);return isFinite(e)?e:0},Ha=function(){s.useEffect(function(){return document.body.setAttribute($e,(vn()+1).toString()),function(){var e=vn()-1;e<=0?document.body.removeAttribute($e):document.body.setAttribute($e,e.toString())}},[])},Wa=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Ha();var a=s.useMemo(function(){return Fa(o)},[o]);return s.createElement($a,{styles:Ba(a,!t,o,n?"":"!important")})},qt=!1;if(typeof window<"u")try{var dt=Object.defineProperty({},"passive",{get:function(){return qt=!0,!0}});window.addEventListener("test",dt,dt),window.removeEventListener("test",dt,dt)}catch{qt=!1}var je=qt?{passive:!1}:!1,Ua=function(e){return e.tagName==="TEXTAREA"},Kn=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Ua(e)&&n[t]==="visible")},Va=function(e){return Kn(e,"overflowY")},za=function(e){return Kn(e,"overflowX")},gn=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Yn(e,r);if(o){var a=Gn(e,r),i=a[1],c=a[2];if(i>c)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},qa=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Ka=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Yn=function(e,t){return e==="v"?Va(t):za(t)},Gn=function(e,t){return e==="v"?qa(t):Ka(t)},Ya=function(e,t){return e==="h"&&t==="rtl"?-1:1},Ga=function(e,t,n,r,o){var a=Ya(e,window.getComputedStyle(t).direction),i=a*r,c=n.target,p=t.contains(c),f=!1,l=i>0,u=0,h=0;do{if(!c)break;var w=Gn(e,c),x=w[0],d=w[1],E=w[2],b=d-E-a*x;(x||b)&&Yn(e,c)&&(u+=b,h+=x);var D=c.parentNode;c=D&&D.nodeType===Node.DOCUMENT_FRAGMENT_NODE?D.host:D}while(!p&&c!==document.body||p&&(t.contains(c)||t===c));return(l&&Math.abs(u)<1||!l&&Math.abs(h)<1)&&(f=!0),f},ft=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},wn=function(e){return[e.deltaX,e.deltaY]},yn=function(e){return e&&"current"in e?e.current:e},Xa=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Qa=function(e){return`
41
41
  .block-interactivity-`.concat(e,` {pointer-events: none;}
42
42
  .allow-interactivity-`).concat(e,` {pointer-events: all;}
43
- `)},Za=0,Fe=[];function Ja(e){var t=s.useRef([]),n=s.useRef([0,0]),r=s.useRef(),o=s.useState(Za++)[0],a=s.useState(qn)[0],i=s.useRef(e);s.useEffect(function(){i.current=e},[e]),s.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var d=Ir([e.lockRef.current],(e.shards||[]).map(yn),!0).filter(Boolean);return d.forEach(function(E){return E.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),d.forEach(function(E){return E.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var c=s.useCallback(function(d,E){if("touches"in d&&d.touches.length===2||d.type==="wheel"&&d.ctrlKey)return!i.current.allowPinchZoom;var b=ft(d),D=n.current,g="deltaX"in d?d.deltaX:D[0]-b[0],v="deltaY"in d?d.deltaY:D[1]-b[1],T,M=d.target,S=Math.abs(g)>Math.abs(v)?"h":"v";if("touches"in d&&S==="h"&&M.type==="range")return!1;var O=window.getSelection(),N=O&&O.anchorNode,F=N?N===M||N.contains(M):!1;if(F)return!1;var y=gn(S,M);if(!y)return!0;if(y?T=S:(T=S==="v"?"h":"v",y=gn(S,M)),!y)return!1;if(!r.current&&"changedTouches"in d&&(g||v)&&(r.current=T),!T)return!0;var _=r.current||T;return Ga(_,E,d,_==="h"?g:v)},[]),p=s.useCallback(function(d){var E=d;if(!(!Fe.length||Fe[Fe.length-1]!==a)){var b="deltaY"in E?wn(E):ft(E),D=t.current.filter(function(T){return T.name===E.type&&(T.target===E.target||E.target===T.shadowParent)&&Xa(T.delta,b)})[0];if(D&&D.should){E.cancelable&&E.preventDefault();return}if(!D){var g=(i.current.shards||[]).map(yn).filter(Boolean).filter(function(T){return T.contains(E.target)}),v=g.length>0?c(E,g[0]):!i.current.noIsolation;v&&E.cancelable&&E.preventDefault()}}},[]),f=s.useCallback(function(d,E,b,D){var g={name:d,delta:E,target:b,should:D,shadowParent:es(b)};t.current.push(g),setTimeout(function(){t.current=t.current.filter(function(v){return v!==g})},1)},[]),l=s.useCallback(function(d){n.current=ft(d),r.current=void 0},[]),u=s.useCallback(function(d){f(d.type,wn(d),d.target,c(d,e.lockRef.current))},[]),h=s.useCallback(function(d){f(d.type,ft(d),d.target,c(d,e.lockRef.current))},[]);s.useEffect(function(){return Fe.push(a),e.setCallbacks({onScrollCapture:u,onWheelCapture:u,onTouchMoveCapture:h}),document.addEventListener("wheel",p,je),document.addEventListener("touchmove",p,je),document.addEventListener("touchstart",l,je),function(){Fe=Fe.filter(function(d){return d!==a}),document.removeEventListener("wheel",p,je),document.removeEventListener("touchmove",p,je),document.removeEventListener("touchstart",l,je)}},[]);var w=e.removeScrollBar,x=e.inert;return s.createElement(s.Fragment,null,x?s.createElement(a,{styles:Qa(o)}):null,w?s.createElement(Wa,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function es(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const ts=Oa(zn,Ja);var Xn=s.forwardRef(function(e,t){return s.createElement(St,ye({},e,{ref:t,sideCar:ts}))});Xn.classNames=St.classNames;const ns={brief:"/mail/brief",flagged:"/mail/flagged",outbox:"/mail/outbox",settings:"/settings",accounts:"/settings/accounts"};function Ei(){const e=In();return s.useCallback(t=>{e({to:ns[t]})},[e])}function rs(){const e=In();return s.useCallback(t=>{e({to:"/settings/accounts",search:{editAccountId:t,focusSmtp:!0}})},[e])}const Si=({enabled:e=!0,bindings:t,capture:n=!1})=>{const r=s.useCallback(o=>{const a=o.target;if(!(a.tagName==="INPUT"||a.tagName==="TEXTAREA"||a.isContentEditable))for(const i of t){if(!(o.key.toLowerCase()===i.key.toLowerCase())||i.requireShift!==void 0&&i.requireShift!==o.shiftKey)continue;const p=o.ctrlKey||o.metaKey;if(i.requireMeta!==void 0){if(i.requireMeta!==p)continue}else{const f=i.noModifiers??!0,l=p||o.altKey||i.requireShift===void 0&&o.shiftKey;if(f&&l)continue}i.preventDefault&&o.preventDefault(),i.stopPropagation&&(o.stopPropagation(),o.stopImmediatePropagation()),i.handler(o);return}},[t]);s.useEffect(()=>{if(e)return window.addEventListener("keydown",r,n),()=>window.removeEventListener("keydown",r,n)},[e,r,n])},os=(e,t)=>e===void 0&&t.toAddresses.length===0,as={status:"unsaved",reason:"Not saved — add a To address to keep this draft."},bn={status:"idle"},ss={status:"saving"},En={status:"saved"},Sn={status:"error"},is=e=>e.then(()=>{},()=>{}),cs=({outboxMessageId:e,onDraftCreated:t})=>{const[n,r]=s.useState(bn),[o,a]=s.useState(null),i=s.useRef(void 0),c=s.useRef(new Set),p=Lr(),f=s.useRef(e),l=s.useRef(e);if(f.current!==e){const g=f.current!==void 0;f.current=e,l.current=e,g&&i.current&&clearTimeout(i.current)}const u=gt({...Mr(),meta:wt}),h=gt({..._r(),meta:wt}),w=s.useCallback(async g=>{r(ss),a(null);const v=l.current;if(v){const M=await h.mutateAsync({path:{outboxMessageId:v},body:{toAddresses:g.toAddresses,ccAddresses:g.ccAddresses,bccAddresses:g.bccAddresses,subject:g.subject,textBody:g.textBody,htmlBody:g.htmlBody,inReplyTo:g.inReplyTo,references:g.references}});return r(En),M}const T=await u.mutateAsync({body:{...g,sendImmediately:!1}});return l.current=T.outboxMessageId,t(T.outboxMessageId),r(En),p.invalidateQueries({queryKey:jr().queryKey}),T},[u.mutateAsync,h.mutateAsync,t,p]),x=s.useRef(Promise.resolve()),d=s.useCallback(g=>{const v=x.current.then(()=>w(g));return x.current=is(v),v},[w]),E=s.useCallback(g=>{if(i.current&&clearTimeout(i.current),os(l.current,g)){r(as);return}r(v=>v.status==="unsaved"?bn:v),i.current=setTimeout(()=>{const v=l.current;v&&c.current.has(v)||d(g).catch(T=>{a(T),r(Sn)})},2e3)},[d]),b=s.useCallback(g=>(i.current&&clearTimeout(i.current),d(g).then(v=>({outcome:"saved",outboxMessageId:v.outboxMessageId})).catch(v=>(r(Sn),{outcome:"failed",error:v}))),[d]),D=s.useCallback(g=>{i.current&&clearTimeout(i.current),g&&c.current.add(g)},[]);return{saveState:n,saveError:o,saveDraft:E,saveImmediately:b,stopAutoSave:D}},us=e=>e.outboundCount>0||e.replyCount>0||e.flags?.vip?.value===!0||e.flags?.trusted?.value===!0,ls=e=>e.flags?.blocked?.value===!0?!1:e.flags?.junkOnly?.value!==!0?!0:us(e),Ft=({label:e,addresses:t,onChange:n,placeholder:r,onPendingChange:o,ref:a})=>{const[i,c]=s.useState(""),p=to(i,200),{data:f}=yt({...Fr({query:{q:p,limit:8}}),enabled:p.length>=2}),l=s.useMemo(()=>(f?.items??[]).filter(ls).map(u=>({email:u.normalizedEmail,displayName:u.displayName})),[f]);return m.jsx(lo,{label:e,addresses:t,onChange:n,placeholder:r,suggestions:l,onQueryChange:c,onPendingChange:o,ref:a})},ds=({accountId:e,configureRef:t})=>{const n=rs();return m.jsx(vo,{configureRef:t,onConfigure:()=>{n(e)}})},fs={download:"its dictionary could not be downloaded",engine:"the checker could not start",worker:"the checker stopped running"},ms=e=>{const t=`Spellcheck for ${e.language} is off: ${fs[e.reason]}.`;return{severity:"warning",title:"Spellcheck stopped",detail:`${t} Your browser is checking this message instead. ${e.detail}`,action:{label:"Report this",href:$r(Br({title:`Spellcheck stopped: ${e.reason} (${e.language})`,errorMessage:`${t} ${e.detail}`}))}}},ps=e=>({provider:async t=>{const{openSpellcheckWorker:n}=await Ln(async()=>{const{openSpellcheckWorker:r}=await import("./rich-text-spellcheck-worker-provider-DTxcyJ9W.js");return{openSpellcheckWorker:r}},__vite__mapDeps([0,1,2,3]));return n(t)},onStatus:t=>{t.state==="failed"&&e(ms(t))}}),xn=150,hs=()=>{const[e,t]=s.useState(()=>{if(typeof window>"u"||!window.visualViewport)return{viewportHeight:0,isKeyboardOpen:!1};const n=window.visualViewport.height;return{viewportHeight:n,isKeyboardOpen:window.innerHeight-n>xn}});return s.useEffect(()=>{if(typeof window>"u"||!window.visualViewport)return;const n=window.visualViewport,r=()=>{const o=n.height;t({viewportHeight:o,isKeyboardOpen:window.innerHeight-o>xn})};return r(),n.addEventListener("resize",r),()=>n.removeEventListener("resize",r)},[]),e},vs=({selectedAccountId:e,onSelect:t})=>{const{data:n}=yt({...Mn(),staleTime:1/0}),r=n?.accounts??[];if(s.useEffect(()=>{!e&&r.length===1&&r[0]&&t(r[0])},[e,r,t]),r.length<=1){const o=r[0];return o?m.jsxs("div",{className:"flex items-start gap-2",children:[m.jsx("label",{className:"text-sm text-fg-muted shrink-0 w-12 pt-1.5",children:"From:"}),m.jsx("div",{className:"text-sm py-1.5",children:o.email})]}):null}return m.jsxs("div",{className:"flex items-start gap-2",children:[m.jsx("label",{htmlFor:"from-account-selector",className:"text-sm text-fg-muted shrink-0 w-12 pt-1.5",children:"From:"}),m.jsx("select",{id:"from-account-selector",value:e??"",onChange:o=>{const a=r.find(i=>i.accountId===o.target.value);a&&t(a)},className:"flex-1 px-2 py-1.5 border rounded-md bg-canvas text-sm",children:r.map(o=>m.jsx("option",{value:o.accountId,children:o.email},o.accountId))})]})},gs=s.lazy(()=>Ln(()=>import("./rich-text-DUWqcHC5.js"),__vite__mapDeps([4,1,2,5,6,7,3,8,9,10,11])).then(e=>({default:e.ComposeBody}))),ws=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),ys=e=>e.split(`
43
+ `)},Za=0,Fe=[];function Ja(e){var t=s.useRef([]),n=s.useRef([0,0]),r=s.useRef(),o=s.useState(Za++)[0],a=s.useState(qn)[0],i=s.useRef(e);s.useEffect(function(){i.current=e},[e]),s.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var d=Ir([e.lockRef.current],(e.shards||[]).map(yn),!0).filter(Boolean);return d.forEach(function(E){return E.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),d.forEach(function(E){return E.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var c=s.useCallback(function(d,E){if("touches"in d&&d.touches.length===2||d.type==="wheel"&&d.ctrlKey)return!i.current.allowPinchZoom;var b=ft(d),D=n.current,g="deltaX"in d?d.deltaX:D[0]-b[0],v="deltaY"in d?d.deltaY:D[1]-b[1],T,M=d.target,S=Math.abs(g)>Math.abs(v)?"h":"v";if("touches"in d&&S==="h"&&M.type==="range")return!1;var O=window.getSelection(),N=O&&O.anchorNode,F=N?N===M||N.contains(M):!1;if(F)return!1;var y=gn(S,M);if(!y)return!0;if(y?T=S:(T=S==="v"?"h":"v",y=gn(S,M)),!y)return!1;if(!r.current&&"changedTouches"in d&&(g||v)&&(r.current=T),!T)return!0;var _=r.current||T;return Ga(_,E,d,_==="h"?g:v)},[]),p=s.useCallback(function(d){var E=d;if(!(!Fe.length||Fe[Fe.length-1]!==a)){var b="deltaY"in E?wn(E):ft(E),D=t.current.filter(function(T){return T.name===E.type&&(T.target===E.target||E.target===T.shadowParent)&&Xa(T.delta,b)})[0];if(D&&D.should){E.cancelable&&E.preventDefault();return}if(!D){var g=(i.current.shards||[]).map(yn).filter(Boolean).filter(function(T){return T.contains(E.target)}),v=g.length>0?c(E,g[0]):!i.current.noIsolation;v&&E.cancelable&&E.preventDefault()}}},[]),f=s.useCallback(function(d,E,b,D){var g={name:d,delta:E,target:b,should:D,shadowParent:es(b)};t.current.push(g),setTimeout(function(){t.current=t.current.filter(function(v){return v!==g})},1)},[]),l=s.useCallback(function(d){n.current=ft(d),r.current=void 0},[]),u=s.useCallback(function(d){f(d.type,wn(d),d.target,c(d,e.lockRef.current))},[]),h=s.useCallback(function(d){f(d.type,ft(d),d.target,c(d,e.lockRef.current))},[]);s.useEffect(function(){return Fe.push(a),e.setCallbacks({onScrollCapture:u,onWheelCapture:u,onTouchMoveCapture:h}),document.addEventListener("wheel",p,je),document.addEventListener("touchmove",p,je),document.addEventListener("touchstart",l,je),function(){Fe=Fe.filter(function(d){return d!==a}),document.removeEventListener("wheel",p,je),document.removeEventListener("touchmove",p,je),document.removeEventListener("touchstart",l,je)}},[]);var w=e.removeScrollBar,x=e.inert;return s.createElement(s.Fragment,null,x?s.createElement(a,{styles:Qa(o)}):null,w?s.createElement(Wa,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function es(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const ts=Oa(zn,Ja);var Xn=s.forwardRef(function(e,t){return s.createElement(St,ye({},e,{ref:t,sideCar:ts}))});Xn.classNames=St.classNames;const ns={brief:"/mail/brief",flagged:"/mail/flagged",outbox:"/mail/outbox",settings:"/settings",accounts:"/settings/accounts"};function Ei(){const e=In();return s.useCallback(t=>{e({to:ns[t]})},[e])}function rs(){const e=In();return s.useCallback(t=>{e({to:"/settings/accounts",search:{editAccountId:t,focusSmtp:!0}})},[e])}const Si=({enabled:e=!0,bindings:t,capture:n=!1})=>{const r=s.useCallback(o=>{const a=o.target;if(!(a.tagName==="INPUT"||a.tagName==="TEXTAREA"||a.isContentEditable))for(const i of t){if(!(o.key.toLowerCase()===i.key.toLowerCase())||i.requireShift!==void 0&&i.requireShift!==o.shiftKey)continue;const p=o.ctrlKey||o.metaKey;if(i.requireMeta!==void 0){if(i.requireMeta!==p)continue}else{const f=i.noModifiers??!0,l=p||o.altKey||i.requireShift===void 0&&o.shiftKey;if(f&&l)continue}i.preventDefault&&o.preventDefault(),i.stopPropagation&&(o.stopPropagation(),o.stopImmediatePropagation()),i.handler(o);return}},[t]);s.useEffect(()=>{if(e)return window.addEventListener("keydown",r,n),()=>window.removeEventListener("keydown",r,n)},[e,r,n])},os=(e,t)=>e===void 0&&t.toAddresses.length===0,as={status:"unsaved",reason:"Not saved — add a To address to keep this draft."},bn={status:"idle"},ss={status:"saving"},En={status:"saved"},Sn={status:"error"},is=e=>e.then(()=>{},()=>{}),cs=({outboxMessageId:e,onDraftCreated:t})=>{const[n,r]=s.useState(bn),[o,a]=s.useState(null),i=s.useRef(void 0),c=s.useRef(new Set),p=Lr(),f=s.useRef(e),l=s.useRef(e);if(f.current!==e){const g=f.current!==void 0;f.current=e,l.current=e,g&&i.current&&clearTimeout(i.current)}const u=gt({...Mr(),meta:wt}),h=gt({..._r(),meta:wt}),w=s.useCallback(async g=>{r(ss),a(null);const v=l.current;if(v){const M=await h.mutateAsync({path:{outboxMessageId:v},body:{toAddresses:g.toAddresses,ccAddresses:g.ccAddresses,bccAddresses:g.bccAddresses,subject:g.subject,textBody:g.textBody,htmlBody:g.htmlBody,inReplyTo:g.inReplyTo,references:g.references}});return r(En),M}const T=await u.mutateAsync({body:{...g,sendImmediately:!1}});return l.current=T.outboxMessageId,t(T.outboxMessageId),r(En),p.invalidateQueries({queryKey:jr().queryKey}),T},[u.mutateAsync,h.mutateAsync,t,p]),x=s.useRef(Promise.resolve()),d=s.useCallback(g=>{const v=x.current.then(()=>w(g));return x.current=is(v),v},[w]),E=s.useCallback(g=>{if(i.current&&clearTimeout(i.current),os(l.current,g)){r(as);return}r(v=>v.status==="unsaved"?bn:v),i.current=setTimeout(()=>{const v=l.current;v&&c.current.has(v)||d(g).catch(T=>{a(T),r(Sn)})},2e3)},[d]),b=s.useCallback(g=>(i.current&&clearTimeout(i.current),d(g).then(v=>({outcome:"saved",outboxMessageId:v.outboxMessageId})).catch(v=>(r(Sn),{outcome:"failed",error:v}))),[d]),D=s.useCallback(g=>{i.current&&clearTimeout(i.current),g&&c.current.add(g)},[]);return{saveState:n,saveError:o,saveDraft:E,saveImmediately:b,stopAutoSave:D}},us=e=>e.outboundCount>0||e.replyCount>0||e.flags?.vip?.value===!0||e.flags?.trusted?.value===!0,ls=e=>e.flags?.blocked?.value===!0?!1:e.flags?.junkOnly?.value!==!0?!0:us(e),Ft=({label:e,addresses:t,onChange:n,placeholder:r,onPendingChange:o,ref:a})=>{const[i,c]=s.useState(""),p=to(i,200),{data:f}=yt({...Fr({query:{q:p,limit:8}}),enabled:p.length>=2}),l=s.useMemo(()=>(f?.items??[]).filter(ls).map(u=>({email:u.normalizedEmail,displayName:u.displayName})),[f]);return m.jsx(lo,{label:e,addresses:t,onChange:n,placeholder:r,suggestions:l,onQueryChange:c,onPendingChange:o,ref:a})},ds=({accountId:e,configureRef:t})=>{const n=rs();return m.jsx(vo,{configureRef:t,onConfigure:()=>{n(e)}})},fs={download:"its dictionary could not be downloaded",engine:"the checker could not start",worker:"the checker stopped running"},ms=e=>{const t=`Spellcheck for ${e.language} is off: ${fs[e.reason]}.`;return{severity:"warning",title:"Spellcheck stopped",detail:`${t} Your browser is checking this message instead. ${e.detail}`,action:{label:"Report this",href:$r(Br({title:`Spellcheck stopped: ${e.reason} (${e.language})`,errorMessage:`${t} ${e.detail}`}))}}},ps=e=>({provider:async t=>{const{openSpellcheckWorker:n}=await Ln(async()=>{const{openSpellcheckWorker:r}=await import("./rich-text-spellcheck-worker-provider-CXOEqFHn.js");return{openSpellcheckWorker:r}},__vite__mapDeps([0,1,2,3]));return n(t)},onStatus:t=>{t.state==="failed"&&e(ms(t))}}),xn=150,hs=()=>{const[e,t]=s.useState(()=>{if(typeof window>"u"||!window.visualViewport)return{viewportHeight:0,isKeyboardOpen:!1};const n=window.visualViewport.height;return{viewportHeight:n,isKeyboardOpen:window.innerHeight-n>xn}});return s.useEffect(()=>{if(typeof window>"u"||!window.visualViewport)return;const n=window.visualViewport,r=()=>{const o=n.height;t({viewportHeight:o,isKeyboardOpen:window.innerHeight-o>xn})};return r(),n.addEventListener("resize",r),()=>n.removeEventListener("resize",r)},[]),e},vs=({selectedAccountId:e,onSelect:t})=>{const{data:n}=yt({...Mn(),staleTime:1/0}),r=n?.accounts??[];if(s.useEffect(()=>{!e&&r.length===1&&r[0]&&t(r[0])},[e,r,t]),r.length<=1){const o=r[0];return o?m.jsxs("div",{className:"flex items-start gap-2",children:[m.jsx("label",{className:"text-sm text-fg-muted shrink-0 w-12 pt-1.5",children:"From:"}),m.jsx("div",{className:"text-sm py-1.5",children:o.email})]}):null}return m.jsxs("div",{className:"flex items-start gap-2",children:[m.jsx("label",{htmlFor:"from-account-selector",className:"text-sm text-fg-muted shrink-0 w-12 pt-1.5",children:"From:"}),m.jsx("select",{id:"from-account-selector",value:e??"",onChange:o=>{const a=r.find(i=>i.accountId===o.target.value);a&&t(a)},className:"flex-1 px-2 py-1.5 border rounded-md bg-canvas text-sm",children:r.map(o=>m.jsx("option",{value:o.accountId,children:o.email},o.accountId))})]})},gs=s.lazy(()=>Ln(()=>import("./rich-text-DTviXfBN.js"),__vite__mapDeps([4,1,2,5,6,7,3,8,9,10,11])).then(e=>({default:e.ComposeBody}))),ws=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),ys=e=>e.split(`
44
44
  `).map(t=>`<p>${ws(t)}</p>`).join(""),bs=e=>e?`<p></p><p>-- </p>${ys(e)}`:"",$t=e=>({html:bs(e),text:e}),Es=e=>e?/^re:\s/i.test(e)?e:`Re: ${e}`:"Re: ",Ss=e=>e?/^fwd?:\s/i.test(e)?e:`Fwd: ${e}`:"Fwd: ",xs=(e,t,n)=>{const{envelope:r}=e,a=(r.replyTo.length>0?r.replyTo:r.from).map(f=>({email:f.normalizedEmail,displayName:f.displayName}));if(t!=="reply-all")return{to:a,cc:[]};const i=n?.toLowerCase(),c=new Set(a.map(f=>f.email.toLowerCase())),p=[...r.to,...r.cc].filter(f=>f.normalizedEmail.toLowerCase()!==i&&!c.has(f.normalizedEmail.toLowerCase())).map(f=>({email:f.normalizedEmail,displayName:f.displayName}));return{to:a,cc:p}},Cs=e=>{const t=e.envelope.messageIdValue,r=[...e.references.filter(o=>o.referenceType==="references").sort((o,a)=>o.referenceOrder-a.referenceOrder).map(o=>o.messageIdValue)];return t&&!r.includes(t)&&r.push(t),{inReplyTo:t,references:r}},Cn=(e,t,n)=>({textBody:t.text||void 0,htmlBody:e==="plain"?"":t.html?Gr(t.html,n):void 0}),Rs="Add a To address before sending.",Ds=({label:e,text:t})=>`${e} holds "${t}", which is not an address.`,Rn=e=>e.find(t=>t.text.trim()!==""),Ts={entries:[],unparsed:""},As=(e,t,n,r,o)=>e.length===0&&t.length===0&&n.length===0&&r.trim()===""&&o.text.trim()==="",Os=({documentGeneration:e,selectedAccountId:t,onAccountChange:n,toAddresses:r,setToAddresses:o,ccAddresses:a,setCcAddresses:i,bccAddresses:c,setBccAddresses:p,showCc:f,setShowCc:l,showBcc:u,setShowBcc:h,subject:w,setSubject:x,fieldHandles:d,onToPendingChange:E})=>{const b=Xr(),{isKeyboardOpen:D}=hs(),[g,v]=s.useState(void 0),T=g===e;return m.jsx(ho,{collapsed:!b&&D&&!T,onExpand:()=>v(e),summary:po({to:r,cc:a,bcc:c,subject:w}),from:m.jsx(vs,{selectedAccountId:t,onSelect:n}),to:m.jsx(Ft,{label:"To",addresses:r,onChange:o,placeholder:"Recipients",onPendingChange:E,ref:d.to}),cc:f?m.jsx(Ft,{label:"Cc",addresses:a,onChange:i,ref:d.cc}):void 0,bcc:u?m.jsx(Ft,{label:"Bcc",addresses:c,onChange:p,ref:d.bcc}):void 0,subject:m.jsx(go,{value:w,onChange:x}),onShowCc:()=>l(!0),onShowBcc:()=>h(!0)})},xi=({mode:e,account:t,sourceMessage:n,outboxMessageId:r,onDraftCreated:o,onClose:a,onAccountChange:i,layout:c="fill"})=>{const{startSendPolling:p}=Hr(),{pushError:f}=Wr(),[l,u]=s.useState([]),[h,w]=s.useState([]),[x,d]=s.useState([]),[E,b]=s.useState(Ts),D=s.useRef(null),g=s.useRef(null),v=s.useRef(null),T=s.useMemo(()=>({to:D,cc:g,bcc:v}),[]),M=s.useCallback(()=>{D.current?.clearPending(),g.current?.clearPending(),v.current?.clearPending()},[]),[S,O]=s.useState(""),[N,F]=s.useState(!1),[y,_]=s.useState(!1),[R,W]=s.useState(t?.accountId),[U,X]=s.useState(!1),[V,J]=s.useState(r),oe=s.useRef(null),me=s.useRef(r),He=s.useRef(r!==void 0),We=s.useRef(t?.accountId);s.useEffect(()=>{const P=t?.accountId;!P||We.current===P||(We.current=P,!He.current&&W(P))},[t?.accountId]),s.useEffect(()=>{const P=me.current;if(P===r||(me.current=r,P===void 0))return;He.current=r!==void 0;const $=r?{html:"",text:""}:$t(Ee.current);u([]),w([]),d([]),M(),O(""),F(!1),_(!1),pe($.html),Ne($.text),ke("rich"),Ve(void 0),ze({...$,formatting:[]}),Oe(Q=>Q+1),X(!1),J(r)},[r,M]);const{signature:ee}=Jr(R),Ee=s.useRef(ee.plainText);Ee.current=ee.plainText;const[Ae,Oe]=s.useState(0),[Se,pe]=s.useState(()=>$t(ee.plainText).html),[Ue,Ne]=s.useState(ee.plainText),[te,ke]=s.useState("rich"),[xe,k]=s.useState("en"),[tt,Ve]=s.useState(),[ue,ze]=s.useState(()=>({...$t(ee.plainText),formatting:[]})),{data:Y,error:le}=yt({...Ur({path:{outboxMessageId:r??""}}),enabled:!!r&&!U,meta:Qr,retry:(P,$)=>!tn($)&&P<1});s.useEffect(()=>{tn(le)&&a()},[le,a]),s.useEffect(()=>{if(!Y||U)return;u(Y.toAddresses.map(re=>({email:re,displayName:void 0}))),Y.ccAddresses&&Y.ccAddresses.length>0&&(w(Y.ccAddresses.map(re=>({email:re,displayName:void 0}))),F(!0)),Y.bccAddresses&&Y.bccAddresses.length>0&&(d(Y.bccAddresses.map(re=>({email:re,displayName:void 0}))),_(!0)),Y.subject&&O(Y.subject);const P=Vr(Y.htmlBody??""),$=P.html,Q=Y.textBody??"";ke(To(Y.htmlBody)),Ve(P.language??void 0),pe($),Ne(Q),ze({html:$,text:Q,formatting:[]}),Oe(re=>re+1),W(Y.accountId),X(!0)},[Y,U]),s.useEffect(()=>{if(!He.current&&n){if(M(),e==="reply"||e==="reply-all"){const{to:P,cc:$}=xs(n,e,t?.email);u(P),w($),$.length>0&&F(!0),O(Es(n.envelope.subject))}e==="forward"&&(u([]),w([]),d([]),O(Ss(n.envelope.subject)))}},[e,n,t?.email,M]);const nt=e==="reply"||e==="reply-all"||e==="forward",{data:Pe}=Zr({messageId:n?.message.messageId,bodyParts:n?.bodyParts,enabled:nt&&!!n}),he=Pe?.kind==="text"?Pe.body:"",rt=Pe?.kind==="html"?Do(Pe.body):void 0,ot=n?.envelope.from[0]?.displayName??n?.envelope.from[0]?.normalizedEmail,Ct=s.useCallback(P=>{X(!0),J(P),o(P)},[o]),{saveState:Rt,saveError:de,saveDraft:at,saveImmediately:qe,stopAutoSave:Ce}=cs({outboxMessageId:r,onDraftCreated:Ct});s.useEffect(()=>{de&&f({title:"Couldn't save draft",detail:Ot(de)??"Saving the draft failed.",error:de})},[de,f]);const ve=gt({...zr(),meta:wt}),Ke=gt({...Kr(),meta:wt,onError:P=>{f(qr("Couldn't discard draft","The draft wasn't discarded.",P))}}),{data:Dt}=yt({...Mn(),staleTime:1/0}),Re=Dt?.accounts.find(P=>P.accountId===R),Ye=Re?eo(Re):!1,Ie=Re?.composeLanguages,Tt=s.useMemo(()=>Ie&&Ie.length>0?Ie:Yr(navigator.languages),[Ie]),A=s.useMemo(()=>ps(f),[f]),L=s.useRef(!1),[j,I]=s.useState(!1),B=s.useCallback((P,$)=>j?{status:"sending"}:R?Ye?{status:"blocked",reason:Vt}:$?{status:"blocked",reason:Ds($)}:P===0?{status:"blocked",reason:Rs}:{status:"ready",accountId:R}:{status:"blocked",reason:"Choose an account to send from."},[j,R,Ye]),K=s.useMemo(()=>B(l.length+E.entries.length,Rn([{label:"To",text:E.unparsed}])),[B,l.length,E]),G=K;s.useEffect(()=>{if(!R||L.current||V!==void 0&&V!==r||r&&!U||As(l,h,x,S,ue))return;const{htmlBody:P,textBody:$}=Cn(te,ue,xe);at({accountId:R,toAddresses:l.map(Q=>Q.email),ccAddresses:h.length>0?h.map(Q=>Q.email):void 0,bccAddresses:x.length>0?x.map(Q=>Q.email):void 0,subject:S||void 0,textBody:$,htmlBody:P})},[R,r,V,U,l,h,x,S,ue,te,xe,at]);const ae=s.useCallback(async(P,$)=>{if(!L.current){L.current=!0,I(!0);try{Ce();const Q=n&&(e==="reply"||e==="reply-all")?Cs(n):{},{htmlBody:re,textBody:Le}=Cn(te,ue,xe),Er=!r,st=await qe({accountId:P,toAddresses:$.to.map(ge=>ge.email),ccAddresses:$.cc.length>0?$.cc.map(ge=>ge.email):void 0,bccAddresses:$.bcc.length>0?$.bcc.map(ge=>ge.email):void 0,subject:S||void 0,textBody:Le,htmlBody:re,...Q});if(st.outcome==="failed"){f({title:"Couldn't send message",detail:Ot(st.error)??"Saving the message failed, so nothing was sent. Try again.",error:st.error});return}const At=st.outboxMessageId;if(await ve.mutateAsync({path:{outboxMessageId:At}}).catch(ge=>(f({title:"Couldn't send message",detail:Ot(ge)??(Er?"The draft was saved but the send request failed. Try again from the Outbox.":"The send request failed. Try again."),error:ge}),null))===null)return;Ce(At),p(At),a()}finally{L.current=!1,I(!1)}}},[S,ue,te,xe,e,n,r,qe,ve,Ce,p,f,a]),Z=s.useCallback(()=>{Ce(r),r&&Ke.mutate({path:{outboxMessageId:r}}),a()},[Ce,r,Ke,a]),se=s.useCallback(P=>{f({title:"Can't send yet",detail:P}),P===Vt&&oe.current?.focus()},[f]),ie=s.useCallback(()=>{if(K.status==="sending")return;const P=T.to.current?.commitPending(),$=T.cc.current?.commitPending(),Q=T.bcc.current?.commitPending(),re={to:P?.addresses??l,cc:$?.addresses??h,bcc:Q?.addresses??x},Le=B(re.to.length,Rn([{label:"To",text:P?.unparsed??""},{label:"Cc",text:$?.unparsed??""},{label:"Bcc",text:Q?.unparsed??""}]));if(Le.status!=="sending"){if(Le.status==="blocked"){se(Le.reason);return}ae(Le.accountId,re)}},[K.status,T,l,h,x,B,se,ae]),ne=s.useCallback(P=>{W(P.accountId),i?.(P)},[i]);return m.jsx(mo,{layout:c,banner:Re&&Ye?m.jsx(ds,{accountId:Re.accountId,configureRef:oe}):void 0,header:m.jsx(Os,{documentGeneration:Ae,selectedAccountId:R,onAccountChange:ne,toAddresses:l,setToAddresses:u,ccAddresses:h,setCcAddresses:w,bccAddresses:x,setBccAddresses:d,showCc:N,setShowCc:F,showBcc:y,setShowBcc:_,subject:S,setSubject:O,fieldHandles:T,onToPendingChange:b}),quoted:he||rt?m.jsx(wo,{text:he,html:rt,senderName:ot}):void 0,actionBar:m.jsx(oo,{send:G,onSend:ie,onBlocked:se,onDiscard:Z,save:Rt}),children:m.jsx(s.Suspense,{fallback:m.jsx(fo,{}),children:m.jsx(gs,{mode:te,onModeChange:ke,initialHtml:Se,initialText:Ue,onChange:ze,onSubmit:ie,initialCaret:e==="new"?"start":void 0,onConversionError:f,languages:Tt,initialLanguage:tt,onLanguageChange:k,spellcheck:A},Ae)})})};var xt="Dialog",[Qn]=No(xt),[Ns,ce]=Qn(xt),Zn=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:a,modal:i=!0}=e,c=s.useRef(null),p=s.useRef(null),[f,l]=Io({prop:r,defaultProp:o??!1,onChange:a,caller:xt});return m.jsx(Ns,{scope:t,triggerRef:c,contentRef:p,contentId:It(),titleId:It(),descriptionId:It(),open:f,onOpenChange:l,onOpenToggle:s.useCallback(()=>l(u=>!u),[l]),modal:i,children:n})};Zn.displayName=xt;var Jn="DialogTrigger",ks=s.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ce(Jn,n),a=Te(t,o.triggerRef);return m.jsx(fe.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":Zt(o.open),...r,ref:a,onClick:be(e.onClick,o.onOpenToggle)})});ks.displayName=Jn;var Qt="DialogPortal",[Ps,er]=Qn(Qt,{forceMount:void 0}),tr=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,a=ce(Qt,t);return m.jsx(Ps,{scope:t,forceMount:n,children:s.Children.map(r,i=>m.jsx(Et,{present:n||a.open,children:m.jsx(Wn,{asChild:!0,container:o,children:i})}))})};tr.displayName=Qt;var bt="DialogOverlay",nr=s.forwardRef((e,t)=>{const n=er(bt,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,a=ce(bt,e.__scopeDialog);return a.modal?m.jsx(Et,{present:r||a.open,children:m.jsx(Ls,{...o,ref:t})}):null});nr.displayName=bt;var Is=jn("DialogOverlay.RemoveScroll"),Ls=s.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ce(bt,n),a=Zo(),i=Te(t,a);return m.jsx(Xn,{as:Is,allowPinchZoom:!0,shards:[o.contentRef],children:m.jsx(fe.div,{"data-state":Zt(o.open),...r,ref:i,style:{pointerEvents:"auto",...r.style}})})}),Be="DialogContent",rr=s.forwardRef((e,t)=>{const n=er(Be,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,a=ce(Be,e.__scopeDialog);return m.jsx(Et,{present:r||a.open,children:a.modal?m.jsx(Ms,{...o,ref:t}):m.jsx(_s,{...o,ref:t})})});rr.displayName=Be;var Ms=s.forwardRef((e,t)=>{const n=ce(Be,e.__scopeDialog),r=s.useRef(null),o=Te(t,n.contentRef,r);return s.useEffect(()=>{const a=r.current;if(a)return ba(a)},[]),m.jsx(or,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:be(e.onCloseAutoFocus,a=>{a.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:be(e.onPointerDownOutside,a=>{const i=a.detail.originalEvent,c=i.button===0&&i.ctrlKey===!0;(i.button===2||c)&&a.preventDefault()}),onFocusOutside:be(e.onFocusOutside,a=>a.preventDefault())})}),_s=s.forwardRef((e,t)=>{const n=ce(Be,e.__scopeDialog),r=s.useRef(!1),o=s.useRef(!1);return m.jsx(or,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{e.onCloseAutoFocus?.(a),a.defaultPrevented||(r.current||n.triggerRef.current?.focus(),a.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:a=>{e.onInteractOutside?.(a),a.defaultPrevented||(r.current=!0,a.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=a.target;n.triggerRef.current?.contains(i)&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&o.current&&a.preventDefault()}})}),or=s.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:a,...i}=e,c=ce(Be,n);return na(),m.jsx(m.Fragment,{children:m.jsx(Bn,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:a,children:m.jsx(Fn,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":Zt(c.open),...i,ref:t,deferPointerDownOutside:!0,onDismiss:()=>c.onOpenChange(!1)})})})}),ar="DialogTitle",sr=s.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ce(ar,n);return m.jsx(fe.h2,{id:o.titleId,...r,ref:t})});sr.displayName=ar;var ir="DialogDescription",js=s.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ce(ir,n);return m.jsx(fe.p,{id:o.descriptionId,...r,ref:t})});js.displayName=ir;var cr="DialogClose",Fs=s.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ce(cr,n);return m.jsx(fe.button,{type:"button",...r,ref:t,onClick:be(e.onClick,()=>o.onOpenChange(!1))})});Fs.displayName=cr;function Zt(e){return e?"open":"closed"}function $s(e){if(typeof document>"u")return;let t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}const ur=C.createContext({drawerRef:{current:null},overlayRef:{current:null},onPress:()=>{},onRelease:()=>{},onDrag:()=>{},onNestedDrag:()=>{},onNestedOpenChange:()=>{},onNestedRelease:()=>{},openProp:void 0,dismissible:!1,isOpen:!1,isDragging:!1,keyboardIsOpen:{current:!1},snapPointsOffset:null,snapPoints:null,handleOnly:!1,modal:!1,shouldFade:!1,activeSnapPoint:null,onOpenChange:()=>{},setActiveSnapPoint:()=>{},closeDrawer:()=>{},direction:"bottom",shouldAnimate:{current:!0},shouldScaleBackground:!1,setBackgroundColorOnScale:!0,noBodyStyles:!1,container:null,autoFocus:!1}),et=()=>{const e=C.useContext(ur);if(!e)throw new Error("useDrawerContext must be used within a Drawer.Root");return e};$s(`[data-vaul-drawer]{touch-action:none;will-change:transform;transition:transform .5s cubic-bezier(.32, .72, 0, 1);animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=open]{animation-name:slideFromBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=closed]{animation-name:slideToBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=open]{animation-name:slideFromTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=closed]{animation-name:slideToTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=open]{animation-name:slideFromLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=closed]{animation-name:slideToLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=open]{animation-name:slideFromRight}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=closed]{animation-name:slideToRight}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--initial-transform,100%),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--initial-transform,100%),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-overlay][data-vaul-snap-points=false]{animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-overlay][data-vaul-snap-points=false][data-state=open]{animation-name:fadeIn}[data-vaul-overlay][data-state=closed]{animation-name:fadeOut}[data-vaul-animate=false]{animation:none!important}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:0;transition:opacity .5s cubic-bezier(.32, .72, 0, 1)}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:1}[data-vaul-drawer]:not([data-vaul-custom-container=true])::after{content:'';position:absolute;background:inherit;background-color:inherit}[data-vaul-drawer][data-vaul-drawer-direction=top]::after{top:initial;bottom:100%;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=bottom]::after{top:100%;bottom:initial;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=left]::after{left:initial;right:100%;top:0;bottom:0;width:200%}[data-vaul-drawer][data-vaul-drawer-direction=right]::after{left:100%;right:initial;top:0;bottom:0;width:200%}[data-vaul-overlay][data-vaul-snap-points=true]:not([data-vaul-snap-points-overlay=true]):not(
45
45
  [data-state=closed]
46
46
  ){opacity:0}[data-vaul-overlay][data-vaul-snap-points-overlay=true]{opacity:1}[data-vaul-handle]{display:block;position:relative;opacity:.7;background:#e2e2e4;margin-left:auto;margin-right:auto;height:5px;width:32px;border-radius:1rem;touch-action:pan-y}[data-vaul-handle]:active,[data-vaul-handle]:hover{opacity:1}[data-vaul-handle-hitarea]{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:max(100%,2.75rem);height:max(100%,2.75rem);touch-action:inherit}@media (hover:hover) and (pointer:fine){[data-vaul-drawer]{user-select:none}}@media (pointer:fine){[data-vaul-handle-hitarea]:{width:100%;height:100%}}@keyframes fadeIn{from{opacity:0}to{opacity:1}}@keyframes fadeOut{to{opacity:0}}@keyframes slideFromBottom{from{transform:translate3d(0,var(--initial-transform,100%),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToBottom{to{transform:translate3d(0,var(--initial-transform,100%),0)}}@keyframes slideFromTop{from{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToTop{to{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}}@keyframes slideFromLeft{from{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToLeft{to{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}}@keyframes slideFromRight{from{transform:translate3d(var(--initial-transform,100%),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToRight{to{transform:translate3d(var(--initial-transform,100%),0,0)}}`);function Bs(){const e=navigator.userAgent;return typeof window<"u"&&(/Firefox/.test(e)&&/Mobile/.test(e)||/FxiOS/.test(e))}function Hs(){return Jt(/^Mac/)}function Ws(){return Jt(/^iPhone/)}function Dn(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function Us(){return Jt(/^iPad/)||Hs()&&navigator.maxTouchPoints>1}function lr(){return Ws()||Us()}function Jt(e){return typeof window<"u"&&window.navigator!=null?e.test(window.navigator.platform):void 0}const Vs=24,zs=typeof window<"u"?s.useLayoutEffect:s.useEffect;function Tn(...e){return(...t)=>{for(let n of e)typeof n=="function"&&n(...t)}}const Bt=typeof document<"u"&&window.visualViewport;function An(e){let t=window.getComputedStyle(e);return/(auto|scroll)/.test(t.overflow+t.overflowX+t.overflowY)}function dr(e){for(An(e)&&(e=e.parentElement);e&&!An(e);)e=e.parentElement;return e||document.scrollingElement||document.documentElement}const qs=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);let mt=0,Ht;function Ks(e={}){let{isDisabled:t}=e;zs(()=>{if(!t)return mt++,mt===1&&lr()&&(Ht=Ys()),()=>{mt--,mt===0&&Ht?.()}},[t])}function Ys(){let e,t=0,n=u=>{e=dr(u.target),!(e===document.documentElement&&e===document.body)&&(t=u.changedTouches[0].pageY)},r=u=>{if(!e||e===document.documentElement||e===document.body){u.preventDefault();return}let h=u.changedTouches[0].pageY,w=e.scrollTop,x=e.scrollHeight-e.clientHeight;x!==0&&((w<=0&&h>t||w>=x&&h<t)&&u.preventDefault(),t=h)},o=u=>{let h=u.target;Kt(h)&&h!==document.activeElement&&(u.preventDefault(),h.style.transform="translateY(-2000px)",h.focus(),requestAnimationFrame(()=>{h.style.transform=""}))},a=u=>{let h=u.target;Kt(h)&&(h.style.transform="translateY(-2000px)",requestAnimationFrame(()=>{h.style.transform="",Bt&&(Bt.height<window.innerHeight?requestAnimationFrame(()=>{On(h)}):Bt.addEventListener("resize",()=>On(h),{once:!0}))}))},i=()=>{window.scrollTo(0,0)},c=window.pageXOffset,p=window.pageYOffset,f=Tn(Gs(document.documentElement,"paddingRight",`${window.innerWidth-document.documentElement.clientWidth}px`));window.scrollTo(0,0);let l=Tn(Xe(document,"touchstart",n,{passive:!1,capture:!0}),Xe(document,"touchmove",r,{passive:!1,capture:!0}),Xe(document,"touchend",o,{passive:!1,capture:!0}),Xe(document,"focus",a,!0),Xe(window,"scroll",i));return()=>{f(),l(),window.scrollTo(c,p)}}function Gs(e,t,n){let r=e.style[t];return e.style[t]=n,()=>{e.style[t]=r}}function Xe(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}function On(e){let t=document.scrollingElement||document.documentElement;for(;e&&e!==t;){let n=dr(e);if(n!==document.documentElement&&n!==document.body&&n!==e){let r=n.getBoundingClientRect().top,o=e.getBoundingClientRect().top,a=e.getBoundingClientRect().bottom;const i=n.getBoundingClientRect().bottom+Vs;a>i&&(n.scrollTop+=o-r)}e=n.parentElement}}function Kt(e){return e instanceof HTMLInputElement&&!qs.has(e.type)||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}function Xs(e,t){typeof e=="function"?e(t):e!=null&&(e.current=t)}function Qs(...e){return t=>e.forEach(n=>Xs(n,t))}function fr(...e){return s.useCallback(Qs(...e),e)}const mr=new WeakMap;function q(e,t,n=!1){if(!e||!(e instanceof HTMLElement))return;let r={};Object.entries(t).forEach(([o,a])=>{if(o.startsWith("--")){e.style.setProperty(o,a);return}r[o]=e.style[o],e.style[o]=a}),!n&&mr.set(e,r)}function Zs(e,t){if(!e||!(e instanceof HTMLElement))return;let n=mr.get(e);n&&(e.style[t]=n[t])}const z=e=>{switch(e){case"top":case"bottom":return!0;case"left":case"right":return!1;default:return e}};function pt(e,t){if(!e)return null;const n=window.getComputedStyle(e),r=n.transform||n.webkitTransform||n.mozTransform;let o=r.match(/^matrix3d\((.+)\)$/);return o?parseFloat(o[1].split(", ")[z(t)?13:12]):(o=r.match(/^matrix\((.+)\)$/),o?parseFloat(o[1].split(", ")[z(t)?5:4]):null)}function Js(e){return 8*(Math.log(e+1)-2)}function Wt(e,t){if(!e)return()=>{};const n=e.style.cssText;return Object.assign(e.style,t),()=>{e.style.cssText=n}}function ei(...e){return(...t)=>{for(const n of e)typeof n=="function"&&n(...t)}}const H={DURATION:.5,EASE:[.32,.72,0,1]},pr=.4,ti=.25,ni=100,hr=8,De=16,Yt=26,Ut="vaul-dragging";function vr(e){const t=C.useRef(e);return C.useEffect(()=>{t.current=e}),C.useMemo(()=>(...n)=>t.current==null?void 0:t.current.call(t,...n),[])}function ri({defaultProp:e,onChange:t}){const n=C.useState(e),[r]=n,o=C.useRef(r),a=vr(t);return C.useEffect(()=>{o.current!==r&&(a(r),o.current=r)},[r,o,a]),n}function gr({prop:e,defaultProp:t,onChange:n=()=>{}}){const[r,o]=ri({defaultProp:t,onChange:n}),a=e!==void 0,i=a?e:r,c=vr(n),p=C.useCallback(f=>{if(a){const u=typeof f=="function"?f(e):f;u!==e&&c(u)}else o(f)},[a,e,o,c]);return[i,p]}function oi({activeSnapPointProp:e,setActiveSnapPointProp:t,snapPoints:n,drawerRef:r,overlayRef:o,fadeFromIndex:a,onSnapPointChange:i,direction:c="bottom",container:p,snapToSequentialPoint:f}){const[l,u]=gr({prop:e,defaultProp:n?.[0],onChange:t}),[h,w]=C.useState(typeof window<"u"?{innerWidth:window.innerWidth,innerHeight:window.innerHeight}:void 0);C.useEffect(()=>{function S(){w({innerWidth:window.innerWidth,innerHeight:window.innerHeight})}return window.addEventListener("resize",S),()=>window.removeEventListener("resize",S)},[]);const x=C.useMemo(()=>l===n?.[n.length-1]||null,[n,l]),d=C.useMemo(()=>{var S;return(S=n?.findIndex(O=>O===l))!=null?S:null},[n,l]),E=n&&n.length>0&&(a||a===0)&&!Number.isNaN(a)&&n[a]===l||!n,b=C.useMemo(()=>{const S=p?{width:p.getBoundingClientRect().width,height:p.getBoundingClientRect().height}:typeof window<"u"?{width:window.innerWidth,height:window.innerHeight}:{width:0,height:0};var O;return(O=n?.map(N=>{const F=typeof N=="string";let y=0;if(F&&(y=parseInt(N,10)),z(c)){const R=F?y:h?N*S.height:0;return h?c==="bottom"?S.height-R:-S.height+R:R}const _=F?y:h?N*S.width:0;return h?c==="right"?S.width-_:-S.width+_:_}))!=null?O:[]},[n,h,p]),D=C.useMemo(()=>d!==null?b?.[d]:null,[b,d]),g=C.useCallback(S=>{var O;const N=(O=b?.findIndex(F=>F===S))!=null?O:null;i(N),q(r.current,{transition:`transform ${H.DURATION}s cubic-bezier(${H.EASE.join(",")})`,transform:z(c)?`translate3d(0, ${S}px, 0)`:`translate3d(${S}px, 0, 0)`}),b&&N!==b.length-1&&a!==void 0&&N!==a&&N<a?q(o.current,{transition:`opacity ${H.DURATION}s cubic-bezier(${H.EASE.join(",")})`,opacity:"0"}):q(o.current,{transition:`opacity ${H.DURATION}s cubic-bezier(${H.EASE.join(",")})`,opacity:"1"}),u(n?.[Math.max(N,0)])},[r.current,n,b,a,o,u]);C.useEffect(()=>{if(l||e){var S;const O=(S=n?.findIndex(N=>N===e||N===l))!=null?S:-1;b&&O!==-1&&typeof b[O]=="number"&&g(b[O])}},[l,e,n,b,g]);function v({draggedDistance:S,closeDrawer:O,velocity:N,dismissible:F}){if(a===void 0)return;const y=c==="bottom"||c==="right"?(D??0)-S:(D??0)+S,_=d===a-1,R=d===0,W=S>0;if(_&&q(o.current,{transition:`opacity ${H.DURATION}s cubic-bezier(${H.EASE.join(",")})`}),!f&&N>2&&!W){F?O():g(b[0]);return}if(!f&&N>2&&W&&b&&n){g(b[n.length-1]);return}const U=b?.reduce((V,J)=>typeof V!="number"||typeof J!="number"?V:Math.abs(J-y)<Math.abs(V-y)?J:V),X=z(c)?window.innerHeight:window.innerWidth;if(N>pr&&Math.abs(S)<X*.4){const V=W?1:-1;if(V>0&&x&&n){g(b[n.length-1]);return}if(R&&V<0&&F&&O(),d===null)return;g(b[d+V]);return}g(U)}function T({draggedDistance:S}){if(D===null)return;const O=c==="bottom"||c==="right"?D-S:D+S;(c==="bottom"||c==="right")&&O<b[b.length-1]||(c==="top"||c==="left")&&O>b[b.length-1]||q(r.current,{transform:z(c)?`translate3d(0, ${O}px, 0)`:`translate3d(${O}px, 0, 0)`})}function M(S,O){if(!n||typeof d!="number"||!b||a===void 0)return null;const N=d===a-1;if(d>=a&&O)return 0;if(N&&!O)return 1;if(!E&&!N)return null;const y=N?d+1:d-1,_=N?b[y]-b[y-1]:b[y+1]-b[y],R=S/Math.abs(_);return N?1-R:R}return{isLastSnapPoint:x,activeSnapPoint:l,shouldFade:E,getPercentageDragged:M,setActiveSnapPoint:u,activeSnapPointIndex:d,onRelease:v,onDrag:T,snapPointsOffset:b}}const ai=()=>()=>{};function si(){const{direction:e,isOpen:t,shouldScaleBackground:n,setBackgroundColorOnScale:r,noBodyStyles:o}=et(),a=C.useRef(null),i=s.useMemo(()=>document.body.style.backgroundColor,[]);function c(){return(window.innerWidth-Yt)/window.innerWidth}C.useEffect(()=>{if(t&&n){a.current&&clearTimeout(a.current);const p=document.querySelector("[data-vaul-drawer-wrapper]")||document.querySelector("[vaul-drawer-wrapper]");if(!p)return;ei(r&&!o?Wt(document.body,{background:"black"}):ai,Wt(p,{transformOrigin:z(e)?"top":"left",transitionProperty:"transform, border-radius",transitionDuration:`${H.DURATION}s`,transitionTimingFunction:`cubic-bezier(${H.EASE.join(",")})`}));const f=Wt(p,{borderRadius:`${hr}px`,overflow:"hidden",...z(e)?{transform:`scale(${c()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`}:{transform:`scale(${c()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`}});return()=>{f(),a.current=window.setTimeout(()=>{i?document.body.style.background=i:document.body.style.removeProperty("background")},H.DURATION*1e3)}}},[t,n,i])}let Qe=null;function ii({isOpen:e,modal:t,nested:n,hasBeenOpened:r,preventScrollRestoration:o,noBodyStyles:a}){const[i,c]=C.useState(()=>typeof window<"u"?window.location.href:""),p=C.useRef(0),f=C.useCallback(()=>{if(Dn()&&Qe===null&&e&&!a){Qe={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left,height:document.body.style.height,right:"unset"};const{scrollX:u,innerHeight:h}=window;document.body.style.setProperty("position","fixed","important"),Object.assign(document.body.style,{top:`${-p.current}px`,left:`${-u}px`,right:"0px",height:"auto"}),window.setTimeout(()=>window.requestAnimationFrame(()=>{const w=h-window.innerHeight;w&&p.current>=h&&(document.body.style.top=`${-(p.current+w)}px`)}),300)}},[e]),l=C.useCallback(()=>{if(Dn()&&Qe!==null&&!a){const u=-parseInt(document.body.style.top,10),h=-parseInt(document.body.style.left,10);Object.assign(document.body.style,Qe),window.requestAnimationFrame(()=>{if(o&&i!==window.location.href){c(window.location.href);return}window.scrollTo(h,u)}),Qe=null}},[i]);return C.useEffect(()=>{function u(){p.current=window.scrollY}return u(),window.addEventListener("scroll",u),()=>{window.removeEventListener("scroll",u)}},[]),C.useEffect(()=>{if(t)return()=>{typeof document>"u"||document.querySelector("[data-vaul-drawer]")||l()}},[t,l]),C.useEffect(()=>{n||!r||(e?(!window.matchMedia("(display-mode: standalone)").matches&&f(),t||window.setTimeout(()=>{l()},500)):l())},[e,r,i,t,n,f,l]),{restorePositionSetting:l}}function ci({open:e,onOpenChange:t,children:n,onDrag:r,onRelease:o,snapPoints:a,shouldScaleBackground:i=!1,setBackgroundColorOnScale:c=!0,closeThreshold:p=ti,scrollLockTimeout:f=ni,dismissible:l=!0,handleOnly:u=!1,fadeFromIndex:h=a&&a.length-1,activeSnapPoint:w,setActiveSnapPoint:x,fixed:d,modal:E=!0,onClose:b,nested:D,noBodyStyles:g=!1,direction:v="bottom",defaultOpen:T=!1,disablePreventScroll:M=!0,snapToSequentialPoint:S=!1,preventScrollRestoration:O=!1,repositionInputs:N=!0,onAnimationEnd:F,container:y,autoFocus:_=!1}){var R,W;const[U=!1,X]=gr({defaultProp:T,prop:e,onChange:A=>{t?.(A),!A&&!D&&Rt(),setTimeout(()=>{F?.(A)},H.DURATION*1e3),A&&!E&&typeof window<"u"&&window.requestAnimationFrame(()=>{document.body.style.pointerEvents="auto"}),A||(document.body.style.pointerEvents="auto")}}),[V,J]=C.useState(!1),[oe,me]=C.useState(!1),[He,We]=C.useState(!1),ee=C.useRef(null),Ee=C.useRef(null),Ae=C.useRef(null),Oe=C.useRef(null),Se=C.useRef(null),pe=C.useRef(!1),Ue=C.useRef(null),Ne=C.useRef(0),te=C.useRef(!1),ke=C.useRef(!T),xe=C.useRef(0),k=C.useRef(null),tt=C.useRef(((R=k.current)==null?void 0:R.getBoundingClientRect().height)||0),Ve=C.useRef(((W=k.current)==null?void 0:W.getBoundingClientRect().width)||0),ue=C.useRef(0),ze=C.useCallback(A=>{a&&A===he.length-1&&(Ee.current=new Date)},[]),{activeSnapPoint:Y,activeSnapPointIndex:le,setActiveSnapPoint:nt,onRelease:Pe,snapPointsOffset:he,onDrag:rt,shouldFade:ot,getPercentageDragged:Ct}=oi({snapPoints:a,activeSnapPointProp:w,setActiveSnapPointProp:x,drawerRef:k,fadeFromIndex:h,overlayRef:ee,onSnapPointChange:ze,direction:v,container:y,snapToSequentialPoint:S});Ks({isDisabled:!U||oe||!E||He||!V||!N||!M});const{restorePositionSetting:Rt}=ii({isOpen:U,modal:E,nested:D??!1,hasBeenOpened:V,preventScrollRestoration:O,noBodyStyles:g});function de(){return(window.innerWidth-Yt)/window.innerWidth}function at(A){var L,j;!l&&!a||k.current&&!k.current.contains(A.target)||(tt.current=((L=k.current)==null?void 0:L.getBoundingClientRect().height)||0,Ve.current=((j=k.current)==null?void 0:j.getBoundingClientRect().width)||0,me(!0),Ae.current=new Date,lr()&&window.addEventListener("touchend",()=>pe.current=!1,{once:!0}),A.target.setPointerCapture(A.pointerId),Ne.current=z(v)?A.pageY:A.pageX)}function qe(A,L){var j;let I=A;const B=(j=window.getSelection())==null?void 0:j.toString(),K=k.current?pt(k.current,v):null,G=new Date;if(I.tagName==="SELECT"||I.hasAttribute("data-vaul-no-drag")||I.closest("[data-vaul-no-drag]"))return!1;if(v==="right"||v==="left")return!0;if(Ee.current&&G.getTime()-Ee.current.getTime()<500)return!1;if(K!==null&&(v==="bottom"?K>0:K<0))return!0;if(B&&B.length>0)return!1;if(Se.current&&G.getTime()-Se.current.getTime()<f&&K===0||L)return Se.current=G,!1;for(;I;){if(I.scrollHeight>I.clientHeight){if(I.scrollTop!==0)return Se.current=new Date,!1;if(I.getAttribute("role")==="dialog")return!0}I=I.parentNode}return!0}function Ce(A){if(k.current&&oe){const L=v==="bottom"||v==="right"?1:-1,j=(Ne.current-(z(v)?A.pageY:A.pageX))*L,I=j>0,B=a&&!l&&!I;if(B&&le===0)return;const K=Math.abs(j),G=document.querySelector("[data-vaul-drawer-wrapper]"),ae=v==="bottom"||v==="top"?tt.current:Ve.current;let Z=K/ae;const se=Ct(K,I);if(se!==null&&(Z=se),B&&Z>=1||!pe.current&&!qe(A.target,I))return;if(k.current.classList.add(Ut),pe.current=!0,q(k.current,{transition:"none"}),q(ee.current,{transition:"none"}),a&&rt({draggedDistance:j}),I&&!a){const ne=Js(j),P=Math.min(ne*-1,0)*L;q(k.current,{transform:z(v)?`translate3d(0, ${P}px, 0)`:`translate3d(${P}px, 0, 0)`});return}const ie=1-Z;if((ot||h&&le===h-1)&&(r?.(A,Z),q(ee.current,{opacity:`${ie}`,transition:"none"},!0)),G&&ee.current&&i){const ne=Math.min(de()+Z*(1-de()),1),P=8-Z*8,$=Math.max(0,14-Z*14);q(G,{borderRadius:`${P}px`,transform:z(v)?`scale(${ne}) translate3d(0, ${$}px, 0)`:`scale(${ne}) translate3d(${$}px, 0, 0)`,transition:"none"},!0)}if(!a){const ne=K*L;q(k.current,{transform:z(v)?`translate3d(0, ${ne}px, 0)`:`translate3d(${ne}px, 0, 0)`})}}}C.useEffect(()=>{window.requestAnimationFrame(()=>{ke.current=!0})},[]),C.useEffect(()=>{var A;function L(){if(!k.current||!N)return;const j=document.activeElement;if(Kt(j)||te.current){var I;const B=((I=window.visualViewport)==null?void 0:I.height)||0,K=window.innerHeight;let G=K-B;const ae=k.current.getBoundingClientRect().height||0,Z=ae>K*.8;ue.current||(ue.current=ae);const se=k.current.getBoundingClientRect().top;if(Math.abs(xe.current-G)>60&&(te.current=!te.current),a&&a.length>0&&he&&le){const ie=he[le]||0;G+=ie}if(xe.current=G,ae>B||te.current){const ie=k.current.getBoundingClientRect().height;let ne=ie;ie>B&&(ne=B-(Z?se:Yt)),d?k.current.style.height=`${ie-Math.max(G,0)}px`:k.current.style.height=`${Math.max(ne,B-se)}px`}else Bs()||(k.current.style.height=`${ue.current}px`);a&&a.length>0&&!te.current?k.current.style.bottom="0px":k.current.style.bottom=`${Math.max(G,0)}px`}}return(A=window.visualViewport)==null||A.addEventListener("resize",L),()=>{var j;return(j=window.visualViewport)==null?void 0:j.removeEventListener("resize",L)}},[le,a,he]);function ve(A){Dt(),b?.(),A||X(!1),setTimeout(()=>{a&&nt(a[0])},H.DURATION*1e3)}function Ke(){if(!k.current)return;const A=document.querySelector("[data-vaul-drawer-wrapper]"),L=pt(k.current,v);q(k.current,{transform:"translate3d(0, 0, 0)",transition:`transform ${H.DURATION}s cubic-bezier(${H.EASE.join(",")})`}),q(ee.current,{transition:`opacity ${H.DURATION}s cubic-bezier(${H.EASE.join(",")})`,opacity:"1"}),i&&L&&L>0&&U&&q(A,{borderRadius:`${hr}px`,overflow:"hidden",...z(v)?{transform:`scale(${de()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,transformOrigin:"top"}:{transform:`scale(${de()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`,transformOrigin:"left"},transitionProperty:"transform, border-radius",transitionDuration:`${H.DURATION}s`,transitionTimingFunction:`cubic-bezier(${H.EASE.join(",")})`},!0)}function Dt(){!oe||!k.current||(k.current.classList.remove(Ut),pe.current=!1,me(!1),Oe.current=new Date)}function Re(A){if(!oe||!k.current)return;k.current.classList.remove(Ut),pe.current=!1,me(!1),Oe.current=new Date;const L=pt(k.current,v);if(!A||!qe(A.target,!1)||!L||Number.isNaN(L)||Ae.current===null)return;const j=Oe.current.getTime()-Ae.current.getTime(),I=Ne.current-(z(v)?A.pageY:A.pageX),B=Math.abs(I)/j;if(B>.05&&(We(!0),setTimeout(()=>{We(!1)},200)),a){Pe({draggedDistance:I*(v==="bottom"||v==="right"?1:-1),closeDrawer:ve,velocity:B,dismissible:l}),o?.(A,!0);return}if(v==="bottom"||v==="right"?I>0:I<0){Ke(),o?.(A,!0);return}if(B>pr){ve(),o?.(A,!1);return}var K;const G=Math.min((K=k.current.getBoundingClientRect().height)!=null?K:0,window.innerHeight);var ae;const Z=Math.min((ae=k.current.getBoundingClientRect().width)!=null?ae:0,window.innerWidth),se=v==="left"||v==="right";if(Math.abs(L)>=(se?Z:G)*p){ve(),o?.(A,!1);return}o?.(A,!0),Ke()}C.useEffect(()=>(U&&(q(document.documentElement,{scrollBehavior:"auto"}),Ee.current=new Date),()=>{Zs(document.documentElement,"scrollBehavior")}),[U]);function Ye(A){const L=A?(window.innerWidth-De)/window.innerWidth:1,j=A?-De:0;Ue.current&&window.clearTimeout(Ue.current),q(k.current,{transition:`transform ${H.DURATION}s cubic-bezier(${H.EASE.join(",")})`,transform:z(v)?`scale(${L}) translate3d(0, ${j}px, 0)`:`scale(${L}) translate3d(${j}px, 0, 0)`}),!A&&k.current&&(Ue.current=setTimeout(()=>{const I=pt(k.current,v);q(k.current,{transition:"none",transform:z(v)?`translate3d(0, ${I}px, 0)`:`translate3d(${I}px, 0, 0)`})},500))}function Ie(A,L){if(L<0)return;const j=(window.innerWidth-De)/window.innerWidth,I=j+L*(1-j),B=-De+L*De;q(k.current,{transform:z(v)?`scale(${I}) translate3d(0, ${B}px, 0)`:`scale(${I}) translate3d(${B}px, 0, 0)`,transition:"none"})}function Tt(A,L){const j=z(v)?window.innerHeight:window.innerWidth,I=L?(j-De)/j:1,B=L?-De:0;L&&q(k.current,{transition:`transform ${H.DURATION}s cubic-bezier(${H.EASE.join(",")})`,transform:z(v)?`scale(${I}) translate3d(0, ${B}px, 0)`:`scale(${I}) translate3d(${B}px, 0, 0)`})}return C.useEffect(()=>{E||window.requestAnimationFrame(()=>{document.body.style.pointerEvents="auto"})},[E]),C.createElement(Zn,{defaultOpen:T,onOpenChange:A=>{!l&&!A||(A?J(!0):ve(!0),X(A))},open:U},C.createElement(ur.Provider,{value:{activeSnapPoint:Y,snapPoints:a,setActiveSnapPoint:nt,drawerRef:k,overlayRef:ee,onOpenChange:t,onPress:at,onRelease:Re,onDrag:Ce,dismissible:l,shouldAnimate:ke,handleOnly:u,isOpen:U,isDragging:oe,shouldFade:ot,closeDrawer:ve,onNestedDrag:Ie,onNestedOpenChange:Ye,onNestedRelease:Tt,keyboardIsOpen:te,modal:E,snapPointsOffset:he,activeSnapPointIndex:le,direction:v,shouldScaleBackground:i,setBackgroundColorOnScale:c,noBodyStyles:g,container:y,autoFocus:_}},n))}const wr=C.forwardRef(function({...e},t){const{overlayRef:n,snapPoints:r,onRelease:o,shouldFade:a,isOpen:i,modal:c,shouldAnimate:p}=et(),f=fr(t,n),l=r&&r.length>0;if(!c)return null;const u=C.useCallback(h=>o(h),[o]);return C.createElement(nr,{onMouseUp:u,ref:f,"data-vaul-overlay":"","data-vaul-snap-points":i&&l?"true":"false","data-vaul-snap-points-overlay":i&&a?"true":"false","data-vaul-animate":p?.current?"true":"false",...e})});wr.displayName="Drawer.Overlay";const yr=C.forwardRef(function({onPointerDownOutside:e,style:t,onOpenAutoFocus:n,...r},o){const{drawerRef:a,onPress:i,onRelease:c,onDrag:p,keyboardIsOpen:f,snapPointsOffset:l,activeSnapPointIndex:u,modal:h,isOpen:w,direction:x,snapPoints:d,container:E,handleOnly:b,shouldAnimate:D,autoFocus:g}=et(),[v,T]=C.useState(!1),M=fr(o,a),S=C.useRef(null),O=C.useRef(null),N=C.useRef(!1),F=d&&d.length>0;si();const y=(R,W,U=0)=>{if(N.current)return!0;const X=Math.abs(R.y),V=Math.abs(R.x),J=V>X,oe=["bottom","right"].includes(W)?1:-1;if(W==="left"||W==="right"){if(!(R.x*oe<0)&&V>=0&&V<=U)return J}else if(!(R.y*oe<0)&&X>=0&&X<=U)return!J;return N.current=!0,!0};C.useEffect(()=>{F&&window.requestAnimationFrame(()=>{T(!0)})},[]);function _(R){S.current=null,N.current=!1,c(R)}return C.createElement(rr,{"data-vaul-drawer-direction":x,"data-vaul-drawer":"","data-vaul-delayed-snap-points":v?"true":"false","data-vaul-snap-points":w&&F?"true":"false","data-vaul-custom-container":E?"true":"false","data-vaul-animate":D?.current?"true":"false",...r,ref:M,style:l&&l.length>0?{"--snap-point-height":`${l[u??0]}px`,...t}:t,onPointerDown:R=>{b||(r.onPointerDown==null||r.onPointerDown.call(r,R),S.current={x:R.pageX,y:R.pageY},i(R))},onOpenAutoFocus:R=>{n?.(R),g||R.preventDefault()},onPointerDownOutside:R=>{if(e?.(R),!h||R.defaultPrevented){R.preventDefault();return}f.current&&(f.current=!1)},onFocusOutside:R=>{if(!h){R.preventDefault();return}},onPointerMove:R=>{if(O.current=R,b||(r.onPointerMove==null||r.onPointerMove.call(r,R),!S.current))return;const W=R.pageY-S.current.y,U=R.pageX-S.current.x,X=R.pointerType==="touch"?10:2;y({x:U,y:W},x,X)?p(R):(Math.abs(U)>X||Math.abs(W)>X)&&(S.current=null)},onPointerUp:R=>{r.onPointerUp==null||r.onPointerUp.call(r,R),S.current=null,N.current=!1,c(R)},onPointerOut:R=>{r.onPointerOut==null||r.onPointerOut.call(r,R),_(O.current)},onContextMenu:R=>{r.onContextMenu==null||r.onContextMenu.call(r,R),O.current&&_(O.current)}})});yr.displayName="Drawer.Content";const ui=250,li=120,br=C.forwardRef(function({preventCycle:e=!1,children:t,...n},r){const{closeDrawer:o,isDragging:a,snapPoints:i,activeSnapPoint:c,setActiveSnapPoint:p,dismissible:f,handleOnly:l,isOpen:u,onPress:h,onDrag:w}=et(),x=C.useRef(null),d=C.useRef(!1);function E(){if(d.current){g();return}window.setTimeout(()=>{b()},li)}function b(){if(a||e||d.current){g();return}if(g(),!i||i.length===0){f||o();return}if(c===i[i.length-1]&&f){o();return}const T=i.findIndex(S=>S===c);if(T===-1)return;const M=i[T+1];p(M)}function D(){x.current=window.setTimeout(()=>{d.current=!0},ui)}function g(){x.current&&window.clearTimeout(x.current),d.current=!1}return C.createElement("div",{onClick:E,onPointerCancel:g,onPointerDown:v=>{l&&h(v),D()},onPointerMove:v=>{l&&w(v)},ref:r,"data-vaul-drawer-visible":u?"true":"false","data-vaul-handle":"","aria-hidden":"true",...n},C.createElement("span",{"data-vaul-handle-hitarea":"","aria-hidden":"true"},t))});br.displayName="Drawer.Handle";function di(e){const t=et(),{container:n=t.container,...r}=e;return C.createElement(tr,{container:n,...r})}const Ci={Root:ci,Content:yr,Overlay:wr,Portal:di,Handle:br,Title:sr};export{xi as C,Ci as D,Si as a,yi as b,bi as c,wi as s,Ei as u};
@@ -0,0 +1 @@
1
+ import{j as o}from"./index-CrStk0va.js";import{O as t}from"./OutboxPane-BWql0oaX.js";import"./useSearchTokenContext-BFF5PFp_.js";import"./kbd-CIM88W-i.js";import"./useMessageBodyContent-D2ppLfqI.js";import"./search-scope-DTcpOp3S.js";import"./circle-check-big-CTk0kr4F.js";import"./clock-sbv7ILkY.js";import"./row-actions-YLjTr0Pe.js";import"./rotate-ccw-BdyunlX_.js";import"./NavMenuButton-C6jexGVY.js";import"./menu-CVMIxRRy.js";import"./format-23Av07Go.js";import"./outbox-status-BlKn6P0x.js";import"./search-query-Cr_ZXBCp.js";function c(){return o.jsx(t.Reading,{})}export{c as component};