@remit/web-client-dist 0.0.688 → 0.0.689

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 (187) hide show
  1. package/assets/{BriefPane-D9xGqyxR.js → BriefPane-CIgScC6f.js} +1 -1
  2. package/assets/{CalendarEventEditor-Cuivix6B.js → CalendarEventEditor-Bv8Zwepk.js} +1 -1
  3. package/assets/{CalendarEventPopup-RUgpY-Yn.js → CalendarEventPopup-DzSD-pN5.js} +1 -1
  4. package/assets/{CalendarLoadFailed-DsTPS9bF.js → CalendarLoadFailed-DlvWlSvt.js} +1 -1
  5. package/assets/{CalendarQuickCreate-FK6jRrvs.js → CalendarQuickCreate-6gB_5E4G.js} +1 -1
  6. package/assets/{CalendarSession-CJCauncC.js → CalendarSession-DViVPv6J.js} +1 -1
  7. package/assets/{DesktopChrome-CpxOryJF.js → DesktopChrome-m6od8Ja9.js} +1 -1
  8. package/assets/{DropdownMenu-CAD4JZmN.js → DropdownMenu-C_eApX94.js} +1 -1
  9. package/assets/{EmptyState-DirhyLKZ.js → EmptyState-BL1JRo_I.js} +1 -1
  10. package/assets/{ErrorState-BDj_H2Rc.js → ErrorState-CKFCoido.js} +1 -1
  11. package/assets/{FlaggedPane-CXYlNbB4.js → FlaggedPane-B-I6yPP2.js} +1 -1
  12. package/assets/{FullCompose-CLLZZTDi.js → FullCompose-_sj778B4.js} +1 -1
  13. package/assets/{LabelApplyTrigger-BPiCPvOQ.js → LabelApplyTrigger-BhX06pIz.js} +1 -1
  14. package/assets/{MailShell-CaZXZkkc.js → MailShell-C_g9w1zh.js} +1 -1
  15. package/assets/{MailViewChrome-BZA2CsvY.js → MailViewChrome-CvBM49lf.js} +1 -1
  16. package/assets/{MailboxPane-DoBLIguh.js → MailboxPane-DI1t1Hak.js} +1 -1
  17. package/assets/{MessageBody-D6YVQ7Ek.js → MessageBody-Bk3iKnM5.js} +4 -4
  18. package/assets/MessageToolbar-CvppODup.js +1 -0
  19. package/assets/{NavMenuButton-CSk-ecU-.js → NavMenuButton-BkOzMsgi.js} +1 -1
  20. package/assets/{OnboardingWizard-DbvpJ09j.js → OnboardingWizard-Bcxk8WK5.js} +1 -1
  21. package/assets/OutboxPane-DIpS2Rm4.js +1 -0
  22. package/assets/{ReportLink-BTOR-1yq.js → ReportLink-DlgYSSed.js} +1 -1
  23. package/assets/_calendarObjectId-CVhLhFXf.js +1 -0
  24. package/assets/_mailboxId-DlqMqGqM.js +1 -0
  25. package/assets/_messageId-DN1DLs0X.js +1 -0
  26. package/assets/_messageId-DVrkUlX2.js +1 -0
  27. package/assets/_messageId-KN8V6cN7.js +1 -0
  28. package/assets/_outboxMessageId-BIrIq3Vo.js +1 -0
  29. package/assets/_recurrenceId-0huvJmsM.js +1 -0
  30. package/assets/{_slotId-5d6oD_Ma.js → _slotId-DDM7bXIa.js} +1 -1
  31. package/assets/_threadId-BSH0itQ1.js +1 -0
  32. package/assets/_threadId-Bp-Ew-3E.js +1 -0
  33. package/assets/_threadId-CdQh_MJ8.js +1 -0
  34. package/assets/{_view._date-DPulTRnp.js → _view._date-aunsrlO1.js} +1 -1
  35. package/assets/{account-service-status-BcIwnoSK.js → account-service-status-BzuS1vKt.js} +1 -1
  36. package/assets/{accounts-tKoz9mXg.js → accounts-LD3DHIQP.js} +1 -1
  37. package/assets/{advanced-UPYFCj1L.js → advanced-CwHXjE5M.js} +1 -1
  38. package/assets/{agenda-time-DSxqMI31.js → agenda-time-wv3Yn4YC.js} +1 -1
  39. package/assets/{app-chrome-DsNAGBzs.js → app-chrome-Ct8iEAKc.js} +1 -1
  40. package/assets/{appearance-nv_KQzWd.js → appearance-DXhCiVla.js} +1 -1
  41. package/assets/{avatar-CAJhX3gE.js → avatar-UfQRtoX1.js} +1 -1
  42. package/assets/{badge-DL_zWZca.js → badge-Ci5wC_7z.js} +1 -1
  43. package/assets/{bottom-sheet-CXqO5e8V.js → bottom-sheet-BHLpXy8c.js} +1 -1
  44. package/assets/brief-BAVboLUI.js +1 -0
  45. package/assets/{brief-DVz-TCIS.js → brief-CbjthOAj.js} +1 -1
  46. package/assets/{calendar-D-6SDX7I.js → calendar-C7o1JZFZ.js} +1 -1
  47. package/assets/{calendar-Ckmsdwam.js → calendar-Dm6uO2dA.js} +1 -1
  48. package/assets/{calendar-event-popup-BPDsVk8G.js → calendar-event-popup-C9kH8QF7.js} +1 -1
  49. package/assets/{calendar-event-sidebar-DE7aDbdU.js → calendar-event-sidebar-B3JdISzb.js} +1 -1
  50. package/assets/{calendar-failure-note-D04B487B.js → calendar-failure-note-CRMNo9aW.js} +1 -1
  51. package/assets/{calendar-guests-_9JIL5bL.js → calendar-guests-CnGUT-A_.js} +1 -1
  52. package/assets/{calendar-suggestion-wuE0EAnn.js → calendar-suggestion-CtFQODJx.js} +1 -1
  53. package/assets/{calendars-BGSrzGp6.js → calendars-fNaRHaAx.js} +1 -1
  54. package/assets/{card-Bt0rEzaX.js → card-anoxIkUJ.js} +1 -1
  55. package/assets/{checkbox-Ox4avOrC.js → checkbox-CqsFCQg_.js} +1 -1
  56. package/assets/chevron-down-DGwUrOcf.js +1 -0
  57. package/assets/chevron-left-BW50jo-d.js +1 -0
  58. package/assets/{circle-check-big-BUyvgO1_.js → circle-check-big-DLjZoyk0.js} +1 -1
  59. package/assets/{circle-check-DQZO12v1.js → circle-check-d7R16tcy.js} +1 -1
  60. package/assets/{circle-help-BHDb6fr4.js → circle-help-C8FYparP.js} +1 -1
  61. package/assets/{classification-BicjMjYL.js → classification-CRDKgH1K.js} +1 -1
  62. package/assets/{clock-V9PRsNAj.js → clock-Bbm6HW1W.js} +1 -1
  63. package/assets/compose._-_outboxMessageId_-B33uCNdX.js +1 -0
  64. package/assets/compose._-_outboxMessageId_-CHBzY_fa.js +1 -0
  65. package/assets/compose._-_outboxMessageId_-D7hd8Tdl.js +1 -0
  66. package/assets/compose._-_outboxMessageId_-DiYwMDkQ.js +1 -0
  67. package/assets/{config-import-CI_-oqoX.js → config-import-DC-oD8sZ.js} +1 -1
  68. package/assets/{confirm-dialog-B9uXBCde.js → confirm-dialog-IJNXJDPm.js} +1 -1
  69. package/assets/{copy-DGIy9NV0.js → copy-hvuziBW_.js} +1 -1
  70. package/assets/{credential-steps-CEwGV_Jz.js → credential-steps-DlMC5KrE.js} +1 -1
  71. package/assets/{download-CQ1TZW-j.js → download-CG1DfqLR.js} +1 -1
  72. package/assets/{draft-BpctUOpv.js → draft-DNqwi2Zh.js} +1 -1
  73. package/assets/edit-BZa7tCBO.js +1 -0
  74. package/assets/edit-DNs-CH-e.js +1 -0
  75. package/assets/{external-link-C_rqxanx.js → external-link-PMyhSgaf.js} +1 -1
  76. package/assets/{file-json-B9WSoC-B.js → file-json-WnVFOoAJ.js} +1 -1
  77. package/assets/{filters-C0gUXTR2.js → filters-DKLKnl_R.js} +1 -1
  78. package/assets/{flagged-BsnAiP7z.js → flagged-Bjq-IpS_.js} +1 -1
  79. package/assets/flagged-DF7M44oi.js +1 -0
  80. package/assets/{folder-input-8Q2m_scb.js → folder-input-BOF5ZXG3.js} +1 -1
  81. package/assets/{folders-z8VOcTpR.js → folders-CBDVbqCE.js} +1 -1
  82. package/assets/{help-copy-9yhT3UQO.js → help-copy-pLuI87o4.js} +1 -1
  83. package/assets/{import-B1gI2hQx.js → import-LYqvEMAJ.js} +1 -1
  84. package/assets/index-6pj7tvZO.js +1 -0
  85. package/assets/index-BWIWbASS.js +1 -0
  86. package/assets/index-BhHZ2hYz.js +1 -0
  87. package/assets/{index-NTsfKnzH.js → index-BoYUTbor.js} +52 -52
  88. package/assets/index-CJFN6_qF.js +1 -0
  89. package/assets/index-CKwz4x5U.js +1 -0
  90. package/assets/index-CLJXg4M_.js +1 -0
  91. package/assets/{index-BdVwGX5L.js → index-DCmMcCPu.js} +4 -4
  92. package/assets/index-DN1DLs0X.js +1 -0
  93. package/assets/index-DVrkUlX2.js +1 -0
  94. package/assets/{index-CqMlmBtY.css → index-DjD_uOHk.css} +1 -1
  95. package/assets/index-KN8V6cN7.js +1 -0
  96. package/assets/index-icM3qGGf.js +1 -0
  97. package/assets/{kbd-CsEUx1iS.js → kbd-CdSSr8_e.js} +1 -1
  98. package/assets/{label-chip-CCEWnnFq.js → label-chip-5FAmbl-0.js} +1 -1
  99. package/assets/{labels-nI-ApWXD.js → labels-CMfUV9F8.js} +1 -1
  100. package/assets/{mail-HviNQK7z.js → mail-S3HHCKeG.js} +1 -1
  101. package/assets/{mail-YPl0v6Rg.js → mail-VDHZ9yHE.js} +1 -1
  102. package/assets/{menu-Bjei5qcd.js → menu-BoWQGjnP.js} +1 -1
  103. package/assets/{nav-link-Bsus6xvs.js → nav-link-Bdfj8Qsa.js} +1 -1
  104. package/assets/new-CKTDsGv_.js +1 -0
  105. package/assets/onboarding-DGPNq5IJ.js +1 -0
  106. package/assets/{onboarding-completion-DnD7ZKm2.js → onboarding-completion-DapNqjan.js} +1 -1
  107. package/assets/outbox-M7c0xAzB.js +1 -0
  108. package/assets/{pencil-SmE0J4lF.js → pencil-CIMfGyWW.js} +1 -1
  109. package/assets/{people-CeFoz9je.js → people-WnhpS7pI.js} +1 -1
  110. package/assets/{plus-CBEQXEYM.js → plus-CPYNu12K.js} +1 -1
  111. package/assets/{popover-menu-BKr-RjB3.js → popover-menu-BpInrjNp.js} +1 -1
  112. package/assets/{refresh-cw-COTmGpG_.js → refresh-cw-DNktlgJw.js} +1 -1
  113. package/assets/{reply-CkAu_qmt.js → reply-uZv24OMi.js} +1 -1
  114. package/assets/{rich-text-CUFDUo-_.js → rich-text-Z2SPIW-n.js} +1 -1
  115. package/assets/{rich-text-spellcheck-worker-provider-Bi73VIdS.js → rich-text-spellcheck-worker-provider-C9P5xz-f.js} +1 -1
  116. package/assets/{rotate-ccw-DcPTHd9U.js → rotate-ccw-BJZUR8Nt.js} +1 -1
  117. package/assets/{roving-focus-DGskqkqC.js → roving-focus-yjJNzNce.js} +1 -1
  118. package/assets/{row-actions-CO60uRRB.js → row-actions-PBH1Gp1Q.js} +1 -1
  119. package/assets/{search-mirror-DkPI5xYg.js → search-mirror-CuvGXRcx.js} +1 -1
  120. package/assets/{search-scope-DeUeCslw.js → search-scope-t7_lhEwH.js} +1 -1
  121. package/assets/{search-token-index-i96KeAvp.js → search-token-index-CocSlVpd.js} +1 -1
  122. package/assets/{sections-DbaGT3GX.js → sections-BlI9KK6M.js} +1 -1
  123. package/assets/{segmented-control-Duuz4QJh.js → segmented-control-a7ri58vM.js} +1 -1
  124. package/assets/{select-D3KrqhMa.js → select-BzudQ-hj.js} +1 -1
  125. package/assets/{senders-eAH7WB_9.js → senders-CjrCpj3s.js} +1 -1
  126. package/assets/settings-4eabvjnS.js +1 -0
  127. package/assets/{settings-screen-Dc-Ptb7G.js → settings-screen-DRlPhwXt.js} +1 -1
  128. package/assets/{shield-check-DuLyMeRb.js → shield-check-CLfzxgNh.js} +1 -1
  129. package/assets/{suggest-list-Bwwkhu1A.js → suggest-list-D2yVcukg.js} +1 -1
  130. package/assets/{suggested-vips-BNtuB8--.js → suggested-vips-D5AG6FUm.js} +1 -1
  131. package/assets/{suggestion._suggestionId-CLm21cP9.js → suggestion._suggestionId-CDQ4j2h8.js} +1 -1
  132. package/assets/{switch-DOM72IV6.js → switch-BTBLx1IK.js} +1 -1
  133. package/assets/{task._calendarTaskId-C3uxFcb7.js → task._calendarTaskId-DQA8KsVJ.js} +1 -1
  134. package/assets/{undo-2-BHUHtOC6.js → undo-2-B5wu3SLV.js} +1 -1
  135. package/assets/{useCalendarData-CXuwQioO.js → useCalendarData-qfV6gCnL.js} +1 -1
  136. package/assets/{useCalendarScheduling-DFvOUPbg.js → useCalendarScheduling-7KLsotZJ.js} +1 -1
  137. package/assets/{useCalendarSuggestions-epkXEJdf.js → useCalendarSuggestions-BQrUJL_8.js} +1 -1
  138. package/assets/{useCalendarTasks-BygC_sdR.js → useCalendarTasks-97JGdBNu.js} +1 -1
  139. package/assets/{useDebouncedValue-C_EHxcaO.js → useDebouncedValue-BMLVeivZ.js} +1 -1
  140. package/assets/{useFilters-B59gFNK-.js → useFilters-Gs-HP3Pc.js} +1 -1
  141. package/assets/{useLabels-BrzW0a91.js → useLabels-s52ZXGjz.js} +1 -1
  142. package/assets/{useLayoutTier-Bd5ZeqbW.js → useLayoutTier-Byf0e8X8.js} +1 -1
  143. package/assets/{useMediaQuery-Dti_5Bdw.js → useMediaQuery-Bd0VbOGT.js} +1 -1
  144. package/assets/{useMessageBodyContent-zzHQirBA.js → useMessageBodyContent-DECgYR7u.js} +1 -1
  145. package/assets/{useQueries-BWuMMxTL.js → useQueries-wqN_e7rn.js} +1 -1
  146. package/assets/{useRefreshControl-B9CDgsXO.js → useRefreshControl-B-sdQjVt.js} +1 -1
  147. package/assets/{useResultFolderIndex-CAzxcbUl.js → useResultFolderIndex-ETlz8Y4G.js} +1 -1
  148. package/assets/{useSignature-2RGHbdGD.js → useSignature-C5PObLcq.js} +1 -1
  149. package/assets/{warnings-BLb1FQ-u.js → warnings-CxANki4C.js} +1 -1
  150. package/index.html +2 -2
  151. package/package.json +1 -1
  152. package/assets/MessageToolbar-DPpw-H8f.js +0 -1
  153. package/assets/OutboxPane-B-r7Diu5.js +0 -1
  154. package/assets/_calendarObjectId-CwaNizXc.js +0 -1
  155. package/assets/_mailboxId-BtYF9Z-z.js +0 -1
  156. package/assets/_messageId-BOaAe-Cg.js +0 -1
  157. package/assets/_messageId-Dpp0v6qX.js +0 -1
  158. package/assets/_messageId-DrVz3SWm.js +0 -1
  159. package/assets/_outboxMessageId-m8S0EG0y.js +0 -1
  160. package/assets/_recurrenceId-i_lpAOY5.js +0 -1
  161. package/assets/_threadId-Bc_oUcgf.js +0 -1
  162. package/assets/_threadId-DR3-Udrv.js +0 -1
  163. package/assets/_threadId-abYB8VNM.js +0 -1
  164. package/assets/brief-B8h4s7Ej.js +0 -1
  165. package/assets/chevron-down-Dcb1svev.js +0 -1
  166. package/assets/chevron-left-BPKjlJZD.js +0 -1
  167. package/assets/compose._-_outboxMessageId_-BPGN3v1J.js +0 -1
  168. package/assets/compose._-_outboxMessageId_-BipLjF3-.js +0 -1
  169. package/assets/compose._-_outboxMessageId_-DjrjrdOu.js +0 -1
  170. package/assets/compose._-_outboxMessageId_-rVez9Jix.js +0 -1
  171. package/assets/edit-BxTub7jS.js +0 -1
  172. package/assets/edit-DkErEsCT.js +0 -1
  173. package/assets/flagged-DRrc_j4t.js +0 -1
  174. package/assets/index-BOaAe-Cg.js +0 -1
  175. package/assets/index-Ba5vyePJ.js +0 -1
  176. package/assets/index-CYvHKrFm.js +0 -1
  177. package/assets/index-CovWtYXy.js +0 -1
  178. package/assets/index-DBeMMF1M.js +0 -1
  179. package/assets/index-DQEipxIu.js +0 -1
  180. package/assets/index-DQwQYH37.js +0 -1
  181. package/assets/index-Dpp0v6qX.js +0 -1
  182. package/assets/index-DrVz3SWm.js +0 -1
  183. package/assets/index-uWoobwwo.js +0 -1
  184. package/assets/new-OETnXUFu.js +0 -1
  185. package/assets/onboarding-DfnR1O2K.js +0 -1
  186. package/assets/outbox-DCcPw0F-.js +0 -1
  187. package/assets/settings-CTGDnSFz.js +0 -1
