@remit/web-client-dist 0.0.680 → 0.0.681

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 (182) hide show
  1. package/assets/{BriefPane-CcwdfBlh.js → BriefPane-Ct5mLFno.js} +1 -1
  2. package/assets/{CalendarEventEditor-Cpu5cJxJ.js → CalendarEventEditor-BDZOuAkE.js} +1 -1
  3. package/assets/{CalendarEventPopup-ecl1-NSt.js → CalendarEventPopup-Cd49o1aV.js} +1 -1
  4. package/assets/{CalendarLoadFailed-BbUr2ubu.js → CalendarLoadFailed--QaS7mCJ.js} +1 -1
  5. package/assets/{CalendarQuickCreate-DF0Uxv4V.js → CalendarQuickCreate-BYHJja5o.js} +1 -1
  6. package/assets/{CalendarSession-XIbMK3oT.js → CalendarSession-CS_x_fs5.js} +1 -1
  7. package/assets/{DesktopChrome-Ciuao7Ro.js → DesktopChrome-DGlb8cny.js} +1 -1
  8. package/assets/{DropdownMenu-fskbk1FW.js → DropdownMenu-T79mAX3f.js} +1 -1
  9. package/assets/{EmptyState-CzSAWxdK.js → EmptyState-CA538vCg.js} +1 -1
  10. package/assets/{ErrorState-KWmymUQR.js → ErrorState-DD3UfsN8.js} +1 -1
  11. package/assets/{FlaggedPane-CMZMZWbM.js → FlaggedPane-DLqwSIp0.js} +1 -1
  12. package/assets/{FullCompose-6pNo7wi4.js → FullCompose-DnUwBsN_.js} +1 -1
  13. package/assets/{LabelApplyTrigger-C0GQNIEk.js → LabelApplyTrigger-Ox3K3UZo.js} +1 -1
  14. package/assets/{MailShell--jgEGKni.js → MailShell-DVTROO5Y.js} +1 -1
  15. package/assets/{MailViewChrome-33SQAjQn.js → MailViewChrome-BXIIRW1m.js} +1 -1
  16. package/assets/{MailboxPane-CvW6x3uh.js → MailboxPane-ZTGfkp9r.js} +1 -1
  17. package/assets/{MessageBody-Ba6dVlG6.js → MessageBody-Bn9CiLsL.js} +1 -1
  18. package/assets/{MessageToolbar-BB_mPS4p.js → MessageToolbar-bKPOSy0d.js} +1 -1
  19. package/assets/{NavMenuButton-DuV5qIvO.js → NavMenuButton-DS-H9eDz.js} +1 -1
  20. package/assets/{OnboardingWizard-BHqhUNht.js → OnboardingWizard-BpOpo7pG.js} +1 -1
  21. package/assets/OutboxPane-D90GSWPB.js +1 -0
  22. package/assets/_calendarObjectId-DLrseFHy.js +1 -0
  23. package/assets/_mailboxId-ChbfZSu5.js +1 -0
  24. package/assets/_messageId-C3xB5mTr.js +1 -0
  25. package/assets/_messageId-DkZ9lbs8.js +1 -0
  26. package/assets/_messageId-sIYPsGs_.js +1 -0
  27. package/assets/_outboxMessageId-p9gMPFrF.js +1 -0
  28. package/assets/_recurrenceId-Dr6Hnp4i.js +1 -0
  29. package/assets/_threadId-CZDsH_MT.js +1 -0
  30. package/assets/_threadId-H8aKyGzF.js +1 -0
  31. package/assets/_threadId-KqET2q-N.js +1 -0
  32. package/assets/{_view._date-BcsaqrBS.js → _view._date-FIQ-o-2N.js} +1 -1
  33. package/assets/{account-service-status-u9m2wO3G.js → account-service-status-6nrumJJk.js} +1 -1
  34. package/assets/{accounts-GeT0KphS.js → accounts-BzG1i3mT.js} +1 -1
  35. package/assets/{advanced-A-kGFwE6.js → advanced-BNNZ1epf.js} +1 -1
  36. package/assets/{agenda-time-C_tFoNHA.js → agenda-time-C_THqiEa.js} +1 -1
  37. package/assets/{app-chrome-CAqI0L8I.js → app-chrome-Cb3lBdOZ.js} +1 -1
  38. package/assets/{appearance-C0uk70LK.js → appearance-BihwpGRs.js} +1 -1
  39. package/assets/{avatar-BKCZjVnK.js → avatar-COUm7SBG.js} +1 -1
  40. package/assets/{badge-BmEPIQJj.js → badge-C-N2Sfyc.js} +1 -1
  41. package/assets/{bottom-sheet-CYnEFnuG.js → bottom-sheet-DDC7O5sx.js} +1 -1
  42. package/assets/{brief-CT4sagsk.js → brief-Bs9H-S4e.js} +1 -1
  43. package/assets/brief-DJ5051HC.js +1 -0
  44. package/assets/{calendar-DEqazg7d.js → calendar-BR-28-ej.js} +1 -1
  45. package/assets/{calendar-W0j7nrh5.js → calendar-BYyDHpZa.js} +1 -1
  46. package/assets/{calendar-event-popup-GQy2blc9.js → calendar-event-popup-Clle6FA1.js} +1 -1
  47. package/assets/{calendar-event-sidebar-BdPLf9Q-.js → calendar-event-sidebar-CPgDwmOs.js} +1 -1
  48. package/assets/{calendar-failure-note-Cc_-yh_l.js → calendar-failure-note-C9fIL_8K.js} +1 -1
  49. package/assets/{calendar-guests-DCkwUUaR.js → calendar-guests-DEOe1juO.js} +1 -1
  50. package/assets/{calendar-suggestion-w5Buli06.js → calendar-suggestion-DVjK0aSt.js} +1 -1
  51. package/assets/{calendars-CN_LOe7f.js → calendars-DaDEW0oA.js} +1 -1
  52. package/assets/{card-BYFKESRL.js → card-MWxaP_DH.js} +1 -1
  53. package/assets/{checkbox-CPr2JwkJ.js → checkbox-jLurGcNS.js} +1 -1
  54. package/assets/chevron-down-B3lcZAVN.js +1 -0
  55. package/assets/chevron-left-B-i0rFYx.js +1 -0
  56. package/assets/{circle-check-DyyOWTYB.js → circle-check-QqmhC0RV.js} +1 -1
  57. package/assets/{circle-check-big-CVlYwPvW.js → circle-check-big-ChJ8pH-b.js} +1 -1
  58. package/assets/{circle-help-BSxYNH4r.js → circle-help-C9O6dqh6.js} +1 -1
  59. package/assets/{clock-DQO0Oi4O.js → clock-CNuf0kus.js} +1 -1
  60. package/assets/{cloud-off-CUN7xSDU.js → cloud-off-C48CGroa.js} +1 -1
  61. package/assets/compose._-_outboxMessageId_-7cX9IraZ.js +1 -0
  62. package/assets/compose._-_outboxMessageId_-B4dAIiSz.js +1 -0
  63. package/assets/compose._-_outboxMessageId_-B8Bi18pS.js +1 -0
  64. package/assets/compose._-_outboxMessageId_-T4c20e76.js +1 -0
  65. package/assets/{config-import-3qED7KRP.js → config-import-BAWkCcKm.js} +1 -1
  66. package/assets/{confirm-dialog-DCFAU3wg.js → confirm-dialog-CjHvZbGT.js} +1 -1
  67. package/assets/{copy-CMEksM9b.js → copy-Ixy5ZR35.js} +1 -1
  68. package/assets/{credential-steps-DjMS9JxY.js → credential-steps-CREMZs9P.js} +1 -1
  69. package/assets/{download-DpUgrnYE.js → download-DCGyf3W_.js} +1 -1
  70. package/assets/{draft-UntYYkEO.js → draft-H1bLeWg_.js} +1 -1
  71. package/assets/edit-BX860zdz.js +1 -0
  72. package/assets/edit-DvrV6duf.js +1 -0
  73. package/assets/{external-link-Dp_vrT3U.js → external-link-kBeg4Rkl.js} +1 -1
  74. package/assets/{file-json-BXCpWMKO.js → file-json-CxV9Z8Xk.js} +1 -1
  75. package/assets/{filters-BPOqWe_z.js → filters-BqpcwwPd.js} +1 -1
  76. package/assets/{flagged-DOHBcWRm.js → flagged-Bjcd8w-O.js} +1 -1
  77. package/assets/flagged-DXwt3SZW.js +1 -0
  78. package/assets/{folder-input-v9jv3QvB.js → folder-input-CmDkygvp.js} +1 -1
  79. package/assets/{folders-WZv8o8Yl.js → folders-CeYrerQG.js} +1 -1
  80. package/assets/{help-copy-BEXklmCF.js → help-copy-DLhRgp5W.js} +1 -1
  81. package/assets/{import-H021ROti.js → import-yc3QynRF.js} +1 -1
  82. package/assets/index-44Nd6hoS.js +1 -0
  83. package/assets/index-BafgExsO.js +1 -0
  84. package/assets/index-C3xB5mTr.js +1 -0
  85. package/assets/index-D4ibfGR2.js +1 -0
  86. package/assets/index-D8uIyhWM.js +1 -0
  87. package/assets/index-DXydIDl3.js +1 -0
  88. package/assets/index-D_t--guV.js +1 -0
  89. package/assets/{index-KSq98OCk.js → index-DjF679iU.js} +4 -4
  90. package/assets/index-PazExuj-.js +1 -0
  91. package/assets/{index-BVIV7uOn.js → index-X3HUQEvM.js} +3 -3
  92. package/assets/index-rv5AdzRX.js +1 -0
  93. package/assets/index-sIYPsGs_.js +1 -0
  94. package/assets/{kbd-CD9WJQDD.js → kbd-DiYloCGE.js} +1 -1
  95. package/assets/{label-chip-D6H7mAQZ.js → label-chip-tLLbdHoz.js} +1 -1
  96. package/assets/{labels-B1aYofac.js → labels-DwqUITi6.js} +1 -1
  97. package/assets/{mail-BXDRGUJS.js → mail-CDuFGyaA.js} +1 -1
  98. package/assets/{mail-CzYW0cEP.js → mail-DxkYnpSf.js} +1 -1
  99. package/assets/{menu-Cul_tOCl.js → menu-v-YxaQQ_.js} +1 -1
  100. package/assets/new-BrQZmpeT.js +1 -0
  101. package/assets/onboarding-DLvfj4LK.js +1 -0
  102. package/assets/{onboarding-completion-C5SxIJff.js → onboarding-completion-BG60cd5s.js} +1 -1
  103. package/assets/outbox-CZQb6qAX.js +1 -0
  104. package/assets/{pencil-D4t_TOKs.js → pencil-BnBK7tmS.js} +1 -1
  105. package/assets/{people-CBau3oq-.js → people-OwHrHrdJ.js} +1 -1
  106. package/assets/{plus-BSFg3ibr.js → plus-GnqfNmfx.js} +1 -1
  107. package/assets/{popover-menu-Drk7oRld.js → popover-menu-J56UZVjI.js} +1 -1
  108. package/assets/{refresh-cw-CuoE7FSQ.js → refresh-cw-3jpeaUi7.js} +1 -1
  109. package/assets/{reply-DtObeSB2.js → reply-Bs_YhRF4.js} +1 -1
  110. package/assets/{rich-text-Fi0gjjkk.js → rich-text-Bd-wRHu1.js} +1 -1
  111. package/assets/{rich-text-spellcheck-worker-provider-uKovGi4E.js → rich-text-spellcheck-worker-provider-Bnm0BFqL.js} +1 -1
  112. package/assets/{rotate-ccw-9KACcb0y.js → rotate-ccw-D8SF2xHr.js} +1 -1
  113. package/assets/{roving-focus-WwAX8-VC.js → roving-focus-nxbliQos.js} +1 -1
  114. package/assets/{row-actions-C0oNI3Ia.js → row-actions-YYjMjrwp.js} +1 -1
  115. package/assets/{search-mirror-CQaPpynv.js → search-mirror-DgYKzQ_z.js} +1 -1
  116. package/assets/{search-scope-CuQFKckU.js → search-scope-D_Xp19lV.js} +1 -1
  117. package/assets/{search-token-index-BXdRQHFC.js → search-token-index-BIZzLNv9.js} +1 -1
  118. package/assets/{sections-DssOe_S4.js → sections-CRDaS4nn.js} +1 -1
  119. package/assets/{segmented-control-DH-yNZtm.js → segmented-control-DFN0EF39.js} +1 -1
  120. package/assets/{select-CU_oR6rc.js → select-DaBof-xM.js} +1 -1
  121. package/assets/{senders-OMax5Bsf.js → senders-BReSWLlj.js} +1 -1
  122. package/assets/settings-DXQ3zZlR.js +1 -0
  123. package/assets/{settings-screen-FlCW-JB0.js → settings-screen-DU3TjNi2.js} +1 -1
  124. package/assets/{shield-check-7IzpHero.js → shield-check-DZBDPqGc.js} +1 -1
  125. package/assets/{sparkles-D9JSeha5.js → sparkles-DrZ81rOU.js} +1 -1
  126. package/assets/{suggest-list-MxpHM4zs.js → suggest-list-Bl5m8GjB.js} +1 -1
  127. package/assets/{suggested-vips-CUOrJsvn.js → suggested-vips-CjpCfM-Q.js} +1 -1
  128. package/assets/{suggestion._suggestionId-BDEu9XtG.js → suggestion._suggestionId-KbtftShf.js} +1 -1
  129. package/assets/{task._calendarTaskId-glaP1HGu.js → task._calendarTaskId-CJNNC87Y.js} +1 -1
  130. package/assets/{undo-2-BLxVGig8.js → undo-2-DT3EdJen.js} +1 -1
  131. package/assets/{useCalendarData-BHwxEmxu.js → useCalendarData-CDMAl9sB.js} +1 -1
  132. package/assets/{useCalendarScheduling-BPs-bAlU.js → useCalendarScheduling-J13iQDXH.js} +1 -1
  133. package/assets/{useCalendarSuggestions-C4O39URl.js → useCalendarSuggestions-BLiBIz-1.js} +1 -1
  134. package/assets/{useCalendarTasks-BYrDBjzg.js → useCalendarTasks-DClcdx9Q.js} +1 -1
  135. package/assets/{useDebouncedValue-CQk7uQJy.js → useDebouncedValue-CiTDV7kX.js} +1 -1
  136. package/assets/{useFilters-DXcDtC9M.js → useFilters-D_mEdyEH.js} +1 -1
  137. package/assets/{useLabels-Ds4FhWUf.js → useLabels-Beg-UxxE.js} +1 -1
  138. package/assets/{useLayoutTier-CDh6ugx0.js → useLayoutTier-B5_piqNJ.js} +1 -1
  139. package/assets/{useMediaQuery-DHHct6HU.js → useMediaQuery-9NJJDrX6.js} +1 -1
  140. package/assets/{useMessageBodyContent-Bz4eLwYW.js → useMessageBodyContent-Dhtu6I6l.js} +1 -1
  141. package/assets/{useQueries-CFXMrDWB.js → useQueries-BO8eIXDf.js} +1 -1
  142. package/assets/{useRefreshControl-CmSuQYeT.js → useRefreshControl-c8RtcGU3.js} +1 -1
  143. package/assets/{useResultFolderIndex-B-bcuKwK.js → useResultFolderIndex-CJrt60fl.js} +1 -1
  144. package/assets/{useSignature-ChD8g6V6.js → useSignature-ZAeHuLA5.js} +1 -1
  145. package/assets/{warnings-DuiY0HQB.js → warnings-CN1cP32K.js} +1 -1
  146. package/index.html +1 -1
  147. package/package.json +1 -1
  148. package/assets/OutboxPane-vxvckaxe.js +0 -1
  149. package/assets/_calendarObjectId-CysTJCDO.js +0 -1
  150. package/assets/_mailboxId-sUyLlrph.js +0 -1
  151. package/assets/_messageId-BNOLD_NW.js +0 -1
  152. package/assets/_messageId-C11dYlL_.js +0 -1
  153. package/assets/_messageId-sL5uhmsZ.js +0 -1
  154. package/assets/_outboxMessageId-D8CVGqIw.js +0 -1
  155. package/assets/_recurrenceId-BZ43TEn7.js +0 -1
  156. package/assets/_threadId-CKva01mK.js +0 -1
  157. package/assets/_threadId-Dcu-hZiA.js +0 -1
  158. package/assets/_threadId-mSRKzdYV.js +0 -1
  159. package/assets/brief-DcVaSAff.js +0 -1
  160. package/assets/chevron-down-BI1fWP0V.js +0 -1
  161. package/assets/chevron-left-BQBw-0xj.js +0 -1
  162. package/assets/compose._-_outboxMessageId_--bw-JQyQ.js +0 -1
  163. package/assets/compose._-_outboxMessageId_-9p2UwGZ2.js +0 -1
  164. package/assets/compose._-_outboxMessageId_-BKX6xXkK.js +0 -1
  165. package/assets/compose._-_outboxMessageId_-CoRtMIvt.js +0 -1
  166. package/assets/edit-C5xc8ZMZ.js +0 -1
  167. package/assets/edit-DY8bOvEH.js +0 -1
  168. package/assets/flagged-B0gfe6c8.js +0 -1
  169. package/assets/index-B0WA56eY.js +0 -1
  170. package/assets/index-BNOLD_NW.js +0 -1
  171. package/assets/index-BQRB4Hbr.js +0 -1
  172. package/assets/index-BSVI2qk3.js +0 -1
  173. package/assets/index-BTWqd0y1.js +0 -1
  174. package/assets/index-C11dYlL_.js +0 -1
  175. package/assets/index-C9L3Y4ln.js +0 -1
  176. package/assets/index-CMYDLexx.js +0 -1
  177. package/assets/index-Ct_bZm5J.js +0 -1
  178. package/assets/index-cUEB_Vmo.js +0 -1
  179. package/assets/new-CdrTfyYm.js +0 -1
  180. package/assets/onboarding-Bt28IS6_.js +0 -1
  181. package/assets/outbox-C-QNKevV.js +0 -1
  182. package/assets/settings-qYifOymR.js +0 -1
