@remit/web-client-dist 0.0.457 → 0.0.458

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/assets/{BriefPane-DkIisyhD.js → BriefPane-DyTCfE7R.js} +1 -1
  2. package/assets/{ErrorState-CDN8OkAT.js → ErrorState-DxtMMIPM.js} +1 -1
  3. package/assets/{FlaggedPane-yUCuVDrF.js → FlaggedPane-DRj5zl39.js} +1 -1
  4. package/assets/{FullCompose-DzuCOaYk.js → FullCompose-BoG12Gnw.js} +1 -1
  5. package/assets/{MailListHeader-C4lftUEo.js → MailListHeader-BvUp2YAz.js} +1 -1
  6. package/assets/{MailShell-EBHUhgkn.js → MailShell-DdiQTKjw.js} +1 -1
  7. package/assets/{MailViewChrome-DDfMPO16.js → MailViewChrome-CV4Xw32m.js} +1 -1
  8. package/assets/{MailboxPane-CXDOqiF_.js → MailboxPane-DPXlleMN.js} +1 -1
  9. package/assets/{NavMenuButton-Dfz7rRBq.js → NavMenuButton-DCzDPYUK.js} +1 -1
  10. package/assets/OnboardingWizard-CcfEszMQ.js +1 -0
  11. package/assets/{OutboxPane-CgELyxEH.js → OutboxPane-Drq27E5R.js} +1 -1
  12. package/assets/_mailboxId-Cdqn4AND.js +1 -0
  13. package/assets/_messageId-DszEly0K.js +1 -0
  14. package/assets/_messageId-TfLVIOYC.js +1 -0
  15. package/assets/_messageId-USJgxF9U.js +1 -0
  16. package/assets/_outboxMessageId-Dlr-4V_S.js +1 -0
  17. package/assets/_threadId-B9MvrtrB.js +1 -0
  18. package/assets/_threadId-CsCEc_U2.js +1 -0
  19. package/assets/_threadId-a49iEnU3.js +1 -0
  20. package/assets/accounts-_l96d4U-.js +1 -0
  21. package/assets/{advanced-DwkXqrI5.js → advanced-BX8urixV.js} +1 -1
  22. package/assets/{appearance-E9IryAAJ.js → appearance-BvCx3QuQ.js} +1 -1
  23. package/assets/{attachment-file-D-Cvcyx2.js → attachment-file-7SlOQtaK.js} +1 -1
  24. package/assets/{avatar-CQ3ej2nF.js → avatar-Dx2nnu8-.js} +1 -1
  25. package/assets/{bottom-sheet-CJAkwg1D.js → bottom-sheet-B9BJ1XTT.js} +1 -1
  26. package/assets/{brief-DDiYVjb-.js → brief-Dq--qnCH.js} +1 -1
  27. package/assets/brief-wYPCy3Pg.js +1 -0
  28. package/assets/{browser-ponyfill-BOzOW77a.js → browser-ponyfill-gO2wURX_.js} +1 -1
  29. package/assets/{bug-C69OozF0.js → bug-ui4WBEYY.js} +1 -1
  30. package/assets/{circle-check-BlV3yF1E.js → circle-check-4_VJQKru.js} +1 -1
  31. package/assets/{circle-check-big-DostR7Uj.js → circle-check-big-CcZaO_x-.js} +1 -1
  32. package/assets/{circle-help-BrBilteI.js → circle-help-Bl00srtt.js} +1 -1
  33. package/assets/{clock-gfYrT9HU.js → clock-BqYKa4LY.js} +1 -1
  34. package/assets/compose._-_outboxMessageId_-C-dTZD8u.js +1 -0
  35. package/assets/compose._-_outboxMessageId_-CV38fxsg.js +1 -0
  36. package/assets/compose._-_outboxMessageId_-Cy8UzE5w.js +1 -0
  37. package/assets/compose._-_outboxMessageId_-D0tv7HGf.js +1 -0
  38. package/assets/{confirm-dialog-DLbVncLb.js → confirm-dialog-DwQkoRYj.js} +1 -1
  39. package/assets/{download-Cb45kClh.js → download-DBrnYKAw.js} +1 -1
  40. package/assets/{filters-Czngcrqa.js → filters-CZoJP1ag.js} +1 -1
  41. package/assets/flagged-DNpuylMn.js +1 -0
  42. package/assets/{flagged-D56IqmEm.js → flagged-GRqBmRm0.js} +1 -1
  43. package/assets/{folders-CMV1kSVY.js → folders-DHjhBJ3L.js} +1 -1
  44. package/assets/{format-HW3C18y-.js → format-B3uyVYnZ.js} +1 -1
  45. package/assets/{help-copy-DEsN5V8b.js → help-copy-Fs4K997z.js} +1 -1
  46. package/assets/index-BHc_DUCd.js +1 -0
  47. package/assets/{index-CFkAgUJA.js → index-C5WTfF4A.js} +4 -4
  48. package/assets/index-C7-jN1da.js +1 -0
  49. package/assets/{index-Bmk2EDh1.js → index-C8DX_EQn.js} +3 -3
  50. package/assets/index-C9gjWfix.js +1 -0
  51. package/assets/index-CItZ2D0w.js +1 -0
  52. package/assets/index-DszEly0K.js +1 -0
  53. package/assets/index-J_OrADLr.js +1 -0
  54. package/assets/index-USJgxF9U.js +1 -0
  55. package/assets/index-fEXcHum5.js +1 -0
  56. package/assets/{kbd-bB3ZAr68.js → kbd-B62acStO.js} +1 -1
  57. package/assets/{labels-uxywzvaP.js → labels-6fZH_eHi.js} +1 -1
  58. package/assets/{mail-Dvas2UDV.js → mail-7swSEn2S.js} +1 -1
  59. package/assets/{mail-D86HvrYR.js → mail-BNCTp4RF.js} +1 -1
  60. package/assets/{menu-CHgXvbDR.js → menu-DGvf1N4B.js} +1 -1
  61. package/assets/{onboarding-BbPYOg2c.js → onboarding-no6XeVz4.js} +1 -1
  62. package/assets/outbox-FKUIA1q2.js +1 -0
  63. package/assets/{pencil-YqDJ1UNw.js → pencil-DrCSwjWE.js} +1 -1
  64. package/assets/{rich-text-D1HtzDNr.js → rich-text-Bsxr2TS3.js} +1 -1
  65. package/assets/{rich-text-spellcheck-worker-provider-Cni3UkLD.js → rich-text-spellcheck-worker-provider-CN7fG4n3.js} +1 -1
  66. package/assets/{rotate-ccw-Bxy1oybp.js → rotate-ccw-CrFWWh3G.js} +1 -1
  67. package/assets/{row-actions-mYLXim9h.js → row-actions-CO2bb9oK.js} +1 -1
  68. package/assets/{search-mirror-z_kwOSxA.js → search-mirror-8yIdpqZ4.js} +1 -1
  69. package/assets/{search-token-index-D2aIcKlQ.js → search-token-index-BpY-q8ZV.js} +1 -1
  70. package/assets/{senders-CSsFf2Q-.js → senders-B11PA4bD.js} +1 -1
  71. package/assets/settings-DYMDRfIw.js +1 -0
  72. package/assets/{settings-screen-5dMLPXnl.js → settings-screen-K5psovZm.js} +1 -1
  73. package/assets/{shield-check-7qB60EQS.js → shield-check-CK0lIMjR.js} +1 -1
  74. package/assets/{suggested-vips-DudJtbhk.js → suggested-vips-C2C2XZwO.js} +1 -1
  75. package/assets/{useDebouncedValue-zfkxbezK.js → useDebouncedValue-CxejlkZq.js} +1 -1
  76. package/assets/{useFilters-D9VfT5eI.js → useFilters-ClTpCTul.js} +1 -1
  77. package/assets/{useLabels-epnfWwuH.js → useLabels-Jy2JcPrZ.js} +1 -1
  78. package/assets/{useMessageBodyContent-CG3Q2Vwi.js → useMessageBodyContent-yDESgRfR.js} +1 -1
  79. package/assets/{useRefreshControl-BCWsGgbC.js → useRefreshControl-DQLj8qF7.js} +1 -1
  80. package/assets/{useSearchTokenContext-Dmt9kbMV.js → useSearchTokenContext-CrFL5qdR.js} +1 -1
  81. package/assets/{useSemanticSearch-DIrzI_5M.js → useSemanticSearch-RVZNROuq.js} +1 -1
  82. package/assets/{useSignature-CszyYw-c.js → useSignature-D7z3ao3j.js} +1 -1
  83. package/index.html +1 -1
  84. package/package.json +1 -1
  85. package/assets/OnboardingWizard-DVTmeiRu.js +0 -1
  86. package/assets/_mailboxId-BvUpoNJA.js +0 -1
  87. package/assets/_messageId-BrWi7o0d.js +0 -1
  88. package/assets/_messageId-Cre03qv2.js +0 -1
  89. package/assets/_messageId-SNK7cNKb.js +0 -1
  90. package/assets/_outboxMessageId-DXRd29ZS.js +0 -1
  91. package/assets/_threadId-BSYf5xRS.js +0 -1
  92. package/assets/_threadId-BnYfx0Rb.js +0 -1
  93. package/assets/_threadId-XkXdGgV_.js +0 -1
  94. package/assets/accounts-CMzsfN0X.js +0 -1
  95. package/assets/brief-DKqUqMK_.js +0 -1
  96. package/assets/compose._-_outboxMessageId_-7r0vhP8s.js +0 -1
  97. package/assets/compose._-_outboxMessageId_-BsNUf1hO.js +0 -1
  98. package/assets/compose._-_outboxMessageId_-CHny8x-H.js +0 -1
  99. package/assets/compose._-_outboxMessageId_-DMLC7GLn.js +0 -1
  100. package/assets/flagged-UFppCitR.js +0 -1
  101. package/assets/index-2pciiULo.js +0 -1
  102. package/assets/index-BOJxa1a7.js +0 -1
  103. package/assets/index-BrWi7o0d.js +0 -1
  104. package/assets/index-CazB_sn0.js +0 -1
  105. package/assets/index-CbgNWLCh.js +0 -1
  106. package/assets/index-Cw-QVcPZ.js +0 -1
  107. package/assets/index-Iq8mQpYa.js +0 -1
  108. package/assets/index-SNK7cNKb.js +0 -1
  109. package/assets/outbox-MyveMEco.js +0 -1
  110. package/assets/settings-DrRcfeGm.js +0 -1