@@ -1 +1 @@
1
- import{n as N,r as n,o as k,j as a,p as g}from"./index-NTsfKnzH.js";const R=320,C="cubic-bezier(0.32, 0.9, 0.3, 1)",E=.5,P=.4,T=360;function A(s){return Math.sign(s)*Math.sqrt(Math.abs(s))*4}function L({open:s,onClose:l,children:S,label:Y,dismissLabel:y="Dismiss"}){N({id:"bottom-sheet",open:s,answers:{back:l}});const b=n.useRef(null),f=n.useRef(null),[i,M]=n.useState(T),[m,u]=n.useState(null);k(f,s),n.useLayoutEffect(()=>{const t=b.current;if(!t)return;const e=()=>M(t.offsetHeight);e();const r=new ResizeObserver(e);return r.observe(t),()=>r.disconnect()},[]);const c=n.useRef(null),j=n.useCallback(t=>{t.currentTarget.setPointerCapture(t.pointerId),c.current={startY:t.clientY,lastY:t.clientY,lastT:t.timeStamp,velocity:0,moved:!1},u(0)},[]),w=n.useCallback(t=>{const e=c.current;if(!e)return;const r=t.timeStamp-e.lastT;r>0&&(e.velocity=(t.clientY-e.lastY)/r),e.lastY=t.clientY,e.lastT=t.timeStamp;const o=t.clientY-e.startY;Math.abs(o)>4&&(e.moved=!0);const I=o<0?A(o):o;u(I)},[]),h=n.useCallback(()=>{const t=c.current;if(c.current=null,!t)return;const e=t.lastY-t.startY,o=t.velocity>E||e>i*P;u(null),o&&l()},[i,l]),x=m!==null,p=s?m??0:i,d=Math.min(Math.max(1-p/i,0),1),v=x?"none":`transform ${R}ms ${C}`;return a.jsxs("div",{className:g("absolute inset-0 z-40 select-none overflow-hidden",s||x?"":"pointer-events-none"),children:[a.jsx("button",{type:"button","aria-label":y,tabIndex:-1,onClick:l,className:g("absolute inset-0 bg-black/40",d>0?"pointer-events-auto":"pointer-events-none"),style:{opacity:d*.6,transition:v.replace("transform","opacity")}}),a.jsxs("div",{ref:b,role:"dialog","aria-modal":"true","aria-labelledby":"bottom-sheet-title","aria-hidden":!s,inert:!s,className:"absolute inset-x-0 bottom-0 flex max-h-[92%] flex-col rounded-t-3xl border-t border-line bg-surface pb-[env(safe-area-inset-bottom,0px)] shadow-2xl shadow-black/30",style:{transform:`translateY(${p}px)`,transition:v},children:[a.jsx("h2",{id:"bottom-sheet-title",className:"sr-only",children:Y}),a.jsx("div",{role:"slider","aria-label":"Drag down to dismiss","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(d*100),tabIndex:-1,onPointerDown:j,onPointerMove:w,onPointerUp:h,onPointerCancel:h,className:"flex cursor-grab touch-none justify-center pb-1 pt-2.5 active:cursor-grabbing",children:a.jsx("div",{className:"h-1 w-10 rounded-full bg-fg-subtle/40"})}),a.jsx("div",{ref:f,tabIndex:-1,className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:S})]})]})}export{L as B};
1
+ import{n as N,r as n,o as k,j as a,p as g}from"./index-BoYUTbor.js";const R=320,C="cubic-bezier(0.32, 0.9, 0.3, 1)",E=.5,P=.4,T=360;function A(s){return Math.sign(s)*Math.sqrt(Math.abs(s))*4}function L({open:s,onClose:l,children:S,label:Y,dismissLabel:y="Dismiss"}){N({id:"bottom-sheet",open:s,answers:{back:l}});const b=n.useRef(null),f=n.useRef(null),[i,M]=n.useState(T),[m,u]=n.useState(null);k(f,s),n.useLayoutEffect(()=>{const t=b.current;if(!t)return;const e=()=>M(t.offsetHeight);e();const r=new ResizeObserver(e);return r.observe(t),()=>r.disconnect()},[]);const c=n.useRef(null),j=n.useCallback(t=>{t.currentTarget.setPointerCapture(t.pointerId),c.current={startY:t.clientY,lastY:t.clientY,lastT:t.timeStamp,velocity:0,moved:!1},u(0)},[]),w=n.useCallback(t=>{const e=c.current;if(!e)return;const r=t.timeStamp-e.lastT;r>0&&(e.velocity=(t.clientY-e.lastY)/r),e.lastY=t.clientY,e.lastT=t.timeStamp;const o=t.clientY-e.startY;Math.abs(o)>4&&(e.moved=!0);const I=o<0?A(o):o;u(I)},[]),h=n.useCallback(()=>{const t=c.current;if(c.current=null,!t)return;const e=t.lastY-t.startY,o=t.velocity>E||e>i*P;u(null),o&&l()},[i,l]),x=m!==null,p=s?m??0:i,d=Math.min(Math.max(1-p/i,0),1),v=x?"none":`transform ${R}ms ${C}`;return a.jsxs("div",{className:g("absolute inset-0 z-40 select-none overflow-hidden",s||x?"":"pointer-events-none"),children:[a.jsx("button",{type:"button","aria-label":y,tabIndex:-1,onClick:l,className:g("absolute inset-0 bg-black/40",d>0?"pointer-events-auto":"pointer-events-none"),style:{opacity:d*.6,transition:v.replace("transform","opacity")}}),a.jsxs("div",{ref:b,role:"dialog","aria-modal":"true","aria-labelledby":"bottom-sheet-title","aria-hidden":!s,inert:!s,className:"absolute inset-x-0 bottom-0 flex max-h-[92%] flex-col rounded-t-3xl border-t border-line bg-surface pb-[env(safe-area-inset-bottom,0px)] shadow-2xl shadow-black/30",style:{transform:`translateY(${p}px)`,transition:v},children:[a.jsx("h2",{id:"bottom-sheet-title",className:"sr-only",children:Y}),a.jsx("div",{role:"slider","aria-label":"Drag down to dismiss","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(d*100),tabIndex:-1,onPointerDown:j,onPointerMove:w,onPointerUp:h,onPointerCancel:h,className:"flex cursor-grab touch-none justify-center pb-1 pt-2.5 active:cursor-grabbing",children:a.jsx("div",{className:"h-1 w-10 rounded-full bg-fg-subtle/40"})}),a.jsx("div",{ref:f,tabIndex:-1,className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:S})]})]})}export{L as B};
@@ -0,0 +1 @@
1
+ import{j as r,O as i}from"./index-BoYUTbor.js";import{a as m}from"./MailShell-C_g9w1zh.js";import{B as o}from"./BriefPane-CIgScC6f.js";import"./nav-link-Bdfj8Qsa.js";import{a as p}from"./search-token-index-CocSlVpd.js";import"./reply-uZv24OMi.js";import{u as e}from"./search-mirror-CuvGXRcx.js";import"./useMessageBodyContent-DECgYR7u.js";import"./FullCompose-_sj778B4.js";import"./index-DCmMcCPu.js";import"./useSignature-C5PObLcq.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-BMLVeivZ.js";import"./suggest-list-D2yVcukg.js";import"./sections-BlI9KK6M.js";import"./useMediaQuery-Bd0VbOGT.js";import"./chevron-down-DGwUrOcf.js";import"./ErrorState-CKFCoido.js";import"./confirm-dialog-IJNXJDPm.js";import"./search-scope-t7_lhEwH.js";import"./app-chrome-Ct8iEAKc.js";import"./MessageToolbar-CvppODup.js";import"./MessageBody-Bk3iKnM5.js";import"./kbd-CdSSr8_e.js";import"./roving-focus-yjJNzNce.js";import"./useQueries-wqN_e7rn.js";import"./badge-Ci5wC_7z.js";import"./undo-2-B5wu3SLV.js";import"./DropdownMenu-C_eApX94.js";import"./popover-menu-BpInrjNp.js";import"./mail-VDHZ9yHE.js";import"./download-CG1DfqLR.js";import"./avatar-UfQRtoX1.js";import"./EmptyState-BL1JRo_I.js";import"./calendar-suggestion-CtFQODJx.js";import"./useCalendarSuggestions-BQrUJL_8.js";import"./agenda-time-wv3Yn4YC.js";import"./plus-CPYNu12K.js";import"./calendar-format-BwCpz-JZ.js";import"./calendar-C7o1JZFZ.js";import"./calendar-failure-note-CRMNo9aW.js";import"./checkbox-CqsFCQg_.js";import"./clock-Bbm6HW1W.js";import"./segmented-control-a7ri58vM.js";import"./shield-check-CLfzxgNh.js";import"./useLayoutTier-Byf0e8X8.js";import"./menu-BoWQGjnP.js";import"./useFilters-Gs-HP3Pc.js";import"./select-BzudQ-hj.js";import"./folder-input-BOF5ZXG3.js";import"./label-chip-5FAmbl-0.js";import"./LabelApplyTrigger-BhX06pIz.js";import"./useLabels-s52ZXGjz.js";import"./useRefreshControl-B-sdQjVt.js";import"./circle-check-big-DLjZoyk0.js";import"./refresh-cw-DNktlgJw.js";import"./wizard-selection-zWa1qc6-.js";function lr(){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{lr as component};
@@ -1 +1 @@
1
- import{j as r}from"./index-NTsfKnzH.js";import{E as t}from"./ErrorState-BDj_H2Rc.js";const i=({error:e,reset:o})=>r.jsx("div",{className:"flex h-full items-center justify-center bg-canvas p-4",children:r.jsx(t,{title:"Couldn't load your mailboxes",error:e,onRetry:o})});export{i as errorComponent};
1
+ import{j as r}from"./index-BoYUTbor.js";import{E as t}from"./ErrorState-CKFCoido.js";const i=({error:e,reset:o})=>r.jsx("div",{className:"flex h-full items-center justify-center bg-canvas p-4",children:r.jsx(t,{title:"Couldn't load your mailboxes",error:e,onRetry:o})});export{i as errorComponent};
@@ -1 +1 @@
1
- import{H as B,r as c,u as k,G as i,cf as O,cg as C,c5 as F}from"./index-NTsfKnzH.js";import{c as R}from"./nav-link-Bsus6xvs.js";function y(e,n){if(e===void 0)return{shouldBlockFn:()=>!0,withResolver:!1};if("shouldBlockFn"in e)return e;if(typeof e=="function")return{shouldBlockFn:async()=>await e(),enableBeforeUnload:!0,withResolver:!1};const a=!!(e.condition??!0),t=e.blockerFn;return{shouldBlockFn:async()=>a&&t!==void 0?await t():a,enableBeforeUnload:a,withResolver:t===void 0}}function j(e,n){const{shouldBlockFn:a,enableBeforeUnload:t=!0,disabled:s=!1,withResolver:h=!1}=y(e),u=B(),{history:d}=u,[f,v]=c.useState({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0});return c.useEffect(()=>{const o=async r=>{function T(p){const w=u.parseLocation(p),m=u.getMatchedRoutes(w.pathname);return m.foundRoute===void 0?{routeId:"__notFound__",fullPath:w.pathname,pathname:w.pathname,params:m.routeParams,search:u.options.parseSearch(p.search)}:{routeId:m.foundRoute.id,fullPath:m.foundRoute.fullPath,pathname:w.pathname,params:m.routeParams,search:u.options.parseSearch(p.search)}}const I=T(r.currentLocation),g=T(r.nextLocation);if(I.routeId==="__notFound__"&&g.routeId!=="__notFound__")return!1;const b=await a({action:r.action,current:I,next:g});if(!h)return b;if(!b)return!1;const E=await new Promise(p=>{v({status:"blocked",current:I,next:g,action:r.action,proceed:()=>p(!1),reset:()=>p(!0)})});return v({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0}),E};return s?void 0:d.block({blockerFn:o,enableBeforeUnload:t})},[a,t,s,h,d,u]),f}const l="/calendar/$view/$date",$="/calendar/$view/$date/suggestion/$suggestionId",_="/calendar/$view/$date/task/$calendarTaskId";function P(){const e=i({from:l,shouldThrow:!1}),n=O({from:l,shouldThrow:!1}),a=e?.view??"",t=e?.date??"",s=n?.calendarId;return c.useMemo(()=>({...C({view:a,date:t},F(new Date)),calendarIds:s??[]}),[a,t,s])}function S(){const e=i({from:"/calendar/$view/$date/$calendarObjectId",shouldThrow:!1}),n=i({from:"/calendar/$view/$date/$calendarObjectId/$recurrenceId",shouldThrow:!1}),a=e?.calendarObjectId,t=n?.recurrenceId;return c.useMemo(()=>a?{calendarObjectId:a,recurrenceId:t}:void 0,[a,t])}function V(){return i({from:_,shouldThrow:!1})?.calendarTaskId}function D(){return i({from:$,shouldThrow:!1})?.suggestionId}function U(){const e=i({from:"/calendar/$view/$date/$calendarObjectId/edit",shouldThrow:!1}),n=i({from:"/calendar/$view/$date/$calendarObjectId/$recurrenceId/edit",shouldThrow:!1}),a=e?.calendarObjectId??n?.calendarObjectId,t=n?.recurrenceId;return c.useMemo(()=>a?{calendarObjectId:a,recurrenceId:t}:void 0,[a,t])}function L(){const e=O({from:"/calendar/$view/$date/new",shouldThrow:!1}),n=e?.start,a=e?.end,t=e!==void 0;return c.useMemo(()=>t?{start:n,end:a}:void 0,[t,n,a])}function M(){const e=U(),n=i({from:"/calendar/$view/$date/new",shouldThrow:!1}),a=i({from:$,shouldThrow:!1});return n!==void 0||a!==void 0||e!==void 0}function G(){const e=k(),n=B(),a=R(),{view:t,date:s}=P(),h=S(),u=V(),d=h!==void 0||u!==void 0,f=c.useCallback(o=>{e({to:l,params:o,search:!0,hash:a})},[e,a]),v=c.useCallback(o=>n.buildLocation({to:l,params:{view:"day",date:o},search:!0,hash:a}).href,[n,a]);return c.useMemo(()=>({goToView:o=>f({view:o,date:s}),goToToday:()=>f({view:t,date:F(new Date)}),goToDate:o=>f({view:t,date:o}),setCalendarIds:o=>e({to:l,params:{view:t,date:s},search:r=>({...r,calendarId:o.length===0?void 0:[...o]}),hash:!0,replace:!0}),setAnchorDate:o=>{d||e({to:l,params:{view:t,date:o},search:!0,hash:a,replace:!0})},zoomToDay:o=>e({href:v(o)}),dayHref:v,openEvent:(o,r)=>e(r===void 0||r===""?{to:"/calendar/$view/$date/$calendarObjectId",params:{view:t,date:s,calendarObjectId:o},search:!0,hash:a,replace:d,state:{openedFromView:!0}}:{to:"/calendar/$view/$date/$calendarObjectId/$recurrenceId",params:{view:t,date:s,calendarObjectId:o,recurrenceId:r},search:!0,hash:a,replace:d,state:{openedFromView:!0}}),openTask:o=>e({to:_,params:{view:t,date:s,calendarTaskId:o},search:!0,hash:a,replace:d,state:{openedFromView:!0}}),closeToView:()=>{if(n.state.location.state.openedFromView===!0){n.history.back();return}e({to:l,params:{view:t,date:s},search:o=>({calendarId:o.calendarId}),hash:a,replace:!0})},openNewEvent:o=>e({to:"/calendar/$view/$date/new",params:{view:t,date:s},search:r=>({...r,...o}),hash:a,replace:d,state:{openedFromView:!0}}),setNewEventBounds:o=>e({to:"/calendar/$view/$date/new",params:{view:t,date:s},search:r=>({...r,...o}),hash:!0,replace:!0,state:r=>r}),openEditor:(o,r)=>e(r===void 0||r===""?{to:"/calendar/$view/$date/$calendarObjectId/edit",params:{view:t,date:s,calendarObjectId:o},search:!0,hash:a,replace:d,state:{openedFromView:!0}}:{to:"/calendar/$view/$date/$calendarObjectId/$recurrenceId/edit",params:{view:t,date:s,calendarObjectId:o,recurrenceId:r},search:!0,hash:a,replace:d,state:{openedFromView:!0}}),changeSuggestionFirst:(o,r)=>e({to:$,params:{view:t,date:r,suggestionId:o},search:!0,hash:a})}),[f,e,v,a,t,s,n,d])}function A(){const e=k();return c.useCallback((n,a,t)=>{if(t===""){e({to:"/calendar/$view/$date/$calendarObjectId",params:{view:"day",date:n,calendarObjectId:a}});return}e({to:"/calendar/$view/$date/$calendarObjectId/$recurrenceId",params:{view:"day",date:n,calendarObjectId:a,recurrenceId:t}})},[e])}function H(){const e=k();return c.useCallback((n,a)=>{e({to:$,params:{view:"day",date:n,suggestionId:a}})},[e])}function K(e,n){const a=c.useRef(n);a.current=n,j({shouldBlockFn:({action:t})=>t!=="BACK"?!1:a.current(),enableBeforeUnload:!1,disabled:!e})}export{P as a,G as b,S as c,U as d,V as e,j as f,A as g,H as h,K as i,L as j,D as k,M as u};
1
+ import{H as B,r as c,u as k,G as i,cf as O,cg as C,c5 as F}from"./index-BoYUTbor.js";import{c as R}from"./nav-link-Bdfj8Qsa.js";function y(e,n){if(e===void 0)return{shouldBlockFn:()=>!0,withResolver:!1};if("shouldBlockFn"in e)return e;if(typeof e=="function")return{shouldBlockFn:async()=>await e(),enableBeforeUnload:!0,withResolver:!1};const a=!!(e.condition??!0),t=e.blockerFn;return{shouldBlockFn:async()=>a&&t!==void 0?await t():a,enableBeforeUnload:a,withResolver:t===void 0}}function j(e,n){const{shouldBlockFn:a,enableBeforeUnload:t=!0,disabled:s=!1,withResolver:h=!1}=y(e),u=B(),{history:d}=u,[f,v]=c.useState({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0});return c.useEffect(()=>{const o=async r=>{function T(p){const w=u.parseLocation(p),m=u.getMatchedRoutes(w.pathname);return m.foundRoute===void 0?{routeId:"__notFound__",fullPath:w.pathname,pathname:w.pathname,params:m.routeParams,search:u.options.parseSearch(p.search)}:{routeId:m.foundRoute.id,fullPath:m.foundRoute.fullPath,pathname:w.pathname,params:m.routeParams,search:u.options.parseSearch(p.search)}}const I=T(r.currentLocation),g=T(r.nextLocation);if(I.routeId==="__notFound__"&&g.routeId!=="__notFound__")return!1;const b=await a({action:r.action,current:I,next:g});if(!h)return b;if(!b)return!1;const E=await new Promise(p=>{v({status:"blocked",current:I,next:g,action:r.action,proceed:()=>p(!1),reset:()=>p(!0)})});return v({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0}),E};return s?void 0:d.block({blockerFn:o,enableBeforeUnload:t})},[a,t,s,h,d,u]),f}const l="/calendar/$view/$date",$="/calendar/$view/$date/suggestion/$suggestionId",_="/calendar/$view/$date/task/$calendarTaskId";function P(){const e=i({from:l,shouldThrow:!1}),n=O({from:l,shouldThrow:!1}),a=e?.view??"",t=e?.date??"",s=n?.calendarId;return c.useMemo(()=>({...C({view:a,date:t},F(new Date)),calendarIds:s??[]}),[a,t,s])}function S(){const e=i({from:"/calendar/$view/$date/$calendarObjectId",shouldThrow:!1}),n=i({from:"/calendar/$view/$date/$calendarObjectId/$recurrenceId",shouldThrow:!1}),a=e?.calendarObjectId,t=n?.recurrenceId;return c.useMemo(()=>a?{calendarObjectId:a,recurrenceId:t}:void 0,[a,t])}function V(){return i({from:_,shouldThrow:!1})?.calendarTaskId}function D(){return i({from:$,shouldThrow:!1})?.suggestionId}function U(){const e=i({from:"/calendar/$view/$date/$calendarObjectId/edit",shouldThrow:!1}),n=i({from:"/calendar/$view/$date/$calendarObjectId/$recurrenceId/edit",shouldThrow:!1}),a=e?.calendarObjectId??n?.calendarObjectId,t=n?.recurrenceId;return c.useMemo(()=>a?{calendarObjectId:a,recurrenceId:t}:void 0,[a,t])}function L(){const e=O({from:"/calendar/$view/$date/new",shouldThrow:!1}),n=e?.start,a=e?.end,t=e!==void 0;return c.useMemo(()=>t?{start:n,end:a}:void 0,[t,n,a])}function M(){const e=U(),n=i({from:"/calendar/$view/$date/new",shouldThrow:!1}),a=i({from:$,shouldThrow:!1});return n!==void 0||a!==void 0||e!==void 0}function G(){const e=k(),n=B(),a=R(),{view:t,date:s}=P(),h=S(),u=V(),d=h!==void 0||u!==void 0,f=c.useCallback(o=>{e({to:l,params:o,search:!0,hash:a})},[e,a]),v=c.useCallback(o=>n.buildLocation({to:l,params:{view:"day",date:o},search:!0,hash:a}).href,[n,a]);return c.useMemo(()=>({goToView:o=>f({view:o,date:s}),goToToday:()=>f({view:t,date:F(new Date)}),goToDate:o=>f({view:t,date:o}),setCalendarIds:o=>e({to:l,params:{view:t,date:s},search:r=>({...r,calendarId:o.length===0?void 0:[...o]}),hash:!0,replace:!0}),setAnchorDate:o=>{d||e({to:l,params:{view:t,date:o},search:!0,hash:a,replace:!0})},zoomToDay:o=>e({href:v(o)}),dayHref:v,openEvent:(o,r)=>e(r===void 0||r===""?{to:"/calendar/$view/$date/$calendarObjectId",params:{view:t,date:s,calendarObjectId:o},search:!0,hash:a,replace:d,state:{openedFromView:!0}}:{to:"/calendar/$view/$date/$calendarObjectId/$recurrenceId",params:{view:t,date:s,calendarObjectId:o,recurrenceId:r},search:!0,hash:a,replace:d,state:{openedFromView:!0}}),openTask:o=>e({to:_,params:{view:t,date:s,calendarTaskId:o},search:!0,hash:a,replace:d,state:{openedFromView:!0}}),closeToView:()=>{if(n.state.location.state.openedFromView===!0){n.history.back();return}e({to:l,params:{view:t,date:s},search:o=>({calendarId:o.calendarId}),hash:a,replace:!0})},openNewEvent:o=>e({to:"/calendar/$view/$date/new",params:{view:t,date:s},search:r=>({...r,...o}),hash:a,replace:d,state:{openedFromView:!0}}),setNewEventBounds:o=>e({to:"/calendar/$view/$date/new",params:{view:t,date:s},search:r=>({...r,...o}),hash:!0,replace:!0,state:r=>r}),openEditor:(o,r)=>e(r===void 0||r===""?{to:"/calendar/$view/$date/$calendarObjectId/edit",params:{view:t,date:s,calendarObjectId:o},search:!0,hash:a,replace:d,state:{openedFromView:!0}}:{to:"/calendar/$view/$date/$calendarObjectId/$recurrenceId/edit",params:{view:t,date:s,calendarObjectId:o,recurrenceId:r},search:!0,hash:a,replace:d,state:{openedFromView:!0}}),changeSuggestionFirst:(o,r)=>e({to:$,params:{view:t,date:r,suggestionId:o},search:!0,hash:a})}),[f,e,v,a,t,s,n,d])}function A(){const e=k();return c.useCallback((n,a,t)=>{if(t===""){e({to:"/calendar/$view/$date/$calendarObjectId",params:{view:"day",date:n,calendarObjectId:a}});return}e({to:"/calendar/$view/$date/$calendarObjectId/$recurrenceId",params:{view:"day",date:n,calendarObjectId:a,recurrenceId:t}})},[e])}function H(){const e=k();return c.useCallback((n,a)=>{e({to:$,params:{view:"day",date:n,suggestionId:a}})},[e])}function K(e,n){const a=c.useRef(n);a.current=n,j({shouldBlockFn:({action:t})=>t!=="BACK"?!1:a.current(),enableBeforeUnload:!1,disabled:!e})}export{P as a,G as b,S as c,U as d,V as e,j as f,A as g,H as h,K as i,L as j,D as k,M as u};
@@ -1 +1 @@
1
- import{j as t,B as l,u as m,a as f,c as x,r as g,A as j,O as d}from"./index-NTsfKnzH.js";import{A as h,S,a as B,D as e,b as A}from"./DesktopChrome-CpxOryJF.js";import"./nav-link-Bsus6xvs.js";import"./reply-CkAu_qmt.js";import{u as E}from"./sections-DbaGT3GX.js";import{u as v}from"./calendar-D-6SDX7I.js";import{E as y}from"./ErrorState-BDj_H2Rc.js";import"./useLayoutTier-Bd5ZeqbW.js";import"./useMediaQuery-Dti_5Bdw.js";import"./avatar-CAJhX3gE.js";import"./popover-menu-BKr-RjB3.js";import"./roving-focus-DGskqkqC.js";import"./mail-YPl0v6Rg.js";import"./app-chrome-DsNAGBzs.js";function a(){const o=E();return t.jsx(h,{search:null,actions:t.jsxs(t.Fragment,{children:[t.jsx(l,{variant:"ghost",size:"sm",icon:t.jsx(S,{className:"size-4"}),title:"Settings","aria-label":"Settings",onClick:()=>o("accounts")}),t.jsx(B,{})]})})}function M(){const o=m(),n=v(),{data:r,isLoading:i,isError:c,error:p,refetch:u}=f({...x(),staleTime:1/0}),s=!!(r&&(r.accounts?.length??0)===0);return g.useEffect(()=>{s&&o({to:"/onboarding",replace:!0})},[s,o]),c?t.jsx(e,{topBar:t.jsx(a,{}),children:t.jsx("div",{className:"flex h-full items-center justify-center bg-canvas p-4",children:t.jsx(y,{title:"Couldn't load your account",error:p,onRetry:()=>{u()}})})}):t.jsx(A,{hideTabBar:n,children:t.jsx(e,{topBar:t.jsx(a,{}),children:i||s?t.jsx(j,{}):t.jsx(d,{})})})}export{M as component};
1
+ import{j as t,B as l,u as m,a as f,c as x,r as g,A as j,O as d}from"./index-BoYUTbor.js";import{A as h,S,a as B,D as e,b as A}from"./DesktopChrome-m6od8Ja9.js";import"./nav-link-Bdfj8Qsa.js";import"./reply-uZv24OMi.js";import{u as E}from"./sections-BlI9KK6M.js";import{u as v}from"./calendar-C7o1JZFZ.js";import{E as y}from"./ErrorState-CKFCoido.js";import"./useLayoutTier-Byf0e8X8.js";import"./useMediaQuery-Bd0VbOGT.js";import"./avatar-UfQRtoX1.js";import"./popover-menu-BpInrjNp.js";import"./roving-focus-yjJNzNce.js";import"./mail-VDHZ9yHE.js";import"./app-chrome-Ct8iEAKc.js";function a(){const o=E();return t.jsx(h,{search:null,actions:t.jsxs(t.Fragment,{children:[t.jsx(l,{variant:"ghost",size:"sm",icon:t.jsx(S,{className:"size-4"}),title:"Settings","aria-label":"Settings",onClick:()=>o("accounts")}),t.jsx(B,{})]})})}function M(){const o=m(),n=v(),{data:r,isLoading:i,isError:c,error:p,refetch:u}=f({...x(),staleTime:1/0}),s=!!(r&&(r.accounts?.length??0)===0);return g.useEffect(()=>{s&&o({to:"/onboarding",replace:!0})},[s,o]),c?t.jsx(e,{topBar:t.jsx(a,{}),children:t.jsx("div",{className:"flex h-full items-center justify-center bg-canvas p-4",children:t.jsx(y,{title:"Couldn't load your account",error:p,onRetry:()=>{u()}})})}):t.jsx(A,{hideTabBar:n,children:t.jsx(e,{topBar:t.jsx(a,{}),children:i||s?t.jsx(j,{}):t.jsx(d,{})})})}export{M as component};
@@ -1 +1 @@
1
- import{j as e,T as g,X as j,p as N,C as v}from"./index-NTsfKnzH.js";import{M as C,d as y}from"./useCalendarSuggestions-epkXEJdf.js";import{P as k}from"./pencil-SmE0J4lF.js";function z({failure:s,focusRef:a}){return e.jsxs("div",{ref:a,role:"alert",tabIndex:-1,className:"flex flex-col gap-2 rounded-md border border-danger/40 bg-danger-soft p-3 text-sm outline-none",children:[e.jsx("p",{className:"text-danger",children:s.text}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:s.onRetry,className:"rounded-md border border-line bg-surface px-3 py-1 text-sm font-medium hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring",children:s.retryLabel??"Try again"}),e.jsx("a",{href:s.reportHref,target:"_blank",rel:"noreferrer",className:"text-sm font-medium text-accent hover:underline",children:"Report an issue"})]})]})}const l="flex size-9 items-center justify-center rounded-full text-fg-muted outline-none hover:bg-surface-sunken hover:text-fg focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-40";function T({headingId:s,headingRef:a,title:n,color:c,when:o,location:r,calendarName:x,availability:m,onEdit:t,onDelete:i,deleting:u=!1,onClose:f,failure:d,failureRef:b,children:p}){const h=y(c);return e.jsxs("div",{className:"flex flex-col gap-3 p-3",children:[e.jsxs("div",{className:"flex justify-end gap-1",children:[t&&e.jsx("button",{type:"button","aria-label":"Edit",onClick:t,className:l,children:e.jsx(k,{className:"size-4"})}),i&&e.jsx("button",{type:"button","aria-label":"Delete",onClick:i,disabled:u,className:l,children:e.jsx(g,{className:"size-4"})}),e.jsx("button",{type:"button","aria-label":"Close",onClick:f,className:l,children:e.jsx(j,{className:"size-4"})})]}),e.jsxs("div",{className:"flex gap-3 px-2",children:[e.jsx("span",{className:N("mt-1.5 size-3.5 shrink-0 rounded-sm",h.solid),"aria-hidden":"true"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{id:s,ref:a,tabIndex:-1,className:"text-xl font-normal break-words text-fg outline-none",children:n===""?"(No title)":n}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:o})]})]}),e.jsxs("dl",{className:"flex flex-col gap-2 px-2 text-sm",children:[r!==""&&e.jsxs("div",{className:"flex gap-3",children:[e.jsx("dt",{children:e.jsx(C,{className:"size-4 text-fg-subtle","aria-label":"Location"})}),e.jsx("dd",{className:"min-w-0 break-words",children:r})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("dt",{children:e.jsx(v,{className:"size-4 text-fg-subtle","aria-label":"Calendar"})}),e.jsxs("dd",{children:[x," · ",m]})]})]}),p,d&&e.jsx(z,{failure:d,focusRef:b})]})}function E({headingId:s,onClose:a,closeRef:n}){return e.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[e.jsx("h2",{id:s,className:"text-base font-medium text-fg",children:"This event was deleted or moved"}),e.jsx("button",{ref:n,type:"button",onClick:a,className:"self-end rounded-md border border-line px-3 py-1.5 text-sm font-medium hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring",children:"Close"})]})}export{z as C,E as a,T as b};
1
+ import{j as e,T as g,X as j,p as N,C as v}from"./index-BoYUTbor.js";import{M as C,d as y}from"./useCalendarSuggestions-BQrUJL_8.js";import{P as k}from"./pencil-CIMfGyWW.js";function z({failure:s,focusRef:a}){return e.jsxs("div",{ref:a,role:"alert",tabIndex:-1,className:"flex flex-col gap-2 rounded-md border border-danger/40 bg-danger-soft p-3 text-sm outline-none",children:[e.jsx("p",{className:"text-danger",children:s.text}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:s.onRetry,className:"rounded-md border border-line bg-surface px-3 py-1 text-sm font-medium hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring",children:s.retryLabel??"Try again"}),e.jsx("a",{href:s.reportHref,target:"_blank",rel:"noreferrer",className:"text-sm font-medium text-accent hover:underline",children:"Report an issue"})]})]})}const l="flex size-9 items-center justify-center rounded-full text-fg-muted outline-none hover:bg-surface-sunken hover:text-fg focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-40";function T({headingId:s,headingRef:a,title:n,color:c,when:o,location:r,calendarName:x,availability:m,onEdit:t,onDelete:i,deleting:u=!1,onClose:f,failure:d,failureRef:b,children:p}){const h=y(c);return e.jsxs("div",{className:"flex flex-col gap-3 p-3",children:[e.jsxs("div",{className:"flex justify-end gap-1",children:[t&&e.jsx("button",{type:"button","aria-label":"Edit",onClick:t,className:l,children:e.jsx(k,{className:"size-4"})}),i&&e.jsx("button",{type:"button","aria-label":"Delete",onClick:i,disabled:u,className:l,children:e.jsx(g,{className:"size-4"})}),e.jsx("button",{type:"button","aria-label":"Close",onClick:f,className:l,children:e.jsx(j,{className:"size-4"})})]}),e.jsxs("div",{className:"flex gap-3 px-2",children:[e.jsx("span",{className:N("mt-1.5 size-3.5 shrink-0 rounded-sm",h.solid),"aria-hidden":"true"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{id:s,ref:a,tabIndex:-1,className:"text-xl font-normal break-words text-fg outline-none",children:n===""?"(No title)":n}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:o})]})]}),e.jsxs("dl",{className:"flex flex-col gap-2 px-2 text-sm",children:[r!==""&&e.jsxs("div",{className:"flex gap-3",children:[e.jsx("dt",{children:e.jsx(C,{className:"size-4 text-fg-subtle","aria-label":"Location"})}),e.jsx("dd",{className:"min-w-0 break-words",children:r})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("dt",{children:e.jsx(v,{className:"size-4 text-fg-subtle","aria-label":"Calendar"})}),e.jsxs("dd",{children:[x," · ",m]})]})]}),p,d&&e.jsx(z,{failure:d,focusRef:b})]})}function E({headingId:s,onClose:a,closeRef:n}){return e.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[e.jsx("h2",{id:s,className:"text-base font-medium text-fg",children:"This event was deleted or moved"}),e.jsx("button",{ref:n,type:"button",onClick:a,className:"self-end rounded-md border border-line px-3 py-1.5 text-sm font-medium hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring",children:"Close"})]})}export{z as C,E as a,T as b};
@@ -1 +1 @@
1
- import{r as _,p,j as s,ao as v,X as I}from"./index-NTsfKnzH.js";import{i as z,c as U,C as W}from"./calendar-guests-_9JIL5bL.js";import{C as B}from"./calendar-event-popup-BPDsVk8G.js";import{R as E,j as y,s as G}from"./agenda-time-DSxqMI31.js";import{S as J}from"./select-D3KrqhMa.js";const L=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],P=["January","February","March","April","May","June","July","August","September","October","November","December"],H=["first","second","third","fourth","last"],N="";function Q(e,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(e))return[];const[a,r,i]=e.split("-").map(Number),d=new Date(Date.UTC(a,r-1,i)),o=L[d.getUTCDay()],m=H[Math.min(Math.floor((i-1)/7),4)],l=n===""?"":`, ${n}`,c=d.getUTCDay()>=1&&d.getUTCDay()<=5;return[`Every day${l}`,...c?[`Every weekday${l}`]:[],`Every week on ${o}${l}`,`Every month on the ${m} ${o}${l}`,`Every year on ${i} ${P[r-1]}${l}`]}const g=({draft:e,onChange:n},a,r)=>n({...e,[a]:r});function b({label:e,children:n}){return s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:e}),n]})}function w(e){return e.date===""||e.endDate===""?!1:e.allDay?e.endDate<e.date:e.startTime===""||e.endTime===""?!1:`${e.endDate}T${e.endTime}`<`${e.date}T${e.startTime}`}function K(e,n){return n===""?{...e,date:n}:e.endDate===""?{...e,date:n,endDate:n}:e.date===""?{...e,date:n}:{...e,date:n,endDate:y(n,G(e.date,e.endDate))}}function X(e,n){const a=e.date!==""&&e.endDate===y(e.date,1)&&e.startTime!==""&&e.endTime!==""&&e.endTime<e.startTime;return n&&a?{...e,allDay:n,endDate:e.date}:!n&&e.date!==""&&e.endDate===e.date&&e.startTime!==""&&e.endTime!==""&&e.endTime<e.startTime?{...e,allDay:n,endDate:y(e.date,1)}:{...e,allDay:n}}function Y({draft:e,onChange:n,touch:a}){const r=a?"min-h-11":"",i=w(e),d=_.useId(),o={"aria-invalid":i,"aria-describedby":i?d:void 0},m=p("w-40",r,i&&"border-danger/60"),l=p("w-28",r,i&&"border-danger/60");return s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(v,{type:"date",value:e.date,"aria-label":"Date",...o,onChange:c=>n(K(e,c.target.value)),className:m}),!e.allDay&&s.jsx(v,{type:"time",value:e.startTime,"aria-label":"Start time",...o,onChange:c=>g({draft:e,onChange:n},"startTime",c.target.value),className:l}),s.jsx("span",{className:"text-sm text-fg-subtle",children:"to"}),s.jsx(v,{type:"date",value:e.endDate,"aria-label":"End date",min:e.date===""?void 0:e.date,...o,onChange:c=>g({draft:e,onChange:n},"endDate",c.target.value),className:m}),!e.allDay&&s.jsx(v,{type:"time",value:e.endTime,"aria-label":"End time",...o,onChange:c=>g({draft:e,onChange:n},"endTime",c.target.value),className:l}),s.jsxs("label",{className:"flex items-center gap-2 text-sm text-fg-muted",children:[s.jsx("input",{type:"checkbox",checked:e.allDay,onChange:c=>n(X(e,c.target.checked)),className:"size-4 accent-current"}),"All day"]})]}),i&&s.jsx("p",{id:d,className:"text-xs text-danger",role:"alert",children:e.allDay?`Ends before it starts. Move the end to ${e.date} or later.`:`Ends before it starts. Move the end past ${e.date} ${e.startTime}, or start earlier.`})]})}function q({draft:e,onChange:n,touch:a,repeatEditable:r=!0,onCustom:i}){return r?s.jsx(V,{value:e.repeat,date:e.date,startTime:e.startTime,onChange:d=>g({draft:e,onChange:n},"repeat",d),onCustom:i,className:a?"min-h-11":""}):s.jsxs("p",{className:"flex items-center gap-2 text-sm text-fg-muted",children:[s.jsx(E,{className:"size-4 shrink-0 text-fg-subtle","aria-hidden":!0}),e.repeat===N?"Does not repeat":e.repeat]})}const S="__custom__";function V({value:e,date:n,startTime:a,onChange:r,onCustom:i,className:d}){const o=Q(n,a),m=e===N||o.includes(e)?o:[e,...o];return s.jsxs(J,{icon:s.jsx(E,{className:"size-4"}),"aria-label":"Repeat",value:e,onChange:l=>{if(l.target.value===S){i?.();return}r(l.target.value)},className:d,children:[s.jsx("option",{value:N,children:"Does not repeat"}),m.map(l=>s.jsx("option",{value:l,children:l},l)),i&&s.jsx("option",{value:S,children:"Custom…"})]})}const Z="h-9 w-full rounded-md border border-line bg-surface-sunken px-2 text-sm text-fg outline-none focus-visible:border-line-strong focus-visible:ring-2 focus-visible:ring-ring/30 disabled:opacity-60";function le({heading:e,draft:n,onChange:a,calendars:r,calendarEditable:i,repeatEditable:d,timeZone:o,timeZones:m,onTimeZone:l,busy:c,onBusy:$,onSave:A,onCancel:f,saving:j=!1,saveLabel:M="Save",problem:T="",failure:D,failureRef:F,titleRef:O,touch:x=!1,children:R,guests:u}){const h=p(Z,x&&"h-11"),C=w(n),k=u!==void 0&&z(n.guests)!==void 0;return s.jsxs("form",{"aria-label":e,"data-event-sidebar":"",className:"flex h-full min-h-0 flex-col bg-surface",onSubmit:t=>{t.preventDefault(),!j&&!C&&!k&&A()},children:[s.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-line px-4 py-2",children:[s.jsx("h2",{className:"text-base font-medium text-fg",children:e}),s.jsx("button",{type:"button","aria-label":"Close",onClick:f,className:p("flex items-center justify-center rounded-full text-fg-muted outline-none hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring",x?"size-11":"size-8"),children:s.jsx(I,{className:"size-4"})})]}),s.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-4 py-4",children:[s.jsx("input",{ref:O,"aria-label":"Title",placeholder:"Add title",value:n.title,onChange:t=>a({...n,title:t.target.value}),className:"border-b-2 border-line bg-transparent pb-1 text-xl text-fg outline-none placeholder:text-fg-subtle focus:border-accent"}),s.jsx(Y,{draft:n,onChange:a,touch:x}),s.jsx(b,{label:"Time zone",children:s.jsx("select",{"aria-label":"Time zone",value:o,onChange:t=>l(t.target.value),className:h,children:m.map(t=>s.jsx("option",{value:t,children:t},t))})}),s.jsx(b,{label:"Repeat",children:s.jsx(q,{draft:n,onChange:a,touch:x,repeatEditable:d})}),s.jsx(b,{label:"Calendar",children:s.jsx("select",{"aria-label":"Calendar",value:n.calendarId,disabled:!i,onChange:t=>a({...n,calendarId:t.target.value}),className:h,children:r.map(t=>s.jsx("option",{value:t.id,children:t.name},t.id))})}),s.jsx(b,{label:"Location",children:s.jsx("input",{"aria-label":"Location",placeholder:"Add location",value:n.location,onChange:t=>a({...n,location:t.target.value}),className:h})}),s.jsx(b,{label:"Show as",children:s.jsxs("select",{"aria-label":"Show as",value:c?"busy":"free",onChange:t=>$(t.target.value==="busy"),className:h,children:[s.jsx("option",{value:"busy",children:"Busy"}),s.jsx("option",{value:"free",children:"Free"})]})}),s.jsx(b,{label:"Description",children:s.jsx("textarea",{"aria-label":"Description",placeholder:"Add description",rows:5,value:n.notes,onChange:t=>a({...n,notes:t.target.value}),className:"w-full rounded-md border border-line bg-surface-sunken px-3 py-2 text-sm text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring/30"})}),u&&s.jsx(b,{label:"Guests",children:s.jsx(U,{value:n.guests,onChange:t=>a({...n,guests:t}),suggestions:u.suggestions,onQuery:u.onQuery,touch:x})}),u&&n.guests.length>0&&u.senders.length>0&&s.jsxs(b,{label:"Send invitations from",children:[s.jsx(W,{label:"Send invitations from",senders:u.senders,value:u.sender,onChange:u.onSender,disabled:!u.senderEditable,touch:x}),s.jsx("p",{className:"mt-1 text-xs text-fg-muted",children:"Default set in Settings, Calendars"})]}),R]}),s.jsxs("div",{className:"flex shrink-0 flex-col gap-2 border-t border-line px-4 py-3",children:[T!==""&&s.jsx("p",{role:"alert",className:"text-sm text-danger",children:T}),D&&s.jsx(B,{failure:D,focusRef:F}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx("button",{type:"button",onClick:f,className:p("rounded-md border border-line px-4 text-sm font-medium hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring",x?"min-h-11":"h-9"),children:"Cancel"}),s.jsx("button",{type:"submit",disabled:j||C||k,className:p("rounded-md bg-accent px-5 text-sm font-medium text-accent-fg hover:bg-accent-hover focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50",x?"min-h-11":"h-9"),children:j?"Saving…":M})]})]})]})}export{le as C};
1
+ import{r as _,p,j as s,ao as v,X as I}from"./index-BoYUTbor.js";import{i as z,c as U,C as W}from"./calendar-guests-CnGUT-A_.js";import{C as B}from"./calendar-event-popup-C9kH8QF7.js";import{R as E,j as y,s as G}from"./agenda-time-wv3Yn4YC.js";import{S as J}from"./select-BzudQ-hj.js";const L=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],P=["January","February","March","April","May","June","July","August","September","October","November","December"],H=["first","second","third","fourth","last"],N="";function Q(e,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(e))return[];const[a,r,i]=e.split("-").map(Number),d=new Date(Date.UTC(a,r-1,i)),o=L[d.getUTCDay()],m=H[Math.min(Math.floor((i-1)/7),4)],l=n===""?"":`, ${n}`,c=d.getUTCDay()>=1&&d.getUTCDay()<=5;return[`Every day${l}`,...c?[`Every weekday${l}`]:[],`Every week on ${o}${l}`,`Every month on the ${m} ${o}${l}`,`Every year on ${i} ${P[r-1]}${l}`]}const g=({draft:e,onChange:n},a,r)=>n({...e,[a]:r});function b({label:e,children:n}){return s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:e}),n]})}function w(e){return e.date===""||e.endDate===""?!1:e.allDay?e.endDate<e.date:e.startTime===""||e.endTime===""?!1:`${e.endDate}T${e.endTime}`<`${e.date}T${e.startTime}`}function K(e,n){return n===""?{...e,date:n}:e.endDate===""?{...e,date:n,endDate:n}:e.date===""?{...e,date:n}:{...e,date:n,endDate:y(n,G(e.date,e.endDate))}}function X(e,n){const a=e.date!==""&&e.endDate===y(e.date,1)&&e.startTime!==""&&e.endTime!==""&&e.endTime<e.startTime;return n&&a?{...e,allDay:n,endDate:e.date}:!n&&e.date!==""&&e.endDate===e.date&&e.startTime!==""&&e.endTime!==""&&e.endTime<e.startTime?{...e,allDay:n,endDate:y(e.date,1)}:{...e,allDay:n}}function Y({draft:e,onChange:n,touch:a}){const r=a?"min-h-11":"",i=w(e),d=_.useId(),o={"aria-invalid":i,"aria-describedby":i?d:void 0},m=p("w-40",r,i&&"border-danger/60"),l=p("w-28",r,i&&"border-danger/60");return s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(v,{type:"date",value:e.date,"aria-label":"Date",...o,onChange:c=>n(K(e,c.target.value)),className:m}),!e.allDay&&s.jsx(v,{type:"time",value:e.startTime,"aria-label":"Start time",...o,onChange:c=>g({draft:e,onChange:n},"startTime",c.target.value),className:l}),s.jsx("span",{className:"text-sm text-fg-subtle",children:"to"}),s.jsx(v,{type:"date",value:e.endDate,"aria-label":"End date",min:e.date===""?void 0:e.date,...o,onChange:c=>g({draft:e,onChange:n},"endDate",c.target.value),className:m}),!e.allDay&&s.jsx(v,{type:"time",value:e.endTime,"aria-label":"End time",...o,onChange:c=>g({draft:e,onChange:n},"endTime",c.target.value),className:l}),s.jsxs("label",{className:"flex items-center gap-2 text-sm text-fg-muted",children:[s.jsx("input",{type:"checkbox",checked:e.allDay,onChange:c=>n(X(e,c.target.checked)),className:"size-4 accent-current"}),"All day"]})]}),i&&s.jsx("p",{id:d,className:"text-xs text-danger",role:"alert",children:e.allDay?`Ends before it starts. Move the end to ${e.date} or later.`:`Ends before it starts. Move the end past ${e.date} ${e.startTime}, or start earlier.`})]})}function q({draft:e,onChange:n,touch:a,repeatEditable:r=!0,onCustom:i}){return r?s.jsx(V,{value:e.repeat,date:e.date,startTime:e.startTime,onChange:d=>g({draft:e,onChange:n},"repeat",d),onCustom:i,className:a?"min-h-11":""}):s.jsxs("p",{className:"flex items-center gap-2 text-sm text-fg-muted",children:[s.jsx(E,{className:"size-4 shrink-0 text-fg-subtle","aria-hidden":!0}),e.repeat===N?"Does not repeat":e.repeat]})}const S="__custom__";function V({value:e,date:n,startTime:a,onChange:r,onCustom:i,className:d}){const o=Q(n,a),m=e===N||o.includes(e)?o:[e,...o];return s.jsxs(J,{icon:s.jsx(E,{className:"size-4"}),"aria-label":"Repeat",value:e,onChange:l=>{if(l.target.value===S){i?.();return}r(l.target.value)},className:d,children:[s.jsx("option",{value:N,children:"Does not repeat"}),m.map(l=>s.jsx("option",{value:l,children:l},l)),i&&s.jsx("option",{value:S,children:"Custom…"})]})}const Z="h-9 w-full rounded-md border border-line bg-surface-sunken px-2 text-sm text-fg outline-none focus-visible:border-line-strong focus-visible:ring-2 focus-visible:ring-ring/30 disabled:opacity-60";function le({heading:e,draft:n,onChange:a,calendars:r,calendarEditable:i,repeatEditable:d,timeZone:o,timeZones:m,onTimeZone:l,busy:c,onBusy:$,onSave:A,onCancel:f,saving:j=!1,saveLabel:M="Save",problem:T="",failure:D,failureRef:F,titleRef:O,touch:x=!1,children:R,guests:u}){const h=p(Z,x&&"h-11"),C=w(n),k=u!==void 0&&z(n.guests)!==void 0;return s.jsxs("form",{"aria-label":e,"data-event-sidebar":"",className:"flex h-full min-h-0 flex-col bg-surface",onSubmit:t=>{t.preventDefault(),!j&&!C&&!k&&A()},children:[s.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-line px-4 py-2",children:[s.jsx("h2",{className:"text-base font-medium text-fg",children:e}),s.jsx("button",{type:"button","aria-label":"Close",onClick:f,className:p("flex items-center justify-center rounded-full text-fg-muted outline-none hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring",x?"size-11":"size-8"),children:s.jsx(I,{className:"size-4"})})]}),s.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-4 py-4",children:[s.jsx("input",{ref:O,"aria-label":"Title",placeholder:"Add title",value:n.title,onChange:t=>a({...n,title:t.target.value}),className:"border-b-2 border-line bg-transparent pb-1 text-xl text-fg outline-none placeholder:text-fg-subtle focus:border-accent"}),s.jsx(Y,{draft:n,onChange:a,touch:x}),s.jsx(b,{label:"Time zone",children:s.jsx("select",{"aria-label":"Time zone",value:o,onChange:t=>l(t.target.value),className:h,children:m.map(t=>s.jsx("option",{value:t,children:t},t))})}),s.jsx(b,{label:"Repeat",children:s.jsx(q,{draft:n,onChange:a,touch:x,repeatEditable:d})}),s.jsx(b,{label:"Calendar",children:s.jsx("select",{"aria-label":"Calendar",value:n.calendarId,disabled:!i,onChange:t=>a({...n,calendarId:t.target.value}),className:h,children:r.map(t=>s.jsx("option",{value:t.id,children:t.name},t.id))})}),s.jsx(b,{label:"Location",children:s.jsx("input",{"aria-label":"Location",placeholder:"Add location",value:n.location,onChange:t=>a({...n,location:t.target.value}),className:h})}),s.jsx(b,{label:"Show as",children:s.jsxs("select",{"aria-label":"Show as",value:c?"busy":"free",onChange:t=>$(t.target.value==="busy"),className:h,children:[s.jsx("option",{value:"busy",children:"Busy"}),s.jsx("option",{value:"free",children:"Free"})]})}),s.jsx(b,{label:"Description",children:s.jsx("textarea",{"aria-label":"Description",placeholder:"Add description",rows:5,value:n.notes,onChange:t=>a({...n,notes:t.target.value}),className:"w-full rounded-md border border-line bg-surface-sunken px-3 py-2 text-sm text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring/30"})}),u&&s.jsx(b,{label:"Guests",children:s.jsx(U,{value:n.guests,onChange:t=>a({...n,guests:t}),suggestions:u.suggestions,onQuery:u.onQuery,touch:x})}),u&&n.guests.length>0&&u.senders.length>0&&s.jsxs(b,{label:"Send invitations from",children:[s.jsx(W,{label:"Send invitations from",senders:u.senders,value:u.sender,onChange:u.onSender,disabled:!u.senderEditable,touch:x}),s.jsx("p",{className:"mt-1 text-xs text-fg-muted",children:"Default set in Settings, Calendars"})]}),R]}),s.jsxs("div",{className:"flex shrink-0 flex-col gap-2 border-t border-line px-4 py-3",children:[T!==""&&s.jsx("p",{role:"alert",className:"text-sm text-danger",children:T}),D&&s.jsx(B,{failure:D,focusRef:F}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx("button",{type:"button",onClick:f,className:p("rounded-md border border-line px-4 text-sm font-medium hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring",x?"min-h-11":"h-9"),children:"Cancel"}),s.jsx("button",{type:"submit",disabled:j||C||k,className:p("rounded-md bg-accent px-5 text-sm font-medium text-accent-fg hover:bg-accent-hover focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50",x?"min-h-11":"h-9"),children:j?"Saving…":M})]})]})]})}export{le as C};
@@ -1 +1 @@
1
- import{j as e,ad as n,p as t}from"./index-NTsfKnzH.js";function i({text:a,reportHref:r,className:s}){return e.jsxs("div",{role:"alert",className:t("flex items-start gap-1.5 rounded-md border border-danger/40 bg-danger-soft p-2 text-xs text-danger",s),children:[e.jsx(n,{className:"mt-0.5 size-3.5 shrink-0","aria-hidden":!0}),e.jsxs("p",{className:"min-w-0 flex-1",children:[a,r&&e.jsxs(e.Fragment,{children:[" ",e.jsx("a",{href:r,target:"_blank",rel:"noreferrer",className:"font-medium text-accent hover:underline",children:"Report an issue"})]})]})]})}export{i as C};
1
+ import{j as e,ad as n,p as t}from"./index-BoYUTbor.js";function i({text:a,reportHref:r,className:s}){return e.jsxs("div",{role:"alert",className:t("flex items-start gap-1.5 rounded-md border border-danger/40 bg-danger-soft p-2 text-xs text-danger",s),children:[e.jsx(n,{className:"mt-0.5 size-3.5 shrink-0","aria-hidden":!0}),e.jsxs("p",{className:"min-w-0 flex-1",children:[a,r&&e.jsxs(e.Fragment,{children:[" ",e.jsx("a",{href:r,target:"_blank",rel:"noreferrer",className:"font-medium text-accent hover:underline",children:"Report an issue"})]})]})]})}export{i as C};
@@ -1 +1 @@
1
- import{b as v,j as e,p as x,X as f,r as b,aq as C}from"./index-NTsfKnzH.js";import{C as k}from"./calendar-event-popup-BPDsVk8G.js";import{C as w}from"./circle-help-BHDb6fr4.js";const z=v("Clock3",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16.5 12",key:"1aq6pp"}]]);const G=v("Crown",[["path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z",key:"1vdc57"}],["path",{d:"M5 21h14",key:"11awu3"}]]),I=/^[^\s@<>",;]+@[^\s@<>",;]+\.[^\s@<>",;]+$/,L=/^\s*"?([^"<]*?)"?\s*<([^>]+)>\s*$/;function h(a){const s=a.trim(),t=L.exec(s),i=(t?.[2]??s).trim().toLowerCase(),l=t?.[1]?.trim()??"";return{text:s,email:i,displayName:l===""?i:l,valid:I.test(i)}}function Y(a,s){return{text:a,email:a,displayName:s===""?a:s,valid:!0}}function A(a,s){return s.valid&&a.some(t=>t.email===s.email)?[...a]:[...a,s]}function q(a){return a.find(s=>!s.valid)}const D="inline-flex max-w-full items-center gap-1 rounded-full border px-2 py-0.5 text-sm";function B({value:a,onChange:s,suggestions:t,onQuery:i,touch:l=!1}){const o=b.useId(),c=b.useId(),[u,g]=b.useState(""),d=a,m=d.find(n=>!n.valid),p=n=>{if(n.trim()==="")return;const r=t.find(y=>y.email===n.trim().toLowerCase()),N=h(r?r.name===""?r.email:`${r.name} <${r.email}>`:n);s(A(d,N)),g(""),i("")},j=n=>s(d.filter(r=>r!==n));return e.jsxs("div",{className:"flex flex-col gap-2",children:[d.length>0&&e.jsx("ul",{"aria-label":"Guests",className:"flex flex-wrap gap-1.5",children:d.map(n=>e.jsxs("li",{className:x(D,n.valid?"border-line bg-surface-sunken text-fg":"border-danger bg-danger-soft text-danger"),children:[e.jsx("span",{className:"truncate",children:n.valid?n.displayName:n.text}),e.jsx("button",{type:"button","aria-label":`Remove ${n.valid?n.email:n.text}`,onClick:()=>j(n),className:"rounded-full p-0.5 hover:bg-surface focus-visible:ring-2 focus-visible:ring-ring",children:e.jsx(f,{className:"size-3"})})]},n.text))}),e.jsx("input",{"aria-label":"Guests","aria-describedby":m?c:void 0,"aria-invalid":m?!0:void 0,placeholder:"Add guests",list:o,value:u,onChange:n=>{const r=n.target.value;if(/[,;]$/.test(r)){p(r.slice(0,-1));return}g(r),i(r)},onKeyDown:n=>{n.key!=="Enter"||u.trim()===""||(n.preventDefault(),p(u))},onBlur:()=>p(u),className:x("h-9 w-full rounded-md border border-line bg-surface-sunken px-2 text-sm text-fg outline-none focus-visible:border-line-strong focus-visible:ring-2 focus-visible:ring-ring/30",l&&"h-11")}),e.jsx("datalist",{id:o,children:t.map(n=>e.jsx("option",{value:n.email,children:n.name},n.email))}),m&&e.jsxs("p",{id:c,role:"status",className:"text-sm text-danger",children:[m.text," is not an email address. Fix or remove it to save."]})]})}function H({label:a,senders:s,value:t,onChange:i,disabled:l=!1,touch:o=!1}){return e.jsx("select",{"aria-label":a,value:t,disabled:l,onChange:c=>i(c.target.value),className:x("h-9 w-full rounded-md border border-line bg-surface-sunken px-2 text-sm text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring/30 disabled:opacity-60",o&&"h-11"),children:s.map(c=>e.jsx("option",{value:c.accountId,children:c.email},c.accountId))})}const M=[["accepted","yes"],["declined","no"],["tentative","maybe"],["needsAction","awaiting"]],S=a=>M.flatMap(([s,t])=>a[s]===0?[]:[`${a[s]} ${t}`]).join(", "),$=a=>a==="accepted"?e.jsx(C,{className:"size-3.5 text-positive","aria-label":"Yes"}):a==="declined"?e.jsx(f,{className:"size-3.5 text-danger","aria-label":"No"}):a==="tentative"?e.jsx(w,{className:"size-3.5 text-fg-muted","aria-label":"Maybe"}):e.jsx(z,{className:"size-3.5 text-fg-subtle","aria-label":"Awaiting"});function T({attendees:a,counts:s}){return a.length===0?null:e.jsxs("section",{"aria-label":"Guests",className:"flex flex-col gap-1.5 px-2 text-sm",children:[e.jsxs("p",{className:"font-medium text-fg",children:[a.length," ",a.length===1?"guest":"guests"]}),e.jsx("p",{className:"text-fg-muted",children:S(s)}),e.jsx("ul",{className:"flex flex-col gap-1",children:a.map(t=>e.jsxs("li",{className:"flex items-center gap-2",children:[$(t.rsvp),e.jsx("span",{className:"min-w-0 truncate",children:t.name===""?t.email:t.name}),t.role==="organizer"&&e.jsxs("span",{className:"inline-flex items-center gap-0.5 text-xs text-fg-muted",children:[e.jsx(G,{className:"size-3","aria-hidden":"true"}),"Organizer"]})]},t.email))})]})}const E=[["accepted","Yes"],["declined","No"],["tentative","Maybe"]];function W({current:a,onAnswer:s,sending:t=!1,failure:i}){return e.jsxs("div",{className:"flex flex-col gap-2 border-t border-line px-2 pt-3",children:[e.jsxs("fieldset",{className:"flex items-center gap-2",children:[e.jsx("legend",{className:"sr-only",children:"Going?"}),e.jsx("span",{"aria-hidden":"true",className:"mr-1 text-sm text-fg",children:"Going?"}),E.map(([l,o])=>e.jsx("button",{type:"button","aria-pressed":a===l,disabled:t,onClick:()=>s(l),className:x("h-8 rounded-full border px-3 text-sm font-medium outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-60",a===l?"border-accent bg-accent text-accent-fg":"border-line hover:bg-surface-sunken"),children:o},l))]}),i&&e.jsx(k,{failure:i})]})}function _({missed:a,onRetry:s,reportHref:t,onDismiss:i}){if(a.length===0)return null;const l=a.join(", ");return e.jsxs("div",{role:"alert",className:"flex flex-wrap items-center gap-3 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-sm",children:[e.jsxs("p",{className:"text-danger",children:["Saved, but the ",a.length===1?"invitation":"invitations"," to"," ",l," didn't go out."]}),e.jsx("button",{type:"button",onClick:s,className:"rounded-md border border-line bg-surface px-3 py-1 font-medium hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring",children:"Try again"}),e.jsx("a",{href:t,target:"_blank",rel:"noreferrer",className:"font-medium text-accent hover:underline",children:"Report an issue"}),e.jsx("button",{type:"button","aria-label":"Dismiss",onClick:i,className:"ml-auto rounded-full p-1 text-fg-muted hover:bg-surface focus-visible:ring-2 focus-visible:ring-ring",children:e.jsx(f,{className:"size-4"})})]})}function K({guests:a,onDismiss:s}){return a.length===0?null:e.jsxs("div",{role:"status",className:"flex flex-wrap items-center gap-3 rounded-md border border-line bg-surface-sunken px-3 py-2 text-sm",children:[e.jsxs("p",{className:"text-fg",children:["Deleted. A cancellation is going to ",a.join(", "),"."]}),e.jsx("button",{type:"button","aria-label":"Dismiss",onClick:s,className:"ml-auto rounded-full p-1 text-fg-muted hover:bg-surface focus-visible:ring-2 focus-visible:ring-ring",children:e.jsx(f,{className:"size-4"})})]})}export{H as C,K as a,_ as b,B as c,T as d,W as e,q as i,Y as s};
1
+ import{b as v,j as e,p as x,X as f,r as b,aq as C}from"./index-BoYUTbor.js";import{C as k}from"./calendar-event-popup-C9kH8QF7.js";import{C as w}from"./circle-help-C8FYparP.js";const z=v("Clock3",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16.5 12",key:"1aq6pp"}]]);const G=v("Crown",[["path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z",key:"1vdc57"}],["path",{d:"M5 21h14",key:"11awu3"}]]),I=/^[^\s@<>",;]+@[^\s@<>",;]+\.[^\s@<>",;]+$/,L=/^\s*"?([^"<]*?)"?\s*<([^>]+)>\s*$/;function h(a){const s=a.trim(),t=L.exec(s),i=(t?.[2]??s).trim().toLowerCase(),l=t?.[1]?.trim()??"";return{text:s,email:i,displayName:l===""?i:l,valid:I.test(i)}}function Y(a,s){return{text:a,email:a,displayName:s===""?a:s,valid:!0}}function A(a,s){return s.valid&&a.some(t=>t.email===s.email)?[...a]:[...a,s]}function q(a){return a.find(s=>!s.valid)}const D="inline-flex max-w-full items-center gap-1 rounded-full border px-2 py-0.5 text-sm";function B({value:a,onChange:s,suggestions:t,onQuery:i,touch:l=!1}){const o=b.useId(),c=b.useId(),[u,g]=b.useState(""),d=a,m=d.find(n=>!n.valid),p=n=>{if(n.trim()==="")return;const r=t.find(y=>y.email===n.trim().toLowerCase()),N=h(r?r.name===""?r.email:`${r.name} <${r.email}>`:n);s(A(d,N)),g(""),i("")},j=n=>s(d.filter(r=>r!==n));return e.jsxs("div",{className:"flex flex-col gap-2",children:[d.length>0&&e.jsx("ul",{"aria-label":"Guests",className:"flex flex-wrap gap-1.5",children:d.map(n=>e.jsxs("li",{className:x(D,n.valid?"border-line bg-surface-sunken text-fg":"border-danger bg-danger-soft text-danger"),children:[e.jsx("span",{className:"truncate",children:n.valid?n.displayName:n.text}),e.jsx("button",{type:"button","aria-label":`Remove ${n.valid?n.email:n.text}`,onClick:()=>j(n),className:"rounded-full p-0.5 hover:bg-surface focus-visible:ring-2 focus-visible:ring-ring",children:e.jsx(f,{className:"size-3"})})]},n.text))}),e.jsx("input",{"aria-label":"Guests","aria-describedby":m?c:void 0,"aria-invalid":m?!0:void 0,placeholder:"Add guests",list:o,value:u,onChange:n=>{const r=n.target.value;if(/[,;]$/.test(r)){p(r.slice(0,-1));return}g(r),i(r)},onKeyDown:n=>{n.key!=="Enter"||u.trim()===""||(n.preventDefault(),p(u))},onBlur:()=>p(u),className:x("h-9 w-full rounded-md border border-line bg-surface-sunken px-2 text-sm text-fg outline-none focus-visible:border-line-strong focus-visible:ring-2 focus-visible:ring-ring/30",l&&"h-11")}),e.jsx("datalist",{id:o,children:t.map(n=>e.jsx("option",{value:n.email,children:n.name},n.email))}),m&&e.jsxs("p",{id:c,role:"status",className:"text-sm text-danger",children:[m.text," is not an email address. Fix or remove it to save."]})]})}function H({label:a,senders:s,value:t,onChange:i,disabled:l=!1,touch:o=!1}){return e.jsx("select",{"aria-label":a,value:t,disabled:l,onChange:c=>i(c.target.value),className:x("h-9 w-full rounded-md border border-line bg-surface-sunken px-2 text-sm text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring/30 disabled:opacity-60",o&&"h-11"),children:s.map(c=>e.jsx("option",{value:c.accountId,children:c.email},c.accountId))})}const M=[["accepted","yes"],["declined","no"],["tentative","maybe"],["needsAction","awaiting"]],S=a=>M.flatMap(([s,t])=>a[s]===0?[]:[`${a[s]} ${t}`]).join(", "),$=a=>a==="accepted"?e.jsx(C,{className:"size-3.5 text-positive","aria-label":"Yes"}):a==="declined"?e.jsx(f,{className:"size-3.5 text-danger","aria-label":"No"}):a==="tentative"?e.jsx(w,{className:"size-3.5 text-fg-muted","aria-label":"Maybe"}):e.jsx(z,{className:"size-3.5 text-fg-subtle","aria-label":"Awaiting"});function T({attendees:a,counts:s}){return a.length===0?null:e.jsxs("section",{"aria-label":"Guests",className:"flex flex-col gap-1.5 px-2 text-sm",children:[e.jsxs("p",{className:"font-medium text-fg",children:[a.length," ",a.length===1?"guest":"guests"]}),e.jsx("p",{className:"text-fg-muted",children:S(s)}),e.jsx("ul",{className:"flex flex-col gap-1",children:a.map(t=>e.jsxs("li",{className:"flex items-center gap-2",children:[$(t.rsvp),e.jsx("span",{className:"min-w-0 truncate",children:t.name===""?t.email:t.name}),t.role==="organizer"&&e.jsxs("span",{className:"inline-flex items-center gap-0.5 text-xs text-fg-muted",children:[e.jsx(G,{className:"size-3","aria-hidden":"true"}),"Organizer"]})]},t.email))})]})}const E=[["accepted","Yes"],["declined","No"],["tentative","Maybe"]];function W({current:a,onAnswer:s,sending:t=!1,failure:i}){return e.jsxs("div",{className:"flex flex-col gap-2 border-t border-line px-2 pt-3",children:[e.jsxs("fieldset",{className:"flex items-center gap-2",children:[e.jsx("legend",{className:"sr-only",children:"Going?"}),e.jsx("span",{"aria-hidden":"true",className:"mr-1 text-sm text-fg",children:"Going?"}),E.map(([l,o])=>e.jsx("button",{type:"button","aria-pressed":a===l,disabled:t,onClick:()=>s(l),className:x("h-8 rounded-full border px-3 text-sm font-medium outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-60",a===l?"border-accent bg-accent text-accent-fg":"border-line hover:bg-surface-sunken"),children:o},l))]}),i&&e.jsx(k,{failure:i})]})}function _({missed:a,onRetry:s,reportHref:t,onDismiss:i}){if(a.length===0)return null;const l=a.join(", ");return e.jsxs("div",{role:"alert",className:"flex flex-wrap items-center gap-3 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-sm",children:[e.jsxs("p",{className:"text-danger",children:["Saved, but the ",a.length===1?"invitation":"invitations"," to"," ",l," didn't go out."]}),e.jsx("button",{type:"button",onClick:s,className:"rounded-md border border-line bg-surface px-3 py-1 font-medium hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring",children:"Try again"}),e.jsx("a",{href:t,target:"_blank",rel:"noreferrer",className:"font-medium text-accent hover:underline",children:"Report an issue"}),e.jsx("button",{type:"button","aria-label":"Dismiss",onClick:i,className:"ml-auto rounded-full p-1 text-fg-muted hover:bg-surface focus-visible:ring-2 focus-visible:ring-ring",children:e.jsx(f,{className:"size-4"})})]})}function K({guests:a,onDismiss:s}){return a.length===0?null:e.jsxs("div",{role:"status",className:"flex flex-wrap items-center gap-3 rounded-md border border-line bg-surface-sunken px-3 py-2 text-sm",children:[e.jsxs("p",{className:"text-fg",children:["Deleted. A cancellation is going to ",a.join(", "),"."]}),e.jsx("button",{type:"button","aria-label":"Dismiss",onClick:s,className:"ml-auto rounded-full p-1 text-fg-muted hover:bg-surface focus-visible:ring-2 focus-visible:ring-ring",children:e.jsx(f,{className:"size-4"})})]})}export{H as C,K as a,_ as b,B as c,T as d,W as e,q as i,Y as s};
@@ -1 +1 @@
1
- import{b as Z,p as c,j as n,S as q,r as z,X as H,ad as Y,B as T,c5 as k,en as p,eo as B}from"./index-NTsfKnzH.js";import{d as K}from"./useCalendarSuggestions-epkXEJdf.js";import{R as X,n as J,o as Q,p as $,d as A}from"./agenda-time-DSxqMI31.js";import{M as g}from"./mail-YPl0v6Rg.js";import{P as V}from"./plus-CBEQXEYM.js";import{N as ee}from"./nav-link-Bsus6xvs.js";import"./reply-CkAu_qmt.js";import{a as R,c as D,f as te,d as O,b as ne}from"./calendar-format-BwCpz-JZ.js";const L=Z("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);const se=Z("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 ae(e){const t=K(e.color),s=e.rsvp==="tentative"||e.status==="tentative";return c("flex min-w-0 overflow-hidden rounded-sm border-l-2 px-1.5 py-0.5",t.soft,t.text,t.rail,e.layout==="column"||e.stacked?"flex-col":"items-center gap-1.5",s&&"border-y border-r border-dashed",s&&t.border,e.rsvp==="declined"&&"opacity-60",e.selected&&"ring-2 ring-ring",e.density==="compact"?"text-2xs":"text-xs")}function re({title:e,timeText:t,layout:s,rsvp:a,hasThread:i,isRecurring:r,zoneCertainty:d,trailing:u,detail:h}){const o=s==="column",m=d==="ambiguous",l=!o&&h!==void 0,x=n.jsxs("span",{className:c("flex min-w-0 items-center gap-1",o&&"w-full",a==="declined"&&"line-through"),children:[t!==""&&n.jsx("span",{className:"shrink-0 tabular-nums opacity-80",children:t}),n.jsx("span",{className:"truncate font-medium",children:e})]}),v=(r||i||m)&&n.jsxs("span",{className:c("flex shrink-0 items-center gap-1",o&&"mt-0.5",!o&&u===void 0&&"ml-auto"),children:[r&&n.jsx(X,{className:"size-2.5","aria-label":"Repeats"}),i&&n.jsx(g,{className:"size-2.5","aria-label":"From mail"}),m&&n.jsx(L,{className:"size-2.5 text-warning","aria-label":"Unclear zone"})]}),b=u!==void 0&&n.jsx("span",{className:c("shrink-0 opacity-80",!o&&"ml-auto"),children:u});return n.jsxs(n.Fragment,{children:[l?n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[x,v,b]}):n.jsxs(n.Fragment,{children:[x,v,b]}),h]})}function Me({title:e,timeText:t,color:s,layout:a,density:i,rsvp:r,status:d,hasThread:u,isRecurring:h,zoneCertainty:o,selected:m,onClick:l,leading:x,trailing:v,detail:b}){const N=a==="column";return n.jsxs("button",{type:"button",onClick:l,"aria-pressed":m,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",N?"h-full":"items-start",x!==void 0&&"gap-2"),children:[x,n.jsx("span",{className:c(ae({color:s,layout:a,density:i,rsvp:r,status:d,selected:m,stacked:b!==void 0}),"flex-1",N&&"h-full"),children:n.jsx(re,{title:e,timeText:t,layout:a,rsvp:r,hasThread:u,isRecurring:h,zoneCertainty:o,trailing:v,detail:b})})]})}function ie({id:e,reason:t,nudged:s,className:a}){return n.jsxs(n.Fragment,{children:[n.jsx("p",{id:e,className:c(a,!s&&"sr-only"),children:t}),n.jsx("span",{role:"status","aria-live":"polite",className:"sr-only",children:s?t:""})]})}function Fe({items:e,className:t}){return e.length===0?n.jsxs("div",{className:c("flex flex-col items-center gap-2 p-6 text-center",t),children:[n.jsx(q,{className:"size-6 text-fg-subtle","aria-hidden":!0}),n.jsx("p",{className:"text-sm text-fg-muted",children:"Nothing in your mail is waiting on a decision about time."})]}):n.jsx("ul",{"aria-label":"Suggested events",className:c("flex min-h-0 flex-col gap-3 overflow-y-auto",t),children:e.map(s=>n.jsx("li",{children:s.card},s.id))})}const oe="Pick a clock first. The mail never said, and the reader will not choose for you.";function le(e,t){const s=e.zoneOptions;return s===void 0?{settled:!0,timeZone:""}:s.some(a=>a.timeZone===t)?{settled:!0,timeZone:t}:{settled:!1,reason:oe}}function M(e){return e.threadSubject===""?e.sender:`${e.sender} — ${e.threadSubject}`}function ce(e){return e>=.85?"Read cleanly":e>=.6?"Read with gaps":"Barely read"}function Ze({suggestion:e,whenText:t,onAdd:s,onReview:a,onDismiss:i,onOpenThread:r,busy:d=!1,addBlocked:u=!1,zoneChoice:h,onZoneChoice:o,addLabel:m="Add",touch:l,className:x}){const[v,b]=z.useState(""),[N,E]=z.useState(!1),S=z.useId(),C=h??v,G=f=>{E(!1),o?o(f):b(f)},y=le(e,C),I=f=>()=>{if(!y.settled){E(!0);return}f(y.timeZone)};return n.jsxs("article",{"aria-label":e.title,className:c("flex flex-col gap-2 rounded-lg border border-dashed border-line-strong bg-surface-sunken p-3",x),children:[n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsxs("span",{className:"block text-2xs uppercase tracking-wider text-fg-subtle",children:["Suggested from mail · ",ce(e.confidence)]}),n.jsx("span",{className:"block truncate text-sm font-medium text-fg",children:e.title}),n.jsx("span",{className:"block text-xs text-fg-muted",children:t}),e.location!==""&&n.jsx("span",{className:"block truncate text-xs text-fg-muted",children:e.location})]}),n.jsx("button",{type:"button","aria-label":"Dismiss suggestion",onClick:i,disabled:d,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",l?"size-11":"size-7"),children:n.jsx(H,{className:"size-4"})})]}),e.ambiguity!==""&&n.jsxs("p",{className:"flex items-start gap-1.5 text-2xs text-warning",children:[n.jsx(Y,{className:"mt-0.5 size-3 shrink-0","aria-hidden":!0}),e.ambiguity]}),r?n.jsxs("button",{type:"button",onClick:r,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:[n.jsx(g,{className:"size-3 shrink-0"}),n.jsx("span",{className:"truncate",children:M(e)})]}):n.jsxs("p",{className:"flex w-full min-w-0 items-center gap-1.5 text-2xs text-fg-subtle",children:[n.jsx(g,{className:"size-3 shrink-0"}),n.jsx("span",{className:"truncate",children:M(e)})]}),e.zoneOptions&&n.jsxs("div",{className:"flex flex-col gap-1.5 rounded-md border border-warning/40 p-2",children:[n.jsxs("p",{className:"flex items-center gap-1.5 text-2xs font-semibold text-warning",children:[n.jsx(L,{className:"size-3 shrink-0","aria-hidden":!0}),"Which clock is this on?"]}),e.zoneOptions.map(f=>n.jsxs("button",{type:"button","aria-pressed":C===f.timeZone,onClick:()=>G(f.timeZone),className:c("rounded-md border px-2 py-1 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",l&&"min-h-11",C===f.timeZone?"border-accent bg-accent-soft":"border-line bg-surface hover:border-line-strong"),children:[n.jsx("span",{className:"block text-xs font-medium text-fg",children:f.label}),n.jsx("span",{className:"block text-2xs text-fg-subtle",children:f.note})]},f.timeZone))]}),!y.settled&&n.jsx(ie,{id:S,reason:y.reason,nudged:N,className:"text-2xs text-warning"}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(T,{variant:"primary",size:l?"md":"sm",icon:n.jsx(V,{className:"size-3.5"}),onClick:I(s),disabled:d||u,"aria-describedby":y.settled?void 0:S,className:c(l&&"min-h-11 flex-1",!y.settled&&"opacity-55"),children:m}),a&&n.jsx(T,{variant:"secondary",size:l?"md":"sm",icon:n.jsx(se,{className:"size-3.5"}),onClick:I(a),disabled:d,"aria-describedby":y.settled?void 0:S,className:c(l&&"min-h-11",!y.settled&&"opacity-55"),children:"Change first"})]})]})}function Be(e){return e.defaultCalendarId!==""?"ready":e.error!==null?"failed":e.isLoading?"loading":"none"}function $e(e,t){if(e!=="ready")return e==="loading"?"Reading your calendars…":e==="failed"?n.jsxs(n.Fragment,{children:["Couldn't read your calendars, so there is nowhere to add this yet. Reload to try again."," ",n.jsx("a",{href:t,target:"_blank",rel:"noreferrer",className:"font-medium text-accent hover:underline",children:"Report an issue"})]}):n.jsxs(n.Fragment,{children:["You have no calendar yet, so there is nowhere to add this."," ",n.jsx(ee,{to:"/settings/calendars",className:"font-medium text-accent hover:underline",children:"Create a calendar"})]})}const de=24,_=7,me=52,w=me*7,fe=e=>({from:p(e,-10),to:p(e,de),floor:p(e,-w),ceiling:p(e,w)}),ue=e=>e.from<=e.floor,xe=e=>e.to>=e.ceiling,pe=(e,t)=>e>t?e:t,he=(e,t)=>e<t?e:t,ye=e=>ue(e)?e:{...e,from:pe(p(e.from,-_),e.floor)},be=e=>xe(e)?e:{...e,to:he(p(e.to,_),e.ceiling)},Le=e=>ye({...e,floor:p(e.from,-w)}),_e=e=>be({...e,ceiling:p(e.to,w)});function Ue(e,t){return t>=e.from&&t<=e.to?e:fe(t)}function Pe(e){const t=new Map;for(const s of e){const a=B("week",s);t.has(a.from)||t.set(a.from,a)}return[...t.values()]}const We=e=>B("week",e).from,ve=1440,F=e=>e.getHours()*60+e.getMinutes();function U(e,t){const s=new Set(e),a=new Map;for(const i of t){const r=new Date(i.start),d=new Date(i.end);if(Number.isNaN(r.getTime())||Number.isNaN(d.getTime())||d.getTime()<=r.getTime())continue;const u=k(r),h=k(new Date(d.getTime()-1));for(let o=u;o<=h;o=p(o,1)){if(!s.has(o))continue;const m=o===u?F(r):0,l=k(d)===o?F(d):ve;if(l<=m)continue;const x=a.get(o);x?x.push({from:m,to:l}):a.set(o,[{from:m,to:l}])}}for(const[i,r]of a)a.set(i,J(r));return a}function Ge(e,t){const s=U(e,t);return new Map(e.map(a=>[a,$(a,s.get(a)??[])]))}const qe=e=>Q(e.from,e.to),j=30,Ne=6,P={Local:"local",Explicit:"explicit",Ambiguous:"ambiguous"},je="The invitation's time zone could not be resolved. Add opens the editor so you can set the time.",ke="The invitation's time zone could not be resolved.";function He(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 we=e=>e.source!=="TextHeuristic";function Ye(e){return e.allDay?e.dtStart.slice(0,10):k(new Date(e.dtStart))}const W=e=>e.summary===""?"Untitled event":e.summary;function Ke(e){if(e.allDay){const t=e.dtStart.slice(0,10),s=e.dtEnd.slice(0,10),a=s>t?p(s,-1):t;return a===t?`${D(t)}, all day`:`${D(t)} – ${D(a)}, all day`}return te({start:e.dtStart,end:e.dtEnd,allDay:e.allDay})}function Se(e,t){return{id:e.suggestionId,calendarId:t.calendarId,title:W(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 Xe(e,t,s){const a=e.organizer===""?s.senderName:e.organizer;return{id:e.suggestionId,threadId:s.threadId,proposed:Se(e,s),organizerName:a===""?"The sender":a,organizerEmail:e.organizer,method:"ics",evidence:"",state:t,sequence:e.sequence}}function Ce(e){return e.zoneCertainty!=="Ambiguous"?"":e.method==="Cancel"?ke:je}function Je(e,t){return{id:e.suggestionId,title:W(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:we(e)?1:.6,ambiguity:Ce(e),suggestedCalendarId:t.calendarId,timeZone:"",zoneCertainty:P[e.zoneCertainty]}}const ze=(e,t)=>Date.parse(t.start)<Date.parse(e.end)&&Date.parse(t.end)>Date.parse(e.start);function Qe(e,t){return t.filter(s=>ze(e,s)).map(s=>({id:`${s.start}/${s.end}`,label:`Busy ${R(s.start)} – ${R(s.end)}`}))}function Ve(e,t){const s=U([e],t).get(e)??[],a=[];for(const i of $(e,s,j))for(let r=i.startMinute;r+j<=i.endMinute&&a.length<Ne;r+=j)a.push({date:e,endDate:e,startTime:A(r),endTime:A(r+j),allDay:!1});return a}function et(e,t,s){const a=t.filter(i=>s.includes(i.startTime)).map(i=>`${O(i.startTime)} – ${O(i.endTime)}`);return`${ne(e)}: ${a.join(", ")}`}export{ie as B,Me as C,Ze as E,re as a,Ue as b,ae as c,qe as d,We as e,Ge as f,ye as g,be as h,_e as i,xe as j,ue as k,Le as l,Fe as m,$e as n,Be as o,Ye as p,we as q,fe as r,Ke as s,Je as t,He as u,Qe as v,Pe as w,Xe as x,Ve as y,et as z};
1
+ import{b as Z,p as c,j as n,S as q,r as z,X as H,ad as Y,B as T,c5 as k,eo as p,ep as B}from"./index-BoYUTbor.js";import{d as K}from"./useCalendarSuggestions-BQrUJL_8.js";import{R as X,n as J,o as Q,p as $,d as A}from"./agenda-time-wv3Yn4YC.js";import{M as g}from"./mail-VDHZ9yHE.js";import{P as V}from"./plus-CPYNu12K.js";import{N as ee}from"./nav-link-Bdfj8Qsa.js";import"./reply-uZv24OMi.js";import{a as R,c as D,f as te,d as O,b as ne}from"./calendar-format-BwCpz-JZ.js";const L=Z("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);const se=Z("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 ae(e){const t=K(e.color),s=e.rsvp==="tentative"||e.status==="tentative";return c("flex min-w-0 overflow-hidden rounded-sm border-l-2 px-1.5 py-0.5",t.soft,t.text,t.rail,e.layout==="column"||e.stacked?"flex-col":"items-center gap-1.5",s&&"border-y border-r border-dashed",s&&t.border,e.rsvp==="declined"&&"opacity-60",e.selected&&"ring-2 ring-ring",e.density==="compact"?"text-2xs":"text-xs")}function re({title:e,timeText:t,layout:s,rsvp:a,hasThread:i,isRecurring:r,zoneCertainty:d,trailing:u,detail:h}){const o=s==="column",m=d==="ambiguous",l=!o&&h!==void 0,x=n.jsxs("span",{className:c("flex min-w-0 items-center gap-1",o&&"w-full",a==="declined"&&"line-through"),children:[t!==""&&n.jsx("span",{className:"shrink-0 tabular-nums opacity-80",children:t}),n.jsx("span",{className:"truncate font-medium",children:e})]}),v=(r||i||m)&&n.jsxs("span",{className:c("flex shrink-0 items-center gap-1",o&&"mt-0.5",!o&&u===void 0&&"ml-auto"),children:[r&&n.jsx(X,{className:"size-2.5","aria-label":"Repeats"}),i&&n.jsx(g,{className:"size-2.5","aria-label":"From mail"}),m&&n.jsx(L,{className:"size-2.5 text-warning","aria-label":"Unclear zone"})]}),b=u!==void 0&&n.jsx("span",{className:c("shrink-0 opacity-80",!o&&"ml-auto"),children:u});return n.jsxs(n.Fragment,{children:[l?n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[x,v,b]}):n.jsxs(n.Fragment,{children:[x,v,b]}),h]})}function Me({title:e,timeText:t,color:s,layout:a,density:i,rsvp:r,status:d,hasThread:u,isRecurring:h,zoneCertainty:o,selected:m,onClick:l,leading:x,trailing:v,detail:b}){const N=a==="column";return n.jsxs("button",{type:"button",onClick:l,"aria-pressed":m,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",N?"h-full":"items-start",x!==void 0&&"gap-2"),children:[x,n.jsx("span",{className:c(ae({color:s,layout:a,density:i,rsvp:r,status:d,selected:m,stacked:b!==void 0}),"flex-1",N&&"h-full"),children:n.jsx(re,{title:e,timeText:t,layout:a,rsvp:r,hasThread:u,isRecurring:h,zoneCertainty:o,trailing:v,detail:b})})]})}function ie({id:e,reason:t,nudged:s,className:a}){return n.jsxs(n.Fragment,{children:[n.jsx("p",{id:e,className:c(a,!s&&"sr-only"),children:t}),n.jsx("span",{role:"status","aria-live":"polite",className:"sr-only",children:s?t:""})]})}function Fe({items:e,className:t}){return e.length===0?n.jsxs("div",{className:c("flex flex-col items-center gap-2 p-6 text-center",t),children:[n.jsx(q,{className:"size-6 text-fg-subtle","aria-hidden":!0}),n.jsx("p",{className:"text-sm text-fg-muted",children:"Nothing in your mail is waiting on a decision about time."})]}):n.jsx("ul",{"aria-label":"Suggested events",className:c("flex min-h-0 flex-col gap-3 overflow-y-auto",t),children:e.map(s=>n.jsx("li",{children:s.card},s.id))})}const oe="Pick a clock first. The mail never said, and the reader will not choose for you.";function le(e,t){const s=e.zoneOptions;return s===void 0?{settled:!0,timeZone:""}:s.some(a=>a.timeZone===t)?{settled:!0,timeZone:t}:{settled:!1,reason:oe}}function M(e){return e.threadSubject===""?e.sender:`${e.sender} — ${e.threadSubject}`}function ce(e){return e>=.85?"Read cleanly":e>=.6?"Read with gaps":"Barely read"}function Ze({suggestion:e,whenText:t,onAdd:s,onReview:a,onDismiss:i,onOpenThread:r,busy:d=!1,addBlocked:u=!1,zoneChoice:h,onZoneChoice:o,addLabel:m="Add",touch:l,className:x}){const[v,b]=z.useState(""),[N,E]=z.useState(!1),S=z.useId(),C=h??v,G=f=>{E(!1),o?o(f):b(f)},y=le(e,C),I=f=>()=>{if(!y.settled){E(!0);return}f(y.timeZone)};return n.jsxs("article",{"aria-label":e.title,className:c("flex flex-col gap-2 rounded-lg border border-dashed border-line-strong bg-surface-sunken p-3",x),children:[n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsxs("span",{className:"block text-2xs uppercase tracking-wider text-fg-subtle",children:["Suggested from mail · ",ce(e.confidence)]}),n.jsx("span",{className:"block truncate text-sm font-medium text-fg",children:e.title}),n.jsx("span",{className:"block text-xs text-fg-muted",children:t}),e.location!==""&&n.jsx("span",{className:"block truncate text-xs text-fg-muted",children:e.location})]}),n.jsx("button",{type:"button","aria-label":"Dismiss suggestion",onClick:i,disabled:d,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",l?"size-11":"size-7"),children:n.jsx(H,{className:"size-4"})})]}),e.ambiguity!==""&&n.jsxs("p",{className:"flex items-start gap-1.5 text-2xs text-warning",children:[n.jsx(Y,{className:"mt-0.5 size-3 shrink-0","aria-hidden":!0}),e.ambiguity]}),r?n.jsxs("button",{type:"button",onClick:r,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:[n.jsx(g,{className:"size-3 shrink-0"}),n.jsx("span",{className:"truncate",children:M(e)})]}):n.jsxs("p",{className:"flex w-full min-w-0 items-center gap-1.5 text-2xs text-fg-subtle",children:[n.jsx(g,{className:"size-3 shrink-0"}),n.jsx("span",{className:"truncate",children:M(e)})]}),e.zoneOptions&&n.jsxs("div",{className:"flex flex-col gap-1.5 rounded-md border border-warning/40 p-2",children:[n.jsxs("p",{className:"flex items-center gap-1.5 text-2xs font-semibold text-warning",children:[n.jsx(L,{className:"size-3 shrink-0","aria-hidden":!0}),"Which clock is this on?"]}),e.zoneOptions.map(f=>n.jsxs("button",{type:"button","aria-pressed":C===f.timeZone,onClick:()=>G(f.timeZone),className:c("rounded-md border px-2 py-1 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",l&&"min-h-11",C===f.timeZone?"border-accent bg-accent-soft":"border-line bg-surface hover:border-line-strong"),children:[n.jsx("span",{className:"block text-xs font-medium text-fg",children:f.label}),n.jsx("span",{className:"block text-2xs text-fg-subtle",children:f.note})]},f.timeZone))]}),!y.settled&&n.jsx(ie,{id:S,reason:y.reason,nudged:N,className:"text-2xs text-warning"}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(T,{variant:"primary",size:l?"md":"sm",icon:n.jsx(V,{className:"size-3.5"}),onClick:I(s),disabled:d||u,"aria-describedby":y.settled?void 0:S,className:c(l&&"min-h-11 flex-1",!y.settled&&"opacity-55"),children:m}),a&&n.jsx(T,{variant:"secondary",size:l?"md":"sm",icon:n.jsx(se,{className:"size-3.5"}),onClick:I(a),disabled:d,"aria-describedby":y.settled?void 0:S,className:c(l&&"min-h-11",!y.settled&&"opacity-55"),children:"Change first"})]})]})}function Be(e){return e.defaultCalendarId!==""?"ready":e.error!==null?"failed":e.isLoading?"loading":"none"}function $e(e,t){if(e!=="ready")return e==="loading"?"Reading your calendars…":e==="failed"?n.jsxs(n.Fragment,{children:["Couldn't read your calendars, so there is nowhere to add this yet. Reload to try again."," ",n.jsx("a",{href:t,target:"_blank",rel:"noreferrer",className:"font-medium text-accent hover:underline",children:"Report an issue"})]}):n.jsxs(n.Fragment,{children:["You have no calendar yet, so there is nowhere to add this."," ",n.jsx(ee,{to:"/settings/calendars",className:"font-medium text-accent hover:underline",children:"Create a calendar"})]})}const de=24,_=7,me=52,w=me*7,fe=e=>({from:p(e,-10),to:p(e,de),floor:p(e,-w),ceiling:p(e,w)}),ue=e=>e.from<=e.floor,xe=e=>e.to>=e.ceiling,pe=(e,t)=>e>t?e:t,he=(e,t)=>e<t?e:t,ye=e=>ue(e)?e:{...e,from:pe(p(e.from,-_),e.floor)},be=e=>xe(e)?e:{...e,to:he(p(e.to,_),e.ceiling)},Le=e=>ye({...e,floor:p(e.from,-w)}),_e=e=>be({...e,ceiling:p(e.to,w)});function Ue(e,t){return t>=e.from&&t<=e.to?e:fe(t)}function Pe(e){const t=new Map;for(const s of e){const a=B("week",s);t.has(a.from)||t.set(a.from,a)}return[...t.values()]}const We=e=>B("week",e).from,ve=1440,F=e=>e.getHours()*60+e.getMinutes();function U(e,t){const s=new Set(e),a=new Map;for(const i of t){const r=new Date(i.start),d=new Date(i.end);if(Number.isNaN(r.getTime())||Number.isNaN(d.getTime())||d.getTime()<=r.getTime())continue;const u=k(r),h=k(new Date(d.getTime()-1));for(let o=u;o<=h;o=p(o,1)){if(!s.has(o))continue;const m=o===u?F(r):0,l=k(d)===o?F(d):ve;if(l<=m)continue;const x=a.get(o);x?x.push({from:m,to:l}):a.set(o,[{from:m,to:l}])}}for(const[i,r]of a)a.set(i,J(r));return a}function Ge(e,t){const s=U(e,t);return new Map(e.map(a=>[a,$(a,s.get(a)??[])]))}const qe=e=>Q(e.from,e.to),j=30,Ne=6,P={Local:"local",Explicit:"explicit",Ambiguous:"ambiguous"},je="The invitation's time zone could not be resolved. Add opens the editor so you can set the time.",ke="The invitation's time zone could not be resolved.";function He(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 we=e=>e.source!=="TextHeuristic";function Ye(e){return e.allDay?e.dtStart.slice(0,10):k(new Date(e.dtStart))}const W=e=>e.summary===""?"Untitled event":e.summary;function Ke(e){if(e.allDay){const t=e.dtStart.slice(0,10),s=e.dtEnd.slice(0,10),a=s>t?p(s,-1):t;return a===t?`${D(t)}, all day`:`${D(t)} – ${D(a)}, all day`}return te({start:e.dtStart,end:e.dtEnd,allDay:e.allDay})}function Se(e,t){return{id:e.suggestionId,calendarId:t.calendarId,title:W(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 Xe(e,t,s){const a=e.organizer===""?s.senderName:e.organizer;return{id:e.suggestionId,threadId:s.threadId,proposed:Se(e,s),organizerName:a===""?"The sender":a,organizerEmail:e.organizer,method:"ics",evidence:"",state:t,sequence:e.sequence}}function Ce(e){return e.zoneCertainty!=="Ambiguous"?"":e.method==="Cancel"?ke:je}function Je(e,t){return{id:e.suggestionId,title:W(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:we(e)?1:.6,ambiguity:Ce(e),suggestedCalendarId:t.calendarId,timeZone:"",zoneCertainty:P[e.zoneCertainty]}}const ze=(e,t)=>Date.parse(t.start)<Date.parse(e.end)&&Date.parse(t.end)>Date.parse(e.start);function Qe(e,t){return t.filter(s=>ze(e,s)).map(s=>({id:`${s.start}/${s.end}`,label:`Busy ${R(s.start)} – ${R(s.end)}`}))}function Ve(e,t){const s=U([e],t).get(e)??[],a=[];for(const i of $(e,s,j))for(let r=i.startMinute;r+j<=i.endMinute&&a.length<Ne;r+=j)a.push({date:e,endDate:e,startTime:A(r),endTime:A(r+j),allDay:!1});return a}function et(e,t,s){const a=t.filter(i=>s.includes(i.startTime)).map(i=>`${O(i.startTime)} – ${O(i.endTime)}`);return`${ne(e)}: ${a.join(", ")}`}export{ie as B,Me as C,Ze as E,re as a,Ue as b,ae as c,qe as d,We as e,Ge as f,ye as g,be as h,_e as i,xe as j,ue as k,Le as l,Fe as m,$e as n,Be as o,Ye as p,we as q,fe as r,Ke as s,Je as t,He as u,Qe as v,Pe as w,Xe as x,Ve as y,et as z};
@@ -1 +1 @@
1
- import{b as N,j as e,r as i,ao as C,d as j,B as v,T as P,e as A,aT as B,a as G,aU as V,f as S,ay as E,aV as Z,aW as Q,aX as K,s as O,aY as T,aq as W,aZ as X,a_ as Y,a$ as q,u as J,ac as ee}from"./index-NTsfKnzH.js";import{U as k,c as se,u as U,a as ae,b as te}from"./useCalendarSuggestions-epkXEJdf.js";import{S as ne}from"./select-D3KrqhMa.js";import{C as F,a as z,b as M,c as D}from"./card-Bt0rEzaX.js";import{P as re}from"./plus-CBEQXEYM.js";import{u as ie}from"./useCalendarScheduling-DFvOUPbg.js";import{C as de}from"./calendar-guests-_9JIL5bL.js";import{f as w,E as oe}from"./ErrorState-BDj_H2Rc.js";import{C as L}from"./confirm-dialog-B9uXBCde.js";import{B as $}from"./badge-DL_zWZca.js";import{R as le}from"./refresh-cw-COTmGpG_.js";import{C as ce}from"./copy-DGIy9NV0.js";import{a as me}from"./sections-DbaGT3GX.js";import{S as ue}from"./settings-screen-Dc-Ptb7G.js";import"./useQueries-BWuMMxTL.js";import"./chevron-down-Dcb1svev.js";import"./useDebouncedValue-C_EHxcaO.js";import"./calendar-event-popup-BPDsVk8G.js";import"./pencil-SmE0J4lF.js";import"./circle-help-BHDb6fr4.js";import"./avatar-CAJhX3gE.js";import"./chevron-left-BPKjlJZD.js";import"./menu-Bjei5qcd.js";const he=N("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 pe=N("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 xe=N("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=N("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const be=N("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"}]]),ge=s=>({title:`Delete ${s}?`,description:`This removes ${s} and every event in it, and any subscription address stops working. It cannot be undone.`}),ve=s=>s.normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,64),I=Intl.supportedValuesOf("timeZone");function H({id:s,value:n,disabled:t,onChange:a}){const r=n===k||I.includes(n)?I:[n,...I];return e.jsxs(ne,{id:s,value:n,disabled:t,onChange:d=>a(d.target.value),children:[e.jsx("option",{value:k,children:"None (read as UTC)"}),r.map(d=>e.jsx("option",{value:d,children:d},d))]})}function je({isBusy:s,problem:n,onCreate:t}){const[a,r]=i.useState(""),[d,l]=i.useState(void 0),[h,c]=i.useState(k),o=i.useId(),m=i.useId(),f=i.useId(),x=i.useId(),b=d??ve(a),u=a.trim()!==""&&b.trim()!=="";return e.jsxs(F,{className:"max-w-xl",role:"region","aria-labelledby":o,children:[e.jsx(z,{children:e.jsx(M,{id:o,children:"New calendar"})}),e.jsx(D,{children:e.jsxs("form",{className:"space-y-3",onSubmit:p=>{p.preventDefault(),u&&t({displayName:a.trim(),urlSegment:b.trim(),timezone:h}).then(g=>{g&&(r(""),l(void 0),c(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:m,className:"text-xs font-medium text-fg-muted",children:"Name"}),e.jsx(C,{id:m,value:a,maxLength:140,disabled:s,onChange:p=>r(p.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:f,className:"text-xs font-medium text-fg-muted",children:"Address"}),e.jsx(C,{id:f,value:b,maxLength:64,disabled:s,onChange:p=>l(p.target.value)})]}),e.jsxs("div",{className:"space-y-1 sm:col-span-2",children:[e.jsx("label",{htmlFor:x,className:"text-xs font-medium text-fg-muted",children:"Time zone"}),e.jsx(H,{id:x,value:h,disabled:s,onChange:c})]})]}),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(v,{type:"submit",variant:"primary",size:"sm",disabled:s||!u,icon:e.jsx(re,{className:"size-3.5"}),children:s?"Adding…":"Add calendar"})]})})]})}function ye(){const{senders:s,defaultSenderId:n,setDefaultSender:t}=ie(),[a,r]=i.useState("");return s.length===0?null:e.jsxs("section",{"aria-labelledby":"calendar-default-sender",className:"space-y-2 rounded-sm border border-line bg-surface p-4",children:[e.jsx("h2",{id:"calendar-default-sender",className:"text-sm font-semibold",children:"Invitations: default sender"}),e.jsx("p",{className:"text-sm text-fg-muted",children:"Invitations, updates and cancellations go out from this account unless you pick another on the event."}),e.jsx(de,{label:"Default sender",senders:s,value:n??"",onChange:d=>{r(""),t(d).catch(l=>r(w(l)))}}),a!==""&&e.jsxs("p",{role:"alert",className:"text-sm text-danger",children:["Couldn't save the default sender: ",a," ",e.jsx("a",{href:se(a),target:"_blank",rel:"noreferrer",className:"font-medium text-accent hover:underline",children:"Report an issue"})]})]})}function Ce({calendarName:s,timezone:n,isBusy:t,problem:a,onSave:r,onDelete:d}){const[l,h]=i.useState(s),[c,o]=i.useState(n),[m,f]=i.useState(!1),x=i.useId(),b=i.useId(),u=l.trim(),p=u!==s||c!==n,g=ge(s);return e.jsxs(e.Fragment,{children:[e.jsxs("form",{className:"space-y-3",onSubmit:y=>{y.preventDefault(),!(!p||u==="")&&r({displayName:u,timezone:c})},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:x,className:"text-xs font-medium text-fg-muted",children:"Name"}),e.jsx(C,{id:x,value:l,maxLength:140,disabled:t,onChange:y=>h(y.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:b,className:"text-xs font-medium text-fg-muted",children:"Time zone"}),e.jsx(H,{id:b,value:c,disabled:t,onChange:o})]})]}),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(v,{type:"submit",variant:"secondary",size:"sm",disabled:t||!p||u==="",icon:e.jsx(be,{className:"size-3.5"}),children:"Save changes"}),e.jsx(v,{type:"button",variant:"danger",size:"sm",disabled:t,icon:e.jsx(P,{className:"size-3.5"}),onClick:()=>f(!0),children:"Delete calendar"})]})]}),e.jsx(L,{isOpen:m,title:g.title,description:g.description,confirmLabel:"Delete calendar",destructive:!0,onConfirm:()=>{f(!1),d()},onCancel:()=>f(!1)})]})}const Ne="/feeds/calendar/",Se=".ics",ke=(s,n)=>`webcal://${s}${Ne}${n}${Se}`;function we(s){const n=A(),[t,a]=i.useState(""),r=B({path:{calendarId:s}}),d=G({...V({path:{calendarId:s}}),meta:O(404,403),retry:!1}),l=()=>{n.invalidateQueries({queryKey:r})},h=i.useRef(()=>{}),c=S({...Z(),meta:E,onMutate:()=>{h.current()},onSuccess:()=>{a(""),l()}}),o=S({...Q(),meta:E,gcTime:0,onMutate:()=>{c.reset()},onSuccess:_=>{a(ke(window.location.host,_.feedToken)),l()}});h.current=o.reset;const{mutate:m,reset:f}=o,{mutate:x}=c,b=i.useCallback(()=>{m({path:{calendarId:s}})},[s,m]),u=i.useCallback(()=>{x({path:{calendarId:s}})},[s,x]),p=i.useCallback(()=>{a(""),f()},[f]),{refetch:g}=d,y=i.useCallback(()=>{g()},[g]);return{state:Ie(d),mintedUrl:t,isBusy:o.isPending||c.isPending,actionError:o.error??c.error,mint:b,revoke:u,dismissMinted:p,retry:y}}function Ie(s){return s.error?K(s.error)?{status:"absent"}:{status:"unreadable",error:s.error}:s.isPending?{status:"loading"}:s.data?{status:"active",createdAt:s.data.createdAt,rotatedAt:s.data.rotatedAt}:{status:"absent"}}const Te=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."}),Fe=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 ze({calendarName:s,url:n,onDismiss:t}){const[a,r]=i.useState(!1),[d,l]=i.useState(!1),h=i.useRef(0);i.useEffect(()=>()=>window.clearTimeout(h.current),[]);const c=()=>{navigator.clipboard.writeText(n).then(()=>{l(!1),r(!0),h.current=window.setTimeout(()=>r(!1),2e3)}).catch(()=>l(!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:o=>o.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(v,{variant:"primary",size:"sm",icon:a?e.jsx(W,{className:"size-3.5"}):e.jsx(ce,{className:"size-3.5"}),onClick:c,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(v,{variant:"ghost",size:"sm",onClick:t,children:"I've saved it"})]})}function Me({createdAt:s,rotatedAt:n,isBusy:t,onRotate:a,onRevoke:r}){return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx($,{tone:"positive",children:"shared"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:["Address created ",T(s,"medium"),n>0?`, last replaced ${T(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(v,{variant:"secondary",size:"sm",disabled:t,icon:e.jsx(le,{className:"size-3.5"}),onClick:a,children:"Replace address"}),e.jsx(v,{variant:"danger",size:"sm",disabled:t,icon:e.jsx(P,{className:"size-3.5"}),onClick:r,children:"Stop sharing"})]})]})}function De({calendarName:s,details:n,state:t,mintedUrl:a,isBusy:r,actionError:d,onMint:l,onRevoke:h,onDismissMinted:c,onRetry:o}){const[m,f]=i.useState("none"),x=i.useId(),b=()=>{const p=m;f("none"),p==="rotate"&&l(),p==="revoke"&&h()},u=m==="revoke"?Fe(s):Te(s);return e.jsxs(F,{className:"max-w-xl",role:"region","aria-labelledby":x,children:[e.jsx(z,{children:e.jsx(M,{id:x,children:s})}),e.jsxs(D,{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(oe,{variant:"inline",title:`Couldn't read whether ${s} is shared`,error:t.error,onRetry:o}),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(v,{variant:"primary",size:"sm",disabled:r,icon:e.jsx(pe,{className:"size-3.5"}),onClick:l,children:r?"Creating…":"Create subscription address"})]}),t.status==="active"&&e.jsx(Me,{createdAt:t.createdAt,rotatedAt:t.rotatedAt,isBusy:r,onRotate:()=>f("rotate"),onRevoke:()=>f("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(ze,{calendarName:s,url:a,onDismiss:c})]}),e.jsx(L,{isOpen:m!=="none",title:u.title,description:u.description,confirmLabel:m==="revoke"?"Stop sharing":"Replace address",destructive:!0,onConfirm:b,onCancel:()=>f("none")})]})}function Ee({calendarId:s,calendarName:n,details:t}){const a=we(s);return e.jsx(De,{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 Re({calendarId:s,calendarName:n,timezone:t,subscription:a}){const{updateCalendar:r,deleteCalendar:d,isWriting:l}=U(),[h,c]=i.useState(""),o=m=>c(m.kind==="refused"?m.message:"");return e.jsx(Ee,{calendarId:s,calendarName:n,details:e.jsxs(e.Fragment,{children:[a,e.jsx(Ce,{calendarName:n,timezone:t,isBusy:l,problem:h,onSave:m=>{c(""),r(s,m).then(o)},onDelete:()=>{c(""),d(s).then(o)}},`${n}\0${t}`)]})})}const Pe="Subscribe to a calendar";function Ae({isBusy:s,error:n,onSubscribe:t}){const a=i.useId(),r=i.useId(),d=i.useId(),[l,h]=i.useState(""),[c,o]=i.useState(""),m=l.trim()!==""&&c.trim()!=="",f=x=>{x.preventDefault(),m&&t({displayName:l,url:c},()=>{h(""),o("")})};return e.jsxs(F,{className:"max-w-xl",role:"region","aria-labelledby":a,children:[e.jsx(z,{children:e.jsx(M,{id:a,children:Pe})}),e.jsx(D,{children:e.jsxs("form",{className:"space-y-3",onSubmit:f,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:r,className:"text-sm font-medium text-fg",children:"Calendar name"}),e.jsx(C,{id:r,value:l,onChange:x=>h(x.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(C,{id:d,value:c,onChange:x=>o(x.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(v,{type:"submit",variant:"primary",size:"sm",disabled:!m||s,icon:e.jsx(he,{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)})]})]})})]})}const Oe=s=>URL.canParse(s)?new URL(s).host:"an iCalendar feed";function Ue({calendarName:s,subscriptionUrl:n,enabled:t,fetchedAt:a,error:r,isBusy:d,actionError:l,onSetEnabled:h}){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($,{tone:t?"positive":"neutral",children:t?"subscribed":"paused"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:["Read-only, from ",Oe(n),a>0?`. Last updated ${T(a,"medium")}`:""]})]}),r!==""&&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:r})]}),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(v,{variant:"secondary",size:"sm",disabled:d,icon:t?e.jsx(xe,{className:"size-3.5"}):e.jsx(fe,{className:"size-3.5"}),onClick:()=>h(!t),children:t?"Pause updates":"Resume updates"}),l!=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(l)})]})]})}const R=O(400,404),Le=()=>`subscribed-${crypto.randomUUID().slice(0,8)}`;function $e(){const s=A(),n=ae(),t=()=>{s.invalidateQueries({queryKey:q()}),n()},a=S({...X(),meta:R,onSuccess:t}),r=S({...Y(),meta:R,onSuccess:t}),{mutate:d}=a,l=i.useCallback((o,m)=>{d({body:{urlSegment:Le(),displayName:o.displayName.trim(),subscriptionUrl:o.url.trim()}},{onSuccess:m})},[d]),{mutate:h}=r,c=i.useCallback((o,m)=>{h({path:{calendarId:o},body:{subscriptionEnabled:m}})},[h]);return{subscribe:l,isSubscribing:a.isPending,subscribeError:a.error,setEnabled:c,togglingCalendarId:r.isPending?r.variables?.path.calendarId??"":"",toggleFailure:{calendarId:r.variables?.path.calendarId??"",error:r.error}}}const He=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 ms(){const s=J(),n=ee(),t=me(),[a,r]=i.useState(!0),{calendars:d,collections:l,timeZoneByCalendarId:h,isLoading:c}=te(),o=$e(),{createCalendar:m,isWriting:f}=U(),[x,b]=i.useState("");return e.jsx(ue,{items:n,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:He,helpOpen:a,onToggleHelp:()=>r(u=>!u),onSelect:t,onBackToMail:()=>{s({to:"/mail"})},children:c?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:[e.jsx(ye,{}),d.map(u=>{const p=l.find(g=>g.calendarId===u.id);return e.jsx(Re,{calendarId:u.id,calendarName:u.name,timezone:h[u.id]??"",subscription:p?.source==="Subscribed"&&e.jsx(Ue,{calendarName:p.displayName,subscriptionUrl:p.subscriptionUrl,enabled:p.subscriptionEnabled,fetchedAt:p.subscriptionFetchedAt,error:p.subscriptionError,isBusy:o.togglingCalendarId===u.id,actionError:o.toggleFailure.calendarId===u.id?o.toggleFailure.error:void 0,onSetEnabled:g=>o.setEnabled(u.id,g)})},u.id)}),e.jsx(Ae,{isBusy:o.isSubscribing,error:o.subscribeError,onSubscribe:o.subscribe}),e.jsx(je,{isBusy:f,problem:x,onCreate:u=>(b(""),m(u).then(p=>p.kind==="written"?!0:(b(p.message),!1)))})]})})}export{ms as component};
1
+ import{b as N,j as e,r as i,ao as C,d as j,B as v,T as P,e as A,aT as B,a as G,aU as V,f as S,ay as E,aV as Z,aW as Q,aX as K,s as O,aY as T,aq as W,aZ as X,a_ as Y,a$ as q,u as J,ac as ee}from"./index-BoYUTbor.js";import{U as k,c as se,u as U,a as ae,b as te}from"./useCalendarSuggestions-BQrUJL_8.js";import{S as ne}from"./select-BzudQ-hj.js";import{C as F,a as z,b as M,c as D}from"./card-anoxIkUJ.js";import{P as re}from"./plus-CPYNu12K.js";import{u as ie}from"./useCalendarScheduling-7KLsotZJ.js";import{C as de}from"./calendar-guests-CnGUT-A_.js";import{f as w,E as oe}from"./ErrorState-CKFCoido.js";import{C as L}from"./confirm-dialog-IJNXJDPm.js";import{B as $}from"./badge-Ci5wC_7z.js";import{R as le}from"./refresh-cw-DNktlgJw.js";import{C as ce}from"./copy-hvuziBW_.js";import{a as me}from"./sections-BlI9KK6M.js";import{S as ue}from"./settings-screen-DRlPhwXt.js";import"./useQueries-wqN_e7rn.js";import"./chevron-down-DGwUrOcf.js";import"./useDebouncedValue-BMLVeivZ.js";import"./calendar-event-popup-C9kH8QF7.js";import"./pencil-CIMfGyWW.js";import"./circle-help-C8FYparP.js";import"./avatar-UfQRtoX1.js";import"./chevron-left-BW50jo-d.js";import"./menu-BoWQGjnP.js";const he=N("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 pe=N("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 xe=N("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=N("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const be=N("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"}]]),ge=s=>({title:`Delete ${s}?`,description:`This removes ${s} and every event in it, and any subscription address stops working. It cannot be undone.`}),ve=s=>s.normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,64),I=Intl.supportedValuesOf("timeZone");function H({id:s,value:n,disabled:t,onChange:a}){const r=n===k||I.includes(n)?I:[n,...I];return e.jsxs(ne,{id:s,value:n,disabled:t,onChange:d=>a(d.target.value),children:[e.jsx("option",{value:k,children:"None (read as UTC)"}),r.map(d=>e.jsx("option",{value:d,children:d},d))]})}function je({isBusy:s,problem:n,onCreate:t}){const[a,r]=i.useState(""),[d,l]=i.useState(void 0),[h,c]=i.useState(k),o=i.useId(),m=i.useId(),f=i.useId(),x=i.useId(),b=d??ve(a),u=a.trim()!==""&&b.trim()!=="";return e.jsxs(F,{className:"max-w-xl",role:"region","aria-labelledby":o,children:[e.jsx(z,{children:e.jsx(M,{id:o,children:"New calendar"})}),e.jsx(D,{children:e.jsxs("form",{className:"space-y-3",onSubmit:p=>{p.preventDefault(),u&&t({displayName:a.trim(),urlSegment:b.trim(),timezone:h}).then(g=>{g&&(r(""),l(void 0),c(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:m,className:"text-xs font-medium text-fg-muted",children:"Name"}),e.jsx(C,{id:m,value:a,maxLength:140,disabled:s,onChange:p=>r(p.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:f,className:"text-xs font-medium text-fg-muted",children:"Address"}),e.jsx(C,{id:f,value:b,maxLength:64,disabled:s,onChange:p=>l(p.target.value)})]}),e.jsxs("div",{className:"space-y-1 sm:col-span-2",children:[e.jsx("label",{htmlFor:x,className:"text-xs font-medium text-fg-muted",children:"Time zone"}),e.jsx(H,{id:x,value:h,disabled:s,onChange:c})]})]}),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(v,{type:"submit",variant:"primary",size:"sm",disabled:s||!u,icon:e.jsx(re,{className:"size-3.5"}),children:s?"Adding…":"Add calendar"})]})})]})}function ye(){const{senders:s,defaultSenderId:n,setDefaultSender:t}=ie(),[a,r]=i.useState("");return s.length===0?null:e.jsxs("section",{"aria-labelledby":"calendar-default-sender",className:"space-y-2 rounded-sm border border-line bg-surface p-4",children:[e.jsx("h2",{id:"calendar-default-sender",className:"text-sm font-semibold",children:"Invitations: default sender"}),e.jsx("p",{className:"text-sm text-fg-muted",children:"Invitations, updates and cancellations go out from this account unless you pick another on the event."}),e.jsx(de,{label:"Default sender",senders:s,value:n??"",onChange:d=>{r(""),t(d).catch(l=>r(w(l)))}}),a!==""&&e.jsxs("p",{role:"alert",className:"text-sm text-danger",children:["Couldn't save the default sender: ",a," ",e.jsx("a",{href:se(a),target:"_blank",rel:"noreferrer",className:"font-medium text-accent hover:underline",children:"Report an issue"})]})]})}function Ce({calendarName:s,timezone:n,isBusy:t,problem:a,onSave:r,onDelete:d}){const[l,h]=i.useState(s),[c,o]=i.useState(n),[m,f]=i.useState(!1),x=i.useId(),b=i.useId(),u=l.trim(),p=u!==s||c!==n,g=ge(s);return e.jsxs(e.Fragment,{children:[e.jsxs("form",{className:"space-y-3",onSubmit:y=>{y.preventDefault(),!(!p||u==="")&&r({displayName:u,timezone:c})},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:x,className:"text-xs font-medium text-fg-muted",children:"Name"}),e.jsx(C,{id:x,value:l,maxLength:140,disabled:t,onChange:y=>h(y.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:b,className:"text-xs font-medium text-fg-muted",children:"Time zone"}),e.jsx(H,{id:b,value:c,disabled:t,onChange:o})]})]}),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(v,{type:"submit",variant:"secondary",size:"sm",disabled:t||!p||u==="",icon:e.jsx(be,{className:"size-3.5"}),children:"Save changes"}),e.jsx(v,{type:"button",variant:"danger",size:"sm",disabled:t,icon:e.jsx(P,{className:"size-3.5"}),onClick:()=>f(!0),children:"Delete calendar"})]})]}),e.jsx(L,{isOpen:m,title:g.title,description:g.description,confirmLabel:"Delete calendar",destructive:!0,onConfirm:()=>{f(!1),d()},onCancel:()=>f(!1)})]})}const Ne="/feeds/calendar/",Se=".ics",ke=(s,n)=>`webcal://${s}${Ne}${n}${Se}`;function we(s){const n=A(),[t,a]=i.useState(""),r=B({path:{calendarId:s}}),d=G({...V({path:{calendarId:s}}),meta:O(404,403),retry:!1}),l=()=>{n.invalidateQueries({queryKey:r})},h=i.useRef(()=>{}),c=S({...Z(),meta:E,onMutate:()=>{h.current()},onSuccess:()=>{a(""),l()}}),o=S({...Q(),meta:E,gcTime:0,onMutate:()=>{c.reset()},onSuccess:_=>{a(ke(window.location.host,_.feedToken)),l()}});h.current=o.reset;const{mutate:m,reset:f}=o,{mutate:x}=c,b=i.useCallback(()=>{m({path:{calendarId:s}})},[s,m]),u=i.useCallback(()=>{x({path:{calendarId:s}})},[s,x]),p=i.useCallback(()=>{a(""),f()},[f]),{refetch:g}=d,y=i.useCallback(()=>{g()},[g]);return{state:Ie(d),mintedUrl:t,isBusy:o.isPending||c.isPending,actionError:o.error??c.error,mint:b,revoke:u,dismissMinted:p,retry:y}}function Ie(s){return s.error?K(s.error)?{status:"absent"}:{status:"unreadable",error:s.error}:s.isPending?{status:"loading"}:s.data?{status:"active",createdAt:s.data.createdAt,rotatedAt:s.data.rotatedAt}:{status:"absent"}}const Te=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."}),Fe=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 ze({calendarName:s,url:n,onDismiss:t}){const[a,r]=i.useState(!1),[d,l]=i.useState(!1),h=i.useRef(0);i.useEffect(()=>()=>window.clearTimeout(h.current),[]);const c=()=>{navigator.clipboard.writeText(n).then(()=>{l(!1),r(!0),h.current=window.setTimeout(()=>r(!1),2e3)}).catch(()=>l(!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:o=>o.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(v,{variant:"primary",size:"sm",icon:a?e.jsx(W,{className:"size-3.5"}):e.jsx(ce,{className:"size-3.5"}),onClick:c,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(v,{variant:"ghost",size:"sm",onClick:t,children:"I've saved it"})]})}function Me({createdAt:s,rotatedAt:n,isBusy:t,onRotate:a,onRevoke:r}){return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx($,{tone:"positive",children:"shared"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:["Address created ",T(s,"medium"),n>0?`, last replaced ${T(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(v,{variant:"secondary",size:"sm",disabled:t,icon:e.jsx(le,{className:"size-3.5"}),onClick:a,children:"Replace address"}),e.jsx(v,{variant:"danger",size:"sm",disabled:t,icon:e.jsx(P,{className:"size-3.5"}),onClick:r,children:"Stop sharing"})]})]})}function De({calendarName:s,details:n,state:t,mintedUrl:a,isBusy:r,actionError:d,onMint:l,onRevoke:h,onDismissMinted:c,onRetry:o}){const[m,f]=i.useState("none"),x=i.useId(),b=()=>{const p=m;f("none"),p==="rotate"&&l(),p==="revoke"&&h()},u=m==="revoke"?Fe(s):Te(s);return e.jsxs(F,{className:"max-w-xl",role:"region","aria-labelledby":x,children:[e.jsx(z,{children:e.jsx(M,{id:x,children:s})}),e.jsxs(D,{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(oe,{variant:"inline",title:`Couldn't read whether ${s} is shared`,error:t.error,onRetry:o}),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(v,{variant:"primary",size:"sm",disabled:r,icon:e.jsx(pe,{className:"size-3.5"}),onClick:l,children:r?"Creating…":"Create subscription address"})]}),t.status==="active"&&e.jsx(Me,{createdAt:t.createdAt,rotatedAt:t.rotatedAt,isBusy:r,onRotate:()=>f("rotate"),onRevoke:()=>f("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(ze,{calendarName:s,url:a,onDismiss:c})]}),e.jsx(L,{isOpen:m!=="none",title:u.title,description:u.description,confirmLabel:m==="revoke"?"Stop sharing":"Replace address",destructive:!0,onConfirm:b,onCancel:()=>f("none")})]})}function Ee({calendarId:s,calendarName:n,details:t}){const a=we(s);return e.jsx(De,{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 Re({calendarId:s,calendarName:n,timezone:t,subscription:a}){const{updateCalendar:r,deleteCalendar:d,isWriting:l}=U(),[h,c]=i.useState(""),o=m=>c(m.kind==="refused"?m.message:"");return e.jsx(Ee,{calendarId:s,calendarName:n,details:e.jsxs(e.Fragment,{children:[a,e.jsx(Ce,{calendarName:n,timezone:t,isBusy:l,problem:h,onSave:m=>{c(""),r(s,m).then(o)},onDelete:()=>{c(""),d(s).then(o)}},`${n}\0${t}`)]})})}const Pe="Subscribe to a calendar";function Ae({isBusy:s,error:n,onSubscribe:t}){const a=i.useId(),r=i.useId(),d=i.useId(),[l,h]=i.useState(""),[c,o]=i.useState(""),m=l.trim()!==""&&c.trim()!=="",f=x=>{x.preventDefault(),m&&t({displayName:l,url:c},()=>{h(""),o("")})};return e.jsxs(F,{className:"max-w-xl",role:"region","aria-labelledby":a,children:[e.jsx(z,{children:e.jsx(M,{id:a,children:Pe})}),e.jsx(D,{children:e.jsxs("form",{className:"space-y-3",onSubmit:f,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:r,className:"text-sm font-medium text-fg",children:"Calendar name"}),e.jsx(C,{id:r,value:l,onChange:x=>h(x.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(C,{id:d,value:c,onChange:x=>o(x.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(v,{type:"submit",variant:"primary",size:"sm",disabled:!m||s,icon:e.jsx(he,{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)})]})]})})]})}const Oe=s=>URL.canParse(s)?new URL(s).host:"an iCalendar feed";function Ue({calendarName:s,subscriptionUrl:n,enabled:t,fetchedAt:a,error:r,isBusy:d,actionError:l,onSetEnabled:h}){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($,{tone:t?"positive":"neutral",children:t?"subscribed":"paused"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:["Read-only, from ",Oe(n),a>0?`. Last updated ${T(a,"medium")}`:""]})]}),r!==""&&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:r})]}),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(v,{variant:"secondary",size:"sm",disabled:d,icon:t?e.jsx(xe,{className:"size-3.5"}):e.jsx(fe,{className:"size-3.5"}),onClick:()=>h(!t),children:t?"Pause updates":"Resume updates"}),l!=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(l)})]})]})}const R=O(400,404),Le=()=>`subscribed-${crypto.randomUUID().slice(0,8)}`;function $e(){const s=A(),n=ae(),t=()=>{s.invalidateQueries({queryKey:q()}),n()},a=S({...X(),meta:R,onSuccess:t}),r=S({...Y(),meta:R,onSuccess:t}),{mutate:d}=a,l=i.useCallback((o,m)=>{d({body:{urlSegment:Le(),displayName:o.displayName.trim(),subscriptionUrl:o.url.trim()}},{onSuccess:m})},[d]),{mutate:h}=r,c=i.useCallback((o,m)=>{h({path:{calendarId:o},body:{subscriptionEnabled:m}})},[h]);return{subscribe:l,isSubscribing:a.isPending,subscribeError:a.error,setEnabled:c,togglingCalendarId:r.isPending?r.variables?.path.calendarId??"":"",toggleFailure:{calendarId:r.variables?.path.calendarId??"",error:r.error}}}const He=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 ms(){const s=J(),n=ee(),t=me(),[a,r]=i.useState(!0),{calendars:d,collections:l,timeZoneByCalendarId:h,isLoading:c}=te(),o=$e(),{createCalendar:m,isWriting:f}=U(),[x,b]=i.useState("");return e.jsx(ue,{items:n,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:He,helpOpen:a,onToggleHelp:()=>r(u=>!u),onSelect:t,onBackToMail:()=>{s({to:"/mail"})},children:c?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:[e.jsx(ye,{}),d.map(u=>{const p=l.find(g=>g.calendarId===u.id);return e.jsx(Re,{calendarId:u.id,calendarName:u.name,timezone:h[u.id]??"",subscription:p?.source==="Subscribed"&&e.jsx(Ue,{calendarName:p.displayName,subscriptionUrl:p.subscriptionUrl,enabled:p.subscriptionEnabled,fetchedAt:p.subscriptionFetchedAt,error:p.subscriptionError,isBusy:o.togglingCalendarId===u.id,actionError:o.toggleFailure.calendarId===u.id?o.toggleFailure.error:void 0,onSetEnabled:g=>o.setEnabled(u.id,g)})},u.id)}),e.jsx(Ae,{isBusy:o.isSubscribing,error:o.subscribeError,onSubscribe:o.subscribe}),e.jsx(je,{isBusy:f,problem:x,onCreate:u=>(b(""),m(u).then(p=>p.kind==="written"?!0:(b(p.message),!1)))})]})})}export{ms as component};
@@ -1 +1 @@
1
- import{j as r,p as a}from"./index-NTsfKnzH.js";function n({raised:s,className:e,...t}){return r.jsx("div",{className:a("rounded-sm border border-line bg-surface",s?"bg-surface-raised shadow-sm":"",e),...t})}function o({className:s,...e}){return r.jsx("div",{className:a("px-4 pt-3 pb-2",s),...e})}function i({className:s,...e}){return r.jsx("h3",{className:a("text-md font-semibold text-fg",s),...e})}function m({className:s,...e}){return r.jsx("div",{className:a("px-4 pb-3 text-sm text-fg-muted",s),...e})}export{n as C,o as a,i as b,m as c};
1
+ import{j as r,p as a}from"./index-BoYUTbor.js";function n({raised:s,className:e,...t}){return r.jsx("div",{className:a("rounded-sm border border-line bg-surface",s?"bg-surface-raised shadow-sm":"",e),...t})}function o({className:s,...e}){return r.jsx("div",{className:a("px-4 pt-3 pb-2",s),...e})}function i({className:s,...e}){return r.jsx("h3",{className:a("text-md font-semibold text-fg",s),...e})}function m({className:s,...e}){return r.jsx("div",{className:a("px-4 pb-3 text-sm text-fg-muted",s),...e})}export{n as C,o as a,i as b,m as c};
@@ -1 +1 @@
1
- import{b as x,r as a,j as e,aq as p,p as r}from"./index-NTsfKnzH.js";const h=x("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]),m="peer relative size-5 shrink-0 cursor-pointer appearance-none rounded-md border border-line-strong bg-surface outline-none transition-colors checked:border-positive checked:bg-positive indeterminate:border-positive indeterminate:bg-positive focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-surface",l="pointer-events-none absolute inset-0 m-auto size-3.5 text-accent-fg";function v({label:s,description:n,indeterminate:t=!1,checked:d,onChange:u,className:c,...f}){const i=a.useRef(null);a.useEffect(()=>{i.current&&(i.current.indeterminate=t)},[t]);const o=e.jsxs("span",{className:"relative inline-flex",children:[e.jsx("input",{ref:i,type:"checkbox",checked:d,onChange:u,className:m,...f}),e.jsx(p,{className:r(l,"hidden peer-checked:block"),"aria-hidden":!0}),e.jsx(h,{className:r(l,"hidden peer-indeterminate:block"),"aria-hidden":!0})]});return s===void 0&&n===void 0?e.jsx("span",{className:c,children:o}):e.jsxs("label",{className:r("flex min-h-11 cursor-pointer items-center gap-3 text-left",c),children:[o,e.jsxs("span",{className:"flex min-w-0 flex-col",children:[s!==void 0&&e.jsx("span",{className:"text-sm text-fg",children:s}),n!==void 0&&e.jsx("span",{className:"text-xs text-fg-subtle",children:n})]})]})}export{v as C,h as M};
1
+ import{b as x,r as a,j as e,aq as p,p as r}from"./index-BoYUTbor.js";const h=x("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]),m="peer relative size-5 shrink-0 cursor-pointer appearance-none rounded-md border border-line-strong bg-surface outline-none transition-colors checked:border-positive checked:bg-positive indeterminate:border-positive indeterminate:bg-positive focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-surface",l="pointer-events-none absolute inset-0 m-auto size-3.5 text-accent-fg";function v({label:s,description:n,indeterminate:t=!1,checked:d,onChange:u,className:c,...f}){const i=a.useRef(null);a.useEffect(()=>{i.current&&(i.current.indeterminate=t)},[t]);const o=e.jsxs("span",{className:"relative inline-flex",children:[e.jsx("input",{ref:i,type:"checkbox",checked:d,onChange:u,className:m,...f}),e.jsx(p,{className:r(l,"hidden peer-checked:block"),"aria-hidden":!0}),e.jsx(h,{className:r(l,"hidden peer-indeterminate:block"),"aria-hidden":!0})]});return s===void 0&&n===void 0?e.jsx("span",{className:c,children:o}):e.jsxs("label",{className:r("flex min-h-11 cursor-pointer items-center gap-3 text-left",c),children:[o,e.jsxs("span",{className:"flex min-w-0 flex-col",children:[s!==void 0&&e.jsx("span",{className:"text-sm text-fg",children:s}),n!==void 0&&e.jsx("span",{className:"text-xs text-fg-subtle",children:n})]})]})}export{v as C,h as M};
@@ -0,0 +1 @@
1
+ import{b as o}from"./index-BoYUTbor.js";const n=o("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);export{n as C};
@@ -0,0 +1 @@
1
+ import{b as e}from"./index-BoYUTbor.js";const t=e("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);export{t as C};
@@ -1 +1 @@
1
- import{b as e}from"./index-NTsfKnzH.js";const t=e("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);export{t as C};
1
+ import{b as e}from"./index-BoYUTbor.js";const t=e("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);export{t as C};
@@ -1 +1 @@
1
- import{b as c}from"./index-NTsfKnzH.js";const r=c("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);export{r as C};
1
+ import{b as c}from"./index-BoYUTbor.js";const r=c("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);export{r as C};
@@ -1 +1 @@
1
- import{b as e}from"./index-NTsfKnzH.js";const p=e("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);export{p as C};
1
+ import{b as e}from"./index-BoYUTbor.js";const p=e("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);export{p as C};
@@ -1 +1 @@
1
- import{aP as Ke,aw as $e,ax as Ae,b0 as Ee,b1 as N,b2 as Le,s as fe,b3 as Be,a as me,b4 as pe,r as l,b5 as he,e as xe,f as Q,b6 as Fe,b7 as Me,b8 as Te,j as s,d as K,B as S,aG as De,ao as q,ap as Oe,c as He,b9 as ne,u as _e,ac as qe}from"./index-NTsfKnzH.js";import{R as ye}from"./ReportLink-BTOR-1yq.js";import{f as Ve}from"./ErrorState-BDj_H2Rc.js";import{S as Ge}from"./select-D3KrqhMa.js";import{C as Qe}from"./confirm-dialog-B9uXBCde.js";import{S as Xe}from"./switch-DOM72IV6.js";import{B as _}from"./badge-DL_zWZca.js";import{a as Ye}from"./sections-DbaGT3GX.js";import{S as We}from"./settings-screen-Dc-Ptb7G.js";import"./chevron-down-Dcb1svev.js";import"./avatar-CAJhX3gE.js";import"./chevron-left-BPKjlJZD.js";import"./menu-Bjei5qcd.js";import"./circle-help-BHDb6fr4.js";const Ze=fe(403),X={...fe(400,403,404,409,422,429),...Ee},be=e=>Ke(e)===403,k=e=>e.state==="NotConfigured"?{presetId:void 0,sources:void 0}:e.state==="Unrunnable"?{presetId:e.presetId,sources:void 0}:{presetId:e.presetId,sources:e.sources},ge=(e,t)=>{const a=k(e);return a.presetId===t?a.sources:void 0},re=(e,t)=>e.state==="Configured"&&e.sources[t]===N.Saved?e[t]:"",V=(e,t,a)=>e.state==="Configured"&&e.presetId===t&&e[a]!==""?e[a]:void 0,G=e=>({presetId:k(e).presetId,model:re(e,"model"),baseUrl:re(e,"baseUrl"),apiKey:""}),ze=(e,t)=>k(t).presetId===e.presetId?G(t):{presetId:e.presetId,model:"",baseUrl:"",apiKey:""},Je=e=>e.state==="Unrunnable"?!0:e.state==="NotConfigured"?!1:Object.values(e.sources).includes(N.Saved),es={Hosted:"Hosted",Custom:"Your own endpoint",Local:"Self-hosted"},ss=e=>{const t=[];for(const a of e){const i=t.find(n=>n.group===a.group);if(i){i.presets.push(a);continue}t.push({group:a.group,label:es[a.group],presets:[a]})}return t},ve=e=>e.defaultBaseUrl===void 0,A=(e,t)=>t===N.Saved?`${e} Saved by you.`:t===N.Deployment?`${e} Provided by the deployment.`:e,je="Paste an API key",ts=e=>Be(e)?.code==="ClassificationApiKeyRequired",oe="Enter a URL that starts with http:// or https://",as=e=>{if(!URL.canParse(e))return!1;const{protocol:t}=new URL(e);return t==="http:"||t==="https:"},is=(e,t,a)=>{const i=e.baseUrl.trim(),n=e.apiKey.trim(),o=ge(a,t.presetId);if(i!==""&&!as(i))return{ok:!1,field:"BaseUrl",message:oe};if(i===""&&ve(t)&&V(a,t.presetId,"baseUrl")===void 0)return{ok:!1,field:"BaseUrl",message:oe};const d=o?.apiKey??N.Default;return t.needsKey&&n===""&&d===N.Default?{ok:!1,field:"ApiKey",message:je}:{ok:!0,body:{...k(a).presetId!==t.presetId?{classificationPresetId:t.presetId}:{},classificationModel:e.model.trim(),classificationBaseUrl:i,...t.needsKey&&n!==""?{classificationApiKey:n}:{}}}},ns=(e,t,a)=>{const i=k(e).presetId;if(!(i===void 0||t===void 0)&&i!==t)return a.find(n=>n.presetId===i)},rs=e=>{const t=e.status===void 0?e.kind:`${e.status}`;return`Test failed after ${e.latencyMs} ms: ${t}`},Ne=(e,t)=>$e(Ae({title:`Mail classification: ${e}`,errorMessage:`${e}. ${t}`})),os=e=>{const t=e.needsKey?"Needs an API key.":"No key needed.";if(e.price.state!=="Priced")return t;const a=new Intl.NumberFormat("en",{style:"currency",currency:e.price.currency,maximumFractionDigits:4}).format(e.price.perMillionInputTokens);return`${t} ${a} per million input tokens.`},le="Enter a whole number of 1 or more.",ls=2147483647,cs=e=>{const t=e.trim();if(!/^\d+$/.test(t))return{ok:!1,message:le};const a=Number(t);return a<1||a>ls?{ok:!1,message:le}:{ok:!0,limit:a}},Se=e=>e.calls>=e.dailyLimit,ds=(e,t)=>{const{cost:a}=e;if(a.state==="Priced"){const i=new Intl.NumberFormat("en",{style:"currency",currency:a.currency,maximumFractionDigits:2});return a.amount>0&&a.amount<.01?`under ${i.format(.01)}`:a.amount===0?i.format(0):`about ${i.format(a.amount)}`}return t?.group==="Local"?"no price, self-hosted":"no price"},Ie=e=>Le(e,{hour:"2-digit",minute:"2-digit",timeZoneName:"shortOffset"}),Y=e=>{be(e)&&he()},Ce=e=>t=>{e.setQueryData(pe().queryKey,t)},us=()=>{const e=me({...pe(),meta:Ze}),t=e.isError&&be(e.error);return l.useEffect(()=>{t&&he()},[t]),{...e,signedOut:t}},W=()=>{const e=xe();return Q({...Fe(),meta:X,onSuccess:Ce(e),onError:Y})},fs=()=>{const e=xe();return Q({...Me(),meta:X,onSuccess:Ce(e),onError:Y})},ms=()=>Q({...Te(),meta:X,onError:Y});function w({failure:e,onRetry:t}){const a=Ve(e.error);return s.jsxs(K,{tone:"danger",variant:"soft",children:[s.jsx("p",{className:"font-medium",children:e.title}),s.jsx("p",{className:"mt-0.5 break-words text-fg-muted",children:a}),s.jsxs("p",{className:"flex flex-wrap items-center gap-x-4",children:[t&&s.jsx(S,{variant:"secondary",className:"min-h-11",onClick:t,children:"Retry"}),s.jsx(ye,{href:Ne(e.title,a)})]})]})}function P({id:e,label:t,hint:a,error:i,children:n}){return s.jsxs("div",{children:[s.jsx(De,{htmlFor:e,children:t}),n,i&&s.jsx("p",{id:`${e}-error`,className:"mt-1 text-xs text-danger",children:i}),a&&s.jsx("p",{id:`${e}-hint`,className:"mt-1 text-xs text-fg-subtle",children:a})]})}const R=(e,t,a)=>[a?`${e}-error`:"",t?`${e}-hint`:""].filter(Boolean).join(" ")||void 0;function ps({settings:e,inputRef:t,onAnnounce:a}){const i=W(),[n,o]=l.useState(()=>`${e.dailyLimit}`),[d,c]=l.useState(void 0),[f,m]=l.useState(null),h=l.useId(),u=`${h}-limit`,[b]=e.usage,x=b?`Counts reset at ${Ie(b.resetsAt)}. `:"",v=()=>{if(i.isPending)return;const y=cs(n);if(!y.ok){c(y.message);return}m(null),i.mutate({body:{classificationDailyLimit:y.limit}},{onSuccess:()=>a("Saved"),onError:U=>m({title:"The daily limit was not saved",error:U})})};return s.jsxs("section",{"aria-labelledby":`${h}-title`,className:"space-y-4",children:[s.jsx("h2",{id:`${h}-title`,className:"text-xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Daily limit"}),s.jsx(P,{id:u,label:"Calls per account per day",hint:A(`${x}Past the limit, that account's new mail uses built-in rules.`,e.sources.dailyLimit),error:d,children:s.jsx(q,{id:u,ref:t,className:"h-11",inputMode:"numeric",value:n,autoComplete:"off","aria-invalid":d!==void 0,"aria-describedby":R(u,!0,d!==void 0),onChange:y=>{o(y.target.value),c(void 0),a("")},onKeyDown:y=>{y.key==="Enter"&&v()}})}),s.jsx(S,{variant:"primary",className:"min-h-11","aria-disabled":i.isPending,"aria-busy":i.isPending,onClick:v,children:i.isPending?"Saving…":"Save limit"}),f&&s.jsx(w,{failure:f})]})}const hs={ApiKey:"Replace key",Model:"Fix the model",BaseUrl:"Fix the base URL"};function xs({result:e,presetLabel:t,onFix:a,shown:i}){if(e.state==="Passed")return s.jsxs(K,{tone:"success",variant:"soft",children:[s.jsxs("p",{className:"font-medium",children:["Test passed in ",e.latencyMs," ms"]}),s.jsxs("p",{className:"mt-0.5 text-fg-muted",children:["Sample message labelled ",e.label,","," ",Math.round(e.confidence*100),"% confident."]})]});const n=rs(e),o=e.field;return s.jsxs(K,{tone:"danger",variant:"soft",children:[s.jsx("p",{className:"font-medium",children:n}),s.jsxs("p",{className:"mt-0.5 break-words text-fg-muted",children:[e.fix," Nothing changed: classification stays as it was."]}),s.jsxs("p",{className:"flex flex-wrap items-center gap-x-4",children:[o!==void 0&&i[o]&&s.jsx("button",{type:"button",onClick:()=>a(o),className:"inline-flex min-h-11 items-center font-medium text-accent hover:underline",children:hs[o]}),s.jsx(ye,{href:Ne(`Test of ${t} failed`,`${n}. ${e.kind}. ${e.fix}`)})]})]})}function ys({preset:e,settings:t,onAnnounce:a}){const i=W(),n=ms(),[o,d]=l.useState(()=>ze(e,t)),[c,f]=l.useState(null),[m,h]=l.useState(null),[u,b]=l.useState(!1),[x,v]=l.useState(null),[y,U]=l.useState(null),p=l.useRef(null),j=l.useRef(null),Z=l.useRef(null),z=l.useRef(null),E=l.useId(),L=`${E}-model`,B=`${E}-base-url`,F=`${E}-key`;l.useEffect(()=>{if(!y)return;({Model:p,BaseUrl:j,ApiKey:Z,Replace:z})[y.target].current?.focus()},[y]);const M=ge(t,e.presetId),J=M?.apiKey??N.Default,T=e.needsKey&&J!==N.Default,ee=J===N.Deployment,we=e.needsKey&&(!T||u),ke={ApiKey:e.needsKey,Model:!0,BaseUrl:!0},I=r=>c?.field===r?c.message:void 0,C=r=>I(r)!==void 0||m?.state==="Failed"&&m.field===r,$=r=>U({target:r}),D=(r,H)=>{d(g=>({...g,...H})),h(g=>g?.state==="Passed"?null:g),f(g=>g?.field===r?null:g),a("")},se=()=>{b(!0),$("ApiKey")},te=()=>{b(!1),d(r=>({...r,apiKey:""})),f(r=>r?.field==="ApiKey"?null:r),$("Replace")},O=r=>{if(r==="ApiKey"&&T){se();return}$(r)},Ue=()=>{const r=is(o,e,t);if(!r.ok){f({field:r.field,message:r.message}),O(r.field);return}v(null);const H=u;i.mutate({body:r.body},{onSuccess:()=>{d(g=>({...g,apiKey:""})),b(!1),f(null),a("Saved"),H&&$("Replace")},onError:g=>{if(ts(g)){f({field:"ApiKey",message:je}),O("ApiKey");return}v({title:`${e.label} was not saved`,error:g})}})},Pe=()=>{n.isPending||(h(null),v(null),a(""),n.mutate({body:{presetId:e.presetId,model:o.model.trim(),baseUrl:o.baseUrl.trim(),apiKey:o.apiKey.trim()}},{onSuccess:h,onError:r=>v({title:`The test of ${e.label} did not run`,error:r})}))},ae=V(t,e.presetId,"model")??e.defaultModel,Re=V(t,e.presetId,"baseUrl")??e.defaultBaseUrl??"http://localhost:11434/v1",ie=I("ApiKey");return s.jsxs(s.Fragment,{children:[s.jsx(P,{id:L,label:"Model",hint:A(`Empty uses ${ae}.`,M?.model),error:I("Model"),children:s.jsx(q,{id:L,ref:p,className:"h-11",value:o.model,placeholder:ae,autoComplete:"off",spellCheck:!1,"aria-invalid":C("Model"),"aria-describedby":R(L,!0,I("Model")!==void 0),onChange:r=>D("Model",{model:r.target.value})})}),s.jsx(P,{id:B,label:"Base URL",hint:A("Remit's server calls this URL.",M?.baseUrl),error:I("BaseUrl"),children:s.jsx(q,{id:B,ref:j,className:"h-11",type:"url",inputMode:"url",value:o.baseUrl,placeholder:Re,autoComplete:"off",spellCheck:!1,required:ve(e),"aria-invalid":C("BaseUrl"),"aria-describedby":R(B,!0,I("BaseUrl")!==void 0),onChange:r=>D("BaseUrl",{baseUrl:r.target.value})})}),T&&!u&&s.jsxs("div",{children:[s.jsx("p",{className:"mb-1 text-xs font-medium text-fg-muted",children:"API key"}),s.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:[ee?s.jsx("span",{className:C("ApiKey")?"text-sm text-danger":"text-sm text-fg-muted",children:"provided by the deployment"}):s.jsx("span",{className:C("ApiKey")?"text-sm text-danger":"text-sm text-fg",children:"set"}),s.jsx("span",{className:"flex-1"}),s.jsx(S,{ref:z,variant:"secondary",className:"min-h-11","aria-invalid":C("ApiKey"),onClick:se,children:ee?"Use your own key":"Replace"})]})]}),we&&s.jsx(P,{id:F,label:u?"New API key":"API key",hint:u?"The key in use stays until you press Save.":void 0,error:ie,children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Oe,{id:F,ref:Z,className:"h-11 flex-1",value:o.apiKey,placeholder:u?"Paste the new key":"Paste the key",autoComplete:"off",spellCheck:!1,"aria-invalid":C("ApiKey"),"aria-describedby":R(F,u,ie!==void 0),onChange:r=>D("ApiKey",{apiKey:r.target.value}),onKeyDown:r=>{r.key==="Escape"&&u&&(r.preventDefault(),r.stopPropagation(),te())}}),u&&s.jsx(S,{variant:"ghost",className:"min-h-11",onClick:te,children:"Cancel"})]})}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsx(S,{variant:"primary",className:"min-h-11","aria-disabled":i.isPending,onClick:()=>{i.isPending||Ue()},children:i.isPending?"Saving…":"Save"}),s.jsx(S,{variant:"secondary",className:"min-h-11","aria-disabled":n.isPending,"aria-busy":n.isPending,onClick:Pe,children:n.isPending?"Testing…":"Test connection"})]}),s.jsx("p",{"aria-live":"polite",className:"text-sm text-fg-muted empty:hidden",children:n.isPending?`Sending one sample message to ${e.label}`:""}),m&&s.jsx(xs,{result:m,presetLabel:e.label,onFix:O,shown:ke}),x&&s.jsx(w,{failure:x})]})}function bs({presets:e,settings:t,onAnnounce:a}){const[i,n]=l.useState(()=>G(t).presetId),o=fs(),[d,c]=l.useState(!1),[f,m]=l.useState(0),[h,u]=l.useState(null),b=l.useId(),x=e.find(p=>p.presetId===i),v=ns(t,i,e),y=t.state==="Configured"&&t.enabled,U=()=>{u(null),o.mutate({},{onSuccess:p=>{c(!1),n(G(p.classification).presetId),m(j=>j+1)},onError:p=>{c(!1),u({title:"The provider settings were not cleared",error:p})}})};return s.jsxs("section",{className:"space-y-4",children:[s.jsxs("div",{className:"flex min-h-11 items-center gap-3",children:[s.jsx("h2",{className:"flex-1 text-xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Provider"}),Je(t)&&s.jsx(S,{variant:"secondary",className:"min-h-11",onClick:()=>c(!0),children:"Clear"})]}),h&&s.jsx(w,{failure:h}),s.jsx(P,{id:b,label:"Provider",hint:x?os(x):void 0,children:s.jsxs(Ge,{id:b,className:"h-11",value:i??"",onChange:p=>n(e.find(j=>j.presetId===p.target.value)?.presetId),"aria-describedby":R(b,x!==void 0,!1),children:[s.jsx("option",{value:"",disabled:!0,children:"Choose a provider"}),ss(e).map(p=>s.jsx("optgroup",{label:p.label,children:p.presets.map(j=>s.jsx("option",{value:j.presetId,children:j.label},j.presetId))},p.group))]})}),v&&s.jsxs("p",{className:"text-sm text-warning",children:["Saving switches from ",v.label,k(t).sources?.apiKey===N.Saved?" and deletes its saved key.":"."]}),x&&s.jsx(ys,{preset:x,settings:t,onAnnounce:a},`${x.presetId}-${f}`),s.jsx(Qe,{isOpen:d,title:"Clear the provider settings?",description:y?"Classification is on. Clearing the provider switches it off, and new mail goes back to built-in rules. Every field returns to the deployment default.":"Clearing the provider returns every field to the deployment default.",confirmLabel:"Clear",destructive:!0,isBusy:o.isPending,onConfirm:U,onCancel:()=>c(!1)})]})}const ce="Mail classification settings did not load",de={[ne.NoBaseUrl]:"a base URL",[ne.NoApiKey]:"an API key"},gs=e=>{if(e.state==="NotConfigured")return"Save a provider below first. Until then, built-in rules label your mail.";if(e.state==="Unrunnable")return"The provider cannot run yet. Built-in rules label your mail.";const t=e.enabled?"New mail goes to the model. A failed call falls back to built-in rules.":"Provider saved. Built-in rules label your mail until you switch this on.";return A(t,e.sources.enabled)};function vs({settings:e}){return s.jsxs(K,{tone:"warning",variant:"soft",children:[s.jsxs("p",{className:"font-medium",children:["Classification cannot run without ",de[e.reason]]}),s.jsxs("p",{className:"mt-0.5 text-fg-muted",children:["Add ",de[e.reason]," below and save. Until then, built-in rules label your mail."]})]})}const js=e=>t=>{const a=e.find(i=>i.accountId===t);return a?.displayName?.trim()||a?.email||t};function Ns({on:e,capped:t}){return e?t?s.jsx(_,{tone:"warning",dot:!0,children:"cap reached"}):s.jsx(_,{tone:"positive",dot:!0,children:"on"}):s.jsx(_,{dot:!0,children:"off"})}function Ss({usage:e,preset:t,nameOf:a}){return s.jsx("dl",{className:"space-y-2",children:e.map(i=>s.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-x-3",children:[s.jsx("dt",{className:"min-w-0 truncate text-sm text-fg",children:a(i.accountId)}),s.jsxs("dd",{className:"text-right text-sm text-fg-muted",children:[s.jsxs("span",{className:"text-fg",children:[i.calls," / ",i.dailyLimit," calls"]})," ",s.jsxs("span",{className:"text-xs",children:[ds(i,t),Se(i)&&s.jsx("span",{className:"text-warning",children:" · limit reached"})]})]})]},i.accountId))})}function Is({first:e,capped:t,nameOf:a,onRaiseLimit:i}){const n=new Intl.ListFormat("en",{type:"conjunction"}).format(t.map(o=>a(o.accountId)));return s.jsxs(K,{tone:"warning",variant:"soft",children:[s.jsxs("p",{className:"font-medium",children:[n," reached the daily limit of ",e.dailyLimit," calls"]}),s.jsxs("p",{className:"mt-0.5 text-fg-muted",children:[t.length===1?"Its":"Their"," new mail uses built-in rules until ",Ie(e.resetsAt),"."]}),s.jsx(S,{variant:"secondary",className:"mt-2 min-h-11",onClick:i,children:"Raise the limit"})]})}function Cs({settings:e,presets:t,nameOf:a,onRaiseLimit:i}){const n=W(),[o,d]=l.useState(null),c=l.useId(),f=e.state==="Configured",m=f&&e.enabled,h=m?e.usage.filter(Se):[],[u]=h,b=()=>{d(null),n.mutate({body:{classificationEnabled:!m}},{onError:d})};return s.jsxs("section",{"aria-labelledby":`${c}-title`,className:"space-y-3",children:[s.jsx("h2",{id:`${c}-title`,className:"text-xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Status"}),s.jsxs("div",{className:"flex min-h-11 items-center gap-3",children:[s.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[s.jsx("span",{id:`${c}-label`,className:"text-sm text-fg",children:"Use the model"}),s.jsx("span",{id:`${c}-note`,className:"text-xs text-fg-subtle",children:gs(e)})]}),s.jsx(Ns,{on:m,capped:u!==void 0}),s.jsx(Xe,{checked:m,"aria-labelledby":`${c}-label`,"aria-describedby":`${c}-note`,"aria-disabled":!f||n.isPending,"aria-busy":n.isPending,onToggle:b})]}),e.state==="Unrunnable"&&s.jsx(vs,{settings:e}),u&&s.jsx(Is,{first:u,capped:h,nameOf:a,onRaiseLimit:i}),f&&s.jsx(Ss,{usage:e.usage,preset:t.find(x=>x.presetId===e.presetId),nameOf:a}),o!==null&&s.jsx(w,{failure:{title:m?"Classification was not switched off":"Classification was not switched on",error:o}})]})}function ue(){return s.jsx("div",{className:"h-48 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":"Loading mail classification settings"})}function ws(){const e=us(),t=me({...He(),staleTime:1/0}),[a,i]=l.useState(""),n=l.useRef(null),o=()=>{const f=n.current;f&&(f.focus(),f.select(),f.scrollIntoView({block:"center"}))};if(e.isPending)return s.jsx(ue,{});if(e.signedOut)return null;if(e.isError)return s.jsx(w,{failure:{title:ce,error:e.error},onRetry:()=>{e.refetch()}});if(t.isPending)return s.jsx(ue,{});if(t.isError)return s.jsx(w,{failure:{title:ce,error:t.error},onRetry:()=>{t.refetch()}});const{classification:d,classificationPresets:c}=e.data;return s.jsxs("div",{className:"max-w-xl space-y-8",children:[s.jsx(Cs,{settings:d,presets:c,nameOf:js(t.data.accounts),onRaiseLimit:o}),s.jsx(bs,{presets:c,settings:d,onAnnounce:i},d.state),d.state==="Configured"&&s.jsx(ps,{settings:d,inputRef:n,onAnnounce:i}),s.jsx("p",{"aria-live":"polite",className:"text-sm text-fg-muted",children:a})]})}const ks=s.jsxs("div",{className:"space-y-3",children:[s.jsx("p",{children:"A model labels new mail: spam and phishing, priority, personal, and a category. With classification off, or when a call fails, the built-in rules label it."}),s.jsx("p",{children:"The API key is stored encrypted on the server and never sent back to the browser. Test connection sends one built-in sample message, with the form as it stands, and changes nothing."})]});function Hs(){const e=_e(),t=qe(),a=Ye(),[i,n]=l.useState(!0);return s.jsx(We,{items:t,activeId:"classification",title:"Mail classification",description:"Label new mail with a model. Mail already in your folders keeps its labels.",help:ks,helpOpen:i,onToggleHelp:()=>n(o=>!o),onSelect:a,onBackToMail:()=>{e({to:"/mail"})},children:s.jsx(ws,{})})}export{Hs as component};
1
+ import{aP as Ke,aw as $e,ax as Ae,b0 as Ee,b1 as N,b2 as Le,s as fe,b3 as Be,a as me,b4 as pe,r as l,b5 as he,e as xe,f as Q,b6 as Fe,b7 as Me,b8 as Te,j as s,d as K,B as S,aG as De,ao as q,ap as Oe,c as He,b9 as ne,u as _e,ac as qe}from"./index-BoYUTbor.js";import{R as ye}from"./ReportLink-DlgYSSed.js";import{f as Ve}from"./ErrorState-CKFCoido.js";import{S as Ge}from"./select-BzudQ-hj.js";import{C as Qe}from"./confirm-dialog-IJNXJDPm.js";import{S as Xe}from"./switch-BTBLx1IK.js";import{B as _}from"./badge-Ci5wC_7z.js";import{a as Ye}from"./sections-BlI9KK6M.js";import{S as We}from"./settings-screen-DRlPhwXt.js";import"./chevron-down-DGwUrOcf.js";import"./avatar-UfQRtoX1.js";import"./chevron-left-BW50jo-d.js";import"./menu-BoWQGjnP.js";import"./circle-help-C8FYparP.js";const Ze=fe(403),X={...fe(400,403,404,409,422,429),...Ee},be=e=>Ke(e)===403,k=e=>e.state==="NotConfigured"?{presetId:void 0,sources:void 0}:e.state==="Unrunnable"?{presetId:e.presetId,sources:void 0}:{presetId:e.presetId,sources:e.sources},ge=(e,t)=>{const a=k(e);return a.presetId===t?a.sources:void 0},re=(e,t)=>e.state==="Configured"&&e.sources[t]===N.Saved?e[t]:"",V=(e,t,a)=>e.state==="Configured"&&e.presetId===t&&e[a]!==""?e[a]:void 0,G=e=>({presetId:k(e).presetId,model:re(e,"model"),baseUrl:re(e,"baseUrl"),apiKey:""}),ze=(e,t)=>k(t).presetId===e.presetId?G(t):{presetId:e.presetId,model:"",baseUrl:"",apiKey:""},Je=e=>e.state==="Unrunnable"?!0:e.state==="NotConfigured"?!1:Object.values(e.sources).includes(N.Saved),es={Hosted:"Hosted",Custom:"Your own endpoint",Local:"Self-hosted"},ss=e=>{const t=[];for(const a of e){const i=t.find(n=>n.group===a.group);if(i){i.presets.push(a);continue}t.push({group:a.group,label:es[a.group],presets:[a]})}return t},ve=e=>e.defaultBaseUrl===void 0,A=(e,t)=>t===N.Saved?`${e} Saved by you.`:t===N.Deployment?`${e} Provided by the deployment.`:e,je="Paste an API key",ts=e=>Be(e)?.code==="ClassificationApiKeyRequired",oe="Enter a URL that starts with http:// or https://",as=e=>{if(!URL.canParse(e))return!1;const{protocol:t}=new URL(e);return t==="http:"||t==="https:"},is=(e,t,a)=>{const i=e.baseUrl.trim(),n=e.apiKey.trim(),o=ge(a,t.presetId);if(i!==""&&!as(i))return{ok:!1,field:"BaseUrl",message:oe};if(i===""&&ve(t)&&V(a,t.presetId,"baseUrl")===void 0)return{ok:!1,field:"BaseUrl",message:oe};const d=o?.apiKey??N.Default;return t.needsKey&&n===""&&d===N.Default?{ok:!1,field:"ApiKey",message:je}:{ok:!0,body:{...k(a).presetId!==t.presetId?{classificationPresetId:t.presetId}:{},classificationModel:e.model.trim(),classificationBaseUrl:i,...t.needsKey&&n!==""?{classificationApiKey:n}:{}}}},ns=(e,t,a)=>{const i=k(e).presetId;if(!(i===void 0||t===void 0)&&i!==t)return a.find(n=>n.presetId===i)},rs=e=>{const t=e.status===void 0?e.kind:`${e.status}`;return`Test failed after ${e.latencyMs} ms: ${t}`},Ne=(e,t)=>$e(Ae({title:`Mail classification: ${e}`,errorMessage:`${e}. ${t}`})),os=e=>{const t=e.needsKey?"Needs an API key.":"No key needed.";if(e.price.state!=="Priced")return t;const a=new Intl.NumberFormat("en",{style:"currency",currency:e.price.currency,maximumFractionDigits:4}).format(e.price.perMillionInputTokens);return`${t} ${a} per million input tokens.`},le="Enter a whole number of 1 or more.",ls=2147483647,cs=e=>{const t=e.trim();if(!/^\d+$/.test(t))return{ok:!1,message:le};const a=Number(t);return a<1||a>ls?{ok:!1,message:le}:{ok:!0,limit:a}},Se=e=>e.calls>=e.dailyLimit,ds=(e,t)=>{const{cost:a}=e;if(a.state==="Priced"){const i=new Intl.NumberFormat("en",{style:"currency",currency:a.currency,maximumFractionDigits:2});return a.amount>0&&a.amount<.01?`under ${i.format(.01)}`:a.amount===0?i.format(0):`about ${i.format(a.amount)}`}return t?.group==="Local"?"no price, self-hosted":"no price"},Ie=e=>Le(e,{hour:"2-digit",minute:"2-digit",timeZoneName:"shortOffset"}),Y=e=>{be(e)&&he()},Ce=e=>t=>{e.setQueryData(pe().queryKey,t)},us=()=>{const e=me({...pe(),meta:Ze}),t=e.isError&&be(e.error);return l.useEffect(()=>{t&&he()},[t]),{...e,signedOut:t}},W=()=>{const e=xe();return Q({...Fe(),meta:X,onSuccess:Ce(e),onError:Y})},fs=()=>{const e=xe();return Q({...Me(),meta:X,onSuccess:Ce(e),onError:Y})},ms=()=>Q({...Te(),meta:X,onError:Y});function w({failure:e,onRetry:t}){const a=Ve(e.error);return s.jsxs(K,{tone:"danger",variant:"soft",children:[s.jsx("p",{className:"font-medium",children:e.title}),s.jsx("p",{className:"mt-0.5 break-words text-fg-muted",children:a}),s.jsxs("p",{className:"flex flex-wrap items-center gap-x-4",children:[t&&s.jsx(S,{variant:"secondary",className:"min-h-11",onClick:t,children:"Retry"}),s.jsx(ye,{href:Ne(e.title,a)})]})]})}function P({id:e,label:t,hint:a,error:i,children:n}){return s.jsxs("div",{children:[s.jsx(De,{htmlFor:e,children:t}),n,i&&s.jsx("p",{id:`${e}-error`,className:"mt-1 text-xs text-danger",children:i}),a&&s.jsx("p",{id:`${e}-hint`,className:"mt-1 text-xs text-fg-subtle",children:a})]})}const R=(e,t,a)=>[a?`${e}-error`:"",t?`${e}-hint`:""].filter(Boolean).join(" ")||void 0;function ps({settings:e,inputRef:t,onAnnounce:a}){const i=W(),[n,o]=l.useState(()=>`${e.dailyLimit}`),[d,c]=l.useState(void 0),[f,m]=l.useState(null),h=l.useId(),u=`${h}-limit`,[b]=e.usage,x=b?`Counts reset at ${Ie(b.resetsAt)}. `:"",v=()=>{if(i.isPending)return;const y=cs(n);if(!y.ok){c(y.message);return}m(null),i.mutate({body:{classificationDailyLimit:y.limit}},{onSuccess:()=>a("Saved"),onError:U=>m({title:"The daily limit was not saved",error:U})})};return s.jsxs("section",{"aria-labelledby":`${h}-title`,className:"space-y-4",children:[s.jsx("h2",{id:`${h}-title`,className:"text-xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Daily limit"}),s.jsx(P,{id:u,label:"Calls per account per day",hint:A(`${x}Past the limit, that account's new mail uses built-in rules.`,e.sources.dailyLimit),error:d,children:s.jsx(q,{id:u,ref:t,className:"h-11",inputMode:"numeric",value:n,autoComplete:"off","aria-invalid":d!==void 0,"aria-describedby":R(u,!0,d!==void 0),onChange:y=>{o(y.target.value),c(void 0),a("")},onKeyDown:y=>{y.key==="Enter"&&v()}})}),s.jsx(S,{variant:"primary",className:"min-h-11","aria-disabled":i.isPending,"aria-busy":i.isPending,onClick:v,children:i.isPending?"Saving…":"Save limit"}),f&&s.jsx(w,{failure:f})]})}const hs={ApiKey:"Replace key",Model:"Fix the model",BaseUrl:"Fix the base URL"};function xs({result:e,presetLabel:t,onFix:a,shown:i}){if(e.state==="Passed")return s.jsxs(K,{tone:"success",variant:"soft",children:[s.jsxs("p",{className:"font-medium",children:["Test passed in ",e.latencyMs," ms"]}),s.jsxs("p",{className:"mt-0.5 text-fg-muted",children:["Sample message labelled ",e.label,","," ",Math.round(e.confidence*100),"% confident."]})]});const n=rs(e),o=e.field;return s.jsxs(K,{tone:"danger",variant:"soft",children:[s.jsx("p",{className:"font-medium",children:n}),s.jsxs("p",{className:"mt-0.5 break-words text-fg-muted",children:[e.fix," Nothing changed: classification stays as it was."]}),s.jsxs("p",{className:"flex flex-wrap items-center gap-x-4",children:[o!==void 0&&i[o]&&s.jsx("button",{type:"button",onClick:()=>a(o),className:"inline-flex min-h-11 items-center font-medium text-accent hover:underline",children:hs[o]}),s.jsx(ye,{href:Ne(`Test of ${t} failed`,`${n}. ${e.kind}. ${e.fix}`)})]})]})}function ys({preset:e,settings:t,onAnnounce:a}){const i=W(),n=ms(),[o,d]=l.useState(()=>ze(e,t)),[c,f]=l.useState(null),[m,h]=l.useState(null),[u,b]=l.useState(!1),[x,v]=l.useState(null),[y,U]=l.useState(null),p=l.useRef(null),j=l.useRef(null),Z=l.useRef(null),z=l.useRef(null),E=l.useId(),L=`${E}-model`,B=`${E}-base-url`,F=`${E}-key`;l.useEffect(()=>{if(!y)return;({Model:p,BaseUrl:j,ApiKey:Z,Replace:z})[y.target].current?.focus()},[y]);const M=ge(t,e.presetId),J=M?.apiKey??N.Default,T=e.needsKey&&J!==N.Default,ee=J===N.Deployment,we=e.needsKey&&(!T||u),ke={ApiKey:e.needsKey,Model:!0,BaseUrl:!0},I=r=>c?.field===r?c.message:void 0,C=r=>I(r)!==void 0||m?.state==="Failed"&&m.field===r,$=r=>U({target:r}),D=(r,H)=>{d(g=>({...g,...H})),h(g=>g?.state==="Passed"?null:g),f(g=>g?.field===r?null:g),a("")},se=()=>{b(!0),$("ApiKey")},te=()=>{b(!1),d(r=>({...r,apiKey:""})),f(r=>r?.field==="ApiKey"?null:r),$("Replace")},O=r=>{if(r==="ApiKey"&&T){se();return}$(r)},Ue=()=>{const r=is(o,e,t);if(!r.ok){f({field:r.field,message:r.message}),O(r.field);return}v(null);const H=u;i.mutate({body:r.body},{onSuccess:()=>{d(g=>({...g,apiKey:""})),b(!1),f(null),a("Saved"),H&&$("Replace")},onError:g=>{if(ts(g)){f({field:"ApiKey",message:je}),O("ApiKey");return}v({title:`${e.label} was not saved`,error:g})}})},Pe=()=>{n.isPending||(h(null),v(null),a(""),n.mutate({body:{presetId:e.presetId,model:o.model.trim(),baseUrl:o.baseUrl.trim(),apiKey:o.apiKey.trim()}},{onSuccess:h,onError:r=>v({title:`The test of ${e.label} did not run`,error:r})}))},ae=V(t,e.presetId,"model")??e.defaultModel,Re=V(t,e.presetId,"baseUrl")??e.defaultBaseUrl??"http://localhost:11434/v1",ie=I("ApiKey");return s.jsxs(s.Fragment,{children:[s.jsx(P,{id:L,label:"Model",hint:A(`Empty uses ${ae}.`,M?.model),error:I("Model"),children:s.jsx(q,{id:L,ref:p,className:"h-11",value:o.model,placeholder:ae,autoComplete:"off",spellCheck:!1,"aria-invalid":C("Model"),"aria-describedby":R(L,!0,I("Model")!==void 0),onChange:r=>D("Model",{model:r.target.value})})}),s.jsx(P,{id:B,label:"Base URL",hint:A("Remit's server calls this URL.",M?.baseUrl),error:I("BaseUrl"),children:s.jsx(q,{id:B,ref:j,className:"h-11",type:"url",inputMode:"url",value:o.baseUrl,placeholder:Re,autoComplete:"off",spellCheck:!1,required:ve(e),"aria-invalid":C("BaseUrl"),"aria-describedby":R(B,!0,I("BaseUrl")!==void 0),onChange:r=>D("BaseUrl",{baseUrl:r.target.value})})}),T&&!u&&s.jsxs("div",{children:[s.jsx("p",{className:"mb-1 text-xs font-medium text-fg-muted",children:"API key"}),s.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:[ee?s.jsx("span",{className:C("ApiKey")?"text-sm text-danger":"text-sm text-fg-muted",children:"provided by the deployment"}):s.jsx("span",{className:C("ApiKey")?"text-sm text-danger":"text-sm text-fg",children:"set"}),s.jsx("span",{className:"flex-1"}),s.jsx(S,{ref:z,variant:"secondary",className:"min-h-11","aria-invalid":C("ApiKey"),onClick:se,children:ee?"Use your own key":"Replace"})]})]}),we&&s.jsx(P,{id:F,label:u?"New API key":"API key",hint:u?"The key in use stays until you press Save.":void 0,error:ie,children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Oe,{id:F,ref:Z,className:"h-11 flex-1",value:o.apiKey,placeholder:u?"Paste the new key":"Paste the key",autoComplete:"off",spellCheck:!1,"aria-invalid":C("ApiKey"),"aria-describedby":R(F,u,ie!==void 0),onChange:r=>D("ApiKey",{apiKey:r.target.value}),onKeyDown:r=>{r.key==="Escape"&&u&&(r.preventDefault(),r.stopPropagation(),te())}}),u&&s.jsx(S,{variant:"ghost",className:"min-h-11",onClick:te,children:"Cancel"})]})}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsx(S,{variant:"primary",className:"min-h-11","aria-disabled":i.isPending,onClick:()=>{i.isPending||Ue()},children:i.isPending?"Saving…":"Save"}),s.jsx(S,{variant:"secondary",className:"min-h-11","aria-disabled":n.isPending,"aria-busy":n.isPending,onClick:Pe,children:n.isPending?"Testing…":"Test connection"})]}),s.jsx("p",{"aria-live":"polite",className:"text-sm text-fg-muted empty:hidden",children:n.isPending?`Sending one sample message to ${e.label}`:""}),m&&s.jsx(xs,{result:m,presetLabel:e.label,onFix:O,shown:ke}),x&&s.jsx(w,{failure:x})]})}function bs({presets:e,settings:t,onAnnounce:a}){const[i,n]=l.useState(()=>G(t).presetId),o=fs(),[d,c]=l.useState(!1),[f,m]=l.useState(0),[h,u]=l.useState(null),b=l.useId(),x=e.find(p=>p.presetId===i),v=ns(t,i,e),y=t.state==="Configured"&&t.enabled,U=()=>{u(null),o.mutate({},{onSuccess:p=>{c(!1),n(G(p.classification).presetId),m(j=>j+1)},onError:p=>{c(!1),u({title:"The provider settings were not cleared",error:p})}})};return s.jsxs("section",{className:"space-y-4",children:[s.jsxs("div",{className:"flex min-h-11 items-center gap-3",children:[s.jsx("h2",{className:"flex-1 text-xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Provider"}),Je(t)&&s.jsx(S,{variant:"secondary",className:"min-h-11",onClick:()=>c(!0),children:"Clear"})]}),h&&s.jsx(w,{failure:h}),s.jsx(P,{id:b,label:"Provider",hint:x?os(x):void 0,children:s.jsxs(Ge,{id:b,className:"h-11",value:i??"",onChange:p=>n(e.find(j=>j.presetId===p.target.value)?.presetId),"aria-describedby":R(b,x!==void 0,!1),children:[s.jsx("option",{value:"",disabled:!0,children:"Choose a provider"}),ss(e).map(p=>s.jsx("optgroup",{label:p.label,children:p.presets.map(j=>s.jsx("option",{value:j.presetId,children:j.label},j.presetId))},p.group))]})}),v&&s.jsxs("p",{className:"text-sm text-warning",children:["Saving switches from ",v.label,k(t).sources?.apiKey===N.Saved?" and deletes its saved key.":"."]}),x&&s.jsx(ys,{preset:x,settings:t,onAnnounce:a},`${x.presetId}-${f}`),s.jsx(Qe,{isOpen:d,title:"Clear the provider settings?",description:y?"Classification is on. Clearing the provider switches it off, and new mail goes back to built-in rules. Every field returns to the deployment default.":"Clearing the provider returns every field to the deployment default.",confirmLabel:"Clear",destructive:!0,isBusy:o.isPending,onConfirm:U,onCancel:()=>c(!1)})]})}const ce="Mail classification settings did not load",de={[ne.NoBaseUrl]:"a base URL",[ne.NoApiKey]:"an API key"},gs=e=>{if(e.state==="NotConfigured")return"Save a provider below first. Until then, built-in rules label your mail.";if(e.state==="Unrunnable")return"The provider cannot run yet. Built-in rules label your mail.";const t=e.enabled?"New mail goes to the model. A failed call falls back to built-in rules.":"Provider saved. Built-in rules label your mail until you switch this on.";return A(t,e.sources.enabled)};function vs({settings:e}){return s.jsxs(K,{tone:"warning",variant:"soft",children:[s.jsxs("p",{className:"font-medium",children:["Classification cannot run without ",de[e.reason]]}),s.jsxs("p",{className:"mt-0.5 text-fg-muted",children:["Add ",de[e.reason]," below and save. Until then, built-in rules label your mail."]})]})}const js=e=>t=>{const a=e.find(i=>i.accountId===t);return a?.displayName?.trim()||a?.email||t};function Ns({on:e,capped:t}){return e?t?s.jsx(_,{tone:"warning",dot:!0,children:"cap reached"}):s.jsx(_,{tone:"positive",dot:!0,children:"on"}):s.jsx(_,{dot:!0,children:"off"})}function Ss({usage:e,preset:t,nameOf:a}){return s.jsx("dl",{className:"space-y-2",children:e.map(i=>s.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-x-3",children:[s.jsx("dt",{className:"min-w-0 truncate text-sm text-fg",children:a(i.accountId)}),s.jsxs("dd",{className:"text-right text-sm text-fg-muted",children:[s.jsxs("span",{className:"text-fg",children:[i.calls," / ",i.dailyLimit," calls"]})," ",s.jsxs("span",{className:"text-xs",children:[ds(i,t),Se(i)&&s.jsx("span",{className:"text-warning",children:" · limit reached"})]})]})]},i.accountId))})}function Is({first:e,capped:t,nameOf:a,onRaiseLimit:i}){const n=new Intl.ListFormat("en",{type:"conjunction"}).format(t.map(o=>a(o.accountId)));return s.jsxs(K,{tone:"warning",variant:"soft",children:[s.jsxs("p",{className:"font-medium",children:[n," reached the daily limit of ",e.dailyLimit," calls"]}),s.jsxs("p",{className:"mt-0.5 text-fg-muted",children:[t.length===1?"Its":"Their"," new mail uses built-in rules until ",Ie(e.resetsAt),"."]}),s.jsx(S,{variant:"secondary",className:"mt-2 min-h-11",onClick:i,children:"Raise the limit"})]})}function Cs({settings:e,presets:t,nameOf:a,onRaiseLimit:i}){const n=W(),[o,d]=l.useState(null),c=l.useId(),f=e.state==="Configured",m=f&&e.enabled,h=m?e.usage.filter(Se):[],[u]=h,b=()=>{d(null),n.mutate({body:{classificationEnabled:!m}},{onError:d})};return s.jsxs("section",{"aria-labelledby":`${c}-title`,className:"space-y-3",children:[s.jsx("h2",{id:`${c}-title`,className:"text-xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Status"}),s.jsxs("div",{className:"flex min-h-11 items-center gap-3",children:[s.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[s.jsx("span",{id:`${c}-label`,className:"text-sm text-fg",children:"Use the model"}),s.jsx("span",{id:`${c}-note`,className:"text-xs text-fg-subtle",children:gs(e)})]}),s.jsx(Ns,{on:m,capped:u!==void 0}),s.jsx(Xe,{checked:m,"aria-labelledby":`${c}-label`,"aria-describedby":`${c}-note`,"aria-disabled":!f||n.isPending,"aria-busy":n.isPending,onToggle:b})]}),e.state==="Unrunnable"&&s.jsx(vs,{settings:e}),u&&s.jsx(Is,{first:u,capped:h,nameOf:a,onRaiseLimit:i}),f&&s.jsx(Ss,{usage:e.usage,preset:t.find(x=>x.presetId===e.presetId),nameOf:a}),o!==null&&s.jsx(w,{failure:{title:m?"Classification was not switched off":"Classification was not switched on",error:o}})]})}function ue(){return s.jsx("div",{className:"h-48 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":"Loading mail classification settings"})}function ws(){const e=us(),t=me({...He(),staleTime:1/0}),[a,i]=l.useState(""),n=l.useRef(null),o=()=>{const f=n.current;f&&(f.focus(),f.select(),f.scrollIntoView({block:"center"}))};if(e.isPending)return s.jsx(ue,{});if(e.signedOut)return null;if(e.isError)return s.jsx(w,{failure:{title:ce,error:e.error},onRetry:()=>{e.refetch()}});if(t.isPending)return s.jsx(ue,{});if(t.isError)return s.jsx(w,{failure:{title:ce,error:t.error},onRetry:()=>{t.refetch()}});const{classification:d,classificationPresets:c}=e.data;return s.jsxs("div",{className:"max-w-xl space-y-8",children:[s.jsx(Cs,{settings:d,presets:c,nameOf:js(t.data.accounts),onRaiseLimit:o}),s.jsx(bs,{presets:c,settings:d,onAnnounce:i},d.state),d.state==="Configured"&&s.jsx(ps,{settings:d,inputRef:n,onAnnounce:i}),s.jsx("p",{"aria-live":"polite",className:"text-sm text-fg-muted",children:a})]})}const ks=s.jsxs("div",{className:"space-y-3",children:[s.jsx("p",{children:"A model labels new mail: spam and phishing, priority, personal, and a category. With classification off, or when a call fails, the built-in rules label it."}),s.jsx("p",{children:"The API key is stored encrypted on the server and never sent back to the browser. Test connection sends one built-in sample message, with the form as it stands, and changes nothing."})]});function Hs(){const e=_e(),t=qe(),a=Ye(),[i,n]=l.useState(!0);return s.jsx(We,{items:t,activeId:"classification",title:"Mail classification",description:"Label new mail with a model. Mail already in your folders keeps its labels.",help:ks,helpOpen:i,onToggleHelp:()=>n(o=>!o),onSelect:a,onBackToMail:()=>{e({to:"/mail"})},children:s.jsx(ws,{})})}export{Hs as component};
@@ -1 +1 @@
1
- import{b as c}from"./index-NTsfKnzH.js";const o=c("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);export{o as C};
1
+ import{b as c}from"./index-BoYUTbor.js";const o=c("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);export{o as C};
@@ -0,0 +1 @@
1
+ import{F as o}from"./FullCompose-_sj778B4.js";import"./index-BoYUTbor.js";import"./index-DCmMcCPu.js";import"./useMessageBodyContent-DECgYR7u.js";import"./reply-uZv24OMi.js";import"./nav-link-Bdfj8Qsa.js";import"./useMediaQuery-Bd0VbOGT.js";import"./useSignature-C5PObLcq.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-BMLVeivZ.js";import"./suggest-list-D2yVcukg.js";import"./sections-BlI9KK6M.js";import"./chevron-down-DGwUrOcf.js";import"./ErrorState-CKFCoido.js";import"./confirm-dialog-IJNXJDPm.js";const x=o;export{x as component};
@@ -0,0 +1 @@
1
+ import{F as o}from"./FullCompose-_sj778B4.js";import"./index-BoYUTbor.js";import"./index-DCmMcCPu.js";import"./useMessageBodyContent-DECgYR7u.js";import"./reply-uZv24OMi.js";import"./nav-link-Bdfj8Qsa.js";import"./useMediaQuery-Bd0VbOGT.js";import"./useSignature-C5PObLcq.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-BMLVeivZ.js";import"./suggest-list-D2yVcukg.js";import"./sections-BlI9KK6M.js";import"./chevron-down-DGwUrOcf.js";import"./ErrorState-CKFCoido.js";import"./confirm-dialog-IJNXJDPm.js";const x=o;export{x as component};
@@ -0,0 +1 @@
1
+ import{F as o}from"./FullCompose-_sj778B4.js";import"./index-BoYUTbor.js";import"./index-DCmMcCPu.js";import"./useMessageBodyContent-DECgYR7u.js";import"./reply-uZv24OMi.js";import"./nav-link-Bdfj8Qsa.js";import"./useMediaQuery-Bd0VbOGT.js";import"./useSignature-C5PObLcq.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-BMLVeivZ.js";import"./suggest-list-D2yVcukg.js";import"./sections-BlI9KK6M.js";import"./chevron-down-DGwUrOcf.js";import"./ErrorState-CKFCoido.js";import"./confirm-dialog-IJNXJDPm.js";const x=o;export{x as component};
@@ -0,0 +1 @@
1
+ import{F as o}from"./FullCompose-_sj778B4.js";import"./index-BoYUTbor.js";import"./index-DCmMcCPu.js";import"./useMessageBodyContent-DECgYR7u.js";import"./reply-uZv24OMi.js";import"./nav-link-Bdfj8Qsa.js";import"./useMediaQuery-Bd0VbOGT.js";import"./useSignature-C5PObLcq.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-BMLVeivZ.js";import"./suggest-list-D2yVcukg.js";import"./sections-BlI9KK6M.js";import"./chevron-down-DGwUrOcf.js";import"./ErrorState-CKFCoido.js";import"./confirm-dialog-IJNXJDPm.js";const x=o;export{x as component};