@remit/web-client-dist 0.0.656 → 0.0.658
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.
- package/assets/BriefPane-DTnPypWR.js +1 -0
- package/assets/CalendarComposePane-B5vgWbn2.js +1 -0
- package/assets/{CalendarComposeSeed-B6HxfV-P.js → CalendarComposeSeed-CvfYDo6K.js} +1 -1
- package/assets/{CalendarShell-D-5dI0jc.js → CalendarShell-CNCnuYI7.js} +1 -1
- package/assets/{EmptyState-Dw5-fMm4.js → EmptyState-DCvsovpV.js} +1 -1
- package/assets/{ErrorState-PNI7QSLU.js → ErrorState-BVvZa9Hj.js} +1 -1
- package/assets/{FlaggedPane-D0pQWXT9.js → FlaggedPane-CmOkn_je.js} +1 -1
- package/assets/{FullCompose-BACzjpTB.js → FullCompose-C-kYe1x_.js} +1 -1
- package/assets/MailListHeader-qqqmfyRg.js +1 -0
- package/assets/MailNav-UWoxDID1.js +1 -0
- package/assets/MailShell-D1RYjXBs.js +1 -0
- package/assets/{MailViewChrome-CP2oa-r7.js → MailViewChrome-CyrIkwO-.js} +1 -1
- package/assets/MailboxPane-sVCHNXDC.js +1 -0
- package/assets/{NavMenuButton-D17iXFBM.js → NavMenuButton-tjQzgXI6.js} +1 -1
- package/assets/{OnboardingWizard-BOAnucJW.js → OnboardingWizard-DC3VOl45.js} +1 -1
- package/assets/OpenCalendarEvent-DIV9Zaoz.js +2 -0
- package/assets/OutboxPane-DYMpq8YL.js +1 -0
- package/assets/SignInAgain-BroDYbz-.js +1 -0
- package/assets/_calendarObjectId-vj5yYITL.js +1 -0
- package/assets/_mailboxId-Cd2gcjfj.js +1 -0
- package/assets/_messageId-CKLpxaGL.js +1 -0
- package/assets/_messageId-otRrahEY.js +1 -0
- package/assets/_messageId-r661xgv7.js +1 -0
- package/assets/_outboxMessageId-DDWh3QXk.js +1 -0
- package/assets/_recurrenceId-Dmg0Y1yT.js +1 -0
- package/assets/_threadId-CatNqDrS.js +1 -0
- package/assets/_threadId-CtFGotoc.js +1 -0
- package/assets/_threadId-bIsty-QI.js +1 -0
- package/assets/_view._date-DWJzo3Lb.js +1 -0
- package/assets/accounts-BnWAstqJ.js +1 -0
- package/assets/advanced-CO3uos8-.js +1 -0
- package/assets/{appearance-CIBowvkx.js → appearance-l54q8jn2.js} +1 -1
- package/assets/{attendee-row-BRiEaasS.js → attendee-row-D2LMbq_7.js} +1 -1
- package/assets/{avatar-CCaAcetc.js → avatar-BEy9bmfT.js} +1 -1
- package/assets/{bell-off-CpcOtCIq.js → bell-off-o-5HqpFD.js} +1 -1
- package/assets/{bottom-sheet-BPiS9aBo.js → bottom-sheet-BQrIuUAp.js} +1 -1
- package/assets/{brief-C2k_YLnA.js → brief-BRyi3cpm.js} +1 -1
- package/assets/brief-CubStJH7.js +1 -0
- package/assets/{bug-C6xR86kp.js → bug-CiMAHRp3.js} +1 -1
- package/assets/calendar-CUTV9vSe.js +1 -0
- package/assets/{calendar-clash-strip-7S3XyUIT.js → calendar-clash-strip-BbznG7yo.js} +1 -1
- package/assets/{calendar-format-CDiJYM60.js → calendar-format-BZ1D5Ywu.js} +1 -1
- package/assets/{calendar-report-C-w9d_X_.js → calendar-report-1ttmpioo.js} +1 -1
- package/assets/{calendar-suggestion-BQoWPMtl.js → calendar-suggestion-DJ5uMZX8.js} +1 -1
- package/assets/{calendars-DHYpHK8C.js → calendars-Db5I-yCU.js} +1 -1
- package/assets/{card-Bqz6khhJ.js → card-BKgdv2bH.js} +1 -1
- package/assets/{checkbox-BwzvnbNT.js → checkbox-p9mLPjVs.js} +1 -1
- package/assets/chevron-left-iD9K0p2O.js +1 -0
- package/assets/{circle-check-DE9CwgTP.js → circle-check-6Bb3NNZS.js} +1 -1
- package/assets/{circle-check-big-kuolCFUC.js → circle-check-big-Cc1ertAI.js} +1 -1
- package/assets/{circle-help--jGrrMan.js → circle-help-C0X0r4BQ.js} +1 -1
- package/assets/{clock-CwmO_JCY.js → clock-BDHe3TX8.js} +1 -1
- package/assets/compose._-_outboxMessageId_-BAjHEoO7.js +1 -0
- package/assets/compose._-_outboxMessageId_-BjU_oGCR.js +1 -0
- package/assets/compose._-_outboxMessageId_-C-wPU4AM.js +1 -0
- package/assets/compose._-_outboxMessageId_-OEkiz68p.js +1 -0
- package/assets/{config-import-jGvPqLLa.js → config-import-DH8GC5mw.js} +1 -1
- package/assets/{confirm-dialog-WrJoQuYb.js → confirm-dialog-BmiOsB9N.js} +1 -1
- package/assets/{copy-BVqTKL-m.js → copy-B89b-33D.js} +1 -1
- package/assets/{credential-steps-BPNJm3Px.js → credential-steps-CKcZdVNd.js} +1 -1
- package/assets/{download-BoHBLdA7.js → download-53lT8mTP.js} +1 -1
- package/assets/external-link-NCezTZkT.js +1 -0
- package/assets/{file-json-CTXp7rcG.js → file-json-ofsJkIbX.js} +1 -1
- package/assets/filters-aur8iSET.js +1 -0
- package/assets/flagged-Cr5tlDf5.js +1 -0
- package/assets/{flagged-Cg2xxD0P.js → flagged-gRZxDkLX.js} +1 -1
- package/assets/folders-17G_KhLm.js +1 -0
- package/assets/{help-copy-BReMOm6I.js → help-copy-CADUhLzQ.js} +1 -1
- package/assets/{import-x6uYtBKs.js → import-CdvuJtNy.js} +1 -1
- package/assets/index-69yokqv5.js +1 -0
- package/assets/index-BDIVfNXM.js +293 -0
- package/assets/index-BFBfS7ek.js +1 -0
- package/assets/index-BRntGNJA.js +1 -0
- package/assets/{index-Cw3Kql7t.js → index-BngpvrPX.js} +1 -1
- package/assets/{index-BtYEmjxr.css → index-C2Hz4y-Q.css} +1 -1
- package/assets/index-Cg4p98vB.js +1 -0
- package/assets/{index-CyocVpgw.js → index-DDSpdJ8F.js} +8 -8
- package/assets/index-RmCPyEb8.js +1 -0
- package/assets/index-bYkeiMeC.js +1 -0
- package/assets/index-otRrahEY.js +1 -0
- package/assets/index-r661xgv7.js +1 -0
- package/assets/index-tN5HaTuq.js +1 -0
- package/assets/{kbd-Ccl_4UMN.js → kbd-BTTdW6-z.js} +1 -1
- package/assets/{labels-BbpPALNZ.js → labels-DoKExISZ.js} +1 -1
- package/assets/mail--BAAD5Tl.js +1 -0
- package/assets/{mail-BD9CFExB.js → mail-bV9GGVUQ.js} +1 -1
- package/assets/{map-pin-DM-UwFHl.js → map-pin-Bme-miZ2.js} +1 -1
- package/assets/{menu-Bk7fxS2w.js → menu-DQ-pJ4eT.js} +1 -1
- package/assets/minus-kSr1dVnA.js +1 -0
- package/assets/{new-mpTt3w7l.js → new-B4HXKzav.js} +1 -1
- package/assets/onboarding-Bsm3JVIj.js +1 -0
- package/assets/{onboarding-completion-Ckx99cv9.js → onboarding-completion-5Y5D9Jbr.js} +1 -1
- package/assets/outbox-BfHInRjp.js +1 -0
- package/assets/{pencil-C8Yuq6zp.js → pencil-D3GOCGCB.js} +1 -1
- package/assets/{popover-menu-CG5nGI0G.js → popover-menu-BRPef6re.js} +1 -1
- package/assets/{refresh-cw-DV6lCoUu.js → refresh-cw-BQa9I63p.js} +1 -1
- package/assets/result-count-C11MdZzg.js +1 -0
- package/assets/{rich-text-BFDSPN3k.js → rich-text-BxJPXURQ.js} +1 -1
- package/assets/{rich-text-spellcheck-worker-provider-eksJruIx.js → rich-text-spellcheck-worker-provider-BL2Dc5f1.js} +1 -1
- package/assets/{rotate-ccw-BWReSl7L.js → rotate-ccw-BzM31Pwc.js} +1 -1
- package/assets/{roving-focus-BgNxAjAj.js → roving-focus-DyhhSwbQ.js} +1 -1
- package/assets/{row-actions-BwuDucsx.js → row-actions-BtiK9OA9.js} +1 -1
- package/assets/{search-mirror-DSVQGDLi.js → search-mirror-CJ0qbKsO.js} +1 -1
- package/assets/search-query-hRPzdZsl.js +1 -0
- package/assets/search-scope-UI1H6AzA.js +1 -0
- package/assets/{search-token-index-BXtgewDi.js → search-token-index-C1Z6zA5N.js} +1 -1
- package/assets/{sections-45KeddjZ.js → sections-FEvJ4c2c.js} +1 -1
- package/assets/senders-DtHgpQ3C.js +1 -0
- package/assets/settings-DO0FWB3_.js +1 -0
- package/assets/{settings-screen-Bm-R0ESO.js → settings-screen-B51b9lvj.js} +1 -1
- package/assets/{shield-check-B_rWkRQY.js → shield-check-CgX3iFVl.js} +1 -1
- package/assets/suggested-vips-CZ7lFymc.js +1 -0
- package/assets/{suggestion._suggestionId-DHVADd-e.js → suggestion._suggestionId-YuPshPzz.js} +1 -1
- package/assets/{undo-2-UQEFkwhb.js → undo-2-DkaYLmdO.js} +1 -1
- package/assets/{useCalendarData-D27Ge-qS.js → useCalendarData-BQoK5111.js} +1 -1
- package/assets/useCalendarFreeBusy-d-s_-0eR.js +1 -0
- package/assets/{useCalendarWrites-OAZeHI6o.js → useCalendarWrites-xN5WbPCM.js} +1 -1
- package/assets/{useCalendars-O5ZvqPWu.js → useCalendars-CqOpDn21.js} +1 -1
- package/assets/{useDebouncedValue-BSAyBygv.js → useDebouncedValue-CTq8lKtR.js} +1 -1
- package/assets/useFilters-Oiv4LZCZ.js +1 -0
- package/assets/{useLabels-qT2MGxVA.js → useLabels-DLtLZsv9.js} +1 -1
- package/assets/useLayoutTier-94OSKAiu.js +1 -0
- package/assets/useMessageBodyContent-BTmHg9m0.js +1 -0
- package/assets/{useQueries-DH9StZ-W.js → useQueries-DFq_6laq.js} +1 -1
- package/assets/useRefreshControl-DzEBgWRZ.js +1 -0
- package/assets/{useResultFolderIndex-DYd3UAzD.js → useResultFolderIndex-DqH89sZ0.js} +1 -1
- package/assets/{useSearchTokenContext-CnVweHh1.js → useSearchTokenContext-BYEkwdSc.js} +3 -3
- package/assets/{useSignature-B8GSTQOi.js → useSignature-V-VSVmYl.js} +1 -1
- package/assets/warnings-rdkIsd04.js +5 -0
- package/index.html +2 -2
- package/package.json +1 -1
- package/assets/BriefPane-l0C6HwIU.js +0 -1
- package/assets/CalendarComposePane-C61ZEczL.js +0 -1
- package/assets/MailListHeader-Dp-YNlPj.js +0 -1
- package/assets/MailNav-C7sJoax-.js +0 -1
- package/assets/MailShell-DzKQC7Uj.js +0 -1
- package/assets/MailboxPane-DkOrdudP.js +0 -1
- package/assets/OpenCalendarEvent-CYS0fC96.js +0 -2
- package/assets/OutboxPane-DNsIelwN.js +0 -1
- package/assets/_calendarObjectId-BkE4AxkO.js +0 -1
- package/assets/_mailboxId-BrtMTF-6.js +0 -1
- package/assets/_messageId-96unnwX9.js +0 -1
- package/assets/_messageId-BsV3aJW4.js +0 -1
- package/assets/_messageId-Rm-pv9Lj.js +0 -1
- package/assets/_outboxMessageId-DZ9oEoGq.js +0 -1
- package/assets/_recurrenceId-lKshLGFv.js +0 -1
- package/assets/_threadId-Cn4_VbTC.js +0 -1
- package/assets/_threadId-CtlfYdJq.js +0 -1
- package/assets/_threadId-DQSQ3t5D.js +0 -1
- package/assets/_view._date-CxLoYpLy.js +0 -1
- package/assets/accounts-BOzP33IK.js +0 -1
- package/assets/advanced-DH74AtyY.js +0 -4
- package/assets/brief-CCQtHA98.js +0 -1
- package/assets/browser-ponyfill-DJ9g5dlz.js +0 -2
- package/assets/calendar-CGSjs-MW.js +0 -1
- package/assets/chevron-left-DV5pp97l.js +0 -1
- package/assets/compose._-_outboxMessageId_-80p_LIdF.js +0 -1
- package/assets/compose._-_outboxMessageId_-CGCC4WR7.js +0 -1
- package/assets/compose._-_outboxMessageId_-DAF6UnCQ.js +0 -1
- package/assets/compose._-_outboxMessageId_-PPnxrxD_.js +0 -1
- package/assets/filters-C2ETBIda.js +0 -1
- package/assets/flagged-CXk9IuTv.js +0 -1
- package/assets/folders-CZZ0A6LY.js +0 -1
- package/assets/index-8Jk9sv8H.js +0 -1
- package/assets/index-96unnwX9.js +0 -1
- package/assets/index-BsV3aJW4.js +0 -1
- package/assets/index-C3Ii4qBr.js +0 -1
- package/assets/index-CPfQZ4De.js +0 -1
- package/assets/index-CnGqfQe0.js +0 -1
- package/assets/index-Dtovse-L.js +0 -294
- package/assets/index-Fjp1XhHg.js +0 -1
- package/assets/index-VbZ_wTmr.js +0 -1
- package/assets/index-vGdOUxLx.js +0 -1
- package/assets/mail-kBNM6qac.js +0 -1
- package/assets/minus-BUHU6kmL.js +0 -1
- package/assets/onboarding-DanUIq9r.js +0 -1
- package/assets/outbox-DuDPZsm-.js +0 -1
- package/assets/pane-header-BTNHnxOW.js +0 -1
- package/assets/search-query-Cr_ZXBCp.js +0 -1
- package/assets/search-scope-B5-OK3Cq.js +0 -1
- package/assets/senders-C2MCK2u2.js +0 -1
- package/assets/settings-_XfaP7nx.js +0 -1
- package/assets/suggested-vips-DZJBdJAU.js +0 -1
- package/assets/useCalendarFreeBusy-BgHa55K-.js +0 -1
- package/assets/useFilters-R3V1TB7X.js +0 -1
- package/assets/useLayoutTier-BT9E1-ej.js +0 -1
- package/assets/useMessageBodyContent-DIF3dieb.js +0 -1
- package/assets/useRefreshControl-DfkVEG2l.js +0 -1
- package/assets/useSemanticSearch-BQ_df8hM.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as r,r as I,t as Ve,ap as Ce,f as se,_ as zs,X as De,aq as $s,ar as Bs,as as pt,v as qs,w as Ws,at as te,h as Qe,au as Gs,c as os,d as ls,av as Ks,i as pe,aw as Qs,o as we,l as ht,ax as Ys,ay as Zs,az as Js,aA as ve,aB as Pt,L as it,aC as Ct,aD as Xs,aE as Ie,aF as je,aG as Vt,aH as at,B as nt,aI as er,aJ as tr,aK as Dt,n as cs,ac as sr,aL as rr,aM as ir,aN as ds,aO as Ft,u as ar,aP as nr,aQ as or,g as lr,aR as Ot,aS as cr,a4 as dr,aT as ur}from"./index-BDIVfNXM.js";import{A as ot,g as Rt,P as fr,O as mr}from"./OnboardingWizard-DC3VOl45.js";import{f as It,E as pr}from"./ErrorState-BVvZa9Hj.js";import{R as hr}from"./row-actions-BtiK9OA9.js";import{S as gr,A as yr}from"./settings-screen-B51b9lvj.js";import{s as $e,b as us,R as fs,u as xr}from"./credential-steps-CKcZdVNd.js";import{u as vr}from"./useSignature-V-VSVmYl.js";import{c as br,a as Mt,d as Sr}from"./account-form-helpers-DhckT_PN.js";import{C as jr}from"./confirm-dialog-BmiOsB9N.js";import{D as wr}from"./download-53lT8mTP.js";import{a as Nr}from"./help-copy-CADUhLzQ.js";import"./checkbox-p9mLPjVs.js";import"./minus-kSr1dVnA.js";import"./kbd-BTTdW6-z.js";import"./mail-bV9GGVUQ.js";import"./file-json-ofsJkIbX.js";import"./avatar-BEy9bmfT.js";import"./chevron-left-iD9K0p2O.js";import"./menu-DQ-pJ4eT.js";import"./circle-help-C0X0r4BQ.js";import"./card-BKgdv2bH.js";const Ar={Mail:"Mail already in Remit stays, and you can keep reading it.",Calendar:"Events already in Remit stay on your calendar."},Tr={Mail:"New mail stops arriving until you turn it back on.",Calendar:"Changes stop arriving until you turn it back on."},Er={Mail:"mail",Calendar:"calendar"};function kr(e,s){const t=Er[e.service];return e.kind==="enable"?{title:`Sign in with ${s} to add ${t}?`,description:`This account was never asked for ${t} access. Remit sends you to ${s} to ask for it, and brings you back here when you are done. Nothing changes until you get back.`,confirmLabel:`Continue to ${s}`,cancelLabel:"Cancel",destructive:!1}:e.kind==="last"?{title:`${e.service} is the only thing this account syncs`,description:`An account has to sync something. To stop this one entirely, remove the account — that deletes what Remit stored for it, which switching ${t} off never does.`,confirmLabel:"Remove account",cancelLabel:`Keep syncing ${t}`,destructive:!0}:{title:`Stop syncing ${t} for this account?`,description:`${Ar[e.service]} ${Tr[e.service]} Nothing is deleted.`,confirmLabel:`Stop syncing ${t}`,cancelLabel:"Cancel",destructive:!1}}function _r({change:e,providerName:s,onConfirm:t,onCancel:a,isBusy:n}){if(e===null)return null;const l=kr(e,s);return r.jsx(jr,{isOpen:!0,title:l.title,description:l.description,confirmLabel:l.confirmLabel,cancelLabel:l.cancelLabel,destructive:l.destructive,isBusy:n??!1,onConfirm:t,onCancel:a})}function Pr({checked:e,label:s,describedBy:t,disabled:a,onToggle:n}){return r.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":s,"aria-describedby":t,disabled:a,onClick:n,className:Ve("relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors","outline-none disabled:cursor-not-allowed disabled:opacity-60 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-surface",e?"border-positive bg-positive":"border-line-strong bg-surface-sunken"),children:r.jsx("span",{"aria-hidden":!0,className:Ve("size-4 rounded-full bg-canvas transition-transform",e?"translate-x-6":"translate-x-1")})})}function Cr({providerName:e,offered:s,enabled:t,consented:a,disabled:n=!1,onRequestChange:l}){const o=I.useId(),u=ot.filter(g=>s.includes(g.id));return u.length<2?null:r.jsxs("fieldset",{children:[r.jsx("legend",{className:"text-sm font-semibold text-fg",children:"What this account syncs"}),r.jsx("div",{className:"mt-1 divide-y divide-line",children:u.map(g=>{const S=t.includes(g.id),N=`${o}-${g.id}`,P=!S&&!a.includes(g.id);return r.jsxs("div",{className:"flex min-h-11 items-center gap-3 py-2 text-left",children:[r.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[r.jsx("span",{className:"text-sm text-fg",children:g.label}),r.jsx("span",{id:N,className:"text-xs text-fg-subtle",children:P?`${g.description} Turning this on means signing in with ${e} again.`:g.description})]}),r.jsx(Pr,{checked:S,label:`Sync ${g.label.toLowerCase()}`,describedBy:N,disabled:n,onToggle:()=>l(g.id,S?"off":"on")})]},g.id)})})]})}const Vr=e=>{const s=new Set(e.map($s));return Bs.map(t=>t.tag).filter(t=>!s.has(t)).sort((t,a)=>Ce(t).localeCompare(Ce(a)))},Dr=({value:e,onChange:s,busy:t=!1})=>{const a=Vr(e);return r.jsxs("div",{className:"space-y-2","data-testid":"compose-language-setting",children:[r.jsx("ul",{className:"space-y-1",children:e.map((n,l)=>r.jsxs("li",{"data-testid":`compose-language-row-${n}`,className:"flex items-center gap-2 rounded-md border border-line bg-surface-sunken px-3 py-1.5",children:[r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-fg",lang:n,children:Ce(n)}),l===0?r.jsx("span",{className:"shrink-0 text-2xs uppercase tracking-wider text-fg-subtle",children:"Default"}):r.jsx(se,{variant:"ghost",size:"sm",icon:r.jsx(zs,{className:"size-3.5"}),disabled:t,"aria-label":`Write new messages in ${Ce(n)} by default`,onClick:()=>s([n,...e.filter(o=>o!==n)]),children:"Default"}),r.jsx(se,{variant:"ghost",size:"sm",icon:r.jsx(De,{className:"size-3.5"}),disabled:t||e.length===1,"aria-label":`Remove ${Ce(n)}`,onClick:()=>s(e.filter(o=>o!==n))})]},n))}),r.jsxs("select",{"aria-label":"Add a language",value:"",disabled:t||a.length===0,onChange:n=>{n.target.value!==""&&s([...e,n.target.value])},className:"w-full rounded-md border border-line bg-surface-sunken px-3 py-2 text-sm text-fg outline-none transition-colors focus-within:border-line-strong focus-within:ring-2 focus-within:ring-ring/30",children:[r.jsx("option",{value:"",children:"Add a language…"}),a.map(n=>r.jsx("option",{value:n,children:Ce(n)},n))]}),r.jsx("p",{className:"text-xs text-fg-muted",children:"A message is tagged with the language you write it in, picked from this list. Your browser, not this app, decides which dictionaries it spellchecks against — add the language there too to get its underlines."})]})};function Fr({title:e,description:s,action:t}){return r.jsxs("div",{className:"rounded-sm border border-danger/50",children:[r.jsxs("div",{className:"flex items-center gap-2 border-b border-danger/30 bg-danger-soft px-row-inset py-2",children:[r.jsx(pt,{className:"size-4 text-danger"}),r.jsx("h2",{className:"text-sm font-semibold text-danger",children:"Danger zone"})]}),r.jsxs("div",{className:"flex flex-col gap-3 px-row-inset py-3 sm:flex-row sm:items-center sm:justify-between sm:gap-4",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"text-sm font-medium text-fg",children:e}),r.jsx("p",{className:"text-xs text-fg-muted",children:s})]}),r.jsx("div",{className:"shrink-0",children:t})]})]})}function Lt({isOpen:e,onClose:s,title:t,children:a,footer:n}){qs({id:"slide-panel",open:e,answers:{back:s}});const l=I.useRef(null);return Ws(l,e),r.jsxs(r.Fragment,{children:[r.jsx("div",{className:Ve("fixed inset-0 z-40 bg-black/30 transition-opacity",e?"opacity-100":"pointer-events-none opacity-0"),onClick:s,"aria-hidden":"true"}),r.jsxs("div",{ref:l,className:Ve("safe-area-frame fixed top-0 right-0 z-50 flex h-full w-full flex-col border-l border-line bg-canvas shadow-xl sm:w-[400px] sm:max-w-[90vw]","transform transition-transform duration-200 ease-out",e?"translate-x-0":"pointer-events-none translate-x-full"),role:"dialog","aria-modal":"true","aria-hidden":!e,inert:!e,"aria-labelledby":"slide-panel-title",tabIndex:-1,children:[r.jsxs("div",{className:"flex h-14 shrink-0 items-center justify-between border-b border-line px-4",children:[r.jsx("h2",{id:"slide-panel-title",className:"font-semibold",children:t}),r.jsx("button",{type:"button",onClick:s,className:"rounded-md p-1.5 transition-colors hover:bg-surface-raised","aria-label":"Close",children:r.jsx(De,{className:"size-5"})})]}),r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[r.jsx("div",{className:"flex-1 overflow-auto p-4",children:a}),n&&r.jsx("div",{className:"flex justify-end gap-3 border-t border-line bg-canvas p-4",children:n})]})]})]})}var Ue=e=>e.type==="checkbox",Ne=e=>e instanceof Date,Y=e=>e==null;const gt=e=>typeof e=="object";var z=e=>!Y(e)&&!Array.isArray(e)&>(e)&&!Ne(e),Or=e=>z(e)&&e.target?Ue(e.target)?e.target.checked:e.target.value:e,Rr=(e,s)=>s.split(".").some((t,a,n)=>!isNaN(Number(t))&&e.has(n.slice(0,a).join("."))),ms=e=>{const s=e.constructor&&e.constructor.prototype;return z(s)&&s.hasOwnProperty("isPrototypeOf")},Ye=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function B(e){if(e instanceof Date)return new Date(e);const s=typeof FileList<"u"&&e instanceof FileList;if(Ye&&(e instanceof Blob||s))return e;const t=Array.isArray(e);if(!t&&!(z(e)&&ms(e)))return e;const a=t?[]:Object.create(Object.getPrototypeOf(e));for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(a[n]=B(e[n]));return a}const _e={BLUR:"blur",FOCUS_OUT:"focusout",SUBMIT:"submit",TRIGGER:"trigger",VALID:"valid"},ue={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},de={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},ps="root",yt=["__proto__","constructor","prototype"],Ir=/^\w*$/;var He=e=>Ir.test(e),L=e=>e===void 0;const Mr=/[.[\]'"]/;var Ze=e=>e.split(Mr).filter(Boolean),v=(e,s,t)=>{if(!s||!z(e))return t;const a=He(s)?[s]:Ze(s);if(a.some(l=>yt.includes(l)))return t;const n=a.reduce((l,o)=>Y(l)?void 0:l[o],e);return L(n)||n===e?L(e[s])?t:e[s]:n},fe=e=>typeof e=="boolean",le=e=>typeof e=="function",M=(e,s,t)=>{let a=-1;const n=He(s)?[s]:Ze(s),l=n.length,o=l-1;for(;++a<l;){const u=n[a];let g=t;if(a!==o){const S=e[u];g=z(S)||Array.isArray(S)?S:isNaN(+n[a+1])?{}:[]}if(yt.includes(u))return;e[u]=g,e=e[u]}};const Lr=te.createContext(null);Lr.displayName="HookFormControlContext";var Ur=(e,s,t,a=!0)=>{const n={};for(const l in e)Object.defineProperty(n,l,{get:()=>{const o=l;return s._proxyFormState[o]!==ue.all&&(s._proxyFormState[o]=!a||ue.all),e[o]}});return n};const Hr=Ye?te.useLayoutEffect:te.useEffect;var Z=e=>typeof e=="string",zr=(e,s,t,a,n)=>Z(e)?(a&&s.watch.add(e),v(t,e,n)):Array.isArray(e)?e.map(l=>(a&&s.watch.add(l),v(t,l))):(a&&(s.watchAll=!0),t),lt=e=>Y(e)||!gt(e);const Ut=(e,s)=>s.length===0&&!Array.isArray(e)&&!ms(e);function me(e,s,t=new WeakMap){if(e===s)return!0;if(lt(e)||lt(s))return Object.is(e,s);if(Ne(e)&&Ne(s))return Object.is(e.getTime(),s.getTime());const a=Object.keys(e),n=Object.keys(s);if(a.length!==n.length)return!1;if(Ut(e,a)||Ut(s,n))return Object.is(e,s);if(!a.length&&Array.isArray(e)!==Array.isArray(s))return!1;const l=t.get(e);if(l&&l.has(s))return!0;if(l)l.add(s);else{const o=new WeakSet;o.add(s),t.set(e,o)}for(const o of a){const u=e[o];if(!(o in s))return!1;if(o!=="ref"){const g=s[o];if(Ne(u)&&Ne(g)||(z(u)||Array.isArray(u))&&(z(g)||Array.isArray(g))?!me(u,g,t):!Object.is(u,g))return!1}}return!0}var Be=e=>({isOnSubmit:!e||e===ue.onSubmit,isOnBlur:e===ue.onBlur,isOnChange:e===ue.onChange,isOnAll:e===ue.all,isOnTouch:e===ue.onTouched}),tt=(e,s,t)=>{if(t)return!1;if(s.watchAll||s.watch.has(e))return!0;for(const a of s.watch)if(e.startsWith(a)&&e.charAt(a.length)===".")return!0;return!1};const Le=(e,s,t,a)=>{for(const n of t||Object.keys(e)){const l=v(e,n);if(l){const{_f:o,...u}=l;if(o){if(o.refs&&o.refs[0]&&s(o.refs[0],n)&&!a)return!0;if(o.ref&&s(o.ref,o.name)&&!a)return!0;if(Le(u,s))break}else if(z(u)&&Le(u,s))break}}};var Ht=(e,s,t)=>{const a=v(e,t),n=Array.isArray(a)?a:[];return M(n,ps,s[t]),M(e,t,n),e},Q=e=>z(e)&&!Object.keys(e).length,xt=e=>e.type==="file",Ge=e=>{if(!Ye)return!1;const s=e?e.ownerDocument:0;return e instanceof(s&&s.defaultView?s.defaultView.HTMLElement:HTMLElement)},vt=e=>e.type==="radio",Ke=e=>e instanceof RegExp,bt=(e,s,t,a,n)=>s?{...t[e],types:{...t[e]&&t[e].types?t[e].types:{},[a]:n||!0}}:{};const zt={value:!1,isValid:!1},$t={value:!0,isValid:!0};var hs=e=>{if(Array.isArray(e)){if(e.length>1){const s=e.filter(t=>t&&t.checked&&!t.disabled).map(t=>t.value);return{value:s,isValid:!!s.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!L(e[0].attributes.value)?L(e[0].value)||e[0].value===""?$t:{value:e[0].value,isValid:!0}:$t:zt}return zt};const Bt={isValid:!1,value:null};var gs=e=>Array.isArray(e)?e.reduce((s,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:s,Bt):Bt;function qt(e,s,t="validate"){if(Z(e)||Array.isArray(e)&&e.every(Z)||fe(e)&&!e)return{type:t,message:Z(e)?e:"",ref:s}}var Pe=e=>z(e)&&!Ke(e)?e:{value:e,message:""},Wt=async(e,s,t,a,n,l)=>{const{ref:o,refs:u,required:g,maxLength:S,minLength:N,min:P,max:H,pattern:h,validate:j,name:E,valueAsNumber:T,mount:oe}=e._f,C=v(t,E);if(!oe||s.has(E))return{};const V=u?u[0]:o,_=F=>{if(n&&V.reportValidity){const D=fe(F)?"":F||"";u?u.forEach(O=>O.setCustomValidity(D)):V.setCustomValidity(D),V.reportValidity()}},k={},J=vt(o),W=Ue(o),ae=J||W,re=(T||xt(o))&&L(o.value)&&L(C)||Ge(o)&&o.value===""||C===""||Array.isArray(C)&&!C.length,ce=bt.bind(null,E,a,k),he=(F,D,O,$=de.maxLength,K=de.minLength)=>{const G=F?D:O;k[E]={type:F?$:K,message:G,ref:o,...ce(F?$:K,G)}};if(l?!Array.isArray(C)||!C.length:g&&(!ae&&(re||Y(C))||fe(C)&&!C||W&&!hs(u).isValid||J&&!gs(u).isValid)){const{value:F,message:D}=Z(g)?{value:!!g,message:g}:Pe(g);if(F&&(k[E]={type:de.required,message:D,ref:V,...ce(de.required,D)},!a))return _(D),k}if(!re&&(!Y(P)||!Y(H))){let F,D;const O=Pe(H),$=Pe(P);if(!Y(C)&&!isNaN(C)){const K=o.valueAsNumber||C&&+C;Y(O.value)||(F=K>O.value),Y($.value)||(D=K<$.value)}else{const K=o.valueAsDate||new Date(C),G=ie=>new Date(new Date().toDateString()+" "+ie),be=o.type=="time",w=o.type=="week";Z(O.value)&&C&&(F=be?G(C)>G(O.value):w?C>O.value:K>new Date(O.value)),Z($.value)&&C&&(D=be?G(C)<G($.value):w?C<$.value:K<new Date($.value))}if((F||D)&&(he(!!F,O.message,$.message,de.max,de.min),!a))return _(k[E].message),k}if((S||N)&&!re&&(Z(C)||l&&Array.isArray(C))){const F=Pe(S),D=Pe(N),O=!Y(F.value)&&C.length>+F.value,$=!Y(D.value)&&C.length<+D.value;if((O||$)&&(he(O,F.message,D.message),!a))return _(k[E].message),k}if(h&&!re&&Z(C)){const{value:F,message:D}=Pe(h);if(Ke(F)&&!C.match(F)&&(k[E]={type:de.pattern,message:D,ref:o,...ce(de.pattern,D)},!a))return _(D),k}if(j){if(le(j)){const F=await j(C,t),D=qt(F,V);if(D&&(k[E]={...D,...ce(de.validate,D.message)},!a))return _(D.message),k}else if(z(j)){let F={};for(const D in j){if(!Q(F)&&!a)break;const O=qt(await j[D](C,t),V,D);O&&(F={...O,...ce(D,O.message)},_(O.message),a&&(k[E]=F))}if(!Q(F)&&(k[E]={ref:V,...F},!a))return k}}return _(!0),k},We=e=>Array.isArray(e)?e:[e],ys=e=>Array.isArray(e)?e.filter(Boolean):[];function $r(e,s){const t=s.slice(0,-1).length;let a=0;for(;a<t;){if(Y(e)){e=void 0;break}e=e[s[a]],a++}return e}function Br(e){for(const s in e)if(e.hasOwnProperty(s)&&!L(e[s]))return!1;return!0}function q(e,s){if(Z(s)&&Object.prototype.hasOwnProperty.call(e,s))return delete e[s],e;const t=Array.isArray(s)?s:He(s)?[s]:Ze(s);if(t.some(o=>yt.includes(String(o))))return e;const a=t.length===1?e:$r(e,t),n=t.length-1,l=t[n];return a&&delete a[l],n!==0&&(z(a)&&Q(a)||Array.isArray(a)&&Br(a))&&q(e,t.slice(0,-1)),e}const xs=e=>{const s={};for(const t of Object.keys(e))if(gt(e[t])&&e[t]!==null&&!Ne(e[t])){const a=xs(e[t]);for(const n of Object.keys(a))s[`${t}.${n}`]=a[n]}else s[t]=e[t];return s},qr=te.createContext(null);qr.displayName="HookFormContext";var Gt=()=>{let e=[];return{get observers(){return e},next:n=>{for(const l of e)l.next&&l.next(n)},subscribe:n=>(e.push(n),{unsubscribe:()=>{e=e.filter(l=>l!==n)}}),unsubscribe:()=>{e=[]}}};function vs(e,s){const t={};for(const a in e)if(e.hasOwnProperty(a)){const n=e[a],l=s[a];if(n&&z(n)&&l){const o=vs(n,l);z(o)&&(t[a]=o)}else e[a]&&(t[a]=l)}return t}var bs=e=>e.type==="select-multiple",Wr=e=>vt(e)||Ue(e),st=e=>Ge(e)&&e.isConnected,Gr=e=>{for(const s in e)if(le(e[s]))return!0;return!1};function Ss(e){return Array.isArray(e)||z(e)&&!Gr(e)}function js(e){return!!(e&&"_f"in e)}function ws(e){return Array.isArray(e)?!e.some(s=>!L(s)):!Object.keys(e).length}function ct(e,s){Array.isArray(e)?e[s]=void 0:delete e[s]}function dt(e,s={},t){for(const a in e){const n=e[a],l=t&&t[a];Ss(n)&&(!Array.isArray(n)||!js(l))?(s[a]=Array.isArray(n)?[]:{},dt(n,s[a],l),ws(s[a])&&ct(s,a)):L(n)||(s[a]=!0)}return s}function Te(e,s,t,a){t||(t=dt(s,{},a));for(const n in e){const l=e[n],o=a&&a[n];Ss(l)&&(!Array.isArray(l)||!js(o))?(L(s)||lt(t[n])?t[n]=dt(l,Array.isArray(l)?[]:{},o):Te(l,Y(s)?{}:s[n],t[n],o),ws(t[n])&&ct(t,n)):me(l,s[n])?ct(t,n):t[n]=!0}return t}var Ns=(e,{valueAsNumber:s,valueAsDate:t,setValueAs:a})=>L(e)?e:s?e===""?NaN:e&&+e:t&&Z(e)?new Date(e):a?a(e):e;function Kt(e){const s=e.ref;return xt(s)?s.files:vt(s)?gs(e.refs).value:bs(s)?[...s.selectedOptions].map(({value:t})=>t):Ue(s)?hs(e.refs).value:Ns(L(s.value)?e.ref.value:s.value,e)}var Kr=(e,s,t,a)=>{const n={};for(const l of e){const o=v(s,l);o&&M(n,l,o._f)}return{criteriaMode:t,names:[...e],fields:n,shouldUseNativeValidation:a}},Me=e=>L(e)?e:Ke(e)?e.source:z(e)?Ke(e.value)?e.value.source:e.value:e;const Qt="AsyncFunction";var Qr=e=>{if(!e||!e.validate)return!1;if(le(e.validate))return e.validate.constructor.name===Qt;if(z(e.validate)){for(const s in e.validate)if(e.validate[s].constructor.name===Qt)return!0}return!1},Yr=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function Yt(e,s,t){const a=v(e,t);if(a||He(t))return{error:a,name:t};const n=t.split(".");for(;n.length;){const l=n.join("."),o=v(s,l),u=v(e,l);if(o&&!Array.isArray(o)&&t!==l)return{name:t};if(u&&u.type)return{name:l,error:u};if(u&&u.root&&u.root.type)return{name:`${l}.root`,error:u.root};n.pop()}return{name:t}}var Zr=(e,s,t,a)=>{t(e);const{name:n,...l}=e,o=Object.keys(l);return!o.length||a&&o.length>=Object.keys(s).length||o.find(u=>s[u]===(!a||ue.all))},Jr=(e,s,t)=>!e||!s||e===s||We(e).some(a=>a&&(t?a===s||a.startsWith(s+"."):a.startsWith(s)||s.startsWith(a))),Xr=(e,s,t,a,n)=>n.isOnAll?!1:!t&&n.isOnTouch?!(s||e):(t?a.isOnBlur:n.isOnBlur)?!e:(t?a.isOnChange:n.isOnChange)?e:!0,ei=(e,s)=>!ys(v(e,s)).length&&q(e,s);const ti={mode:ue.onSubmit,reValidateMode:ue.onChange,shouldFocusError:!0},rt="form",As={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function si(e={}){let s={...ti,...e},t={...B(As),isLoading:le(s.defaultValues),errors:s.errors||{},disabled:s.disabled||!1},a={},n=z(s.defaultValues)||z(s.values)?B(s.defaultValues||s.values)||{}:{},l=s.shouldUnregister?{}:B(n),o={action:!1,mount:!1,watch:!1,keepIsValid:!1},u={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set,registerName:new Set};const g={},S={};let N=0,P=Be(s.mode),H=Be(s.reValidateMode);const h={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},j={...h};let E={...j};const T={array:Gt(),state:Gt()};let oe=0;const C=s.criteriaMode===ue.all,V=(i,c)=>d=>{clearTimeout(S[i]),S[i]=setTimeout(c,d)},_=async i=>{if(!o.keepIsValid&&!s.disabled&&(j.isValid||E.isValid||i)){const c=++oe;let d;s.resolver?(d=Q((await O()).errors),c===oe&&k()):d=await G({fields:a,onlyCheckValid:!0,eventType:_e.VALID}),c===oe&&d!==t.isValid&&T.state.next({isValid:d})}},k=(i,c)=>{!s.disabled&&(j.isValidating||j.validatingFields||E.isValidating||E.validatingFields)&&((i||Array.from(u.mount)).forEach(d=>{d&&(c?M(t.validatingFields,d,c):q(t.validatingFields,d))}),T.state.next({validatingFields:t.validatingFields,isValidating:!Q(t.validatingFields)}))},J=()=>{t.dirtyFields=Te(n,l,void 0,a)},W=(i,c=[],d,f,m=!0,x=!0)=>{if(f&&d&&!s.disabled){if(o.action=!0,x&&Array.isArray(v(a,i))){const y=d(v(a,i),f.argA,f.argB);m&&M(a,i,y)}if(x&&Array.isArray(v(t.errors,i))){const y=d(v(t.errors,i),f.argA,f.argB);m&&M(t.errors,i,y),ei(t.errors,i)}if((j.touchedFields||E.touchedFields)&&x&&Array.isArray(v(t.touchedFields,i))){const y=d(v(t.touchedFields,i),f.argA,f.argB);m&&M(t.touchedFields,i,y)}(j.dirtyFields||E.dirtyFields)&&J(),T.state.next({name:i,isDirty:w(i,c),dirtyFields:t.dirtyFields,errors:t.errors,isValid:t.isValid})}else M(l,i,c)},ae=(i,c)=>{M(t.errors,i,c),t.errors={...t.errors},T.state.next({errors:t.errors})},re=i=>{t.errors=i,T.state.next({errors:t.errors,isValid:!1})},ce=i=>{const c=He(i)?[i]:Ze(i);let d=l,f=n;for(let m=0;m<c.length-1;m++){const x=c[m];if(d=Y(d)?d:d[x],f=Y(f)?f:f[x],d===null&&f!==null)return!0}return!1},he=(i,c,d,f)=>{const m=v(a,i);if(m){if(ce(i))return;const x=L(v(l,i)),y=v(l,i,L(d)?v(n,i):d);L(y)||f&&f.defaultChecked||c?M(l,i,c?y:Kt(m._f)):Ae(i,y),o.mount&&!o.action&&(_(),x&&t.isDirty&&(j.isDirty||E.isDirty)&&(w()||(t.isDirty=!1,T.state.next({...t}))),e.shouldUnregister&&x&&!L(v(l,i))&&tt(i,u)&&(o.watch=!0))}},F=(i,c,d,f,m)=>{let x=!1,y=!1;const b={name:i};if(!s.disabled||f===!0){if(!d||f){const A=me(v(n,i),c);(j.isDirty||E.isDirty)&&(y=t.isDirty,t.isDirty=b.isDirty=!A||w(),x=y!==b.isDirty),y=!!v(t.dirtyFields,i),A!==t.isDirty?t.dirtyFields=Te(n,l,void 0,a):A?q(t.dirtyFields,i):M(t.dirtyFields,i,!0),b.dirtyFields=t.dirtyFields,x=x||(j.dirtyFields||E.dirtyFields)&&y!==!A}if(d){const A=v(t.touchedFields,i);A||(M(t.touchedFields,i,d),b.touchedFields=t.touchedFields,x=x||(j.touchedFields||E.touchedFields)&&A!==d)}x&&m&&T.state.next(b)}return x?b:{}},D=(i,c,d,f)=>{const m=v(t.errors,i),x=(j.isValid||E.isValid)&&fe(c)&&t.isValid!==c;if(s.delayError&&d?(g[i]=V(i,()=>ae(i,d)),g[i](s.delayError)):(clearTimeout(S[i]),delete g[i],d?M(t.errors,i,d):q(t.errors,i),t.errors={...t.errors}),(d?!me(m,d):m)||!Q(f)||x){const y={...f,...x&&fe(c)?{isValid:c}:{},errors:t.errors,name:i};t={...t,...y},T.state.next(y)}},O=async i=>(k(i,!0),await s.resolver(l,s.context,Kr(i||u.mount,a,s.criteriaMode,s.shouldUseNativeValidation))),$=async i=>{const{errors:c}=await O(i);if(k(i),i){for(const d of i){const f=v(c,d);f?u.array.has(d)&&z(f)&&!Object.keys(f).some(m=>!Number.isNaN(Number(m)))?Ht(t.errors,{[d]:f},d):M(t.errors,d,f):q(t.errors,d)}t.errors={...t.errors}}else t.errors=c;return c},K=async({name:i,eventType:c})=>{if(e.validate){const d=await e.validate({formValues:l,formState:t,name:i,eventType:c});if(z(d))for(const f in d){const m=d[f];m&&ze(`${rt}.${f}`,{message:Z(m.message)?m.message:"",type:m.type||de.validate})}else Z(d)||!d?ze(rt,{message:d||"",type:de.validate}):jt(rt);return d}return!0},G=async({fields:i,onlyCheckValid:c,name:d,eventType:f,context:m={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(m.runRootValidation=!0,!await K({name:d,eventType:f})&&(m.valid=!1,c)))return m.valid;for(const x in i){const y=i[x];if(y){const{_f:b,...A}=y;if(b){const U=u.array.has(b.name),ee=y._f&&Qr(y._f),ye=j.validatingFields||j.isValidating||E.validatingFields||E.isValidating;ee&&ye&&k([b.name],!0);const xe=await Wt(y,u.disabled,l,C,s.shouldUseNativeValidation&&!c,U);if(ee&&ye&&k([b.name]),xe[b.name]&&(m.valid=!1,c)||(!c&&(v(xe,b.name)?U?Ht(t.errors,xe,b.name):M(t.errors,b.name,xe[b.name]):q(t.errors,b.name)),e.shouldUseNativeValidation&&xe[b.name]))break}!Q(A)&&await G({context:m,onlyCheckValid:c,fields:A,name:x,eventType:f})}}return m.valid},be=()=>{for(const i of u.unMount){const c=v(a,i);c&&(c._f.refs?c._f.refs.every(d=>!st(d)):!st(c._f.ref))&&Je(i)}u.unMount=new Set},w=(i,c)=>(i&&c&&M(l,i,c),!me(o.mount?l:n,n)),ie=(i,c,d)=>zr(i,u,{...o.mount?l:L(c)?n:Z(i)?{[i]:c}:c},d,c),Ee=i=>ys(v(o.mount?l:n,i,s.shouldUnregister?v(n,i,[]):[])),Ae=(i,c,d={},f=!1,m=!1)=>{const x=v(a,i);let y=c;if(x){const b=x._f;b&&(!b.disabled&&M(l,i,Ns(c,b)),y=Ge(b.ref)&&Y(c)?"":c,bs(b.ref)?[...b.ref.options].forEach(A=>A.selected=y.includes(A.value)):b.refs?Ue(b.ref)?b.refs.forEach(A=>{(!A.defaultChecked||!A.disabled)&&(Array.isArray(y)?A.checked=!!y.find(U=>U===A.value):A.checked=y===A.value||!!y)}):b.refs.forEach(A=>A.checked=A.value===y):xt(b.ref)?b.ref.value="":(b.ref.value=y,!b.ref.type&&!m&&T.state.next({name:i,values:f?l:B(l)})))}(d.shouldDirty||d.shouldTouch)&&F(i,y,d.shouldTouch,d.shouldDirty,!m),d.shouldValidate&&ke(i,{delayError:d.delayError})},p=(i,c,d,f=!1,m=!1)=>{for(const x in c){if(!c.hasOwnProperty(x))return;const y=c[x],b=i+"."+x,A=v(a,b);(u.array.has(i)||z(y)||A&&!A._f)&&!Ne(y)?p(b,y,d,f,m):Ae(b,y,d,f,m)}},R=(i,c,d,f,m=!1)=>{const x=v(a,i),y=u.array.has(i),b=f?c:B(c),A=v(l,i),U=me(A,b);if(U||M(l,i,b),y)T.array.next({name:i,values:f?l:B(l)}),(j.isDirty||j.dirtyFields||E.isDirty||E.dirtyFields)&&d.shouldDirty&&(J(),m||T.state.next({name:i,dirtyFields:t.dirtyFields,isDirty:w(i,b)}));else{const ee=Array.isArray(b)&&!b.length||Q(b);!x||x._f||Y(b)||ee?Ae(i,b,d,f,m):p(i,b,d,f,m)}if(!U&&!m){const ee=tt(i,u),ye=f?l:B(l);T.state.next({...ee&&t,name:o.mount||ee?i:void 0,values:ye})}},X=(i,c,d={})=>R(i,c,d,!1),ne=(i,c={})=>{const d=le(i)?i(l):i;if(!me(l,d)){l={...l,...d};const f=xs(d);for(const m of u.mount)m in f&&R(m,f[m],c,!0,!0);T.state.next({...t,name:void 0,type:void 0,...N?{values:l}:{}}),c.shouldValidate&&_()}},ge=async i=>{o.mount=!0;const c=i.target;let d=c.name,f=!0;const m=v(a,d),x=y=>{f=Number.isNaN(y)||Ne(y)&&isNaN(y.getTime())||me(y,v(l,d,y))};if(m){let y,b;const A=c.type?Kt(m._f):Or(i),U=i.type===_e.BLUR||i.type===_e.FOCUS_OUT,ee=!Yr(m._f)&&!e.validate&&!s.resolver&&!v(t.errors,d)&&!m._f.deps,ye=ee||Xr(U,v(t.touchedFields,d),t.isSubmitted,H,P),xe=tt(d,u,U);if(M(l,d,A),U){if(!c||!c.readOnly){m._f.onBlur&&m._f.onBlur(i);const Re=g[d];Re&&Re(0)}}else m._f.onChange&&m._f.onChange(i);const Oe=F(d,A,U),Us=!Q(Oe)||xe;if(!U&&T.state.next({name:d,type:i.type,...N?{values:B(l)}:{}}),ye)return(!ee||!t.isValid)&&(j.isValid||E.isValid)&&(s.mode==="onBlur"?U&&_():U||_()),Us&&T.state.next({name:d,...xe?{}:Oe});if(!s.resolver&&e.validate&&await K({name:d,eventType:i.type}),!U&&xe&&T.state.next({...t}),s.resolver){const{errors:Re}=await O([d]);if(k([d]),x(A),!f){!Q(Oe)&&T.state.next(Oe);return}const Hs=Yt(t.errors,a,d),_t=Yt(Re,a,Hs.name||d);y=_t.error,d=_t.name,b=Q(Re)}else k([d],!0),y=(await Wt(m,u.disabled,l,C,s.shouldUseNativeValidation))[d],k([d]),x(A),f&&(y?b=!1:(j.isValid||E.isValid)&&(b=await G({fields:a,onlyCheckValid:!0,name:d,eventType:i.type})));f&&(m._f.deps&&(!Array.isArray(m._f.deps)||m._f.deps.length>0)&&ke(m._f.deps),D(d,b,y,Oe))}},Se=(i,c)=>{if(v(t.errors,c)&&i.focus)return i.focus(),1},ke=async(i,c={})=>{let d,f;const m=We(i);if(s.resolver){const x=await $(L(i)?i:m);d=Q(x),f=i?!m.some(y=>v(x,y)):d}else i?(f=(await Promise.all(m.map(async x=>{const y=v(a,x);return await G({fields:y&&y._f?{[x]:y}:y,eventType:_e.TRIGGER})}))).every(Boolean),!(!f&&!t.isValid)&&_()):f=d=await G({fields:a,name:i,eventType:_e.TRIGGER});if(c.delayError&&s.delayError&&Z(i)){const x=v(t.errors,i);x?(q(t.errors,i),g[i]=V(i,()=>ae(i,x)),g[i](s.delayError)):(clearTimeout(S[i]),delete g[i])}return T.state.next({...!Z(i)||(j.isValid||E.isValid)&&d!==t.isValid?{}:{name:i},...s.resolver||!i?{isValid:d}:{},errors:t.errors}),c.shouldFocus&&!f&&Le(a,Se,i?m:u.mount),f},Fe=(i,c)=>{let d={...o.mount?l:n};return c&&(d=vs(c.dirtyFields?t.dirtyFields:t.touchedFields,d)),L(i)?d:Z(i)?v(d,i):i.map(f=>v(d,f))},St=(i,c)=>({invalid:!!v((c||t).errors,i),isDirty:!!v((c||t).dirtyFields,i),error:v((c||t).errors,i),isValidating:!!v(t.validatingFields,i),isTouched:!!v((c||t).touchedFields,i)}),jt=i=>{const c=i?We(i):void 0;c?.forEach(d=>q(t.errors,d)),c?c.forEach(d=>{T.state.next({name:d,errors:t.errors})}):T.state.next({errors:{}})},ze=(i,c,d)=>{const f=(v(a,i,{_f:{}})._f||{}).ref,m=v(t.errors,i)||{},{ref:x,message:y,type:b,...A}=m;M(t.errors,i,{...A,...c,ref:f}),T.state.next({name:i,errors:t.errors,isValid:!1}),d&&d.shouldFocus&&f&&f.focus&&f.focus()},Fs=(i,c)=>{if(le(i)){N++;const{unsubscribe:d}=T.state.subscribe({next:m=>"values"in m&&i(m.values||ie(void 0,c),m)});let f=!1;return{unsubscribe:()=>{f||(f=!0,N--,d())}}}return ie(i,c,!0)},wt=i=>{var c;const d=!!(!((c=i.formState)===null||c===void 0)&&c.values);d&&N++;const{unsubscribe:f}=T.state.subscribe({next:x=>{if(Jr(i.name,x.name,i.exact)&&Zr(x,i.formState||j,Ls,i.reRenderRoot)){const y={...l};i.callback({values:y,...t,...x,defaultValues:n})}}});if(!d)return f;let m=!1;return()=>{m||(m=!0,N--,f())}},Os=i=>(o.mount=!0,E={...E,...i.formState},wt({...i,formState:{...h,...i.formState}})),Je=(i,c={})=>{for(const d of i?We(i):u.mount)u.mount.delete(d),u.array.delete(d),c.keepValue||(q(a,d),q(l,d)),!c.keepError&&q(t.errors,d),!c.keepDirty&&q(t.dirtyFields,d),!c.keepTouched&&q(t.touchedFields,d),!c.keepIsValidating&&q(t.validatingFields,d),!s.shouldUnregister&&!c.keepDefaultValue&&q(n,d);T.state.next({values:B(l)}),T.state.next({...t,...c.keepDirty?{isDirty:w()}:{}}),!c.keepIsValid&&_()},Nt=({disabled:i,name:c})=>{if(fe(i)&&o.mount||i||u.disabled.has(c)){const m=u.disabled.has(c)!==!!i;i?u.disabled.add(c):u.disabled.delete(c),m&&o.mount&&!o.action&&_()}},Xe=(i,c={})=>{let d=v(a,i);const f=fe(c.disabled)||fe(s.disabled),m=!u.registerName.has(i)&&d&&d._f&&!d._f.mount;return M(a,i,{...d||{},_f:{...d&&d._f?d._f:{ref:{name:i}},name:i,mount:!0,...c}}),u.mount.add(i),d&&!m?Nt({disabled:fe(c.disabled)?c.disabled:s.disabled,name:i}):he(i,!0,c.value),{...f?{disabled:c.disabled||s.disabled}:{},...s.progressive?{required:!!c.required,min:Me(c.min),max:Me(c.max),minLength:Me(c.minLength),maxLength:Me(c.maxLength),pattern:Me(c.pattern)}:{},name:i,onChange:ge,onBlur:ge,ref:x=>{if(x){u.registerName.add(i),Xe(i,c),u.registerName.delete(i),d=v(a,i);const y=L(x.value)&&x.querySelectorAll&&x.querySelectorAll("input,select,textarea")[0]||x,b=Wr(y),A=d._f.refs||[];if(b?A.find(U=>U===y):y===d._f.ref)return;M(a,i,{_f:{...d._f,...b?{refs:[...A.filter(st),y,...Array.isArray(v(n,i))?[{}]:[]],ref:{type:y.type,name:i}}:{ref:y}}}),he(i,!1,void 0,y)}else d=v(a,i,{}),d._f&&(d._f.mount=!1),(s.shouldUnregister||c.shouldUnregister)&&!(Rr(u.array,i)&&o.action)&&u.unMount.add(i)}}},et=()=>s.shouldFocusError&&!s.shouldUseNativeValidation&&Le(a,Se,u.mount),Rs=i=>{fe(i)&&(T.state.next({disabled:i}),Le(a,(c,d)=>{const f=v(a,d);f&&(c.disabled=f._f.disabled||i,Array.isArray(f._f.refs)&&f._f.refs.forEach(m=>{m.disabled=f._f.disabled||i}))},0,!1))},At=(i,c)=>async d=>{let f;d&&(d.preventDefault&&d.preventDefault(),d.persist&&d.persist());let m=B(l);if(T.state.next({isSubmitting:!0}),s.resolver){const{errors:x,values:y}=await O();k(),t.errors=x,m=B(y)}else await G({fields:a,eventType:_e.SUBMIT});if(u.disabled.size)for(const x of u.disabled)q(m,x);if(q(t.errors,ps),Q(t.errors)){T.state.next({errors:{}});try{await i(m,d)}catch(x){f=x}}else c&&await c({...t.errors},d),et(),setTimeout(et);if(T.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Q(t.errors)&&!f,submitCount:t.submitCount+1,errors:t.errors}),f)throw f},Is=(i,c={})=>{v(a,i)&&(L(c.defaultValue)?X(i,B(v(n,i))):(X(i,c.defaultValue),M(n,i,B(c.defaultValue))),c.keepTouched||q(t.touchedFields,i),c.keepDirty||(q(t.dirtyFields,i),t.isDirty=c.defaultValue?w(i,B(v(n,i))):w()),c.keepError||(q(t.errors,i),j.isValid&&_()),T.state.next({...t}))},Tt=(i,c={})=>{const d=i?B(i):n,f=B(d),m=Q(i),x=f,y=a;if(c.keepDefaultValues||(n=d),!c.keepValues){if(c.keepDirtyValues){const b=new Set([...u.mount,...Object.keys(Te(n,l,void 0,y))]);for(const A of Array.from(b)){const U=v(t.dirtyFields,A),ee=v(l,A),ye=v(x,A);U&&!L(ee)?M(x,A,ee):!U&&!L(ye)&&X(A,ye)}}else{if(Ye&&L(i))for(const b of u.mount){const A=v(a,b);if(A&&A._f){const U=Array.isArray(A._f.refs)?A._f.refs[0]:A._f.ref;if(Ge(U)){const ee=U.closest("form");if(ee){ee.reset();break}}}}if(c.keepFieldsRef)for(const b of u.mount)X(b,v(x,b));else a={}}if(s.shouldUnregister){if(l=c.keepDefaultValues?B(n):{},c.keepFieldsRef)for(const b of u.mount)M(l,b,v(x,b))}else l=B(x);T.array.next({values:{...x}}),T.state.next({name:void 0,type:void 0,values:{...x}})}u={mount:c.keepDirtyValues?u.mount:new Set,unMount:new Set,array:new Set,registerName:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!j.isValid||!!c.keepIsValid||!!c.keepDirtyValues||!s.shouldUnregister&&!Q(x),o.watch=!!s.shouldUnregister,o.keepIsValid=!!c.keepIsValid,o.action=!1,c.keepErrors||(t.errors={}),T.state.next({submitCount:c.keepSubmitCount?t.submitCount:0,isDirty:m?!1:c.keepDirty?t.isDirty:c.keepValues?w():!!(c.keepDefaultValues&&!me(i,n)),isSubmitted:c.keepIsSubmitted?t.isSubmitted:!1,dirtyFields:m?{}:c.keepDirtyValues?c.keepDefaultValues&&l?Te(n,l,void 0,y):t.dirtyFields:c.keepDefaultValues&&i?Te(n,i,void 0,y):c.keepDirty?t.dirtyFields:{},touchedFields:c.keepTouched?t.touchedFields:{},errors:c.keepErrors?t.errors:{},isSubmitSuccessful:c.keepIsSubmitSuccessful?t.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:n})},Et=(i,c)=>Tt(le(i)?i(l):i,{...s.resetOptions,...c}),Ms=(i,c={})=>{const d=v(a,i),f=d&&d._f;if(f){const m=f.refs?f.refs[0]:f.ref;m.focus&&setTimeout(()=>{m.focus(),c.shouldSelect&&le(m.select)&&m.select()})}},Ls=i=>{const{name:c,type:d,values:f,...m}=i;t={...t,...m}},kt={control:{register:Xe,unregister:Je,getFieldState:St,handleSubmit:At,setError:ze,_subscribe:wt,_runSchema:O,_updateIsValidating:k,_focusError:et,_getWatch:ie,_getDirty:w,_setValid:_,_setFieldArray:W,_setDisabledField:Nt,_setErrors:re,_getFieldArray:Ee,_reset:Tt,_resetDefaultValues:()=>le(s.defaultValues)&&s.defaultValues().then(i=>{Et(i,s.resetOptions),T.state.next({isLoading:!1})}),_removeUnmounted:be,_disableForm:Rs,_subjects:T,_proxyFormState:j,get _fields(){return a},get _formValues(){return l},get _state(){return o},set _state(i){o=i},get _defaultValues(){return n},get _names(){return u},set _names(i){u=i},get _formState(){return t},get _options(){return s},set _options(i){s={...s,...i},P=Be(s.mode),H=Be(s.reValidateMode)}},subscribe:Os,trigger:ke,register:Xe,handleSubmit:At,watch:Fs,setValue:X,setValues:ne,getValues:Fe,reset:Et,resetField:Is,resetDefaultValues:(i,c={})=>{if(n=B(i),!c.keepDirty){const d=Te(n,l,void 0,a);t.dirtyFields=d,t.isDirty=!Q(d)}c.keepIsValid||_(),T.state.next({...t,defaultValues:n})},clearErrors:jt,unregister:Je,setError:ze,setFocus:Ms,getFieldState:St};return{...kt,formControl:kt}}function ri(e={}){const s=te.useRef(void 0),t=te.useRef(void 0),a=te.useRef(e.formControl),[n,l]=te.useState(()=>({...B(As),isLoading:le(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1,defaultValues:le(e.defaultValues)?void 0:e.defaultValues}));if(!s.current||e.formControl&&a.current!==e.formControl)if(a.current=e.formControl,e.formControl)s.current={...e.formControl,formState:n},e.defaultValues&&!le(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:u,...g}=si(e);s.current={...g,formState:n}}const o=s.current.control;return o._options=e,Hr(()=>{const u=o._subscribe({formState:o._proxyFormState,callback:()=>l({...o._formState,defaultValues:o._defaultValues}),reRenderRoot:!0});return l(g=>({...g,isReady:!0})),o._formState.isReady=!0,u},[o]),te.useEffect(()=>o._disableForm(e.disabled),[o,e.disabled]),te.useEffect(()=>{e.mode&&(o._options.mode=e.mode),e.reValidateMode&&(o._options.reValidateMode=e.reValidateMode)},[o,e.mode,e.reValidateMode]),te.useEffect(()=>{e.errors&&(o._setErrors(e.errors),o._focusError())},[o,e.errors]),te.useEffect(()=>{e.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,e.shouldUnregister]),te.useEffect(()=>{if(o._proxyFormState.isDirty){const u=o._getDirty();u!==n.isDirty&&o._subjects.state.next({isDirty:u})}},[o,n.isDirty]),te.useEffect(()=>{var u;e.values&&!me(e.values,t.current)?(o._reset(e.values,{keepFieldsRef:!0,...o._options.resetOptions}),!((u=o._options.resetOptions)===null||u===void 0)&&u.keepIsValid||o._setValid(),t.current=e.values,l(g=>({...g}))):o._resetDefaultValues()},[o,e.values]),te.useEffect(()=>{o._state.mount||(o._setValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()}),s.current.formState=te.useMemo(()=>Ur(n,o),[o,n]),s.current}const Zt=(e,s,t)=>{if(e&&"reportValidity"in e){const a=v(t,s);e.setCustomValidity(a&&a.message||""),e.reportValidity()}},ut=(e,s)=>{for(const t in s.fields){const a=s.fields[t];a&&a.ref&&"reportValidity"in a.ref?Zt(a.ref,t,e):a&&a.refs&&a.refs.forEach(n=>Zt(n,t,e))}},Jt=(e,s)=>{s.shouldUseNativeValidation&&ut(e,s);const t={};for(const a in e){const n=v(s.fields,a),l=Object.assign(e[a]||{},{ref:n&&n.ref});if(ii(s.names||Object.keys(e),a)){const o=Object.assign({},v(t,a));M(o,"root",l),M(t,a,o)}else M(t,a,l)}return t},ii=(e,s)=>{const t=Xt(s).replace(/[.*+?^${}()|\\]/g,"\\$&");return e.some(a=>Xt(a).match(`^${t}\\.\\d+`))};function Xt(e){return e.replace(/[\[\]]/g,"")}function Ts(e,s,t){function a(u,g){var S;Object.defineProperty(u,"_zod",{value:u._zod??{},enumerable:!1}),(S=u._zod).traits??(S.traits=new Set),u._zod.traits.add(e),s(u,g);for(const N in o.prototype)N in u||Object.defineProperty(u,N,{value:o.prototype[N].bind(u)});u._zod.constr=o,u._zod.def=g}const n=t?.Parent??Object;class l extends n{}Object.defineProperty(l,"name",{value:e});function o(u){var g;const S=t?.Parent?new l:this;a(S,u),(g=S._zod).deferred??(g.deferred=[]);for(const N of S._zod.deferred)N();return S}return Object.defineProperty(o,"init",{value:a}),Object.defineProperty(o,Symbol.hasInstance,{value:u=>t?.Parent&&u instanceof t.Parent?!0:u?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}class ai extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const ni={};function Es(e){return ni}function oi(e,s){return typeof s=="bigint"?s.toString():s}const ks=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function qe(e){return typeof e=="string"?e:e?.message}function _s(e,s,t){const a={...e,path:e.path??[]};if(!e.message){const n=qe(e.inst?._zod.def?.error?.(e))??qe(s?.error?.(e))??qe(t.customError?.(e))??qe(t.localeError?.(e))??"Invalid input";a.message=n}return delete a.inst,delete a.continue,s?.reportInput||delete a.input,a}const Ps=(e,s)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:s,enumerable:!1}),Object.defineProperty(e,"message",{get(){return JSON.stringify(s,oi,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},li=Ts("$ZodError",Ps),Cs=Ts("$ZodError",Ps,{Parent:Error}),ci=e=>(s,t,a,n)=>{const l=a?Object.assign(a,{async:!1}):{async:!1},o=s._zod.run({value:t,issues:[]},l);if(o instanceof Promise)throw new ai;if(o.issues.length){const u=new(n?.Err??e)(o.issues.map(g=>_s(g,l,Es())));throw ks(u,n?.callee),u}return o.value},di=ci(Cs),ui=e=>async(s,t,a,n)=>{const l=a?Object.assign(a,{async:!0}):{async:!0};let o=s._zod.run({value:t,issues:[]},l);if(o instanceof Promise&&(o=await o),o.issues.length){const u=new(n?.Err??e)(o.issues.map(g=>_s(g,l,Es())));throw ks(u,n?.callee),u}return o.value},fi=ui(Cs);function ft(){return ft=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var t=arguments[s];for(var a in t)({}).hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e},ft.apply(null,arguments)}function es(e,s){try{var t=e()}catch(a){return s(a)}return t&&t.then?t.then(void 0,s):t}function mi(e,s){for(var t={};e.length;){var a=e[0],n=a.code,l=a.message,o=a.path.join(".");if(!t[o])if("unionErrors"in a){var u=a.unionErrors[0].errors[0];t[o]={message:u.message,type:u.code}}else t[o]={message:l,type:n};if("unionErrors"in a&&a.unionErrors.forEach(function(N){return N.errors.forEach(function(P){return e.push(P)})}),s){var g=t[o].types,S=g&&g[a.code];t[o]=bt(o,s,t,n,S?[].concat(S,a.message):a.message)}e.shift()}return t}function pi(e,s){for(var t={},a=function(){var n=e[0],l=n.code,o=n.message,u=n.path.join(".");if(!t[u])if(n.code==="invalid_union"&&n.errors.length>0){var g=n.errors[0][0];t[u]={message:g.message,type:g.code}}else t[u]={message:o,type:l};if(n.code==="invalid_union"&&n.errors.forEach(function(P){return P.forEach(function(H){return e.push(ft({},H,{path:[].concat(n.path,H.path)}))})}),s){var S=t[u].types,N=S&&S[n.code];t[u]=bt(u,s,t,l,N?[].concat(N,n.message):n.message)}e.shift()};e.length;)a();return t}function hi(e,s,t){if(t===void 0&&(t={}),(function(a){return"_def"in a&&typeof a._def=="object"&&"typeName"in a._def})(e))return function(a,n,l){try{return Promise.resolve(es(function(){return Promise.resolve(e[t.mode==="sync"?"parse":"parseAsync"](a,s)).then(function(o){return l.shouldUseNativeValidation&&ut({},l),{errors:{},values:t.raw?Object.assign({},a):o}})},function(o){if((function(u){return Array.isArray(u?.issues)})(o))return{values:{},errors:Jt(mi(o.errors,!l.shouldUseNativeValidation&&l.criteriaMode==="all"),l)};throw o}))}catch(o){return Promise.reject(o)}};if((function(a){return"_zod"in a&&typeof a._zod=="object"})(e))return function(a,n,l){try{return Promise.resolve(es(function(){return Promise.resolve((t.mode==="sync"?di:fi)(e,a,s)).then(function(o){return l.shouldUseNativeValidation&&ut({},l),{errors:{},values:t.raw?Object.assign({},a):o}})},function(o){if((function(u){return u instanceof li})(o))return{values:{},errors:Jt(pi(o.issues,!l.shouldUseNativeValidation&&l.criteriaMode==="all"),l)};throw o}))}catch(o){return Promise.reject(o)}};throw new Error("Invalid input: not a Zod schema")}const gi=e=>{const s=Qe(),{pushError:t}=Gs(),{data:a}=os({...ls(),staleTime:1/0}),n=a?.accounts.find(g=>g.accountId===e)?.composeLanguages,l=I.useMemo(()=>n&&n.length>0?[...n]:Ks(navigator.languages),[n]),o=pe({...ht(),onSuccess:()=>{s.invalidateQueries({queryKey:we()})},onError:g=>{t(Qs("Couldn't save languages","The writing languages weren't saved.",g))}}),u=I.useCallback(g=>{e&&o.mutate({path:{accountId:e},body:{composeLanguages:g}})},[e,o]);return{languages:l,setLanguages:u,isSaving:o.isPending}},yi=e=>e.authType==="oauthMicrosoft",xi=e=>{const s=e.smtpUsername?.trim();return s?s!==e.username:!1},vi=Xs({email:je().email().min(1,"Email is required"),displayName:je().optional(),username:je().optional(),password:je().optional(),imapHost:je().min(1,"IMAP host is required"),imapPort:Vt.number().int().min(1).max(65535),imapTls:Ie(),imapStartTls:Ie(),smtpHost:je().optional(),smtpPort:Vt.number().int().min(1).max(65535).optional(),smtpTls:Ie().optional(),smtpStartTls:Ie().optional(),smtpUsername:je().optional(),smtpPassword:je().optional(),useDifferentSmtpCreds:Ie().optional()}),bi=({isOpen:e,onClose:s,account:t,focusSmtp:a})=>{const n=Qe(),l=!!t,[o,u]=I.useState(""),[g,S]=I.useState(!1),N=Rt(o),P=!!N&&!g,H=I.useRef(null),h=ri({resolver:hi(vi),defaultValues:{email:"",displayName:"",username:"",password:"",imapHost:"",imapPort:993,imapTls:!0,imapStartTls:!1,smtpHost:"",smtpPort:587,smtpTls:!1,smtpStartTls:!0,useDifferentSmtpCreds:!1}});I.useEffect(()=>{if(t){const p=xi(t);h.reset({email:t.email,displayName:t.displayName||"",username:t.username||"",password:"",imapHost:t.imapHost,imapPort:t.imapPort,imapTls:t.imapTls,imapStartTls:t.imapStartTls,smtpHost:t.smtpHost||"",smtpPort:t.smtpPort||587,smtpTls:t.smtpTls||!1,smtpStartTls:t.smtpStartTls||!0,smtpUsername:p&&t.smtpUsername||"",smtpPassword:"",useDifferentSmtpCreds:p})}else h.reset({email:"",displayName:"",username:"",password:"",imapHost:"",imapPort:993,imapTls:!0,imapStartTls:!1,smtpHost:"",smtpPort:587,smtpTls:!1,smtpStartTls:!0,useDifferentSmtpCreds:!1})},[t,h]);const j=pe({...Ys()}),E=pe({...Zs(),onSuccess:()=>{n.invalidateQueries({queryKey:we()}),s()}}),T=pe({...ht(),onSuccess:()=>{n.invalidateQueries({queryKey:we()}),s()}}),oe=()=>{const p=h.getValues(),R=l&&!p.password;j.mutate({body:{accountId:R?t?.accountId:void 0,username:p.username||p.email,password:R?void 0:p.password||void 0,imapHost:p.imapHost,imapPort:Number(p.imapPort),imapTls:p.imapTls,imapStartTls:p.imapStartTls}})},C=()=>{const p=h.getValues(),R=l&&!p.password;j.mutate({body:{accountId:R?t?.accountId:void 0,username:p.username||p.email,password:R?void 0:p.password||void 0,imapHost:p.imapHost,imapPort:Number(p.imapPort),imapTls:p.imapTls,imapStartTls:p.imapStartTls,smtpHost:p.smtpHost||void 0,smtpPort:p.smtpPort?Number(p.smtpPort):void 0,smtpTls:p.smtpTls,smtpStartTls:p.smtpStartTls,smtpUsername:p.useDifferentSmtpCreds?p.smtpUsername:void 0,smtpPassword:p.useDifferentSmtpCreds?p.smtpPassword:void 0}})},V=h.handleSubmit(p=>{if(!l&&!p.password){h.setError("password",{message:"Password is required"});return}const R=br({imapHost:p.imapHost,smtpHost:p.smtpHost,smtpPort:p.smtpPort,smtpTls:p.smtpTls,smtpStartTls:p.smtpStartTls});R&&(h.setValue("smtpHost",R.smtpHost),h.setValue("smtpPort",R.smtpPort),h.setValue("smtpTls",R.smtpTls),h.setValue("smtpStartTls",R.smtpStartTls));const X=R?.smtpHost??p.smtpHost,ne=R?.smtpPort??p.smtpPort,ge=R?.smtpTls??p.smtpTls,Se=R?.smtpStartTls??p.smtpStartTls,ke={email:p.email,displayName:p.displayName?.trim()||void 0,username:p.username||void 0,imapHost:p.imapHost,imapPort:Number(p.imapPort),imapTls:p.imapTls,imapStartTls:p.imapStartTls,smtpHost:X||void 0,smtpPort:ne?Number(ne):void 0,smtpTls:ge,smtpStartTls:Se,smtpUsername:p.useDifferentSmtpCreds&&p.smtpUsername||void 0,smtpPassword:p.useDifferentSmtpCreds&&p.smtpPassword||void 0};if(l&&t){const Fe={...ke,password:p.password||void 0};T.mutate({path:{accountId:t.accountId},body:Fe})}else{const Fe={...ke,password:p.password};E.mutate({body:Fe})}}),_=E.isPending||T.isPending,{signature:k,setSignature:J,isSaving:W}=vr(t?.accountId),[ae,re]=I.useState(k.plainText),{languages:ce,setLanguages:he,isSaving:F}=gi(t?.accountId),D=r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Writing languages"}),r.jsx(Dr,{value:ce,onChange:he,busy:F})]});I.useEffect(()=>{re(k.plainText)},[k.plainText]),I.useEffect(()=>{if(!e||!a)return;const p=H.current;if(!p)return;const R=window.setTimeout(()=>{p.scrollIntoView({behavior:"smooth",block:"start"})},250);return()=>window.clearTimeout(R)},[e,a]);const O=I.useCallback(()=>{ae!==k.plainText&&J(ae,ae)},[ae,k.plainText,J]),$=p=>{const{tls:R,startTls:X}=$e(p);h.setValue("imapTls",R),h.setValue("imapStartTls",X);const ne=h.getValues("imapPort");(ne===993||ne===143)&&h.setValue("imapPort",p==="tls"?993:143)},K=p=>{const{tls:R,startTls:X}=$e(p);h.setValue("smtpTls",R),h.setValue("smtpStartTls",X);const ne=h.getValues("smtpPort");if(ne===465||ne===587||ne===25){const Se=p==="tls"?465:p==="starttls"?587:25;h.setValue("smtpPort",Se)}},G=()=>{const p=h.getValues("imapHost");h.setValue("smtpHost",Sr(p)),h.setValue("smtpTls",!1),h.setValue("smtpStartTls",!0),h.setValue("smtpPort",587)},be=p=>{u(p),S(!1);const R=Rt(p);if(!R)return;const X=$e(R.imap.security);h.setValue("imapHost",R.imap.host),h.setValue("imapPort",R.imap.port),h.setValue("imapTls",X.tls),h.setValue("imapStartTls",X.startTls);const ne=$e(R.smtp.security);h.setValue("smtpHost",R.smtp.host),h.setValue("smtpPort",R.smtp.port),h.setValue("smtpTls",ne.tls),h.setValue("smtpStartTls",ne.startTls);const ge=h.getValues("email").trim(),Se=h.getValues("username")?.trim();ge&&!Se&&h.setValue("username",ge)},w=N?.passwordHelp.text,ie=Mt(j.data?.imapError,w),Ee=Mt(j.data?.smtpError,w);return(t?yi(t):!1)&&l?r.jsx(Lt,{isOpen:e,onClose:s,title:"Edit Account",footer:r.jsx(se,{type:"button",variant:"secondary",onClick:s,children:"Close"}),children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Microsoft 365 Account"}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"rounded-md border border-line bg-surface-sunken px-3 py-2.5 text-sm text-fg-muted",children:[r.jsx("span",{className:"block text-2xs font-medium uppercase tracking-wider text-fg-subtle mb-1",children:"Email"}),r.jsx("span",{className:"text-fg",children:t?.email})]}),r.jsxs("div",{className:"rounded-md border border-line bg-surface-sunken px-3 py-2.5 text-sm text-fg-muted",children:[r.jsx("span",{className:"block text-2xs font-medium uppercase tracking-wider text-fg-subtle mb-1",children:"Authentication"}),r.jsx("span",{className:"text-fg",children:"Microsoft OAuth (XOAUTH2)"})]}),r.jsx("p",{className:"text-xs text-fg-muted",children:"Server settings are managed automatically for Microsoft 365 accounts. To update credentials, use the Reconnect button."})]})]}),l&&r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Signature"}),r.jsx("div",{className:"space-y-3",children:r.jsxs("div",{children:[r.jsx("label",{htmlFor:"email-sig-view",className:"text-sm font-medium mb-1.5 block",children:"Email Signature"}),r.jsx("textarea",{id:"email-sig-view",value:ae,onChange:p=>re(p.target.value),onBlur:O,rows:5,className:"w-full px-3 py-2 border border-line rounded-md bg-surface-sunken text-sm text-fg placeholder:text-fg-subtle focus-within:border-line-strong focus-within:ring-2 focus-within:ring-ring/30 transition-colors resize-y outline-none",placeholder:"Enter your email signature..."}),r.jsx("p",{className:"text-xs text-fg-muted mt-1",children:W?"Saving signature...":"This signature will be appended to new emails."})]})})]}),l&&D]})}):r.jsx(Lt,{isOpen:e,onClose:s,title:l?"Edit Account":"Add Account",footer:r.jsxs(r.Fragment,{children:[r.jsx(se,{type:"button",variant:"secondary",onClick:s,children:"Cancel"}),r.jsx(se,{type:"submit",form:"account-form",variant:"primary",disabled:_,children:_?"Saving...":"Save Account"})]}),children:r.jsxs("form",{id:"account-form",onSubmit:V,className:"space-y-6",children:[r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Account Information"}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-provider",className:"text-sm font-medium mb-1.5 block",children:"Provider"}),r.jsxs(Js,{id:"account-provider",value:o,onChange:p=>be(p.target.value),children:[r.jsx("option",{value:"",children:"Custom / other"}),fr.map(p=>r.jsx("option",{value:p.id,children:p.label},p.id))]}),r.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Pick your email provider to fill in server settings automatically, or choose Custom to enter them by hand."})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-email",className:"text-sm font-medium mb-1.5 block",children:"Email Address"}),r.jsx(ve,{id:"account-email",...h.register("email"),placeholder:"alice@example.com"}),h.formState.errors.email&&r.jsx("p",{className:"text-sm text-danger mt-1",children:h.formState.errors.email.message})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-displayName",className:"text-sm font-medium mb-1.5 block",children:"Display name (optional)"}),r.jsx(ve,{id:"account-displayName",...h.register("displayName"),placeholder:"Alice"}),r.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"What to call this account in Remit. Leave blank to use a name derived from the address."})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-username",className:"text-sm font-medium mb-1.5 block",children:"Username"}),r.jsx(ve,{id:"account-username",...h.register("username"),placeholder:"Same as email if empty"})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-password",className:"text-sm font-medium mb-1.5 block",children:"Password"}),r.jsx(Pt,{id:"account-password",...h.register("password"),placeholder:l?"Leave empty to keep current":""}),h.formState.errors.password&&r.jsx("p",{className:"text-sm text-danger mt-1",children:h.formState.errors.password.message}),N&&r.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[N.passwordHelp.text," ",r.jsx("a",{href:N.passwordHelp.url,target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline",children:"Get an app password"})]})]})]})]}),r.jsxs("section",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider",children:"Incoming Mail (IMAP)"}),N&&r.jsx("button",{type:"button",onClick:()=>S(p=>!p),className:"text-xs text-fg-muted hover:text-fg transition-colors",children:g?"Use preset settings":"Advanced"})]}),P&&r.jsxs("p",{className:"text-xs text-fg-muted mb-3",children:["Server settings are pre-filled for ",N?.label," and locked. Choose Advanced to edit them by hand."]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"imap-host",className:"text-sm font-medium mb-1.5 block",children:"Server"}),r.jsx(ve,{id:"imap-host",...h.register("imapHost"),readOnly:P,placeholder:"imap.example.com"}),h.formState.errors.imapHost&&r.jsx("p",{className:"text-sm text-danger mt-1",children:h.formState.errors.imapHost.message})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"imap-port",className:"text-sm font-medium mb-1.5 block",children:"Port"}),r.jsx(ve,{id:"imap-port",...h.register("imapPort"),readOnly:P,type:"number"})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-sm font-medium mb-1.5 block",children:"Security"}),r.jsxs("div",{className:"space-y-1.5 mt-2",children:[r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:P,checked:h.watch("imapTls"),onChange:()=>$("tls")}),"TLS (Port 993)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:P,checked:!h.watch("imapTls")&&h.watch("imapStartTls"),onChange:()=>$("starttls")}),"STARTTLS (Port 143)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:P,checked:!h.watch("imapTls")&&!h.watch("imapStartTls"),onChange:()=>$("none")}),"None (Unencrypted)"]})]})]})]}),r.jsx(se,{type:"button",variant:"secondary",onClick:oe,disabled:j.isPending,className:"w-full",icon:j.isPending?r.jsx(it,{className:"size-4 animate-spin"}):void 0,children:j.isPending?"Testing...":"Test IMAP Connection"}),j.data&&r.jsxs("div",{className:Ve("p-2 rounded-md text-sm",j.data.imapSuccess?"bg-positive/10 text-positive":"bg-danger-soft text-danger"),children:[j.data.imapSuccess?r.jsx(Ct,{className:"inline size-4 mr-1"}):r.jsx(De,{className:"inline size-4 mr-1"}),j.data.imapSuccess?"IMAP Connected":ie]})]})]}),r.jsxs("section",{ref:H,"data-testid":"smtp-section",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider",children:"Outgoing Mail (SMTP)"}),!P&&r.jsx("button",{type:"button",onClick:G,disabled:!h.watch("imapHost"),className:"text-xs text-fg-muted hover:text-fg transition-colors disabled:opacity-50",children:"Pre-fill from IMAP"})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"smtp-host",className:"text-sm font-medium mb-1.5 block",children:"Server"}),r.jsx(ve,{id:"smtp-host",...h.register("smtpHost"),readOnly:P,placeholder:"smtp.example.com"})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"smtp-port",className:"text-sm font-medium mb-1.5 block",children:"Port"}),r.jsx(ve,{id:"smtp-port",...h.register("smtpPort"),readOnly:P,type:"number"})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-sm font-medium mb-1.5 block",children:"Security"}),r.jsxs("div",{className:"space-y-1.5 mt-2",children:[r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:P,checked:h.watch("smtpTls")===!0,onChange:()=>K("tls")}),"TLS (Port 465)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:P,checked:!h.watch("smtpTls")&&h.watch("smtpStartTls")===!0,onChange:()=>K("starttls")}),"STARTTLS (Port 587)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:P,checked:!h.watch("smtpTls")&&!h.watch("smtpStartTls"),onChange:()=>K("none")}),"None (Unencrypted)"]})]})]})]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"checkbox",...h.register("useDifferentSmtpCreds")}),"Use different credentials for SMTP"]}),h.watch("useDifferentSmtpCreds")&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"smtp-username",className:"text-sm font-medium mb-1.5 block",children:"SMTP Username"}),r.jsx(ve,{id:"smtp-username",...h.register("smtpUsername")})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"smtp-password",className:"text-sm font-medium mb-1.5 block",children:"SMTP Password"}),r.jsx(Pt,{id:"smtp-password",...h.register("smtpPassword")})]})]}),r.jsx(se,{type:"button",variant:"secondary",onClick:C,disabled:j.isPending||!h.watch("smtpHost"),className:"w-full",icon:j.isPending?r.jsx(it,{className:"size-4 animate-spin"}):void 0,children:j.isPending?"Testing...":"Test SMTP Connection"}),j.data?.smtpSuccess!==void 0&&r.jsxs("div",{className:Ve("p-2 rounded-md text-sm",j.data.smtpSuccess?"bg-positive/10 text-positive":"bg-danger-soft text-danger"),children:[j.data.smtpSuccess?r.jsx(Ct,{className:"inline size-4 mr-1"}):r.jsx(De,{className:"inline size-4 mr-1"}),j.data.smtpSuccess?"SMTP Connected":Ee]})]})]}),l&&r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Signature"}),r.jsx("div",{className:"space-y-3",children:r.jsxs("div",{children:[r.jsx("label",{htmlFor:"email-sig-edit",className:"text-sm font-medium mb-1.5 block",children:"Email Signature"}),r.jsx("textarea",{id:"email-sig-edit",value:ae,onChange:p=>re(p.target.value),onBlur:O,rows:5,className:"w-full px-3 py-2 border border-line rounded-md bg-surface-sunken text-sm text-fg placeholder:text-fg-subtle focus-within:border-line-strong focus-within:ring-2 focus-within:ring-ring/30 transition-colors resize-y outline-none",placeholder:"Enter your email signature..."}),r.jsx("p",{className:"text-xs text-fg-muted mt-1",children:W?"Saving signature...":"This signature will be appended to new emails."})]})})]}),l&&D]})})},Si="https://graph.microsoft.com/",ji={[at.Mail]:["https://outlook.office.com/IMAP.AccessAsUser.All","https://outlook.office.com/SMTP.Send"],[at.Calendar]:[`${Si}Calendars.Read`]},wi=e=>{const s=new Set(e.map(t=>t.toLowerCase()));return Object.values(at).filter(t=>ji[t].every(a=>s.has(a.toLowerCase())))},mt=e=>`Couldn't turn ${e.service.toLowerCase()} ${e.intent}`,Ni=e=>er(tr({title:`Bug: ${mt(e)}`,errorMessage:`${mt(e)} — ${e.message}`}));function Ai({providerName:e,offered:s,enabled:t,consented:a,disabled:n,refusal:l,onRequestChange:o}){return s.length<2?null:r.jsxs("section",{className:"space-y-2 rounded-sm border border-line bg-surface px-row-inset py-3",children:[r.jsx(Cr,{providerName:e,offered:s,enabled:t,consented:a,disabled:n,onRequestChange:o}),l&&r.jsxs(nt,{tone:"danger",variant:"soft",children:[r.jsx("p",{className:"font-medium",children:mt(l)}),r.jsx("p",{className:"mt-0.5 break-words text-fg-muted",children:l.message}),r.jsx("a",{href:Ni(l),target:"_blank",rel:"noopener noreferrer",className:"mt-1 inline-block font-medium text-accent hover:underline",children:"Report an issue"})]})]})}const Vs=["Mail","Calendar"],ts="Microsoft",ss=e=>e.authType==="oauthMicrosoft",rs=(e,s)=>Vs.filter(t=>t===s||e.includes(t));function Ti({account:e,onRemoveAccount:s}){const t=Qe(),[a,n]=I.useState(null),[l,o]=I.useState(null),[u,g]=I.useState(null),S=pe({...ht(),meta:Dt,onSuccess:()=>t.invalidateQueries({queryKey:we()})}),N=pe({...cs(),meta:Dt}),P=us(V=>{const _=u;g(null),!(V!=="stalled"||_===null)&&o({service:_,intent:"on",message:fs})}),H=S.isPending&&S.variables?.body.syncedServices?S.variables.body.syncedServices:e.syncedServices,h=ss(e)?Vs:["Mail"],j=ss(e)?wi(e.grantedScopes):h,E=(V,_,k)=>{o(null),S.mutate({path:{accountId:e.accountId},body:{syncedServices:V}},{onError:J=>o({service:_,intent:k,message:It(J)})})},T=V=>{o(null),N.mutate({body:{email:e.email,services:rs(H,V)}},{onSuccess:_=>{g(V),P(),window.location.assign(_.authorizationUrl)},onError:_=>o({service:V,intent:"on",message:It(_)})})},oe=(V,_)=>{if(_==="off"){n({kind:H.length===1?"last":"disable",service:V});return}if(!j.includes(V)){n({kind:"enable",service:V});return}E(rs(H,V),V,"on")},C=()=>{const V=a;if(n(null),V!==null){if(V.kind==="last"){s();return}if(V.kind==="enable"){T(V.service);return}E(H.filter(_=>_!==V.service),V.service,"off")}};return r.jsxs(r.Fragment,{children:[r.jsx(Ai,{providerName:ts,offered:h,enabled:H,consented:j,disabled:S.isPending||N.isPending||u!==null,refusal:l,onRequestChange:oe}),r.jsx(_r,{change:a,providerName:ts,onConfirm:C,onCancel:()=>n(null)})]})}function is({open:e,onClose:s,accountEmail:t,signOut:a}){const[n,l]=I.useState(""),[o,u]=I.useState(!1),[g,S]=I.useState(!1),N=pe({...rr(),onSuccess:()=>{S(!0),setTimeout(()=>a(),2e3)}}),P=pe(ir()),H=()=>{N.isPending||(l(""),u(!1),S(!1),N.reset(),P.reset(),s())},h=()=>{if(n.trim().toLowerCase()!==t.toLowerCase()){u(!0);return}u(!1),N.mutate({body:{confirmEmail:n.trim()}})};return r.jsxs(ds,{open:e,onClose:H,title:"Delete your Remit account",children:[r.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[r.jsx(pt,{className:"size-4 shrink-0 text-danger"}),r.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:"Delete your Remit account"}),r.jsx(se,{variant:"ghost",size:"sm",icon:r.jsx(De,{className:"size-3.5"}),onClick:H,"aria-label":"Cancel"})]}),g?r.jsxs("div",{className:"px-5 py-6 text-sm text-fg-muted",children:[r.jsx("p",{className:"font-medium text-fg",children:"Account deletion scheduled."}),r.jsx("p",{className:"mt-1",children:"Your data will be erased shortly. Signing you out…"})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"space-y-4 px-5 py-4 text-sm text-fg-muted",children:[r.jsx("p",{children:"This permanently erases everything Remit holds for you:"}),r.jsxs("ul",{className:"space-y-1.5 text-xs",children:[r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"text-danger",children:"•"}),"All connected accounts disconnected and access tokens revoked."]}),r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"text-danger",children:"•"}),"Synced mail cache and search index."]}),r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"text-danger",children:"•"}),"AI history and insights."]}),r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"text-danger",children:"•"}),"Preferences and rules."]})]}),r.jsxs("div",{className:"rounded-sm border border-line bg-surface-sunken px-3 py-2 text-xs",children:[r.jsx("strong",{className:"text-fg",children:"Your mail at Gmail / IMAP is not deleted."})," ","This only removes Remit's copy and its access — the mail stays in your provider mailboxes."]}),r.jsxs("div",{className:"text-xs",children:[r.jsxs("button",{type:"button",onClick:()=>P.mutate({}),"aria-busy":P.isPending,className:"inline-flex items-center gap-1.5 font-medium text-accent hover:underline",children:[r.jsx(wr,{className:"size-3.5"}),P.isPending?"Requesting export…":"Export my data first"]}),P.isSuccess&&r.jsx("p",{className:"mt-1.5 text-fg-muted",role:"status",children:"Export requested. We'll prepare a ZIP of your mail — find it under your data exports when it's ready."}),P.isError&&r.jsx("p",{className:"mt-1.5 text-danger",role:"alert",children:"Couldn't start the export. Please try again."})]}),r.jsxs("div",{children:[r.jsxs("label",{htmlFor:"confirm-remit-email",className:"mb-1 block text-xs font-medium text-fg",children:["Type"," ",r.jsx("span",{className:"font-mono text-fg-muted",children:t})," ","to confirm"]}),r.jsx(ve,{id:"confirm-remit-email",type:"email",placeholder:t,value:n,onChange:j=>{l(j.target.value),o&&u(!1),N.isError&&N.reset()},autoComplete:"off"}),o&&r.jsx("p",{className:"mt-1.5 text-xs text-danger",role:"alert",children:"That doesn't match your account email. Type it exactly to confirm."}),N.isError&&r.jsx("p",{className:"mt-1.5 text-xs text-danger",role:"alert",children:N.error instanceof Error?N.error.message:"Something went wrong. Please try again."})]})]}),r.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[r.jsx(se,{variant:"secondary",size:"sm",onClick:H,children:"Cancel"}),r.jsx(se,{variant:"danger",size:"sm",onClick:h,"aria-busy":N.isPending,children:N.isPending?"Deleting…":"Delete everything"})]})]})]})}function Ei(e){const{Account:s}=sr();return r.jsx(s,{fallback:r.jsx(is,{...e,accountEmail:"",signOut:()=>{}}),children:({email:t,signOut:a})=>r.jsx(is,{...e,accountEmail:t??"",signOut:a})})}function ki(){const[e,s]=I.useState(!1);return r.jsxs("section",{className:"mt-8 border-t border-line pt-6",children:[r.jsx(Fr,{title:"Delete your Remit account",description:"Disconnects every account and erases Remit's copy of your mail, insights and preferences. Your mail at the providers is untouched.",action:r.jsx(se,{variant:"danger",size:"sm",onClick:()=>s(!0),children:"Delete your Remit account"})}),r.jsx(Ei,{open:e,onClose:()=>s(!1)})]})}function Ds(e){const s=e.toLowerCase();return s==="access_denied"?"You cancelled the sign-in.":s==="scope_not_granted"?"Microsoft did not grant access to every service you picked. Sign in again and accept each permission Microsoft asks for.":s==="consent_required"||s.includes("admin_consent")||s.includes("interaction_required")?"Your organisation's admin needs to approve Remit. Ask your IT admin to grant the required permissions.":s.includes("imap_disabled")||s.includes("imap disabled")?"IMAP is disabled for this account. Ask your admin to enable IMAP access in the Microsoft 365 admin centre.":`Sign-in failed: ${e}. Please try again.`}const _i=e=>e.length>1?`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`:e[0]??"";function Pi(e,s){const t=(e.missingServices??"").split(","),a=ot.filter(S=>t.includes(S.id)),n=e.oauthEmail,l=n?s.find(S=>S.authType==="oauthMicrosoft"&&S.email.toLowerCase()===n.toLowerCase()):void 0,o=_i(a.map(S=>S.label)),u=a.length===0?Ds("scope_not_granted"):`Microsoft did not grant access to ${o}. Sign in again and accept the ${o} ${a.length>1?"permissions":"permission"} when Microsoft asks.`,g=l?ot.filter(S=>l.syncedServices.includes(S.id)||a.some(N=>N.id===S.id)).map(S=>S.id):void 0;return{kind:"refused",message:u,email:n,services:g,reconnect:!!l}}function Ci(e){const s=e.split("@")[0]??"";return s?s.split(/[._-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" "):e}function Vi(e){const s=e.displayName?.trim();return s||Ci(e.email)}function Di(e){if(!e.lastSyncAt)return"never synced";const s=ur(e.lastSyncAt);return s?`synced ${s}`:"never synced"}function as(e){return e.muted?.value?"muted":e.lastError?"error":e.connectionState==="authenticated"?"healthy":"error"}function ns(e){return e.connectionState==="reauth_required"}function Fi(e){return e.connectionState==="credentials_missing"}const Oi=()=>r.jsx("div",{className:"space-y-3",role:"status","aria-busy":"true","aria-label":"Loading accounts",children:["skeleton-0","skeleton-1"].map(e=>r.jsx("div",{className:"rounded-sm border border-line bg-surface animate-pulse p-4",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"size-10 rounded-full bg-surface-sunken"}),r.jsxs("div",{className:"flex-1 space-y-2",children:[r.jsx("div",{className:"h-4 bg-surface-sunken rounded w-1/3"}),r.jsx("div",{className:"h-3 bg-surface-sunken rounded w-2/3"})]})]})},e))});function aa(){const e=Ft.useSearch(),s=ar({from:Ft.fullPath}),[t,a]=I.useState(!0),[n,l]=I.useState(!1),[o,u]=I.useState(!1),[g,S]=I.useState(void 0),[N,P]=I.useState(null),[H,h]=I.useState(!1),[j,E]=I.useState(null),[T,oe]=I.useState(null),[C,V]=I.useState(null),[_,k]=I.useState(null),J=Qe(),{data:W,isPending:ae,isError:re,error:ce,refetch:he}=os(ls());I.useEffect(()=>{e.editAccountId&&(P(e.editAccountId),h(!!e.focusSmtp),s({search:{editAccountId:void 0,focusSmtp:void 0,connected:e.connected,oauthError:e.oauthError,oauthEmail:e.oauthEmail,missingServices:e.missingServices},replace:!0}))},[e.editAccountId,e.focusSmtp,s,e.connected,e.oauthError,e.oauthEmail,e.missingServices]),I.useEffect(()=>{e.connected&&(S({kind:"connected",accountId:e.connected}),u(!0),J.invalidateQueries({queryKey:we()}),s({search:{connected:void 0,oauthError:void 0,editAccountId:void 0,focusSmtp:void 0},replace:!0}))},[e.connected,s,J]),I.useEffect(()=>{if(!e.oauthError)return;const w=e.oauthError==="scope_not_granted";w&&!W&&!re||(k(null),w?(S(Pi({oauthEmail:e.oauthEmail,missingServices:e.missingServices},W?.accounts??[])),u(!0)):V(Ds(e.oauthError)),s({search:{oauthError:void 0,connected:void 0,editAccountId:void 0,focusSmtp:void 0},replace:!0}))},[e.oauthError,e.oauthEmail,e.missingServices,W,re,s]),xr(_!==null,()=>{J.invalidateQueries({queryKey:we()})}),I.useEffect(()=>{if(!_||!W)return;const w=W.accounts.find(ie=>ie.accountId===_);(!w||!ns(w))&&k(null)},[W,_]);const F=us(w=>{k(null),w==="stalled"&&V(fs)}),D=pe({...cs(),onSuccess:w=>{F(),window.location.assign(w.authorizationUrl)},onError:w=>{V(w instanceof Error?w.message:"Failed to start reconnect"),k(null)}}),O=pe({...nr(),onSuccess:()=>{J.invalidateQueries({queryKey:we()}),E(null)}}),$=W?.accounts.find(w=>w.accountId===j),K=W?.accounts.find(w=>w.accountId===N),G=()=>{l(!1),u(!1),P(null),h(!1)},be=w=>{const ie=cr[w];ie&&s({to:ie})};return r.jsxs(gr,{items:or,activeId:"accounts",title:"Accounts",description:"Every account keeps syncing — muted ones just stay out of unified views.",help:Nr,helpOpen:t,onToggleHelp:()=>a(w=>!w),onSelect:be,onBackToMail:()=>{s({to:"/mail"})},children:[T&&r.jsx(nt,{tone:"success",variant:"soft","data-testid":"oauth-success-banner",onDismiss:()=>oe(null),children:T}),C&&r.jsx(nt,{tone:"danger",variant:"soft","data-testid":"oauth-error-banner",onDismiss:()=>V(null),children:C}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(lr,{tone:"neutral",children:ae||re?"accounts":`${W.accounts.length} ${W.accounts.length===1?"account":"accounts"}`}),r.jsx(se,{variant:"primary",size:"sm",icon:r.jsx(Ot,{className:"size-3.5"}),onClick:()=>u(!0),children:"Add account"})]}),ae?r.jsx(Oi,{}):re?r.jsx(pr,{title:"Couldn't load accounts",error:ce,onRetry:()=>{he()}}):W.accounts.length===0?r.jsxs("div",{className:"py-12 text-sm text-fg-muted","data-testid":"accounts-empty",children:[r.jsx("p",{className:"mb-3",children:"No accounts configured."}),r.jsx(se,{variant:"primary",size:"sm",icon:r.jsx(Ot,{className:"size-3.5"}),onClick:()=>u(!0),children:"Add your first account"})]}):r.jsx("div",{className:"space-y-3",children:W.accounts.map(w=>{const ie=ns(w),Ee=Fi(w),Ae=w.authType==="oauthMicrosoft",p=_===w.accountId,R=ie&&Ae?{label:"Reconnect",variant:"secondary",busy:p,busyLabel:"Redirecting…",onClick:()=>{k(w.accountId),D.mutate({body:{email:w.email,services:w.syncedServices}})}}:Ee?{label:"Enter password",variant:"secondary",onClick:()=>P(w.accountId)}:as(w)==="error"?{label:"Reconnect",variant:"secondary",onClick:()=>P(w.accountId)}:{label:"Manage",variant:"ghost",onClick:()=>P(w.accountId)},X=r.jsx(hr,{actions:[R],destructive:{label:"Delete account",iconOnly:!0,icon:r.jsx(dr,{className:"size-3.5"}),onClick:()=>E(w.accountId)}});return r.jsxs("div",{className:"space-y-2",children:[r.jsx(yr,{label:Vi(w),email:w.email,connector:Ae?"Microsoft 365":"IMAP",syncLabel:Di(w),state:as(w),errorDetail:ie?w.lastError??"Re-authentication required":Ee?"Imported from a config file, which carries no password. Enter one to start syncing.":w.lastError,trailing:X}),r.jsx(Ti,{account:w,onRemoveAccount:()=>E(w.accountId)})]},w.accountId)})}),o&&r.jsx("div",{className:"fixed inset-0 z-40 overflow-auto bg-canvas",children:r.jsx(mr,{skipWelcome:!0,microsoftReturn:g,onComplete:()=>{g?.kind==="connected"&&oe("Account connected successfully."),u(!1),S(void 0),J.invalidateQueries({queryKey:we()})},onCancel:()=>{u(!1),S(void 0)}})}),r.jsx(bi,{isOpen:n||!!N,account:K,focusSmtp:H,onClose:G}),r.jsxs(ds,{open:!!j,onClose:()=>E(null),title:"Delete account",children:[r.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[r.jsx(pt,{className:"size-4 shrink-0 text-danger"}),r.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:"Delete account"}),r.jsx(se,{variant:"ghost",size:"sm",icon:r.jsx(De,{className:"size-3.5"}),onClick:()=>E(null),"aria-label":"Cancel"})]}),r.jsxs("div",{className:"space-y-3 px-5 py-4 text-sm text-fg-muted",children:[r.jsx("p",{className:"text-center text-lg font-medium text-fg",children:"Are you sure?"}),$&&r.jsx("p",{className:"text-center",children:$.email}),r.jsxs("ul",{className:"list-inside list-disc space-y-1",children:[r.jsx("li",{children:"Remove the account from your settings"}),r.jsx("li",{children:"Stop syncing mail for this account"}),r.jsx("li",{children:"Delete all associated data (within 24 hours)"})]})]}),r.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[r.jsx(se,{variant:"secondary",size:"sm",onClick:()=>E(null),children:"Cancel"}),r.jsx(se,{variant:"danger",size:"sm","aria-busy":O.isPending,icon:O.isPending?r.jsx(it,{className:"size-3.5 animate-spin"}):void 0,onClick:()=>{O.isPending||j&&O.mutate({path:{accountId:j}})},children:O.isPending?"Deleting…":"Delete account"})]})]}),r.jsx(ki,{})]})}export{aa as component,Ds as mapOauthError,Pi as scopeRefusalReturn};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e,aN as R,aW as y,f as l,aX as j,r as h,as as u,B as T,L as g,g as k,aY as p,t as S,h as I,aZ as A,a_ as D,V as L,a$ as O,b0 as U,b1 as B,u as E,aQ as _,aS as V}from"./index-BDIVfNXM.js";import{S as Y}from"./settings-screen-B51b9lvj.js";import{e as F}from"./config-import-DH8GC5mw.js";import{u as H}from"./sections-FEvJ4c2c.js";import{C as M,a as P,b as G,c as J}from"./card-BKgdv2bH.js";import{D as N}from"./download-53lT8mTP.js";import{F as W}from"./file-json-ofsJkIbX.js";import{E as w}from"./external-link-NCezTZkT.js";import{R as v}from"./rotate-ccw-BzM31Pwc.js";import{C as b}from"./circle-check-6Bb3NNZS.js";import{C as Q,S as $}from"./shield-check-CgX3iFVl.js";import{C as q}from"./clock-BDHe3TX8.js";import{b as X}from"./help-copy-CADUhLzQ.js";import"./avatar-BEy9bmfT.js";import"./chevron-left-iD9K0p2O.js";import"./menu-DQ-pJ4eT.js";import"./circle-help-C0X0r4BQ.js";import"./kbd-BTTdW6-z.js";const Z=["Remit restarts. Mail stops loading for about a minute and this page will lose its connection while that happens.","Nothing is sent, deleted or moved. Your mail stays at your provider.","If the new version does not come back up, the version you are running now is restored automatically."];function K({open:s,currentVersion:n,release:a,appliesSchemaMigration:t=!1,onClose:i,onConfirm:r}){return s?e.jsx(R,{open:!0,onClose:i,title:`Install Remit ${a.version}`,children:e.jsxs("div",{className:"flex max-h-[80vh] flex-col",children:[e.jsxs("header",{className:"space-y-1 border-b border-line px-4 py-3",children:[e.jsxs("h3",{className:"text-sm font-semibold text-fg",children:["Install Remit ",a.version,"?"]}),e.jsxs("p",{className:"text-xs text-fg-muted",children:["You are on ",n,". ",a.version," was released"," ",y(a.releasedAt),"."]})]}),e.jsxs("div",{className:"flex-1 space-y-3 overflow-auto px-4 py-3",children:[e.jsx("p",{className:"text-sm text-fg-muted",children:a.summary}),e.jsxs("ul",{className:"space-y-2",children:[Z.map(c=>e.jsxs("li",{className:"flex gap-2 text-sm text-fg-muted",children:[e.jsx("span",{className:"mt-1.5 size-1.5 shrink-0 rounded-full bg-fg-subtle"}),e.jsx("span",{children:c})]},c)),t&&e.jsxs("li",{className:"flex gap-2 text-sm text-fg-muted",children:[e.jsx("span",{className:"mt-1.5 size-1.5 shrink-0 rounded-full bg-fg-subtle"}),e.jsx("span",{children:"This version updates the database while Remit is offline. The step forward cannot be undone by hand, but a failed start is still rolled back to the version and data you have now."})]})]}),e.jsx("p",{className:"text-xs text-fg-subtle",children:"Good moment for this: when you are not waiting on a message."})]}),e.jsxs("footer",{className:"flex flex-wrap items-center justify-end gap-2 border-t border-line px-4 py-3",children:[e.jsx(l,{variant:"ghost",size:"sm",onClick:i,children:"Not now"}),e.jsx(j,{variant:"secondary",size:"sm",external:!0,href:a.releaseNotesUrl,icon:e.jsx(w,{className:"size-3.5"}),children:"Release notes"}),e.jsx(l,{size:"sm",icon:e.jsx(N,{className:"size-3.5"}),onClick:r,children:"Install and restart"})]})]})}):null}function o({children:s,tone:n}){return e.jsx("div",{className:S("rounded-sm border bg-surface px-row-inset py-3",n==="danger"?"border-danger/50":"border-line"),children:s})}function ee({state:s,onCheck:n,onInstall:a,onDismissResult:t,now:i=Date.now()}){const[r,c]=h.useState(null),m=s.status==="checking",d=s.status==="available",x=()=>{if(m){c("Already checking. The result appears here in a moment.");return}c(null),n()},C=()=>{t(),x()},f=()=>{if(!d&&s.status!=="rolledBack"&&s.status!=="abandoned"){c("There is no update to install. Check for updates first — if one is found it appears here.");return}c(null),a()},z=(()=>{switch(s.status){case"upToDate":return e.jsx(o,{children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(b,{className:"size-4 shrink-0 text-positive","aria-hidden":!0}),e.jsxs("p",{className:"text-sm text-fg",children:["Remit ",s.version," is the latest version.",e.jsxs("span",{className:"text-fg-subtle",children:[" ","Checked ",p(s.checkedAt,i),"."]})]})]}),e.jsx(l,{variant:"secondary",size:"sm",className:"shrink-0",onClick:x,children:"Check again"})]})});case"checking":return e.jsx(o,{children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(g,{className:"size-4 shrink-0 animate-spin text-fg-subtle","aria-hidden":!0}),e.jsxs("p",{className:"text-sm text-fg-muted",children:["Looking for a newer version. You are on ",s.version,"."]})]}),e.jsx(l,{variant:"secondary",size:"sm",className:"shrink-0",onClick:x,children:"Check again"})]})});case"neverChecked":return e.jsx(o,{children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[e.jsx(q,{className:"mt-0.5 size-4 shrink-0 text-fg-subtle","aria-hidden":!0}),e.jsxs("p",{className:"text-sm text-fg-muted",children:["No update check has run yet. Remit checks for updates on its own in the background.",s.lastCheckedAt!==void 0&&e.jsxs("span",{className:"text-fg-subtle",children:[" ","Last checked"," ",p(s.lastCheckedAt,i),"."]})]})]}),e.jsx(l,{variant:"secondary",size:"sm",className:"shrink-0",onClick:x,children:"Check now"})]})});case"checkFailed":return e.jsx(o,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Q,{className:"mt-0.5 size-4 shrink-0 text-fg-subtle","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("p",{className:"text-sm text-fg",children:"Could not reach the update source."}),e.jsx("p",{className:"text-xs text-fg-muted",children:s.reason}),e.jsxs("p",{className:"text-xs text-fg-subtle",children:["You are still on ",s.version," and it keeps working.",s.lastCheckedAt!==void 0&&e.jsxs(e.Fragment,{children:[" ","Last successful check"," ",p(s.lastCheckedAt,i),"."]})]})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(l,{variant:"secondary",size:"sm",onClick:x,children:"Try again"})})]})});case"available":return e.jsx(o,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"text-sm font-semibold text-fg",children:["Remit ",s.release.version]}),e.jsx(k,{tone:"accent",children:"update available"}),e.jsxs("span",{className:"text-2xs text-fg-subtle",children:["released ",y(s.release.releasedAt)," · you are on ",s.version]})]}),e.jsx("p",{className:"text-sm text-fg-muted",children:s.release.summary}),e.jsx("p",{className:"text-xs text-fg-subtle",children:"Installing restarts Remit, so mail stops loading for about a minute. If the new version does not come back up, the one you are running now is restored on its own."}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(l,{size:"sm",icon:e.jsx(N,{className:"size-3.5"}),onClick:f,children:["Install ",s.release.version]}),e.jsx(j,{variant:"secondary",size:"sm",external:!0,href:s.release.releaseNotesUrl,icon:e.jsx(w,{className:"size-3.5"}),children:"Release notes"})]})]})});case"applying":return e.jsx(o,{children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(g,{className:"size-4 shrink-0 animate-spin text-accent-2","aria-hidden":!0}),e.jsxs("p",{className:"text-sm text-fg-muted",children:["Installing Remit ",s.target,". The restart screen has the details."]})]})});case"succeeded":return e.jsxs(e.Fragment,{children:[e.jsx(T,{tone:"success",onDismiss:t,children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"font-semibold",children:["Updated to Remit ",s.version,"."]}),e.jsxs("p",{children:["You were on ",s.previousVersion,"."," ",e.jsx("a",{href:s.releaseNotesUrl,target:"_blank",rel:"noopener noreferrer",className:"underline",children:"See what changed"}),"."]})]})}),e.jsx(o,{children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(b,{className:"size-4 shrink-0 text-positive","aria-hidden":!0}),e.jsxs("p",{className:"text-sm text-fg",children:["Remit ",s.version," is running."]})]}),e.jsx(l,{variant:"secondary",size:"sm",className:"shrink-0",onClick:C,children:"Check for updates"})]})})]});case"rolledBack":return e.jsx(o,{tone:"danger",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(u,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("p",{className:"text-sm font-semibold text-fg",children:["Remit ",s.attemptedVersion," did not start. Remit reports that it put ",s.version," back."]}),e.jsxs("p",{className:"text-sm text-fg-muted",children:["You are running ",s.version," again. A failed update can still have changed things on the way — the log below is the only account of what it got as far as doing."]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-fg-subtle",children:"What Remit reported as the failure"}),e.jsx("code",{className:"block rounded-xs bg-danger-soft px-2 py-1 text-2xs text-danger",children:s.reason})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-fg-subtle",children:"Read the full log before trying again:"}),e.jsx("code",{className:"block rounded-xs bg-surface-sunken px-2 py-1 text-2xs text-fg-muted",children:s.logsCommand})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(l,{variant:"secondary",size:"sm",icon:e.jsx(v,{className:"size-3.5"}),onClick:f,children:["Try ",s.attemptedVersion," again"]}),e.jsxs(l,{variant:"ghost",size:"sm",onClick:t,children:["Stay on ",s.version]})]})]})});case"unreachable":return e.jsx(o,{tone:"danger",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(u,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("p",{className:"text-sm font-semibold text-fg",children:["Installing ",s.attemptedVersion," left the server unreachable."]}),e.jsx("p",{className:"text-sm text-fg-muted",children:"Remit has answered again since, but nothing here can say what happened during the silence."})]})]}),e.jsx("code",{className:"block rounded-xs bg-surface-sunken px-2 py-1 text-2xs text-fg-muted",children:s.logsCommand}),e.jsx("div",{className:"flex justify-end",children:e.jsx(l,{variant:"ghost",size:"sm",onClick:t,children:"Dismiss"})})]})});case"rollbackFailed":return e.jsx(o,{tone:"danger",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(u,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("p",{className:"text-sm font-semibold text-fg",children:["Remit ",s.attemptedVersion," did not start, and Remit could not put ",s.previousVersion," back."]}),e.jsx("p",{className:"text-sm text-fg-muted",children:"This is the one outcome Remit cannot resolve on its own. The server is in a half-changed state and needs you at a shell. The log below is the only account of where it stopped."})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-fg-subtle",children:"What Remit reported as the failure"}),e.jsx("code",{className:"block rounded-xs bg-danger-soft px-2 py-1 text-2xs text-danger",children:s.reason})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-fg-subtle",children:"Read the full log on the server:"}),e.jsx("code",{className:"block rounded-xs bg-surface-sunken px-2 py-1 text-2xs text-fg-muted",children:s.logsCommand})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(l,{variant:"ghost",size:"sm",onClick:t,children:"Dismiss"})})]})});case"abandoned":return e.jsx(o,{tone:"danger",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(u,{className:"mt-0.5 size-4 shrink-0 text-fg-subtle","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("p",{className:"text-sm font-semibold text-fg",children:["Remit ",s.attemptedVersion," was not installed. Nothing changed."]}),e.jsxs("p",{className:"text-sm text-fg-muted",children:["The update stopped before it altered anything. You are still running ",s.version,"."]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-fg-subtle",children:"What Remit reported"}),e.jsx("code",{className:"block rounded-xs bg-surface-sunken px-2 py-1 text-2xs text-fg-muted",children:s.reason})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-fg-subtle",children:"Read the full log before trying again:"}),e.jsx("code",{className:"block rounded-xs bg-surface-sunken px-2 py-1 text-2xs text-fg-muted",children:s.logsCommand})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(l,{variant:"secondary",size:"sm",icon:e.jsx(v,{className:"size-3.5"}),onClick:f,children:["Try ",s.attemptedVersion," again"]}),e.jsxs(l,{variant:"ghost",size:"sm",onClick:t,children:["Stay on ",s.version]})]})]})});default:return s}})();return e.jsxs("section",{className:"space-y-3",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Updates"}),e.jsx("p",{className:"text-xs text-fg-muted",children:"This Remit runs on your own server, so it updates when you say so. Your mail lives at your provider and is never touched by an update."})]}),z,r&&e.jsx("p",{role:"status",className:"text-xs text-fg-muted",children:r})]})}function se({fileName:s,state:n="ready",error:a,onDownload:t,onImport:i}){const r=n==="downloading";return e.jsxs(M,{className:"max-w-xl",children:[e.jsx(P,{children:e.jsx(G,{children:"Configuration file"})}),e.jsxs(J,{children:[e.jsx("p",{className:"text-sm text-fg-muted",children:"One versioned JSON document carrying every setting this instance holds: accounts and their servers, folder roles, rules, labels, flagged senders and appearance. No passwords and no OAuth tokens — you sign in again wherever you import it."}),n==="failed"&&e.jsxs("div",{className:"mt-3 space-y-2 rounded-sm border border-danger/40 bg-danger-soft px-3 py-2.5",children:[e.jsx("p",{className:"text-sm font-medium text-danger",children:"The config file could not be written."}),e.jsxs("p",{className:"text-xs text-fg-muted",children:["Nothing was downloaded. Try again — if it keeps failing, use"," ",e.jsx("code",{className:"rounded bg-surface-sunken px-1 py-0.5",children:"remit config save"})," ","on the host in the meantime."]}),a&&e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:a})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[e.jsx(l,{variant:"secondary",size:"sm",disabled:r,icon:r?e.jsx(g,{className:"size-3.5 animate-spin"}):e.jsx(N,{className:"size-3.5"}),onClick:t,children:r?"Preparing…":`Download ${s}`}),e.jsx(k,{tone:"neutral",children:"no passwords"})]}),e.jsxs("p",{className:"mt-3 text-2xs text-fg-subtle",children:["On the host, the same file comes from"," ",e.jsxs("code",{className:"rounded bg-surface-sunken px-1 py-0.5",children:["remit config save ~/",s]}),"."]}),e.jsxs("div",{className:"mt-5 border-t border-line pt-4",children:[e.jsx("p",{className:"text-sm font-medium text-fg",children:"Import a config file"}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:"Read a file from another Reader into this one. It shows what will change before anything is written, and asks for each account's credentials afterwards."}),e.jsx(l,{className:"mt-3",variant:"secondary",size:"sm",icon:e.jsx(W,{className:"size-3.5"}),onClick:i,children:"Import a config file"})]})]})]})}const ae=(s,n)=>{const a=URL.createObjectURL(new Blob([JSON.stringify(n,null,2)],{type:"application/json"})),t=document.createElement("a");t.href=a,t.download=s,t.click(),URL.revokeObjectURL(a)};function te(){const s=I(),n=H(),[a,t]=h.useState("ready"),[i,r]=h.useState(void 0),c=F(new Date),m=()=>{a!=="downloading"&&(t("downloading"),r(void 0),s.fetchQuery(A()).then(d=>{ae(c,d.document),t("ready")}).catch(d=>{t("failed"),r(d instanceof Error?d.message:"GET /config/export did not answer with a configuration.")}))};return e.jsx(se,{fileName:c,state:a,error:i,onDownload:m,onImport:()=>n("importConfig")})}function ne(){const{surface:s,release:n,currentVersion:a,appliesSchemaMigration:t,onCheck:i,install:r,onDismissResult:c}=D(),[m,d]=h.useState(!1);return s.status!=="ready"?null:e.jsxs(e.Fragment,{children:[e.jsx(ee,{state:s.section,onCheck:i,onInstall:()=>d(!0),onDismissResult:c}),n&&a&&e.jsx(K,{open:m,currentVersion:a,release:n,appliesSchemaMigration:t,onClose:()=>d(!1),onConfirm:()=>{d(!1),r(n.version)}})]})}function ie(){return L().tlsMode!=="internal"?null:e.jsxs("div",{className:"border-t border-line pt-4 mt-4",children:[e.jsx("p",{className:"text-sm font-medium text-fg mb-1",children:"TLS root certificate"}),e.jsx("p",{className:"text-sm text-fg-muted mb-2",children:"This deployment signs its own certificate. Import it into the trust store of each device you browse from, and the browser warning stops for good."}),e.jsx(j,{href:"/tls-root-ca.crt",download:!0,variant:"secondary",size:"sm",icon:e.jsx($,{className:"size-3.5"}),children:"Download root certificate"})]})}function re(s){try{return new Date(s).toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return s}}function le({sha:s=U,commitUrl:n=O,buildTime:a=B}){return e.jsxs("p",{className:"text-xs text-fg-subtle",children:["Version"," ",n?e.jsx("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"font-mono hover:text-fg-muted hover:underline",children:s}):e.jsx("span",{className:"font-mono",children:s})," · ",e.jsxs("span",{children:["Built ",re(a)]})]})}function Re(){const s=E(),[n,a]=h.useState(!0),t=i=>{const r=V[i];r&&s({to:r})};return e.jsxs(Y,{items:_,activeId:"advanced",title:"Advanced",description:"Notification rules, export, and diagnostics.",help:X,helpOpen:n,onToggleHelp:()=>a(i=>!i),onSelect:t,onBackToMail:()=>{s({to:"/mail"})},children:[e.jsx(ne,{}),e.jsx("div",{className:"mt-6 border-t border-line pt-4",children:e.jsx(te,{})}),e.jsx("div",{className:"mt-6 border-t border-line pt-4",children:e.jsx("p",{className:"text-sm text-fg-muted",children:"Notification rules are coming in a future release."})}),e.jsx(ie,{}),e.jsxs("div",{className:"border-t border-line pt-4 mt-4",children:[e.jsx("p",{className:"text-sm font-medium text-fg mb-1",children:"About"}),e.jsx(le,{})]})]})}export{Re as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as x,r as a,
|
|
1
|
+
import{u as x,r as a,b4 as S,j as e,aQ as g,b5 as n,aS as y,b6 as b}from"./index-BDIVfNXM.js";import{S as T}from"./settings-screen-B51b9lvj.js";import{c as v}from"./help-copy-CADUhLzQ.js";import"./avatar-BEy9bmfT.js";import"./chevron-left-iD9K0p2O.js";import"./menu-DQ-pJ4eT.js";import"./circle-help-C0X0r4BQ.js";import"./kbd-BTTdW6-z.js";const o="remit.density";function N(){return typeof localStorage>"u"?"comfortable":localStorage.getItem(o)??"comfortable"}function O(){const s=x(),[i,r]=a.useState(!0),[c,m]=a.useState(N),[p,d]=a.useState(S),h=t=>{m(t),typeof localStorage<"u"&&localStorage.setItem(o,t)},f=t=>{d(t),b(t)},u=t=>{const l=y[t];l&&s({to:l})};return e.jsx(T,{items:g,activeId:"appearance",title:"Appearance",description:"Display density and colour theme — instant-apply.",help:v,helpOpen:i,onToggleHelp:()=>r(t=>!t),onSelect:u,onBackToMail:()=>{s({to:"/mail"})},children:e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-fg",children:"Density"}),e.jsx(n,{name:"density","aria-label":"Density",value:c,onChange:h,options:[{value:"comfortable",label:"Comfortable"},{value:"compact",label:"Compact"}]}),e.jsx("p",{className:"text-xs text-fg-subtle",children:"Controls the spacing of message rows in the mail list."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-fg",children:"Theme"}),e.jsx(n,{name:"theme","aria-label":"Theme",value:p,onChange:f,options:[{value:"system",label:"System"},{value:"light",label:"Light"},{value:"dark",label:"Dark"}]}),e.jsx("p",{className:"text-xs text-fg-subtle",children:"Applies immediately. System default follows your OS preference."})]})]})})}export{O as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,X as h,
|
|
1
|
+
import{j as e,X as h,aC as j,t as o,r as d}from"./index-BDIVfNXM.js";import{A as b}from"./avatar-BEy9bmfT.js";import{M as v}from"./minus-kSr1dVnA.js";import{C as N}from"./clock-BDHe3TX8.js";const g={accepted:"Coming",tentative:"Maybe",declined:"Not coming",noReply:"No reply"},y={accepted:"text-positive",tentative:"text-warning",declined:"text-danger",noReply:"text-fg-subtle"},k={accepted:j,tentative:N,declined:h,noReply:v};function w({rsvp:s,className:t}){const r=k[s];return e.jsxs("span",{className:o("inline-flex items-center gap-1 text-2xs font-medium",y[s],t),children:[e.jsx(r,{className:"size-3"}),g[s]]})}function R({attendee:s,active:t=!1,onActivate:r,contextId:l,touch:m=!1,className:a}){const c=e.jsxs(e.Fragment,{children:[e.jsx(b,{name:s.name,email:s.email,size:"sm"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-sm text-fg",children:s.name}),s.role==="organizer"&&e.jsx("span",{className:"block text-2xs text-fg-subtle",children:"Organiser"})]}),e.jsx(w,{rsvp:s.rsvp})]});return r?e.jsx("button",{type:"button","aria-expanded":t,"aria-controls":t&&l!==void 0?l:void 0,onClick:()=>r(t?"":s.email),onKeyDown:i=>{i.key==="Escape"&&r("")},onBlur:i=>{t&&i.relatedTarget!==null&&(i.currentTarget.parentElement?.contains(i.relatedTarget)||r(""))},className:o("flex w-full items-center gap-2.5 rounded-md px-1.5 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",m?"min-h-11":"min-h-9",t?"bg-accent-2-soft":"hover:bg-surface-sunken",a),children:c}):e.jsx("div",{className:o("flex min-h-9 items-center gap-2.5",a),children:c})}function T({attendees:s,activeEmail:t="",onActivate:r,renderContext:l,touch:m=!1,className:a}){const c=d.useId();if(s.length===0)return null;const i=["accepted","tentative","declined","noReply"].map(n=>({state:n,count:s.filter(p=>p.rsvp===n).length})).filter(n=>n.count>0).map(n=>`${n.count} ${g[n.state].toLowerCase()}`).join(" · ");return e.jsxs("div",{className:o("flex flex-col",a),children:[e.jsx("p",{className:"pb-1 text-2xs uppercase tracking-wider text-fg-subtle",children:`${s.length} guests · ${i}`}),s.map((n,p)=>{const x=n.email===t,u=`${c}-guest-${p}`,f=e.jsx(R,{attendee:n,active:x,onActivate:r,contextId:l?u:void 0,touch:m});return r?e.jsxs("div",{children:[f,x&&l&&e.jsx("div",{id:u,className:"py-1",children:l(n)})]},n.email):e.jsx(d.Fragment,{children:f},n.email)})]})}export{T as A,w as R};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as a,j as h,t as u}from"./index-
|
|
1
|
+
import{r as a,j as h,t as u}from"./index-BDIVfNXM.js";const p={sm:"size-7 text-2xs",md:"size-9 text-sm",lg:"size-11 text-md"},n=["oklch(0.6 0.08 150)","oklch(0.6 0.08 185)","oklch(0.6 0.08 215)","oklch(0.6 0.07 250)","oklch(0.6 0.07 310)","oklch(0.62 0.07 110)"],d="oklch(0.97 0.012 90)";function f(e){const t=e.trim().split(/\s+/).filter(Boolean);return t.length===0?"?":t.length===1?t[0].slice(0,2).toUpperCase():(t[0][0]+t[t.length-1][0]).toUpperCase()}function m({name:e,email:t,size:l="md",className:c}){const i=a.useMemo(()=>{const r=t??e;let s=0;for(let o=0;o<r.length;o++)s=s*31+r.charCodeAt(o)>>>0;return n[s%n.length]},[e,t]);return h.jsx("span",{className:u("inline-flex shrink-0 items-center justify-center rounded-full font-semibold select-none",p[l],c),style:{backgroundColor:i,color:d},"aria-hidden":!0,children:f(e)})}export{m as A};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e}from"./index-
|
|
1
|
+
import{e}from"./index-BDIVfNXM.js";const t=e("BellOff",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742",key:"178tsu"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05",key:"1hqiys"}]]);export{t as B};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{v as N,r as n,w as k,j as a,t as g}from"./index-BDIVfNXM.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,w]=n.useState(T),[m,u]=n.useState(null);k(f,s),n.useLayoutEffect(()=>{const t=b.current;if(!t)return;const e=()=>w(t.offsetHeight);e();const r=new ResizeObserver(e);return r.observe(t),()=>r.disconnect()},[]);const c=n.useRef(null),M=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)},[]),j=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,v=s?m??0:i,d=Math.min(Math.max(1-v/i,0),1),p=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:p.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(${v}px)`,transition:p},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:M,onPointerMove:j,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 +1 @@
|
|
|
1
|
-
import{j as r}from"./index-
|
|
1
|
+
import{j as r}from"./index-BDIVfNXM.js";import{E as t}from"./ErrorState-BVvZa9Hj.js";const i=({error:e,reset:o})=>r.jsx("div",{className:"flex h-full items-center justify-center bg-canvas p-4",children:r.jsx(t,{title:"Couldn't load your mailboxes",error:e,onRetry:o})});export{i as errorComponent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as r,O as i}from"./index-BDIVfNXM.js";import{a as m}from"./MailShell-D1RYjXBs.js";import{B as o}from"./BriefPane-DTnPypWR.js";import{a as p}from"./search-token-index-C1Z6zA5N.js";import{u as e}from"./search-mirror-CJ0qbKsO.js";import"./FullCompose-C-kYe1x_.js";import"./ErrorState-BVvZa9Hj.js";import"./index-DDSpdJ8F.js";import"./useMessageBodyContent-BTmHg9m0.js";import"./useSignature-V-VSVmYl.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-CTq8lKtR.js";import"./sections-FEvJ4c2c.js";import"./confirm-dialog-BmiOsB9N.js";import"./useSearchTokenContext-BYEkwdSc.js";import"./kbd-BTTdW6-z.js";import"./search-scope-UI1H6AzA.js";import"./MailListHeader-qqqmfyRg.js";import"./roving-focus-DyhhSwbQ.js";import"./EmptyState-DCvsovpV.js";import"./popover-menu-BRPef6re.js";import"./mail-bV9GGVUQ.js";import"./avatar-BEy9bmfT.js";import"./undo-2-DkaYLmdO.js";import"./download-53lT8mTP.js";import"./useCalendarFreeBusy-d-s_-0eR.js";import"./calendar-format-BZ1D5Ywu.js";import"./useQueries-DFq_6laq.js";import"./useCalendars-CqOpDn21.js";import"./map-pin-Bme-miZ2.js";import"./useLayoutTier-94OSKAiu.js";import"./calendar-suggestion-DJ5uMZX8.js";import"./attendee-row-D2LMbq_7.js";import"./minus-kSr1dVnA.js";import"./clock-BDHe3TX8.js";import"./calendar-clash-strip-BbznG7yo.js";import"./bell-off-o-5HqpFD.js";import"./shield-check-CgX3iFVl.js";import"./calendar-report-1ttmpioo.js";import"./useFilters-Oiv4LZCZ.js";import"./checkbox-p9mLPjVs.js";import"./menu-DQ-pJ4eT.js";import"./useRefreshControl-DzEBgWRZ.js";import"./circle-check-big-Cc1ertAI.js";import"./refresh-cw-BQa9I63p.js";import"./result-count-C11MdZzg.js";import"./useLabels-DLtLZsv9.js";import"./wizard-selection-zWa1qc6-.js";function or(){const t=p();return e({to:"/mail/brief"}),r.jsx(o,{thread:t,children:r.jsx(m,{phone:r.jsx(o.Phone,{}),list:r.jsx(o.List,{}),reading:r.jsx(i,{}),intelligence:r.jsx(o.Intelligence,{}),hasThread:!!t})})}export{or as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as a}from"./index-
|
|
1
|
+
import{e as a}from"./index-BDIVfNXM.js";const p=a("Bug",[["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}],["path",{d:"M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",key:"xs1cw7"}],["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M17.2 17c2.1.1 3.8 1.9 3.8 4",key:"k3fwyw"}]]);export{p as B};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as g,a as x,b as h,r as i,p as O,c as j,d as y,j as e,O as C}from"./index-BDIVfNXM.js";import{E as N}from"./ErrorState-BVvZa9Hj.js";import{C as P}from"./CalendarShell-CNCnuYI7.js";import{M as E}from"./MailNav-UWoxDID1.js";import{i as S,u as b}from"./useLayoutTier-94OSKAiu.js";import"./roving-focus-DyhhSwbQ.js";import"./bell-off-o-5HqpFD.js";import"./useQueries-DFq_6laq.js";import"./folder-failure-CqkVSsrb.js";import"./outbox-status-BlKn6P0x.js";import"./bug-CiMAHRp3.js";function W(){const t=g(),c=S(b()),a=x(),r=h(),l=a.includes("nav"),n=i.useCallback(v=>{r(O(a,v?"nav":void 0))},[a,r]),{data:o,isLoading:u,isError:p,error:m,refetch:f}=j({...y(),staleTime:1/0}),s=!!(o&&(o.accounts?.length??0)===0);i.useEffect(()=>{s&&t({to:"/onboarding",replace:!0})},[s,t]);const d=o?.accounts??[];return p?e.jsx("div",{className:"flex h-full items-center justify-center bg-canvas p-4",children:e.jsx(N,{title:"Couldn't load your account",error:m,onRetry:()=>{f()}})}):e.jsx(P,{chrome:{isSinglePane:c,isLoading:u||s,nav:e.jsx(E,{accounts:d,onMailboxSelect:()=>n(!1)}),navOpen:l,onOpenNav:()=>n(!0),onCloseNav:()=>n(!1)},children:e.jsx(C,{})})}export{W as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,
|
|
1
|
+
import{j as e,aC as n,t as r,as as d}from"./index-BDIVfNXM.js";function x({clashes:s,clearText:i="Nothing else is booked over it.",className:t}){return s.length===0?e.jsxs("p",{className:r("flex items-center gap-2 rounded-md border border-line bg-surface-sunken p-2 text-xs text-fg-muted",t),children:[e.jsx(n,{className:"size-3.5 shrink-0 text-positive","aria-hidden":!0}),i]}):e.jsxs("div",{className:r("flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft p-2",t),children:[e.jsx(d,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-xs font-semibold text-danger",children:s.length===1?"This clashes with something you have already agreed to.":`This clashes with ${s.length} things you have already agreed to.`}),e.jsx("ul",{className:"mt-1 flex flex-col gap-0.5",children:s.map(a=>e.jsx("li",{className:"text-xs text-fg",children:a.label},a.id))})]})]})}export{x as C};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as A,u as M,r as d,a9 as p,eJ as R,eK as _,bZ as S,w as j,cm as U,eL as I,c as W,eM as T,h as F,s as G}from"./index-Dtovse-L.js";import{u as B}from"./useQueries-DH9StZ-W.js";import{b as Z}from"./useCalendars-O5ZvqPWu.js";const it=A("Repeat",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]]),g=480,m=1320,v=90;function $(t){return Number(t.slice(11,13))*60+Number(t.slice(14,16))}function ut(t){const n=Math.max(0,Math.min(1440,Math.round(t)));return`${String(Math.floor(n/60)).padStart(2,"0")}:${String(n%60).padStart(2,"0")}`}function lt(t){const n=Math.round(t);if(n<60)return`${n}m`;const a=Math.floor(n/60),e=n%60;return e===0?`${a}h`:`${a}h ${e}m`}function O(t,n){const a=new Date(`${t}T00:00:00Z`);return a.setUTCDate(a.getUTCDate()+n),a.toISOString().slice(0,10)}function dt(t,n){return Math.round((Date.parse(`${n}T00:00:00Z`)-Date.parse(`${t}T00:00:00Z`))/864e5)}function ft(t){const n=t.start.slice(0,10),a=t.end.slice(0,10);if(!t.allDay)return a;const e=O(a,-1);return e<n?n:e}function mt(t,n){const a=[];for(let e=t;e<=n;e=O(e,1))a.push(e);return a}function ht(t){const[n,a,e]=t.split("-").map(Number);return new Date(n,a-1,e).toLocaleDateString("en-GB",{month:"long",year:"numeric"})}function pt(t){const[n,a,e]=t.split("-").map(Number);return new Date(n,a-1,e).toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"})}function yt(t){const[n,a,e]=t.split("-").map(Number);return new Date(n,a-1,e).toLocaleDateString("en-GB",{weekday:"long"})}function gt(t,n){const[a,e,o]=t.split("-").map(Number),[r,c,s]=n.split("-").map(Number),u=new Date(a,e-1,o),l=new Date(r,c-1,s),i=u.toLocaleDateString("en-GB",{weekday:"short",day:"numeric",...e===c?{}:{month:"short"}}),w=l.toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"});return`${i} – ${w}`}function P(t){const[n,a,e]=t.split("-").map(Number);return new Date(n,a-1,e).toLocaleDateString("en-GB",{weekday:"short"})}function f(t){return new Date(t).getTime()}function Y(t,n){return t.allDay?n>=t.start.slice(0,10)&&n<t.end.slice(0,10):t.start.slice(0,10)===n}function q(t,n){return f(t.start)<f(n.end)&&f(n.start)<f(t.end)}function K(t){const n=t.map(r=>[f(r.start),f(r.end)]).sort((r,c)=>r[0]-c[0]);let a=0,e=0,o=0;for(const[r,c]of n){if(r>o){a+=o-e,e=r,o=c;continue}o=Math.max(o,c)}return a+=o-e,Math.round(a/6e4)}function Q(t){const n=[];for(const a of t){const e=t.filter(r=>r.id===a.id||q(a,r)).map(r=>r.id).sort();if(e.length<2)continue;const o=e.join("|");n.some(r=>r.join("|")===o)||n.push(e)}return n.filter(a=>!n.some(e=>e!==a&&a.every(o=>e.includes(o))))}function Dt(t,n,a){const e=n.filter(r=>Y(r,t)),o=e.filter(r=>!r.allDay).sort((r,c)=>f(r.start)-f(c.start));return{date:t,weekdayLabel:P(t),dayNumber:Number(t.slice(8)),isToday:t===a,timed:o,allDay:e.filter(r=>r.allDay),busyMinutes:K(o),conflicts:Q(o)}}function H(t){return t.timed.length===0&&t.allDay.length===0}function V(t){return x(t.timed.map(n=>({from:$(n.start),to:$(n.end)})))}function x(t){const n=[...t].sort((e,o)=>e.from-o.from),a=[];for(const e of n){const o=a[a.length-1];if(o&&e.from<=o.to){o.to=Math.max(o.to,e.to);continue}a.push({...e})}return a}function k(t){return Math.min(Math.max(t,g),m)}function z(t,n,a=v){const e=x(n);if(e.length===0)return[{date:t,startMinute:g,endMinute:m,minutes:m-g,wholeDay:!0}];const o=[];let r=g;for(const c of e){const s=k(c.from),u=k(c.to);s-r>=a&&o.push({date:t,startMinute:r,endMinute:s,minutes:s-r,wholeDay:!1}),r=Math.max(r,s,u)}return m-r>=a&&o.push({date:t,startMinute:r,endMinute:m,minutes:m-r,wholeDay:!1}),o}function J(t,n=v){return z(t.date,V(t),n)}function wt(t,n,{ignoreIds:a=[]}={}){const e=Date.parse(t.start),o=Date.parse(t.end);return n.filter(r=>r.allDay||r.myRsvp==="declined"||a.includes(r.id)?!1:Date.parse(r.start)<o&&e<Date.parse(r.end))}function bt(t,n){const a=[];let e=[];const o=()=>{e.length!==0&&(e.length===1?a.push({kind:"day",key:e[0].date,day:e[0]}):a.push({kind:"run",key:`run_${e[0].date}`,from:e[0].date,to:e[e.length-1].date,days:e.length}),e=[])};for(const r of t){if(H(r)&&!n.includes(r.date)){e.push(r);continue}o(),a.push({kind:"day",key:r.date,day:r})}return o(),a}function $t(t){const n=[];for(const a of t){const e=n[n.length-1],o=e?Math.max(...e.map(r=>Date.parse(r.end))):0;if(e&&Date.parse(a.start)<o){e.push(a);continue}n.push([a])}return n}function Mt(t,n){const a=Date.parse(n),e=n.slice(0,10),o=t.flatMap(l=>l.timed).sort((l,i)=>Date.parse(l.start)-Date.parse(i.start)),r=o.filter(l=>Date.parse(l.start)<=a&&Date.parse(l.end)>a),c=o.filter(l=>Date.parse(l.start)>a),s=c[0],u=r.filter(l=>l.start.slice(0,10)===e).length+c.filter(l=>l.start.slice(0,10)===e).length;return{running:r,next:s,minutesUntilNext:s?Math.round((Date.parse(s.start)-a)/6e4):0,after:c[1],restOfDay:u,free:X(t,n,1)[0]}}function X(t,n,a){const e=n.slice(0,10),o=$(n),r=[];for(const c of t)if(!(c.date<e))for(const s of J(c)){if(c.date>e)r.push(s);else{const u=Math.max(s.startMinute,o);if(s.endMinute-u<v)continue;r.push({...s,startMinute:u,minutes:s.endMinute-u,wholeDay:s.wholeDay&&u===s.startMinute})}if(r.length===a)return r}return r}const tt={"cal-1":{solid:"bg-cal-1",soft:"bg-cal-1-soft",text:"text-cal-1",border:"border-cal-1",rail:"border-l-cal-1"},"cal-2":{solid:"bg-cal-2",soft:"bg-cal-2-soft",text:"text-cal-2",border:"border-cal-2",rail:"border-l-cal-2"},"cal-3":{solid:"bg-cal-3",soft:"bg-cal-3-soft",text:"text-cal-3",border:"border-cal-3",rail:"border-l-cal-3"},"cal-4":{solid:"bg-cal-4",soft:"bg-cal-4-soft",text:"text-cal-4",border:"border-cal-4",rail:"border-l-cal-4"},"cal-5":{solid:"bg-cal-5",soft:"bg-cal-5-soft",text:"text-cal-5",border:"border-cal-5",rail:"border-l-cal-5"},"cal-6":{solid:"bg-cal-6",soft:"bg-cal-6-soft",text:"text-cal-6",border:"border-cal-6",rail:"border-l-cal-6"}};function Tt(t){return tt[t]}const y="/calendar/$view/$date",D="/calendar/$view/$date/suggestion/$suggestionId";function et(){const t=p({from:y,shouldThrow:!1}),n=R({from:y,shouldThrow:!1}),a=t?.view??"",e=t?.date??"",o=n?.calendarId;return d.useMemo(()=>({..._({view:a,date:e},S(new Date)),calendarIds:o??[]}),[a,e,o])}function vt(){const t=p({from:"/calendar/$view/$date/$calendarObjectId",shouldThrow:!1}),n=p({from:"/calendar/$view/$date/$calendarObjectId/$recurrenceId",shouldThrow:!1}),a=t?.calendarObjectId,e=n?.recurrenceId;return d.useMemo(()=>a?{calendarObjectId:a,recurrenceId:e}:void 0,[a,e])}function Ct(){return p({from:D,shouldThrow:!1})?.suggestionId}function Et(){const t=p({from:"/calendar/$view/$date/new",shouldThrow:!1}),n=p({from:D,shouldThrow:!1});return t!==void 0||n!==void 0}function kt(){const t=M(),n=j(),a=U(),{view:e,date:o}=et(),r=d.useCallback(s=>{t({to:y,params:s,search:!0,hash:a})},[t,a]),c=d.useCallback(s=>n.buildLocation({to:y,params:{view:"day",date:s},search:!0,hash:a}).href,[n,a]);return d.useMemo(()=>({goToView:s=>r({view:s,date:o}),step:s=>r({view:e,date:I(o,e,s)}),goToToday:()=>r({view:e,date:S(new Date)}),setAnchorDate:s=>t({to:y,params:{view:e,date:s},search:!0,hash:a,replace:!0}),zoomToDay:s=>t({href:c(s)}),dayHref:c,openEvent:(s,u)=>t(u===void 0||u===""?{to:"/calendar/$view/$date/$calendarObjectId",params:{view:e,date:o,calendarObjectId:s},search:!0,hash:a}:{to:"/calendar/$view/$date/$calendarObjectId/$recurrenceId",params:{view:e,date:o,calendarObjectId:s,recurrenceId:u},search:!0,hash:a}),closeEvent:()=>r({view:e,date:o}),openComposer:()=>t({to:"/calendar/$view/$date/new",params:{view:e,date:o},search:!0,hash:a}),changeSuggestionFirst:(s,u)=>t({to:D,params:{view:e,date:u,suggestionId:s},search:!0,hash:a})}),[r,t,c,a,e,o])}function St(){const t=M();return d.useCallback((n,a,e)=>{if(e===""){t({to:"/calendar/$view/$date/$calendarObjectId",params:{view:"day",date:n,calendarObjectId:a}});return}t({to:"/calendar/$view/$date/$calendarObjectId/$recurrenceId",params:{view:"day",date:n,calendarObjectId:a,recurrenceId:e}})},[t])}function It(){const t=M();return d.useCallback((n,a)=>{t({to:D,params:{view:"day",date:n,suggestionId:a}})},[t])}const L=G(400,404),C=5*6e4,E=({from:t,to:n,calendarIds:a})=>({query:a.length===0?{from:t,to:n}:{from:t,to:n,calendarId:[...a]}});function Ot(t){const{data:n,isLoading:a,error:e,refetch:o}=W({...T(E(t)),meta:L,staleTime:C,enabled:t.enabled??!0});return{instances:n?.items??[],isLoading:a,error:e,refetch:()=>{o()}}}function xt(t,n,a){const e=B({queries:t.map(i=>({...T(E({...i,calendarIds:n})),meta:L,staleTime:C,enabled:a}))}),o=t.map(i=>i.from).join("|"),r=e.map(i=>i.data),c=e.map(i=>i.isPending).join("|"),s=e.find(i=>i.error)?.error??null,u=d.useMemo(()=>r.flatMap(i=>i?.items??[]),[o,c]),l=d.useMemo(()=>{const i=new Set;return t.forEach((w,N)=>{e[N]?.isPending&&i.add(w.from)}),i},[o,c]);return{instances:u,pendingWindows:l,error:s,refetch:()=>{for(const i of e)i.error&&i.refetch()}}}function Lt(t,n,a,e){const o=F(),r=[...a].join(",");d.useEffect(()=>{if(!e)return;const c=r===""?[]:r.split(",");for(const s of[-1,1]){const u=Z(t,I(n,t,s));o.prefetchQuery({...T(E({...u,calendarIds:c})),staleTime:C})}},[o,t,n,r,e])}const b=new Intl.DateTimeFormat(void 0,{weekday:"short",day:"numeric",month:"long"}),h=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1}),at=new Intl.DateTimeFormat(void 0,{weekday:"long",day:"numeric",month:"long",timeZone:"UTC"}),nt=new Intl.DateTimeFormat(void 0,{weekday:"short",day:"numeric",month:"long",timeZone:"UTC"});function rt(t){return nt.format(new Date(`${t}T00:00:00Z`))}function Nt(t){if(t.allDay)return`${rt(t.start.slice(0,10))}, all day`;const n=new Date(t.start),a=new Date(t.end),e=b.format(n);return b.format(a)===e?`${e}, ${h.format(n)} – ${h.format(a)}`:`${e}, ${h.format(n)} – ${b.format(a)}, ${h.format(a)}`}function At(t){return at.format(new Date(`${t}T00:00:00Z`))}function Rt(t){return h.format(new Date(`1970-01-01T${t}:00`))}function _t(t){return h.format(new Date(t))}export{x as A,mt as B,C,g as D,z as E,rt as F,Nt as G,Rt as H,Lt as I,dt as J,ft as K,wt as L,Ct as M,it as R,gt as a,bt as b,Tt as c,$ as d,ut as e,J as f,$t as g,V as h,m as i,lt as j,O as k,pt as l,ht as m,kt as n,vt as o,xt as p,Dt as q,Mt as r,Et as s,St as t,et as u,It as v,yt as w,Ot as x,_t as y,At as z};
|
|
1
|
+
import{e as A,u as M,r as d,aa as p,eI as R,eJ as _,c0 as I,y as j,cp as U,eK as S,c as W,eL as T,h as F,s as G}from"./index-BDIVfNXM.js";import{u as B}from"./useQueries-DFq_6laq.js";import{b as P}from"./useCalendars-CqOpDn21.js";const it=A("Repeat",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]]),g=480,m=1320,v=90;function $(t){return Number(t.slice(11,13))*60+Number(t.slice(14,16))}function ut(t){const n=Math.max(0,Math.min(1440,Math.round(t)));return`${String(Math.floor(n/60)).padStart(2,"0")}:${String(n%60).padStart(2,"0")}`}function lt(t){const n=Math.round(t);if(n<60)return`${n}m`;const a=Math.floor(n/60),e=n%60;return e===0?`${a}h`:`${a}h ${e}m`}function O(t,n){const a=new Date(`${t}T00:00:00Z`);return a.setUTCDate(a.getUTCDate()+n),a.toISOString().slice(0,10)}function dt(t,n){return Math.round((Date.parse(`${n}T00:00:00Z`)-Date.parse(`${t}T00:00:00Z`))/864e5)}function ft(t){const n=t.start.slice(0,10),a=t.end.slice(0,10);if(!t.allDay)return a;const e=O(a,-1);return e<n?n:e}function mt(t,n){const a=[];for(let e=t;e<=n;e=O(e,1))a.push(e);return a}function ht(t){const[n,a,e]=t.split("-").map(Number);return new Date(n,a-1,e).toLocaleDateString("en-GB",{month:"long",year:"numeric"})}function pt(t){const[n,a,e]=t.split("-").map(Number);return new Date(n,a-1,e).toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"})}function yt(t){const[n,a,e]=t.split("-").map(Number);return new Date(n,a-1,e).toLocaleDateString("en-GB",{weekday:"long"})}function gt(t,n){const[a,e,o]=t.split("-").map(Number),[r,c,s]=n.split("-").map(Number),u=new Date(a,e-1,o),l=new Date(r,c-1,s),i=u.toLocaleDateString("en-GB",{weekday:"short",day:"numeric",...e===c?{}:{month:"short"}}),w=l.toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"});return`${i} – ${w}`}function Y(t){const[n,a,e]=t.split("-").map(Number);return new Date(n,a-1,e).toLocaleDateString("en-GB",{weekday:"short"})}function f(t){return new Date(t).getTime()}function Z(t,n){return t.allDay?n>=t.start.slice(0,10)&&n<t.end.slice(0,10):t.start.slice(0,10)===n}function q(t,n){return f(t.start)<f(n.end)&&f(n.start)<f(t.end)}function K(t){const n=t.map(r=>[f(r.start),f(r.end)]).sort((r,c)=>r[0]-c[0]);let a=0,e=0,o=0;for(const[r,c]of n){if(r>o){a+=o-e,e=r,o=c;continue}o=Math.max(o,c)}return a+=o-e,Math.round(a/6e4)}function Q(t){const n=[];for(const a of t){const e=t.filter(r=>r.id===a.id||q(a,r)).map(r=>r.id).sort();if(e.length<2)continue;const o=e.join("|");n.some(r=>r.join("|")===o)||n.push(e)}return n.filter(a=>!n.some(e=>e!==a&&a.every(o=>e.includes(o))))}function Dt(t,n,a){const e=n.filter(r=>Z(r,t)),o=e.filter(r=>!r.allDay).sort((r,c)=>f(r.start)-f(c.start));return{date:t,weekdayLabel:Y(t),dayNumber:Number(t.slice(8)),isToday:t===a,timed:o,allDay:e.filter(r=>r.allDay),busyMinutes:K(o),conflicts:Q(o)}}function H(t){return t.timed.length===0&&t.allDay.length===0}function V(t){return x(t.timed.map(n=>({from:$(n.start),to:$(n.end)})))}function x(t){const n=[...t].sort((e,o)=>e.from-o.from),a=[];for(const e of n){const o=a[a.length-1];if(o&&e.from<=o.to){o.to=Math.max(o.to,e.to);continue}a.push({...e})}return a}function k(t){return Math.min(Math.max(t,g),m)}function z(t,n,a=v){const e=x(n);if(e.length===0)return[{date:t,startMinute:g,endMinute:m,minutes:m-g,wholeDay:!0}];const o=[];let r=g;for(const c of e){const s=k(c.from),u=k(c.to);s-r>=a&&o.push({date:t,startMinute:r,endMinute:s,minutes:s-r,wholeDay:!1}),r=Math.max(r,s,u)}return m-r>=a&&o.push({date:t,startMinute:r,endMinute:m,minutes:m-r,wholeDay:!1}),o}function J(t,n=v){return z(t.date,V(t),n)}function wt(t,n,{ignoreIds:a=[]}={}){const e=Date.parse(t.start),o=Date.parse(t.end);return n.filter(r=>r.allDay||r.myRsvp==="declined"||a.includes(r.id)?!1:Date.parse(r.start)<o&&e<Date.parse(r.end))}function bt(t,n){const a=[];let e=[];const o=()=>{e.length!==0&&(e.length===1?a.push({kind:"day",key:e[0].date,day:e[0]}):a.push({kind:"run",key:`run_${e[0].date}`,from:e[0].date,to:e[e.length-1].date,days:e.length}),e=[])};for(const r of t){if(H(r)&&!n.includes(r.date)){e.push(r);continue}o(),a.push({kind:"day",key:r.date,day:r})}return o(),a}function $t(t){const n=[];for(const a of t){const e=n[n.length-1],o=e?Math.max(...e.map(r=>Date.parse(r.end))):0;if(e&&Date.parse(a.start)<o){e.push(a);continue}n.push([a])}return n}function Mt(t,n){const a=Date.parse(n),e=n.slice(0,10),o=t.flatMap(l=>l.timed).sort((l,i)=>Date.parse(l.start)-Date.parse(i.start)),r=o.filter(l=>Date.parse(l.start)<=a&&Date.parse(l.end)>a),c=o.filter(l=>Date.parse(l.start)>a),s=c[0],u=r.filter(l=>l.start.slice(0,10)===e).length+c.filter(l=>l.start.slice(0,10)===e).length;return{running:r,next:s,minutesUntilNext:s?Math.round((Date.parse(s.start)-a)/6e4):0,after:c[1],restOfDay:u,free:X(t,n,1)[0]}}function X(t,n,a){const e=n.slice(0,10),o=$(n),r=[];for(const c of t)if(!(c.date<e))for(const s of J(c)){if(c.date>e)r.push(s);else{const u=Math.max(s.startMinute,o);if(s.endMinute-u<v)continue;r.push({...s,startMinute:u,minutes:s.endMinute-u,wholeDay:s.wholeDay&&u===s.startMinute})}if(r.length===a)return r}return r}const tt={"cal-1":{solid:"bg-cal-1",soft:"bg-cal-1-soft",text:"text-cal-1",border:"border-cal-1",rail:"border-l-cal-1"},"cal-2":{solid:"bg-cal-2",soft:"bg-cal-2-soft",text:"text-cal-2",border:"border-cal-2",rail:"border-l-cal-2"},"cal-3":{solid:"bg-cal-3",soft:"bg-cal-3-soft",text:"text-cal-3",border:"border-cal-3",rail:"border-l-cal-3"},"cal-4":{solid:"bg-cal-4",soft:"bg-cal-4-soft",text:"text-cal-4",border:"border-cal-4",rail:"border-l-cal-4"},"cal-5":{solid:"bg-cal-5",soft:"bg-cal-5-soft",text:"text-cal-5",border:"border-cal-5",rail:"border-l-cal-5"},"cal-6":{solid:"bg-cal-6",soft:"bg-cal-6-soft",text:"text-cal-6",border:"border-cal-6",rail:"border-l-cal-6"}};function Tt(t){return tt[t]}const y="/calendar/$view/$date",D="/calendar/$view/$date/suggestion/$suggestionId";function et(){const t=p({from:y,shouldThrow:!1}),n=R({from:y,shouldThrow:!1}),a=t?.view??"",e=t?.date??"",o=n?.calendarId;return d.useMemo(()=>({..._({view:a,date:e},I(new Date)),calendarIds:o??[]}),[a,e,o])}function vt(){const t=p({from:"/calendar/$view/$date/$calendarObjectId",shouldThrow:!1}),n=p({from:"/calendar/$view/$date/$calendarObjectId/$recurrenceId",shouldThrow:!1}),a=t?.calendarObjectId,e=n?.recurrenceId;return d.useMemo(()=>a?{calendarObjectId:a,recurrenceId:e}:void 0,[a,e])}function Ct(){return p({from:D,shouldThrow:!1})?.suggestionId}function Et(){const t=p({from:"/calendar/$view/$date/new",shouldThrow:!1}),n=p({from:D,shouldThrow:!1});return t!==void 0||n!==void 0}function kt(){const t=M(),n=j(),a=U(),{view:e,date:o}=et(),r=d.useCallback(s=>{t({to:y,params:s,search:!0,hash:a})},[t,a]),c=d.useCallback(s=>n.buildLocation({to:y,params:{view:"day",date:s},search:!0,hash:a}).href,[n,a]);return d.useMemo(()=>({goToView:s=>r({view:s,date:o}),step:s=>r({view:e,date:S(o,e,s)}),goToToday:()=>r({view:e,date:I(new Date)}),setAnchorDate:s=>t({to:y,params:{view:e,date:s},search:!0,hash:a,replace:!0}),zoomToDay:s=>t({href:c(s)}),dayHref:c,openEvent:(s,u)=>t(u===void 0||u===""?{to:"/calendar/$view/$date/$calendarObjectId",params:{view:e,date:o,calendarObjectId:s},search:!0,hash:a}:{to:"/calendar/$view/$date/$calendarObjectId/$recurrenceId",params:{view:e,date:o,calendarObjectId:s,recurrenceId:u},search:!0,hash:a}),closeEvent:()=>r({view:e,date:o}),openComposer:()=>t({to:"/calendar/$view/$date/new",params:{view:e,date:o},search:!0,hash:a}),changeSuggestionFirst:(s,u)=>t({to:D,params:{view:e,date:u,suggestionId:s},search:!0,hash:a})}),[r,t,c,a,e,o])}function It(){const t=M();return d.useCallback((n,a,e)=>{if(e===""){t({to:"/calendar/$view/$date/$calendarObjectId",params:{view:"day",date:n,calendarObjectId:a}});return}t({to:"/calendar/$view/$date/$calendarObjectId/$recurrenceId",params:{view:"day",date:n,calendarObjectId:a,recurrenceId:e}})},[t])}function St(){const t=M();return d.useCallback((n,a)=>{t({to:D,params:{view:"day",date:n,suggestionId:a}})},[t])}const L=G(400,404),C=5*6e4,E=({from:t,to:n,calendarIds:a})=>({query:a.length===0?{from:t,to:n}:{from:t,to:n,calendarId:[...a]}});function Ot(t){const{data:n,isLoading:a,error:e,refetch:o}=W({...T(E(t)),meta:L,staleTime:C,enabled:t.enabled??!0});return{instances:n?.items??[],isLoading:a,error:e,refetch:()=>{o()}}}function xt(t,n,a){const e=B({queries:t.map(i=>({...T(E({...i,calendarIds:n})),meta:L,staleTime:C,enabled:a}))}),o=t.map(i=>i.from).join("|"),r=e.map(i=>i.data),c=e.map(i=>i.isPending).join("|"),s=e.find(i=>i.error)?.error??null,u=d.useMemo(()=>r.flatMap(i=>i?.items??[]),[o,c]),l=d.useMemo(()=>{const i=new Set;return t.forEach((w,N)=>{e[N]?.isPending&&i.add(w.from)}),i},[o,c]);return{instances:u,pendingWindows:l,error:s,refetch:()=>{for(const i of e)i.error&&i.refetch()}}}function Lt(t,n,a,e){const o=F(),r=[...a].join(",");d.useEffect(()=>{if(!e)return;const c=r===""?[]:r.split(",");for(const s of[-1,1]){const u=P(t,S(n,t,s));o.prefetchQuery({...T(E({...u,calendarIds:c})),staleTime:C})}},[o,t,n,r,e])}const b=new Intl.DateTimeFormat(void 0,{weekday:"short",day:"numeric",month:"long"}),h=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1}),at=new Intl.DateTimeFormat(void 0,{weekday:"long",day:"numeric",month:"long",timeZone:"UTC"}),nt=new Intl.DateTimeFormat(void 0,{weekday:"short",day:"numeric",month:"long",timeZone:"UTC"});function rt(t){return nt.format(new Date(`${t}T00:00:00Z`))}function Nt(t){if(t.allDay)return`${rt(t.start.slice(0,10))}, all day`;const n=new Date(t.start),a=new Date(t.end),e=b.format(n);return b.format(a)===e?`${e}, ${h.format(n)} – ${h.format(a)}`:`${e}, ${h.format(n)} – ${b.format(a)}, ${h.format(a)}`}function At(t){return at.format(new Date(`${t}T00:00:00Z`))}function Rt(t){return h.format(new Date(`1970-01-01T${t}:00`))}function _t(t){return h.format(new Date(t))}export{x as A,mt as B,C,g as D,z as E,rt as F,Nt as G,Rt as H,Lt as I,dt as J,ft as K,wt as L,Ct as M,it as R,gt as a,bt as b,Tt as c,$ as d,ut as e,J as f,$t as g,V as h,m as i,lt as j,O as k,pt as l,ht as m,kt as n,vt as o,xt as p,Dt as q,Mt as r,Et as s,It as t,et as u,St as v,yt as w,Ot as x,_t as y,At as z};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{aI as r,aJ as t}from"./index-BDIVfNXM.js";function n(e){return r(t({title:`Calendar invitation: ${e}`,errorMessage:e}))}function o(e){return r(t({title:`Calendar event: ${e}`,errorMessage:e}))}export{o as a,n as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as g,
|
|
1
|
+
import{j as g,as as z,t as F,c0 as D,c as O,eM as _,h as j,r as l,i as v,eN as $,eO as B,eP as U,eQ as q,s as G,eR as W,eS as Q}from"./index-BDIVfNXM.js";import{f as K}from"./ErrorState-BVvZa9Hj.js";import{A as Z,B as Y,E as N,y as w,F as b,G as H,e as I,H as T,z as J}from"./calendar-format-BZ1D5Ywu.js";import{e as c,b as k}from"./useCalendars-CqOpDn21.js";function De({text:e,reportHref:t,className:n}){return g.jsxs("div",{role:"alert",className:F("flex items-start gap-1.5 rounded-md border border-danger/40 bg-danger-soft p-2 text-xs text-danger",n),children:[g.jsx(z,{className:"mt-0.5 size-3.5 shrink-0","aria-hidden":!0}),g.jsxs("p",{className:"min-w-0 flex-1",children:[e,t&&g.jsxs(g.Fragment,{children:[" ",g.jsx("a",{href:t,target:"_blank",rel:"noreferrer",className:"font-medium text-accent hover:underline",children:"Report an issue"})]})]})]})}const V=24,R=7,X=52,A=X*7,ee=e=>({from:c(e,-10),to:c(e,V),floor:c(e,-A),ceiling:c(e,A)}),te=e=>e.from<=e.floor,ne=e=>e.to>=e.ceiling,ae=(e,t)=>e>t?e:t,se=(e,t)=>e<t?e:t,re=e=>te(e)?e:{...e,from:ae(c(e.from,-R),e.floor)},ie=e=>ne(e)?e:{...e,to:se(c(e.to,R),e.ceiling)},Ae=e=>re({...e,floor:c(e.from,-A)}),be=e=>ie({...e,ceiling:c(e.to,A)});function Oe(e,t){return t>=e.from&&t<=e.to?e:ee(t)}function we(e){const t=new Map;for(const n of e){const a=k("week",n);t.has(a.from)||t.set(a.from,a)}return[...t.values()]}const Ie=e=>k("week",e).from,oe=1440,M=e=>e.getHours()*60+e.getMinutes();function L(e,t){const n=new Set(e),a=new Map;for(const s of t){const r=new Date(s.start),d=new Date(s.end);if(Number.isNaN(r.getTime())||Number.isNaN(d.getTime())||d.getTime()<=r.getTime())continue;const h=D(r),C=D(new Date(d.getTime()-1));for(let o=h;o<=C;o=c(o,1)){if(!n.has(o))continue;const m=o===h?M(r):0,p=D(d)===o?M(d):oe;if(p<=m)continue;const i=a.get(o);i?i.push({from:m,to:p}):a.set(o,[{from:m,to:p}])}}for(const[s,r]of a)a.set(s,Z(r));return a}function Te(e,t){const n=L(e,t);return new Map(e.map(a=>[a,N(a,n.get(a)??[])]))}const Me=e=>Y(e.from,e.to),f=G(400,404),ce=new Set(["calendarSuggestionOperationsListCalendarSuggestions","messageCalendarSuggestionOperationsListMessageCalendarSuggestions","calendarEventOperationsListCalendarEvents","calendarEventDetailOperationsGetCalendarEvent","calendarFreeBusyOperationsListCalendarFreeBusy","filterOperationsListFilters"]),de=e=>e.invalidateQueries({predicate:t=>{const n=t.queryKey[0];if(typeof n!="object"||n===null)return!1;const a=n._id;return typeof a=="string"&&ce.has(a)}});function Ne(e){const{data:t,isLoading:n,error:a}=O({..._({path:{messageId:e}}),meta:f});return{suggestions:t?.items??[],isLoading:n,error:a??null}}function ke(){const{data:e,isLoading:t,error:n}=O({...W({query:{state:"Pending"}}),meta:f});return{suggestions:e?.items??[],isLoading:t,error:n??null}}const le=async(e,t)=>{let n;do{const{data:a}=await Q({query:{state:"Pending",continuationToken:n},signal:t,throwOnError:!0}),s=a.items.find(r=>r.suggestionId===e);if(s)return s;n=a.continuationToken}while(n);return null};function Re(e){const{data:t,isLoading:n,error:a}=O({queryKey:[{_id:"calendarSuggestionOperationsListCalendarSuggestions",suggestionId:e}],queryFn:({signal:s})=>le(e,s),meta:f});return{suggestion:t,isLoading:n,error:a??null}}const S={kind:"answered"},y=e=>({kind:"refused",message:K(e)});function Le(){const e=j(),t=l.useCallback(()=>de(e),[e]),n=v({...$(),meta:f,onSuccess:t}),a=v({...B(),meta:f,onSuccess:t}),s=v({...U(),meta:f,onSuccess:t}),r=v({...q(),meta:f,onSuccess:t}),d=l.useCallback((i,u)=>n.mutateAsync({path:{suggestionId:i},body:{calendarId:u}}).then(()=>S).catch(y),[n]),h=l.useCallback((i,u)=>n.mutateAsync({path:{suggestionId:i},body:{calendarId:u,answer:"Tentative"}}).then(()=>S).catch(y),[n]),C=l.useCallback((i,u)=>n.mutateAsync({path:{suggestionId:i},body:u}).then(()=>S).catch(y),[n]),o=l.useCallback(i=>a.mutateAsync({path:{suggestionId:i}}).then(()=>S).catch(y),[a]),m=l.useCallback((i,u)=>s.mutateAsync({path:{suggestionId:i},body:{muteSender:u}}).then(()=>S).catch(y),[s]),p=l.useCallback(i=>r.mutateAsync({path:{suggestionId:i}}).then(()=>S).catch(y),[r]);return l.useMemo(()=>({accept:d,tentative:h,acceptEdited:C,decline:o,dismiss:m,reopen:p,isAnswering:n.isPending||a.isPending||s.isPending||r.isPending}),[d,h,C,o,m,p,n.isPending,a.isPending,s.isPending,r.isPending])}const E=30,ue=6,P={Local:"local",Explicit:"explicit",Ambiguous:"ambiguous"},fe="The invitation's time zone could not be resolved. Add opens the editor so you can set the time.",me="The invitation's time zone could not be resolved.";function Pe(e){return e.method==="Cancel"?e.state==="Pending"?{state:"cancelled",rsvp:"noReply"}:void 0:e.state==="Dismissed"?{state:"dismissed",rsvp:"noReply"}:e.state==="Superseded"?{state:"superseded",rsvp:"noReply"}:e.state==="Accepted"?{state:"answered",rsvp:"accepted"}:e.state==="Declined"?{state:"answered",rsvp:"declined"}:e.state==="Tentative"?{state:"answered",rsvp:"tentative"}:{state:"pending",rsvp:"noReply"}}const pe=e=>e.source!=="TextHeuristic";function xe(e){return e.allDay?e.dtStart.slice(0,10):D(new Date(e.dtStart))}const x=e=>e.summary===""?"Untitled event":e.summary;function ze(e){if(e.allDay){const t=e.dtStart.slice(0,10),n=e.dtEnd.slice(0,10),a=n>t?c(n,-1):t;return a===t?`${b(t)}, all day`:`${b(t)} – ${b(a)}, all day`}return H({start:e.dtStart,end:e.dtEnd,allDay:e.allDay})}function ge(e,t){return{id:e.suggestionId,calendarId:t.calendarId,title:x(e),start:e.dtStart,end:e.dtEnd,allDay:e.allDay,location:e.location,notes:"",attendees:[],myRsvp:"noReply",threadId:t.threadId,threadSubject:t.threadSubject,timeZone:"",zoneCertainty:P[e.zoneCertainty],recurrenceRule:"",seriesId:"",seriesException:!1,status:"confirmed"}}function Fe(e,t,n){const a=e.organizer===""?n.senderName:e.organizer;return{id:e.suggestionId,threadId:n.threadId,proposed:ge(e,n),organizerName:a===""?"The sender":a,organizerEmail:e.organizer,method:"ics",evidence:"",state:t,sequence:e.sequence}}function Se(e){return e.zoneCertainty!=="Ambiguous"?"":e.method==="Cancel"?me:fe}function _e(e,t){return{id:e.suggestionId,title:x(e),start:e.dtStart,end:e.dtEnd,allDay:e.allDay,location:e.location,threadId:t.threadId,threadSubject:t.threadSubject,sender:t.sender,senderAddress:e.organizer,confidence:pe(e)?1:.6,ambiguity:Se(e),suggestedCalendarId:t.calendarId,timeZone:"",zoneCertainty:P[e.zoneCertainty]}}const ye=(e,t)=>Date.parse(t.start)<Date.parse(e.end)&&Date.parse(t.end)>Date.parse(e.start);function je(e,t){return t.filter(n=>ye(e,n)).map(n=>({id:`${n.start}/${n.end}`,label:`Busy ${w(n.start)} – ${w(n.end)}`}))}function $e(e,t){const n=L([e],t).get(e)??[],a=[];for(const s of N(e,n,E))for(let r=s.startMinute;r+E<=s.endMinute&&a.length<ue;r+=E)a.push({date:e,endDate:e,startTime:I(r),endTime:I(r+E),allDay:!1});return a}function Be(e,t,n){const a=t.filter(s=>n.includes(s.startTime)).map(s=>`${T(s.startTime)} – ${T(s.endTime)}`);return`${J(e)}: ${a.join(", ")}`}export{De as C,Oe as a,Ie as b,ie as c,Me as d,re as e,Te as f,be as g,ne as h,te as i,Le as j,xe as k,Ae as l,Ne as m,pe as n,Pe as o,je as p,Fe as q,ee as r,ze as s,_e as t,ke as u,$e as v,we as w,Be as x,Re as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as k,h as z,r,bb as $,i as y,bc as _,bd as H,be as X,s as A,j as e,ay as q,az as N,B as j,f,aQ as J,a3 as G,g as Q,bf as M,aB as Y,bg as ee,c as se,bh as ae,aJ as L,bi as te,bj as ne,bk as re,u as ie,aP as de,aR as oe}from"./index-Dtovse-L.js";import{S as le}from"./settings-screen-Bm-R0ESO.js";import{C as P,a as D,b as R,c as O}from"./card-Bqz6khhJ.js";import{U as S,u as ce}from"./useCalendars-O5ZvqPWu.js";import{C as B}from"./confirm-dialog-WrJoQuYb.js";import{f as w,E as ue}from"./ErrorState-PNI7QSLU.js";import{R as me}from"./refresh-cw-DV6lCoUu.js";import{C as he}from"./copy-BVqTKL-m.js";import{u as V}from"./useCalendarWrites-OAZeHI6o.js";import{s as pe}from"./calendar-subscription-B-aAc2Gy.js";import"./avatar-CCaAcetc.js";import"./chevron-left-DV5pp97l.js";import"./menu-Bk7fxS2w.js";import"./circle-help--jGrrMan.js";const xe=k("CalendarPlus",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 13V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8",key:"3spt84"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M16 19h6",key:"xwg31i"}],["path",{d:"M19 16v6",key:"tddt3s"}]]);const be=k("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);const ge=k("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=k("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const ve=k("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]),T=A(400,404),I={kind:"written"},F=s=>({kind:"refused",message:w(s)});function W(){const s=z(),n=V(),t=r.useCallback(()=>s.invalidateQueries({queryKey:$()}),[s]),a=r.useCallback(()=>(n(),t()),[n,t]),i=y({..._(),meta:T,onSuccess:t}),d=y({...H(),meta:T,onSuccess:a}),o=y({...X(),meta:T,onSuccess:a}),l=r.useCallback(c=>i.mutateAsync({body:c}).then(()=>I).catch(F),[i]),m=r.useCallback((c,x)=>d.mutateAsync({path:{calendarId:c},body:x}).then(()=>I).catch(F),[d]),h=r.useCallback(c=>o.mutateAsync({path:{calendarId:c}}).then(()=>I).catch(F),[o]);return r.useMemo(()=>({createCalendar:l,updateCalendar:m,deleteCalendar:h,isWriting:i.isPending||d.isPending||o.isPending}),[l,m,h,i.isPending,d.isPending,o.isPending])}const E=Intl.supportedValuesOf("timeZone");function K({id:s,value:n,disabled:t,onChange:a}){const i=n===S||E.includes(n)?E:[n,...E];return e.jsxs(q,{id:s,value:n,disabled:t,onChange:d=>a(d.target.value),children:[e.jsx("option",{value:S,children:"None (read as UTC)"}),i.map(d=>e.jsx("option",{value:d,children:d},d))]})}const ye=s=>({title:`Delete ${s}?`,description:`This removes ${s} and every event in it, and any subscription address stops working. It cannot be undone.`}),je=s=>s.normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,64);function Ce({isBusy:s,problem:n,onCreate:t}){const[a,i]=r.useState(""),[d,o]=r.useState(void 0),[l,m]=r.useState(S),h=r.useId(),c=r.useId(),x=r.useId(),u=r.useId(),p=d??je(a),b=a.trim()!==""&&p.trim()!=="";return e.jsxs(P,{className:"max-w-xl",role:"region","aria-labelledby":h,children:[e.jsx(D,{children:e.jsx(R,{id:h,children:"New calendar"})}),e.jsx(O,{children:e.jsxs("form",{className:"space-y-3",onSubmit:g=>{g.preventDefault(),b&&t({displayName:a.trim(),urlSegment:p.trim(),timezone:l}).then(v=>{v&&(i(""),o(void 0),m(S))})},children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:c,className:"text-xs font-medium text-fg-muted",children:"Name"}),e.jsx(N,{id:c,value:a,maxLength:140,disabled:s,onChange:g=>i(g.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:x,className:"text-xs font-medium text-fg-muted",children:"Address"}),e.jsx(N,{id:x,value:p,maxLength:64,disabled:s,onChange:g=>o(g.target.value)})]}),e.jsxs("div",{className:"space-y-1 sm:col-span-2",children:[e.jsx("label",{htmlFor:u,className:"text-xs font-medium text-fg-muted",children:"Time zone"}),e.jsx(K,{id:u,value:l,disabled:s,onChange:m})]})]}),e.jsx("p",{className:"text-xs text-fg-muted",children:"The address names the calendar for CalDAV clients and cannot be changed later. The name and zone can."}),n!==""&&e.jsxs(j,{tone:"danger",variant:"soft",children:[e.jsx("p",{className:"font-medium",children:"The calendar was not added."}),e.jsx("p",{className:"mt-0.5 break-words",children:n})]}),e.jsx(f,{type:"submit",variant:"primary",size:"sm",disabled:s||!b,icon:e.jsx(J,{className:"size-3.5"}),children:s?"Adding…":"Add calendar"})]})})]})}function Ne({calendarName:s,timezone:n,isBusy:t,problem:a,onSave:i,onDelete:d}){const[o,l]=r.useState(s),[m,h]=r.useState(n),[c,x]=r.useState(!1),u=r.useId(),p=r.useId(),b=o.trim(),g=b!==s||m!==n,v=ye(s);return e.jsxs(e.Fragment,{children:[e.jsxs("form",{className:"space-y-3",onSubmit:C=>{C.preventDefault(),!(!g||b==="")&&i({displayName:b,timezone:m})},children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:u,className:"text-xs font-medium text-fg-muted",children:"Name"}),e.jsx(N,{id:u,value:o,maxLength:140,disabled:t,onChange:C=>l(C.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:p,className:"text-xs font-medium text-fg-muted",children:"Time zone"}),e.jsx(K,{id:p,value:m,disabled:t,onChange:h})]})]}),a!==""&&e.jsxs(j,{tone:"danger",variant:"soft",children:[e.jsxs("p",{className:"font-medium",children:[s," was not changed."]}),e.jsx("p",{className:"mt-0.5 break-words",children:a})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(f,{type:"submit",variant:"secondary",size:"sm",disabled:t||!g||b==="",icon:e.jsx(ve,{className:"size-3.5"}),children:"Save changes"}),e.jsx(f,{type:"button",variant:"danger",size:"sm",disabled:t,icon:e.jsx(G,{className:"size-3.5"}),onClick:()=>x(!0),children:"Delete calendar"})]})]}),e.jsx(B,{isOpen:c,title:v.title,description:v.description,confirmLabel:"Delete calendar",destructive:!0,onConfirm:()=>{x(!1),d()},onCancel:()=>x(!1)})]})}const ke=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."}),Se=s=>({title:`Stop sharing ${s}?`,description:"The address stops working immediately and every client subscribed to it stops updating. Sharing again mints a different address."});function we({calendarName:s,url:n,onDismiss:t}){const[a,i]=r.useState(!1),[d,o]=r.useState(!1),l=r.useRef(0);r.useEffect(()=>()=>window.clearTimeout(l.current),[]);const m=()=>{navigator.clipboard.writeText(n).then(()=>{o(!1),i(!0),l.current=window.setTimeout(()=>i(!1),2e3)}).catch(()=>o(!0))};return e.jsxs("div",{className:"mt-3 space-y-2 rounded-sm border border-accent-2/40 bg-accent-2/10 px-3 py-2.5",children:[e.jsx("p",{className:"text-sm font-medium text-fg",children:"Subscribe with this address. It is shown once and cannot be read back."}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsx("input",{readOnly:!0,value:n,"aria-label":`Subscription address for ${s}`,onFocus:h=>h.currentTarget.select(),className:"min-w-0 flex-1 rounded-sm border border-line bg-surface px-2 py-1.5 font-mono text-xs text-fg"}),e.jsx(f,{variant:"primary",size:"sm",icon:a?e.jsx(Y,{className:"size-3.5"}):e.jsx(he,{className:"size-3.5"}),onClick:m,children:a?"Copied":"Copy address"})]}),d&&e.jsx(j,{tone:"warning",variant:"soft",children:"The address could not be copied to the clipboard. Select it above and copy it by hand before leaving this page."}),e.jsx("p",{className:"text-xs text-fg-muted",children:"Anyone holding this address can read every event in this calendar, without signing in. Rotate it if it reaches the wrong person."}),e.jsx(f,{variant:"ghost",size:"sm",onClick:t,children:"I've saved it"})]})}function Te({createdAt:s,rotatedAt:n,isBusy:t,onRotate:a,onRevoke:i}){return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Q,{tone:"positive",children:"shared"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:["Address created ",M(s,"medium"),n>0?`, last replaced ${M(n,"medium")}`:""]})]}),e.jsx("p",{className:"text-sm text-fg-muted",children:"The address itself is not stored in readable form, so it cannot be shown again. Replace it if you no longer know where it went."}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(f,{variant:"secondary",size:"sm",disabled:t,icon:e.jsx(me,{className:"size-3.5"}),onClick:a,children:"Replace address"}),e.jsx(f,{variant:"danger",size:"sm",disabled:t,icon:e.jsx(G,{className:"size-3.5"}),onClick:i,children:"Stop sharing"})]})]})}function Ie({calendarName:s,details:n,state:t,mintedUrl:a,isBusy:i,actionError:d,onMint:o,onRevoke:l,onDismissMinted:m,onRetry:h}){const[c,x]=r.useState("none"),u=r.useId(),p=()=>{const g=c;x("none"),g==="rotate"&&o(),g==="revoke"&&l()},b=c==="revoke"?Se(s):ke(s);return e.jsxs(P,{className:"max-w-xl",role:"region","aria-labelledby":u,children:[e.jsx(D,{children:e.jsx(R,{id:u,children:s})}),e.jsxs(O,{children:[n&&e.jsx("div",{className:"mb-4 border-b border-line pb-4",children:n}),t.status==="loading"&&a===""&&e.jsx("div",{className:"h-12 animate-pulse rounded-sm bg-surface-sunken","aria-busy":"true","aria-label":`Loading the subscription address for ${s}`}),t.status==="unreadable"&&a===""&&e.jsx(ue,{variant:"inline",title:`Couldn't read whether ${s} is shared`,error:t.error,onRetry:h}),t.status==="absent"&&a===""&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-fg-muted",children:"Give this calendar a secret address and Apple Calendar, Google Calendar, Outlook and Thunderbird can subscribe to it read-only. Nobody signs in — the address is the credential, so treat it like a password."}),e.jsx(f,{variant:"primary",size:"sm",disabled:i,icon:e.jsx(be,{className:"size-3.5"}),onClick:o,children:i?"Creating…":"Create subscription address"})]}),t.status==="active"&&e.jsx(Te,{createdAt:t.createdAt,rotatedAt:t.rotatedAt,isBusy:i,onRotate:()=>x("rotate"),onRevoke:()=>x("revoke")}),d!=null&&e.jsxs(j,{tone:"danger",variant:"soft",className:"mt-3",children:[e.jsxs("p",{className:"font-medium",children:["The subscription address for ",s," was not changed."]}),e.jsx("p",{className:"mt-0.5 break-words",children:w(d)})]}),a!==""&&e.jsx(we,{calendarName:s,url:a,onDismiss:m})]}),e.jsx(B,{isOpen:c!=="none",title:b.title,description:b.description,confirmLabel:c==="revoke"?"Stop sharing":"Replace address",destructive:!0,onConfirm:p,onCancel:()=>x("none")})]})}const Fe="/feeds/calendar/",Ee=".ics",Me=(s,n)=>`webcal://${s}${Fe}${n}${Ee}`;function ze(s){const n=z(),[t,a]=r.useState(""),i=ee({path:{calendarId:s}}),d=se({...ae({path:{calendarId:s}}),meta:A(404,403),retry:!1}),o=()=>{n.invalidateQueries({queryKey:i})},l=r.useRef(()=>{}),m=y({...te(),meta:L,onMutate:()=>{l.current()},onSuccess:()=>{a(""),o()}}),h=y({...ne(),meta:L,gcTime:0,onMutate:()=>{m.reset()},onSuccess:Z=>{a(Me(window.location.host,Z.feedToken)),o()}});l.current=h.reset;const{mutate:c,reset:x}=h,{mutate:u}=m,p=r.useCallback(()=>{c({path:{calendarId:s}})},[s,c]),b=r.useCallback(()=>{u({path:{calendarId:s}})},[s,u]),g=r.useCallback(()=>{a(""),x()},[x]),{refetch:v}=d,C=r.useCallback(()=>{v()},[v]);return{state:Ae(d),mintedUrl:t,isBusy:h.isPending||m.isPending,actionError:h.error??m.error,mint:p,revoke:b,dismissMinted:g,retry:C}}function Ae(s){return s.error?re(s.error)?{status:"absent"}:{status:"unreadable",error:s.error}:s.isPending?{status:"loading"}:s.data?{status:"active",createdAt:s.data.createdAt,rotatedAt:s.data.rotatedAt}:{status:"absent"}}function Pe({calendarId:s,calendarName:n,details:t}){const a=ze(s);return e.jsx(Ie,{calendarName:n,details:t,state:a.state,mintedUrl:a.mintedUrl,isBusy:a.isBusy,actionError:a.actionError,onMint:a.mint,onRevoke:a.revoke,onDismissMinted:a.dismissMinted,onRetry:a.retry})}function De({calendarId:s,calendarName:n,timezone:t,subscription:a}){const{updateCalendar:i,deleteCalendar:d,isWriting:o}=W(),[l,m]=r.useState(""),h=c=>m(c.kind==="refused"?c.message:"");return e.jsx(Pe,{calendarId:s,calendarName:n,details:e.jsxs(e.Fragment,{children:[a,e.jsx(Ne,{calendarName:n,timezone:t,isBusy:o,problem:l,onSave:c=>{m(""),i(s,c).then(h)},onDelete:()=>{m(""),d(s).then(h)}},`${n}\0${t}`)]})})}const Re="Subscribe to a calendar";function Oe({isBusy:s,error:n,onSubscribe:t}){const a=r.useId(),i=r.useId(),d=r.useId(),[o,l]=r.useState(""),[m,h]=r.useState(""),c=o.trim()!==""&&m.trim()!=="",x=u=>{u.preventDefault(),c&&t({displayName:o,url:m},()=>{l(""),h("")})};return e.jsxs(P,{className:"max-w-xl",role:"region","aria-labelledby":a,children:[e.jsx(D,{children:e.jsx(R,{id:a,children:Re})}),e.jsx(O,{children:e.jsxs("form",{className:"space-y-3",onSubmit:x,children:[e.jsx("p",{className:"text-sm text-fg-muted",children:"Paste the secret iCal address from Google Calendar, a published Outlook calendar or any other feed. It shows here read-only and refreshes on its own."}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:i,className:"text-sm font-medium text-fg",children:"Calendar name"}),e.jsx(N,{id:i,value:o,onChange:u=>l(u.target.value),placeholder:"Team rota",autoComplete:"off"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:d,className:"text-sm font-medium text-fg",children:"Calendar address"}),e.jsx(N,{id:d,value:m,onChange:u=>h(u.target.value),placeholder:"https://calendar.google.com/calendar/ical/…/basic.ics",autoComplete:"off",spellCheck:!1,inputMode:"url"}),e.jsx("p",{className:"text-xs text-fg-muted",children:"For Google Calendar the address is the password to the calendar. Reader never shows it in full again."})]}),e.jsx(f,{type:"submit",variant:"primary",size:"sm",disabled:!c||s,icon:e.jsx(xe,{className:"size-3.5"}),children:s?"Subscribing…":"Subscribe"}),n!=null&&e.jsxs(j,{tone:"danger",variant:"soft",children:[e.jsx("p",{className:"font-medium",children:"The calendar was not added."}),e.jsx("p",{className:"mt-0.5 break-words",children:w(n)})]})]})})]})}function Le({calendarName:s,subscriptionUrl:n,enabled:t,fetchedAt:a,error:i,isBusy:d,actionError:o,onSetEnabled:l}){return e.jsxs("div",{className:"mb-4 space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Q,{tone:t?"positive":"neutral",children:t?"subscribed":"paused"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:["Read-only, from ",pe(n),a>0?`. Last updated ${M(a,"medium")}`:""]})]}),i!==""&&e.jsxs(j,{tone:"warning",variant:"soft",children:[e.jsxs("p",{className:"font-medium",children:[s," was not refreshed."]}),e.jsx("p",{className:"mt-0.5 break-words",children:i})]}),e.jsx("p",{className:"text-sm text-fg-muted",children:t?"Events are read from the feed on a schedule and cannot be edited here.":"Updates are paused. The events already here stay until you resume or remove the calendar."}),e.jsx(f,{variant:"secondary",size:"sm",disabled:d,icon:t?e.jsx(ge,{className:"size-3.5"}):e.jsx(fe,{className:"size-3.5"}),onClick:()=>l(!t),children:t?"Pause updates":"Resume updates"}),o!=null&&e.jsxs(j,{tone:"danger",variant:"soft",children:[e.jsxs("p",{className:"font-medium",children:["Updates for ",s," were not changed."]}),e.jsx("p",{className:"mt-0.5 break-words",children:w(o)})]})]})}const U=A(400,404),Ue=()=>`subscribed-${crypto.randomUUID().slice(0,8)}`;function $e(){const s=z(),n=V(),t=()=>{s.invalidateQueries({queryKey:$()}),n()},a=y({..._(),meta:U,onSuccess:t}),i=y({...H(),meta:U,onSuccess:t}),{mutate:d}=a,o=r.useCallback((h,c)=>{d({body:{urlSegment:Ue(),displayName:h.displayName.trim(),subscriptionUrl:h.url.trim()}},{onSuccess:c})},[d]),{mutate:l}=i,m=r.useCallback((h,c)=>{l({path:{calendarId:h},body:{subscriptionEnabled:c}})},[l]);return{subscribe:o,isSubscribing:a.isPending,subscribeError:a.error,setEnabled:m,togglingCalendarId:i.isPending?i.variables?.path.calendarId??"":"",toggleFailure:{calendarId:i.variables?.path.calendarId??"",error:i.error}}}const _e=e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{children:"Each calendar has a name, a time zone its floating times are read in, and an address CalDAV clients reach it by. The address is fixed when the calendar is added; the name and zone can change. Deleting a calendar deletes every event in it. The default calendar is where accepted invitations land, so it cannot be deleted."}),e.jsx("p",{children:"A subscription address lets Apple Calendar, Google Calendar, Outlook and Thunderbird show a calendar from here, read-only and kept up to date."}),e.jsx("p",{children:"Those clients never sign in, so the address itself is the credential. Anyone who has it can read the calendar; nobody who has it can change anything."}),e.jsx("p",{children:"Only a hash of the address is stored, so it is shown once and cannot be looked up later. Replacing it breaks every subscription built on the old one, which is how a shared address is taken back."}),e.jsx("p",{children:"Subscribing works the other way round: paste another calendar's iCal address and its events show here, read-only, refreshed on a schedule."})]});function as(){const s=ie(),[n,t]=r.useState(!0),{calendars:a,collections:i,timeZoneByCalendarId:d,isLoading:o}=ce(),l=$e(),{createCalendar:m,isWriting:h}=W(),[c,x]=r.useState("");return e.jsx(le,{items:de,activeId:"calendars",title:"Calendars",description:"Add, rename and delete calendars, subscribe to a calendar feed, and share one with any client that can subscribe to a URL.",help:_e,helpOpen:n,onToggleHelp:()=>t(u=>!u),onSelect:u=>{const p=oe[u];p&&s({to:p})},onBackToMail:()=>{s({to:"/mail"})},children:o?e.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":"Loading calendars"}):e.jsxs("div",{className:"space-y-4",children:[a.map(u=>{const p=i.find(b=>b.calendarId===u.id);return e.jsx(De,{calendarId:u.id,calendarName:u.name,timezone:d[u.id]??"",subscription:p?.source==="Subscribed"&&e.jsx(Le,{calendarName:p.displayName,subscriptionUrl:p.subscriptionUrl,enabled:p.subscriptionEnabled,fetchedAt:p.subscriptionFetchedAt,error:p.subscriptionError,isBusy:l.togglingCalendarId===u.id,actionError:l.toggleFailure.calendarId===u.id?l.toggleFailure.error:void 0,onSetEnabled:b=>l.setEnabled(u.id,b)})},u.id)}),e.jsx(Oe,{isBusy:l.isSubscribing,error:l.subscribeError,onSubscribe:l.subscribe}),e.jsx(Ce,{isBusy:h,problem:c,onCreate:u=>(x(""),m(u).then(p=>p.kind==="written"?!0:(x(p.message),!1)))})]})})}export{as as component};
|
|
1
|
+
import{e as S,h as z,r,b7 as $,i as y,b8 as _,b9 as H,ba as X,s as A,j as e,az as q,aA as N,B as j,f,aR as J,a4 as G,g as Q,bb as M,aC as Y,bc as ee,c as se,bd as ae,aK as L,be as te,bf as ne,bg as re,u as ie,aQ as de,aS as oe}from"./index-BDIVfNXM.js";import{S as le}from"./settings-screen-B51b9lvj.js";import{C as P,a as D,b as R,c as O}from"./card-BKgdv2bH.js";import{U as k,u as ce}from"./useCalendars-CqOpDn21.js";import{C as K}from"./confirm-dialog-BmiOsB9N.js";import{f as w,E as ue}from"./ErrorState-BVvZa9Hj.js";import{R as me}from"./refresh-cw-BQa9I63p.js";import{C as he}from"./copy-B89b-33D.js";import{u as V}from"./useCalendarWrites-xN5WbPCM.js";import{s as pe}from"./calendar-subscription-B-aAc2Gy.js";import"./avatar-BEy9bmfT.js";import"./chevron-left-iD9K0p2O.js";import"./menu-DQ-pJ4eT.js";import"./circle-help-C0X0r4BQ.js";const xe=S("CalendarPlus",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 13V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8",key:"3spt84"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M16 19h6",key:"xwg31i"}],["path",{d:"M19 16v6",key:"tddt3s"}]]);const be=S("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);const ge=S("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]]);const fe=S("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const ve=S("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]),T=A(400,404),I={kind:"written"},F=s=>({kind:"refused",message:w(s)});function W(){const s=z(),n=V(),t=r.useCallback(()=>s.invalidateQueries({queryKey:$()}),[s]),a=r.useCallback(()=>(n(),t()),[n,t]),i=y({..._(),meta:T,onSuccess:t}),d=y({...H(),meta:T,onSuccess:a}),o=y({...X(),meta:T,onSuccess:a}),l=r.useCallback(c=>i.mutateAsync({body:c}).then(()=>I).catch(F),[i]),m=r.useCallback((c,x)=>d.mutateAsync({path:{calendarId:c},body:x}).then(()=>I).catch(F),[d]),h=r.useCallback(c=>o.mutateAsync({path:{calendarId:c}}).then(()=>I).catch(F),[o]);return r.useMemo(()=>({createCalendar:l,updateCalendar:m,deleteCalendar:h,isWriting:i.isPending||d.isPending||o.isPending}),[l,m,h,i.isPending,d.isPending,o.isPending])}const E=Intl.supportedValuesOf("timeZone");function B({id:s,value:n,disabled:t,onChange:a}){const i=n===k||E.includes(n)?E:[n,...E];return e.jsxs(q,{id:s,value:n,disabled:t,onChange:d=>a(d.target.value),children:[e.jsx("option",{value:k,children:"None (read as UTC)"}),i.map(d=>e.jsx("option",{value:d,children:d},d))]})}const ye=s=>({title:`Delete ${s}?`,description:`This removes ${s} and every event in it, and any subscription address stops working. It cannot be undone.`}),je=s=>s.normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,64);function Ce({isBusy:s,problem:n,onCreate:t}){const[a,i]=r.useState(""),[d,o]=r.useState(void 0),[l,m]=r.useState(k),h=r.useId(),c=r.useId(),x=r.useId(),u=r.useId(),p=d??je(a),b=a.trim()!==""&&p.trim()!=="";return e.jsxs(P,{className:"max-w-xl",role:"region","aria-labelledby":h,children:[e.jsx(D,{children:e.jsx(R,{id:h,children:"New calendar"})}),e.jsx(O,{children:e.jsxs("form",{className:"space-y-3",onSubmit:g=>{g.preventDefault(),b&&t({displayName:a.trim(),urlSegment:p.trim(),timezone:l}).then(v=>{v&&(i(""),o(void 0),m(k))})},children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:c,className:"text-xs font-medium text-fg-muted",children:"Name"}),e.jsx(N,{id:c,value:a,maxLength:140,disabled:s,onChange:g=>i(g.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:x,className:"text-xs font-medium text-fg-muted",children:"Address"}),e.jsx(N,{id:x,value:p,maxLength:64,disabled:s,onChange:g=>o(g.target.value)})]}),e.jsxs("div",{className:"space-y-1 sm:col-span-2",children:[e.jsx("label",{htmlFor:u,className:"text-xs font-medium text-fg-muted",children:"Time zone"}),e.jsx(B,{id:u,value:l,disabled:s,onChange:m})]})]}),e.jsx("p",{className:"text-xs text-fg-muted",children:"The address names the calendar for CalDAV clients and cannot be changed later. The name and zone can."}),n!==""&&e.jsxs(j,{tone:"danger",variant:"soft",children:[e.jsx("p",{className:"font-medium",children:"The calendar was not added."}),e.jsx("p",{className:"mt-0.5 break-words",children:n})]}),e.jsx(f,{type:"submit",variant:"primary",size:"sm",disabled:s||!b,icon:e.jsx(J,{className:"size-3.5"}),children:s?"Adding…":"Add calendar"})]})})]})}function Ne({calendarName:s,timezone:n,isBusy:t,problem:a,onSave:i,onDelete:d}){const[o,l]=r.useState(s),[m,h]=r.useState(n),[c,x]=r.useState(!1),u=r.useId(),p=r.useId(),b=o.trim(),g=b!==s||m!==n,v=ye(s);return e.jsxs(e.Fragment,{children:[e.jsxs("form",{className:"space-y-3",onSubmit:C=>{C.preventDefault(),!(!g||b==="")&&i({displayName:b,timezone:m})},children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:u,className:"text-xs font-medium text-fg-muted",children:"Name"}),e.jsx(N,{id:u,value:o,maxLength:140,disabled:t,onChange:C=>l(C.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:p,className:"text-xs font-medium text-fg-muted",children:"Time zone"}),e.jsx(B,{id:p,value:m,disabled:t,onChange:h})]})]}),a!==""&&e.jsxs(j,{tone:"danger",variant:"soft",children:[e.jsxs("p",{className:"font-medium",children:[s," was not changed."]}),e.jsx("p",{className:"mt-0.5 break-words",children:a})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(f,{type:"submit",variant:"secondary",size:"sm",disabled:t||!g||b==="",icon:e.jsx(ve,{className:"size-3.5"}),children:"Save changes"}),e.jsx(f,{type:"button",variant:"danger",size:"sm",disabled:t,icon:e.jsx(G,{className:"size-3.5"}),onClick:()=>x(!0),children:"Delete calendar"})]})]}),e.jsx(K,{isOpen:c,title:v.title,description:v.description,confirmLabel:"Delete calendar",destructive:!0,onConfirm:()=>{x(!1),d()},onCancel:()=>x(!1)})]})}const Se=s=>({title:`Replace the address for ${s}?`,description:"Every client already subscribed to the current address stops updating and has to be pointed at the new one. The new address is shown once."}),ke=s=>({title:`Stop sharing ${s}?`,description:"The address stops working immediately and every client subscribed to it stops updating. Sharing again mints a different address."});function we({calendarName:s,url:n,onDismiss:t}){const[a,i]=r.useState(!1),[d,o]=r.useState(!1),l=r.useRef(0);r.useEffect(()=>()=>window.clearTimeout(l.current),[]);const m=()=>{navigator.clipboard.writeText(n).then(()=>{o(!1),i(!0),l.current=window.setTimeout(()=>i(!1),2e3)}).catch(()=>o(!0))};return e.jsxs("div",{className:"mt-3 space-y-2 rounded-sm border border-accent-2/40 bg-accent-2/10 px-3 py-2.5",children:[e.jsx("p",{className:"text-sm font-medium text-fg",children:"Subscribe with this address. It is shown once and cannot be read back."}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsx("input",{readOnly:!0,value:n,"aria-label":`Subscription address for ${s}`,onFocus:h=>h.currentTarget.select(),className:"min-w-0 flex-1 rounded-sm border border-line bg-surface px-2 py-1.5 font-mono text-xs text-fg"}),e.jsx(f,{variant:"primary",size:"sm",icon:a?e.jsx(Y,{className:"size-3.5"}):e.jsx(he,{className:"size-3.5"}),onClick:m,children:a?"Copied":"Copy address"})]}),d&&e.jsx(j,{tone:"warning",variant:"soft",children:"The address could not be copied to the clipboard. Select it above and copy it by hand before leaving this page."}),e.jsx("p",{className:"text-xs text-fg-muted",children:"Anyone holding this address can read every event in this calendar, without signing in. Rotate it if it reaches the wrong person."}),e.jsx(f,{variant:"ghost",size:"sm",onClick:t,children:"I've saved it"})]})}function Te({createdAt:s,rotatedAt:n,isBusy:t,onRotate:a,onRevoke:i}){return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Q,{tone:"positive",children:"shared"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:["Address created ",M(s,"medium"),n>0?`, last replaced ${M(n,"medium")}`:""]})]}),e.jsx("p",{className:"text-sm text-fg-muted",children:"The address itself is not stored in readable form, so it cannot be shown again. Replace it if you no longer know where it went."}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(f,{variant:"secondary",size:"sm",disabled:t,icon:e.jsx(me,{className:"size-3.5"}),onClick:a,children:"Replace address"}),e.jsx(f,{variant:"danger",size:"sm",disabled:t,icon:e.jsx(G,{className:"size-3.5"}),onClick:i,children:"Stop sharing"})]})]})}function Ie({calendarName:s,details:n,state:t,mintedUrl:a,isBusy:i,actionError:d,onMint:o,onRevoke:l,onDismissMinted:m,onRetry:h}){const[c,x]=r.useState("none"),u=r.useId(),p=()=>{const g=c;x("none"),g==="rotate"&&o(),g==="revoke"&&l()},b=c==="revoke"?ke(s):Se(s);return e.jsxs(P,{className:"max-w-xl",role:"region","aria-labelledby":u,children:[e.jsx(D,{children:e.jsx(R,{id:u,children:s})}),e.jsxs(O,{children:[n&&e.jsx("div",{className:"mb-4 border-b border-line pb-4",children:n}),t.status==="loading"&&a===""&&e.jsx("div",{className:"h-12 animate-pulse rounded-sm bg-surface-sunken","aria-busy":"true","aria-label":`Loading the subscription address for ${s}`}),t.status==="unreadable"&&a===""&&e.jsx(ue,{variant:"inline",title:`Couldn't read whether ${s} is shared`,error:t.error,onRetry:h}),t.status==="absent"&&a===""&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-fg-muted",children:"Give this calendar a secret address and Apple Calendar, Google Calendar, Outlook and Thunderbird can subscribe to it read-only. Nobody signs in — the address is the credential, so treat it like a password."}),e.jsx(f,{variant:"primary",size:"sm",disabled:i,icon:e.jsx(be,{className:"size-3.5"}),onClick:o,children:i?"Creating…":"Create subscription address"})]}),t.status==="active"&&e.jsx(Te,{createdAt:t.createdAt,rotatedAt:t.rotatedAt,isBusy:i,onRotate:()=>x("rotate"),onRevoke:()=>x("revoke")}),d!=null&&e.jsxs(j,{tone:"danger",variant:"soft",className:"mt-3",children:[e.jsxs("p",{className:"font-medium",children:["The subscription address for ",s," was not changed."]}),e.jsx("p",{className:"mt-0.5 break-words",children:w(d)})]}),a!==""&&e.jsx(we,{calendarName:s,url:a,onDismiss:m})]}),e.jsx(K,{isOpen:c!=="none",title:b.title,description:b.description,confirmLabel:c==="revoke"?"Stop sharing":"Replace address",destructive:!0,onConfirm:p,onCancel:()=>x("none")})]})}const Fe="/feeds/calendar/",Ee=".ics",Me=(s,n)=>`webcal://${s}${Fe}${n}${Ee}`;function ze(s){const n=z(),[t,a]=r.useState(""),i=ee({path:{calendarId:s}}),d=se({...ae({path:{calendarId:s}}),meta:A(404,403),retry:!1}),o=()=>{n.invalidateQueries({queryKey:i})},l=r.useRef(()=>{}),m=y({...te(),meta:L,onMutate:()=>{l.current()},onSuccess:()=>{a(""),o()}}),h=y({...ne(),meta:L,gcTime:0,onMutate:()=>{m.reset()},onSuccess:Z=>{a(Me(window.location.host,Z.feedToken)),o()}});l.current=h.reset;const{mutate:c,reset:x}=h,{mutate:u}=m,p=r.useCallback(()=>{c({path:{calendarId:s}})},[s,c]),b=r.useCallback(()=>{u({path:{calendarId:s}})},[s,u]),g=r.useCallback(()=>{a(""),x()},[x]),{refetch:v}=d,C=r.useCallback(()=>{v()},[v]);return{state:Ae(d),mintedUrl:t,isBusy:h.isPending||m.isPending,actionError:h.error??m.error,mint:p,revoke:b,dismissMinted:g,retry:C}}function Ae(s){return s.error?re(s.error)?{status:"absent"}:{status:"unreadable",error:s.error}:s.isPending?{status:"loading"}:s.data?{status:"active",createdAt:s.data.createdAt,rotatedAt:s.data.rotatedAt}:{status:"absent"}}function Pe({calendarId:s,calendarName:n,details:t}){const a=ze(s);return e.jsx(Ie,{calendarName:n,details:t,state:a.state,mintedUrl:a.mintedUrl,isBusy:a.isBusy,actionError:a.actionError,onMint:a.mint,onRevoke:a.revoke,onDismissMinted:a.dismissMinted,onRetry:a.retry})}function De({calendarId:s,calendarName:n,timezone:t,subscription:a}){const{updateCalendar:i,deleteCalendar:d,isWriting:o}=W(),[l,m]=r.useState(""),h=c=>m(c.kind==="refused"?c.message:"");return e.jsx(Pe,{calendarId:s,calendarName:n,details:e.jsxs(e.Fragment,{children:[a,e.jsx(Ne,{calendarName:n,timezone:t,isBusy:o,problem:l,onSave:c=>{m(""),i(s,c).then(h)},onDelete:()=>{m(""),d(s).then(h)}},`${n}\0${t}`)]})})}const Re="Subscribe to a calendar";function Oe({isBusy:s,error:n,onSubscribe:t}){const a=r.useId(),i=r.useId(),d=r.useId(),[o,l]=r.useState(""),[m,h]=r.useState(""),c=o.trim()!==""&&m.trim()!=="",x=u=>{u.preventDefault(),c&&t({displayName:o,url:m},()=>{l(""),h("")})};return e.jsxs(P,{className:"max-w-xl",role:"region","aria-labelledby":a,children:[e.jsx(D,{children:e.jsx(R,{id:a,children:Re})}),e.jsx(O,{children:e.jsxs("form",{className:"space-y-3",onSubmit:x,children:[e.jsx("p",{className:"text-sm text-fg-muted",children:"Paste the secret iCal address from Google Calendar, a published Outlook calendar or any other feed. It shows here read-only and refreshes on its own."}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:i,className:"text-sm font-medium text-fg",children:"Calendar name"}),e.jsx(N,{id:i,value:o,onChange:u=>l(u.target.value),placeholder:"Team rota",autoComplete:"off"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:d,className:"text-sm font-medium text-fg",children:"Calendar address"}),e.jsx(N,{id:d,value:m,onChange:u=>h(u.target.value),placeholder:"https://calendar.google.com/calendar/ical/…/basic.ics",autoComplete:"off",spellCheck:!1,inputMode:"url"}),e.jsx("p",{className:"text-xs text-fg-muted",children:"For Google Calendar the address is the password to the calendar. Reader never shows it in full again."})]}),e.jsx(f,{type:"submit",variant:"primary",size:"sm",disabled:!c||s,icon:e.jsx(xe,{className:"size-3.5"}),children:s?"Subscribing…":"Subscribe"}),n!=null&&e.jsxs(j,{tone:"danger",variant:"soft",children:[e.jsx("p",{className:"font-medium",children:"The calendar was not added."}),e.jsx("p",{className:"mt-0.5 break-words",children:w(n)})]})]})})]})}function Le({calendarName:s,subscriptionUrl:n,enabled:t,fetchedAt:a,error:i,isBusy:d,actionError:o,onSetEnabled:l}){return e.jsxs("div",{className:"mb-4 space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Q,{tone:t?"positive":"neutral",children:t?"subscribed":"paused"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:["Read-only, from ",pe(n),a>0?`. Last updated ${M(a,"medium")}`:""]})]}),i!==""&&e.jsxs(j,{tone:"warning",variant:"soft",children:[e.jsxs("p",{className:"font-medium",children:[s," was not refreshed."]}),e.jsx("p",{className:"mt-0.5 break-words",children:i})]}),e.jsx("p",{className:"text-sm text-fg-muted",children:t?"Events are read from the feed on a schedule and cannot be edited here.":"Updates are paused. The events already here stay until you resume or remove the calendar."}),e.jsx(f,{variant:"secondary",size:"sm",disabled:d,icon:t?e.jsx(ge,{className:"size-3.5"}):e.jsx(fe,{className:"size-3.5"}),onClick:()=>l(!t),children:t?"Pause updates":"Resume updates"}),o!=null&&e.jsxs(j,{tone:"danger",variant:"soft",children:[e.jsxs("p",{className:"font-medium",children:["Updates for ",s," were not changed."]}),e.jsx("p",{className:"mt-0.5 break-words",children:w(o)})]})]})}const U=A(400,404),Ue=()=>`subscribed-${crypto.randomUUID().slice(0,8)}`;function $e(){const s=z(),n=V(),t=()=>{s.invalidateQueries({queryKey:$()}),n()},a=y({..._(),meta:U,onSuccess:t}),i=y({...H(),meta:U,onSuccess:t}),{mutate:d}=a,o=r.useCallback((h,c)=>{d({body:{urlSegment:Ue(),displayName:h.displayName.trim(),subscriptionUrl:h.url.trim()}},{onSuccess:c})},[d]),{mutate:l}=i,m=r.useCallback((h,c)=>{l({path:{calendarId:h},body:{subscriptionEnabled:c}})},[l]);return{subscribe:o,isSubscribing:a.isPending,subscribeError:a.error,setEnabled:m,togglingCalendarId:i.isPending?i.variables?.path.calendarId??"":"",toggleFailure:{calendarId:i.variables?.path.calendarId??"",error:i.error}}}const _e=e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{children:"Each calendar has a name, a time zone its floating times are read in, and an address CalDAV clients reach it by. The address is fixed when the calendar is added; the name and zone can change. Deleting a calendar deletes every event in it. The default calendar is where accepted invitations land, so it cannot be deleted."}),e.jsx("p",{children:"A subscription address lets Apple Calendar, Google Calendar, Outlook and Thunderbird show a calendar from here, read-only and kept up to date."}),e.jsx("p",{children:"Those clients never sign in, so the address itself is the credential. Anyone who has it can read the calendar; nobody who has it can change anything."}),e.jsx("p",{children:"Only a hash of the address is stored, so it is shown once and cannot be looked up later. Replacing it breaks every subscription built on the old one, which is how a shared address is taken back."}),e.jsx("p",{children:"Subscribing works the other way round: paste another calendar's iCal address and its events show here, read-only, refreshed on a schedule."})]});function as(){const s=ie(),[n,t]=r.useState(!0),{calendars:a,collections:i,timeZoneByCalendarId:d,isLoading:o}=ce(),l=$e(),{createCalendar:m,isWriting:h}=W(),[c,x]=r.useState("");return e.jsx(le,{items:de,activeId:"calendars",title:"Calendars",description:"Add, rename and delete calendars, subscribe to a calendar feed, and share one with any client that can subscribe to a URL.",help:_e,helpOpen:n,onToggleHelp:()=>t(u=>!u),onSelect:u=>{const p=oe[u];p&&s({to:p})},onBackToMail:()=>{s({to:"/mail"})},children:o?e.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":"Loading calendars"}):e.jsxs("div",{className:"space-y-4",children:[a.map(u=>{const p=i.find(b=>b.calendarId===u.id);return e.jsx(De,{calendarId:u.id,calendarName:u.name,timezone:d[u.id]??"",subscription:p?.source==="Subscribed"&&e.jsx(Le,{calendarName:p.displayName,subscriptionUrl:p.subscriptionUrl,enabled:p.subscriptionEnabled,fetchedAt:p.subscriptionFetchedAt,error:p.subscriptionError,isBusy:l.togglingCalendarId===u.id,actionError:l.toggleFailure.calendarId===u.id?l.toggleFailure.error:void 0,onSetEnabled:b=>l.setEnabled(u.id,b)})},u.id)}),e.jsx(Oe,{isBusy:l.isSubscribing,error:l.subscribeError,onSubscribe:l.subscribe}),e.jsx(Ce,{isBusy:h,problem:c,onCreate:u=>(x(""),m(u).then(p=>p.kind==="written"?!0:(x(p.message),!1)))})]})})}export{as as component};
|