@remit/web-client-dist 0.0.486 → 0.0.488

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 (145) hide show
  1. package/assets/{BriefPane-C5f59Mn7.js → BriefPane-8e5wD9U2.js} +1 -1
  2. package/assets/CalendarComposePane-CnkwI8w6.js +1 -0
  3. package/assets/CalendarComposeSeed-bGtEytNs.js +1 -0
  4. package/assets/{CalendarShell-CHBR4YdK.js → CalendarShell-D8nnETBx.js} +1 -1
  5. package/assets/{EmptyState-CQL1Pjbh.js → EmptyState-Bnpl3mxy.js} +1 -1
  6. package/assets/{ErrorState-D8AQD4QI.js → ErrorState-BN1KI1QC.js} +1 -1
  7. package/assets/{FlaggedPane-DM3Wy8rZ.js → FlaggedPane--S_CB4Cc.js} +1 -1
  8. package/assets/{FullCompose-Ca20lPOA.js → FullCompose-BOiOQ-Qf.js} +1 -1
  9. package/assets/{MailListHeader-D7oYyz3_.js → MailListHeader-D3QJgz1J.js} +1 -1
  10. package/assets/{MailNav-D93z2NPe.js → MailNav-BmcDEbrF.js} +1 -1
  11. package/assets/{MailShell-BpD0VQlu.js → MailShell-CZF1GQXr.js} +1 -1
  12. package/assets/{MailViewChrome-C3m2xTjA.js → MailViewChrome-BSKS3ijj.js} +1 -1
  13. package/assets/{MailboxPane-BODFQwbs.js → MailboxPane-M3YI2Lhj.js} +1 -1
  14. package/assets/{NavMenuButton-C23ZlNzG.js → NavMenuButton-DZeoJSH-.js} +1 -1
  15. package/assets/{OnboardingWizard-8NOySNwj.js → OnboardingWizard-Dpl2R9Cy.js} +1 -1
  16. package/assets/OpenCalendarEvent-kYb3ZTPU.js +2 -0
  17. package/assets/{OutboxPane-qfe7PmY5.js → OutboxPane-uihHargp.js} +1 -1
  18. package/assets/_calendarObjectId-B1Oalf3b.js +1 -0
  19. package/assets/_mailboxId-DdbPW7YF.js +1 -0
  20. package/assets/_messageId-BP9-n-lV.js +1 -0
  21. package/assets/_messageId-C-cSawQe.js +1 -0
  22. package/assets/_messageId-mWUrP87X.js +1 -0
  23. package/assets/_outboxMessageId-IVVtaP13.js +1 -0
  24. package/assets/_recurrenceId-DMP1BEIN.js +1 -0
  25. package/assets/_threadId-C5CRN2ch.js +1 -0
  26. package/assets/_threadId-DOK4zcvh.js +1 -0
  27. package/assets/_threadId-qUW2tqRz.js +1 -0
  28. package/assets/_view._date-Djnasj-2.js +1 -0
  29. package/assets/{accounts-DV03g8iQ.js → accounts-Coh0pl5z.js} +1 -1
  30. package/assets/{advanced-Ba8zDo2z.js → advanced-BMnUr3k2.js} +1 -1
  31. package/assets/{appearance-u-ZvKiJu.js → appearance-Cc_1nX_R.js} +1 -1
  32. package/assets/{attachment-file-CZyLTO92.js → attachment-file-DEgj4Vud.js} +1 -1
  33. package/assets/{avatar-BUFzqa0m.js → avatar-jIsSo2Zf.js} +1 -1
  34. package/assets/{bottom-sheet-DTbJ9FNm.js → bottom-sheet-DheWfAIR.js} +1 -1
  35. package/assets/{brief-8uXFnUen.js → brief-CcZTo542.js} +1 -1
  36. package/assets/brief-Dln7pOiH.js +1 -0
  37. package/assets/{browser-ponyfill-A1bHqxco.js → browser-ponyfill-B4xJekFS.js} +1 -1
  38. package/assets/{bug-C_nJpj_h.js → bug-D1kIQg-0.js} +1 -1
  39. package/assets/{calendar-O9O5ZUgT.js → calendar-DxJZvi6b.js} +1 -1
  40. package/assets/{calendar-days-BiSAAPsl.js → calendar-days-C_HOm0G3.js} +1 -1
  41. package/assets/{card-CCWeYAnf.js → card-BvJM4Bar.js} +1 -1
  42. package/assets/chevron-left-DLqD6AAq.js +1 -0
  43. package/assets/{circle-check-CZSsF6OM.js → circle-check-DtpNGVtU.js} +1 -1
  44. package/assets/{circle-check-big-CJe-UlT7.js → circle-check-big-UXLrOtDo.js} +1 -1
  45. package/assets/{circle-help-r3PbN8xG.js → circle-help-Bn8ystJn.js} +1 -1
  46. package/assets/{clock-BLND_Uqn.js → clock-a9wtJIFb.js} +1 -1
  47. package/assets/compose._-_outboxMessageId_-BEQR2RT3.js +1 -0
  48. package/assets/compose._-_outboxMessageId_-Bdvxfy8-.js +1 -0
  49. package/assets/compose._-_outboxMessageId_-CUn9IfOQ.js +1 -0
  50. package/assets/compose._-_outboxMessageId_-YNuTsqHY.js +1 -0
  51. package/assets/{config-import-Bci3Xwoi.js → config-import-B94_wCpF.js} +1 -1
  52. package/assets/{confirm-dialog-NVOOFruZ.js → confirm-dialog-5hKuL5ov.js} +1 -1
  53. package/assets/{credential-steps-CtI45h_j.js → credential-steps-DJcQCoMN.js} +1 -1
  54. package/assets/{download-BJz8IQEk.js → download-CiAfXfNQ.js} +1 -1
  55. package/assets/{filters-YM-AjxWk.js → filters-BNAxy-pd.js} +1 -1
  56. package/assets/flagged-BYKUghBm.js +1 -0
  57. package/assets/{flagged-zj7lygZW.js → flagged-C0mYVO9Q.js} +1 -1
  58. package/assets/{folders-DB27d312.js → folders-B8E9XQGy.js} +1 -1
  59. package/assets/{format-DxgW1axG.js → format-CxG3FNVs.js} +1 -1
  60. package/assets/{help-copy-B9B_sS4o.js → help-copy-DC0qUPIv.js} +1 -1
  61. package/assets/{import-DFAWR-kC.js → import-mtITAI1H.js} +1 -1
  62. package/assets/index-BP9-n-lV.js +1 -0
  63. package/assets/{index-oS749L3s.js → index-BW01bO1J.js} +4 -4
  64. package/assets/{index-DSi1cxOe.js → index-Bcu7BqZh.js} +62 -62
  65. package/assets/index-C-cSawQe.js +1 -0
  66. package/assets/index-CpVVKgK6.js +1 -0
  67. package/assets/index-Crs0s6jC.js +1 -0
  68. package/assets/index-DAUjRbOW.js +1 -0
  69. package/assets/index-DHdIEMDT.js +1 -0
  70. package/assets/{index-CDQgKHBD.js → index-DThWcnpG.js} +1 -1
  71. package/assets/index-DX4E3icM.js +1 -0
  72. package/assets/index-DXZ_UtbG.js +1 -0
  73. package/assets/index-Dz7e4G6z.js +1 -0
  74. package/assets/{kbd-EJpwdDwi.js → kbd-wWeybs89.js} +1 -1
  75. package/assets/{labels-C2P2HsOp.js → labels-RhvMKifz.js} +1 -1
  76. package/assets/{mail-Dp-ZQxV4.js → mail-BAbQAZ9G.js} +1 -1
  77. package/assets/{mail-5cZo03IU.js → mail-WRNyVFjV.js} +1 -1
  78. package/assets/{menu-ByhBSEmm.js → menu-BXqls5WZ.js} +1 -1
  79. package/assets/minus-BaGFpEMe.js +1 -0
  80. package/assets/new-CzBf8alD.js +1 -0
  81. package/assets/onboarding-D7fm-uK7.js +1 -0
  82. package/assets/{onboarding-completion-CW5PdZse.js → onboarding-completion-lWgQaoiS.js} +1 -1
  83. package/assets/outbox-BJe-Ixj_.js +1 -0
  84. package/assets/{pencil-DLTDTx7a.js → pencil-CkHvTVt7.js} +1 -1
  85. package/assets/{rich-text-DYJXalrz.js → rich-text-CTg_ypvW.js} +1 -1
  86. package/assets/{rich-text-spellcheck-worker-provider-CfVhFCIc.js → rich-text-spellcheck-worker-provider-DNPJIUYl.js} +1 -1
  87. package/assets/{rotate-ccw-D4M_tmYq.js → rotate-ccw-Coc_HVFv.js} +1 -1
  88. package/assets/{row-actions-Dp_6Oacr.js → row-actions-D6pg-4y5.js} +1 -1
  89. package/assets/{search-mirror-B3kZUGfA.js → search-mirror-Csy2vxLR.js} +1 -1
  90. package/assets/{search-token-index-DeYdHtqE.js → search-token-index-B4kJtFA_.js} +1 -1
  91. package/assets/{sections-qjX9kREL.js → sections-DT0azgaj.js} +1 -1
  92. package/assets/{senders-BhsqVDaT.js → senders-DzxfBV7S.js} +1 -1
  93. package/assets/settings-HKkjK28O.js +1 -0
  94. package/assets/{settings-screen-Bxg7gmcf.js → settings-screen-EigWdTdk.js} +1 -1
  95. package/assets/{shield-check-Cvh9jlfx.js → shield-check-CWXSXjpp.js} +1 -1
  96. package/assets/{suggested-vips-DuweqHkG.js → suggested-vips-HChlmA8o.js} +1 -1
  97. package/assets/useCalendarData-Uek-8FpX.js +1 -0
  98. package/assets/useCalendars-Rv-pJFtI.js +1 -0
  99. package/assets/{useDebouncedValue-Ca-AmULI.js → useDebouncedValue-jtTlNJDr.js} +1 -1
  100. package/assets/{useFilters-BT2H6A9z.js → useFilters-BxnI0t9W.js} +1 -1
  101. package/assets/{useLabels-C3ibzzsY.js → useLabels-C-ytwpWV.js} +1 -1
  102. package/assets/{useLayoutTier-D0kPsil-.js → useLayoutTier-P9na-5Xh.js} +1 -1
  103. package/assets/{useMessageBodyContent-DgKoLcSS.js → useMessageBodyContent-ClKIcNPh.js} +1 -1
  104. package/assets/{useQueries-7N8So0Dt.js → useQueries-4YYdm8Yg.js} +1 -1
  105. package/assets/{useRefreshControl--nOYmIrG.js → useRefreshControl-BMS0clfU.js} +1 -1
  106. package/assets/{useSearchTokenContext-DUxpTOVT.js → useSearchTokenContext-BW55Y3Yb.js} +1 -1
  107. package/assets/{useSemanticSearch-BUANNC0c.js → useSemanticSearch-BrrFjCJ5.js} +1 -1
  108. package/assets/{useSignature-DYlo-oZl.js → useSignature-BISqUCGf.js} +1 -1
  109. package/index.html +1 -1
  110. package/package.json +1 -1
  111. package/assets/OpenCalendarEvent-CZoxi6ny.js +0 -1
  112. package/assets/_calendarObjectId-DXyBrLAy.js +0 -1
  113. package/assets/_mailboxId-qseqIpui.js +0 -1
  114. package/assets/_messageId-B08xPLe0.js +0 -1
  115. package/assets/_messageId-B7fwW8yi.js +0 -1
  116. package/assets/_messageId-iLGr4PWp.js +0 -1
  117. package/assets/_outboxMessageId-CKi0BpD-.js +0 -1
  118. package/assets/_recurrenceId-DCd_xCg3.js +0 -1
  119. package/assets/_threadId-CVmQFHBU.js +0 -1
  120. package/assets/_threadId-D-Y9MY3x.js +0 -1
  121. package/assets/_threadId-LOJwXMXk.js +0 -1
  122. package/assets/_view._date-pVW7O5az.js +0 -1
  123. package/assets/brief-DbjV3yOh.js +0 -1
  124. package/assets/calendar-DztH7JbA.js +0 -1
  125. package/assets/chevron-left-dl0LCVOD.js +0 -1
  126. package/assets/compose._-_outboxMessageId_-B_LR6PmJ.js +0 -1
  127. package/assets/compose._-_outboxMessageId_-C_gw9w32.js +0 -1
  128. package/assets/compose._-_outboxMessageId_-CdllO2zY.js +0 -1
  129. package/assets/compose._-_outboxMessageId_-ciaOsodJ.js +0 -1
  130. package/assets/flagged-CzD-VxgB.js +0 -1
  131. package/assets/index-B08xPLe0.js +0 -1
  132. package/assets/index-B7fwW8yi.js +0 -1
  133. package/assets/index-CZaX92xn.js +0 -1
  134. package/assets/index-Cemc4mf0.js +0 -1
  135. package/assets/index-CuHcq9gH.js +0 -1
  136. package/assets/index-DlXlL9UD.js +0 -1
  137. package/assets/index-G-uvsuNZ.js +0 -1
  138. package/assets/index-I0w0IbzN.js +0 -1
  139. package/assets/index-MYTdUrZy.js +0 -1
  140. package/assets/minus-CZaIJLbB.js +0 -1
  141. package/assets/new-N7ksMnEk.js +0 -1
  142. package/assets/onboarding-CbY3TxBB.js +0 -1
  143. package/assets/outbox-CLgw1jRo.js +0 -1
  144. package/assets/settings-Bz2o4JO9.js +0 -1
  145. package/assets/useCalendarData-d4Z1IfQ7.js +0 -1
