@remit/web-client-dist 0.0.671 → 0.0.672

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 (176) hide show
  1. package/assets/BriefPane-B6R3KmQZ.js +1 -0
  2. package/assets/CalendarComposePane-QYpMNL9q.js +1 -0
  3. package/assets/{CalendarComposeSeed-sw3-kicN.js → CalendarComposeSeed-C9w7BCjb.js} +1 -1
  4. package/assets/{CalendarShell-DhpD8MqL.js → CalendarShell-DhMfxOKQ.js} +1 -1
  5. package/assets/{EmptyState-BvdGNd01.js → EmptyState-Lplntbv_.js} +1 -1
  6. package/assets/{ErrorState-C-GqtxHT.js → ErrorState-U7sVw9dY.js} +1 -1
  7. package/assets/FlaggedPane-IbpzjKsY.js +1 -0
  8. package/assets/{FullCompose-B7Gvo6hb.js → FullCompose-C97Y0rHa.js} +1 -1
  9. package/assets/LabelApplyTrigger-MvfgBk5z.js +1 -0
  10. package/assets/{MailNav-DLpm1pnY.js → MailNav-DVs9SxH3.js} +1 -1
  11. package/assets/{MailShell-CsFJTXUG.js → MailShell-YyCoPjof.js} +1 -1
  12. package/assets/{MailViewChrome-CjK9Dnpp.js → MailViewChrome-Dh-GY2tA.js} +1 -1
  13. package/assets/MailboxPane-bFOldx9r.js +1 -0
  14. package/assets/{useSearchTokenContext-PpLW_UHw.js → MessageBody-C676rd7J.js} +2 -2
  15. package/assets/MessageToolbar-BxFKpYvj.js +1 -0
  16. package/assets/{NavMenuButton-8KfNqFDk.js → NavMenuButton-CIu2PlpX.js} +1 -1
  17. package/assets/{OnboardingWizard-VEiZ5SiP.js → OnboardingWizard-DMYpSH3N.js} +1 -1
  18. package/assets/{OpenCalendarEvent-lS6fjUiq.js → OpenCalendarEvent-Cqy0hp_A.js} +2 -2
  19. package/assets/OutboxPane-BRXDNKGE.js +1 -0
  20. package/assets/{SignInAgain-DH1Fdj-N.js → SignInAgain-PV_y3RtI.js} +1 -1
  21. package/assets/_calendarObjectId-C554QO4A.js +1 -0
  22. package/assets/_mailboxId-CP2xm7mJ.js +1 -0
  23. package/assets/_messageId-Co-XhbCe.js +1 -0
  24. package/assets/_messageId-Dm-cFvWc.js +1 -0
  25. package/assets/_messageId-qftp2SP8.js +1 -0
  26. package/assets/_outboxMessageId-BxIJdt9e.js +1 -0
  27. package/assets/_recurrenceId-DygnfvYv.js +1 -0
  28. package/assets/_threadId-CPjiITcE.js +1 -0
  29. package/assets/_threadId-D5zlF-gr.js +1 -0
  30. package/assets/_threadId-DftsiPw3.js +1 -0
  31. package/assets/_view._date-Dt8xCWQ_.js +1 -0
  32. package/assets/{accounts-CjiarZXs.js → accounts-D-wXF-E_.js} +1 -1
  33. package/assets/{advanced-SAvf5P8v.js → advanced-BoeTrbqE.js} +1 -1
  34. package/assets/{appearance-CUPwkBCw.js → appearance-DrAyJE0x.js} +1 -1
  35. package/assets/{attendee-row-D_Iu4VYw.js → attendee-row-CfV-VGdv.js} +1 -1
  36. package/assets/{avatar-ByFhyZLr.js → avatar-DPq_EAZk.js} +1 -1
  37. package/assets/{bell-off-C0wHlgOp.js → bell-off-TX9ZjBn9.js} +1 -1
  38. package/assets/{bottom-sheet-DQgPWkXI.js → bottom-sheet-DxTFUy2E.js} +1 -1
  39. package/assets/{brief-UmPkAR4U.js → brief-CpJ2qh9a.js} +1 -1
  40. package/assets/brief-DOAeAabQ.js +1 -0
  41. package/assets/{bug-BckO5YCO.js → bug-DvYTwFLF.js} +1 -1
  42. package/assets/{calendar-Dc-B3sio.js → calendar-7FnOinQ7.js} +1 -1
  43. package/assets/{calendar-clash-strip-DoAFMGom.js → calendar-clash-strip-CZKSYHne.js} +1 -1
  44. package/assets/{calendar-report-C-XuHGk-.js → calendar-report-DdEEmF6Z.js} +1 -1
  45. package/assets/calendar-suggestion-CEyL4gPa.js +1 -0
  46. package/assets/calendars-CYORrHmn.js +1 -0
  47. package/assets/{card-Bk8XYDq2.js → card-o848IbRj.js} +1 -1
  48. package/assets/{checkbox-D0odK_wH.js → checkbox-CjTT5ES0.js} +1 -1
  49. package/assets/chevron-left-BVg2BJhm.js +1 -0
  50. package/assets/{circle-check-big-4GwHrTFa.js → circle-check-big-DbaQY2vy.js} +1 -1
  51. package/assets/{circle-check-BZo2PeBJ.js → circle-check-lnLFo0FD.js} +1 -1
  52. package/assets/{circle-help-QkeLuDiC.js → circle-help-B6vmvmbF.js} +1 -1
  53. package/assets/{clock-DHHTtMvk.js → clock-Cv1IU_So.js} +1 -1
  54. package/assets/compose._-_outboxMessageId_-C-0N5b4O.js +1 -0
  55. package/assets/compose._-_outboxMessageId_-CLmL6rNy.js +1 -0
  56. package/assets/compose._-_outboxMessageId_-CrGQAmBh.js +1 -0
  57. package/assets/compose._-_outboxMessageId_-DsyC1LHn.js +1 -0
  58. package/assets/{config-import-BAGzZhCz.js → config-import-Cn_3moj6.js} +1 -1
  59. package/assets/{confirm-dialog-B9re_jFm.js → confirm-dialog-DcfLr_VV.js} +1 -1
  60. package/assets/{copy-Ctmrzdfp.js → copy-BOxB39My.js} +1 -1
  61. package/assets/{credential-steps-CZFDsRoC.js → credential-steps-BYXdvc6X.js} +1 -1
  62. package/assets/{download-hgu-A5WC.js → download-BIBKQvTj.js} +1 -1
  63. package/assets/{external-link-Dhni3Eg5.js → external-link-8knc6nvP.js} +1 -1
  64. package/assets/{file-json-C-t1pL6m.js → file-json-YOrGpuD8.js} +1 -1
  65. package/assets/{filters-DvW0WvCf.js → filters-Cv1Gmsq9.js} +1 -1
  66. package/assets/flagged-CHQmCz7D.js +1 -0
  67. package/assets/{flagged-VOnkzcbc.js → flagged-CqMpCGJo.js} +1 -1
  68. package/assets/{folders-DtPDNl-l.js → folders-Cja3LAC_.js} +1 -1
  69. package/assets/{help-copy-CdYqiDpm.js → help-copy-S6Ri4ByH.js} +1 -1
  70. package/assets/{import-BtgA3dex.js → import-B2ANVOl-.js} +1 -1
  71. package/assets/index-4EaeJ4jf.js +1 -0
  72. package/assets/{index-CF22K49S.js → index-5tcvhU2B.js} +1 -1
  73. package/assets/index-BdpT1uQw.js +1 -0
  74. package/assets/index-BqqvJwGn.js +1 -0
  75. package/assets/index-C1x7--DZ.js +1 -0
  76. package/assets/index-Co-XhbCe.js +1 -0
  77. package/assets/{index-BVefvGgO.js → index-CwI22pqH.js} +4 -4
  78. package/assets/{index-cubACEd8.js → index-D4MtLdrW.js} +4 -4
  79. package/assets/index-DJzaAYGf.js +1 -0
  80. package/assets/index-jmt1GqpT.js +1 -0
  81. package/assets/index-qTS44Ji9.js +1 -0
  82. package/assets/index-qftp2SP8.js +1 -0
  83. package/assets/{kbd-C6M51ovo.js → kbd-B6fJcnhn.js} +1 -1
  84. package/assets/{labels-QNRXqxQK.js → labels-BTYKFfU4.js} +1 -1
  85. package/assets/{mail-CfslMQ7s.js → mail-B1xchVjt.js} +1 -1
  86. package/assets/{mail-4zzmmiWK.js → mail-f9ZAFfdw.js} +1 -1
  87. package/assets/{map-pin-CO81Zh5s.js → map-pin-35e-1RVT.js} +1 -1
  88. package/assets/{menu-BkQ4G0tI.js → menu-hJvWIs1N.js} +1 -1
  89. package/assets/minus-u23qRtsG.js +1 -0
  90. package/assets/new-DUufBdYM.js +1 -0
  91. package/assets/onboarding-Uk6iFlNr.js +1 -0
  92. package/assets/{onboarding-completion-CgqykfP5.js → onboarding-completion-CbQwAlqk.js} +1 -1
  93. package/assets/outbox-BvVfW0CI.js +1 -0
  94. package/assets/{pencil-DYtxEeVu.js → pencil-DpNZS_31.js} +1 -1
  95. package/assets/{popover-menu-BFWBKaTJ.js → popover-menu-B2lo44EX.js} +1 -1
  96. package/assets/{refresh-cw-CuDrOkmw.js → refresh-cw-CDQ2xZbt.js} +1 -1
  97. package/assets/{rich-text-spellcheck-worker-provider-BTpAV_xA.js → rich-text-spellcheck-worker-provider-Cw0xnZKP.js} +1 -1
  98. package/assets/{rich-text-DyZjqA4b.js → rich-text-vG9mdl0O.js} +1 -1
  99. package/assets/{rotate-ccw-gM8iCdpA.js → rotate-ccw-BKGT9oCK.js} +1 -1
  100. package/assets/{roving-focus-pflLgyvB.js → roving-focus-B2beIkcs.js} +1 -1
  101. package/assets/{row-actions-DqODANSe.js → row-actions-B32GgPjM.js} +1 -1
  102. package/assets/{search-mirror-BPmmvfUK.js → search-mirror-CCS7HTrR.js} +1 -1
  103. package/assets/{search-query-Bfvoxxg4.js → search-query-CAVAQ88t.js} +1 -1
  104. package/assets/{search-token-index-DnVW2A-U.js → search-token-index-CpNMPGXa.js} +1 -1
  105. package/assets/{sections-CI8sUA-m.js → sections-yYR5lj5B.js} +1 -1
  106. package/assets/{senders-CXDuYLon.js → senders-BQUohPe4.js} +1 -1
  107. package/assets/settings-8vexnTwM.js +1 -0
  108. package/assets/{settings-screen-a-xqubF0.js → settings-screen-DIq3lhTN.js} +1 -1
  109. package/assets/{shield-check-C76VpI9Q.js → shield-check-82yPViXE.js} +1 -1
  110. package/assets/{suggested-vips-DKoHfOxA.js → suggested-vips-pyfL4tBL.js} +1 -1
  111. package/assets/suggestion._suggestionId-DSXOmfLm.js +1 -0
  112. package/assets/{undo-2-DlatIdv3.js → undo-2-DiDBLYQX.js} +1 -1
  113. package/assets/useCalendarData-CCBsntW3.js +1 -0
  114. package/assets/{calendar-format-BovOEuV7.js → useCalendarEvents-CrWcNz4p.js} +1 -1
  115. package/assets/useCalendarFreeBusy-DuQyTiBf.js +1 -0
  116. package/assets/{useCalendarWrites-BGQ8emvx.js → useCalendarWrites-BV5Czl6K.js} +1 -1
  117. package/assets/{useCalendars-DpG3wNVl.js → useCalendars-7HDjkRuY.js} +1 -1
  118. package/assets/{useDebouncedValue-D87mJggE.js → useDebouncedValue-VlBdfJHe.js} +1 -1
  119. package/assets/{useFilters-CjhcpObW.js → useFilters-C8oAo8fh.js} +1 -1
  120. package/assets/{useLabels-BZ4I9RAK.js → useLabels-UgAc0ur8.js} +1 -1
  121. package/assets/{useLayoutTier-Cme1U69S.js → useLayoutTier-DAXt_X3A.js} +1 -1
  122. package/assets/{useMessageBodyContent-oSPoCcAo.js → useMessageBodyContent-CnzHiG9b.js} +1 -1
  123. package/assets/{useQueries-BgVJvl8E.js → useQueries-ktaWu7Pv.js} +1 -1
  124. package/assets/useRefreshControl-DQ537M3s.js +1 -0
  125. package/assets/{useResultFolderIndex-q07DaZO-.js → useResultFolderIndex-CkQexziN.js} +1 -1
  126. package/assets/{useSignature-C8_KOsXT.js → useSignature-CD6M-2Jc.js} +1 -1
  127. package/assets/{warnings-Ba73_41o.js → warnings-lUeu-pd_.js} +1 -1
  128. package/index.html +6 -10
  129. package/package.json +2 -2
  130. package/spellcheck/de99b00dc30674fd/NOTICE.txt +1 -1
  131. package/spellcheck/de99b00dc30674fd/manifest.json +1 -1
  132. package/assets/BriefPane-CjGWdd8a.js +0 -1
  133. package/assets/CalendarComposePane-Dx8OkeLw.js +0 -1
  134. package/assets/FlaggedPane-BxOdsnw1.js +0 -1
  135. package/assets/MailListHeader-CRcUWHvS.js +0 -1
  136. package/assets/MailboxPane-Bo9JttiA.js +0 -1
  137. package/assets/OutboxPane-CP5sRwfd.js +0 -1
  138. package/assets/_calendarObjectId-BnSnl92f.js +0 -1
  139. package/assets/_mailboxId-CNwKdI8w.js +0 -1
  140. package/assets/_messageId-C9wsfdzq.js +0 -1
  141. package/assets/_messageId-DBNLE0tb.js +0 -1
  142. package/assets/_messageId-HdLzcjMe.js +0 -1
  143. package/assets/_outboxMessageId-DHN5fMou.js +0 -1
  144. package/assets/_recurrenceId-CniHh10K.js +0 -1
  145. package/assets/_threadId-C3p0YYSS.js +0 -1
  146. package/assets/_threadId-ChtUn47n.js +0 -1
  147. package/assets/_threadId-DFtqyHil.js +0 -1
  148. package/assets/_view._date-CZQj0j1i.js +0 -1
  149. package/assets/brief-Drn9-8tt.js +0 -1
  150. package/assets/calendar-suggestion-C_OSjndS.js +0 -1
  151. package/assets/calendars-DBG7BQZr.js +0 -1
  152. package/assets/chevron-left-SkeGnPD1.js +0 -1
  153. package/assets/compose._-_outboxMessageId_-B-R8VIDx.js +0 -1
  154. package/assets/compose._-_outboxMessageId_-CRT9iVyv.js +0 -1
  155. package/assets/compose._-_outboxMessageId_-Cd-9BJez.js +0 -1
  156. package/assets/compose._-_outboxMessageId_-Cnw34yB-.js +0 -1
  157. package/assets/flagged-CGRoEDEr.js +0 -1
  158. package/assets/index-91ywJtSA.js +0 -1
  159. package/assets/index-BSloTjxB.js +0 -1
  160. package/assets/index-C9wsfdzq.js +0 -1
  161. package/assets/index-CFGRT_20.js +0 -1
  162. package/assets/index-CzzzRc7f.js +0 -1
  163. package/assets/index-D-aF7kT3.js +0 -1
  164. package/assets/index-DBNLE0tb.js +0 -1
  165. package/assets/index-DFpmjJVI.js +0 -1
  166. package/assets/index-hMino1Zj.js +0 -1
  167. package/assets/minus-tJx7k6NN.js +0 -1
  168. package/assets/new-CFrxbOp1.js +0 -1
  169. package/assets/onboarding-BfZPTDb2.js +0 -1
  170. package/assets/outbox-CS_GQ7eb.js +0 -1
  171. package/assets/result-count-BTXdc_1e.js +0 -1
  172. package/assets/settings-CLLqV8u4.js +0 -1
  173. package/assets/suggestion._suggestionId-Cz28HTX7.js +0 -1
  174. package/assets/useCalendarData-DbJEV-YD.js +0 -1
  175. package/assets/useCalendarFreeBusy-q7sx9n0O.js +0 -1
  176. package/assets/useRefreshControl-DPzIiFlp.js +0 -1