@@ -1 +1 @@
1
- import{b as W,j as t,am as _,p as E,r as n,aE as R,ak as C,f as B,ai as G,d as X,al as J,B as N}from"./index-BVIV7uOn.js";import{S as F}from"./select-CU_oR6rc.js";import{B as K}from"./badge-BmEPIQJj.js";import{C as Q}from"./card-BYFKESRL.js";const dt=W("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);function Y({url:r}){return t.jsxs("p",{className:"text-2xs text-fg-subtle",children:["Stored encrypted, used only to connect to your mail server."," ",r?t.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"How to create an app password"}):t.jsx("span",{children:"Check your provider's help for app password instructions."})]})}function M({value:r,defaultValue:i,onValueChange:s,...e}){return s?t.jsxs(F,{value:r,onChange:a=>s(a.target.value),...e,children:[t.jsx("option",{value:"tls",children:"TLS/SSL"}),t.jsx("option",{value:"starttls",children:"STARTTLS"}),t.jsx("option",{value:"none",children:"None (insecure)"})]}):t.jsxs(F,{defaultValue:i??r,...e,children:[t.jsx("option",{value:"tls",children:"TLS/SSL"}),t.jsx("option",{value:"starttls",children:"STARTTLS"}),t.jsx("option",{value:"none",children:"None (insecure)"})]})}function D(r){return{tls:r==="tls",startTls:r==="starttls"}}function Z({steps:r,activeStep:i}){return t.jsx("ol",{className:"flex items-center gap-1",children:r.map((s,e)=>{const a=e<i,o=e===i;return t.jsxs("li",{className:"flex items-center gap-1",children:[e>0&&t.jsx("span",{className:"h-px w-5 bg-line","aria-hidden":!0}),t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:E("flex size-5 items-center justify-center rounded-full text-2xs font-semibold tabular-nums",a&&"bg-accent text-accent-fg",o&&"bg-accent-soft text-accent ring-1 ring-accent",!a&&!o&&"bg-surface-sunken text-fg-subtle"),children:a?t.jsx(_,{className:"size-3"}):e+1}),t.jsx("span",{className:E("hidden text-2xs sm:inline",o?"font-medium text-fg":"text-fg-subtle"),children:s})]})]},s)})})}function H({steps:r,activeStep:i,title:s,subtitle:e,children:a,footer:o,hideSteps:c}){return t.jsxs("div",{className:"flex h-dvh w-full flex-col items-center overflow-hidden bg-canvas pb-[max(2rem,env(safe-area-inset-bottom,0px))] pl-[max(2rem,env(safe-area-inset-left,0px))] pr-[max(2rem,env(safe-area-inset-right,0px))] pt-[max(2rem,env(safe-area-inset-top,0px))] font-sans text-fg",children:[t.jsx("div",{className:"hidden shrink-[9999] basis-[30vh] sm:block"}),!c&&t.jsx("div",{className:"mb-5 w-full max-w-xl shrink-0",children:t.jsx(Z,{steps:r,activeStep:i})}),t.jsxs(Q,{raised:!0,className:"flex w-full min-h-0 max-w-xl flex-col",children:[t.jsxs("div",{className:"shrink-0 px-5 pt-5",children:[t.jsx("h1",{className:"text-xl font-semibold text-fg",children:s}),e&&t.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:e})]}),t.jsx("div",{"data-testid":"wizard-body",className:"min-h-0 overflow-y-auto px-5 py-5",children:a}),o&&t.jsx("div",{"data-testid":"wizard-footer",className:"flex shrink-0 items-center justify-between gap-3 border-t border-line px-5 py-3",children:o})]})]})}const tt="Coming soon — use IMAP for now.";function ht({name:r,description:i,icon:s,comingSoon:e,selected:a,onSelect:o}){const[c,l]=n.useState(!1),m=()=>{if(o){o();return}e&&l(!0)};return t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsxs("button",{type:"button",onClick:m,"aria-disabled":e||void 0,className:E("flex flex-col items-start gap-2 rounded-sm border p-3 text-left transition-colors",a?"border-accent-2 bg-accent-2-soft":"border-line bg-surface hover:border-line-strong",e&&"opacity-55"),children:[t.jsx("span",{className:E("text-fg-muted",a&&"text-accent-2"),children:s}),t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-semibold text-fg",children:r}),e&&t.jsx("span",{className:"rounded-full bg-surface-sunken px-1.5 py-0.5 text-2xs text-fg-subtle",children:"soon"})]}),t.jsx("span",{className:"text-xs text-fg-subtle",children:i})]}),c&&t.jsx("p",{className:"text-2xs text-fg-subtle",children:tt})]})}function xt({legend:r,badge:i,host:s,port:e,security:a,readOnly:o,onHostChange:c,onPortChange:l,onSecurityChange:m,hostPlaceholder:x,portPlaceholder:y}){const v=n.useId(),b=n.useId(),h=n.useId();return t.jsxs("fieldset",{children:[t.jsxs("legend",{className:"flex items-center gap-2 text-sm font-semibold text-fg",children:[r,i&&t.jsx(K,{tone:i.tone,children:i.label})]}),t.jsxs("div",{className:"mt-2 grid grid-cols-1 gap-3 sm:grid-cols-[1fr_6rem_8rem] sm:gap-2",children:[t.jsxs("div",{children:[t.jsx(R,{htmlFor:v,children:"Host"}),c?t.jsx(C,{id:v,readOnly:o,value:s,onChange:p=>c(p.target.value),placeholder:x}):t.jsx(C,{id:v,readOnly:o,defaultValue:s,placeholder:x})]}),t.jsxs("div",{children:[t.jsx(R,{htmlFor:b,children:"Port"}),l?t.jsx(C,{id:b,readOnly:o,value:e,onChange:p=>l(p.target.value),placeholder:y}):t.jsx(C,{id:b,readOnly:o,defaultValue:e,placeholder:y})]}),t.jsxs("div",{children:[t.jsx(R,{htmlFor:h,children:"Security"}),m?t.jsx(M,{id:h,disabled:o,value:a,onValueChange:m}):t.jsx(M,{id:h,disabled:o,defaultValue:a})]})]})]})}function q({label:r,detail:i,state:s}){return t.jsxs("div",{className:"flex items-start gap-3 py-2",children:[t.jsxs("span",{className:E("mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full text-2xs",s==="ok"&&"bg-positive text-accent-fg",s==="failed"&&"bg-danger text-accent-fg",s==="running"&&"border border-accent text-accent",s==="pending"&&"border border-line text-fg-subtle"),children:[s==="ok"&&t.jsx(_,{className:"size-3"}),s==="failed"&&"!",s==="running"&&t.jsx("span",{className:"size-2 animate-pulse rounded-full bg-accent"})]}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:E("text-sm",s==="failed"?"font-medium text-danger":"text-fg"),children:r}),i&&t.jsx("div",{className:"mt-0.5 text-xs text-fg-subtle",children:i})]})]})}const et=(r,i)=>{const s=n.useRef(i);s.current=i,n.useEffect(()=>{if(!r)return;const e=()=>{document.visibilityState==="visible"&&s.current()};return document.addEventListener("visibilitychange",e),window.addEventListener("pageshow",e),()=>{document.removeEventListener("visibilitychange",e),window.removeEventListener("pageshow",e)}},[r])},st=2e4,ft="Couldn't open Microsoft's sign-in page. Check your connection, and anything blocking redirects, then try again.",gt=r=>{const i=n.useRef(!1),s=n.useRef(!1),e=n.useRef(null),a=n.useRef(r);a.current=r;const o=n.useCallback(()=>{e.current!==null&&(clearTimeout(e.current),e.current=null)},[]),c=n.useCallback(()=>{!i.current||!s.current||(o(),s.current=!1,a.current("returned"))},[o]);return n.useEffect(()=>{const l=()=>{s.current=!0,o()},m=()=>{document.visibilityState==="hidden"&&l()},x=y=>{y.persisted&&(l(),c())};return document.addEventListener("visibilitychange",m),window.addEventListener("pagehide",l),window.addEventListener("pageshow",x),()=>{document.removeEventListener("visibilitychange",m),window.removeEventListener("pagehide",l),window.removeEventListener("pageshow",x),o()}},[c,o]),et(!0,c),n.useCallback(()=>{i.current=!0,s.current=!1,o(),e.current=setTimeout(()=>{e.current=null,i.current=!1,s.current=!1,a.current("stalled")},st)},[o])},rt={"gmail.com":{imap:{host:"imap.gmail.com",port:993,security:"tls"},smtp:{host:"smtp.gmail.com",port:587,security:"starttls"},source:"provider-table"},"googlemail.com":{imap:{host:"imap.gmail.com",port:993,security:"tls"},smtp:{host:"smtp.gmail.com",port:587,security:"starttls"},source:"provider-table"},"outlook.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"hotmail.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"live.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"msn.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"icloud.com":{imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},source:"provider-table"},"me.com":{imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},source:"provider-table"},"mac.com":{imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},source:"provider-table"},"fastmail.com":{imap:{host:"imap.fastmail.com",port:993,security:"tls"},smtp:{host:"smtp.fastmail.com",port:465,security:"tls"},source:"provider-table"},"fastmail.fm":{imap:{host:"imap.fastmail.com",port:993,security:"tls"},smtp:{host:"smtp.fastmail.com",port:465,security:"tls"},source:"provider-table"},"yahoo.com":{imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},source:"provider-table"},"yahoo.co.uk":{imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},source:"provider-table"},"ymail.com":{imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},source:"provider-table"},"aol.com":{imap:{host:"imap.aol.com",port:993,security:"tls"},smtp:{host:"smtp.aol.com",port:465,security:"tls"},source:"provider-table"},"zoho.com":{imap:{host:"imap.zoho.com",port:993,security:"tls"},smtp:{host:"smtp.zoho.com",port:465,security:"tls"},source:"provider-table"},"gmx.com":{imap:{host:"imap.gmx.com",port:993,security:"tls"},smtp:{host:"smtp.gmx.com",port:587,security:"starttls"},source:"provider-table"},"gmx.net":{imap:{host:"imap.gmx.net",port:993,security:"tls"},smtp:{host:"mail.gmx.net",port:587,security:"starttls"},source:"provider-table"},"gmx.de":{imap:{host:"imap.gmx.net",port:993,security:"tls"},smtp:{host:"mail.gmx.net",port:587,security:"starttls"},source:"provider-table"},"web.de":{imap:{host:"imap.web.de",port:993,security:"tls"},smtp:{host:"smtp.web.de",port:587,security:"starttls"},source:"provider-table"},"mail.com":{imap:{host:"imap.mail.com",port:993,security:"tls"},smtp:{host:"smtp.mail.com",port:465,security:"tls"},source:"provider-table"},"hey.com":{imap:{host:"imap.hey.com",port:993,security:"tls"},smtp:{host:"smtp.hey.com",port:465,security:"tls"},source:"provider-table"},"tutanota.com":{imap:{host:"mail.tutanota.com",port:993,security:"tls"},smtp:{host:"mail.tutanota.com",port:465,security:"tls"},source:"provider-table"},"tuta.io":{imap:{host:"mail.tutanota.com",port:993,security:"tls"},smtp:{host:"mail.tutanota.com",port:465,security:"tls"},source:"provider-table"},"posteo.de":{imap:{host:"posteo.de",port:993,security:"tls"},smtp:{host:"posteo.de",port:465,security:"tls"},source:"provider-table"},"runbox.com":{imap:{host:"imap.runbox.com",port:993,security:"tls"},smtp:{host:"smtp.runbox.com",port:587,security:"starttls"},source:"provider-table"},"mailbox.org":{imap:{host:"imap.mailbox.org",port:993,security:"tls"},smtp:{host:"smtp.mailbox.org",port:465,security:"tls"},source:"provider-table"},"hushmail.com":{imap:{host:"imap.hushmail.com",port:993,security:"tls"},smtp:{host:"smtp.hushmail.com",port:465,security:"tls"},source:"provider-table"}},ot={"gmail.com":"https://support.google.com/accounts/answer/185833","googlemail.com":"https://support.google.com/accounts/answer/185833","yahoo.com":"https://help.yahoo.com/kb/generate-manage-third-party-passwords-sln15241.html","icloud.com":"https://support.apple.com/en-us/102654","me.com":"https://support.apple.com/en-us/102654","mac.com":"https://support.apple.com/en-us/102654","fastmail.com":"https://www.fastmail.help/hc/en-us/articles/360058752854","fastmail.fm":"https://www.fastmail.help/hc/en-us/articles/360058752854","outlook.com":"https://support.microsoft.com/en-us/account-billing/manage-app-passwords-for-two-step-verification-d6dc8c6d-4bf7-4851-ad95-6d07799387e9","hotmail.com":"https://support.microsoft.com/en-us/account-billing/manage-app-passwords-for-two-step-verification-d6dc8c6d-4bf7-4851-ad95-6d07799387e9","zoho.com":"https://help.zoho.com/portal/en/kb/zoho-mail/client-configuration/imap-access/articles/zoho-mail-app-passwords"};function U(r){try{const s=new DOMParser().parseFromString(r,"application/xml");if(s.querySelector("parsererror"))return null;const e=s.querySelectorAll("incomingServer[type='imap']"),a=s.querySelectorAll("outgoingServer[type='smtp']");if(!e.length||!a.length)return null;const o=e[0],c=a[0],l=o.querySelector("hostname")?.textContent?.trim(),m=o.querySelector("port")?.textContent?.trim(),x=o.querySelector("socketType")?.textContent?.trim().toUpperCase(),y=c.querySelector("hostname")?.textContent?.trim(),v=c.querySelector("port")?.textContent?.trim(),b=c.querySelector("socketType")?.textContent?.trim().toUpperCase();if(!l||!m||!y||!v)return null;const h=p=>p==="SSL"||p==="TLS"||p==="SSL/TLS"?"tls":p==="STARTTLS"?"starttls":"none";return{imap:{host:l,port:Number.parseInt(m,10),security:h(x)},smtp:{host:y,port:Number.parseInt(v,10),security:h(b)},source:"mozilla-autoconfig"}}catch{return null}}async function it(r,i){try{const s=`https://autoconfig.thunderbird.net/v1.1/${r}`,e=await fetch(s,{signal:i});if(!e.ok)return null;const a=await e.text(),o=U(a);return o||null}catch{return null}}async function at(r,i){try{const s=`https://autoconfig.${r}/mail/config-v1.1.xml`,e=await fetch(s,{signal:i});if(!e.ok)return null;const a=await e.text(),o=U(a);return o?{...o,source:"domain-autoconfig"}:null}catch{return null}}function nt(r){return{imap:{host:`imap.${r}`,port:993,security:"tls"},smtp:{host:`smtp.${r}`,port:587,security:"starttls"},source:"heuristic"}}async function yt(r,i=1500){const s=r.indexOf("@");if(s===-1)return null;const e=r.slice(s+1).toLowerCase();if(!e)return null;const a=rt[e];if(a)return a;const o=new AbortController,c=setTimeout(()=>o.abort(),i);try{const l=await it(e,o.signal);if(l)return l;const m=await at(e,o.signal);if(m)return m}finally{clearTimeout(c)}return nt(e)}function vt(r){const i=r.indexOf("@");return i===-1?"Looking up server settings…":`Looking up settings for ${r.slice(i+1)}…`}function ct(r){const i=r.indexOf("@");if(i===-1)return;const s=r.slice(i+1).toLowerCase();return ot[s]}function bt({steps:r,activeStep:i,title:s,subtitle:e,email:a,username:o,password:c,notice:l,error:m,continueLabel:x="Test connection",backLabel:y="Back",onContinue:v,onBack:b,onChange:h}){const[p,z]=n.useState(o||a),[S,w]=n.useState(c),[T,k]=n.useState(null),I=ct(a),g=p.trim()!==""&&S.trim()!=="";n.useEffect(()=>{h(p,S)},[p,S,h]);const L=n.useCallback(()=>{if(!g){k("Enter your username and password.");return}k(null),v()},[g,v]);return n.useEffect(()=>{const u=j=>{j.key==="Enter"&&L(),j.key==="Escape"&&b()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[L,b]),t.jsx(H,{steps:r,activeStep:i,title:s,subtitle:e,footer:t.jsxs(t.Fragment,{children:[t.jsx(N,{variant:"ghost",onClick:b,children:y}),t.jsx(N,{variant:"primary",onClick:L,children:x})]}),children:t.jsxs("div",{className:"space-y-3",children:[m&&t.jsx(X,{tone:"danger",children:m}),T&&t.jsx("div",{className:"rounded-md bg-danger-soft px-3 py-2 text-sm text-danger",children:T}),l,t.jsxs("div",{children:[t.jsx(R,{htmlFor:"credentials-username",children:"Username"}),t.jsx(C,{id:"credentials-username",value:p,onChange:u=>{z(u.target.value),k(null)},autoComplete:"username"})]}),t.jsxs("div",{children:[t.jsx(R,{htmlFor:"credentials-password",children:"Password or app password"}),t.jsx(J,{id:"credentials-password",value:S,onChange:u=>{w(u.target.value),k(null)},autoComplete:"current-password"})]}),t.jsx(Y,{url:I})]})})}function wt({steps:r,activeStep:i,email:s,imapConfig:e,smtpConfig:a,username:o,password:c,onSuccess:l,onBackToCredentials:m,onBackToServers:x,credentialsBackLabel:y="Back to credentials",serversBackLabel:v="Back to servers",successLabel:b="Start syncing"}){const[h,p]=n.useState({imapState:"running",smtpState:"pending",phase:"running"}),[z,S]=n.useState(0),w=a.host.trim()!=="",T=D(e.security),k=D(a.security),I=B({...G()});n.useEffect(()=>{let u=!1;const j=[];return p({imapState:"running",smtpState:"pending",phase:"running"}),I.mutate({body:{username:o,password:c,imapHost:e.host,imapPort:e.port,imapTls:T.tls,imapStartTls:T.startTls,smtpHost:a.host,smtpPort:a.port,smtpTls:k.tls,smtpStartTls:k.startTls}},{onSuccess:d=>{if(u)return;const f=d.imapSuccess,P=w?d.smtpSuccess:!0;p({imapState:f?"ok":"failed",smtpState:w?"running":"ok",imapDetail:f?`Connected — ${e.host}:${e.port}`:d.imapError,phase:"running"}),j.push(window.setTimeout(()=>{if(u)return;const $=O=>{const A=O?.toLowerCase()??"";return A.includes("auth")||A.includes("login")||A.includes("535")||A.includes("credential")},V=!f&&$(d.imapError)||f&&w&&!d.smtpSuccess&&$(d.smtpError);p({imapState:f?"ok":"failed",smtpState:w?d.smtpSuccess?"ok":"failed":"ok",imapDetail:f?`Connected — ${e.host}:${e.port}`:d.imapError,smtpDetail:w?d.smtpSuccess?`Connected — ${a.host}:${a.port}`:d.smtpError:"Not set up — receive-only",rawError:f?w&&!d.smtpSuccess?d.smtpError:void 0:d.imapError,phase:f&&P?"success":V?"auth-failure":"network-failure"}),f&&P&&j.push(window.setTimeout(()=>{u||l()},800))},400))},onError:d=>{if(u)return;const f=d instanceof Error?d.message:"Connection failed";p({imapState:"failed",smtpState:"failed",imapDetail:f,smtpDetail:f,rawError:f,phase:"network-failure"})}}),()=>{u=!0;for(const d of j)window.clearTimeout(d)}},[z]);const{phase:g}=h;n.useEffect(()=>{const u=j=>{j.key==="Escape"&&(g==="auth-failure"?m():g==="network-failure"&&x())};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[g,m,x]);const L=g==="auth-failure"?t.jsxs(t.Fragment,{children:[t.jsx(N,{variant:"ghost",onClick:m,children:y}),t.jsx(N,{variant:"primary",onClick:()=>S(u=>u+1),children:"Retry"})]}):g==="network-failure"?t.jsxs(t.Fragment,{children:[t.jsx(N,{variant:"ghost",onClick:x,children:v}),t.jsx(N,{variant:"primary",onClick:()=>S(u=>u+1),children:"Retry"})]}):g==="success"?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-2xs text-fg-subtle",children:"Connection verified"}),t.jsx(N,{variant:"primary",onClick:l,children:b})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-2xs text-fg-subtle",children:"Testing…"}),t.jsx("span",{})]});return t.jsx(H,{steps:r,activeStep:i,title:"Testing the connection",subtitle:`Checking ${s}`,footer:L,children:t.jsxs("div",{className:"divide-y divide-line",children:[t.jsx(q,{label:`IMAP — ${e.host}:${e.port}`,detail:h.imapDetail,state:h.imapState}),t.jsx(q,{label:w?`SMTP — ${a.host}:${a.port}`:"SMTP — sending",detail:w?h.smtpDetail:"Not set up — you can add sending later in Settings",state:h.smtpState}),(g==="auth-failure"||g==="network-failure")&&h.rawError&&t.jsxs("div",{className:"py-3",children:[g==="auth-failure"&&t.jsx("p",{className:"mb-2 text-xs text-fg-muted",children:"Check your password — many providers require an app password."}),t.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:h.rawError})]})]})})}export{ot as A,q as C,ft as R,dt as S,H as W,ht as a,gt as b,wt as c,bt as d,xt as e,vt as f,ct as g,yt as h,D as s,et as u};
1
+ import{b as W,j as t,am as _,p as E,r as n,aE as R,ak as C,f as B,ai as G,d as X,al as J,B as N}from"./index-X3HUQEvM.js";import{S as F}from"./select-DaBof-xM.js";import{B as K}from"./badge-C-N2Sfyc.js";import{C as Q}from"./card-MWxaP_DH.js";const dt=W("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);function Y({url:r}){return t.jsxs("p",{className:"text-2xs text-fg-subtle",children:["Stored encrypted, used only to connect to your mail server."," ",r?t.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"How to create an app password"}):t.jsx("span",{children:"Check your provider's help for app password instructions."})]})}function M({value:r,defaultValue:i,onValueChange:s,...e}){return s?t.jsxs(F,{value:r,onChange:a=>s(a.target.value),...e,children:[t.jsx("option",{value:"tls",children:"TLS/SSL"}),t.jsx("option",{value:"starttls",children:"STARTTLS"}),t.jsx("option",{value:"none",children:"None (insecure)"})]}):t.jsxs(F,{defaultValue:i??r,...e,children:[t.jsx("option",{value:"tls",children:"TLS/SSL"}),t.jsx("option",{value:"starttls",children:"STARTTLS"}),t.jsx("option",{value:"none",children:"None (insecure)"})]})}function D(r){return{tls:r==="tls",startTls:r==="starttls"}}function Z({steps:r,activeStep:i}){return t.jsx("ol",{className:"flex items-center gap-1",children:r.map((s,e)=>{const a=e<i,o=e===i;return t.jsxs("li",{className:"flex items-center gap-1",children:[e>0&&t.jsx("span",{className:"h-px w-5 bg-line","aria-hidden":!0}),t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:E("flex size-5 items-center justify-center rounded-full text-2xs font-semibold tabular-nums",a&&"bg-accent text-accent-fg",o&&"bg-accent-soft text-accent ring-1 ring-accent",!a&&!o&&"bg-surface-sunken text-fg-subtle"),children:a?t.jsx(_,{className:"size-3"}):e+1}),t.jsx("span",{className:E("hidden text-2xs sm:inline",o?"font-medium text-fg":"text-fg-subtle"),children:s})]})]},s)})})}function H({steps:r,activeStep:i,title:s,subtitle:e,children:a,footer:o,hideSteps:c}){return t.jsxs("div",{className:"flex h-dvh w-full flex-col items-center overflow-hidden bg-canvas pb-[max(2rem,env(safe-area-inset-bottom,0px))] pl-[max(2rem,env(safe-area-inset-left,0px))] pr-[max(2rem,env(safe-area-inset-right,0px))] pt-[max(2rem,env(safe-area-inset-top,0px))] font-sans text-fg",children:[t.jsx("div",{className:"hidden shrink-[9999] basis-[30vh] sm:block"}),!c&&t.jsx("div",{className:"mb-5 w-full max-w-xl shrink-0",children:t.jsx(Z,{steps:r,activeStep:i})}),t.jsxs(Q,{raised:!0,className:"flex w-full min-h-0 max-w-xl flex-col",children:[t.jsxs("div",{className:"shrink-0 px-5 pt-5",children:[t.jsx("h1",{className:"text-xl font-semibold text-fg",children:s}),e&&t.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:e})]}),t.jsx("div",{"data-testid":"wizard-body",className:"min-h-0 overflow-y-auto px-5 py-5",children:a}),o&&t.jsx("div",{"data-testid":"wizard-footer",className:"flex shrink-0 items-center justify-between gap-3 border-t border-line px-5 py-3",children:o})]})]})}const tt="Coming soon — use IMAP for now.";function ht({name:r,description:i,icon:s,comingSoon:e,selected:a,onSelect:o}){const[c,l]=n.useState(!1),m=()=>{if(o){o();return}e&&l(!0)};return t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsxs("button",{type:"button",onClick:m,"aria-disabled":e||void 0,className:E("flex flex-col items-start gap-2 rounded-sm border p-3 text-left transition-colors",a?"border-accent-2 bg-accent-2-soft":"border-line bg-surface hover:border-line-strong",e&&"opacity-55"),children:[t.jsx("span",{className:E("text-fg-muted",a&&"text-accent-2"),children:s}),t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-semibold text-fg",children:r}),e&&t.jsx("span",{className:"rounded-full bg-surface-sunken px-1.5 py-0.5 text-2xs text-fg-subtle",children:"soon"})]}),t.jsx("span",{className:"text-xs text-fg-subtle",children:i})]}),c&&t.jsx("p",{className:"text-2xs text-fg-subtle",children:tt})]})}function xt({legend:r,badge:i,host:s,port:e,security:a,readOnly:o,onHostChange:c,onPortChange:l,onSecurityChange:m,hostPlaceholder:x,portPlaceholder:y}){const v=n.useId(),b=n.useId(),h=n.useId();return t.jsxs("fieldset",{children:[t.jsxs("legend",{className:"flex items-center gap-2 text-sm font-semibold text-fg",children:[r,i&&t.jsx(K,{tone:i.tone,children:i.label})]}),t.jsxs("div",{className:"mt-2 grid grid-cols-1 gap-3 sm:grid-cols-[1fr_6rem_8rem] sm:gap-2",children:[t.jsxs("div",{children:[t.jsx(R,{htmlFor:v,children:"Host"}),c?t.jsx(C,{id:v,readOnly:o,value:s,onChange:p=>c(p.target.value),placeholder:x}):t.jsx(C,{id:v,readOnly:o,defaultValue:s,placeholder:x})]}),t.jsxs("div",{children:[t.jsx(R,{htmlFor:b,children:"Port"}),l?t.jsx(C,{id:b,readOnly:o,value:e,onChange:p=>l(p.target.value),placeholder:y}):t.jsx(C,{id:b,readOnly:o,defaultValue:e,placeholder:y})]}),t.jsxs("div",{children:[t.jsx(R,{htmlFor:h,children:"Security"}),m?t.jsx(M,{id:h,disabled:o,value:a,onValueChange:m}):t.jsx(M,{id:h,disabled:o,defaultValue:a})]})]})]})}function q({label:r,detail:i,state:s}){return t.jsxs("div",{className:"flex items-start gap-3 py-2",children:[t.jsxs("span",{className:E("mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full text-2xs",s==="ok"&&"bg-positive text-accent-fg",s==="failed"&&"bg-danger text-accent-fg",s==="running"&&"border border-accent text-accent",s==="pending"&&"border border-line text-fg-subtle"),children:[s==="ok"&&t.jsx(_,{className:"size-3"}),s==="failed"&&"!",s==="running"&&t.jsx("span",{className:"size-2 animate-pulse rounded-full bg-accent"})]}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:E("text-sm",s==="failed"?"font-medium text-danger":"text-fg"),children:r}),i&&t.jsx("div",{className:"mt-0.5 text-xs text-fg-subtle",children:i})]})]})}const et=(r,i)=>{const s=n.useRef(i);s.current=i,n.useEffect(()=>{if(!r)return;const e=()=>{document.visibilityState==="visible"&&s.current()};return document.addEventListener("visibilitychange",e),window.addEventListener("pageshow",e),()=>{document.removeEventListener("visibilitychange",e),window.removeEventListener("pageshow",e)}},[r])},st=2e4,ft="Couldn't open Microsoft's sign-in page. Check your connection, and anything blocking redirects, then try again.",gt=r=>{const i=n.useRef(!1),s=n.useRef(!1),e=n.useRef(null),a=n.useRef(r);a.current=r;const o=n.useCallback(()=>{e.current!==null&&(clearTimeout(e.current),e.current=null)},[]),c=n.useCallback(()=>{!i.current||!s.current||(o(),s.current=!1,a.current("returned"))},[o]);return n.useEffect(()=>{const l=()=>{s.current=!0,o()},m=()=>{document.visibilityState==="hidden"&&l()},x=y=>{y.persisted&&(l(),c())};return document.addEventListener("visibilitychange",m),window.addEventListener("pagehide",l),window.addEventListener("pageshow",x),()=>{document.removeEventListener("visibilitychange",m),window.removeEventListener("pagehide",l),window.removeEventListener("pageshow",x),o()}},[c,o]),et(!0,c),n.useCallback(()=>{i.current=!0,s.current=!1,o(),e.current=setTimeout(()=>{e.current=null,i.current=!1,s.current=!1,a.current("stalled")},st)},[o])},rt={"gmail.com":{imap:{host:"imap.gmail.com",port:993,security:"tls"},smtp:{host:"smtp.gmail.com",port:587,security:"starttls"},source:"provider-table"},"googlemail.com":{imap:{host:"imap.gmail.com",port:993,security:"tls"},smtp:{host:"smtp.gmail.com",port:587,security:"starttls"},source:"provider-table"},"outlook.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"hotmail.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"live.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"msn.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"icloud.com":{imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},source:"provider-table"},"me.com":{imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},source:"provider-table"},"mac.com":{imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},source:"provider-table"},"fastmail.com":{imap:{host:"imap.fastmail.com",port:993,security:"tls"},smtp:{host:"smtp.fastmail.com",port:465,security:"tls"},source:"provider-table"},"fastmail.fm":{imap:{host:"imap.fastmail.com",port:993,security:"tls"},smtp:{host:"smtp.fastmail.com",port:465,security:"tls"},source:"provider-table"},"yahoo.com":{imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},source:"provider-table"},"yahoo.co.uk":{imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},source:"provider-table"},"ymail.com":{imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},source:"provider-table"},"aol.com":{imap:{host:"imap.aol.com",port:993,security:"tls"},smtp:{host:"smtp.aol.com",port:465,security:"tls"},source:"provider-table"},"zoho.com":{imap:{host:"imap.zoho.com",port:993,security:"tls"},smtp:{host:"smtp.zoho.com",port:465,security:"tls"},source:"provider-table"},"gmx.com":{imap:{host:"imap.gmx.com",port:993,security:"tls"},smtp:{host:"smtp.gmx.com",port:587,security:"starttls"},source:"provider-table"},"gmx.net":{imap:{host:"imap.gmx.net",port:993,security:"tls"},smtp:{host:"mail.gmx.net",port:587,security:"starttls"},source:"provider-table"},"gmx.de":{imap:{host:"imap.gmx.net",port:993,security:"tls"},smtp:{host:"mail.gmx.net",port:587,security:"starttls"},source:"provider-table"},"web.de":{imap:{host:"imap.web.de",port:993,security:"tls"},smtp:{host:"smtp.web.de",port:587,security:"starttls"},source:"provider-table"},"mail.com":{imap:{host:"imap.mail.com",port:993,security:"tls"},smtp:{host:"smtp.mail.com",port:465,security:"tls"},source:"provider-table"},"hey.com":{imap:{host:"imap.hey.com",port:993,security:"tls"},smtp:{host:"smtp.hey.com",port:465,security:"tls"},source:"provider-table"},"tutanota.com":{imap:{host:"mail.tutanota.com",port:993,security:"tls"},smtp:{host:"mail.tutanota.com",port:465,security:"tls"},source:"provider-table"},"tuta.io":{imap:{host:"mail.tutanota.com",port:993,security:"tls"},smtp:{host:"mail.tutanota.com",port:465,security:"tls"},source:"provider-table"},"posteo.de":{imap:{host:"posteo.de",port:993,security:"tls"},smtp:{host:"posteo.de",port:465,security:"tls"},source:"provider-table"},"runbox.com":{imap:{host:"imap.runbox.com",port:993,security:"tls"},smtp:{host:"smtp.runbox.com",port:587,security:"starttls"},source:"provider-table"},"mailbox.org":{imap:{host:"imap.mailbox.org",port:993,security:"tls"},smtp:{host:"smtp.mailbox.org",port:465,security:"tls"},source:"provider-table"},"hushmail.com":{imap:{host:"imap.hushmail.com",port:993,security:"tls"},smtp:{host:"smtp.hushmail.com",port:465,security:"tls"},source:"provider-table"}},ot={"gmail.com":"https://support.google.com/accounts/answer/185833","googlemail.com":"https://support.google.com/accounts/answer/185833","yahoo.com":"https://help.yahoo.com/kb/generate-manage-third-party-passwords-sln15241.html","icloud.com":"https://support.apple.com/en-us/102654","me.com":"https://support.apple.com/en-us/102654","mac.com":"https://support.apple.com/en-us/102654","fastmail.com":"https://www.fastmail.help/hc/en-us/articles/360058752854","fastmail.fm":"https://www.fastmail.help/hc/en-us/articles/360058752854","outlook.com":"https://support.microsoft.com/en-us/account-billing/manage-app-passwords-for-two-step-verification-d6dc8c6d-4bf7-4851-ad95-6d07799387e9","hotmail.com":"https://support.microsoft.com/en-us/account-billing/manage-app-passwords-for-two-step-verification-d6dc8c6d-4bf7-4851-ad95-6d07799387e9","zoho.com":"https://help.zoho.com/portal/en/kb/zoho-mail/client-configuration/imap-access/articles/zoho-mail-app-passwords"};function U(r){try{const s=new DOMParser().parseFromString(r,"application/xml");if(s.querySelector("parsererror"))return null;const e=s.querySelectorAll("incomingServer[type='imap']"),a=s.querySelectorAll("outgoingServer[type='smtp']");if(!e.length||!a.length)return null;const o=e[0],c=a[0],l=o.querySelector("hostname")?.textContent?.trim(),m=o.querySelector("port")?.textContent?.trim(),x=o.querySelector("socketType")?.textContent?.trim().toUpperCase(),y=c.querySelector("hostname")?.textContent?.trim(),v=c.querySelector("port")?.textContent?.trim(),b=c.querySelector("socketType")?.textContent?.trim().toUpperCase();if(!l||!m||!y||!v)return null;const h=p=>p==="SSL"||p==="TLS"||p==="SSL/TLS"?"tls":p==="STARTTLS"?"starttls":"none";return{imap:{host:l,port:Number.parseInt(m,10),security:h(x)},smtp:{host:y,port:Number.parseInt(v,10),security:h(b)},source:"mozilla-autoconfig"}}catch{return null}}async function it(r,i){try{const s=`https://autoconfig.thunderbird.net/v1.1/${r}`,e=await fetch(s,{signal:i});if(!e.ok)return null;const a=await e.text(),o=U(a);return o||null}catch{return null}}async function at(r,i){try{const s=`https://autoconfig.${r}/mail/config-v1.1.xml`,e=await fetch(s,{signal:i});if(!e.ok)return null;const a=await e.text(),o=U(a);return o?{...o,source:"domain-autoconfig"}:null}catch{return null}}function nt(r){return{imap:{host:`imap.${r}`,port:993,security:"tls"},smtp:{host:`smtp.${r}`,port:587,security:"starttls"},source:"heuristic"}}async function yt(r,i=1500){const s=r.indexOf("@");if(s===-1)return null;const e=r.slice(s+1).toLowerCase();if(!e)return null;const a=rt[e];if(a)return a;const o=new AbortController,c=setTimeout(()=>o.abort(),i);try{const l=await it(e,o.signal);if(l)return l;const m=await at(e,o.signal);if(m)return m}finally{clearTimeout(c)}return nt(e)}function vt(r){const i=r.indexOf("@");return i===-1?"Looking up server settings…":`Looking up settings for ${r.slice(i+1)}…`}function ct(r){const i=r.indexOf("@");if(i===-1)return;const s=r.slice(i+1).toLowerCase();return ot[s]}function bt({steps:r,activeStep:i,title:s,subtitle:e,email:a,username:o,password:c,notice:l,error:m,continueLabel:x="Test connection",backLabel:y="Back",onContinue:v,onBack:b,onChange:h}){const[p,z]=n.useState(o||a),[S,w]=n.useState(c),[T,k]=n.useState(null),I=ct(a),g=p.trim()!==""&&S.trim()!=="";n.useEffect(()=>{h(p,S)},[p,S,h]);const L=n.useCallback(()=>{if(!g){k("Enter your username and password.");return}k(null),v()},[g,v]);return n.useEffect(()=>{const u=j=>{j.key==="Enter"&&L(),j.key==="Escape"&&b()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[L,b]),t.jsx(H,{steps:r,activeStep:i,title:s,subtitle:e,footer:t.jsxs(t.Fragment,{children:[t.jsx(N,{variant:"ghost",onClick:b,children:y}),t.jsx(N,{variant:"primary",onClick:L,children:x})]}),children:t.jsxs("div",{className:"space-y-3",children:[m&&t.jsx(X,{tone:"danger",children:m}),T&&t.jsx("div",{className:"rounded-md bg-danger-soft px-3 py-2 text-sm text-danger",children:T}),l,t.jsxs("div",{children:[t.jsx(R,{htmlFor:"credentials-username",children:"Username"}),t.jsx(C,{id:"credentials-username",value:p,onChange:u=>{z(u.target.value),k(null)},autoComplete:"username"})]}),t.jsxs("div",{children:[t.jsx(R,{htmlFor:"credentials-password",children:"Password or app password"}),t.jsx(J,{id:"credentials-password",value:S,onChange:u=>{w(u.target.value),k(null)},autoComplete:"current-password"})]}),t.jsx(Y,{url:I})]})})}function wt({steps:r,activeStep:i,email:s,imapConfig:e,smtpConfig:a,username:o,password:c,onSuccess:l,onBackToCredentials:m,onBackToServers:x,credentialsBackLabel:y="Back to credentials",serversBackLabel:v="Back to servers",successLabel:b="Start syncing"}){const[h,p]=n.useState({imapState:"running",smtpState:"pending",phase:"running"}),[z,S]=n.useState(0),w=a.host.trim()!=="",T=D(e.security),k=D(a.security),I=B({...G()});n.useEffect(()=>{let u=!1;const j=[];return p({imapState:"running",smtpState:"pending",phase:"running"}),I.mutate({body:{username:o,password:c,imapHost:e.host,imapPort:e.port,imapTls:T.tls,imapStartTls:T.startTls,smtpHost:a.host,smtpPort:a.port,smtpTls:k.tls,smtpStartTls:k.startTls}},{onSuccess:d=>{if(u)return;const f=d.imapSuccess,P=w?d.smtpSuccess:!0;p({imapState:f?"ok":"failed",smtpState:w?"running":"ok",imapDetail:f?`Connected — ${e.host}:${e.port}`:d.imapError,phase:"running"}),j.push(window.setTimeout(()=>{if(u)return;const $=O=>{const A=O?.toLowerCase()??"";return A.includes("auth")||A.includes("login")||A.includes("535")||A.includes("credential")},V=!f&&$(d.imapError)||f&&w&&!d.smtpSuccess&&$(d.smtpError);p({imapState:f?"ok":"failed",smtpState:w?d.smtpSuccess?"ok":"failed":"ok",imapDetail:f?`Connected — ${e.host}:${e.port}`:d.imapError,smtpDetail:w?d.smtpSuccess?`Connected — ${a.host}:${a.port}`:d.smtpError:"Not set up — receive-only",rawError:f?w&&!d.smtpSuccess?d.smtpError:void 0:d.imapError,phase:f&&P?"success":V?"auth-failure":"network-failure"}),f&&P&&j.push(window.setTimeout(()=>{u||l()},800))},400))},onError:d=>{if(u)return;const f=d instanceof Error?d.message:"Connection failed";p({imapState:"failed",smtpState:"failed",imapDetail:f,smtpDetail:f,rawError:f,phase:"network-failure"})}}),()=>{u=!0;for(const d of j)window.clearTimeout(d)}},[z]);const{phase:g}=h;n.useEffect(()=>{const u=j=>{j.key==="Escape"&&(g==="auth-failure"?m():g==="network-failure"&&x())};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[g,m,x]);const L=g==="auth-failure"?t.jsxs(t.Fragment,{children:[t.jsx(N,{variant:"ghost",onClick:m,children:y}),t.jsx(N,{variant:"primary",onClick:()=>S(u=>u+1),children:"Retry"})]}):g==="network-failure"?t.jsxs(t.Fragment,{children:[t.jsx(N,{variant:"ghost",onClick:x,children:v}),t.jsx(N,{variant:"primary",onClick:()=>S(u=>u+1),children:"Retry"})]}):g==="success"?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-2xs text-fg-subtle",children:"Connection verified"}),t.jsx(N,{variant:"primary",onClick:l,children:b})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-2xs text-fg-subtle",children:"Testing…"}),t.jsx("span",{})]});return t.jsx(H,{steps:r,activeStep:i,title:"Testing the connection",subtitle:`Checking ${s}`,footer:L,children:t.jsxs("div",{className:"divide-y divide-line",children:[t.jsx(q,{label:`IMAP — ${e.host}:${e.port}`,detail:h.imapDetail,state:h.imapState}),t.jsx(q,{label:w?`SMTP — ${a.host}:${a.port}`:"SMTP — sending",detail:w?h.smtpDetail:"Not set up — you can add sending later in Settings",state:h.smtpState}),(g==="auth-failure"||g==="network-failure")&&h.rawError&&t.jsxs("div",{className:"py-3",children:[g==="auth-failure"&&t.jsx("p",{className:"mb-2 text-xs text-fg-muted",children:"Check your password — many providers require an app password."}),t.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:h.rawError})]})]})})}export{ot as A,q as C,ft as R,dt as S,H as W,ht as a,gt as b,wt as c,bt as d,xt as e,vt as f,ct as g,yt as h,D as s,et as u};
@@ -1 +1 @@
1
- import{b as o}from"./index-BVIV7uOn.js";const a=o("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);export{a as D};
1
+ import{b as o}from"./index-X3HUQEvM.js";const a=o("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);export{a as D};
@@ -1 +1 @@
1
- import{ed as g,bY as Y,ef as B}from"./index-BVIV7uOn.js";import{q as F}from"./agenda-time-C_tFoNHA.js";import{i as x}from"./calendar-guests-DCkwUUaR.js";const m=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],l=["SU","MO","TU","WE","TH","FR","SA"],E=["January","February","March","April","May","June","July","August","September","October","November","December"],$=["first","second","third","fourth","last"],D=[1,2,3,4,-1],N="MO,TU,WE,TH,FR",L=e=>e.replace(/,\s*\d{2}:\d{2}$/,"").trim();function O(e){const t=L(e);if(t==="")return"";if(t==="Every day")return"FREQ=DAILY";if(t==="Every weekday")return`FREQ=WEEKLY;BYDAY=${N}`;const a=t.match(/^Every week on (\w+)$/);if(a){const i=m.indexOf(a[1]);return i===-1?void 0:`FREQ=WEEKLY;BYDAY=${l[i]}`}const r=t.match(/^Every month on the (\w+) (\w+)$/);if(r){const i=$.indexOf(r[1]),n=m.indexOf(r[2]);return i===-1||n===-1?void 0:`FREQ=MONTHLY;BYDAY=${D[i]}${l[n]}`}const o=t.match(/^Every year on (\d{1,2}) (\w+)$/);if(o){const i=E.indexOf(o[2]);return i===-1?void 0:`FREQ=YEARLY;BYMONTH=${i+1};BYMONTHDAY=${Number(o[1])}`}}const w=e=>e===""?"":`, ${e}`;function S(e,t){const a=new Map(e.split(";").map(n=>n.split("=")).filter(n=>n.length===2).map(([n,c])=>[n.toUpperCase(),c.toUpperCase()])),r=w(t),o=a.get("FREQ"),i=a.get("BYDAY");if(!(a.has("INTERVAL")&&a.get("INTERVAL")!=="1")&&!(a.has("UNTIL")||a.has("COUNT"))){if(o==="DAILY")return`Every day${r}`;if(o==="WEEKLY"){if(i===void 0)return;if(i===N)return`Every weekday${r}`;const n=l.indexOf(i);return n===-1?void 0:`Every week on ${m[n]}${r}`}if(o==="MONTHLY"){const n=i?.match(/^(-?\d)([A-Z]{2})$/);if(!n)return;const c=D.indexOf(Number(n[1])),s=l.indexOf(n[2]);return c===-1||s===-1?void 0:`Every month on the ${$[c]} ${m[s]}${r}`}if(o==="YEARLY"){const n=Number(a.get("BYMONTH")),c=Number(a.get("BYMONTHDAY"));return!n||!c||n>12?void 0:`Every year on ${c} ${E[n-1]}${r}`}}}const f=e=>Date.parse(`${e}T00:00:00Z`)/864e5;function C(e,t,a){const r=f(a)-f(t);if(e===""||r===0||Number.isNaN(r))return e;const[o,i,n]=a.split("-").map(Number),c=new Date(Date.UTC(o,i-1,n)).getUTCDay(),s=/FREQ=(\w+)/i.exec(e)?.[1]?.toUpperCase();return e.split(";").map(u=>{const[y,R=""]=u.split("="),d=y.toUpperCase();return d==="BYDAY"&&s==="MONTHLY"?`BYDAY=${D[Math.min(Math.floor((n-1)/7),4)]}${l[c]}`:d==="BYDAY"?`BYDAY=${R.split(",").map(p=>{const T=l.indexOf(p.toUpperCase());return T===-1?p:l[(T+r+7)%7]}).join(",")}`:d==="BYMONTH"?`BYMONTH=${i}`:d==="BYMONTHDAY"?`BYMONTHDAY=${n}`:u}).join(";")}function b(e,t){return{title:"",date:e,startTime:"09:00",endDate:e,endTime:"10:00",allDay:!1,calendarId:t,location:"",guests:[],notes:"",repeat:""}}function W(e,t){return{title:e.title,date:e.start.slice(0,10),startTime:e.allDay?"":e.start.slice(11,16),endDate:F(e),endTime:e.allDay?"":e.end.slice(11,16),allDay:e.allDay,calendarId:e.calendarId,location:t.location,guests:t.guests,notes:t.notes,repeat:t.repeat}}function A(e,t){return e.allDay?{start:e.date,end:g(e.endDate,1)}:{start:Y(e.date,e.startTime,t),end:Y(e.endDate,e.endTime,t)}}function M(e,t,a){const r=O(e.repeat)??"",o=e.allDay?e.date:B(t,a.anchor===""?"UTC":a.anchor).slice(0,10);return C(r,e.date,o)}function k(e,t){if(e.title.trim()==="")return"Give the event a title before saving it.";if(e.date==="")return"Pick the day the event is on.";if(e.endDate==="")return"Pick the day the event ends on.";if(e.calendarId==="")return"Pick the calendar to save the event in.";if(!e.allDay&&(e.startTime===""||e.endTime===""))return"Set a start and an end time, or mark the event all day.";if(e.allDay&&e.endDate<e.date)return"The last day is before the first. Move one of them.";if(!e.allDay&&`${e.endDate}T${e.endTime}`<=`${e.date}T${e.startTime}`)return"The end is not after the start. Move one of them.";const a=x(e.guests);return a?`${a.text} is not an email address. Fix or remove it to save.`:t&&O(e.repeat)===void 0?"This calendar can't store that repeat rule. Pick one of the offered rules, or turn the repeat off.":""}const h=e=>e.guests.filter(t=>t.valid).map(t=>({email:t.email,displayName:t.displayName})),v=e=>JSON.stringify(h(e));function Q(e,t,a){const r=k(e,!0);if(r!=="")return{ok:!1,problem:r};const{start:o,end:i}=A(e,t.clock),n=h(e);return{ok:!0,input:{calendarId:e.calendarId,summary:e.title.trim(),description:e.notes,location:e.location,start:o,end:i,allDay:e.allDay,...t.anchor===""?{}:{timeZone:t.anchor},recurrenceRule:M(e,o,t),attendees:n,...n.length===0?{}:{organizerAccountId:a}}}}function K(e,t,a){const r=t.repeat!==e.repeat,i=t.allDay!==e.allDay||t.date!==e.date||t.startTime!==e.startTime,n=i||t.endDate!==e.endDate||t.endTime!==e.endTime,c=k(t,r);if(c!=="")return{ok:!1,problem:c};const s={};t.title.trim()!==e.title.trim()&&(s.summary=t.title.trim()),t.location!==e.location&&(s.location=t.location),t.notes!==e.notes&&(s.description=t.notes);const{start:u,end:y}=A(t,a.clock);return i&&(s.start=u),n&&(s.end=y,s.allDay=t.allDay,a.anchor!==""&&(s.timeZone=a.anchor)),r&&(s.recurrenceRule=M(t,u,a)),v(t)!==v(e)&&(s.attendees=h(t)),{ok:!0,patch:s}}export{A as a,Q as c,W as d,b as e,C as m,K as p,S as t};
1
+ import{ed as g,bY as Y,ef as B}from"./index-X3HUQEvM.js";import{q as F}from"./agenda-time-C_THqiEa.js";import{i as x}from"./calendar-guests-DEOe1juO.js";const m=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],l=["SU","MO","TU","WE","TH","FR","SA"],E=["January","February","March","April","May","June","July","August","September","October","November","December"],$=["first","second","third","fourth","last"],D=[1,2,3,4,-1],N="MO,TU,WE,TH,FR",L=e=>e.replace(/,\s*\d{2}:\d{2}$/,"").trim();function O(e){const t=L(e);if(t==="")return"";if(t==="Every day")return"FREQ=DAILY";if(t==="Every weekday")return`FREQ=WEEKLY;BYDAY=${N}`;const a=t.match(/^Every week on (\w+)$/);if(a){const i=m.indexOf(a[1]);return i===-1?void 0:`FREQ=WEEKLY;BYDAY=${l[i]}`}const r=t.match(/^Every month on the (\w+) (\w+)$/);if(r){const i=$.indexOf(r[1]),n=m.indexOf(r[2]);return i===-1||n===-1?void 0:`FREQ=MONTHLY;BYDAY=${D[i]}${l[n]}`}const o=t.match(/^Every year on (\d{1,2}) (\w+)$/);if(o){const i=E.indexOf(o[2]);return i===-1?void 0:`FREQ=YEARLY;BYMONTH=${i+1};BYMONTHDAY=${Number(o[1])}`}}const w=e=>e===""?"":`, ${e}`;function S(e,t){const a=new Map(e.split(";").map(n=>n.split("=")).filter(n=>n.length===2).map(([n,c])=>[n.toUpperCase(),c.toUpperCase()])),r=w(t),o=a.get("FREQ"),i=a.get("BYDAY");if(!(a.has("INTERVAL")&&a.get("INTERVAL")!=="1")&&!(a.has("UNTIL")||a.has("COUNT"))){if(o==="DAILY")return`Every day${r}`;if(o==="WEEKLY"){if(i===void 0)return;if(i===N)return`Every weekday${r}`;const n=l.indexOf(i);return n===-1?void 0:`Every week on ${m[n]}${r}`}if(o==="MONTHLY"){const n=i?.match(/^(-?\d)([A-Z]{2})$/);if(!n)return;const c=D.indexOf(Number(n[1])),s=l.indexOf(n[2]);return c===-1||s===-1?void 0:`Every month on the ${$[c]} ${m[s]}${r}`}if(o==="YEARLY"){const n=Number(a.get("BYMONTH")),c=Number(a.get("BYMONTHDAY"));return!n||!c||n>12?void 0:`Every year on ${c} ${E[n-1]}${r}`}}}const f=e=>Date.parse(`${e}T00:00:00Z`)/864e5;function C(e,t,a){const r=f(a)-f(t);if(e===""||r===0||Number.isNaN(r))return e;const[o,i,n]=a.split("-").map(Number),c=new Date(Date.UTC(o,i-1,n)).getUTCDay(),s=/FREQ=(\w+)/i.exec(e)?.[1]?.toUpperCase();return e.split(";").map(u=>{const[y,R=""]=u.split("="),d=y.toUpperCase();return d==="BYDAY"&&s==="MONTHLY"?`BYDAY=${D[Math.min(Math.floor((n-1)/7),4)]}${l[c]}`:d==="BYDAY"?`BYDAY=${R.split(",").map(p=>{const T=l.indexOf(p.toUpperCase());return T===-1?p:l[(T+r+7)%7]}).join(",")}`:d==="BYMONTH"?`BYMONTH=${i}`:d==="BYMONTHDAY"?`BYMONTHDAY=${n}`:u}).join(";")}function b(e,t){return{title:"",date:e,startTime:"09:00",endDate:e,endTime:"10:00",allDay:!1,calendarId:t,location:"",guests:[],notes:"",repeat:""}}function W(e,t){return{title:e.title,date:e.start.slice(0,10),startTime:e.allDay?"":e.start.slice(11,16),endDate:F(e),endTime:e.allDay?"":e.end.slice(11,16),allDay:e.allDay,calendarId:e.calendarId,location:t.location,guests:t.guests,notes:t.notes,repeat:t.repeat}}function A(e,t){return e.allDay?{start:e.date,end:g(e.endDate,1)}:{start:Y(e.date,e.startTime,t),end:Y(e.endDate,e.endTime,t)}}function M(e,t,a){const r=O(e.repeat)??"",o=e.allDay?e.date:B(t,a.anchor===""?"UTC":a.anchor).slice(0,10);return C(r,e.date,o)}function k(e,t){if(e.title.trim()==="")return"Give the event a title before saving it.";if(e.date==="")return"Pick the day the event is on.";if(e.endDate==="")return"Pick the day the event ends on.";if(e.calendarId==="")return"Pick the calendar to save the event in.";if(!e.allDay&&(e.startTime===""||e.endTime===""))return"Set a start and an end time, or mark the event all day.";if(e.allDay&&e.endDate<e.date)return"The last day is before the first. Move one of them.";if(!e.allDay&&`${e.endDate}T${e.endTime}`<=`${e.date}T${e.startTime}`)return"The end is not after the start. Move one of them.";const a=x(e.guests);return a?`${a.text} is not an email address. Fix or remove it to save.`:t&&O(e.repeat)===void 0?"This calendar can't store that repeat rule. Pick one of the offered rules, or turn the repeat off.":""}const h=e=>e.guests.filter(t=>t.valid).map(t=>({email:t.email,displayName:t.displayName})),v=e=>JSON.stringify(h(e));function Q(e,t,a){const r=k(e,!0);if(r!=="")return{ok:!1,problem:r};const{start:o,end:i}=A(e,t.clock),n=h(e);return{ok:!0,input:{calendarId:e.calendarId,summary:e.title.trim(),description:e.notes,location:e.location,start:o,end:i,allDay:e.allDay,...t.anchor===""?{}:{timeZone:t.anchor},recurrenceRule:M(e,o,t),attendees:n,...n.length===0?{}:{organizerAccountId:a}}}}function K(e,t,a){const r=t.repeat!==e.repeat,i=t.allDay!==e.allDay||t.date!==e.date||t.startTime!==e.startTime,n=i||t.endDate!==e.endDate||t.endTime!==e.endTime,c=k(t,r);if(c!=="")return{ok:!1,problem:c};const s={};t.title.trim()!==e.title.trim()&&(s.summary=t.title.trim()),t.location!==e.location&&(s.location=t.location),t.notes!==e.notes&&(s.description=t.notes);const{start:u,end:y}=A(t,a.clock);return i&&(s.start=u),n&&(s.end=y,s.allDay=t.allDay,a.anchor!==""&&(s.timeZone=a.anchor)),r&&(s.recurrenceRule=M(t,u,a)),v(t)!==v(e)&&(s.attendees=h(t)),{ok:!0,patch:s}}export{A as a,Q as c,W as d,b as e,C as m,K as p,S as t};
@@ -0,0 +1 @@
1
+ import{eS as o,j as r}from"./index-X3HUQEvM.js";import{a as i}from"./CalendarEventEditor-BDZOuAkE.js";import"./draft-H1bLeWg_.js";import"./agenda-time-C_THqiEa.js";import"./calendar-guests-DEOe1juO.js";import"./calendar-event-popup-Clle6FA1.js";import"./useCalendarSuggestions-BLiBIz-1.js";import"./ErrorState-DD3UfsN8.js";import"./useQueries-BO8eIXDf.js";import"./pencil-BnBK7tmS.js";import"./circle-help-C9O6dqh6.js";import"./useCalendarData-CDMAl9sB.js";import"./useCalendarTasks-DClcdx9Q.js";import"./useCalendarScheduling-J13iQDXH.js";import"./useDebouncedValue-CiTDV7kX.js";import"./calendar-format-BwCpz-JZ.js";import"./reply-Bs_YhRF4.js";import"./useMediaQuery-9NJJDrX6.js";import"./calendar-BYyDHpZa.js";import"./CalendarQuickCreate-BYHJja5o.js";import"./CalendarSession-CS_x_fs5.js";import"./calendar-event-sidebar-CPgDwmOs.js";import"./select-DaBof-xM.js";import"./chevron-down-B3lcZAVN.js";import"./confirm-dialog-CjHvZbGT.js";function q(){const{calendarObjectId:t}=o.useParams();return r.jsx(i,{calendarObjectId:t})}export{q as component};
@@ -0,0 +1 @@
1
+ import{eV as o,j as i}from"./index-X3HUQEvM.js";import{a as m}from"./CalendarEventEditor-BDZOuAkE.js";import"./draft-H1bLeWg_.js";import"./agenda-time-C_THqiEa.js";import"./calendar-guests-DEOe1juO.js";import"./calendar-event-popup-Clle6FA1.js";import"./useCalendarSuggestions-BLiBIz-1.js";import"./ErrorState-DD3UfsN8.js";import"./useQueries-BO8eIXDf.js";import"./pencil-BnBK7tmS.js";import"./circle-help-C9O6dqh6.js";import"./useCalendarData-CDMAl9sB.js";import"./useCalendarTasks-DClcdx9Q.js";import"./useCalendarScheduling-J13iQDXH.js";import"./useDebouncedValue-CiTDV7kX.js";import"./calendar-format-BwCpz-JZ.js";import"./reply-Bs_YhRF4.js";import"./useMediaQuery-9NJJDrX6.js";import"./calendar-BYyDHpZa.js";import"./CalendarQuickCreate-BYHJja5o.js";import"./CalendarSession-CS_x_fs5.js";import"./calendar-event-sidebar-CPgDwmOs.js";import"./select-DaBof-xM.js";import"./chevron-down-B3lcZAVN.js";import"./confirm-dialog-CjHvZbGT.js";function q(){const{calendarObjectId:r,recurrenceId:t}=o.useParams();return i.jsx(m,{calendarObjectId:r,recurrenceId:t})}export{q as component};
@@ -1 +1 @@
1
- import{b as a}from"./index-BVIV7uOn.js";const e=a("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);export{e as E};
1
+ import{b as a}from"./index-X3HUQEvM.js";const e=a("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);export{e as E};
@@ -1 +1 @@
1
- import{b as a}from"./index-BVIV7uOn.js";const o=a("FileJson",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]]);export{o as F};
1
+ import{b as a}from"./index-X3HUQEvM.js";const o=a("FileJson",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]]);export{o as F};
@@ -1 +1 @@
1
- import{a_ as ee,j as e,L as _,a9 as oe,p as ce,a$ as de,b0 as me,r as x,ak as H,B as F,b1 as ue,b2 as J,b3 as xe,b4 as pe,aN as fe,e as he,f as ge,b5 as be,b6 as je,b7 as ve,ax as Ne,T as ye,as as te,at as se,a as ae,R as Ce,b8 as Se,V as ke,W as we,b9 as Fe,ba as Ie,u as Me,az as Re,c as Ee,aB as Oe}from"./index-BVIV7uOn.js";import{E as K,f as De}from"./ErrorState-KWmymUQR.js";import{u as Le}from"./useMediaQuery-DHHct6HU.js";import{u as Te,a as Ae}from"./useLabels-Ds4FhWUf.js";import{C as ze,A as $e,a as Pe,b as _e,N as E,p as Be,u as Ue,r as He,c as ne,S as V,d as Ke,n as qe,f as Je,e as Ve,g as Qe,h as Ge,i as We,j as Ye}from"./useFilters-DXcDtC9M.js";import{L as ie}from"./label-chip-D6H7mAQZ.js";import{S as Q}from"./segmented-control-DH-yNZtm.js";import{S as Xe}from"./select-CU_oR6rc.js";import{C as q}from"./circle-check-DyyOWTYB.js";import{B as Ze}from"./bottom-sheet-CYnEFnuG.js";import{B as et}from"./badge-BmEPIQJj.js";import{S as tt}from"./settings-screen-FlCW-JB0.js";import"./suggest-list-MxpHM4zs.js";import"./plus-BSFg3ibr.js";import"./chevron-down-BI1fWP0V.js";import"./avatar-BKCZjVnK.js";import"./chevron-left-BQBw-0xj.js";import"./menu-Cul_tOCl.js";import"./circle-help-BSxYNH4r.js";function st({preview:t}){const s=ee(t);if(t.status==="loading")return e.jsxs("p",{className:"flex items-center gap-2 text-xs text-fg-muted","aria-live":"polite",children:[e.jsx(_,{className:"size-3.5 animate-spin","aria-hidden":"true"}),s]});if(t.status==="error")return e.jsxs("p",{className:"flex items-center gap-2 text-xs text-danger",role:"alert",children:[e.jsx(oe,{className:"size-3.5 shrink-0","aria-hidden":"true"}),s]});const a=t.count===0;return e.jsxs("p",{className:ce("flex items-center gap-2 text-xs",t.stale?"text-fg-subtle":a?"text-fg-muted":"font-medium text-fg"),"aria-live":"polite",children:[t.stale&&e.jsx(_,{className:"size-3.5 animate-spin","aria-hidden":"true"}),s]})}const at=[{value:"all",label:J("all")},{value:"any",label:J("any")}],G=[{value:"once",label:"Just once"},{value:"standing",label:"Keep doing this"},{value:"until",label:"Until a date"}],W="__filter_create_label__";function nt({folders:t,value:s,delimiter:a="/",onChangeMove:n,onCreateFolder:m}){const[f,j]=x.useState(!1),[h,g]=x.useState(),[o,u]=x.useState([]),y=x.useMemo(()=>{const v=new Set(t.map(p=>p.id));return[...t,...o.filter(p=>!v.has(p.id))]},[t,o]),l=x.useMemo(()=>{if(m)return async(v,p,r)=>{const d=await m(v,p,r);return u(k=>k.some(M=>M.id===d.id)?k:[...k,d]),d}},[m]),w=y.find(v=>v.id===s),C=y.find(v=>v.id===h),b=v=>{const p=pe(v.path,a);return p.map((r,d)=>{const k=p.slice(0,d+1).join(a);return y.find(M=>M.path===k)?.label??r}).join(" / ")},S=()=>{j(!1),g(void 0)};return f?e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex h-72 min-h-0 overflow-hidden rounded-md border border-line bg-surface",children:e.jsx(xe,{folders:y,selectedId:h,delimiter:a,onSelect:g,onCreateFolder:l,onCancel:S,labels:{createPending:"Waiting for the mail server to confirm the folder…"}})}),C?e.jsx(F,{variant:"primary",onClick:()=>{n?.(C.id),S()},className:"w-full",children:e.jsx("span",{className:"truncate",children:`Move matches to ${b(C)}`})}):e.jsx("p",{className:"text-2xs text-fg-subtle",children:"Tap a folder to open it, or make a new one where you want it."}),e.jsx(F,{variant:"ghost",size:"sm",onClick:S,className:"w-full",children:"Cancel"})]}):e.jsxs("div",{className:"rounded-md border border-line bg-surface-sunken p-3",children:[e.jsx("p",{className:"text-sm font-medium text-fg",children:w?b(w):"No folder yet"}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-3",children:[e.jsx(F,{variant:"ghost",size:"sm",className:"px-0",onClick:()=>{g(s),j(!0)},children:"Choose a folder"}),w&&e.jsx(F,{variant:"ghost",size:"sm",className:"px-0",onClick:()=>n?.(""),children:"Don't move matches"})]})]})}function it({labels:t,value:s,onChangeLabel:a,onCreateLabel:n}){const[m,f]=x.useState(!1),[j,h]=x.useState(""),[g,o]=x.useState(!1),[u,y]=x.useState(),[l,w]=x.useState([]),C=x.useMemo(()=>{const r=new Set(t.map(d=>d.id));return[...t,...l.filter(d=>!r.has(d.id))]},[t,l]),b=C.find(r=>r.id===s),S=r=>{if(r===W){y(void 0),f(!0);return}a?.(r)},v=()=>{if(!n)return;const r=j.trim();r!==""&&(o(!0),y(void 0),n(r).then(d=>{w(k=>k.some(M=>M.id===d.id)?k:[...k,d]),a?.(d.id),f(!1),h(""),o(!1)}).catch(d=>{y(d instanceof Error?d.message:"Couldn't create that label. Please try again."),o(!1)}))},p=()=>{f(!1),h(""),y(void 0)};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Xe,{"aria-label":"Label to apply",value:s,onChange:r=>S(r.target.value),className:"flex-1",children:[e.jsx("option",{value:"",children:"No label"}),C.map(r=>e.jsx("option",{value:r.id,children:r.name},r.id)),n&&e.jsx("option",{value:W,children:"+ New label…"})]}),b&&e.jsx(ie,{label:{...b,labelId:b.id}})]}),m&&e.jsxs("div",{className:"space-y-2 rounded-md border border-line bg-surface-sunken p-2",children:[e.jsx(H,{value:j,onChange:r=>h(r.target.value),placeholder:"Label name","aria-label":"New label name",disabled:g,autoFocus:!0,onKeyDown:r=>{r.key==="Enter"&&(r.preventDefault(),v()),r.key==="Escape"&&(r.preventDefault(),p())}}),u&&e.jsx("p",{className:"text-2xs text-danger",role:"alert",children:u}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(F,{variant:"primary",size:"sm",onClick:v,disabled:g||j.trim()==="",children:g?"Creating…":"Create label"}),e.jsx(F,{variant:"ghost",size:"sm",onClick:p,disabled:g,children:"Cancel"})]})]})]})}function rt({rule:t,folders:s,delimiter:a,labels:n=[],preview:m,notice:f,clauseFields:j,persisted:h=!1,clauseSuggestions:g,clauseEdit:o,onStartAddClause:u,onStartEditClause:y,onRemoveClause:l,onChangeDraftField:w,onChangeDraftValue:C,onSubmitClause:b,onCancelClause:S,onChangeMatchOperator:v,onChangeMove:p,onCreateFolder:r,onChangeLabel:d,onCreateLabel:k,onChangeScope:M,onChangeName:O,onChangeUntil:L,onCommit:D,onCancel:z}){const T=t.clauses.length>=2,$=de(t.matchOperator),N=me(t,m),A=t.scope==="standing"||t.scope==="until",P=h?G.filter(I=>I.value!=="once"):G;return e.jsxs("div",{className:"flex min-h-0 flex-col",children:[e.jsxs("div",{className:"border-b border-line px-5 py-3",children:[e.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Filter rule"}),e.jsx("p",{className:"mt-0.5 text-xs text-fg-muted",children:"These chips are the whole rule — what you see is what applies."})]}),e.jsxs("div",{className:"min-h-0 flex-1 space-y-5 overflow-y-auto px-5 py-4",children:[f,e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.clauses.map((I,B)=>e.jsxs(x.Fragment,{children:[B>0&&e.jsx("span",{className:"text-2xs font-medium uppercase text-fg-subtle",children:$}),e.jsx(ze,{clause:I,onEdit:()=>y?.(I.id),onRemove:()=>l?.(I.id)})]},I.id)),!o&&e.jsx($e,{label:"Add clause",onClick:u})]}),o&&e.jsx(Pe,{draft:o.draft,mode:o.mode,fields:j,suggestions:g,onChangeField:w,onChangeValue:C,onSubmit:b,onCancel:S}),T&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-fg-muted",children:"Match"}),e.jsx(Q,{name:"match-operator",size:"sm","aria-label":"Match operator",options:at,value:t.matchOperator,onChange:I=>v?.(I)})]})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-fg-muted",children:"Move matches to"}),e.jsx(nt,{folders:s,value:t.moveMailboxId,delimiter:a,onChangeMove:p,onCreateFolder:r})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-fg-muted",children:"Apply a label"}),e.jsx(it,{labels:n,value:t.labelId??"",onChangeLabel:d,onCreateLabel:k})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-fg-muted",children:"How long"}),e.jsx(Q,{name:"rule-scope",size:"sm","aria-label":"Rule scope",options:P,value:t.scope,onChange:I=>M?.(I)}),A&&e.jsx(H,{value:t.name??"",onChange:I=>O?.(I.target.value),placeholder:"Name this rule (e.g. Receipts)","aria-label":"Rule name",className:"w-full"}),t.scope==="until"&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-muted",children:[e.jsx("span",{children:"Until"}),e.jsx(H,{type:"date",value:t.until??"",onChange:I=>L?.(I.target.value),"aria-label":"Expiry date",className:"flex-1"})]})]}),e.jsx("div",{className:"border-t border-line pt-3",children:e.jsx(st,{preview:m})})]}),e.jsxs("div",{className:"space-y-2 border-t border-line px-5 py-3",children:[N&&e.jsx("p",{className:"text-xs text-fg-subtle",role:"status",children:N}),e.jsx(F,{variant:"primary",onClick:D,disabled:N!==void 0,className:"w-full",children:ue(t.scope)}),e.jsx(F,{variant:"ghost",onClick:z,className:"w-full",children:"Not now"})]})]})}const lt=t=>{const s=fe(t);return s!==void 0&&s>=400&&s<500};function Y({title:t,error:s,onRetry:a,reportHref:n}){return e.jsxs("div",{className:"space-y-1",children:[e.jsx(K,{variant:"inline",title:t,error:s,onRetry:lt(s)?void 0:a}),e.jsx("a",{href:n(De(s)),target:"_blank",rel:"noreferrer",className:"text-xs text-accent hover:underline",children:"Report an issue"})]})}const ot=(t,s)=>{const a=he(),n=ge({...je(),onSuccess:()=>{t&&(a.invalidateQueries({queryKey:_e(t)}),s&&a.invalidateQueries({queryKey:be({path:{accountId:t,filterId:s}})}))}}),{mutate:m}=n;return{updateFilter:x.useCallback(j=>{!t||!s||m({path:{accountId:t,filterId:s},body:j})},[t,s,m]),isPending:n.isPending,isSuccess:n.isSuccess,isError:n.isError,error:n.error,reset:n.reset}},ct=t=>({clauses:t.literalClauses.map((a,n)=>({id:`clause-${n}`,field:a.field,value:a.value})),matchOperator:t.matchOperator==="And"?"all":"any",moveMailboxId:t.actionMailboxId!==E?t.actionMailboxId:void 0,labelId:t.actionLabelId!==E?t.actionLabelId:void 0,scope:t.scope==="Temporary"?"until":"standing",until:t.scope==="Temporary"?dt(t.expiresAt):void 0,name:t.name}),dt=t=>{if(!t)return"";const s=Date.parse(t);if(Number.isNaN(s))return"";const a=new Date(s),n=m=>String(m).padStart(2,"0");return`${a.getFullYear()}-${n(a.getMonth()+1)}-${n(a.getDate())}`},X=t=>JSON.stringify({clauses:t.clauses.map(s=>[s.field,s.value]),operator:t.matchOperator,move:t.moveMailboxId??null,label:t.labelId??null}),re=(t,s)=>X(t)!==X(s),Z=t=>JSON.stringify({scope:t.scope==="until"?"until":"standing",until:t.scope==="until"?t.until??"":""}),le=(t,s)=>Z(t)!==Z(s),mt=(t,s)=>{const a={},n=(t.name??"").trim();return n!==(s.name??"").trim()&&(a.name=n),re(t,s)&&(a.matchOperator=t.matchOperator==="all"?"And":"Or",a.literalClauses=t.clauses.map(m=>({field:m.field,value:m.value})),a.actionMailboxId=t.moveMailboxId??E,a.actionLabelId=t.labelId??E),le(t,s)&&(a.scope=t.scope==="until"?"Temporary":"Standing",t.scope==="until"&&(a.expiresAt=Be(t.until??""))),a};function ut({accountId:t,filter:s,folders:a,delimiter:n,labels:m,onClose:f}){const j=x.useMemo(()=>ct(s),[s]),[h,g]=x.useState(j),[o,u]=x.useState(),[y,l]=x.useState(!1),w=x.useRef(0),{count:C}=Ue(t,He(h)),b=ot(t,s.filterId),S=ne(t),{createFolderIn:v}=ve(t),{createLabel:p}=Te(t),r=async c=>{const i=await p(c);return{id:i.labelId,name:i.name,color:i.color}},d=()=>u({mode:"add",draft:{field:V[0],value:""}}),k=c=>{const i=h.clauses.find(R=>R.id===c);i&&u({mode:"edit",clauseId:c,draft:{field:i.field,value:i.value}})},M=c=>u(i=>i&&{...i,draft:{...i.draft,field:c}}),O=c=>u(i=>i&&{...i,draft:{...i.draft,value:c}}),L=()=>{if(!o)return;const c=o.draft.field,i=qe(c,o.draft.value);i!==""&&(g(R=>o.mode==="edit"&&o.clauseId?{...R,clauses:R.clauses.map(U=>U.id===o.clauseId?{id:U.id,field:c,value:i}:U)}:(w.current+=1,{...R,clauses:[...R.clauses,{id:`new-${w.current}`,field:c,value:i}]})),u(void 0))},D=c=>g(i=>({...i,clauses:i.clauses.filter(R=>R.id!==c)})),z=c=>g(i=>({...i,matchOperator:c})),T=c=>g(i=>({...i,moveMailboxId:c||void 0})),$=c=>g(i=>({...i,labelId:c||void 0})),N=c=>g(i=>({...i,name:c})),A=c=>g(i=>({...i,scope:c,until:c==="until"?i.until:void 0})),P=c=>g(i=>({...i,until:c})),I=()=>{const c=re(h,j)||le(h,j),i=mt(h,j);if(Object.keys(i).length===0){f();return}l(c),b.updateFilter(i)},B=()=>S.start(Ke(h));return S.isStarting||S.isRunning||S.isDone?e.jsx(ht,{progress:S.progress,isDone:S.isDone,onClose:f}):b.isPending?e.jsx(xt,{}):b.isError?e.jsx(gt,{onRetry:b.reset,onClose:f}):b.isSuccess?y?e.jsx(ft,{preview:ee(C),blocked:C.status!=="ready"||C.stale===!0,onReapply:B,onClose:f}):e.jsx(pt,{onClose:f}):e.jsx(rt,{rule:h,folders:a,delimiter:n,labels:m,preview:C,clauseFields:V,persisted:!0,clauseEdit:o,onStartAddClause:d,onStartEditClause:k,onRemoveClause:D,onChangeDraftField:M,onChangeDraftValue:O,onSubmitClause:L,onCancelClause:()=>u(void 0),onChangeMatchOperator:z,onChangeMove:T,onCreateFolder:v,onChangeLabel:$,onCreateLabel:r,onChangeName:N,onChangeScope:A,onChangeUntil:P,onCommit:I,onCancel:f})}function xt(){return e.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[e.jsx(_,{className:"size-8 animate-spin text-accent-2"}),e.jsx("p",{className:"text-sm font-medium text-fg",children:"Saving changes…"})]})}function pt({onClose:t}){return e.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[e.jsx(q,{className:"size-8 text-positive"}),e.jsx("p",{className:"text-sm font-medium text-fg",children:"Filter updated"}),e.jsx(F,{variant:"primary",onClick:t,className:"mt-2",children:"Done"})]})}function ft({preview:t,blocked:s,onReapply:a,onClose:n}){return e.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[e.jsx(q,{className:"size-8 text-positive"}),e.jsx("p",{className:"text-sm font-medium text-fg",children:"Rule saved"}),e.jsxs("p",{className:"max-w-xs text-xs text-fg-muted",children:["New mail follows the rule automatically. ",t," — move the mail already in your mailbox too?"]}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx(F,{variant:"primary",onClick:a,disabled:s,children:"Move existing mail"}),e.jsx(F,{variant:"ghost",onClick:n,children:"Not now"})]})]})}function ht({progress:t,isDone:s,onClose:a}){const n=t.state==="Failed";return e.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[s?n?e.jsx("span",{className:"text-sm font-semibold text-danger",children:"Move failed"}):e.jsx(q,{className:"size-8 text-positive"}):e.jsx(_,{className:"size-8 animate-spin text-accent-2"}),!s&&e.jsx("p",{className:"text-sm font-medium text-fg",children:"Moving existing mail…"}),s&&!n&&e.jsxs("div",{className:"text-sm text-fg",children:[e.jsx("p",{className:"font-medium",children:"Done"}),e.jsxs("p",{className:"mt-1 text-xs text-fg-muted",children:[t.appliedCount," of ",t.matchedCount," moved",t.failedCount>0?` · ${t.failedCount} failed`:"","."]})]}),s&&n&&e.jsx("p",{className:"max-w-xs text-xs text-fg-muted",children:t.errorMessage||"Something went wrong. Please try again."}),s&&e.jsx(F,{variant:"primary",onClick:a,className:"mt-2",children:"Done"})]})}function gt({onRetry:t,onClose:s}){return e.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[e.jsx("p",{className:"text-sm font-medium text-danger",children:"Couldn't save changes"}),e.jsx("p",{className:"max-w-xs text-xs text-fg-muted",children:"Please try again."}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx(F,{variant:"primary",onClick:t,children:"Try again"}),e.jsx(F,{variant:"ghost",onClick:s,children:"Not now"})]})]})}function bt({accountId:t,filter:s,folders:a,delimiter:n,labels:m,onClose:f}){const j=Le(),h=e.jsx(ut,{accountId:t,filter:s,folders:a,delimiter:n,labels:m,onClose:f});return j?e.jsx(Ne,{open:!0,onClose:f,title:"Filter rule",children:h}):e.jsx(Ze,{open:!0,onClose:f,label:"Filter rule",dismissLabel:"Dismiss filter rule",children:h})}const jt=t=>{switch(t.kind){case"queuing":case"running":return"Running over the inbox…";case"done":return t.matched===0?"Done. Nothing in the inbox matched.":`Done. Filed ${t.applied} of ${t.matched} matching messages in the inbox.`;case"failed":return}};function vt({filters:t,mailboxName:s,labelById:a,onEdit:n,onDelete:m,deletingFilterId:f,onToggle:j,togglingFilterId:h,onRunNow:g,runFilterId:o,runStatus:u,now:y=Date.now()}){return t.length===0?e.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."}):e.jsx("ul",{className:"divide-y divide-line rounded-md border border-line",children:t.map(l=>{const w=Je(l,y),C=w==="Expired",b=w==="Disabled",S=b?Ve(l):void 0,v=l.actionMailboxId!==E?s(l.actionMailboxId):void 0,p=l.actionLabelId!==E?a.get(l.actionLabelId):void 0,r=Qe(l.expiresAt),d=o===l.filterId?u:void 0,k=d?.kind==="queuing"||d?.kind==="running",M=d?jt(d):void 0,O=w==="Active"&&(l.actionMailboxId!==E||l.actionLabelId!==E);return e.jsxs("li",{className:"flex items-start gap-3 px-3 py-2.5",children:[e.jsxs("button",{type:"button",onClick:()=>n(l.filterId),"aria-label":`Edit filter ${l.name}`,className:"min-w-0 flex-1 rounded-sm text-left hover:opacity-80",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`truncate text-sm font-medium ${C||b?"text-fg-muted":"text-fg"}`,children:l.name}),e.jsx(et,{tone:C?"neutral":b?"warning":"positive",dot:!0,children:w})]}),e.jsxs("p",{className:"mt-0.5 text-xs text-fg-subtle",children:[v?`Moves matches to ${v}`:"No move action",l.scope==="Temporary"&&r?C?` · expired ${r}`:` · until ${r}`:l.scope==="Standing"?" · always":""]}),S&&e.jsx("p",{className:"mt-0.5 text-xs text-warning",children:S}),M&&e.jsx("p",{role:"status",className:"mt-0.5 text-xs text-fg-muted",children:M}),p&&e.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:e.jsx(ie,{label:{labelId:p.id,name:p.name,color:p.color}})})]}),O&&e.jsx(F,{variant:"ghost",size:"sm",onClick:()=>g(l.filterId),disabled:k,"aria-label":`Run now: filter ${l.name}`,children:k?"Running…":"Run now"}),!C&&e.jsx(F,{variant:"ghost",size:"sm",onClick:()=>j(l.filterId,b),disabled:h===l.filterId,"aria-label":`${b?"Turn on":"Turn off"} filter ${l.name}`,children:b?"Turn on":"Turn off"}),e.jsx(F,{variant:"ghost",size:"sm",icon:e.jsx(ye,{className:"size-4 text-danger"}),onClick:()=>m(l.filterId),disabled:f===l.filterId,"aria-label":`Delete filter ${l.name}`})]},l.filterId)})})}function Nt(t){return te(se({title:`Filter toggle: ${t}`,errorMessage:t}))}function yt(t){return te(se({title:`Filter run now: ${t}`,errorMessage:t}))}const Ct=t=>{if(t.failure)return{kind:"failed",error:t.failure.error};if(t.isStarting)return{kind:"queuing"};if(t.isDone)return t.progress.state==="Failed"?{kind:"failed",error:new Error(t.progress.errorMessage||"The run over the inbox failed.")}:{kind:"done",matched:t.progress.matchedCount,applied:t.progress.appliedCount};if(t.isRunning)return{kind:"running"}},St=e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{children:["Filters are the standing rules Organize creates. A"," ",e.jsx("strong",{children:"Standing"})," filter keeps working on new mail; a"," ",e.jsx("strong",{children:"Temporary"})," one stops on its own at the date you picked."]}),e.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."}),e.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 kt({account:t}){const s=t.accountId,{filters:a,isPending:n,isError:m,error:f,refetch:j}=Ge(s),{deleteFilter:h,deletingFilterId:g}=We(s),o=Ye(s),u=ne(s),{startForFilter:y}=u,[l,w]=x.useState(),C=x.useCallback(N=>{w(N),y(N)},[y]),b=Ct(u),[S,v]=x.useState(),{data:p}=ae({...Ce({path:{accountId:s}}),staleTime:1/0}),r=Se(),d=x.useMemo(()=>ke(t.folderAppointments),[t.folderAppointments]),k=x.useCallback(N=>{const A=p?.items.find(P=>P.mailboxId===N);if(A)return we(A,d.get(N),r)},[p?.items,d,r]),M=x.useMemo(()=>Fe({mailboxes:p?.items??[],folderAppointments:t.folderAppointments,translator:r}),[p?.items,t.folderAppointments,r]),O=Ie(p?.items??[]),{labels:L}=Ae(s),D=x.useMemo(()=>L.map(N=>({id:N.labelId,name:N.name,color:N.color})),[L]),z=x.useMemo(()=>new Map(D.map(N=>[N.id,N])),[D]),T=a.find(N=>N.filterId===S),$=a.find(N=>N.filterId===l)?.name;return e.jsxs("section",{className:"space-y-2",children:[e.jsx("h2",{className:"text-sm font-semibold text-fg",children:t.email}),T&&e.jsx(bt,{accountId:s,filter:T,folders:M,delimiter:O,labels:D,onClose:()=>v(void 0)}),n?e.jsx("div",{className:"h-16 animate-pulse rounded-md border border-line bg-surface","aria-busy":"true","aria-label":`Loading filters for ${t.email}`}):m?e.jsx(K,{variant:"inline",title:`Couldn't load filters for ${t.email}`,error:f,onRetry:()=>{j()}}):e.jsxs(e.Fragment,{children:[o.isError&&e.jsx(Y,{title:o.enabling?"Couldn't turn the filter on":"Couldn't turn the filter off",error:o.error,onRetry:o.retry,reportHref:Nt}),l&&b?.kind==="failed"&&e.jsx(Y,{title:`Couldn't run ${$??"the filter"} over the inbox`,error:b.error,onRetry:u.failure?.kind==="statusUnreadable"?u.refreshStatus:()=>C(l),reportHref:yt}),e.jsx(vt,{filters:a,mailboxName:k,labelById:z,onEdit:v,onDelete:h,deletingFilterId:g,onToggle:o.toggleFilter,togglingFilterId:o.togglingFilterId,onRunNow:C,runFilterId:l,runStatus:b})]})]})}function qt(){const t=Me(),s=Re(),[a,n]=x.useState(!0),{data:m,isPending:f,isError:j,error:h,refetch:g}=ae(Ee()),o=u=>{const y=Oe[u];y&&t({to:y})};return e.jsx(tt,{items:s,activeId:"filters",title:"Filters",description:"Standing and temporary rules created by Organize, per account.",help:St,helpOpen:a,onToggleHelp:()=>n(u=>!u),onSelect:o,onBackToMail:()=>{t({to:"/mail"})},children:f?e.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":"Loading accounts"}):j?e.jsx(K,{title:"Couldn't load accounts",error:h,onRetry:()=>{g()}}):m.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:m.accounts.map(u=>e.jsx(kt,{account:u},u.accountId))})})}export{kt as AccountFilters,qt as component};
1
+ import{a_ as ee,j as e,L as _,a9 as oe,p as ce,a$ as de,b0 as me,r as x,ak as H,B as F,b1 as ue,b2 as J,b3 as xe,b4 as pe,aN as fe,e as he,f as ge,b5 as be,b6 as je,b7 as ve,ax as Ne,T as ye,as as te,at as se,a as ae,R as Ce,b8 as Se,V as ke,W as we,b9 as Fe,ba as Ie,u as Me,az as Re,c as Ee,aB as Oe}from"./index-X3HUQEvM.js";import{E as K,f as De}from"./ErrorState-DD3UfsN8.js";import{u as Le}from"./useMediaQuery-9NJJDrX6.js";import{u as Te,a as Ae}from"./useLabels-Beg-UxxE.js";import{C as ze,A as $e,a as Pe,b as _e,N as E,p as Be,u as Ue,r as He,c as ne,S as V,d as Ke,n as qe,f as Je,e as Ve,g as Qe,h as Ge,i as We,j as Ye}from"./useFilters-D_mEdyEH.js";import{L as ie}from"./label-chip-tLLbdHoz.js";import{S as Q}from"./segmented-control-DFN0EF39.js";import{S as Xe}from"./select-DaBof-xM.js";import{C as q}from"./circle-check-QqmhC0RV.js";import{B as Ze}from"./bottom-sheet-DDC7O5sx.js";import{B as et}from"./badge-C-N2Sfyc.js";import{S as tt}from"./settings-screen-DU3TjNi2.js";import"./suggest-list-Bl5m8GjB.js";import"./plus-GnqfNmfx.js";import"./chevron-down-B3lcZAVN.js";import"./avatar-COUm7SBG.js";import"./chevron-left-B-i0rFYx.js";import"./menu-v-YxaQQ_.js";import"./circle-help-C9O6dqh6.js";function st({preview:t}){const s=ee(t);if(t.status==="loading")return e.jsxs("p",{className:"flex items-center gap-2 text-xs text-fg-muted","aria-live":"polite",children:[e.jsx(_,{className:"size-3.5 animate-spin","aria-hidden":"true"}),s]});if(t.status==="error")return e.jsxs("p",{className:"flex items-center gap-2 text-xs text-danger",role:"alert",children:[e.jsx(oe,{className:"size-3.5 shrink-0","aria-hidden":"true"}),s]});const a=t.count===0;return e.jsxs("p",{className:ce("flex items-center gap-2 text-xs",t.stale?"text-fg-subtle":a?"text-fg-muted":"font-medium text-fg"),"aria-live":"polite",children:[t.stale&&e.jsx(_,{className:"size-3.5 animate-spin","aria-hidden":"true"}),s]})}const at=[{value:"all",label:J("all")},{value:"any",label:J("any")}],G=[{value:"once",label:"Just once"},{value:"standing",label:"Keep doing this"},{value:"until",label:"Until a date"}],W="__filter_create_label__";function nt({folders:t,value:s,delimiter:a="/",onChangeMove:n,onCreateFolder:m}){const[f,j]=x.useState(!1),[h,g]=x.useState(),[o,u]=x.useState([]),y=x.useMemo(()=>{const v=new Set(t.map(p=>p.id));return[...t,...o.filter(p=>!v.has(p.id))]},[t,o]),l=x.useMemo(()=>{if(m)return async(v,p,r)=>{const d=await m(v,p,r);return u(k=>k.some(M=>M.id===d.id)?k:[...k,d]),d}},[m]),w=y.find(v=>v.id===s),C=y.find(v=>v.id===h),b=v=>{const p=pe(v.path,a);return p.map((r,d)=>{const k=p.slice(0,d+1).join(a);return y.find(M=>M.path===k)?.label??r}).join(" / ")},S=()=>{j(!1),g(void 0)};return f?e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex h-72 min-h-0 overflow-hidden rounded-md border border-line bg-surface",children:e.jsx(xe,{folders:y,selectedId:h,delimiter:a,onSelect:g,onCreateFolder:l,onCancel:S,labels:{createPending:"Waiting for the mail server to confirm the folder…"}})}),C?e.jsx(F,{variant:"primary",onClick:()=>{n?.(C.id),S()},className:"w-full",children:e.jsx("span",{className:"truncate",children:`Move matches to ${b(C)}`})}):e.jsx("p",{className:"text-2xs text-fg-subtle",children:"Tap a folder to open it, or make a new one where you want it."}),e.jsx(F,{variant:"ghost",size:"sm",onClick:S,className:"w-full",children:"Cancel"})]}):e.jsxs("div",{className:"rounded-md border border-line bg-surface-sunken p-3",children:[e.jsx("p",{className:"text-sm font-medium text-fg",children:w?b(w):"No folder yet"}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-3",children:[e.jsx(F,{variant:"ghost",size:"sm",className:"px-0",onClick:()=>{g(s),j(!0)},children:"Choose a folder"}),w&&e.jsx(F,{variant:"ghost",size:"sm",className:"px-0",onClick:()=>n?.(""),children:"Don't move matches"})]})]})}function it({labels:t,value:s,onChangeLabel:a,onCreateLabel:n}){const[m,f]=x.useState(!1),[j,h]=x.useState(""),[g,o]=x.useState(!1),[u,y]=x.useState(),[l,w]=x.useState([]),C=x.useMemo(()=>{const r=new Set(t.map(d=>d.id));return[...t,...l.filter(d=>!r.has(d.id))]},[t,l]),b=C.find(r=>r.id===s),S=r=>{if(r===W){y(void 0),f(!0);return}a?.(r)},v=()=>{if(!n)return;const r=j.trim();r!==""&&(o(!0),y(void 0),n(r).then(d=>{w(k=>k.some(M=>M.id===d.id)?k:[...k,d]),a?.(d.id),f(!1),h(""),o(!1)}).catch(d=>{y(d instanceof Error?d.message:"Couldn't create that label. Please try again."),o(!1)}))},p=()=>{f(!1),h(""),y(void 0)};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Xe,{"aria-label":"Label to apply",value:s,onChange:r=>S(r.target.value),className:"flex-1",children:[e.jsx("option",{value:"",children:"No label"}),C.map(r=>e.jsx("option",{value:r.id,children:r.name},r.id)),n&&e.jsx("option",{value:W,children:"+ New label…"})]}),b&&e.jsx(ie,{label:{...b,labelId:b.id}})]}),m&&e.jsxs("div",{className:"space-y-2 rounded-md border border-line bg-surface-sunken p-2",children:[e.jsx(H,{value:j,onChange:r=>h(r.target.value),placeholder:"Label name","aria-label":"New label name",disabled:g,autoFocus:!0,onKeyDown:r=>{r.key==="Enter"&&(r.preventDefault(),v()),r.key==="Escape"&&(r.preventDefault(),p())}}),u&&e.jsx("p",{className:"text-2xs text-danger",role:"alert",children:u}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(F,{variant:"primary",size:"sm",onClick:v,disabled:g||j.trim()==="",children:g?"Creating…":"Create label"}),e.jsx(F,{variant:"ghost",size:"sm",onClick:p,disabled:g,children:"Cancel"})]})]})]})}function rt({rule:t,folders:s,delimiter:a,labels:n=[],preview:m,notice:f,clauseFields:j,persisted:h=!1,clauseSuggestions:g,clauseEdit:o,onStartAddClause:u,onStartEditClause:y,onRemoveClause:l,onChangeDraftField:w,onChangeDraftValue:C,onSubmitClause:b,onCancelClause:S,onChangeMatchOperator:v,onChangeMove:p,onCreateFolder:r,onChangeLabel:d,onCreateLabel:k,onChangeScope:M,onChangeName:O,onChangeUntil:L,onCommit:D,onCancel:z}){const T=t.clauses.length>=2,$=de(t.matchOperator),N=me(t,m),A=t.scope==="standing"||t.scope==="until",P=h?G.filter(I=>I.value!=="once"):G;return e.jsxs("div",{className:"flex min-h-0 flex-col",children:[e.jsxs("div",{className:"border-b border-line px-5 py-3",children:[e.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Filter rule"}),e.jsx("p",{className:"mt-0.5 text-xs text-fg-muted",children:"These chips are the whole rule — what you see is what applies."})]}),e.jsxs("div",{className:"min-h-0 flex-1 space-y-5 overflow-y-auto px-5 py-4",children:[f,e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.clauses.map((I,B)=>e.jsxs(x.Fragment,{children:[B>0&&e.jsx("span",{className:"text-2xs font-medium uppercase text-fg-subtle",children:$}),e.jsx(ze,{clause:I,onEdit:()=>y?.(I.id),onRemove:()=>l?.(I.id)})]},I.id)),!o&&e.jsx($e,{label:"Add clause",onClick:u})]}),o&&e.jsx(Pe,{draft:o.draft,mode:o.mode,fields:j,suggestions:g,onChangeField:w,onChangeValue:C,onSubmit:b,onCancel:S}),T&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-fg-muted",children:"Match"}),e.jsx(Q,{name:"match-operator",size:"sm","aria-label":"Match operator",options:at,value:t.matchOperator,onChange:I=>v?.(I)})]})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-fg-muted",children:"Move matches to"}),e.jsx(nt,{folders:s,value:t.moveMailboxId,delimiter:a,onChangeMove:p,onCreateFolder:r})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-fg-muted",children:"Apply a label"}),e.jsx(it,{labels:n,value:t.labelId??"",onChangeLabel:d,onCreateLabel:k})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-fg-muted",children:"How long"}),e.jsx(Q,{name:"rule-scope",size:"sm","aria-label":"Rule scope",options:P,value:t.scope,onChange:I=>M?.(I)}),A&&e.jsx(H,{value:t.name??"",onChange:I=>O?.(I.target.value),placeholder:"Name this rule (e.g. Receipts)","aria-label":"Rule name",className:"w-full"}),t.scope==="until"&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-muted",children:[e.jsx("span",{children:"Until"}),e.jsx(H,{type:"date",value:t.until??"",onChange:I=>L?.(I.target.value),"aria-label":"Expiry date",className:"flex-1"})]})]}),e.jsx("div",{className:"border-t border-line pt-3",children:e.jsx(st,{preview:m})})]}),e.jsxs("div",{className:"space-y-2 border-t border-line px-5 py-3",children:[N&&e.jsx("p",{className:"text-xs text-fg-subtle",role:"status",children:N}),e.jsx(F,{variant:"primary",onClick:D,disabled:N!==void 0,className:"w-full",children:ue(t.scope)}),e.jsx(F,{variant:"ghost",onClick:z,className:"w-full",children:"Not now"})]})]})}const lt=t=>{const s=fe(t);return s!==void 0&&s>=400&&s<500};function Y({title:t,error:s,onRetry:a,reportHref:n}){return e.jsxs("div",{className:"space-y-1",children:[e.jsx(K,{variant:"inline",title:t,error:s,onRetry:lt(s)?void 0:a}),e.jsx("a",{href:n(De(s)),target:"_blank",rel:"noreferrer",className:"text-xs text-accent hover:underline",children:"Report an issue"})]})}const ot=(t,s)=>{const a=he(),n=ge({...je(),onSuccess:()=>{t&&(a.invalidateQueries({queryKey:_e(t)}),s&&a.invalidateQueries({queryKey:be({path:{accountId:t,filterId:s}})}))}}),{mutate:m}=n;return{updateFilter:x.useCallback(j=>{!t||!s||m({path:{accountId:t,filterId:s},body:j})},[t,s,m]),isPending:n.isPending,isSuccess:n.isSuccess,isError:n.isError,error:n.error,reset:n.reset}},ct=t=>({clauses:t.literalClauses.map((a,n)=>({id:`clause-${n}`,field:a.field,value:a.value})),matchOperator:t.matchOperator==="And"?"all":"any",moveMailboxId:t.actionMailboxId!==E?t.actionMailboxId:void 0,labelId:t.actionLabelId!==E?t.actionLabelId:void 0,scope:t.scope==="Temporary"?"until":"standing",until:t.scope==="Temporary"?dt(t.expiresAt):void 0,name:t.name}),dt=t=>{if(!t)return"";const s=Date.parse(t);if(Number.isNaN(s))return"";const a=new Date(s),n=m=>String(m).padStart(2,"0");return`${a.getFullYear()}-${n(a.getMonth()+1)}-${n(a.getDate())}`},X=t=>JSON.stringify({clauses:t.clauses.map(s=>[s.field,s.value]),operator:t.matchOperator,move:t.moveMailboxId??null,label:t.labelId??null}),re=(t,s)=>X(t)!==X(s),Z=t=>JSON.stringify({scope:t.scope==="until"?"until":"standing",until:t.scope==="until"?t.until??"":""}),le=(t,s)=>Z(t)!==Z(s),mt=(t,s)=>{const a={},n=(t.name??"").trim();return n!==(s.name??"").trim()&&(a.name=n),re(t,s)&&(a.matchOperator=t.matchOperator==="all"?"And":"Or",a.literalClauses=t.clauses.map(m=>({field:m.field,value:m.value})),a.actionMailboxId=t.moveMailboxId??E,a.actionLabelId=t.labelId??E),le(t,s)&&(a.scope=t.scope==="until"?"Temporary":"Standing",t.scope==="until"&&(a.expiresAt=Be(t.until??""))),a};function ut({accountId:t,filter:s,folders:a,delimiter:n,labels:m,onClose:f}){const j=x.useMemo(()=>ct(s),[s]),[h,g]=x.useState(j),[o,u]=x.useState(),[y,l]=x.useState(!1),w=x.useRef(0),{count:C}=Ue(t,He(h)),b=ot(t,s.filterId),S=ne(t),{createFolderIn:v}=ve(t),{createLabel:p}=Te(t),r=async c=>{const i=await p(c);return{id:i.labelId,name:i.name,color:i.color}},d=()=>u({mode:"add",draft:{field:V[0],value:""}}),k=c=>{const i=h.clauses.find(R=>R.id===c);i&&u({mode:"edit",clauseId:c,draft:{field:i.field,value:i.value}})},M=c=>u(i=>i&&{...i,draft:{...i.draft,field:c}}),O=c=>u(i=>i&&{...i,draft:{...i.draft,value:c}}),L=()=>{if(!o)return;const c=o.draft.field,i=qe(c,o.draft.value);i!==""&&(g(R=>o.mode==="edit"&&o.clauseId?{...R,clauses:R.clauses.map(U=>U.id===o.clauseId?{id:U.id,field:c,value:i}:U)}:(w.current+=1,{...R,clauses:[...R.clauses,{id:`new-${w.current}`,field:c,value:i}]})),u(void 0))},D=c=>g(i=>({...i,clauses:i.clauses.filter(R=>R.id!==c)})),z=c=>g(i=>({...i,matchOperator:c})),T=c=>g(i=>({...i,moveMailboxId:c||void 0})),$=c=>g(i=>({...i,labelId:c||void 0})),N=c=>g(i=>({...i,name:c})),A=c=>g(i=>({...i,scope:c,until:c==="until"?i.until:void 0})),P=c=>g(i=>({...i,until:c})),I=()=>{const c=re(h,j)||le(h,j),i=mt(h,j);if(Object.keys(i).length===0){f();return}l(c),b.updateFilter(i)},B=()=>S.start(Ke(h));return S.isStarting||S.isRunning||S.isDone?e.jsx(ht,{progress:S.progress,isDone:S.isDone,onClose:f}):b.isPending?e.jsx(xt,{}):b.isError?e.jsx(gt,{onRetry:b.reset,onClose:f}):b.isSuccess?y?e.jsx(ft,{preview:ee(C),blocked:C.status!=="ready"||C.stale===!0,onReapply:B,onClose:f}):e.jsx(pt,{onClose:f}):e.jsx(rt,{rule:h,folders:a,delimiter:n,labels:m,preview:C,clauseFields:V,persisted:!0,clauseEdit:o,onStartAddClause:d,onStartEditClause:k,onRemoveClause:D,onChangeDraftField:M,onChangeDraftValue:O,onSubmitClause:L,onCancelClause:()=>u(void 0),onChangeMatchOperator:z,onChangeMove:T,onCreateFolder:v,onChangeLabel:$,onCreateLabel:r,onChangeName:N,onChangeScope:A,onChangeUntil:P,onCommit:I,onCancel:f})}function xt(){return e.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[e.jsx(_,{className:"size-8 animate-spin text-accent-2"}),e.jsx("p",{className:"text-sm font-medium text-fg",children:"Saving changes…"})]})}function pt({onClose:t}){return e.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[e.jsx(q,{className:"size-8 text-positive"}),e.jsx("p",{className:"text-sm font-medium text-fg",children:"Filter updated"}),e.jsx(F,{variant:"primary",onClick:t,className:"mt-2",children:"Done"})]})}function ft({preview:t,blocked:s,onReapply:a,onClose:n}){return e.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[e.jsx(q,{className:"size-8 text-positive"}),e.jsx("p",{className:"text-sm font-medium text-fg",children:"Rule saved"}),e.jsxs("p",{className:"max-w-xs text-xs text-fg-muted",children:["New mail follows the rule automatically. ",t," — move the mail already in your mailbox too?"]}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx(F,{variant:"primary",onClick:a,disabled:s,children:"Move existing mail"}),e.jsx(F,{variant:"ghost",onClick:n,children:"Not now"})]})]})}function ht({progress:t,isDone:s,onClose:a}){const n=t.state==="Failed";return e.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[s?n?e.jsx("span",{className:"text-sm font-semibold text-danger",children:"Move failed"}):e.jsx(q,{className:"size-8 text-positive"}):e.jsx(_,{className:"size-8 animate-spin text-accent-2"}),!s&&e.jsx("p",{className:"text-sm font-medium text-fg",children:"Moving existing mail…"}),s&&!n&&e.jsxs("div",{className:"text-sm text-fg",children:[e.jsx("p",{className:"font-medium",children:"Done"}),e.jsxs("p",{className:"mt-1 text-xs text-fg-muted",children:[t.appliedCount," of ",t.matchedCount," moved",t.failedCount>0?` · ${t.failedCount} failed`:"","."]})]}),s&&n&&e.jsx("p",{className:"max-w-xs text-xs text-fg-muted",children:t.errorMessage||"Something went wrong. Please try again."}),s&&e.jsx(F,{variant:"primary",onClick:a,className:"mt-2",children:"Done"})]})}function gt({onRetry:t,onClose:s}){return e.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[e.jsx("p",{className:"text-sm font-medium text-danger",children:"Couldn't save changes"}),e.jsx("p",{className:"max-w-xs text-xs text-fg-muted",children:"Please try again."}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx(F,{variant:"primary",onClick:t,children:"Try again"}),e.jsx(F,{variant:"ghost",onClick:s,children:"Not now"})]})]})}function bt({accountId:t,filter:s,folders:a,delimiter:n,labels:m,onClose:f}){const j=Le(),h=e.jsx(ut,{accountId:t,filter:s,folders:a,delimiter:n,labels:m,onClose:f});return j?e.jsx(Ne,{open:!0,onClose:f,title:"Filter rule",children:h}):e.jsx(Ze,{open:!0,onClose:f,label:"Filter rule",dismissLabel:"Dismiss filter rule",children:h})}const jt=t=>{switch(t.kind){case"queuing":case"running":return"Running over the inbox…";case"done":return t.matched===0?"Done. Nothing in the inbox matched.":`Done. Filed ${t.applied} of ${t.matched} matching messages in the inbox.`;case"failed":return}};function vt({filters:t,mailboxName:s,labelById:a,onEdit:n,onDelete:m,deletingFilterId:f,onToggle:j,togglingFilterId:h,onRunNow:g,runFilterId:o,runStatus:u,now:y=Date.now()}){return t.length===0?e.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."}):e.jsx("ul",{className:"divide-y divide-line rounded-md border border-line",children:t.map(l=>{const w=Je(l,y),C=w==="Expired",b=w==="Disabled",S=b?Ve(l):void 0,v=l.actionMailboxId!==E?s(l.actionMailboxId):void 0,p=l.actionLabelId!==E?a.get(l.actionLabelId):void 0,r=Qe(l.expiresAt),d=o===l.filterId?u:void 0,k=d?.kind==="queuing"||d?.kind==="running",M=d?jt(d):void 0,O=w==="Active"&&(l.actionMailboxId!==E||l.actionLabelId!==E);return e.jsxs("li",{className:"flex items-start gap-3 px-3 py-2.5",children:[e.jsxs("button",{type:"button",onClick:()=>n(l.filterId),"aria-label":`Edit filter ${l.name}`,className:"min-w-0 flex-1 rounded-sm text-left hover:opacity-80",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`truncate text-sm font-medium ${C||b?"text-fg-muted":"text-fg"}`,children:l.name}),e.jsx(et,{tone:C?"neutral":b?"warning":"positive",dot:!0,children:w})]}),e.jsxs("p",{className:"mt-0.5 text-xs text-fg-subtle",children:[v?`Moves matches to ${v}`:"No move action",l.scope==="Temporary"&&r?C?` · expired ${r}`:` · until ${r}`:l.scope==="Standing"?" · always":""]}),S&&e.jsx("p",{className:"mt-0.5 text-xs text-warning",children:S}),M&&e.jsx("p",{role:"status",className:"mt-0.5 text-xs text-fg-muted",children:M}),p&&e.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:e.jsx(ie,{label:{labelId:p.id,name:p.name,color:p.color}})})]}),O&&e.jsx(F,{variant:"ghost",size:"sm",onClick:()=>g(l.filterId),disabled:k,"aria-label":`Run now: filter ${l.name}`,children:k?"Running…":"Run now"}),!C&&e.jsx(F,{variant:"ghost",size:"sm",onClick:()=>j(l.filterId,b),disabled:h===l.filterId,"aria-label":`${b?"Turn on":"Turn off"} filter ${l.name}`,children:b?"Turn on":"Turn off"}),e.jsx(F,{variant:"ghost",size:"sm",icon:e.jsx(ye,{className:"size-4 text-danger"}),onClick:()=>m(l.filterId),disabled:f===l.filterId,"aria-label":`Delete filter ${l.name}`})]},l.filterId)})})}function Nt(t){return te(se({title:`Filter toggle: ${t}`,errorMessage:t}))}function yt(t){return te(se({title:`Filter run now: ${t}`,errorMessage:t}))}const Ct=t=>{if(t.failure)return{kind:"failed",error:t.failure.error};if(t.isStarting)return{kind:"queuing"};if(t.isDone)return t.progress.state==="Failed"?{kind:"failed",error:new Error(t.progress.errorMessage||"The run over the inbox failed.")}:{kind:"done",matched:t.progress.matchedCount,applied:t.progress.appliedCount};if(t.isRunning)return{kind:"running"}},St=e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{children:["Filters are the standing rules Organize creates. A"," ",e.jsx("strong",{children:"Standing"})," filter keeps working on new mail; a"," ",e.jsx("strong",{children:"Temporary"})," one stops on its own at the date you picked."]}),e.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."}),e.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 kt({account:t}){const s=t.accountId,{filters:a,isPending:n,isError:m,error:f,refetch:j}=Ge(s),{deleteFilter:h,deletingFilterId:g}=We(s),o=Ye(s),u=ne(s),{startForFilter:y}=u,[l,w]=x.useState(),C=x.useCallback(N=>{w(N),y(N)},[y]),b=Ct(u),[S,v]=x.useState(),{data:p}=ae({...Ce({path:{accountId:s}}),staleTime:1/0}),r=Se(),d=x.useMemo(()=>ke(t.folderAppointments),[t.folderAppointments]),k=x.useCallback(N=>{const A=p?.items.find(P=>P.mailboxId===N);if(A)return we(A,d.get(N),r)},[p?.items,d,r]),M=x.useMemo(()=>Fe({mailboxes:p?.items??[],folderAppointments:t.folderAppointments,translator:r}),[p?.items,t.folderAppointments,r]),O=Ie(p?.items??[]),{labels:L}=Ae(s),D=x.useMemo(()=>L.map(N=>({id:N.labelId,name:N.name,color:N.color})),[L]),z=x.useMemo(()=>new Map(D.map(N=>[N.id,N])),[D]),T=a.find(N=>N.filterId===S),$=a.find(N=>N.filterId===l)?.name;return e.jsxs("section",{className:"space-y-2",children:[e.jsx("h2",{className:"text-sm font-semibold text-fg",children:t.email}),T&&e.jsx(bt,{accountId:s,filter:T,folders:M,delimiter:O,labels:D,onClose:()=>v(void 0)}),n?e.jsx("div",{className:"h-16 animate-pulse rounded-md border border-line bg-surface","aria-busy":"true","aria-label":`Loading filters for ${t.email}`}):m?e.jsx(K,{variant:"inline",title:`Couldn't load filters for ${t.email}`,error:f,onRetry:()=>{j()}}):e.jsxs(e.Fragment,{children:[o.isError&&e.jsx(Y,{title:o.enabling?"Couldn't turn the filter on":"Couldn't turn the filter off",error:o.error,onRetry:o.retry,reportHref:Nt}),l&&b?.kind==="failed"&&e.jsx(Y,{title:`Couldn't run ${$??"the filter"} over the inbox`,error:b.error,onRetry:u.failure?.kind==="statusUnreadable"?u.refreshStatus:()=>C(l),reportHref:yt}),e.jsx(vt,{filters:a,mailboxName:k,labelById:z,onEdit:v,onDelete:h,deletingFilterId:g,onToggle:o.toggleFilter,togglingFilterId:o.togglingFilterId,onRunNow:C,runFilterId:l,runStatus:b})]})]})}function qt(){const t=Me(),s=Re(),[a,n]=x.useState(!0),{data:m,isPending:f,isError:j,error:h,refetch:g}=ae(Ee()),o=u=>{const y=Oe[u];y&&t({to:y})};return e.jsx(tt,{items:s,activeId:"filters",title:"Filters",description:"Standing and temporary rules created by Organize, per account.",help:St,helpOpen:a,onToggleHelp:()=>n(u=>!u),onSelect:o,onBackToMail:()=>{t({to:"/mail"})},children:f?e.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":"Loading accounts"}):j?e.jsx(K,{title:"Couldn't load accounts",error:h,onRetry:()=>{g()}}):m.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:m.accounts.map(u=>e.jsx(kt,{account:u},u.accountId))})})}export{kt as AccountFilters,qt as component};
@@ -1 +1 @@
1
- import{j as r}from"./index-BVIV7uOn.js";import{E as o}from"./ErrorState-KWmymUQR.js";const l=({error:t,reset:e})=>r.jsx("div",{className:"flex h-full items-center justify-center bg-canvas p-4",children:r.jsx(o,{title:"Couldn't load your starred mail",error:t,onRetry:e})});export{l as errorComponent};
1
+ import{j as r}from"./index-X3HUQEvM.js";import{E as o}from"./ErrorState-DD3UfsN8.js";const l=({error:t,reset:e})=>r.jsx("div",{className:"flex h-full items-center justify-center bg-canvas p-4",children:r.jsx(o,{title:"Couldn't load your starred mail",error:t,onRetry:e})});export{l as errorComponent};
@@ -0,0 +1 @@
1
+ import{j as o,O as i}from"./index-X3HUQEvM.js";import{a as m}from"./MailShell-DVTROO5Y.js";import{F as r}from"./FlaggedPane-DLqwSIp0.js";import"./reply-Bs_YhRF4.js";import{a as p}from"./search-token-index-BIZzLNv9.js";import{u as e}from"./search-mirror-DgYKzQ_z.js";import"./useMessageBodyContent-Dhtu6I6l.js";import"./FullCompose-DnUwBsN_.js";import"./index-DjF679iU.js";import"./useSignature-ZAeHuLA5.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-CiTDV7kX.js";import"./suggest-list-Bl5m8GjB.js";import"./sections-CRDaS4nn.js";import"./useMediaQuery-9NJJDrX6.js";import"./chevron-down-B3lcZAVN.js";import"./ErrorState-DD3UfsN8.js";import"./confirm-dialog-CjHvZbGT.js";import"./search-scope-D_Xp19lV.js";import"./app-chrome-Cb3lBdOZ.js";import"./MessageToolbar-bKPOSy0d.js";import"./MessageBody-Bn9CiLsL.js";import"./kbd-DiYloCGE.js";import"./roving-focus-nxbliQos.js";import"./useQueries-BO8eIXDf.js";import"./badge-C-N2Sfyc.js";import"./undo-2-DT3EdJen.js";import"./DropdownMenu-T79mAX3f.js";import"./popover-menu-J56UZVjI.js";import"./mail-CDuFGyaA.js";import"./download-DCGyf3W_.js";import"./avatar-COUm7SBG.js";import"./EmptyState-CA538vCg.js";import"./calendar-suggestion-DVjK0aSt.js";import"./useCalendarSuggestions-BLiBIz-1.js";import"./agenda-time-C_THqiEa.js";import"./sparkles-DrZ81rOU.js";import"./plus-GnqfNmfx.js";import"./calendar-format-BwCpz-JZ.js";import"./calendar-BYyDHpZa.js";import"./calendar-failure-note-C9fIL_8K.js";import"./checkbox-jLurGcNS.js";import"./clock-CNuf0kus.js";import"./segmented-control-DFN0EF39.js";import"./shield-check-DZBDPqGc.js";import"./useLayoutTier-B5_piqNJ.js";import"./menu-v-YxaQQ_.js";import"./useFilters-D_mEdyEH.js";import"./select-DaBof-xM.js";import"./folder-input-CmDkygvp.js";import"./label-chip-tLLbdHoz.js";import"./cloud-off-C48CGroa.js";import"./MailViewChrome-BXIIRW1m.js";import"./refresh-cw-3jpeaUi7.js";import"./wizard-selection-zWa1qc6-.js";function so(){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{so as component};
@@ -1 +1 @@
1
- import{b as a}from"./index-BVIV7uOn.js";const e=a("FolderInput",[["path",{d:"M2 9V5a2 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 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1",key:"fm4g5t"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m9 16 3-3-3-3",key:"6m91ic"}]]);export{e as F};
1
+ import{b as a}from"./index-X3HUQEvM.js";const e=a("FolderInput",[["path",{d:"M2 9V5a2 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 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1",key:"fm4g5t"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m9 16 3-3-3-3",key:"6m91ic"}]]);export{e as F};
@@ -1 +1 @@
1
- import{j as e,B as y,T as B,b3 as W,r as c,ax as Y,X,aE as he,ak as Z,F as xe,bb as K,bc as fe,am as pe,d as z,bd as ge,be,e as J,a0 as ee,k as se,bf as ve,bg as je,aD as ye,$ as Ne,bh as ke,bi as _,bj as Ce,bk as we,bl as te,bm as Se,bn as Q,b7 as ae,b8 as re,b9 as Ie,W as q,V as ne,L as H,bo as G,a9 as Me,bp as Ee,u as De,az as Ae,a as ie,c as Oe,aB as Te,R as Re,f as V,s as Fe,bq as Pe,br as $e,bs as Le,bt as ze,bu as _e,bv as Be}from"./index-BVIV7uOn.js";import{F as qe}from"./folder-input-v9jv3QvB.js";import{f as He}from"./folder-failure-CqkVSsrb.js";import{S as Ke}from"./settings-screen-FlCW-JB0.js";import{E as oe}from"./ErrorState-KWmymUQR.js";import{S as Qe}from"./select-CU_oR6rc.js";import{P as Ge}from"./pencil-D4t_TOKs.js";import"./avatar-BKCZjVnK.js";import"./badge-BmEPIQJj.js";import"./chevron-left-BQBw-0xj.js";import"./menu-Cul_tOCl.js";import"./circle-help-BSxYNH4r.js";import"./chevron-down-BI1fWP0V.js";const Ve=({label:s,onRename:t,onDelete:a,deleteBlockedReason:l,renameLabel:d=m=>`Rename ${m}`,deleteLabel:r=m=>`Delete ${m}`})=>{const m=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(Ge,{className:"size-3.5"}),"aria-label":d(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":m,disabled:l!==void 0,onClick:a})})]})},Ue=({folders:s,onRename:t,onDelete:a,onCreateFolder:l,delimiter:d,labels:r})=>{const m=new Map(s.map(o=>[o.id,o]));return e.jsx(W,{folders:s,onCreateFolder:l,delimiter:d,labels:{treeAriaLabel:"Your folders",optionLabel:o=>o.label,...r},rowFailure:o=>m.get(o.id)?.failure,rowActions:o=>{const i=m.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}})},We=({open:s,folderLabel:t,defaultLabel:a,name:l,onNameChange:d,onSubmit:r,onClose:m,pending:o=!1,error:i})=>{const h=c.useId(),f=`Rename ${t}`;return s?e.jsxs(Y,{open:s,onClose:m,title:f,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:f}),e.jsx(y,{variant:"ghost",size:"sm",icon:e.jsx(X,{className:"size-3.5"}),onClick:m,"aria-label":"Cancel"})]}),e.jsxs("div",{className:"space-y-3 px-5 py-4",children:[e.jsxs("div",{children:[e.jsx(he,{htmlFor:h,children:"Folder name"}),e.jsx(Z,{id:h,value:l,placeholder:a,onChange:g=>d(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:m,children:"Cancel"}),e.jsx(y,{variant:"primary",size:"sm",onClick:r,disabled:o,children:o?"Saving…":"Save name"})]})]}):null},Ye=["inbox","drafts","sent","archive","junk","trash"],U="",Xe={mailboxId:null,source:"None"};function Ze(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"}`,Je=(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:d,onRename:r}){const[m,o]=c.useState(l),i=c.useRef(null),h=c.useRef(!1),f=c.useId(),{mailboxId:g,source:v,staleFolderPath:j}=a,u=t.find(N=>N.mailboxId===g)??null,p=ge(s),O=u!=null&&m.trim()!==l.trim();c.useEffect(()=>{!h.current||v==="Proposed"||(h.current=!1,i.current?.focus())},[v]);const M=(()=>{if(v==="None"){const N=s==="trash"?" Deleting mail needs one.":"";return e.jsx("span",{id:f,className:"pl-[7.5rem] text-xs text-fg-muted",children:`Not set — pick the folder this account uses for ${p}.${N}`})}return v==="Stale"||!u?null:e.jsx("span",{id:f,className:"truncate pl-[7.5rem] text-2xs text-fg-subtle",title:u.providerPath,children:`${Je(v,p)} · ${u.providerPath} · ${le(u.messageCount)}`})})(),w=s==="trash"?" Deleting mail is stopped until you pick another one.":u?` reader is using ${K(u.providerPath,u.hierarchyDelimiter)} instead.`:"",A=`The folder you chose for ${p}${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),p]}),e.jsxs(Qe,{ref:i,className:"w-56 shrink-0",value:u?.mailboxId??U,"aria-label":`Folder for ${p}`,"aria-describedby":M||v==="Stale"?f:void 0,onChange:N=>d(s,N.target.value),children:[!u&&e.jsx("option",{value:U,disabled:!0,children:"Choose a folder"}),t.map(N=>e.jsx("option",{value:N.mailboxId,children:Ze(N)},N.mailboxId))]}),v==="Proposed"&&u&&e.jsx(y,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>{h.current=!0,d(s,u.mailboxId)},children:`Set as ${p}`}),u&&e.jsxs(e.Fragment,{children:[e.jsx(Z,{className:"flex-1",value:m,placeholder:p,"aria-label":`Display name for ${p}`,onChange:N=>o(N.target.value)}),O&&e.jsx(y,{variant:"ghost",size:"sm",className:"shrink-0",icon:e.jsx(pe,{className:"size-4"}),"aria-label":"Save display name",onClick:()=>r(u.mailboxId,m)})]})]}),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:f,className:"flex-1",children:A}),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:d,onRename:r}){const m=new Set(Object.values(a).map(i=>i.mailboxId).filter(i=>i!=null)),o=t.filter(i=>!m.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:Ye.map(i=>{const h=a[i]??Xe;return e.jsx(es,{role:i,folders:t,appointment:h,displayName:h.mailboxId?l[h.mailboxId]??"":"",onAppoint:d,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:d=as,pollIntervalMs:r=rs,delay:m=be,now:o=Date.now}){const i=o()+d;for(;;){l?.throwIfAborted();const h=ce(await s(),t);if((h.lastSyncedAt??0)>a)return{status:"fresh",messageCount:h.messagesTotal};if(o()>=i)return{status:"pending"};await m(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 d=[];let r;for(let m=0;m<de;m+=1){if(l.aborted)return d;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)&&!d.includes(i.messageId)&&(d.push(i.messageId),d.length>=a))return d;if(!o.continuationToken)break;r=o.continuationToken}return d},ds=async(s,t)=>{let a=0,l;for(let d=0;d<de;d+=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=J(),[d,r]=c.useState("idle"),[m,o]=c.useState(null),[i,h]=c.useState(),[f,g]=c.useState(),v=c.useRef(null),j=c.useRef(void 0),u=c.useCallback(()=>{l.invalidateQueries({queryKey:ee({path:{accountId:s}})}),l.invalidateQueries({queryKey:se()})},[l,s]),p=c.useCallback(async()=>{r("deleting");const k=await $(ve({path:{accountId:s,mailboxId:t},throwOnError:!0}));if(!k.ok){h(k.error),r("error");return}u(),r("done"),a()},[s,t,u,a]),O=c.useCallback(()=>je({path:{accountId:s},throwOnError:!0}).then(({data:k})=>k.items.find(S=>S.mailboxId===t)?.messageCount??0),[s,t]),M=c.useCallback(()=>l.fetchQuery({...ye({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"),h(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 Ne({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"),u(),{status:"blocked",messageCount:C.value.messageCount}):(await p(),{status:"deleted"})):(j.current=void 0,h(C.error),r("error"),{status:"failed"})},[s,t,M,p,u]),A=c.useCallback(()=>{v.current?.abort()},[]),N=c.useCallback(async k=>{const S=new AbortController;v.current=S;const{signal:I}=S;r("moving"),h(void 0);const C=await $(O());if(I.aborted)return;if(!C.ok){h(C.error),r("error");return}let x=ke(C.value);o(x);const E=new Set;for(;;){if(I.aborted)return;const n=await $(cs(t,E,Se,I));if(I.aborted)return;if(!n.ok){x=_(x,n.error),o(x),h(n.error),r("error");return}const b=n.value;if(b.length===0)break;const T=await $(Ce({body:{messageIds:b,destinationMailboxId:k},throwOnError:!0}));if(I.aborted)return;if(!T.ok){x=_(x,T.error),o(x),h(T.error),r("error");return}for(const P of b)E.add(P);x=we(x,b.length),o(x)}const D=await $(ds(t,I));if(!I.aborted){if(!D.ok){x=_(x,D.error),o(x),h(D.error),r("error");return}if(D.value>0){const n=`${D.value} ${D.value===1?"email is":"emails are"} still syncing. Re-open delete to finish removing this folder.`;x=_(x,n),o(x),h(n),r("error"),u();return}await p()}},[t,O,p,u]),R=c.useCallback(()=>{v.current?.abort(),v.current=null,j.current=void 0,r("idle"),o(null),h(void 0),g(void 0)},[]);return{phase:d,progress:m,errorMessage:i,checkStartedAt:f,deleteMailbox:p,deleteIfEmpty:w,moveThenDelete:N,cancel:A,reset:R}}const L=s=>`${s} ${s===1?"email":"emails"}`;function us({open:s,accountId:t,folder:a,mailboxes:l,appointments:d,onClose:r}){const[m,o]=c.useState(()=>Q(a.messageCount)),[i,h]=c.useState(),[f,g]=c.useState(),{createFolderIn:v}=ae(t),j=re(),{phase:u,progress:p,errorMessage:O,checkStartedAt:M,deleteMailbox:w,deleteIfEmpty:A,moveThenDelete:N,cancel:R,reset:k}=ms({accountId:t,mailboxId:a.mailboxId,onDeleted:r}),[S,I]=c.useState("0:00"),C=u==="checking"||u==="check-stalled";c.useEffect(()=>{if(!C||M===void 0)return;const F=()=>I(Ee(Date.now()-M));F();const ue=setInterval(F,1e3);return()=>clearInterval(ue)},[C,M]),c.useEffect(()=>{s&&(o(Q(a.messageCount)),h(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 A();F.status==="blocked"&&(h(F.messageCount),o("choose-fate"))},[A]),D=c.useMemo(()=>Ie({mailboxes:l,folderAppointments:d,excludeMailboxId:a.mailboxId,translator:j}),[l,d,a.mailboxId,j]),n=D.find(F=>F.id===f),b=c.useMemo(()=>q(a,ne(d).get(a.mailboxId),j),[a,d,j]);if(!s)return null;const T=`Delete ${b}`,P=i??a.messageCount,me=u==="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:p?G(p):"Moved 0 of 0"})]}):u==="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.`})]}):u==="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"})]})]}):u==="deleting"||u==="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…"})]}):u==="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."}),p&&e.jsxs("p",{className:"text-xs text-fg-muted",children:[G(p),". 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"})})]}):m==="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"})]})]}):m==="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(qe,{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"})})]}):m==="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(W,{folders:D,selectedId:f,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(Y,{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(Me,{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=J(),a=s.accountId,l=re(),{data:d,isPending:r,isError:m,error:o,refetch:i}=ie(Re({path:{accountId:a}})),{createFolderIn:h}=ae(a),f=V({...Pe(),meta:Fe(409),onSuccess:()=>{t.invalidateQueries({queryKey:se()})}}),g=V({...$e(),onSuccess:()=>{t.invalidateQueries({queryKey:ee({path:{accountId:a}})})}}),[v,j]=c.useState(),[u,p]=c.useState(),[O,M]=c.useState(""),w=c.useMemo(()=>d?.items??[],[d]),A=c.useMemo(()=>ne(s.folderAppointments),[s.folderAppointments]),N=c.useMemo(()=>w.map(n=>({id:n.mailboxId,label:q(n,A.get(n.mailboxId),l),path:n.fullPath,deleteBlockedReason:Le(n,w,s.folderAppointments).message,failure:He(n)})),[w,A,l,s.folderAppointments]),R=(n,b)=>{f.mutate({path:{accountId:a,role:Be[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(m)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=ze[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(u),D=x(v);return e.jsxs("div",{className:"space-y-4",children:[(f.isError||g.isError)&&e.jsx(z,{tone:"danger",variant:"soft",children:_e(f.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:h,onRename:n=>{p(n.id),M(x(n.id)?.displayNameOverride?.trim()??"")},onDelete:n=>j(n.id),labels:{treeAriaLabel:`All folders for ${s.email}`}})})]}),E&&e.jsx(We,{open:!0,folderLabel:q(E,A.get(E.mailboxId),l),defaultLabel:q({fullPath:E.fullPath,hierarchyDelimiter:E.hierarchyDelimiter},A.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:()=>p(void 0)})},onClose:()=>p(void 0)}),D&&e.jsx(us,{open:!0,accountId:a,folder:D,mailboxes:w,appointments:s.folderAppointments,onClose:()=>j(void 0)})]})}function Is(){const s=De(),t=Ae(),[a,l]=c.useState(!0),{data:d,isPending:r,isError:m,error:o,refetch:i}=ie(Oe()),h=f=>{const g=Te[f];g&&s({to:g})};return e.jsx(Ke,{items:t,activeId:"folders",title:"Folder roles",description:"Appoint which real folder fills each canonical role, per account.",help:e.jsx(ss,{}),helpOpen:a,onToggleHelp:()=>l(f=>!f),onSelect:h,onBackToMail:()=>{s({to:"/mail"})},children:r?e.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":"Loading accounts"}):m?e.jsx(oe,{title:"Couldn't load accounts",error:o,onRetry:()=>{i()}}):d.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:d.accounts.map(f=>e.jsx(hs,{account:f},f.accountId))})})}export{Is as component};
1
+ import{j as e,B as y,T as B,b3 as W,r as c,ax as Y,X,aE as he,ak as Z,F as xe,bb as K,bc as fe,am as pe,d as z,bd as ge,be,e as J,a0 as ee,k as se,bf as ve,bg as je,aD as ye,$ as Ne,bh as ke,bi as _,bj as Ce,bk as we,bl as te,bm as Se,bn as Q,b7 as ae,b8 as re,b9 as Ie,W as q,V as ne,L as H,bo as G,a9 as Me,bp as Ee,u as De,az as Ae,a as ie,c as Oe,aB as Te,R as Re,f as V,s as Fe,bq as Pe,br as $e,bs as Le,bt as ze,bu as _e,bv as Be}from"./index-X3HUQEvM.js";import{F as qe}from"./folder-input-CmDkygvp.js";import{f as He}from"./folder-failure-CqkVSsrb.js";import{S as Ke}from"./settings-screen-DU3TjNi2.js";import{E as oe}from"./ErrorState-DD3UfsN8.js";import{S as Qe}from"./select-DaBof-xM.js";import{P as Ge}from"./pencil-BnBK7tmS.js";import"./avatar-COUm7SBG.js";import"./badge-C-N2Sfyc.js";import"./chevron-left-B-i0rFYx.js";import"./menu-v-YxaQQ_.js";import"./circle-help-C9O6dqh6.js";import"./chevron-down-B3lcZAVN.js";const Ve=({label:s,onRename:t,onDelete:a,deleteBlockedReason:l,renameLabel:d=m=>`Rename ${m}`,deleteLabel:r=m=>`Delete ${m}`})=>{const m=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(Ge,{className:"size-3.5"}),"aria-label":d(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":m,disabled:l!==void 0,onClick:a})})]})},Ue=({folders:s,onRename:t,onDelete:a,onCreateFolder:l,delimiter:d,labels:r})=>{const m=new Map(s.map(o=>[o.id,o]));return e.jsx(W,{folders:s,onCreateFolder:l,delimiter:d,labels:{treeAriaLabel:"Your folders",optionLabel:o=>o.label,...r},rowFailure:o=>m.get(o.id)?.failure,rowActions:o=>{const i=m.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}})},We=({open:s,folderLabel:t,defaultLabel:a,name:l,onNameChange:d,onSubmit:r,onClose:m,pending:o=!1,error:i})=>{const h=c.useId(),f=`Rename ${t}`;return s?e.jsxs(Y,{open:s,onClose:m,title:f,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:f}),e.jsx(y,{variant:"ghost",size:"sm",icon:e.jsx(X,{className:"size-3.5"}),onClick:m,"aria-label":"Cancel"})]}),e.jsxs("div",{className:"space-y-3 px-5 py-4",children:[e.jsxs("div",{children:[e.jsx(he,{htmlFor:h,children:"Folder name"}),e.jsx(Z,{id:h,value:l,placeholder:a,onChange:g=>d(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:m,children:"Cancel"}),e.jsx(y,{variant:"primary",size:"sm",onClick:r,disabled:o,children:o?"Saving…":"Save name"})]})]}):null},Ye=["inbox","drafts","sent","archive","junk","trash"],U="",Xe={mailboxId:null,source:"None"};function Ze(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"}`,Je=(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:d,onRename:r}){const[m,o]=c.useState(l),i=c.useRef(null),h=c.useRef(!1),f=c.useId(),{mailboxId:g,source:v,staleFolderPath:j}=a,u=t.find(N=>N.mailboxId===g)??null,p=ge(s),O=u!=null&&m.trim()!==l.trim();c.useEffect(()=>{!h.current||v==="Proposed"||(h.current=!1,i.current?.focus())},[v]);const M=(()=>{if(v==="None"){const N=s==="trash"?" Deleting mail needs one.":"";return e.jsx("span",{id:f,className:"pl-[7.5rem] text-xs text-fg-muted",children:`Not set — pick the folder this account uses for ${p}.${N}`})}return v==="Stale"||!u?null:e.jsx("span",{id:f,className:"truncate pl-[7.5rem] text-2xs text-fg-subtle",title:u.providerPath,children:`${Je(v,p)} · ${u.providerPath} · ${le(u.messageCount)}`})})(),w=s==="trash"?" Deleting mail is stopped until you pick another one.":u?` reader is using ${K(u.providerPath,u.hierarchyDelimiter)} instead.`:"",A=`The folder you chose for ${p}${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),p]}),e.jsxs(Qe,{ref:i,className:"w-56 shrink-0",value:u?.mailboxId??U,"aria-label":`Folder for ${p}`,"aria-describedby":M||v==="Stale"?f:void 0,onChange:N=>d(s,N.target.value),children:[!u&&e.jsx("option",{value:U,disabled:!0,children:"Choose a folder"}),t.map(N=>e.jsx("option",{value:N.mailboxId,children:Ze(N)},N.mailboxId))]}),v==="Proposed"&&u&&e.jsx(y,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>{h.current=!0,d(s,u.mailboxId)},children:`Set as ${p}`}),u&&e.jsxs(e.Fragment,{children:[e.jsx(Z,{className:"flex-1",value:m,placeholder:p,"aria-label":`Display name for ${p}`,onChange:N=>o(N.target.value)}),O&&e.jsx(y,{variant:"ghost",size:"sm",className:"shrink-0",icon:e.jsx(pe,{className:"size-4"}),"aria-label":"Save display name",onClick:()=>r(u.mailboxId,m)})]})]}),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:f,className:"flex-1",children:A}),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:d,onRename:r}){const m=new Set(Object.values(a).map(i=>i.mailboxId).filter(i=>i!=null)),o=t.filter(i=>!m.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:Ye.map(i=>{const h=a[i]??Xe;return e.jsx(es,{role:i,folders:t,appointment:h,displayName:h.mailboxId?l[h.mailboxId]??"":"",onAppoint:d,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:d=as,pollIntervalMs:r=rs,delay:m=be,now:o=Date.now}){const i=o()+d;for(;;){l?.throwIfAborted();const h=ce(await s(),t);if((h.lastSyncedAt??0)>a)return{status:"fresh",messageCount:h.messagesTotal};if(o()>=i)return{status:"pending"};await m(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 d=[];let r;for(let m=0;m<de;m+=1){if(l.aborted)return d;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)&&!d.includes(i.messageId)&&(d.push(i.messageId),d.length>=a))return d;if(!o.continuationToken)break;r=o.continuationToken}return d},ds=async(s,t)=>{let a=0,l;for(let d=0;d<de;d+=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=J(),[d,r]=c.useState("idle"),[m,o]=c.useState(null),[i,h]=c.useState(),[f,g]=c.useState(),v=c.useRef(null),j=c.useRef(void 0),u=c.useCallback(()=>{l.invalidateQueries({queryKey:ee({path:{accountId:s}})}),l.invalidateQueries({queryKey:se()})},[l,s]),p=c.useCallback(async()=>{r("deleting");const k=await $(ve({path:{accountId:s,mailboxId:t},throwOnError:!0}));if(!k.ok){h(k.error),r("error");return}u(),r("done"),a()},[s,t,u,a]),O=c.useCallback(()=>je({path:{accountId:s},throwOnError:!0}).then(({data:k})=>k.items.find(S=>S.mailboxId===t)?.messageCount??0),[s,t]),M=c.useCallback(()=>l.fetchQuery({...ye({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"),h(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 Ne({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"),u(),{status:"blocked",messageCount:C.value.messageCount}):(await p(),{status:"deleted"})):(j.current=void 0,h(C.error),r("error"),{status:"failed"})},[s,t,M,p,u]),A=c.useCallback(()=>{v.current?.abort()},[]),N=c.useCallback(async k=>{const S=new AbortController;v.current=S;const{signal:I}=S;r("moving"),h(void 0);const C=await $(O());if(I.aborted)return;if(!C.ok){h(C.error),r("error");return}let x=ke(C.value);o(x);const E=new Set;for(;;){if(I.aborted)return;const n=await $(cs(t,E,Se,I));if(I.aborted)return;if(!n.ok){x=_(x,n.error),o(x),h(n.error),r("error");return}const b=n.value;if(b.length===0)break;const T=await $(Ce({body:{messageIds:b,destinationMailboxId:k},throwOnError:!0}));if(I.aborted)return;if(!T.ok){x=_(x,T.error),o(x),h(T.error),r("error");return}for(const P of b)E.add(P);x=we(x,b.length),o(x)}const D=await $(ds(t,I));if(!I.aborted){if(!D.ok){x=_(x,D.error),o(x),h(D.error),r("error");return}if(D.value>0){const n=`${D.value} ${D.value===1?"email is":"emails are"} still syncing. Re-open delete to finish removing this folder.`;x=_(x,n),o(x),h(n),r("error"),u();return}await p()}},[t,O,p,u]),R=c.useCallback(()=>{v.current?.abort(),v.current=null,j.current=void 0,r("idle"),o(null),h(void 0),g(void 0)},[]);return{phase:d,progress:m,errorMessage:i,checkStartedAt:f,deleteMailbox:p,deleteIfEmpty:w,moveThenDelete:N,cancel:A,reset:R}}const L=s=>`${s} ${s===1?"email":"emails"}`;function us({open:s,accountId:t,folder:a,mailboxes:l,appointments:d,onClose:r}){const[m,o]=c.useState(()=>Q(a.messageCount)),[i,h]=c.useState(),[f,g]=c.useState(),{createFolderIn:v}=ae(t),j=re(),{phase:u,progress:p,errorMessage:O,checkStartedAt:M,deleteMailbox:w,deleteIfEmpty:A,moveThenDelete:N,cancel:R,reset:k}=ms({accountId:t,mailboxId:a.mailboxId,onDeleted:r}),[S,I]=c.useState("0:00"),C=u==="checking"||u==="check-stalled";c.useEffect(()=>{if(!C||M===void 0)return;const F=()=>I(Ee(Date.now()-M));F();const ue=setInterval(F,1e3);return()=>clearInterval(ue)},[C,M]),c.useEffect(()=>{s&&(o(Q(a.messageCount)),h(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 A();F.status==="blocked"&&(h(F.messageCount),o("choose-fate"))},[A]),D=c.useMemo(()=>Ie({mailboxes:l,folderAppointments:d,excludeMailboxId:a.mailboxId,translator:j}),[l,d,a.mailboxId,j]),n=D.find(F=>F.id===f),b=c.useMemo(()=>q(a,ne(d).get(a.mailboxId),j),[a,d,j]);if(!s)return null;const T=`Delete ${b}`,P=i??a.messageCount,me=u==="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:p?G(p):"Moved 0 of 0"})]}):u==="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.`})]}):u==="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"})]})]}):u==="deleting"||u==="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…"})]}):u==="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."}),p&&e.jsxs("p",{className:"text-xs text-fg-muted",children:[G(p),". 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"})})]}):m==="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"})]})]}):m==="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(qe,{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"})})]}):m==="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(W,{folders:D,selectedId:f,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(Y,{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(Me,{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=J(),a=s.accountId,l=re(),{data:d,isPending:r,isError:m,error:o,refetch:i}=ie(Re({path:{accountId:a}})),{createFolderIn:h}=ae(a),f=V({...Pe(),meta:Fe(409),onSuccess:()=>{t.invalidateQueries({queryKey:se()})}}),g=V({...$e(),onSuccess:()=>{t.invalidateQueries({queryKey:ee({path:{accountId:a}})})}}),[v,j]=c.useState(),[u,p]=c.useState(),[O,M]=c.useState(""),w=c.useMemo(()=>d?.items??[],[d]),A=c.useMemo(()=>ne(s.folderAppointments),[s.folderAppointments]),N=c.useMemo(()=>w.map(n=>({id:n.mailboxId,label:q(n,A.get(n.mailboxId),l),path:n.fullPath,deleteBlockedReason:Le(n,w,s.folderAppointments).message,failure:He(n)})),[w,A,l,s.folderAppointments]),R=(n,b)=>{f.mutate({path:{accountId:a,role:Be[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(m)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=ze[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(u),D=x(v);return e.jsxs("div",{className:"space-y-4",children:[(f.isError||g.isError)&&e.jsx(z,{tone:"danger",variant:"soft",children:_e(f.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:h,onRename:n=>{p(n.id),M(x(n.id)?.displayNameOverride?.trim()??"")},onDelete:n=>j(n.id),labels:{treeAriaLabel:`All folders for ${s.email}`}})})]}),E&&e.jsx(We,{open:!0,folderLabel:q(E,A.get(E.mailboxId),l),defaultLabel:q({fullPath:E.fullPath,hierarchyDelimiter:E.hierarchyDelimiter},A.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:()=>p(void 0)})},onClose:()=>p(void 0)}),D&&e.jsx(us,{open:!0,accountId:a,folder:D,mailboxes:w,appointments:s.folderAppointments,onClose:()=>j(void 0)})]})}function Is(){const s=De(),t=Ae(),[a,l]=c.useState(!0),{data:d,isPending:r,isError:m,error:o,refetch:i}=ie(Oe()),h=f=>{const g=Te[f];g&&s({to:g})};return e.jsx(Ke,{items:t,activeId:"folders",title:"Folder roles",description:"Appoint which real folder fills each canonical role, per account.",help:e.jsx(ss,{}),helpOpen:a,onToggleHelp:()=>l(f=>!f),onSelect:h,onBackToMail:()=>{s({to:"/mail"})},children:r?e.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":"Loading accounts"}):m?e.jsx(oe,{title:"Couldn't load accounts",error:o,onRetry:()=>{i()}}):d.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:d.accounts.map(f=>e.jsx(hs,{account:f},f.accountId))})})}export{Is as component};
@@ -1 +1 @@
1
- import{j as e}from"./index-BVIV7uOn.js";import{K as s}from"./kbd-CD9WJQDD.js";const a=e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"VIP"})," senders get priority surface in the daily brief and notification escalation, even when an account is quiet."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Muted"})," senders never notify and stay out of the brief. Their mail still syncs and stays searchable."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Blocked"})," senders never load images and go straight to junk."]}),e.jsxs("p",{children:["Tip: flag from the keyboard on any message — ",e.jsx(s,{children:"v"})," VIP,"," ",e.jsx(s,{children:"m"})," mute, ",e.jsx(s,{children:"b"})," block. Every rule an automation creates shows up here and can be removed."]})]}),r=e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Sync health"})," shows the IMAP connection state and the last successful sync per account."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Error"})," means the last connection attempt failed — the raw server response is shown on the card. Reconnect re-runs the connection test from the add-account wizard."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Muted"})," accounts keep syncing but stay out of the daily brief and unified counts."]})]}),c=e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Density"})," controls how much information fits on screen. Compact is great on smaller displays; Comfortable gives each item more breathing room."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Theme"})," switches between light, dark, and system-preference modes instantly. The change takes effect across the whole app immediately."]}),e.jsx("p",{className:"text-2xs text-fg-subtle",children:"Preferences are stored locally in this browser. Server-side sync is coming soon."})]}),i=e.jsx("div",{className:"space-y-3",children:e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Notification rules"})," and data export are coming in a future release."]})}),o=e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{children:["A message that fails to sync three times shows here. A"," ",e.jsx("strong",{className:"text-fg",children:"retrying"})," one is tried again every sync; a body that ",e.jsx("strong",{className:"text-fg",children:"gave up"})," is not. Either leaves the list once it syncs."]}),e.jsxs("p",{children:["A message Remit cannot read is"," ",e.jsx("strong",{className:"text-fg",children:"set aside"})," rather than skipped, and the folder keeps syncing. Setting one aside is a defect in Remit, so every entry can be reported with the diagnostics already attached."]}),e.jsx("p",{children:"A report carries no folder name, subject, address, message content or error text."})]});export{r as a,i as b,c,a as s,o as w};
1
+ import{j as e}from"./index-X3HUQEvM.js";import{K as s}from"./kbd-DiYloCGE.js";const a=e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"VIP"})," senders get priority surface in the daily brief and notification escalation, even when an account is quiet."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Muted"})," senders never notify and stay out of the brief. Their mail still syncs and stays searchable."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Blocked"})," senders never load images and go straight to junk."]}),e.jsxs("p",{children:["Tip: flag from the keyboard on any message — ",e.jsx(s,{children:"v"})," VIP,"," ",e.jsx(s,{children:"m"})," mute, ",e.jsx(s,{children:"b"})," block. Every rule an automation creates shows up here and can be removed."]})]}),r=e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Sync health"})," shows the IMAP connection state and the last successful sync per account."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Error"})," means the last connection attempt failed — the raw server response is shown on the card. Reconnect re-runs the connection test from the add-account wizard."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Muted"})," accounts keep syncing but stay out of the daily brief and unified counts."]})]}),c=e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Density"})," controls how much information fits on screen. Compact is great on smaller displays; Comfortable gives each item more breathing room."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Theme"})," switches between light, dark, and system-preference modes instantly. The change takes effect across the whole app immediately."]}),e.jsx("p",{className:"text-2xs text-fg-subtle",children:"Preferences are stored locally in this browser. Server-side sync is coming soon."})]}),i=e.jsx("div",{className:"space-y-3",children:e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Notification rules"})," and data export are coming in a future release."]})}),o=e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{children:["A message that fails to sync three times shows here. A"," ",e.jsx("strong",{className:"text-fg",children:"retrying"})," one is tried again every sync; a body that ",e.jsx("strong",{className:"text-fg",children:"gave up"})," is not. Either leaves the list once it syncs."]}),e.jsxs("p",{children:["A message Remit cannot read is"," ",e.jsx("strong",{className:"text-fg",children:"set aside"})," rather than skipped, and the folder keeps syncing. Setting one aside is a defect in Remit, so every entry can be reported with the diagnostics already attached."]}),e.jsx("p",{children:"A report carries no folder name, subject, address, message content or error text."})]});export{r as a,i as b,c,a as s,o as w};