@remit/web-client-dist 0.0.673 → 0.0.674

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 (207) hide show
  1. package/assets/BriefPane-zWXuK_Pj.js +1 -0
  2. package/assets/CalendarComposePane-Bz_-lcWc.js +1 -0
  3. package/assets/{CalendarComposeSeed-B0PN5iBD.js → CalendarComposeSeed-DrUkfGTc.js} +1 -1
  4. package/assets/CalendarShell-BATnya1t.js +1 -0
  5. package/assets/{EmptyState-Do3nwfV4.js → EmptyState-DjcO1Fvj.js} +1 -1
  6. package/assets/ErrorState-Bi4vrhhQ.js +1 -0
  7. package/assets/FlaggedPane-Doc9iLZn.js +1 -0
  8. package/assets/FullCompose-D6Xef8Ur.js +1 -0
  9. package/assets/{LabelApplyTrigger-BNJ7ewFc.js → LabelApplyTrigger-BnPNejnI.js} +1 -1
  10. package/assets/MailNav-C8EZGG4u.js +1 -0
  11. package/assets/MailShell-Dc5V-rLi.js +1 -0
  12. package/assets/MailViewChrome-CJkUbWPO.js +1 -0
  13. package/assets/MailboxPane-Bzn-4kym.js +1 -0
  14. package/assets/{MessageBody-xzQttW18.js → MessageBody-AvWIklnv.js} +3 -3
  15. package/assets/MessageToolbar-CvC2dLSg.js +1 -0
  16. package/assets/NavMenuButton-DSpTQKmQ.js +1 -0
  17. package/assets/{OnboardingWizard-hiUJAJmS.js → OnboardingWizard-DzR2uArY.js} +1 -1
  18. package/assets/OpenCalendarEvent-DuKGo-jF.js +2 -0
  19. package/assets/OutboxPane-Bf8T7dxW.js +1 -0
  20. package/assets/{SignInAgain-CZ5gXYZu.js → SignInAgain-CCZnH9Mt.js} +1 -1
  21. package/assets/_calendarObjectId-BGZWGcp9.js +1 -0
  22. package/assets/_mailboxId-GGJA-jVS.js +1 -0
  23. package/assets/_messageId-C5LRx072.js +1 -0
  24. package/assets/_messageId-CCba-TdT.js +1 -0
  25. package/assets/_messageId-TW2iI02X.js +1 -0
  26. package/assets/_outboxMessageId-BwVgR2h4.js +1 -0
  27. package/assets/_recurrenceId-pJxBSSXe.js +1 -0
  28. package/assets/_threadId-B_SsLFXa.js +1 -0
  29. package/assets/_threadId-CL2HHRtw.js +1 -0
  30. package/assets/_threadId-DLvgcvlr.js +1 -0
  31. package/assets/_view._date-wBuxk5kG.js +1 -0
  32. package/assets/accounts-Dc5147aO.js +1 -0
  33. package/assets/{advanced-CmQPXUBR.js → advanced-C3zdMHK5.js} +1 -1
  34. package/assets/{appearance-Bj0VbMeI.js → appearance-Df1fh0eu.js} +1 -1
  35. package/assets/attendee-row-r-oUgLyi.js +1 -0
  36. package/assets/{avatar-CDZx9RcB.js → avatar-qD7fcqFf.js} +1 -1
  37. package/assets/bell-off-DNCJLc9z.js +1 -0
  38. package/assets/{bottom-sheet-B-kTBnyv.js → bottom-sheet-B_7iO-ln.js} +1 -1
  39. package/assets/brief-ClYJePmh.js +1 -0
  40. package/assets/{brief-BnVwi6Bh.js → brief-RK0pe25_.js} +1 -1
  41. package/assets/{bug-rutCyt-b.js → bug-D6xXLRSh.js} +1 -1
  42. package/assets/calendar-Dg7vWWgr.js +1 -0
  43. package/assets/{calendar-clash-strip-DBNuXhBt.js → calendar-clash-strip-C9X1djbQ.js} +1 -1
  44. package/assets/{calendar-report-OI80fkc1.js → calendar-report-BRGottVJ.js} +1 -1
  45. package/assets/{calendar-suggestion-B5sKDqe0.js → calendar-suggestion-qEC_UasM.js} +1 -1
  46. package/assets/calendars-DBDN0ptk.js +1 -0
  47. package/assets/card-C9cgHaft.js +1 -0
  48. package/assets/{checkbox-DJpIppZD.js → checkbox-CiQllE1Y.js} +1 -1
  49. package/assets/chevron-left-Bt4eJ35K.js +1 -0
  50. package/assets/{circle-check-Nj7sUGPS.js → circle-check-CQPt1U9q.js} +1 -1
  51. package/assets/circle-check-big-ZwVj0mbk.js +1 -0
  52. package/assets/circle-help-BtMu5xYr.js +1 -0
  53. package/assets/{clock-99u2Mdmy.js → clock-B-eYdLBT.js} +1 -1
  54. package/assets/compose._-_outboxMessageId_-BMq7tjfo.js +1 -0
  55. package/assets/compose._-_outboxMessageId_-CbnOP01x.js +1 -0
  56. package/assets/compose._-_outboxMessageId_-CoBJDS24.js +1 -0
  57. package/assets/compose._-_outboxMessageId_-Cr5hBZLH.js +1 -0
  58. package/assets/{config-import-CAmEPP05.js → config-import-DhLbROIb.js} +1 -1
  59. package/assets/{confirm-dialog-PhUq_oc3.js → confirm-dialog-AppxcVfC.js} +1 -1
  60. package/assets/copy-BCzZpML3.js +1 -0
  61. package/assets/{credential-steps-BES-y0iD.js → credential-steps-DCjuFFo-.js} +1 -1
  62. package/assets/download-C6M2pRs1.js +1 -0
  63. package/assets/{external-link-BsYxbrL5.js → external-link-tmwz3hf0.js} +1 -1
  64. package/assets/{file-json-C0JfxlBX.js → file-json-BgVPDajK.js} +1 -1
  65. package/assets/filters-CwblOGNb.js +1 -0
  66. package/assets/flagged-DvOlELtX.js +1 -0
  67. package/assets/{flagged-BTJq-RZj.js → flagged-IHM3vv4x.js} +1 -1
  68. package/assets/folders-lF0pnG5O.js +1 -0
  69. package/assets/{help-copy-BUCBLhdW.js → help-copy-BN4-5aIP.js} +1 -1
  70. package/assets/import-BT72aUBc.js +1 -0
  71. package/assets/index-BDcVKyir.js +1 -0
  72. package/assets/index-C5LRx072.js +1 -0
  73. package/assets/index-CCba-TdT.js +1 -0
  74. package/assets/index-CVKDJurZ.js +1 -0
  75. package/assets/index-CXrVnh7V.js +1 -0
  76. package/assets/index-CXzCthHG.js +349 -0
  77. package/assets/{index-BBaBlwlN.js → index-Cb2UJhnj.js} +7 -7
  78. package/assets/{index-XWbwFOgn.js → index-DRT_I4p4.js} +1 -1
  79. package/assets/index-DSNc3rHB.js +1 -0
  80. package/assets/index-T04Kj7bC.js +1 -0
  81. package/assets/index-TW2iI02X.js +1 -0
  82. package/assets/index-u72ANhps.js +1 -0
  83. package/assets/kbd-DxdiA2Fl.js +1 -0
  84. package/assets/labels-CTSVGM1M.js +1 -0
  85. package/assets/mail-BLRLmM-I.js +1 -0
  86. package/assets/mail-CHopLOA-.js +1 -0
  87. package/assets/{map-pin-C0usgYas.js → map-pin-DbNUeHlR.js} +1 -1
  88. package/assets/menu-ouYQ8aI9.js +1 -0
  89. package/assets/minus-COyPQ5q9.js +1 -0
  90. package/assets/{new-BEBqxznp.js → new-DRfIDZVL.js} +1 -1
  91. package/assets/onboarding-U6yiJPWH.js +1 -0
  92. package/assets/onboarding-completion-h9meGJrm.js +1 -0
  93. package/assets/outbox-DFxDZsE8.js +1 -0
  94. package/assets/{pencil-CoAnhAKI.js → pencil-D0Kwpd2W.js} +1 -1
  95. package/assets/{popover-menu-BHNjsQiI.js → popover-menu-CTiORP1p.js} +1 -1
  96. package/assets/refresh-cw-aweb7slK.js +1 -0
  97. package/assets/reply-B9-kr45N.js +1 -0
  98. package/assets/{rich-text-D9hn7JQa.js → rich-text-BlpPNJ69.js} +14 -14
  99. package/assets/{rich-text-spellcheck-worker-provider-BqOsf6u-.js → rich-text-spellcheck-worker-provider-BVC2WqOs.js} +1 -1
  100. package/assets/rotate-ccw-cFCdZR4R.js +1 -0
  101. package/assets/{roving-focus-B9mHbGbD.js → roving-focus-iNw1K_A-.js} +1 -1
  102. package/assets/{row-actions-BkhFe3TY.js → row-actions-CsY_49bo.js} +1 -1
  103. package/assets/search-mirror-Bg0i4bJE.js +1 -0
  104. package/assets/{search-query-0wEBmb1P.js → search-query-Dq2--dgF.js} +1 -1
  105. package/assets/search-token-index-JnwciDu0.js +1 -0
  106. package/assets/{sections-ClqQBEFv.js → sections-By63r1y_.js} +1 -1
  107. package/assets/{senders-DuUfs3Pf.js → senders-BollE7le.js} +1 -1
  108. package/assets/settings-aPDqsj-M.js +1 -0
  109. package/assets/{settings-screen-BjSyVU2l.js → settings-screen-DxN6mICP.js} +1 -1
  110. package/assets/shield-check-C6K5BNfE.js +1 -0
  111. package/assets/suggested-vips-DnRYIdD0.js +1 -0
  112. package/assets/{suggestion._suggestionId-BnW2e786.js → suggestion._suggestionId-m9OzQCaR.js} +1 -1
  113. package/assets/{undo-2-WqFuHEgY.js → undo-2-BV0sKXdu.js} +1 -1
  114. package/assets/{useCalendarData-C3g6QMEH.js → useCalendarData-BQ_jLMR7.js} +1 -1
  115. package/assets/useCalendarEvents-lDPF_B6_.js +1 -0
  116. package/assets/useCalendarFreeBusy-BFq23gzr.js +1 -0
  117. package/assets/{useCalendarWrites-LwW_U-yG.js → useCalendarWrites-CIJUCBzo.js} +1 -1
  118. package/assets/{useCalendars-B1migLvB.js → useCalendars-BgSJfw8G.js} +1 -1
  119. package/assets/{useDebouncedValue-nmGpghjy.js → useDebouncedValue--u19KX6h.js} +1 -1
  120. package/assets/{useFilters-zdrGUBZF.js → useFilters-Cmf0Cndn.js} +1 -1
  121. package/assets/{useLabels-CesUuQey.js → useLabels-CN56tbCw.js} +1 -1
  122. package/assets/useLayoutTier-CUyuK30O.js +1 -0
  123. package/assets/useMediaQuery-DB2OdJvp.js +1 -0
  124. package/assets/useMessageBodyContent-Gq_pdN4f.js +1 -0
  125. package/assets/{useQueries-BDOaD0Tu.js → useQueries-gpmd3w5y.js} +1 -1
  126. package/assets/useRefreshControl-DdZILsE1.js +1 -0
  127. package/assets/{useResultFolderIndex-D44p4QVU.js → useResultFolderIndex-EOtkNq1e.js} +1 -1
  128. package/assets/{useSignature-BMl5h116.js → useSignature-37xUEwqG.js} +1 -1
  129. package/assets/{warnings-L0tU6MHK.js → warnings-BYDfjgnx.js} +5 -5
  130. package/index.html +1 -1
  131. package/package.json +1 -1
  132. package/assets/BriefPane-DqtL8KK7.js +0 -1
  133. package/assets/CalendarComposePane-Sr72cVvW.js +0 -1
  134. package/assets/CalendarShell-_yGJJZGQ.js +0 -1
  135. package/assets/ErrorState-DcwvjIQG.js +0 -1
  136. package/assets/FlaggedPane-Cmhk0gcN.js +0 -1
  137. package/assets/FullCompose-aUTiTI79.js +0 -1
  138. package/assets/MailNav-BdiWAfH_.js +0 -1
  139. package/assets/MailShell-DTW4ysuk.js +0 -1
  140. package/assets/MailViewChrome-BOp09SXr.js +0 -1
  141. package/assets/MailboxPane-CbM92Ovm.js +0 -1
  142. package/assets/MessageToolbar-D_XXU4rk.js +0 -1
  143. package/assets/NavMenuButton-D-YzcNLk.js +0 -1
  144. package/assets/OpenCalendarEvent-DI9FmufS.js +0 -2
  145. package/assets/OutboxPane-5Tg_XaNz.js +0 -1
  146. package/assets/_calendarObjectId-vCwbJTnk.js +0 -1
  147. package/assets/_mailboxId-Cfuu19RK.js +0 -1
  148. package/assets/_messageId-CgycoOJ5.js +0 -1
  149. package/assets/_messageId-D-b80c2N.js +0 -1
  150. package/assets/_messageId-DRetwfpf.js +0 -1
  151. package/assets/_outboxMessageId-Bn0dQ4xZ.js +0 -1
  152. package/assets/_recurrenceId-Cnhx2TOl.js +0 -1
  153. package/assets/_threadId-Cng5uaoZ.js +0 -1
  154. package/assets/_threadId-DOrkCv20.js +0 -1
  155. package/assets/_threadId-DXMeaFS2.js +0 -1
  156. package/assets/_view._date-CbKJy0l4.js +0 -1
  157. package/assets/accounts-Cq3q9zT9.js +0 -1
  158. package/assets/attendee-row-CPJnqwGs.js +0 -1
  159. package/assets/bell-off-Bzm-PBgf.js +0 -1
  160. package/assets/brief-smZMIU_D.js +0 -1
  161. package/assets/calendar-Badl9o28.js +0 -1
  162. package/assets/calendars-CUfsifTm.js +0 -1
  163. package/assets/card-WnranLyn.js +0 -1
  164. package/assets/chevron-left-CF03ieoO.js +0 -1
  165. package/assets/circle-check-big-Bkno0zML.js +0 -1
  166. package/assets/circle-help-DqnCeQ17.js +0 -1
  167. package/assets/compose._-_outboxMessageId_-BKdFP0ao.js +0 -1
  168. package/assets/compose._-_outboxMessageId_-BtlHF3xu.js +0 -1
  169. package/assets/compose._-_outboxMessageId_-D0RsY9X4.js +0 -1
  170. package/assets/compose._-_outboxMessageId_-D388BLER.js +0 -1
  171. package/assets/copy-CLKRqvl9.js +0 -1
  172. package/assets/download-DS8Ui8jJ.js +0 -1
  173. package/assets/filters-BAZYluMO.js +0 -1
  174. package/assets/flagged-CoNpo9-C.js +0 -1
  175. package/assets/folders-C-gfrylt.js +0 -1
  176. package/assets/import-D5avZjYG.js +0 -1
  177. package/assets/index-B-6f2NO7.js +0 -1
  178. package/assets/index-BCw2cMz0.js +0 -1
  179. package/assets/index-BVmS60uo.js +0 -1
  180. package/assets/index-Bnka257H.js +0 -1
  181. package/assets/index-CBHO_oxW.js +0 -1
  182. package/assets/index-CgycoOJ5.js +0 -1
  183. package/assets/index-D-b80c2N.js +0 -1
  184. package/assets/index-D7VpR8Bx.js +0 -293
  185. package/assets/index-DYyayMku.js +0 -1
  186. package/assets/index-DZZWB09x.js +0 -1
  187. package/assets/kbd-DzZig-MJ.js +0 -1
  188. package/assets/labels-dyDIPXoj.js +0 -1
  189. package/assets/mail-BiL0g7on.js +0 -1
  190. package/assets/mail-Bir39SMd.js +0 -1
  191. package/assets/menu-liPRY-HF.js +0 -1
  192. package/assets/minus-Cs2PKH6V.js +0 -1
  193. package/assets/onboarding-CHwAu1ha.js +0 -1
  194. package/assets/onboarding-completion-CYRjdQQn.js +0 -1
  195. package/assets/outbox-C0EOKXQq.js +0 -1
  196. package/assets/refresh-cw-CpnxiYht.js +0 -1
  197. package/assets/rotate-ccw-Cj4SUyhN.js +0 -1
  198. package/assets/search-mirror-DQmL3P3k.js +0 -1
  199. package/assets/search-token-index-CXQQu5cA.js +0 -1
  200. package/assets/settings-KZn9t_aP.js +0 -1
  201. package/assets/shield-check-CD-wbm99.js +0 -1
  202. package/assets/suggested-vips-B7UuI1d0.js +0 -1
  203. package/assets/useCalendarEvents-BQ8pmFV8.js +0 -1
  204. package/assets/useCalendarFreeBusy-CrTlSUQQ.js +0 -1
  205. package/assets/useLayoutTier-B0zSRsSh.js +0 -1
  206. package/assets/useMessageBodyContent-DPlXjxls.js +0 -1
  207. package/assets/useRefreshControl-CSd_fo15.js +0 -1