@@ -1 +0,0 @@
1
- import{j as r,O as i}from"./index-cubACEd8.js";import{a as m}from"./MailShell-CsFJTXUG.js";import{B as o}from"./BriefPane-CjGWdd8a.js";import{a as p}from"./search-token-index-DnVW2A-U.js";import{u as e}from"./search-mirror-BPmmvfUK.js";import"./FullCompose-B7Gvo6hb.js";import"./ErrorState-C-GqtxHT.js";import"./index-BVefvGgO.js";import"./useMessageBodyContent-oSPoCcAo.js";import"./useSignature-C8_KOsXT.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-D87mJggE.js";import"./sections-CI8sUA-m.js";import"./confirm-dialog-B9re_jFm.js";import"./useSearchTokenContext-PpLW_UHw.js";import"./kbd-C6M51ovo.js";import"./search-scope-UI1H6AzA.js";import"./MailListHeader-CRcUWHvS.js";import"./roving-focus-pflLgyvB.js";import"./EmptyState-BvdGNd01.js";import"./popover-menu-BFWBKaTJ.js";import"./mail-CfslMQ7s.js";import"./avatar-ByFhyZLr.js";import"./undo-2-DlatIdv3.js";import"./download-hgu-A5WC.js";import"./useCalendarFreeBusy-q7sx9n0O.js";import"./calendar-format-BovOEuV7.js";import"./useQueries-BgVJvl8E.js";import"./useCalendars-DpG3wNVl.js";import"./map-pin-CO81Zh5s.js";import"./useLayoutTier-Cme1U69S.js";import"./calendar-suggestion-C_OSjndS.js";import"./attendee-row-D_Iu4VYw.js";import"./minus-tJx7k6NN.js";import"./clock-DHHTtMvk.js";import"./calendar-clash-strip-DoAFMGom.js";import"./bell-off-C0wHlgOp.js";import"./shield-check-C76VpI9Q.js";import"./calendar-report-C-XuHGk-.js";import"./useFilters-CjhcpObW.js";import"./checkbox-D0odK_wH.js";import"./menu-BkQ4G0tI.js";import"./useRefreshControl-DPzIiFlp.js";import"./circle-check-big-4GwHrTFa.js";import"./refresh-cw-CuDrOkmw.js";import"./result-count-BTXdc_1e.js";import"./useLabels-BZ4I9RAK.js";import"./wizard-selection-zWa1qc6-.js";function or(){const t=p();return e({to:"/mail/brief"}),r.jsx(o,{thread:t,children:r.jsx(m,{phone:r.jsx(o.Phone,{}),list:r.jsx(o.List,{}),reading:r.jsx(i,{}),intelligence:r.jsx(o.Intelligence,{}),hasThread:!!t})})}export{or as component};
@@ -1 +0,0 @@
1
- import{j as g,as as z,t as F,c0 as D,c as O,eM as _,h as j,r as l,i as v,eN as $,eO as B,eP as U,eQ as q,s as G,eR as W,eS as Q}from"./index-cubACEd8.js";import{f as K}from"./ErrorState-C-GqtxHT.js";import{A as Z,B as Y,E as N,y as w,F as b,G as H,e as I,H as T,z as J}from"./calendar-format-BovOEuV7.js";import{e as c,b as k}from"./useCalendars-DpG3wNVl.js";function De({text:e,reportHref:t,className:n}){return g.jsxs("div",{role:"alert",className:F("flex items-start gap-1.5 rounded-md border border-danger/40 bg-danger-soft p-2 text-xs text-danger",n),children:[g.jsx(z,{className:"mt-0.5 size-3.5 shrink-0","aria-hidden":!0}),g.jsxs("p",{className:"min-w-0 flex-1",children:[e,t&&g.jsxs(g.Fragment,{children:[" ",g.jsx("a",{href:t,target:"_blank",rel:"noreferrer",className:"font-medium text-accent hover:underline",children:"Report an issue"})]})]})]})}const V=24,R=7,X=52,A=X*7,ee=e=>({from:c(e,-10),to:c(e,V),floor:c(e,-A),ceiling:c(e,A)}),te=e=>e.from<=e.floor,ne=e=>e.to>=e.ceiling,ae=(e,t)=>e>t?e:t,se=(e,t)=>e<t?e:t,re=e=>te(e)?e:{...e,from:ae(c(e.from,-R),e.floor)},ie=e=>ne(e)?e:{...e,to:se(c(e.to,R),e.ceiling)},Ae=e=>re({...e,floor:c(e.from,-A)}),be=e=>ie({...e,ceiling:c(e.to,A)});function Oe(e,t){return t>=e.from&&t<=e.to?e:ee(t)}function we(e){const t=new Map;for(const n of e){const a=k("week",n);t.has(a.from)||t.set(a.from,a)}return[...t.values()]}const Ie=e=>k("week",e).from,oe=1440,M=e=>e.getHours()*60+e.getMinutes();function L(e,t){const n=new Set(e),a=new Map;for(const s of t){const r=new Date(s.start),d=new Date(s.end);if(Number.isNaN(r.getTime())||Number.isNaN(d.getTime())||d.getTime()<=r.getTime())continue;const h=D(r),C=D(new Date(d.getTime()-1));for(let o=h;o<=C;o=c(o,1)){if(!n.has(o))continue;const m=o===h?M(r):0,p=D(d)===o?M(d):oe;if(p<=m)continue;const i=a.get(o);i?i.push({from:m,to:p}):a.set(o,[{from:m,to:p}])}}for(const[s,r]of a)a.set(s,Z(r));return a}function Te(e,t){const n=L(e,t);return new Map(e.map(a=>[a,N(a,n.get(a)??[])]))}const Me=e=>Y(e.from,e.to),f=G(400,404),ce=new Set(["calendarSuggestionOperationsListCalendarSuggestions","messageCalendarSuggestionOperationsListMessageCalendarSuggestions","calendarEventOperationsListCalendarEvents","calendarEventDetailOperationsGetCalendarEvent","calendarFreeBusyOperationsListCalendarFreeBusy","filterOperationsListFilters"]),de=e=>e.invalidateQueries({predicate:t=>{const n=t.queryKey[0];if(typeof n!="object"||n===null)return!1;const a=n._id;return typeof a=="string"&&ce.has(a)}});function Ne(e){const{data:t,isLoading:n,error:a}=O({..._({path:{messageId:e}}),meta:f});return{suggestions:t?.items??[],isLoading:n,error:a??null}}function ke(){const{data:e,isLoading:t,error:n}=O({...W({query:{state:"Pending"}}),meta:f});return{suggestions:e?.items??[],isLoading:t,error:n??null}}const le=async(e,t)=>{let n;do{const{data:a}=await Q({query:{state:"Pending",continuationToken:n},signal:t,throwOnError:!0}),s=a.items.find(r=>r.suggestionId===e);if(s)return s;n=a.continuationToken}while(n);return null};function Re(e){const{data:t,isLoading:n,error:a}=O({queryKey:[{_id:"calendarSuggestionOperationsListCalendarSuggestions",suggestionId:e}],queryFn:({signal:s})=>le(e,s),meta:f});return{suggestion:t,isLoading:n,error:a??null}}const S={kind:"answered"},y=e=>({kind:"refused",message:K(e)});function Le(){const e=j(),t=l.useCallback(()=>de(e),[e]),n=v({...$(),meta:f,onSuccess:t}),a=v({...B(),meta:f,onSuccess:t}),s=v({...U(),meta:f,onSuccess:t}),r=v({...q(),meta:f,onSuccess:t}),d=l.useCallback((i,u)=>n.mutateAsync({path:{suggestionId:i},body:{calendarId:u}}).then(()=>S).catch(y),[n]),h=l.useCallback((i,u)=>n.mutateAsync({path:{suggestionId:i},body:{calendarId:u,answer:"Tentative"}}).then(()=>S).catch(y),[n]),C=l.useCallback((i,u)=>n.mutateAsync({path:{suggestionId:i},body:u}).then(()=>S).catch(y),[n]),o=l.useCallback(i=>a.mutateAsync({path:{suggestionId:i}}).then(()=>S).catch(y),[a]),m=l.useCallback((i,u)=>s.mutateAsync({path:{suggestionId:i},body:{muteSender:u}}).then(()=>S).catch(y),[s]),p=l.useCallback(i=>r.mutateAsync({path:{suggestionId:i}}).then(()=>S).catch(y),[r]);return l.useMemo(()=>({accept:d,tentative:h,acceptEdited:C,decline:o,dismiss:m,reopen:p,isAnswering:n.isPending||a.isPending||s.isPending||r.isPending}),[d,h,C,o,m,p,n.isPending,a.isPending,s.isPending,r.isPending])}const E=30,ue=6,P={Local:"local",Explicit:"explicit",Ambiguous:"ambiguous"},fe="The invitation's time zone could not be resolved. Add opens the editor so you can set the time.",me="The invitation's time zone could not be resolved.";function Pe(e){return e.method==="Cancel"?e.state==="Pending"?{state:"cancelled",rsvp:"noReply"}:void 0:e.state==="Dismissed"?{state:"dismissed",rsvp:"noReply"}:e.state==="Superseded"?{state:"superseded",rsvp:"noReply"}:e.state==="Accepted"?{state:"answered",rsvp:"accepted"}:e.state==="Declined"?{state:"answered",rsvp:"declined"}:e.state==="Tentative"?{state:"answered",rsvp:"tentative"}:{state:"pending",rsvp:"noReply"}}const pe=e=>e.source!=="TextHeuristic";function xe(e){return e.allDay?e.dtStart.slice(0,10):D(new Date(e.dtStart))}const x=e=>e.summary===""?"Untitled event":e.summary;function ze(e){if(e.allDay){const t=e.dtStart.slice(0,10),n=e.dtEnd.slice(0,10),a=n>t?c(n,-1):t;return a===t?`${b(t)}, all day`:`${b(t)} – ${b(a)}, all day`}return H({start:e.dtStart,end:e.dtEnd,allDay:e.allDay})}function ge(e,t){return{id:e.suggestionId,calendarId:t.calendarId,title:x(e),start:e.dtStart,end:e.dtEnd,allDay:e.allDay,location:e.location,notes:"",attendees:[],myRsvp:"noReply",threadId:t.threadId,threadSubject:t.threadSubject,timeZone:"",zoneCertainty:P[e.zoneCertainty],recurrenceRule:"",seriesId:"",seriesException:!1,status:"confirmed"}}function Fe(e,t,n){const a=e.organizer===""?n.senderName:e.organizer;return{id:e.suggestionId,threadId:n.threadId,proposed:ge(e,n),organizerName:a===""?"The sender":a,organizerEmail:e.organizer,method:"ics",evidence:"",state:t,sequence:e.sequence}}function Se(e){return e.zoneCertainty!=="Ambiguous"?"":e.method==="Cancel"?me:fe}function _e(e,t){return{id:e.suggestionId,title:x(e),start:e.dtStart,end:e.dtEnd,allDay:e.allDay,location:e.location,threadId:t.threadId,threadSubject:t.threadSubject,sender:t.sender,senderAddress:e.organizer,confidence:pe(e)?1:.6,ambiguity:Se(e),suggestedCalendarId:t.calendarId,timeZone:"",zoneCertainty:P[e.zoneCertainty]}}const ye=(e,t)=>Date.parse(t.start)<Date.parse(e.end)&&Date.parse(t.end)>Date.parse(e.start);function je(e,t){return t.filter(n=>ye(e,n)).map(n=>({id:`${n.start}/${n.end}`,label:`Busy ${w(n.start)} – ${w(n.end)}`}))}function $e(e,t){const n=L([e],t).get(e)??[],a=[];for(const s of N(e,n,E))for(let r=s.startMinute;r+E<=s.endMinute&&a.length<ue;r+=E)a.push({date:e,endDate:e,startTime:I(r),endTime:I(r+E),allDay:!1});return a}function Be(e,t,n){const a=t.filter(s=>n.includes(s.startTime)).map(s=>`${T(s.startTime)} – ${T(s.endTime)}`);return`${J(e)}: ${a.join(", ")}`}export{De as C,Oe as a,Ie as b,ie as c,Me as d,re as e,Te as f,be as g,ne as h,te as i,Le as j,xe as k,Ae as l,Ne as m,pe as n,Pe as o,je as p,Fe as q,ee as r,ze as s,_e as t,ke as u,$e as v,we as w,Be as x,Re as y};
@@ -1 +0,0 @@
1
- import{e as S,h as z,r,b7 as $,i as y,b8 as _,b9 as H,ba as X,s as A,j as e,az as q,aA as N,B as j,f,aR as J,a4 as G,g as Q,bb as M,aC as Y,bc as ee,c as se,bd as ae,aK as L,be as te,bf as ne,bg as re,u as ie,aQ as de,aS as oe}from"./index-cubACEd8.js";import{S as le}from"./settings-screen-a-xqubF0.js";import{C as P,a as D,b as R,c as O}from"./card-Bk8XYDq2.js";import{U as k,u as ce}from"./useCalendars-DpG3wNVl.js";import{C as K}from"./confirm-dialog-B9re_jFm.js";import{f as w,E as ue}from"./ErrorState-C-GqtxHT.js";import{R as me}from"./refresh-cw-CuDrOkmw.js";import{C as he}from"./copy-Ctmrzdfp.js";import{u as V}from"./useCalendarWrites-BGQ8emvx.js";import{s as pe}from"./calendar-subscription-B-aAc2Gy.js";import"./avatar-ByFhyZLr.js";import"./chevron-left-SkeGnPD1.js";import"./menu-BkQ4G0tI.js";import"./circle-help-QkeLuDiC.js";const xe=S("CalendarPlus",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 13V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8",key:"3spt84"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M16 19h6",key:"xwg31i"}],["path",{d:"M19 16v6",key:"tddt3s"}]]);const be=S("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);const ge=S("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]]);const fe=S("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const ve=S("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]),T=A(400,404),I={kind:"written"},F=s=>({kind:"refused",message:w(s)});function W(){const s=z(),n=V(),t=r.useCallback(()=>s.invalidateQueries({queryKey:$()}),[s]),a=r.useCallback(()=>(n(),t()),[n,t]),i=y({..._(),meta:T,onSuccess:t}),d=y({...H(),meta:T,onSuccess:a}),o=y({...X(),meta:T,onSuccess:a}),l=r.useCallback(c=>i.mutateAsync({body:c}).then(()=>I).catch(F),[i]),m=r.useCallback((c,x)=>d.mutateAsync({path:{calendarId:c},body:x}).then(()=>I).catch(F),[d]),h=r.useCallback(c=>o.mutateAsync({path:{calendarId:c}}).then(()=>I).catch(F),[o]);return r.useMemo(()=>({createCalendar:l,updateCalendar:m,deleteCalendar:h,isWriting:i.isPending||d.isPending||o.isPending}),[l,m,h,i.isPending,d.isPending,o.isPending])}const E=Intl.supportedValuesOf("timeZone");function B({id:s,value:n,disabled:t,onChange:a}){const i=n===k||E.includes(n)?E:[n,...E];return e.jsxs(q,{id:s,value:n,disabled:t,onChange:d=>a(d.target.value),children:[e.jsx("option",{value:k,children:"None (read as UTC)"}),i.map(d=>e.jsx("option",{value:d,children:d},d))]})}const ye=s=>({title:`Delete ${s}?`,description:`This removes ${s} and every event in it, and any subscription address stops working. It cannot be undone.`}),je=s=>s.normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,64);function Ce({isBusy:s,problem:n,onCreate:t}){const[a,i]=r.useState(""),[d,o]=r.useState(void 0),[l,m]=r.useState(k),h=r.useId(),c=r.useId(),x=r.useId(),u=r.useId(),p=d??je(a),b=a.trim()!==""&&p.trim()!=="";return e.jsxs(P,{className:"max-w-xl",role:"region","aria-labelledby":h,children:[e.jsx(D,{children:e.jsx(R,{id:h,children:"New calendar"})}),e.jsx(O,{children:e.jsxs("form",{className:"space-y-3",onSubmit:g=>{g.preventDefault(),b&&t({displayName:a.trim(),urlSegment:p.trim(),timezone:l}).then(v=>{v&&(i(""),o(void 0),m(k))})},children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:c,className:"text-xs font-medium text-fg-muted",children:"Name"}),e.jsx(N,{id:c,value:a,maxLength:140,disabled:s,onChange:g=>i(g.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:x,className:"text-xs font-medium text-fg-muted",children:"Address"}),e.jsx(N,{id:x,value:p,maxLength:64,disabled:s,onChange:g=>o(g.target.value)})]}),e.jsxs("div",{className:"space-y-1 sm:col-span-2",children:[e.jsx("label",{htmlFor:u,className:"text-xs font-medium text-fg-muted",children:"Time zone"}),e.jsx(B,{id:u,value:l,disabled:s,onChange:m})]})]}),e.jsx("p",{className:"text-xs text-fg-muted",children:"The address names the calendar for CalDAV clients and cannot be changed later. The name and zone can."}),n!==""&&e.jsxs(j,{tone:"danger",variant:"soft",children:[e.jsx("p",{className:"font-medium",children:"The calendar was not added."}),e.jsx("p",{className:"mt-0.5 break-words",children:n})]}),e.jsx(f,{type:"submit",variant:"primary",size:"sm",disabled:s||!b,icon:e.jsx(J,{className:"size-3.5"}),children:s?"Adding…":"Add calendar"})]})})]})}function Ne({calendarName:s,timezone:n,isBusy:t,problem:a,onSave:i,onDelete:d}){const[o,l]=r.useState(s),[m,h]=r.useState(n),[c,x]=r.useState(!1),u=r.useId(),p=r.useId(),b=o.trim(),g=b!==s||m!==n,v=ye(s);return e.jsxs(e.Fragment,{children:[e.jsxs("form",{className:"space-y-3",onSubmit:C=>{C.preventDefault(),!(!g||b==="")&&i({displayName:b,timezone:m})},children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:u,className:"text-xs font-medium text-fg-muted",children:"Name"}),e.jsx(N,{id:u,value:o,maxLength:140,disabled:t,onChange:C=>l(C.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:p,className:"text-xs font-medium text-fg-muted",children:"Time zone"}),e.jsx(B,{id:p,value:m,disabled:t,onChange:h})]})]}),a!==""&&e.jsxs(j,{tone:"danger",variant:"soft",children:[e.jsxs("p",{className:"font-medium",children:[s," was not changed."]}),e.jsx("p",{className:"mt-0.5 break-words",children:a})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(f,{type:"submit",variant:"secondary",size:"sm",disabled:t||!g||b==="",icon:e.jsx(ve,{className:"size-3.5"}),children:"Save changes"}),e.jsx(f,{type:"button",variant:"danger",size:"sm",disabled:t,icon:e.jsx(G,{className:"size-3.5"}),onClick:()=>x(!0),children:"Delete calendar"})]})]}),e.jsx(K,{isOpen:c,title:v.title,description:v.description,confirmLabel:"Delete calendar",destructive:!0,onConfirm:()=>{x(!1),d()},onCancel:()=>x(!1)})]})}const Se=s=>({title:`Replace the address for ${s}?`,description:"Every client already subscribed to the current address stops updating and has to be pointed at the new one. The new address is shown once."}),ke=s=>({title:`Stop sharing ${s}?`,description:"The address stops working immediately and every client subscribed to it stops updating. Sharing again mints a different address."});function we({calendarName:s,url:n,onDismiss:t}){const[a,i]=r.useState(!1),[d,o]=r.useState(!1),l=r.useRef(0);r.useEffect(()=>()=>window.clearTimeout(l.current),[]);const m=()=>{navigator.clipboard.writeText(n).then(()=>{o(!1),i(!0),l.current=window.setTimeout(()=>i(!1),2e3)}).catch(()=>o(!0))};return e.jsxs("div",{className:"mt-3 space-y-2 rounded-sm border border-accent-2/40 bg-accent-2/10 px-3 py-2.5",children:[e.jsx("p",{className:"text-sm font-medium text-fg",children:"Subscribe with this address. It is shown once and cannot be read back."}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsx("input",{readOnly:!0,value:n,"aria-label":`Subscription address for ${s}`,onFocus:h=>h.currentTarget.select(),className:"min-w-0 flex-1 rounded-sm border border-line bg-surface px-2 py-1.5 font-mono text-xs text-fg"}),e.jsx(f,{variant:"primary",size:"sm",icon:a?e.jsx(Y,{className:"size-3.5"}):e.jsx(he,{className:"size-3.5"}),onClick:m,children:a?"Copied":"Copy address"})]}),d&&e.jsx(j,{tone:"warning",variant:"soft",children:"The address could not be copied to the clipboard. Select it above and copy it by hand before leaving this page."}),e.jsx("p",{className:"text-xs text-fg-muted",children:"Anyone holding this address can read every event in this calendar, without signing in. Rotate it if it reaches the wrong person."}),e.jsx(f,{variant:"ghost",size:"sm",onClick:t,children:"I've saved it"})]})}function Te({createdAt:s,rotatedAt:n,isBusy:t,onRotate:a,onRevoke:i}){return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Q,{tone:"positive",children:"shared"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:["Address created ",M(s,"medium"),n>0?`, last replaced ${M(n,"medium")}`:""]})]}),e.jsx("p",{className:"text-sm text-fg-muted",children:"The address itself is not stored in readable form, so it cannot be shown again. Replace it if you no longer know where it went."}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(f,{variant:"secondary",size:"sm",disabled:t,icon:e.jsx(me,{className:"size-3.5"}),onClick:a,children:"Replace address"}),e.jsx(f,{variant:"danger",size:"sm",disabled:t,icon:e.jsx(G,{className:"size-3.5"}),onClick:i,children:"Stop sharing"})]})]})}function Ie({calendarName:s,details:n,state:t,mintedUrl:a,isBusy:i,actionError:d,onMint:o,onRevoke:l,onDismissMinted:m,onRetry:h}){const[c,x]=r.useState("none"),u=r.useId(),p=()=>{const g=c;x("none"),g==="rotate"&&o(),g==="revoke"&&l()},b=c==="revoke"?ke(s):Se(s);return e.jsxs(P,{className:"max-w-xl",role:"region","aria-labelledby":u,children:[e.jsx(D,{children:e.jsx(R,{id:u,children:s})}),e.jsxs(O,{children:[n&&e.jsx("div",{className:"mb-4 border-b border-line pb-4",children:n}),t.status==="loading"&&a===""&&e.jsx("div",{className:"h-12 animate-pulse rounded-sm bg-surface-sunken","aria-busy":"true","aria-label":`Loading the subscription address for ${s}`}),t.status==="unreadable"&&a===""&&e.jsx(ue,{variant:"inline",title:`Couldn't read whether ${s} is shared`,error:t.error,onRetry:h}),t.status==="absent"&&a===""&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-fg-muted",children:"Give this calendar a secret address and Apple Calendar, Google Calendar, Outlook and Thunderbird can subscribe to it read-only. Nobody signs in — the address is the credential, so treat it like a password."}),e.jsx(f,{variant:"primary",size:"sm",disabled:i,icon:e.jsx(be,{className:"size-3.5"}),onClick:o,children:i?"Creating…":"Create subscription address"})]}),t.status==="active"&&e.jsx(Te,{createdAt:t.createdAt,rotatedAt:t.rotatedAt,isBusy:i,onRotate:()=>x("rotate"),onRevoke:()=>x("revoke")}),d!=null&&e.jsxs(j,{tone:"danger",variant:"soft",className:"mt-3",children:[e.jsxs("p",{className:"font-medium",children:["The subscription address for ",s," was not changed."]}),e.jsx("p",{className:"mt-0.5 break-words",children:w(d)})]}),a!==""&&e.jsx(we,{calendarName:s,url:a,onDismiss:m})]}),e.jsx(K,{isOpen:c!=="none",title:b.title,description:b.description,confirmLabel:c==="revoke"?"Stop sharing":"Replace address",destructive:!0,onConfirm:p,onCancel:()=>x("none")})]})}const Fe="/feeds/calendar/",Ee=".ics",Me=(s,n)=>`webcal://${s}${Fe}${n}${Ee}`;function ze(s){const n=z(),[t,a]=r.useState(""),i=ee({path:{calendarId:s}}),d=se({...ae({path:{calendarId:s}}),meta:A(404,403),retry:!1}),o=()=>{n.invalidateQueries({queryKey:i})},l=r.useRef(()=>{}),m=y({...te(),meta:L,onMutate:()=>{l.current()},onSuccess:()=>{a(""),o()}}),h=y({...ne(),meta:L,gcTime:0,onMutate:()=>{m.reset()},onSuccess:Z=>{a(Me(window.location.host,Z.feedToken)),o()}});l.current=h.reset;const{mutate:c,reset:x}=h,{mutate:u}=m,p=r.useCallback(()=>{c({path:{calendarId:s}})},[s,c]),b=r.useCallback(()=>{u({path:{calendarId:s}})},[s,u]),g=r.useCallback(()=>{a(""),x()},[x]),{refetch:v}=d,C=r.useCallback(()=>{v()},[v]);return{state:Ae(d),mintedUrl:t,isBusy:h.isPending||m.isPending,actionError:h.error??m.error,mint:p,revoke:b,dismissMinted:g,retry:C}}function Ae(s){return s.error?re(s.error)?{status:"absent"}:{status:"unreadable",error:s.error}:s.isPending?{status:"loading"}:s.data?{status:"active",createdAt:s.data.createdAt,rotatedAt:s.data.rotatedAt}:{status:"absent"}}function Pe({calendarId:s,calendarName:n,details:t}){const a=ze(s);return e.jsx(Ie,{calendarName:n,details:t,state:a.state,mintedUrl:a.mintedUrl,isBusy:a.isBusy,actionError:a.actionError,onMint:a.mint,onRevoke:a.revoke,onDismissMinted:a.dismissMinted,onRetry:a.retry})}function De({calendarId:s,calendarName:n,timezone:t,subscription:a}){const{updateCalendar:i,deleteCalendar:d,isWriting:o}=W(),[l,m]=r.useState(""),h=c=>m(c.kind==="refused"?c.message:"");return e.jsx(Pe,{calendarId:s,calendarName:n,details:e.jsxs(e.Fragment,{children:[a,e.jsx(Ne,{calendarName:n,timezone:t,isBusy:o,problem:l,onSave:c=>{m(""),i(s,c).then(h)},onDelete:()=>{m(""),d(s).then(h)}},`${n}\0${t}`)]})})}const Re="Subscribe to a calendar";function Oe({isBusy:s,error:n,onSubscribe:t}){const a=r.useId(),i=r.useId(),d=r.useId(),[o,l]=r.useState(""),[m,h]=r.useState(""),c=o.trim()!==""&&m.trim()!=="",x=u=>{u.preventDefault(),c&&t({displayName:o,url:m},()=>{l(""),h("")})};return e.jsxs(P,{className:"max-w-xl",role:"region","aria-labelledby":a,children:[e.jsx(D,{children:e.jsx(R,{id:a,children:Re})}),e.jsx(O,{children:e.jsxs("form",{className:"space-y-3",onSubmit:x,children:[e.jsx("p",{className:"text-sm text-fg-muted",children:"Paste the secret iCal address from Google Calendar, a published Outlook calendar or any other feed. It shows here read-only and refreshes on its own."}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:i,className:"text-sm font-medium text-fg",children:"Calendar name"}),e.jsx(N,{id:i,value:o,onChange:u=>l(u.target.value),placeholder:"Team rota",autoComplete:"off"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:d,className:"text-sm font-medium text-fg",children:"Calendar address"}),e.jsx(N,{id:d,value:m,onChange:u=>h(u.target.value),placeholder:"https://calendar.google.com/calendar/ical/…/basic.ics",autoComplete:"off",spellCheck:!1,inputMode:"url"}),e.jsx("p",{className:"text-xs text-fg-muted",children:"For Google Calendar the address is the password to the calendar. Reader never shows it in full again."})]}),e.jsx(f,{type:"submit",variant:"primary",size:"sm",disabled:!c||s,icon:e.jsx(xe,{className:"size-3.5"}),children:s?"Subscribing…":"Subscribe"}),n!=null&&e.jsxs(j,{tone:"danger",variant:"soft",children:[e.jsx("p",{className:"font-medium",children:"The calendar was not added."}),e.jsx("p",{className:"mt-0.5 break-words",children:w(n)})]})]})})]})}function Le({calendarName:s,subscriptionUrl:n,enabled:t,fetchedAt:a,error:i,isBusy:d,actionError:o,onSetEnabled:l}){return e.jsxs("div",{className:"mb-4 space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Q,{tone:t?"positive":"neutral",children:t?"subscribed":"paused"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:["Read-only, from ",pe(n),a>0?`. Last updated ${M(a,"medium")}`:""]})]}),i!==""&&e.jsxs(j,{tone:"warning",variant:"soft",children:[e.jsxs("p",{className:"font-medium",children:[s," was not refreshed."]}),e.jsx("p",{className:"mt-0.5 break-words",children:i})]}),e.jsx("p",{className:"text-sm text-fg-muted",children:t?"Events are read from the feed on a schedule and cannot be edited here.":"Updates are paused. The events already here stay until you resume or remove the calendar."}),e.jsx(f,{variant:"secondary",size:"sm",disabled:d,icon:t?e.jsx(ge,{className:"size-3.5"}):e.jsx(fe,{className:"size-3.5"}),onClick:()=>l(!t),children:t?"Pause updates":"Resume updates"}),o!=null&&e.jsxs(j,{tone:"danger",variant:"soft",children:[e.jsxs("p",{className:"font-medium",children:["Updates for ",s," were not changed."]}),e.jsx("p",{className:"mt-0.5 break-words",children:w(o)})]})]})}const U=A(400,404),Ue=()=>`subscribed-${crypto.randomUUID().slice(0,8)}`;function $e(){const s=z(),n=V(),t=()=>{s.invalidateQueries({queryKey:$()}),n()},a=y({..._(),meta:U,onSuccess:t}),i=y({...H(),meta:U,onSuccess:t}),{mutate:d}=a,o=r.useCallback((h,c)=>{d({body:{urlSegment:Ue(),displayName:h.displayName.trim(),subscriptionUrl:h.url.trim()}},{onSuccess:c})},[d]),{mutate:l}=i,m=r.useCallback((h,c)=>{l({path:{calendarId:h},body:{subscriptionEnabled:c}})},[l]);return{subscribe:o,isSubscribing:a.isPending,subscribeError:a.error,setEnabled:m,togglingCalendarId:i.isPending?i.variables?.path.calendarId??"":"",toggleFailure:{calendarId:i.variables?.path.calendarId??"",error:i.error}}}const _e=e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{children:"Each calendar has a name, a time zone its floating times are read in, and an address CalDAV clients reach it by. The address is fixed when the calendar is added; the name and zone can change. Deleting a calendar deletes every event in it. The default calendar is where accepted invitations land, so it cannot be deleted."}),e.jsx("p",{children:"A subscription address lets Apple Calendar, Google Calendar, Outlook and Thunderbird show a calendar from here, read-only and kept up to date."}),e.jsx("p",{children:"Those clients never sign in, so the address itself is the credential. Anyone who has it can read the calendar; nobody who has it can change anything."}),e.jsx("p",{children:"Only a hash of the address is stored, so it is shown once and cannot be looked up later. Replacing it breaks every subscription built on the old one, which is how a shared address is taken back."}),e.jsx("p",{children:"Subscribing works the other way round: paste another calendar's iCal address and its events show here, read-only, refreshed on a schedule."})]});function as(){const s=ie(),[n,t]=r.useState(!0),{calendars:a,collections:i,timeZoneByCalendarId:d,isLoading:o}=ce(),l=$e(),{createCalendar:m,isWriting:h}=W(),[c,x]=r.useState("");return e.jsx(le,{items:de,activeId:"calendars",title:"Calendars",description:"Add, rename and delete calendars, subscribe to a calendar feed, and share one with any client that can subscribe to a URL.",help:_e,helpOpen:n,onToggleHelp:()=>t(u=>!u),onSelect:u=>{const p=oe[u];p&&s({to:p})},onBackToMail:()=>{s({to:"/mail"})},children:o?e.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":"Loading calendars"}):e.jsxs("div",{className:"space-y-4",children:[a.map(u=>{const p=i.find(b=>b.calendarId===u.id);return e.jsx(De,{calendarId:u.id,calendarName:u.name,timezone:d[u.id]??"",subscription:p?.source==="Subscribed"&&e.jsx(Le,{calendarName:p.displayName,subscriptionUrl:p.subscriptionUrl,enabled:p.subscriptionEnabled,fetchedAt:p.subscriptionFetchedAt,error:p.subscriptionError,isBusy:l.togglingCalendarId===u.id,actionError:l.toggleFailure.calendarId===u.id?l.toggleFailure.error:void 0,onSetEnabled:b=>l.setEnabled(u.id,b)})},u.id)}),e.jsx(Oe,{isBusy:l.isSubscribing,error:l.subscribeError,onSubscribe:l.subscribe}),e.jsx(Ce,{isBusy:h,problem:c,onCreate:u=>(x(""),m(u).then(p=>p.kind==="written"?!0:(x(p.message),!1)))})]})})}export{as as component};
@@ -1 +0,0 @@
1
- import{e}from"./index-cubACEd8.js";const t=e("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);export{t as C};
@@ -1 +0,0 @@
1
- import{F as o}from"./FullCompose-B7Gvo6hb.js";import"./index-cubACEd8.js";import"./ErrorState-C-GqtxHT.js";import"./index-BVefvGgO.js";import"./useMessageBodyContent-oSPoCcAo.js";import"./useSignature-C8_KOsXT.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-D87mJggE.js";import"./sections-CI8sUA-m.js";import"./confirm-dialog-B9re_jFm.js";const c=o;export{c as component};
@@ -1 +0,0 @@
1
- import{F as o}from"./FullCompose-B7Gvo6hb.js";import"./index-cubACEd8.js";import"./ErrorState-C-GqtxHT.js";import"./index-BVefvGgO.js";import"./useMessageBodyContent-oSPoCcAo.js";import"./useSignature-C8_KOsXT.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-D87mJggE.js";import"./sections-CI8sUA-m.js";import"./confirm-dialog-B9re_jFm.js";const c=o;export{c as component};
@@ -1 +0,0 @@
1
- import{F as o}from"./FullCompose-B7Gvo6hb.js";import"./index-cubACEd8.js";import"./ErrorState-C-GqtxHT.js";import"./index-BVefvGgO.js";import"./useMessageBodyContent-oSPoCcAo.js";import"./useSignature-C8_KOsXT.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-D87mJggE.js";import"./sections-CI8sUA-m.js";import"./confirm-dialog-B9re_jFm.js";const c=o;export{c as component};
@@ -1 +0,0 @@
1
- import{F as o}from"./FullCompose-B7Gvo6hb.js";import"./index-cubACEd8.js";import"./ErrorState-C-GqtxHT.js";import"./index-BVefvGgO.js";import"./useMessageBodyContent-oSPoCcAo.js";import"./useSignature-C8_KOsXT.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-D87mJggE.js";import"./sections-CI8sUA-m.js";import"./confirm-dialog-B9re_jFm.js";const c=o;export{c as component};
@@ -1 +0,0 @@
1
- import{j as o,O as i}from"./index-cubACEd8.js";import{a as m}from"./MailShell-CsFJTXUG.js";import{F as r}from"./FlaggedPane-BxOdsnw1.js";import{a as p}from"./search-token-index-DnVW2A-U.js";import{u as e}from"./search-mirror-BPmmvfUK.js";import"./FullCompose-B7Gvo6hb.js";import"./ErrorState-C-GqtxHT.js";import"./index-BVefvGgO.js";import"./useMessageBodyContent-oSPoCcAo.js";import"./useSignature-C8_KOsXT.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-D87mJggE.js";import"./sections-CI8sUA-m.js";import"./confirm-dialog-B9re_jFm.js";import"./useSearchTokenContext-PpLW_UHw.js";import"./kbd-C6M51ovo.js";import"./search-scope-UI1H6AzA.js";import"./MailListHeader-CRcUWHvS.js";import"./roving-focus-pflLgyvB.js";import"./EmptyState-BvdGNd01.js";import"./popover-menu-BFWBKaTJ.js";import"./mail-CfslMQ7s.js";import"./avatar-ByFhyZLr.js";import"./undo-2-DlatIdv3.js";import"./download-hgu-A5WC.js";import"./useCalendarFreeBusy-q7sx9n0O.js";import"./calendar-format-BovOEuV7.js";import"./useQueries-BgVJvl8E.js";import"./useCalendars-DpG3wNVl.js";import"./map-pin-CO81Zh5s.js";import"./useLayoutTier-Cme1U69S.js";import"./calendar-suggestion-C_OSjndS.js";import"./attendee-row-D_Iu4VYw.js";import"./minus-tJx7k6NN.js";import"./clock-DHHTtMvk.js";import"./calendar-clash-strip-DoAFMGom.js";import"./bell-off-C0wHlgOp.js";import"./shield-check-C76VpI9Q.js";import"./calendar-report-C-XuHGk-.js";import"./useFilters-CjhcpObW.js";import"./checkbox-D0odK_wH.js";import"./menu-BkQ4G0tI.js";import"./MailViewChrome-CjK9Dnpp.js";import"./refresh-cw-CuDrOkmw.js";import"./wizard-selection-zWa1qc6-.js";function _(){const t=p();return e({to:"/mail/flagged"}),o.jsx(r,{thread:t,children:o.jsx(m,{phone:o.jsx(r.Phone,{}),list:o.jsx(r.List,{}),reading:o.jsx(i,{}),intelligence:o.jsx(r.Intelligence,{}),hasThread:!!t})})}export{_ as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-cubACEd8.js";import{O as t}from"./OutboxPane-CP5sRwfd.js";import"./roving-focus-pflLgyvB.js";import"./useSearchTokenContext-PpLW_UHw.js";import"./kbd-C6M51ovo.js";import"./useMessageBodyContent-oSPoCcAo.js";import"./search-scope-UI1H6AzA.js";import"./circle-check-big-4GwHrTFa.js";import"./clock-DHHTtMvk.js";import"./row-actions-DqODANSe.js";import"./rotate-ccw-gM8iCdpA.js";import"./search-query-Bfvoxxg4.js";import"./NavMenuButton-8KfNqFDk.js";import"./menu-BkQ4G0tI.js";import"./outbox-status-BlKn6P0x.js";function c(){return o.jsx(t.Reading,{})}export{c as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-cubACEd8.js";import{F as r}from"./FlaggedPane-BxOdsnw1.js";import"./useSearchTokenContext-PpLW_UHw.js";import"./kbd-C6M51ovo.js";import"./useMessageBodyContent-oSPoCcAo.js";import"./search-scope-UI1H6AzA.js";import"./MailListHeader-CRcUWHvS.js";import"./roving-focus-pflLgyvB.js";import"./search-token-index-DnVW2A-U.js";import"./useQueries-BgVJvl8E.js";import"./EmptyState-BvdGNd01.js";import"./ErrorState-C-GqtxHT.js";import"./popover-menu-BFWBKaTJ.js";import"./mail-CfslMQ7s.js";import"./avatar-ByFhyZLr.js";import"./index-BVefvGgO.js";import"./useSignature-C8_KOsXT.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-D87mJggE.js";import"./sections-CI8sUA-m.js";import"./undo-2-DlatIdv3.js";import"./download-hgu-A5WC.js";import"./useCalendarFreeBusy-q7sx9n0O.js";import"./calendar-format-BovOEuV7.js";import"./useCalendars-DpG3wNVl.js";import"./map-pin-CO81Zh5s.js";import"./useLayoutTier-Cme1U69S.js";import"./calendar-suggestion-C_OSjndS.js";import"./attendee-row-D_Iu4VYw.js";import"./minus-tJx7k6NN.js";import"./clock-DHHTtMvk.js";import"./calendar-clash-strip-DoAFMGom.js";import"./bell-off-C0wHlgOp.js";import"./shield-check-C76VpI9Q.js";import"./calendar-report-C-XuHGk-.js";import"./useFilters-CjhcpObW.js";import"./checkbox-D0odK_wH.js";import"./confirm-dialog-B9re_jFm.js";import"./menu-BkQ4G0tI.js";import"./MailViewChrome-CjK9Dnpp.js";import"./refresh-cw-CuDrOkmw.js";import"./wizard-selection-zWa1qc6-.js";function Q(){return o.jsx(r.Reading,{})}export{Q as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-cubACEd8.js";import{M as r}from"./MailboxPane-Bo9JttiA.js";import"./useSearchTokenContext-PpLW_UHw.js";import"./kbd-C6M51ovo.js";import"./useMessageBodyContent-oSPoCcAo.js";import"./search-scope-UI1H6AzA.js";import"./useRefreshControl-DPzIiFlp.js";import"./circle-check-big-4GwHrTFa.js";import"./refresh-cw-CuDrOkmw.js";import"./useQueries-BgVJvl8E.js";import"./MailListHeader-CRcUWHvS.js";import"./roving-focus-pflLgyvB.js";import"./search-token-index-DnVW2A-U.js";import"./EmptyState-BvdGNd01.js";import"./ErrorState-C-GqtxHT.js";import"./popover-menu-BFWBKaTJ.js";import"./mail-CfslMQ7s.js";import"./avatar-ByFhyZLr.js";import"./index-BVefvGgO.js";import"./useSignature-C8_KOsXT.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-D87mJggE.js";import"./sections-CI8sUA-m.js";import"./undo-2-DlatIdv3.js";import"./download-hgu-A5WC.js";import"./useCalendarFreeBusy-q7sx9n0O.js";import"./calendar-format-BovOEuV7.js";import"./useCalendars-DpG3wNVl.js";import"./map-pin-CO81Zh5s.js";import"./useLayoutTier-Cme1U69S.js";import"./calendar-suggestion-C_OSjndS.js";import"./attendee-row-D_Iu4VYw.js";import"./minus-tJx7k6NN.js";import"./clock-DHHTtMvk.js";import"./calendar-clash-strip-DoAFMGom.js";import"./bell-off-C0wHlgOp.js";import"./shield-check-C76VpI9Q.js";import"./calendar-report-C-XuHGk-.js";import"./useFilters-CjhcpObW.js";import"./checkbox-D0odK_wH.js";import"./confirm-dialog-B9re_jFm.js";import"./menu-BkQ4G0tI.js";import"./MailViewChrome-CjK9Dnpp.js";import"./search-query-Bfvoxxg4.js";import"./NavMenuButton-8KfNqFDk.js";import"./useLabels-BZ4I9RAK.js";import"./result-count-BTXdc_1e.js";import"./bottom-sheet-DQgPWkXI.js";import"./circle-help-QkeLuDiC.js";import"./circle-check-BZo2PeBJ.js";function _(){return o.jsx(r.Reading,{})}export{_ as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-cubACEd8.js";import{M as i}from"./MailboxPane-Bo9JttiA.js";import"./useSearchTokenContext-PpLW_UHw.js";import"./kbd-C6M51ovo.js";import"./useMessageBodyContent-oSPoCcAo.js";import"./search-scope-UI1H6AzA.js";import"./useRefreshControl-DPzIiFlp.js";import"./circle-check-big-4GwHrTFa.js";import"./refresh-cw-CuDrOkmw.js";import"./useQueries-BgVJvl8E.js";import"./MailListHeader-CRcUWHvS.js";import"./roving-focus-pflLgyvB.js";import"./search-token-index-DnVW2A-U.js";import"./EmptyState-BvdGNd01.js";import"./ErrorState-C-GqtxHT.js";import"./popover-menu-BFWBKaTJ.js";import"./mail-CfslMQ7s.js";import"./avatar-ByFhyZLr.js";import"./index-BVefvGgO.js";import"./useSignature-C8_KOsXT.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-D87mJggE.js";import"./sections-CI8sUA-m.js";import"./undo-2-DlatIdv3.js";import"./download-hgu-A5WC.js";import"./useCalendarFreeBusy-q7sx9n0O.js";import"./calendar-format-BovOEuV7.js";import"./useCalendars-DpG3wNVl.js";import"./map-pin-CO81Zh5s.js";import"./useLayoutTier-Cme1U69S.js";import"./calendar-suggestion-C_OSjndS.js";import"./attendee-row-D_Iu4VYw.js";import"./minus-tJx7k6NN.js";import"./clock-DHHTtMvk.js";import"./calendar-clash-strip-DoAFMGom.js";import"./bell-off-C0wHlgOp.js";import"./shield-check-C76VpI9Q.js";import"./calendar-report-C-XuHGk-.js";import"./useFilters-CjhcpObW.js";import"./checkbox-D0odK_wH.js";import"./confirm-dialog-B9re_jFm.js";import"./menu-BkQ4G0tI.js";import"./MailViewChrome-CjK9Dnpp.js";import"./search-query-Bfvoxxg4.js";import"./NavMenuButton-8KfNqFDk.js";import"./useLabels-BZ4I9RAK.js";import"./result-count-BTXdc_1e.js";import"./bottom-sheet-DQgPWkXI.js";import"./circle-help-QkeLuDiC.js";import"./circle-check-BZo2PeBJ.js";function _(){return o.jsx(i.Reading,{})}export{_ as component};
@@ -1 +0,0 @@
1
- import{j as t,ao as o}from"./index-cubACEd8.js";const n=()=>t.jsx(o,{to:"/settings/accounts"});export{n as component};
@@ -1 +0,0 @@
1
- import{j as r}from"./index-cubACEd8.js";import{B as o}from"./BriefPane-CjGWdd8a.js";import"./useSearchTokenContext-PpLW_UHw.js";import"./kbd-C6M51ovo.js";import"./useMessageBodyContent-oSPoCcAo.js";import"./search-scope-UI1H6AzA.js";import"./MailListHeader-CRcUWHvS.js";import"./roving-focus-pflLgyvB.js";import"./search-token-index-DnVW2A-U.js";import"./useQueries-BgVJvl8E.js";import"./EmptyState-BvdGNd01.js";import"./ErrorState-C-GqtxHT.js";import"./popover-menu-BFWBKaTJ.js";import"./mail-CfslMQ7s.js";import"./avatar-ByFhyZLr.js";import"./index-BVefvGgO.js";import"./useSignature-C8_KOsXT.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-D87mJggE.js";import"./sections-CI8sUA-m.js";import"./undo-2-DlatIdv3.js";import"./download-hgu-A5WC.js";import"./useCalendarFreeBusy-q7sx9n0O.js";import"./calendar-format-BovOEuV7.js";import"./useCalendars-DpG3wNVl.js";import"./map-pin-CO81Zh5s.js";import"./useLayoutTier-Cme1U69S.js";import"./calendar-suggestion-C_OSjndS.js";import"./attendee-row-D_Iu4VYw.js";import"./minus-tJx7k6NN.js";import"./clock-DHHTtMvk.js";import"./calendar-clash-strip-DoAFMGom.js";import"./bell-off-C0wHlgOp.js";import"./shield-check-C76VpI9Q.js";import"./calendar-report-C-XuHGk-.js";import"./useFilters-CjhcpObW.js";import"./checkbox-D0odK_wH.js";import"./confirm-dialog-B9re_jFm.js";import"./menu-BkQ4G0tI.js";import"./useRefreshControl-DPzIiFlp.js";import"./circle-check-big-4GwHrTFa.js";import"./refresh-cw-CuDrOkmw.js";import"./result-count-BTXdc_1e.js";import"./useLabels-BZ4I9RAK.js";import"./wizard-selection-zWa1qc6-.js";function V(){return r.jsx(o.Reading,{})}export{V as component};
@@ -1 +0,0 @@
1
- import{j as r}from"./index-cubACEd8.js";import{B as o}from"./BriefPane-CjGWdd8a.js";import"./useSearchTokenContext-PpLW_UHw.js";import"./kbd-C6M51ovo.js";import"./useMessageBodyContent-oSPoCcAo.js";import"./search-scope-UI1H6AzA.js";import"./MailListHeader-CRcUWHvS.js";import"./roving-focus-pflLgyvB.js";import"./search-token-index-DnVW2A-U.js";import"./useQueries-BgVJvl8E.js";import"./EmptyState-BvdGNd01.js";import"./ErrorState-C-GqtxHT.js";import"./popover-menu-BFWBKaTJ.js";import"./mail-CfslMQ7s.js";import"./avatar-ByFhyZLr.js";import"./index-BVefvGgO.js";import"./useSignature-C8_KOsXT.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-D87mJggE.js";import"./sections-CI8sUA-m.js";import"./undo-2-DlatIdv3.js";import"./download-hgu-A5WC.js";import"./useCalendarFreeBusy-q7sx9n0O.js";import"./calendar-format-BovOEuV7.js";import"./useCalendars-DpG3wNVl.js";import"./map-pin-CO81Zh5s.js";import"./useLayoutTier-Cme1U69S.js";import"./calendar-suggestion-C_OSjndS.js";import"./attendee-row-D_Iu4VYw.js";import"./minus-tJx7k6NN.js";import"./clock-DHHTtMvk.js";import"./calendar-clash-strip-DoAFMGom.js";import"./bell-off-C0wHlgOp.js";import"./shield-check-C76VpI9Q.js";import"./calendar-report-C-XuHGk-.js";import"./useFilters-CjhcpObW.js";import"./checkbox-D0odK_wH.js";import"./confirm-dialog-B9re_jFm.js";import"./menu-BkQ4G0tI.js";import"./useRefreshControl-DPzIiFlp.js";import"./circle-check-big-4GwHrTFa.js";import"./refresh-cw-CuDrOkmw.js";import"./result-count-BTXdc_1e.js";import"./useLabels-BZ4I9RAK.js";import"./wizard-selection-zWa1qc6-.js";function V(){return r.jsx(o.Reading,{})}export{V as component};
@@ -1 +0,0 @@
1
- import{f8 as o,j as r}from"./index-cubACEd8.js";import{O as m}from"./OpenCalendarEvent-lS6fjUiq.js";import"./SignInAgain-DH1Fdj-N.js";import"./CalendarComposePane-Dx8OkeLw.js";import"./calendar-format-BovOEuV7.js";import"./useQueries-BgVJvl8E.js";import"./useCalendars-DpG3wNVl.js";import"./calendar-clash-strip-DoAFMGom.js";import"./attendee-row-D_Iu4VYw.js";import"./avatar-ByFhyZLr.js";import"./minus-tJx7k6NN.js";import"./clock-DHHTtMvk.js";import"./map-pin-CO81Zh5s.js";import"./mail-CfslMQ7s.js";import"./pencil-DYtxEeVu.js";import"./useCalendarWrites-BGQ8emvx.js";import"./ErrorState-C-GqtxHT.js";import"./useCalendarData-DbJEV-YD.js";import"./calendar-report-C-XuHGk-.js";import"./calendar-subscription-B-aAc2Gy.js";function P(){const{calendarObjectId:t}=o.useParams();return r.jsx(m,{calendarObjectId:t})}export{P as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-cubACEd8.js";import{F as r}from"./FlaggedPane-BxOdsnw1.js";import"./useSearchTokenContext-PpLW_UHw.js";import"./kbd-C6M51ovo.js";import"./useMessageBodyContent-oSPoCcAo.js";import"./search-scope-UI1H6AzA.js";import"./MailListHeader-CRcUWHvS.js";import"./roving-focus-pflLgyvB.js";import"./search-token-index-DnVW2A-U.js";import"./useQueries-BgVJvl8E.js";import"./EmptyState-BvdGNd01.js";import"./ErrorState-C-GqtxHT.js";import"./popover-menu-BFWBKaTJ.js";import"./mail-CfslMQ7s.js";import"./avatar-ByFhyZLr.js";import"./index-BVefvGgO.js";import"./useSignature-C8_KOsXT.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-D87mJggE.js";import"./sections-CI8sUA-m.js";import"./undo-2-DlatIdv3.js";import"./download-hgu-A5WC.js";import"./useCalendarFreeBusy-q7sx9n0O.js";import"./calendar-format-BovOEuV7.js";import"./useCalendars-DpG3wNVl.js";import"./map-pin-CO81Zh5s.js";import"./useLayoutTier-Cme1U69S.js";import"./calendar-suggestion-C_OSjndS.js";import"./attendee-row-D_Iu4VYw.js";import"./minus-tJx7k6NN.js";import"./clock-DHHTtMvk.js";import"./calendar-clash-strip-DoAFMGom.js";import"./bell-off-C0wHlgOp.js";import"./shield-check-C76VpI9Q.js";import"./calendar-report-C-XuHGk-.js";import"./useFilters-CjhcpObW.js";import"./checkbox-D0odK_wH.js";import"./confirm-dialog-B9re_jFm.js";import"./menu-BkQ4G0tI.js";import"./MailViewChrome-CjK9Dnpp.js";import"./refresh-cw-CuDrOkmw.js";import"./wizard-selection-zWa1qc6-.js";function S(){return o.jsx(r.Reading,{})}export{S as component};
@@ -1 +0,0 @@
1
- import{e}from"./index-cubACEd8.js";const a=e("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);export{a as M};
@@ -1 +0,0 @@
1
- import{r as i,j as c}from"./index-cubACEd8.js";import{e as y,u as g,C as E,c as b}from"./CalendarComposePane-Dx8OkeLw.js";import{u as x}from"./CalendarComposeSeed-sw3-kicN.js";import{u as I,f as T,U as k,d as w}from"./useCalendars-DpG3wNVl.js";import{a as N}from"./useCalendarWrites-BGQ8emvx.js";import{u as S,n as j}from"./calendar-format-BovOEuV7.js";import"./calendar-clash-strip-DoAFMGom.js";import"./ErrorState-C-GqtxHT.js";import"./useQueries-BgVJvl8E.js";function A({onClose:n}){const{date:m}=S(),a=x(),{calendars:u,timeZoneByCalendarId:f}=I(),d=u.filter(e=>!e.readOnly),{createEvent:p,isWriting:C}=N(),[D,r]=i.useState(""),[t,l]=i.useState(()=>{const e=y(a?.date??m,"");return a?{...e,allDay:a.allDay,startTime:a.allDay?"":a.startTime,endDate:a.endDate,endTime:a.allDay?"":a.endTime}:e}),h=g(t),s=d[0]?.id??"";i.useEffect(()=>{s!==""&&l(e=>e.calendarId===""?{...e,calendarId:s}:e)},[s]);const v=()=>{const e=b(t,{clock:w(),anchor:T(f[t.calendarId]??k)});if(!e.ok){r(e.problem);return}p(e.input).then(o=>{if(o.kind==="written"){r(""),n();return}r(o.kind==="conflict"?"This calendar changed while you were writing. Close the form and try again.":o.message)})};return c.jsx(E,{title:"New event",subtitle:t.date,calendars:d,draft:t,onChange:l,problem:D,saveLabel:"Add",isSaving:C,clashes:h,onSave:v,onCancel:n})}function _(){const{closeEvent:n}=j();return c.jsx(A,{onClose:n})}export{_ as component};
@@ -1 +0,0 @@
1
- import{q as i,h as n,u as a,r as m,j as s}from"./index-cubACEd8.js";import{O as p}from"./OnboardingWizard-VEiZ5SiP.js";import{c}from"./onboarding-completion-CgqykfP5.js";import"./checkbox-D0odK_wH.js";import"./minus-tJx7k6NN.js";import"./kbd-C6M51ovo.js";import"./credential-steps-CZFDsRoC.js";import"./card-Bk8XYDq2.js";import"./account-form-helpers-DhckT_PN.js";import"./mail-CfslMQ7s.js";import"./file-json-C-t1pL6m.js";function E(){const o=i(),t=n(),e=a(),r=m.useCallback(l=>{c({queryClient:t,recordCompleted:()=>o.recordEvent("onboarding.completed"),navigateToInbox:()=>{window.location.assign("/mail")}})},[o,t]);return s.jsx(p,{skipWelcome:!1,onComplete:r,onImportConfig:()=>{e({to:"/import"})}})}export{E as component};
@@ -1 +0,0 @@
1
- import{j as o,O as i}from"./index-cubACEd8.js";import{a as m}from"./MailShell-CsFJTXUG.js";import{u as p,O as t}from"./OutboxPane-CP5sRwfd.js";import{u as s}from"./search-mirror-BPmmvfUK.js";import"./FullCompose-B7Gvo6hb.js";import"./ErrorState-C-GqtxHT.js";import"./index-BVefvGgO.js";import"./useMessageBodyContent-oSPoCcAo.js";import"./useSignature-C8_KOsXT.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-D87mJggE.js";import"./sections-CI8sUA-m.js";import"./confirm-dialog-B9re_jFm.js";import"./roving-focus-pflLgyvB.js";import"./useSearchTokenContext-PpLW_UHw.js";import"./kbd-C6M51ovo.js";import"./search-scope-UI1H6AzA.js";import"./circle-check-big-4GwHrTFa.js";import"./clock-DHHTtMvk.js";import"./row-actions-DqODANSe.js";import"./rotate-ccw-gM8iCdpA.js";import"./search-query-Bfvoxxg4.js";import"./NavMenuButton-8KfNqFDk.js";import"./menu-BkQ4G0tI.js";import"./outbox-status-BlKn6P0x.js";function v(){const r=p();return s({to:"/mail/outbox"}),o.jsx(t,{outboxMessageId:r,children:o.jsx(m,{phone:o.jsx(t.Phone,{}),list:o.jsx(t.List,{}),reading:o.jsx(i,{})})})}export{v as component};
@@ -1 +0,0 @@
1
- import{h as g,au as f,i as b,K as y,M as v,cB as x,ex as h,r as p,dJ as L,j as c,ey as d,ez as C,eA as M}from"./index-cubACEd8.js";import{c as k}from"./popover-menu-BFWBKaTJ.js";import{am as A}from"./MailListHeader-CRcUWHvS.js";import{a as E}from"./useLabels-BZ4I9RAK.js";const z=e=>{const t=new Set;for(const s of e)s&&t.add(s);return t.size>1?{accountId:void 0,restriction:"spansAccounts",moveDisabledHint:"Move only works within one account — clear selection or pick messages from a single account"}:{accountId:t.size===1?[...t][0]:void 0,restriction:void 0,moveDisabledHint:void 0}},I=e=>{const{mailboxId:t,messages:s}=e,a=g(),{pushError:l}=f(),{mutateAsync:r,isPending:o}=b({...h(),onError:(n,i)=>{l({title:i.body.action==="Remove"?"Couldn't remove label":"Couldn't apply label",detail:x(n),error:n})},onSettled:(n,i,u)=>{y(a,v(A(u.body.messageIds??[],s??[],t)))}});return{applyLabel:p.useCallback((n,i,u)=>{n.length!==0&&L(n,m=>r({body:{messageIds:m,labelId:i,action:u}}))},[r]),isPending:o}};function S({accountId:e,mailboxId:t,messageIds:s}){const{labels:a}=E(e),{applyLabel:l}=I({mailboxId:t}),r=p.useMemo(()=>a.map(o=>({key:o.labelId,label:o.name,icon:c.jsx("span",{className:`size-2.5 rounded-full ${C(o.color)?d[o.color]:d.Default}`}),onSelect:()=>l(s,o.labelId,"Apply")})),[a,s,l]);return r.length===0?null:c.jsx(k,{triggerLabel:"Apply label to selected messages",triggerIcon:c.jsx(M,{className:"size-4 text-fg-subtle"}),triggerText:"Apply label",items:r,align:"start",nested:!0,touch:!1,triggerClassName:"min-h-11 w-full justify-start gap-3 px-4 py-2.5 text-sm font-normal text-fg"})}const j=3,_=({hasSearchQuery:e,freeText:t,residualTokenCount:s})=>{if(!e||s>0)return!1;const a=t.trim();return a.length===0||a.length>=j},B=e=>e===void 0?{kind:"unknown"}:{kind:"exact",value:e};export{S as L,z as r,_ as s,B as t};
@@ -1 +0,0 @@
1
- import{j as t,O as o}from"./index-cubACEd8.js";const n=()=>t.jsx(o,{});export{n as component};
@@ -1 +0,0 @@
1
- import{r as m,j as c}from"./index-cubACEd8.js";import{y as b,C as D,j as x,s as w}from"./calendar-suggestion-C_OSjndS.js";import{E as T}from"./EmptyState-BvdGNd01.js";import{e as C,p as j,a as A,E as v,u as k,C as N}from"./CalendarComposePane-Dx8OkeLw.js";import{e as F,h as O,u as R,d as E,f as Z,U as L}from"./useCalendars-DpG3wNVl.js";import{c as P}from"./calendar-report-C-XuHGk-.js";import{M as U,n as H}from"./calendar-format-BovOEuV7.js";import"./ErrorState-C-GqtxHT.js";import"./calendar-clash-strip-DoAFMGom.js";import"./useQueries-BgVJvl8E.js";function z(e,t,d){const n={title:e.summary,location:e.location};if(e.allDay){const o=e.dtStart.slice(0,10),i=e.dtEnd.slice(0,10);return{...C(o,t),...n,allDay:!0,startTime:"",endDate:i>o?F(i,-1):o,endTime:""}}const a=o=>e.zoneCertainty==="Ambiguous"?o:O(o,d),s=a(e.dtStart),l=a(e.dtEnd);return{...C(s.slice(0,10),t),...n,startTime:s.slice(11,16),endDate:l.slice(0,10),endTime:l.slice(11,16)}}function B(e,t,d,n){const a=j(t,d,n);if(!a.ok)return a;const l=e.zoneCertainty==="Ambiguous"||a.patch.start!==void 0?{...a.patch,...A(d,n.clock),allDay:d.allDay,timeZone:n.anchor}:a.patch;return{ok:!0,input:{calendarId:d.calendarId,event:l}}}const g="Add from mail",M="The invitation named a time zone nothing could resolve. The time below is as the mail wrote it — check it before adding.";function _({suggestionId:e,onClose:t}){const{suggestion:d,isLoading:n,error:a}=b(e),s=d??void 0,[l,o]=m.useState(void 0);s!==void 0&&l===void 0&&o(s);const i=l??s;if(i!==void 0)return c.jsx($,{suggestion:i,onClose:t},i.suggestionId);if(a!==null){const u="Couldn't read what your mail is waiting on.";return c.jsx(v,{title:g,onClose:t,children:c.jsx(D,{text:`${u} Close this and try again.`,reportHref:P(u),className:"m-row-inset"})})}return c.jsx(v,{title:g,onClose:t,children:c.jsx(T,{message:n?"Reading the suggestion…":"This suggestion is no longer waiting on you. It was answered, or a later message replaced it."})})}function $({suggestion:e,onClose:t}){const{calendars:d,defaultCalendarId:n,timeZoneByCalendarId:a}=R(),s=d.filter(r=>!r.readOnly),l=x(),[o]=m.useState(()=>z(e,"",E())),[i,u]=m.useState(o),[y,f]=m.useState(""),S=k(i),p=s.some(r=>r.id===n)?n:s[0]?.id??"";m.useEffect(()=>{p!==""&&u(r=>r.calendarId===""?{...r,calendarId:p}:r)},[p]);const I=()=>{const r=B(e,o,i,{clock:E(),anchor:Z(a[i.calendarId]??L)});if(!r.ok){f(r.problem);return}f(""),l.acceptEdited(e.suggestionId,r.input).then(h=>{if(h.kind==="answered"){t();return}f(`Couldn't add this to your calendar: ${h.message}`)})};return c.jsx(N,{title:g,subtitle:w(e),notice:e.zoneCertainty==="Ambiguous"?M:"",calendars:s,draft:i,onChange:u,problem:y,saveLabel:"Add",isSaving:l.isAnswering,repeatEditable:!1,clashes:S,onSave:I,onCancel:t})}function te(){const e=U(),{closeEvent:t}=H();return e===void 0?null:c.jsx(_,{suggestionId:e,onClose:t})}export{te as component};
@@ -1 +0,0 @@
1
- import{r as m}from"./index-cubACEd8.js";import{u as C,d as g,i as I,t as v,U as p,b as D,r as E}from"./useCalendars-DpG3wNVl.js";import{x as y,I as L}from"./calendar-format-BovOEuV7.js";function Z(a,n){const t=a.map(e=>e.id);if(n.length===0)return t;const s=new Set(n),o=t.filter(e=>s.has(e));return o.length===0?t:o}function b(a){const{calendars:n,colorByCalendarId:t,timeZoneByCalendarId:s,isLoading:o}=C(),e=Z(n,a),r=e.length===n.length?[]:e,c=a.length===0||n.length>0;return{calendars:n,colorByCalendarId:t,timeZoneByCalendarId:s,shown:e,narrowed:r,resolved:c,isLoading:o}}function x(a,n,t){const s=t.join(",");return m.useMemo(()=>{const o=g(),e=new Set(s===""?[]:s.split(","));return a.filter(r=>I(r)&&e.has(r.calendarId)).map(r=>v(r,n[r.calendarId]??p,o))},[a,n,s])}function S({view:a,date:n,calendarIds:t,enabled:s=!0}){const{calendars:o,colorByCalendarId:e,timeZoneByCalendarId:r,shown:c,narrowed:l,resolved:u,isLoading:w}=b(t),h=D(a,n),i=s&&u,d=y({...h,calendarIds:l,enabled:i});L(a,n,l,i);const f=x(d.instances,r,c);return{calendars:o,events:f,colorByCalendarId:e,timeZoneByCalendarId:r,isLoading:w||d.isLoading,error:d.error,retry:d.refetch,instanceOf:E}}export{x as a,S as b,b as u};
@@ -1 +0,0 @@
1
- import{e as M,t as c,j as e,r as N,X as D,as as P,dA as T,f as z,aR as Z,ai as I,eG as L,s as O}from"./index-cubACEd8.js";import{c as _,R as F,C as B}from"./calendar-format-BovOEuV7.js";import{M as C}from"./mail-CfslMQ7s.js";import{G as A}from"./map-pin-CO81Zh5s.js";import{S as W}from"./useLayoutTier-Cme1U69S.js";import{u as G}from"./useQueries-BgVJvl8E.js";const U=M("SlidersHorizontal",[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]]);function X(s){const n=_(s.color),a=s.rsvp==="tentative"||s.status==="tentative";return c("flex min-w-0 overflow-hidden rounded-sm border-l-2 px-1.5 py-0.5",n.soft,n.text,n.rail,s.layout==="column"||s.stacked?"flex-col":"items-center gap-1.5",a&&"border-y border-r border-dashed",a&&n.border,s.rsvp==="declined"&&"opacity-60",s.selected&&"ring-2 ring-ring",s.density==="compact"?"text-2xs":"text-xs")}function $({title:s,timeText:n,layout:a,rsvp:l,hasThread:d,isRecurring:m,zoneCertainty:x,trailing:t,detail:p}){const r=a==="column",i=x==="ambiguous",o=!r&&p!==void 0,u=e.jsxs("span",{className:c("flex min-w-0 items-center gap-1",r&&"w-full",l==="declined"&&"line-through"),children:[n!==""&&e.jsx("span",{className:"shrink-0 tabular-nums opacity-80",children:n}),e.jsx("span",{className:"truncate font-medium",children:s})]}),h=(m||d||i)&&e.jsxs("span",{className:c("flex shrink-0 items-center gap-1",r&&"mt-0.5",!r&&t===void 0&&"ml-auto"),children:[m&&e.jsx(F,{className:"size-2.5","aria-label":"Repeats"}),d&&e.jsx(C,{className:"size-2.5","aria-label":"From mail"}),i&&e.jsx(A,{className:"size-2.5 text-warning","aria-label":"Unclear zone"})]}),g=t!==void 0&&e.jsx("span",{className:c("shrink-0 opacity-80",!r&&"ml-auto"),children:t});return e.jsxs(e.Fragment,{children:[o?e.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[u,h,g]}):e.jsxs(e.Fragment,{children:[u,h,g]}),p]})}function ae({title:s,timeText:n,color:a,layout:l,density:d,rsvp:m,status:x,hasThread:t,isRecurring:p,zoneCertainty:r,selected:i,onClick:o,leading:u,trailing:h,detail:g}){const j=l==="column";return e.jsxs("button",{type:"button",onClick:o,"aria-pressed":i,className:c("group flex w-full min-w-0 text-left outline-none transition-colors","focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-surface",j?"h-full":"items-start",u!==void 0&&"gap-2"),children:[u,e.jsx("span",{className:c(X({color:a,layout:l,density:d,rsvp:m,status:x,selected:i,stacked:g!==void 0}),"flex-1",j&&"h-full"),children:e.jsx($,{title:s,timeText:n,layout:l,rsvp:m,hasThread:t,isRecurring:p,zoneCertainty:r,trailing:h,detail:g})})]})}const E=96,q=6;function re({children:s,hasCard:n,onConfirm:a,onReject:l,blocked:d,blockedReason:m,remaining:x,confirmLabel:t="Add",emptyText:p="Nothing in your mail is waiting on a decision about time.",className:r}){const[i,o]=N.useState(0),[u,h]=N.useState(null);if(!n)return e.jsxs("div",{className:c("flex flex-col items-center gap-2 p-6 text-center",r),children:[e.jsx(W,{className:"size-6 text-fg-subtle","aria-hidden":!0}),e.jsx("p",{className:"text-sm text-fg-muted",children:p})]});const g=Math.abs(i)>E,j=i>0;return e.jsxs("div",{className:c("flex flex-col gap-3",r),children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"touch-pan-y select-none",style:{transform:`translateX(${i}px) rotate(${i/40}deg)`,transition:u===null?"transform 180ms ease-out":"none"},onPointerDown:b=>{h(b.clientX)},onPointerMove:b=>{if(u===null)return;const v=b.clientX-u;Math.abs(v)>q&&!b.currentTarget.hasPointerCapture(b.pointerId)&&b.currentTarget.setPointerCapture(b.pointerId),o(v)},onPointerUp:()=>{Math.abs(i)>E&&(i>0&&!d&&a(),i<0&&l()),h(null),o(0)},onPointerCancel:()=>{h(null),o(0)},children:s}),g&&e.jsx("span",{className:c("pointer-events-none absolute top-3 rounded-md px-2 py-1 text-xs font-semibold",j?"right-3 bg-accent-soft text-accent":"left-3 bg-danger-soft text-danger"),children:j?d?m:t:"Not this"})]}),e.jsxs("p",{className:"text-center text-2xs text-fg-subtle",children:[x," left · swipe right to accept, left to drop, or use the buttons"]})]})}const H="Pick a clock first. The mail never said, and the reader will not choose for you.";function K(s,n){const a=s.zoneOptions;return a===void 0?{settled:!0,timeZone:""}:a.some(l=>l.timeZone===n)?{settled:!0,timeZone:n}:{settled:!1,reason:H}}function S(s){return s.threadSubject===""?s.sender:`${s.sender} — ${s.threadSubject}`}function Q(s){return s>=.85?"Read cleanly":s>=.6?"Read with gaps":"Barely read"}function ie({suggestion:s,whenText:n,onAdd:a,onReview:l,onDismiss:d,onOpenThread:m,busy:x=!1,addBlocked:t=!1,zoneChoice:p,onZoneChoice:r,addLabel:i="Add",touch:o,className:u}){const[h,g]=N.useState(""),[j,b]=N.useState(!1),v=N.useId(),k=p??h,R=f=>{b(!1),r?r(f):g(f)},y=K(s,k),w=f=>()=>{if(!y.settled){b(!0);return}f(y.timeZone)};return e.jsxs("article",{"aria-label":s.title,className:c("flex flex-col gap-2 rounded-lg border border-dashed border-line-strong bg-surface-sunken p-3",u),children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:"block text-2xs uppercase tracking-wider text-fg-subtle",children:["Suggested from mail · ",Q(s.confidence)]}),e.jsx("span",{className:"block truncate text-sm font-medium text-fg",children:s.title}),e.jsx("span",{className:"block text-xs text-fg-muted",children:n}),s.location!==""&&e.jsx("span",{className:"block truncate text-xs text-fg-muted",children:s.location})]}),e.jsx("button",{type:"button","aria-label":"Dismiss suggestion",onClick:d,disabled:x,className:c("flex shrink-0 items-center justify-center rounded-md text-fg-subtle outline-none hover:bg-surface hover:text-fg focus-visible:ring-2 focus-visible:ring-ring",o?"size-11":"size-7"),children:e.jsx(D,{className:"size-4"})})]}),s.ambiguity!==""&&e.jsxs("p",{className:"flex items-start gap-1.5 text-2xs text-warning",children:[e.jsx(P,{className:"mt-0.5 size-3 shrink-0","aria-hidden":!0}),s.ambiguity]}),m?e.jsxs("button",{type:"button",onClick:m,className:"flex w-full min-w-0 items-center gap-1.5 rounded-sm text-left text-2xs text-accent-2 outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring",children:[e.jsx(C,{className:"size-3 shrink-0"}),e.jsx("span",{className:"truncate",children:S(s)})]}):e.jsxs("p",{className:"flex w-full min-w-0 items-center gap-1.5 text-2xs text-fg-subtle",children:[e.jsx(C,{className:"size-3 shrink-0"}),e.jsx("span",{className:"truncate",children:S(s)})]}),s.zoneOptions&&e.jsxs("div",{className:"flex flex-col gap-1.5 rounded-md border border-warning/40 p-2",children:[e.jsxs("p",{className:"flex items-center gap-1.5 text-2xs font-semibold text-warning",children:[e.jsx(A,{className:"size-3 shrink-0","aria-hidden":!0}),"Which clock is this on?"]}),s.zoneOptions.map(f=>e.jsxs("button",{type:"button","aria-pressed":k===f.timeZone,onClick:()=>R(f.timeZone),className:c("rounded-md border px-2 py-1 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",o&&"min-h-11",k===f.timeZone?"border-accent bg-accent-soft":"border-line bg-surface hover:border-line-strong"),children:[e.jsx("span",{className:"block text-xs font-medium text-fg",children:f.label}),e.jsx("span",{className:"block text-2xs text-fg-subtle",children:f.note})]},f.timeZone))]}),!y.settled&&e.jsx(T,{id:v,reason:y.reason,nudged:j,className:"text-2xs text-warning"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(z,{variant:"primary",size:o?"md":"sm",icon:e.jsx(Z,{className:"size-3.5"}),onClick:w(a),disabled:x||t,"aria-describedby":y.settled?void 0:v,className:c(o&&"min-h-11 flex-1",!y.settled&&"opacity-55"),children:i}),l&&e.jsx(z,{variant:"secondary",size:o?"md":"sm",icon:e.jsx(U,{className:"size-3.5"}),onClick:w(l),disabled:x,"aria-describedby":y.settled?void 0:v,className:c(o&&"min-h-11",!y.settled&&"opacity-55"),children:"Change first"})]})]})}function le(s){return s.defaultCalendarId!==""?"ready":s.error!==null?"failed":s.isLoading?"loading":"none"}function oe(s,n){if(s!=="ready")return s==="loading"?"Reading your calendars…":s==="failed"?e.jsxs(e.Fragment,{children:["Couldn't read your calendars, so there is nowhere to add this yet. Reload to try again."," ",e.jsx("a",{href:n,target:"_blank",rel:"noreferrer",className:"font-medium text-accent hover:underline",children:"Report an issue"})]}):e.jsxs(e.Fragment,{children:["You have no calendar yet, so there is nowhere to add this."," ",e.jsx(I,{to:"/settings/calendars",className:"font-medium text-accent hover:underline",children:"Create a calendar"})]})}const Y=O(400,404);function ce(s){const n=G({queries:s.map(t=>({...L({query:{from:t.from,to:t.to}}),meta:Y,staleTime:B}))}),a=s.map(t=>t.from).join("|"),l=n.map(t=>t.data),d=n.map(t=>t.isPending).join("|"),m=N.useMemo(()=>l.flatMap(t=>t?.items??[]),[a,d]),x=N.useMemo(()=>{const t=new Set;return s.forEach((p,r)=>{n[r]?.isPending&&t.add(p.from)}),t},[a,d]);return{spans:m,pendingWindows:x,error:n.find(t=>t.error)?.error??null,refetch:()=>{for(const t of n)t.error&&t.refetch()}}}export{ae as C,ie as E,H as Z,$ as a,re as b,X as c,oe as d,le as e,K as s,ce as u};
@@ -1 +0,0 @@
1
- import{j as E,a1 as K,t as U,f as Q,r as o,aU as R,h as N,G,K as $,M as z,q as B,R as I,S as X,T as V,U as J}from"./index-cubACEd8.js";import{C as Y}from"./circle-check-big-4GwHrTFa.js";import{R as Z}from"./refresh-cw-CuDrOkmw.js";import{u as L}from"./useQueries-BgVJvl8E.js";function ye({state:e,onRefresh:s,label:t,errorMessage:n,hasUpdate:a,size:u="sm",className:c}){const i=e==="refreshing",r=e==="error",h=e==="success",S=r?E.jsx(K,{className:"size-4 text-danger"}):h?E.jsx(Y,{className:"size-4 text-positive"}):E.jsx(Z,{className:U("size-4",i&&"animate-spin")}),w=r?`${t} — failed: ${n??"try again"}`:i?`${t} — refreshing`:h?`${t} — up to date`:a?`${t} — new mail`:t;return E.jsxs("div",{className:"relative inline-flex",children:[E.jsx(Q,{variant:"ghost",size:u,icon:S,onClick:s,disabled:i,"aria-label":w,"aria-busy":i||void 0,title:r?n:t,className:c}),e==="idle"&&a&&E.jsx("span",{"aria-hidden":"true",className:"absolute right-1 top-1 size-1.5 rounded-full bg-accent-2"})]})}const ee=new Set(["discovering_mailboxes","syncing_inbox","syncing_others"]);function P(e){return!!e&&ee.has(e)}const q=3e3,te=q*2,T={syncing:!1,resolved:!1,synced:0,total:0};function we(e,s){const t=e.join(","),[n,a]=o.useState(!1),[u,c]=o.useState(!1);o.useEffect(()=>{a(!1),c(!1)},[t,s]),o.useEffect(()=>{if(!s)return;const m=setTimeout(()=>c(!0),te);return()=>clearTimeout(m)},[t,s]);const i=L({queries:e.map(m=>({...R({path:{accountId:m}}),enabled:s&&!n,refetchInterval:q,meta:{softError:!0}}))}),r=i.every(m=>m.isSuccess||m.isError),h=i.length===0||r||u;let S=!1,w=0,y=0;for(const m of i)if(P(m.data?.syncPhase)){S=!0;for(const l of m.data?.mailboxes??[])w+=l.messagesSynced,y+=l.messagesTotal}const x=s&&h&&!S;return o.useEffect(()=>{x&&a(!0)},[x]),!s||!h?T:{syncing:S,resolved:!0,synced:w,total:y}}const se=180*1e3,xe=30*1e3;let F=0;const M=new Set,re=(e=Date.now())=>{F=e+se;for(const s of M)s()},pe=(e=Date.now())=>e<F,Ee=e=>(M.add(e),()=>{M.delete(e)}),_=6e4,ne=new Set(["sent","drafts","trash","archive"]),C=(e,s)=>{const t=new Map;for(const n of e){const a=s.get(n.mailboxId)?.role;a&&ne.has(a)||t.set(n.mailboxId,n.highWaterMarkUid)}return t},j=(e,s)=>{const t=[];for(const[n,a]of s)a>(e.get(n)??0)&&t.push(n);return t},oe=(e,s)=>j(e,s).length>0,D=o.createContext(null),ae=()=>{const e=o.useContext(D);if(!e)throw new Error("useMailFreshness must be used inside <MailFreshnessProvider>");return e};function be({accountIds:e,children:s}){const t=N(),{resultFolderIndex:n}=G(),a=o.useRef(new Map),u=o.useRef(new Set),c=o.useRef(new Map),[i,r]=o.useState(new Set),h=L({queries:e.map(l=>({...R({path:{accountId:l}}),refetchInterval:_,staleTime:_,meta:{softError:!0}}))}),S=h.map(l=>l.dataUpdatedAt).join(","),w=e.join(",");o.useEffect(()=>{let l=!1;const f=new Set(i);e.forEach((d,p)=>{const b=h[p]?.data;if(!b)return;const g=C(b.mailboxes??[],n),v=c.current.get(d);if(c.current.set(d,g),v){const A=j(v,g);A.length>0&&$(t,z(A))}if(!u.current.has(d)){u.current.add(d),a.current.set(d,g);return}if(f.has(d))return;const W=a.current.get(d)??new Map;oe(W,g)&&(f.add(d),l=!0)}),l&&r(f)},[w,S]);const y=o.useCallback(l=>l.some(f=>i.has(f)),[i]),x=o.useCallback(l=>{r(f=>{if(l.every(p=>!f.has(p)))return f;const d=new Set(f);for(const p of l)d.delete(p);return d});for(const f of l){const d=t.getQueryData(R({path:{accountId:f}}).queryKey);a.current.set(f,C(d?.mailboxes??[],n)),u.current.add(f)}},[t,n]),m=o.useMemo(()=>({hasNewMail:y,acknowledge:x}),[y,x]);return E.jsx(D.Provider,{value:m,children:s})}const ie=2e3,ce=45e3,ue=e=>new Promise(s=>setTimeout(s,e)),k=e=>e instanceof Error&&e.message?e.message:"Something went wrong",le=e=>{V(e,{softError:!0},"user")&&J(e)},O=(e,s)=>e.fetchQuery({...R({path:{accountId:s}}),staleTime:0}),H=e=>e.mailboxes?.find(s=>s.fullPath?.toUpperCase()==="INBOX")?.lastSyncedAt??0,fe=async({accountId:e,readStatus:s,baselineLastSyncAt:t,baselineInboxSyncedAt:n=0,onInboxSynced:a,deadline:u,pollMs:c=ie})=>{let i=!1;for(;;){const r=await s().then(y=>({ok:!0,data:y})).catch(y=>({ok:!1,error:y}));if(!r.ok)return{accountId:e,message:k(r.error)};const{syncPhase:h,lastSyncAt:S}=r.data;if((S??0)>t&&!P(h))return h==="error"?{accountId:e,message:"Sync failed for this account"}:void 0;if(!i&&H(r.data)>n&&(i=!0,a?.()),Date.now()>=u)return{accountId:e,message:"Refresh is taking longer than usual"};await ue(c)}},de=async(e,s,t,n,a)=>{const u=await O(e,t).then(r=>({ok:!0,lastSyncAt:r.lastSyncAt??0,inboxSyncedAt:H(r)})).catch(r=>({ok:!1,error:r}));if(!u.ok)return{accountId:t,enqueued:!1,ok:!1,message:k(u.error)};const c=await I({path:{accountId:t},throwOnError:!0}).then(()=>({ok:!0})).catch(r=>({ok:!1,error:r}));if(!c.ok)return le(c.error),{accountId:t,enqueued:!1,ok:!1,message:k(c.error)};s.recordEvent("sync.triggered");const i=await fe({accountId:t,readStatus:()=>O(e,t),baselineLastSyncAt:u.lastSyncAt,baselineInboxSyncedAt:u.inboxSyncedAt,onInboxSynced:()=>a(t),deadline:n});return i?{accountId:t,enqueued:!0,ok:!1,message:i.message}:{accountId:t,enqueued:!0,ok:!0}},Re=(e,s={})=>{const t=N(),n=B(),{acknowledge:a}=ae(),[u,c]=o.useState("idle"),[i,r]=o.useState(),h=o.useRef(0),S=o.useRef(e);S.current=e;const w=o.useRef(s);w.current=s,o.useEffect(()=>{if(u!=="success")return;const x=setTimeout(()=>c("idle"),2e3);return()=>clearTimeout(x)},[u]);const y=o.useCallback(()=>{const x=S.current;if(x.length===0){c("error"),r("Nothing to refresh yet");return}const m=++h.current;c("refreshing"),r(void 0),re();const l=f=>{h.current===m&&(t.invalidateQueries({queryKey:X({path:{accountId:f}})}),w.current.onSettled?.())};(async()=>{const f=Date.now()+ce,d=await Promise.all(x.map(g=>de(t,n,g,f,l)));if(h.current!==m)return;const p=d.filter(g=>g.enqueued).map(g=>g.accountId);for(const g of p)l(g);p.length>0&&a(p);const b=d.filter(g=>!g.ok);b.length===0?c("success"):(c("error"),r(b[0]?.message))})()},[a,t,n]);return{state:u,errorMessage:i,refresh:y}};export{xe as H,be as M,ye as R,Re as a,P as b,we as c,pe as i,Ee as s,ae as u};