@@ -1 +1 @@
1
- import{j as a,an as De,f as te,W as Ps,X as Ce,ao as ks,ap as Vs,aq as ut,E as Ds,t as Ge,ar as ee,h as ft,as as Cs,c as Jt,d as Xt,r as F,at as Fs,i as Se,au as Os,o as Te,l as es,av as Is,aw as Rs,ax as Ms,ay as ve,az as At,L as it,aA as Tt,aB as Ls,aC as Re,aD as be,aE as Et,aa as Us,aF as Hs,aG as zs,aH as ts,aI as _t,u as Bs,n as qs,aJ as Ws,aK as $s,B as Pt,g as Gs,aL as kt,aM as Ks,a2 as Ys}from"./index-DSi1cxOe.js";import{R as Qs}from"./row-actions-Dp_6Oacr.js";import{S as Zs,A as Js}from"./settings-screen-Bxg7gmcf.js";import{g as Vt,P as Xs,O as er}from"./OnboardingWizard-8NOySNwj.js";import{s as Be,u as tr,b as sr,R as rr}from"./credential-steps-CtI45h_j.js";import{u as ar}from"./useSignature-DYlo-oZl.js";import{c as ir,a as Dt,d as nr}from"./account-form-helpers-DhckT_PN.js";import{D as or}from"./download-BJz8IQEk.js";import{E as lr}from"./ErrorState-D8AQD4QI.js";import{f as cr}from"./format-DxgW1axG.js";import{a as dr}from"./help-copy-B9B_sS4o.js";import"./avatar-BUFzqa0m.js";import"./chevron-left-dl0LCVOD.js";import"./menu-ByhBSEmm.js";import"./circle-help-r3PbN8xG.js";import"./kbd-EJpwdDwi.js";import"./mail-5cZo03IU.js";import"./card-CCWeYAnf.js";const ur=e=>{const s=new Set(e.map(ks));return Vs.map(t=>t.tag).filter(t=>!s.has(t)).sort((t,i)=>De(t).localeCompare(De(i)))},fr=({value:e,onChange:s,busy:t=!1})=>{const i=ur(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:De(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(Ps,{className:"size-3.5"}),disabled:t,"aria-label":`Write new messages in ${De(o)} by default`,onClick:()=>s([o,...e.filter(n=>n!==o)]),children:"Default"}),a.jsx(te,{variant:"ghost",size:"sm",icon:a.jsx(Ce,{className:"size-3.5"}),disabled:t||e.length===1,"aria-label":`Remove ${De(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:De(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 mr({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 Ds({id:"slide-panel",open:e,answers:{back: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(Ce,{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 Ue=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),pr=e=>H(e)&&e.target?Ue(e.target)?e.target.checked:e.target.value:e,hr=(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"],gr=/^\w*$/;var He=e=>gr.test(e),M=e=>e===void 0;const xr=/[.[\]'"]/;var Ze=e=>e.split(xr).filter(Boolean),y=(e,s,t)=>{if(!s||!H(e))return t;const i=He(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},pe=e=>typeof e=="boolean",ie=e=>typeof e=="function",C=(e,s,t)=>{let i=-1;const o=He(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=e[u];j=H(E)||Array.isArray(E)?E:isNaN(+o[i+1])?{}:[]}if(pt.includes(u))return;e[u]=j,e=e[u]}};const yr=ee.createContext(null);yr.displayName="HookFormControlContext";var vr=(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 br=Qe?ee.useLayoutEffect:ee.useEffect;var Y=e=>typeof e=="string",jr=(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 he(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))?!he(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 Le=(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(Le(u,s))break}else if(H(u)&&Le(u,s))break}}};var Ot=(e,s,t)=>{const i=y(e,t),o=Array.isArray(i)?i:[];return C(o,rs,s[t]),C(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)||pe(e)&&!e)return{type:t,message:Y(e)?e:"",ref:s}}var Ve=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:E,minLength:P,min:U,max:R,pattern:O,validate:_,name:f,valueAsNumber:b,mount:re}=e._f,N=y(t,f);if(!re||s.has(f))return{};const W=u?u[0]:n,I=T=>{if(o&&W.reportValidity){const k=pe(T)?"":T||"";u?u.forEach(D=>D.setCustomValidity(k)):W.setCustomValidity(k),W.reportValidity()}},A={},ne=gt(n),ae=Ue(n),ge=ne||ae,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,k,D,q=de.maxLength,Z=de.minLength)=>{const S=T?k:D;A[f]={type:T?q:Z,message:S,ref:n,...Q(T?q:Z,S)}};if(d?!Array.isArray(N)||!N.length:j&&(!ge&&(oe||K(N))||pe(N)&&!N||ae&&!as(u).isValid||ne&&!is(u).isValid)){const{value:T,message:k}=Y(j)?{value:!!j,message:j}:Ve(j);if(T&&(A[f]={type:de.required,message:k,ref:W,...Q(de.required,k)},!i))return I(k),A}if(!oe&&(!K(U)||!K(R))){let T,k;const D=Ve(R),q=Ve(U);if(!K(N)&&!isNaN(N)){const Z=n.valueAsNumber||N&&+N;K(D.value)||(T=Z>D.value),K(q.value)||(k=Z<q.value)}else{const Z=n.valueAsDate||new Date(N),S=fe=>new Date(new Date().toDateString()+" "+fe),J=n.type=="time",$=n.type=="week";Y(D.value)&&N&&(T=J?S(N)>S(D.value):$?N>D.value:Z>new Date(D.value)),Y(q.value)&&N&&(k=J?S(N)<S(q.value):$?N<q.value:Z<new Date(q.value))}if((T||k)&&(le(!!T,D.message,q.message,de.max,de.min),!i))return I(A[f].message),A}if((E||P)&&!oe&&(Y(N)||d&&Array.isArray(N))){const T=Ve(E),k=Ve(P),D=!K(T.value)&&N.length>+T.value,q=!K(k.value)&&N.length<+k.value;if((D||q)&&(le(D,T.message,k.message),!i))return I(A[f].message),A}if(O&&!oe&&Y(N)){const{value:T,message:k}=Ve(O);if(Ye(T)&&!N.match(T)&&(A[f]={type:de.pattern,message:k,ref:n,...Q(de.pattern,k)},!i))return I(k),A}if(_){if(ie(_)){const T=await _(N,t),k=Lt(T,W);if(k&&(A[f]={...k,...Q(de.validate,k.message)},!i))return I(k.message),A}else if(H(_)){let T={};for(const k in _){if(!G(T)&&!i)break;const D=Lt(await _[k](N,t),W,k);D&&(T={...D,...Q(k,D.message)},I(D.message),i&&(A[f]=T))}if(!G(T)&&(A[f]={ref:W,...T},!i))return A}}return I(!0),A},$e=e=>Array.isArray(e)?e:[e],ns=e=>Array.isArray(e)?e.filter(Boolean):[];function Sr(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 wr(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:He(s)?[s]:Ze(s);if(t.some(n=>pt.includes(String(n))))return e;const i=t.length===1?e:Sr(e,t),o=t.length-1,d=t[o];return i&&delete i[d],o!==0&&(H(i)&&G(i)||Array.isArray(i)&&wr(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},Nr=ee.createContext(null);Nr.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",Ar=e=>gt(e)||Ue(e),rt=e=>Ke(e)&&e.isConnected,Tr=e=>{for(const s in e)if(ie(e[s]))return!0;return!1};function ds(e){return Array.isArray(e)||H(e)&&!Tr(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)):he(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):Ue(s)?as(e.refs).value:ms(M(s.value)?e.ref.value:s.value,e)}var Er=(e,s,t,i)=>{const o={};for(const d of e){const n=y(s,d);n&&C(o,d,n._f)}return{criteriaMode:t,names:[...e],fields:o,shouldUseNativeValidation:i}},Me=e=>M(e)?e:Ye(e)?e.source:H(e)?Ye(e.value)?e.value.source:e.value:e;const Bt="AsyncFunction";var _r=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},Pr=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||He(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 kr=(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))},Vr=(e,s,t)=>!e||!s||e===s||$e(e).some(i=>i&&(t?i===s||i.startsWith(s+"."):i.startsWith(s)||s.startsWith(i))),Dr=(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,Cr=(e,s)=>!ns(y(e,s)).length&&B(e,s);const Fr={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 Or(e={}){let s={...Fr,...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={},E={};let P=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},_={...O};let f={..._};const b={array:Ht(),state:Ht()};let re=0;const N=s.criteriaMode===ue.all,W=(r,l)=>c=>{clearTimeout(E[r]),E[r]=setTimeout(l,c)},I=async r=>{if(!n.keepIsValid&&!s.disabled&&(_.isValid||f.isValid||r)){const l=++re;let c;s.resolver?(c=G((await D()).errors),l===re&&A()):c=await S({fields:i,onlyCheckValid:!0,eventType:ke.VALID}),l===re&&c!==t.isValid&&b.state.next({isValid:c})}},A=(r,l)=>{!s.disabled&&(_.isValidating||_.validatingFields||f.isValidating||f.validatingFields)&&((r||Array.from(u.mount)).forEach(c=>{c&&(l?C(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)},ae=(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&&C(i,r,g)}if(x&&Array.isArray(y(t.errors,r))){const g=c(y(t.errors,r),m.argA,m.argB);p&&C(t.errors,r,g),Cr(t.errors,r)}if((_.touchedFields||f.touchedFields)&&x&&Array.isArray(y(t.touchedFields,r))){const g=c(y(t.touchedFields,r),m.argA,m.argB);p&&C(t.touchedFields,r,g)}(_.dirtyFields||f.dirtyFields)&&ne(),b.state.next({name:r,isDirty:$(r,l),dirtyFields:t.dirtyFields,errors:t.errors,isValid:t.isValid})}else C(d,r,l)},ge=(r,l)=>{C(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=He(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?C(d,r,l?g:zt(p._f)):we(r,g),n.mount&&!n.action&&(I(),x&&t.isDirty&&(_.isDirty||f.isDirty)&&($()||(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=he(y(o,r),l);(_.isDirty||f.isDirty)&&(g=t.isDirty,t.isDirty=v.isDirty=!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):C(t.dirtyFields,r,!0),v.dirtyFields=t.dirtyFields,x=x||(_.dirtyFields||f.dirtyFields)&&g!==!w}if(c){const w=y(t.touchedFields,r);w||(C(t.touchedFields,r,c),v.touchedFields=t.touchedFields,x=x||(_.touchedFields||f.touchedFields)&&w!==c)}x&&p&&b.state.next(v)}return x?v:{}},k=(r,l,c,m)=>{const p=y(t.errors,r),x=(_.isValid||f.isValid)&&pe(l)&&t.isValid!==l;if(s.delayError&&c?(j[r]=W(r,()=>ge(r,c)),j[r](s.delayError)):(clearTimeout(E[r]),delete j[r],c?C(t.errors,r,c):B(t.errors,r),t.errors={...t.errors}),(c?!he(p,c):p)||!G(m)||x){const g={...m,...x&&pe(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,Er(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):C(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}):Pe(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),X=g._f&&_r(g._f),xe=_.validatingFields||_.isValidating||f.validatingFields||f.isValidating;X&&xe&&A([v.name],!0);const ye=await Ut(g,u.disabled,d,N,s.shouldUseNativeValidation&&!l,L);if(X&&xe&&A([v.name]),ye[v.name]&&(p.valid=!1,l)||(!l&&(y(ye,v.name)?L?Ot(t.errors,ye,v.name):C(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},J=()=>{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))&&Xe(r)}u.unMount=new Set},$=(r,l)=>(r&&l&&C(d,r,l),!he(n.mount?d:o,o)),fe=(r,l,c)=>jr(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&&C(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?Ue(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&&me(r,{delayError:c.delayError})},_e=(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)?_e(v,g,c,m,p):we(v,g,c,m,p)}},Je=(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=he(w,v);if(L||C(d,r,v),g)b.array.next({name:r,values:m?d:z(d)}),(_.isDirty||_.dirtyFields||f.isDirty||f.dirtyFields)&&c.shouldDirty&&(ne(),p||b.state.next({name:r,dirtyFields:t.dirtyFields,isDirty:$(r,v)}));else{const X=Array.isArray(v)&&!v.length||G(v);!x||x._f||K(v)||X?we(r,v,c,m,p):_e(r,v,c,m,p)}if(!L&&!p){const X=st(r,u),xe=m?d:z(d);b.state.next({...X&&t,name:n.mount||X?r:void 0,values:xe})}},h=(r,l,c={})=>Je(r,l,c,!1),V=(r,l={})=>{const c=ie(r)?r(d):r;if(!he(d,c)){d={...d,...c};const m=os(c);for(const p of u.mount)p in m&&Je(p,m[p],l,!0,!0);b.state.next({...t,name:void 0,type:void 0,...P?{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())||he(g,y(d,c,g))};if(p){let g,v;const w=l.type?zt(p._f):pr(r),L=r.type===ke.BLUR||r.type===ke.FOCUS_OUT,X=!Pr(p._f)&&!e.validate&&!s.resolver&&!y(t.errors,c)&&!p._f.deps,xe=X||Dr(L,y(t.touchedFields,c),t.isSubmitted,R,U),ye=st(c,u,L);if(C(d,c,w),L){if(!l||!l.readOnly){p._f.onBlur&&p._f.onBlur(r);const Ie=j[c];Ie&&Ie(0)}}else p._f.onChange&&p._f.onChange(r);const Oe=T(c,w,L),Es=!G(Oe)||ye;if(!L&&b.state.next({name:c,type:r.type,...P?{values:z(d)}:{}}),xe)return(!X||!t.isValid)&&(_.isValid||f.isValid)&&(s.mode==="onBlur"?L&&I():L||I()),Es&&b.state.next({name:c,...ye?{}:Oe});if(!s.resolver&&e.validate&&await Z({name:c,eventType:r.type}),!L&&ye&&b.state.next({...t}),s.resolver){const{errors:Ie}=await D([c]);if(A([c]),x(w),!m){!G(Oe)&&b.state.next(Oe);return}const _s=qt(t.errors,i,c),Nt=qt(Ie,i,_s.name||c);g=Nt.error,c=Nt.name,v=G(Ie)}else A([c],!0),g=(await Ut(p,u.disabled,d,N,s.shouldUseNativeValidation))[c],A([c]),x(w),m&&(g?v=!1:(_.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)&&me(p._f.deps),k(c,v,g,Oe))}},se=(r,l)=>{if(y(t.errors,l)&&r.focus)return r.focus(),1},me=async(r,l={})=>{let c,m;const p=$e(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]=W(r,()=>ge(r,x)),j[r](s.delayError)):(clearTimeout(E[r]),delete j[r])}return b.state.next({...!Y(r)||(_.isValid||f.isValid)&&c!==t.isValid?{}:{name:r},...s.resolver||!r?{isValid:c}:{},errors:t.errors}),l.shouldFocus&&!m&&Le(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))},Fe=(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)}),Pe=r=>{const l=r?$e(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;C(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)){P++;const{unsubscribe:c}=b.state.subscribe({next:p=>"values"in p&&r(p.values||fe(void 0,l),p)});let m=!1;return{unsubscribe:()=>{m||(m=!0,P--,c())}}}return fe(r,l,!0)},yt=r=>{var l;const c=!!(!((l=r.formState)===null||l===void 0)&&l.values);c&&P++;const{unsubscribe:m}=b.state.subscribe({next:x=>{if(Vr(r.name,x.name,r.exact)&&kr(x,r.formState||_,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,P--,m())}},Ss=r=>(n.mount=!0,f={...f,...r.formState},yt({...r,formState:{...O,...r.formState}})),Xe=(r,l={})=>{for(const c of r?$e(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:$()}:{}}),!l.keepIsValid&&I()},vt=({disabled:r,name:l})=>{if(pe(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=pe(l.disabled)||pe(s.disabled),p=!u.registerName.has(r)&&c&&c._f&&!c._f.mount;return C(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:pe(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:Me(l.min),max:Me(l.max),minLength:Me(l.minLength),maxLength:Me(l.maxLength),pattern:Me(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=Ar(g),w=c._f.refs||[];if(v?w.find(L=>L===g):g===c._f.ref)return;C(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)&&!(hr(u.array,r)&&n.action)&&u.unMount.add(r)}}},tt=()=>s.shouldFocusError&&!s.shouldUseNativeValidation&&Le(i,se,u.mount),ws=r=>{pe(r)&&(b.state.next({disabled:r}),Le(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),C(o,r,z(l.defaultValue))),l.keepTouched||B(t.touchedFields,r),l.keepDirty||(B(t.dirtyFields,r),t.isDirty=l.defaultValue?$(r,z(y(o,r))):$()),l.keepError||(B(t.errors,r),_.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),X=y(d,w),xe=y(x,w);L&&!M(X)?C(x,w,X):!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 X=L.closest("form");if(X){X.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)C(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=!_.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?$():!!(l.keepDefaultValues&&!he(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:Xe,getFieldState:Fe,handleSubmit:bt,setError:ze,_subscribe:yt,_runSchema:D,_updateIsValidating:A,_focusError:tt,_getWatch:fe,_getDirty:$,_setValid:I,_setFieldArray:ae,_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:J,_disableForm:ws,_subjects:b,_proxyFormState:_,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:me,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:Pe,unregister:Xe,setError:ze,setFocus:As,getFieldState:Fe};return{...wt,formControl:wt}}function Ir(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}=Or(e);s.current={...j,formState:o}}const n=s.current.control;return n._options=e,br(()=>{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&&!he(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(()=>vr(o,n),[n,o]),s.current}const Wt=(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?Wt(i.ref,t,e):i&&i.refs&&i.refs.forEach(o=>Wt(o,t,e))}},$t=(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(Rr(s.names||Object.keys(e),i)){const n=Object.assign({},y(t,i));C(n,"root",d),C(t,i,n)}else C(t,i,d)}return t},Rr=(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 E;Object.defineProperty(u,"_zod",{value:u._zod??{},enumerable:!1}),(E=u._zod).traits??(E.traits=new Set),u._zod.traits.add(e),s(u,j);for(const P in n.prototype)P in u||Object.defineProperty(u,P,{value:n.prototype[P].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 E=t?.Parent?new d:this;i(E,u),(j=E._zod).deferred??(j.deferred=[]);for(const P of E._zod.deferred)P();return E}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 Mr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const Lr={};function gs(e){return Lr}function Ur(e,s){return typeof s=="bigint"?s.toString():s}const xs=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function We(e){return typeof e=="string"?e:e?.message}function ys(e,s,t){const i={...e,path:e.path??[]};if(!e.message){const o=We(e.inst?._zod.def?.error?.(e))??We(s?.error?.(e))??We(t.customError?.(e))??We(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,Ur,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Hr=hs("$ZodError",vs),bs=hs("$ZodError",vs,{Parent:Error}),zr=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 Mr;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},Br=zr(bs),qr=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},Wr=qr(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 $r(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(P){return P.errors.forEach(function(U){return e.push(U)})}),s){var j=t[n].types,E=j&&j[i.code];t[n]=xt(n,s,t,o,E?[].concat(E,i.message):i.message)}e.shift()}return t}function Gr(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 E=t[u].types,P=E&&E[o.code];t[u]=xt(u,s,t,d,P?[].concat(P,o.message):o.message)}e.shift()};e.length;)i();return t}function Kr(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:$t($r(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"?Br:Wr)(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 Hr})(n))return{values:{},errors:$t(Gr(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 Yr=e=>{const s=ft(),{pushError:t}=Cs(),{data:i}=Jt({...Xt(),staleTime:1/0}),o=i?.accounts.find(j=>j.accountId===e)?.composeLanguages,d=F.useMemo(()=>o&&o.length>0?[...o]:Fs(navigator.languages),[o]),n=Se({...es(),onSuccess:()=>{s.invalidateQueries({queryKey:Te()})},onError:j=>{t(Os("Couldn't save languages","The writing languages weren't saved.",j))}}),u=F.useCallback(j=>{e&&n.mutate({path:{accountId:e},body:{composeLanguages:j}})},[e,n]);return{languages:d,setLanguages:u,isSaving:n.isPending}},Qr=e=>e.authType==="oauthMicrosoft",Zr="••••••••••",Jr=e=>{const s=e.smtpUsername?.trim();return s?s!==e.username:!1},Xr=Ls({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:Re(),imapStartTls:Re(),smtpHost:be().optional(),smtpPort:Et.number().int().min(1).max(65535).optional(),smtpTls:Re().optional(),smtpStartTls:Re().optional(),smtpUsername:be().optional(),smtpPassword:be().optional(),useDifferentSmtpCreds:Re().optional()}),ea=({isOpen:e,onClose:s,account:t,focusSmtp:i})=>{const o=ft(),d=!!t,[n,u]=F.useState(!1),[j,E]=F.useState(""),[P,U]=F.useState(!1),R=Vt(j),O=!!R&&!P,_=F.useRef(null),f=Ir({resolver:Kr(Xr),defaultValues:{email:"",displayName:"",username:"",password:"",imapHost:"",imapPort:993,imapTls:!0,imapStartTls:!1,smtpHost:"",smtpPort:587,smtpTls:!1,smtpStartTls:!0,useDifferentSmtpCreds:!1}});F.useEffect(()=>{if(t){const h=Jr(t);f.reset({email:t.email,displayName:t.displayName||"",username:t.username||"",password:Zr,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({...Is()}),re=Se({...Rs(),onSuccess:()=>{o.invalidateQueries({queryKey:Te()}),s()}}),N=Se({...es(),onSuccess:()=>{o.invalidateQueries({queryKey:Te()}),s()}}),W=()=>{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=ir({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,me=V?.smtpTls??h.smtpTls,Ne=V?.smtpStartTls??h.smtpStartTls,Fe={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:me,smtpStartTls:Ne,smtpUsername:h.useDifferentSmtpCreds&&h.smtpUsername||void 0,smtpPassword:h.useDifferentSmtpCreds&&h.smtpPassword||void 0};if(d&&t){const Pe={...Fe,password:n?h.password:void 0};N.mutate({path:{accountId:t.accountId},body:Pe})}else{const Pe={...Fe,password:h.password};re.mutate({body:Pe})}}),ne=re.isPending||N.isPending,{signature:ae,setSignature:ge,isSaving:oe}=ar(t?.accountId),[Q,le]=F.useState(ae.plainText),{languages:T,setLanguages:k,isSaving:D}=Yr(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(fr,{value:T,onChange:k,busy:D})]});F.useEffect(()=>{le(ae.plainText)},[ae.plainText]),F.useEffect(()=>{if(!e||!i)return;const h=_.current;if(!h)return;const V=window.setTimeout(()=>{h.scrollIntoView({behavior:"smooth",block:"start"})},250);return()=>window.clearTimeout(V)},[e,i]);const Z=F.useCallback(()=>{Q!==ae.plainText&&ge(Q,Q)},[Q,ae.plainText,ge]),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)},J=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)}},$=()=>{const h=f.getValues("imapHost");f.setValue("smtpHost",nr(h)),f.setValue("smtpTls",!1),f.setValue("smtpStartTls",!0),f.setValue("smtpPort",587)},fe=h=>{E(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 me=f.getValues("email").trim(),Ne=f.getValues("username")?.trim();me&&!Ne&&f.setValue("username",me)},Ee=R?.passwordHelp.text,we=Dt(b.data?.imapError,Ee),_e=Dt(b.data?.smtpError,Ee);return(t?Qr(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(Ms,{id:"account-provider",value:j,onChange:h=>fe(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:P?"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:W,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(Ce,{className:"inline size-4 mr-1"}),b.data.imapSuccess?"IMAP Connected":we]})]})]}),a.jsxs("section",{ref:_,"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:$,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:()=>J("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:()=>J("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:()=>J("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(Ce,{className:"inline size-4 mr-1"}),b.data.smtpSuccess?"SMTP Connected":_e]})]})]}),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]=F.useState(""),[n,u]=F.useState(!1),[j,E]=F.useState(!1),P=Se({...Hs(),onSuccess:()=>{E(!0),setTimeout(()=>i(),2e3)}}),U=Se(zs()),R=()=>{P.isPending||(d(""),u(!1),E(!1),P.reset(),U.reset(),s())},O=()=>{if(o.trim().toLowerCase()!==t.toLowerCase()){u(!0);return}u(!1),P.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(Ce,{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(or,{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:_=>{d(_.target.value),n&&u(!1),P.isError&&P.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."}),P.isError&&a.jsx("p",{className:"mt-1.5 text-xs text-danger",role:"alert",children:P.error instanceof Error?P.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":P.isPending,children:P.isPending?"Deleting…":"Delete everything"})]})]})]})}function ta(e){const{Account:s}=Us();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 sa(){const[e,s]=F.useState(!1);return a.jsxs("section",{className:"mt-8 border-t border-line pt-6",children:[a.jsx(mr,{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(ta,{open:e,onClose:()=>s(!1)})]})}function ra(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 aa(e){const s=e.split("@")[0]??"";return s?s.split(/[._-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" "):e}function ia(e){const s=e.displayName?.trim();return s||aa(e.email)}function na(e){if(!e.lastSyncAt)return"never synced";const s=cr(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"}function oa(e){return e.connectionState==="credentials_missing"}const la=()=>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 Pa(){const e=_t.useSearch(),s=Bs({from:_t.fullPath}),[t,i]=F.useState(!0),[o,d]=F.useState(!1),[n,u]=F.useState(!1),[j,E]=F.useState(null),[P,U]=F.useState(!1),[R,O]=F.useState(null),[_,f]=F.useState(null),[b,re]=F.useState(null),[N,W]=F.useState(null),I=ft(),{data:A,isPending:ne,isError:ae,error:ge,refetch:oe}=Jt(Xt());F.useEffect(()=>{e.editAccountId&&(E(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]),F.useEffect(()=>{e.connected&&(f("Account connected successfully."),E(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]),F.useEffect(()=>{e.oauthError&&(re(ra(e.oauthError)),W(null),s({search:{oauthError:void 0,connected:void 0,editAccountId:void 0,focusSmtp:void 0},replace:!0}))},[e.oauthError,s]),tr(N!==null,()=>{I.invalidateQueries({queryKey:Te()})}),F.useEffect(()=>{if(!N||!A)return;const S=A.accounts.find(J=>J.accountId===N);(!S||!Zt(S))&&W(null)},[A,N]);const Q=sr(S=>{W(null),S==="stalled"&&re(rr)}),le=Se({...qs(),onSuccess:S=>{Q(),window.location.assign(S.authorizationUrl)},onError:S=>{re(S instanceof Error?S.message:"Failed to start reconnect"),W(null)}}),T=Se({...Ws(),onSuccess:()=>{I.invalidateQueries({queryKey:Te()}),O(null)}}),k=A?.accounts.find(S=>S.accountId===R),D=A?.accounts.find(S=>S.accountId===j),q=()=>{d(!1),u(!1),E(null),U(!1)},Z=S=>{const J=Ks[S];J&&s({to:J})};return a.jsxs(Zs,{items:$s,activeId:"accounts",title:"Accounts",description:"Every account keeps syncing — muted ones just stay out of unified views.",help:dr,helpOpen:t,onToggleHelp:()=>i(S=>!S),onSelect:Z,onBackToMail:()=>{s({to:"/mail"})},children:[_&&a.jsx(Pt,{tone:"success",variant:"soft","data-testid":"oauth-success-banner",onDismiss:()=>f(null),children:_}),b&&a.jsx(Pt,{tone:"danger",variant:"soft","data-testid":"oauth-error-banner",onDismiss:()=>re(null),children:b}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx(Gs,{tone:"neutral",children:ne||ae?"accounts":`${A.accounts.length} ${A.accounts.length===1?"account":"accounts"}`}),a.jsx(te,{variant:"primary",size:"sm",icon:a.jsx(kt,{className:"size-3.5"}),onClick:()=>u(!0),children:"Add account"})]}),ne?a.jsx(la,{}):ae?a.jsx(lr,{title:"Couldn't load accounts",error:ge,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(kt,{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 J=Zt(S),$=oa(S),fe=S.authType==="oauthMicrosoft",Ee=N===S.accountId,we=J&&fe?{label:"Reconnect",variant:"secondary",busy:Ee,busyLabel:"Redirecting…",onClick:()=>{W(S.accountId),le.mutate({body:{email:S.email}})}}:$?{label:"Enter password",variant:"secondary",onClick:()=>E(S.accountId)}:Qt(S)==="error"?{label:"Reconnect",variant:"secondary",onClick:()=>E(S.accountId)}:{label:"Manage",variant:"ghost",onClick:()=>E(S.accountId)},_e=a.jsx(Qs,{actions:[we],destructive:{label:"Delete account",iconOnly:!0,icon:a.jsx(Ys,{className:"size-3.5"}),onClick:()=>O(S.accountId)}});return a.jsx(Js,{label:ia(S),email:S.email,connector:fe?"Microsoft 365":"IMAP",syncLabel:na(S),state:Qt(S),errorDetail:J?"Re-authentication required":$?"Imported from a config file, which carries no password. Enter one to start syncing.":S.lastError,trailing:_e},S.accountId)})}),n&&a.jsx("div",{className:"fixed inset-0 z-40 overflow-auto bg-canvas",children:a.jsx(er,{skipWelcome:!0,onComplete:()=>{u(!1),I.invalidateQueries({queryKey:Te()})},onCancel:()=>u(!1)})}),a.jsx(ea,{isOpen:o||!!j,account:D,focusSmtp:P,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(Ce,{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?"}),k&&a.jsx("p",{className:"text-center",children:k.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(sa,{})]})}export{Pa as component,ra as mapOauthError};
1
+ import{j as a,an as De,f as te,W as Ps,X as Ce,ao as ks,ap as Vs,aq as ut,E as Ds,t as Ge,ar as ee,h as ft,as as Cs,c as Jt,d as Xt,r as F,at as Fs,i as Se,au as Os,o as Te,l as es,av as Is,aw as Rs,ax as Ms,ay as ve,az as At,L as it,aA as Tt,aB as Ls,aC as Re,aD as be,aE as Et,aa as Us,aF as Hs,aG as zs,aH as ts,aI as _t,u as Bs,n as qs,aJ as Ws,aK as $s,B as Pt,g as Gs,aL as kt,aM as Ks,a2 as Ys}from"./index-Bcu7BqZh.js";import{R as Qs}from"./row-actions-D6pg-4y5.js";import{S as Zs,A as Js}from"./settings-screen-EigWdTdk.js";import{g as Vt,P as Xs,O as er}from"./OnboardingWizard-Dpl2R9Cy.js";import{s as Be,u as tr,b as sr,R as rr}from"./credential-steps-DJcQCoMN.js";import{u as ar}from"./useSignature-BISqUCGf.js";import{c as ir,a as Dt,d as nr}from"./account-form-helpers-DhckT_PN.js";import{D as or}from"./download-CiAfXfNQ.js";import{E as lr}from"./ErrorState-BN1KI1QC.js";import{f as cr}from"./format-CxG3FNVs.js";import{a as dr}from"./help-copy-DC0qUPIv.js";import"./avatar-jIsSo2Zf.js";import"./chevron-left-DLqD6AAq.js";import"./menu-BXqls5WZ.js";import"./circle-help-Bn8ystJn.js";import"./kbd-wWeybs89.js";import"./mail-WRNyVFjV.js";import"./card-BvJM4Bar.js";const ur=e=>{const s=new Set(e.map(ks));return Vs.map(t=>t.tag).filter(t=>!s.has(t)).sort((t,i)=>De(t).localeCompare(De(i)))},fr=({value:e,onChange:s,busy:t=!1})=>{const i=ur(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:De(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(Ps,{className:"size-3.5"}),disabled:t,"aria-label":`Write new messages in ${De(o)} by default`,onClick:()=>s([o,...e.filter(n=>n!==o)]),children:"Default"}),a.jsx(te,{variant:"ghost",size:"sm",icon:a.jsx(Ce,{className:"size-3.5"}),disabled:t||e.length===1,"aria-label":`Remove ${De(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:De(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 mr({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 Ds({id:"slide-panel",open:e,answers:{back: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(Ce,{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 Ue=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),pr=e=>H(e)&&e.target?Ue(e.target)?e.target.checked:e.target.value:e,hr=(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"],gr=/^\w*$/;var He=e=>gr.test(e),M=e=>e===void 0;const xr=/[.[\]'"]/;var Ze=e=>e.split(xr).filter(Boolean),y=(e,s,t)=>{if(!s||!H(e))return t;const i=He(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},pe=e=>typeof e=="boolean",ie=e=>typeof e=="function",C=(e,s,t)=>{let i=-1;const o=He(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=e[u];j=H(E)||Array.isArray(E)?E:isNaN(+o[i+1])?{}:[]}if(pt.includes(u))return;e[u]=j,e=e[u]}};const yr=ee.createContext(null);yr.displayName="HookFormControlContext";var vr=(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 br=Qe?ee.useLayoutEffect:ee.useEffect;var Y=e=>typeof e=="string",jr=(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 he(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))?!he(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 Le=(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(Le(u,s))break}else if(H(u)&&Le(u,s))break}}};var Ot=(e,s,t)=>{const i=y(e,t),o=Array.isArray(i)?i:[];return C(o,rs,s[t]),C(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)||pe(e)&&!e)return{type:t,message:Y(e)?e:"",ref:s}}var Ve=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:E,minLength:P,min:U,max:R,pattern:O,validate:_,name:f,valueAsNumber:b,mount:re}=e._f,N=y(t,f);if(!re||s.has(f))return{};const W=u?u[0]:n,I=T=>{if(o&&W.reportValidity){const k=pe(T)?"":T||"";u?u.forEach(D=>D.setCustomValidity(k)):W.setCustomValidity(k),W.reportValidity()}},A={},ne=gt(n),ae=Ue(n),ge=ne||ae,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,k,D,q=de.maxLength,Z=de.minLength)=>{const S=T?k:D;A[f]={type:T?q:Z,message:S,ref:n,...Q(T?q:Z,S)}};if(d?!Array.isArray(N)||!N.length:j&&(!ge&&(oe||K(N))||pe(N)&&!N||ae&&!as(u).isValid||ne&&!is(u).isValid)){const{value:T,message:k}=Y(j)?{value:!!j,message:j}:Ve(j);if(T&&(A[f]={type:de.required,message:k,ref:W,...Q(de.required,k)},!i))return I(k),A}if(!oe&&(!K(U)||!K(R))){let T,k;const D=Ve(R),q=Ve(U);if(!K(N)&&!isNaN(N)){const Z=n.valueAsNumber||N&&+N;K(D.value)||(T=Z>D.value),K(q.value)||(k=Z<q.value)}else{const Z=n.valueAsDate||new Date(N),S=fe=>new Date(new Date().toDateString()+" "+fe),J=n.type=="time",$=n.type=="week";Y(D.value)&&N&&(T=J?S(N)>S(D.value):$?N>D.value:Z>new Date(D.value)),Y(q.value)&&N&&(k=J?S(N)<S(q.value):$?N<q.value:Z<new Date(q.value))}if((T||k)&&(le(!!T,D.message,q.message,de.max,de.min),!i))return I(A[f].message),A}if((E||P)&&!oe&&(Y(N)||d&&Array.isArray(N))){const T=Ve(E),k=Ve(P),D=!K(T.value)&&N.length>+T.value,q=!K(k.value)&&N.length<+k.value;if((D||q)&&(le(D,T.message,k.message),!i))return I(A[f].message),A}if(O&&!oe&&Y(N)){const{value:T,message:k}=Ve(O);if(Ye(T)&&!N.match(T)&&(A[f]={type:de.pattern,message:k,ref:n,...Q(de.pattern,k)},!i))return I(k),A}if(_){if(ie(_)){const T=await _(N,t),k=Lt(T,W);if(k&&(A[f]={...k,...Q(de.validate,k.message)},!i))return I(k.message),A}else if(H(_)){let T={};for(const k in _){if(!G(T)&&!i)break;const D=Lt(await _[k](N,t),W,k);D&&(T={...D,...Q(k,D.message)},I(D.message),i&&(A[f]=T))}if(!G(T)&&(A[f]={ref:W,...T},!i))return A}}return I(!0),A},$e=e=>Array.isArray(e)?e:[e],ns=e=>Array.isArray(e)?e.filter(Boolean):[];function Sr(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 wr(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:He(s)?[s]:Ze(s);if(t.some(n=>pt.includes(String(n))))return e;const i=t.length===1?e:Sr(e,t),o=t.length-1,d=t[o];return i&&delete i[d],o!==0&&(H(i)&&G(i)||Array.isArray(i)&&wr(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},Nr=ee.createContext(null);Nr.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",Ar=e=>gt(e)||Ue(e),rt=e=>Ke(e)&&e.isConnected,Tr=e=>{for(const s in e)if(ie(e[s]))return!0;return!1};function ds(e){return Array.isArray(e)||H(e)&&!Tr(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)):he(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):Ue(s)?as(e.refs).value:ms(M(s.value)?e.ref.value:s.value,e)}var Er=(e,s,t,i)=>{const o={};for(const d of e){const n=y(s,d);n&&C(o,d,n._f)}return{criteriaMode:t,names:[...e],fields:o,shouldUseNativeValidation:i}},Me=e=>M(e)?e:Ye(e)?e.source:H(e)?Ye(e.value)?e.value.source:e.value:e;const Bt="AsyncFunction";var _r=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},Pr=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||He(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 kr=(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))},Vr=(e,s,t)=>!e||!s||e===s||$e(e).some(i=>i&&(t?i===s||i.startsWith(s+"."):i.startsWith(s)||s.startsWith(i))),Dr=(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,Cr=(e,s)=>!ns(y(e,s)).length&&B(e,s);const Fr={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 Or(e={}){let s={...Fr,...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={},E={};let P=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},_={...O};let f={..._};const b={array:Ht(),state:Ht()};let re=0;const N=s.criteriaMode===ue.all,W=(r,l)=>c=>{clearTimeout(E[r]),E[r]=setTimeout(l,c)},I=async r=>{if(!n.keepIsValid&&!s.disabled&&(_.isValid||f.isValid||r)){const l=++re;let c;s.resolver?(c=G((await D()).errors),l===re&&A()):c=await S({fields:i,onlyCheckValid:!0,eventType:ke.VALID}),l===re&&c!==t.isValid&&b.state.next({isValid:c})}},A=(r,l)=>{!s.disabled&&(_.isValidating||_.validatingFields||f.isValidating||f.validatingFields)&&((r||Array.from(u.mount)).forEach(c=>{c&&(l?C(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)},ae=(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&&C(i,r,g)}if(x&&Array.isArray(y(t.errors,r))){const g=c(y(t.errors,r),m.argA,m.argB);p&&C(t.errors,r,g),Cr(t.errors,r)}if((_.touchedFields||f.touchedFields)&&x&&Array.isArray(y(t.touchedFields,r))){const g=c(y(t.touchedFields,r),m.argA,m.argB);p&&C(t.touchedFields,r,g)}(_.dirtyFields||f.dirtyFields)&&ne(),b.state.next({name:r,isDirty:$(r,l),dirtyFields:t.dirtyFields,errors:t.errors,isValid:t.isValid})}else C(d,r,l)},ge=(r,l)=>{C(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=He(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?C(d,r,l?g:zt(p._f)):we(r,g),n.mount&&!n.action&&(I(),x&&t.isDirty&&(_.isDirty||f.isDirty)&&($()||(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=he(y(o,r),l);(_.isDirty||f.isDirty)&&(g=t.isDirty,t.isDirty=v.isDirty=!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):C(t.dirtyFields,r,!0),v.dirtyFields=t.dirtyFields,x=x||(_.dirtyFields||f.dirtyFields)&&g!==!w}if(c){const w=y(t.touchedFields,r);w||(C(t.touchedFields,r,c),v.touchedFields=t.touchedFields,x=x||(_.touchedFields||f.touchedFields)&&w!==c)}x&&p&&b.state.next(v)}return x?v:{}},k=(r,l,c,m)=>{const p=y(t.errors,r),x=(_.isValid||f.isValid)&&pe(l)&&t.isValid!==l;if(s.delayError&&c?(j[r]=W(r,()=>ge(r,c)),j[r](s.delayError)):(clearTimeout(E[r]),delete j[r],c?C(t.errors,r,c):B(t.errors,r),t.errors={...t.errors}),(c?!he(p,c):p)||!G(m)||x){const g={...m,...x&&pe(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,Er(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):C(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}):Pe(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),X=g._f&&_r(g._f),xe=_.validatingFields||_.isValidating||f.validatingFields||f.isValidating;X&&xe&&A([v.name],!0);const ye=await Ut(g,u.disabled,d,N,s.shouldUseNativeValidation&&!l,L);if(X&&xe&&A([v.name]),ye[v.name]&&(p.valid=!1,l)||(!l&&(y(ye,v.name)?L?Ot(t.errors,ye,v.name):C(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},J=()=>{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))&&Xe(r)}u.unMount=new Set},$=(r,l)=>(r&&l&&C(d,r,l),!he(n.mount?d:o,o)),fe=(r,l,c)=>jr(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&&C(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?Ue(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&&me(r,{delayError:c.delayError})},_e=(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)?_e(v,g,c,m,p):we(v,g,c,m,p)}},Je=(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=he(w,v);if(L||C(d,r,v),g)b.array.next({name:r,values:m?d:z(d)}),(_.isDirty||_.dirtyFields||f.isDirty||f.dirtyFields)&&c.shouldDirty&&(ne(),p||b.state.next({name:r,dirtyFields:t.dirtyFields,isDirty:$(r,v)}));else{const X=Array.isArray(v)&&!v.length||G(v);!x||x._f||K(v)||X?we(r,v,c,m,p):_e(r,v,c,m,p)}if(!L&&!p){const X=st(r,u),xe=m?d:z(d);b.state.next({...X&&t,name:n.mount||X?r:void 0,values:xe})}},h=(r,l,c={})=>Je(r,l,c,!1),V=(r,l={})=>{const c=ie(r)?r(d):r;if(!he(d,c)){d={...d,...c};const m=os(c);for(const p of u.mount)p in m&&Je(p,m[p],l,!0,!0);b.state.next({...t,name:void 0,type:void 0,...P?{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())||he(g,y(d,c,g))};if(p){let g,v;const w=l.type?zt(p._f):pr(r),L=r.type===ke.BLUR||r.type===ke.FOCUS_OUT,X=!Pr(p._f)&&!e.validate&&!s.resolver&&!y(t.errors,c)&&!p._f.deps,xe=X||Dr(L,y(t.touchedFields,c),t.isSubmitted,R,U),ye=st(c,u,L);if(C(d,c,w),L){if(!l||!l.readOnly){p._f.onBlur&&p._f.onBlur(r);const Ie=j[c];Ie&&Ie(0)}}else p._f.onChange&&p._f.onChange(r);const Oe=T(c,w,L),Es=!G(Oe)||ye;if(!L&&b.state.next({name:c,type:r.type,...P?{values:z(d)}:{}}),xe)return(!X||!t.isValid)&&(_.isValid||f.isValid)&&(s.mode==="onBlur"?L&&I():L||I()),Es&&b.state.next({name:c,...ye?{}:Oe});if(!s.resolver&&e.validate&&await Z({name:c,eventType:r.type}),!L&&ye&&b.state.next({...t}),s.resolver){const{errors:Ie}=await D([c]);if(A([c]),x(w),!m){!G(Oe)&&b.state.next(Oe);return}const _s=qt(t.errors,i,c),Nt=qt(Ie,i,_s.name||c);g=Nt.error,c=Nt.name,v=G(Ie)}else A([c],!0),g=(await Ut(p,u.disabled,d,N,s.shouldUseNativeValidation))[c],A([c]),x(w),m&&(g?v=!1:(_.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)&&me(p._f.deps),k(c,v,g,Oe))}},se=(r,l)=>{if(y(t.errors,l)&&r.focus)return r.focus(),1},me=async(r,l={})=>{let c,m;const p=$e(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]=W(r,()=>ge(r,x)),j[r](s.delayError)):(clearTimeout(E[r]),delete j[r])}return b.state.next({...!Y(r)||(_.isValid||f.isValid)&&c!==t.isValid?{}:{name:r},...s.resolver||!r?{isValid:c}:{},errors:t.errors}),l.shouldFocus&&!m&&Le(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))},Fe=(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)}),Pe=r=>{const l=r?$e(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;C(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)){P++;const{unsubscribe:c}=b.state.subscribe({next:p=>"values"in p&&r(p.values||fe(void 0,l),p)});let m=!1;return{unsubscribe:()=>{m||(m=!0,P--,c())}}}return fe(r,l,!0)},yt=r=>{var l;const c=!!(!((l=r.formState)===null||l===void 0)&&l.values);c&&P++;const{unsubscribe:m}=b.state.subscribe({next:x=>{if(Vr(r.name,x.name,r.exact)&&kr(x,r.formState||_,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,P--,m())}},Ss=r=>(n.mount=!0,f={...f,...r.formState},yt({...r,formState:{...O,...r.formState}})),Xe=(r,l={})=>{for(const c of r?$e(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:$()}:{}}),!l.keepIsValid&&I()},vt=({disabled:r,name:l})=>{if(pe(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=pe(l.disabled)||pe(s.disabled),p=!u.registerName.has(r)&&c&&c._f&&!c._f.mount;return C(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:pe(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:Me(l.min),max:Me(l.max),minLength:Me(l.minLength),maxLength:Me(l.maxLength),pattern:Me(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=Ar(g),w=c._f.refs||[];if(v?w.find(L=>L===g):g===c._f.ref)return;C(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)&&!(hr(u.array,r)&&n.action)&&u.unMount.add(r)}}},tt=()=>s.shouldFocusError&&!s.shouldUseNativeValidation&&Le(i,se,u.mount),ws=r=>{pe(r)&&(b.state.next({disabled:r}),Le(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),C(o,r,z(l.defaultValue))),l.keepTouched||B(t.touchedFields,r),l.keepDirty||(B(t.dirtyFields,r),t.isDirty=l.defaultValue?$(r,z(y(o,r))):$()),l.keepError||(B(t.errors,r),_.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),X=y(d,w),xe=y(x,w);L&&!M(X)?C(x,w,X):!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 X=L.closest("form");if(X){X.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)C(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=!_.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?$():!!(l.keepDefaultValues&&!he(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:Xe,getFieldState:Fe,handleSubmit:bt,setError:ze,_subscribe:yt,_runSchema:D,_updateIsValidating:A,_focusError:tt,_getWatch:fe,_getDirty:$,_setValid:I,_setFieldArray:ae,_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:J,_disableForm:ws,_subjects:b,_proxyFormState:_,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:me,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:Pe,unregister:Xe,setError:ze,setFocus:As,getFieldState:Fe};return{...wt,formControl:wt}}function Ir(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}=Or(e);s.current={...j,formState:o}}const n=s.current.control;return n._options=e,br(()=>{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&&!he(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(()=>vr(o,n),[n,o]),s.current}const Wt=(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?Wt(i.ref,t,e):i&&i.refs&&i.refs.forEach(o=>Wt(o,t,e))}},$t=(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(Rr(s.names||Object.keys(e),i)){const n=Object.assign({},y(t,i));C(n,"root",d),C(t,i,n)}else C(t,i,d)}return t},Rr=(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 E;Object.defineProperty(u,"_zod",{value:u._zod??{},enumerable:!1}),(E=u._zod).traits??(E.traits=new Set),u._zod.traits.add(e),s(u,j);for(const P in n.prototype)P in u||Object.defineProperty(u,P,{value:n.prototype[P].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 E=t?.Parent?new d:this;i(E,u),(j=E._zod).deferred??(j.deferred=[]);for(const P of E._zod.deferred)P();return E}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 Mr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const Lr={};function gs(e){return Lr}function Ur(e,s){return typeof s=="bigint"?s.toString():s}const xs=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function We(e){return typeof e=="string"?e:e?.message}function ys(e,s,t){const i={...e,path:e.path??[]};if(!e.message){const o=We(e.inst?._zod.def?.error?.(e))??We(s?.error?.(e))??We(t.customError?.(e))??We(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,Ur,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Hr=hs("$ZodError",vs),bs=hs("$ZodError",vs,{Parent:Error}),zr=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 Mr;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},Br=zr(bs),qr=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},Wr=qr(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 $r(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(P){return P.errors.forEach(function(U){return e.push(U)})}),s){var j=t[n].types,E=j&&j[i.code];t[n]=xt(n,s,t,o,E?[].concat(E,i.message):i.message)}e.shift()}return t}function Gr(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 E=t[u].types,P=E&&E[o.code];t[u]=xt(u,s,t,d,P?[].concat(P,o.message):o.message)}e.shift()};e.length;)i();return t}function Kr(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:$t($r(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"?Br:Wr)(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 Hr})(n))return{values:{},errors:$t(Gr(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 Yr=e=>{const s=ft(),{pushError:t}=Cs(),{data:i}=Jt({...Xt(),staleTime:1/0}),o=i?.accounts.find(j=>j.accountId===e)?.composeLanguages,d=F.useMemo(()=>o&&o.length>0?[...o]:Fs(navigator.languages),[o]),n=Se({...es(),onSuccess:()=>{s.invalidateQueries({queryKey:Te()})},onError:j=>{t(Os("Couldn't save languages","The writing languages weren't saved.",j))}}),u=F.useCallback(j=>{e&&n.mutate({path:{accountId:e},body:{composeLanguages:j}})},[e,n]);return{languages:d,setLanguages:u,isSaving:n.isPending}},Qr=e=>e.authType==="oauthMicrosoft",Zr="••••••••••",Jr=e=>{const s=e.smtpUsername?.trim();return s?s!==e.username:!1},Xr=Ls({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:Re(),imapStartTls:Re(),smtpHost:be().optional(),smtpPort:Et.number().int().min(1).max(65535).optional(),smtpTls:Re().optional(),smtpStartTls:Re().optional(),smtpUsername:be().optional(),smtpPassword:be().optional(),useDifferentSmtpCreds:Re().optional()}),ea=({isOpen:e,onClose:s,account:t,focusSmtp:i})=>{const o=ft(),d=!!t,[n,u]=F.useState(!1),[j,E]=F.useState(""),[P,U]=F.useState(!1),R=Vt(j),O=!!R&&!P,_=F.useRef(null),f=Ir({resolver:Kr(Xr),defaultValues:{email:"",displayName:"",username:"",password:"",imapHost:"",imapPort:993,imapTls:!0,imapStartTls:!1,smtpHost:"",smtpPort:587,smtpTls:!1,smtpStartTls:!0,useDifferentSmtpCreds:!1}});F.useEffect(()=>{if(t){const h=Jr(t);f.reset({email:t.email,displayName:t.displayName||"",username:t.username||"",password:Zr,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({...Is()}),re=Se({...Rs(),onSuccess:()=>{o.invalidateQueries({queryKey:Te()}),s()}}),N=Se({...es(),onSuccess:()=>{o.invalidateQueries({queryKey:Te()}),s()}}),W=()=>{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=ir({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,me=V?.smtpTls??h.smtpTls,Ne=V?.smtpStartTls??h.smtpStartTls,Fe={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:me,smtpStartTls:Ne,smtpUsername:h.useDifferentSmtpCreds&&h.smtpUsername||void 0,smtpPassword:h.useDifferentSmtpCreds&&h.smtpPassword||void 0};if(d&&t){const Pe={...Fe,password:n?h.password:void 0};N.mutate({path:{accountId:t.accountId},body:Pe})}else{const Pe={...Fe,password:h.password};re.mutate({body:Pe})}}),ne=re.isPending||N.isPending,{signature:ae,setSignature:ge,isSaving:oe}=ar(t?.accountId),[Q,le]=F.useState(ae.plainText),{languages:T,setLanguages:k,isSaving:D}=Yr(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(fr,{value:T,onChange:k,busy:D})]});F.useEffect(()=>{le(ae.plainText)},[ae.plainText]),F.useEffect(()=>{if(!e||!i)return;const h=_.current;if(!h)return;const V=window.setTimeout(()=>{h.scrollIntoView({behavior:"smooth",block:"start"})},250);return()=>window.clearTimeout(V)},[e,i]);const Z=F.useCallback(()=>{Q!==ae.plainText&&ge(Q,Q)},[Q,ae.plainText,ge]),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)},J=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)}},$=()=>{const h=f.getValues("imapHost");f.setValue("smtpHost",nr(h)),f.setValue("smtpTls",!1),f.setValue("smtpStartTls",!0),f.setValue("smtpPort",587)},fe=h=>{E(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 me=f.getValues("email").trim(),Ne=f.getValues("username")?.trim();me&&!Ne&&f.setValue("username",me)},Ee=R?.passwordHelp.text,we=Dt(b.data?.imapError,Ee),_e=Dt(b.data?.smtpError,Ee);return(t?Qr(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(Ms,{id:"account-provider",value:j,onChange:h=>fe(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:P?"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:W,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(Ce,{className:"inline size-4 mr-1"}),b.data.imapSuccess?"IMAP Connected":we]})]})]}),a.jsxs("section",{ref:_,"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:$,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:()=>J("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:()=>J("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:()=>J("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(Ce,{className:"inline size-4 mr-1"}),b.data.smtpSuccess?"SMTP Connected":_e]})]})]}),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]=F.useState(""),[n,u]=F.useState(!1),[j,E]=F.useState(!1),P=Se({...Hs(),onSuccess:()=>{E(!0),setTimeout(()=>i(),2e3)}}),U=Se(zs()),R=()=>{P.isPending||(d(""),u(!1),E(!1),P.reset(),U.reset(),s())},O=()=>{if(o.trim().toLowerCase()!==t.toLowerCase()){u(!0);return}u(!1),P.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(Ce,{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(or,{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:_=>{d(_.target.value),n&&u(!1),P.isError&&P.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."}),P.isError&&a.jsx("p",{className:"mt-1.5 text-xs text-danger",role:"alert",children:P.error instanceof Error?P.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":P.isPending,children:P.isPending?"Deleting…":"Delete everything"})]})]})]})}function ta(e){const{Account:s}=Us();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 sa(){const[e,s]=F.useState(!1);return a.jsxs("section",{className:"mt-8 border-t border-line pt-6",children:[a.jsx(mr,{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(ta,{open:e,onClose:()=>s(!1)})]})}function ra(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 aa(e){const s=e.split("@")[0]??"";return s?s.split(/[._-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" "):e}function ia(e){const s=e.displayName?.trim();return s||aa(e.email)}function na(e){if(!e.lastSyncAt)return"never synced";const s=cr(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"}function oa(e){return e.connectionState==="credentials_missing"}const la=()=>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 Pa(){const e=_t.useSearch(),s=Bs({from:_t.fullPath}),[t,i]=F.useState(!0),[o,d]=F.useState(!1),[n,u]=F.useState(!1),[j,E]=F.useState(null),[P,U]=F.useState(!1),[R,O]=F.useState(null),[_,f]=F.useState(null),[b,re]=F.useState(null),[N,W]=F.useState(null),I=ft(),{data:A,isPending:ne,isError:ae,error:ge,refetch:oe}=Jt(Xt());F.useEffect(()=>{e.editAccountId&&(E(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]),F.useEffect(()=>{e.connected&&(f("Account connected successfully."),E(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]),F.useEffect(()=>{e.oauthError&&(re(ra(e.oauthError)),W(null),s({search:{oauthError:void 0,connected:void 0,editAccountId:void 0,focusSmtp:void 0},replace:!0}))},[e.oauthError,s]),tr(N!==null,()=>{I.invalidateQueries({queryKey:Te()})}),F.useEffect(()=>{if(!N||!A)return;const S=A.accounts.find(J=>J.accountId===N);(!S||!Zt(S))&&W(null)},[A,N]);const Q=sr(S=>{W(null),S==="stalled"&&re(rr)}),le=Se({...qs(),onSuccess:S=>{Q(),window.location.assign(S.authorizationUrl)},onError:S=>{re(S instanceof Error?S.message:"Failed to start reconnect"),W(null)}}),T=Se({...Ws(),onSuccess:()=>{I.invalidateQueries({queryKey:Te()}),O(null)}}),k=A?.accounts.find(S=>S.accountId===R),D=A?.accounts.find(S=>S.accountId===j),q=()=>{d(!1),u(!1),E(null),U(!1)},Z=S=>{const J=Ks[S];J&&s({to:J})};return a.jsxs(Zs,{items:$s,activeId:"accounts",title:"Accounts",description:"Every account keeps syncing — muted ones just stay out of unified views.",help:dr,helpOpen:t,onToggleHelp:()=>i(S=>!S),onSelect:Z,onBackToMail:()=>{s({to:"/mail"})},children:[_&&a.jsx(Pt,{tone:"success",variant:"soft","data-testid":"oauth-success-banner",onDismiss:()=>f(null),children:_}),b&&a.jsx(Pt,{tone:"danger",variant:"soft","data-testid":"oauth-error-banner",onDismiss:()=>re(null),children:b}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx(Gs,{tone:"neutral",children:ne||ae?"accounts":`${A.accounts.length} ${A.accounts.length===1?"account":"accounts"}`}),a.jsx(te,{variant:"primary",size:"sm",icon:a.jsx(kt,{className:"size-3.5"}),onClick:()=>u(!0),children:"Add account"})]}),ne?a.jsx(la,{}):ae?a.jsx(lr,{title:"Couldn't load accounts",error:ge,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(kt,{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 J=Zt(S),$=oa(S),fe=S.authType==="oauthMicrosoft",Ee=N===S.accountId,we=J&&fe?{label:"Reconnect",variant:"secondary",busy:Ee,busyLabel:"Redirecting…",onClick:()=>{W(S.accountId),le.mutate({body:{email:S.email}})}}:$?{label:"Enter password",variant:"secondary",onClick:()=>E(S.accountId)}:Qt(S)==="error"?{label:"Reconnect",variant:"secondary",onClick:()=>E(S.accountId)}:{label:"Manage",variant:"ghost",onClick:()=>E(S.accountId)},_e=a.jsx(Qs,{actions:[we],destructive:{label:"Delete account",iconOnly:!0,icon:a.jsx(Ys,{className:"size-3.5"}),onClick:()=>O(S.accountId)}});return a.jsx(Js,{label:ia(S),email:S.email,connector:fe?"Microsoft 365":"IMAP",syncLabel:na(S),state:Qt(S),errorDetail:J?"Re-authentication required":$?"Imported from a config file, which carries no password. Enter one to start syncing.":S.lastError,trailing:_e},S.accountId)})}),n&&a.jsx("div",{className:"fixed inset-0 z-40 overflow-auto bg-canvas",children:a.jsx(er,{skipWelcome:!0,onComplete:()=>{u(!1),I.invalidateQueries({queryKey:Te()})},onCancel:()=>u(!1)})}),a.jsx(ea,{isOpen:o||!!j,account:D,focusSmtp:P,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(Ce,{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?"}),k&&a.jsx("p",{className:"text-center",children:k.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(sa,{})]})}export{Pa as component,ra as mapOauthError};
@@ -1,4 +1,4 @@
1
- import{e as v,j as e,aH as T,f as l,aP as p,g as y,aQ as D,aR as L,B as z,aq as h,aS as S,r as x,L as b,aT as g,t as B,h as V,aU as q,G as U,aV as H,aW as F,c as Q,aX as Y,aY as I,aZ as M,a_ as G,R as J,a$ as W,b0 as Z,b1 as K,u as X,aK as ee,aM as se}from"./index-DSi1cxOe.js";import{S as te}from"./settings-screen-Bxg7gmcf.js";import{e as ae}from"./config-import-Bci3Xwoi.js";import{u as ne}from"./sections-qjX9kREL.js";import{C as ie,a as re,b as le,c as oe,F as ce}from"./card-CCWeYAnf.js";import{D as k}from"./download-BJz8IQEk.js";import{B as A}from"./bug-C_nJpj_h.js";import{C as _}from"./circle-check-CZSsF6OM.js";import{f as de}from"./ErrorState-D8AQD4QI.js";import{u as me}from"./useQueries-7N8So0Dt.js";import{R as C}from"./rotate-ccw-D4M_tmYq.js";import{C as xe}from"./clock-BLND_Uqn.js";import{S as he}from"./shield-check-Cvh9jlfx.js";import{b as ue}from"./help-copy-B9B_sS4o.js";import"./avatar-BUFzqa0m.js";import"./chevron-left-dl0LCVOD.js";import"./menu-ByhBSEmm.js";import"./circle-help-r3PbN8xG.js";import"./kbd-EJpwdDwi.js";const pe=v("CloudOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193",key:"yfwify"}],["path",{d:"M21.532 16.5A4.5 4.5 0 0 0 17.5 10h-1.79A7.008 7.008 0 0 0 10 5.07",key:"jlfiyv"}]]);const fe=v("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);const w=v("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]),ge={BodyParse:"The message is built in a way Remit could not read."};function je(s){return ge[s]}function E(s){return s.split(";")[0].trim()}const R=/^[A-Za-z0-9!#$%&'*+._-]+$/,$=/^[A-Za-z0-9!#$%&'*+._-]+\/[A-Za-z0-9!#$%&'*+._-]+$/;function j(s,t){return t.test(s)?`\`${s}\``:`\`${JSON.stringify(s).replace(/`/g,"\\u0060")}\` (malformed)`}function Ne(s){const t=E(s);return $.test(t)?t:JSON.stringify(t)}const N="_not read_";function be(s){return s.length===0?["(no MIME structure was read)"]:s.map(t=>`${" ".repeat(t.depth)}- ${Ne(t.contentType)}`)}const ve="_No message content, addresses, subject, attachment names or parser output are included._";function O(s){return{head:[`### Message quarantined at \`${s.failureStage}\``,"",`- **Failure**: \`${s.failureCode}\``,`- **Folder role**: ${s.mailboxRole??"_none appointed_"}`,`- **Failing part**: ${s.failurePartPath==null?"_whole message_":`\`${s.failurePartPath}\``}`,`- **Attempts before quarantine**: ${s.attempts}`,`- **Worker build**: ${s.workerVersion}`,`- **Message-ID hash**: ${s.messageIdHash==null?"_none declared_":`\`${s.messageIdHash}\``}`,"","#### Message shape","",`- **Content-Type**: ${s.contentType==null?N:j(E(s.contentType),$)}`,`- **Content-Transfer-Encoding**: ${s.transferEncoding==null?N:j(s.transferEncoding,R)}`,`- **Charset**: ${s.charset==null?"_not declared_":j(s.charset,R)}`,`- **Size**: ${s.sizeBytes==null?N:`${s.sizeBytes} bytes`}`,"","MIME structure:"].join(`
1
+ import{e as v,j as e,aH as T,f as l,aP as p,g as y,aQ as D,aR as L,B as z,aq as h,aS as S,r as x,L as b,aT as g,t as B,h as V,aU as q,G as U,aV as H,aW as F,c as Q,aX as Y,aY as I,aZ as M,a_ as G,R as J,a$ as W,b0 as Z,b1 as K,u as X,aK as ee,aM as se}from"./index-Bcu7BqZh.js";import{S as te}from"./settings-screen-EigWdTdk.js";import{e as ae}from"./config-import-B94_wCpF.js";import{u as ne}from"./sections-DT0azgaj.js";import{C as ie,a as re,b as le,c as oe,F as ce}from"./card-BvJM4Bar.js";import{D as k}from"./download-CiAfXfNQ.js";import{B as A}from"./bug-D1kIQg-0.js";import{C as _}from"./circle-check-DtpNGVtU.js";import{f as de}from"./ErrorState-BN1KI1QC.js";import{u as me}from"./useQueries-4YYdm8Yg.js";import{R as C}from"./rotate-ccw-Coc_HVFv.js";import{C as xe}from"./clock-a9wtJIFb.js";import{S as he}from"./shield-check-CWXSXjpp.js";import{b as ue}from"./help-copy-DC0qUPIv.js";import"./avatar-jIsSo2Zf.js";import"./chevron-left-DLqD6AAq.js";import"./menu-BXqls5WZ.js";import"./circle-help-Bn8ystJn.js";import"./kbd-wWeybs89.js";const pe=v("CloudOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193",key:"yfwify"}],["path",{d:"M21.532 16.5A4.5 4.5 0 0 0 17.5 10h-1.79A7.008 7.008 0 0 0 10 5.07",key:"jlfiyv"}]]);const fe=v("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);const w=v("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]),ge={BodyParse:"The message is built in a way Remit could not read."};function je(s){return ge[s]}function E(s){return s.split(";")[0].trim()}const R=/^[A-Za-z0-9!#$%&'*+._-]+$/,$=/^[A-Za-z0-9!#$%&'*+._-]+\/[A-Za-z0-9!#$%&'*+._-]+$/;function j(s,t){return t.test(s)?`\`${s}\``:`\`${JSON.stringify(s).replace(/`/g,"\\u0060")}\` (malformed)`}function Ne(s){const t=E(s);return $.test(t)?t:JSON.stringify(t)}const N="_not read_";function be(s){return s.length===0?["(no MIME structure was read)"]:s.map(t=>`${" ".repeat(t.depth)}- ${Ne(t.contentType)}`)}const ve="_No message content, addresses, subject, attachment names or parser output are included._";function O(s){return{head:[`### Message quarantined at \`${s.failureStage}\``,"",`- **Failure**: \`${s.failureCode}\``,`- **Folder role**: ${s.mailboxRole??"_none appointed_"}`,`- **Failing part**: ${s.failurePartPath==null?"_whole message_":`\`${s.failurePartPath}\``}`,`- **Attempts before quarantine**: ${s.attempts}`,`- **Worker build**: ${s.workerVersion}`,`- **Message-ID hash**: ${s.messageIdHash==null?"_none declared_":`\`${s.messageIdHash}\``}`,"","#### Message shape","",`- **Content-Type**: ${s.contentType==null?N:j(E(s.contentType),$)}`,`- **Content-Transfer-Encoding**: ${s.transferEncoding==null?N:j(s.transferEncoding,R)}`,`- **Charset**: ${s.charset==null?"_not declared_":j(s.charset,R)}`,`- **Size**: ${s.sizeBytes==null?N:`${s.sizeBytes} bytes`}`,"","MIME structure:"].join(`
2
2
  `),structure:be(s.structure).join(`
3
3
  `),disclaimer:ve}}function ye(s){const{head:t,structure:a,disclaimer:n}=O(s);return[t,"","```",a,"```","",n].join(`
4
4
  `)}function ke(s){return`Message quarantined: ${s.failureCode} at ${s.failureStage}`}function we({entry:s,onClose:t,issueUrl:a,onCopy:n}){if(!s)return null;const i=ye(s);return e.jsx(T,{open:!0,onClose:t,title:"Report this message",children:e.jsxs("div",{className:"flex max-h-[80vh] flex-col",children:[e.jsxs("header",{className:"space-y-1 border-b border-line px-4 py-3",children:[e.jsx("h3",{className:"text-sm font-semibold text-fg",children:"Report this message"}),e.jsx("p",{className:"text-xs text-fg-muted",children:"This is everything the report contains. It describes the shape of the message — never its contents, addresses, subject, attachment names, or the parser's own error text."})]}),e.jsx("pre",{className:"flex-1 overflow-auto bg-surface-sunken px-4 py-3 text-2xs leading-relaxed whitespace-pre-wrap text-fg-muted",children:i}),e.jsxs("footer",{className:"flex flex-wrap items-center justify-end gap-2 border-t border-line px-4 py-3",children:[e.jsx(l,{variant:"ghost",size:"sm",onClick:t,children:"Cancel"}),e.jsx(l,{variant:"secondary",size:"sm",icon:e.jsx(fe,{className:"size-3.5"}),onClick:()=>n(i),children:"Copy report"}),e.jsx(p,{external:!0,size:"sm",href:a,icon:e.jsx(w,{className:"size-3.5"}),children:"Open on GitHub"})]})]})})}function Ce(s){return new Date(s).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}function Re({entry:s,onCutBug:t}){return e.jsxs("li",{className:"flex flex-col gap-2 border-b border-line px-row-inset py-3 last:border-b-0 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("p",{className:"text-sm text-fg",children:je(s.failureStage)}),e.jsx("p",{className:"truncate text-xs text-fg-muted",title:s.failureMessage,children:s.failureMessage}),e.jsxs("p",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-2xs text-fg-subtle",children:[s.mailboxRole&&e.jsx(y,{tone:"warning",children:D(s.mailboxRole)}),e.jsx("span",{className:"truncate",title:s.mailboxPath,children:L(s.mailboxPath,s.mailboxDelimiter)}),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{children:`uid ${s.uid}`}),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{children:Ce(s.quarantinedAt)}),s.attempts>1&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{children:`${s.attempts} attempts`})]})]})]}),e.jsx(l,{variant:"secondary",size:"sm",className:"shrink-0",icon:e.jsx(A,{className:"size-3.5"}),onClick:()=>t(s),children:"Cut a bug"})]})}function Te({entries:s,onCutBug:t}){return e.jsxs("section",{className:"space-y-3",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Messages set aside"}),e.jsx("p",{className:"text-xs text-fg-muted",children:"Mail Remit could not read is set aside here instead of being skipped, so nothing goes missing quietly. The rest of the folder keeps syncing. Recovering a set-aside message is a re-sync, not a per-row action."})]}),s.length===0&&e.jsxs("div",{className:"flex items-center gap-2 rounded-sm border border-line bg-surface px-row-inset py-3",children:[e.jsx(_,{className:"size-4 shrink-0 text-positive","aria-hidden":!0}),e.jsx("p",{className:"text-sm text-fg-muted",children:"Every message has been read successfully. Nothing is set aside."})]}),s.length>1&&e.jsx(z,{tone:"warning",children:e.jsxs("p",{className:"flex items-start gap-2",children:[e.jsx(h,{className:"mt-0.5 size-4 shrink-0","aria-hidden":!0}),e.jsxs("span",{children:[e.jsx("span",{className:"font-semibold",children:`${s.length} messages could not be read.`})," ","More than one means something is wrong with how Remit reads mail, not with the mail. Reporting one of these gets it fixed."]})]})}),s.length>0&&e.jsx("ul",{className:"rounded-sm border border-line bg-surface",children:s.map(a=>e.jsx(Re,{entry:a,onCutBug:t},a.quarantineId))})]})}const ze=["Remit restarts. Mail stops loading for about a minute and this page will lose its connection while that happens.","Nothing is sent, deleted or moved. Your mail stays at your provider.","If the new version does not come back up, the version you are running now is restored automatically."];function Se({open:s,currentVersion:t,release:a,appliesSchemaMigration:n=!1,onClose:i,onConfirm:r}){return s?e.jsx(T,{open:!0,onClose:i,title:`Install Remit ${a.version}`,children:e.jsxs("div",{className:"flex max-h-[80vh] flex-col",children:[e.jsxs("header",{className:"space-y-1 border-b border-line px-4 py-3",children:[e.jsxs("h3",{className:"text-sm font-semibold text-fg",children:["Install Remit ",a.version,"?"]}),e.jsxs("p",{className:"text-xs text-fg-muted",children:["You are on ",t,". ",a.version," was released"," ",S(a.releasedAt),"."]})]}),e.jsxs("div",{className:"flex-1 space-y-3 overflow-auto px-4 py-3",children:[e.jsx("p",{className:"text-sm text-fg-muted",children:a.summary}),e.jsxs("ul",{className:"space-y-2",children:[ze.map(o=>e.jsxs("li",{className:"flex gap-2 text-sm text-fg-muted",children:[e.jsx("span",{className:"mt-1.5 size-1.5 shrink-0 rounded-full bg-fg-subtle"}),e.jsx("span",{children:o})]},o)),n&&e.jsxs("li",{className:"flex gap-2 text-sm text-fg-muted",children:[e.jsx("span",{className:"mt-1.5 size-1.5 shrink-0 rounded-full bg-fg-subtle"}),e.jsx("span",{children:"This version updates the database while Remit is offline. The step forward cannot be undone by hand, but a failed start is still rolled back to the version and data you have now."})]})]}),e.jsx("p",{className:"text-xs text-fg-subtle",children:"Good moment for this: when you are not waiting on a message."})]}),e.jsxs("footer",{className:"flex flex-wrap items-center justify-end gap-2 border-t border-line px-4 py-3",children:[e.jsx(l,{variant:"ghost",size:"sm",onClick:i,children:"Not now"}),e.jsx(p,{variant:"secondary",size:"sm",external:!0,href:a.releaseNotesUrl,icon:e.jsx(w,{className:"size-3.5"}),children:"Release notes"}),e.jsx(l,{size:"sm",icon:e.jsx(k,{className:"size-3.5"}),onClick:r,children:"Install and restart"})]})]})}):null}function m({children:s,tone:t}){return e.jsx("div",{className:B("rounded-sm border bg-surface px-row-inset py-3",t==="danger"?"border-danger/50":"border-line"),children:s})}function Ie({state:s,onCheck:t,onInstall:a,onDismissResult:n,now:i=Date.now()}){const[r,o]=x.useState(null),c=s.status==="checking",d=s.status==="available",u=()=>{if(c){o("Already checking. The result appears here in a moment.");return}o(null),t()},f=()=>{if(!d&&s.status!=="rolledBack"&&s.status!=="abandoned"){o("There is no update to install. Check for updates first — if one is found it appears here.");return}o(null),a()},P=(()=>{switch(s.status){case"upToDate":return e.jsx(m,{children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(_,{className:"size-4 shrink-0 text-positive","aria-hidden":!0}),e.jsxs("p",{className:"text-sm text-fg",children:["Remit ",s.version," is the latest version.",e.jsxs("span",{className:"text-fg-subtle",children:[" ","Checked ",g(s.checkedAt,i),"."]})]})]}),e.jsx(l,{variant:"secondary",size:"sm",className:"shrink-0",onClick:u,children:"Check again"})]})});case"checking":return e.jsx(m,{children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(b,{className:"size-4 shrink-0 animate-spin text-fg-subtle","aria-hidden":!0}),e.jsxs("p",{className:"text-sm text-fg-muted",children:["Looking for a newer version. You are on ",s.version,"."]})]}),e.jsx(l,{variant:"secondary",size:"sm",className:"shrink-0",onClick:u,children:"Check again"})]})});case"neverChecked":return e.jsx(m,{children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[e.jsx(xe,{className:"mt-0.5 size-4 shrink-0 text-fg-subtle","aria-hidden":!0}),e.jsxs("p",{className:"text-sm text-fg-muted",children:["No update check has run yet. Remit checks for updates on its own in the background.",s.lastCheckedAt!==void 0&&e.jsxs("span",{className:"text-fg-subtle",children:[" ","Last checked"," ",g(s.lastCheckedAt,i),"."]})]})]}),e.jsx(l,{variant:"secondary",size:"sm",className:"shrink-0",onClick:u,children:"Check now"})]})});case"checkFailed":return e.jsx(m,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(pe,{className:"mt-0.5 size-4 shrink-0 text-fg-subtle","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("p",{className:"text-sm text-fg",children:"Could not reach the update source."}),e.jsx("p",{className:"text-xs text-fg-muted",children:s.reason}),e.jsxs("p",{className:"text-xs text-fg-subtle",children:["You are still on ",s.version," and it keeps working.",s.lastCheckedAt!==void 0&&e.jsxs(e.Fragment,{children:[" ","Last successful check"," ",g(s.lastCheckedAt,i),"."]})]})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(l,{variant:"secondary",size:"sm",onClick:u,children:"Try again"})})]})});case"available":return e.jsx(m,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"text-sm font-semibold text-fg",children:["Remit ",s.release.version]}),e.jsx(y,{tone:"accent",children:"update available"}),e.jsxs("span",{className:"text-2xs text-fg-subtle",children:["released ",S(s.release.releasedAt)," · you are on ",s.version]})]}),e.jsx("p",{className:"text-sm text-fg-muted",children:s.release.summary}),e.jsx("p",{className:"text-xs text-fg-subtle",children:"Installing restarts Remit, so mail stops loading for about a minute. If the new version does not come back up, the one you are running now is restored on its own."}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(l,{size:"sm",icon:e.jsx(k,{className:"size-3.5"}),onClick:f,children:["Install ",s.release.version]}),e.jsx(p,{variant:"secondary",size:"sm",external:!0,href:s.release.releaseNotesUrl,icon:e.jsx(w,{className:"size-3.5"}),children:"Release notes"})]})]})});case"applying":return e.jsx(m,{children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(b,{className:"size-4 shrink-0 animate-spin text-accent-2","aria-hidden":!0}),e.jsxs("p",{className:"text-sm text-fg-muted",children:["Installing Remit ",s.target,". The restart screen has the details."]})]})});case"succeeded":return e.jsx(z,{tone:"success",onDismiss:n,children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"font-semibold",children:["Updated to Remit ",s.version,"."]}),e.jsxs("p",{children:["You were on ",s.previousVersion,"."," ",e.jsx("a",{href:s.releaseNotesUrl,target:"_blank",rel:"noopener noreferrer",className:"underline",children:"See what changed"}),"."]})]})});case"rolledBack":return e.jsx(m,{tone:"danger",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(h,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("p",{className:"text-sm font-semibold text-fg",children:["Remit ",s.attemptedVersion," did not start. Remit reports that it put ",s.version," back."]}),e.jsxs("p",{className:"text-sm text-fg-muted",children:["You are running ",s.version," again. A failed update can still have changed things on the way — the log below is the only account of what it got as far as doing."]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-fg-subtle",children:"What Remit reported as the failure"}),e.jsx("code",{className:"block rounded-xs bg-danger-soft px-2 py-1 text-2xs text-danger",children:s.reason})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-fg-subtle",children:"Read the full log before trying again:"}),e.jsx("code",{className:"block rounded-xs bg-surface-sunken px-2 py-1 text-2xs text-fg-muted",children:s.logsCommand})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(l,{variant:"secondary",size:"sm",icon:e.jsx(C,{className:"size-3.5"}),onClick:f,children:["Try ",s.attemptedVersion," again"]}),e.jsxs(l,{variant:"ghost",size:"sm",onClick:n,children:["Stay on ",s.version]})]})]})});case"unreachable":return e.jsx(m,{tone:"danger",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(h,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("p",{className:"text-sm font-semibold text-fg",children:["Installing ",s.attemptedVersion," left the server unreachable."]}),e.jsx("p",{className:"text-sm text-fg-muted",children:"Remit has answered again since, but nothing here can say what happened during the silence."})]})]}),e.jsx("code",{className:"block rounded-xs bg-surface-sunken px-2 py-1 text-2xs text-fg-muted",children:s.logsCommand}),e.jsx("div",{className:"flex justify-end",children:e.jsx(l,{variant:"ghost",size:"sm",onClick:n,children:"Dismiss"})})]})});case"rollbackFailed":return e.jsx(m,{tone:"danger",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(h,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("p",{className:"text-sm font-semibold text-fg",children:["Remit ",s.attemptedVersion," did not start, and Remit could not put ",s.previousVersion," back."]}),e.jsx("p",{className:"text-sm text-fg-muted",children:"This is the one outcome Remit cannot resolve on its own. The server is in a half-changed state and needs you at a shell. The log below is the only account of where it stopped."})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-fg-subtle",children:"What Remit reported as the failure"}),e.jsx("code",{className:"block rounded-xs bg-danger-soft px-2 py-1 text-2xs text-danger",children:s.reason})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-fg-subtle",children:"Read the full log on the server:"}),e.jsx("code",{className:"block rounded-xs bg-surface-sunken px-2 py-1 text-2xs text-fg-muted",children:s.logsCommand})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(l,{variant:"ghost",size:"sm",onClick:n,children:"Dismiss"})})]})});case"abandoned":return e.jsx(m,{tone:"danger",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(h,{className:"mt-0.5 size-4 shrink-0 text-fg-subtle","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("p",{className:"text-sm font-semibold text-fg",children:["Remit ",s.attemptedVersion," was not installed. Nothing changed."]}),e.jsxs("p",{className:"text-sm text-fg-muted",children:["The update stopped before it altered anything. You are still running ",s.version,"."]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-fg-subtle",children:"What Remit reported"}),e.jsx("code",{className:"block rounded-xs bg-surface-sunken px-2 py-1 text-2xs text-fg-muted",children:s.reason})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-fg-subtle",children:"Read the full log before trying again:"}),e.jsx("code",{className:"block rounded-xs bg-surface-sunken px-2 py-1 text-2xs text-fg-muted",children:s.logsCommand})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(l,{variant:"secondary",size:"sm",icon:e.jsx(C,{className:"size-3.5"}),onClick:f,children:["Try ",s.attemptedVersion," again"]}),e.jsxs(l,{variant:"ghost",size:"sm",onClick:n,children:["Stay on ",s.version]})]})]})});default:return s}})();return e.jsxs("section",{className:"space-y-3",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Updates"}),e.jsx("p",{className:"text-xs text-fg-muted",children:"This Remit runs on your own server, so it updates when you say so. Your mail lives at your provider and is never touched by an update."})]}),P,r&&e.jsx("p",{role:"status",className:"text-xs text-fg-muted",children:r})]})}function Me({fileName:s,state:t="ready",error:a,onDownload:n,onImport:i}){const r=t==="downloading";return e.jsxs(ie,{className:"max-w-xl",children:[e.jsx(re,{children:e.jsx(le,{children:"Configuration file"})}),e.jsxs(oe,{children:[e.jsx("p",{className:"text-sm text-fg-muted",children:"One versioned JSON document carrying every setting this instance holds: accounts and their servers, folder roles, rules, labels, flagged senders and appearance. No passwords and no OAuth tokens — you sign in again wherever you import it."}),t==="failed"&&e.jsxs("div",{className:"mt-3 space-y-2 rounded-sm border border-danger/40 bg-danger-soft px-3 py-2.5",children:[e.jsx("p",{className:"text-sm font-medium text-danger",children:"The config file could not be written."}),e.jsxs("p",{className:"text-xs text-fg-muted",children:["Nothing was downloaded. Try again — if it keeps failing, use"," ",e.jsx("code",{className:"rounded bg-surface-sunken px-1 py-0.5",children:"remit config save"})," ","on the host in the meantime."]}),a&&e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:a})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[e.jsx(l,{variant:"secondary",size:"sm",disabled:r,icon:r?e.jsx(b,{className:"size-3.5 animate-spin"}):e.jsx(k,{className:"size-3.5"}),onClick:n,children:r?"Preparing…":`Download ${s}`}),e.jsx(y,{tone:"neutral",children:"no passwords"})]}),e.jsxs("p",{className:"mt-3 text-2xs text-fg-subtle",children:["On the host, the same file comes from"," ",e.jsxs("code",{className:"rounded bg-surface-sunken px-1 py-0.5",children:["remit config save ~/",s]}),"."]}),e.jsxs("div",{className:"mt-5 border-t border-line pt-4",children:[e.jsx("p",{className:"text-sm font-medium text-fg",children:"Import a config file"}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:"Read a file from another Reader into this one. It shows what will change before anything is written, and asks for each account's credentials afterwards."}),e.jsx(l,{className:"mt-3",variant:"secondary",size:"sm",icon:e.jsx(ce,{className:"size-3.5"}),onClick:i,children:"Import a config file"})]})]})]})}const Ae=(s,t)=>{const a=URL.createObjectURL(new Blob([JSON.stringify(t,null,2)],{type:"application/json"})),n=document.createElement("a");n.href=a,n.download=s,n.click(),URL.revokeObjectURL(a)};function _e(){const s=V(),t=ne(),[a,n]=x.useState("ready"),[i,r]=x.useState(void 0),o=ae(new Date),c=()=>{a!=="downloading"&&(n("downloading"),r(void 0),s.fetchQuery(q()).then(d=>{Ae(o,d.document),n("ready")}).catch(d=>{n("failed"),r(d instanceof Error?d.message:"GET /config/export did not answer with a configuration.")}))};return e.jsx(Me,{fileName:o,state:a,error:i,onDownload:c,onImport:()=>t("importConfig")})}const Ee=s=>s.map(t=>H(t.data?.items??[]));function $e(s){const t=me({queries:s.map(a=>({...U({path:{accountId:a}}),staleTime:1/0})),combine:Ee});return x.useMemo(()=>new Map(s.map((a,n)=>[a,t[n]??"/"])),[s,t])}function Oe(s,t){return{quarantineId:s.quarantineId,accountId:s.accountId,mailboxId:s.mailboxId,uidValidity:s.uidValidity,uid:s.uid,mailboxRole:s.mailboxRole?F[s.mailboxRole]:void 0,mailboxPath:s.mailboxPath,mailboxDelimiter:t,failureStage:s.failureStage,failureCode:s.failureCode,failureMessage:s.failureMessage,failurePartPath:s.failurePartPath,quarantinedAt:s.quarantinedAt,attempts:s.attempts,sizeBytes:s.sizeBytes,contentType:s.contentType,transferEncoding:s.transferEncoding,charset:s.charset,structure:s.structure,messageIdHash:s.messageIdHash,workerVersion:s.workerVersion}}const Pe=[];function De(s){window.open(s,"_blank","noopener,noreferrer")}function Le(s){return I(M({quarantine:O(s),title:ke(s)}))}function Be({error:s}){return e.jsxs("section",{role:"alert",className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Messages set aside"}),e.jsxs("div",{className:"space-y-2 rounded-sm border border-danger/40 bg-danger-soft px-row-inset py-3",children:[e.jsx("p",{className:"text-sm font-medium text-danger",children:"The list of set-aside messages could not be read."}),e.jsx("p",{className:"break-words text-sm text-fg-muted",children:de(s)}),e.jsx("p",{className:"text-xs text-fg-muted",children:"Mail may still have been set aside — this page cannot say either way until it can read the list. Reporting this gets it fixed."}),e.jsx(l,{variant:"secondary",size:"sm",icon:e.jsx(A,{className:"size-3.5"}),onClick:()=>De(I(M())),children:"Report this"})]})]})}function Ve({entries:s,isPending:t,error:a}){const[n,i]=x.useState(null),[r,o]=x.useState(!1);if(t)return e.jsx("p",{className:"animate-pulse text-sm text-fg-subtle",children:"Checking for messages set aside…"});if(a)return e.jsx(Be,{error:a});const c=d=>{navigator.clipboard.writeText(d).then(()=>{o(!1),i(null)},()=>{o(!0),i(null)})};return e.jsxs(e.Fragment,{children:[r&&e.jsx("p",{role:"alert",className:"mb-3 text-sm text-danger",children:"The report was not copied — this browser refused clipboard access. Cut the bug again and use Open on GitHub, which needs no clipboard."}),e.jsx(Te,{entries:s,onCutBug:i}),e.jsx(we,{entry:n,issueUrl:n?Le(n):"",onClose:()=>i(null),onCopy:c})]})}function qe(){const{data:s,isPending:t,error:a}=Q(Y()),n=s?.entries??Pe,i=x.useMemo(()=>[...new Set(n.map(c=>c.accountId))],[n]),r=$e(i),o=x.useMemo(()=>n.map(c=>Oe(c,r.get(c.accountId)??"/")),[n,r]);return e.jsx(Ve,{entries:o,isPending:t,error:a})}function Ue(){const{surface:s,release:t,currentVersion:a,appliesSchemaMigration:n,onCheck:i,install:r,onDismissResult:o}=G(),[c,d]=x.useState(!1);return s.status!=="ready"?null:e.jsxs(e.Fragment,{children:[e.jsx(Ie,{state:s.section,onCheck:i,onInstall:()=>d(!0),onDismissResult:o}),t&&a&&e.jsx(Se,{open:c,currentVersion:a,release:t,appliesSchemaMigration:n,onClose:()=>d(!1),onConfirm:()=>{d(!1),r(t.version)}})]})}function He(){return J().tlsMode!=="internal"?null:e.jsxs("div",{className:"border-t border-line pt-4 mt-4",children:[e.jsx("p",{className:"text-sm font-medium text-fg mb-1",children:"TLS root certificate"}),e.jsx("p",{className:"text-sm text-fg-muted mb-2",children:"This deployment signs its own certificate. Import it into the trust store of each device you browse from, and the browser warning stops for good."}),e.jsx(p,{href:"/tls-root-ca.crt",download:!0,variant:"secondary",size:"sm",icon:e.jsx(he,{className:"size-3.5"}),children:"Download root certificate"})]})}function Fe(s){try{return new Date(s).toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return s}}function Qe({sha:s=Z,commitUrl:t=W,buildTime:a=K}){return e.jsxs("p",{className:"text-xs text-fg-subtle",children:["Version"," ",t?e.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"font-mono hover:text-fg-muted hover:underline",children:s}):e.jsx("span",{className:"font-mono",children:s})," · ",e.jsxs("span",{children:["Built ",Fe(a)]})]})}function hs(){const s=X(),[t,a]=x.useState(!0),n=i=>{const r=se[i];r&&s({to:r})};return e.jsxs(te,{items:ee,activeId:"advanced",title:"Advanced",description:"Notification rules, export, and diagnostics.",help:ue,helpOpen:t,onToggleHelp:()=>a(i=>!i),onSelect:n,onBackToMail:()=>{s({to:"/mail"})},children:[e.jsx(Ue,{}),e.jsx(qe,{}),e.jsx("div",{className:"mt-6 border-t border-line pt-4",children:e.jsx(_e,{})}),e.jsx("div",{className:"mt-6 border-t border-line pt-4",children:e.jsx("p",{className:"text-sm text-fg-muted",children:"Notification rules are coming in a future release."})}),e.jsx(He,{}),e.jsxs("div",{className:"border-t border-line pt-4 mt-4",children:[e.jsx("p",{className:"text-sm font-medium text-fg mb-1",children:"About"}),e.jsx(Qe,{})]})]})}export{hs as component};
@@ -1 +1 @@
1
- import{u as x,r as a,b4 as g,j as e,aK as S,b5 as n,aM as y,b6 as b}from"./index-DSi1cxOe.js";import{S as T}from"./settings-screen-Bxg7gmcf.js";import{c as v}from"./help-copy-B9B_sS4o.js";import"./avatar-BUFzqa0m.js";import"./chevron-left-dl0LCVOD.js";import"./menu-ByhBSEmm.js";import"./circle-help-r3PbN8xG.js";import"./kbd-EJpwdDwi.js";const o="remit.density";function N(){return typeof localStorage>"u"?"comfortable":localStorage.getItem(o)??"comfortable"}function O(){const s=x(),[i,r]=a.useState(!0),[c,m]=a.useState(N),[p,d]=a.useState(g),h=t=>{m(t),typeof localStorage<"u"&&localStorage.setItem(o,t)},f=t=>{d(t),b(t)},u=t=>{const l=y[t];l&&s({to:l})};return e.jsx(T,{items:S,activeId:"appearance",title:"Appearance",description:"Display density and colour theme — instant-apply.",help:v,helpOpen:i,onToggleHelp:()=>r(t=>!t),onSelect:u,onBackToMail:()=>{s({to:"/mail"})},children:e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-fg",children:"Density"}),e.jsx(n,{name:"density","aria-label":"Density",value:c,onChange:h,options:[{value:"comfortable",label:"Comfortable"},{value:"compact",label:"Compact"}]}),e.jsx("p",{className:"text-xs text-fg-subtle",children:"Controls the spacing of message rows in the mail list."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-fg",children:"Theme"}),e.jsx(n,{name:"theme","aria-label":"Theme",value:p,onChange:f,options:[{value:"system",label:"System"},{value:"light",label:"Light"},{value:"dark",label:"Dark"}]}),e.jsx("p",{className:"text-xs text-fg-subtle",children:"Applies immediately. System default follows your OS preference."})]})]})})}export{O as component};
1
+ import{u as x,r as a,b4 as g,j as e,aK as S,b5 as n,aM as y,b6 as b}from"./index-Bcu7BqZh.js";import{S as T}from"./settings-screen-EigWdTdk.js";import{c as v}from"./help-copy-DC0qUPIv.js";import"./avatar-jIsSo2Zf.js";import"./chevron-left-DLqD6AAq.js";import"./menu-BXqls5WZ.js";import"./circle-help-Bn8ystJn.js";import"./kbd-wWeybs89.js";const o="remit.density";function N(){return typeof localStorage>"u"?"comfortable":localStorage.getItem(o)??"comfortable"}function O(){const s=x(),[i,r]=a.useState(!0),[c,m]=a.useState(N),[p,d]=a.useState(g),h=t=>{m(t),typeof localStorage<"u"&&localStorage.setItem(o,t)},f=t=>{d(t),b(t)},u=t=>{const l=y[t];l&&s({to:l})};return e.jsx(T,{items:S,activeId:"appearance",title:"Appearance",description:"Display density and colour theme — instant-apply.",help:v,helpOpen:i,onToggleHelp:()=>r(t=>!t),onSelect:u,onBackToMail:()=>{s({to:"/mail"})},children:e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-fg",children:"Density"}),e.jsx(n,{name:"density","aria-label":"Density",value:c,onChange:h,options:[{value:"comfortable",label:"Comfortable"},{value:"compact",label:"Compact"}]}),e.jsx("p",{className:"text-xs text-fg-subtle",children:"Controls the spacing of message rows in the mail list."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-fg",children:"Theme"}),e.jsx(n,{name:"theme","aria-label":"Theme",value:p,onChange:f,options:[{value:"system",label:"System"},{value:"light",label:"Light"},{value:"dark",label:"Dark"}]}),e.jsx("p",{className:"text-xs text-fg-subtle",children:"Applies immediately. System default follows your OS preference."})]})]})})}export{O as component};
@@ -1 +1 @@
1
- import{e as R,bG as M,j as l,r as p,E as L,f as _,t as g}from"./index-DSi1cxOe.js";const S=R("EllipsisVertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]);const V=R("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]),w=4,b=8;function I(e,t,s){const n=Math.max(b,window.innerWidth-t.width-b),o=s==="end"?e.right-t.width:e.left,r=Math.min(Math.max(o,b),n),a=e.bottom+w,i=e.top-w-t.height,u=a+t.height<=window.innerHeight-b||i<b?a:i;return{left:r,top:u}}function P(e,t,s,n){const[o,r]=p.useState(null),a=p.useRef(n);return a.current=n,p.useLayoutEffect(()=>{if(!t){r(null);return}const i=()=>{const d=e.current,m=a.current();if(!d||!m)return;const f=d.getBoundingClientRect(),x={width:f.right-f.left,height:f.bottom-f.top},c=I(m,x,s);r(E=>E?.left===c.left&&E.top===c.top?E:{position:"fixed",left:c.left,top:c.top})};i(),window.addEventListener("resize",i),window.addEventListener("scroll",i,!0);const h=e.current;let u=null;return h&&typeof ResizeObserver<"u"&&(u=new ResizeObserver(i),u.observe(h)),()=>{u?.disconnect(),window.removeEventListener("resize",i),window.removeEventListener("scroll",i,!0)}},[t,s,e]),o}function j({open:e,align:t="start",getAnchor:s,panelRef:n,children:o}){const r=P(n,e,t,s);return e?M.createPortal(l.jsx("div",{className:"z-50",style:r??{position:"fixed",visibility:"hidden"},children:o}),document.body):null}function k({label:e,children:t,className:s,ref:n,onKeyDown:o,"data-testid":r}){return l.jsx("div",{ref:n,role:"menu","aria-label":e,tabIndex:-1,onKeyDown:o,"data-testid":r,className:g("z-50 flex max-h-[60dvh] min-w-44 flex-col overflow-y-auto overscroll-contain rounded-md border border-line bg-surface py-1 shadow-lg outline-none",s),children:t})}function T({label:e,icon:t,onSelect:s,className:n,lang:o,"data-testid":r}){return l.jsxs("button",{type:"button",role:"menuitem",lang:o,onClick:s,"data-testid":r,className:g("flex min-h-11 items-center gap-3 px-4 py-2.5 text-left text-sm text-fg transition-colors hover:bg-surface-sunken",n),children:[t&&l.jsx("span",{className:"shrink-0 text-fg-subtle",children:t}),e]})}function $({triggerLabel:e,triggerIcon:t,triggerText:s,items:n,align:o="end",touch:r=!0,className:a,triggerClassName:i,nested:h=!1,children:u}){const[d,m]=p.useState(!1),f=p.useRef(null),x=p.useRef(null);return L({id:"popover-menu",open:d,answers:{back:()=>m(!1)}}),p.useEffect(()=>{if(!d)return;const c=E=>{const v=E.target;f.current?.contains(v)||x.current?.contains(v)||m(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[d]),n.length===0&&!u?null:l.jsxs("div",{ref:f,className:g("relative",a),...h?{role:"none"}:{},children:[l.jsx(_,{variant:"ghost",size:"sm",icon:t??l.jsx(S,{className:"size-5"}),onClick:()=>m(c=>!c),"aria-label":e,"aria-haspopup":"menu","aria-expanded":d,...h?{role:"menuitem"}:{},className:g(r&&"min-h-11 min-w-11 px-0",i),children:s}),l.jsx(j,{open:d,align:o,panelRef:x,getAnchor:()=>f.current?.getBoundingClientRect()??null,children:l.jsxs(k,{ref:x,children:[n.map(c=>l.jsx(T,{label:c.label,icon:c.icon,onSelect:()=>{m(!1),c.onSelect()}},c.key)),u]})})]})}const z=/[\u0000-\u001f\u007f-\u009f\u061c\u200b-\u200f\u2028\u2029\u202a-\u202e\u2066-\u2069\ufeff]/g,B=/[<>:"|?*]/g,C=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\.|$)/i,y=120,H=12,O="attachment",N=e=>{const t=[...e];if(t.length<=y)return e;const s=e.lastIndexOf("."),n=s>0&&[...e.slice(s)].length<=H?e.slice(s):"",o=y-[...n].length;return t.slice(0,o).join("")+n},G=(e,t=O)=>{const n=e.replace(z,"").split(/[/\\]/),r=(n[n.length-1]??"").replace(B,"_").replace(/^[.\s]+/,"").replace(/[.\s]+$/,"");if(r.length===0)return N(t);const a=C.test(r)?`_${r}`:r;return N(a)},A=["KB","MB","GB","TB"],U=e=>{if(!Number.isFinite(e)||e<0)return"unknown size";const t=Math.round(e);if(t<1024)return t===1?"1 byte":`${t} bytes`;const s=1023.95;let n=t/1024,o=0;for(;n>=s&&o<A.length-1;)n/=1024,o+=1;return`${n.toFixed(1).replace(/\.0$/,"")} ${A[o]}`};export{S as E,$ as P,V as U,j as a,k as b,T as c,U as f,G as s};
1
+ import{e as R,bG as M,j as l,r as p,E as L,f as _,t as g}from"./index-Bcu7BqZh.js";const S=R("EllipsisVertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]);const V=R("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]),w=4,b=8;function I(e,t,s){const n=Math.max(b,window.innerWidth-t.width-b),o=s==="end"?e.right-t.width:e.left,r=Math.min(Math.max(o,b),n),a=e.bottom+w,i=e.top-w-t.height,u=a+t.height<=window.innerHeight-b||i<b?a:i;return{left:r,top:u}}function P(e,t,s,n){const[o,r]=p.useState(null),a=p.useRef(n);return a.current=n,p.useLayoutEffect(()=>{if(!t){r(null);return}const i=()=>{const d=e.current,m=a.current();if(!d||!m)return;const f=d.getBoundingClientRect(),x={width:f.right-f.left,height:f.bottom-f.top},c=I(m,x,s);r(E=>E?.left===c.left&&E.top===c.top?E:{position:"fixed",left:c.left,top:c.top})};i(),window.addEventListener("resize",i),window.addEventListener("scroll",i,!0);const h=e.current;let u=null;return h&&typeof ResizeObserver<"u"&&(u=new ResizeObserver(i),u.observe(h)),()=>{u?.disconnect(),window.removeEventListener("resize",i),window.removeEventListener("scroll",i,!0)}},[t,s,e]),o}function j({open:e,align:t="start",getAnchor:s,panelRef:n,children:o}){const r=P(n,e,t,s);return e?M.createPortal(l.jsx("div",{className:"z-50",style:r??{position:"fixed",visibility:"hidden"},children:o}),document.body):null}function k({label:e,children:t,className:s,ref:n,onKeyDown:o,"data-testid":r}){return l.jsx("div",{ref:n,role:"menu","aria-label":e,tabIndex:-1,onKeyDown:o,"data-testid":r,className:g("z-50 flex max-h-[60dvh] min-w-44 flex-col overflow-y-auto overscroll-contain rounded-md border border-line bg-surface py-1 shadow-lg outline-none",s),children:t})}function T({label:e,icon:t,onSelect:s,className:n,lang:o,"data-testid":r}){return l.jsxs("button",{type:"button",role:"menuitem",lang:o,onClick:s,"data-testid":r,className:g("flex min-h-11 items-center gap-3 px-4 py-2.5 text-left text-sm text-fg transition-colors hover:bg-surface-sunken",n),children:[t&&l.jsx("span",{className:"shrink-0 text-fg-subtle",children:t}),e]})}function $({triggerLabel:e,triggerIcon:t,triggerText:s,items:n,align:o="end",touch:r=!0,className:a,triggerClassName:i,nested:h=!1,children:u}){const[d,m]=p.useState(!1),f=p.useRef(null),x=p.useRef(null);return L({id:"popover-menu",open:d,answers:{back:()=>m(!1)}}),p.useEffect(()=>{if(!d)return;const c=E=>{const v=E.target;f.current?.contains(v)||x.current?.contains(v)||m(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[d]),n.length===0&&!u?null:l.jsxs("div",{ref:f,className:g("relative",a),...h?{role:"none"}:{},children:[l.jsx(_,{variant:"ghost",size:"sm",icon:t??l.jsx(S,{className:"size-5"}),onClick:()=>m(c=>!c),"aria-label":e,"aria-haspopup":"menu","aria-expanded":d,...h?{role:"menuitem"}:{},className:g(r&&"min-h-11 min-w-11 px-0",i),children:s}),l.jsx(j,{open:d,align:o,panelRef:x,getAnchor:()=>f.current?.getBoundingClientRect()??null,children:l.jsxs(k,{ref:x,children:[n.map(c=>l.jsx(T,{label:c.label,icon:c.icon,onSelect:()=>{m(!1),c.onSelect()}},c.key)),u]})})]})}const z=/[\u0000-\u001f\u007f-\u009f\u061c\u200b-\u200f\u2028\u2029\u202a-\u202e\u2066-\u2069\ufeff]/g,B=/[<>:"|?*]/g,C=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\.|$)/i,y=120,H=12,O="attachment",N=e=>{const t=[...e];if(t.length<=y)return e;const s=e.lastIndexOf("."),n=s>0&&[...e.slice(s)].length<=H?e.slice(s):"",o=y-[...n].length;return t.slice(0,o).join("")+n},G=(e,t=O)=>{const n=e.replace(z,"").split(/[/\\]/),r=(n[n.length-1]??"").replace(B,"_").replace(/^[.\s]+/,"").replace(/[.\s]+$/,"");if(r.length===0)return N(t);const a=C.test(r)?`_${r}`:r;return N(a)},A=["KB","MB","GB","TB"],U=e=>{if(!Number.isFinite(e)||e<0)return"unknown size";const t=Math.round(e);if(t<1024)return t===1?"1 byte":`${t} bytes`;const s=1023.95;let n=t/1024,o=0;for(;n>=s&&o<A.length-1;)n/=1024,o+=1;return`${n.toFixed(1).replace(/\.0$/,"")} ${A[o]}`};export{S as E,$ as P,V as U,j as a,k as b,T as c,U as f,G as s};
@@ -1 +1 @@
1
- import{r as a,j as h,t as u}from"./index-DSi1cxOe.js";const p={sm:"size-7 text-2xs",md:"size-9 text-sm",lg:"size-11 text-md"},n=["oklch(0.6 0.08 150)","oklch(0.6 0.08 185)","oklch(0.6 0.08 215)","oklch(0.6 0.07 250)","oklch(0.6 0.07 310)","oklch(0.62 0.07 110)"],d="oklch(0.97 0.012 90)";function f(e){const t=e.trim().split(/\s+/).filter(Boolean);return t.length===0?"?":t.length===1?t[0].slice(0,2).toUpperCase():(t[0][0]+t[t.length-1][0]).toUpperCase()}function m({name:e,email:t,size:l="md",className:c}){const i=a.useMemo(()=>{const r=t??e;let s=0;for(let o=0;o<r.length;o++)s=s*31+r.charCodeAt(o)>>>0;return n[s%n.length]},[e,t]);return h.jsx("span",{className:u("inline-flex shrink-0 items-center justify-center rounded-full font-semibold select-none",p[l],c),style:{backgroundColor:i,color:d},"aria-hidden":!0,children:f(e)})}export{m as A};
1
+ import{r as a,j as h,t as u}from"./index-Bcu7BqZh.js";const p={sm:"size-7 text-2xs",md:"size-9 text-sm",lg:"size-11 text-md"},n=["oklch(0.6 0.08 150)","oklch(0.6 0.08 185)","oklch(0.6 0.08 215)","oklch(0.6 0.07 250)","oklch(0.6 0.07 310)","oklch(0.62 0.07 110)"],d="oklch(0.97 0.012 90)";function f(e){const t=e.trim().split(/\s+/).filter(Boolean);return t.length===0?"?":t.length===1?t[0].slice(0,2).toUpperCase():(t[0][0]+t[t.length-1][0]).toUpperCase()}function m({name:e,email:t,size:l="md",className:c}){const i=a.useMemo(()=>{const r=t??e;let s=0;for(let o=0;o<r.length;o++)s=s*31+r.charCodeAt(o)>>>0;return n[s%n.length]},[e,t]);return h.jsx("span",{className:u("inline-flex shrink-0 items-center justify-center rounded-full font-semibold select-none",p[l],c),style:{backgroundColor:i,color:d},"aria-hidden":!0,children:f(e)})}export{m as A};
@@ -1 +1 @@
1
- import{E as j,r as s,j as o,t as v}from"./index-DSi1cxOe.js";const k=320,I="cubic-bezier(0.32, 0.9, 0.3, 1)",N=.5,E=.4,C=360;function P(n){return Math.sign(n)*Math.sqrt(Math.abs(n))*4}function A({open:n,onClose:i,children:g,dismissLabel:S="Dismiss"}){j({id:"bottom-sheet",open:n,answers:{back:i}});const d=s.useRef(null),[l,Y]=s.useState(C),[b,u]=s.useState(null);s.useLayoutEffect(()=>{const t=d.current;if(!t)return;const e=()=>Y(t.offsetHeight);e();const a=new ResizeObserver(e);return a.observe(t),()=>a.disconnect()},[]);const c=s.useRef(null),y=s.useCallback(t=>{t.currentTarget.setPointerCapture(t.pointerId),c.current={startY:t.clientY,lastY:t.clientY,lastT:t.timeStamp,velocity:0,moved:!1},u(0)},[]),w=s.useCallback(t=>{const e=c.current;if(!e)return;const a=t.timeStamp-e.lastT;a>0&&(e.velocity=(t.clientY-e.lastY)/a),e.lastY=t.clientY,e.lastT=t.timeStamp;const r=t.clientY-e.startY;Math.abs(r)>4&&(e.moved=!0);const M=r<0?P(r):r;u(M)},[]),m=s.useCallback(()=>{const t=c.current;if(c.current=null,!t)return;const e=t.lastY-t.startY,r=t.velocity>N||e>l*E;u(null),r&&i()},[l,i]),x=b!==null,h=n?b??0:l,f=Math.min(Math.max(1-h/l,0),1),p=x?"none":`transform ${k}ms ${I}`;return o.jsxs("div",{className:v("absolute inset-0 z-40 select-none overflow-hidden",n||x?"":"pointer-events-none"),children:[o.jsx("button",{type:"button","aria-label":S,tabIndex:-1,onClick:i,className:v("absolute inset-0 bg-black/40",f>0?"pointer-events-auto":"pointer-events-none"),style:{opacity:f*.6,transition:p.replace("transform","opacity")}}),o.jsxs("div",{ref:d,className:"absolute inset-x-0 bottom-0 flex max-h-[92%] flex-col rounded-t-3xl border-t border-line bg-surface pb-[env(safe-area-inset-bottom,0px)] shadow-2xl shadow-black/30",style:{transform:`translateY(${h}px)`,transition:p},children:[o.jsx("div",{role:"slider","aria-label":"Drag down to dismiss","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(f*100),tabIndex:0,onPointerDown:y,onPointerMove:w,onPointerUp:m,onPointerCancel:m,className:"flex cursor-grab touch-none justify-center pb-1 pt-2.5 active:cursor-grabbing",children:o.jsx("div",{className:"h-1 w-10 rounded-full bg-fg-subtle/40"})}),o.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:g})]})]})}export{A as B};
1
+ import{E as j,r as s,j as o,t as v}from"./index-Bcu7BqZh.js";const k=320,I="cubic-bezier(0.32, 0.9, 0.3, 1)",N=.5,E=.4,C=360;function P(n){return Math.sign(n)*Math.sqrt(Math.abs(n))*4}function A({open:n,onClose:i,children:g,dismissLabel:S="Dismiss"}){j({id:"bottom-sheet",open:n,answers:{back:i}});const d=s.useRef(null),[l,Y]=s.useState(C),[b,u]=s.useState(null);s.useLayoutEffect(()=>{const t=d.current;if(!t)return;const e=()=>Y(t.offsetHeight);e();const a=new ResizeObserver(e);return a.observe(t),()=>a.disconnect()},[]);const c=s.useRef(null),y=s.useCallback(t=>{t.currentTarget.setPointerCapture(t.pointerId),c.current={startY:t.clientY,lastY:t.clientY,lastT:t.timeStamp,velocity:0,moved:!1},u(0)},[]),w=s.useCallback(t=>{const e=c.current;if(!e)return;const a=t.timeStamp-e.lastT;a>0&&(e.velocity=(t.clientY-e.lastY)/a),e.lastY=t.clientY,e.lastT=t.timeStamp;const r=t.clientY-e.startY;Math.abs(r)>4&&(e.moved=!0);const M=r<0?P(r):r;u(M)},[]),m=s.useCallback(()=>{const t=c.current;if(c.current=null,!t)return;const e=t.lastY-t.startY,r=t.velocity>N||e>l*E;u(null),r&&i()},[l,i]),x=b!==null,h=n?b??0:l,f=Math.min(Math.max(1-h/l,0),1),p=x?"none":`transform ${k}ms ${I}`;return o.jsxs("div",{className:v("absolute inset-0 z-40 select-none overflow-hidden",n||x?"":"pointer-events-none"),children:[o.jsx("button",{type:"button","aria-label":S,tabIndex:-1,onClick:i,className:v("absolute inset-0 bg-black/40",f>0?"pointer-events-auto":"pointer-events-none"),style:{opacity:f*.6,transition:p.replace("transform","opacity")}}),o.jsxs("div",{ref:d,className:"absolute inset-x-0 bottom-0 flex max-h-[92%] flex-col rounded-t-3xl border-t border-line bg-surface pb-[env(safe-area-inset-bottom,0px)] shadow-2xl shadow-black/30",style:{transform:`translateY(${h}px)`,transition:p},children:[o.jsx("div",{role:"slider","aria-label":"Drag down to dismiss","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(f*100),tabIndex:0,onPointerDown:y,onPointerMove:w,onPointerUp:m,onPointerCancel:m,className:"flex cursor-grab touch-none justify-center pb-1 pt-2.5 active:cursor-grabbing",children:o.jsx("div",{className:"h-1 w-10 rounded-full bg-fg-subtle/40"})}),o.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:g})]})]})}export{A as B};
@@ -1 +1 @@
1
- import{j as r}from"./index-DSi1cxOe.js";import{E as t}from"./ErrorState-D8AQD4QI.js";const i=({error:e,reset:o})=>r.jsx("div",{className:"flex h-full items-center justify-center bg-canvas p-4",children:r.jsx(t,{title:"Couldn't load your mailboxes",error:e,onRetry:o})});export{i as errorComponent};
1
+ import{j as r}from"./index-Bcu7BqZh.js";import{E as t}from"./ErrorState-BN1KI1QC.js";const i=({error:e,reset:o})=>r.jsx("div",{className:"flex h-full items-center justify-center bg-canvas p-4",children:r.jsx(t,{title:"Couldn't load your mailboxes",error:e,onRetry:o})});export{i as errorComponent};
@@ -0,0 +1 @@
1
+ import{j as r,O as i}from"./index-Bcu7BqZh.js";import{a as m}from"./MailShell-CZF1GQXr.js";import{B as o}from"./BriefPane-8e5wD9U2.js";import{d as p}from"./search-token-index-B4kJtFA_.js";import{u as e}from"./search-mirror-Csy2vxLR.js";import"./FullCompose-BOiOQ-Qf.js";import"./ErrorState-BN1KI1QC.js";import"./index-BW01bO1J.js";import"./useMessageBodyContent-ClKIcNPh.js";import"./useSignature-BISqUCGf.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-jtTlNJDr.js";import"./sections-DT0azgaj.js";import"./format-CxG3FNVs.js";import"./confirm-dialog-5hKuL5ov.js";import"./useSearchTokenContext-BW55Y3Yb.js";import"./kbd-wWeybs89.js";import"./search-scope-B5-OK3Cq.js";import"./MailListHeader-D3QJgz1J.js";import"./attachment-file-DEgj4Vud.js";import"./mail-WRNyVFjV.js";import"./avatar-jIsSo2Zf.js";import"./EmptyState-Bnpl3mxy.js";import"./download-CiAfXfNQ.js";import"./useLayoutTier-P9na-5Xh.js";import"./shield-check-CWXSXjpp.js";import"./useFilters-BxnI0t9W.js";import"./useQueries-4YYdm8Yg.js";import"./minus-BaGFpEMe.js";import"./clock-a9wtJIFb.js";import"./menu-BXqls5WZ.js";import"./useRefreshControl-BMS0clfU.js";import"./circle-check-big-UXLrOtDo.js";import"./useLabels-C-ytwpWV.js";import"./useSemanticSearch-BrrFjCJ5.js";import"./search-query-Cr_ZXBCp.js";import"./wizard-selection-B1bng5Jq.js";function N(){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{N as component};