@@ -1 +0,0 @@
1
- import{j as r,r as I,t as Ve,ap as Ce,f as se,_ as zs,X as De,aq as $s,ar as Bs,as as pt,v as qs,w as Ws,at as te,h as Qe,au as Gs,c as os,d as ls,av as Ks,i as pe,aw as Qs,o as we,l as ht,ax as Ys,ay as Zs,az as Js,aA as ve,aB as Pt,L as it,aC as Ct,aD as Xs,aE as Ie,aF as je,aG as Vt,aH as at,B as nt,aI as er,aJ as tr,aK as Dt,n as cs,ac as sr,aL as rr,aM as ir,aN as ds,aO as Ft,u as ar,aP as nr,aQ as or,g as lr,aR as Ot,aS as cr,a4 as dr,aT as ur}from"./index-D7VpR8Bx.js";import{A as ot,g as Rt,P as fr,O as mr}from"./OnboardingWizard-hiUJAJmS.js";import{f as It,E as pr}from"./ErrorState-DcwvjIQG.js";import{R as hr}from"./row-actions-BkhFe3TY.js";import{S as gr,A as yr}from"./settings-screen-BjSyVU2l.js";import{s as $e,b as us,R as fs,u as xr}from"./credential-steps-BES-y0iD.js";import{u as vr}from"./useSignature-BMl5h116.js";import{c as br,a as Mt,d as Sr}from"./account-form-helpers-DhckT_PN.js";import{C as jr}from"./confirm-dialog-PhUq_oc3.js";import{D as wr}from"./download-DS8Ui8jJ.js";import{a as Nr}from"./help-copy-BUCBLhdW.js";import"./checkbox-DJpIppZD.js";import"./minus-Cs2PKH6V.js";import"./kbd-DzZig-MJ.js";import"./mail-BiL0g7on.js";import"./file-json-C0JfxlBX.js";import"./avatar-CDZx9RcB.js";import"./chevron-left-CF03ieoO.js";import"./menu-liPRY-HF.js";import"./circle-help-DqnCeQ17.js";import"./card-WnranLyn.js";const Ar={Mail:"Mail already in Remit stays, and you can keep reading it.",Calendar:"Events already in Remit stay on your calendar."},Tr={Mail:"New mail stops arriving until you turn it back on.",Calendar:"Changes stop arriving until you turn it back on."},Er={Mail:"mail",Calendar:"calendar"};function kr(e,s){const t=Er[e.service];return e.kind==="enable"?{title:`Sign in with ${s} to add ${t}?`,description:`This account was never asked for ${t} access. Remit sends you to ${s} to ask for it, and brings you back here when you are done. Nothing changes until you get back.`,confirmLabel:`Continue to ${s}`,cancelLabel:"Cancel",destructive:!1}:e.kind==="last"?{title:`${e.service} is the only thing this account syncs`,description:`An account has to sync something. To stop this one entirely, remove the account — that deletes what Remit stored for it, which switching ${t} off never does.`,confirmLabel:"Remove account",cancelLabel:`Keep syncing ${t}`,destructive:!0}:{title:`Stop syncing ${t} for this account?`,description:`${Ar[e.service]} ${Tr[e.service]} Nothing is deleted.`,confirmLabel:`Stop syncing ${t}`,cancelLabel:"Cancel",destructive:!1}}function _r({change:e,providerName:s,onConfirm:t,onCancel:a,isBusy:n}){if(e===null)return null;const l=kr(e,s);return r.jsx(jr,{isOpen:!0,title:l.title,description:l.description,confirmLabel:l.confirmLabel,cancelLabel:l.cancelLabel,destructive:l.destructive,isBusy:n??!1,onConfirm:t,onCancel:a})}function Pr({checked:e,label:s,describedBy:t,disabled:a,onToggle:n}){return r.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":s,"aria-describedby":t,disabled:a,onClick:n,className:Ve("relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors","outline-none disabled:cursor-not-allowed disabled:opacity-60 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-surface",e?"border-positive bg-positive":"border-line-strong bg-surface-sunken"),children:r.jsx("span",{"aria-hidden":!0,className:Ve("size-4 rounded-full bg-canvas transition-transform",e?"translate-x-6":"translate-x-1")})})}function Cr({providerName:e,offered:s,enabled:t,consented:a,disabled:n=!1,onRequestChange:l}){const o=I.useId(),u=ot.filter(g=>s.includes(g.id));return u.length<2?null:r.jsxs("fieldset",{children:[r.jsx("legend",{className:"text-sm font-semibold text-fg",children:"What this account syncs"}),r.jsx("div",{className:"mt-1 divide-y divide-line",children:u.map(g=>{const S=t.includes(g.id),N=`${o}-${g.id}`,P=!S&&!a.includes(g.id);return r.jsxs("div",{className:"flex min-h-11 items-center gap-3 py-2 text-left",children:[r.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[r.jsx("span",{className:"text-sm text-fg",children:g.label}),r.jsx("span",{id:N,className:"text-xs text-fg-subtle",children:P?`${g.description} Turning this on means signing in with ${e} again.`:g.description})]}),r.jsx(Pr,{checked:S,label:`Sync ${g.label.toLowerCase()}`,describedBy:N,disabled:n,onToggle:()=>l(g.id,S?"off":"on")})]},g.id)})})]})}const Vr=e=>{const s=new Set(e.map($s));return Bs.map(t=>t.tag).filter(t=>!s.has(t)).sort((t,a)=>Ce(t).localeCompare(Ce(a)))},Dr=({value:e,onChange:s,busy:t=!1})=>{const a=Vr(e);return r.jsxs("div",{className:"space-y-2","data-testid":"compose-language-setting",children:[r.jsx("ul",{className:"space-y-1",children:e.map((n,l)=>r.jsxs("li",{"data-testid":`compose-language-row-${n}`,className:"flex items-center gap-2 rounded-md border border-line bg-surface-sunken px-3 py-1.5",children:[r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-fg",lang:n,children:Ce(n)}),l===0?r.jsx("span",{className:"shrink-0 text-2xs uppercase tracking-wider text-fg-subtle",children:"Default"}):r.jsx(se,{variant:"ghost",size:"sm",icon:r.jsx(zs,{className:"size-3.5"}),disabled:t,"aria-label":`Write new messages in ${Ce(n)} by default`,onClick:()=>s([n,...e.filter(o=>o!==n)]),children:"Default"}),r.jsx(se,{variant:"ghost",size:"sm",icon:r.jsx(De,{className:"size-3.5"}),disabled:t||e.length===1,"aria-label":`Remove ${Ce(n)}`,onClick:()=>s(e.filter(o=>o!==n))})]},n))}),r.jsxs("select",{"aria-label":"Add a language",value:"",disabled:t||a.length===0,onChange:n=>{n.target.value!==""&&s([...e,n.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:[r.jsx("option",{value:"",children:"Add a language…"}),a.map(n=>r.jsx("option",{value:n,children:Ce(n)},n))]}),r.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 Fr({title:e,description:s,action:t}){return r.jsxs("div",{className:"rounded-sm border border-danger/50",children:[r.jsxs("div",{className:"flex items-center gap-2 border-b border-danger/30 bg-danger-soft px-row-inset py-2",children:[r.jsx(pt,{className:"size-4 text-danger"}),r.jsx("h2",{className:"text-sm font-semibold text-danger",children:"Danger zone"})]}),r.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:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"text-sm font-medium text-fg",children:e}),r.jsx("p",{className:"text-xs text-fg-muted",children:s})]}),r.jsx("div",{className:"shrink-0",children:t})]})]})}function Lt({isOpen:e,onClose:s,title:t,children:a,footer:n}){qs({id:"slide-panel",open:e,answers:{back:s}});const l=I.useRef(null);return Ws(l,e),r.jsxs(r.Fragment,{children:[r.jsx("div",{className:Ve("fixed inset-0 z-40 bg-black/30 transition-opacity",e?"opacity-100":"pointer-events-none opacity-0"),onClick:s,"aria-hidden":"true"}),r.jsxs("div",{ref:l,className:Ve("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",tabIndex:-1,children:[r.jsxs("div",{className:"flex h-14 shrink-0 items-center justify-between border-b border-line px-4",children:[r.jsx("h2",{id:"slide-panel-title",className:"font-semibold",children:t}),r.jsx("button",{type:"button",onClick:s,className:"rounded-md p-1.5 transition-colors hover:bg-surface-raised","aria-label":"Close",children:r.jsx(De,{className:"size-5"})})]}),r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[r.jsx("div",{className:"flex-1 overflow-auto p-4",children:a}),n&&r.jsx("div",{className:"flex justify-end gap-3 border-t border-line bg-canvas p-4",children:n})]})]})]})}var Ue=e=>e.type==="checkbox",Ne=e=>e instanceof Date,Y=e=>e==null;const gt=e=>typeof e=="object";var z=e=>!Y(e)&&!Array.isArray(e)&&gt(e)&&!Ne(e),Or=e=>z(e)&&e.target?Ue(e.target)?e.target.checked:e.target.value:e,Rr=(e,s)=>s.split(".").some((t,a,n)=>!isNaN(Number(t))&&e.has(n.slice(0,a).join("."))),ms=e=>{const s=e.constructor&&e.constructor.prototype;return z(s)&&s.hasOwnProperty("isPrototypeOf")},Ye=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function B(e){if(e instanceof Date)return new Date(e);const s=typeof FileList<"u"&&e instanceof FileList;if(Ye&&(e instanceof Blob||s))return e;const t=Array.isArray(e);if(!t&&!(z(e)&&ms(e)))return e;const a=t?[]:Object.create(Object.getPrototypeOf(e));for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(a[n]=B(e[n]));return a}const _e={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"},ps="root",yt=["__proto__","constructor","prototype"],Ir=/^\w*$/;var He=e=>Ir.test(e),L=e=>e===void 0;const Mr=/[.[\]'"]/;var Ze=e=>e.split(Mr).filter(Boolean),v=(e,s,t)=>{if(!s||!z(e))return t;const a=He(s)?[s]:Ze(s);if(a.some(l=>yt.includes(l)))return t;const n=a.reduce((l,o)=>Y(l)?void 0:l[o],e);return L(n)||n===e?L(e[s])?t:e[s]:n},fe=e=>typeof e=="boolean",le=e=>typeof e=="function",M=(e,s,t)=>{let a=-1;const n=He(s)?[s]:Ze(s),l=n.length,o=l-1;for(;++a<l;){const u=n[a];let g=t;if(a!==o){const S=e[u];g=z(S)||Array.isArray(S)?S:isNaN(+n[a+1])?{}:[]}if(yt.includes(u))return;e[u]=g,e=e[u]}};const Lr=te.createContext(null);Lr.displayName="HookFormControlContext";var Ur=(e,s,t,a=!0)=>{const n={};for(const l in e)Object.defineProperty(n,l,{get:()=>{const o=l;return s._proxyFormState[o]!==ue.all&&(s._proxyFormState[o]=!a||ue.all),e[o]}});return n};const Hr=Ye?te.useLayoutEffect:te.useEffect;var Z=e=>typeof e=="string",zr=(e,s,t,a,n)=>Z(e)?(a&&s.watch.add(e),v(t,e,n)):Array.isArray(e)?e.map(l=>(a&&s.watch.add(l),v(t,l))):(a&&(s.watchAll=!0),t),lt=e=>Y(e)||!gt(e);const Ut=(e,s)=>s.length===0&&!Array.isArray(e)&&!ms(e);function me(e,s,t=new WeakMap){if(e===s)return!0;if(lt(e)||lt(s))return Object.is(e,s);if(Ne(e)&&Ne(s))return Object.is(e.getTime(),s.getTime());const a=Object.keys(e),n=Object.keys(s);if(a.length!==n.length)return!1;if(Ut(e,a)||Ut(s,n))return Object.is(e,s);if(!a.length&&Array.isArray(e)!==Array.isArray(s))return!1;const l=t.get(e);if(l&&l.has(s))return!0;if(l)l.add(s);else{const o=new WeakSet;o.add(s),t.set(e,o)}for(const o of a){const u=e[o];if(!(o in s))return!1;if(o!=="ref"){const g=s[o];if(Ne(u)&&Ne(g)||(z(u)||Array.isArray(u))&&(z(g)||Array.isArray(g))?!me(u,g,t):!Object.is(u,g))return!1}}return!0}var Be=e=>({isOnSubmit:!e||e===ue.onSubmit,isOnBlur:e===ue.onBlur,isOnChange:e===ue.onChange,isOnAll:e===ue.all,isOnTouch:e===ue.onTouched}),tt=(e,s,t)=>{if(t)return!1;if(s.watchAll||s.watch.has(e))return!0;for(const a of s.watch)if(e.startsWith(a)&&e.charAt(a.length)===".")return!0;return!1};const Le=(e,s,t,a)=>{for(const n of t||Object.keys(e)){const l=v(e,n);if(l){const{_f:o,...u}=l;if(o){if(o.refs&&o.refs[0]&&s(o.refs[0],n)&&!a)return!0;if(o.ref&&s(o.ref,o.name)&&!a)return!0;if(Le(u,s))break}else if(z(u)&&Le(u,s))break}}};var Ht=(e,s,t)=>{const a=v(e,t),n=Array.isArray(a)?a:[];return M(n,ps,s[t]),M(e,t,n),e},Q=e=>z(e)&&!Object.keys(e).length,xt=e=>e.type==="file",Ge=e=>{if(!Ye)return!1;const s=e?e.ownerDocument:0;return e instanceof(s&&s.defaultView?s.defaultView.HTMLElement:HTMLElement)},vt=e=>e.type==="radio",Ke=e=>e instanceof RegExp,bt=(e,s,t,a,n)=>s?{...t[e],types:{...t[e]&&t[e].types?t[e].types:{},[a]:n||!0}}:{};const zt={value:!1,isValid:!1},$t={value:!0,isValid:!0};var hs=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&&!L(e[0].attributes.value)?L(e[0].value)||e[0].value===""?$t:{value:e[0].value,isValid:!0}:$t:zt}return zt};const Bt={isValid:!1,value:null};var gs=e=>Array.isArray(e)?e.reduce((s,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:s,Bt):Bt;function qt(e,s,t="validate"){if(Z(e)||Array.isArray(e)&&e.every(Z)||fe(e)&&!e)return{type:t,message:Z(e)?e:"",ref:s}}var Pe=e=>z(e)&&!Ke(e)?e:{value:e,message:""},Wt=async(e,s,t,a,n,l)=>{const{ref:o,refs:u,required:g,maxLength:S,minLength:N,min:P,max:H,pattern:h,validate:j,name:E,valueAsNumber:T,mount:oe}=e._f,C=v(t,E);if(!oe||s.has(E))return{};const V=u?u[0]:o,_=F=>{if(n&&V.reportValidity){const D=fe(F)?"":F||"";u?u.forEach(O=>O.setCustomValidity(D)):V.setCustomValidity(D),V.reportValidity()}},k={},J=vt(o),W=Ue(o),ae=J||W,re=(T||xt(o))&&L(o.value)&&L(C)||Ge(o)&&o.value===""||C===""||Array.isArray(C)&&!C.length,ce=bt.bind(null,E,a,k),he=(F,D,O,$=de.maxLength,K=de.minLength)=>{const G=F?D:O;k[E]={type:F?$:K,message:G,ref:o,...ce(F?$:K,G)}};if(l?!Array.isArray(C)||!C.length:g&&(!ae&&(re||Y(C))||fe(C)&&!C||W&&!hs(u).isValid||J&&!gs(u).isValid)){const{value:F,message:D}=Z(g)?{value:!!g,message:g}:Pe(g);if(F&&(k[E]={type:de.required,message:D,ref:V,...ce(de.required,D)},!a))return _(D),k}if(!re&&(!Y(P)||!Y(H))){let F,D;const O=Pe(H),$=Pe(P);if(!Y(C)&&!isNaN(C)){const K=o.valueAsNumber||C&&+C;Y(O.value)||(F=K>O.value),Y($.value)||(D=K<$.value)}else{const K=o.valueAsDate||new Date(C),G=ie=>new Date(new Date().toDateString()+" "+ie),be=o.type=="time",w=o.type=="week";Z(O.value)&&C&&(F=be?G(C)>G(O.value):w?C>O.value:K>new Date(O.value)),Z($.value)&&C&&(D=be?G(C)<G($.value):w?C<$.value:K<new Date($.value))}if((F||D)&&(he(!!F,O.message,$.message,de.max,de.min),!a))return _(k[E].message),k}if((S||N)&&!re&&(Z(C)||l&&Array.isArray(C))){const F=Pe(S),D=Pe(N),O=!Y(F.value)&&C.length>+F.value,$=!Y(D.value)&&C.length<+D.value;if((O||$)&&(he(O,F.message,D.message),!a))return _(k[E].message),k}if(h&&!re&&Z(C)){const{value:F,message:D}=Pe(h);if(Ke(F)&&!C.match(F)&&(k[E]={type:de.pattern,message:D,ref:o,...ce(de.pattern,D)},!a))return _(D),k}if(j){if(le(j)){const F=await j(C,t),D=qt(F,V);if(D&&(k[E]={...D,...ce(de.validate,D.message)},!a))return _(D.message),k}else if(z(j)){let F={};for(const D in j){if(!Q(F)&&!a)break;const O=qt(await j[D](C,t),V,D);O&&(F={...O,...ce(D,O.message)},_(O.message),a&&(k[E]=F))}if(!Q(F)&&(k[E]={ref:V,...F},!a))return k}}return _(!0),k},We=e=>Array.isArray(e)?e:[e],ys=e=>Array.isArray(e)?e.filter(Boolean):[];function $r(e,s){const t=s.slice(0,-1).length;let a=0;for(;a<t;){if(Y(e)){e=void 0;break}e=e[s[a]],a++}return e}function Br(e){for(const s in e)if(e.hasOwnProperty(s)&&!L(e[s]))return!1;return!0}function q(e,s){if(Z(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(o=>yt.includes(String(o))))return e;const a=t.length===1?e:$r(e,t),n=t.length-1,l=t[n];return a&&delete a[l],n!==0&&(z(a)&&Q(a)||Array.isArray(a)&&Br(a))&&q(e,t.slice(0,-1)),e}const xs=e=>{const s={};for(const t of Object.keys(e))if(gt(e[t])&&e[t]!==null&&!Ne(e[t])){const a=xs(e[t]);for(const n of Object.keys(a))s[`${t}.${n}`]=a[n]}else s[t]=e[t];return s},qr=te.createContext(null);qr.displayName="HookFormContext";var Gt=()=>{let e=[];return{get observers(){return e},next:n=>{for(const l of e)l.next&&l.next(n)},subscribe:n=>(e.push(n),{unsubscribe:()=>{e=e.filter(l=>l!==n)}}),unsubscribe:()=>{e=[]}}};function vs(e,s){const t={};for(const a in e)if(e.hasOwnProperty(a)){const n=e[a],l=s[a];if(n&&z(n)&&l){const o=vs(n,l);z(o)&&(t[a]=o)}else e[a]&&(t[a]=l)}return t}var bs=e=>e.type==="select-multiple",Wr=e=>vt(e)||Ue(e),st=e=>Ge(e)&&e.isConnected,Gr=e=>{for(const s in e)if(le(e[s]))return!0;return!1};function Ss(e){return Array.isArray(e)||z(e)&&!Gr(e)}function js(e){return!!(e&&"_f"in e)}function ws(e){return Array.isArray(e)?!e.some(s=>!L(s)):!Object.keys(e).length}function ct(e,s){Array.isArray(e)?e[s]=void 0:delete e[s]}function dt(e,s={},t){for(const a in e){const n=e[a],l=t&&t[a];Ss(n)&&(!Array.isArray(n)||!js(l))?(s[a]=Array.isArray(n)?[]:{},dt(n,s[a],l),ws(s[a])&&ct(s,a)):L(n)||(s[a]=!0)}return s}function Te(e,s,t,a){t||(t=dt(s,{},a));for(const n in e){const l=e[n],o=a&&a[n];Ss(l)&&(!Array.isArray(l)||!js(o))?(L(s)||lt(t[n])?t[n]=dt(l,Array.isArray(l)?[]:{},o):Te(l,Y(s)?{}:s[n],t[n],o),ws(t[n])&&ct(t,n)):me(l,s[n])?ct(t,n):t[n]=!0}return t}var Ns=(e,{valueAsNumber:s,valueAsDate:t,setValueAs:a})=>L(e)?e:s?e===""?NaN:e&&+e:t&&Z(e)?new Date(e):a?a(e):e;function Kt(e){const s=e.ref;return xt(s)?s.files:vt(s)?gs(e.refs).value:bs(s)?[...s.selectedOptions].map(({value:t})=>t):Ue(s)?hs(e.refs).value:Ns(L(s.value)?e.ref.value:s.value,e)}var Kr=(e,s,t,a)=>{const n={};for(const l of e){const o=v(s,l);o&&M(n,l,o._f)}return{criteriaMode:t,names:[...e],fields:n,shouldUseNativeValidation:a}},Me=e=>L(e)?e:Ke(e)?e.source:z(e)?Ke(e.value)?e.value.source:e.value:e;const Qt="AsyncFunction";var Qr=e=>{if(!e||!e.validate)return!1;if(le(e.validate))return e.validate.constructor.name===Qt;if(z(e.validate)){for(const s in e.validate)if(e.validate[s].constructor.name===Qt)return!0}return!1},Yr=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function Yt(e,s,t){const a=v(e,t);if(a||He(t))return{error:a,name:t};const n=t.split(".");for(;n.length;){const l=n.join("."),o=v(s,l),u=v(e,l);if(o&&!Array.isArray(o)&&t!==l)return{name:t};if(u&&u.type)return{name:l,error:u};if(u&&u.root&&u.root.type)return{name:`${l}.root`,error:u.root};n.pop()}return{name:t}}var Zr=(e,s,t,a)=>{t(e);const{name:n,...l}=e,o=Object.keys(l);return!o.length||a&&o.length>=Object.keys(s).length||o.find(u=>s[u]===(!a||ue.all))},Jr=(e,s,t)=>!e||!s||e===s||We(e).some(a=>a&&(t?a===s||a.startsWith(s+"."):a.startsWith(s)||s.startsWith(a))),Xr=(e,s,t,a,n)=>n.isOnAll?!1:!t&&n.isOnTouch?!(s||e):(t?a.isOnBlur:n.isOnBlur)?!e:(t?a.isOnChange:n.isOnChange)?e:!0,ei=(e,s)=>!ys(v(e,s)).length&&q(e,s);const ti={mode:ue.onSubmit,reValidateMode:ue.onChange,shouldFocusError:!0},rt="form",As={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function si(e={}){let s={...ti,...e},t={...B(As),isLoading:le(s.defaultValues),errors:s.errors||{},disabled:s.disabled||!1},a={},n=z(s.defaultValues)||z(s.values)?B(s.defaultValues||s.values)||{}:{},l=s.shouldUnregister?{}:B(n),o={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 g={},S={};let N=0,P=Be(s.mode),H=Be(s.reValidateMode);const h={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},j={...h};let E={...j};const T={array:Gt(),state:Gt()};let oe=0;const C=s.criteriaMode===ue.all,V=(i,c)=>d=>{clearTimeout(S[i]),S[i]=setTimeout(c,d)},_=async i=>{if(!o.keepIsValid&&!s.disabled&&(j.isValid||E.isValid||i)){const c=++oe;let d;s.resolver?(d=Q((await O()).errors),c===oe&&k()):d=await G({fields:a,onlyCheckValid:!0,eventType:_e.VALID}),c===oe&&d!==t.isValid&&T.state.next({isValid:d})}},k=(i,c)=>{!s.disabled&&(j.isValidating||j.validatingFields||E.isValidating||E.validatingFields)&&((i||Array.from(u.mount)).forEach(d=>{d&&(c?M(t.validatingFields,d,c):q(t.validatingFields,d))}),T.state.next({validatingFields:t.validatingFields,isValidating:!Q(t.validatingFields)}))},J=()=>{t.dirtyFields=Te(n,l,void 0,a)},W=(i,c=[],d,f,m=!0,x=!0)=>{if(f&&d&&!s.disabled){if(o.action=!0,x&&Array.isArray(v(a,i))){const y=d(v(a,i),f.argA,f.argB);m&&M(a,i,y)}if(x&&Array.isArray(v(t.errors,i))){const y=d(v(t.errors,i),f.argA,f.argB);m&&M(t.errors,i,y),ei(t.errors,i)}if((j.touchedFields||E.touchedFields)&&x&&Array.isArray(v(t.touchedFields,i))){const y=d(v(t.touchedFields,i),f.argA,f.argB);m&&M(t.touchedFields,i,y)}(j.dirtyFields||E.dirtyFields)&&J(),T.state.next({name:i,isDirty:w(i,c),dirtyFields:t.dirtyFields,errors:t.errors,isValid:t.isValid})}else M(l,i,c)},ae=(i,c)=>{M(t.errors,i,c),t.errors={...t.errors},T.state.next({errors:t.errors})},re=i=>{t.errors=i,T.state.next({errors:t.errors,isValid:!1})},ce=i=>{const c=He(i)?[i]:Ze(i);let d=l,f=n;for(let m=0;m<c.length-1;m++){const x=c[m];if(d=Y(d)?d:d[x],f=Y(f)?f:f[x],d===null&&f!==null)return!0}return!1},he=(i,c,d,f)=>{const m=v(a,i);if(m){if(ce(i))return;const x=L(v(l,i)),y=v(l,i,L(d)?v(n,i):d);L(y)||f&&f.defaultChecked||c?M(l,i,c?y:Kt(m._f)):Ae(i,y),o.mount&&!o.action&&(_(),x&&t.isDirty&&(j.isDirty||E.isDirty)&&(w()||(t.isDirty=!1,T.state.next({...t}))),e.shouldUnregister&&x&&!L(v(l,i))&&tt(i,u)&&(o.watch=!0))}},F=(i,c,d,f,m)=>{let x=!1,y=!1;const b={name:i};if(!s.disabled||f===!0){if(!d||f){const A=me(v(n,i),c);(j.isDirty||E.isDirty)&&(y=t.isDirty,t.isDirty=b.isDirty=!A||w(),x=y!==b.isDirty),y=!!v(t.dirtyFields,i),A!==t.isDirty?t.dirtyFields=Te(n,l,void 0,a):A?q(t.dirtyFields,i):M(t.dirtyFields,i,!0),b.dirtyFields=t.dirtyFields,x=x||(j.dirtyFields||E.dirtyFields)&&y!==!A}if(d){const A=v(t.touchedFields,i);A||(M(t.touchedFields,i,d),b.touchedFields=t.touchedFields,x=x||(j.touchedFields||E.touchedFields)&&A!==d)}x&&m&&T.state.next(b)}return x?b:{}},D=(i,c,d,f)=>{const m=v(t.errors,i),x=(j.isValid||E.isValid)&&fe(c)&&t.isValid!==c;if(s.delayError&&d?(g[i]=V(i,()=>ae(i,d)),g[i](s.delayError)):(clearTimeout(S[i]),delete g[i],d?M(t.errors,i,d):q(t.errors,i),t.errors={...t.errors}),(d?!me(m,d):m)||!Q(f)||x){const y={...f,...x&&fe(c)?{isValid:c}:{},errors:t.errors,name:i};t={...t,...y},T.state.next(y)}},O=async i=>(k(i,!0),await s.resolver(l,s.context,Kr(i||u.mount,a,s.criteriaMode,s.shouldUseNativeValidation))),$=async i=>{const{errors:c}=await O(i);if(k(i),i){for(const d of i){const f=v(c,d);f?u.array.has(d)&&z(f)&&!Object.keys(f).some(m=>!Number.isNaN(Number(m)))?Ht(t.errors,{[d]:f},d):M(t.errors,d,f):q(t.errors,d)}t.errors={...t.errors}}else t.errors=c;return c},K=async({name:i,eventType:c})=>{if(e.validate){const d=await e.validate({formValues:l,formState:t,name:i,eventType:c});if(z(d))for(const f in d){const m=d[f];m&&ze(`${rt}.${f}`,{message:Z(m.message)?m.message:"",type:m.type||de.validate})}else Z(d)||!d?ze(rt,{message:d||"",type:de.validate}):jt(rt);return d}return!0},G=async({fields:i,onlyCheckValid:c,name:d,eventType:f,context:m={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(m.runRootValidation=!0,!await K({name:d,eventType:f})&&(m.valid=!1,c)))return m.valid;for(const x in i){const y=i[x];if(y){const{_f:b,...A}=y;if(b){const U=u.array.has(b.name),ee=y._f&&Qr(y._f),ye=j.validatingFields||j.isValidating||E.validatingFields||E.isValidating;ee&&ye&&k([b.name],!0);const xe=await Wt(y,u.disabled,l,C,s.shouldUseNativeValidation&&!c,U);if(ee&&ye&&k([b.name]),xe[b.name]&&(m.valid=!1,c)||(!c&&(v(xe,b.name)?U?Ht(t.errors,xe,b.name):M(t.errors,b.name,xe[b.name]):q(t.errors,b.name)),e.shouldUseNativeValidation&&xe[b.name]))break}!Q(A)&&await G({context:m,onlyCheckValid:c,fields:A,name:x,eventType:f})}}return m.valid},be=()=>{for(const i of u.unMount){const c=v(a,i);c&&(c._f.refs?c._f.refs.every(d=>!st(d)):!st(c._f.ref))&&Je(i)}u.unMount=new Set},w=(i,c)=>(i&&c&&M(l,i,c),!me(o.mount?l:n,n)),ie=(i,c,d)=>zr(i,u,{...o.mount?l:L(c)?n:Z(i)?{[i]:c}:c},d,c),Ee=i=>ys(v(o.mount?l:n,i,s.shouldUnregister?v(n,i,[]):[])),Ae=(i,c,d={},f=!1,m=!1)=>{const x=v(a,i);let y=c;if(x){const b=x._f;b&&(!b.disabled&&M(l,i,Ns(c,b)),y=Ge(b.ref)&&Y(c)?"":c,bs(b.ref)?[...b.ref.options].forEach(A=>A.selected=y.includes(A.value)):b.refs?Ue(b.ref)?b.refs.forEach(A=>{(!A.defaultChecked||!A.disabled)&&(Array.isArray(y)?A.checked=!!y.find(U=>U===A.value):A.checked=y===A.value||!!y)}):b.refs.forEach(A=>A.checked=A.value===y):xt(b.ref)?b.ref.value="":(b.ref.value=y,!b.ref.type&&!m&&T.state.next({name:i,values:f?l:B(l)})))}(d.shouldDirty||d.shouldTouch)&&F(i,y,d.shouldTouch,d.shouldDirty,!m),d.shouldValidate&&ke(i,{delayError:d.delayError})},p=(i,c,d,f=!1,m=!1)=>{for(const x in c){if(!c.hasOwnProperty(x))return;const y=c[x],b=i+"."+x,A=v(a,b);(u.array.has(i)||z(y)||A&&!A._f)&&!Ne(y)?p(b,y,d,f,m):Ae(b,y,d,f,m)}},R=(i,c,d,f,m=!1)=>{const x=v(a,i),y=u.array.has(i),b=f?c:B(c),A=v(l,i),U=me(A,b);if(U||M(l,i,b),y)T.array.next({name:i,values:f?l:B(l)}),(j.isDirty||j.dirtyFields||E.isDirty||E.dirtyFields)&&d.shouldDirty&&(J(),m||T.state.next({name:i,dirtyFields:t.dirtyFields,isDirty:w(i,b)}));else{const ee=Array.isArray(b)&&!b.length||Q(b);!x||x._f||Y(b)||ee?Ae(i,b,d,f,m):p(i,b,d,f,m)}if(!U&&!m){const ee=tt(i,u),ye=f?l:B(l);T.state.next({...ee&&t,name:o.mount||ee?i:void 0,values:ye})}},X=(i,c,d={})=>R(i,c,d,!1),ne=(i,c={})=>{const d=le(i)?i(l):i;if(!me(l,d)){l={...l,...d};const f=xs(d);for(const m of u.mount)m in f&&R(m,f[m],c,!0,!0);T.state.next({...t,name:void 0,type:void 0,...N?{values:l}:{}}),c.shouldValidate&&_()}},ge=async i=>{o.mount=!0;const c=i.target;let d=c.name,f=!0;const m=v(a,d),x=y=>{f=Number.isNaN(y)||Ne(y)&&isNaN(y.getTime())||me(y,v(l,d,y))};if(m){let y,b;const A=c.type?Kt(m._f):Or(i),U=i.type===_e.BLUR||i.type===_e.FOCUS_OUT,ee=!Yr(m._f)&&!e.validate&&!s.resolver&&!v(t.errors,d)&&!m._f.deps,ye=ee||Xr(U,v(t.touchedFields,d),t.isSubmitted,H,P),xe=tt(d,u,U);if(M(l,d,A),U){if(!c||!c.readOnly){m._f.onBlur&&m._f.onBlur(i);const Re=g[d];Re&&Re(0)}}else m._f.onChange&&m._f.onChange(i);const Oe=F(d,A,U),Us=!Q(Oe)||xe;if(!U&&T.state.next({name:d,type:i.type,...N?{values:B(l)}:{}}),ye)return(!ee||!t.isValid)&&(j.isValid||E.isValid)&&(s.mode==="onBlur"?U&&_():U||_()),Us&&T.state.next({name:d,...xe?{}:Oe});if(!s.resolver&&e.validate&&await K({name:d,eventType:i.type}),!U&&xe&&T.state.next({...t}),s.resolver){const{errors:Re}=await O([d]);if(k([d]),x(A),!f){!Q(Oe)&&T.state.next(Oe);return}const Hs=Yt(t.errors,a,d),_t=Yt(Re,a,Hs.name||d);y=_t.error,d=_t.name,b=Q(Re)}else k([d],!0),y=(await Wt(m,u.disabled,l,C,s.shouldUseNativeValidation))[d],k([d]),x(A),f&&(y?b=!1:(j.isValid||E.isValid)&&(b=await G({fields:a,onlyCheckValid:!0,name:d,eventType:i.type})));f&&(m._f.deps&&(!Array.isArray(m._f.deps)||m._f.deps.length>0)&&ke(m._f.deps),D(d,b,y,Oe))}},Se=(i,c)=>{if(v(t.errors,c)&&i.focus)return i.focus(),1},ke=async(i,c={})=>{let d,f;const m=We(i);if(s.resolver){const x=await $(L(i)?i:m);d=Q(x),f=i?!m.some(y=>v(x,y)):d}else i?(f=(await Promise.all(m.map(async x=>{const y=v(a,x);return await G({fields:y&&y._f?{[x]:y}:y,eventType:_e.TRIGGER})}))).every(Boolean),!(!f&&!t.isValid)&&_()):f=d=await G({fields:a,name:i,eventType:_e.TRIGGER});if(c.delayError&&s.delayError&&Z(i)){const x=v(t.errors,i);x?(q(t.errors,i),g[i]=V(i,()=>ae(i,x)),g[i](s.delayError)):(clearTimeout(S[i]),delete g[i])}return T.state.next({...!Z(i)||(j.isValid||E.isValid)&&d!==t.isValid?{}:{name:i},...s.resolver||!i?{isValid:d}:{},errors:t.errors}),c.shouldFocus&&!f&&Le(a,Se,i?m:u.mount),f},Fe=(i,c)=>{let d={...o.mount?l:n};return c&&(d=vs(c.dirtyFields?t.dirtyFields:t.touchedFields,d)),L(i)?d:Z(i)?v(d,i):i.map(f=>v(d,f))},St=(i,c)=>({invalid:!!v((c||t).errors,i),isDirty:!!v((c||t).dirtyFields,i),error:v((c||t).errors,i),isValidating:!!v(t.validatingFields,i),isTouched:!!v((c||t).touchedFields,i)}),jt=i=>{const c=i?We(i):void 0;c?.forEach(d=>q(t.errors,d)),c?c.forEach(d=>{T.state.next({name:d,errors:t.errors})}):T.state.next({errors:{}})},ze=(i,c,d)=>{const f=(v(a,i,{_f:{}})._f||{}).ref,m=v(t.errors,i)||{},{ref:x,message:y,type:b,...A}=m;M(t.errors,i,{...A,...c,ref:f}),T.state.next({name:i,errors:t.errors,isValid:!1}),d&&d.shouldFocus&&f&&f.focus&&f.focus()},Fs=(i,c)=>{if(le(i)){N++;const{unsubscribe:d}=T.state.subscribe({next:m=>"values"in m&&i(m.values||ie(void 0,c),m)});let f=!1;return{unsubscribe:()=>{f||(f=!0,N--,d())}}}return ie(i,c,!0)},wt=i=>{var c;const d=!!(!((c=i.formState)===null||c===void 0)&&c.values);d&&N++;const{unsubscribe:f}=T.state.subscribe({next:x=>{if(Jr(i.name,x.name,i.exact)&&Zr(x,i.formState||j,Ls,i.reRenderRoot)){const y={...l};i.callback({values:y,...t,...x,defaultValues:n})}}});if(!d)return f;let m=!1;return()=>{m||(m=!0,N--,f())}},Os=i=>(o.mount=!0,E={...E,...i.formState},wt({...i,formState:{...h,...i.formState}})),Je=(i,c={})=>{for(const d of i?We(i):u.mount)u.mount.delete(d),u.array.delete(d),c.keepValue||(q(a,d),q(l,d)),!c.keepError&&q(t.errors,d),!c.keepDirty&&q(t.dirtyFields,d),!c.keepTouched&&q(t.touchedFields,d),!c.keepIsValidating&&q(t.validatingFields,d),!s.shouldUnregister&&!c.keepDefaultValue&&q(n,d);T.state.next({values:B(l)}),T.state.next({...t,...c.keepDirty?{isDirty:w()}:{}}),!c.keepIsValid&&_()},Nt=({disabled:i,name:c})=>{if(fe(i)&&o.mount||i||u.disabled.has(c)){const m=u.disabled.has(c)!==!!i;i?u.disabled.add(c):u.disabled.delete(c),m&&o.mount&&!o.action&&_()}},Xe=(i,c={})=>{let d=v(a,i);const f=fe(c.disabled)||fe(s.disabled),m=!u.registerName.has(i)&&d&&d._f&&!d._f.mount;return M(a,i,{...d||{},_f:{...d&&d._f?d._f:{ref:{name:i}},name:i,mount:!0,...c}}),u.mount.add(i),d&&!m?Nt({disabled:fe(c.disabled)?c.disabled:s.disabled,name:i}):he(i,!0,c.value),{...f?{disabled:c.disabled||s.disabled}:{},...s.progressive?{required:!!c.required,min:Me(c.min),max:Me(c.max),minLength:Me(c.minLength),maxLength:Me(c.maxLength),pattern:Me(c.pattern)}:{},name:i,onChange:ge,onBlur:ge,ref:x=>{if(x){u.registerName.add(i),Xe(i,c),u.registerName.delete(i),d=v(a,i);const y=L(x.value)&&x.querySelectorAll&&x.querySelectorAll("input,select,textarea")[0]||x,b=Wr(y),A=d._f.refs||[];if(b?A.find(U=>U===y):y===d._f.ref)return;M(a,i,{_f:{...d._f,...b?{refs:[...A.filter(st),y,...Array.isArray(v(n,i))?[{}]:[]],ref:{type:y.type,name:i}}:{ref:y}}}),he(i,!1,void 0,y)}else d=v(a,i,{}),d._f&&(d._f.mount=!1),(s.shouldUnregister||c.shouldUnregister)&&!(Rr(u.array,i)&&o.action)&&u.unMount.add(i)}}},et=()=>s.shouldFocusError&&!s.shouldUseNativeValidation&&Le(a,Se,u.mount),Rs=i=>{fe(i)&&(T.state.next({disabled:i}),Le(a,(c,d)=>{const f=v(a,d);f&&(c.disabled=f._f.disabled||i,Array.isArray(f._f.refs)&&f._f.refs.forEach(m=>{m.disabled=f._f.disabled||i}))},0,!1))},At=(i,c)=>async d=>{let f;d&&(d.preventDefault&&d.preventDefault(),d.persist&&d.persist());let m=B(l);if(T.state.next({isSubmitting:!0}),s.resolver){const{errors:x,values:y}=await O();k(),t.errors=x,m=B(y)}else await G({fields:a,eventType:_e.SUBMIT});if(u.disabled.size)for(const x of u.disabled)q(m,x);if(q(t.errors,ps),Q(t.errors)){T.state.next({errors:{}});try{await i(m,d)}catch(x){f=x}}else c&&await c({...t.errors},d),et(),setTimeout(et);if(T.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Q(t.errors)&&!f,submitCount:t.submitCount+1,errors:t.errors}),f)throw f},Is=(i,c={})=>{v(a,i)&&(L(c.defaultValue)?X(i,B(v(n,i))):(X(i,c.defaultValue),M(n,i,B(c.defaultValue))),c.keepTouched||q(t.touchedFields,i),c.keepDirty||(q(t.dirtyFields,i),t.isDirty=c.defaultValue?w(i,B(v(n,i))):w()),c.keepError||(q(t.errors,i),j.isValid&&_()),T.state.next({...t}))},Tt=(i,c={})=>{const d=i?B(i):n,f=B(d),m=Q(i),x=f,y=a;if(c.keepDefaultValues||(n=d),!c.keepValues){if(c.keepDirtyValues){const b=new Set([...u.mount,...Object.keys(Te(n,l,void 0,y))]);for(const A of Array.from(b)){const U=v(t.dirtyFields,A),ee=v(l,A),ye=v(x,A);U&&!L(ee)?M(x,A,ee):!U&&!L(ye)&&X(A,ye)}}else{if(Ye&&L(i))for(const b of u.mount){const A=v(a,b);if(A&&A._f){const U=Array.isArray(A._f.refs)?A._f.refs[0]:A._f.ref;if(Ge(U)){const ee=U.closest("form");if(ee){ee.reset();break}}}}if(c.keepFieldsRef)for(const b of u.mount)X(b,v(x,b));else a={}}if(s.shouldUnregister){if(l=c.keepDefaultValues?B(n):{},c.keepFieldsRef)for(const b of u.mount)M(l,b,v(x,b))}else l=B(x);T.array.next({values:{...x}}),T.state.next({name:void 0,type:void 0,values:{...x}})}u={mount:c.keepDirtyValues?u.mount:new Set,unMount:new Set,array:new Set,registerName:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!j.isValid||!!c.keepIsValid||!!c.keepDirtyValues||!s.shouldUnregister&&!Q(x),o.watch=!!s.shouldUnregister,o.keepIsValid=!!c.keepIsValid,o.action=!1,c.keepErrors||(t.errors={}),T.state.next({submitCount:c.keepSubmitCount?t.submitCount:0,isDirty:m?!1:c.keepDirty?t.isDirty:c.keepValues?w():!!(c.keepDefaultValues&&!me(i,n)),isSubmitted:c.keepIsSubmitted?t.isSubmitted:!1,dirtyFields:m?{}:c.keepDirtyValues?c.keepDefaultValues&&l?Te(n,l,void 0,y):t.dirtyFields:c.keepDefaultValues&&i?Te(n,i,void 0,y):c.keepDirty?t.dirtyFields:{},touchedFields:c.keepTouched?t.touchedFields:{},errors:c.keepErrors?t.errors:{},isSubmitSuccessful:c.keepIsSubmitSuccessful?t.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:n})},Et=(i,c)=>Tt(le(i)?i(l):i,{...s.resetOptions,...c}),Ms=(i,c={})=>{const d=v(a,i),f=d&&d._f;if(f){const m=f.refs?f.refs[0]:f.ref;m.focus&&setTimeout(()=>{m.focus(),c.shouldSelect&&le(m.select)&&m.select()})}},Ls=i=>{const{name:c,type:d,values:f,...m}=i;t={...t,...m}},kt={control:{register:Xe,unregister:Je,getFieldState:St,handleSubmit:At,setError:ze,_subscribe:wt,_runSchema:O,_updateIsValidating:k,_focusError:et,_getWatch:ie,_getDirty:w,_setValid:_,_setFieldArray:W,_setDisabledField:Nt,_setErrors:re,_getFieldArray:Ee,_reset:Tt,_resetDefaultValues:()=>le(s.defaultValues)&&s.defaultValues().then(i=>{Et(i,s.resetOptions),T.state.next({isLoading:!1})}),_removeUnmounted:be,_disableForm:Rs,_subjects:T,_proxyFormState:j,get _fields(){return a},get _formValues(){return l},get _state(){return o},set _state(i){o=i},get _defaultValues(){return n},get _names(){return u},set _names(i){u=i},get _formState(){return t},get _options(){return s},set _options(i){s={...s,...i},P=Be(s.mode),H=Be(s.reValidateMode)}},subscribe:Os,trigger:ke,register:Xe,handleSubmit:At,watch:Fs,setValue:X,setValues:ne,getValues:Fe,reset:Et,resetField:Is,resetDefaultValues:(i,c={})=>{if(n=B(i),!c.keepDirty){const d=Te(n,l,void 0,a);t.dirtyFields=d,t.isDirty=!Q(d)}c.keepIsValid||_(),T.state.next({...t,defaultValues:n})},clearErrors:jt,unregister:Je,setError:ze,setFocus:Ms,getFieldState:St};return{...kt,formControl:kt}}function ri(e={}){const s=te.useRef(void 0),t=te.useRef(void 0),a=te.useRef(e.formControl),[n,l]=te.useState(()=>({...B(As),isLoading:le(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1,defaultValues:le(e.defaultValues)?void 0:e.defaultValues}));if(!s.current||e.formControl&&a.current!==e.formControl)if(a.current=e.formControl,e.formControl)s.current={...e.formControl,formState:n},e.defaultValues&&!le(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:u,...g}=si(e);s.current={...g,formState:n}}const o=s.current.control;return o._options=e,Hr(()=>{const u=o._subscribe({formState:o._proxyFormState,callback:()=>l({...o._formState,defaultValues:o._defaultValues}),reRenderRoot:!0});return l(g=>({...g,isReady:!0})),o._formState.isReady=!0,u},[o]),te.useEffect(()=>o._disableForm(e.disabled),[o,e.disabled]),te.useEffect(()=>{e.mode&&(o._options.mode=e.mode),e.reValidateMode&&(o._options.reValidateMode=e.reValidateMode)},[o,e.mode,e.reValidateMode]),te.useEffect(()=>{e.errors&&(o._setErrors(e.errors),o._focusError())},[o,e.errors]),te.useEffect(()=>{e.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,e.shouldUnregister]),te.useEffect(()=>{if(o._proxyFormState.isDirty){const u=o._getDirty();u!==n.isDirty&&o._subjects.state.next({isDirty:u})}},[o,n.isDirty]),te.useEffect(()=>{var u;e.values&&!me(e.values,t.current)?(o._reset(e.values,{keepFieldsRef:!0,...o._options.resetOptions}),!((u=o._options.resetOptions)===null||u===void 0)&&u.keepIsValid||o._setValid(),t.current=e.values,l(g=>({...g}))):o._resetDefaultValues()},[o,e.values]),te.useEffect(()=>{o._state.mount||(o._setValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()}),s.current.formState=te.useMemo(()=>Ur(n,o),[o,n]),s.current}const Zt=(e,s,t)=>{if(e&&"reportValidity"in e){const a=v(t,s);e.setCustomValidity(a&&a.message||""),e.reportValidity()}},ut=(e,s)=>{for(const t in s.fields){const a=s.fields[t];a&&a.ref&&"reportValidity"in a.ref?Zt(a.ref,t,e):a&&a.refs&&a.refs.forEach(n=>Zt(n,t,e))}},Jt=(e,s)=>{s.shouldUseNativeValidation&&ut(e,s);const t={};for(const a in e){const n=v(s.fields,a),l=Object.assign(e[a]||{},{ref:n&&n.ref});if(ii(s.names||Object.keys(e),a)){const o=Object.assign({},v(t,a));M(o,"root",l),M(t,a,o)}else M(t,a,l)}return t},ii=(e,s)=>{const t=Xt(s).replace(/[.*+?^${}()|\\]/g,"\\$&");return e.some(a=>Xt(a).match(`^${t}\\.\\d+`))};function Xt(e){return e.replace(/[\[\]]/g,"")}function Ts(e,s,t){function a(u,g){var S;Object.defineProperty(u,"_zod",{value:u._zod??{},enumerable:!1}),(S=u._zod).traits??(S.traits=new Set),u._zod.traits.add(e),s(u,g);for(const N in o.prototype)N in u||Object.defineProperty(u,N,{value:o.prototype[N].bind(u)});u._zod.constr=o,u._zod.def=g}const n=t?.Parent??Object;class l extends n{}Object.defineProperty(l,"name",{value:e});function o(u){var g;const S=t?.Parent?new l:this;a(S,u),(g=S._zod).deferred??(g.deferred=[]);for(const N of S._zod.deferred)N();return S}return Object.defineProperty(o,"init",{value:a}),Object.defineProperty(o,Symbol.hasInstance,{value:u=>t?.Parent&&u instanceof t.Parent?!0:u?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}class ai extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const ni={};function Es(e){return ni}function oi(e,s){return typeof s=="bigint"?s.toString():s}const ks=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function qe(e){return typeof e=="string"?e:e?.message}function _s(e,s,t){const a={...e,path:e.path??[]};if(!e.message){const n=qe(e.inst?._zod.def?.error?.(e))??qe(s?.error?.(e))??qe(t.customError?.(e))??qe(t.localeError?.(e))??"Invalid input";a.message=n}return delete a.inst,delete a.continue,s?.reportInput||delete a.input,a}const Ps=(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,oi,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},li=Ts("$ZodError",Ps),Cs=Ts("$ZodError",Ps,{Parent:Error}),ci=e=>(s,t,a,n)=>{const l=a?Object.assign(a,{async:!1}):{async:!1},o=s._zod.run({value:t,issues:[]},l);if(o instanceof Promise)throw new ai;if(o.issues.length){const u=new(n?.Err??e)(o.issues.map(g=>_s(g,l,Es())));throw ks(u,n?.callee),u}return o.value},di=ci(Cs),ui=e=>async(s,t,a,n)=>{const l=a?Object.assign(a,{async:!0}):{async:!0};let o=s._zod.run({value:t,issues:[]},l);if(o instanceof Promise&&(o=await o),o.issues.length){const u=new(n?.Err??e)(o.issues.map(g=>_s(g,l,Es())));throw ks(u,n?.callee),u}return o.value},fi=ui(Cs);function ft(){return ft=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var t=arguments[s];for(var a in t)({}).hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e},ft.apply(null,arguments)}function es(e,s){try{var t=e()}catch(a){return s(a)}return t&&t.then?t.then(void 0,s):t}function mi(e,s){for(var t={};e.length;){var a=e[0],n=a.code,l=a.message,o=a.path.join(".");if(!t[o])if("unionErrors"in a){var u=a.unionErrors[0].errors[0];t[o]={message:u.message,type:u.code}}else t[o]={message:l,type:n};if("unionErrors"in a&&a.unionErrors.forEach(function(N){return N.errors.forEach(function(P){return e.push(P)})}),s){var g=t[o].types,S=g&&g[a.code];t[o]=bt(o,s,t,n,S?[].concat(S,a.message):a.message)}e.shift()}return t}function pi(e,s){for(var t={},a=function(){var n=e[0],l=n.code,o=n.message,u=n.path.join(".");if(!t[u])if(n.code==="invalid_union"&&n.errors.length>0){var g=n.errors[0][0];t[u]={message:g.message,type:g.code}}else t[u]={message:o,type:l};if(n.code==="invalid_union"&&n.errors.forEach(function(P){return P.forEach(function(H){return e.push(ft({},H,{path:[].concat(n.path,H.path)}))})}),s){var S=t[u].types,N=S&&S[n.code];t[u]=bt(u,s,t,l,N?[].concat(N,n.message):n.message)}e.shift()};e.length;)a();return t}function hi(e,s,t){if(t===void 0&&(t={}),(function(a){return"_def"in a&&typeof a._def=="object"&&"typeName"in a._def})(e))return function(a,n,l){try{return Promise.resolve(es(function(){return Promise.resolve(e[t.mode==="sync"?"parse":"parseAsync"](a,s)).then(function(o){return l.shouldUseNativeValidation&&ut({},l),{errors:{},values:t.raw?Object.assign({},a):o}})},function(o){if((function(u){return Array.isArray(u?.issues)})(o))return{values:{},errors:Jt(mi(o.errors,!l.shouldUseNativeValidation&&l.criteriaMode==="all"),l)};throw o}))}catch(o){return Promise.reject(o)}};if((function(a){return"_zod"in a&&typeof a._zod=="object"})(e))return function(a,n,l){try{return Promise.resolve(es(function(){return Promise.resolve((t.mode==="sync"?di:fi)(e,a,s)).then(function(o){return l.shouldUseNativeValidation&&ut({},l),{errors:{},values:t.raw?Object.assign({},a):o}})},function(o){if((function(u){return u instanceof li})(o))return{values:{},errors:Jt(pi(o.issues,!l.shouldUseNativeValidation&&l.criteriaMode==="all"),l)};throw o}))}catch(o){return Promise.reject(o)}};throw new Error("Invalid input: not a Zod schema")}const gi=e=>{const s=Qe(),{pushError:t}=Gs(),{data:a}=os({...ls(),staleTime:1/0}),n=a?.accounts.find(g=>g.accountId===e)?.composeLanguages,l=I.useMemo(()=>n&&n.length>0?[...n]:Ks(navigator.languages),[n]),o=pe({...ht(),onSuccess:()=>{s.invalidateQueries({queryKey:we()})},onError:g=>{t(Qs("Couldn't save languages","The writing languages weren't saved.",g))}}),u=I.useCallback(g=>{e&&o.mutate({path:{accountId:e},body:{composeLanguages:g}})},[e,o]);return{languages:l,setLanguages:u,isSaving:o.isPending}},yi=e=>e.authType==="oauthMicrosoft",xi=e=>{const s=e.smtpUsername?.trim();return s?s!==e.username:!1},vi=Xs({email:je().email().min(1,"Email is required"),displayName:je().optional(),username:je().optional(),password:je().optional(),imapHost:je().min(1,"IMAP host is required"),imapPort:Vt.number().int().min(1).max(65535),imapTls:Ie(),imapStartTls:Ie(),smtpHost:je().optional(),smtpPort:Vt.number().int().min(1).max(65535).optional(),smtpTls:Ie().optional(),smtpStartTls:Ie().optional(),smtpUsername:je().optional(),smtpPassword:je().optional(),useDifferentSmtpCreds:Ie().optional()}),bi=({isOpen:e,onClose:s,account:t,focusSmtp:a})=>{const n=Qe(),l=!!t,[o,u]=I.useState(""),[g,S]=I.useState(!1),N=Rt(o),P=!!N&&!g,H=I.useRef(null),h=ri({resolver:hi(vi),defaultValues:{email:"",displayName:"",username:"",password:"",imapHost:"",imapPort:993,imapTls:!0,imapStartTls:!1,smtpHost:"",smtpPort:587,smtpTls:!1,smtpStartTls:!0,useDifferentSmtpCreds:!1}});I.useEffect(()=>{if(t){const p=xi(t);h.reset({email:t.email,displayName:t.displayName||"",username:t.username||"",password:"",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:p&&t.smtpUsername||"",smtpPassword:"",useDifferentSmtpCreds:p})}else h.reset({email:"",displayName:"",username:"",password:"",imapHost:"",imapPort:993,imapTls:!0,imapStartTls:!1,smtpHost:"",smtpPort:587,smtpTls:!1,smtpStartTls:!0,useDifferentSmtpCreds:!1})},[t,h]);const j=pe({...Ys()}),E=pe({...Zs(),onSuccess:()=>{n.invalidateQueries({queryKey:we()}),s()}}),T=pe({...ht(),onSuccess:()=>{n.invalidateQueries({queryKey:we()}),s()}}),oe=()=>{const p=h.getValues(),R=l&&!p.password;j.mutate({body:{accountId:R?t?.accountId:void 0,username:p.username||p.email,password:R?void 0:p.password||void 0,imapHost:p.imapHost,imapPort:Number(p.imapPort),imapTls:p.imapTls,imapStartTls:p.imapStartTls}})},C=()=>{const p=h.getValues(),R=l&&!p.password;j.mutate({body:{accountId:R?t?.accountId:void 0,username:p.username||p.email,password:R?void 0:p.password||void 0,imapHost:p.imapHost,imapPort:Number(p.imapPort),imapTls:p.imapTls,imapStartTls:p.imapStartTls,smtpHost:p.smtpHost||void 0,smtpPort:p.smtpPort?Number(p.smtpPort):void 0,smtpTls:p.smtpTls,smtpStartTls:p.smtpStartTls,smtpUsername:p.useDifferentSmtpCreds?p.smtpUsername:void 0,smtpPassword:p.useDifferentSmtpCreds?p.smtpPassword:void 0}})},V=h.handleSubmit(p=>{if(!l&&!p.password){h.setError("password",{message:"Password is required"});return}const R=br({imapHost:p.imapHost,smtpHost:p.smtpHost,smtpPort:p.smtpPort,smtpTls:p.smtpTls,smtpStartTls:p.smtpStartTls});R&&(h.setValue("smtpHost",R.smtpHost),h.setValue("smtpPort",R.smtpPort),h.setValue("smtpTls",R.smtpTls),h.setValue("smtpStartTls",R.smtpStartTls));const X=R?.smtpHost??p.smtpHost,ne=R?.smtpPort??p.smtpPort,ge=R?.smtpTls??p.smtpTls,Se=R?.smtpStartTls??p.smtpStartTls,ke={email:p.email,displayName:p.displayName?.trim()||void 0,username:p.username||void 0,imapHost:p.imapHost,imapPort:Number(p.imapPort),imapTls:p.imapTls,imapStartTls:p.imapStartTls,smtpHost:X||void 0,smtpPort:ne?Number(ne):void 0,smtpTls:ge,smtpStartTls:Se,smtpUsername:p.useDifferentSmtpCreds&&p.smtpUsername||void 0,smtpPassword:p.useDifferentSmtpCreds&&p.smtpPassword||void 0};if(l&&t){const Fe={...ke,password:p.password||void 0};T.mutate({path:{accountId:t.accountId},body:Fe})}else{const Fe={...ke,password:p.password};E.mutate({body:Fe})}}),_=E.isPending||T.isPending,{signature:k,setSignature:J,isSaving:W}=vr(t?.accountId),[ae,re]=I.useState(k.plainText),{languages:ce,setLanguages:he,isSaving:F}=gi(t?.accountId),D=r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Writing languages"}),r.jsx(Dr,{value:ce,onChange:he,busy:F})]});I.useEffect(()=>{re(k.plainText)},[k.plainText]),I.useEffect(()=>{if(!e||!a)return;const p=H.current;if(!p)return;const R=window.setTimeout(()=>{p.scrollIntoView({behavior:"smooth",block:"start"})},250);return()=>window.clearTimeout(R)},[e,a]);const O=I.useCallback(()=>{ae!==k.plainText&&J(ae,ae)},[ae,k.plainText,J]),$=p=>{const{tls:R,startTls:X}=$e(p);h.setValue("imapTls",R),h.setValue("imapStartTls",X);const ne=h.getValues("imapPort");(ne===993||ne===143)&&h.setValue("imapPort",p==="tls"?993:143)},K=p=>{const{tls:R,startTls:X}=$e(p);h.setValue("smtpTls",R),h.setValue("smtpStartTls",X);const ne=h.getValues("smtpPort");if(ne===465||ne===587||ne===25){const Se=p==="tls"?465:p==="starttls"?587:25;h.setValue("smtpPort",Se)}},G=()=>{const p=h.getValues("imapHost");h.setValue("smtpHost",Sr(p)),h.setValue("smtpTls",!1),h.setValue("smtpStartTls",!0),h.setValue("smtpPort",587)},be=p=>{u(p),S(!1);const R=Rt(p);if(!R)return;const X=$e(R.imap.security);h.setValue("imapHost",R.imap.host),h.setValue("imapPort",R.imap.port),h.setValue("imapTls",X.tls),h.setValue("imapStartTls",X.startTls);const ne=$e(R.smtp.security);h.setValue("smtpHost",R.smtp.host),h.setValue("smtpPort",R.smtp.port),h.setValue("smtpTls",ne.tls),h.setValue("smtpStartTls",ne.startTls);const ge=h.getValues("email").trim(),Se=h.getValues("username")?.trim();ge&&!Se&&h.setValue("username",ge)},w=N?.passwordHelp.text,ie=Mt(j.data?.imapError,w),Ee=Mt(j.data?.smtpError,w);return(t?yi(t):!1)&&l?r.jsx(Lt,{isOpen:e,onClose:s,title:"Edit Account",footer:r.jsx(se,{type:"button",variant:"secondary",onClick:s,children:"Close"}),children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Microsoft 365 Account"}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"rounded-md border border-line bg-surface-sunken px-3 py-2.5 text-sm text-fg-muted",children:[r.jsx("span",{className:"block text-2xs font-medium uppercase tracking-wider text-fg-subtle mb-1",children:"Email"}),r.jsx("span",{className:"text-fg",children:t?.email})]}),r.jsxs("div",{className:"rounded-md border border-line bg-surface-sunken px-3 py-2.5 text-sm text-fg-muted",children:[r.jsx("span",{className:"block text-2xs font-medium uppercase tracking-wider text-fg-subtle mb-1",children:"Authentication"}),r.jsx("span",{className:"text-fg",children:"Microsoft OAuth (XOAUTH2)"})]}),r.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."})]})]}),l&&r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Signature"}),r.jsx("div",{className:"space-y-3",children:r.jsxs("div",{children:[r.jsx("label",{htmlFor:"email-sig-view",className:"text-sm font-medium mb-1.5 block",children:"Email Signature"}),r.jsx("textarea",{id:"email-sig-view",value:ae,onChange:p=>re(p.target.value),onBlur:O,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..."}),r.jsx("p",{className:"text-xs text-fg-muted mt-1",children:W?"Saving signature...":"This signature will be appended to new emails."})]})})]}),l&&D]})}):r.jsx(Lt,{isOpen:e,onClose:s,title:l?"Edit Account":"Add Account",footer:r.jsxs(r.Fragment,{children:[r.jsx(se,{type:"button",variant:"secondary",onClick:s,children:"Cancel"}),r.jsx(se,{type:"submit",form:"account-form",variant:"primary",disabled:_,children:_?"Saving...":"Save Account"})]}),children:r.jsxs("form",{id:"account-form",onSubmit:V,className:"space-y-6",children:[r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Account Information"}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-provider",className:"text-sm font-medium mb-1.5 block",children:"Provider"}),r.jsxs(Js,{id:"account-provider",value:o,onChange:p=>be(p.target.value),children:[r.jsx("option",{value:"",children:"Custom / other"}),fr.map(p=>r.jsx("option",{value:p.id,children:p.label},p.id))]}),r.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."})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-email",className:"text-sm font-medium mb-1.5 block",children:"Email Address"}),r.jsx(ve,{id:"account-email",...h.register("email"),placeholder:"alice@example.com"}),h.formState.errors.email&&r.jsx("p",{className:"text-sm text-danger mt-1",children:h.formState.errors.email.message})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-displayName",className:"text-sm font-medium mb-1.5 block",children:"Display name (optional)"}),r.jsx(ve,{id:"account-displayName",...h.register("displayName"),placeholder:"Alice"}),r.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."})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-username",className:"text-sm font-medium mb-1.5 block",children:"Username"}),r.jsx(ve,{id:"account-username",...h.register("username"),placeholder:"Same as email if empty"})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-password",className:"text-sm font-medium mb-1.5 block",children:"Password"}),r.jsx(Pt,{id:"account-password",...h.register("password"),placeholder:l?"Leave empty to keep current":""}),h.formState.errors.password&&r.jsx("p",{className:"text-sm text-danger mt-1",children:h.formState.errors.password.message}),N&&r.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[N.passwordHelp.text," ",r.jsx("a",{href:N.passwordHelp.url,target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline",children:"Get an app password"})]})]})]})]}),r.jsxs("section",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider",children:"Incoming Mail (IMAP)"}),N&&r.jsx("button",{type:"button",onClick:()=>S(p=>!p),className:"text-xs text-fg-muted hover:text-fg transition-colors",children:g?"Use preset settings":"Advanced"})]}),P&&r.jsxs("p",{className:"text-xs text-fg-muted mb-3",children:["Server settings are pre-filled for ",N?.label," and locked. Choose Advanced to edit them by hand."]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"imap-host",className:"text-sm font-medium mb-1.5 block",children:"Server"}),r.jsx(ve,{id:"imap-host",...h.register("imapHost"),readOnly:P,placeholder:"imap.example.com"}),h.formState.errors.imapHost&&r.jsx("p",{className:"text-sm text-danger mt-1",children:h.formState.errors.imapHost.message})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"imap-port",className:"text-sm font-medium mb-1.5 block",children:"Port"}),r.jsx(ve,{id:"imap-port",...h.register("imapPort"),readOnly:P,type:"number"})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-sm font-medium mb-1.5 block",children:"Security"}),r.jsxs("div",{className:"space-y-1.5 mt-2",children:[r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:P,checked:h.watch("imapTls"),onChange:()=>$("tls")}),"TLS (Port 993)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:P,checked:!h.watch("imapTls")&&h.watch("imapStartTls"),onChange:()=>$("starttls")}),"STARTTLS (Port 143)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:P,checked:!h.watch("imapTls")&&!h.watch("imapStartTls"),onChange:()=>$("none")}),"None (Unencrypted)"]})]})]})]}),r.jsx(se,{type:"button",variant:"secondary",onClick:oe,disabled:j.isPending,className:"w-full",icon:j.isPending?r.jsx(it,{className:"size-4 animate-spin"}):void 0,children:j.isPending?"Testing...":"Test IMAP Connection"}),j.data&&r.jsxs("div",{className:Ve("p-2 rounded-md text-sm",j.data.imapSuccess?"bg-positive/10 text-positive":"bg-danger-soft text-danger"),children:[j.data.imapSuccess?r.jsx(Ct,{className:"inline size-4 mr-1"}):r.jsx(De,{className:"inline size-4 mr-1"}),j.data.imapSuccess?"IMAP Connected":ie]})]})]}),r.jsxs("section",{ref:H,"data-testid":"smtp-section",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider",children:"Outgoing Mail (SMTP)"}),!P&&r.jsx("button",{type:"button",onClick:G,disabled:!h.watch("imapHost"),className:"text-xs text-fg-muted hover:text-fg transition-colors disabled:opacity-50",children:"Pre-fill from IMAP"})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"smtp-host",className:"text-sm font-medium mb-1.5 block",children:"Server"}),r.jsx(ve,{id:"smtp-host",...h.register("smtpHost"),readOnly:P,placeholder:"smtp.example.com"})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"smtp-port",className:"text-sm font-medium mb-1.5 block",children:"Port"}),r.jsx(ve,{id:"smtp-port",...h.register("smtpPort"),readOnly:P,type:"number"})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-sm font-medium mb-1.5 block",children:"Security"}),r.jsxs("div",{className:"space-y-1.5 mt-2",children:[r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:P,checked:h.watch("smtpTls")===!0,onChange:()=>K("tls")}),"TLS (Port 465)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:P,checked:!h.watch("smtpTls")&&h.watch("smtpStartTls")===!0,onChange:()=>K("starttls")}),"STARTTLS (Port 587)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:P,checked:!h.watch("smtpTls")&&!h.watch("smtpStartTls"),onChange:()=>K("none")}),"None (Unencrypted)"]})]})]})]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"checkbox",...h.register("useDifferentSmtpCreds")}),"Use different credentials for SMTP"]}),h.watch("useDifferentSmtpCreds")&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"smtp-username",className:"text-sm font-medium mb-1.5 block",children:"SMTP Username"}),r.jsx(ve,{id:"smtp-username",...h.register("smtpUsername")})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"smtp-password",className:"text-sm font-medium mb-1.5 block",children:"SMTP Password"}),r.jsx(Pt,{id:"smtp-password",...h.register("smtpPassword")})]})]}),r.jsx(se,{type:"button",variant:"secondary",onClick:C,disabled:j.isPending||!h.watch("smtpHost"),className:"w-full",icon:j.isPending?r.jsx(it,{className:"size-4 animate-spin"}):void 0,children:j.isPending?"Testing...":"Test SMTP Connection"}),j.data?.smtpSuccess!==void 0&&r.jsxs("div",{className:Ve("p-2 rounded-md text-sm",j.data.smtpSuccess?"bg-positive/10 text-positive":"bg-danger-soft text-danger"),children:[j.data.smtpSuccess?r.jsx(Ct,{className:"inline size-4 mr-1"}):r.jsx(De,{className:"inline size-4 mr-1"}),j.data.smtpSuccess?"SMTP Connected":Ee]})]})]}),l&&r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Signature"}),r.jsx("div",{className:"space-y-3",children:r.jsxs("div",{children:[r.jsx("label",{htmlFor:"email-sig-edit",className:"text-sm font-medium mb-1.5 block",children:"Email Signature"}),r.jsx("textarea",{id:"email-sig-edit",value:ae,onChange:p=>re(p.target.value),onBlur:O,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..."}),r.jsx("p",{className:"text-xs text-fg-muted mt-1",children:W?"Saving signature...":"This signature will be appended to new emails."})]})})]}),l&&D]})})},Si="https://graph.microsoft.com/",ji={[at.Mail]:["https://outlook.office.com/IMAP.AccessAsUser.All","https://outlook.office.com/SMTP.Send"],[at.Calendar]:[`${Si}Calendars.Read`]},wi=e=>{const s=new Set(e.map(t=>t.toLowerCase()));return Object.values(at).filter(t=>ji[t].every(a=>s.has(a.toLowerCase())))},mt=e=>`Couldn't turn ${e.service.toLowerCase()} ${e.intent}`,Ni=e=>er(tr({title:`Bug: ${mt(e)}`,errorMessage:`${mt(e)} — ${e.message}`}));function Ai({providerName:e,offered:s,enabled:t,consented:a,disabled:n,refusal:l,onRequestChange:o}){return s.length<2?null:r.jsxs("section",{className:"space-y-2 rounded-sm border border-line bg-surface px-row-inset py-3",children:[r.jsx(Cr,{providerName:e,offered:s,enabled:t,consented:a,disabled:n,onRequestChange:o}),l&&r.jsxs(nt,{tone:"danger",variant:"soft",children:[r.jsx("p",{className:"font-medium",children:mt(l)}),r.jsx("p",{className:"mt-0.5 break-words text-fg-muted",children:l.message}),r.jsx("a",{href:Ni(l),target:"_blank",rel:"noopener noreferrer",className:"mt-1 inline-block font-medium text-accent hover:underline",children:"Report an issue"})]})]})}const Vs=["Mail","Calendar"],ts="Microsoft",ss=e=>e.authType==="oauthMicrosoft",rs=(e,s)=>Vs.filter(t=>t===s||e.includes(t));function Ti({account:e,onRemoveAccount:s}){const t=Qe(),[a,n]=I.useState(null),[l,o]=I.useState(null),[u,g]=I.useState(null),S=pe({...ht(),meta:Dt,onSuccess:()=>t.invalidateQueries({queryKey:we()})}),N=pe({...cs(),meta:Dt}),P=us(V=>{const _=u;g(null),!(V!=="stalled"||_===null)&&o({service:_,intent:"on",message:fs})}),H=S.isPending&&S.variables?.body.syncedServices?S.variables.body.syncedServices:e.syncedServices,h=ss(e)?Vs:["Mail"],j=ss(e)?wi(e.grantedScopes):h,E=(V,_,k)=>{o(null),S.mutate({path:{accountId:e.accountId},body:{syncedServices:V}},{onError:J=>o({service:_,intent:k,message:It(J)})})},T=V=>{o(null),N.mutate({body:{email:e.email,services:rs(H,V)}},{onSuccess:_=>{g(V),P(),window.location.assign(_.authorizationUrl)},onError:_=>o({service:V,intent:"on",message:It(_)})})},oe=(V,_)=>{if(_==="off"){n({kind:H.length===1?"last":"disable",service:V});return}if(!j.includes(V)){n({kind:"enable",service:V});return}E(rs(H,V),V,"on")},C=()=>{const V=a;if(n(null),V!==null){if(V.kind==="last"){s();return}if(V.kind==="enable"){T(V.service);return}E(H.filter(_=>_!==V.service),V.service,"off")}};return r.jsxs(r.Fragment,{children:[r.jsx(Ai,{providerName:ts,offered:h,enabled:H,consented:j,disabled:S.isPending||N.isPending||u!==null,refusal:l,onRequestChange:oe}),r.jsx(_r,{change:a,providerName:ts,onConfirm:C,onCancel:()=>n(null)})]})}function is({open:e,onClose:s,accountEmail:t,signOut:a}){const[n,l]=I.useState(""),[o,u]=I.useState(!1),[g,S]=I.useState(!1),N=pe({...rr(),onSuccess:()=>{S(!0),setTimeout(()=>a(),2e3)}}),P=pe(ir()),H=()=>{N.isPending||(l(""),u(!1),S(!1),N.reset(),P.reset(),s())},h=()=>{if(n.trim().toLowerCase()!==t.toLowerCase()){u(!0);return}u(!1),N.mutate({body:{confirmEmail:n.trim()}})};return r.jsxs(ds,{open:e,onClose:H,title:"Delete your Remit account",children:[r.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[r.jsx(pt,{className:"size-4 shrink-0 text-danger"}),r.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:"Delete your Remit account"}),r.jsx(se,{variant:"ghost",size:"sm",icon:r.jsx(De,{className:"size-3.5"}),onClick:H,"aria-label":"Cancel"})]}),g?r.jsxs("div",{className:"px-5 py-6 text-sm text-fg-muted",children:[r.jsx("p",{className:"font-medium text-fg",children:"Account deletion scheduled."}),r.jsx("p",{className:"mt-1",children:"Your data will be erased shortly. Signing you out…"})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"space-y-4 px-5 py-4 text-sm text-fg-muted",children:[r.jsx("p",{children:"This permanently erases everything Remit holds for you:"}),r.jsxs("ul",{className:"space-y-1.5 text-xs",children:[r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"text-danger",children:"•"}),"All connected accounts disconnected and access tokens revoked."]}),r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"text-danger",children:"•"}),"Synced mail cache and search index."]}),r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"text-danger",children:"•"}),"AI history and insights."]}),r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"text-danger",children:"•"}),"Preferences and rules."]})]}),r.jsxs("div",{className:"rounded-sm border border-line bg-surface-sunken px-3 py-2 text-xs",children:[r.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."]}),r.jsxs("div",{className:"text-xs",children:[r.jsxs("button",{type:"button",onClick:()=>P.mutate({}),"aria-busy":P.isPending,className:"inline-flex items-center gap-1.5 font-medium text-accent hover:underline",children:[r.jsx(wr,{className:"size-3.5"}),P.isPending?"Requesting export…":"Export my data first"]}),P.isSuccess&&r.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."}),P.isError&&r.jsx("p",{className:"mt-1.5 text-danger",role:"alert",children:"Couldn't start the export. Please try again."})]}),r.jsxs("div",{children:[r.jsxs("label",{htmlFor:"confirm-remit-email",className:"mb-1 block text-xs font-medium text-fg",children:["Type"," ",r.jsx("span",{className:"font-mono text-fg-muted",children:t})," ","to confirm"]}),r.jsx(ve,{id:"confirm-remit-email",type:"email",placeholder:t,value:n,onChange:j=>{l(j.target.value),o&&u(!1),N.isError&&N.reset()},autoComplete:"off"}),o&&r.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."}),N.isError&&r.jsx("p",{className:"mt-1.5 text-xs text-danger",role:"alert",children:N.error instanceof Error?N.error.message:"Something went wrong. Please try again."})]})]}),r.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[r.jsx(se,{variant:"secondary",size:"sm",onClick:H,children:"Cancel"}),r.jsx(se,{variant:"danger",size:"sm",onClick:h,"aria-busy":N.isPending,children:N.isPending?"Deleting…":"Delete everything"})]})]})]})}function Ei(e){const{Account:s}=sr();return r.jsx(s,{fallback:r.jsx(is,{...e,accountEmail:"",signOut:()=>{}}),children:({email:t,signOut:a})=>r.jsx(is,{...e,accountEmail:t??"",signOut:a})})}function ki(){const[e,s]=I.useState(!1);return r.jsxs("section",{className:"mt-8 border-t border-line pt-6",children:[r.jsx(Fr,{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:r.jsx(se,{variant:"danger",size:"sm",onClick:()=>s(!0),children:"Delete your Remit account"})}),r.jsx(Ei,{open:e,onClose:()=>s(!1)})]})}function Ds(e){const s=e.toLowerCase();return s==="access_denied"?"You cancelled the sign-in.":s==="scope_not_granted"?"Microsoft did not grant access to every service you picked. Sign in again and accept each permission Microsoft asks for.":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.`}const _i=e=>e.length>1?`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`:e[0]??"";function Pi(e,s){const t=(e.missingServices??"").split(","),a=ot.filter(S=>t.includes(S.id)),n=e.oauthEmail,l=n?s.find(S=>S.authType==="oauthMicrosoft"&&S.email.toLowerCase()===n.toLowerCase()):void 0,o=_i(a.map(S=>S.label)),u=a.length===0?Ds("scope_not_granted"):`Microsoft did not grant access to ${o}. Sign in again and accept the ${o} ${a.length>1?"permissions":"permission"} when Microsoft asks.`,g=l?ot.filter(S=>l.syncedServices.includes(S.id)||a.some(N=>N.id===S.id)).map(S=>S.id):void 0;return{kind:"refused",message:u,email:n,services:g,reconnect:!!l}}function Ci(e){const s=e.split("@")[0]??"";return s?s.split(/[._-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" "):e}function Vi(e){const s=e.displayName?.trim();return s||Ci(e.email)}function Di(e){if(!e.lastSyncAt)return"never synced";const s=ur(e.lastSyncAt);return s?`synced ${s}`:"never synced"}function as(e){return e.muted?.value?"muted":e.lastError?"error":e.connectionState==="authenticated"?"healthy":"error"}function ns(e){return e.connectionState==="reauth_required"}function Fi(e){return e.connectionState==="credentials_missing"}const Oi=()=>r.jsx("div",{className:"space-y-3",role:"status","aria-busy":"true","aria-label":"Loading accounts",children:["skeleton-0","skeleton-1"].map(e=>r.jsx("div",{className:"rounded-sm border border-line bg-surface animate-pulse p-4",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"size-10 rounded-full bg-surface-sunken"}),r.jsxs("div",{className:"flex-1 space-y-2",children:[r.jsx("div",{className:"h-4 bg-surface-sunken rounded w-1/3"}),r.jsx("div",{className:"h-3 bg-surface-sunken rounded w-2/3"})]})]})},e))});function aa(){const e=Ft.useSearch(),s=ar({from:Ft.fullPath}),[t,a]=I.useState(!0),[n,l]=I.useState(!1),[o,u]=I.useState(!1),[g,S]=I.useState(void 0),[N,P]=I.useState(null),[H,h]=I.useState(!1),[j,E]=I.useState(null),[T,oe]=I.useState(null),[C,V]=I.useState(null),[_,k]=I.useState(null),J=Qe(),{data:W,isPending:ae,isError:re,error:ce,refetch:he}=os(ls());I.useEffect(()=>{e.editAccountId&&(P(e.editAccountId),h(!!e.focusSmtp),s({search:{editAccountId:void 0,focusSmtp:void 0,connected:e.connected,oauthError:e.oauthError,oauthEmail:e.oauthEmail,missingServices:e.missingServices},replace:!0}))},[e.editAccountId,e.focusSmtp,s,e.connected,e.oauthError,e.oauthEmail,e.missingServices]),I.useEffect(()=>{e.connected&&(S({kind:"connected",accountId:e.connected}),u(!0),J.invalidateQueries({queryKey:we()}),s({search:{connected:void 0,oauthError:void 0,editAccountId:void 0,focusSmtp:void 0},replace:!0}))},[e.connected,s,J]),I.useEffect(()=>{if(!e.oauthError)return;const w=e.oauthError==="scope_not_granted";w&&!W&&!re||(k(null),w?(S(Pi({oauthEmail:e.oauthEmail,missingServices:e.missingServices},W?.accounts??[])),u(!0)):V(Ds(e.oauthError)),s({search:{oauthError:void 0,connected:void 0,editAccountId:void 0,focusSmtp:void 0},replace:!0}))},[e.oauthError,e.oauthEmail,e.missingServices,W,re,s]),xr(_!==null,()=>{J.invalidateQueries({queryKey:we()})}),I.useEffect(()=>{if(!_||!W)return;const w=W.accounts.find(ie=>ie.accountId===_);(!w||!ns(w))&&k(null)},[W,_]);const F=us(w=>{k(null),w==="stalled"&&V(fs)}),D=pe({...cs(),onSuccess:w=>{F(),window.location.assign(w.authorizationUrl)},onError:w=>{V(w instanceof Error?w.message:"Failed to start reconnect"),k(null)}}),O=pe({...nr(),onSuccess:()=>{J.invalidateQueries({queryKey:we()}),E(null)}}),$=W?.accounts.find(w=>w.accountId===j),K=W?.accounts.find(w=>w.accountId===N),G=()=>{l(!1),u(!1),P(null),h(!1)},be=w=>{const ie=cr[w];ie&&s({to:ie})};return r.jsxs(gr,{items:or,activeId:"accounts",title:"Accounts",description:"Every account keeps syncing — muted ones just stay out of unified views.",help:Nr,helpOpen:t,onToggleHelp:()=>a(w=>!w),onSelect:be,onBackToMail:()=>{s({to:"/mail"})},children:[T&&r.jsx(nt,{tone:"success",variant:"soft","data-testid":"oauth-success-banner",onDismiss:()=>oe(null),children:T}),C&&r.jsx(nt,{tone:"danger",variant:"soft","data-testid":"oauth-error-banner",onDismiss:()=>V(null),children:C}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(lr,{tone:"neutral",children:ae||re?"accounts":`${W.accounts.length} ${W.accounts.length===1?"account":"accounts"}`}),r.jsx(se,{variant:"primary",size:"sm",icon:r.jsx(Ot,{className:"size-3.5"}),onClick:()=>u(!0),children:"Add account"})]}),ae?r.jsx(Oi,{}):re?r.jsx(pr,{title:"Couldn't load accounts",error:ce,onRetry:()=>{he()}}):W.accounts.length===0?r.jsxs("div",{className:"py-12 text-sm text-fg-muted","data-testid":"accounts-empty",children:[r.jsx("p",{className:"mb-3",children:"No accounts configured."}),r.jsx(se,{variant:"primary",size:"sm",icon:r.jsx(Ot,{className:"size-3.5"}),onClick:()=>u(!0),children:"Add your first account"})]}):r.jsx("div",{className:"space-y-3",children:W.accounts.map(w=>{const ie=ns(w),Ee=Fi(w),Ae=w.authType==="oauthMicrosoft",p=_===w.accountId,R=ie&&Ae?{label:"Reconnect",variant:"secondary",busy:p,busyLabel:"Redirecting…",onClick:()=>{k(w.accountId),D.mutate({body:{email:w.email,services:w.syncedServices}})}}:Ee?{label:"Enter password",variant:"secondary",onClick:()=>P(w.accountId)}:as(w)==="error"?{label:"Reconnect",variant:"secondary",onClick:()=>P(w.accountId)}:{label:"Manage",variant:"ghost",onClick:()=>P(w.accountId)},X=r.jsx(hr,{actions:[R],destructive:{label:"Delete account",iconOnly:!0,icon:r.jsx(dr,{className:"size-3.5"}),onClick:()=>E(w.accountId)}});return r.jsxs("div",{className:"space-y-2",children:[r.jsx(yr,{label:Vi(w),email:w.email,connector:Ae?"Microsoft 365":"IMAP",syncLabel:Di(w),state:as(w),errorDetail:ie?w.lastError??"Re-authentication required":Ee?"Imported from a config file, which carries no password. Enter one to start syncing.":w.lastError,trailing:X}),r.jsx(Ti,{account:w,onRemoveAccount:()=>E(w.accountId)})]},w.accountId)})}),o&&r.jsx("div",{className:"fixed inset-0 z-40 overflow-auto bg-canvas",children:r.jsx(mr,{skipWelcome:!0,microsoftReturn:g,onComplete:()=>{g?.kind==="connected"&&oe("Account connected successfully."),u(!1),S(void 0),J.invalidateQueries({queryKey:we()})},onCancel:()=>{u(!1),S(void 0)}})}),r.jsx(bi,{isOpen:n||!!N,account:K,focusSmtp:H,onClose:G}),r.jsxs(ds,{open:!!j,onClose:()=>E(null),title:"Delete account",children:[r.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[r.jsx(pt,{className:"size-4 shrink-0 text-danger"}),r.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:"Delete account"}),r.jsx(se,{variant:"ghost",size:"sm",icon:r.jsx(De,{className:"size-3.5"}),onClick:()=>E(null),"aria-label":"Cancel"})]}),r.jsxs("div",{className:"space-y-3 px-5 py-4 text-sm text-fg-muted",children:[r.jsx("p",{className:"text-center text-lg font-medium text-fg",children:"Are you sure?"}),$&&r.jsx("p",{className:"text-center",children:$.email}),r.jsxs("ul",{className:"list-inside list-disc space-y-1",children:[r.jsx("li",{children:"Remove the account from your settings"}),r.jsx("li",{children:"Stop syncing mail for this account"}),r.jsx("li",{children:"Delete all associated data (within 24 hours)"})]})]}),r.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[r.jsx(se,{variant:"secondary",size:"sm",onClick:()=>E(null),children:"Cancel"}),r.jsx(se,{variant:"danger",size:"sm","aria-busy":O.isPending,icon:O.isPending?r.jsx(it,{className:"size-3.5 animate-spin"}):void 0,onClick:()=>{O.isPending||j&&O.mutate({path:{accountId:j}})},children:O.isPending?"Deleting…":"Delete account"})]})]}),r.jsx(ki,{})]})}export{aa as component,Ds as mapOauthError,Pi as scopeRefusalReturn};
@@ -1 +0,0 @@
1
- import{j as e,X as h,aC as j,t as o,r as d}from"./index-D7VpR8Bx.js";import{A as b}from"./avatar-CDZx9RcB.js";import{M as v}from"./minus-Cs2PKH6V.js";import{C as N}from"./clock-99u2Mdmy.js";const g={accepted:"Coming",tentative:"Maybe",declined:"Not coming",noReply:"No reply"},y={accepted:"text-positive",tentative:"text-warning",declined:"text-danger",noReply:"text-fg-subtle"},k={accepted:j,tentative:N,declined:h,noReply:v};function w({rsvp:s,className:t}){const r=k[s];return e.jsxs("span",{className:o("inline-flex items-center gap-1 text-2xs font-medium",y[s],t),children:[e.jsx(r,{className:"size-3"}),g[s]]})}function R({attendee:s,active:t=!1,onActivate:r,contextId:l,touch:m=!1,className:a}){const c=e.jsxs(e.Fragment,{children:[e.jsx(b,{name:s.name,email:s.email,size:"sm"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-sm text-fg",children:s.name}),s.role==="organizer"&&e.jsx("span",{className:"block text-2xs text-fg-subtle",children:"Organiser"})]}),e.jsx(w,{rsvp:s.rsvp})]});return r?e.jsx("button",{type:"button","aria-expanded":t,"aria-controls":t&&l!==void 0?l:void 0,onClick:()=>r(t?"":s.email),onKeyDown:i=>{i.key==="Escape"&&r("")},onBlur:i=>{t&&i.relatedTarget!==null&&(i.currentTarget.parentElement?.contains(i.relatedTarget)||r(""))},className:o("flex w-full items-center gap-2.5 rounded-md px-1.5 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",m?"min-h-11":"min-h-9",t?"bg-accent-2-soft":"hover:bg-surface-sunken",a),children:c}):e.jsx("div",{className:o("flex min-h-9 items-center gap-2.5",a),children:c})}function T({attendees:s,activeEmail:t="",onActivate:r,renderContext:l,touch:m=!1,className:a}){const c=d.useId();if(s.length===0)return null;const i=["accepted","tentative","declined","noReply"].map(n=>({state:n,count:s.filter(p=>p.rsvp===n).length})).filter(n=>n.count>0).map(n=>`${n.count} ${g[n.state].toLowerCase()}`).join(" · ");return e.jsxs("div",{className:o("flex flex-col",a),children:[e.jsx("p",{className:"pb-1 text-2xs uppercase tracking-wider text-fg-subtle",children:`${s.length} guests · ${i}`}),s.map((n,p)=>{const x=n.email===t,u=`${c}-guest-${p}`,f=e.jsx(R,{attendee:n,active:x,onActivate:r,contextId:l?u:void 0,touch:m});return r?e.jsxs("div",{children:[f,x&&l&&e.jsx("div",{id:u,className:"py-1",children:l(n)})]},n.email):e.jsx(d.Fragment,{children:f},n.email)})]})}export{T as A,w as R};
@@ -1 +0,0 @@
1
- import{e}from"./index-D7VpR8Bx.js";const t=e("BellOff",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742",key:"178tsu"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05",key:"1hqiys"}]]);export{t as B};
@@ -1 +0,0 @@
1
- import{j as r,O as i}from"./index-D7VpR8Bx.js";import{a as m}from"./MailShell-DTW4ysuk.js";import{B as o}from"./BriefPane-DqtL8KK7.js";import{a as p}from"./search-token-index-CXQQu5cA.js";import{u as e}from"./search-mirror-DQmL3P3k.js";import"./useMessageBodyContent-DPlXjxls.js";import"./FullCompose-aUTiTI79.js";import"./ErrorState-DcwvjIQG.js";import"./index-BBaBlwlN.js";import"./useSignature-BMl5h116.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-nmGpghjy.js";import"./sections-ClqQBEFv.js";import"./confirm-dialog-PhUq_oc3.js";import"./MessageBody-xzQttW18.js";import"./kbd-DzZig-MJ.js";import"./search-scope-UI1H6AzA.js";import"./MessageToolbar-D_XXU4rk.js";import"./roving-focus-B9mHbGbD.js";import"./EmptyState-Do3nwfV4.js";import"./popover-menu-BHNjsQiI.js";import"./mail-BiL0g7on.js";import"./avatar-CDZx9RcB.js";import"./useQueries-BDOaD0Tu.js";import"./undo-2-WqFuHEgY.js";import"./download-DS8Ui8jJ.js";import"./useCalendarFreeBusy-CrTlSUQQ.js";import"./useCalendarEvents-BQ8pmFV8.js";import"./useCalendars-B1migLvB.js";import"./map-pin-C0usgYas.js";import"./useLayoutTier-B0zSRsSh.js";import"./calendar-suggestion-B5sKDqe0.js";import"./attendee-row-CPJnqwGs.js";import"./minus-Cs2PKH6V.js";import"./clock-99u2Mdmy.js";import"./calendar-clash-strip-DBNuXhBt.js";import"./bell-off-Bzm-PBgf.js";import"./shield-check-CD-wbm99.js";import"./calendar-report-OI80fkc1.js";import"./menu-liPRY-HF.js";import"./useFilters-zdrGUBZF.js";import"./checkbox-DJpIppZD.js";import"./useRefreshControl-CSd_fo15.js";import"./circle-check-big-Bkno0zML.js";import"./refresh-cw-CpnxiYht.js";import"./LabelApplyTrigger-BNJ7ewFc.js";import"./useLabels-CesUuQey.js";import"./wizard-selection-zWa1qc6-.js";function or(){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{or as component};
@@ -1 +0,0 @@
1
- import{u as g,a as x,b as h,r as i,p as O,c as j,d as y,j as e,O as C}from"./index-D7VpR8Bx.js";import{E as N}from"./ErrorState-DcwvjIQG.js";import{C as P}from"./CalendarShell-_yGJJZGQ.js";import{M as E}from"./MailNav-BdiWAfH_.js";import{i as S,u as b}from"./useLayoutTier-B0zSRsSh.js";import"./bug-rutCyt-b.js";import"./roving-focus-B9mHbGbD.js";import"./bell-off-Bzm-PBgf.js";import"./useQueries-BDOaD0Tu.js";import"./folder-failure-CqkVSsrb.js";import"./outbox-status-BlKn6P0x.js";function W(){const t=g(),c=S(b()),a=x(),r=h(),l=a.includes("nav"),n=i.useCallback(v=>{r(O(a,v?"nav":void 0))},[a,r]),{data:o,isLoading:u,isError:p,error:m,refetch:f}=j({...y(),staleTime:1/0}),s=!!(o&&(o.accounts?.length??0)===0);i.useEffect(()=>{s&&t({to:"/onboarding",replace:!0})},[s,t]);const d=o?.accounts??[];return p?e.jsx("div",{className:"flex h-full items-center justify-center bg-canvas p-4",children:e.jsx(N,{title:"Couldn't load your account",error:m,onRetry:()=>{f()}})}):e.jsx(P,{chrome:{isSinglePane:c,isLoading:u||s,nav:e.jsx(E,{accounts:d,onMailboxSelect:()=>n(!1)}),navOpen:l,onOpenNav:()=>n(!0),onCloseNav:()=>n(!1)},children:e.jsx(C,{})})}export{W as component};
@@ -1 +0,0 @@
1
- import{e as S,h as z,r,b7 as $,i as y,b8 as _,b9 as H,ba as X,s as A,j as e,az as q,aA as N,B as j,f,aR as J,a4 as G,bb as Y,c as ee,bc as se,aK as L,bd as ae,be as te,bf as ne,g as Q,bg as M,aC as re,u as ie,aQ as de,aS as oe}from"./index-D7VpR8Bx.js";import{S as le}from"./settings-screen-BjSyVU2l.js";import{C as P,a as D,b as R,c as O}from"./card-WnranLyn.js";import{U as k,u as ce}from"./useCalendars-B1migLvB.js";import{f as w,E as ue}from"./ErrorState-DcwvjIQG.js";import{u as K}from"./useCalendarWrites-LwW_U-yG.js";import{C as V}from"./confirm-dialog-PhUq_oc3.js";import{R as me}from"./refresh-cw-CpnxiYht.js";import{C as he}from"./copy-CLKRqvl9.js";import{s as pe}from"./calendar-subscription-B-aAc2Gy.js";import"./avatar-CDZx9RcB.js";import"./chevron-left-CF03ieoO.js";import"./menu-liPRY-HF.js";import"./circle-help-DqnCeQ17.js";const xe=S("CalendarPlus",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 13V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8",key:"3spt84"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M16 19h6",key:"xwg31i"}],["path",{d:"M19 16v6",key:"tddt3s"}]]);const be=S("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);const ge=S("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]]);const fe=S("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const ve=S("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]),T=A(400,404),I={kind:"written"},F=s=>({kind:"refused",message:w(s)});function W(){const s=z(),n=K(),t=r.useCallback(()=>s.invalidateQueries({queryKey:$()}),[s]),a=r.useCallback(()=>(n(),t()),[n,t]),i=y({..._(),meta:T,onSuccess:t}),d=y({...H(),meta:T,onSuccess:a}),o=y({...X(),meta:T,onSuccess:a}),l=r.useCallback(c=>i.mutateAsync({body:c}).then(()=>I).catch(F),[i]),m=r.useCallback((c,x)=>d.mutateAsync({path:{calendarId:c},body:x}).then(()=>I).catch(F),[d]),h=r.useCallback(c=>o.mutateAsync({path:{calendarId:c}}).then(()=>I).catch(F),[o]);return r.useMemo(()=>({createCalendar:l,updateCalendar:m,deleteCalendar:h,isWriting:i.isPending||d.isPending||o.isPending}),[l,m,h,i.isPending,d.isPending,o.isPending])}const ye=s=>({title:`Delete ${s}?`,description:`This removes ${s} and every event in it, and any subscription address stops working. It cannot be undone.`}),je=s=>s.normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,64),E=Intl.supportedValuesOf("timeZone");function B({id:s,value:n,disabled:t,onChange:a}){const i=n===k||E.includes(n)?E:[n,...E];return e.jsxs(q,{id:s,value:n,disabled:t,onChange:d=>a(d.target.value),children:[e.jsx("option",{value:k,children:"None (read as UTC)"}),i.map(d=>e.jsx("option",{value:d,children:d},d))]})}function Ce({isBusy:s,problem:n,onCreate:t}){const[a,i]=r.useState(""),[d,o]=r.useState(void 0),[l,m]=r.useState(k),h=r.useId(),c=r.useId(),x=r.useId(),u=r.useId(),p=d??je(a),b=a.trim()!==""&&p.trim()!=="";return e.jsxs(P,{className:"max-w-xl",role:"region","aria-labelledby":h,children:[e.jsx(D,{children:e.jsx(R,{id:h,children:"New calendar"})}),e.jsx(O,{children:e.jsxs("form",{className:"space-y-3",onSubmit:g=>{g.preventDefault(),b&&t({displayName:a.trim(),urlSegment:p.trim(),timezone:l}).then(v=>{v&&(i(""),o(void 0),m(k))})},children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:c,className:"text-xs font-medium text-fg-muted",children:"Name"}),e.jsx(N,{id:c,value:a,maxLength:140,disabled:s,onChange:g=>i(g.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:x,className:"text-xs font-medium text-fg-muted",children:"Address"}),e.jsx(N,{id:x,value:p,maxLength:64,disabled:s,onChange:g=>o(g.target.value)})]}),e.jsxs("div",{className:"space-y-1 sm:col-span-2",children:[e.jsx("label",{htmlFor:u,className:"text-xs font-medium text-fg-muted",children:"Time zone"}),e.jsx(B,{id:u,value:l,disabled:s,onChange:m})]})]}),e.jsx("p",{className:"text-xs text-fg-muted",children:"The address names the calendar for CalDAV clients and cannot be changed later. The name and zone can."}),n!==""&&e.jsxs(j,{tone:"danger",variant:"soft",children:[e.jsx("p",{className:"font-medium",children:"The calendar was not added."}),e.jsx("p",{className:"mt-0.5 break-words",children:n})]}),e.jsx(f,{type:"submit",variant:"primary",size:"sm",disabled:s||!b,icon:e.jsx(J,{className:"size-3.5"}),children:s?"Adding…":"Add calendar"})]})})]})}function Ne({calendarName:s,timezone:n,isBusy:t,problem:a,onSave:i,onDelete:d}){const[o,l]=r.useState(s),[m,h]=r.useState(n),[c,x]=r.useState(!1),u=r.useId(),p=r.useId(),b=o.trim(),g=b!==s||m!==n,v=ye(s);return e.jsxs(e.Fragment,{children:[e.jsxs("form",{className:"space-y-3",onSubmit:C=>{C.preventDefault(),!(!g||b==="")&&i({displayName:b,timezone:m})},children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:u,className:"text-xs font-medium text-fg-muted",children:"Name"}),e.jsx(N,{id:u,value:o,maxLength:140,disabled:t,onChange:C=>l(C.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:p,className:"text-xs font-medium text-fg-muted",children:"Time zone"}),e.jsx(B,{id:p,value:m,disabled:t,onChange:h})]})]}),a!==""&&e.jsxs(j,{tone:"danger",variant:"soft",children:[e.jsxs("p",{className:"font-medium",children:[s," was not changed."]}),e.jsx("p",{className:"mt-0.5 break-words",children:a})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(f,{type:"submit",variant:"secondary",size:"sm",disabled:t||!g||b==="",icon:e.jsx(ve,{className:"size-3.5"}),children:"Save changes"}),e.jsx(f,{type:"button",variant:"danger",size:"sm",disabled:t,icon:e.jsx(G,{className:"size-3.5"}),onClick:()=>x(!0),children:"Delete calendar"})]})]}),e.jsx(V,{isOpen:c,title:v.title,description:v.description,confirmLabel:"Delete calendar",destructive:!0,onConfirm:()=>{x(!1),d()},onCancel:()=>x(!1)})]})}const Se="/feeds/calendar/",ke=".ics",we=(s,n)=>`webcal://${s}${Se}${n}${ke}`;function Te(s){const n=z(),[t,a]=r.useState(""),i=Y({path:{calendarId:s}}),d=ee({...se({path:{calendarId:s}}),meta:A(404,403),retry:!1}),o=()=>{n.invalidateQueries({queryKey:i})},l=r.useRef(()=>{}),m=y({...ae(),meta:L,onMutate:()=>{l.current()},onSuccess:()=>{a(""),o()}}),h=y({...te(),meta:L,gcTime:0,onMutate:()=>{m.reset()},onSuccess:Z=>{a(we(window.location.host,Z.feedToken)),o()}});l.current=h.reset;const{mutate:c,reset:x}=h,{mutate:u}=m,p=r.useCallback(()=>{c({path:{calendarId:s}})},[s,c]),b=r.useCallback(()=>{u({path:{calendarId:s}})},[s,u]),g=r.useCallback(()=>{a(""),x()},[x]),{refetch:v}=d,C=r.useCallback(()=>{v()},[v]);return{state:Ie(d),mintedUrl:t,isBusy:h.isPending||m.isPending,actionError:h.error??m.error,mint:p,revoke:b,dismissMinted:g,retry:C}}function Ie(s){return s.error?ne(s.error)?{status:"absent"}:{status:"unreadable",error:s.error}:s.isPending?{status:"loading"}:s.data?{status:"active",createdAt:s.data.createdAt,rotatedAt:s.data.rotatedAt}:{status:"absent"}}const Fe=s=>({title:`Replace the address for ${s}?`,description:"Every client already subscribed to the current address stops updating and has to be pointed at the new one. The new address is shown once."}),Ee=s=>({title:`Stop sharing ${s}?`,description:"The address stops working immediately and every client subscribed to it stops updating. Sharing again mints a different address."});function Me({calendarName:s,url:n,onDismiss:t}){const[a,i]=r.useState(!1),[d,o]=r.useState(!1),l=r.useRef(0);r.useEffect(()=>()=>window.clearTimeout(l.current),[]);const m=()=>{navigator.clipboard.writeText(n).then(()=>{o(!1),i(!0),l.current=window.setTimeout(()=>i(!1),2e3)}).catch(()=>o(!0))};return e.jsxs("div",{className:"mt-3 space-y-2 rounded-sm border border-accent-2/40 bg-accent-2/10 px-3 py-2.5",children:[e.jsx("p",{className:"text-sm font-medium text-fg",children:"Subscribe with this address. It is shown once and cannot be read back."}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsx("input",{readOnly:!0,value:n,"aria-label":`Subscription address for ${s}`,onFocus:h=>h.currentTarget.select(),className:"min-w-0 flex-1 rounded-sm border border-line bg-surface px-2 py-1.5 font-mono text-xs text-fg"}),e.jsx(f,{variant:"primary",size:"sm",icon:a?e.jsx(re,{className:"size-3.5"}):e.jsx(he,{className:"size-3.5"}),onClick:m,children:a?"Copied":"Copy address"})]}),d&&e.jsx(j,{tone:"warning",variant:"soft",children:"The address could not be copied to the clipboard. Select it above and copy it by hand before leaving this page."}),e.jsx("p",{className:"text-xs text-fg-muted",children:"Anyone holding this address can read every event in this calendar, without signing in. Rotate it if it reaches the wrong person."}),e.jsx(f,{variant:"ghost",size:"sm",onClick:t,children:"I've saved it"})]})}function ze({createdAt:s,rotatedAt:n,isBusy:t,onRotate:a,onRevoke:i}){return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Q,{tone:"positive",children:"shared"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:["Address created ",M(s,"medium"),n>0?`, last replaced ${M(n,"medium")}`:""]})]}),e.jsx("p",{className:"text-sm text-fg-muted",children:"The address itself is not stored in readable form, so it cannot be shown again. Replace it if you no longer know where it went."}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(f,{variant:"secondary",size:"sm",disabled:t,icon:e.jsx(me,{className:"size-3.5"}),onClick:a,children:"Replace address"}),e.jsx(f,{variant:"danger",size:"sm",disabled:t,icon:e.jsx(G,{className:"size-3.5"}),onClick:i,children:"Stop sharing"})]})]})}function Ae({calendarName:s,details:n,state:t,mintedUrl:a,isBusy:i,actionError:d,onMint:o,onRevoke:l,onDismissMinted:m,onRetry:h}){const[c,x]=r.useState("none"),u=r.useId(),p=()=>{const g=c;x("none"),g==="rotate"&&o(),g==="revoke"&&l()},b=c==="revoke"?Ee(s):Fe(s);return e.jsxs(P,{className:"max-w-xl",role:"region","aria-labelledby":u,children:[e.jsx(D,{children:e.jsx(R,{id:u,children:s})}),e.jsxs(O,{children:[n&&e.jsx("div",{className:"mb-4 border-b border-line pb-4",children:n}),t.status==="loading"&&a===""&&e.jsx("div",{className:"h-12 animate-pulse rounded-sm bg-surface-sunken","aria-busy":"true","aria-label":`Loading the subscription address for ${s}`}),t.status==="unreadable"&&a===""&&e.jsx(ue,{variant:"inline",title:`Couldn't read whether ${s} is shared`,error:t.error,onRetry:h}),t.status==="absent"&&a===""&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-fg-muted",children:"Give this calendar a secret address and Apple Calendar, Google Calendar, Outlook and Thunderbird can subscribe to it read-only. Nobody signs in — the address is the credential, so treat it like a password."}),e.jsx(f,{variant:"primary",size:"sm",disabled:i,icon:e.jsx(be,{className:"size-3.5"}),onClick:o,children:i?"Creating…":"Create subscription address"})]}),t.status==="active"&&e.jsx(ze,{createdAt:t.createdAt,rotatedAt:t.rotatedAt,isBusy:i,onRotate:()=>x("rotate"),onRevoke:()=>x("revoke")}),d!=null&&e.jsxs(j,{tone:"danger",variant:"soft",className:"mt-3",children:[e.jsxs("p",{className:"font-medium",children:["The subscription address for ",s," was not changed."]}),e.jsx("p",{className:"mt-0.5 break-words",children:w(d)})]}),a!==""&&e.jsx(Me,{calendarName:s,url:a,onDismiss:m})]}),e.jsx(V,{isOpen:c!=="none",title:b.title,description:b.description,confirmLabel:c==="revoke"?"Stop sharing":"Replace address",destructive:!0,onConfirm:p,onCancel:()=>x("none")})]})}function Pe({calendarId:s,calendarName:n,details:t}){const a=Te(s);return e.jsx(Ae,{calendarName:n,details:t,state:a.state,mintedUrl:a.mintedUrl,isBusy:a.isBusy,actionError:a.actionError,onMint:a.mint,onRevoke:a.revoke,onDismissMinted:a.dismissMinted,onRetry:a.retry})}function De({calendarId:s,calendarName:n,timezone:t,subscription:a}){const{updateCalendar:i,deleteCalendar:d,isWriting:o}=W(),[l,m]=r.useState(""),h=c=>m(c.kind==="refused"?c.message:"");return e.jsx(Pe,{calendarId:s,calendarName:n,details:e.jsxs(e.Fragment,{children:[a,e.jsx(Ne,{calendarName:n,timezone:t,isBusy:o,problem:l,onSave:c=>{m(""),i(s,c).then(h)},onDelete:()=>{m(""),d(s).then(h)}},`${n}\0${t}`)]})})}const Re="Subscribe to a calendar";function Oe({isBusy:s,error:n,onSubscribe:t}){const a=r.useId(),i=r.useId(),d=r.useId(),[o,l]=r.useState(""),[m,h]=r.useState(""),c=o.trim()!==""&&m.trim()!=="",x=u=>{u.preventDefault(),c&&t({displayName:o,url:m},()=>{l(""),h("")})};return e.jsxs(P,{className:"max-w-xl",role:"region","aria-labelledby":a,children:[e.jsx(D,{children:e.jsx(R,{id:a,children:Re})}),e.jsx(O,{children:e.jsxs("form",{className:"space-y-3",onSubmit:x,children:[e.jsx("p",{className:"text-sm text-fg-muted",children:"Paste the secret iCal address from Google Calendar, a published Outlook calendar or any other feed. It shows here read-only and refreshes on its own."}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:i,className:"text-sm font-medium text-fg",children:"Calendar name"}),e.jsx(N,{id:i,value:o,onChange:u=>l(u.target.value),placeholder:"Team rota",autoComplete:"off"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:d,className:"text-sm font-medium text-fg",children:"Calendar address"}),e.jsx(N,{id:d,value:m,onChange:u=>h(u.target.value),placeholder:"https://calendar.google.com/calendar/ical/…/basic.ics",autoComplete:"off",spellCheck:!1,inputMode:"url"}),e.jsx("p",{className:"text-xs text-fg-muted",children:"For Google Calendar the address is the password to the calendar. Reader never shows it in full again."})]}),e.jsx(f,{type:"submit",variant:"primary",size:"sm",disabled:!c||s,icon:e.jsx(xe,{className:"size-3.5"}),children:s?"Subscribing…":"Subscribe"}),n!=null&&e.jsxs(j,{tone:"danger",variant:"soft",children:[e.jsx("p",{className:"font-medium",children:"The calendar was not added."}),e.jsx("p",{className:"mt-0.5 break-words",children:w(n)})]})]})})]})}function Le({calendarName:s,subscriptionUrl:n,enabled:t,fetchedAt:a,error:i,isBusy:d,actionError:o,onSetEnabled:l}){return e.jsxs("div",{className:"mb-4 space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Q,{tone:t?"positive":"neutral",children:t?"subscribed":"paused"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:["Read-only, from ",pe(n),a>0?`. Last updated ${M(a,"medium")}`:""]})]}),i!==""&&e.jsxs(j,{tone:"warning",variant:"soft",children:[e.jsxs("p",{className:"font-medium",children:[s," was not refreshed."]}),e.jsx("p",{className:"mt-0.5 break-words",children:i})]}),e.jsx("p",{className:"text-sm text-fg-muted",children:t?"Events are read from the feed on a schedule and cannot be edited here.":"Updates are paused. The events already here stay until you resume or remove the calendar."}),e.jsx(f,{variant:"secondary",size:"sm",disabled:d,icon:t?e.jsx(ge,{className:"size-3.5"}):e.jsx(fe,{className:"size-3.5"}),onClick:()=>l(!t),children:t?"Pause updates":"Resume updates"}),o!=null&&e.jsxs(j,{tone:"danger",variant:"soft",children:[e.jsxs("p",{className:"font-medium",children:["Updates for ",s," were not changed."]}),e.jsx("p",{className:"mt-0.5 break-words",children:w(o)})]})]})}const U=A(400,404),Ue=()=>`subscribed-${crypto.randomUUID().slice(0,8)}`;function $e(){const s=z(),n=K(),t=()=>{s.invalidateQueries({queryKey:$()}),n()},a=y({..._(),meta:U,onSuccess:t}),i=y({...H(),meta:U,onSuccess:t}),{mutate:d}=a,o=r.useCallback((h,c)=>{d({body:{urlSegment:Ue(),displayName:h.displayName.trim(),subscriptionUrl:h.url.trim()}},{onSuccess:c})},[d]),{mutate:l}=i,m=r.useCallback((h,c)=>{l({path:{calendarId:h},body:{subscriptionEnabled:c}})},[l]);return{subscribe:o,isSubscribing:a.isPending,subscribeError:a.error,setEnabled:m,togglingCalendarId:i.isPending?i.variables?.path.calendarId??"":"",toggleFailure:{calendarId:i.variables?.path.calendarId??"",error:i.error}}}const _e=e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{children:"Each calendar has a name, a time zone its floating times are read in, and an address CalDAV clients reach it by. The address is fixed when the calendar is added; the name and zone can change. Deleting a calendar deletes every event in it. The default calendar is where accepted invitations land, so it cannot be deleted."}),e.jsx("p",{children:"A subscription address lets Apple Calendar, Google Calendar, Outlook and Thunderbird show a calendar from here, read-only and kept up to date."}),e.jsx("p",{children:"Those clients never sign in, so the address itself is the credential. Anyone who has it can read the calendar; nobody who has it can change anything."}),e.jsx("p",{children:"Only a hash of the address is stored, so it is shown once and cannot be looked up later. Replacing it breaks every subscription built on the old one, which is how a shared address is taken back."}),e.jsx("p",{children:"Subscribing works the other way round: paste another calendar's iCal address and its events show here, read-only, refreshed on a schedule."})]});function as(){const s=ie(),[n,t]=r.useState(!0),{calendars:a,collections:i,timeZoneByCalendarId:d,isLoading:o}=ce(),l=$e(),{createCalendar:m,isWriting:h}=W(),[c,x]=r.useState("");return e.jsx(le,{items:de,activeId:"calendars",title:"Calendars",description:"Add, rename and delete calendars, subscribe to a calendar feed, and share one with any client that can subscribe to a URL.",help:_e,helpOpen:n,onToggleHelp:()=>t(u=>!u),onSelect:u=>{const p=oe[u];p&&s({to:p})},onBackToMail:()=>{s({to:"/mail"})},children:o?e.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":"Loading calendars"}):e.jsxs("div",{className:"space-y-4",children:[a.map(u=>{const p=i.find(b=>b.calendarId===u.id);return e.jsx(De,{calendarId:u.id,calendarName:u.name,timezone:d[u.id]??"",subscription:p?.source==="Subscribed"&&e.jsx(Le,{calendarName:p.displayName,subscriptionUrl:p.subscriptionUrl,enabled:p.subscriptionEnabled,fetchedAt:p.subscriptionFetchedAt,error:p.subscriptionError,isBusy:l.togglingCalendarId===u.id,actionError:l.toggleFailure.calendarId===u.id?l.toggleFailure.error:void 0,onSetEnabled:b=>l.setEnabled(u.id,b)})},u.id)}),e.jsx(Oe,{isBusy:l.isSubscribing,error:l.subscribeError,onSubscribe:l.subscribe}),e.jsx(Ce,{isBusy:h,problem:c,onCreate:u=>(x(""),m(u).then(p=>p.kind==="written"?!0:(x(p.message),!1)))})]})})}export{as as component};
@@ -1 +0,0 @@
1
- import{j as r,t}from"./index-D7VpR8Bx.js";function n({raised:s,className:e,...a}){return r.jsx("div",{className:t("rounded-sm border border-line bg-surface",s?"bg-surface-raised shadow-sm":"",e),...a})}function o({className:s,...e}){return r.jsx("div",{className:t("px-4 pt-3 pb-2",s),...e})}function i({className:s,...e}){return r.jsx("h3",{className:t("text-md font-semibold text-fg",s),...e})}function m({className:s,...e}){return r.jsx("div",{className:t("px-4 pb-3 text-sm text-fg-muted",s),...e})}export{n as C,o as a,i as b,m as c};
@@ -1 +0,0 @@
1
- import{e}from"./index-D7VpR8Bx.js";const t=e("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);export{t as C};
@@ -1 +0,0 @@
1
- import{e}from"./index-D7VpR8Bx.js";const t=e("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);export{t as C};
@@ -1 +0,0 @@
1
- import{e}from"./index-D7VpR8Bx.js";const p=e("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);export{p as C};
@@ -1 +0,0 @@
1
- import{F as o}from"./FullCompose-aUTiTI79.js";import"./index-D7VpR8Bx.js";import"./ErrorState-DcwvjIQG.js";import"./index-BBaBlwlN.js";import"./useMessageBodyContent-DPlXjxls.js";import"./useSignature-BMl5h116.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-nmGpghjy.js";import"./sections-ClqQBEFv.js";import"./confirm-dialog-PhUq_oc3.js";const c=o;export{c as component};
@@ -1 +0,0 @@
1
- import{F as o}from"./FullCompose-aUTiTI79.js";import"./index-D7VpR8Bx.js";import"./ErrorState-DcwvjIQG.js";import"./index-BBaBlwlN.js";import"./useMessageBodyContent-DPlXjxls.js";import"./useSignature-BMl5h116.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-nmGpghjy.js";import"./sections-ClqQBEFv.js";import"./confirm-dialog-PhUq_oc3.js";const c=o;export{c as component};
@@ -1 +0,0 @@
1
- import{F as o}from"./FullCompose-aUTiTI79.js";import"./index-D7VpR8Bx.js";import"./ErrorState-DcwvjIQG.js";import"./index-BBaBlwlN.js";import"./useMessageBodyContent-DPlXjxls.js";import"./useSignature-BMl5h116.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-nmGpghjy.js";import"./sections-ClqQBEFv.js";import"./confirm-dialog-PhUq_oc3.js";const c=o;export{c as component};
@@ -1 +0,0 @@
1
- import{F as o}from"./FullCompose-aUTiTI79.js";import"./index-D7VpR8Bx.js";import"./ErrorState-DcwvjIQG.js";import"./index-BBaBlwlN.js";import"./useMessageBodyContent-DPlXjxls.js";import"./useSignature-BMl5h116.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-nmGpghjy.js";import"./sections-ClqQBEFv.js";import"./confirm-dialog-PhUq_oc3.js";const c=o;export{c as component};
@@ -1 +0,0 @@
1
- import{e}from"./index-D7VpR8Bx.js";const t=e("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"}]]);export{t as C};
@@ -1 +0,0 @@
1
- import{e}from"./index-D7VpR8Bx.js";const a=e("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);export{a as D};
@@ -1 +0,0 @@
1
- import{j as t,b2 as te,h as se,i as ae,bh as ne,bi as ie,r as f,bj as re,bk as oe,bl as le,L as Q,f as S,bm as de,aN as ce,g as ue,bn as me,a4 as pe,aI as G,aJ as J,c as V,N as xe,bo as fe,af as ge,ag as he,bp as be,bq as ve,u as je,d as ye,aQ as Ne,aS as Ce}from"./index-D7VpR8Bx.js";import{E as U,f as Se}from"./ErrorState-DcwvjIQG.js";import{S as Fe}from"./settings-screen-BjSyVU2l.js";import{B as Ie}from"./bottom-sheet-B-kTBnyv.js";import{u as Me,a as ke}from"./useLabels-CesUuQey.js";import{b as we,N as I,p as Ee,u as Re,r as Te,a as Y,S as _,c as De,n as Oe,f as Le,d as Ae,e as $e,g as ze,h as Pe,i as Ue}from"./useFilters-zdrGUBZF.js";import{C as H}from"./circle-check-Nj7sUGPS.js";import"./avatar-CDZx9RcB.js";import"./chevron-left-CF03ieoO.js";import"./menu-liPRY-HF.js";import"./circle-help-DqnCeQ17.js";const He=e=>{const s=te(e);return s!==void 0&&s>=400&&s<500};function q({title:e,error:s,onRetry:n,reportHref:i}){return t.jsxs("div",{className:"space-y-1",children:[t.jsx(U,{variant:"inline",title:e,error:s,onRetry:He(s)?void 0:n}),t.jsx("a",{href:i(Se(s)),target:"_blank",rel:"noreferrer",className:"text-xs text-accent hover:underline",children:"Report an issue"})]})}const _e=(e,s)=>{const n=se(),i=ae({...ie(),onSuccess:()=>{e&&(n.invalidateQueries({queryKey:we(e)}),s&&n.invalidateQueries({queryKey:ne({path:{accountId:e,filterId:s}})}))}}),{mutate:c}=i;return{updateFilter:f.useCallback(g=>{!e||!s||c({path:{accountId:e,filterId:s},body:g})},[e,s,c]),isPending:i.isPending,isSuccess:i.isSuccess,isError:i.isError,error:i.error,reset:i.reset}},qe=e=>({clauses:e.literalClauses.map((n,i)=>({id:`clause-${i}`,field:n.field,value:n.value})),matchOperator:e.matchOperator==="And"?"all":"any",moveMailboxId:e.actionMailboxId!==I?e.actionMailboxId:void 0,labelId:e.actionLabelId!==I?e.actionLabelId:void 0,scope:e.scope==="Temporary"?"until":"standing",until:e.scope==="Temporary"?Be(e.expiresAt):void 0,name:e.name}),Be=e=>{if(!e)return"";const s=Date.parse(e);if(Number.isNaN(s))return"";const n=new Date(s),i=c=>String(c).padStart(2,"0");return`${n.getFullYear()}-${i(n.getMonth()+1)}-${i(n.getDate())}`},B=e=>JSON.stringify({clauses:e.clauses.map(s=>[s.field,s.value]),operator:e.matchOperator,move:e.moveMailboxId??null,label:e.labelId??null}),W=(e,s)=>B(e)!==B(s),K=e=>JSON.stringify({scope:e.scope==="until"?"until":"standing",until:e.scope==="until"?e.until??"":""}),X=(e,s)=>K(e)!==K(s),Ke=(e,s)=>{const n={},i=(e.name??"").trim();return i!==(s.name??"").trim()&&(n.name=i),W(e,s)&&(n.matchOperator=e.matchOperator==="all"?"And":"Or",n.literalClauses=e.clauses.map(c=>({field:c.field,value:c.value})),n.actionMailboxId=e.moveMailboxId??I,n.actionLabelId=e.labelId??I),X(e,s)&&(n.scope=e.scope==="until"?"Temporary":"Standing",e.scope==="until"&&(n.expiresAt=Ee(e.until??""))),n};function Qe({accountId:e,filter:s,folders:n,delimiter:i,labels:c,onClose:u}){const g=f.useMemo(()=>qe(s),[s]),[m,h]=f.useState(g),[l,p]=f.useState(),[k,r]=f.useState(!1),N=f.useRef(0),{count:b}=Re(e,Te(m)),x=_e(e,s.filterId),j=Y(e),{createFolderIn:M}=re(e),{createLabel:v}=Me(e),y=async o=>{const a=await v(o);return{id:a.labelId,name:a.name,color:a.color}},C=()=>p({mode:"add",draft:{field:_[0],value:""}}),w=o=>{const a=m.clauses.find(F=>F.id===o);a&&p({mode:"edit",clauseId:o,draft:{field:a.field,value:a.value}})},E=o=>p(a=>a&&{...a,draft:{...a.draft,field:o}}),R=o=>p(a=>a&&{...a,draft:{...a.draft,value:o}}),D=()=>{if(!l)return;const o=l.draft.field,a=Oe(o,l.draft.value);a!==""&&(h(F=>l.mode==="edit"&&l.clauseId?{...F,clauses:F.clauses.map(P=>P.id===l.clauseId?{id:P.id,field:o,value:a}:P)}:(N.current+=1,{...F,clauses:[...F.clauses,{id:`new-${N.current}`,field:o,value:a}]})),p(void 0))},T=o=>h(a=>({...a,clauses:a.clauses.filter(F=>F.id!==o)})),A=o=>h(a=>({...a,matchOperator:o})),O=o=>h(a=>({...a,moveMailboxId:o||void 0})),$=o=>h(a=>({...a,labelId:o||void 0})),d=o=>h(a=>({...a,name:o})),L=o=>h(a=>({...a,scope:o,until:o==="until"?a.until:void 0})),z=o=>h(a=>({...a,until:o})),Z=()=>{const o=W(m,g)||X(m,g),a=Ke(m,g);if(Object.keys(a).length===0){u();return}r(o),x.updateFilter(a)},ee=()=>j.start(De(m));return j.isStarting||j.isRunning||j.isDone?t.jsx(Ye,{progress:j.progress,isDone:j.isDone,onClose:u}):x.isPending?t.jsx(Ge,{}):x.isError?t.jsx(We,{onRetry:x.reset,onClose:u}):x.isSuccess?k?t.jsx(Ve,{preview:oe(b),blocked:b.status!=="ready"||b.stale===!0,onReapply:ee,onClose:u}):t.jsx(Je,{onClose:u}):t.jsx(le,{rule:m,folders:n,delimiter:i,labels:c,preview:b,clauseFields:_,persisted:!0,clauseEdit:l,onStartAddClause:C,onStartEditClause:w,onRemoveClause:T,onChangeDraftField:E,onChangeDraftValue:R,onSubmitClause:D,onCancelClause:()=>p(void 0),onChangeMatchOperator:A,onChangeMove:O,onCreateFolder:M,onChangeLabel:$,onCreateLabel:y,onChangeName:d,onChangeScope:L,onChangeUntil:z,onCommit:Z,onCancel:u})}function Ge(){return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[t.jsx(Q,{className:"size-8 animate-spin text-accent-2"}),t.jsx("p",{className:"text-sm font-medium text-fg",children:"Saving changes…"})]})}function Je({onClose:e}){return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[t.jsx(H,{className:"size-8 text-positive"}),t.jsx("p",{className:"text-sm font-medium text-fg",children:"Filter updated"}),t.jsx(S,{variant:"primary",onClick:e,className:"mt-2",children:"Done"})]})}function Ve({preview:e,blocked:s,onReapply:n,onClose:i}){return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[t.jsx(H,{className:"size-8 text-positive"}),t.jsx("p",{className:"text-sm font-medium text-fg",children:"Rule saved"}),t.jsxs("p",{className:"max-w-xs text-xs text-fg-muted",children:["New mail follows the rule automatically. ",e," — move the mail already in your mailbox too?"]}),t.jsxs("div",{className:"mt-2 flex gap-2",children:[t.jsx(S,{variant:"primary",onClick:n,disabled:s,children:"Move existing mail"}),t.jsx(S,{variant:"ghost",onClick:i,children:"Not now"})]})]})}function Ye({progress:e,isDone:s,onClose:n}){const i=e.state==="Failed";return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[s?i?t.jsx("span",{className:"text-sm font-semibold text-danger",children:"Move failed"}):t.jsx(H,{className:"size-8 text-positive"}):t.jsx(Q,{className:"size-8 animate-spin text-accent-2"}),!s&&t.jsx("p",{className:"text-sm font-medium text-fg",children:"Moving existing mail…"}),s&&!i&&t.jsxs("div",{className:"text-sm text-fg",children:[t.jsx("p",{className:"font-medium",children:"Done"}),t.jsxs("p",{className:"mt-1 text-xs text-fg-muted",children:[e.appliedCount," of ",e.matchedCount," moved",e.failedCount>0?` · ${e.failedCount} failed`:"","."]})]}),s&&i&&t.jsx("p",{className:"max-w-xs text-xs text-fg-muted",children:e.errorMessage||"Something went wrong. Please try again."}),s&&t.jsx(S,{variant:"primary",onClick:n,className:"mt-2",children:"Done"})]})}function We({onRetry:e,onClose:s}){return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[t.jsx("p",{className:"text-sm font-medium text-danger",children:"Couldn't save changes"}),t.jsx("p",{className:"max-w-xs text-xs text-fg-muted",children:"Please try again."}),t.jsxs("div",{className:"mt-2 flex gap-2",children:[t.jsx(S,{variant:"primary",onClick:e,children:"Try again"}),t.jsx(S,{variant:"ghost",onClick:s,children:"Not now"})]})]})}function Xe({accountId:e,filter:s,folders:n,delimiter:i,labels:c,onClose:u}){const g=de(),m=t.jsx(Qe,{accountId:e,filter:s,folders:n,delimiter:i,labels:c,onClose:u});return g?t.jsx(ce,{open:!0,onClose:u,title:"Filter rule",children:m}):t.jsx(Ie,{open:!0,onClose:u,label:"Filter rule",dismissLabel:"Dismiss filter rule",children:m})}const Ze=e=>{switch(e.kind){case"queuing":case"running":return"Running over the inbox…";case"done":return e.matched===0?"Done. Nothing in the inbox matched.":`Done. Filed ${e.applied} of ${e.matched} matching messages in the inbox.`;case"failed":return}};function et({filters:e,mailboxName:s,labelById:n,onEdit:i,onDelete:c,deletingFilterId:u,onToggle:g,togglingFilterId:m,onRunNow:h,runFilterId:l,runStatus:p,now:k=Date.now()}){return e.length===0?t.jsx("p",{className:"py-6 text-sm text-fg-muted",children:"No filters yet. Select a few messages in the inbox and choose Organize to make one."}):t.jsx("ul",{className:"divide-y divide-line rounded-md border border-line",children:e.map(r=>{const N=Le(r,k),b=N==="Expired",x=N==="Disabled",j=x?Ae(r):void 0,M=r.actionMailboxId!==I?s(r.actionMailboxId):void 0,v=r.actionLabelId!==I?n.get(r.actionLabelId):void 0,y=$e(r.expiresAt),C=l===r.filterId?p:void 0,w=C?.kind==="queuing"||C?.kind==="running",E=C?Ze(C):void 0,R=N==="Active"&&(r.actionMailboxId!==I||r.actionLabelId!==I);return t.jsxs("li",{className:"flex items-start gap-3 px-3 py-2.5",children:[t.jsxs("button",{type:"button",onClick:()=>i(r.filterId),"aria-label":`Edit filter ${r.name}`,className:"min-w-0 flex-1 rounded-sm text-left hover:opacity-80",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`truncate text-sm font-medium ${b||x?"text-fg-muted":"text-fg"}`,children:r.name}),t.jsx(ue,{tone:b?"neutral":x?"warning":"positive",dot:!0,children:N})]}),t.jsxs("p",{className:"mt-0.5 text-xs text-fg-subtle",children:[M?`Moves matches to ${M}`:"No move action",r.scope==="Temporary"&&y?b?` · expired ${y}`:` · until ${y}`:r.scope==="Standing"?" · always":""]}),j&&t.jsx("p",{className:"mt-0.5 text-xs text-warning",children:j}),E&&t.jsx("p",{role:"status",className:"mt-0.5 text-xs text-fg-muted",children:E}),v&&t.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:t.jsx(me,{label:{labelId:v.id,name:v.name,color:v.color}})})]}),R&&t.jsx(S,{variant:"ghost",size:"sm",onClick:()=>h(r.filterId),disabled:w,"aria-label":`Run now: filter ${r.name}`,children:w?"Running…":"Run now"}),!b&&t.jsx(S,{variant:"ghost",size:"sm",onClick:()=>g(r.filterId,x),disabled:m===r.filterId,"aria-label":`${x?"Turn on":"Turn off"} filter ${r.name}`,children:x?"Turn on":"Turn off"}),t.jsx(S,{variant:"ghost",size:"sm",icon:t.jsx(pe,{className:"size-4 text-danger"}),onClick:()=>c(r.filterId),disabled:u===r.filterId,"aria-label":`Delete filter ${r.name}`})]},r.filterId)})})}function tt(e){return G(J({title:`Filter toggle: ${e}`,errorMessage:e}))}function st(e){return G(J({title:`Filter run now: ${e}`,errorMessage:e}))}const at=e=>{if(e.failure)return{kind:"failed",error:e.failure.error};if(e.isStarting)return{kind:"queuing"};if(e.isDone)return e.progress.state==="Failed"?{kind:"failed",error:new Error(e.progress.errorMessage||"The run over the inbox failed.")}:{kind:"done",matched:e.progress.matchedCount,applied:e.progress.appliedCount};if(e.isRunning)return{kind:"running"}},nt=t.jsxs("div",{className:"space-y-3",children:[t.jsxs("p",{children:["Filters are the standing rules Organize creates. A"," ",t.jsx("strong",{children:"Standing"})," filter keeps working on new mail; a"," ",t.jsx("strong",{children:"Temporary"})," one stops on its own at the date you picked."]}),t.jsx("p",{children:"An expired filter isn't deleted the instant it lapses — it stays here, marked Expired, so you can see what it did and when it stopped."}),t.jsx("p",{children:"A filter that can't do its job turns itself off and says why, for example when its folder no longer exists. Turn it back on once that is fixed."})]});function it({account:e}){const s=e.accountId,{filters:n,isPending:i,isError:c,error:u,refetch:g}=ze(s),{deleteFilter:m,deletingFilterId:h}=Pe(s),l=Ue(s),p=Y(s),{startForFilter:k}=p,[r,N]=f.useState(),b=f.useCallback(d=>{N(d),k(d)},[k]),x=at(p),[j,M]=f.useState(),{data:v}=V({...xe({path:{accountId:s}}),staleTime:1/0}),y=fe(),C=f.useMemo(()=>ge(e.folderAppointments),[e.folderAppointments]),w=f.useCallback(d=>{const L=v?.items.find(z=>z.mailboxId===d);if(L)return he(L,C.get(d),y)},[v?.items,C,y]),E=f.useMemo(()=>be({mailboxes:v?.items??[],folderAppointments:e.folderAppointments,translator:y}),[v?.items,e.folderAppointments,y]),R=ve(v?.items??[]),{labels:D}=ke(s),T=f.useMemo(()=>D.map(d=>({id:d.labelId,name:d.name,color:d.color})),[D]),A=f.useMemo(()=>new Map(T.map(d=>[d.id,d])),[T]),O=n.find(d=>d.filterId===j),$=n.find(d=>d.filterId===r)?.name;return t.jsxs("section",{className:"space-y-2",children:[t.jsx("h2",{className:"text-sm font-semibold text-fg",children:e.email}),O&&t.jsx(Xe,{accountId:s,filter:O,folders:E,delimiter:R,labels:T,onClose:()=>M(void 0)}),i?t.jsx("div",{className:"h-16 animate-pulse rounded-md border border-line bg-surface","aria-busy":"true","aria-label":`Loading filters for ${e.email}`}):c?t.jsx(U,{variant:"inline",title:`Couldn't load filters for ${e.email}`,error:u,onRetry:()=>{g()}}):t.jsxs(t.Fragment,{children:[l.isError&&t.jsx(q,{title:l.enabling?"Couldn't turn the filter on":"Couldn't turn the filter off",error:l.error,onRetry:l.retry,reportHref:tt}),r&&x?.kind==="failed"&&t.jsx(q,{title:`Couldn't run ${$??"the filter"} over the inbox`,error:x.error,onRetry:p.failure?.kind==="statusUnreadable"?p.refreshStatus:()=>b(r),reportHref:st}),t.jsx(et,{filters:n,mailboxName:w,labelById:A,onEdit:M,onDelete:m,deletingFilterId:h,onToggle:l.toggleFilter,togglingFilterId:l.togglingFilterId,onRunNow:b,runFilterId:r,runStatus:x})]})]})}function ht(){const e=je(),[s,n]=f.useState(!0),{data:i,isPending:c,isError:u,error:g,refetch:m}=V(ye()),h=l=>{const p=Ce[l];p&&e({to:p})};return t.jsx(Fe,{items:Ne,activeId:"filters",title:"Filters",description:"Standing and temporary rules created by Organize, per account.",help:nt,helpOpen:s,onToggleHelp:()=>n(l=>!l),onSelect:h,onBackToMail:()=>{e({to:"/mail"})},children:c?t.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":"Loading accounts"}):u?t.jsx(U,{title:"Couldn't load accounts",error:g,onRetry:()=>{m()}}):i.accounts.length===0?t.jsx("p",{className:"py-12 text-sm text-fg-muted",children:"No accounts configured."}):t.jsx("div",{className:"space-y-8",children:i.accounts.map(l=>t.jsx(it,{account:l},l.accountId))})})}export{it as AccountFilters,ht as component};
@@ -1 +0,0 @@
1
- import{j as o,O as i}from"./index-D7VpR8Bx.js";import{a as m}from"./MailShell-DTW4ysuk.js";import{F as r}from"./FlaggedPane-Cmhk0gcN.js";import{a as p}from"./search-token-index-CXQQu5cA.js";import{u as e}from"./search-mirror-DQmL3P3k.js";import"./useMessageBodyContent-DPlXjxls.js";import"./FullCompose-aUTiTI79.js";import"./ErrorState-DcwvjIQG.js";import"./index-BBaBlwlN.js";import"./useSignature-BMl5h116.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-nmGpghjy.js";import"./sections-ClqQBEFv.js";import"./confirm-dialog-PhUq_oc3.js";import"./MessageBody-xzQttW18.js";import"./kbd-DzZig-MJ.js";import"./search-scope-UI1H6AzA.js";import"./MessageToolbar-D_XXU4rk.js";import"./roving-focus-B9mHbGbD.js";import"./EmptyState-Do3nwfV4.js";import"./popover-menu-BHNjsQiI.js";import"./mail-BiL0g7on.js";import"./avatar-CDZx9RcB.js";import"./useQueries-BDOaD0Tu.js";import"./undo-2-WqFuHEgY.js";import"./download-DS8Ui8jJ.js";import"./useCalendarFreeBusy-CrTlSUQQ.js";import"./useCalendarEvents-BQ8pmFV8.js";import"./useCalendars-B1migLvB.js";import"./map-pin-C0usgYas.js";import"./useLayoutTier-B0zSRsSh.js";import"./calendar-suggestion-B5sKDqe0.js";import"./attendee-row-CPJnqwGs.js";import"./minus-Cs2PKH6V.js";import"./clock-99u2Mdmy.js";import"./calendar-clash-strip-DBNuXhBt.js";import"./bell-off-Bzm-PBgf.js";import"./shield-check-CD-wbm99.js";import"./calendar-report-OI80fkc1.js";import"./menu-liPRY-HF.js";import"./useFilters-zdrGUBZF.js";import"./checkbox-DJpIppZD.js";import"./MailViewChrome-BOp09SXr.js";import"./refresh-cw-CpnxiYht.js";import"./wizard-selection-zWa1qc6-.js";function _(){const t=p();return e({to:"/mail/flagged"}),o.jsx(r,{thread:t,children:o.jsx(m,{phone:o.jsx(r.Phone,{}),list:o.jsx(r.List,{}),reading:o.jsx(i,{}),intelligence:o.jsx(r.Intelligence,{}),hasThread:!!t})})}export{_ as component};
@@ -1 +0,0 @@
1
- import{j as e,f as y,a4 as B,br as Y,r as c,aN as W,X,aV as he,aA as J,a3 as xe,bs as K,bt as fe,az as pe,aC as ge,B as z,bu as be,bv as ve,h as Z,S as ee,o as se,bw as je,bx as ye,aU as Ne,R as ke,by as Ce,bz as _,bA as we,bB as Se,bC as te,bD as Ie,bE as Q,bj as ae,bo as re,bp as Me,ag as G,af as ne,L as H,bF as q,bG as Ee,as as Ae,bH as De,u as Oe,c as ie,d as Te,aQ as Re,aS as Fe,N as Pe,i as V,s as $e,bI as Le,bJ as ze,bK as _e,bL as Be,bM as Ge,bN as He}from"./index-D7VpR8Bx.js";import{E as oe}from"./ErrorState-DcwvjIQG.js";import{P as Ke}from"./pencil-CoAnhAKI.js";import{S as Qe}from"./settings-screen-BjSyVU2l.js";import{f as qe}from"./folder-failure-CqkVSsrb.js";import"./avatar-CDZx9RcB.js";import"./chevron-left-CF03ieoO.js";import"./menu-liPRY-HF.js";import"./circle-help-DqnCeQ17.js";const Ve=({label:s,onRename:t,onDelete:a,deleteBlockedReason:l,renameLabel:m=u=>`Rename ${u}`,deleteLabel:r=u=>`Delete ${u}`})=>{const u=l?`${r(s)} — ${l}`:r(s);return e.jsxs("span",{className:"flex shrink-0 items-center gap-0.5 pr-2",children:[e.jsx(y,{variant:"ghost",size:"sm",icon:e.jsx(Ke,{className:"size-3.5"}),"aria-label":m(s),onClick:t}),e.jsx("span",{title:l,children:e.jsx(y,{variant:"ghost",size:"sm",icon:e.jsx(B,{className:"size-3.5"}),"aria-label":u,disabled:l!==void 0,onClick:a})})]})},Ue=({folders:s,onRename:t,onDelete:a,onCreateFolder:l,delimiter:m,labels:r})=>{const u=new Map(s.map(o=>[o.id,o]));return e.jsx(Y,{folders:s,onCreateFolder:l,delimiter:m,labels:{treeAriaLabel:"Your folders",optionLabel:o=>o.label,...r},rowFailure:o=>u.get(o.id)?.failure,rowActions:o=>{const i=u.get(o.id);return i?e.jsx(Ve,{label:i.label,deleteBlockedReason:i.deleteBlockedReason,renameLabel:r?.rename,deleteLabel:r?.remove,onRename:()=>t(i),onDelete:()=>a(i)}):null}})},Ye=({open:s,folderLabel:t,defaultLabel:a,name:l,onNameChange:m,onSubmit:r,onClose:u,pending:o=!1,error:i})=>{const d=c.useId(),p=`Rename ${t}`;return s?e.jsxs(W,{open:s,onClose:u,title:p,children:[e.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[e.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:p}),e.jsx(y,{variant:"ghost",size:"sm",icon:e.jsx(X,{className:"size-3.5"}),onClick:u,"aria-label":"Cancel"})]}),e.jsxs("div",{className:"space-y-3 px-5 py-4",children:[e.jsxs("div",{children:[e.jsx(he,{htmlFor:d,children:"Folder name"}),e.jsx(J,{id:d,value:l,placeholder:a,onChange:g=>m(g.target.value),onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),r())}})]}),e.jsxs("p",{className:"text-xs text-fg-muted",children:["Shown everywhere in Remit. Leave it blank to use"," ",e.jsx("span",{className:"font-medium text-fg",children:a}),"."]}),i&&e.jsx("p",{className:"text-xs text-danger",role:"alert",children:i})]}),e.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[e.jsx(y,{variant:"secondary",size:"sm",onClick:u,children:"Cancel"}),e.jsx(y,{variant:"primary",size:"sm",onClick:r,disabled:o,children:o?"Saving…":"Save name"})]})]}):null},We=["inbox","drafts","sent","archive","junk","trash"],U="",Xe={mailboxId:null,source:"None"};function Je(s){const t=s.messageCount===1?"msg":"msgs";return`${K(s.providerPath,s.hierarchyDelimiter)} · ${s.messageCount} ${t}`}const le=s=>`${s} ${s===1?"message":"messages"}`,Ze=(s,t)=>s==="Appointed"?"Chosen by you":s==="Flagged"?`The mail server marks it as ${t}`:s==="Reserved"?"The account's own INBOX":"Matched by name, not confirmed";function es({role:s,folders:t,appointment:a,displayName:l,onAppoint:m,onRename:r}){const[u,o]=c.useState(l),i=c.useRef(null),d=c.useRef(!1),p=c.useId(),{mailboxId:g,source:v,staleFolderPath:j}=a,h=t.find(N=>N.mailboxId===g)??null,f=be(s),O=h!=null&&u.trim()!==l.trim();c.useEffect(()=>{!d.current||v==="Proposed"||(d.current=!1,i.current?.focus())},[v]);const M=(()=>{if(v==="None"){const N=s==="trash"?" Deleting mail needs one.":"";return e.jsx("span",{id:p,className:"pl-[7.5rem] text-xs text-fg-muted",children:`Not set — pick the folder this account uses for ${f}.${N}`})}return v==="Stale"||!h?null:e.jsx("span",{id:p,className:"truncate pl-[7.5rem] text-2xs text-fg-subtle",title:h.providerPath,children:`${Ze(v,f)} · ${h.providerPath} · ${le(h.messageCount)}`})})(),w=s==="trash"?" Deleting mail is stopped until you pick another one.":h?` reader is using ${K(h.providerPath,h.hierarchyDelimiter)} instead.`:"",D=`The folder you chose for ${f}${j?` — ${j} —`:""} is gone from the mail server.${w}`;return e.jsxs("div",{className:"flex flex-col gap-1 border-b border-line px-row-inset py-2.5 last:border-b-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"flex w-28 shrink-0 items-center gap-2 text-sm font-medium text-fg",children:[fe(s),f]}),e.jsxs(pe,{ref:i,className:"w-56 shrink-0",value:h?.mailboxId??U,"aria-label":`Folder for ${f}`,"aria-describedby":M||v==="Stale"?p:void 0,onChange:N=>m(s,N.target.value),children:[!h&&e.jsx("option",{value:U,disabled:!0,children:"Choose a folder"}),t.map(N=>e.jsx("option",{value:N.mailboxId,children:Je(N)},N.mailboxId))]}),v==="Proposed"&&h&&e.jsx(y,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>{d.current=!0,m(s,h.mailboxId)},children:`Set as ${f}`}),h&&e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"flex-1",value:u,placeholder:f,"aria-label":`Display name for ${f}`,onChange:N=>o(N.target.value)}),O&&e.jsx(y,{variant:"ghost",size:"sm",className:"shrink-0",icon:e.jsx(ge,{className:"size-4"}),"aria-label":"Save display name",onClick:()=>r(h.mailboxId,u)})]})]}),M,v==="Stale"&&e.jsx(z,{tone:"warning",variant:"soft",className:"ml-[7.5rem]",children:e.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{id:p,className:"flex-1",children:D}),e.jsx(y,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>i.current?.focus(),children:"Pick a folder"})]})})]})}function ss(){return e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{children:"Each canonical role — Inbox, Drafts, Sent, Archive, Spam, Trash — points at one of your account's real folders. Pick the one that actually holds the mail; the message counts tell real folders from empty look-alikes."}),e.jsx("p",{children:`Appointing a folder to a role here doesn't touch any other role, and doesn't move or rename anything on the server — it just tells Remit which folder to treat as e.g. "Drafts" everywhere (sidebar, unread badges, the compose flow).`}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Your folders"})," is the account's real hierarchy. Open a folder to see what's inside it, make a new one where you're looking, and rename or delete any of them from its row."]})]})}function ts({accountEmail:s,folders:t,appointments:a,displayNames:l={},onAppoint:m,onRename:r}){const u=new Set(Object.values(a).map(i=>i.mailboxId).filter(i=>i!=null)),o=t.filter(i=>!u.has(i.mailboxId));return e.jsxs("section",{className:"space-y-3",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsxs("h2",{className:"text-sm font-semibold text-fg",children:["Folder roles — ",s]}),e.jsx("p",{className:"text-xs text-fg-muted",children:"Each row says where its answer came from — your choice, the mail server's own flag, or a name reader matched."})]}),e.jsx("div",{className:"rounded-sm border border-line bg-surface",children:We.map(i=>{const d=a[i]??Xe;return e.jsx(es,{role:i,folders:t,appointment:d,displayName:d.mailboxId?l[d.mailboxId]??"":"",onAppoint:m,onRename:r},i)})}),o.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h3",{className:"text-xs font-medium text-fg-muted",children:"Other folders"}),e.jsx("ul",{className:"rounded-sm border border-line bg-surface",children:o.map(i=>e.jsxs("li",{className:"flex items-center gap-2 border-b border-line px-row-inset py-2 text-sm text-fg last:border-b-0",children:[e.jsx(xe,{className:"size-4 shrink-0 text-fg-subtle"}),e.jsx("span",{className:"truncate",children:K(i.providerPath,i.hierarchyDelimiter)}),e.jsx("span",{className:"ml-auto shrink-0 text-2xs text-fg-subtle",children:le(i.messageCount)})]},i.mailboxId))})]})]})}const as=12e4,rs=2e3,ns="This folder is no longer in the account's folder list, so nothing was deleted.",ce=(s,t)=>{const a=s.find(l=>l.mailboxId===t);if(!a)throw new Error(ns);return a},is=(s,t)=>ce(s,t).lastSyncedAt??0;async function os({readMailboxes:s,mailboxId:t,since:a,signal:l,segmentMs:m=as,pollIntervalMs:r=rs,delay:u=ve,now:o=Date.now}){const i=o()+m;for(;;){l?.throwIfAborted();const d=ce(await s(),t);if((d.lastSyncedAt??0)>a)return{status:"fresh",messageCount:d.messagesTotal};if(o()>=i)return{status:"pending"};await u(r,l)}}const de=50,ls=s=>s instanceof Error?s.message:"Something went wrong.",$=s=>s.then(t=>({ok:!0,value:t}),t=>({ok:!1,error:ls(t)})),cs=async(s,t,a,l)=>{const m=[];let r;for(let u=0;u<de;u+=1){if(l.aborted)return m;const{data:o}=await te({path:{mailboxId:s},query:{order:"desc",continuationToken:r},throwOnError:!0});for(const i of o.items)if(!t.has(i.messageId)&&!m.includes(i.messageId)&&(m.push(i.messageId),m.length>=a))return m;if(!o.continuationToken)break;r=o.continuationToken}return m},ds=async(s,t)=>{let a=0,l;for(let m=0;m<de;m+=1){if(t.aborted)return a;const{data:r}=await te({path:{mailboxId:s},query:{order:"desc",continuationToken:l},throwOnError:!0});if(a+=r.items.length,!r.continuationToken)break;l=r.continuationToken}return a};function ms({accountId:s,mailboxId:t,onDeleted:a}){const l=Z(),[m,r]=c.useState("idle"),[u,o]=c.useState(null),[i,d]=c.useState(),[p,g]=c.useState(),v=c.useRef(null),j=c.useRef(void 0),h=c.useCallback(()=>{l.invalidateQueries({queryKey:ee({path:{accountId:s}})}),l.invalidateQueries({queryKey:se()})},[l,s]),f=c.useCallback(async()=>{r("deleting");const k=await $(je({path:{accountId:s,mailboxId:t},throwOnError:!0}));if(!k.ok){d(k.error),r("error");return}h(),r("done"),a()},[s,t,h,a]),O=c.useCallback(()=>ye({path:{accountId:s},throwOnError:!0}).then(({data:k})=>k.items.find(S=>S.mailboxId===t)?.messageCount??0),[s,t]),M=c.useCallback(()=>l.fetchQuery({...Ne({path:{accountId:s}}),staleTime:0}).then(k=>k.mailboxes??[]),[l,s]),w=c.useCallback(async()=>{const k=new AbortController;v.current=k;const{signal:S}=k;r("checking"),d(void 0);const I=j.current!==void 0,C=await $((async()=>(I||(S.throwIfAborted(),j.current=is(await M(),t),S.throwIfAborted(),g(Date.now()),await ke({path:{accountId:s},throwOnError:!0})),os({readMailboxes:M,mailboxId:t,since:j.current??0,signal:S})))());return S.aborted?(r("idle"),j.current=void 0,{status:"failed"}):C.ok?C.value.status==="pending"?(r("check-stalled"),{status:"pending"}):(j.current=void 0,C.value.messageCount>0?(r("idle"),h(),{status:"blocked",messageCount:C.value.messageCount}):(await f(),{status:"deleted"})):(j.current=void 0,d(C.error),r("error"),{status:"failed"})},[s,t,M,f,h]),D=c.useCallback(()=>{v.current?.abort()},[]),N=c.useCallback(async k=>{const S=new AbortController;v.current=S;const{signal:I}=S;r("moving"),d(void 0);const C=await $(O());if(I.aborted)return;if(!C.ok){d(C.error),r("error");return}let x=Ce(C.value);o(x);const E=new Set;for(;;){if(I.aborted)return;const n=await $(cs(t,E,Ie,I));if(I.aborted)return;if(!n.ok){x=_(x,n.error),o(x),d(n.error),r("error");return}const b=n.value;if(b.length===0)break;const T=await $(we({body:{messageIds:b,destinationMailboxId:k},throwOnError:!0}));if(I.aborted)return;if(!T.ok){x=_(x,T.error),o(x),d(T.error),r("error");return}for(const P of b)E.add(P);x=Se(x,b.length),o(x)}const A=await $(ds(t,I));if(!I.aborted){if(!A.ok){x=_(x,A.error),o(x),d(A.error),r("error");return}if(A.value>0){const n=`${A.value} ${A.value===1?"email is":"emails are"} still syncing. Re-open delete to finish removing this folder.`;x=_(x,n),o(x),d(n),r("error"),h();return}await f()}},[t,O,f,h]),R=c.useCallback(()=>{v.current?.abort(),v.current=null,j.current=void 0,r("idle"),o(null),d(void 0),g(void 0)},[]);return{phase:m,progress:u,errorMessage:i,checkStartedAt:p,deleteMailbox:f,deleteIfEmpty:w,moveThenDelete:N,cancel:D,reset:R}}const L=s=>`${s} ${s===1?"email":"emails"}`;function us({open:s,accountId:t,folder:a,mailboxes:l,appointments:m,onClose:r}){const[u,o]=c.useState(()=>Q(a.messageCount)),[i,d]=c.useState(),[p,g]=c.useState(),{createFolderIn:v}=ae(t),j=re(),{phase:h,progress:f,errorMessage:O,checkStartedAt:M,deleteMailbox:w,deleteIfEmpty:D,moveThenDelete:N,cancel:R,reset:k}=ms({accountId:t,mailboxId:a.mailboxId,onDeleted:r}),[S,I]=c.useState("0:00"),C=h==="checking"||h==="check-stalled";c.useEffect(()=>{if(!C||M===void 0)return;const F=()=>I(De(Date.now()-M));F();const ue=setInterval(F,1e3);return()=>clearInterval(ue)},[C,M]),c.useEffect(()=>{s&&(o(Q(a.messageCount)),d(void 0),k())},[s,k]),c.useEffect(()=>{s&&g(void 0)},[s]),c.useEffect(()=>R,[R]);const x=c.useCallback(()=>{R(),r()},[R,r]),E=c.useCallback(async()=>{const F=await D();F.status==="blocked"&&(d(F.messageCount),o("choose-fate"))},[D]),A=c.useMemo(()=>Me({mailboxes:l,folderAppointments:m,excludeMailboxId:a.mailboxId,translator:j}),[l,m,a.mailboxId,j]),n=A.find(F=>F.id===p),b=c.useMemo(()=>G(a,ne(m).get(a.mailboxId),j),[a,m,j]);if(!s)return null;const T=`Delete ${b}`,P=i??a.messageCount,me=h==="moving"?e.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[e.jsx(H,{className:"size-8 animate-spin text-accent-2"}),e.jsx("p",{className:"text-sm font-medium text-fg",children:"Moving emails…"}),e.jsx("p",{className:"text-xs text-fg-muted",role:"status","aria-live":"polite",children:f?q(f):"Moved 0 of 0"})]}):h==="checking"?e.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[e.jsx(H,{className:"size-8 animate-spin text-accent-2"}),e.jsx("p",{className:"text-sm font-medium text-fg",children:"Checking the folder on the mail server…"}),e.jsx("p",{className:"text-xs text-fg-muted",role:"status","aria-live":"polite",children:`Waiting ${S}. Nothing is deleted until the server answers.`})]}):h==="check-stalled"?e.jsxs("div",{className:"space-y-4 px-5 py-4",children:[e.jsx(z,{tone:"warning",variant:"soft",children:`The mail server hasn't reported back on this folder yet — ${S} so far. Nothing has been deleted.`}),e.jsx("p",{className:"text-xs text-fg-muted",children:"A sync covers the whole account, so a busy mailbox can take a while to come round to this folder."}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(y,{variant:"secondary",size:"sm",onClick:x,children:"Cancel"}),e.jsx(y,{size:"sm",onClick:()=>E(),children:"Keep waiting"})]})]}):h==="deleting"||h==="done"?e.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[e.jsx(H,{className:"size-8 animate-spin text-accent-2"}),e.jsx("p",{className:"text-sm font-medium text-fg",children:"Deleting folder…"})]}):h==="error"?e.jsxs("div",{className:"space-y-4 px-5 py-4",children:[e.jsx(z,{tone:"danger",variant:"soft",children:O??"Something went wrong. Please try again."}),f&&e.jsxs("p",{className:"text-xs text-fg-muted",children:[q(f),". Already-moved emails stay moved — re-open delete to continue with the rest."]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(y,{variant:"secondary",size:"sm",onClick:x,children:"Close"})})]}):u==="confirm-empty"?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-3 px-5 py-4 text-sm text-fg-muted",children:e.jsxs("p",{children:["Delete ",e.jsx("strong",{className:"text-fg",children:b}),"? This folder is empty and will be removed from the server."]})}),e.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[e.jsx(y,{variant:"secondary",size:"sm",onClick:x,children:"Cancel"}),e.jsx(y,{variant:"danger",size:"sm",icon:e.jsx(B,{className:"size-3.5"}),onClick:()=>E(),children:"Delete folder"})]})]}):u==="choose-fate"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-3 px-5 py-4 text-sm text-fg-muted",children:[i!==void 0&&e.jsx(z,{tone:"warning",variant:"soft",children:`This folder is not empty: the mail server reports ${L(i)} in it. Nothing was deleted.`}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:b})," holds"," ",L(P),". What should happen to them?"]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("button",{type:"button",onClick:()=>o("confirm-delete-all"),className:"flex w-full items-center gap-3 rounded-sm border border-line px-3 py-2.5 text-left hover:bg-surface-raised",children:[e.jsx(B,{className:"size-4 shrink-0 text-danger"}),e.jsxs("span",{className:"flex-1",children:[e.jsx("span",{className:"block text-sm font-medium text-fg",children:"Delete them with the folder"}),e.jsx("span",{className:"block text-xs text-fg-muted",children:"The emails are removed from the server and can't be recovered."})]})]}),e.jsxs("button",{type:"button",onClick:()=>o("pick-destination"),className:"flex w-full items-center gap-3 rounded-sm border border-line px-3 py-2.5 text-left hover:bg-surface-raised",children:[e.jsx(Ee,{className:"size-4 shrink-0 text-accent-2"}),e.jsxs("span",{className:"flex-1",children:[e.jsx("span",{className:"block text-sm font-medium text-fg",children:"Move them to another folder"}),e.jsx("span",{className:"block text-xs text-fg-muted",children:"Keep the emails, then delete the emptied folder."})]})]})]})]}),e.jsx("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:e.jsx(y,{variant:"secondary",size:"sm",onClick:x,children:"Cancel"})})]}):u==="confirm-delete-all"?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-3 px-5 py-4 text-sm text-fg-muted",children:e.jsxs("p",{children:["Delete ",e.jsx("strong",{className:"text-fg",children:b})," and its"," ",L(P),"? The messages are removed from the server with the folder and can't be recovered."]})}),e.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[e.jsx(y,{variant:"secondary",size:"sm",onClick:()=>o("choose-fate"),children:"Back"}),e.jsx(y,{variant:"danger",size:"sm",icon:e.jsx(B,{className:"size-3.5"}),onClick:()=>w(),children:"Delete folder and emails"})]})]}):e.jsxs("div",{className:"flex h-[26rem] flex-col",children:[e.jsxs("p",{className:"px-5 pt-4 text-sm text-fg-muted",children:["Move the ",L(P)," in"," ",e.jsx("strong",{className:"text-fg",children:b})," to:"]}),e.jsx("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:e.jsx(Y,{folders:A,selectedId:p,delimiter:l[0]?.hierarchyDelimiter??"/",onSelect:g,onCreateFolder:v,onCancel:()=>{g(void 0),o("choose-fate")},labels:{filterPlaceholder:"Move emails to…"}})}),n&&e.jsx("footer",{className:"shrink-0 border-t border-line p-2",children:e.jsx(y,{variant:"danger",onClick:()=>N(n.id),className:"h-11 w-full font-semibold",children:e.jsx("span",{className:"truncate",children:`Move ${L(P)} to ${n.label}`})})})]});return e.jsxs(W,{open:s,onClose:x,title:T,children:[e.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[e.jsx(Ae,{className:"size-4 shrink-0 text-danger"}),e.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:T}),e.jsx(y,{variant:"ghost",size:"sm",icon:e.jsx(X,{className:"size-3.5"}),onClick:x,"aria-label":"Cancel"})]}),me]})}function hs({account:s}){const t=Z(),a=s.accountId,l=re(),{data:m,isPending:r,isError:u,error:o,refetch:i}=ie(Pe({path:{accountId:a}})),{createFolderIn:d}=ae(a),p=V({...Le(),meta:$e(409),onSuccess:()=>{t.invalidateQueries({queryKey:se()})}}),g=V({...ze(),onSuccess:()=>{t.invalidateQueries({queryKey:ee({path:{accountId:a}})})}}),[v,j]=c.useState(),[h,f]=c.useState(),[O,M]=c.useState(""),w=c.useMemo(()=>m?.items??[],[m]),D=c.useMemo(()=>ne(s.folderAppointments),[s.folderAppointments]),N=c.useMemo(()=>w.map(n=>({id:n.mailboxId,label:G(n,D.get(n.mailboxId),l),path:n.fullPath,deleteBlockedReason:_e(n,w,s.folderAppointments).message,failure:qe(n)})),[w,D,l,s.folderAppointments]),R=(n,b)=>{p.mutate({path:{accountId:a,role:He[n]},body:{mailboxId:b}})},k=(n,b)=>{const T=b.trim();g.mutate({path:{accountId:a,mailboxId:n},body:{displayNameOverride:T===""?null:T}})};if(r)return e.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":`Loading folders for ${s.email}`});if(u)return e.jsx(oe,{variant:"inline",title:`Couldn't load folders for ${s.email}`,error:o,onRetry:()=>{i()}});const S=w.map(n=>({mailboxId:n.mailboxId,providerPath:n.fullPath,hierarchyDelimiter:n.hierarchyDelimiter,messageCount:n.messageCount})),I={};for(const n of s.folderAppointments){const b=Be[n.role];b&&(I[b]={mailboxId:n.mailboxId??null,source:n.source,staleFolderPath:n.staleAppointmentPath})}const C={};for(const n of w)n.displayNameOverride&&(C[n.mailboxId]=n.displayNameOverride);const x=n=>w.find(b=>b.mailboxId===n),E=x(h),A=x(v);return e.jsxs("div",{className:"space-y-4",children:[(p.isError||g.isError)&&e.jsx(z,{tone:"danger",variant:"soft",children:Ge(p.error)?"That folder is still being created on the mail server — wait for it to finish, then try again.":"Couldn't save that change. Please try again."}),e.jsx(ts,{accountEmail:s.email,folders:S,appointments:I,displayNames:C,onAppoint:R,onRename:k}),e.jsxs("section",{className:"space-y-1.5",children:[e.jsxs("h3",{className:"text-sm font-semibold text-fg",children:["Your folders — ",s.email]}),e.jsx("div",{className:"flex h-[28rem] flex-col overflow-hidden rounded-sm border border-line bg-surface",children:e.jsx(Ue,{folders:N,delimiter:w[0]?.hierarchyDelimiter??"/",onCreateFolder:d,onRename:n=>{f(n.id),M(x(n.id)?.displayNameOverride?.trim()??"")},onDelete:n=>j(n.id),labels:{treeAriaLabel:`All folders for ${s.email}`}})})]}),E&&e.jsx(Ye,{open:!0,folderLabel:G(E,D.get(E.mailboxId),l),defaultLabel:G({fullPath:E.fullPath,hierarchyDelimiter:E.hierarchyDelimiter},D.get(E.mailboxId),l),name:O,onNameChange:M,pending:g.isPending,error:g.isError?"Couldn't save that name. Please try again.":void 0,onSubmit:()=>{const n=O.trim();g.mutate({path:{accountId:a,mailboxId:E.mailboxId},body:{displayNameOverride:n===""?null:n}},{onSuccess:()=>f(void 0)})},onClose:()=>f(void 0)}),A&&e.jsx(us,{open:!0,accountId:a,folder:A,mailboxes:w,appointments:s.folderAppointments,onClose:()=>j(void 0)})]})}function ks(){const s=Oe(),[t,a]=c.useState(!0),{data:l,isPending:m,isError:r,error:u,refetch:o}=ie(Te()),i=d=>{const p=Fe[d];p&&s({to:p})};return e.jsx(Qe,{items:Re,activeId:"folders",title:"Folder roles",description:"Appoint which real folder fills each canonical role, per account.",help:e.jsx(ss,{}),helpOpen:t,onToggleHelp:()=>a(d=>!d),onSelect:i,onBackToMail:()=>{s({to:"/mail"})},children:m?e.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":"Loading accounts"}):r?e.jsx(oe,{title:"Couldn't load accounts",error:u,onRetry:()=>{o()}}):l.accounts.length===0?e.jsx("p",{className:"py-12 text-sm text-fg-muted",children:"No accounts configured."}):e.jsx("div",{className:"space-y-8",children:l.accounts.map(d=>e.jsx(hs,{account:d},d.accountId))})})}export{ks as component};
@@ -1 +0,0 @@
1
- import{e as W,j as e,B as x,f,L as _,X as Ee,r,I as Oe,g as O,h as pe,c as ze,d as Be,i as q,s as de,k as $e,l as Pe,m as De,n as Le,o as J,q as qe}from"./index-D7VpR8Bx.js";import{W as k,C as fe,a as le,u as He,b as We,c as _e,d as Ke,S as Qe,R as Ue}from"./credential-steps-BES-y0iD.js";import{c as ge,f as Ve,v as xe,r as Ge,a as Je,b as ue,w as he,p as Xe,W as Ye,s as Ze,g as et}from"./config-import-CAmEPP05.js";import{F as tt}from"./file-json-C0JfxlBX.js";import{c as st}from"./onboarding-completion-CYRjdQQn.js";import"./card-WnranLyn.js";const nt=W("FolderClock",[["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}],["path",{d:"M7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2",key:"1urifu"}],["path",{d:"M16 14v2l1 1",key:"xth2jh"}]]);const it=W("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);const at=W("Merge",[["path",{d:"m8 6 4-4 4 4",key:"ybng9g"}],["path",{d:"M12 2v10.3a4 4 0 0 1-1.172 2.872L4 22",key:"1hyw0i"}],["path",{d:"m20 22-5-5",key:"1m27yz"}]]);const rt=W("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]),y=["File","Review","Credentials","Folders"];function Y({children:t}){return e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:t})}function ot({state:t="idle",file:n,ready:i=!1,failure:s,onChoose:d,onDragStateChange:l,onNext:m}){const w=r.useId(),u=r.useRef(null),p=t==="dragging",j=t==="reading",N=t==="checking",R=j||N,S=h=>{h.preventDefault(),l?.(!1);const b=h.dataTransfer.files.item(0);b&&d?.(b)};return e.jsx(k,{steps:y,activeStep:0,title:"Import a config file",subtitle:"Accounts, folder roles, rules, senders and appearance — everything except passwords.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"Nothing is written until you have seen what will change."}),e.jsx(f,{variant:"primary",disabled:R||!i,icon:R?e.jsx(_,{className:"size-3.5 animate-spin"}):void 0,onClick:m,children:j?"Reading…":N?"Checking…":"Check the file"})]}),children:e.jsxs("div",{className:"space-y-4",children:[s&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{tone:"danger",children:s.title}),e.jsx("p",{className:"text-sm text-fg",children:s.explanation}),e.jsx("p",{className:"text-sm text-fg-muted",children:s.fix}),e.jsx(Y,{children:s.raw})]}),e.jsxs("div",{onDragOver:h=>{h.preventDefault(),l?.(!0)},onDragLeave:()=>l?.(!1),onDrop:S,className:p?"flex flex-col items-center gap-3 rounded-sm border-2 border-dashed border-accent bg-accent-soft px-4 py-9 text-center":"flex flex-col items-center gap-3 rounded-sm border-2 border-dashed border-line px-4 py-9 text-center",children:[e.jsx("span",{className:"flex size-11 items-center justify-center rounded-md bg-surface-sunken",children:e.jsx(rt,{className:"size-5 text-fg-muted"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-fg",children:p?"Drop it here":"Drop a config file here, or choose one"}),e.jsx("p",{className:"mt-1 text-xs text-fg-subtle",children:"A .json file written by Reader — up to 2 MB."})]}),e.jsx("input",{ref:u,id:w,type:"file",accept:"application/json,.json",className:"sr-only",onChange:h=>{const b=h.target.files?.item(0);b&&d?.(b)}}),e.jsx(f,{variant:"secondary",size:"sm",onClick:()=>u.current?.click(),children:"Choose file"})]}),n&&e.jsxs("div",{className:"flex items-start gap-3 rounded-sm border border-line px-3 py-2.5",children:[e.jsx(tt,{className:"mt-0.5 size-4 shrink-0 text-fg-muted"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm text-fg",children:n.name}),e.jsxs("p",{className:"mt-0.5 text-xs text-fg-subtle",children:[Ve(n.size)," ·"," ",j?"reading it from disk":N?"checking it against this instance":i?"ready to check — nothing has been sent yet":"not a configuration this instance can read"]})]})]}),e.jsxs("p",{className:"text-2xs text-fg-subtle",children:["Export one from Settings → Advanced on the instance you are moving from, or run"," ",e.jsx("code",{className:"rounded bg-surface-sunken px-1 py-0.5",children:"remit config save"})," ","on its host."]})]})})}function ct({sections:t}){const n=ge(t.flatMap(i=>i.entries.map(s=>({section:i.id,key:s.label,verdict:s.verdict}))));return e.jsx("div",{className:"flex flex-wrap gap-1.5",children:["created","updated","unchanged","skipped","rejected"].filter(i=>n[i]>0).map(i=>e.jsxs(O,{tone:xe[i],dot:!0,children:[n[i]," ",i]},i))})}function dt({section:t}){return e.jsxs("section",{children:[e.jsx("h2",{className:"text-sm font-semibold text-fg",children:t.title}),e.jsx("ul",{className:"mt-1.5 divide-y divide-line",children:t.entries.map(n=>e.jsxs("li",{className:"flex items-start gap-3 py-2",children:[e.jsx(O,{tone:xe[n.verdict],className:"mt-0.5 shrink-0",children:n.verdict}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm text-fg",children:n.label}),n.reason&&e.jsx("p",{className:n.verdict==="rejected"?"mt-1 text-xs text-danger":"mt-1 text-xs text-warning",children:n.reason})]})]},n.id))})]})}function lt({sections:t,fileName:n,warnings:i=[],applying:s=!1,onBack:d,onNext:l}){const m=ge(t.flatMap(p=>p.entries.map(j=>({section:p.id,key:j.label,verdict:j.verdict})))),w=m.created+m.updated,u=m.skipped+m.rejected;return e.jsx(k,{steps:y,activeStep:1,title:"What this file will change",subtitle:`${n} · nothing has been written yet.`,footer:e.jsxs(e.Fragment,{children:[e.jsx(f,{variant:"ghost",onClick:d,children:"Choose another file"}),e.jsx(f,{variant:"primary",disabled:s,icon:s?e.jsx(_,{className:"size-3.5 animate-spin"}):void 0,onClick:l,children:s?"Importing…":`Import ${w} changes`})]}),children:e.jsxs("div",{className:"space-y-5",children:[e.jsx(ct,{sections:t}),u>0&&e.jsxs(x,{tone:"warning",children:[u," entries will not be imported. Each says why below — read them before you continue, because nothing here retries on its own."]}),i.length>0&&e.jsx("ul",{className:"space-y-1 text-xs text-warning",children:i.map(p=>e.jsx("li",{children:p},p))}),t.map(p=>e.jsx(dt,{section:p},p.id))]})})}function ut({choice:t,held:n,onChoose:i,onBack:s,onNext:d}){return e.jsx(k,{steps:y,activeStep:1,title:"This instance already has configuration",subtitle:n,footer:e.jsxs(e.Fragment,{children:[e.jsx(f,{variant:"ghost",onClick:s,children:"Choose another file"}),e.jsx(f,{variant:"primary",disabled:!t,onClick:d,children:t==="merge"?"Continue with merge":"Continue"})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(x,{tone:"warning",children:"An import into a configured instance can only add and update — it never deletes what is here. Pick how the two should meet."}),e.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[e.jsx(le,{name:"Stop, keep this instance",description:"Nothing is written. Use this if you meant to import into a fresh instance.",icon:e.jsx(Ee,{className:"size-5"}),selected:t==="abort",onSelect:()=>i?.("abort")}),e.jsx(le,{name:"Merge the file in",description:"Adds what is missing and updates what differs. Existing accounts keep their server settings.",icon:e.jsx(at,{className:"size-5"}),selected:t==="merge",onSelect:()=>i?.("merge")})]}),t==="merge"&&e.jsx("p",{className:"text-xs text-fg-muted",children:"The next screen lists every add and update before anything is written."})]})})}function ht(t){return t==="entered"?e.jsx(O,{tone:"positive",children:"ready"}):t==="failed"?e.jsx(O,{tone:"danger",children:"sign-in failed"}):e.jsx(O,{tone:"danger",children:"credentials needed"})}function mt({accounts:t,busyAccountId:n,onOpen:i}){return e.jsx("ul",{className:"divide-y divide-line",children:t.map(s=>e.jsxs("li",{className:s.state==="entered"?"flex flex-wrap items-start justify-between gap-3 py-3":"flex flex-wrap items-start justify-between gap-3 border-l-2 border-danger bg-danger-soft py-3 pl-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-fg",children:s.address}),ht(s.state)]}),e.jsxs("p",{className:"mt-0.5 text-xs text-fg-subtle",children:[s.displayName," ·"," ",s.connector==="microsoft"?"Microsoft 365":"IMAP / SMTP"," ","· ",s.server]}),s.state!=="entered"&&e.jsx("p",{className:"mt-1 text-xs text-danger",children:s.failure??(s.connector==="microsoft"?"Config files never carry OAuth tokens. Reconnect with Microsoft to start syncing this account.":"Config files never carry passwords. Enter this mailbox's password to start syncing.")})]}),s.state!=="entered"&&e.jsx(f,{variant:"primary",size:"sm",disabled:n===s.accountId,icon:n===s.accountId?e.jsx(_,{className:"size-3.5 animate-spin"}):s.connector==="microsoft"?e.jsx(Oe,{className:"size-3.5"}):e.jsx(it,{className:"size-3.5"}),onClick:()=>i?.(s),children:n===s.accountId?"Redirecting…":s.connector==="microsoft"?"Reconnect":s.state==="failed"?"Try again":"Enter password"})]},s.accountId))})}function pt({accounts:t,busyAccountId:n,error:i,onOpen:s,onNext:d}){const l=t.filter(m=>m.state!=="entered").length;return e.jsx(k,{steps:y,activeStep:2,title:"These accounts need credentials",subtitle:"The config file carries servers and settings. Passwords and Microsoft sign-ins it deliberately leaves out.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:l>0?"Settings › Accounts keeps asking until every account is signed in.":"Every account can sync."}),e.jsx(f,{variant:"primary",onClick:d,children:l>0?"Finish later":"All accounts connected"})]}),children:e.jsxs("div",{className:"space-y-4",children:[i&&e.jsx(x,{tone:"danger",children:i}),l>0&&e.jsxs(x,{tone:"danger",children:[l," of ",t.length," accounts cannot sync yet. They stay listed in Settings, marked like this, until you sign in — no mail arrives for them in the meantime."]}),e.jsx(mt,{accounts:t,busyAccountId:n,onOpen:s})]})})}function ft({account:t,position:n,total:i,error:s,busy:d=!1,onBack:l,onNext:m}){return e.jsx(k,{steps:y,activeStep:2,title:`Reconnect ${t.address}`,subtitle:`Account ${n} of ${i} · Microsoft 365`,footer:e.jsxs(e.Fragment,{children:[e.jsx(f,{variant:"ghost",onClick:l,children:"Back"}),e.jsx(f,{variant:"primary",disabled:d,icon:d?e.jsx(_,{className:"size-3.5 animate-spin"}):void 0,onClick:m,children:d?"Redirecting…":"Sign in with Microsoft"})]}),children:e.jsxs("div",{className:"space-y-4",children:[s&&e.jsx(x,{tone:"danger",children:s}),e.jsx(x,{tone:"info",children:"A config file never carries an OAuth token — one only works for the instance it was granted to. Signing in here mints a fresh one for this instance."}),e.jsxs("div",{className:"rounded-sm border border-line px-3 py-2.5",children:[e.jsx("p",{className:"text-sm text-fg",children:t.displayName}),e.jsxs("p",{className:"mt-0.5 text-xs text-fg-subtle",children:[t.address," · ",t.server]})]}),e.jsx("p",{className:"text-2xs text-fg-subtle",children:"You will be sent to Microsoft and returned here. If your organisation requires admin approval, the sign-in stops there and this account keeps waiting."})]})})}function gt({folders:t,onNext:n}){return e.jsx(k,{steps:y,activeStep:3,title:t.length>0?"Creating folders":"Import finished",subtitle:t.length>0?"The config names folders this account does not have yet. Reader creates them on the mail server.":"Everything in the file landed, and every folder it named resolved.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"Folder discovery runs with every sync."}),e.jsx(f,{variant:"primary",onClick:n,children:"Go to inbox"})]}),children:e.jsx("div",{className:"space-y-4",children:t.length>0?e.jsxs(e.Fragment,{children:[e.jsxs(x,{tone:"warning",children:[t.length," settings are imported but switched off. Reader creates each missing folder on the mail server the next time the account syncs, and turns the setting on once the server confirms it. A rule whose folder cannot be created stays off, and Settings → Filters says why."]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-muted",children:[e.jsx(nt,{className:"size-4"}),"Folder discovery runs with every sync of the account."]}),e.jsx("div",{className:"divide-y divide-line",children:t.map(i=>e.jsx(fe,{label:i.path,detail:i.waitingFor,state:"pending"},`${i.accountId??""}-${i.path}-${i.waitingFor}`))})]}):e.jsx(x,{tone:"success",children:"Every account, rule, label and sender in the file is live on this instance."})})})}function xt({failure:t,onBack:n}){return e.jsx(k,{steps:y,activeStep:0,title:t.title,subtitle:"Nothing was imported.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"This instance is unchanged."}),e.jsx(f,{variant:"primary",onClick:n,children:"Choose another file"})]}),children:e.jsxs("div",{className:"space-y-3",children:[e.jsx(x,{tone:"danger",children:t.explanation}),e.jsx("p",{className:"text-sm text-fg",children:t.fix}),e.jsx(Y,{children:t.raw})]})})}function jt(t){return t==="landed"?"ok":t==="failed"||t==="unknown"?"failed":"pending"}function vt({results:t,message:n,raw:i,nothingLanded:s,onBack:d,onNext:l}){const m=t.filter(u=>u.state==="landed").length,w=t.some(u=>u.state==="unknown");return e.jsx(k,{steps:y,activeStep:1,title:s?"The import stopped, and nothing landed":"The import stopped part-way",subtitle:s?"No section of the file was written.":w?"It did not say how far it got, so check Settings before importing again.":`${m} of ${t.length} sections landed.`,footer:e.jsxs(e.Fragment,{children:[e.jsx(f,{variant:"ghost",onClick:d,children:"Choose another file"}),e.jsx(f,{variant:"primary",onClick:l,children:s?"Try the import again":"Retry the rest"})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(x,{tone:"danger",children:n}),e.jsx("p",{className:"text-sm text-fg-muted",children:"Retrying is safe: an import folds into what is already here rather than replacing it, so what landed is recognised and left alone."}),e.jsx("div",{className:"divide-y divide-line",children:t.map(u=>e.jsx(fe,{label:u.title,detail:u.detail,state:jt(u.state)},u.section))}),e.jsx(Y,{children:i})]})})}const je=(t,n)=>t?"tls":n?"starttls":"none",yt=t=>({host:t.imapHost,port:t.imapPort,security:je(t.imapTls,t.imapStartTls)}),wt=t=>({host:t.smtpEnabled?t.smtpHost:"",port:t.smtpPort,security:je(t.smtpTls,t.smtpStartTls)}),me=(t,n,i)=>{const s=t.authType==="oauthMicrosoft"?"microsoft":"imap",d=!i&&(s==="microsoft"?t.connectionState==="reauth_required":t.connectionState==="credentials_missing");return{accountId:t.accountId,address:t.email,displayName:t.displayName?.trim()||t.email,connector:s,server:`${t.imapHost}:${t.imapPort}`,state:n?"failed":d?"needed":"entered",failure:n}},bt=t=>{if(!t)return"This instance already holds configuration of its own.";const n=[["accounts","account"],["labels","label"],["filters","rule"],["addressFlags","flagged sender"]].map(([i,s])=>({count:Number(t[i]??0),noun:s})).filter(i=>i.count>0).map(i=>`${i.count} ${i.noun}${i.count===1?"":"s"}`);return n.length===0?"This instance already holds configuration of its own.":`${n.join(", ")} are set up here already.`},H=(t,n)=>{if(t instanceof Error)return t.message;if(typeof t=="object"&&t!==null){const i=t.message;if(typeof i=="string")return i}return n};function kt({onDone:t}){const n=pe(),[i,s]=r.useState("file"),[d,l]=r.useState(!1),[m,w]=r.useState(!1),[u,p]=r.useState(void 0),[j,N]=r.useState(void 0),[R,S]=r.useState(void 0),[h,b]=r.useState(void 0),[Z,ee]=r.useState("abort"),[te,se]=r.useState(void 0),[ye,K]=r.useState(void 0),[C,we]=r.useState([]),[Q,be]=r.useState([]),[g,I]=r.useState(null),[T,U]=r.useState({username:"",password:""}),[F,V]=r.useState({}),[ke,ne]=r.useState(void 0),[G,z]=r.useState(null),[B,Ne]=r.useState([]),{data:$}=ze({...Be(),enabled:C.length>0||i==="folders"}),A=r.useMemo(()=>{const a=new Map;for(const o of $?.accounts??[])a.set(o.accountId,o);return a},[$]),Se=r.useMemo(()=>C.map(a=>A.get(a)).filter(a=>!!a).map(a=>me(a,F[a.accountId],Q.includes(a.accountId))),[C,A,F,Q]),c=g?A.get(g):void 0,ie=g?C.indexOf(g)+1:0,P=q({...$e(),meta:de(409)}),ae=q({...Pe(),meta:de(403,404)}),re=q(De()),oe=q(Le());He(G!==null,()=>{n.invalidateQueries({queryKey:J()}),z(null)});const ce=We(a=>{z(null),a==="stalled"&&ne(Ue)}),Ce=r.useCallback(a=>{l(!1),w(!0),p({name:a.name,size:a.size}),S(void 0),N(void 0),a.text().then(o=>Ge(a.name,a.size,o)).then(o=>{if(w(!1),!o.ok){S(o.failure);return}N(o.document)}).catch(o=>{w(!1),S({title:"That file could not be read",explanation:`The browser could not read ${a.name} from disk, so nothing was sent.`,fix:"Check the file is still there and try again.",raw:H(o,"the file read was refused")})})},[]),D=r.useCallback((a,o)=>{j&&(K(void 0),P.mutate({body:{mode:a,onExisting:o,document:j}},{onSuccess:v=>{if(b(v),ue(v)){s("rejected");return}if(he(v)){s("partial");return}if(a==="validate"){s("review");return}if(Ne(Xe(v)),n.invalidateQueries({queryKey:J()}),v.accountsNeedingCredentials.length>0){we([...v.accountsNeedingCredentials]),s("credentials");return}s("folders")},onError:v=>{const L=Je(v);if(L){K(L),se(void 0),s("conflict");return}S({title:"The import could not be sent",explanation:"The request to this instance failed before it produced a report, so nothing was written.",fix:"Check your connection and try again.",raw:H(v,"POST /config/import failed")}),s("file")}}))},[j,P,n]),Ie=r.useCallback(a=>{if(I(a.accountId),ne(void 0),a.connector==="microsoft"){s("account-oauth");return}const o=A.get(a.accountId);U({username:o?.username||a.address,password:""}),s("account-password")},[A]),Te=r.useCallback(()=>{g&&ae.mutate({path:{accountId:g},body:{password:T.password,isActive:!0}},{onSuccess:()=>{re.mutate({path:{accountId:g}}),be(a=>a.includes(g)?a:[...a,g]),V(a=>{const o={...a};return delete o[g],o}),n.invalidateQueries({queryKey:J()}),U({username:"",password:""}),I(null),s("credentials")},onError:a=>{V(o=>({...o,[g]:H(a,"The password was verified but could not be stored. Try again.")})),I(null),s("credentials")}})},[g,T.password,n,re,ae]),Re=r.useCallback(()=>{c&&(z(c.accountId),oe.mutate({body:{email:c.email}},{onSuccess:a=>{ce(),window.location.assign(a.authorizationUrl)},onError:a=>{z(null),V(o=>({...o,[c.accountId]:H(a,"Microsoft sign-in could not be started.")})),I(null),s("credentials")}}))},[c,ce,oe]),Fe=r.useCallback((a,o)=>U({username:a,password:o}),[]),Ae=r.useMemo(()=>{const a=$?.pendingImport?.folderPaths;if(!a)return B;const o=new Set(a),v=B.filter(E=>o.has(E.path)),L=a.filter(E=>!B.some(Me=>Me.path===E)).map(E=>({path:E,waitingFor:"An imported setting"}));return[...v,...L]},[$,B]),M=r.useCallback(()=>{b(void 0),K(void 0),S(void 0),p(void 0),N(void 0),ee("abort"),s("file")},[]);switch(i){case"file":return e.jsx(ot,{state:m?"reading":P.isPending?"checking":d?"dragging":"idle",file:u,ready:j!==void 0,failure:R,onChoose:Ce,onDragStateChange:l,onNext:()=>D("validate",Z)});case"rejected":return e.jsx(xt,{failure:(h&&ue(h))??R??{title:"The file could not be imported",explanation:"The import was refused and nothing was written.",fix:"Re-export the configuration and try again.",raw:"no error was reported"},onBack:M});case"conflict":return e.jsx(ut,{choice:te,held:bt(ye?.details),onChoose:se,onBack:M,onNext:()=>{if(te==="abort"){t("abandoned");return}ee("merge"),D("validate","merge")}});case"review":return e.jsx(lt,{sections:et(h?.items??[]),fileName:u?.name??"the config file",warnings:(h?.warnings??[]).map(a=>a.message),applying:P.isPending,onBack:M,onNext:()=>D("apply",Z)});case"partial":{if(!h)return e.jsx(Nt,{onBack:M});const a=he(h);return e.jsx(vt,{results:Ze(h),message:a?.message??"The import stopped before it finished.",raw:`${a?.code??Ye}: ${a?.message??"no message"}`,nothingLanded:!h.applied,onBack:M,onNext:()=>D("apply","merge")})}case"credentials":return e.jsx(pt,{accounts:Se,busyAccountId:G??void 0,error:ke,onOpen:Ie,onNext:()=>s("folders")});case"account-password":return c?e.jsx(Ke,{steps:y,activeStep:2,title:`Sign in to ${c.email}`,subtitle:`Account ${ie} of ${C.length} · ${c.imapHost}:${c.imapPort}`,email:c.email,username:T.username,password:T.password,error:F[c.accountId],continueLabel:"Test and continue",notice:e.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-muted",children:[e.jsx(Qe,{className:"size-3.5"}),"Server settings came from the config file — edit them in Settings if they are wrong."]}),onContinue:()=>s("account-test"),onBack:()=>{I(null),s("credentials")},onChange:Fe}):e.jsx(X,{onBack:()=>t("abandoned")});case"account-test":return c?e.jsx(_e,{steps:y,activeStep:2,email:c.email,imapConfig:yt(c),smtpConfig:wt(c),username:T.username,password:T.password,credentialsBackLabel:"Back to the password",serversBackLabel:"Back to the password",successLabel:"Save and continue",onSuccess:Te,onBackToCredentials:()=>s("account-password"),onBackToServers:()=>s("account-password")}):e.jsx(X,{onBack:()=>t("abandoned")});case"account-oauth":return c?e.jsx(ft,{account:me(c,F[c.accountId],Q.includes(c.accountId)),position:ie,total:C.length,error:F[c.accountId],busy:G===c.accountId,onBack:()=>{I(null),s("credentials")},onNext:Re}):e.jsx(X,{onBack:()=>t("abandoned")});case"folders":return e.jsx(gt,{folders:Ae,onNext:()=>t("imported")})}}function ve({children:t,label:n,onBack:i}){return e.jsxs("div",{className:"mx-auto max-w-lg p-6",children:[e.jsx(x,{tone:"danger",children:t}),e.jsx("button",{type:"button",className:"mt-3 text-sm text-accent underline",onClick:i,children:n})]})}function X({onBack:t}){return e.jsx(ve,{label:"Go to inbox",onBack:t,children:"That account is no longer in this instance's configuration, so there is nothing left to sign in to. Open Settings › Accounts to see what is here."})}function Nt({onBack:t}){return e.jsx(ve,{label:"Choose another file",onBack:t,children:"The import stopped but produced no report, so nothing here can say what it wrote. Open Settings to see what this instance holds before importing again."})}function At(){const t=qe(),n=pe(),i=r.useCallback(s=>{st({queryClient:n,recordCompleted:()=>{s==="imported"&&t.recordEvent("config.imported")},navigateToInbox:()=>{window.location.assign("/mail")}})},[t,n]);return e.jsx(kt,{onDone:i})}export{At as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-D7VpR8Bx.js";import{M as i}from"./MailboxPane-CbM92Ovm.js";import"./MessageBody-xzQttW18.js";import"./kbd-DzZig-MJ.js";import"./search-scope-UI1H6AzA.js";import"./useMessageBodyContent-DPlXjxls.js";import"./useRefreshControl-CSd_fo15.js";import"./circle-check-big-Bkno0zML.js";import"./refresh-cw-CpnxiYht.js";import"./useQueries-BDOaD0Tu.js";import"./MessageToolbar-D_XXU4rk.js";import"./roving-focus-B9mHbGbD.js";import"./search-token-index-CXQQu5cA.js";import"./EmptyState-Do3nwfV4.js";import"./ErrorState-DcwvjIQG.js";import"./popover-menu-BHNjsQiI.js";import"./mail-BiL0g7on.js";import"./avatar-CDZx9RcB.js";import"./index-BBaBlwlN.js";import"./useSignature-BMl5h116.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-nmGpghjy.js";import"./sections-ClqQBEFv.js";import"./undo-2-WqFuHEgY.js";import"./download-DS8Ui8jJ.js";import"./useCalendarFreeBusy-CrTlSUQQ.js";import"./useCalendarEvents-BQ8pmFV8.js";import"./useCalendars-B1migLvB.js";import"./map-pin-C0usgYas.js";import"./useLayoutTier-B0zSRsSh.js";import"./calendar-suggestion-B5sKDqe0.js";import"./attendee-row-CPJnqwGs.js";import"./minus-Cs2PKH6V.js";import"./clock-99u2Mdmy.js";import"./calendar-clash-strip-DBNuXhBt.js";import"./bell-off-Bzm-PBgf.js";import"./shield-check-CD-wbm99.js";import"./calendar-report-OI80fkc1.js";import"./menu-liPRY-HF.js";import"./useFilters-zdrGUBZF.js";import"./checkbox-DJpIppZD.js";import"./confirm-dialog-PhUq_oc3.js";import"./MailViewChrome-BOp09SXr.js";import"./LabelApplyTrigger-BNJ7ewFc.js";import"./useLabels-CesUuQey.js";import"./search-query-0wEBmb1P.js";import"./NavMenuButton-D-YzcNLk.js";import"./bottom-sheet-B-kTBnyv.js";import"./circle-help-DqnCeQ17.js";import"./circle-check-Nj7sUGPS.js";function _(){return o.jsx(i.Reading,{})}export{_ as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-D7VpR8Bx.js";import{F as r}from"./FlaggedPane-Cmhk0gcN.js";import"./MessageBody-xzQttW18.js";import"./kbd-DzZig-MJ.js";import"./search-scope-UI1H6AzA.js";import"./useMessageBodyContent-DPlXjxls.js";import"./MessageToolbar-D_XXU4rk.js";import"./roving-focus-B9mHbGbD.js";import"./search-token-index-CXQQu5cA.js";import"./useQueries-BDOaD0Tu.js";import"./EmptyState-Do3nwfV4.js";import"./ErrorState-DcwvjIQG.js";import"./popover-menu-BHNjsQiI.js";import"./mail-BiL0g7on.js";import"./avatar-CDZx9RcB.js";import"./index-BBaBlwlN.js";import"./useSignature-BMl5h116.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-nmGpghjy.js";import"./sections-ClqQBEFv.js";import"./undo-2-WqFuHEgY.js";import"./download-DS8Ui8jJ.js";import"./useCalendarFreeBusy-CrTlSUQQ.js";import"./useCalendarEvents-BQ8pmFV8.js";import"./useCalendars-B1migLvB.js";import"./map-pin-C0usgYas.js";import"./useLayoutTier-B0zSRsSh.js";import"./calendar-suggestion-B5sKDqe0.js";import"./attendee-row-CPJnqwGs.js";import"./minus-Cs2PKH6V.js";import"./clock-99u2Mdmy.js";import"./calendar-clash-strip-DBNuXhBt.js";import"./bell-off-Bzm-PBgf.js";import"./shield-check-CD-wbm99.js";import"./calendar-report-OI80fkc1.js";import"./menu-liPRY-HF.js";import"./useFilters-zdrGUBZF.js";import"./checkbox-DJpIppZD.js";import"./confirm-dialog-PhUq_oc3.js";import"./MailViewChrome-BOp09SXr.js";import"./refresh-cw-CpnxiYht.js";import"./wizard-selection-zWa1qc6-.js";function Q(){return o.jsx(r.Reading,{})}export{Q as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-D7VpR8Bx.js";import{O as t}from"./OutboxPane-5Tg_XaNz.js";import"./roving-focus-B9mHbGbD.js";import"./MessageBody-xzQttW18.js";import"./kbd-DzZig-MJ.js";import"./search-scope-UI1H6AzA.js";import"./useMessageBodyContent-DPlXjxls.js";import"./circle-check-big-Bkno0zML.js";import"./clock-99u2Mdmy.js";import"./row-actions-BkhFe3TY.js";import"./rotate-ccw-Cj4SUyhN.js";import"./search-query-0wEBmb1P.js";import"./outbox-status-BlKn6P0x.js";import"./NavMenuButton-D-YzcNLk.js";import"./menu-liPRY-HF.js";function c(){return o.jsx(t.Reading,{})}export{c as component};
@@ -1 +0,0 @@
1
- import{j as t,ao as o}from"./index-D7VpR8Bx.js";const n=()=>t.jsx(o,{to:"/settings/accounts"});export{n as component};
@@ -1 +0,0 @@
1
- import{j as r}from"./index-D7VpR8Bx.js";import{B as o}from"./BriefPane-DqtL8KK7.js";import"./MessageBody-xzQttW18.js";import"./kbd-DzZig-MJ.js";import"./search-scope-UI1H6AzA.js";import"./useMessageBodyContent-DPlXjxls.js";import"./MessageToolbar-D_XXU4rk.js";import"./roving-focus-B9mHbGbD.js";import"./search-token-index-CXQQu5cA.js";import"./useQueries-BDOaD0Tu.js";import"./EmptyState-Do3nwfV4.js";import"./ErrorState-DcwvjIQG.js";import"./popover-menu-BHNjsQiI.js";import"./mail-BiL0g7on.js";import"./avatar-CDZx9RcB.js";import"./index-BBaBlwlN.js";import"./useSignature-BMl5h116.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-nmGpghjy.js";import"./sections-ClqQBEFv.js";import"./undo-2-WqFuHEgY.js";import"./download-DS8Ui8jJ.js";import"./useCalendarFreeBusy-CrTlSUQQ.js";import"./useCalendarEvents-BQ8pmFV8.js";import"./useCalendars-B1migLvB.js";import"./map-pin-C0usgYas.js";import"./useLayoutTier-B0zSRsSh.js";import"./calendar-suggestion-B5sKDqe0.js";import"./attendee-row-CPJnqwGs.js";import"./minus-Cs2PKH6V.js";import"./clock-99u2Mdmy.js";import"./calendar-clash-strip-DBNuXhBt.js";import"./bell-off-Bzm-PBgf.js";import"./shield-check-CD-wbm99.js";import"./calendar-report-OI80fkc1.js";import"./menu-liPRY-HF.js";import"./useFilters-zdrGUBZF.js";import"./checkbox-DJpIppZD.js";import"./confirm-dialog-PhUq_oc3.js";import"./useRefreshControl-CSd_fo15.js";import"./circle-check-big-Bkno0zML.js";import"./refresh-cw-CpnxiYht.js";import"./LabelApplyTrigger-BNJ7ewFc.js";import"./useLabels-CesUuQey.js";import"./wizard-selection-zWa1qc6-.js";function V(){return r.jsx(o.Reading,{})}export{V as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-D7VpR8Bx.js";import{M as r}from"./MailboxPane-CbM92Ovm.js";import"./MessageBody-xzQttW18.js";import"./kbd-DzZig-MJ.js";import"./search-scope-UI1H6AzA.js";import"./useMessageBodyContent-DPlXjxls.js";import"./useRefreshControl-CSd_fo15.js";import"./circle-check-big-Bkno0zML.js";import"./refresh-cw-CpnxiYht.js";import"./useQueries-BDOaD0Tu.js";import"./MessageToolbar-D_XXU4rk.js";import"./roving-focus-B9mHbGbD.js";import"./search-token-index-CXQQu5cA.js";import"./EmptyState-Do3nwfV4.js";import"./ErrorState-DcwvjIQG.js";import"./popover-menu-BHNjsQiI.js";import"./mail-BiL0g7on.js";import"./avatar-CDZx9RcB.js";import"./index-BBaBlwlN.js";import"./useSignature-BMl5h116.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-nmGpghjy.js";import"./sections-ClqQBEFv.js";import"./undo-2-WqFuHEgY.js";import"./download-DS8Ui8jJ.js";import"./useCalendarFreeBusy-CrTlSUQQ.js";import"./useCalendarEvents-BQ8pmFV8.js";import"./useCalendars-B1migLvB.js";import"./map-pin-C0usgYas.js";import"./useLayoutTier-B0zSRsSh.js";import"./calendar-suggestion-B5sKDqe0.js";import"./attendee-row-CPJnqwGs.js";import"./minus-Cs2PKH6V.js";import"./clock-99u2Mdmy.js";import"./calendar-clash-strip-DBNuXhBt.js";import"./bell-off-Bzm-PBgf.js";import"./shield-check-CD-wbm99.js";import"./calendar-report-OI80fkc1.js";import"./menu-liPRY-HF.js";import"./useFilters-zdrGUBZF.js";import"./checkbox-DJpIppZD.js";import"./confirm-dialog-PhUq_oc3.js";import"./MailViewChrome-BOp09SXr.js";import"./LabelApplyTrigger-BNJ7ewFc.js";import"./useLabels-CesUuQey.js";import"./search-query-0wEBmb1P.js";import"./NavMenuButton-D-YzcNLk.js";import"./bottom-sheet-B-kTBnyv.js";import"./circle-help-DqnCeQ17.js";import"./circle-check-Nj7sUGPS.js";function _(){return o.jsx(r.Reading,{})}export{_ as component};
@@ -1 +0,0 @@
1
- import{j as r}from"./index-D7VpR8Bx.js";import{B as o}from"./BriefPane-DqtL8KK7.js";import"./MessageBody-xzQttW18.js";import"./kbd-DzZig-MJ.js";import"./search-scope-UI1H6AzA.js";import"./useMessageBodyContent-DPlXjxls.js";import"./MessageToolbar-D_XXU4rk.js";import"./roving-focus-B9mHbGbD.js";import"./search-token-index-CXQQu5cA.js";import"./useQueries-BDOaD0Tu.js";import"./EmptyState-Do3nwfV4.js";import"./ErrorState-DcwvjIQG.js";import"./popover-menu-BHNjsQiI.js";import"./mail-BiL0g7on.js";import"./avatar-CDZx9RcB.js";import"./index-BBaBlwlN.js";import"./useSignature-BMl5h116.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-nmGpghjy.js";import"./sections-ClqQBEFv.js";import"./undo-2-WqFuHEgY.js";import"./download-DS8Ui8jJ.js";import"./useCalendarFreeBusy-CrTlSUQQ.js";import"./useCalendarEvents-BQ8pmFV8.js";import"./useCalendars-B1migLvB.js";import"./map-pin-C0usgYas.js";import"./useLayoutTier-B0zSRsSh.js";import"./calendar-suggestion-B5sKDqe0.js";import"./attendee-row-CPJnqwGs.js";import"./minus-Cs2PKH6V.js";import"./clock-99u2Mdmy.js";import"./calendar-clash-strip-DBNuXhBt.js";import"./bell-off-Bzm-PBgf.js";import"./shield-check-CD-wbm99.js";import"./calendar-report-OI80fkc1.js";import"./menu-liPRY-HF.js";import"./useFilters-zdrGUBZF.js";import"./checkbox-DJpIppZD.js";import"./confirm-dialog-PhUq_oc3.js";import"./useRefreshControl-CSd_fo15.js";import"./circle-check-big-Bkno0zML.js";import"./refresh-cw-CpnxiYht.js";import"./LabelApplyTrigger-BNJ7ewFc.js";import"./useLabels-CesUuQey.js";import"./wizard-selection-zWa1qc6-.js";function V(){return r.jsx(o.Reading,{})}export{V as component};