@@ -1 +0,0 @@
1
- import{c as re,j as e,b as z,ao as V,as as oe,r as i,aF as he,aI as I,ap as R,x as xe,aj as X,a5 as fe,an as ye,D as Q,aJ as Y,a1 as ne,B as N,ar as $,am as ge,aq as ve,aE as q,aB as be,I as we}from"./index-CFkAgUJA.js";import{K as je}from"./kbd-bB3ZAr68.js";import{c as Se}from"./account-form-helpers-DhckT_PN.js";import{M as ke}from"./mail-Dvas2UDV.js";const K=re("AtSign",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]]);const Ce=re("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);function Ne({url:t}){return e.jsxs("p",{className:"text-2xs text-fg-subtle",children:["Stored encrypted, used only to connect to your mail server."," ",t?e.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"How to create an app password"}):e.jsx("span",{children:"Check your provider's help for app password instructions."})]})}function Ee({raised:t,className:o,...s}){return e.jsx("div",{className:z("rounded-sm border border-line bg-surface",t?"bg-surface-raised shadow-sm":"",o),...s})}function J({value:t,defaultValue:o,onValueChange:s,...a}){return s?e.jsxs(V,{value:t,onChange:n=>s(n.target.value),...a,children:[e.jsx("option",{value:"tls",children:"TLS/SSL"}),e.jsx("option",{value:"starttls",children:"STARTTLS"}),e.jsx("option",{value:"none",children:"None (insecure)"})]}):e.jsxs(V,{defaultValue:o??t,...a,children:[e.jsx("option",{value:"tls",children:"TLS/SSL"}),e.jsx("option",{value:"starttls",children:"STARTTLS"}),e.jsx("option",{value:"none",children:"None (insecure)"})]})}function G(t){return{tls:t==="tls",startTls:t==="starttls"}}function Te({steps:t,activeStep:o}){return e.jsx("ol",{className:"flex items-center gap-1",children:t.map((s,a)=>{const n=a<o,r=a===o;return e.jsxs("li",{className:"flex items-center gap-1",children:[a>0&&e.jsx("span",{className:"h-px w-5 bg-line","aria-hidden":!0}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:z("flex size-5 items-center justify-center rounded-full text-2xs font-semibold tabular-nums",n&&"bg-accent text-accent-fg",r&&"bg-accent-soft text-accent ring-1 ring-accent",!n&&!r&&"bg-surface-sunken text-fg-subtle"),children:n?e.jsx(oe,{className:"size-3"}):a+1}),e.jsx("span",{className:z("hidden text-2xs sm:inline",r?"font-medium text-fg":"text-fg-subtle"),children:s})]})]},s)})})}function A({steps:t,activeStep:o,title:s,subtitle:a,children:n,footer:r,hideSteps:m}){return e.jsxs("div",{className:"flex min-h-dvh w-full flex-col items-center overflow-y-auto bg-canvas pb-[max(2rem,env(safe-area-inset-bottom,0px))] pl-[max(2rem,env(safe-area-inset-left,0px))] pr-[max(2rem,env(safe-area-inset-right,0px))] pt-[max(2rem,env(safe-area-inset-top,0px))] font-sans text-fg sm:pt-[30vh]",children:[!m&&e.jsx("div",{className:"mb-5 w-full max-w-xl",children:e.jsx(Te,{steps:t,activeStep:o})}),e.jsxs(Ee,{raised:!0,className:"w-full max-w-xl",children:[e.jsxs("div",{className:"px-5 pt-5",children:[e.jsx("h1",{className:"text-xl font-semibold text-fg",children:s}),a&&e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:a})]}),e.jsx("div",{className:"px-5 py-5",children:n}),r&&e.jsx("div",{className:"flex items-center justify-between gap-3 border-t border-line px-5 py-3",children:r})]})]})}const Pe="Coming soon — use IMAP for now.";function W({name:t,description:o,icon:s,comingSoon:a,selected:n,onSelect:r}){const[m,p]=i.useState(!1),c=()=>{if(r){r();return}a&&p(!0)};return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("button",{type:"button",onClick:c,"aria-disabled":a||void 0,className:z("flex flex-col items-start gap-2 rounded-sm border p-3 text-left transition-colors",n?"border-accent-2 bg-accent-2-soft":"border-line bg-surface hover:border-line-strong",a&&"opacity-55"),children:[e.jsx("span",{className:z("text-fg-muted",n&&"text-accent-2"),children:s}),e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold text-fg",children:t}),a&&e.jsx("span",{className:"rounded-full bg-surface-sunken px-1.5 py-0.5 text-2xs text-fg-subtle",children:"soon"})]}),e.jsx("span",{className:"text-xs text-fg-subtle",children:o})]}),m&&e.jsx("p",{className:"text-2xs text-fg-subtle",children:Pe})]})}function Z({legend:t,badge:o,host:s,port:a,security:n,readOnly:r,onHostChange:m,onPortChange:p,onSecurityChange:c,hostPlaceholder:v,portPlaceholder:b}){const w=i.useId(),y=i.useId(),j=i.useId();return e.jsxs("fieldset",{children:[e.jsxs("legend",{className:"flex items-center gap-2 text-sm font-semibold text-fg",children:[t,o&&e.jsx(he,{tone:o.tone,children:o.label})]}),e.jsxs("div",{className:"mt-2 grid grid-cols-1 gap-3 sm:grid-cols-[1fr_6rem_8rem] sm:gap-2",children:[e.jsxs("div",{children:[e.jsx(I,{htmlFor:w,children:"Host"}),m?e.jsx(R,{id:w,readOnly:r,value:s,onChange:f=>m(f.target.value),placeholder:v}):e.jsx(R,{id:w,readOnly:r,defaultValue:s,placeholder:v})]}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:y,children:"Port"}),p?e.jsx(R,{id:y,readOnly:r,value:a,onChange:f=>p(f.target.value),placeholder:b}):e.jsx(R,{id:y,readOnly:r,defaultValue:a,placeholder:b})]}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:j,children:"Security"}),c?e.jsx(J,{id:j,value:n,onValueChange:c}):e.jsx(J,{id:j,defaultValue:n})]})]})]})}function H({label:t,detail:o,state:s}){return e.jsxs("div",{className:"flex items-start gap-3 py-2",children:[e.jsxs("span",{className:z("mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full text-2xs",s==="ok"&&"bg-positive text-accent-fg",s==="failed"&&"bg-danger text-accent-fg",s==="running"&&"border border-accent text-accent",s==="pending"&&"border border-line text-fg-subtle"),children:[s==="ok"&&e.jsx(oe,{className:"size-3"}),s==="failed"&&"!",s==="running"&&e.jsx("span",{className:"size-2 animate-pulse rounded-full bg-accent"})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:z("text-sm",s==="failed"?"font-medium text-danger":"text-fg"),children:t}),o&&e.jsx("div",{className:"mt-0.5 text-xs text-fg-subtle",children:o})]})]})}const Le=(t,o)=>{const s=i.useRef(o);s.current=o,i.useEffect(()=>{if(!t)return;const a=()=>{document.visibilityState==="visible"&&s.current()};return document.addEventListener("visibilitychange",a),window.addEventListener("pageshow",a),()=>{document.removeEventListener("visibilitychange",a),window.removeEventListener("pageshow",a)}},[t])},Ie=t=>{const o=i.useRef(!1),s=i.useRef(!1),a=i.useRef(t);a.current=t;const n=i.useCallback(()=>{!o.current||!s.current||(s.current=!1,a.current())},[]);return i.useEffect(()=>{const r=()=>{s.current=!0},m=()=>{document.visibilityState==="hidden"&&r()},p=c=>{c.persisted&&(r(),n())};return document.addEventListener("visibilitychange",m),window.addEventListener("pagehide",r),window.addEventListener("pageshow",p),()=>{document.removeEventListener("visibilitychange",m),window.removeEventListener("pagehide",r),window.removeEventListener("pageshow",p)}},[n]),Le(!0,n),i.useCallback(()=>{o.current=!0,s.current=!1},[])},Ae={"gmail.com":{imap:{host:"imap.gmail.com",port:993,security:"tls"},smtp:{host:"smtp.gmail.com",port:587,security:"starttls"},source:"provider-table"},"googlemail.com":{imap:{host:"imap.gmail.com",port:993,security:"tls"},smtp:{host:"smtp.gmail.com",port:587,security:"starttls"},source:"provider-table"},"outlook.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"hotmail.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"live.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"msn.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"icloud.com":{imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},source:"provider-table"},"me.com":{imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},source:"provider-table"},"mac.com":{imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},source:"provider-table"},"fastmail.com":{imap:{host:"imap.fastmail.com",port:993,security:"tls"},smtp:{host:"smtp.fastmail.com",port:465,security:"tls"},source:"provider-table"},"fastmail.fm":{imap:{host:"imap.fastmail.com",port:993,security:"tls"},smtp:{host:"smtp.fastmail.com",port:465,security:"tls"},source:"provider-table"},"yahoo.com":{imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},source:"provider-table"},"yahoo.co.uk":{imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},source:"provider-table"},"ymail.com":{imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},source:"provider-table"},"aol.com":{imap:{host:"imap.aol.com",port:993,security:"tls"},smtp:{host:"smtp.aol.com",port:465,security:"tls"},source:"provider-table"},"zoho.com":{imap:{host:"imap.zoho.com",port:993,security:"tls"},smtp:{host:"smtp.zoho.com",port:465,security:"tls"},source:"provider-table"},"gmx.com":{imap:{host:"imap.gmx.com",port:993,security:"tls"},smtp:{host:"smtp.gmx.com",port:587,security:"starttls"},source:"provider-table"},"gmx.net":{imap:{host:"imap.gmx.net",port:993,security:"tls"},smtp:{host:"mail.gmx.net",port:587,security:"starttls"},source:"provider-table"},"gmx.de":{imap:{host:"imap.gmx.net",port:993,security:"tls"},smtp:{host:"mail.gmx.net",port:587,security:"starttls"},source:"provider-table"},"web.de":{imap:{host:"imap.web.de",port:993,security:"tls"},smtp:{host:"smtp.web.de",port:587,security:"starttls"},source:"provider-table"},"mail.com":{imap:{host:"imap.mail.com",port:993,security:"tls"},smtp:{host:"smtp.mail.com",port:465,security:"tls"},source:"provider-table"},"hey.com":{imap:{host:"imap.hey.com",port:993,security:"tls"},smtp:{host:"smtp.hey.com",port:465,security:"tls"},source:"provider-table"},"tutanota.com":{imap:{host:"mail.tutanota.com",port:993,security:"tls"},smtp:{host:"mail.tutanota.com",port:465,security:"tls"},source:"provider-table"},"tuta.io":{imap:{host:"mail.tutanota.com",port:993,security:"tls"},smtp:{host:"mail.tutanota.com",port:465,security:"tls"},source:"provider-table"},"posteo.de":{imap:{host:"posteo.de",port:993,security:"tls"},smtp:{host:"posteo.de",port:465,security:"tls"},source:"provider-table"},"runbox.com":{imap:{host:"imap.runbox.com",port:993,security:"tls"},smtp:{host:"smtp.runbox.com",port:587,security:"starttls"},source:"provider-table"},"mailbox.org":{imap:{host:"imap.mailbox.org",port:993,security:"tls"},smtp:{host:"smtp.mailbox.org",port:465,security:"tls"},source:"provider-table"},"hushmail.com":{imap:{host:"imap.hushmail.com",port:993,security:"tls"},smtp:{host:"smtp.hushmail.com",port:465,security:"tls"},source:"provider-table"}},Me={"gmail.com":"https://support.google.com/accounts/answer/185833","googlemail.com":"https://support.google.com/accounts/answer/185833","yahoo.com":"https://help.yahoo.com/kb/generate-manage-third-party-passwords-sln15241.html","icloud.com":"https://support.apple.com/en-us/102654","me.com":"https://support.apple.com/en-us/102654","mac.com":"https://support.apple.com/en-us/102654","fastmail.com":"https://www.fastmail.help/hc/en-us/articles/360058752854","fastmail.fm":"https://www.fastmail.help/hc/en-us/articles/360058752854","outlook.com":"https://support.microsoft.com/en-us/account-billing/manage-app-passwords-for-two-step-verification-d6dc8c6d-4bf7-4851-ad95-6d07799387e9","hotmail.com":"https://support.microsoft.com/en-us/account-billing/manage-app-passwords-for-two-step-verification-d6dc8c6d-4bf7-4851-ad95-6d07799387e9","zoho.com":"https://help.zoho.com/portal/en/kb/zoho-mail/client-configuration/imap-access/articles/zoho-mail-app-passwords"};function ae(t){try{const s=new DOMParser().parseFromString(t,"application/xml");if(s.querySelector("parsererror"))return null;const a=s.querySelectorAll("incomingServer[type='imap']"),n=s.querySelectorAll("outgoingServer[type='smtp']");if(!a.length||!n.length)return null;const r=a[0],m=n[0],p=r.querySelector("hostname")?.textContent?.trim(),c=r.querySelector("port")?.textContent?.trim(),v=r.querySelector("socketType")?.textContent?.trim().toUpperCase(),b=m.querySelector("hostname")?.textContent?.trim(),w=m.querySelector("port")?.textContent?.trim(),y=m.querySelector("socketType")?.textContent?.trim().toUpperCase();if(!p||!c||!b||!w)return null;const j=f=>f==="SSL"||f==="TLS"||f==="SSL/TLS"?"tls":f==="STARTTLS"?"starttls":"none";return{imap:{host:p,port:Number.parseInt(c,10),security:j(v)},smtp:{host:b,port:Number.parseInt(w,10),security:j(y)},source:"mozilla-autoconfig"}}catch{return null}}async function Re(t,o){try{const s=`https://autoconfig.thunderbird.net/v1.1/${t}`,a=await fetch(s,{signal:o});if(!a.ok)return null;const n=await a.text(),r=ae(n);return r||null}catch{return null}}async function Fe(t,o){try{const s=`https://autoconfig.${t}/mail/config-v1.1.xml`,a=await fetch(s,{signal:o});if(!a.ok)return null;const n=await a.text(),r=ae(n);return r?{...r,source:"domain-autoconfig"}:null}catch{return null}}function Oe(t){return{imap:{host:`imap.${t}`,port:993,security:"tls"},smtp:{host:`smtp.${t}`,port:587,security:"starttls"},source:"heuristic"}}async function ze(t,o=1500){const s=t.indexOf("@");if(s===-1)return null;const a=t.slice(s+1).toLowerCase();if(!a)return null;const n=Ae[a];if(n)return n;const r=new AbortController,m=setTimeout(()=>r.abort(),o);try{const p=await Re(a,r.signal);if(p)return p;const c=await Fe(a,r.signal);if(c)return c}finally{clearTimeout(m)}return Oe(a)}function He(t){const o=t.indexOf("@");return o===-1?"Looking up server settings…":`Looking up settings for ${t.slice(o+1)}…`}function ie(t){const o=t.indexOf("@");if(o===-1)return;const s=t.slice(o+1).toLowerCase();return Me[s]}const ce=[{id:"icloud",label:"iCloud",username:"full-email",imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},passwordHelp:{text:"iCloud requires an app-specific password, not your Apple ID password. Generate one under Sign-In & Security → App-Specific Passwords.",url:"https://support.apple.com/en-us/102654"}},{id:"yahoo",label:"Yahoo",username:"full-email",imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},passwordHelp:{text:"Yahoo requires an app password, not your login password. Generate one under Account Security.",url:"https://help.yahoo.com/kb/generate-manage-third-party-passwords-sln15241.html"}},{id:"aol",label:"AOL",username:"full-email",imap:{host:"imap.aol.com",port:993,security:"tls"},smtp:{host:"smtp.aol.com",port:465,security:"tls"},passwordHelp:{text:"AOL requires an app password, not your login password. Generate one under Account Security.",url:"https://login.aol.com/account/security"}},{id:"fastmail",label:"Fastmail",username:"full-email",imap:{host:"imap.fastmail.com",port:993,security:"tls"},smtp:{host:"smtp.fastmail.com",port:465,security:"tls"},passwordHelp:{text:"Fastmail requires an app password, not your login password. Create one under Settings → Privacy & Security → App passwords.",url:"https://www.fastmail.help/hc/en-us/articles/360058752854"}}];function ee(t){return ce.find(o=>o.id===t)}const _e={"icloud.com":"icloud","me.com":"icloud","mac.com":"icloud","yahoo.com":"yahoo","yahoo.co.uk":"yahoo","ymail.com":"yahoo","aol.com":"aol","fastmail.com":"fastmail","fastmail.fm":"fastmail"};function De(t){const o=t.indexOf("@");if(o===-1)return"";const s=t.slice(o+1).toLowerCase();return _e[s]??""}const M=["Connector","Address","Servers","Credentials","Test","Sync"],F={connector:0,address:1,servers:2,credentials:3,test:4,sync:5},te={host:"",port:993,security:"tls"},se={host:"",port:587,security:"starttls"};function $e({onStart:t}){return i.useEffect(()=>{const o=s=>{s.key==="Enter"&&t()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[t]),e.jsx(A,{steps:M,activeStep:0,hideSteps:!0,title:"Welcome to Remit",subtitle:"One inbox for all your mail, with context about every message.",footer:e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-2xs text-fg-subtle",children:[e.jsx(je,{children:"Enter"})," to continue"]}),e.jsx(N,{variant:"primary",onClick:t,children:"Add your first account"})]}),children:e.jsxs("div",{className:"flex flex-col items-start py-5",children:[e.jsx("span",{className:"flex size-14 items-center justify-center rounded-md bg-accent-soft",children:e.jsx(ke,{className:"size-7 text-accent"})}),e.jsx("p",{className:"mt-5 max-w-sm text-sm leading-relaxed text-fg-muted",children:"Remit syncs your existing mailboxes and tells you who is really writing to you — sender history, authenticity checks, and similar messages, right next to every email."})]})})}function qe({onContinue:t,onMicrosoft:o,onBack:s,showBack:a}){const[n,r]=i.useState("imap");i.useEffect(()=>{const p=c=>{c.key==="Enter"&&(n==="microsoft"?o():t()),c.key==="Escape"&&s()};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[t,o,s,n]);const m=()=>{n==="microsoft"?o():t()};return e.jsx(A,{steps:M,activeStep:F.connector,title:"How does this account connect?",subtitle:"Choose a sign-in method. IMAP works with any provider.",footer:e.jsxs(e.Fragment,{children:[a?e.jsx(N,{variant:"ghost",onClick:s,children:"Back"}):e.jsx("span",{}),e.jsx(N,{variant:"primary",onClick:m,children:n==="microsoft"?"Continue with Microsoft":"Continue with IMAP"})]}),children:e.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[e.jsx(W,{name:"IMAP / SMTP",description:"Any mail provider — Fastmail, iCloud, your own server.",icon:e.jsx(Ce,{className:"size-5"}),selected:n==="imap",onSelect:()=>r("imap")}),e.jsx(W,{name:"Gmail",description:"Sign in with Google. No app passwords.",icon:e.jsx(K,{className:"size-5"}),comingSoon:!0}),e.jsx(W,{name:"Outlook / Microsoft 365",description:"Sign in with Microsoft. Works with Outlook.com and work accounts.",icon:e.jsx(we,{className:"size-5"}),selected:n==="microsoft",onSelect:()=>r("microsoft")})]})})}function Ge({onBack:t,onConnected:o}){const[s,a]=i.useState(""),[n,r]=i.useState(null),[m,p]=i.useState(!1),[c,v]=i.useState(!1),b=i.useRef(!0);i.useEffect(()=>(b.current=!0,()=>{b.current=!1}),[]);const w=i.useRef(new Set),{refetch:y}=Q(ne()),j=Ie(()=>{v(!1),y().then(({data:l,isError:C})=>{if(!b.current)return;if(C||!l){r("Couldn't check whether the sign-in finished. Open Settings › Accounts to see whether the account is connected.");return}r(null);const x=l.accounts.find(S=>!w.current.has(S.accountId));x&&o(x.accountId)})}),f=X({...be(),onSuccess:l=>{b.current&&(j(),p(!0),window.location.assign(l.authorizationUrl))},onError:l=>{v(!1),r(l instanceof Error?l.message:"Failed to start sign-in")}}),h=c||f.isPending,u=()=>{h||(r(null),v(!0),y().then(({data:l,isError:C})=>{if(b.current){if(C||!l){v(!1),r("Couldn't read this instance's accounts, so sign-in can't be tracked. Check your connection and try again.");return}w.current=new Set(l.accounts.map(x=>x.accountId)),f.mutate({body:{email:s.trim()||void 0}})}}))},k=i.useRef(u);return k.current=u,i.useEffect(()=>{const l=C=>{C.key==="Enter"&&k.current(),C.key==="Escape"&&t()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[t]),e.jsx(A,{steps:M,activeStep:F.connector,title:"Sign in with Microsoft",subtitle:"You'll be redirected to Microsoft to sign in securely.",footer:e.jsxs(e.Fragment,{children:[e.jsx(N,{variant:"ghost",onClick:t,children:"Back"}),e.jsx(N,{variant:"primary",onClick:u,disabled:h,icon:h?e.jsx($,{className:"size-4 animate-spin"}):void 0,children:h?"Redirecting…":m?"Start over":"Sign in with Microsoft"})]}),children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(I,{htmlFor:"microsoft-email",children:"Email address (optional)"}),e.jsx(R,{id:"microsoft-email",icon:e.jsx(K,{className:"size-4"}),placeholder:"you@outlook.com",value:s,onChange:l=>a(l.target.value),type:"email",autoComplete:"email"}),e.jsx("p",{className:"mt-1.5 text-2xs text-fg-subtle",children:"Pre-fills the Microsoft sign-in form. Leave blank to choose on the Microsoft page."})]}),m&&e.jsx(q,{tone:"info",children:"Waiting for Microsoft. Finish signing in — this window carries on the moment the account is connected, wherever you finished."}),n&&e.jsx(q,{tone:"danger",children:n})]})})}function Be({initialEmail:t,initialDisplayName:o,onContinue:s,onBack:a}){const[n,r]=i.useState(t),[m,p]=i.useState(o),[c,v]=i.useState(!1),[b,w]=i.useState(""),[y,j]=i.useState(null),f=i.useCallback(async()=>{const h=n.trim();if(!h.includes("@")||!h.includes(".")){j("Enter a valid email address.");return}j(null),v(!0),w(He(h));try{const u=await ze(h);s(h,m.trim(),u)}finally{v(!1)}},[n,m,s]);return i.useEffect(()=>{const h=u=>{u.key==="Enter"&&!c&&f(),u.key==="Escape"&&a()};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[f,c,a]),e.jsx(A,{steps:M,activeStep:F.address,title:"What's the email address?",subtitle:"We'll detect the server settings for you.",footer:e.jsxs(e.Fragment,{children:[e.jsx(N,{variant:"ghost",onClick:a,children:"Back"}),e.jsx(N,{variant:"primary",disabled:c,onClick:()=>{f()},children:"Continue"})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(I,{htmlFor:"onboarding-email",children:"Email address"}),e.jsx(R,{id:"onboarding-email",icon:e.jsx(K,{className:"size-4"}),placeholder:"you@example.com",value:n,onChange:h=>{r(h.target.value),j(null)},type:"email",autoComplete:"email"})]}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:"onboarding-display-name",children:"Display name (optional)"}),e.jsx(R,{id:"onboarding-display-name",placeholder:"Alice",value:m,onChange:h=>p(h.target.value)}),e.jsx("p",{className:"mt-1.5 text-2xs text-fg-subtle",children:"What to call this account in Remit. Leave blank to use a name derived from the address."})]}),c&&e.jsxs("div",{className:"mt-3 flex items-center gap-2 text-xs text-fg-muted",children:[e.jsx($,{className:"size-3.5 animate-spin text-accent"}),b]}),y&&!c&&e.jsx("div",{className:"mt-3",children:e.jsx(q,{tone:"danger",children:y})})]})})}function Ue({email:t,imapConfig:o,smtpConfig:s,discovered:a,onContinue:n,onBack:r,onChange:m}){const[p,c]=i.useState(o),[v,b]=i.useState(s),[w,y]=i.useState(()=>De(t)),[j,f]=i.useState(!1),[h,u]=i.useState(null),k=ee(w),l=k!==void 0&&!j,C=i.useCallback(g=>{y(g),f(!1),u(null);const d=ee(g);d&&(c({host:d.imap.host,port:d.imap.port,security:d.imap.security}),b({host:d.smtp.host,port:d.smtp.port,security:d.smtp.security}))},[]);i.useEffect(()=>{m(p,v)},[p,v,m]);const x=p.host.trim()!=="",S=i.useCallback(()=>{if(!x){u("Enter the IMAP host.");return}u(null),n()},[x,n]);i.useEffect(()=>{const g=d=>{d.key==="Enter"&&S(),d.key==="Escape"&&r()};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[S,r]);const T=t.split("@")[1]??"your domain",O=k?"Pick your provider to fill in the right settings — or choose Custom to enter them by hand.":a?"Found via autodiscovery — adjust anything that looks off.":`We couldn't detect settings for ${T} — enter them manually.`,P=l?{label:"preset",tone:"neutral"}:!k&&a?{label:"detected",tone:"positive"}:void 0,L=k?.passwordHelp.url??ie(t);return e.jsx(A,{steps:M,activeStep:F.servers,title:"Confirm server settings",subtitle:O,footer:e.jsxs(e.Fragment,{children:[e.jsx(N,{variant:"ghost",onClick:r,children:"Back"}),e.jsx(N,{variant:"primary",onClick:S,children:"Continue"})]}),children:e.jsxs("div",{className:"space-y-5",children:[h&&e.jsx(q,{tone:"danger",children:h}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:"provider-select",children:"Provider"}),e.jsxs(V,{id:"provider-select",value:w,onChange:g=>C(g.target.value),children:[e.jsx("option",{value:"",children:"Custom / other"}),ce.map(g=>e.jsx("option",{value:g.id,children:g.label},g.id))]}),k&&e.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:l?e.jsxs(e.Fragment,{children:["Server settings are pre-filled for ",k.label," and locked."," ",e.jsx("button",{type:"button",className:"text-accent underline",onClick:()=>f(!0),children:"Advanced"})," ","lets you edit them by hand."]}):e.jsxs(e.Fragment,{children:["Editing ",k.label,"'s settings by hand."]})})]}),e.jsx(Z,{legend:"IMAP — incoming",badge:P,readOnly:l,host:p.host,port:String(p.port),security:p.security,hostPlaceholder:"imap.example.com",portPlaceholder:"993",onHostChange:g=>{c(d=>({...d,host:g})),u(null)},onPortChange:g=>c(d=>({...d,port:Number(g)})),onSecurityChange:g=>c(d=>({...d,security:g}))}),e.jsx("p",{className:"text-2xs text-fg-subtle",children:"Sending (SMTP) is optional — leave it blank to set up a receive-only account and add sending later in Settings."}),e.jsx(Z,{legend:"SMTP — outgoing (optional)",badge:P,readOnly:l,host:v.host,port:String(v.port),security:v.security,hostPlaceholder:"smtp.example.com",portPlaceholder:"587",onHostChange:g=>{b(d=>({...d,host:g})),u(null)},onPortChange:g=>b(d=>({...d,port:Number(g)})),onSecurityChange:g=>b(d=>({...d,security:g}))}),k&&e.jsxs("p",{className:"text-2xs text-fg-subtle",children:[k.passwordHelp.text," ",L&&e.jsx("a",{href:L,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"Get an app password"})]})]})})}function We({email:t,username:o,password:s,onContinue:a,onBack:n,onChange:r}){const[m,p]=i.useState(o||t),[c,v]=i.useState(s),[b,w]=i.useState(null),y=t.split("@")[1]??"",j=ie(t),f=m.trim()!==""&&c.trim()!=="";i.useEffect(()=>{r(m,c)},[m,c,r]);const h=i.useCallback(()=>{if(!f){w("Enter your username and password.");return}w(null),a()},[f,a]);return i.useEffect(()=>{const u=k=>{k.key==="Enter"&&h(),k.key==="Escape"&&n()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[h,n]),e.jsx(A,{steps:M,activeStep:F.credentials,title:`Sign in to ${y||"your mail server"}`,subtitle:"Many providers require an app password instead of your normal one.",footer:e.jsxs(e.Fragment,{children:[e.jsx(N,{variant:"ghost",onClick:n,children:"Back"}),e.jsx(N,{variant:"primary",onClick:h,children:"Test connection"})]}),children:e.jsxs("div",{className:"space-y-3",children:[b&&e.jsx("div",{className:"rounded-md bg-danger-soft px-3 py-2 text-sm text-danger",children:b}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:"credentials-username",children:"Username"}),e.jsx(R,{id:"credentials-username",value:m,onChange:u=>{p(u.target.value),w(null)},autoComplete:"username"})]}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:"credentials-password",children:"Password or app password"}),e.jsx(ve,{id:"credentials-password",value:c,onChange:u=>{v(u.target.value),w(null)},autoComplete:"current-password"})]}),e.jsx(Ne,{url:j})]})})}function Ve({email:t,imapConfig:o,smtpConfig:s,username:a,password:n,onSuccess:r,onBackToCredentials:m,onBackToServers:p}){const[c,v]=i.useState({imapState:"running",smtpState:"pending",phase:"running"}),[b,w]=i.useState(0),y=s.host.trim()!=="",j=G(o.security),f=G(s.security),h=X({...ge()});i.useEffect(()=>{let l=!1;const C=[];return v({imapState:"running",smtpState:"pending",phase:"running"}),h.mutate({body:{username:a,password:n,imapHost:o.host,imapPort:o.port,imapTls:j.tls,imapStartTls:j.startTls,smtpHost:s.host,smtpPort:s.port,smtpTls:f.tls,smtpStartTls:f.startTls}},{onSuccess:x=>{if(l)return;const S=x.imapSuccess,T=y?x.smtpSuccess:!0;v({imapState:S?"ok":"failed",smtpState:y?"running":"ok",imapDetail:S?`Connected — ${o.host}:${o.port}`:x.imapError,phase:"running"}),C.push(window.setTimeout(()=>{if(l)return;const O=L=>{const g=L?.toLowerCase()??"";return g.includes("auth")||g.includes("login")||g.includes("535")||g.includes("credential")},P=!S&&O(x.imapError)||S&&y&&!x.smtpSuccess&&O(x.smtpError);v({imapState:S?"ok":"failed",smtpState:y?x.smtpSuccess?"ok":"failed":"ok",imapDetail:S?`Connected — ${o.host}:${o.port}`:x.imapError,smtpDetail:y?x.smtpSuccess?`Connected — ${s.host}:${s.port}`:x.smtpError:"Not set up — receive-only",rawError:S?y&&!x.smtpSuccess?x.smtpError:void 0:x.imapError,phase:S&&T?"success":P?"auth-failure":"network-failure"}),S&&T&&C.push(window.setTimeout(()=>{l||r()},800))},400))},onError:x=>{if(l)return;const S=x instanceof Error?x.message:"Connection failed";v({imapState:"failed",smtpState:"failed",imapDetail:S,smtpDetail:S,rawError:S,phase:"network-failure"})}}),()=>{l=!0;for(const x of C)window.clearTimeout(x)}},[b]);const{phase:u}=c;i.useEffect(()=>{const l=C=>{C.key==="Escape"&&(u==="auth-failure"?m():u==="network-failure"&&p())};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[u,m,p]);const k=u==="auth-failure"?e.jsxs(e.Fragment,{children:[e.jsx(N,{variant:"ghost",onClick:m,children:"Back to credentials"}),e.jsx(N,{variant:"primary",onClick:()=>w(l=>l+1),children:"Retry"})]}):u==="network-failure"?e.jsxs(e.Fragment,{children:[e.jsx(N,{variant:"ghost",onClick:p,children:"Back to servers"}),e.jsx(N,{variant:"primary",onClick:()=>w(l=>l+1),children:"Retry"})]}):u==="success"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"Connection verified"}),e.jsx(N,{variant:"primary",onClick:r,children:"Start syncing"})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"Testing…"}),e.jsx("span",{})]});return e.jsx(A,{steps:M,activeStep:F.test,title:"Testing the connection",subtitle:`Checking ${t}`,footer:k,children:e.jsxs("div",{className:"divide-y divide-line",children:[e.jsx(H,{label:`IMAP — ${o.host}:${o.port}`,detail:c.imapDetail,state:c.imapState}),e.jsx(H,{label:y?`SMTP — ${s.host}:${s.port}`:"SMTP — sending",detail:y?c.smtpDetail:"Not set up — you can add sending later in Settings",state:c.smtpState}),(u==="auth-failure"||u==="network-failure")&&c.rawError&&e.jsxs("div",{className:"py-3",children:[u==="auth-failure"&&e.jsx("p",{className:"mb-2 text-xs text-fg-muted",children:"Check your password — many providers require an app password."}),e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:c.rawError})]})]})})}const Qe=2e4;function Xe({email:t,displayName:o,imapConfig:s,smtpConfig:a,username:n,password:r,onGoToInbox:m}){const p=xe(),[c,v]=i.useState(null),[b,w]=i.useState(null),y=i.useRef(!1),j=G(s.security),f=G(a.security),h=X({...ye(),onSuccess:E=>{v(E.accountId),p.invalidateQueries({queryKey:fe()})},onError:E=>{w(E instanceof Error?E.message:"Failed to create account")}});i.useEffect(()=>{if(y.current)return;y.current=!0;const E=a.host.trim()!=="",_=Se({imapHost:s.host,smtpHost:a.host,smtpPort:a.port}),D=E?_??{smtpHost:a.host,smtpPort:a.port,smtpTls:f.tls,smtpStartTls:f.startTls}:null;h.mutate({body:{email:t,displayName:o||void 0,username:n!==t?n:void 0,password:r,imapHost:s.host,imapPort:s.port,imapTls:j.tls,imapStartTls:j.startTls,smtpHost:D?.smtpHost||void 0,smtpPort:D?.smtpPort||void 0,smtpTls:D?.smtpTls??!1,smtpStartTls:D?.smtpStartTls??!1}})},[]);const{data:u,isError:k}=Q({...Y({path:{accountId:c??""}}),enabled:!!c,refetchInterval:E=>{const _=E.state.data?.syncPhase;return _==="complete"||_==="error"?!1:2e3}}),l=u?.syncPhase==="error",{data:C}=Q({...ne(),enabled:!!c&&l}),x=C?.accounts.find(E=>E.accountId===c)?.lastError,S=u?.mailboxes.find(E=>E.fullPath==="INBOX"||E.fullPath==="Inbox"),T=u?.mailboxCountTotal??0,O=u?.mailboxCountSynced??0,P=S?.messagesTotal??0,L=S?.messagesSynced??0,g=P>0?L/P:0,d=u?.syncPhase,le=l?"failed":d==="idle"||d===void 0||d==="discovering_mailboxes"?"running":T>0?"ok":"running",B=l?"failed":!d||d==="idle"||d==="discovering_mailboxes"?"pending":d==="syncing_inbox"||d==="syncing_others"?"running":"ok",U=l?"failed":!d||d==="idle"||d==="discovering_mailboxes"||d==="syncing_inbox"?"pending":d==="syncing_others"?"running":"ok",ue=L>0||S?.phase==="complete"||d==="complete"||l,[me,de]=i.useState(!1);i.useEffect(()=>{if(!c)return;const E=setTimeout(()=>de(!0),Qe);return()=>clearTimeout(E)},[c]);const pe=!!c&&(ue||k||me);return b?e.jsx(A,{steps:M,activeStep:F.sync,title:"Couldn't create account",subtitle:"Something went wrong saving your account.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{}),e.jsx(N,{variant:"primary",onClick:()=>{y.current=!1,w(null),h.mutate({body:{email:t,displayName:o||void 0,username:n!==t?n:void 0,password:r,imapHost:s.host,imapPort:s.port,imapTls:j.tls,imapStartTls:j.startTls,smtpHost:a.host||void 0,smtpPort:a.port||void 0,smtpTls:f.tls,smtpStartTls:f.startTls}})},children:"Retry"})]}),children:e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:b})}):e.jsx(A,{steps:M,activeStep:F.sync,title:`Syncing ${t}`,subtitle:"Newest mail first — you can start reading right away.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"Sync continues in the background"}),pe?e.jsx(N,{variant:"primary",onClick:()=>c&&m(c),children:"Go to inbox"}):e.jsx(N,{variant:"primary",disabled:!0,icon:e.jsx($,{className:"size-3.5 animate-spin"}),children:"Getting your mail…"})]}),children:h.isPending?e.jsxs("div",{className:"flex items-center gap-2 py-4 text-sm text-fg-muted",children:[e.jsx($,{className:"size-4 animate-spin text-accent"}),"Creating your account…"]}):e.jsxs("div",{className:"space-y-3",children:[P>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-baseline justify-between text-xs",children:[e.jsx("span",{className:"font-medium text-fg",children:"INBOX"}),e.jsxs("span",{className:"text-fg-subtle tabular-nums",children:[L.toLocaleString()," / ",P.toLocaleString()," ","messages"]})]}),e.jsx("div",{className:"mt-1 h-1.5 overflow-hidden rounded-full bg-surface-sunken",children:e.jsx("div",{className:"h-full rounded-full bg-accent transition-all duration-500",style:{width:`${Math.max(2,g*100)}%`}})})]}),e.jsxs("div",{className:"divide-y divide-line",children:[e.jsx(H,{label:"Mailboxes discovered",detail:T>0?`${T} mailbox${T===1?"":"es"} found`:"Discovering…",state:le}),e.jsx(H,{label:"INBOX",detail:B==="ok"?`${L.toLocaleString()} messages synced`:B==="running"?"Syncing newest first…":"Queued",state:B}),O>1||d==="syncing_others"||d==="complete"?e.jsx(H,{label:"Other mailboxes",detail:U==="ok"?`${O-1} mailboxes synced`:U==="running"?"Syncing…":"Queued",state:U}):null]}),l&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("p",{className:"text-xs text-danger",children:["Sync stalled. The account is still active —"," ",e.jsx("button",{type:"button",className:"underline",onClick:()=>{p.invalidateQueries({queryKey:Y({path:{accountId:c??""}}).queryKey})},children:"retry"})]}),x&&e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:x})]})]})})}function et({skipWelcome:t=!1,onComplete:o,onCancel:s}){const[a,n]=i.useState(t?"connector":"welcome"),[r,m]=i.useState({email:"",displayName:"",imapConfig:te,smtpConfig:se,username:"",password:"",discoveryResult:null,discovered:!1,createdAccountId:null}),p=i.useCallback(()=>n("connector"),[]),c=i.useCallback(()=>n("address"),[]),v=i.useCallback(()=>n("microsoft-email"),[]),b=i.useCallback(()=>{t?s?.():n("welcome")},[t,s]),w=i.useCallback((u,k,l)=>{let C=te,x=se,S=!1;l&&(S=l.source!=="heuristic",C={host:l.imap.host,port:l.imap.port,security:l.imap.security},x={host:l.smtp.host,port:l.smtp.port,security:l.smtp.security}),m(T=>({...T,email:u,displayName:k,imapConfig:C,smtpConfig:x,discoveryResult:l,discovered:S,username:u})),n("servers")},[]),y=i.useCallback((u,k)=>{m(l=>({...l,imapConfig:u,smtpConfig:k}))},[]),j=i.useCallback((u,k)=>{m(l=>({...l,username:u,password:k}))},[]),f=i.useCallback(()=>n("sync"),[]),h=i.useCallback(u=>{o(u)},[o]);switch(a){case"welcome":return e.jsx($e,{onStart:p});case"connector":return e.jsx(qe,{onContinue:c,onMicrosoft:v,onBack:b,showBack:!t});case"microsoft-email":return e.jsx(Ge,{onBack:()=>n("connector"),onConnected:h});case"address":return e.jsx(Be,{initialEmail:r.email,initialDisplayName:r.displayName,onContinue:w,onBack:()=>n("connector")});case"servers":return e.jsx(Ue,{email:r.email,imapConfig:r.imapConfig,smtpConfig:r.smtpConfig,discovered:r.discovered,onContinue:()=>n("credentials"),onBack:()=>n("address"),onChange:y});case"credentials":return e.jsx(We,{email:r.email,username:r.username,password:r.password,onContinue:()=>n("test"),onBack:()=>n("servers"),onChange:j});case"test":return e.jsx(Ve,{email:r.email,imapConfig:r.imapConfig,smtpConfig:r.smtpConfig,username:r.username,password:r.password,onSuccess:f,onBackToCredentials:()=>n("credentials"),onBackToServers:()=>n("servers")});case"sync":return e.jsx(Xe,{email:r.email,displayName:r.displayName,imapConfig:r.imapConfig,smtpConfig:r.smtpConfig,username:r.username,password:r.password,onGoToInbox:h})}}export{et as O,ce as P,Ie as a,ee as g,G as s,Le as u};
@@ -1 +0,0 @@
1
- import{a7 as m,j as o,a4 as p}from"./index-CFkAgUJA.js";import{a}from"./MailShell-EBHUhgkn.js";import{M as r}from"./MailboxPane-CXDOqiF_.js";import{g as e}from"./search-token-index-D2aIcKlQ.js";import{u as s}from"./search-mirror-z_kwOSxA.js";import"./FullCompose-DzuCOaYk.js";import"./ErrorState-CDN8OkAT.js";import"./index-Bmk2EDh1.js";import"./useMessageBodyContent-CG3Q2Vwi.js";import"./useSignature-CszyYw-c.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-zfkxbezK.js";import"./confirm-dialog-DLbVncLb.js";import"./useSearchTokenContext-Dmt9kbMV.js";import"./kbd-bB3ZAr68.js";import"./search-scope-DTcpOp3S.js";import"./useRefreshControl-BCWsGgbC.js";import"./circle-check-big-DostR7Uj.js";import"./MailListHeader-C4lftUEo.js";import"./attachment-file-D-Cvcyx2.js";import"./mail-Dvas2UDV.js";import"./avatar-CQ3ej2nF.js";import"./format-HW3C18y-.js";import"./download-Cb45kClh.js";import"./shield-check-7qB60EQS.js";import"./useFilters-D9VfT5eI.js";import"./clock-gfYrT9HU.js";import"./menu-CHgXvbDR.js";import"./MailViewChrome-DDfMPO16.js";import"./NavMenuButton-Dfz7rRBq.js";import"./useLabels-epnfWwuH.js";import"./useSemanticSearch-DIrzI_5M.js";import"./search-query-Cr_ZXBCp.js";import"./bottom-sheet-CJAkwg1D.js";import"./circle-help-BrBilteI.js";import"./circle-check-BlV3yF1E.js";function N(){const{mailboxId:t}=m.useParams(),i=e();return s({to:"/mail/$mailboxId",params:{mailboxId:t}}),o.jsx(r,{mailboxId:t,thread:i,children:o.jsx(a,{phone:o.jsx(r.Phone,{}),list:o.jsx(r.List,{}),reading:o.jsx(p,{}),intelligence:o.jsx(r.Intelligence,{}),hasThread:!!i})})}export{N as component};
@@ -1 +0,0 @@
1
- import{j as r}from"./index-CFkAgUJA.js";import{B as o}from"./BriefPane-DkIisyhD.js";import"./useSearchTokenContext-Dmt9kbMV.js";import"./kbd-bB3ZAr68.js";import"./useMessageBodyContent-CG3Q2Vwi.js";import"./search-scope-DTcpOp3S.js";import"./MailListHeader-C4lftUEo.js";import"./search-token-index-D2aIcKlQ.js";import"./attachment-file-D-Cvcyx2.js";import"./mail-Dvas2UDV.js";import"./avatar-CQ3ej2nF.js";import"./index-Bmk2EDh1.js";import"./useSignature-CszyYw-c.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-zfkxbezK.js";import"./ErrorState-CDN8OkAT.js";import"./format-HW3C18y-.js";import"./download-Cb45kClh.js";import"./shield-check-7qB60EQS.js";import"./useFilters-D9VfT5eI.js";import"./confirm-dialog-DLbVncLb.js";import"./clock-gfYrT9HU.js";import"./menu-CHgXvbDR.js";import"./useRefreshControl-BCWsGgbC.js";import"./circle-check-big-DostR7Uj.js";import"./useLabels-epnfWwuH.js";import"./useSemanticSearch-DIrzI_5M.js";import"./search-query-Cr_ZXBCp.js";import"./wizard-selection-B1bng5Jq.js";function A(){return r.jsx(o.Reading,{})}export{A as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-CFkAgUJA.js";import{M as r}from"./MailboxPane-CXDOqiF_.js";import"./useSearchTokenContext-Dmt9kbMV.js";import"./kbd-bB3ZAr68.js";import"./useMessageBodyContent-CG3Q2Vwi.js";import"./search-scope-DTcpOp3S.js";import"./useRefreshControl-BCWsGgbC.js";import"./circle-check-big-DostR7Uj.js";import"./search-token-index-D2aIcKlQ.js";import"./MailListHeader-C4lftUEo.js";import"./attachment-file-D-Cvcyx2.js";import"./mail-Dvas2UDV.js";import"./avatar-CQ3ej2nF.js";import"./index-Bmk2EDh1.js";import"./useSignature-CszyYw-c.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-zfkxbezK.js";import"./ErrorState-CDN8OkAT.js";import"./format-HW3C18y-.js";import"./download-Cb45kClh.js";import"./shield-check-7qB60EQS.js";import"./useFilters-D9VfT5eI.js";import"./confirm-dialog-DLbVncLb.js";import"./clock-gfYrT9HU.js";import"./menu-CHgXvbDR.js";import"./MailViewChrome-DDfMPO16.js";import"./NavMenuButton-Dfz7rRBq.js";import"./useLabels-epnfWwuH.js";import"./useSemanticSearch-DIrzI_5M.js";import"./search-query-Cr_ZXBCp.js";import"./bottom-sheet-CJAkwg1D.js";import"./circle-help-BrBilteI.js";import"./circle-check-BlV3yF1E.js";function G(){return o.jsx(r.Reading,{})}export{G as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-CFkAgUJA.js";import{F as r}from"./FlaggedPane-yUCuVDrF.js";import"./useSearchTokenContext-Dmt9kbMV.js";import"./kbd-bB3ZAr68.js";import"./useMessageBodyContent-CG3Q2Vwi.js";import"./search-scope-DTcpOp3S.js";import"./MailListHeader-C4lftUEo.js";import"./search-token-index-D2aIcKlQ.js";import"./attachment-file-D-Cvcyx2.js";import"./mail-Dvas2UDV.js";import"./avatar-CQ3ej2nF.js";import"./index-Bmk2EDh1.js";import"./useSignature-CszyYw-c.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-zfkxbezK.js";import"./ErrorState-CDN8OkAT.js";import"./format-HW3C18y-.js";import"./download-Cb45kClh.js";import"./shield-check-7qB60EQS.js";import"./useFilters-D9VfT5eI.js";import"./confirm-dialog-DLbVncLb.js";import"./clock-gfYrT9HU.js";import"./menu-CHgXvbDR.js";import"./MailViewChrome-DDfMPO16.js";import"./wizard-selection-B1bng5Jq.js";function v(){return o.jsx(r.Reading,{})}export{v as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-CFkAgUJA.js";import{O as t}from"./OutboxPane-CgELyxEH.js";import"./useSearchTokenContext-Dmt9kbMV.js";import"./kbd-bB3ZAr68.js";import"./useMessageBodyContent-CG3Q2Vwi.js";import"./search-scope-DTcpOp3S.js";import"./circle-check-big-DostR7Uj.js";import"./clock-gfYrT9HU.js";import"./row-actions-mYLXim9h.js";import"./rotate-ccw-Bxy1oybp.js";import"./NavMenuButton-Dfz7rRBq.js";import"./menu-CHgXvbDR.js";import"./format-HW3C18y-.js";import"./outbox-status-BlKn6P0x.js";import"./search-query-Cr_ZXBCp.js";function P(){return o.jsx(t.Reading,{})}export{P as component};
@@ -1 +0,0 @@
1
- import{a4 as o}from"./index-CFkAgUJA.js";const n=o;export{n as component};
@@ -1 +0,0 @@
1
- import{a4 as o}from"./index-CFkAgUJA.js";const n=o;export{n as component};
@@ -1 +0,0 @@
1
- import{a4 as o}from"./index-CFkAgUJA.js";const n=o;export{n as component};
@@ -1 +0,0 @@
1
- import{j as a,ac as Ve,B as te,a as ks,X as De,ad as Ps,ae as Vs,af as ut,r as C,b as Ge,ag as ee,x as ft,ah as Ds,D as Xt,a1 as Jt,ai as Cs,aj as Se,ak as Fs,a5 as Te,al as es,am as Os,an as Is,ao as Rs,ap as ve,aq as At,ar as it,as as Tt,at as Ms,au as Ie,av as be,aw as Et,t as Ls,ax as Us,ay as Hs,az as ts,aA as _t,a0 as zs,aB as Bs,aC as qs,aD as $s,aE as kt,aF as Ws,aG as Pt,aH as Gs,T as Ks}from"./index-CFkAgUJA.js";import{R as Ys}from"./row-actions-mYLXim9h.js";import{S as Qs,A as Zs}from"./settings-screen-5dMLPXnl.js";import{g as Vt,P as Xs,s as Be,u as Js,a as er,O as tr}from"./OnboardingWizard-DVTmeiRu.js";import{u as sr}from"./useSignature-CszyYw-c.js";import{c as rr,a as Dt,d as ar}from"./account-form-helpers-DhckT_PN.js";import{D as ir}from"./download-Cb45kClh.js";import{E as nr}from"./ErrorState-CDN8OkAT.js";import{f as or}from"./format-HW3C18y-.js";import{a as lr}from"./help-copy-DEsN5V8b.js";import"./avatar-CQ3ej2nF.js";import"./menu-CHgXvbDR.js";import"./circle-help-BrBilteI.js";import"./kbd-bB3ZAr68.js";import"./mail-Dvas2UDV.js";const cr=e=>{const s=new Set(e.map(Ps));return Vs.map(t=>t.tag).filter(t=>!s.has(t)).sort((t,i)=>Ve(t).localeCompare(Ve(i)))},dr=({value:e,onChange:s,busy:t=!1})=>{const i=cr(e);return a.jsxs("div",{className:"space-y-2","data-testid":"compose-language-setting",children:[a.jsx("ul",{className:"space-y-1",children:e.map((o,d)=>a.jsxs("li",{"data-testid":`compose-language-row-${o}`,className:"flex items-center gap-2 rounded-md border border-line bg-surface-sunken px-3 py-1.5",children:[a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-fg",lang:o,children:Ve(o)}),d===0?a.jsx("span",{className:"shrink-0 text-2xs uppercase tracking-wider text-fg-subtle",children:"Default"}):a.jsx(te,{variant:"ghost",size:"sm",icon:a.jsx(ks,{className:"size-3.5"}),disabled:t,"aria-label":`Write new messages in ${Ve(o)} by default`,onClick:()=>s([o,...e.filter(n=>n!==o)]),children:"Default"}),a.jsx(te,{variant:"ghost",size:"sm",icon:a.jsx(De,{className:"size-3.5"}),disabled:t||e.length===1,"aria-label":`Remove ${Ve(o)}`,onClick:()=>s(e.filter(n=>n!==o))})]},o))}),a.jsxs("select",{"aria-label":"Add a language",value:"",disabled:t||i.length===0,onChange:o=>{o.target.value!==""&&s([...e,o.target.value])},className:"w-full rounded-md border border-line bg-surface-sunken px-3 py-2 text-sm text-fg outline-none transition-colors focus-within:border-line-strong focus-within:ring-2 focus-within:ring-ring/30",children:[a.jsx("option",{value:"",children:"Add a language…"}),i.map(o=>a.jsx("option",{value:o,children:Ve(o)},o))]}),a.jsx("p",{className:"text-xs text-fg-muted",children:"A message is tagged with the language you write it in, picked from this list. Your browser, not this app, decides which dictionaries it spellchecks against — add the language there too to get its underlines."})]})};function ur({title:e,description:s,action:t}){return a.jsxs("div",{className:"rounded-sm border border-danger/50",children:[a.jsxs("div",{className:"flex items-center gap-2 border-b border-danger/30 bg-danger-soft px-row-inset py-2",children:[a.jsx(ut,{className:"size-4 text-danger"}),a.jsx("h2",{className:"text-sm font-semibold text-danger",children:"Danger zone"})]}),a.jsxs("div",{className:"flex flex-col gap-3 px-row-inset py-3 sm:flex-row sm:items-center sm:justify-between sm:gap-4",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"text-sm font-medium text-fg",children:e}),a.jsx("p",{className:"text-xs text-fg-muted",children:s})]}),a.jsx("div",{className:"shrink-0",children:t})]})]})}function Ct({isOpen:e,onClose:s,title:t,children:i,footer:o}){return C.useEffect(()=>{if(!e)return;const d=n=>{n.key==="Escape"&&s()};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[e,s]),a.jsxs(a.Fragment,{children:[a.jsx("div",{className:Ge("fixed inset-0 z-40 bg-black/30 transition-opacity",e?"opacity-100":"pointer-events-none opacity-0"),onClick:s,"aria-hidden":"true"}),a.jsxs("div",{className:Ge("safe-area-frame fixed top-0 right-0 z-50 flex h-full w-full flex-col border-l border-line bg-canvas shadow-xl sm:w-[400px] sm:max-w-[90vw]","transform transition-transform duration-200 ease-out",e?"translate-x-0":"pointer-events-none translate-x-full"),role:"dialog","aria-modal":"true","aria-hidden":!e,inert:!e,"aria-labelledby":"slide-panel-title",children:[a.jsxs("div",{className:"flex h-14 shrink-0 items-center justify-between border-b border-line px-4",children:[a.jsx("h2",{id:"slide-panel-title",className:"font-semibold",children:t}),a.jsx("button",{type:"button",onClick:s,className:"rounded-md p-1.5 transition-colors hover:bg-surface-raised","aria-label":"Close",children:a.jsx(De,{className:"size-5"})})]}),a.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[a.jsx("div",{className:"flex-1 overflow-auto p-4",children:i}),o&&a.jsx("div",{className:"flex justify-end gap-3 border-t border-line bg-canvas p-4",children:o})]})]})]})}var Le=e=>e.type==="checkbox",je=e=>e instanceof Date,K=e=>e==null;const mt=e=>typeof e=="object";var H=e=>!K(e)&&!Array.isArray(e)&&mt(e)&&!je(e),fr=e=>H(e)&&e.target?Le(e.target)?e.target.checked:e.target.value:e,mr=(e,s)=>s.split(".").some((t,i,o)=>!isNaN(Number(t))&&e.has(o.slice(0,i).join("."))),ss=e=>{const s=e.constructor&&e.constructor.prototype;return H(s)&&s.hasOwnProperty("isPrototypeOf")},Qe=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function z(e){if(e instanceof Date)return new Date(e);const s=typeof FileList<"u"&&e instanceof FileList;if(Qe&&(e instanceof Blob||s))return e;const t=Array.isArray(e);if(!t&&!(H(e)&&ss(e)))return e;const i=t?[]:Object.create(Object.getPrototypeOf(e));for(const o in e)Object.prototype.hasOwnProperty.call(e,o)&&(i[o]=z(e[o]));return i}const ke={BLUR:"blur",FOCUS_OUT:"focusout",SUBMIT:"submit",TRIGGER:"trigger",VALID:"valid"},ue={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},de={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},rs="root",pt=["__proto__","constructor","prototype"],pr=/^\w*$/;var Ue=e=>pr.test(e),M=e=>e===void 0;const hr=/[.[\]'"]/;var Ze=e=>e.split(hr).filter(Boolean),y=(e,s,t)=>{if(!s||!H(e))return t;const i=Ue(s)?[s]:Ze(s);if(i.some(d=>pt.includes(d)))return t;const o=i.reduce((d,n)=>K(d)?void 0:d[n],e);return M(o)||o===e?M(e[s])?t:e[s]:o},me=e=>typeof e=="boolean",ie=e=>typeof e=="function",F=(e,s,t)=>{let i=-1;const o=Ue(s)?[s]:Ze(s),d=o.length,n=d-1;for(;++i<d;){const u=o[i];let j=t;if(i!==n){const _=e[u];j=H(_)||Array.isArray(_)?_:isNaN(+o[i+1])?{}:[]}if(pt.includes(u))return;e[u]=j,e=e[u]}};const gr=ee.createContext(null);gr.displayName="HookFormControlContext";var xr=(e,s,t,i=!0)=>{const o={};for(const d in e)Object.defineProperty(o,d,{get:()=>{const n=d;return s._proxyFormState[n]!==ue.all&&(s._proxyFormState[n]=!i||ue.all),e[n]}});return o};const yr=Qe?ee.useLayoutEffect:ee.useEffect;var Y=e=>typeof e=="string",vr=(e,s,t,i,o)=>Y(e)?(i&&s.watch.add(e),y(t,e,o)):Array.isArray(e)?e.map(d=>(i&&s.watch.add(d),y(t,d))):(i&&(s.watchAll=!0),t),nt=e=>K(e)||!mt(e);const Ft=(e,s)=>s.length===0&&!Array.isArray(e)&&!ss(e);function pe(e,s,t=new WeakMap){if(e===s)return!0;if(nt(e)||nt(s))return Object.is(e,s);if(je(e)&&je(s))return Object.is(e.getTime(),s.getTime());const i=Object.keys(e),o=Object.keys(s);if(i.length!==o.length)return!1;if(Ft(e,i)||Ft(s,o))return Object.is(e,s);if(!i.length&&Array.isArray(e)!==Array.isArray(s))return!1;const d=t.get(e);if(d&&d.has(s))return!0;if(d)d.add(s);else{const n=new WeakSet;n.add(s),t.set(e,n)}for(const n of i){const u=e[n];if(!(n in s))return!1;if(n!=="ref"){const j=s[n];if(je(u)&&je(j)||(H(u)||Array.isArray(u))&&(H(j)||Array.isArray(j))?!pe(u,j,t):!Object.is(u,j))return!1}}return!0}var qe=e=>({isOnSubmit:!e||e===ue.onSubmit,isOnBlur:e===ue.onBlur,isOnChange:e===ue.onChange,isOnAll:e===ue.all,isOnTouch:e===ue.onTouched}),st=(e,s,t)=>{if(t)return!1;if(s.watchAll||s.watch.has(e))return!0;for(const i of s.watch)if(e.startsWith(i)&&e.charAt(i.length)===".")return!0;return!1};const Me=(e,s,t,i)=>{for(const o of t||Object.keys(e)){const d=y(e,o);if(d){const{_f:n,...u}=d;if(n){if(n.refs&&n.refs[0]&&s(n.refs[0],o)&&!i)return!0;if(n.ref&&s(n.ref,n.name)&&!i)return!0;if(Me(u,s))break}else if(H(u)&&Me(u,s))break}}};var Ot=(e,s,t)=>{const i=y(e,t),o=Array.isArray(i)?i:[];return F(o,rs,s[t]),F(e,t,o),e},G=e=>H(e)&&!Object.keys(e).length,ht=e=>e.type==="file",Ke=e=>{if(!Qe)return!1;const s=e?e.ownerDocument:0;return e instanceof(s&&s.defaultView?s.defaultView.HTMLElement:HTMLElement)},gt=e=>e.type==="radio",Ye=e=>e instanceof RegExp,xt=(e,s,t,i,o)=>s?{...t[e],types:{...t[e]&&t[e].types?t[e].types:{},[i]:o||!0}}:{};const It={value:!1,isValid:!1},Rt={value:!0,isValid:!0};var as=e=>{if(Array.isArray(e)){if(e.length>1){const s=e.filter(t=>t&&t.checked&&!t.disabled).map(t=>t.value);return{value:s,isValid:!!s.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!M(e[0].attributes.value)?M(e[0].value)||e[0].value===""?Rt:{value:e[0].value,isValid:!0}:Rt:It}return It};const Mt={isValid:!1,value:null};var is=e=>Array.isArray(e)?e.reduce((s,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:s,Mt):Mt;function Lt(e,s,t="validate"){if(Y(e)||Array.isArray(e)&&e.every(Y)||me(e)&&!e)return{type:t,message:Y(e)?e:"",ref:s}}var Pe=e=>H(e)&&!Ye(e)?e:{value:e,message:""},Ut=async(e,s,t,i,o,d)=>{const{ref:n,refs:u,required:j,maxLength:_,minLength:k,min:U,max:R,pattern:O,validate:E,name:f,valueAsNumber:b,mount:ae}=e._f,N=y(t,f);if(!ae||s.has(f))return{};const $=u?u[0]:n,I=T=>{if(o&&$.reportValidity){const P=me(T)?"":T||"";u?u.forEach(D=>D.setCustomValidity(P)):$.setCustomValidity(P),$.reportValidity()}},A={},ne=gt(n),re=Le(n),he=ne||re,oe=(b||ht(n))&&M(n.value)&&M(N)||Ke(n)&&n.value===""||N===""||Array.isArray(N)&&!N.length,Q=xt.bind(null,f,i,A),le=(T,P,D,q=de.maxLength,Z=de.minLength)=>{const S=T?P:D;A[f]={type:T?q:Z,message:S,ref:n,...Q(T?q:Z,S)}};if(d?!Array.isArray(N)||!N.length:j&&(!he&&(oe||K(N))||me(N)&&!N||re&&!as(u).isValid||ne&&!is(u).isValid)){const{value:T,message:P}=Y(j)?{value:!!j,message:j}:Pe(j);if(T&&(A[f]={type:de.required,message:P,ref:$,...Q(de.required,P)},!i))return I(P),A}if(!oe&&(!K(U)||!K(R))){let T,P;const D=Pe(R),q=Pe(U);if(!K(N)&&!isNaN(N)){const Z=n.valueAsNumber||N&&+N;K(D.value)||(T=Z>D.value),K(q.value)||(P=Z<q.value)}else{const Z=n.valueAsDate||new Date(N),S=ge=>new Date(new Date().toDateString()+" "+ge),X=n.type=="time",W=n.type=="week";Y(D.value)&&N&&(T=X?S(N)>S(D.value):W?N>D.value:Z>new Date(D.value)),Y(q.value)&&N&&(P=X?S(N)<S(q.value):W?N<q.value:Z<new Date(q.value))}if((T||P)&&(le(!!T,D.message,q.message,de.max,de.min),!i))return I(A[f].message),A}if((_||k)&&!oe&&(Y(N)||d&&Array.isArray(N))){const T=Pe(_),P=Pe(k),D=!K(T.value)&&N.length>+T.value,q=!K(P.value)&&N.length<+P.value;if((D||q)&&(le(D,T.message,P.message),!i))return I(A[f].message),A}if(O&&!oe&&Y(N)){const{value:T,message:P}=Pe(O);if(Ye(T)&&!N.match(T)&&(A[f]={type:de.pattern,message:P,ref:n,...Q(de.pattern,P)},!i))return I(P),A}if(E){if(ie(E)){const T=await E(N,t),P=Lt(T,$);if(P&&(A[f]={...P,...Q(de.validate,P.message)},!i))return I(P.message),A}else if(H(E)){let T={};for(const P in E){if(!G(T)&&!i)break;const D=Lt(await E[P](N,t),$,P);D&&(T={...D,...Q(P,D.message)},I(D.message),i&&(A[f]=T))}if(!G(T)&&(A[f]={ref:$,...T},!i))return A}}return I(!0),A},We=e=>Array.isArray(e)?e:[e],ns=e=>Array.isArray(e)?e.filter(Boolean):[];function br(e,s){const t=s.slice(0,-1).length;let i=0;for(;i<t;){if(K(e)){e=void 0;break}e=e[s[i]],i++}return e}function jr(e){for(const s in e)if(e.hasOwnProperty(s)&&!M(e[s]))return!1;return!0}function B(e,s){if(Y(s)&&Object.prototype.hasOwnProperty.call(e,s))return delete e[s],e;const t=Array.isArray(s)?s:Ue(s)?[s]:Ze(s);if(t.some(n=>pt.includes(String(n))))return e;const i=t.length===1?e:br(e,t),o=t.length-1,d=t[o];return i&&delete i[d],o!==0&&(H(i)&&G(i)||Array.isArray(i)&&jr(i))&&B(e,t.slice(0,-1)),e}const os=e=>{const s={};for(const t of Object.keys(e))if(mt(e[t])&&e[t]!==null&&!je(e[t])){const i=os(e[t]);for(const o of Object.keys(i))s[`${t}.${o}`]=i[o]}else s[t]=e[t];return s},Sr=ee.createContext(null);Sr.displayName="HookFormContext";var Ht=()=>{let e=[];return{get observers(){return e},next:o=>{for(const d of e)d.next&&d.next(o)},subscribe:o=>(e.push(o),{unsubscribe:()=>{e=e.filter(d=>d!==o)}}),unsubscribe:()=>{e=[]}}};function ls(e,s){const t={};for(const i in e)if(e.hasOwnProperty(i)){const o=e[i],d=s[i];if(o&&H(o)&&d){const n=ls(o,d);H(n)&&(t[i]=n)}else e[i]&&(t[i]=d)}return t}var cs=e=>e.type==="select-multiple",wr=e=>gt(e)||Le(e),rt=e=>Ke(e)&&e.isConnected,Nr=e=>{for(const s in e)if(ie(e[s]))return!0;return!1};function ds(e){return Array.isArray(e)||H(e)&&!Nr(e)}function us(e){return!!(e&&"_f"in e)}function fs(e){return Array.isArray(e)?!e.some(s=>!M(s)):!Object.keys(e).length}function ot(e,s){Array.isArray(e)?e[s]=void 0:delete e[s]}function lt(e,s={},t){for(const i in e){const o=e[i],d=t&&t[i];ds(o)&&(!Array.isArray(o)||!us(d))?(s[i]=Array.isArray(o)?[]:{},lt(o,s[i],d),fs(s[i])&&ot(s,i)):M(o)||(s[i]=!0)}return s}function Ae(e,s,t,i){t||(t=lt(s,{},i));for(const o in e){const d=e[o],n=i&&i[o];ds(d)&&(!Array.isArray(d)||!us(n))?(M(s)||nt(t[o])?t[o]=lt(d,Array.isArray(d)?[]:{},n):Ae(d,K(s)?{}:s[o],t[o],n),fs(t[o])&&ot(t,o)):pe(d,s[o])?ot(t,o):t[o]=!0}return t}var ms=(e,{valueAsNumber:s,valueAsDate:t,setValueAs:i})=>M(e)?e:s?e===""?NaN:e&&+e:t&&Y(e)?new Date(e):i?i(e):e;function zt(e){const s=e.ref;return ht(s)?s.files:gt(s)?is(e.refs).value:cs(s)?[...s.selectedOptions].map(({value:t})=>t):Le(s)?as(e.refs).value:ms(M(s.value)?e.ref.value:s.value,e)}var Ar=(e,s,t,i)=>{const o={};for(const d of e){const n=y(s,d);n&&F(o,d,n._f)}return{criteriaMode:t,names:[...e],fields:o,shouldUseNativeValidation:i}},Re=e=>M(e)?e:Ye(e)?e.source:H(e)?Ye(e.value)?e.value.source:e.value:e;const Bt="AsyncFunction";var Tr=e=>{if(!e||!e.validate)return!1;if(ie(e.validate))return e.validate.constructor.name===Bt;if(H(e.validate)){for(const s in e.validate)if(e.validate[s].constructor.name===Bt)return!0}return!1},Er=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function qt(e,s,t){const i=y(e,t);if(i||Ue(t))return{error:i,name:t};const o=t.split(".");for(;o.length;){const d=o.join("."),n=y(s,d),u=y(e,d);if(n&&!Array.isArray(n)&&t!==d)return{name:t};if(u&&u.type)return{name:d,error:u};if(u&&u.root&&u.root.type)return{name:`${d}.root`,error:u.root};o.pop()}return{name:t}}var _r=(e,s,t,i)=>{t(e);const{name:o,...d}=e,n=Object.keys(d);return!n.length||i&&n.length>=Object.keys(s).length||n.find(u=>s[u]===(!i||ue.all))},kr=(e,s,t)=>!e||!s||e===s||We(e).some(i=>i&&(t?i===s||i.startsWith(s+"."):i.startsWith(s)||s.startsWith(i))),Pr=(e,s,t,i,o)=>o.isOnAll?!1:!t&&o.isOnTouch?!(s||e):(t?i.isOnBlur:o.isOnBlur)?!e:(t?i.isOnChange:o.isOnChange)?e:!0,Vr=(e,s)=>!ns(y(e,s)).length&&B(e,s);const Dr={mode:ue.onSubmit,reValidateMode:ue.onChange,shouldFocusError:!0},at="form",ps={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function Cr(e={}){let s={...Dr,...e},t={...z(ps),isLoading:ie(s.defaultValues),errors:s.errors||{},disabled:s.disabled||!1},i={},o=H(s.defaultValues)||H(s.values)?z(s.defaultValues||s.values)||{}:{},d=s.shouldUnregister?{}:z(o),n={action:!1,mount:!1,watch:!1,keepIsValid:!1},u={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set,registerName:new Set};const j={},_={};let k=0,U=qe(s.mode),R=qe(s.reValidateMode);const O={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},E={...O};let f={...E};const b={array:Ht(),state:Ht()};let ae=0;const N=s.criteriaMode===ue.all,$=(r,l)=>c=>{clearTimeout(_[r]),_[r]=setTimeout(l,c)},I=async r=>{if(!n.keepIsValid&&!s.disabled&&(E.isValid||f.isValid||r)){const l=++ae;let c;s.resolver?(c=G((await D()).errors),l===ae&&A()):c=await S({fields:i,onlyCheckValid:!0,eventType:ke.VALID}),l===ae&&c!==t.isValid&&b.state.next({isValid:c})}},A=(r,l)=>{!s.disabled&&(E.isValidating||E.validatingFields||f.isValidating||f.validatingFields)&&((r||Array.from(u.mount)).forEach(c=>{c&&(l?F(t.validatingFields,c,l):B(t.validatingFields,c))}),b.state.next({validatingFields:t.validatingFields,isValidating:!G(t.validatingFields)}))},ne=()=>{t.dirtyFields=Ae(o,d,void 0,i)},re=(r,l=[],c,m,p=!0,x=!0)=>{if(m&&c&&!s.disabled){if(n.action=!0,x&&Array.isArray(y(i,r))){const g=c(y(i,r),m.argA,m.argB);p&&F(i,r,g)}if(x&&Array.isArray(y(t.errors,r))){const g=c(y(t.errors,r),m.argA,m.argB);p&&F(t.errors,r,g),Vr(t.errors,r)}if((E.touchedFields||f.touchedFields)&&x&&Array.isArray(y(t.touchedFields,r))){const g=c(y(t.touchedFields,r),m.argA,m.argB);p&&F(t.touchedFields,r,g)}(E.dirtyFields||f.dirtyFields)&&ne(),b.state.next({name:r,isDirty:W(r,l),dirtyFields:t.dirtyFields,errors:t.errors,isValid:t.isValid})}else F(d,r,l)},he=(r,l)=>{F(t.errors,r,l),t.errors={...t.errors},b.state.next({errors:t.errors})},oe=r=>{t.errors=r,b.state.next({errors:t.errors,isValid:!1})},Q=r=>{const l=Ue(r)?[r]:Ze(r);let c=d,m=o;for(let p=0;p<l.length-1;p++){const x=l[p];if(c=K(c)?c:c[x],m=K(m)?m:m[x],c===null&&m!==null)return!0}return!1},le=(r,l,c,m)=>{const p=y(i,r);if(p){if(Q(r))return;const x=M(y(d,r)),g=y(d,r,M(c)?y(o,r):c);M(g)||m&&m.defaultChecked||l?F(d,r,l?g:zt(p._f)):we(r,g),n.mount&&!n.action&&(I(),x&&t.isDirty&&(E.isDirty||f.isDirty)&&(W()||(t.isDirty=!1,b.state.next({...t}))),e.shouldUnregister&&x&&!M(y(d,r))&&st(r,u)&&(n.watch=!0))}},T=(r,l,c,m,p)=>{let x=!1,g=!1;const v={name:r};if(!s.disabled||m===!0){if(!c||m){const w=pe(y(o,r),l);(E.isDirty||f.isDirty)&&(g=t.isDirty,t.isDirty=v.isDirty=!w||W(),x=g!==v.isDirty),g=!!y(t.dirtyFields,r),w!==t.isDirty?t.dirtyFields=Ae(o,d,void 0,i):w?B(t.dirtyFields,r):F(t.dirtyFields,r,!0),v.dirtyFields=t.dirtyFields,x=x||(E.dirtyFields||f.dirtyFields)&&g!==!w}if(c){const w=y(t.touchedFields,r);w||(F(t.touchedFields,r,c),v.touchedFields=t.touchedFields,x=x||(E.touchedFields||f.touchedFields)&&w!==c)}x&&p&&b.state.next(v)}return x?v:{}},P=(r,l,c,m)=>{const p=y(t.errors,r),x=(E.isValid||f.isValid)&&me(l)&&t.isValid!==l;if(s.delayError&&c?(j[r]=$(r,()=>he(r,c)),j[r](s.delayError)):(clearTimeout(_[r]),delete j[r],c?F(t.errors,r,c):B(t.errors,r),t.errors={...t.errors}),(c?!pe(p,c):p)||!G(m)||x){const g={...m,...x&&me(l)?{isValid:l}:{},errors:t.errors,name:r};t={...t,...g},b.state.next(g)}},D=async r=>(A(r,!0),await s.resolver(d,s.context,Ar(r||u.mount,i,s.criteriaMode,s.shouldUseNativeValidation))),q=async r=>{const{errors:l}=await D(r);if(A(r),r){for(const c of r){const m=y(l,c);m?u.array.has(c)&&H(m)&&!Object.keys(m).some(p=>!Number.isNaN(Number(p)))?Ot(t.errors,{[c]:m},c):F(t.errors,c,m):B(t.errors,c)}t.errors={...t.errors}}else t.errors=l;return l},Z=async({name:r,eventType:l})=>{if(e.validate){const c=await e.validate({formValues:d,formState:t,name:r,eventType:l});if(H(c))for(const m in c){const p=c[m];p&&ze(`${at}.${m}`,{message:Y(p.message)?p.message:"",type:p.type||de.validate})}else Y(c)||!c?ze(at,{message:c||"",type:de.validate}):_e(at);return c}return!0},S=async({fields:r,onlyCheckValid:l,name:c,eventType:m,context:p={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(p.runRootValidation=!0,!await Z({name:c,eventType:m})&&(p.valid=!1,l)))return p.valid;for(const x in r){const g=r[x];if(g){const{_f:v,...w}=g;if(v){const L=u.array.has(v.name),J=g._f&&Tr(g._f),xe=E.validatingFields||E.isValidating||f.validatingFields||f.isValidating;J&&xe&&A([v.name],!0);const ye=await Ut(g,u.disabled,d,N,s.shouldUseNativeValidation&&!l,L);if(J&&xe&&A([v.name]),ye[v.name]&&(p.valid=!1,l)||(!l&&(y(ye,v.name)?L?Ot(t.errors,ye,v.name):F(t.errors,v.name,ye[v.name]):B(t.errors,v.name)),e.shouldUseNativeValidation&&ye[v.name]))break}!G(w)&&await S({context:p,onlyCheckValid:l,fields:w,name:x,eventType:m})}}return p.valid},X=()=>{for(const r of u.unMount){const l=y(i,r);l&&(l._f.refs?l._f.refs.every(c=>!rt(c)):!rt(l._f.ref))&&Je(r)}u.unMount=new Set},W=(r,l)=>(r&&l&&F(d,r,l),!pe(n.mount?d:o,o)),ge=(r,l,c)=>vr(r,u,{...n.mount?d:M(l)?o:Y(r)?{[r]:l}:l},c,l),Ee=r=>ns(y(n.mount?d:o,r,s.shouldUnregister?y(o,r,[]):[])),we=(r,l,c={},m=!1,p=!1)=>{const x=y(i,r);let g=l;if(x){const v=x._f;v&&(!v.disabled&&F(d,r,ms(l,v)),g=Ke(v.ref)&&K(l)?"":l,cs(v.ref)?[...v.ref.options].forEach(w=>w.selected=g.includes(w.value)):v.refs?Le(v.ref)?v.refs.forEach(w=>{(!w.defaultChecked||!w.disabled)&&(Array.isArray(g)?w.checked=!!g.find(L=>L===w.value):w.checked=g===w.value||!!g)}):v.refs.forEach(w=>w.checked=w.value===g):ht(v.ref)?v.ref.value="":(v.ref.value=g,!v.ref.type&&!p&&b.state.next({name:r,values:m?d:z(d)})))}(c.shouldDirty||c.shouldTouch)&&T(r,g,c.shouldTouch,c.shouldDirty,!p),c.shouldValidate&&fe(r,{delayError:c.delayError})},He=(r,l,c,m=!1,p=!1)=>{for(const x in l){if(!l.hasOwnProperty(x))return;const g=l[x],v=r+"."+x,w=y(i,v);(u.array.has(r)||H(g)||w&&!w._f)&&!je(g)?He(v,g,c,m,p):we(v,g,c,m,p)}},Xe=(r,l,c,m,p=!1)=>{const x=y(i,r),g=u.array.has(r),v=m?l:z(l),w=y(d,r),L=pe(w,v);if(L||F(d,r,v),g)b.array.next({name:r,values:m?d:z(d)}),(E.isDirty||E.dirtyFields||f.isDirty||f.dirtyFields)&&c.shouldDirty&&(ne(),p||b.state.next({name:r,dirtyFields:t.dirtyFields,isDirty:W(r,v)}));else{const J=Array.isArray(v)&&!v.length||G(v);!x||x._f||K(v)||J?we(r,v,c,m,p):He(r,v,c,m,p)}if(!L&&!p){const J=st(r,u),xe=m?d:z(d);b.state.next({...J&&t,name:n.mount||J?r:void 0,values:xe})}},h=(r,l,c={})=>Xe(r,l,c,!1),V=(r,l={})=>{const c=ie(r)?r(d):r;if(!pe(d,c)){d={...d,...c};const m=os(c);for(const p of u.mount)p in m&&Xe(p,m[p],l,!0,!0);b.state.next({...t,name:void 0,type:void 0,...k?{values:d}:{}}),l.shouldValidate&&I()}},ce=async r=>{n.mount=!0;const l=r.target;let c=l.name,m=!0;const p=y(i,c),x=g=>{m=Number.isNaN(g)||je(g)&&isNaN(g.getTime())||pe(g,y(d,c,g))};if(p){let g,v;const w=l.type?zt(p._f):fr(r),L=r.type===ke.BLUR||r.type===ke.FOCUS_OUT,J=!Er(p._f)&&!e.validate&&!s.resolver&&!y(t.errors,c)&&!p._f.deps,xe=J||Pr(L,y(t.touchedFields,c),t.isSubmitted,R,U),ye=st(c,u,L);if(F(d,c,w),L){if(!l||!l.readOnly){p._f.onBlur&&p._f.onBlur(r);const Oe=j[c];Oe&&Oe(0)}}else p._f.onChange&&p._f.onChange(r);const Fe=T(c,w,L),Es=!G(Fe)||ye;if(!L&&b.state.next({name:c,type:r.type,...k?{values:z(d)}:{}}),xe)return(!J||!t.isValid)&&(E.isValid||f.isValid)&&(s.mode==="onBlur"?L&&I():L||I()),Es&&b.state.next({name:c,...ye?{}:Fe});if(!s.resolver&&e.validate&&await Z({name:c,eventType:r.type}),!L&&ye&&b.state.next({...t}),s.resolver){const{errors:Oe}=await D([c]);if(A([c]),x(w),!m){!G(Fe)&&b.state.next(Fe);return}const _s=qt(t.errors,i,c),Nt=qt(Oe,i,_s.name||c);g=Nt.error,c=Nt.name,v=G(Oe)}else A([c],!0),g=(await Ut(p,u.disabled,d,N,s.shouldUseNativeValidation))[c],A([c]),x(w),m&&(g?v=!1:(E.isValid||f.isValid)&&(v=await S({fields:i,onlyCheckValid:!0,name:c,eventType:r.type})));m&&(p._f.deps&&(!Array.isArray(p._f.deps)||p._f.deps.length>0)&&fe(p._f.deps),P(c,v,g,Fe))}},se=(r,l)=>{if(y(t.errors,l)&&r.focus)return r.focus(),1},fe=async(r,l={})=>{let c,m;const p=We(r);if(s.resolver){const x=await q(M(r)?r:p);c=G(x),m=r?!p.some(g=>y(x,g)):c}else r?(m=(await Promise.all(p.map(async x=>{const g=y(i,x);return await S({fields:g&&g._f?{[x]:g}:g,eventType:ke.TRIGGER})}))).every(Boolean),!(!m&&!t.isValid)&&I()):m=c=await S({fields:i,name:r,eventType:ke.TRIGGER});if(l.delayError&&s.delayError&&Y(r)){const x=y(t.errors,r);x?(B(t.errors,r),j[r]=$(r,()=>he(r,x)),j[r](s.delayError)):(clearTimeout(_[r]),delete j[r])}return b.state.next({...!Y(r)||(E.isValid||f.isValid)&&c!==t.isValid?{}:{name:r},...s.resolver||!r?{isValid:c}:{},errors:t.errors}),l.shouldFocus&&!m&&Me(i,se,r?p:u.mount),m},Ne=(r,l)=>{let c={...n.mount?d:o};return l&&(c=ls(l.dirtyFields?t.dirtyFields:t.touchedFields,c)),M(r)?c:Y(r)?y(c,r):r.map(m=>y(c,m))},Ce=(r,l)=>({invalid:!!y((l||t).errors,r),isDirty:!!y((l||t).dirtyFields,r),error:y((l||t).errors,r),isValidating:!!y(t.validatingFields,r),isTouched:!!y((l||t).touchedFields,r)}),_e=r=>{const l=r?We(r):void 0;l?.forEach(c=>B(t.errors,c)),l?l.forEach(c=>{b.state.next({name:c,errors:t.errors})}):b.state.next({errors:{}})},ze=(r,l,c)=>{const m=(y(i,r,{_f:{}})._f||{}).ref,p=y(t.errors,r)||{},{ref:x,message:g,type:v,...w}=p;F(t.errors,r,{...w,...l,ref:m}),b.state.next({name:r,errors:t.errors,isValid:!1}),c&&c.shouldFocus&&m&&m.focus&&m.focus()},js=(r,l)=>{if(ie(r)){k++;const{unsubscribe:c}=b.state.subscribe({next:p=>"values"in p&&r(p.values||ge(void 0,l),p)});let m=!1;return{unsubscribe:()=>{m||(m=!0,k--,c())}}}return ge(r,l,!0)},yt=r=>{var l;const c=!!(!((l=r.formState)===null||l===void 0)&&l.values);c&&k++;const{unsubscribe:m}=b.state.subscribe({next:x=>{if(kr(r.name,x.name,r.exact)&&_r(x,r.formState||E,Ts,r.reRenderRoot)){const g={...d};r.callback({values:g,...t,...x,defaultValues:o})}}});if(!c)return m;let p=!1;return()=>{p||(p=!0,k--,m())}},Ss=r=>(n.mount=!0,f={...f,...r.formState},yt({...r,formState:{...O,...r.formState}})),Je=(r,l={})=>{for(const c of r?We(r):u.mount)u.mount.delete(c),u.array.delete(c),l.keepValue||(B(i,c),B(d,c)),!l.keepError&&B(t.errors,c),!l.keepDirty&&B(t.dirtyFields,c),!l.keepTouched&&B(t.touchedFields,c),!l.keepIsValidating&&B(t.validatingFields,c),!s.shouldUnregister&&!l.keepDefaultValue&&B(o,c);b.state.next({values:z(d)}),b.state.next({...t,...l.keepDirty?{isDirty:W()}:{}}),!l.keepIsValid&&I()},vt=({disabled:r,name:l})=>{if(me(r)&&n.mount||r||u.disabled.has(l)){const p=u.disabled.has(l)!==!!r;r?u.disabled.add(l):u.disabled.delete(l),p&&n.mount&&!n.action&&I()}},et=(r,l={})=>{let c=y(i,r);const m=me(l.disabled)||me(s.disabled),p=!u.registerName.has(r)&&c&&c._f&&!c._f.mount;return F(i,r,{...c||{},_f:{...c&&c._f?c._f:{ref:{name:r}},name:r,mount:!0,...l}}),u.mount.add(r),c&&!p?vt({disabled:me(l.disabled)?l.disabled:s.disabled,name:r}):le(r,!0,l.value),{...m?{disabled:l.disabled||s.disabled}:{},...s.progressive?{required:!!l.required,min:Re(l.min),max:Re(l.max),minLength:Re(l.minLength),maxLength:Re(l.maxLength),pattern:Re(l.pattern)}:{},name:r,onChange:ce,onBlur:ce,ref:x=>{if(x){u.registerName.add(r),et(r,l),u.registerName.delete(r),c=y(i,r);const g=M(x.value)&&x.querySelectorAll&&x.querySelectorAll("input,select,textarea")[0]||x,v=wr(g),w=c._f.refs||[];if(v?w.find(L=>L===g):g===c._f.ref)return;F(i,r,{_f:{...c._f,...v?{refs:[...w.filter(rt),g,...Array.isArray(y(o,r))?[{}]:[]],ref:{type:g.type,name:r}}:{ref:g}}}),le(r,!1,void 0,g)}else c=y(i,r,{}),c._f&&(c._f.mount=!1),(s.shouldUnregister||l.shouldUnregister)&&!(mr(u.array,r)&&n.action)&&u.unMount.add(r)}}},tt=()=>s.shouldFocusError&&!s.shouldUseNativeValidation&&Me(i,se,u.mount),ws=r=>{me(r)&&(b.state.next({disabled:r}),Me(i,(l,c)=>{const m=y(i,c);m&&(l.disabled=m._f.disabled||r,Array.isArray(m._f.refs)&&m._f.refs.forEach(p=>{p.disabled=m._f.disabled||r}))},0,!1))},bt=(r,l)=>async c=>{let m;c&&(c.preventDefault&&c.preventDefault(),c.persist&&c.persist());let p=z(d);if(b.state.next({isSubmitting:!0}),s.resolver){const{errors:x,values:g}=await D();A(),t.errors=x,p=z(g)}else await S({fields:i,eventType:ke.SUBMIT});if(u.disabled.size)for(const x of u.disabled)B(p,x);if(B(t.errors,rs),G(t.errors)){b.state.next({errors:{}});try{await r(p,c)}catch(x){m=x}}else l&&await l({...t.errors},c),tt(),setTimeout(tt);if(b.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:G(t.errors)&&!m,submitCount:t.submitCount+1,errors:t.errors}),m)throw m},Ns=(r,l={})=>{y(i,r)&&(M(l.defaultValue)?h(r,z(y(o,r))):(h(r,l.defaultValue),F(o,r,z(l.defaultValue))),l.keepTouched||B(t.touchedFields,r),l.keepDirty||(B(t.dirtyFields,r),t.isDirty=l.defaultValue?W(r,z(y(o,r))):W()),l.keepError||(B(t.errors,r),E.isValid&&I()),b.state.next({...t}))},jt=(r,l={})=>{const c=r?z(r):o,m=z(c),p=G(r),x=m,g=i;if(l.keepDefaultValues||(o=c),!l.keepValues){if(l.keepDirtyValues){const v=new Set([...u.mount,...Object.keys(Ae(o,d,void 0,g))]);for(const w of Array.from(v)){const L=y(t.dirtyFields,w),J=y(d,w),xe=y(x,w);L&&!M(J)?F(x,w,J):!L&&!M(xe)&&h(w,xe)}}else{if(Qe&&M(r))for(const v of u.mount){const w=y(i,v);if(w&&w._f){const L=Array.isArray(w._f.refs)?w._f.refs[0]:w._f.ref;if(Ke(L)){const J=L.closest("form");if(J){J.reset();break}}}}if(l.keepFieldsRef)for(const v of u.mount)h(v,y(x,v));else i={}}if(s.shouldUnregister){if(d=l.keepDefaultValues?z(o):{},l.keepFieldsRef)for(const v of u.mount)F(d,v,y(x,v))}else d=z(x);b.array.next({values:{...x}}),b.state.next({name:void 0,type:void 0,values:{...x}})}u={mount:l.keepDirtyValues?u.mount:new Set,unMount:new Set,array:new Set,registerName:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},n.mount=!E.isValid||!!l.keepIsValid||!!l.keepDirtyValues||!s.shouldUnregister&&!G(x),n.watch=!!s.shouldUnregister,n.keepIsValid=!!l.keepIsValid,n.action=!1,l.keepErrors||(t.errors={}),b.state.next({submitCount:l.keepSubmitCount?t.submitCount:0,isDirty:p?!1:l.keepDirty?t.isDirty:l.keepValues?W():!!(l.keepDefaultValues&&!pe(r,o)),isSubmitted:l.keepIsSubmitted?t.isSubmitted:!1,dirtyFields:p?{}:l.keepDirtyValues?l.keepDefaultValues&&d?Ae(o,d,void 0,g):t.dirtyFields:l.keepDefaultValues&&r?Ae(o,r,void 0,g):l.keepDirty?t.dirtyFields:{},touchedFields:l.keepTouched?t.touchedFields:{},errors:l.keepErrors?t.errors:{},isSubmitSuccessful:l.keepIsSubmitSuccessful?t.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:o})},St=(r,l)=>jt(ie(r)?r(d):r,{...s.resetOptions,...l}),As=(r,l={})=>{const c=y(i,r),m=c&&c._f;if(m){const p=m.refs?m.refs[0]:m.ref;p.focus&&setTimeout(()=>{p.focus(),l.shouldSelect&&ie(p.select)&&p.select()})}},Ts=r=>{const{name:l,type:c,values:m,...p}=r;t={...t,...p}},wt={control:{register:et,unregister:Je,getFieldState:Ce,handleSubmit:bt,setError:ze,_subscribe:yt,_runSchema:D,_updateIsValidating:A,_focusError:tt,_getWatch:ge,_getDirty:W,_setValid:I,_setFieldArray:re,_setDisabledField:vt,_setErrors:oe,_getFieldArray:Ee,_reset:jt,_resetDefaultValues:()=>ie(s.defaultValues)&&s.defaultValues().then(r=>{St(r,s.resetOptions),b.state.next({isLoading:!1})}),_removeUnmounted:X,_disableForm:ws,_subjects:b,_proxyFormState:E,get _fields(){return i},get _formValues(){return d},get _state(){return n},set _state(r){n=r},get _defaultValues(){return o},get _names(){return u},set _names(r){u=r},get _formState(){return t},get _options(){return s},set _options(r){s={...s,...r},U=qe(s.mode),R=qe(s.reValidateMode)}},subscribe:Ss,trigger:fe,register:et,handleSubmit:bt,watch:js,setValue:h,setValues:V,getValues:Ne,reset:St,resetField:Ns,resetDefaultValues:(r,l={})=>{if(o=z(r),!l.keepDirty){const c=Ae(o,d,void 0,i);t.dirtyFields=c,t.isDirty=!G(c)}l.keepIsValid||I(),b.state.next({...t,defaultValues:o})},clearErrors:_e,unregister:Je,setError:ze,setFocus:As,getFieldState:Ce};return{...wt,formControl:wt}}function Fr(e={}){const s=ee.useRef(void 0),t=ee.useRef(void 0),i=ee.useRef(e.formControl),[o,d]=ee.useState(()=>({...z(ps),isLoading:ie(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1,defaultValues:ie(e.defaultValues)?void 0:e.defaultValues}));if(!s.current||e.formControl&&i.current!==e.formControl)if(i.current=e.formControl,e.formControl)s.current={...e.formControl,formState:o},e.defaultValues&&!ie(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:u,...j}=Cr(e);s.current={...j,formState:o}}const n=s.current.control;return n._options=e,yr(()=>{const u=n._subscribe({formState:n._proxyFormState,callback:()=>d({...n._formState,defaultValues:n._defaultValues}),reRenderRoot:!0});return d(j=>({...j,isReady:!0})),n._formState.isReady=!0,u},[n]),ee.useEffect(()=>n._disableForm(e.disabled),[n,e.disabled]),ee.useEffect(()=>{e.mode&&(n._options.mode=e.mode),e.reValidateMode&&(n._options.reValidateMode=e.reValidateMode)},[n,e.mode,e.reValidateMode]),ee.useEffect(()=>{e.errors&&(n._setErrors(e.errors),n._focusError())},[n,e.errors]),ee.useEffect(()=>{e.shouldUnregister&&n._subjects.state.next({values:n._getWatch()})},[n,e.shouldUnregister]),ee.useEffect(()=>{if(n._proxyFormState.isDirty){const u=n._getDirty();u!==o.isDirty&&n._subjects.state.next({isDirty:u})}},[n,o.isDirty]),ee.useEffect(()=>{var u;e.values&&!pe(e.values,t.current)?(n._reset(e.values,{keepFieldsRef:!0,...n._options.resetOptions}),!((u=n._options.resetOptions)===null||u===void 0)&&u.keepIsValid||n._setValid(),t.current=e.values,d(j=>({...j}))):n._resetDefaultValues()},[n,e.values]),ee.useEffect(()=>{n._state.mount||(n._setValid(),n._state.mount=!0),n._state.watch&&(n._state.watch=!1,n._subjects.state.next({...n._formState})),n._removeUnmounted()}),s.current.formState=ee.useMemo(()=>xr(o,n),[n,o]),s.current}const $t=(e,s,t)=>{if(e&&"reportValidity"in e){const i=y(t,s);e.setCustomValidity(i&&i.message||""),e.reportValidity()}},ct=(e,s)=>{for(const t in s.fields){const i=s.fields[t];i&&i.ref&&"reportValidity"in i.ref?$t(i.ref,t,e):i&&i.refs&&i.refs.forEach(o=>$t(o,t,e))}},Wt=(e,s)=>{s.shouldUseNativeValidation&&ct(e,s);const t={};for(const i in e){const o=y(s.fields,i),d=Object.assign(e[i]||{},{ref:o&&o.ref});if(Or(s.names||Object.keys(e),i)){const n=Object.assign({},y(t,i));F(n,"root",d),F(t,i,n)}else F(t,i,d)}return t},Or=(e,s)=>{const t=Gt(s).replace(/[.*+?^${}()|\\]/g,"\\$&");return e.some(i=>Gt(i).match(`^${t}\\.\\d+`))};function Gt(e){return e.replace(/[\[\]]/g,"")}function hs(e,s,t){function i(u,j){var _;Object.defineProperty(u,"_zod",{value:u._zod??{},enumerable:!1}),(_=u._zod).traits??(_.traits=new Set),u._zod.traits.add(e),s(u,j);for(const k in n.prototype)k in u||Object.defineProperty(u,k,{value:n.prototype[k].bind(u)});u._zod.constr=n,u._zod.def=j}const o=t?.Parent??Object;class d extends o{}Object.defineProperty(d,"name",{value:e});function n(u){var j;const _=t?.Parent?new d:this;i(_,u),(j=_._zod).deferred??(j.deferred=[]);for(const k of _._zod.deferred)k();return _}return Object.defineProperty(n,"init",{value:i}),Object.defineProperty(n,Symbol.hasInstance,{value:u=>t?.Parent&&u instanceof t.Parent?!0:u?._zod?.traits?.has(e)}),Object.defineProperty(n,"name",{value:e}),n}class Ir extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const Rr={};function gs(e){return Rr}function Mr(e,s){return typeof s=="bigint"?s.toString():s}const xs=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function $e(e){return typeof e=="string"?e:e?.message}function ys(e,s,t){const i={...e,path:e.path??[]};if(!e.message){const o=$e(e.inst?._zod.def?.error?.(e))??$e(s?.error?.(e))??$e(t.customError?.(e))??$e(t.localeError?.(e))??"Invalid input";i.message=o}return delete i.inst,delete i.continue,s?.reportInput||delete i.input,i}const vs=(e,s)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:s,enumerable:!1}),Object.defineProperty(e,"message",{get(){return JSON.stringify(s,Mr,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Lr=hs("$ZodError",vs),bs=hs("$ZodError",vs,{Parent:Error}),Ur=e=>(s,t,i,o)=>{const d=i?Object.assign(i,{async:!1}):{async:!1},n=s._zod.run({value:t,issues:[]},d);if(n instanceof Promise)throw new Ir;if(n.issues.length){const u=new(o?.Err??e)(n.issues.map(j=>ys(j,d,gs())));throw xs(u,o?.callee),u}return n.value},Hr=Ur(bs),zr=e=>async(s,t,i,o)=>{const d=i?Object.assign(i,{async:!0}):{async:!0};let n=s._zod.run({value:t,issues:[]},d);if(n instanceof Promise&&(n=await n),n.issues.length){const u=new(o?.Err??e)(n.issues.map(j=>ys(j,d,gs())));throw xs(u,o?.callee),u}return n.value},Br=zr(bs);function dt(){return dt=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var t=arguments[s];for(var i in t)({}).hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},dt.apply(null,arguments)}function Kt(e,s){try{var t=e()}catch(i){return s(i)}return t&&t.then?t.then(void 0,s):t}function qr(e,s){for(var t={};e.length;){var i=e[0],o=i.code,d=i.message,n=i.path.join(".");if(!t[n])if("unionErrors"in i){var u=i.unionErrors[0].errors[0];t[n]={message:u.message,type:u.code}}else t[n]={message:d,type:o};if("unionErrors"in i&&i.unionErrors.forEach(function(k){return k.errors.forEach(function(U){return e.push(U)})}),s){var j=t[n].types,_=j&&j[i.code];t[n]=xt(n,s,t,o,_?[].concat(_,i.message):i.message)}e.shift()}return t}function $r(e,s){for(var t={},i=function(){var o=e[0],d=o.code,n=o.message,u=o.path.join(".");if(!t[u])if(o.code==="invalid_union"&&o.errors.length>0){var j=o.errors[0][0];t[u]={message:j.message,type:j.code}}else t[u]={message:n,type:d};if(o.code==="invalid_union"&&o.errors.forEach(function(U){return U.forEach(function(R){return e.push(dt({},R,{path:[].concat(o.path,R.path)}))})}),s){var _=t[u].types,k=_&&_[o.code];t[u]=xt(u,s,t,d,k?[].concat(k,o.message):o.message)}e.shift()};e.length;)i();return t}function Wr(e,s,t){if(t===void 0&&(t={}),(function(i){return"_def"in i&&typeof i._def=="object"&&"typeName"in i._def})(e))return function(i,o,d){try{return Promise.resolve(Kt(function(){return Promise.resolve(e[t.mode==="sync"?"parse":"parseAsync"](i,s)).then(function(n){return d.shouldUseNativeValidation&&ct({},d),{errors:{},values:t.raw?Object.assign({},i):n}})},function(n){if((function(u){return Array.isArray(u?.issues)})(n))return{values:{},errors:Wt(qr(n.errors,!d.shouldUseNativeValidation&&d.criteriaMode==="all"),d)};throw n}))}catch(n){return Promise.reject(n)}};if((function(i){return"_zod"in i&&typeof i._zod=="object"})(e))return function(i,o,d){try{return Promise.resolve(Kt(function(){return Promise.resolve((t.mode==="sync"?Hr:Br)(e,i,s)).then(function(n){return d.shouldUseNativeValidation&&ct({},d),{errors:{},values:t.raw?Object.assign({},i):n}})},function(n){if((function(u){return u instanceof Lr})(n))return{values:{},errors:Wt($r(n.issues,!d.shouldUseNativeValidation&&d.criteriaMode==="all"),d)};throw n}))}catch(n){return Promise.reject(n)}};throw new Error("Invalid input: not a Zod schema")}const Gr=e=>{const s=ft(),{pushError:t}=Ds(),{data:i}=Xt({...Jt(),staleTime:1/0}),o=i?.accounts.find(j=>j.accountId===e)?.composeLanguages,d=C.useMemo(()=>o&&o.length>0?[...o]:Cs(navigator.languages),[o]),n=Se({...es(),onSuccess:()=>{s.invalidateQueries({queryKey:Te()})},onError:j=>{t(Fs("Couldn't save languages","The writing languages weren't saved.",j))}}),u=C.useCallback(j=>{e&&n.mutate({path:{accountId:e},body:{composeLanguages:j}})},[e,n]);return{languages:d,setLanguages:u,isSaving:n.isPending}},Kr=e=>e.authType==="oauthMicrosoft",Yr="••••••••••",Qr=e=>{const s=e.smtpUsername?.trim();return s?s!==e.username:!1},Zr=Ms({email:be().email().min(1,"Email is required"),displayName:be().optional(),username:be().optional(),password:be().optional(),imapHost:be().min(1,"IMAP host is required"),imapPort:Et.number().int().min(1).max(65535),imapTls:Ie(),imapStartTls:Ie(),smtpHost:be().optional(),smtpPort:Et.number().int().min(1).max(65535).optional(),smtpTls:Ie().optional(),smtpStartTls:Ie().optional(),smtpUsername:be().optional(),smtpPassword:be().optional(),useDifferentSmtpCreds:Ie().optional()}),Xr=({isOpen:e,onClose:s,account:t,focusSmtp:i})=>{const o=ft(),d=!!t,[n,u]=C.useState(!1),[j,_]=C.useState(""),[k,U]=C.useState(!1),R=Vt(j),O=!!R&&!k,E=C.useRef(null),f=Fr({resolver:Wr(Zr),defaultValues:{email:"",displayName:"",username:"",password:"",imapHost:"",imapPort:993,imapTls:!0,imapStartTls:!1,smtpHost:"",smtpPort:587,smtpTls:!1,smtpStartTls:!0,useDifferentSmtpCreds:!1}});C.useEffect(()=>{if(t){const h=Qr(t);f.reset({email:t.email,displayName:t.displayName||"",username:t.username||"",password:Yr,imapHost:t.imapHost,imapPort:t.imapPort,imapTls:t.imapTls,imapStartTls:t.imapStartTls,smtpHost:t.smtpHost||"",smtpPort:t.smtpPort||587,smtpTls:t.smtpTls||!1,smtpStartTls:t.smtpStartTls||!0,smtpUsername:h&&t.smtpUsername||"",smtpPassword:"",useDifferentSmtpCreds:h}),u(!1)}else f.reset({email:"",displayName:"",username:"",password:"",imapHost:"",imapPort:993,imapTls:!0,imapStartTls:!1,smtpHost:"",smtpPort:587,smtpTls:!1,smtpStartTls:!0,useDifferentSmtpCreds:!1}),u(!1)},[t,f]);const b=Se({...Os()}),ae=Se({...Is(),onSuccess:()=>{o.invalidateQueries({queryKey:Te()}),s()}}),N=Se({...es(),onSuccess:()=>{o.invalidateQueries({queryKey:Te()}),s()}}),$=()=>{const h=f.getValues(),V=d&&!n;b.mutate({body:{accountId:V?t?.accountId:void 0,username:h.username||h.email,password:V?void 0:h.password||void 0,imapHost:h.imapHost,imapPort:Number(h.imapPort),imapTls:h.imapTls,imapStartTls:h.imapStartTls}})},I=()=>{const h=f.getValues(),V=d&&!n;b.mutate({body:{accountId:V?t?.accountId:void 0,username:h.username||h.email,password:V?void 0:h.password||void 0,imapHost:h.imapHost,imapPort:Number(h.imapPort),imapTls:h.imapTls,imapStartTls:h.imapStartTls,smtpHost:h.smtpHost||void 0,smtpPort:h.smtpPort?Number(h.smtpPort):void 0,smtpTls:h.smtpTls,smtpStartTls:h.smtpStartTls,smtpUsername:h.useDifferentSmtpCreds?h.smtpUsername:void 0,smtpPassword:h.useDifferentSmtpCreds?h.smtpPassword:void 0}})},A=f.handleSubmit(h=>{if(!d&&!h.password){f.setError("password",{message:"Password is required"});return}const V=rr({imapHost:h.imapHost,smtpHost:h.smtpHost,smtpPort:h.smtpPort,smtpTls:h.smtpTls,smtpStartTls:h.smtpStartTls});V&&(f.setValue("smtpHost",V.smtpHost),f.setValue("smtpPort",V.smtpPort),f.setValue("smtpTls",V.smtpTls),f.setValue("smtpStartTls",V.smtpStartTls));const ce=V?.smtpHost??h.smtpHost,se=V?.smtpPort??h.smtpPort,fe=V?.smtpTls??h.smtpTls,Ne=V?.smtpStartTls??h.smtpStartTls,Ce={email:h.email,displayName:h.displayName?.trim()||void 0,username:h.username||void 0,imapHost:h.imapHost,imapPort:Number(h.imapPort),imapTls:h.imapTls,imapStartTls:h.imapStartTls,smtpHost:ce||void 0,smtpPort:se?Number(se):void 0,smtpTls:fe,smtpStartTls:Ne,smtpUsername:h.useDifferentSmtpCreds&&h.smtpUsername||void 0,smtpPassword:h.useDifferentSmtpCreds&&h.smtpPassword||void 0};if(d&&t){const _e={...Ce,password:n?h.password:void 0};N.mutate({path:{accountId:t.accountId},body:_e})}else{const _e={...Ce,password:h.password};ae.mutate({body:_e})}}),ne=ae.isPending||N.isPending,{signature:re,setSignature:he,isSaving:oe}=sr(t?.accountId),[Q,le]=C.useState(re.plainText),{languages:T,setLanguages:P,isSaving:D}=Gr(t?.accountId),q=a.jsxs("section",{children:[a.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Writing languages"}),a.jsx(dr,{value:T,onChange:P,busy:D})]});C.useEffect(()=>{le(re.plainText)},[re.plainText]),C.useEffect(()=>{if(!e||!i)return;const h=E.current;if(!h)return;const V=window.setTimeout(()=>{h.scrollIntoView({behavior:"smooth",block:"start"})},250);return()=>window.clearTimeout(V)},[e,i]);const Z=C.useCallback(()=>{Q!==re.plainText&&he(Q,Q)},[Q,re.plainText,he]),S=h=>{const{tls:V,startTls:ce}=Be(h);f.setValue("imapTls",V),f.setValue("imapStartTls",ce);const se=f.getValues("imapPort");(se===993||se===143)&&f.setValue("imapPort",h==="tls"?993:143)},X=h=>{const{tls:V,startTls:ce}=Be(h);f.setValue("smtpTls",V),f.setValue("smtpStartTls",ce);const se=f.getValues("smtpPort");if(se===465||se===587||se===25){const Ne=h==="tls"?465:h==="starttls"?587:25;f.setValue("smtpPort",Ne)}},W=()=>{const h=f.getValues("imapHost");f.setValue("smtpHost",ar(h)),f.setValue("smtpTls",!1),f.setValue("smtpStartTls",!0),f.setValue("smtpPort",587)},ge=h=>{_(h),U(!1);const V=Vt(h);if(!V)return;const ce=Be(V.imap.security);f.setValue("imapHost",V.imap.host),f.setValue("imapPort",V.imap.port),f.setValue("imapTls",ce.tls),f.setValue("imapStartTls",ce.startTls);const se=Be(V.smtp.security);f.setValue("smtpHost",V.smtp.host),f.setValue("smtpPort",V.smtp.port),f.setValue("smtpTls",se.tls),f.setValue("smtpStartTls",se.startTls);const fe=f.getValues("email").trim(),Ne=f.getValues("username")?.trim();fe&&!Ne&&f.setValue("username",fe)},Ee=R?.passwordHelp.text,we=Dt(b.data?.imapError,Ee),He=Dt(b.data?.smtpError,Ee);return(t?Kr(t):!1)&&d?a.jsx(Ct,{isOpen:e,onClose:s,title:"Edit Account",footer:a.jsx(te,{type:"button",variant:"secondary",onClick:s,children:"Close"}),children:a.jsxs("div",{className:"space-y-6",children:[a.jsxs("section",{children:[a.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Microsoft 365 Account"}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"rounded-md border border-line bg-surface-sunken px-3 py-2.5 text-sm text-fg-muted",children:[a.jsx("span",{className:"block text-2xs font-medium uppercase tracking-wider text-fg-subtle mb-1",children:"Email"}),a.jsx("span",{className:"text-fg",children:t?.email})]}),a.jsxs("div",{className:"rounded-md border border-line bg-surface-sunken px-3 py-2.5 text-sm text-fg-muted",children:[a.jsx("span",{className:"block text-2xs font-medium uppercase tracking-wider text-fg-subtle mb-1",children:"Authentication"}),a.jsx("span",{className:"text-fg",children:"Microsoft OAuth (XOAUTH2)"})]}),a.jsx("p",{className:"text-xs text-fg-muted",children:"Server settings are managed automatically for Microsoft 365 accounts. To update credentials, use the Reconnect button."})]})]}),d&&a.jsxs("section",{children:[a.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Signature"}),a.jsx("div",{className:"space-y-3",children:a.jsxs("div",{children:[a.jsx("label",{htmlFor:"email-sig-view",className:"text-sm font-medium mb-1.5 block",children:"Email Signature"}),a.jsx("textarea",{id:"email-sig-view",value:Q,onChange:h=>le(h.target.value),onBlur:Z,rows:5,className:"w-full px-3 py-2 border border-line rounded-md bg-surface-sunken text-sm text-fg placeholder:text-fg-subtle focus-within:border-line-strong focus-within:ring-2 focus-within:ring-ring/30 transition-colors resize-y outline-none",placeholder:"Enter your email signature..."}),a.jsx("p",{className:"text-xs text-fg-muted mt-1",children:oe?"Saving signature...":"This signature will be appended to new emails."})]})})]}),d&&q]})}):a.jsx(Ct,{isOpen:e,onClose:s,title:d?"Edit Account":"Add Account",footer:a.jsxs(a.Fragment,{children:[a.jsx(te,{type:"button",variant:"secondary",onClick:s,children:"Cancel"}),a.jsx(te,{type:"submit",form:"account-form",variant:"primary",disabled:ne,children:ne?"Saving...":"Save Account"})]}),children:a.jsxs("form",{id:"account-form",onSubmit:A,className:"space-y-6",children:[a.jsxs("section",{children:[a.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Account Information"}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"account-provider",className:"text-sm font-medium mb-1.5 block",children:"Provider"}),a.jsxs(Rs,{id:"account-provider",value:j,onChange:h=>ge(h.target.value),children:[a.jsx("option",{value:"",children:"Custom / other"}),Xs.map(h=>a.jsx("option",{value:h.id,children:h.label},h.id))]}),a.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Pick your email provider to fill in server settings automatically, or choose Custom to enter them by hand."})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"account-email",className:"text-sm font-medium mb-1.5 block",children:"Email Address"}),a.jsx(ve,{id:"account-email",...f.register("email"),placeholder:"alice@example.com"}),f.formState.errors.email&&a.jsx("p",{className:"text-sm text-danger mt-1",children:f.formState.errors.email.message})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"account-displayName",className:"text-sm font-medium mb-1.5 block",children:"Display name (optional)"}),a.jsx(ve,{id:"account-displayName",...f.register("displayName"),placeholder:"Alice"}),a.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"What to call this account in Remit. Leave blank to use a name derived from the address."})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"account-username",className:"text-sm font-medium mb-1.5 block",children:"Username"}),a.jsx(ve,{id:"account-username",...f.register("username"),placeholder:"Same as email if empty"})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"account-password",className:"text-sm font-medium mb-1.5 block",children:"Password"}),a.jsx(At,{id:"account-password",...f.register("password",{onChange:()=>u(!0)}),onFocus:()=>{d&&!n&&(f.setValue("password",""),u(!0))},placeholder:d?"Leave empty to keep current":""}),f.formState.errors.password&&a.jsx("p",{className:"text-sm text-danger mt-1",children:f.formState.errors.password.message}),R&&a.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[R.passwordHelp.text," ",a.jsx("a",{href:R.passwordHelp.url,target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline",children:"Get an app password"})]})]})]})]}),a.jsxs("section",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider",children:"Incoming Mail (IMAP)"}),R&&a.jsx("button",{type:"button",onClick:()=>U(h=>!h),className:"text-xs text-fg-muted hover:text-fg transition-colors",children:k?"Use preset settings":"Advanced"})]}),O&&a.jsxs("p",{className:"text-xs text-fg-muted mb-3",children:["Server settings are pre-filled for ",R?.label," and locked. Choose Advanced to edit them by hand."]}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"imap-host",className:"text-sm font-medium mb-1.5 block",children:"Server"}),a.jsx(ve,{id:"imap-host",...f.register("imapHost"),readOnly:O,placeholder:"imap.example.com"}),f.formState.errors.imapHost&&a.jsx("p",{className:"text-sm text-danger mt-1",children:f.formState.errors.imapHost.message})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"imap-port",className:"text-sm font-medium mb-1.5 block",children:"Port"}),a.jsx(ve,{id:"imap-port",...f.register("imapPort"),readOnly:O,type:"number"})]}),a.jsxs("div",{children:[a.jsx("span",{className:"text-sm font-medium mb-1.5 block",children:"Security"}),a.jsxs("div",{className:"space-y-1.5 mt-2",children:[a.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[a.jsx("input",{type:"radio",disabled:O,checked:f.watch("imapTls"),onChange:()=>S("tls")}),"TLS (Port 993)"]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[a.jsx("input",{type:"radio",disabled:O,checked:!f.watch("imapTls")&&f.watch("imapStartTls"),onChange:()=>S("starttls")}),"STARTTLS (Port 143)"]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[a.jsx("input",{type:"radio",disabled:O,checked:!f.watch("imapTls")&&!f.watch("imapStartTls"),onChange:()=>S("none")}),"None (Unencrypted)"]})]})]})]}),a.jsx(te,{type:"button",variant:"secondary",onClick:$,disabled:b.isPending,className:"w-full",icon:b.isPending?a.jsx(it,{className:"size-4 animate-spin"}):void 0,children:b.isPending?"Testing...":"Test IMAP Connection"}),b.data&&a.jsxs("div",{className:Ge("p-2 rounded-md text-sm",b.data.imapSuccess?"bg-positive/10 text-positive":"bg-danger-soft text-danger"),children:[b.data.imapSuccess?a.jsx(Tt,{className:"inline size-4 mr-1"}):a.jsx(De,{className:"inline size-4 mr-1"}),b.data.imapSuccess?"IMAP Connected":we]})]})]}),a.jsxs("section",{ref:E,"data-testid":"smtp-section",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider",children:"Outgoing Mail (SMTP)"}),!O&&a.jsx("button",{type:"button",onClick:W,disabled:!f.watch("imapHost"),className:"text-xs text-fg-muted hover:text-fg transition-colors disabled:opacity-50",children:"Pre-fill from IMAP"})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"smtp-host",className:"text-sm font-medium mb-1.5 block",children:"Server"}),a.jsx(ve,{id:"smtp-host",...f.register("smtpHost"),readOnly:O,placeholder:"smtp.example.com"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"smtp-port",className:"text-sm font-medium mb-1.5 block",children:"Port"}),a.jsx(ve,{id:"smtp-port",...f.register("smtpPort"),readOnly:O,type:"number"})]}),a.jsxs("div",{children:[a.jsx("span",{className:"text-sm font-medium mb-1.5 block",children:"Security"}),a.jsxs("div",{className:"space-y-1.5 mt-2",children:[a.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[a.jsx("input",{type:"radio",disabled:O,checked:f.watch("smtpTls")===!0,onChange:()=>X("tls")}),"TLS (Port 465)"]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[a.jsx("input",{type:"radio",disabled:O,checked:!f.watch("smtpTls")&&f.watch("smtpStartTls")===!0,onChange:()=>X("starttls")}),"STARTTLS (Port 587)"]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[a.jsx("input",{type:"radio",disabled:O,checked:!f.watch("smtpTls")&&!f.watch("smtpStartTls"),onChange:()=>X("none")}),"None (Unencrypted)"]})]})]})]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[a.jsx("input",{type:"checkbox",...f.register("useDifferentSmtpCreds")}),"Use different credentials for SMTP"]}),f.watch("useDifferentSmtpCreds")&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"smtp-username",className:"text-sm font-medium mb-1.5 block",children:"SMTP Username"}),a.jsx(ve,{id:"smtp-username",...f.register("smtpUsername")})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"smtp-password",className:"text-sm font-medium mb-1.5 block",children:"SMTP Password"}),a.jsx(At,{id:"smtp-password",...f.register("smtpPassword")})]})]}),a.jsx(te,{type:"button",variant:"secondary",onClick:I,disabled:b.isPending||!f.watch("smtpHost"),className:"w-full",icon:b.isPending?a.jsx(it,{className:"size-4 animate-spin"}):void 0,children:b.isPending?"Testing...":"Test SMTP Connection"}),b.data?.smtpSuccess!==void 0&&a.jsxs("div",{className:Ge("p-2 rounded-md text-sm",b.data.smtpSuccess?"bg-positive/10 text-positive":"bg-danger-soft text-danger"),children:[b.data.smtpSuccess?a.jsx(Tt,{className:"inline size-4 mr-1"}):a.jsx(De,{className:"inline size-4 mr-1"}),b.data.smtpSuccess?"SMTP Connected":He]})]})]}),d&&a.jsxs("section",{children:[a.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Signature"}),a.jsx("div",{className:"space-y-3",children:a.jsxs("div",{children:[a.jsx("label",{htmlFor:"email-sig-edit",className:"text-sm font-medium mb-1.5 block",children:"Email Signature"}),a.jsx("textarea",{id:"email-sig-edit",value:Q,onChange:h=>le(h.target.value),onBlur:Z,rows:5,className:"w-full px-3 py-2 border border-line rounded-md bg-surface-sunken text-sm text-fg placeholder:text-fg-subtle focus-within:border-line-strong focus-within:ring-2 focus-within:ring-ring/30 transition-colors resize-y outline-none",placeholder:"Enter your email signature..."}),a.jsx("p",{className:"text-xs text-fg-muted mt-1",children:oe?"Saving signature...":"This signature will be appended to new emails."})]})})]}),d&&q]})})};function Yt({open:e,onClose:s,accountEmail:t,signOut:i}){const[o,d]=C.useState(""),[n,u]=C.useState(!1),[j,_]=C.useState(!1),k=Se({...Us(),onSuccess:()=>{_(!0),setTimeout(()=>i(),2e3)}}),U=Se(Hs()),R=()=>{k.isPending||(d(""),u(!1),_(!1),k.reset(),U.reset(),s())},O=()=>{if(o.trim().toLowerCase()!==t.toLowerCase()){u(!0);return}u(!1),k.mutate({body:{confirmEmail:o.trim()}})};return a.jsxs(ts,{open:e,onClose:R,title:"Delete your Remit account",children:[a.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[a.jsx(ut,{className:"size-4 shrink-0 text-danger"}),a.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:"Delete your Remit account"}),a.jsx(te,{variant:"ghost",size:"sm",icon:a.jsx(De,{className:"size-3.5"}),onClick:R,"aria-label":"Cancel"})]}),j?a.jsxs("div",{className:"px-5 py-6 text-sm text-fg-muted",children:[a.jsx("p",{className:"font-medium text-fg",children:"Account deletion scheduled."}),a.jsx("p",{className:"mt-1",children:"Your data will be erased shortly. Signing you out…"})]}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"space-y-4 px-5 py-4 text-sm text-fg-muted",children:[a.jsx("p",{children:"This permanently erases everything Remit holds for you:"}),a.jsxs("ul",{className:"space-y-1.5 text-xs",children:[a.jsxs("li",{className:"flex gap-2",children:[a.jsx("span",{className:"text-danger",children:"•"}),"All connected accounts disconnected and access tokens revoked."]}),a.jsxs("li",{className:"flex gap-2",children:[a.jsx("span",{className:"text-danger",children:"•"}),"Synced mail cache and search index."]}),a.jsxs("li",{className:"flex gap-2",children:[a.jsx("span",{className:"text-danger",children:"•"}),"AI history and insights."]}),a.jsxs("li",{className:"flex gap-2",children:[a.jsx("span",{className:"text-danger",children:"•"}),"Preferences and rules."]})]}),a.jsxs("div",{className:"rounded-sm border border-line bg-surface-sunken px-3 py-2 text-xs",children:[a.jsx("strong",{className:"text-fg",children:"Your mail at Gmail / IMAP is not deleted."})," ","This only removes Remit's copy and its access — the mail stays in your provider mailboxes."]}),a.jsxs("div",{className:"text-xs",children:[a.jsxs("button",{type:"button",onClick:()=>U.mutate({}),"aria-busy":U.isPending,className:"inline-flex items-center gap-1.5 font-medium text-accent hover:underline",children:[a.jsx(ir,{className:"size-3.5"}),U.isPending?"Requesting export…":"Export my data first"]}),U.isSuccess&&a.jsx("p",{className:"mt-1.5 text-fg-muted",role:"status",children:"Export requested. We'll prepare a ZIP of your mail — find it under your data exports when it's ready."}),U.isError&&a.jsx("p",{className:"mt-1.5 text-danger",role:"alert",children:"Couldn't start the export. Please try again."})]}),a.jsxs("div",{children:[a.jsxs("label",{htmlFor:"confirm-remit-email",className:"mb-1 block text-xs font-medium text-fg",children:["Type"," ",a.jsx("span",{className:"font-mono text-fg-muted",children:t})," ","to confirm"]}),a.jsx(ve,{id:"confirm-remit-email",type:"email",placeholder:t,value:o,onChange:E=>{d(E.target.value),n&&u(!1),k.isError&&k.reset()},autoComplete:"off"}),n&&a.jsx("p",{className:"mt-1.5 text-xs text-danger",role:"alert",children:"That doesn't match your account email. Type it exactly to confirm."}),k.isError&&a.jsx("p",{className:"mt-1.5 text-xs text-danger",role:"alert",children:k.error instanceof Error?k.error.message:"Something went wrong. Please try again."})]})]}),a.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[a.jsx(te,{variant:"secondary",size:"sm",onClick:R,children:"Cancel"}),a.jsx(te,{variant:"danger",size:"sm",onClick:O,"aria-busy":k.isPending,children:k.isPending?"Deleting…":"Delete everything"})]})]})]})}function Jr(e){const{Account:s}=Ls();return a.jsx(s,{fallback:a.jsx(Yt,{...e,accountEmail:"",signOut:()=>{}}),children:({email:t,signOut:i})=>a.jsx(Yt,{...e,accountEmail:t??"",signOut:i})})}function ea(){const[e,s]=C.useState(!1);return a.jsxs("section",{className:"mt-8 border-t border-line pt-6",children:[a.jsx(ur,{title:"Delete your Remit account",description:"Disconnects every account and erases Remit's copy of your mail, insights and preferences. Your mail at the providers is untouched.",action:a.jsx(te,{variant:"danger",size:"sm",onClick:()=>s(!0),children:"Delete your Remit account"})}),a.jsx(Jr,{open:e,onClose:()=>s(!1)})]})}function ta(e){const s=e.toLowerCase();return s==="access_denied"?"You cancelled the sign-in.":s==="consent_required"||s.includes("admin_consent")||s.includes("interaction_required")?"Your organisation's admin needs to approve Remit. Ask your IT admin to grant the required permissions.":s.includes("imap_disabled")||s.includes("imap disabled")?"IMAP is disabled for this account. Ask your admin to enable IMAP access in the Microsoft 365 admin centre.":`Sign-in failed: ${e}. Please try again.`}function sa(e){const s=e.split("@")[0]??"";return s?s.split(/[._-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" "):e}function ra(e){const s=e.displayName?.trim();return s||sa(e.email)}function aa(e){if(!e.lastSyncAt)return"never synced";const s=or(e.lastSyncAt);return s?`synced ${s}`:"never synced"}function Qt(e){return e.muted?.value?"muted":e.lastError?"error":e.connectionState==="authenticated"?"healthy":"error"}function Zt(e){return e.connectionState==="reauth_required"}const ia=()=>a.jsx("div",{className:"space-y-3",role:"status","aria-busy":"true","aria-label":"Loading accounts",children:["skeleton-0","skeleton-1"].map(e=>a.jsx("div",{className:"rounded-sm border border-line bg-surface animate-pulse p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"size-10 rounded-full bg-surface-sunken"}),a.jsxs("div",{className:"flex-1 space-y-2",children:[a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-1/3"}),a.jsx("div",{className:"h-3 bg-surface-sunken rounded w-2/3"})]})]})},e))});function wa(){const e=_t.useSearch(),s=zs({from:_t.fullPath}),[t,i]=C.useState(!0),[o,d]=C.useState(!1),[n,u]=C.useState(!1),[j,_]=C.useState(null),[k,U]=C.useState(!1),[R,O]=C.useState(null),[E,f]=C.useState(null),[b,ae]=C.useState(null),[N,$]=C.useState(null),I=ft(),{data:A,isPending:ne,isError:re,error:he,refetch:oe}=Xt(Jt());C.useEffect(()=>{e.editAccountId&&(_(e.editAccountId),U(!!e.focusSmtp),s({search:{editAccountId:void 0,focusSmtp:void 0,connected:e.connected,oauthError:e.oauthError},replace:!0}))},[e.editAccountId,e.focusSmtp,s,e.connected,e.oauthError]),C.useEffect(()=>{e.connected&&(f("Account connected successfully."),_(e.connected),I.invalidateQueries({queryKey:Te()}),s({search:{connected:void 0,oauthError:void 0,editAccountId:void 0,focusSmtp:void 0},replace:!0}))},[e.connected,s,I]),C.useEffect(()=>{e.oauthError&&(ae(ta(e.oauthError)),$(null),s({search:{oauthError:void 0,connected:void 0,editAccountId:void 0,focusSmtp:void 0},replace:!0}))},[e.oauthError,s]),Js(N!==null,()=>{I.invalidateQueries({queryKey:Te()})}),C.useEffect(()=>{if(!N||!A)return;const S=A.accounts.find(X=>X.accountId===N);(!S||!Zt(S))&&$(null)},[A,N]);const Q=er(()=>{$(null)}),le=Se({...Bs(),onSuccess:S=>{Q(),window.location.assign(S.authorizationUrl)},onError:S=>{ae(S instanceof Error?S.message:"Failed to start reconnect"),$(null)}}),T=Se({...qs(),onSuccess:()=>{I.invalidateQueries({queryKey:Te()}),O(null)}}),P=A?.accounts.find(S=>S.accountId===R),D=A?.accounts.find(S=>S.accountId===j),q=()=>{d(!1),u(!1),_(null),U(!1)},Z=S=>{const X=Gs[S];X&&s({to:X})};return a.jsxs(Qs,{items:$s,activeId:"accounts",title:"Accounts",description:"Every account keeps syncing — muted ones just stay out of unified views.",help:lr,helpOpen:t,onToggleHelp:()=>i(S=>!S),onSelect:Z,onBackToMail:()=>{s({to:"/mail"})},children:[E&&a.jsx(kt,{tone:"success",variant:"soft","data-testid":"oauth-success-banner",onDismiss:()=>f(null),children:E}),b&&a.jsx(kt,{tone:"danger",variant:"soft","data-testid":"oauth-error-banner",onDismiss:()=>ae(null),children:b}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx(Ws,{tone:"neutral",children:ne||re?"accounts":`${A.accounts.length} ${A.accounts.length===1?"account":"accounts"}`}),a.jsx(te,{variant:"primary",size:"sm",icon:a.jsx(Pt,{className:"size-3.5"}),onClick:()=>u(!0),children:"Add account"})]}),ne?a.jsx(ia,{}):re?a.jsx(nr,{title:"Couldn't load accounts",error:he,onRetry:()=>{oe()}}):A.accounts.length===0?a.jsxs("div",{className:"py-12 text-sm text-fg-muted","data-testid":"accounts-empty",children:[a.jsx("p",{className:"mb-3",children:"No accounts configured."}),a.jsx(te,{variant:"primary",size:"sm",icon:a.jsx(Pt,{className:"size-3.5"}),onClick:()=>u(!0),children:"Add your first account"})]}):a.jsx("div",{className:"space-y-3",children:A.accounts.map(S=>{const X=Zt(S),W=S.authType==="oauthMicrosoft",ge=N===S.accountId,Ee=X&&W?{label:"Reconnect",variant:"secondary",busy:ge,busyLabel:"Redirecting…",onClick:()=>{$(S.accountId),le.mutate({body:{email:S.email}})}}:Qt(S)==="error"?{label:"Reconnect",variant:"secondary",onClick:()=>_(S.accountId)}:{label:"Manage",variant:"ghost",onClick:()=>_(S.accountId)},we=a.jsx(Ys,{actions:[Ee],destructive:{label:"Delete account",iconOnly:!0,icon:a.jsx(Ks,{className:"size-3.5"}),onClick:()=>O(S.accountId)}});return a.jsx(Zs,{label:ra(S),email:S.email,connector:W?"Microsoft 365":"IMAP",syncLabel:aa(S),state:Qt(S),errorDetail:X?"Re-authentication required":S.lastError,trailing:we},S.accountId)})}),n&&a.jsx("div",{className:"fixed inset-0 z-40 overflow-auto bg-canvas",children:a.jsx(tr,{skipWelcome:!0,onComplete:()=>{u(!1),I.invalidateQueries({queryKey:Te()})},onCancel:()=>u(!1)})}),a.jsx(Xr,{isOpen:o||!!j,account:D,focusSmtp:k,onClose:q}),a.jsxs(ts,{open:!!R,onClose:()=>O(null),title:"Delete account",children:[a.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[a.jsx(ut,{className:"size-4 shrink-0 text-danger"}),a.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:"Delete account"}),a.jsx(te,{variant:"ghost",size:"sm",icon:a.jsx(De,{className:"size-3.5"}),onClick:()=>O(null),"aria-label":"Cancel"})]}),a.jsxs("div",{className:"space-y-3 px-5 py-4 text-sm text-fg-muted",children:[a.jsx("p",{className:"text-center text-lg font-medium text-fg",children:"Are you sure?"}),P&&a.jsx("p",{className:"text-center",children:P.email}),a.jsxs("ul",{className:"list-inside list-disc space-y-1",children:[a.jsx("li",{children:"Remove the account from your settings"}),a.jsx("li",{children:"Stop syncing mail for this account"}),a.jsx("li",{children:"Delete all associated data (within 24 hours)"})]})]}),a.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[a.jsx(te,{variant:"secondary",size:"sm",onClick:()=>O(null),children:"Cancel"}),a.jsx(te,{variant:"danger",size:"sm","aria-busy":T.isPending,icon:T.isPending?a.jsx(it,{className:"size-3.5 animate-spin"}):void 0,onClick:()=>{T.isPending||R&&T.mutate({path:{accountId:R}})},children:T.isPending?"Deleting…":"Delete account"})]})]}),a.jsx(ea,{})]})}export{wa as component,ta as mapOauthError};
@@ -1 +0,0 @@
1
- import{j as r,a4 as i}from"./index-CFkAgUJA.js";import{a as m}from"./MailShell-EBHUhgkn.js";import{B as o}from"./BriefPane-DkIisyhD.js";import{g as p}from"./search-token-index-D2aIcKlQ.js";import{u as e}from"./search-mirror-z_kwOSxA.js";import"./FullCompose-DzuCOaYk.js";import"./ErrorState-CDN8OkAT.js";import"./index-Bmk2EDh1.js";import"./useMessageBodyContent-CG3Q2Vwi.js";import"./useSignature-CszyYw-c.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-zfkxbezK.js";import"./confirm-dialog-DLbVncLb.js";import"./useSearchTokenContext-Dmt9kbMV.js";import"./kbd-bB3ZAr68.js";import"./search-scope-DTcpOp3S.js";import"./MailListHeader-C4lftUEo.js";import"./attachment-file-D-Cvcyx2.js";import"./mail-Dvas2UDV.js";import"./avatar-CQ3ej2nF.js";import"./format-HW3C18y-.js";import"./download-Cb45kClh.js";import"./shield-check-7qB60EQS.js";import"./useFilters-D9VfT5eI.js";import"./clock-gfYrT9HU.js";import"./menu-CHgXvbDR.js";import"./useRefreshControl-BCWsGgbC.js";import"./circle-check-big-DostR7Uj.js";import"./useLabels-epnfWwuH.js";import"./useSemanticSearch-DIrzI_5M.js";import"./search-query-Cr_ZXBCp.js";import"./wizard-selection-B1bng5Jq.js";function F(){const t=p();return e({to:"/mail/brief"}),r.jsx(o,{thread:t,children:r.jsx(m,{phone:r.jsx(o.Phone,{}),list:r.jsx(o.List,{}),reading:r.jsx(i,{}),intelligence:r.jsx(o.Intelligence,{}),hasThread:!!t})})}export{F as component};
@@ -1 +0,0 @@
1
- import{F as o}from"./FullCompose-DzuCOaYk.js";import"./index-CFkAgUJA.js";import"./ErrorState-CDN8OkAT.js";import"./index-Bmk2EDh1.js";import"./useMessageBodyContent-CG3Q2Vwi.js";import"./useSignature-CszyYw-c.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-zfkxbezK.js";import"./confirm-dialog-DLbVncLb.js";const a=o;export{a as component};
@@ -1 +0,0 @@
1
- import{F as o}from"./FullCompose-DzuCOaYk.js";import"./index-CFkAgUJA.js";import"./ErrorState-CDN8OkAT.js";import"./index-Bmk2EDh1.js";import"./useMessageBodyContent-CG3Q2Vwi.js";import"./useSignature-CszyYw-c.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-zfkxbezK.js";import"./confirm-dialog-DLbVncLb.js";const a=o;export{a as component};
@@ -1 +0,0 @@
1
- import{F as o}from"./FullCompose-DzuCOaYk.js";import"./index-CFkAgUJA.js";import"./ErrorState-CDN8OkAT.js";import"./index-Bmk2EDh1.js";import"./useMessageBodyContent-CG3Q2Vwi.js";import"./useSignature-CszyYw-c.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-zfkxbezK.js";import"./confirm-dialog-DLbVncLb.js";const a=o;export{a as component};
@@ -1 +0,0 @@
1
- import{F as o}from"./FullCompose-DzuCOaYk.js";import"./index-CFkAgUJA.js";import"./ErrorState-CDN8OkAT.js";import"./index-Bmk2EDh1.js";import"./useMessageBodyContent-CG3Q2Vwi.js";import"./useSignature-CszyYw-c.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-zfkxbezK.js";import"./confirm-dialog-DLbVncLb.js";const a=o;export{a as component};
@@ -1 +0,0 @@
1
- import{j as o,a4 as i}from"./index-CFkAgUJA.js";import{a as m}from"./MailShell-EBHUhgkn.js";import{F as r}from"./FlaggedPane-yUCuVDrF.js";import{g as p}from"./search-token-index-D2aIcKlQ.js";import{u as e}from"./search-mirror-z_kwOSxA.js";import"./FullCompose-DzuCOaYk.js";import"./ErrorState-CDN8OkAT.js";import"./index-Bmk2EDh1.js";import"./useMessageBodyContent-CG3Q2Vwi.js";import"./useSignature-CszyYw-c.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-zfkxbezK.js";import"./confirm-dialog-DLbVncLb.js";import"./useSearchTokenContext-Dmt9kbMV.js";import"./kbd-bB3ZAr68.js";import"./search-scope-DTcpOp3S.js";import"./MailListHeader-C4lftUEo.js";import"./attachment-file-D-Cvcyx2.js";import"./mail-Dvas2UDV.js";import"./avatar-CQ3ej2nF.js";import"./format-HW3C18y-.js";import"./download-Cb45kClh.js";import"./shield-check-7qB60EQS.js";import"./useFilters-D9VfT5eI.js";import"./clock-gfYrT9HU.js";import"./menu-CHgXvbDR.js";import"./MailViewChrome-DDfMPO16.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 +0,0 @@
1
- import{j as o}from"./index-CFkAgUJA.js";import{F as r}from"./FlaggedPane-yUCuVDrF.js";import"./useSearchTokenContext-Dmt9kbMV.js";import"./kbd-bB3ZAr68.js";import"./useMessageBodyContent-CG3Q2Vwi.js";import"./search-scope-DTcpOp3S.js";import"./MailListHeader-C4lftUEo.js";import"./search-token-index-D2aIcKlQ.js";import"./attachment-file-D-Cvcyx2.js";import"./mail-Dvas2UDV.js";import"./avatar-CQ3ej2nF.js";import"./index-Bmk2EDh1.js";import"./useSignature-CszyYw-c.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-zfkxbezK.js";import"./ErrorState-CDN8OkAT.js";import"./format-HW3C18y-.js";import"./download-Cb45kClh.js";import"./shield-check-7qB60EQS.js";import"./useFilters-D9VfT5eI.js";import"./confirm-dialog-DLbVncLb.js";import"./clock-gfYrT9HU.js";import"./menu-CHgXvbDR.js";import"./MailViewChrome-DDfMPO16.js";import"./wizard-selection-B1bng5Jq.js";function w(){return o.jsx(r.Reading,{})}export{w as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-CFkAgUJA.js";import{O as t}from"./OutboxPane-CgELyxEH.js";import"./useSearchTokenContext-Dmt9kbMV.js";import"./kbd-bB3ZAr68.js";import"./useMessageBodyContent-CG3Q2Vwi.js";import"./search-scope-DTcpOp3S.js";import"./circle-check-big-DostR7Uj.js";import"./clock-gfYrT9HU.js";import"./row-actions-mYLXim9h.js";import"./rotate-ccw-Bxy1oybp.js";import"./NavMenuButton-Dfz7rRBq.js";import"./menu-CHgXvbDR.js";import"./format-HW3C18y-.js";import"./outbox-status-BlKn6P0x.js";import"./search-query-Cr_ZXBCp.js";function c(){return o.jsx(t.Reading,{})}export{c as component};
@@ -1 +0,0 @@
1
- import{j as r}from"./index-CFkAgUJA.js";import{B as o}from"./BriefPane-DkIisyhD.js";import"./useSearchTokenContext-Dmt9kbMV.js";import"./kbd-bB3ZAr68.js";import"./useMessageBodyContent-CG3Q2Vwi.js";import"./search-scope-DTcpOp3S.js";import"./MailListHeader-C4lftUEo.js";import"./search-token-index-D2aIcKlQ.js";import"./attachment-file-D-Cvcyx2.js";import"./mail-Dvas2UDV.js";import"./avatar-CQ3ej2nF.js";import"./index-Bmk2EDh1.js";import"./useSignature-CszyYw-c.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-zfkxbezK.js";import"./ErrorState-CDN8OkAT.js";import"./format-HW3C18y-.js";import"./download-Cb45kClh.js";import"./shield-check-7qB60EQS.js";import"./useFilters-D9VfT5eI.js";import"./confirm-dialog-DLbVncLb.js";import"./clock-gfYrT9HU.js";import"./menu-CHgXvbDR.js";import"./useRefreshControl-BCWsGgbC.js";import"./circle-check-big-DostR7Uj.js";import"./useLabels-epnfWwuH.js";import"./useSemanticSearch-DIrzI_5M.js";import"./search-query-Cr_ZXBCp.js";import"./wizard-selection-B1bng5Jq.js";function A(){return r.jsx(o.Reading,{})}export{A as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-CFkAgUJA.js";import{M as r}from"./MailboxPane-CXDOqiF_.js";import"./useSearchTokenContext-Dmt9kbMV.js";import"./kbd-bB3ZAr68.js";import"./useMessageBodyContent-CG3Q2Vwi.js";import"./search-scope-DTcpOp3S.js";import"./useRefreshControl-BCWsGgbC.js";import"./circle-check-big-DostR7Uj.js";import"./search-token-index-D2aIcKlQ.js";import"./MailListHeader-C4lftUEo.js";import"./attachment-file-D-Cvcyx2.js";import"./mail-Dvas2UDV.js";import"./avatar-CQ3ej2nF.js";import"./index-Bmk2EDh1.js";import"./useSignature-CszyYw-c.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-zfkxbezK.js";import"./ErrorState-CDN8OkAT.js";import"./format-HW3C18y-.js";import"./download-Cb45kClh.js";import"./shield-check-7qB60EQS.js";import"./useFilters-D9VfT5eI.js";import"./confirm-dialog-DLbVncLb.js";import"./clock-gfYrT9HU.js";import"./menu-CHgXvbDR.js";import"./MailViewChrome-DDfMPO16.js";import"./NavMenuButton-Dfz7rRBq.js";import"./useLabels-epnfWwuH.js";import"./useSemanticSearch-DIrzI_5M.js";import"./search-query-Cr_ZXBCp.js";import"./bottom-sheet-CJAkwg1D.js";import"./circle-help-BrBilteI.js";import"./circle-check-BlV3yF1E.js";function F(){return o.jsx(r.Reading,{})}export{F as component};
@@ -1 +0,0 @@
1
- import{j as t,ab as o}from"./index-CFkAgUJA.js";const n=()=>t.jsx(o,{to:"/settings/accounts"});export{n as component};
@@ -1 +0,0 @@
1
- import{j as r}from"./index-CFkAgUJA.js";import{B as o}from"./BriefPane-DkIisyhD.js";import"./useSearchTokenContext-Dmt9kbMV.js";import"./kbd-bB3ZAr68.js";import"./useMessageBodyContent-CG3Q2Vwi.js";import"./search-scope-DTcpOp3S.js";import"./MailListHeader-C4lftUEo.js";import"./search-token-index-D2aIcKlQ.js";import"./attachment-file-D-Cvcyx2.js";import"./mail-Dvas2UDV.js";import"./avatar-CQ3ej2nF.js";import"./index-Bmk2EDh1.js";import"./useSignature-CszyYw-c.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-zfkxbezK.js";import"./ErrorState-CDN8OkAT.js";import"./format-HW3C18y-.js";import"./download-Cb45kClh.js";import"./shield-check-7qB60EQS.js";import"./useFilters-D9VfT5eI.js";import"./confirm-dialog-DLbVncLb.js";import"./clock-gfYrT9HU.js";import"./menu-CHgXvbDR.js";import"./useRefreshControl-BCWsGgbC.js";import"./circle-check-big-DostR7Uj.js";import"./useLabels-epnfWwuH.js";import"./useSemanticSearch-DIrzI_5M.js";import"./search-query-Cr_ZXBCp.js";import"./wizard-selection-B1bng5Jq.js";function C(){return r.jsx(o.Reading,{})}export{C as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-CFkAgUJA.js";import{M as i}from"./MailboxPane-CXDOqiF_.js";import"./useSearchTokenContext-Dmt9kbMV.js";import"./kbd-bB3ZAr68.js";import"./useMessageBodyContent-CG3Q2Vwi.js";import"./search-scope-DTcpOp3S.js";import"./useRefreshControl-BCWsGgbC.js";import"./circle-check-big-DostR7Uj.js";import"./search-token-index-D2aIcKlQ.js";import"./MailListHeader-C4lftUEo.js";import"./attachment-file-D-Cvcyx2.js";import"./mail-Dvas2UDV.js";import"./avatar-CQ3ej2nF.js";import"./index-Bmk2EDh1.js";import"./useSignature-CszyYw-c.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-zfkxbezK.js";import"./ErrorState-CDN8OkAT.js";import"./format-HW3C18y-.js";import"./download-Cb45kClh.js";import"./shield-check-7qB60EQS.js";import"./useFilters-D9VfT5eI.js";import"./confirm-dialog-DLbVncLb.js";import"./clock-gfYrT9HU.js";import"./menu-CHgXvbDR.js";import"./MailViewChrome-DDfMPO16.js";import"./NavMenuButton-Dfz7rRBq.js";import"./useLabels-epnfWwuH.js";import"./useSemanticSearch-DIrzI_5M.js";import"./search-query-Cr_ZXBCp.js";import"./bottom-sheet-CJAkwg1D.js";import"./circle-help-BrBilteI.js";import"./circle-check-BlV3yF1E.js";function G(){return o.jsx(i.Reading,{})}export{G as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-CFkAgUJA.js";import{F as r}from"./FlaggedPane-yUCuVDrF.js";import"./useSearchTokenContext-Dmt9kbMV.js";import"./kbd-bB3ZAr68.js";import"./useMessageBodyContent-CG3Q2Vwi.js";import"./search-scope-DTcpOp3S.js";import"./MailListHeader-C4lftUEo.js";import"./search-token-index-D2aIcKlQ.js";import"./attachment-file-D-Cvcyx2.js";import"./mail-Dvas2UDV.js";import"./avatar-CQ3ej2nF.js";import"./index-Bmk2EDh1.js";import"./useSignature-CszyYw-c.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-zfkxbezK.js";import"./ErrorState-CDN8OkAT.js";import"./format-HW3C18y-.js";import"./download-Cb45kClh.js";import"./shield-check-7qB60EQS.js";import"./useFilters-D9VfT5eI.js";import"./confirm-dialog-DLbVncLb.js";import"./clock-gfYrT9HU.js";import"./menu-CHgXvbDR.js";import"./MailViewChrome-DDfMPO16.js";import"./wizard-selection-B1bng5Jq.js";function v(){return o.jsx(r.Reading,{})}export{v as component};
@@ -1 +0,0 @@
1
- import{j as o,a4 as i}from"./index-CFkAgUJA.js";import{a as m}from"./MailShell-EBHUhgkn.js";import{u as p,O as t}from"./OutboxPane-CgELyxEH.js";import{u as s}from"./search-mirror-z_kwOSxA.js";import"./FullCompose-DzuCOaYk.js";import"./ErrorState-CDN8OkAT.js";import"./index-Bmk2EDh1.js";import"./useMessageBodyContent-CG3Q2Vwi.js";import"./useSignature-CszyYw-c.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-zfkxbezK.js";import"./confirm-dialog-DLbVncLb.js";import"./useSearchTokenContext-Dmt9kbMV.js";import"./kbd-bB3ZAr68.js";import"./search-scope-DTcpOp3S.js";import"./circle-check-big-DostR7Uj.js";import"./clock-gfYrT9HU.js";import"./row-actions-mYLXim9h.js";import"./rotate-ccw-Bxy1oybp.js";import"./NavMenuButton-Dfz7rRBq.js";import"./menu-CHgXvbDR.js";import"./format-HW3C18y-.js";import"./outbox-status-BlKn6P0x.js";import"./search-query-Cr_ZXBCp.js";function q(){const r=p();return s({to:"/mail/outbox"}),o.jsx(t,{outboxMessageId:r,children:o.jsx(m,{phone:o.jsx(t.Phone,{}),list:o.jsx(t.List,{}),reading:o.jsx(i,{})})})}export{q as component};
@@ -1 +0,0 @@
1
- import{j as t,a4 as o}from"./index-CFkAgUJA.js";const n=()=>t.jsx(o,{});export{n as component};