@remit/web-client-dist 0.0.637 → 0.0.639
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-i-1XzvAd.js → BriefPane-CdiCvSuF.js} +1 -1
- package/assets/{CalendarComposePane-C9LVQJgz.js → CalendarComposePane-C5loQEEz.js} +1 -1
- package/assets/{CalendarComposeSeed-BcquqWwH.js → CalendarComposeSeed-B602bh7Z.js} +1 -1
- package/assets/{CalendarShell-BrNxa6Nn.js → CalendarShell-BP7ONGRL.js} +1 -1
- package/assets/{EmptyState-haDMp8Ar.js → EmptyState-ClLPPGI1.js} +1 -1
- package/assets/{ErrorState-CmLGalXf.js → ErrorState-CX8jPS64.js} +1 -1
- package/assets/{FlaggedPane-B5Ht6vwP.js → FlaggedPane-CD2pUbFg.js} +1 -1
- package/assets/{FullCompose-BDr9-FPu.js → FullCompose-CgTCPbiG.js} +1 -1
- package/assets/MailListHeader-C8fUfLdY.js +7 -0
- package/assets/{MailNav-BQXjAtKO.js → MailNav-CFYn6k9r.js} +1 -1
- package/assets/{MailShell-CBX109fx.js → MailShell-BnAscFqh.js} +1 -1
- package/assets/{MailViewChrome-K588o61G.js → MailViewChrome-BgP0RFzV.js} +1 -1
- package/assets/{MailboxPane-D9zqi3Rr.js → MailboxPane-CG-dcZ55.js} +1 -1
- package/assets/{NavMenuButton-BpGFPcon.js → NavMenuButton-ggAVFYnQ.js} +1 -1
- package/assets/{OnboardingWizard-ThfV-x2z.js → OnboardingWizard-CrpfDnhV.js} +1 -1
- package/assets/{OpenCalendarEvent-BwmHUJaw.js → OpenCalendarEvent-C-aoRB9f.js} +1 -1
- package/assets/{OutboxPane-Bk9nNby0.js → OutboxPane-CM3kwG8i.js} +1 -1
- package/assets/_calendarObjectId-UmX8K95N.js +1 -0
- package/assets/_mailboxId-DRa01xOQ.js +1 -0
- package/assets/_messageId-BMOloRC2.js +1 -0
- package/assets/_messageId-UrdBJAzT.js +1 -0
- package/assets/_messageId-s6b1mjWq.js +1 -0
- package/assets/_outboxMessageId-C8DuFjhs.js +1 -0
- package/assets/_recurrenceId-qf3rXRrq.js +1 -0
- package/assets/_threadId-CkqELJtN.js +1 -0
- package/assets/_threadId-DdjdPPV9.js +1 -0
- package/assets/_threadId-Dehzj5sp.js +1 -0
- package/assets/{_view._date-B1Vb2h-D.js → _view._date-8_v9V7g9.js} +1 -1
- package/assets/{accounts-ChoqdfMH.js → accounts-ezV4xN2p.js} +1 -1
- package/assets/{advanced-BQgtDSX_.js → advanced-CHdzXVPf.js} +1 -1
- package/assets/{appearance-CiLCRkQD.js → appearance-Dzm_Xcwd.js} +1 -1
- package/assets/{attendee-row-DMe42k7H.js → attendee-row-DaC0cWu0.js} +1 -1
- package/assets/{avatar-OJww5F3k.js → avatar-CMrR_WCW.js} +1 -1
- package/assets/{bell-off-JyhxJiJh.js → bell-off-CjFQsmU0.js} +1 -1
- package/assets/{bottom-sheet-BXHtkHEQ.js → bottom-sheet-lVnXVWKS.js} +1 -1
- package/assets/{brief-Ct3P0mmd.js → brief-B2hZLxBG.js} +1 -1
- package/assets/brief-CbnxY4As.js +1 -0
- package/assets/{browser-ponyfill-BZhAFCLP.js → browser-ponyfill-_Ty7DcLK.js} +1 -1
- package/assets/{bug-BXAS92HM.js → bug-ysY2Lcys.js} +1 -1
- package/assets/{calendar-CIrHuuJU.js → calendar-CozJzlZZ.js} +1 -1
- package/assets/{calendar-clash-strip-Do_J9SgJ.js → calendar-clash-strip-DH-rkJMi.js} +1 -1
- package/assets/{calendar-format-CwRw4RDu.js → calendar-format-CHntutZg.js} +1 -1
- package/assets/{calendar-report-DMvb9Sqg.js → calendar-report-DAUzkHX3.js} +1 -1
- package/assets/calendar-suggestion-CaACTNVX.js +1 -0
- package/assets/{calendars-FdgmByI_.js → calendars-CYKvOlYj.js} +1 -1
- package/assets/{card-Cj-QGmCF.js → card-ChUQkNyW.js} +1 -1
- package/assets/{checkbox-SlSTA73y.js → checkbox-lv4ht1p0.js} +1 -1
- package/assets/chevron-left-BnXYRBLM.js +1 -0
- package/assets/{circle-check-Bp2lyV0E.js → circle-check-CmZH70G9.js} +1 -1
- package/assets/{circle-check-big-Vq2QoGgP.js → circle-check-big-DsPxeo1f.js} +1 -1
- package/assets/{circle-help-gen-dtEL.js → circle-help-CxlWBIxf.js} +1 -1
- package/assets/{clock-BBpIdhnS.js → clock-BQFlXobK.js} +1 -1
- package/assets/compose._-_outboxMessageId_-BFJxAVoN.js +1 -0
- package/assets/compose._-_outboxMessageId_-Bth4jzBG.js +1 -0
- package/assets/compose._-_outboxMessageId_-C8FGmbP_.js +1 -0
- package/assets/compose._-_outboxMessageId_-Kpi3RLY9.js +1 -0
- package/assets/{config-import-DwGVp5nY.js → config-import-CO5AR73r.js} +1 -1
- package/assets/{confirm-dialog-DqUyGPYb.js → confirm-dialog-DM1V3tLO.js} +1 -1
- package/assets/{copy-BFnJYo3G.js → copy-D9w0yOJZ.js} +1 -1
- package/assets/{credential-steps-BYrGAoU5.js → credential-steps-8oD-bgsd.js} +1 -1
- package/assets/{download-CExFNT5m.js → download-D3c-jAvE.js} +1 -1
- package/assets/{file-json-ChcZbyWI.js → file-json-DgAW6fCg.js} +1 -1
- package/assets/{filters-DSI3RcDp.js → filters-COsyZM0t.js} +1 -1
- package/assets/flagged-DKGPYmqT.js +1 -0
- package/assets/{flagged-BTuHoVag.js → flagged-PvSBYoZf.js} +1 -1
- package/assets/{folders-B3UvbiMG.js → folders-9bvPOa--.js} +1 -1
- package/assets/{help-copy-BpnCsJKm.js → help-copy-Bfcrl0wG.js} +1 -1
- package/assets/{import-BtjgDhbI.js → import-CZn1xOPk.js} +1 -1
- package/assets/index-BMOloRC2.js +1 -0
- package/assets/{index-CEJMvVKP.js → index-BNf6kiaX.js} +7 -7
- package/assets/index-BT8lpC7o.js +1 -0
- package/assets/index-B_EiAJWG.js +1 -0
- package/assets/index-C3ge01DK.js +1 -0
- package/assets/{index-C44gqDSI.js → index-COLU2y0-.js} +1 -1
- package/assets/index-Ca6ZI10M.js +1 -0
- package/assets/index-CpzmW4H6.js +1 -0
- package/assets/index-DLln0xg-.js +1 -0
- package/assets/{index-BgsHJXrW.js → index-J89guRVU.js} +4 -4
- package/assets/index-Ncy8w6TK.js +1 -0
- package/assets/index-UrdBJAzT.js +1 -0
- package/assets/{kbd-o1nflZRu.js → kbd-CKw25IK5.js} +1 -1
- package/assets/{labels-DHP_zjK4.js → labels-CfHv29D2.js} +1 -1
- package/assets/{mail-Szc-p5g3.js → mail-5fD0jufv.js} +1 -1
- package/assets/{mail-xjJzF7Ec.js → mail-Daw23XZE.js} +1 -1
- package/assets/{menu-B7ZT3hES.js → menu-lOydIsUw.js} +1 -1
- package/assets/minus-oqpCotLr.js +1 -0
- package/assets/{new-DHxq4krb.js → new-Bx8aW3eQ.js} +1 -1
- package/assets/onboarding-CeRgXqq1.js +1 -0
- package/assets/{onboarding-completion-DIPuDK0D.js → onboarding-completion-Dyuup5X9.js} +1 -1
- package/assets/outbox-ughpF9_W.js +1 -0
- package/assets/{pane-header-BCtLNcGD.js → pane-header-CKSUzAfS.js} +1 -1
- package/assets/{pencil-BDdwSTNF.js → pencil-mpUWk0sq.js} +1 -1
- package/assets/{popover-menu-DH1B01dU.js → popover-menu-Cl-N1YPe.js} +1 -1
- package/assets/{refresh-cw-DmMLGyvw.js → refresh-cw-D2y2CKsF.js} +1 -1
- package/assets/{rich-text-DEvS7fTK.js → rich-text-D3O6tZw_.js} +1 -1
- package/assets/{rich-text-spellcheck-worker-provider-BKBVX-2v.js → rich-text-spellcheck-worker-provider-DrY6X3cn.js} +1 -1
- package/assets/{rotate-ccw-BzTXXy6H.js → rotate-ccw-86rVy6Oh.js} +1 -1
- package/assets/{roving-focus-D8ieiood.js → roving-focus-CzTCkI7v.js} +1 -1
- package/assets/{row-actions-d4_6b5VY.js → row-actions-C0iitOlE.js} +1 -1
- package/assets/{search-mirror-wk9khC5m.js → search-mirror-BlS_Ifso.js} +1 -1
- package/assets/{search-token-index-CrVbBlms.js → search-token-index-BXCXhECA.js} +1 -1
- package/assets/{sections-CgVZgQC0.js → sections-CmVNNIn5.js} +1 -1
- package/assets/{senders-mxAKZ_FE.js → senders-D9KOa6tO.js} +1 -1
- package/assets/settings-CGcDDxqi.js +1 -0
- package/assets/{settings-screen-Bsl0UC9v.js → settings-screen-CPKUaFTz.js} +1 -1
- package/assets/{shield-check-CUjnaEJM.js → shield-check-Bz65Alvp.js} +1 -1
- package/assets/{suggested-vips-BENsVw__.js → suggested-vips-jAg1lHBx.js} +1 -1
- package/assets/{undo-2-QAbYZsVP.js → undo-2-C5A6ikAQ.js} +1 -1
- package/assets/{useCalendarData-J9M1uPwl.js → useCalendarData-Di1HMX87.js} +1 -1
- package/assets/{useCalendarWrites-CMxbq1Ns.js → useCalendarWrites-B_iDGi_d.js} +1 -1
- package/assets/{useCalendars-DEAe0d5P.js → useCalendars-Du8oLBQy.js} +1 -1
- package/assets/{useDebouncedValue-CypIbLxd.js → useDebouncedValue-Cyjl5fcM.js} +1 -1
- package/assets/{useFilters-Cv87jtMp.js → useFilters-Dn74lJWT.js} +1 -1
- package/assets/{useLabels-B74FIyrh.js → useLabels-Bhad46sq.js} +1 -1
- package/assets/{useLayoutTier-BnLQZtW5.js → useLayoutTier-I-ZeE96x.js} +1 -1
- package/assets/{useMessageBodyContent-QMy924K4.js → useMessageBodyContent-Bl5Y6AAH.js} +1 -1
- package/assets/{useQueries-DBc1JIwH.js → useQueries-Ch9XYsKm.js} +1 -1
- package/assets/{useRefreshControl-DNtJwW7i.js → useRefreshControl-sKR2_udi.js} +1 -1
- package/assets/{useResultFolderIndex-BeXuylki.js → useResultFolderIndex-CizpN02R.js} +1 -1
- package/assets/{useSearchTokenContext-_mPqHIqE.js → useSearchTokenContext-Dl9jDzQw.js} +1 -1
- package/assets/{useSemanticSearch-JUvleuzy.js → useSemanticSearch-NkagUfNs.js} +1 -1
- package/assets/{useSignature-_lI__r_z.js → useSignature-z9_OAiTD.js} +1 -1
- package/index.html +1 -1
- package/package.json +1 -1
- package/assets/MailListHeader-D8dncvLk.js +0 -7
- package/assets/_calendarObjectId-D9_7PYZI.js +0 -1
- package/assets/_mailboxId-BuhgZ4EU.js +0 -1
- package/assets/_messageId-BoJ0kGms.js +0 -1
- package/assets/_messageId-BtCpeBln.js +0 -1
- package/assets/_messageId-sDYnK_ny.js +0 -1
- package/assets/_outboxMessageId-DnZaclF5.js +0 -1
- package/assets/_recurrenceId-75JuQikX.js +0 -1
- package/assets/_threadId-DQ7XFMjK.js +0 -1
- package/assets/_threadId-Dj_Z5hNe.js +0 -1
- package/assets/_threadId-E1Ji1VBb.js +0 -1
- package/assets/brief-3daIc_U_.js +0 -1
- package/assets/calendar-suggestion-f9IkXHda.js +0 -1
- package/assets/chevron-left-CyT8rYCK.js +0 -1
- package/assets/compose._-_outboxMessageId_-Bx07nXWx.js +0 -1
- package/assets/compose._-_outboxMessageId_-BxSDuFqr.js +0 -1
- package/assets/compose._-_outboxMessageId_-Dskdpi6-.js +0 -1
- package/assets/compose._-_outboxMessageId_-f_gWZERZ.js +0 -1
- package/assets/flagged-BZt2fsuR.js +0 -1
- package/assets/index-BS7Corg7.js +0 -1
- package/assets/index-BbW12rrk.js +0 -1
- package/assets/index-BtCpeBln.js +0 -1
- package/assets/index-C1YxhEeX.js +0 -1
- package/assets/index-CB6Q9Qtt.js +0 -1
- package/assets/index-CTeWdcpn.js +0 -1
- package/assets/index-CWfcTzfZ.js +0 -1
- package/assets/index-Dt3c3MCO.js +0 -1
- package/assets/index-sDYnK_ny.js +0 -1
- package/assets/minus-BD2hQqDO.js +0 -1
- package/assets/onboarding-CdkmnzTh.js +0 -1
- package/assets/outbox-BeQ7n9ml.js +0 -1
- package/assets/settings-Gkdms0mB.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as r,r as D,t as De,ao as Ve,f as se,Z as zs,X as Fe,ap as $s,aq as Bs,ar as gt,G as qs,H as Ws,as as te,h as Ze,at as Gs,c as os,d as ls,au as Ks,i as ye,av as Qs,o as we,l as yt,aw as Ys,ax as Zs,ay as Js,az as be,aA as Pt,L as nt,aB as Ct,aC as Xs,aD as Le,aE as je,aF as Vt,aG as ot,B as lt,aH as er,aI as tr,aJ as Dt,n as cs,ab as sr,aK as rr,aL as ir,aM as ds,aN as Ft,u as ar,aO as nr,aP as or,g as lr,aQ as Ot,aR as cr,a3 as dr,aS as ur}from"./index-BgsHJXrW.js";import{A as ct,g as Rt,P as fr,O as mr}from"./OnboardingWizard-ThfV-x2z.js";import{R as pr}from"./row-actions-d4_6b5VY.js";import{S as hr,A as gr}from"./settings-screen-Bsl0UC9v.js";import{s as qe,b as us,R as fs,u as yr}from"./credential-steps-BYrGAoU5.js";import{u as xr}from"./useSignature-_lI__r_z.js";import{c as vr,a as It,d as br}from"./account-form-helpers-DhckT_PN.js";import{C as Sr}from"./confirm-dialog-DqUyGPYb.js";import{f as Mt,E as jr}from"./ErrorState-CmLGalXf.js";import{D as wr}from"./download-CExFNT5m.js";import{a as Nr}from"./help-copy-BpnCsJKm.js";import"./checkbox-SlSTA73y.js";import"./minus-BD2hQqDO.js";import"./kbd-o1nflZRu.js";import"./mail-xjJzF7Ec.js";import"./file-json-ChcZbyWI.js";import"./avatar-OJww5F3k.js";import"./chevron-left-CyT8rYCK.js";import"./menu-B7ZT3hES.js";import"./circle-help-gen-dtEL.js";import"./card-Cj-QGmCF.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(Sr,{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:De("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:De("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=D.useId(),u=ct.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 j=t.includes(g.id),A=`${o}-${g.id}`,R=!j&&!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:A,className:"text-xs text-fg-subtle",children:R?`${g.description} Turning this on means signing in with ${e} again.`:g.description})]}),r.jsx(Pr,{checked:j,label:`Sync ${g.label.toLowerCase()}`,describedBy:A,disabled:n,onToggle:()=>l(g.id,j?"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)=>Ve(t).localeCompare(Ve(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:Ve(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 ${Ve(n)} by default`,onClick:()=>s([n,...e.filter(o=>o!==n)]),children:"Default"}),r.jsx(se,{variant:"ghost",size:"sm",icon:r.jsx(Fe,{className:"size-3.5"}),disabled:t||e.length===1,"aria-label":`Remove ${Ve(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:Ve(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(gt,{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=D.useRef(null);return Ws(l,e),r.jsxs(r.Fragment,{children:[r.jsx("div",{className:De("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:De("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(Fe,{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 ze=e=>e.type==="checkbox",Ne=e=>e instanceof Date,Q=e=>e==null;const xt=e=>typeof e=="object";var $=e=>!Q(e)&&!Array.isArray(e)&&xt(e)&&!Ne(e),Or=e=>$(e)&&e.target?ze(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 $(s)&&s.hasOwnProperty("isPrototypeOf")},Je=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(Je&&(e instanceof Blob||s))return e;const t=Array.isArray(e);if(!t&&!($(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 Pe={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",vt=["__proto__","constructor","prototype"],Ir=/^\w*$/;var $e=e=>Ir.test(e),U=e=>e===void 0;const Mr=/[.[\]'"]/;var Xe=e=>e.split(Mr).filter(Boolean),v=(e,s,t)=>{if(!s||!$(e))return t;const a=$e(s)?[s]:Xe(s);if(a.some(l=>vt.includes(l)))return t;const n=a.reduce((l,o)=>Q(l)?void 0:l[o],e);return U(n)||n===e?U(e[s])?t:e[s]:n},he=e=>typeof e=="boolean",oe=e=>typeof e=="function",M=(e,s,t)=>{let a=-1;const n=$e(s)?[s]:Xe(s),l=n.length,o=l-1;for(;++a<l;){const u=n[a];let g=t;if(a!==o){const j=e[u];g=$(j)||Array.isArray(j)?j:isNaN(+n[a+1])?{}:[]}if(vt.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=Je?te.useLayoutEffect:te.useEffect;var Y=e=>typeof e=="string",zr=(e,s,t,a,n)=>Y(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),dt=e=>Q(e)||!xt(e);const Ut=(e,s)=>s.length===0&&!Array.isArray(e)&&!ms(e);function ge(e,s,t=new WeakMap){if(e===s)return!0;if(dt(e)||dt(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)||($(u)||Array.isArray(u))&&($(g)||Array.isArray(g))?!ge(u,g,t):!Object.is(u,g))return!1}}return!0}var We=e=>({isOnSubmit:!e||e===ue.onSubmit,isOnBlur:e===ue.onBlur,isOnChange:e===ue.onChange,isOnAll:e===ue.all,isOnTouch:e===ue.onTouched}),rt=(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 He=(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(He(u,s))break}else if($(u)&&He(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},K=e=>$(e)&&!Object.keys(e).length,bt=e=>e.type==="file",Qe=e=>{if(!Je)return!1;const s=e?e.ownerDocument:0;return e instanceof(s&&s.defaultView?s.defaultView.HTMLElement:HTMLElement)},St=e=>e.type==="radio",Ye=e=>e instanceof RegExp,jt=(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&&!U(e[0].attributes.value)?U(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(Y(e)||Array.isArray(e)&&e.every(Y)||he(e)&&!e)return{type:t,message:Y(e)?e:"",ref:s}}var Ce=e=>$(e)&&!Ye(e)?e:{value:e,message:""},Wt=async(e,s,t,a,n,l)=>{const{ref:o,refs:u,required:g,maxLength:j,minLength:A,min:R,max:I,pattern:L,validate:T,name:f,valueAsNumber:S,mount:ne}=e._f,E=v(t,f);if(!ne||s.has(f))return{};const _=u?u[0]:o,k=C=>{if(n&&_.reportValidity){const V=he(C)?"":C||"";u?u.forEach(F=>F.setCustomValidity(V)):_.setCustomValidity(V),_.reportValidity()}},P={},Z=St(o),z=ze(o),fe=Z||z,ae=(S||bt(o))&&U(o.value)&&U(E)||Qe(o)&&o.value===""||E===""||Array.isArray(E)&&!E.length,J=jt.bind(null,f,a,P),le=(C,V,F,W=de.maxLength,X=de.minLength)=>{const G=C?V:F;P[f]={type:C?W:X,message:G,ref:o,...J(C?W:X,G)}};if(l?!Array.isArray(E)||!E.length:g&&(!fe&&(ae||Q(E))||he(E)&&!E||z&&!hs(u).isValid||Z&&!gs(u).isValid)){const{value:C,message:V}=Y(g)?{value:!!g,message:g}:Ce(g);if(C&&(P[f]={type:de.required,message:V,ref:_,...J(de.required,V)},!a))return k(V),P}if(!ae&&(!Q(R)||!Q(I))){let C,V;const F=Ce(I),W=Ce(R);if(!Q(E)&&!isNaN(E)){const X=o.valueAsNumber||E&&+E;Q(F.value)||(C=X>F.value),Q(W.value)||(V=X<W.value)}else{const X=o.valueAsDate||new Date(E),G=re=>new Date(new Date().toDateString()+" "+re),me=o.type=="time",w=o.type=="week";Y(F.value)&&E&&(C=me?G(E)>G(F.value):w?E>F.value:X>new Date(F.value)),Y(W.value)&&E&&(V=me?G(E)<G(W.value):w?E<W.value:X<new Date(W.value))}if((C||V)&&(le(!!C,F.message,W.message,de.max,de.min),!a))return k(P[f].message),P}if((j||A)&&!ae&&(Y(E)||l&&Array.isArray(E))){const C=Ce(j),V=Ce(A),F=!Q(C.value)&&E.length>+C.value,W=!Q(V.value)&&E.length<+V.value;if((F||W)&&(le(F,C.message,V.message),!a))return k(P[f].message),P}if(L&&!ae&&Y(E)){const{value:C,message:V}=Ce(L);if(Ye(C)&&!E.match(C)&&(P[f]={type:de.pattern,message:V,ref:o,...J(de.pattern,V)},!a))return k(V),P}if(T){if(oe(T)){const C=await T(E,t),V=qt(C,_);if(V&&(P[f]={...V,...J(de.validate,V.message)},!a))return k(V.message),P}else if($(T)){let C={};for(const V in T){if(!K(C)&&!a)break;const F=qt(await T[V](E,t),_,V);F&&(C={...F,...J(V,F.message)},k(F.message),a&&(P[f]=C))}if(!K(C)&&(P[f]={ref:_,...C},!a))return P}}return k(!0),P},Ke=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(Q(e)){e=void 0;break}e=e[s[a]],a++}return e}function Br(e){for(const s in e)if(e.hasOwnProperty(s)&&!U(e[s]))return!1;return!0}function q(e,s){if(Y(s)&&Object.prototype.hasOwnProperty.call(e,s))return delete e[s],e;const t=Array.isArray(s)?s:$e(s)?[s]:Xe(s);if(t.some(o=>vt.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&&($(a)&&K(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(xt(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&&$(n)&&l){const o=vs(n,l);$(o)&&(t[a]=o)}else e[a]&&(t[a]=l)}return t}var bs=e=>e.type==="select-multiple",Wr=e=>St(e)||ze(e),it=e=>Qe(e)&&e.isConnected,Gr=e=>{for(const s in e)if(oe(e[s]))return!0;return!1};function Ss(e){return Array.isArray(e)||$(e)&&!Gr(e)}function js(e){return!!(e&&"_f"in e)}function ws(e){return Array.isArray(e)?!e.some(s=>!U(s)):!Object.keys(e).length}function ut(e,s){Array.isArray(e)?e[s]=void 0:delete e[s]}function ft(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)?[]:{},ft(n,s[a],l),ws(s[a])&&ut(s,a)):U(n)||(s[a]=!0)}return s}function Ee(e,s,t,a){t||(t=ft(s,{},a));for(const n in e){const l=e[n],o=a&&a[n];Ss(l)&&(!Array.isArray(l)||!js(o))?(U(s)||dt(t[n])?t[n]=ft(l,Array.isArray(l)?[]:{},o):Ee(l,Q(s)?{}:s[n],t[n],o),ws(t[n])&&ut(t,n)):ge(l,s[n])?ut(t,n):t[n]=!0}return t}var Ns=(e,{valueAsNumber:s,valueAsDate:t,setValueAs:a})=>U(e)?e:s?e===""?NaN:e&&+e:t&&Y(e)?new Date(e):a?a(e):e;function Kt(e){const s=e.ref;return bt(s)?s.files:St(s)?gs(e.refs).value:bs(s)?[...s.selectedOptions].map(({value:t})=>t):ze(s)?hs(e.refs).value:Ns(U(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}},Ue=e=>U(e)?e:Ye(e)?e.source:$(e)?Ye(e.value)?e.value.source:e.value:e;const Qt="AsyncFunction";var Qr=e=>{if(!e||!e.validate)return!1;if(oe(e.validate))return e.validate.constructor.name===Qt;if($(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||$e(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||Ke(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},at="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:oe(s.defaultValues),errors:s.errors||{},disabled:s.disabled||!1},a={},n=$(s.defaultValues)||$(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={},j={};let A=0,R=We(s.mode),I=We(s.reValidateMode);const L={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},T={...L};let f={...T};const S={array:Gt(),state:Gt()};let ne=0;const E=s.criteriaMode===ue.all,_=(i,c)=>d=>{clearTimeout(j[i]),j[i]=setTimeout(c,d)},k=async i=>{if(!o.keepIsValid&&!s.disabled&&(T.isValid||f.isValid||i)){const c=++ne;let d;s.resolver?(d=K((await F()).errors),c===ne&&P()):d=await G({fields:a,onlyCheckValid:!0,eventType:Pe.VALID}),c===ne&&d!==t.isValid&&S.state.next({isValid:d})}},P=(i,c)=>{!s.disabled&&(T.isValidating||T.validatingFields||f.isValidating||f.validatingFields)&&((i||Array.from(u.mount)).forEach(d=>{d&&(c?M(t.validatingFields,d,c):q(t.validatingFields,d))}),S.state.next({validatingFields:t.validatingFields,isValidating:!K(t.validatingFields)}))},Z=()=>{t.dirtyFields=Ee(n,l,void 0,a)},z=(i,c=[],d,m,p=!0,x=!0)=>{if(m&&d&&!s.disabled){if(o.action=!0,x&&Array.isArray(v(a,i))){const y=d(v(a,i),m.argA,m.argB);p&&M(a,i,y)}if(x&&Array.isArray(v(t.errors,i))){const y=d(v(t.errors,i),m.argA,m.argB);p&&M(t.errors,i,y),ei(t.errors,i)}if((T.touchedFields||f.touchedFields)&&x&&Array.isArray(v(t.touchedFields,i))){const y=d(v(t.touchedFields,i),m.argA,m.argB);p&&M(t.touchedFields,i,y)}(T.dirtyFields||f.dirtyFields)&&Z(),S.state.next({name:i,isDirty:w(i,c),dirtyFields:t.dirtyFields,errors:t.errors,isValid:t.isValid})}else M(l,i,c)},fe=(i,c)=>{M(t.errors,i,c),t.errors={...t.errors},S.state.next({errors:t.errors})},ae=i=>{t.errors=i,S.state.next({errors:t.errors,isValid:!1})},J=i=>{const c=$e(i)?[i]:Xe(i);let d=l,m=n;for(let p=0;p<c.length-1;p++){const x=c[p];if(d=Q(d)?d:d[x],m=Q(m)?m:m[x],d===null&&m!==null)return!0}return!1},le=(i,c,d,m)=>{const p=v(a,i);if(p){if(J(i))return;const x=U(v(l,i)),y=v(l,i,U(d)?v(n,i):d);U(y)||m&&m.defaultChecked||c?M(l,i,c?y:Kt(p._f)):Se(i,y),o.mount&&!o.action&&(k(),x&&t.isDirty&&(T.isDirty||f.isDirty)&&(w()||(t.isDirty=!1,S.state.next({...t}))),e.shouldUnregister&&x&&!U(v(l,i))&&rt(i,u)&&(o.watch=!0))}},C=(i,c,d,m,p)=>{let x=!1,y=!1;const b={name:i};if(!s.disabled||m===!0){if(!d||m){const N=ge(v(n,i),c);(T.isDirty||f.isDirty)&&(y=t.isDirty,t.isDirty=b.isDirty=!N||w(),x=y!==b.isDirty),y=!!v(t.dirtyFields,i),N!==t.isDirty?t.dirtyFields=Ee(n,l,void 0,a):N?q(t.dirtyFields,i):M(t.dirtyFields,i,!0),b.dirtyFields=t.dirtyFields,x=x||(T.dirtyFields||f.dirtyFields)&&y!==!N}if(d){const N=v(t.touchedFields,i);N||(M(t.touchedFields,i,d),b.touchedFields=t.touchedFields,x=x||(T.touchedFields||f.touchedFields)&&N!==d)}x&&p&&S.state.next(b)}return x?b:{}},V=(i,c,d,m)=>{const p=v(t.errors,i),x=(T.isValid||f.isValid)&&he(c)&&t.isValid!==c;if(s.delayError&&d?(g[i]=_(i,()=>fe(i,d)),g[i](s.delayError)):(clearTimeout(j[i]),delete g[i],d?M(t.errors,i,d):q(t.errors,i),t.errors={...t.errors}),(d?!ge(p,d):p)||!K(m)||x){const y={...m,...x&&he(c)?{isValid:c}:{},errors:t.errors,name:i};t={...t,...y},S.state.next(y)}},F=async i=>(P(i,!0),await s.resolver(l,s.context,Kr(i||u.mount,a,s.criteriaMode,s.shouldUseNativeValidation))),W=async i=>{const{errors:c}=await F(i);if(P(i),i){for(const d of i){const m=v(c,d);m?u.array.has(d)&&$(m)&&!Object.keys(m).some(p=>!Number.isNaN(Number(p)))?Ht(t.errors,{[d]:m},d):M(t.errors,d,m):q(t.errors,d)}t.errors={...t.errors}}else t.errors=c;return c},X=async({name:i,eventType:c})=>{if(e.validate){const d=await e.validate({formValues:l,formState:t,name:i,eventType:c});if($(d))for(const m in d){const p=d[m];p&&Be(`${at}.${m}`,{message:Y(p.message)?p.message:"",type:p.type||de.validate})}else Y(d)||!d?Be(at,{message:d||"",type:de.validate}):_e(at);return d}return!0},G=async({fields:i,onlyCheckValid:c,name:d,eventType:m,context:p={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(p.runRootValidation=!0,!await X({name:d,eventType:m})&&(p.valid=!1,c)))return p.valid;for(const x in i){const y=i[x];if(y){const{_f:b,...N}=y;if(b){const H=u.array.has(b.name),ee=y._f&&Qr(y._f),xe=T.validatingFields||T.isValidating||f.validatingFields||f.isValidating;ee&&xe&&P([b.name],!0);const ve=await Wt(y,u.disabled,l,E,s.shouldUseNativeValidation&&!c,H);if(ee&&xe&&P([b.name]),ve[b.name]&&(p.valid=!1,c)||(!c&&(v(ve,b.name)?H?Ht(t.errors,ve,b.name):M(t.errors,b.name,ve[b.name]):q(t.errors,b.name)),e.shouldUseNativeValidation&&ve[b.name]))break}!K(N)&&await G({context:p,onlyCheckValid:c,fields:N,name:x,eventType:m})}}return p.valid},me=()=>{for(const i of u.unMount){const c=v(a,i);c&&(c._f.refs?c._f.refs.every(d=>!it(d)):!it(c._f.ref))&&et(i)}u.unMount=new Set},w=(i,c)=>(i&&c&&M(l,i,c),!ge(o.mount?l:n,n)),re=(i,c,d)=>zr(i,u,{...o.mount?l:U(c)?n:Y(i)?{[i]:c}:c},d,c),Ae=i=>ys(v(o.mount?l:n,i,s.shouldUnregister?v(n,i,[]):[])),Se=(i,c,d={},m=!1,p=!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=Qe(b.ref)&&Q(c)?"":c,bs(b.ref)?[...b.ref.options].forEach(N=>N.selected=y.includes(N.value)):b.refs?ze(b.ref)?b.refs.forEach(N=>{(!N.defaultChecked||!N.disabled)&&(Array.isArray(y)?N.checked=!!y.find(H=>H===N.value):N.checked=y===N.value||!!y)}):b.refs.forEach(N=>N.checked=N.value===y):bt(b.ref)?b.ref.value="":(b.ref.value=y,!b.ref.type&&!p&&S.state.next({name:i,values:m?l:B(l)})))}(d.shouldDirty||d.shouldTouch)&&C(i,y,d.shouldTouch,d.shouldDirty,!p),d.shouldValidate&&pe(i,{delayError:d.delayError})},ke=(i,c,d,m=!1,p=!1)=>{for(const x in c){if(!c.hasOwnProperty(x))return;const y=c[x],b=i+"."+x,N=v(a,b);(u.array.has(i)||$(y)||N&&!N._f)&&!Ne(y)?ke(b,y,d,m,p):Se(b,y,d,m,p)}},Oe=(i,c,d,m,p=!1)=>{const x=v(a,i),y=u.array.has(i),b=m?c:B(c),N=v(l,i),H=ge(N,b);if(H||M(l,i,b),y)S.array.next({name:i,values:m?l:B(l)}),(T.isDirty||T.dirtyFields||f.isDirty||f.dirtyFields)&&d.shouldDirty&&(Z(),p||S.state.next({name:i,dirtyFields:t.dirtyFields,isDirty:w(i,b)}));else{const ee=Array.isArray(b)&&!b.length||K(b);!x||x._f||Q(b)||ee?Se(i,b,d,m,p):ke(i,b,d,m,p)}if(!H&&!p){const ee=rt(i,u),xe=m?l:B(l);S.state.next({...ee&&t,name:o.mount||ee?i:void 0,values:xe})}},h=(i,c,d={})=>Oe(i,c,d,!1),O=(i,c={})=>{const d=oe(i)?i(l):i;if(!ge(l,d)){l={...l,...d};const m=xs(d);for(const p of u.mount)p in m&&Oe(p,m[p],c,!0,!0);S.state.next({...t,name:void 0,type:void 0,...A?{values:l}:{}}),c.shouldValidate&&k()}},ce=async i=>{o.mount=!0;const c=i.target;let d=c.name,m=!0;const p=v(a,d),x=y=>{m=Number.isNaN(y)||Ne(y)&&isNaN(y.getTime())||ge(y,v(l,d,y))};if(p){let y,b;const N=c.type?Kt(p._f):Or(i),H=i.type===Pe.BLUR||i.type===Pe.FOCUS_OUT,ee=!Yr(p._f)&&!e.validate&&!s.resolver&&!v(t.errors,d)&&!p._f.deps,xe=ee||Xr(H,v(t.touchedFields,d),t.isSubmitted,I,R),ve=rt(d,u,H);if(M(l,d,N),H){if(!c||!c.readOnly){p._f.onBlur&&p._f.onBlur(i);const Me=g[d];Me&&Me(0)}}else p._f.onChange&&p._f.onChange(i);const Ie=C(d,N,H),Us=!K(Ie)||ve;if(!H&&S.state.next({name:d,type:i.type,...A?{values:B(l)}:{}}),xe)return(!ee||!t.isValid)&&(T.isValid||f.isValid)&&(s.mode==="onBlur"?H&&k():H||k()),Us&&S.state.next({name:d,...ve?{}:Ie});if(!s.resolver&&e.validate&&await X({name:d,eventType:i.type}),!H&&ve&&S.state.next({...t}),s.resolver){const{errors:Me}=await F([d]);if(P([d]),x(N),!m){!K(Ie)&&S.state.next(Ie);return}const Hs=Yt(t.errors,a,d),_t=Yt(Me,a,Hs.name||d);y=_t.error,d=_t.name,b=K(Me)}else P([d],!0),y=(await Wt(p,u.disabled,l,E,s.shouldUseNativeValidation))[d],P([d]),x(N),m&&(y?b=!1:(T.isValid||f.isValid)&&(b=await G({fields:a,onlyCheckValid:!0,name:d,eventType:i.type})));m&&(p._f.deps&&(!Array.isArray(p._f.deps)||p._f.deps.length>0)&&pe(p._f.deps),V(d,b,y,Ie))}},ie=(i,c)=>{if(v(t.errors,c)&&i.focus)return i.focus(),1},pe=async(i,c={})=>{let d,m;const p=Ke(i);if(s.resolver){const x=await W(U(i)?i:p);d=K(x),m=i?!p.some(y=>v(x,y)):d}else i?(m=(await Promise.all(p.map(async x=>{const y=v(a,x);return await G({fields:y&&y._f?{[x]:y}:y,eventType:Pe.TRIGGER})}))).every(Boolean),!(!m&&!t.isValid)&&k()):m=d=await G({fields:a,name:i,eventType:Pe.TRIGGER});if(c.delayError&&s.delayError&&Y(i)){const x=v(t.errors,i);x?(q(t.errors,i),g[i]=_(i,()=>fe(i,x)),g[i](s.delayError)):(clearTimeout(j[i]),delete g[i])}return S.state.next({...!Y(i)||(T.isValid||f.isValid)&&d!==t.isValid?{}:{name:i},...s.resolver||!i?{isValid:d}:{},errors:t.errors}),c.shouldFocus&&!m&&He(a,ie,i?p:u.mount),m},Te=(i,c)=>{let d={...o.mount?l:n};return c&&(d=vs(c.dirtyFields?t.dirtyFields:t.touchedFields,d)),U(i)?d:Y(i)?v(d,i):i.map(m=>v(d,m))},Re=(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)}),_e=i=>{const c=i?Ke(i):void 0;c?.forEach(d=>q(t.errors,d)),c?c.forEach(d=>{S.state.next({name:d,errors:t.errors})}):S.state.next({errors:{}})},Be=(i,c,d)=>{const m=(v(a,i,{_f:{}})._f||{}).ref,p=v(t.errors,i)||{},{ref:x,message:y,type:b,...N}=p;M(t.errors,i,{...N,...c,ref:m}),S.state.next({name:i,errors:t.errors,isValid:!1}),d&&d.shouldFocus&&m&&m.focus&&m.focus()},Fs=(i,c)=>{if(oe(i)){A++;const{unsubscribe:d}=S.state.subscribe({next:p=>"values"in p&&i(p.values||re(void 0,c),p)});let m=!1;return{unsubscribe:()=>{m||(m=!0,A--,d())}}}return re(i,c,!0)},wt=i=>{var c;const d=!!(!((c=i.formState)===null||c===void 0)&&c.values);d&&A++;const{unsubscribe:m}=S.state.subscribe({next:x=>{if(Jr(i.name,x.name,i.exact)&&Zr(x,i.formState||T,Ls,i.reRenderRoot)){const y={...l};i.callback({values:y,...t,...x,defaultValues:n})}}});if(!d)return m;let p=!1;return()=>{p||(p=!0,A--,m())}},Os=i=>(o.mount=!0,f={...f,...i.formState},wt({...i,formState:{...L,...i.formState}})),et=(i,c={})=>{for(const d of i?Ke(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);S.state.next({values:B(l)}),S.state.next({...t,...c.keepDirty?{isDirty:w()}:{}}),!c.keepIsValid&&k()},Nt=({disabled:i,name:c})=>{if(he(i)&&o.mount||i||u.disabled.has(c)){const p=u.disabled.has(c)!==!!i;i?u.disabled.add(c):u.disabled.delete(c),p&&o.mount&&!o.action&&k()}},tt=(i,c={})=>{let d=v(a,i);const m=he(c.disabled)||he(s.disabled),p=!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&&!p?Nt({disabled:he(c.disabled)?c.disabled:s.disabled,name:i}):le(i,!0,c.value),{...m?{disabled:c.disabled||s.disabled}:{},...s.progressive?{required:!!c.required,min:Ue(c.min),max:Ue(c.max),minLength:Ue(c.minLength),maxLength:Ue(c.maxLength),pattern:Ue(c.pattern)}:{},name:i,onChange:ce,onBlur:ce,ref:x=>{if(x){u.registerName.add(i),tt(i,c),u.registerName.delete(i),d=v(a,i);const y=U(x.value)&&x.querySelectorAll&&x.querySelectorAll("input,select,textarea")[0]||x,b=Wr(y),N=d._f.refs||[];if(b?N.find(H=>H===y):y===d._f.ref)return;M(a,i,{_f:{...d._f,...b?{refs:[...N.filter(it),y,...Array.isArray(v(n,i))?[{}]:[]],ref:{type:y.type,name:i}}:{ref:y}}}),le(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)}}},st=()=>s.shouldFocusError&&!s.shouldUseNativeValidation&&He(a,ie,u.mount),Rs=i=>{he(i)&&(S.state.next({disabled:i}),He(a,(c,d)=>{const m=v(a,d);m&&(c.disabled=m._f.disabled||i,Array.isArray(m._f.refs)&&m._f.refs.forEach(p=>{p.disabled=m._f.disabled||i}))},0,!1))},At=(i,c)=>async d=>{let m;d&&(d.preventDefault&&d.preventDefault(),d.persist&&d.persist());let p=B(l);if(S.state.next({isSubmitting:!0}),s.resolver){const{errors:x,values:y}=await F();P(),t.errors=x,p=B(y)}else await G({fields:a,eventType:Pe.SUBMIT});if(u.disabled.size)for(const x of u.disabled)q(p,x);if(q(t.errors,ps),K(t.errors)){S.state.next({errors:{}});try{await i(p,d)}catch(x){m=x}}else c&&await c({...t.errors},d),st(),setTimeout(st);if(S.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:K(t.errors)&&!m,submitCount:t.submitCount+1,errors:t.errors}),m)throw m},Is=(i,c={})=>{v(a,i)&&(U(c.defaultValue)?h(i,B(v(n,i))):(h(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),T.isValid&&k()),S.state.next({...t}))},Tt=(i,c={})=>{const d=i?B(i):n,m=B(d),p=K(i),x=m,y=a;if(c.keepDefaultValues||(n=d),!c.keepValues){if(c.keepDirtyValues){const b=new Set([...u.mount,...Object.keys(Ee(n,l,void 0,y))]);for(const N of Array.from(b)){const H=v(t.dirtyFields,N),ee=v(l,N),xe=v(x,N);H&&!U(ee)?M(x,N,ee):!H&&!U(xe)&&h(N,xe)}}else{if(Je&&U(i))for(const b of u.mount){const N=v(a,b);if(N&&N._f){const H=Array.isArray(N._f.refs)?N._f.refs[0]:N._f.ref;if(Qe(H)){const ee=H.closest("form");if(ee){ee.reset();break}}}}if(c.keepFieldsRef)for(const b of u.mount)h(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);S.array.next({values:{...x}}),S.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=!T.isValid||!!c.keepIsValid||!!c.keepDirtyValues||!s.shouldUnregister&&!K(x),o.watch=!!s.shouldUnregister,o.keepIsValid=!!c.keepIsValid,o.action=!1,c.keepErrors||(t.errors={}),S.state.next({submitCount:c.keepSubmitCount?t.submitCount:0,isDirty:p?!1:c.keepDirty?t.isDirty:c.keepValues?w():!!(c.keepDefaultValues&&!ge(i,n)),isSubmitted:c.keepIsSubmitted?t.isSubmitted:!1,dirtyFields:p?{}:c.keepDirtyValues?c.keepDefaultValues&&l?Ee(n,l,void 0,y):t.dirtyFields:c.keepDefaultValues&&i?Ee(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(oe(i)?i(l):i,{...s.resetOptions,...c}),Ms=(i,c={})=>{const d=v(a,i),m=d&&d._f;if(m){const p=m.refs?m.refs[0]:m.ref;p.focus&&setTimeout(()=>{p.focus(),c.shouldSelect&&oe(p.select)&&p.select()})}},Ls=i=>{const{name:c,type:d,values:m,...p}=i;t={...t,...p}},kt={control:{register:tt,unregister:et,getFieldState:Re,handleSubmit:At,setError:Be,_subscribe:wt,_runSchema:F,_updateIsValidating:P,_focusError:st,_getWatch:re,_getDirty:w,_setValid:k,_setFieldArray:z,_setDisabledField:Nt,_setErrors:ae,_getFieldArray:Ae,_reset:Tt,_resetDefaultValues:()=>oe(s.defaultValues)&&s.defaultValues().then(i=>{Et(i,s.resetOptions),S.state.next({isLoading:!1})}),_removeUnmounted:me,_disableForm:Rs,_subjects:S,_proxyFormState:T,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},R=We(s.mode),I=We(s.reValidateMode)}},subscribe:Os,trigger:pe,register:tt,handleSubmit:At,watch:Fs,setValue:h,setValues:O,getValues:Te,reset:Et,resetField:Is,resetDefaultValues:(i,c={})=>{if(n=B(i),!c.keepDirty){const d=Ee(n,l,void 0,a);t.dirtyFields=d,t.isDirty=!K(d)}c.keepIsValid||k(),S.state.next({...t,defaultValues:n})},clearErrors:_e,unregister:et,setError:Be,setFocus:Ms,getFieldState:Re};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:oe(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1,defaultValues:oe(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&&!oe(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&&!ge(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()}},mt=(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&&mt(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 j;Object.defineProperty(u,"_zod",{value:u._zod??{},enumerable:!1}),(j=u._zod).traits??(j.traits=new Set),u._zod.traits.add(e),s(u,g);for(const A in o.prototype)A in u||Object.defineProperty(u,A,{value:o.prototype[A].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 j=t?.Parent?new l:this;a(j,u),(g=j._zod).deferred??(g.deferred=[]);for(const A of j._zod.deferred)A();return j}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 Ge(e){return typeof e=="string"?e:e?.message}function _s(e,s,t){const a={...e,path:e.path??[]};if(!e.message){const n=Ge(e.inst?._zod.def?.error?.(e))??Ge(s?.error?.(e))??Ge(t.customError?.(e))??Ge(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 pt(){return pt=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},pt.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(A){return A.errors.forEach(function(R){return e.push(R)})}),s){var g=t[o].types,j=g&&g[a.code];t[o]=jt(o,s,t,n,j?[].concat(j,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(R){return R.forEach(function(I){return e.push(pt({},I,{path:[].concat(n.path,I.path)}))})}),s){var j=t[u].types,A=j&&j[n.code];t[u]=jt(u,s,t,l,A?[].concat(A,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&&mt({},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&&mt({},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=Ze(),{pushError:t}=Gs(),{data:a}=os({...ls(),staleTime:1/0}),n=a?.accounts.find(g=>g.accountId===e)?.composeLanguages,l=D.useMemo(()=>n&&n.length>0?[...n]:Ks(navigator.languages),[n]),o=ye({...yt(),onSuccess:()=>{s.invalidateQueries({queryKey:we()})},onError:g=>{t(Qs("Couldn't save languages","The writing languages weren't saved.",g))}}),u=D.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="••••••••••",vi=e=>{const s=e.smtpUsername?.trim();return s?s!==e.username:!1},bi=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:Le(),imapStartTls:Le(),smtpHost:je().optional(),smtpPort:Vt.number().int().min(1).max(65535).optional(),smtpTls:Le().optional(),smtpStartTls:Le().optional(),smtpUsername:je().optional(),smtpPassword:je().optional(),useDifferentSmtpCreds:Le().optional()}),Si=({isOpen:e,onClose:s,account:t,focusSmtp:a})=>{const n=Ze(),l=!!t,[o,u]=D.useState(!1),[g,j]=D.useState(""),[A,R]=D.useState(!1),I=Rt(g),L=!!I&&!A,T=D.useRef(null),f=ri({resolver:hi(bi),defaultValues:{email:"",displayName:"",username:"",password:"",imapHost:"",imapPort:993,imapTls:!0,imapStartTls:!1,smtpHost:"",smtpPort:587,smtpTls:!1,smtpStartTls:!0,useDifferentSmtpCreds:!1}});D.useEffect(()=>{if(t){const h=vi(t);f.reset({email:t.email,displayName:t.displayName||"",username:t.username||"",password:xi,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:h&&t.smtpUsername||"",smtpPassword:"",useDifferentSmtpCreds:h}),u(!1)}else f.reset({email:"",displayName:"",username:"",password:"",imapHost:"",imapPort:993,imapTls:!0,imapStartTls:!1,smtpHost:"",smtpPort:587,smtpTls:!1,smtpStartTls:!0,useDifferentSmtpCreds:!1}),u(!1)},[t,f]);const S=ye({...Ys()}),ne=ye({...Zs(),onSuccess:()=>{n.invalidateQueries({queryKey:we()}),s()}}),E=ye({...yt(),onSuccess:()=>{n.invalidateQueries({queryKey:we()}),s()}}),_=()=>{const h=f.getValues(),O=l&&!o;S.mutate({body:{accountId:O?t?.accountId:void 0,username:h.username||h.email,password:O?void 0:h.password||void 0,imapHost:h.imapHost,imapPort:Number(h.imapPort),imapTls:h.imapTls,imapStartTls:h.imapStartTls}})},k=()=>{const h=f.getValues(),O=l&&!o;S.mutate({body:{accountId:O?t?.accountId:void 0,username:h.username||h.email,password:O?void 0:h.password||void 0,imapHost:h.imapHost,imapPort:Number(h.imapPort),imapTls:h.imapTls,imapStartTls:h.imapStartTls,smtpHost:h.smtpHost||void 0,smtpPort:h.smtpPort?Number(h.smtpPort):void 0,smtpTls:h.smtpTls,smtpStartTls:h.smtpStartTls,smtpUsername:h.useDifferentSmtpCreds?h.smtpUsername:void 0,smtpPassword:h.useDifferentSmtpCreds?h.smtpPassword:void 0}})},P=f.handleSubmit(h=>{if(!l&&!h.password){f.setError("password",{message:"Password is required"});return}const O=vr({imapHost:h.imapHost,smtpHost:h.smtpHost,smtpPort:h.smtpPort,smtpTls:h.smtpTls,smtpStartTls:h.smtpStartTls});O&&(f.setValue("smtpHost",O.smtpHost),f.setValue("smtpPort",O.smtpPort),f.setValue("smtpTls",O.smtpTls),f.setValue("smtpStartTls",O.smtpStartTls));const ce=O?.smtpHost??h.smtpHost,ie=O?.smtpPort??h.smtpPort,pe=O?.smtpTls??h.smtpTls,Te=O?.smtpStartTls??h.smtpStartTls,Re={email:h.email,displayName:h.displayName?.trim()||void 0,username:h.username||void 0,imapHost:h.imapHost,imapPort:Number(h.imapPort),imapTls:h.imapTls,imapStartTls:h.imapStartTls,smtpHost:ce||void 0,smtpPort:ie?Number(ie):void 0,smtpTls:pe,smtpStartTls:Te,smtpUsername:h.useDifferentSmtpCreds&&h.smtpUsername||void 0,smtpPassword:h.useDifferentSmtpCreds&&h.smtpPassword||void 0};if(l&&t){const _e={...Re,password:o?h.password:void 0};E.mutate({path:{accountId:t.accountId},body:_e})}else{const _e={...Re,password:h.password};ne.mutate({body:_e})}}),Z=ne.isPending||E.isPending,{signature:z,setSignature:fe,isSaving:ae}=xr(t?.accountId),[J,le]=D.useState(z.plainText),{languages:C,setLanguages:V,isSaving:F}=gi(t?.accountId),W=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:C,onChange:V,busy:F})]});D.useEffect(()=>{le(z.plainText)},[z.plainText]),D.useEffect(()=>{if(!e||!a)return;const h=T.current;if(!h)return;const O=window.setTimeout(()=>{h.scrollIntoView({behavior:"smooth",block:"start"})},250);return()=>window.clearTimeout(O)},[e,a]);const X=D.useCallback(()=>{J!==z.plainText&&fe(J,J)},[J,z.plainText,fe]),G=h=>{const{tls:O,startTls:ce}=qe(h);f.setValue("imapTls",O),f.setValue("imapStartTls",ce);const ie=f.getValues("imapPort");(ie===993||ie===143)&&f.setValue("imapPort",h==="tls"?993:143)},me=h=>{const{tls:O,startTls:ce}=qe(h);f.setValue("smtpTls",O),f.setValue("smtpStartTls",ce);const ie=f.getValues("smtpPort");if(ie===465||ie===587||ie===25){const Te=h==="tls"?465:h==="starttls"?587:25;f.setValue("smtpPort",Te)}},w=()=>{const h=f.getValues("imapHost");f.setValue("smtpHost",br(h)),f.setValue("smtpTls",!1),f.setValue("smtpStartTls",!0),f.setValue("smtpPort",587)},re=h=>{j(h),R(!1);const O=Rt(h);if(!O)return;const ce=qe(O.imap.security);f.setValue("imapHost",O.imap.host),f.setValue("imapPort",O.imap.port),f.setValue("imapTls",ce.tls),f.setValue("imapStartTls",ce.startTls);const ie=qe(O.smtp.security);f.setValue("smtpHost",O.smtp.host),f.setValue("smtpPort",O.smtp.port),f.setValue("smtpTls",ie.tls),f.setValue("smtpStartTls",ie.startTls);const pe=f.getValues("email").trim(),Te=f.getValues("username")?.trim();pe&&!Te&&f.setValue("username",pe)},Ae=I?.passwordHelp.text,Se=It(S.data?.imapError,Ae),ke=It(S.data?.smtpError,Ae);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:J,onChange:h=>le(h.target.value),onBlur:X,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:ae?"Saving signature...":"This signature will be appended to new emails."})]})})]}),l&&W]})}):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:Z,children:Z?"Saving...":"Save Account"})]}),children:r.jsxs("form",{id:"account-form",onSubmit:P,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:g,onChange:h=>re(h.target.value),children:[r.jsx("option",{value:"",children:"Custom / other"}),fr.map(h=>r.jsx("option",{value:h.id,children:h.label},h.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(be,{id:"account-email",...f.register("email"),placeholder:"alice@example.com"}),f.formState.errors.email&&r.jsx("p",{className:"text-sm text-danger mt-1",children:f.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(be,{id:"account-displayName",...f.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(be,{id:"account-username",...f.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",...f.register("password",{onChange:()=>u(!0)}),onFocus:()=>{l&&!o&&(f.setValue("password",""),u(!0))},placeholder:l?"Leave empty to keep current":""}),f.formState.errors.password&&r.jsx("p",{className:"text-sm text-danger mt-1",children:f.formState.errors.password.message}),I&&r.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[I.passwordHelp.text," ",r.jsx("a",{href:I.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)"}),I&&r.jsx("button",{type:"button",onClick:()=>R(h=>!h),className:"text-xs text-fg-muted hover:text-fg transition-colors",children:A?"Use preset settings":"Advanced"})]}),L&&r.jsxs("p",{className:"text-xs text-fg-muted mb-3",children:["Server settings are pre-filled for ",I?.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(be,{id:"imap-host",...f.register("imapHost"),readOnly:L,placeholder:"imap.example.com"}),f.formState.errors.imapHost&&r.jsx("p",{className:"text-sm text-danger mt-1",children:f.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(be,{id:"imap-port",...f.register("imapPort"),readOnly:L,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:L,checked:f.watch("imapTls"),onChange:()=>G("tls")}),"TLS (Port 993)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:L,checked:!f.watch("imapTls")&&f.watch("imapStartTls"),onChange:()=>G("starttls")}),"STARTTLS (Port 143)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:L,checked:!f.watch("imapTls")&&!f.watch("imapStartTls"),onChange:()=>G("none")}),"None (Unencrypted)"]})]})]})]}),r.jsx(se,{type:"button",variant:"secondary",onClick:_,disabled:S.isPending,className:"w-full",icon:S.isPending?r.jsx(nt,{className:"size-4 animate-spin"}):void 0,children:S.isPending?"Testing...":"Test IMAP Connection"}),S.data&&r.jsxs("div",{className:De("p-2 rounded-md text-sm",S.data.imapSuccess?"bg-positive/10 text-positive":"bg-danger-soft text-danger"),children:[S.data.imapSuccess?r.jsx(Ct,{className:"inline size-4 mr-1"}):r.jsx(Fe,{className:"inline size-4 mr-1"}),S.data.imapSuccess?"IMAP Connected":Se]})]})]}),r.jsxs("section",{ref:T,"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)"}),!L&&r.jsx("button",{type:"button",onClick:w,disabled:!f.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(be,{id:"smtp-host",...f.register("smtpHost"),readOnly:L,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(be,{id:"smtp-port",...f.register("smtpPort"),readOnly:L,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:L,checked:f.watch("smtpTls")===!0,onChange:()=>me("tls")}),"TLS (Port 465)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:L,checked:!f.watch("smtpTls")&&f.watch("smtpStartTls")===!0,onChange:()=>me("starttls")}),"STARTTLS (Port 587)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:L,checked:!f.watch("smtpTls")&&!f.watch("smtpStartTls"),onChange:()=>me("none")}),"None (Unencrypted)"]})]})]})]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"checkbox",...f.register("useDifferentSmtpCreds")}),"Use different credentials for SMTP"]}),f.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(be,{id:"smtp-username",...f.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",...f.register("smtpPassword")})]})]}),r.jsx(se,{type:"button",variant:"secondary",onClick:k,disabled:S.isPending||!f.watch("smtpHost"),className:"w-full",icon:S.isPending?r.jsx(nt,{className:"size-4 animate-spin"}):void 0,children:S.isPending?"Testing...":"Test SMTP Connection"}),S.data?.smtpSuccess!==void 0&&r.jsxs("div",{className:De("p-2 rounded-md text-sm",S.data.smtpSuccess?"bg-positive/10 text-positive":"bg-danger-soft text-danger"),children:[S.data.smtpSuccess?r.jsx(Ct,{className:"inline size-4 mr-1"}):r.jsx(Fe,{className:"inline size-4 mr-1"}),S.data.smtpSuccess?"SMTP Connected":ke]})]})]}),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:J,onChange:h=>le(h.target.value),onBlur:X,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:ae?"Saving signature...":"This signature will be appended to new emails."})]})})]}),l&&W]})})},ji="https://graph.microsoft.com/",wi={[ot.Mail]:["https://outlook.office.com/IMAP.AccessAsUser.All","https://outlook.office.com/SMTP.Send"],[ot.Calendar]:[`${ji}Calendars.Read`]},Ni=e=>{const s=new Set(e.map(t=>t.toLowerCase()));return Object.values(ot).filter(t=>wi[t].every(a=>s.has(a.toLowerCase())))},ht=e=>`Couldn't turn ${e.service.toLowerCase()} ${e.intent}`,Ai=e=>er(tr({title:`Bug: ${ht(e)}`,errorMessage:`${ht(e)} — ${e.message}`}));function Ti({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(lt,{tone:"danger",variant:"soft",children:[r.jsx("p",{className:"font-medium",children:ht(l)}),r.jsx("p",{className:"mt-0.5 break-words text-fg-muted",children:l.message}),r.jsx("a",{href:Ai(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 Ei({account:e,onRemoveAccount:s}){const t=Ze(),[a,n]=D.useState(null),[l,o]=D.useState(null),[u,g]=D.useState(null),j=ye({...yt(),meta:Dt,onSuccess:()=>t.invalidateQueries({queryKey:we()})}),A=ye({...cs(),meta:Dt}),R=us(_=>{const k=u;g(null),!(_!=="stalled"||k===null)&&o({service:k,intent:"on",message:fs})}),I=j.isPending&&j.variables?.body.syncedServices?j.variables.body.syncedServices:e.syncedServices,L=ss(e)?Vs:["Mail"],T=ss(e)?Ni(e.grantedScopes):L,f=(_,k,P)=>{o(null),j.mutate({path:{accountId:e.accountId},body:{syncedServices:_}},{onError:Z=>o({service:k,intent:P,message:Mt(Z)})})},S=_=>{o(null),A.mutate({body:{email:e.email,services:rs(I,_)}},{onSuccess:k=>{g(_),R(),window.location.assign(k.authorizationUrl)},onError:k=>o({service:_,intent:"on",message:Mt(k)})})},ne=(_,k)=>{if(k==="off"){n({kind:I.length===1?"last":"disable",service:_});return}if(!T.includes(_)){n({kind:"enable",service:_});return}f(rs(I,_),_,"on")},E=()=>{const _=a;if(n(null),_!==null){if(_.kind==="last"){s();return}if(_.kind==="enable"){S(_.service);return}f(I.filter(k=>k!==_.service),_.service,"off")}};return r.jsxs(r.Fragment,{children:[r.jsx(Ti,{providerName:ts,offered:L,enabled:I,consented:T,disabled:j.isPending||A.isPending||u!==null,refusal:l,onRequestChange:ne}),r.jsx(_r,{change:a,providerName:ts,onConfirm:E,onCancel:()=>n(null)})]})}function is({open:e,onClose:s,accountEmail:t,signOut:a}){const[n,l]=D.useState(""),[o,u]=D.useState(!1),[g,j]=D.useState(!1),A=ye({...rr(),onSuccess:()=>{j(!0),setTimeout(()=>a(),2e3)}}),R=ye(ir()),I=()=>{A.isPending||(l(""),u(!1),j(!1),A.reset(),R.reset(),s())},L=()=>{if(n.trim().toLowerCase()!==t.toLowerCase()){u(!0);return}u(!1),A.mutate({body:{confirmEmail:n.trim()}})};return r.jsxs(ds,{open:e,onClose:I,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(gt,{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(Fe,{className:"size-3.5"}),onClick:I,"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:()=>R.mutate({}),"aria-busy":R.isPending,className:"inline-flex items-center gap-1.5 font-medium text-accent hover:underline",children:[r.jsx(wr,{className:"size-3.5"}),R.isPending?"Requesting export…":"Export my data first"]}),R.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."}),R.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(be,{id:"confirm-remit-email",type:"email",placeholder:t,value:n,onChange:T=>{l(T.target.value),o&&u(!1),A.isError&&A.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."}),A.isError&&r.jsx("p",{className:"mt-1.5 text-xs text-danger",role:"alert",children:A.error instanceof Error?A.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:I,children:"Cancel"}),r.jsx(se,{variant:"danger",size:"sm",onClick:L,"aria-busy":A.isPending,children:A.isPending?"Deleting…":"Delete everything"})]})]})]})}function ki(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 _i(){const[e,s]=D.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(ki,{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 Pi=e=>e.length>1?`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`:e[0]??"";function Ci(e,s){const t=(e.missingServices??"").split(","),a=ct.filter(j=>t.includes(j.id)),n=e.oauthEmail,l=n?s.find(j=>j.authType==="oauthMicrosoft"&&j.email.toLowerCase()===n.toLowerCase()):void 0,o=Pi(a.map(j=>j.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?ct.filter(j=>l.syncedServices.includes(j.id)||a.some(A=>A.id===j.id)).map(j=>j.id):void 0;return{kind:"refused",message:u,email:n,services:g,reconnect:!!l}}function Vi(e){const s=e.split("@")[0]??"";return s?s.split(/[._-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" "):e}function Di(e){const s=e.displayName?.trim();return s||Vi(e.email)}function Fi(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 Oi(e){return e.connectionState==="credentials_missing"}const Ri=()=>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 na(){const e=Ft.useSearch(),s=ar({from:Ft.fullPath}),[t,a]=D.useState(!0),[n,l]=D.useState(!1),[o,u]=D.useState(!1),[g,j]=D.useState(void 0),[A,R]=D.useState(null),[I,L]=D.useState(!1),[T,f]=D.useState(null),[S,ne]=D.useState(null),[E,_]=D.useState(null),[k,P]=D.useState(null),Z=Ze(),{data:z,isPending:fe,isError:ae,error:J,refetch:le}=os(ls());D.useEffect(()=>{e.editAccountId&&(R(e.editAccountId),L(!!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]),D.useEffect(()=>{e.connected&&(j({kind:"connected",accountId:e.connected}),u(!0),Z.invalidateQueries({queryKey:we()}),s({search:{connected:void 0,oauthError:void 0,editAccountId:void 0,focusSmtp:void 0},replace:!0}))},[e.connected,s,Z]),D.useEffect(()=>{if(!e.oauthError)return;const w=e.oauthError==="scope_not_granted";w&&!z&&!ae||(P(null),w?(j(Ci({oauthEmail:e.oauthEmail,missingServices:e.missingServices},z?.accounts??[])),u(!0)):_(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,z,ae,s]),yr(k!==null,()=>{Z.invalidateQueries({queryKey:we()})}),D.useEffect(()=>{if(!k||!z)return;const w=z.accounts.find(re=>re.accountId===k);(!w||!ns(w))&&P(null)},[z,k]);const C=us(w=>{P(null),w==="stalled"&&_(fs)}),V=ye({...cs(),onSuccess:w=>{C(),window.location.assign(w.authorizationUrl)},onError:w=>{_(w instanceof Error?w.message:"Failed to start reconnect"),P(null)}}),F=ye({...nr(),onSuccess:()=>{Z.invalidateQueries({queryKey:we()}),f(null)}}),W=z?.accounts.find(w=>w.accountId===T),X=z?.accounts.find(w=>w.accountId===A),G=()=>{l(!1),u(!1),R(null),L(!1)},me=w=>{const re=cr[w];re&&s({to:re})};return r.jsxs(hr,{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:me,onBackToMail:()=>{s({to:"/mail"})},children:[S&&r.jsx(lt,{tone:"success",variant:"soft","data-testid":"oauth-success-banner",onDismiss:()=>ne(null),children:S}),E&&r.jsx(lt,{tone:"danger",variant:"soft","data-testid":"oauth-error-banner",onDismiss:()=>_(null),children:E}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(lr,{tone:"neutral",children:fe||ae?"accounts":`${z.accounts.length} ${z.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"})]}),fe?r.jsx(Ri,{}):ae?r.jsx(jr,{title:"Couldn't load accounts",error:J,onRetry:()=>{le()}}):z.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:z.accounts.map(w=>{const re=ns(w),Ae=Oi(w),Se=w.authType==="oauthMicrosoft",ke=k===w.accountId,Oe=re&&Se?{label:"Reconnect",variant:"secondary",busy:ke,busyLabel:"Redirecting…",onClick:()=>{P(w.accountId),V.mutate({body:{email:w.email,services:w.syncedServices}})}}:Ae?{label:"Enter password",variant:"secondary",onClick:()=>R(w.accountId)}:as(w)==="error"?{label:"Reconnect",variant:"secondary",onClick:()=>R(w.accountId)}:{label:"Manage",variant:"ghost",onClick:()=>R(w.accountId)},h=r.jsx(pr,{actions:[Oe],destructive:{label:"Delete account",iconOnly:!0,icon:r.jsx(dr,{className:"size-3.5"}),onClick:()=>f(w.accountId)}});return r.jsxs("div",{className:"space-y-2",children:[r.jsx(gr,{label:Di(w),email:w.email,connector:Se?"Microsoft 365":"IMAP",syncLabel:Fi(w),state:as(w),errorDetail:re?w.lastError??"Re-authentication required":Ae?"Imported from a config file, which carries no password. Enter one to start syncing.":w.lastError,trailing:h}),r.jsx(Ei,{account:w,onRemoveAccount:()=>f(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"&&ne("Account connected successfully."),u(!1),j(void 0),Z.invalidateQueries({queryKey:we()})},onCancel:()=>{u(!1),j(void 0)}})}),r.jsx(Si,{isOpen:n||!!A,account:X,focusSmtp:I,onClose:G}),r.jsxs(ds,{open:!!T,onClose:()=>f(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(gt,{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(Fe,{className:"size-3.5"}),onClick:()=>f(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?"}),W&&r.jsx("p",{className:"text-center",children:W.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:()=>f(null),children:"Cancel"}),r.jsx(se,{variant:"danger",size:"sm","aria-busy":F.isPending,icon:F.isPending?r.jsx(nt,{className:"size-3.5 animate-spin"}):void 0,onClick:()=>{F.isPending||T&&F.mutate({path:{accountId:T}})},children:F.isPending?"Deleting…":"Delete account"})]})]}),r.jsx(_i,{})]})}export{na as component,Ds as mapOauthError,Ci as scopeRefusalReturn};
|
|
1
|
+
import{j as r,r as D,t as De,ao as Ve,f as se,Z as zs,X as Fe,ap as $s,aq as Bs,ar as gt,G as qs,H as Ws,as as te,h as Ze,at as Gs,c as os,d as ls,au as Ks,i as ye,av as Qs,o as we,l as yt,aw as Ys,ax as Zs,ay as Js,az as be,aA as Pt,L as nt,aB as Ct,aC as Xs,aD as Le,aE as je,aF as Vt,aG as ot,B as lt,aH as er,aI as tr,aJ as Dt,n as cs,ab as sr,aK as rr,aL as ir,aM as ds,aN as Ft,u as ar,aO as nr,aP as or,g as lr,aQ as Ot,aR as cr,a3 as dr,aS as ur}from"./index-J89guRVU.js";import{A as ct,g as Rt,P as fr,O as mr}from"./OnboardingWizard-CrpfDnhV.js";import{R as pr}from"./row-actions-C0iitOlE.js";import{S as hr,A as gr}from"./settings-screen-CPKUaFTz.js";import{s as qe,b as us,R as fs,u as yr}from"./credential-steps-8oD-bgsd.js";import{u as xr}from"./useSignature-z9_OAiTD.js";import{c as vr,a as It,d as br}from"./account-form-helpers-DhckT_PN.js";import{C as Sr}from"./confirm-dialog-DM1V3tLO.js";import{f as Mt,E as jr}from"./ErrorState-CX8jPS64.js";import{D as wr}from"./download-D3c-jAvE.js";import{a as Nr}from"./help-copy-Bfcrl0wG.js";import"./checkbox-lv4ht1p0.js";import"./minus-oqpCotLr.js";import"./kbd-CKw25IK5.js";import"./mail-Daw23XZE.js";import"./file-json-DgAW6fCg.js";import"./avatar-CMrR_WCW.js";import"./chevron-left-BnXYRBLM.js";import"./menu-lOydIsUw.js";import"./circle-help-CxlWBIxf.js";import"./card-ChUQkNyW.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(Sr,{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:De("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:De("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=D.useId(),u=ct.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 j=t.includes(g.id),A=`${o}-${g.id}`,R=!j&&!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:A,className:"text-xs text-fg-subtle",children:R?`${g.description} Turning this on means signing in with ${e} again.`:g.description})]}),r.jsx(Pr,{checked:j,label:`Sync ${g.label.toLowerCase()}`,describedBy:A,disabled:n,onToggle:()=>l(g.id,j?"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)=>Ve(t).localeCompare(Ve(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:Ve(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 ${Ve(n)} by default`,onClick:()=>s([n,...e.filter(o=>o!==n)]),children:"Default"}),r.jsx(se,{variant:"ghost",size:"sm",icon:r.jsx(Fe,{className:"size-3.5"}),disabled:t||e.length===1,"aria-label":`Remove ${Ve(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:Ve(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(gt,{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=D.useRef(null);return Ws(l,e),r.jsxs(r.Fragment,{children:[r.jsx("div",{className:De("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:De("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(Fe,{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 ze=e=>e.type==="checkbox",Ne=e=>e instanceof Date,Q=e=>e==null;const xt=e=>typeof e=="object";var $=e=>!Q(e)&&!Array.isArray(e)&&xt(e)&&!Ne(e),Or=e=>$(e)&&e.target?ze(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 $(s)&&s.hasOwnProperty("isPrototypeOf")},Je=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(Je&&(e instanceof Blob||s))return e;const t=Array.isArray(e);if(!t&&!($(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 Pe={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",vt=["__proto__","constructor","prototype"],Ir=/^\w*$/;var $e=e=>Ir.test(e),U=e=>e===void 0;const Mr=/[.[\]'"]/;var Xe=e=>e.split(Mr).filter(Boolean),v=(e,s,t)=>{if(!s||!$(e))return t;const a=$e(s)?[s]:Xe(s);if(a.some(l=>vt.includes(l)))return t;const n=a.reduce((l,o)=>Q(l)?void 0:l[o],e);return U(n)||n===e?U(e[s])?t:e[s]:n},he=e=>typeof e=="boolean",oe=e=>typeof e=="function",M=(e,s,t)=>{let a=-1;const n=$e(s)?[s]:Xe(s),l=n.length,o=l-1;for(;++a<l;){const u=n[a];let g=t;if(a!==o){const j=e[u];g=$(j)||Array.isArray(j)?j:isNaN(+n[a+1])?{}:[]}if(vt.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=Je?te.useLayoutEffect:te.useEffect;var Y=e=>typeof e=="string",zr=(e,s,t,a,n)=>Y(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),dt=e=>Q(e)||!xt(e);const Ut=(e,s)=>s.length===0&&!Array.isArray(e)&&!ms(e);function ge(e,s,t=new WeakMap){if(e===s)return!0;if(dt(e)||dt(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)||($(u)||Array.isArray(u))&&($(g)||Array.isArray(g))?!ge(u,g,t):!Object.is(u,g))return!1}}return!0}var We=e=>({isOnSubmit:!e||e===ue.onSubmit,isOnBlur:e===ue.onBlur,isOnChange:e===ue.onChange,isOnAll:e===ue.all,isOnTouch:e===ue.onTouched}),rt=(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 He=(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(He(u,s))break}else if($(u)&&He(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},K=e=>$(e)&&!Object.keys(e).length,bt=e=>e.type==="file",Qe=e=>{if(!Je)return!1;const s=e?e.ownerDocument:0;return e instanceof(s&&s.defaultView?s.defaultView.HTMLElement:HTMLElement)},St=e=>e.type==="radio",Ye=e=>e instanceof RegExp,jt=(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&&!U(e[0].attributes.value)?U(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(Y(e)||Array.isArray(e)&&e.every(Y)||he(e)&&!e)return{type:t,message:Y(e)?e:"",ref:s}}var Ce=e=>$(e)&&!Ye(e)?e:{value:e,message:""},Wt=async(e,s,t,a,n,l)=>{const{ref:o,refs:u,required:g,maxLength:j,minLength:A,min:R,max:I,pattern:L,validate:T,name:f,valueAsNumber:S,mount:ne}=e._f,E=v(t,f);if(!ne||s.has(f))return{};const _=u?u[0]:o,k=C=>{if(n&&_.reportValidity){const V=he(C)?"":C||"";u?u.forEach(F=>F.setCustomValidity(V)):_.setCustomValidity(V),_.reportValidity()}},P={},Z=St(o),z=ze(o),fe=Z||z,ae=(S||bt(o))&&U(o.value)&&U(E)||Qe(o)&&o.value===""||E===""||Array.isArray(E)&&!E.length,J=jt.bind(null,f,a,P),le=(C,V,F,W=de.maxLength,X=de.minLength)=>{const G=C?V:F;P[f]={type:C?W:X,message:G,ref:o,...J(C?W:X,G)}};if(l?!Array.isArray(E)||!E.length:g&&(!fe&&(ae||Q(E))||he(E)&&!E||z&&!hs(u).isValid||Z&&!gs(u).isValid)){const{value:C,message:V}=Y(g)?{value:!!g,message:g}:Ce(g);if(C&&(P[f]={type:de.required,message:V,ref:_,...J(de.required,V)},!a))return k(V),P}if(!ae&&(!Q(R)||!Q(I))){let C,V;const F=Ce(I),W=Ce(R);if(!Q(E)&&!isNaN(E)){const X=o.valueAsNumber||E&&+E;Q(F.value)||(C=X>F.value),Q(W.value)||(V=X<W.value)}else{const X=o.valueAsDate||new Date(E),G=re=>new Date(new Date().toDateString()+" "+re),me=o.type=="time",w=o.type=="week";Y(F.value)&&E&&(C=me?G(E)>G(F.value):w?E>F.value:X>new Date(F.value)),Y(W.value)&&E&&(V=me?G(E)<G(W.value):w?E<W.value:X<new Date(W.value))}if((C||V)&&(le(!!C,F.message,W.message,de.max,de.min),!a))return k(P[f].message),P}if((j||A)&&!ae&&(Y(E)||l&&Array.isArray(E))){const C=Ce(j),V=Ce(A),F=!Q(C.value)&&E.length>+C.value,W=!Q(V.value)&&E.length<+V.value;if((F||W)&&(le(F,C.message,V.message),!a))return k(P[f].message),P}if(L&&!ae&&Y(E)){const{value:C,message:V}=Ce(L);if(Ye(C)&&!E.match(C)&&(P[f]={type:de.pattern,message:V,ref:o,...J(de.pattern,V)},!a))return k(V),P}if(T){if(oe(T)){const C=await T(E,t),V=qt(C,_);if(V&&(P[f]={...V,...J(de.validate,V.message)},!a))return k(V.message),P}else if($(T)){let C={};for(const V in T){if(!K(C)&&!a)break;const F=qt(await T[V](E,t),_,V);F&&(C={...F,...J(V,F.message)},k(F.message),a&&(P[f]=C))}if(!K(C)&&(P[f]={ref:_,...C},!a))return P}}return k(!0),P},Ke=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(Q(e)){e=void 0;break}e=e[s[a]],a++}return e}function Br(e){for(const s in e)if(e.hasOwnProperty(s)&&!U(e[s]))return!1;return!0}function q(e,s){if(Y(s)&&Object.prototype.hasOwnProperty.call(e,s))return delete e[s],e;const t=Array.isArray(s)?s:$e(s)?[s]:Xe(s);if(t.some(o=>vt.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&&($(a)&&K(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(xt(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&&$(n)&&l){const o=vs(n,l);$(o)&&(t[a]=o)}else e[a]&&(t[a]=l)}return t}var bs=e=>e.type==="select-multiple",Wr=e=>St(e)||ze(e),it=e=>Qe(e)&&e.isConnected,Gr=e=>{for(const s in e)if(oe(e[s]))return!0;return!1};function Ss(e){return Array.isArray(e)||$(e)&&!Gr(e)}function js(e){return!!(e&&"_f"in e)}function ws(e){return Array.isArray(e)?!e.some(s=>!U(s)):!Object.keys(e).length}function ut(e,s){Array.isArray(e)?e[s]=void 0:delete e[s]}function ft(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)?[]:{},ft(n,s[a],l),ws(s[a])&&ut(s,a)):U(n)||(s[a]=!0)}return s}function Ee(e,s,t,a){t||(t=ft(s,{},a));for(const n in e){const l=e[n],o=a&&a[n];Ss(l)&&(!Array.isArray(l)||!js(o))?(U(s)||dt(t[n])?t[n]=ft(l,Array.isArray(l)?[]:{},o):Ee(l,Q(s)?{}:s[n],t[n],o),ws(t[n])&&ut(t,n)):ge(l,s[n])?ut(t,n):t[n]=!0}return t}var Ns=(e,{valueAsNumber:s,valueAsDate:t,setValueAs:a})=>U(e)?e:s?e===""?NaN:e&&+e:t&&Y(e)?new Date(e):a?a(e):e;function Kt(e){const s=e.ref;return bt(s)?s.files:St(s)?gs(e.refs).value:bs(s)?[...s.selectedOptions].map(({value:t})=>t):ze(s)?hs(e.refs).value:Ns(U(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}},Ue=e=>U(e)?e:Ye(e)?e.source:$(e)?Ye(e.value)?e.value.source:e.value:e;const Qt="AsyncFunction";var Qr=e=>{if(!e||!e.validate)return!1;if(oe(e.validate))return e.validate.constructor.name===Qt;if($(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||$e(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||Ke(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},at="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:oe(s.defaultValues),errors:s.errors||{},disabled:s.disabled||!1},a={},n=$(s.defaultValues)||$(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={},j={};let A=0,R=We(s.mode),I=We(s.reValidateMode);const L={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},T={...L};let f={...T};const S={array:Gt(),state:Gt()};let ne=0;const E=s.criteriaMode===ue.all,_=(i,c)=>d=>{clearTimeout(j[i]),j[i]=setTimeout(c,d)},k=async i=>{if(!o.keepIsValid&&!s.disabled&&(T.isValid||f.isValid||i)){const c=++ne;let d;s.resolver?(d=K((await F()).errors),c===ne&&P()):d=await G({fields:a,onlyCheckValid:!0,eventType:Pe.VALID}),c===ne&&d!==t.isValid&&S.state.next({isValid:d})}},P=(i,c)=>{!s.disabled&&(T.isValidating||T.validatingFields||f.isValidating||f.validatingFields)&&((i||Array.from(u.mount)).forEach(d=>{d&&(c?M(t.validatingFields,d,c):q(t.validatingFields,d))}),S.state.next({validatingFields:t.validatingFields,isValidating:!K(t.validatingFields)}))},Z=()=>{t.dirtyFields=Ee(n,l,void 0,a)},z=(i,c=[],d,m,p=!0,x=!0)=>{if(m&&d&&!s.disabled){if(o.action=!0,x&&Array.isArray(v(a,i))){const y=d(v(a,i),m.argA,m.argB);p&&M(a,i,y)}if(x&&Array.isArray(v(t.errors,i))){const y=d(v(t.errors,i),m.argA,m.argB);p&&M(t.errors,i,y),ei(t.errors,i)}if((T.touchedFields||f.touchedFields)&&x&&Array.isArray(v(t.touchedFields,i))){const y=d(v(t.touchedFields,i),m.argA,m.argB);p&&M(t.touchedFields,i,y)}(T.dirtyFields||f.dirtyFields)&&Z(),S.state.next({name:i,isDirty:w(i,c),dirtyFields:t.dirtyFields,errors:t.errors,isValid:t.isValid})}else M(l,i,c)},fe=(i,c)=>{M(t.errors,i,c),t.errors={...t.errors},S.state.next({errors:t.errors})},ae=i=>{t.errors=i,S.state.next({errors:t.errors,isValid:!1})},J=i=>{const c=$e(i)?[i]:Xe(i);let d=l,m=n;for(let p=0;p<c.length-1;p++){const x=c[p];if(d=Q(d)?d:d[x],m=Q(m)?m:m[x],d===null&&m!==null)return!0}return!1},le=(i,c,d,m)=>{const p=v(a,i);if(p){if(J(i))return;const x=U(v(l,i)),y=v(l,i,U(d)?v(n,i):d);U(y)||m&&m.defaultChecked||c?M(l,i,c?y:Kt(p._f)):Se(i,y),o.mount&&!o.action&&(k(),x&&t.isDirty&&(T.isDirty||f.isDirty)&&(w()||(t.isDirty=!1,S.state.next({...t}))),e.shouldUnregister&&x&&!U(v(l,i))&&rt(i,u)&&(o.watch=!0))}},C=(i,c,d,m,p)=>{let x=!1,y=!1;const b={name:i};if(!s.disabled||m===!0){if(!d||m){const N=ge(v(n,i),c);(T.isDirty||f.isDirty)&&(y=t.isDirty,t.isDirty=b.isDirty=!N||w(),x=y!==b.isDirty),y=!!v(t.dirtyFields,i),N!==t.isDirty?t.dirtyFields=Ee(n,l,void 0,a):N?q(t.dirtyFields,i):M(t.dirtyFields,i,!0),b.dirtyFields=t.dirtyFields,x=x||(T.dirtyFields||f.dirtyFields)&&y!==!N}if(d){const N=v(t.touchedFields,i);N||(M(t.touchedFields,i,d),b.touchedFields=t.touchedFields,x=x||(T.touchedFields||f.touchedFields)&&N!==d)}x&&p&&S.state.next(b)}return x?b:{}},V=(i,c,d,m)=>{const p=v(t.errors,i),x=(T.isValid||f.isValid)&&he(c)&&t.isValid!==c;if(s.delayError&&d?(g[i]=_(i,()=>fe(i,d)),g[i](s.delayError)):(clearTimeout(j[i]),delete g[i],d?M(t.errors,i,d):q(t.errors,i),t.errors={...t.errors}),(d?!ge(p,d):p)||!K(m)||x){const y={...m,...x&&he(c)?{isValid:c}:{},errors:t.errors,name:i};t={...t,...y},S.state.next(y)}},F=async i=>(P(i,!0),await s.resolver(l,s.context,Kr(i||u.mount,a,s.criteriaMode,s.shouldUseNativeValidation))),W=async i=>{const{errors:c}=await F(i);if(P(i),i){for(const d of i){const m=v(c,d);m?u.array.has(d)&&$(m)&&!Object.keys(m).some(p=>!Number.isNaN(Number(p)))?Ht(t.errors,{[d]:m},d):M(t.errors,d,m):q(t.errors,d)}t.errors={...t.errors}}else t.errors=c;return c},X=async({name:i,eventType:c})=>{if(e.validate){const d=await e.validate({formValues:l,formState:t,name:i,eventType:c});if($(d))for(const m in d){const p=d[m];p&&Be(`${at}.${m}`,{message:Y(p.message)?p.message:"",type:p.type||de.validate})}else Y(d)||!d?Be(at,{message:d||"",type:de.validate}):_e(at);return d}return!0},G=async({fields:i,onlyCheckValid:c,name:d,eventType:m,context:p={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(p.runRootValidation=!0,!await X({name:d,eventType:m})&&(p.valid=!1,c)))return p.valid;for(const x in i){const y=i[x];if(y){const{_f:b,...N}=y;if(b){const H=u.array.has(b.name),ee=y._f&&Qr(y._f),xe=T.validatingFields||T.isValidating||f.validatingFields||f.isValidating;ee&&xe&&P([b.name],!0);const ve=await Wt(y,u.disabled,l,E,s.shouldUseNativeValidation&&!c,H);if(ee&&xe&&P([b.name]),ve[b.name]&&(p.valid=!1,c)||(!c&&(v(ve,b.name)?H?Ht(t.errors,ve,b.name):M(t.errors,b.name,ve[b.name]):q(t.errors,b.name)),e.shouldUseNativeValidation&&ve[b.name]))break}!K(N)&&await G({context:p,onlyCheckValid:c,fields:N,name:x,eventType:m})}}return p.valid},me=()=>{for(const i of u.unMount){const c=v(a,i);c&&(c._f.refs?c._f.refs.every(d=>!it(d)):!it(c._f.ref))&&et(i)}u.unMount=new Set},w=(i,c)=>(i&&c&&M(l,i,c),!ge(o.mount?l:n,n)),re=(i,c,d)=>zr(i,u,{...o.mount?l:U(c)?n:Y(i)?{[i]:c}:c},d,c),Ae=i=>ys(v(o.mount?l:n,i,s.shouldUnregister?v(n,i,[]):[])),Se=(i,c,d={},m=!1,p=!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=Qe(b.ref)&&Q(c)?"":c,bs(b.ref)?[...b.ref.options].forEach(N=>N.selected=y.includes(N.value)):b.refs?ze(b.ref)?b.refs.forEach(N=>{(!N.defaultChecked||!N.disabled)&&(Array.isArray(y)?N.checked=!!y.find(H=>H===N.value):N.checked=y===N.value||!!y)}):b.refs.forEach(N=>N.checked=N.value===y):bt(b.ref)?b.ref.value="":(b.ref.value=y,!b.ref.type&&!p&&S.state.next({name:i,values:m?l:B(l)})))}(d.shouldDirty||d.shouldTouch)&&C(i,y,d.shouldTouch,d.shouldDirty,!p),d.shouldValidate&&pe(i,{delayError:d.delayError})},ke=(i,c,d,m=!1,p=!1)=>{for(const x in c){if(!c.hasOwnProperty(x))return;const y=c[x],b=i+"."+x,N=v(a,b);(u.array.has(i)||$(y)||N&&!N._f)&&!Ne(y)?ke(b,y,d,m,p):Se(b,y,d,m,p)}},Oe=(i,c,d,m,p=!1)=>{const x=v(a,i),y=u.array.has(i),b=m?c:B(c),N=v(l,i),H=ge(N,b);if(H||M(l,i,b),y)S.array.next({name:i,values:m?l:B(l)}),(T.isDirty||T.dirtyFields||f.isDirty||f.dirtyFields)&&d.shouldDirty&&(Z(),p||S.state.next({name:i,dirtyFields:t.dirtyFields,isDirty:w(i,b)}));else{const ee=Array.isArray(b)&&!b.length||K(b);!x||x._f||Q(b)||ee?Se(i,b,d,m,p):ke(i,b,d,m,p)}if(!H&&!p){const ee=rt(i,u),xe=m?l:B(l);S.state.next({...ee&&t,name:o.mount||ee?i:void 0,values:xe})}},h=(i,c,d={})=>Oe(i,c,d,!1),O=(i,c={})=>{const d=oe(i)?i(l):i;if(!ge(l,d)){l={...l,...d};const m=xs(d);for(const p of u.mount)p in m&&Oe(p,m[p],c,!0,!0);S.state.next({...t,name:void 0,type:void 0,...A?{values:l}:{}}),c.shouldValidate&&k()}},ce=async i=>{o.mount=!0;const c=i.target;let d=c.name,m=!0;const p=v(a,d),x=y=>{m=Number.isNaN(y)||Ne(y)&&isNaN(y.getTime())||ge(y,v(l,d,y))};if(p){let y,b;const N=c.type?Kt(p._f):Or(i),H=i.type===Pe.BLUR||i.type===Pe.FOCUS_OUT,ee=!Yr(p._f)&&!e.validate&&!s.resolver&&!v(t.errors,d)&&!p._f.deps,xe=ee||Xr(H,v(t.touchedFields,d),t.isSubmitted,I,R),ve=rt(d,u,H);if(M(l,d,N),H){if(!c||!c.readOnly){p._f.onBlur&&p._f.onBlur(i);const Me=g[d];Me&&Me(0)}}else p._f.onChange&&p._f.onChange(i);const Ie=C(d,N,H),Us=!K(Ie)||ve;if(!H&&S.state.next({name:d,type:i.type,...A?{values:B(l)}:{}}),xe)return(!ee||!t.isValid)&&(T.isValid||f.isValid)&&(s.mode==="onBlur"?H&&k():H||k()),Us&&S.state.next({name:d,...ve?{}:Ie});if(!s.resolver&&e.validate&&await X({name:d,eventType:i.type}),!H&&ve&&S.state.next({...t}),s.resolver){const{errors:Me}=await F([d]);if(P([d]),x(N),!m){!K(Ie)&&S.state.next(Ie);return}const Hs=Yt(t.errors,a,d),_t=Yt(Me,a,Hs.name||d);y=_t.error,d=_t.name,b=K(Me)}else P([d],!0),y=(await Wt(p,u.disabled,l,E,s.shouldUseNativeValidation))[d],P([d]),x(N),m&&(y?b=!1:(T.isValid||f.isValid)&&(b=await G({fields:a,onlyCheckValid:!0,name:d,eventType:i.type})));m&&(p._f.deps&&(!Array.isArray(p._f.deps)||p._f.deps.length>0)&&pe(p._f.deps),V(d,b,y,Ie))}},ie=(i,c)=>{if(v(t.errors,c)&&i.focus)return i.focus(),1},pe=async(i,c={})=>{let d,m;const p=Ke(i);if(s.resolver){const x=await W(U(i)?i:p);d=K(x),m=i?!p.some(y=>v(x,y)):d}else i?(m=(await Promise.all(p.map(async x=>{const y=v(a,x);return await G({fields:y&&y._f?{[x]:y}:y,eventType:Pe.TRIGGER})}))).every(Boolean),!(!m&&!t.isValid)&&k()):m=d=await G({fields:a,name:i,eventType:Pe.TRIGGER});if(c.delayError&&s.delayError&&Y(i)){const x=v(t.errors,i);x?(q(t.errors,i),g[i]=_(i,()=>fe(i,x)),g[i](s.delayError)):(clearTimeout(j[i]),delete g[i])}return S.state.next({...!Y(i)||(T.isValid||f.isValid)&&d!==t.isValid?{}:{name:i},...s.resolver||!i?{isValid:d}:{},errors:t.errors}),c.shouldFocus&&!m&&He(a,ie,i?p:u.mount),m},Te=(i,c)=>{let d={...o.mount?l:n};return c&&(d=vs(c.dirtyFields?t.dirtyFields:t.touchedFields,d)),U(i)?d:Y(i)?v(d,i):i.map(m=>v(d,m))},Re=(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)}),_e=i=>{const c=i?Ke(i):void 0;c?.forEach(d=>q(t.errors,d)),c?c.forEach(d=>{S.state.next({name:d,errors:t.errors})}):S.state.next({errors:{}})},Be=(i,c,d)=>{const m=(v(a,i,{_f:{}})._f||{}).ref,p=v(t.errors,i)||{},{ref:x,message:y,type:b,...N}=p;M(t.errors,i,{...N,...c,ref:m}),S.state.next({name:i,errors:t.errors,isValid:!1}),d&&d.shouldFocus&&m&&m.focus&&m.focus()},Fs=(i,c)=>{if(oe(i)){A++;const{unsubscribe:d}=S.state.subscribe({next:p=>"values"in p&&i(p.values||re(void 0,c),p)});let m=!1;return{unsubscribe:()=>{m||(m=!0,A--,d())}}}return re(i,c,!0)},wt=i=>{var c;const d=!!(!((c=i.formState)===null||c===void 0)&&c.values);d&&A++;const{unsubscribe:m}=S.state.subscribe({next:x=>{if(Jr(i.name,x.name,i.exact)&&Zr(x,i.formState||T,Ls,i.reRenderRoot)){const y={...l};i.callback({values:y,...t,...x,defaultValues:n})}}});if(!d)return m;let p=!1;return()=>{p||(p=!0,A--,m())}},Os=i=>(o.mount=!0,f={...f,...i.formState},wt({...i,formState:{...L,...i.formState}})),et=(i,c={})=>{for(const d of i?Ke(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);S.state.next({values:B(l)}),S.state.next({...t,...c.keepDirty?{isDirty:w()}:{}}),!c.keepIsValid&&k()},Nt=({disabled:i,name:c})=>{if(he(i)&&o.mount||i||u.disabled.has(c)){const p=u.disabled.has(c)!==!!i;i?u.disabled.add(c):u.disabled.delete(c),p&&o.mount&&!o.action&&k()}},tt=(i,c={})=>{let d=v(a,i);const m=he(c.disabled)||he(s.disabled),p=!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&&!p?Nt({disabled:he(c.disabled)?c.disabled:s.disabled,name:i}):le(i,!0,c.value),{...m?{disabled:c.disabled||s.disabled}:{},...s.progressive?{required:!!c.required,min:Ue(c.min),max:Ue(c.max),minLength:Ue(c.minLength),maxLength:Ue(c.maxLength),pattern:Ue(c.pattern)}:{},name:i,onChange:ce,onBlur:ce,ref:x=>{if(x){u.registerName.add(i),tt(i,c),u.registerName.delete(i),d=v(a,i);const y=U(x.value)&&x.querySelectorAll&&x.querySelectorAll("input,select,textarea")[0]||x,b=Wr(y),N=d._f.refs||[];if(b?N.find(H=>H===y):y===d._f.ref)return;M(a,i,{_f:{...d._f,...b?{refs:[...N.filter(it),y,...Array.isArray(v(n,i))?[{}]:[]],ref:{type:y.type,name:i}}:{ref:y}}}),le(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)}}},st=()=>s.shouldFocusError&&!s.shouldUseNativeValidation&&He(a,ie,u.mount),Rs=i=>{he(i)&&(S.state.next({disabled:i}),He(a,(c,d)=>{const m=v(a,d);m&&(c.disabled=m._f.disabled||i,Array.isArray(m._f.refs)&&m._f.refs.forEach(p=>{p.disabled=m._f.disabled||i}))},0,!1))},At=(i,c)=>async d=>{let m;d&&(d.preventDefault&&d.preventDefault(),d.persist&&d.persist());let p=B(l);if(S.state.next({isSubmitting:!0}),s.resolver){const{errors:x,values:y}=await F();P(),t.errors=x,p=B(y)}else await G({fields:a,eventType:Pe.SUBMIT});if(u.disabled.size)for(const x of u.disabled)q(p,x);if(q(t.errors,ps),K(t.errors)){S.state.next({errors:{}});try{await i(p,d)}catch(x){m=x}}else c&&await c({...t.errors},d),st(),setTimeout(st);if(S.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:K(t.errors)&&!m,submitCount:t.submitCount+1,errors:t.errors}),m)throw m},Is=(i,c={})=>{v(a,i)&&(U(c.defaultValue)?h(i,B(v(n,i))):(h(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),T.isValid&&k()),S.state.next({...t}))},Tt=(i,c={})=>{const d=i?B(i):n,m=B(d),p=K(i),x=m,y=a;if(c.keepDefaultValues||(n=d),!c.keepValues){if(c.keepDirtyValues){const b=new Set([...u.mount,...Object.keys(Ee(n,l,void 0,y))]);for(const N of Array.from(b)){const H=v(t.dirtyFields,N),ee=v(l,N),xe=v(x,N);H&&!U(ee)?M(x,N,ee):!H&&!U(xe)&&h(N,xe)}}else{if(Je&&U(i))for(const b of u.mount){const N=v(a,b);if(N&&N._f){const H=Array.isArray(N._f.refs)?N._f.refs[0]:N._f.ref;if(Qe(H)){const ee=H.closest("form");if(ee){ee.reset();break}}}}if(c.keepFieldsRef)for(const b of u.mount)h(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);S.array.next({values:{...x}}),S.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=!T.isValid||!!c.keepIsValid||!!c.keepDirtyValues||!s.shouldUnregister&&!K(x),o.watch=!!s.shouldUnregister,o.keepIsValid=!!c.keepIsValid,o.action=!1,c.keepErrors||(t.errors={}),S.state.next({submitCount:c.keepSubmitCount?t.submitCount:0,isDirty:p?!1:c.keepDirty?t.isDirty:c.keepValues?w():!!(c.keepDefaultValues&&!ge(i,n)),isSubmitted:c.keepIsSubmitted?t.isSubmitted:!1,dirtyFields:p?{}:c.keepDirtyValues?c.keepDefaultValues&&l?Ee(n,l,void 0,y):t.dirtyFields:c.keepDefaultValues&&i?Ee(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(oe(i)?i(l):i,{...s.resetOptions,...c}),Ms=(i,c={})=>{const d=v(a,i),m=d&&d._f;if(m){const p=m.refs?m.refs[0]:m.ref;p.focus&&setTimeout(()=>{p.focus(),c.shouldSelect&&oe(p.select)&&p.select()})}},Ls=i=>{const{name:c,type:d,values:m,...p}=i;t={...t,...p}},kt={control:{register:tt,unregister:et,getFieldState:Re,handleSubmit:At,setError:Be,_subscribe:wt,_runSchema:F,_updateIsValidating:P,_focusError:st,_getWatch:re,_getDirty:w,_setValid:k,_setFieldArray:z,_setDisabledField:Nt,_setErrors:ae,_getFieldArray:Ae,_reset:Tt,_resetDefaultValues:()=>oe(s.defaultValues)&&s.defaultValues().then(i=>{Et(i,s.resetOptions),S.state.next({isLoading:!1})}),_removeUnmounted:me,_disableForm:Rs,_subjects:S,_proxyFormState:T,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},R=We(s.mode),I=We(s.reValidateMode)}},subscribe:Os,trigger:pe,register:tt,handleSubmit:At,watch:Fs,setValue:h,setValues:O,getValues:Te,reset:Et,resetField:Is,resetDefaultValues:(i,c={})=>{if(n=B(i),!c.keepDirty){const d=Ee(n,l,void 0,a);t.dirtyFields=d,t.isDirty=!K(d)}c.keepIsValid||k(),S.state.next({...t,defaultValues:n})},clearErrors:_e,unregister:et,setError:Be,setFocus:Ms,getFieldState:Re};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:oe(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1,defaultValues:oe(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&&!oe(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&&!ge(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()}},mt=(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&&mt(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 j;Object.defineProperty(u,"_zod",{value:u._zod??{},enumerable:!1}),(j=u._zod).traits??(j.traits=new Set),u._zod.traits.add(e),s(u,g);for(const A in o.prototype)A in u||Object.defineProperty(u,A,{value:o.prototype[A].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 j=t?.Parent?new l:this;a(j,u),(g=j._zod).deferred??(g.deferred=[]);for(const A of j._zod.deferred)A();return j}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 Ge(e){return typeof e=="string"?e:e?.message}function _s(e,s,t){const a={...e,path:e.path??[]};if(!e.message){const n=Ge(e.inst?._zod.def?.error?.(e))??Ge(s?.error?.(e))??Ge(t.customError?.(e))??Ge(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 pt(){return pt=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},pt.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(A){return A.errors.forEach(function(R){return e.push(R)})}),s){var g=t[o].types,j=g&&g[a.code];t[o]=jt(o,s,t,n,j?[].concat(j,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(R){return R.forEach(function(I){return e.push(pt({},I,{path:[].concat(n.path,I.path)}))})}),s){var j=t[u].types,A=j&&j[n.code];t[u]=jt(u,s,t,l,A?[].concat(A,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&&mt({},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&&mt({},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=Ze(),{pushError:t}=Gs(),{data:a}=os({...ls(),staleTime:1/0}),n=a?.accounts.find(g=>g.accountId===e)?.composeLanguages,l=D.useMemo(()=>n&&n.length>0?[...n]:Ks(navigator.languages),[n]),o=ye({...yt(),onSuccess:()=>{s.invalidateQueries({queryKey:we()})},onError:g=>{t(Qs("Couldn't save languages","The writing languages weren't saved.",g))}}),u=D.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="••••••••••",vi=e=>{const s=e.smtpUsername?.trim();return s?s!==e.username:!1},bi=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:Le(),imapStartTls:Le(),smtpHost:je().optional(),smtpPort:Vt.number().int().min(1).max(65535).optional(),smtpTls:Le().optional(),smtpStartTls:Le().optional(),smtpUsername:je().optional(),smtpPassword:je().optional(),useDifferentSmtpCreds:Le().optional()}),Si=({isOpen:e,onClose:s,account:t,focusSmtp:a})=>{const n=Ze(),l=!!t,[o,u]=D.useState(!1),[g,j]=D.useState(""),[A,R]=D.useState(!1),I=Rt(g),L=!!I&&!A,T=D.useRef(null),f=ri({resolver:hi(bi),defaultValues:{email:"",displayName:"",username:"",password:"",imapHost:"",imapPort:993,imapTls:!0,imapStartTls:!1,smtpHost:"",smtpPort:587,smtpTls:!1,smtpStartTls:!0,useDifferentSmtpCreds:!1}});D.useEffect(()=>{if(t){const h=vi(t);f.reset({email:t.email,displayName:t.displayName||"",username:t.username||"",password:xi,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:h&&t.smtpUsername||"",smtpPassword:"",useDifferentSmtpCreds:h}),u(!1)}else f.reset({email:"",displayName:"",username:"",password:"",imapHost:"",imapPort:993,imapTls:!0,imapStartTls:!1,smtpHost:"",smtpPort:587,smtpTls:!1,smtpStartTls:!0,useDifferentSmtpCreds:!1}),u(!1)},[t,f]);const S=ye({...Ys()}),ne=ye({...Zs(),onSuccess:()=>{n.invalidateQueries({queryKey:we()}),s()}}),E=ye({...yt(),onSuccess:()=>{n.invalidateQueries({queryKey:we()}),s()}}),_=()=>{const h=f.getValues(),O=l&&!o;S.mutate({body:{accountId:O?t?.accountId:void 0,username:h.username||h.email,password:O?void 0:h.password||void 0,imapHost:h.imapHost,imapPort:Number(h.imapPort),imapTls:h.imapTls,imapStartTls:h.imapStartTls}})},k=()=>{const h=f.getValues(),O=l&&!o;S.mutate({body:{accountId:O?t?.accountId:void 0,username:h.username||h.email,password:O?void 0:h.password||void 0,imapHost:h.imapHost,imapPort:Number(h.imapPort),imapTls:h.imapTls,imapStartTls:h.imapStartTls,smtpHost:h.smtpHost||void 0,smtpPort:h.smtpPort?Number(h.smtpPort):void 0,smtpTls:h.smtpTls,smtpStartTls:h.smtpStartTls,smtpUsername:h.useDifferentSmtpCreds?h.smtpUsername:void 0,smtpPassword:h.useDifferentSmtpCreds?h.smtpPassword:void 0}})},P=f.handleSubmit(h=>{if(!l&&!h.password){f.setError("password",{message:"Password is required"});return}const O=vr({imapHost:h.imapHost,smtpHost:h.smtpHost,smtpPort:h.smtpPort,smtpTls:h.smtpTls,smtpStartTls:h.smtpStartTls});O&&(f.setValue("smtpHost",O.smtpHost),f.setValue("smtpPort",O.smtpPort),f.setValue("smtpTls",O.smtpTls),f.setValue("smtpStartTls",O.smtpStartTls));const ce=O?.smtpHost??h.smtpHost,ie=O?.smtpPort??h.smtpPort,pe=O?.smtpTls??h.smtpTls,Te=O?.smtpStartTls??h.smtpStartTls,Re={email:h.email,displayName:h.displayName?.trim()||void 0,username:h.username||void 0,imapHost:h.imapHost,imapPort:Number(h.imapPort),imapTls:h.imapTls,imapStartTls:h.imapStartTls,smtpHost:ce||void 0,smtpPort:ie?Number(ie):void 0,smtpTls:pe,smtpStartTls:Te,smtpUsername:h.useDifferentSmtpCreds&&h.smtpUsername||void 0,smtpPassword:h.useDifferentSmtpCreds&&h.smtpPassword||void 0};if(l&&t){const _e={...Re,password:o?h.password:void 0};E.mutate({path:{accountId:t.accountId},body:_e})}else{const _e={...Re,password:h.password};ne.mutate({body:_e})}}),Z=ne.isPending||E.isPending,{signature:z,setSignature:fe,isSaving:ae}=xr(t?.accountId),[J,le]=D.useState(z.plainText),{languages:C,setLanguages:V,isSaving:F}=gi(t?.accountId),W=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:C,onChange:V,busy:F})]});D.useEffect(()=>{le(z.plainText)},[z.plainText]),D.useEffect(()=>{if(!e||!a)return;const h=T.current;if(!h)return;const O=window.setTimeout(()=>{h.scrollIntoView({behavior:"smooth",block:"start"})},250);return()=>window.clearTimeout(O)},[e,a]);const X=D.useCallback(()=>{J!==z.plainText&&fe(J,J)},[J,z.plainText,fe]),G=h=>{const{tls:O,startTls:ce}=qe(h);f.setValue("imapTls",O),f.setValue("imapStartTls",ce);const ie=f.getValues("imapPort");(ie===993||ie===143)&&f.setValue("imapPort",h==="tls"?993:143)},me=h=>{const{tls:O,startTls:ce}=qe(h);f.setValue("smtpTls",O),f.setValue("smtpStartTls",ce);const ie=f.getValues("smtpPort");if(ie===465||ie===587||ie===25){const Te=h==="tls"?465:h==="starttls"?587:25;f.setValue("smtpPort",Te)}},w=()=>{const h=f.getValues("imapHost");f.setValue("smtpHost",br(h)),f.setValue("smtpTls",!1),f.setValue("smtpStartTls",!0),f.setValue("smtpPort",587)},re=h=>{j(h),R(!1);const O=Rt(h);if(!O)return;const ce=qe(O.imap.security);f.setValue("imapHost",O.imap.host),f.setValue("imapPort",O.imap.port),f.setValue("imapTls",ce.tls),f.setValue("imapStartTls",ce.startTls);const ie=qe(O.smtp.security);f.setValue("smtpHost",O.smtp.host),f.setValue("smtpPort",O.smtp.port),f.setValue("smtpTls",ie.tls),f.setValue("smtpStartTls",ie.startTls);const pe=f.getValues("email").trim(),Te=f.getValues("username")?.trim();pe&&!Te&&f.setValue("username",pe)},Ae=I?.passwordHelp.text,Se=It(S.data?.imapError,Ae),ke=It(S.data?.smtpError,Ae);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:J,onChange:h=>le(h.target.value),onBlur:X,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:ae?"Saving signature...":"This signature will be appended to new emails."})]})})]}),l&&W]})}):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:Z,children:Z?"Saving...":"Save Account"})]}),children:r.jsxs("form",{id:"account-form",onSubmit:P,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:g,onChange:h=>re(h.target.value),children:[r.jsx("option",{value:"",children:"Custom / other"}),fr.map(h=>r.jsx("option",{value:h.id,children:h.label},h.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(be,{id:"account-email",...f.register("email"),placeholder:"alice@example.com"}),f.formState.errors.email&&r.jsx("p",{className:"text-sm text-danger mt-1",children:f.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(be,{id:"account-displayName",...f.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(be,{id:"account-username",...f.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",...f.register("password",{onChange:()=>u(!0)}),onFocus:()=>{l&&!o&&(f.setValue("password",""),u(!0))},placeholder:l?"Leave empty to keep current":""}),f.formState.errors.password&&r.jsx("p",{className:"text-sm text-danger mt-1",children:f.formState.errors.password.message}),I&&r.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[I.passwordHelp.text," ",r.jsx("a",{href:I.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)"}),I&&r.jsx("button",{type:"button",onClick:()=>R(h=>!h),className:"text-xs text-fg-muted hover:text-fg transition-colors",children:A?"Use preset settings":"Advanced"})]}),L&&r.jsxs("p",{className:"text-xs text-fg-muted mb-3",children:["Server settings are pre-filled for ",I?.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(be,{id:"imap-host",...f.register("imapHost"),readOnly:L,placeholder:"imap.example.com"}),f.formState.errors.imapHost&&r.jsx("p",{className:"text-sm text-danger mt-1",children:f.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(be,{id:"imap-port",...f.register("imapPort"),readOnly:L,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:L,checked:f.watch("imapTls"),onChange:()=>G("tls")}),"TLS (Port 993)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:L,checked:!f.watch("imapTls")&&f.watch("imapStartTls"),onChange:()=>G("starttls")}),"STARTTLS (Port 143)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:L,checked:!f.watch("imapTls")&&!f.watch("imapStartTls"),onChange:()=>G("none")}),"None (Unencrypted)"]})]})]})]}),r.jsx(se,{type:"button",variant:"secondary",onClick:_,disabled:S.isPending,className:"w-full",icon:S.isPending?r.jsx(nt,{className:"size-4 animate-spin"}):void 0,children:S.isPending?"Testing...":"Test IMAP Connection"}),S.data&&r.jsxs("div",{className:De("p-2 rounded-md text-sm",S.data.imapSuccess?"bg-positive/10 text-positive":"bg-danger-soft text-danger"),children:[S.data.imapSuccess?r.jsx(Ct,{className:"inline size-4 mr-1"}):r.jsx(Fe,{className:"inline size-4 mr-1"}),S.data.imapSuccess?"IMAP Connected":Se]})]})]}),r.jsxs("section",{ref:T,"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)"}),!L&&r.jsx("button",{type:"button",onClick:w,disabled:!f.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(be,{id:"smtp-host",...f.register("smtpHost"),readOnly:L,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(be,{id:"smtp-port",...f.register("smtpPort"),readOnly:L,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:L,checked:f.watch("smtpTls")===!0,onChange:()=>me("tls")}),"TLS (Port 465)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:L,checked:!f.watch("smtpTls")&&f.watch("smtpStartTls")===!0,onChange:()=>me("starttls")}),"STARTTLS (Port 587)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:L,checked:!f.watch("smtpTls")&&!f.watch("smtpStartTls"),onChange:()=>me("none")}),"None (Unencrypted)"]})]})]})]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"checkbox",...f.register("useDifferentSmtpCreds")}),"Use different credentials for SMTP"]}),f.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(be,{id:"smtp-username",...f.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",...f.register("smtpPassword")})]})]}),r.jsx(se,{type:"button",variant:"secondary",onClick:k,disabled:S.isPending||!f.watch("smtpHost"),className:"w-full",icon:S.isPending?r.jsx(nt,{className:"size-4 animate-spin"}):void 0,children:S.isPending?"Testing...":"Test SMTP Connection"}),S.data?.smtpSuccess!==void 0&&r.jsxs("div",{className:De("p-2 rounded-md text-sm",S.data.smtpSuccess?"bg-positive/10 text-positive":"bg-danger-soft text-danger"),children:[S.data.smtpSuccess?r.jsx(Ct,{className:"inline size-4 mr-1"}):r.jsx(Fe,{className:"inline size-4 mr-1"}),S.data.smtpSuccess?"SMTP Connected":ke]})]})]}),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:J,onChange:h=>le(h.target.value),onBlur:X,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:ae?"Saving signature...":"This signature will be appended to new emails."})]})})]}),l&&W]})})},ji="https://graph.microsoft.com/",wi={[ot.Mail]:["https://outlook.office.com/IMAP.AccessAsUser.All","https://outlook.office.com/SMTP.Send"],[ot.Calendar]:[`${ji}Calendars.Read`]},Ni=e=>{const s=new Set(e.map(t=>t.toLowerCase()));return Object.values(ot).filter(t=>wi[t].every(a=>s.has(a.toLowerCase())))},ht=e=>`Couldn't turn ${e.service.toLowerCase()} ${e.intent}`,Ai=e=>er(tr({title:`Bug: ${ht(e)}`,errorMessage:`${ht(e)} — ${e.message}`}));function Ti({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(lt,{tone:"danger",variant:"soft",children:[r.jsx("p",{className:"font-medium",children:ht(l)}),r.jsx("p",{className:"mt-0.5 break-words text-fg-muted",children:l.message}),r.jsx("a",{href:Ai(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 Ei({account:e,onRemoveAccount:s}){const t=Ze(),[a,n]=D.useState(null),[l,o]=D.useState(null),[u,g]=D.useState(null),j=ye({...yt(),meta:Dt,onSuccess:()=>t.invalidateQueries({queryKey:we()})}),A=ye({...cs(),meta:Dt}),R=us(_=>{const k=u;g(null),!(_!=="stalled"||k===null)&&o({service:k,intent:"on",message:fs})}),I=j.isPending&&j.variables?.body.syncedServices?j.variables.body.syncedServices:e.syncedServices,L=ss(e)?Vs:["Mail"],T=ss(e)?Ni(e.grantedScopes):L,f=(_,k,P)=>{o(null),j.mutate({path:{accountId:e.accountId},body:{syncedServices:_}},{onError:Z=>o({service:k,intent:P,message:Mt(Z)})})},S=_=>{o(null),A.mutate({body:{email:e.email,services:rs(I,_)}},{onSuccess:k=>{g(_),R(),window.location.assign(k.authorizationUrl)},onError:k=>o({service:_,intent:"on",message:Mt(k)})})},ne=(_,k)=>{if(k==="off"){n({kind:I.length===1?"last":"disable",service:_});return}if(!T.includes(_)){n({kind:"enable",service:_});return}f(rs(I,_),_,"on")},E=()=>{const _=a;if(n(null),_!==null){if(_.kind==="last"){s();return}if(_.kind==="enable"){S(_.service);return}f(I.filter(k=>k!==_.service),_.service,"off")}};return r.jsxs(r.Fragment,{children:[r.jsx(Ti,{providerName:ts,offered:L,enabled:I,consented:T,disabled:j.isPending||A.isPending||u!==null,refusal:l,onRequestChange:ne}),r.jsx(_r,{change:a,providerName:ts,onConfirm:E,onCancel:()=>n(null)})]})}function is({open:e,onClose:s,accountEmail:t,signOut:a}){const[n,l]=D.useState(""),[o,u]=D.useState(!1),[g,j]=D.useState(!1),A=ye({...rr(),onSuccess:()=>{j(!0),setTimeout(()=>a(),2e3)}}),R=ye(ir()),I=()=>{A.isPending||(l(""),u(!1),j(!1),A.reset(),R.reset(),s())},L=()=>{if(n.trim().toLowerCase()!==t.toLowerCase()){u(!0);return}u(!1),A.mutate({body:{confirmEmail:n.trim()}})};return r.jsxs(ds,{open:e,onClose:I,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(gt,{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(Fe,{className:"size-3.5"}),onClick:I,"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:()=>R.mutate({}),"aria-busy":R.isPending,className:"inline-flex items-center gap-1.5 font-medium text-accent hover:underline",children:[r.jsx(wr,{className:"size-3.5"}),R.isPending?"Requesting export…":"Export my data first"]}),R.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."}),R.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(be,{id:"confirm-remit-email",type:"email",placeholder:t,value:n,onChange:T=>{l(T.target.value),o&&u(!1),A.isError&&A.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."}),A.isError&&r.jsx("p",{className:"mt-1.5 text-xs text-danger",role:"alert",children:A.error instanceof Error?A.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:I,children:"Cancel"}),r.jsx(se,{variant:"danger",size:"sm",onClick:L,"aria-busy":A.isPending,children:A.isPending?"Deleting…":"Delete everything"})]})]})]})}function ki(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 _i(){const[e,s]=D.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(ki,{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 Pi=e=>e.length>1?`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`:e[0]??"";function Ci(e,s){const t=(e.missingServices??"").split(","),a=ct.filter(j=>t.includes(j.id)),n=e.oauthEmail,l=n?s.find(j=>j.authType==="oauthMicrosoft"&&j.email.toLowerCase()===n.toLowerCase()):void 0,o=Pi(a.map(j=>j.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?ct.filter(j=>l.syncedServices.includes(j.id)||a.some(A=>A.id===j.id)).map(j=>j.id):void 0;return{kind:"refused",message:u,email:n,services:g,reconnect:!!l}}function Vi(e){const s=e.split("@")[0]??"";return s?s.split(/[._-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" "):e}function Di(e){const s=e.displayName?.trim();return s||Vi(e.email)}function Fi(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 Oi(e){return e.connectionState==="credentials_missing"}const Ri=()=>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 na(){const e=Ft.useSearch(),s=ar({from:Ft.fullPath}),[t,a]=D.useState(!0),[n,l]=D.useState(!1),[o,u]=D.useState(!1),[g,j]=D.useState(void 0),[A,R]=D.useState(null),[I,L]=D.useState(!1),[T,f]=D.useState(null),[S,ne]=D.useState(null),[E,_]=D.useState(null),[k,P]=D.useState(null),Z=Ze(),{data:z,isPending:fe,isError:ae,error:J,refetch:le}=os(ls());D.useEffect(()=>{e.editAccountId&&(R(e.editAccountId),L(!!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]),D.useEffect(()=>{e.connected&&(j({kind:"connected",accountId:e.connected}),u(!0),Z.invalidateQueries({queryKey:we()}),s({search:{connected:void 0,oauthError:void 0,editAccountId:void 0,focusSmtp:void 0},replace:!0}))},[e.connected,s,Z]),D.useEffect(()=>{if(!e.oauthError)return;const w=e.oauthError==="scope_not_granted";w&&!z&&!ae||(P(null),w?(j(Ci({oauthEmail:e.oauthEmail,missingServices:e.missingServices},z?.accounts??[])),u(!0)):_(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,z,ae,s]),yr(k!==null,()=>{Z.invalidateQueries({queryKey:we()})}),D.useEffect(()=>{if(!k||!z)return;const w=z.accounts.find(re=>re.accountId===k);(!w||!ns(w))&&P(null)},[z,k]);const C=us(w=>{P(null),w==="stalled"&&_(fs)}),V=ye({...cs(),onSuccess:w=>{C(),window.location.assign(w.authorizationUrl)},onError:w=>{_(w instanceof Error?w.message:"Failed to start reconnect"),P(null)}}),F=ye({...nr(),onSuccess:()=>{Z.invalidateQueries({queryKey:we()}),f(null)}}),W=z?.accounts.find(w=>w.accountId===T),X=z?.accounts.find(w=>w.accountId===A),G=()=>{l(!1),u(!1),R(null),L(!1)},me=w=>{const re=cr[w];re&&s({to:re})};return r.jsxs(hr,{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:me,onBackToMail:()=>{s({to:"/mail"})},children:[S&&r.jsx(lt,{tone:"success",variant:"soft","data-testid":"oauth-success-banner",onDismiss:()=>ne(null),children:S}),E&&r.jsx(lt,{tone:"danger",variant:"soft","data-testid":"oauth-error-banner",onDismiss:()=>_(null),children:E}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(lr,{tone:"neutral",children:fe||ae?"accounts":`${z.accounts.length} ${z.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"})]}),fe?r.jsx(Ri,{}):ae?r.jsx(jr,{title:"Couldn't load accounts",error:J,onRetry:()=>{le()}}):z.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:z.accounts.map(w=>{const re=ns(w),Ae=Oi(w),Se=w.authType==="oauthMicrosoft",ke=k===w.accountId,Oe=re&&Se?{label:"Reconnect",variant:"secondary",busy:ke,busyLabel:"Redirecting…",onClick:()=>{P(w.accountId),V.mutate({body:{email:w.email,services:w.syncedServices}})}}:Ae?{label:"Enter password",variant:"secondary",onClick:()=>R(w.accountId)}:as(w)==="error"?{label:"Reconnect",variant:"secondary",onClick:()=>R(w.accountId)}:{label:"Manage",variant:"ghost",onClick:()=>R(w.accountId)},h=r.jsx(pr,{actions:[Oe],destructive:{label:"Delete account",iconOnly:!0,icon:r.jsx(dr,{className:"size-3.5"}),onClick:()=>f(w.accountId)}});return r.jsxs("div",{className:"space-y-2",children:[r.jsx(gr,{label:Di(w),email:w.email,connector:Se?"Microsoft 365":"IMAP",syncLabel:Fi(w),state:as(w),errorDetail:re?w.lastError??"Re-authentication required":Ae?"Imported from a config file, which carries no password. Enter one to start syncing.":w.lastError,trailing:h}),r.jsx(Ei,{account:w,onRemoveAccount:()=>f(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"&&ne("Account connected successfully."),u(!1),j(void 0),Z.invalidateQueries({queryKey:we()})},onCancel:()=>{u(!1),j(void 0)}})}),r.jsx(Si,{isOpen:n||!!A,account:X,focusSmtp:I,onClose:G}),r.jsxs(ds,{open:!!T,onClose:()=>f(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(gt,{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(Fe,{className:"size-3.5"}),onClick:()=>f(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?"}),W&&r.jsx("p",{className:"text-center",children:W.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:()=>f(null),children:"Cancel"}),r.jsx(se,{variant:"danger",size:"sm","aria-busy":F.isPending,icon:F.isPending?r.jsx(nt,{className:"size-3.5 animate-spin"}):void 0,onClick:()=>{F.isPending||T&&F.mutate({path:{accountId:T}})},children:F.isPending?"Deleting…":"Delete account"})]})]}),r.jsx(_i,{})]})}export{na as component,Ds as mapOauthError,Ci as scopeRefusalReturn};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{e as L,j as e,aM as z,f as l,aV as p,g as y,aW as D,aX as V,B as S,ar as u,aY as I,r as m,L as b,aZ as g,t as q,h as F,a_ as U,a$ as H,c as C,b0 as Q,d as Y,aH as _,aI as E,b1 as G,T as J,b2 as W,b3 as Z,b4 as K,u as X,aP as ee,aR as se}from"./index-
|
|
1
|
+
import{e as L,j as e,aM as z,f as l,aV as p,g as y,aW as D,aX as V,B as S,ar as u,aY as I,r as m,L as b,aZ as g,t as q,h as F,a_ as U,a$ as H,c as C,b0 as Q,d as Y,aH as _,aI as E,b1 as G,T as J,b2 as W,b3 as Z,b4 as K,u as X,aP as ee,aR as se}from"./index-J89guRVU.js";import{S as te}from"./settings-screen-CPKUaFTz.js";import{e as ae}from"./config-import-CO5AR73r.js";import{u as ne}from"./sections-CmVNNIn5.js";import{C as re,a as ie,b as le,c as oe}from"./card-ChUQkNyW.js";import{D as k}from"./download-D3c-jAvE.js";import{F as ce}from"./file-json-DgAW6fCg.js";import{C as de}from"./copy-D9w0yOJZ.js";import{B as A}from"./bug-ysY2Lcys.js";import{C as v}from"./circle-check-CmZH70G9.js";import{f as me}from"./ErrorState-CX8jPS64.js";import{u as xe}from"./useResultFolderIndex-CizpN02R.js";import{R}from"./rotate-ccw-86rVy6Oh.js";import{C as he,S as ue}from"./shield-check-Bz65Alvp.js";import{C as pe}from"./clock-BQFlXobK.js";import{b as fe}from"./help-copy-Bfcrl0wG.js";import"./avatar-CMrR_WCW.js";import"./chevron-left-BnXYRBLM.js";import"./menu-lOydIsUw.js";import"./circle-help-CxlWBIxf.js";import"./useQueries-Ch9XYsKm.js";import"./kbd-CKw25IK5.js";const w=L("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]),ge={BodyParse:"The message is built in a way Remit could not read."};function je(s){return ge[s]}function M(s){return s.split(";")[0].trim()}const T=/^[A-Za-z0-9!#$%&'*+._-]+$/,P=/^[A-Za-z0-9!#$%&'*+._-]+\/[A-Za-z0-9!#$%&'*+._-]+$/;function j(s,t){return t.test(s)?`\`${s}\``:`\`${JSON.stringify(s).replace(/`/g,"\\u0060")}\` (malformed)`}function Ne(s){const t=M(s);return P.test(t)?t:JSON.stringify(t)}const N="_not read_";function be(s){return s.length===0?["(no MIME structure was read)"]:s.map(t=>`${" ".repeat(t.depth)}- ${Ne(t.contentType)}`)}const ve="_No message content, addresses, subject, attachment names or parser output are included._";function $(s){return{head:[`### Message quarantined at \`${s.failureStage}\``,"",`- **Failure**: \`${s.failureCode}\``,`- **Folder role**: ${s.mailboxRole??"_none appointed_"}`,`- **Failing part**: ${s.failurePartPath==null?"_whole message_":`\`${s.failurePartPath}\``}`,`- **Attempts before quarantine**: ${s.attempts}`,`- **Worker build**: ${s.workerVersion}`,`- **Message-ID hash**: ${s.messageIdHash==null?"_none declared_":`\`${s.messageIdHash}\``}`,"","#### Message shape","",`- **Content-Type**: ${s.contentType==null?N:j(M(s.contentType),P)}`,`- **Content-Transfer-Encoding**: ${s.transferEncoding==null?N:j(s.transferEncoding,T)}`,`- **Charset**: ${s.charset==null?"_not declared_":j(s.charset,T)}`,`- **Size**: ${s.sizeBytes==null?N:`${s.sizeBytes} bytes`}`,"","MIME structure:"].join(`
|
|
2
2
|
`),structure:be(s.structure).join(`
|
|
3
3
|
`),disclaimer:ve}}function ye(s){const{head:t,structure:a,disclaimer:n}=$(s);return[t,"","```",a,"```","",n].join(`
|
|
4
4
|
`)}function ke(s){return`Message quarantined: ${s.failureCode} at ${s.failureStage}`}function we({entry:s,onClose:t,issueUrl:a,onCopy:n}){if(!s)return null;const r=ye(s);return e.jsx(z,{open:!0,onClose:t,title:"Report this message",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.jsx("h3",{className:"text-sm font-semibold text-fg",children:"Report this message"}),e.jsx("p",{className:"text-xs text-fg-muted",children:"This is everything the report contains. It describes the shape of the message — never its contents, addresses, subject, attachment names, or the parser's own error text."})]}),e.jsx("pre",{className:"flex-1 overflow-auto bg-surface-sunken px-4 py-3 text-2xs leading-relaxed whitespace-pre-wrap text-fg-muted",children:r}),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:t,children:"Cancel"}),e.jsx(l,{variant:"secondary",size:"sm",icon:e.jsx(de,{className:"size-3.5"}),onClick:()=>n(r),children:"Copy report"}),e.jsx(p,{external:!0,size:"sm",href:a,icon:e.jsx(w,{className:"size-3.5"}),children:"Open on GitHub"})]})]})})}function Ce(s){return new Date(s).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}function Re({entry:s,onCutBug:t}){return e.jsxs("li",{className:"flex flex-col gap-2 border-b border-line px-row-inset py-3 last:border-b-0 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("p",{className:"text-sm text-fg",children:je(s.failureStage)}),e.jsx("p",{className:"truncate text-xs text-fg-muted",title:s.failureMessage,children:s.failureMessage}),e.jsxs("p",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-2xs text-fg-subtle",children:[s.mailboxRole&&e.jsx(y,{tone:"warning",children:D(s.mailboxRole)}),e.jsx("span",{className:"truncate",title:s.mailboxPath,children:V(s.mailboxPath,s.mailboxDelimiter)}),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{children:`uid ${s.uid}`}),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{children:Ce(s.quarantinedAt)}),s.attempts>1&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{children:`${s.attempts} attempts`})]})]})]}),e.jsx(l,{variant:"secondary",size:"sm",className:"shrink-0",icon:e.jsx(A,{className:"size-3.5"}),onClick:()=>t(s),children:"Cut a bug"})]})}function Te({entries:s,onCutBug:t}){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:"Messages set aside"}),e.jsx("p",{className:"text-xs text-fg-muted",children:"Mail Remit could not read is set aside here instead of being skipped, so nothing goes missing quietly. The rest of the folder keeps syncing. Recovering a set-aside message is a re-sync, not a per-row action."})]}),s.length===0&&e.jsxs("div",{className:"flex items-center gap-2 rounded-sm border border-line bg-surface px-row-inset py-3",children:[e.jsx(v,{className:"size-4 shrink-0 text-positive","aria-hidden":!0}),e.jsx("p",{className:"text-sm text-fg-muted",children:"Every message has been read successfully. Nothing is set aside."})]}),s.length>1&&e.jsx(S,{tone:"warning",children:e.jsxs("p",{className:"flex items-start gap-2",children:[e.jsx(u,{className:"mt-0.5 size-4 shrink-0","aria-hidden":!0}),e.jsxs("span",{children:[e.jsx("span",{className:"font-semibold",children:`${s.length} messages could not be read.`})," ","More than one means something is wrong with how Remit reads mail, not with the mail. Reporting one of these gets it fixed."]})]})}),s.length>0&&e.jsx("ul",{className:"rounded-sm border border-line bg-surface",children:s.map(a=>e.jsx(Re,{entry:a,onCutBug:t},a.quarantineId))})]})}const ze=["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 Se({open:s,currentVersion:t,release:a,appliesSchemaMigration:n=!1,onClose:r,onConfirm:i}){return s?e.jsx(z,{open:!0,onClose:r,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 ",t,". ",a.version," was released"," ",I(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:[ze.map(o=>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:o})]},o)),n&&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:r,children:"Not now"}),e.jsx(p,{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(k,{className:"size-3.5"}),onClick:i,children:"Install and restart"})]})]})}):null}function d({children:s,tone:t}){return e.jsx("div",{className:q("rounded-sm border bg-surface px-row-inset py-3",t==="danger"?"border-danger/50":"border-line"),children:s})}function Ie({state:s,onCheck:t,onInstall:a,onDismissResult:n,now:r=Date.now()}){const[i,o]=m.useState(null),x=s.status==="checking",c=s.status==="available",h=()=>{if(x){o("Already checking. The result appears here in a moment.");return}o(null),t()},O=()=>{n(),h()},f=()=>{if(!c&&s.status!=="rolledBack"&&s.status!=="abandoned"){o("There is no update to install. Check for updates first — if one is found it appears here.");return}o(null),a()},B=(()=>{switch(s.status){case"upToDate":return e.jsx(d,{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(v,{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 ",g(s.checkedAt,r),"."]})]})]}),e.jsx(l,{variant:"secondary",size:"sm",className:"shrink-0",onClick:h,children:"Check again"})]})});case"checking":return e.jsx(d,{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 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:h,children:"Check again"})]})});case"neverChecked":return e.jsx(d,{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(pe,{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"," ",g(s.lastCheckedAt,r),"."]})]})]}),e.jsx(l,{variant:"secondary",size:"sm",className:"shrink-0",onClick:h,children:"Check now"})]})});case"checkFailed":return e.jsx(d,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(he,{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"," ",g(s.lastCheckedAt,r),"."]})]})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(l,{variant:"secondary",size:"sm",onClick:h,children:"Try again"})})]})});case"available":return e.jsx(d,{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(y,{tone:"accent",children:"update available"}),e.jsxs("span",{className:"text-2xs text-fg-subtle",children:["released ",I(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(k,{className:"size-3.5"}),onClick:f,children:["Install ",s.release.version]}),e.jsx(p,{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(d,{children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(b,{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(S,{tone:"success",onDismiss:n,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(d,{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(v,{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:O,children:"Check for updates"})]})})]});case"rolledBack":return e.jsx(d,{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(R,{className:"size-3.5"}),onClick:f,children:["Try ",s.attemptedVersion," again"]}),e.jsxs(l,{variant:"ghost",size:"sm",onClick:n,children:["Stay on ",s.version]})]})]})});case"unreachable":return e.jsx(d,{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:n,children:"Dismiss"})})]})});case"rollbackFailed":return e.jsx(d,{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:n,children:"Dismiss"})})]})});case"abandoned":return e.jsx(d,{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(R,{className:"size-3.5"}),onClick:f,children:["Try ",s.attemptedVersion," again"]}),e.jsxs(l,{variant:"ghost",size:"sm",onClick:n,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."})]}),B,i&&e.jsx("p",{role:"status",className:"text-xs text-fg-muted",children:i})]})}function _e({fileName:s,state:t="ready",error:a,onDownload:n,onImport:r}){const i=t==="downloading";return e.jsxs(re,{className:"max-w-xl",children:[e.jsx(ie,{children:e.jsx(le,{children:"Configuration file"})}),e.jsxs(oe,{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."}),t==="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:i,icon:i?e.jsx(b,{className:"size-3.5 animate-spin"}):e.jsx(k,{className:"size-3.5"}),onClick:n,children:i?"Preparing…":`Download ${s}`}),e.jsx(y,{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(ce,{className:"size-3.5"}),onClick:r,children:"Import a config file"})]})]})]})}const Ee=(s,t)=>{const a=URL.createObjectURL(new Blob([JSON.stringify(t,null,2)],{type:"application/json"})),n=document.createElement("a");n.href=a,n.download=s,n.click(),URL.revokeObjectURL(a)};function Ae(){const s=F(),t=ne(),[a,n]=m.useState("ready"),[r,i]=m.useState(void 0),o=ae(new Date),x=()=>{a!=="downloading"&&(n("downloading"),i(void 0),s.fetchQuery(U()).then(c=>{Ee(o,c.document),n("ready")}).catch(c=>{n("failed"),i(c instanceof Error?c.message:"GET /config/export did not answer with a configuration.")}))};return e.jsx(_e,{fileName:o,state:a,error:r,onDownload:x,onImport:()=>t("importConfig")})}function Me(s,t){return{quarantineId:s.quarantineId,accountId:s.accountId,mailboxId:s.mailboxId,uidValidity:s.uidValidity,uid:s.uid,mailboxRole:s.mailboxRole?H[s.mailboxRole]:void 0,mailboxPath:s.mailboxPath,mailboxDelimiter:t,failureStage:s.failureStage,failureCode:s.failureCode,failureMessage:s.failureMessage,failurePartPath:s.failurePartPath,quarantinedAt:s.quarantinedAt,attempts:s.attempts,sizeBytes:s.sizeBytes,contentType:s.contentType,transferEncoding:s.transferEncoding,charset:s.charset,structure:s.structure,messageIdHash:s.messageIdHash,workerVersion:s.workerVersion}}const Pe=[];function $e(s){window.open(s,"_blank","noopener,noreferrer")}function Oe(s){return _(E({quarantine:$(s),title:ke(s)}))}function Be({error:s}){return e.jsxs("section",{role:"alert",className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Messages set aside"}),e.jsxs("div",{className:"space-y-2 rounded-sm border border-danger/40 bg-danger-soft px-row-inset py-3",children:[e.jsx("p",{className:"text-sm font-medium text-danger",children:"The list of set-aside messages could not be read."}),e.jsx("p",{className:"break-words text-sm text-fg-muted",children:me(s)}),e.jsx("p",{className:"text-xs text-fg-muted",children:"Mail may still have been set aside — this page cannot say either way until it can read the list. Reporting this gets it fixed."}),e.jsx(l,{variant:"secondary",size:"sm",icon:e.jsx(A,{className:"size-3.5"}),onClick:()=>$e(_(E())),children:"Report this"})]})]})}function Le({entries:s,isPending:t,error:a}){const[n,r]=m.useState(null),[i,o]=m.useState(!1);if(t)return e.jsx("p",{className:"animate-pulse text-sm text-fg-subtle",children:"Checking for messages set aside…"});if(a)return e.jsx(Be,{error:a});const x=c=>{navigator.clipboard.writeText(c).then(()=>{o(!1),r(null)},()=>{o(!0),r(null)})};return e.jsxs(e.Fragment,{children:[i&&e.jsx("p",{role:"alert",className:"mb-3 text-sm text-danger",children:"The report was not copied — this browser refused clipboard access. Cut the bug again and use Open on GitHub, which needs no clipboard."}),e.jsx(Te,{entries:s,onCutBug:r}),e.jsx(we,{entry:n,issueUrl:n?Oe(n):"",onClose:()=>r(null),onCopy:x})]})}function De(s,t){return s.get(t)?.hierarchyDelimiter??""}function Ve(){const s=C(Q()),t=C(Y()),a=m.useMemo(()=>t.data?.accounts??[],[t.data]),n=xe(a),r=s.data?.entries??Pe,i=m.useMemo(()=>r.map(o=>Me(o,De(n.index,o.mailboxId))),[r,n.index]);return e.jsx(Le,{entries:i,isPending:s.isPending||t.isPending||n.isPending,error:s.error??t.error??n.error})}function qe(){const{surface:s,release:t,currentVersion:a,appliesSchemaMigration:n,onCheck:r,install:i,onDismissResult:o}=G(),[x,c]=m.useState(!1);return s.status!=="ready"?null:e.jsxs(e.Fragment,{children:[e.jsx(Ie,{state:s.section,onCheck:r,onInstall:()=>c(!0),onDismissResult:o}),t&&a&&e.jsx(Se,{open:x,currentVersion:a,release:t,appliesSchemaMigration:n,onClose:()=>c(!1),onConfirm:()=>{c(!1),i(t.version)}})]})}function Fe(){return J().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(p,{href:"/tls-root-ca.crt",download:!0,variant:"secondary",size:"sm",icon:e.jsx(ue,{className:"size-3.5"}),children:"Download root certificate"})]})}function Ue(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 He({sha:s=Z,commitUrl:t=W,buildTime:a=K}){return e.jsxs("p",{className:"text-xs text-fg-subtle",children:["Version"," ",t?e.jsx("a",{href:t,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 ",Ue(a)]})]})}function ps(){const s=X(),[t,a]=m.useState(!0),n=r=>{const i=se[r];i&&s({to:i})};return e.jsxs(te,{items:ee,activeId:"advanced",title:"Advanced",description:"Notification rules, export, and diagnostics.",help:fe,helpOpen:t,onToggleHelp:()=>a(r=>!r),onSelect:n,onBackToMail:()=>{s({to:"/mail"})},children:[e.jsx(qe,{}),e.jsx(Ve,{}),e.jsx("div",{className:"mt-6 border-t border-line pt-4",children:e.jsx(Ae,{})}),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(Fe,{}),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(He,{})]})]})}export{ps as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as x,r as a,b8 as g,j as e,aP as S,b9 as n,aR as y,ba as b}from"./index-
|
|
1
|
+
import{u as x,r as a,b8 as g,j as e,aP as S,b9 as n,aR as y,ba as b}from"./index-J89guRVU.js";import{S as T}from"./settings-screen-CPKUaFTz.js";import{c as v}from"./help-copy-Bfcrl0wG.js";import"./avatar-CMrR_WCW.js";import"./chevron-left-BnXYRBLM.js";import"./menu-lOydIsUw.js";import"./circle-help-CxlWBIxf.js";import"./kbd-CKw25IK5.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(g),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:S,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,aB as j,t as o,r as d}from"./index-
|
|
1
|
+
import{j as e,X as h,aB as j,t as o,r as d}from"./index-J89guRVU.js";import{A as b}from"./avatar-CMrR_WCW.js";import{M as v}from"./minus-oqpCotLr.js";import{C as N}from"./clock-BQFlXobK.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-J89guRVU.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-J89guRVU.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{G as N,r as n,H as k,j as a,t as g}from"./index-
|
|
1
|
+
import{G as N,r as n,H as k,j as a,t as g}from"./index-J89guRVU.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 H({open:s,onClose:l,children:S,label:Y,dismissLabel:y="Dismiss"}){N({id:"bottom-sheet",open:s,answers:{back:l}});const b=n.useRef(null),f=n.useRef(null),[i,M]=n.useState(T),[m,u]=n.useState(null);k(f,s),n.useLayoutEffect(()=>{const t=b.current;if(!t)return;const e=()=>M(t.offsetHeight);e();const r=new ResizeObserver(e);return r.observe(t),()=>r.disconnect()},[]);const c=n.useRef(null),j=n.useCallback(t=>{t.currentTarget.setPointerCapture(t.pointerId),c.current={startY:t.clientY,lastY:t.clientY,lastT:t.timeStamp,velocity:0,moved:!1},u(0)},[]),w=n.useCallback(t=>{const e=c.current;if(!e)return;const r=t.timeStamp-e.lastT;r>0&&(e.velocity=(t.clientY-e.lastY)/r),e.lastY=t.clientY,e.lastT=t.timeStamp;const o=t.clientY-e.startY;Math.abs(o)>4&&(e.moved=!0);const I=o<0?A(o):o;u(I)},[]),h=n.useCallback(()=>{const t=c.current;if(c.current=null,!t)return;const e=t.lastY-t.startY,o=t.velocity>E||e>i*P;u(null),o&&l()},[i,l]),x=m!==null,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:j,onPointerMove:w,onPointerUp:h,onPointerCancel:h,className:"flex cursor-grab touch-none justify-center pb-1 pt-2.5 active:cursor-grabbing",children:a.jsx("div",{className:"h-1 w-10 rounded-full bg-fg-subtle/40"})}),a.jsx("div",{ref:f,tabIndex:-1,className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:S})]})]})}export{H as B};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as r}from"./index-
|
|
1
|
+
import{j as r}from"./index-J89guRVU.js";import{E as t}from"./ErrorState-CX8jPS64.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-J89guRVU.js";import{a as m}from"./MailShell-BnAscFqh.js";import{B as o}from"./BriefPane-CdiCvSuF.js";import{a as p}from"./search-token-index-BXCXhECA.js";import{u as e}from"./search-mirror-BlS_Ifso.js";import"./FullCompose-CgTCPbiG.js";import"./ErrorState-CX8jPS64.js";import"./index-BNf6kiaX.js";import"./useMessageBodyContent-Bl5Y6AAH.js";import"./useSignature-z9_OAiTD.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-Cyjl5fcM.js";import"./sections-CmVNNIn5.js";import"./confirm-dialog-DM1V3tLO.js";import"./useSearchTokenContext-Dl9jDzQw.js";import"./kbd-CKw25IK5.js";import"./search-scope-B5-OK3Cq.js";import"./MailListHeader-C8fUfLdY.js";import"./roving-focus-CzTCkI7v.js";import"./popover-menu-Cl-N1YPe.js";import"./mail-Daw23XZE.js";import"./avatar-CMrR_WCW.js";import"./EmptyState-ClLPPGI1.js";import"./undo-2-C5A6ikAQ.js";import"./download-D3c-jAvE.js";import"./calendar-suggestion-CaACTNVX.js";import"./calendar-format-CHntutZg.js";import"./useQueries-Ch9XYsKm.js";import"./useCalendars-Du8oLBQy.js";import"./calendar-report-DAUzkHX3.js";import"./attendee-row-DaC0cWu0.js";import"./minus-oqpCotLr.js";import"./clock-BQFlXobK.js";import"./calendar-clash-strip-DH-rkJMi.js";import"./bell-off-CjFQsmU0.js";import"./copy-D9w0yOJZ.js";import"./shield-check-Bz65Alvp.js";import"./useFilters-Dn74lJWT.js";import"./checkbox-lv4ht1p0.js";import"./useLayoutTier-I-ZeE96x.js";import"./menu-lOydIsUw.js";import"./useRefreshControl-sKR2_udi.js";import"./circle-check-big-DsPxeo1f.js";import"./refresh-cw-D2y2CKsF.js";import"./useSemanticSearch-NkagUfNs.js";import"./useLabels-Bhad46sq.js";import"./search-query-Cr_ZXBCp.js";import"./wizard-selection-DxUM65kM.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};
|