@remit/web-client-dist 0.0.49 → 0.0.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/assets/{ComposeBody-7Vim8npU.js → ComposeBody-b-2CBiMf.js} +3 -3
  2. package/assets/{ErrorState-ozcCp-cA.js → ErrorState-B8pjqLAj.js} +1 -1
  3. package/assets/{OnboardingWizard-lYRoUUwG.js → OnboardingWizard-qsD51xho.js} +1 -1
  4. package/assets/{account-form-helpers-cgQ51wpS.js → account-form-helpers-CcBJx1BZ.js} +1 -1
  5. package/assets/accounts-CqVGiKBs.js +1 -0
  6. package/assets/{advanced-KuYgo_U3.js → advanced-DoXyxBxZ.js} +1 -1
  7. package/assets/{appearance-LNtcc7Yh.js → appearance-Dw4deS_l.js} +1 -1
  8. package/assets/{avatar-K4mVDmMa.js → avatar-BfVIntHI.js} +1 -1
  9. package/assets/{browser-ponyfill-JJh8056-.js → browser-ponyfill-B09jqcu4.js} +2 -2
  10. package/assets/{filter-status-B3jGvEFY.js → filter-status-CApqTg55.js} +1 -1
  11. package/assets/filters-QHdiRy6i.js +1 -0
  12. package/assets/{flagged-Jl0Vpiuz.js → flagged-BCGn4LPP.js} +1 -1
  13. package/assets/folder-lZLJYRNp.js +1 -0
  14. package/assets/folders-B08cAeNo.js +1 -0
  15. package/assets/{index-DFBCf_Ns.js → index-BHDPbJFl.js} +65 -65
  16. package/assets/{index-WttpUE3-.js → index-BKeWRXxj.js} +1 -1
  17. package/assets/index-BXr9E7Yy.js +1 -0
  18. package/assets/{kbd-BfCwcUpt.js → kbd-CokhGhSt.js} +1 -1
  19. package/assets/mail-BABlpWcq.js +118 -0
  20. package/assets/{onboarding-BCBTm3Kx.js → onboarding-D22duyUl.js} +1 -1
  21. package/assets/{select-u4cRyFjX.js → select-DeuuCZfQ.js} +1 -1
  22. package/assets/senders-DLd_pF17.js +1 -0
  23. package/assets/settings-BtwV4TT0.js +1 -0
  24. package/assets/{settings-screen-D48k5Bt1.js → settings-screen-Crm_cfd3.js} +1 -1
  25. package/assets/{suggested-vips-CX5d7mjW.js → suggested-vips-C7SiYIKI.js} +1 -1
  26. package/assets/{useDebouncedValue-DDaNsy8R.js → useDebouncedValue-K6LUFKwO.js} +1 -1
  27. package/assets/{useMutation-driganVD.js → useMutation-w1gwpUuR.js} +1 -1
  28. package/assets/{useSignature-Bvv4geSf.js → useSignature-Dq8MuqLU.js} +1 -1
  29. package/index.html +1 -1
  30. package/package.json +1 -1
  31. package/assets/accounts-CYWD_b63.js +0 -1
  32. package/assets/filters-Chmn8x2p.js +0 -1
  33. package/assets/folder-role-CCoF_M_n.js +0 -1
  34. package/assets/folder-roles-XnseeyyD.js +0 -1
  35. package/assets/folders-CizCae6h.js +0 -1
  36. package/assets/index-CezCYjUz.js +0 -1
  37. package/assets/mail-v3Ghi-YR.js +0 -118
  38. package/assets/senders-Bgz-aBes.js +0 -1
  39. package/assets/settings-CArAM84y.js +0 -1
  40. package/assets/star-cNw1G8pR.js +0 -1
  41. package/assets/trash-2-l_BkiFgy.js +0 -1
@@ -1 +1 @@
1
- import{b2 as r,a0 as a,a9 as i,A as s,r as c,j as m}from"./index-DFBCf_Ns.js";import{O as l}from"./OnboardingWizard-lYRoUUwG.js";import"./kbd-BfCwcUpt.js";import"./select-u4cRyFjX.js";import"./useMutation-driganVD.js";import"./account-form-helpers-cgQ51wpS.js";async function p(e){e.recordCompleted(),await e.queryClient.refetchQueries({queryKey:r()}),e.navigateToInbox()}function v(){const e=a(),o=i(),t=s(),n=c.useCallback(u=>{p({queryClient:t,recordCompleted:()=>o.recordEvent("onboarding.completed"),navigateToInbox:()=>{e({to:"/mail"})}})},[e,o,t]);return m.jsx(l,{skipWelcome:!1,onComplete:n})}export{v as component};
1
+ import{bg as r,a7 as a,ai as i,L as s,r as c,j as m}from"./index-BHDPbJFl.js";import{O as l}from"./OnboardingWizard-qsD51xho.js";import"./kbd-CokhGhSt.js";import"./select-DeuuCZfQ.js";import"./useMutation-w1gwpUuR.js";import"./account-form-helpers-CcBJx1BZ.js";async function p(e){e.recordCompleted(),await e.queryClient.refetchQueries({queryKey:r()}),e.navigateToInbox()}function v(){const e=a(),o=i(),t=s(),n=c.useCallback(u=>{p({queryClient:t,recordCompleted:()=>o.recordEvent("onboarding.completed"),navigateToInbox:()=>{e({to:"/mail"})}})},[e,o,t]);return m.jsx(l,{skipWelcome:!1,onComplete:n})}export{v as component};
@@ -1 +1 @@
1
- import{a,j as e,C as i,b as o}from"./index-DFBCf_Ns.js";const l=a("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);function u({icon:s,className:n,children:t,...r}){return e.jsxs("div",{className:o("relative flex h-9 items-center gap-2 rounded-md border border-line bg-surface-sunken pl-3 text-sm","focus-within:border-line-strong focus-within:ring-2 focus-within:ring-ring/30 transition-colors",n),children:[s&&e.jsx("span",{className:"shrink-0 text-fg-subtle",children:s}),e.jsx("select",{className:"min-w-0 flex-1 appearance-none bg-transparent py-0 pr-8 text-fg outline-none",...r,children:t}),e.jsx(i,{className:"pointer-events-none absolute right-2.5 size-4 text-fg-subtle"})]})}export{l as C,u as S};
1
+ import{a,j as e,C as i,b as o}from"./index-BHDPbJFl.js";const l=a("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);function u({icon:s,className:n,children:t,...r}){return e.jsxs("div",{className:o("relative flex h-9 items-center gap-2 rounded-md border border-line bg-surface-sunken pl-3 text-sm","focus-within:border-line-strong focus-within:ring-2 focus-within:ring-ring/30 transition-colors",n),children:[s&&e.jsx("span",{className:"shrink-0 text-fg-subtle",children:s}),e.jsx("select",{className:"min-w-0 flex-1 appearance-none bg-transparent py-0 pr-8 text-fg outline-none",...r,children:t}),e.jsx(i,{className:"pointer-events-none absolute right-2.5 size-4 text-fg-subtle"})]})}export{l as C,u as S};
@@ -0,0 +1 @@
1
+ import{j as e,b as N,a7 as z,r as c,bu as L,s as O,bv as $,aj as I,bN as q,L as k,bO as A,aH as C,B as S,S as M,ap as R,X as B}from"./index-BHDPbJFl.js";import{K as m}from"./kbd-CokhGhSt.js";import{S as G,a as P}from"./settings-screen-Crm_cfd3.js";import{u as E}from"./useMutation-w1gwpUuR.js";import{E as V}from"./ErrorState-B8pjqLAj.js";import{S as Q,u as K}from"./useDebouncedValue-K6LUFKwO.js";import{b as _}from"./format-QyUYNmWo.js";import"./avatar-BfVIntHI.js";function D({options:t,active:r,onSelect:x}){return e.jsx("div",{role:"tablist",className:N("flex shrink-0 gap-1 overflow-x-auto border-b border-line p-2","lg:w-44 lg:flex-col lg:gap-0 lg:overflow-visible lg:border-r lg:border-b-0 lg:py-2 lg:pr-2 lg:pl-3"),children:t.map(a=>{const d=a.id===r;return e.jsxs("button",{type:"button",role:"tab","aria-selected":d,onClick:()=>x(a.id),className:N("flex min-h-11 shrink-0 items-center gap-2 rounded-md px-3 text-left text-sm transition-colors lg:min-h-0 lg:px-2 lg:py-1",d?"bg-accent-2-soft font-medium text-accent-2":"text-fg-muted hover:bg-surface-sunken hover:text-fg"),children:[e.jsx("span",{className:"flex-1 truncate",children:a.label}),e.jsx("span",{className:N("text-2xs tabular-nums",d?"text-accent-2":"text-fg-subtle"),children:a.count??"—"})]},a.id)})})}const v={vip:"VIPs",muted:"Muted",blocked:"Blocked"},F=e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"VIP"})," senders get priority surface in the daily brief and notification escalation, even when an account is quiet."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Muted"})," senders never notify and stay out of the brief. Their mail still syncs and stays searchable."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Blocked"})," senders never load images and go straight to junk."]}),e.jsxs("p",{children:["Tip: flag from the keyboard on any message — ",e.jsx(m,{children:"v"})," VIP,"," ",e.jsx(m,{children:"m"})," mute, ",e.jsx(m,{children:"b"})," block. Every rule an automation creates shows up here and can be removed."]})]});function H({query:t,onCount:r}){const{data:x,isPending:a,isError:d,error:b}=I(q()),g=k(),i=E({...C(),onSettled:()=>{g.invalidateQueries({queryKey:A()})}}),l=x?.suggestions??[],p=t.trim().toLowerCase(),u=p?l.filter(n=>(n.displayName??"").toLowerCase().includes(p)||n.normalizedEmail.toLowerCase().includes(p)):l;return c.useEffect(()=>{r?.(u.length,l.length)},[r,u.length,l.length]),a?e.jsx("div",{className:"px-row-inset py-3 text-sm text-fg-subtle animate-pulse",children:"Loading VIP suggestions…"}):d?e.jsx("div",{className:"px-row-inset py-3",children:e.jsx(V,{variant:"inline",title:"Couldn't load VIP suggestions",error:b})}):l.length===0?e.jsxs("div",{className:"px-row-inset py-5 text-sm text-fg-subtle",children:["No VIP suggestions yet. As you reply to senders, they'll appear here. Press ",e.jsx(m,{children:"v"})," on any message to promote a sender to VIP."]}):u.length===0?e.jsxs("p",{className:"px-row-inset py-5 text-sm text-fg-subtle",children:["No VIPs match “",t,"”."]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-row-inset py-1 text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Suggested — promote to VIP"}),u.map(n=>e.jsx(P,{name:n.displayName??n.normalizedEmail,email:n.normalizedEmail,meta:n.replyCount>0?`${n.inboundCount} received · you replied ${n.replyCount}×`:`${n.inboundCount} received · you've never replied`,trailing:e.jsx(S,{variant:"ghost",size:"sm",icon:e.jsx(M,{className:"size-3.5"}),"aria-busy":i.isPending,onClick:()=>{i.isPending||i.mutate({path:{addressId:n.addressId},body:{flags:{vip:{value:!0,setAt:Date.now(),setBy:"user"}}}})},children:"Add VIP"})},n.addressId))]})}function U({group:t,query:r,onCount:x}){const a=K(r.trim(),300),d=k(),[b,g]=c.useState(null),i=a.length>=2,l=R({query:{q:a,limit:50}}),{data:p,isPending:u,isError:n,error:j}=I({...l,enabled:i}),h=E({...C(),onSuccess:()=>{d.invalidateQueries({queryKey:l.queryKey})}}),f=(p?.items??[]).filter(s=>t==="muted"?s.flags?.muted?.value??!1:s.flags?.blocked?.value??!1);return c.useEffect(()=>{x?.(i?f.length:0,null)},[x,i,f.length]),i?u?e.jsx("div",{className:"px-row-inset py-3 text-sm text-fg-subtle animate-pulse",children:"Searching…"}):n?e.jsx("div",{className:"px-row-inset py-3",children:e.jsx(V,{variant:"inline",title:"Search failed",error:j})}):f.length===0?e.jsxs("p",{className:"px-row-inset py-5 text-sm text-fg-subtle",children:["No ",v[t].toLowerCase()," senders matching “",a,"”."]}):e.jsx(e.Fragment,{children:f.map(s=>{const o=t==="muted"?s.flags?.muted:s.flags?.blocked,y=o?[`${t}`,o.setAt&&_(o.setAt,{month:"short",year:"numeric"})||null,o.reason?`— ${o.reason}`:null].filter(Boolean).join(" "):t,w=h.isPending&&h.variables?.path.addressId===s.addressId,T=h.isError&&b===s.addressId;return e.jsx(P,{name:s.displayName??s.normalizedEmail,email:s.normalizedEmail,danger:t==="blocked",meta:y,trailing:T?e.jsx(S,{variant:"secondary",size:"sm",onClick:()=>{g(s.addressId),h.mutate({path:{addressId:s.addressId},body:{flags:{[t]:null}}})},children:"Retry"}):e.jsx(S,{variant:"ghost",size:"sm",icon:e.jsx(B,{className:"size-3.5"}),"aria-busy":w,"aria-label":`Remove ${t} flag`,onClick:()=>{w||(g(s.addressId),h.mutate({path:{addressId:s.addressId},body:{flags:{[t]:null}}}))}})},s.addressId)})}):e.jsxs("div",{className:"px-row-inset py-5 text-sm text-fg-subtle space-y-2",children:[e.jsxs("p",{children:["Type 2+ characters to search ",v[t].toLowerCase()," ","senders by name or address."]}),e.jsxs("p",{className:"text-2xs text-fg-subtle",children:["Note: a dedicated flagged-address list endpoint is in the backlog. Press ",e.jsx(m,{children:"m"})," on any message to mute its sender; ",e.jsx(m,{children:"b"})," to block."]})]})}function ne(){const t=z(),[r,x]=c.useState("vip"),[a,d]=c.useState(""),[b,g]=c.useState(!0),[i,l]=c.useState(0),[p,u]=c.useState({vip:0,muted:null,blocked:null}),n=c.useCallback((s,o)=>{l(s),u(y=>({...y,vip:o}))},[]),j=c.useCallback((s,o)=>{l(s),u(y=>({...y,[r]:s}))},[r]),h=p[r],f=s=>{const o=$[s];o&&t({to:o})};return e.jsx(G,{items:L,activeId:"senders",title:"Senders & Rules",description:"Per-sender preferences — set with one key from any message, managed here.",flush:!0,help:F,helpOpen:b,onToggleHelp:()=>g(s=>!s),onSelect:f,onBackToMail:()=>{t({to:"/mail"})},children:e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col lg:flex-row",children:[e.jsx(D,{active:r,onSelect:s=>{x(s),d("")},options:["vip","muted","blocked"].map(s=>({id:s,label:v[s],count:p[s]}))}),e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[e.jsx("div",{className:"border-b border-line px-row-inset py-2",children:e.jsx(O,{icon:e.jsx(Q,{className:"size-4"}),placeholder:`Filter ${v[r].toLowerCase()} by name or address`,className:"h-8 max-w-sm",value:a,onChange:s=>d(s.target.value)})}),e.jsx("div",{className:"min-h-0 flex-1 divide-y divide-line overflow-y-auto",children:r==="vip"?e.jsx(H,{query:a,onCount:n}):e.jsx(U,{group:r,query:a,onCount:j})}),e.jsxs("footer",{className:"flex items-center justify-between border-t border-line px-row-inset py-1 text-2xs text-fg-subtle",children:[e.jsx("span",{children:h!=null?`${i} of ${h} flagged senders`:`${i} flagged senders`}),e.jsxs("span",{children:[e.jsx(m,{children:"j"})," ",e.jsx(m,{children:"k"})," navigate · ",e.jsx(m,{children:"⌫"})," remove flag"]})]})]})]})})}export{ne as component};
@@ -0,0 +1 @@
1
+ import{j as t,bf as o}from"./index-BHDPbJFl.js";const n=()=>t.jsx(o,{});export{n as component};
@@ -1 +1 @@
1
- import{a as z,r as g,j as e,b as m,B as x,X as j,d as S}from"./index-DFBCf_Ns.js";import{M as B,C as N,A as w}from"./avatar-K4mVDmMa.js";const v=z("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);function L({items:l,activeId:t,title:i,description:n,children:r,help:s,helpOpen:d=!0,flush:o,onSelect:k,onToggleHelp:f,onBackToMail:h}){const[y,c]=g.useState(!1),[u,C]=g.useState(!1),b=!!s&&d,p=e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 pt-3 pb-1 text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Settings"}),e.jsx("nav",{className:"flex-1 overflow-y-auto px-2 py-1",children:l.map(a=>e.jsxs("button",{type:"button",onClick:()=>{k?.(a.id),c(!1)},className:m("flex min-h-11 w-full items-center gap-2 rounded-md px-2 py-1 text-left text-sm transition-colors lg:min-h-0",a.id===t?"bg-accent-2-soft font-medium text-accent-2":"text-fg-muted hover:bg-surface hover:text-fg"),children:[a.icon&&e.jsx("span",{className:m("shrink-0",a.id===t?"text-accent-2":"text-fg-subtle"),children:a.icon}),a.label]},a.id))})]});return e.jsxs("div",{className:"flex h-dvh w-full overflow-hidden bg-canvas font-sans text-fg",children:[e.jsxs("aside",{className:"hidden w-60 shrink-0 flex-col border-r border-line bg-surface-sunken lg:flex",children:[e.jsx("div",{className:"flex h-pane-header shrink-0 items-center border-b border-line px-2",children:e.jsxs("button",{type:"button",onClick:h,className:"flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-sm text-fg-muted hover:bg-surface hover:text-fg",children:[e.jsx(v,{className:"size-4 text-fg-subtle"}),"Back to mail"]})}),p]}),y&&e.jsxs("div",{className:"fixed inset-0 z-50 flex lg:hidden",children:[e.jsx("button",{type:"button","aria-label":"Close menu",className:"absolute inset-0 bg-canvas/60",onClick:()=>c(!1)}),e.jsxs("aside",{className:"relative flex w-72 max-w-[85%] flex-col border-r border-line bg-surface-sunken",children:[e.jsxs("div",{className:"flex h-pane-header shrink-0 items-center justify-between border-b border-line px-2",children:[e.jsxs("button",{type:"button",onClick:()=>{h?.(),c(!1)},className:"flex items-center gap-2 rounded-md px-2 py-1 text-left text-sm text-fg-muted hover:bg-surface hover:text-fg",children:[e.jsx(v,{className:"size-4 text-fg-subtle"}),"Back to mail"]}),e.jsx(x,{variant:"ghost",size:"sm",icon:e.jsx(j,{className:"size-4"}),onClick:()=>c(!1),"aria-label":"Close menu"})]}),p]})]}),e.jsxs("main",{className:"flex min-w-0 flex-1 flex-col",children:[e.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-3 border-b border-line px-3 lg:px-5",children:[e.jsx(x,{variant:"ghost",size:"sm",icon:e.jsx(B,{className:"size-4"}),className:"lg:hidden",onClick:()=>c(!0),"aria-label":"Open settings menu"}),e.jsx("h1",{className:"text-md font-semibold text-fg",children:i}),n&&e.jsx("p",{className:"hidden min-w-0 truncate text-xs text-fg-subtle lg:block",children:n}),s&&e.jsx(x,{variant:"ghost",size:"sm",icon:e.jsx(N,{className:"size-4"}),className:"ml-auto lg:hidden",onClick:()=>C(a=>!a),"aria-label":"Tips","aria-expanded":u}),s&&!b&&e.jsx(x,{variant:"ghost",size:"sm",icon:e.jsx(N,{className:"size-4"}),className:"hidden ml-auto lg:inline-flex",onClick:f,"aria-label":"Show tips"})]}),s&&u&&e.jsx("div",{className:"border-b border-line bg-surface-sunken px-row-inset py-3 text-xs leading-relaxed text-fg-muted lg:hidden",children:s}),o?e.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:r}):e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:e.jsx("div",{className:"max-w-2xl px-3 py-5 lg:px-5",children:e.jsx("div",{className:"space-y-5",children:r})})})]}),b&&e.jsxs("aside",{className:"hidden w-64 shrink-0 flex-col border-l border-line bg-surface-sunken lg:flex",children:[e.jsxs("header",{className:"flex h-pane-header shrink-0 items-center justify-between border-b border-line px-row-inset",children:[e.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Tips & tricks"}),e.jsx(x,{variant:"ghost",size:"sm",icon:e.jsx(j,{className:"size-3.5"}),onClick:f,"aria-label":"Collapse tips"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-row-inset py-3 text-xs leading-relaxed text-fg-muted",children:s})]})]})}function E({name:l,email:t,meta:i,caption:n,danger:r,trailing:s}){return e.jsxs("div",{className:"flex items-center gap-3 px-row-inset py-2 hover:bg-surface-sunken",children:[e.jsx("span",{className:m(r&&"rounded-full ring-2 ring-danger/40"),children:e.jsx(w,{name:l,email:t,size:"sm"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-col gap-0 sm:flex-row sm:items-baseline sm:gap-2",children:[e.jsx("span",{className:"truncate text-sm font-medium text-fg",children:l}),e.jsx("span",{className:"truncate text-2xs text-fg-subtle",children:t})]}),e.jsxs("div",{className:"text-xs text-fg-subtle",children:[i,n&&e.jsxs("span",{className:"text-fg-muted",children:[" · ",n]})]})]}),s&&e.jsx("div",{className:"shrink-0",children:s})]})}const O={healthy:{tone:"positive",label:"healthy"},error:{tone:"danger",label:"error"},muted:{tone:"neutral",label:"muted"}};function F({label:l,email:t,connector:i,syncLabel:n,state:r,errorDetail:s,trailing:d}){const o=O[r];return e.jsxs("div",{className:m("rounded-sm border border-line bg-surface",r==="muted"&&"opacity-65"),children:[e.jsxs("div",{className:"flex flex-col gap-3 px-row-inset py-3 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx(w,{name:l,email:t,size:"md"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-semibold text-fg",children:l}),e.jsx(S,{tone:o.tone,dot:!0,children:o.label})]}),e.jsxs("div",{className:"truncate text-xs text-fg-subtle",children:[t," · ",i," · ",n]})]})]}),d&&e.jsx("div",{className:"shrink-0",children:d})]}),s&&e.jsx("div",{className:"border-t border-line px-row-inset py-2",children:e.jsx("code",{className:"block rounded-xs bg-danger-soft px-2 py-1 text-2xs text-danger",children:s})})]})}export{F as A,L as S,E as a};
1
+ import{a as z,r as g,j as e,b as m,B as x,X as j,d as S}from"./index-BHDPbJFl.js";import{M as B,C as N,A as w}from"./avatar-BfVIntHI.js";const v=z("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);function L({items:l,activeId:t,title:i,description:n,children:r,help:s,helpOpen:d=!0,flush:o,onSelect:k,onToggleHelp:f,onBackToMail:h}){const[y,c]=g.useState(!1),[u,C]=g.useState(!1),b=!!s&&d,p=e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 pt-3 pb-1 text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Settings"}),e.jsx("nav",{className:"flex-1 overflow-y-auto px-2 py-1",children:l.map(a=>e.jsxs("button",{type:"button",onClick:()=>{k?.(a.id),c(!1)},className:m("flex min-h-11 w-full items-center gap-2 rounded-md px-2 py-1 text-left text-sm transition-colors lg:min-h-0",a.id===t?"bg-accent-2-soft font-medium text-accent-2":"text-fg-muted hover:bg-surface hover:text-fg"),children:[a.icon&&e.jsx("span",{className:m("shrink-0",a.id===t?"text-accent-2":"text-fg-subtle"),children:a.icon}),a.label]},a.id))})]});return e.jsxs("div",{className:"flex h-dvh w-full overflow-hidden bg-canvas font-sans text-fg",children:[e.jsxs("aside",{className:"hidden w-60 shrink-0 flex-col border-r border-line bg-surface-sunken lg:flex",children:[e.jsx("div",{className:"flex h-pane-header shrink-0 items-center border-b border-line px-2",children:e.jsxs("button",{type:"button",onClick:h,className:"flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-sm text-fg-muted hover:bg-surface hover:text-fg",children:[e.jsx(v,{className:"size-4 text-fg-subtle"}),"Back to mail"]})}),p]}),y&&e.jsxs("div",{className:"fixed inset-0 z-50 flex lg:hidden",children:[e.jsx("button",{type:"button","aria-label":"Close menu",className:"absolute inset-0 bg-canvas/60",onClick:()=>c(!1)}),e.jsxs("aside",{className:"relative flex w-72 max-w-[85%] flex-col border-r border-line bg-surface-sunken",children:[e.jsxs("div",{className:"flex h-pane-header shrink-0 items-center justify-between border-b border-line px-2",children:[e.jsxs("button",{type:"button",onClick:()=>{h?.(),c(!1)},className:"flex items-center gap-2 rounded-md px-2 py-1 text-left text-sm text-fg-muted hover:bg-surface hover:text-fg",children:[e.jsx(v,{className:"size-4 text-fg-subtle"}),"Back to mail"]}),e.jsx(x,{variant:"ghost",size:"sm",icon:e.jsx(j,{className:"size-4"}),onClick:()=>c(!1),"aria-label":"Close menu"})]}),p]})]}),e.jsxs("main",{className:"flex min-w-0 flex-1 flex-col",children:[e.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-3 border-b border-line px-3 lg:px-5",children:[e.jsx(x,{variant:"ghost",size:"sm",icon:e.jsx(B,{className:"size-4"}),className:"lg:hidden",onClick:()=>c(!0),"aria-label":"Open settings menu"}),e.jsx("h1",{className:"text-md font-semibold text-fg",children:i}),n&&e.jsx("p",{className:"hidden min-w-0 truncate text-xs text-fg-subtle lg:block",children:n}),s&&e.jsx(x,{variant:"ghost",size:"sm",icon:e.jsx(N,{className:"size-4"}),className:"ml-auto lg:hidden",onClick:()=>C(a=>!a),"aria-label":"Tips","aria-expanded":u}),s&&!b&&e.jsx(x,{variant:"ghost",size:"sm",icon:e.jsx(N,{className:"size-4"}),className:"hidden ml-auto lg:inline-flex",onClick:f,"aria-label":"Show tips"})]}),s&&u&&e.jsx("div",{className:"border-b border-line bg-surface-sunken px-row-inset py-3 text-xs leading-relaxed text-fg-muted lg:hidden",children:s}),o?e.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:r}):e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:e.jsx("div",{className:"max-w-2xl px-3 py-5 lg:px-5",children:e.jsx("div",{className:"space-y-5",children:r})})})]}),b&&e.jsxs("aside",{className:"hidden w-64 shrink-0 flex-col border-l border-line bg-surface-sunken lg:flex",children:[e.jsxs("header",{className:"flex h-pane-header shrink-0 items-center justify-between border-b border-line px-row-inset",children:[e.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Tips & tricks"}),e.jsx(x,{variant:"ghost",size:"sm",icon:e.jsx(j,{className:"size-3.5"}),onClick:f,"aria-label":"Collapse tips"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-row-inset py-3 text-xs leading-relaxed text-fg-muted",children:s})]})]})}function E({name:l,email:t,meta:i,caption:n,danger:r,trailing:s}){return e.jsxs("div",{className:"flex items-center gap-3 px-row-inset py-2 hover:bg-surface-sunken",children:[e.jsx("span",{className:m(r&&"rounded-full ring-2 ring-danger/40"),children:e.jsx(w,{name:l,email:t,size:"sm"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-col gap-0 sm:flex-row sm:items-baseline sm:gap-2",children:[e.jsx("span",{className:"truncate text-sm font-medium text-fg",children:l}),e.jsx("span",{className:"truncate text-2xs text-fg-subtle",children:t})]}),e.jsxs("div",{className:"text-xs text-fg-subtle",children:[i,n&&e.jsxs("span",{className:"text-fg-muted",children:[" · ",n]})]})]}),s&&e.jsx("div",{className:"shrink-0",children:s})]})}const O={healthy:{tone:"positive",label:"healthy"},error:{tone:"danger",label:"error"},muted:{tone:"neutral",label:"muted"}};function F({label:l,email:t,connector:i,syncLabel:n,state:r,errorDetail:s,trailing:d}){const o=O[r];return e.jsxs("div",{className:m("rounded-sm border border-line bg-surface",r==="muted"&&"opacity-65"),children:[e.jsxs("div",{className:"flex flex-col gap-3 px-row-inset py-3 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx(w,{name:l,email:t,size:"md"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-semibold text-fg",children:l}),e.jsx(S,{tone:o.tone,dot:!0,children:o.label})]}),e.jsxs("div",{className:"truncate text-xs text-fg-subtle",children:[t," · ",i," · ",n]})]})]}),d&&e.jsx("div",{className:"shrink-0",children:d})]}),s&&e.jsx("div",{className:"border-t border-line px-row-inset py-2",children:e.jsx("code",{className:"block rounded-xs bg-danger-soft px-2 py-1 text-2xs text-danger",children:s})})]})}export{F as A,L as S,E as a};
@@ -1 +1 @@
1
- import{j as t,b3 as e}from"./index-DFBCf_Ns.js";const o=()=>t.jsx(e,{to:"/settings/senders",replace:!0});export{o as component};
1
+ import{j as t,bh as e}from"./index-BHDPbJFl.js";const o=()=>t.jsx(e,{to:"/settings/senders",replace:!0});export{o as component};
@@ -1 +1 @@
1
- import{a as u,r as c}from"./index-DFBCf_Ns.js";const n=u("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]),i=(e,t)=>{const[r,o]=c.useState(e);return c.useEffect(()=>{const s=setTimeout(()=>o(e),t);return()=>clearTimeout(s)},[e,t]),r};export{n as S,i as u};
1
+ import{a as u,r as c}from"./index-BHDPbJFl.js";const n=u("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]),i=(e,t)=>{const[r,o]=c.useState(e);return c.useEffect(()=>{const s=setTimeout(()=>o(e),t);return()=>clearTimeout(s)},[e,t]),r};export{n as S,i as u};
@@ -1 +1 @@
1
- import{w as l,y as d,bw as a,bx as b,x as h,A as p,r as o,L as m,by as y}from"./index-DFBCf_Ns.js";var v=class extends l{#s;#i=void 0;#t;#e;constructor(t,s){super(),this.#s=t,this.setOptions(s),this.bindMethods(),this.#r()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){const s=this.options;this.options=this.#s.defaultMutationOptions(t),d(this.options,s)||this.#s.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#t,observer:this}),s?.mutationKey&&this.options.mutationKey&&a(s.mutationKey)!==a(this.options.mutationKey)?this.reset():this.#t?.state.status==="pending"&&this.#t.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#t?.removeObserver(this)}onMutationUpdate(t){this.#r(),this.#o(t)}getCurrentResult(){return this.#i}reset(){this.#t?.removeObserver(this),this.#t=void 0,this.#r(),this.#o()}mutate(t,s){return this.#e=s,this.#t?.removeObserver(this),this.#t=this.#s.getMutationCache().build(this.#s,this.options),this.#t.addObserver(this),this.#t.execute(t)}#r(){const t=this.#t?.state??b();this.#i={...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset}}#o(t){h.batch(()=>{if(this.#e&&this.hasListeners()){const s=this.#i.variables,r=this.#i.context,e={client:this.#s,meta:this.options.meta,mutationKey:this.options.mutationKey};if(t?.type==="success"){try{this.#e.onSuccess?.(t.data,s,r,e)}catch(i){Promise.reject(i)}try{this.#e.onSettled?.(t.data,null,s,r,e)}catch(i){Promise.reject(i)}}else if(t?.type==="error"){try{this.#e.onError?.(t.error,s,r,e)}catch(i){Promise.reject(i)}try{this.#e.onSettled?.(void 0,t.error,s,r,e)}catch(i){Promise.reject(i)}}}this.listeners.forEach(s=>{s(this.#i)})})}};function O(t,s){const r=p(),[e]=o.useState(()=>new v(r,t));o.useEffect(()=>{e.setOptions(t)},[e,t]);const i=o.useSyncExternalStore(o.useCallback(n=>e.subscribe(h.batchCalls(n)),[e]),()=>e.getCurrentResult(),()=>e.getCurrentResult()),u=o.useCallback((n,c)=>{e.mutate(n,c).catch(m)},[e]);if(i.error&&y(e.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:u,mutateAsync:i.mutate}}export{O as u};
1
+ import{G as l,J as d,bP as a,bQ as b,H as h,L as p,r as o,Z as m,bR as v}from"./index-BHDPbJFl.js";var y=class extends l{#s;#i=void 0;#t;#e;constructor(t,s){super(),this.#s=t,this.setOptions(s),this.bindMethods(),this.#r()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){const s=this.options;this.options=this.#s.defaultMutationOptions(t),d(this.options,s)||this.#s.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#t,observer:this}),s?.mutationKey&&this.options.mutationKey&&a(s.mutationKey)!==a(this.options.mutationKey)?this.reset():this.#t?.state.status==="pending"&&this.#t.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#t?.removeObserver(this)}onMutationUpdate(t){this.#r(),this.#o(t)}getCurrentResult(){return this.#i}reset(){this.#t?.removeObserver(this),this.#t=void 0,this.#r(),this.#o()}mutate(t,s){return this.#e=s,this.#t?.removeObserver(this),this.#t=this.#s.getMutationCache().build(this.#s,this.options),this.#t.addObserver(this),this.#t.execute(t)}#r(){const t=this.#t?.state??b();this.#i={...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset}}#o(t){h.batch(()=>{if(this.#e&&this.hasListeners()){const s=this.#i.variables,r=this.#i.context,e={client:this.#s,meta:this.options.meta,mutationKey:this.options.mutationKey};if(t?.type==="success"){try{this.#e.onSuccess?.(t.data,s,r,e)}catch(i){Promise.reject(i)}try{this.#e.onSettled?.(t.data,null,s,r,e)}catch(i){Promise.reject(i)}}else if(t?.type==="error"){try{this.#e.onError?.(t.error,s,r,e)}catch(i){Promise.reject(i)}try{this.#e.onSettled?.(void 0,t.error,s,r,e)}catch(i){Promise.reject(i)}}}this.listeners.forEach(s=>{s(this.#i)})})}};function O(t,s){const r=p(),[e]=o.useState(()=>new y(r,t));o.useEffect(()=>{e.setOptions(t)},[e,t]);const i=o.useSyncExternalStore(o.useCallback(n=>e.subscribe(h.batchCalls(n)),[e]),()=>e.getCurrentResult(),()=>e.getCurrentResult()),u=o.useCallback((n,c)=>{e.mutate(n,c).catch(m)},[e]);if(i.error&&v(e.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:u,mutateAsync:i.mutate}}export{O as u};
@@ -1 +1 @@
1
- import{r as m,j as i,B as u,b as y,A as p,ai as x,aa as h,ah as C,am as j,b2 as L,b6 as k}from"./index-DFBCf_Ns.js";import{L as E}from"./account-form-helpers-cgQ51wpS.js";import{u as O}from"./useMutation-driganVD.js";const b=()=>i.jsx(E,{className:"size-3.5 animate-spin"}),f=(s,n)=>n?i.jsx("span",{className:"sr-only",children:s}):s;function M({actions:s=[],destructive:n,className:l}){const[e,o]=m.useState(!1);return e&&n?.confirm?i.jsxs("div",{className:y("flex items-center gap-2",l),children:[i.jsx("span",{className:"text-xs text-fg-muted",children:n.confirm.prompt}),i.jsx(u,{variant:"secondary",size:"sm",onClick:()=>o(!1),children:n.confirm.cancelLabel??"Cancel"}),i.jsx(u,{variant:"danger",size:"sm","aria-busy":n.busy,icon:n.busy?b():void 0,onClick:()=>{n.busy||n.onClick()},children:n.busy?n.busyLabel??"Working…":n.confirm.confirmLabel??n.label})]}):i.jsxs("div",{className:y("flex items-center gap-2",l),children:[s.map(a=>i.jsx(u,{variant:a.variant??"ghost",size:"sm","aria-busy":a.busy,"aria-label":a.iconOnly?a.label:void 0,icon:a.busy?b():a.icon,onClick:()=>{a.busy||a.onClick()},children:a.busy&&a.busyLabel?a.busyLabel:f(a.label,a.iconOnly)},a.label)),n&&i.jsx(u,{variant:"ghost",size:"sm","aria-busy":n.busy,"aria-label":n.iconOnly?n.label:void 0,icon:n.busy?b():n.icon,onClick:()=>{if(!n.busy){if(n.confirm){o(!0);return}n.onClick()}},children:n.busy&&n.busyLabel?n.busyLabel:f(n.label,n.iconOnly)})]})}const c={html:"",plainText:""},N=s=>{const n=p(),{pushError:l}=x(),{data:e}=h({...C(),staleTime:1/0}),o=m.useMemo(()=>{if(!s||!e)return c;const r=e.accounts.find(t=>t.accountId===s);return r?{html:r.signatureHtml??"",plainText:r.signaturePlainText??""}:c},[s,e]),a=O({...k(),onSuccess:()=>{n.invalidateQueries({queryKey:L()})},onError:r=>{l(j("Couldn't save signature","The signature wasn't saved.",r))}}),g=m.useCallback((r,t)=>{s&&a.mutate({path:{accountId:s},body:{signatureHtml:r,signaturePlainText:t}})},[s,a]);return{signature:o,setSignature:g,isSaving:a.isPending}};export{M as R,N as u};
1
+ import{r as m,j as i,B as u,b as y,L as p,ar as x,aj as C,aq as h,av as j,bg as L,bk as k}from"./index-BHDPbJFl.js";import{L as E}from"./account-form-helpers-CcBJx1BZ.js";import{u as O}from"./useMutation-w1gwpUuR.js";const b=()=>i.jsx(E,{className:"size-3.5 animate-spin"}),f=(s,n)=>n?i.jsx("span",{className:"sr-only",children:s}):s;function M({actions:s=[],destructive:n,className:l}){const[e,o]=m.useState(!1);return e&&n?.confirm?i.jsxs("div",{className:y("flex items-center gap-2",l),children:[i.jsx("span",{className:"text-xs text-fg-muted",children:n.confirm.prompt}),i.jsx(u,{variant:"secondary",size:"sm",onClick:()=>o(!1),children:n.confirm.cancelLabel??"Cancel"}),i.jsx(u,{variant:"danger",size:"sm","aria-busy":n.busy,icon:n.busy?b():void 0,onClick:()=>{n.busy||n.onClick()},children:n.busy?n.busyLabel??"Working…":n.confirm.confirmLabel??n.label})]}):i.jsxs("div",{className:y("flex items-center gap-2",l),children:[s.map(a=>i.jsx(u,{variant:a.variant??"ghost",size:"sm","aria-busy":a.busy,"aria-label":a.iconOnly?a.label:void 0,icon:a.busy?b():a.icon,onClick:()=>{a.busy||a.onClick()},children:a.busy&&a.busyLabel?a.busyLabel:f(a.label,a.iconOnly)},a.label)),n&&i.jsx(u,{variant:"ghost",size:"sm","aria-busy":n.busy,"aria-label":n.iconOnly?n.label:void 0,icon:n.busy?b():n.icon,onClick:()=>{if(!n.busy){if(n.confirm){o(!0);return}n.onClick()}},children:n.busy&&n.busyLabel?n.busyLabel:f(n.label,n.iconOnly)})]})}const c={html:"",plainText:""},N=s=>{const n=p(),{pushError:l}=x(),{data:e}=C({...h(),staleTime:1/0}),o=m.useMemo(()=>{if(!s||!e)return c;const r=e.accounts.find(t=>t.accountId===s);return r?{html:r.signatureHtml??"",plainText:r.signaturePlainText??""}:c},[s,e]),a=O({...k(),onSuccess:()=>{n.invalidateQueries({queryKey:L()})},onError:r=>{l(j("Couldn't save signature","The signature wasn't saved.",r))}}),g=m.useCallback((r,t)=>{s&&a.mutate({path:{accountId:s},body:{signatureHtml:r,signaturePlainText:t}})},[s,a]);return{signature:o,setSignature:g,isSaving:a.isPending}};export{M as R,N as u};
package/index.html CHANGED
@@ -31,7 +31,7 @@
31
31
  } catch (_) {}
32
32
  })();
33
33
  </script>
34
- <script type="module" crossorigin src="/assets/index-DFBCf_Ns.js"></script>
34
+ <script type="module" crossorigin src="/assets/index-BHDPbJFl.js"></script>
35
35
  <link rel="stylesheet" crossorigin href="/assets/index-DgIMsJfP.css">
36
36
  </head>
37
37
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/web-client-dist",
3
- "version": "0.0.49",
3
+ "version": "0.0.51",
4
4
  "description": "Built Remit web client — static assets and the default runtime config.",
5
5
  "files": [
6
6
  "**/*"
@@ -1 +0,0 @@
1
- import{a as Gt,j as i,T as nt,r as O,b as jt,X as Oe,R as X,A as Yt,b4 as Ts,b2 as Fe,b5 as As,b6 as _s,B as se,m as de,a2 as St,b7 as Ps,b8 as ke,b9 as be,ba as wt,a3 as Vs,bb as Es,bc as ks,D as Zt,bd as Nt,a0 as Ds,aa as Fs,ah as Cs,be as Os,bf as Is,bg as Ms,g as Tt,d as Rs,bh as Us}from"./index-DFBCf_Ns.js";import{u as Ls,R as Hs}from"./useSignature-Bvv4geSf.js";import{S as zs,A as Bs}from"./settings-screen-D48k5Bt1.js";import{u as Ne}from"./useMutation-driganVD.js";import{g as At,P as qs,s as Ue,O as $s}from"./OnboardingWizard-lYRoUUwG.js";import{S as Ws,C as _t}from"./select-u4cRyFjX.js";import{c as Ks,b as Pt,L as et,d as Gs}from"./account-form-helpers-cgQ51wpS.js";import{E as Ys}from"./ErrorState-ozcCp-cA.js";import{e as Zs}from"./format-QyUYNmWo.js";import{T as Qs}from"./trash-2-l_BkiFgy.js";import"./avatar-K4mVDmMa.js";import"./kbd-BfCwcUpt.js";const Xs=Gt("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);const Vt=Gt("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);function Js({title:e,description:s,action:t}){return i.jsxs("div",{className:"rounded-sm border border-danger/50",children:[i.jsxs("div",{className:"flex items-center gap-2 border-b border-danger/30 bg-danger-soft px-row-inset py-2",children:[i.jsx(nt,{className:"size-4 text-danger"}),i.jsx("h2",{className:"text-sm font-semibold text-danger",children:"Danger zone"})]}),i.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:[i.jsxs("div",{className:"min-w-0",children:[i.jsx("div",{className:"text-sm font-medium text-fg",children:e}),i.jsx("p",{className:"text-xs text-fg-muted",children:s})]}),i.jsx("div",{className:"shrink-0",children:t})]})]})}function Et({isOpen:e,onClose:s,title:t,children:a,footer:c}){return O.useEffect(()=>{if(!e)return;const d=n=>{n.key==="Escape"&&s()};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[e,s]),i.jsxs(i.Fragment,{children:[i.jsx("div",{className:jt("fixed inset-0 z-40 bg-black/30 transition-opacity",e?"opacity-100":"pointer-events-none opacity-0"),onClick:s,"aria-hidden":"true"}),i.jsxs("div",{className:jt("fixed top-0 right-0 z-50 h-full w-full 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",children:[i.jsxs("div",{className:"flex h-14 items-center justify-between border-b border-line px-4",children:[i.jsx("h2",{id:"slide-panel-title",className:"font-semibold",children:t}),i.jsx("button",{type:"button",onClick:s,className:"rounded-md p-1.5 transition-colors hover:bg-surface-raised","aria-label":"Close",children:i.jsx(Oe,{className:"size-5"})})]}),i.jsxs("div",{className:"flex h-[calc(100%-3.5rem)] flex-col",children:[i.jsx("div",{className:"flex-1 overflow-auto p-4",children:a}),c&&i.jsx("div",{className:"flex justify-end gap-3 border-t border-line bg-canvas p-4",children:c})]})]})]})}var Ie=e=>e.type==="checkbox",je=e=>e instanceof Date,G=e=>e==null;const ot=e=>typeof e=="object";var z=e=>!G(e)&&!Array.isArray(e)&&ot(e)&&!je(e),er=e=>z(e)&&e.target?Ie(e.target)?e.target.checked:e.target.value:e,tr=(e,s)=>s.split(".").some((t,a,c)=>!isNaN(Number(t))&&e.has(c.slice(0,a).join("."))),Qt=e=>{const s=e.constructor&&e.constructor.prototype;return z(s)&&s.hasOwnProperty("isPrototypeOf")},$e=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($e&&(e instanceof Blob||s))return e;const t=Array.isArray(e);if(!t&&!(z(e)&&Qt(e)))return e;const a=t?[]:Object.create(Object.getPrototypeOf(e));for(const c in e)Object.prototype.hasOwnProperty.call(e,c)&&(a[c]=B(e[c]));return a}const Ae={BLUR:"blur",FOCUS_OUT:"focusout",SUBMIT:"submit",TRIGGER:"trigger",VALID:"valid"},fe={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},ue={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},Xt="root",lt=["__proto__","constructor","prototype"],sr=/^\w*$/;var Me=e=>sr.test(e),R=e=>e===void 0;const rr=/[.[\]'"]/;var We=e=>e.split(rr).filter(Boolean),g=(e,s,t)=>{if(!s||!z(e))return t;const a=Me(s)?[s]:We(s);if(a.some(d=>lt.includes(d)))return t;const c=a.reduce((d,n)=>G(d)?void 0:d[n],e);return R(c)||c===e?R(e[s])?t:e[s]:c},me=e=>typeof e=="boolean",ne=e=>typeof e=="function",F=(e,s,t)=>{let a=-1;const c=Me(s)?[s]:We(s),d=c.length,n=d-1;for(;++a<d;){const u=c[a];let j=t;if(a!==n){const P=e[u];j=z(P)||Array.isArray(P)?P:isNaN(+c[a+1])?{}:[]}if(lt.includes(u))return;e[u]=j,e=e[u]}};const ir=X.createContext(null);ir.displayName="HookFormControlContext";var ar=(e,s,t,a=!0)=>{const c={};for(const d in e)Object.defineProperty(c,d,{get:()=>{const n=d;return s._proxyFormState[n]!==fe.all&&(s._proxyFormState[n]=!a||fe.all),e[n]}});return c};const nr=$e?X.useLayoutEffect:X.useEffect;var Y=e=>typeof e=="string",or=(e,s,t,a,c)=>Y(e)?(a&&s.watch.add(e),g(t,e,c)):Array.isArray(e)?e.map(d=>(a&&s.watch.add(d),g(t,d))):(a&&(s.watchAll=!0),t),tt=e=>G(e)||!ot(e);const kt=(e,s)=>s.length===0&&!Array.isArray(e)&&!Qt(e);function he(e,s,t=new WeakMap){if(e===s)return!0;if(tt(e)||tt(s))return Object.is(e,s);if(je(e)&&je(s))return Object.is(e.getTime(),s.getTime());const a=Object.keys(e),c=Object.keys(s);if(a.length!==c.length)return!1;if(kt(e,a)||kt(s,c))return Object.is(e,s);if(!a.length&&Array.isArray(e)!==Array.isArray(s))return!1;const d=t.get(e);if(d&&d.has(s))return!0;if(d)d.add(s);else{const n=new WeakSet;n.add(s),t.set(e,n)}for(const n of a){const u=e[n];if(!(n in s))return!1;if(n!=="ref"){const j=s[n];if(je(u)&&je(j)||(z(u)||Array.isArray(u))&&(z(j)||Array.isArray(j))?!he(u,j,t):!Object.is(u,j))return!1}}return!0}var Le=e=>({isOnSubmit:!e||e===fe.onSubmit,isOnBlur:e===fe.onBlur,isOnChange:e===fe.onChange,isOnAll:e===fe.all,isOnTouch:e===fe.onTouched}),Qe=(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 Ce=(e,s,t,a)=>{for(const c of t||Object.keys(e)){const d=g(e,c);if(d){const{_f:n,...u}=d;if(n){if(n.refs&&n.refs[0]&&s(n.refs[0],c)&&!a)return!0;if(n.ref&&s(n.ref,n.name)&&!a)return!0;if(Ce(u,s))break}else if(z(u)&&Ce(u,s))break}}};var Dt=(e,s,t)=>{const a=g(e,t),c=Array.isArray(a)?a:[];return F(c,Xt,s[t]),F(e,t,c),e},K=e=>z(e)&&!Object.keys(e).length,ct=e=>e.type==="file",Be=e=>{if(!$e)return!1;const s=e?e.ownerDocument:0;return e instanceof(s&&s.defaultView?s.defaultView.HTMLElement:HTMLElement)},dt=e=>e.type==="radio",qe=e=>e instanceof RegExp,ut=(e,s,t,a,c)=>s?{...t[e],types:{...t[e]&&t[e].types?t[e].types:{},[a]:c||!0}}:{};const Ft={value:!1,isValid:!1},Ct={value:!0,isValid:!0};var Jt=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&&!R(e[0].attributes.value)?R(e[0].value)||e[0].value===""?Ct:{value:e[0].value,isValid:!0}:Ct:Ft}return Ft};const Ot={isValid:!1,value:null};var es=e=>Array.isArray(e)?e.reduce((s,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:s,Ot):Ot;function It(e,s,t="validate"){if(Y(e)||Array.isArray(e)&&e.every(Y)||me(e)&&!e)return{type:t,message:Y(e)?e:"",ref:s}}var _e=e=>z(e)&&!qe(e)?e:{value:e,message:""},Mt=async(e,s,t,a,c,d)=>{const{ref:n,refs:u,required:j,maxLength:P,minLength:V,min:H,max:I,pattern:C,validate:N,name:f,valueAsNumber:b,mount:ie}=e._f,T=g(t,f);if(!ie||s.has(f))return{};const J=u?u[0]:n,M=A=>{if(c&&J.reportValidity){const _=me(A)?"":A||"";u?u.forEach(D=>D.setCustomValidity(_)):J.setCustomValidity(_),J.reportValidity()}},E={},oe=dt(n),re=Ie(n),pe=oe||re,le=(b||ct(n))&&R(n.value)&&R(T)||Be(n)&&n.value===""||T===""||Array.isArray(T)&&!T.length,W=ut.bind(null,f,a,E),ee=(A,_,D,$=ue.maxLength,w=ue.minLength)=>{const L=A?_:D;E[f]={type:A?$:w,message:L,ref:n,...W(A?$:w,L)}};if(d?!Array.isArray(T)||!T.length:j&&(!pe&&(le||G(T))||me(T)&&!T||re&&!Jt(u).isValid||oe&&!es(u).isValid)){const{value:A,message:_}=Y(j)?{value:!!j,message:j}:_e(j);if(A&&(E[f]={type:ue.required,message:_,ref:J,...W(ue.required,_)},!a))return M(_),E}if(!le&&(!G(H)||!G(I))){let A,_;const D=_e(I),$=_e(H);if(!G(T)&&!isNaN(T)){const w=n.valueAsNumber||T&&+T;G(D.value)||(A=w>D.value),G($.value)||(_=w<$.value)}else{const w=n.valueAsDate||new Date(T),L=ve=>new Date(new Date().toDateString()+" "+ve),ye=n.type=="time",Z=n.type=="week";Y(D.value)&&T&&(A=ye?L(T)>L(D.value):Z?T>D.value:w>new Date(D.value)),Y($.value)&&T&&(_=ye?L(T)<L($.value):Z?T<$.value:w<new Date($.value))}if((A||_)&&(ee(!!A,D.message,$.message,ue.max,ue.min),!a))return M(E[f].message),E}if((P||V)&&!le&&(Y(T)||d&&Array.isArray(T))){const A=_e(P),_=_e(V),D=!G(A.value)&&T.length>+A.value,$=!G(_.value)&&T.length<+_.value;if((D||$)&&(ee(D,A.message,_.message),!a))return M(E[f].message),E}if(C&&!le&&Y(T)){const{value:A,message:_}=_e(C);if(qe(A)&&!T.match(A)&&(E[f]={type:ue.pattern,message:_,ref:n,...W(ue.pattern,_)},!a))return M(_),E}if(N){if(ne(N)){const A=await N(T,t),_=It(A,J);if(_&&(E[f]={..._,...W(ue.validate,_.message)},!a))return M(_.message),E}else if(z(N)){let A={};for(const _ in N){if(!K(A)&&!a)break;const D=It(await N[_](T,t),J,_);D&&(A={...D,...W(_,D.message)},M(D.message),a&&(E[f]=A))}if(!K(A)&&(E[f]={ref:J,...A},!a))return E}}return M(!0),E},ze=e=>Array.isArray(e)?e:[e],ts=e=>Array.isArray(e)?e.filter(Boolean):[];function lr(e,s){const t=s.slice(0,-1).length;let a=0;for(;a<t;){if(G(e)){e=void 0;break}e=e[s[a]],a++}return e}function cr(e){for(const s in e)if(e.hasOwnProperty(s)&&!R(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:Me(s)?[s]:We(s);if(t.some(n=>lt.includes(String(n))))return e;const a=t.length===1?e:lr(e,t),c=t.length-1,d=t[c];return a&&delete a[d],c!==0&&(z(a)&&K(a)||Array.isArray(a)&&cr(a))&&q(e,t.slice(0,-1)),e}const ss=e=>{const s={};for(const t of Object.keys(e))if(ot(e[t])&&e[t]!==null&&!je(e[t])){const a=ss(e[t]);for(const c of Object.keys(a))s[`${t}.${c}`]=a[c]}else s[t]=e[t];return s},dr=X.createContext(null);dr.displayName="HookFormContext";var Rt=()=>{let e=[];return{get observers(){return e},next:c=>{for(const d of e)d.next&&d.next(c)},subscribe:c=>(e.push(c),{unsubscribe:()=>{e=e.filter(d=>d!==c)}}),unsubscribe:()=>{e=[]}}};function rs(e,s){const t={};for(const a in e)if(e.hasOwnProperty(a)){const c=e[a],d=s[a];if(c&&z(c)&&d){const n=rs(c,d);z(n)&&(t[a]=n)}else e[a]&&(t[a]=d)}return t}var is=e=>e.type==="select-multiple",ur=e=>dt(e)||Ie(e),Xe=e=>Be(e)&&e.isConnected,fr=e=>{for(const s in e)if(ne(e[s]))return!0;return!1};function as(e){return Array.isArray(e)||z(e)&&!fr(e)}function ns(e){return!!(e&&"_f"in e)}function os(e){return Array.isArray(e)?!e.some(s=>!R(s)):!Object.keys(e).length}function st(e,s){Array.isArray(e)?e[s]=void 0:delete e[s]}function rt(e,s={},t){for(const a in e){const c=e[a],d=t&&t[a];as(c)&&(!Array.isArray(c)||!ns(d))?(s[a]=Array.isArray(c)?[]:{},rt(c,s[a],d),os(s[a])&&st(s,a)):R(c)||(s[a]=!0)}return s}function we(e,s,t,a){t||(t=rt(s,{},a));for(const c in e){const d=e[c],n=a&&a[c];as(d)&&(!Array.isArray(d)||!ns(n))?(R(s)||tt(t[c])?t[c]=rt(d,Array.isArray(d)?[]:{},n):we(d,G(s)?{}:s[c],t[c],n),os(t[c])&&st(t,c)):he(d,s[c])?st(t,c):t[c]=!0}return t}var ls=(e,{valueAsNumber:s,valueAsDate:t,setValueAs:a})=>R(e)?e:s?e===""?NaN:e&&+e:t&&Y(e)?new Date(e):a?a(e):e;function Ut(e){const s=e.ref;return ct(s)?s.files:dt(s)?es(e.refs).value:is(s)?[...s.selectedOptions].map(({value:t})=>t):Ie(s)?Jt(e.refs).value:ls(R(s.value)?e.ref.value:s.value,e)}var mr=(e,s,t,a)=>{const c={};for(const d of e){const n=g(s,d);n&&F(c,d,n._f)}return{criteriaMode:t,names:[...e],fields:c,shouldUseNativeValidation:a}},De=e=>R(e)?e:qe(e)?e.source:z(e)?qe(e.value)?e.value.source:e.value:e;const Lt="AsyncFunction";var hr=e=>{if(!e||!e.validate)return!1;if(ne(e.validate))return e.validate.constructor.name===Lt;if(z(e.validate)){for(const s in e.validate)if(e.validate[s].constructor.name===Lt)return!0}return!1},pr=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function Ht(e,s,t){const a=g(e,t);if(a||Me(t))return{error:a,name:t};const c=t.split(".");for(;c.length;){const d=c.join("."),n=g(s,d),u=g(e,d);if(n&&!Array.isArray(n)&&t!==d)return{name:t};if(u&&u.type)return{name:d,error:u};if(u&&u.root&&u.root.type)return{name:`${d}.root`,error:u.root};c.pop()}return{name:t}}var yr=(e,s,t,a)=>{t(e);const{name:c,...d}=e,n=Object.keys(d);return!n.length||a&&n.length>=Object.keys(s).length||n.find(u=>s[u]===(!a||fe.all))},xr=(e,s,t)=>!e||!s||e===s||ze(e).some(a=>a&&(t?a===s||a.startsWith(s+"."):a.startsWith(s)||s.startsWith(a))),gr=(e,s,t,a,c)=>c.isOnAll?!1:!t&&c.isOnTouch?!(s||e):(t?a.isOnBlur:c.isOnBlur)?!e:(t?a.isOnChange:c.isOnChange)?e:!0,vr=(e,s)=>!ts(g(e,s)).length&&q(e,s);const br={mode:fe.onSubmit,reValidateMode:fe.onChange,shouldFocusError:!0},Je="form",cs={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function jr(e={}){let s={...br,...e},t={...B(cs),isLoading:ne(s.defaultValues),errors:s.errors||{},disabled:s.disabled||!1},a={},c=z(s.defaultValues)||z(s.values)?B(s.defaultValues||s.values)||{}:{},d=s.shouldUnregister?{}:B(c),n={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 j={},P={};let V=0,H=Le(s.mode),I=Le(s.reValidateMode);const C={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},N={...C};let f={...N};const b={array:Rt(),state:Rt()};let ie=0;const T=s.criteriaMode===fe.all,J=(r,o)=>l=>{clearTimeout(P[r]),P[r]=setTimeout(o,l)},M=async r=>{if(!n.keepIsValid&&!s.disabled&&(N.isValid||f.isValid||r)){const o=++ie;let l;s.resolver?(l=K((await D()).errors),o===ie&&E()):l=await L({fields:a,onlyCheckValid:!0,eventType:Ae.VALID}),o===ie&&l!==t.isValid&&b.state.next({isValid:l})}},E=(r,o)=>{!s.disabled&&(N.isValidating||N.validatingFields||f.isValidating||f.validatingFields)&&((r||Array.from(u.mount)).forEach(l=>{l&&(o?F(t.validatingFields,l,o):q(t.validatingFields,l))}),b.state.next({validatingFields:t.validatingFields,isValidating:!K(t.validatingFields)}))},oe=()=>{t.dirtyFields=we(c,d,void 0,a)},re=(r,o=[],l,m,h=!0,x=!0)=>{if(m&&l&&!s.disabled){if(n.action=!0,x&&Array.isArray(g(a,r))){const y=l(g(a,r),m.argA,m.argB);h&&F(a,r,y)}if(x&&Array.isArray(g(t.errors,r))){const y=l(g(t.errors,r),m.argA,m.argB);h&&F(t.errors,r,y),vr(t.errors,r)}if((N.touchedFields||f.touchedFields)&&x&&Array.isArray(g(t.touchedFields,r))){const y=l(g(t.touchedFields,r),m.argA,m.argB);h&&F(t.touchedFields,r,y)}(N.dirtyFields||f.dirtyFields)&&oe(),b.state.next({name:r,isDirty:Z(r,o),dirtyFields:t.dirtyFields,errors:t.errors,isValid:t.isValid})}else F(d,r,o)},pe=(r,o)=>{F(t.errors,r,o),t.errors={...t.errors},b.state.next({errors:t.errors})},le=r=>{t.errors=r,b.state.next({errors:t.errors,isValid:!1})},W=r=>{const o=Me(r)?[r]:We(r);let l=d,m=c;for(let h=0;h<o.length-1;h++){const x=o[h];if(l=G(l)?l:l[x],m=G(m)?m:m[x],l===null&&m!==null)return!0}return!1},ee=(r,o,l,m)=>{const h=g(a,r);if(h){if(W(r))return;const x=R(g(d,r)),y=g(d,r,R(l)?g(c,r):l);R(y)||m&&m.defaultChecked||o?F(d,r,o?y:Ut(h._f)):k(r,y),n.mount&&!n.action&&(M(),x&&t.isDirty&&(N.isDirty||f.isDirty)&&(Z()||(t.isDirty=!1,b.state.next({...t}))),e.shouldUnregister&&x&&!R(g(d,r))&&Qe(r,u)&&(n.watch=!0))}},A=(r,o,l,m,h)=>{let x=!1,y=!1;const v={name:r};if(!s.disabled||m===!0){if(!l||m){const S=he(g(c,r),o);(N.isDirty||f.isDirty)&&(y=t.isDirty,t.isDirty=v.isDirty=!S||Z(),x=y!==v.isDirty),y=!!g(t.dirtyFields,r),S!==t.isDirty?t.dirtyFields=we(c,d,void 0,a):S?q(t.dirtyFields,r):F(t.dirtyFields,r,!0),v.dirtyFields=t.dirtyFields,x=x||(N.dirtyFields||f.dirtyFields)&&y!==!S}if(l){const S=g(t.touchedFields,r);S||(F(t.touchedFields,r,l),v.touchedFields=t.touchedFields,x=x||(N.touchedFields||f.touchedFields)&&S!==l)}x&&h&&b.state.next(v)}return x?v:{}},_=(r,o,l,m)=>{const h=g(t.errors,r),x=(N.isValid||f.isValid)&&me(o)&&t.isValid!==o;if(s.delayError&&l?(j[r]=J(r,()=>pe(r,l)),j[r](s.delayError)):(clearTimeout(P[r]),delete j[r],l?F(t.errors,r,l):q(t.errors,r),t.errors={...t.errors}),(l?!he(h,l):h)||!K(m)||x){const y={...m,...x&&me(o)?{isValid:o}:{},errors:t.errors,name:r};t={...t,...y},b.state.next(y)}},D=async r=>(E(r,!0),await s.resolver(d,s.context,mr(r||u.mount,a,s.criteriaMode,s.shouldUseNativeValidation))),$=async r=>{const{errors:o}=await D(r);if(E(r),r){for(const l of r){const m=g(o,l);m?u.array.has(l)&&z(m)&&!Object.keys(m).some(h=>!Number.isNaN(Number(h)))?Dt(t.errors,{[l]:m},l):F(t.errors,l,m):q(t.errors,l)}t.errors={...t.errors}}else t.errors=o;return o},w=async({name:r,eventType:o})=>{if(e.validate){const l=await e.validate({formValues:d,formState:t,name:r,eventType:o});if(z(l))for(const m in l){const h=l[m];h&&Re(`${Je}.${m}`,{message:Y(h.message)?h.message:"",type:h.type||ue.validate})}else Y(l)||!l?Re(Je,{message:l||"",type:ue.validate}):mt(Je);return l}return!0},L=async({fields:r,onlyCheckValid:o,name:l,eventType:m,context:h={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(h.runRootValidation=!0,!await w({name:l,eventType:m})&&(h.valid=!1,o)))return h.valid;for(const x in r){const y=r[x];if(y){const{_f:v,...S}=y;if(v){const U=u.array.has(v.name),Q=y._f&&hr(y._f),xe=N.validatingFields||N.isValidating||f.validatingFields||f.isValidating;Q&&xe&&E([v.name],!0);const ge=await Mt(y,u.disabled,d,T,s.shouldUseNativeValidation&&!o,U);if(Q&&xe&&E([v.name]),ge[v.name]&&(h.valid=!1,o)||(!o&&(g(ge,v.name)?U?Dt(t.errors,ge,v.name):F(t.errors,v.name,ge[v.name]):q(t.errors,v.name)),e.shouldUseNativeValidation&&ge[v.name]))break}!K(S)&&await L({context:h,onlyCheckValid:o,fields:S,name:x,eventType:m})}}return h.valid},ye=()=>{for(const r of u.unMount){const o=g(a,r);o&&(o._f.refs?o._f.refs.every(l=>!Xe(l)):!Xe(o._f.ref))&&Ge(r)}u.unMount=new Set},Z=(r,o)=>(r&&o&&F(d,r,o),!he(n.mount?d:c,c)),ve=(r,o,l)=>or(r,u,{...n.mount?d:R(o)?c:Y(r)?{[r]:o}:o},l,o),p=r=>ts(g(n.mount?d:c,r,s.shouldUnregister?g(c,r,[]):[])),k=(r,o,l={},m=!1,h=!1)=>{const x=g(a,r);let y=o;if(x){const v=x._f;v&&(!v.disabled&&F(d,r,ls(o,v)),y=Be(v.ref)&&G(o)?"":o,is(v.ref)?[...v.ref.options].forEach(S=>S.selected=y.includes(S.value)):v.refs?Ie(v.ref)?v.refs.forEach(S=>{(!S.defaultChecked||!S.disabled)&&(Array.isArray(y)?S.checked=!!y.find(U=>U===S.value):S.checked=y===S.value||!!y)}):v.refs.forEach(S=>S.checked=S.value===y):ct(v.ref)?v.ref.value="":(v.ref.value=y,!v.ref.type&&!h&&b.state.next({name:r,values:m?d:B(d)})))}(l.shouldDirty||l.shouldTouch)&&A(r,y,l.shouldTouch,l.shouldDirty,!h),l.shouldValidate&&Ke(r,{delayError:l.delayError})},ce=(r,o,l,m=!1,h=!1)=>{for(const x in o){if(!o.hasOwnProperty(x))return;const y=o[x],v=r+"."+x,S=g(a,v);(u.array.has(r)||z(y)||S&&!S._f)&&!je(y)?ce(v,y,l,m,h):k(v,y,l,m,h)}},te=(r,o,l,m,h=!1)=>{const x=g(a,r),y=u.array.has(r),v=m?o:B(o),S=g(d,r),U=he(S,v);if(U||F(d,r,v),y)b.array.next({name:r,values:m?d:B(d)}),(N.isDirty||N.dirtyFields||f.isDirty||f.dirtyFields)&&l.shouldDirty&&(oe(),h||b.state.next({name:r,dirtyFields:t.dirtyFields,isDirty:Z(r,v)}));else{const Q=Array.isArray(v)&&!v.length||K(v);!x||x._f||G(v)||Q?k(r,v,l,m,h):ce(r,v,l,m,h)}if(!U&&!h){const Q=Qe(r,u),xe=m?d:B(d);b.state.next({...Q&&t,name:n.mount||Q?r:void 0,values:xe})}},ae=(r,o,l={})=>te(r,o,l,!1),Se=(r,o={})=>{const l=ne(r)?r(d):r;if(!he(d,l)){d={...d,...l};const m=ss(l);for(const h of u.mount)h in m&&te(h,m[h],o,!0,!0);b.state.next({...t,name:void 0,type:void 0,...V?{values:d}:{}}),o.shouldValidate&&M()}},Pe=async r=>{n.mount=!0;const o=r.target;let l=o.name,m=!0;const h=g(a,l),x=y=>{m=Number.isNaN(y)||je(y)&&isNaN(y.getTime())||he(y,g(d,l,y))};if(h){let y,v;const S=o.type?Ut(h._f):er(r),U=r.type===Ae.BLUR||r.type===Ae.FOCUS_OUT,Q=!pr(h._f)&&!e.validate&&!s.resolver&&!g(t.errors,l)&&!h._f.deps,xe=Q||gr(U,g(t.touchedFields,l),t.isSubmitted,I,H),ge=Qe(l,u,U);if(F(d,l,S),U){if(!o||!o.readOnly){h._f.onBlur&&h._f.onBlur(r);const Ee=j[l];Ee&&Ee(0)}}else h._f.onChange&&h._f.onChange(r);const Ve=A(l,S,U),ws=!K(Ve)||ge;if(!U&&b.state.next({name:l,type:r.type,...V?{values:B(d)}:{}}),xe)return(!Q||!t.isValid)&&(N.isValid||f.isValid)&&(s.mode==="onBlur"?U&&M():U||M()),ws&&b.state.next({name:l,...ge?{}:Ve});if(!s.resolver&&e.validate&&await w({name:l,eventType:r.type}),!U&&ge&&b.state.next({...t}),s.resolver){const{errors:Ee}=await D([l]);if(E([l]),x(S),!m){!K(Ve)&&b.state.next(Ve);return}const Ns=Ht(t.errors,a,l),bt=Ht(Ee,a,Ns.name||l);y=bt.error,l=bt.name,v=K(Ee)}else E([l],!0),y=(await Mt(h,u.disabled,d,T,s.shouldUseNativeValidation))[l],E([l]),x(S),m&&(y?v=!1:(N.isValid||f.isValid)&&(v=await L({fields:a,onlyCheckValid:!0,name:l,eventType:r.type})));m&&(h._f.deps&&(!Array.isArray(h._f.deps)||h._f.deps.length>0)&&Ke(h._f.deps),_(l,v,y,Ve))}},Te=(r,o)=>{if(g(t.errors,o)&&r.focus)return r.focus(),1},Ke=async(r,o={})=>{let l,m;const h=ze(r);if(s.resolver){const x=await $(R(r)?r:h);l=K(x),m=r?!h.some(y=>g(x,y)):l}else r?(m=(await Promise.all(h.map(async x=>{const y=g(a,x);return await L({fields:y&&y._f?{[x]:y}:y,eventType:Ae.TRIGGER})}))).every(Boolean),!(!m&&!t.isValid)&&M()):m=l=await L({fields:a,name:r,eventType:Ae.TRIGGER});if(o.delayError&&s.delayError&&Y(r)){const x=g(t.errors,r);x?(q(t.errors,r),j[r]=J(r,()=>pe(r,x)),j[r](s.delayError)):(clearTimeout(P[r]),delete j[r])}return b.state.next({...!Y(r)||(N.isValid||f.isValid)&&l!==t.isValid?{}:{name:r},...s.resolver||!r?{isValid:l}:{},errors:t.errors}),o.shouldFocus&&!m&&Ce(a,Te,r?h:u.mount),m},ys=(r,o)=>{let l={...n.mount?d:c};return o&&(l=rs(o.dirtyFields?t.dirtyFields:t.touchedFields,l)),R(r)?l:Y(r)?g(l,r):r.map(m=>g(l,m))},ft=(r,o)=>({invalid:!!g((o||t).errors,r),isDirty:!!g((o||t).dirtyFields,r),error:g((o||t).errors,r),isValidating:!!g(t.validatingFields,r),isTouched:!!g((o||t).touchedFields,r)}),mt=r=>{const o=r?ze(r):void 0;o?.forEach(l=>q(t.errors,l)),o?o.forEach(l=>{b.state.next({name:l,errors:t.errors})}):b.state.next({errors:{}})},Re=(r,o,l)=>{const m=(g(a,r,{_f:{}})._f||{}).ref,h=g(t.errors,r)||{},{ref:x,message:y,type:v,...S}=h;F(t.errors,r,{...S,...o,ref:m}),b.state.next({name:r,errors:t.errors,isValid:!1}),l&&l.shouldFocus&&m&&m.focus&&m.focus()},xs=(r,o)=>{if(ne(r)){V++;const{unsubscribe:l}=b.state.subscribe({next:h=>"values"in h&&r(h.values||ve(void 0,o),h)});let m=!1;return{unsubscribe:()=>{m||(m=!0,V--,l())}}}return ve(r,o,!0)},ht=r=>{var o;const l=!!(!((o=r.formState)===null||o===void 0)&&o.values);l&&V++;const{unsubscribe:m}=b.state.subscribe({next:x=>{if(xr(r.name,x.name,r.exact)&&yr(x,r.formState||N,Ss,r.reRenderRoot)){const y={...d};r.callback({values:y,...t,...x,defaultValues:c})}}});if(!l)return m;let h=!1;return()=>{h||(h=!0,V--,m())}},gs=r=>(n.mount=!0,f={...f,...r.formState},ht({...r,formState:{...C,...r.formState}})),Ge=(r,o={})=>{for(const l of r?ze(r):u.mount)u.mount.delete(l),u.array.delete(l),o.keepValue||(q(a,l),q(d,l)),!o.keepError&&q(t.errors,l),!o.keepDirty&&q(t.dirtyFields,l),!o.keepTouched&&q(t.touchedFields,l),!o.keepIsValidating&&q(t.validatingFields,l),!s.shouldUnregister&&!o.keepDefaultValue&&q(c,l);b.state.next({values:B(d)}),b.state.next({...t,...o.keepDirty?{isDirty:Z()}:{}}),!o.keepIsValid&&M()},pt=({disabled:r,name:o})=>{if(me(r)&&n.mount||r||u.disabled.has(o)){const h=u.disabled.has(o)!==!!r;r?u.disabled.add(o):u.disabled.delete(o),h&&n.mount&&!n.action&&M()}},Ye=(r,o={})=>{let l=g(a,r);const m=me(o.disabled)||me(s.disabled),h=!u.registerName.has(r)&&l&&l._f&&!l._f.mount;return F(a,r,{...l||{},_f:{...l&&l._f?l._f:{ref:{name:r}},name:r,mount:!0,...o}}),u.mount.add(r),l&&!h?pt({disabled:me(o.disabled)?o.disabled:s.disabled,name:r}):ee(r,!0,o.value),{...m?{disabled:o.disabled||s.disabled}:{},...s.progressive?{required:!!o.required,min:De(o.min),max:De(o.max),minLength:De(o.minLength),maxLength:De(o.maxLength),pattern:De(o.pattern)}:{},name:r,onChange:Pe,onBlur:Pe,ref:x=>{if(x){u.registerName.add(r),Ye(r,o),u.registerName.delete(r),l=g(a,r);const y=R(x.value)&&x.querySelectorAll&&x.querySelectorAll("input,select,textarea")[0]||x,v=ur(y),S=l._f.refs||[];if(v?S.find(U=>U===y):y===l._f.ref)return;F(a,r,{_f:{...l._f,...v?{refs:[...S.filter(Xe),y,...Array.isArray(g(c,r))?[{}]:[]],ref:{type:y.type,name:r}}:{ref:y}}}),ee(r,!1,void 0,y)}else l=g(a,r,{}),l._f&&(l._f.mount=!1),(s.shouldUnregister||o.shouldUnregister)&&!(tr(u.array,r)&&n.action)&&u.unMount.add(r)}}},Ze=()=>s.shouldFocusError&&!s.shouldUseNativeValidation&&Ce(a,Te,u.mount),vs=r=>{me(r)&&(b.state.next({disabled:r}),Ce(a,(o,l)=>{const m=g(a,l);m&&(o.disabled=m._f.disabled||r,Array.isArray(m._f.refs)&&m._f.refs.forEach(h=>{h.disabled=m._f.disabled||r}))},0,!1))},yt=(r,o)=>async l=>{let m;l&&(l.preventDefault&&l.preventDefault(),l.persist&&l.persist());let h=B(d);if(b.state.next({isSubmitting:!0}),s.resolver){const{errors:x,values:y}=await D();E(),t.errors=x,h=B(y)}else await L({fields:a,eventType:Ae.SUBMIT});if(u.disabled.size)for(const x of u.disabled)q(h,x);if(q(t.errors,Xt),K(t.errors)){b.state.next({errors:{}});try{await r(h,l)}catch(x){m=x}}else o&&await o({...t.errors},l),Ze(),setTimeout(Ze);if(b.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:K(t.errors)&&!m,submitCount:t.submitCount+1,errors:t.errors}),m)throw m},bs=(r,o={})=>{g(a,r)&&(R(o.defaultValue)?ae(r,B(g(c,r))):(ae(r,o.defaultValue),F(c,r,B(o.defaultValue))),o.keepTouched||q(t.touchedFields,r),o.keepDirty||(q(t.dirtyFields,r),t.isDirty=o.defaultValue?Z(r,B(g(c,r))):Z()),o.keepError||(q(t.errors,r),N.isValid&&M()),b.state.next({...t}))},xt=(r,o={})=>{const l=r?B(r):c,m=B(l),h=K(r),x=m,y=a;if(o.keepDefaultValues||(c=l),!o.keepValues){if(o.keepDirtyValues){const v=new Set([...u.mount,...Object.keys(we(c,d,void 0,y))]);for(const S of Array.from(v)){const U=g(t.dirtyFields,S),Q=g(d,S),xe=g(x,S);U&&!R(Q)?F(x,S,Q):!U&&!R(xe)&&ae(S,xe)}}else{if($e&&R(r))for(const v of u.mount){const S=g(a,v);if(S&&S._f){const U=Array.isArray(S._f.refs)?S._f.refs[0]:S._f.ref;if(Be(U)){const Q=U.closest("form");if(Q){Q.reset();break}}}}if(o.keepFieldsRef)for(const v of u.mount)ae(v,g(x,v));else a={}}if(s.shouldUnregister){if(d=o.keepDefaultValues?B(c):{},o.keepFieldsRef)for(const v of u.mount)F(d,v,g(x,v))}else d=B(x);b.array.next({values:{...x}}),b.state.next({name:void 0,type:void 0,values:{...x}})}u={mount:o.keepDirtyValues?u.mount:new Set,unMount:new Set,array:new Set,registerName:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},n.mount=!N.isValid||!!o.keepIsValid||!!o.keepDirtyValues||!s.shouldUnregister&&!K(x),n.watch=!!s.shouldUnregister,n.keepIsValid=!!o.keepIsValid,n.action=!1,o.keepErrors||(t.errors={}),b.state.next({submitCount:o.keepSubmitCount?t.submitCount:0,isDirty:h?!1:o.keepDirty?t.isDirty:o.keepValues?Z():!!(o.keepDefaultValues&&!he(r,c)),isSubmitted:o.keepIsSubmitted?t.isSubmitted:!1,dirtyFields:h?{}:o.keepDirtyValues?o.keepDefaultValues&&d?we(c,d,void 0,y):t.dirtyFields:o.keepDefaultValues&&r?we(c,r,void 0,y):o.keepDirty?t.dirtyFields:{},touchedFields:o.keepTouched?t.touchedFields:{},errors:o.keepErrors?t.errors:{},isSubmitSuccessful:o.keepIsSubmitSuccessful?t.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:c})},gt=(r,o)=>xt(ne(r)?r(d):r,{...s.resetOptions,...o}),js=(r,o={})=>{const l=g(a,r),m=l&&l._f;if(m){const h=m.refs?m.refs[0]:m.ref;h.focus&&setTimeout(()=>{h.focus(),o.shouldSelect&&ne(h.select)&&h.select()})}},Ss=r=>{const{name:o,type:l,values:m,...h}=r;t={...t,...h}},vt={control:{register:Ye,unregister:Ge,getFieldState:ft,handleSubmit:yt,setError:Re,_subscribe:ht,_runSchema:D,_updateIsValidating:E,_focusError:Ze,_getWatch:ve,_getDirty:Z,_setValid:M,_setFieldArray:re,_setDisabledField:pt,_setErrors:le,_getFieldArray:p,_reset:xt,_resetDefaultValues:()=>ne(s.defaultValues)&&s.defaultValues().then(r=>{gt(r,s.resetOptions),b.state.next({isLoading:!1})}),_removeUnmounted:ye,_disableForm:vs,_subjects:b,_proxyFormState:N,get _fields(){return a},get _formValues(){return d},get _state(){return n},set _state(r){n=r},get _defaultValues(){return c},get _names(){return u},set _names(r){u=r},get _formState(){return t},get _options(){return s},set _options(r){s={...s,...r},H=Le(s.mode),I=Le(s.reValidateMode)}},subscribe:gs,trigger:Ke,register:Ye,handleSubmit:yt,watch:xs,setValue:ae,setValues:Se,getValues:ys,reset:gt,resetField:bs,resetDefaultValues:(r,o={})=>{if(c=B(r),!o.keepDirty){const l=we(c,d,void 0,a);t.dirtyFields=l,t.isDirty=!K(l)}o.keepIsValid||M(),b.state.next({...t,defaultValues:c})},clearErrors:mt,unregister:Ge,setError:Re,setFocus:js,getFieldState:ft};return{...vt,formControl:vt}}function Sr(e={}){const s=X.useRef(void 0),t=X.useRef(void 0),a=X.useRef(e.formControl),[c,d]=X.useState(()=>({...B(cs),isLoading:ne(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1,defaultValues:ne(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:c},e.defaultValues&&!ne(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:u,...j}=jr(e);s.current={...j,formState:c}}const n=s.current.control;return n._options=e,nr(()=>{const u=n._subscribe({formState:n._proxyFormState,callback:()=>d({...n._formState,defaultValues:n._defaultValues}),reRenderRoot:!0});return d(j=>({...j,isReady:!0})),n._formState.isReady=!0,u},[n]),X.useEffect(()=>n._disableForm(e.disabled),[n,e.disabled]),X.useEffect(()=>{e.mode&&(n._options.mode=e.mode),e.reValidateMode&&(n._options.reValidateMode=e.reValidateMode)},[n,e.mode,e.reValidateMode]),X.useEffect(()=>{e.errors&&(n._setErrors(e.errors),n._focusError())},[n,e.errors]),X.useEffect(()=>{e.shouldUnregister&&n._subjects.state.next({values:n._getWatch()})},[n,e.shouldUnregister]),X.useEffect(()=>{if(n._proxyFormState.isDirty){const u=n._getDirty();u!==c.isDirty&&n._subjects.state.next({isDirty:u})}},[n,c.isDirty]),X.useEffect(()=>{var u;e.values&&!he(e.values,t.current)?(n._reset(e.values,{keepFieldsRef:!0,...n._options.resetOptions}),!((u=n._options.resetOptions)===null||u===void 0)&&u.keepIsValid||n._setValid(),t.current=e.values,d(j=>({...j}))):n._resetDefaultValues()},[n,e.values]),X.useEffect(()=>{n._state.mount||(n._setValid(),n._state.mount=!0),n._state.watch&&(n._state.watch=!1,n._subjects.state.next({...n._formState})),n._removeUnmounted()}),s.current.formState=X.useMemo(()=>ar(c,n),[n,c]),s.current}const zt=(e,s,t)=>{if(e&&"reportValidity"in e){const a=g(t,s);e.setCustomValidity(a&&a.message||""),e.reportValidity()}},it=(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(c=>zt(c,t,e))}},Bt=(e,s)=>{s.shouldUseNativeValidation&&it(e,s);const t={};for(const a in e){const c=g(s.fields,a),d=Object.assign(e[a]||{},{ref:c&&c.ref});if(wr(s.names||Object.keys(e),a)){const n=Object.assign({},g(t,a));F(n,"root",d),F(t,a,n)}else F(t,a,d)}return t},wr=(e,s)=>{const t=qt(s).replace(/[.*+?^${}()|\\]/g,"\\$&");return e.some(a=>qt(a).match(`^${t}\\.\\d+`))};function qt(e){return e.replace(/[\[\]]/g,"")}function ds(e,s,t){function a(u,j){var P;Object.defineProperty(u,"_zod",{value:u._zod??{},enumerable:!1}),(P=u._zod).traits??(P.traits=new Set),u._zod.traits.add(e),s(u,j);for(const V in n.prototype)V in u||Object.defineProperty(u,V,{value:n.prototype[V].bind(u)});u._zod.constr=n,u._zod.def=j}const c=t?.Parent??Object;class d extends c{}Object.defineProperty(d,"name",{value:e});function n(u){var j;const P=t?.Parent?new d:this;a(P,u),(j=P._zod).deferred??(j.deferred=[]);for(const V of P._zod.deferred)V();return P}return Object.defineProperty(n,"init",{value:a}),Object.defineProperty(n,Symbol.hasInstance,{value:u=>t?.Parent&&u instanceof t.Parent?!0:u?._zod?.traits?.has(e)}),Object.defineProperty(n,"name",{value:e}),n}class Nr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const Tr={};function us(e){return Tr}function Ar(e,s){return typeof s=="bigint"?s.toString():s}const fs=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function He(e){return typeof e=="string"?e:e?.message}function ms(e,s,t){const a={...e,path:e.path??[]};if(!e.message){const c=He(e.inst?._zod.def?.error?.(e))??He(s?.error?.(e))??He(t.customError?.(e))??He(t.localeError?.(e))??"Invalid input";a.message=c}return delete a.inst,delete a.continue,s?.reportInput||delete a.input,a}const hs=(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,Ar,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},_r=ds("$ZodError",hs),ps=ds("$ZodError",hs,{Parent:Error}),Pr=e=>(s,t,a,c)=>{const d=a?Object.assign(a,{async:!1}):{async:!1},n=s._zod.run({value:t,issues:[]},d);if(n instanceof Promise)throw new Nr;if(n.issues.length){const u=new(c?.Err??e)(n.issues.map(j=>ms(j,d,us())));throw fs(u,c?.callee),u}return n.value},Vr=Pr(ps),Er=e=>async(s,t,a,c)=>{const d=a?Object.assign(a,{async:!0}):{async:!0};let n=s._zod.run({value:t,issues:[]},d);if(n instanceof Promise&&(n=await n),n.issues.length){const u=new(c?.Err??e)(n.issues.map(j=>ms(j,d,us())));throw fs(u,c?.callee),u}return n.value},kr=Er(ps);function at(){return at=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},at.apply(null,arguments)}function $t(e,s){try{var t=e()}catch(a){return s(a)}return t&&t.then?t.then(void 0,s):t}function Dr(e,s){for(var t={};e.length;){var a=e[0],c=a.code,d=a.message,n=a.path.join(".");if(!t[n])if("unionErrors"in a){var u=a.unionErrors[0].errors[0];t[n]={message:u.message,type:u.code}}else t[n]={message:d,type:c};if("unionErrors"in a&&a.unionErrors.forEach(function(V){return V.errors.forEach(function(H){return e.push(H)})}),s){var j=t[n].types,P=j&&j[a.code];t[n]=ut(n,s,t,c,P?[].concat(P,a.message):a.message)}e.shift()}return t}function Fr(e,s){for(var t={},a=function(){var c=e[0],d=c.code,n=c.message,u=c.path.join(".");if(!t[u])if(c.code==="invalid_union"&&c.errors.length>0){var j=c.errors[0][0];t[u]={message:j.message,type:j.code}}else t[u]={message:n,type:d};if(c.code==="invalid_union"&&c.errors.forEach(function(H){return H.forEach(function(I){return e.push(at({},I,{path:[].concat(c.path,I.path)}))})}),s){var P=t[u].types,V=P&&P[c.code];t[u]=ut(u,s,t,d,V?[].concat(V,c.message):c.message)}e.shift()};e.length;)a();return t}function Cr(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,c,d){try{return Promise.resolve($t(function(){return Promise.resolve(e[t.mode==="sync"?"parse":"parseAsync"](a,s)).then(function(n){return d.shouldUseNativeValidation&&it({},d),{errors:{},values:t.raw?Object.assign({},a):n}})},function(n){if((function(u){return Array.isArray(u?.issues)})(n))return{values:{},errors:Bt(Dr(n.errors,!d.shouldUseNativeValidation&&d.criteriaMode==="all"),d)};throw n}))}catch(n){return Promise.reject(n)}};if((function(a){return"_zod"in a&&typeof a._zod=="object"})(e))return function(a,c,d){try{return Promise.resolve($t(function(){return Promise.resolve((t.mode==="sync"?Vr:kr)(e,a,s)).then(function(n){return d.shouldUseNativeValidation&&it({},d),{errors:{},values:t.raw?Object.assign({},a):n}})},function(n){if((function(u){return u instanceof _r})(n))return{values:{},errors:Bt(Fr(n.issues,!d.shouldUseNativeValidation&&d.criteriaMode==="all"),d)};throw n}))}catch(n){return Promise.reject(n)}};throw new Error("Invalid input: not a Zod schema")}const Or=e=>e.authType==="oauthMicrosoft",Ir="••••••••••",Mr=e=>{const s=e.smtpUsername?.trim();return s?s!==e.username:!1},Rr=Ps({email:be().email().min(1,"Email is required"),displayName:be().optional(),username:be().optional(),password:be().optional(),imapHost:be().min(1,"IMAP host is required"),imapPort:wt.number().int().min(1).max(65535),imapTls:ke(),imapStartTls:ke(),smtpHost:be().optional(),smtpPort:wt.number().int().min(1).max(65535).optional(),smtpTls:ke().optional(),smtpStartTls:ke().optional(),smtpUsername:be().optional(),smtpPassword:be().optional(),useDifferentSmtpCreds:ke().optional()}),Ur=({isOpen:e,onClose:s,account:t,focusSmtp:a})=>{const c=Yt(),d=!!t,[n,u]=O.useState(!1),[j,P]=O.useState(""),[V,H]=O.useState(!1),I=At(j),C=!!I&&!V,N=O.useRef(null),f=Sr({resolver:Cr(Rr),defaultValues:{email:"",displayName:"",username:"",password:"",imapHost:"",imapPort:993,imapTls:!0,imapStartTls:!1,smtpHost:"",smtpPort:587,smtpTls:!1,smtpStartTls:!0,useDifferentSmtpCreds:!1}});O.useEffect(()=>{if(t){const p=Mr(t);f.reset({email:t.email,displayName:t.displayName||"",username:t.username||"",password:Ir,imapHost:t.imapHost,imapPort:t.imapPort,imapTls:t.imapTls,imapStartTls:t.imapStartTls,smtpHost:t.smtpHost||"",smtpPort:t.smtpPort||587,smtpTls:t.smtpTls||!1,smtpStartTls:t.smtpStartTls||!0,smtpUsername:p&&t.smtpUsername||"",smtpPassword:"",useDifferentSmtpCreds:p}),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 b=Ne({...Ts()}),ie=Ne({...As(),onSuccess:()=>{c.invalidateQueries({queryKey:Fe()}),s()}}),T=Ne({..._s(),onSuccess:()=>{c.invalidateQueries({queryKey:Fe()}),s()}}),J=()=>{const p=f.getValues(),k=d&&!n;b.mutate({body:{accountId:k?t?.accountId:void 0,username:p.username||p.email,password:k?void 0:p.password||void 0,imapHost:p.imapHost,imapPort:Number(p.imapPort),imapTls:p.imapTls,imapStartTls:p.imapStartTls}})},M=()=>{const p=f.getValues(),k=d&&!n;b.mutate({body:{accountId:k?t?.accountId:void 0,username:p.username||p.email,password:k?void 0:p.password||void 0,imapHost:p.imapHost,imapPort:Number(p.imapPort),imapTls:p.imapTls,imapStartTls:p.imapStartTls,smtpHost:p.smtpHost||void 0,smtpPort:p.smtpPort?Number(p.smtpPort):void 0,smtpTls:p.smtpTls,smtpStartTls:p.smtpStartTls,smtpUsername:p.useDifferentSmtpCreds?p.smtpUsername:void 0,smtpPassword:p.useDifferentSmtpCreds?p.smtpPassword:void 0}})},E=f.handleSubmit(p=>{if(!d&&!p.password){f.setError("password",{message:"Password is required"});return}const k=Ks({imapHost:p.imapHost,smtpHost:p.smtpHost,smtpPort:p.smtpPort,smtpTls:p.smtpTls,smtpStartTls:p.smtpStartTls});k&&(f.setValue("smtpHost",k.smtpHost),f.setValue("smtpPort",k.smtpPort),f.setValue("smtpTls",k.smtpTls),f.setValue("smtpStartTls",k.smtpStartTls));const ce=k?.smtpHost??p.smtpHost,te=k?.smtpPort??p.smtpPort,ae=k?.smtpTls??p.smtpTls,Se=k?.smtpStartTls??p.smtpStartTls,Pe={email:p.email,displayName:p.displayName?.trim()||void 0,username:p.username||void 0,imapHost:p.imapHost,imapPort:Number(p.imapPort),imapTls:p.imapTls,imapStartTls:p.imapStartTls,smtpHost:ce||void 0,smtpPort:te?Number(te):void 0,smtpTls:ae,smtpStartTls:Se,smtpUsername:p.useDifferentSmtpCreds&&p.smtpUsername||void 0,smtpPassword:p.useDifferentSmtpCreds&&p.smtpPassword||void 0};if(d&&t){const Te={...Pe,password:n?p.password:void 0};T.mutate({path:{accountId:t.accountId},body:Te})}else{const Te={...Pe,password:p.password};ie.mutate({body:Te})}}),oe=ie.isPending||T.isPending,{signature:re,setSignature:pe,isSaving:le}=Ls(t?.accountId),[W,ee]=O.useState(re.plainText);O.useEffect(()=>{ee(re.plainText)},[re.plainText]),O.useEffect(()=>{if(!e||!a)return;const p=N.current;if(!p)return;const k=window.setTimeout(()=>{p.scrollIntoView({behavior:"smooth",block:"start"})},250);return()=>window.clearTimeout(k)},[e,a]);const A=O.useCallback(()=>{W!==re.plainText&&pe(W,W)},[W,re.plainText,pe]),_=p=>{const{tls:k,startTls:ce}=Ue(p);f.setValue("imapTls",k),f.setValue("imapStartTls",ce);const te=f.getValues("imapPort");(te===993||te===143)&&f.setValue("imapPort",p==="tls"?993:143)},D=p=>{const{tls:k,startTls:ce}=Ue(p);f.setValue("smtpTls",k),f.setValue("smtpStartTls",ce);const te=f.getValues("smtpPort");if(te===465||te===587||te===25){const Se=p==="tls"?465:p==="starttls"?587:25;f.setValue("smtpPort",Se)}},$=()=>{const p=f.getValues("imapHost");f.setValue("smtpHost",Gs(p)),f.setValue("smtpTls",!1),f.setValue("smtpStartTls",!0),f.setValue("smtpPort",587)},w=p=>{P(p),H(!1);const k=At(p);if(!k)return;const ce=Ue(k.imap.security);f.setValue("imapHost",k.imap.host),f.setValue("imapPort",k.imap.port),f.setValue("imapTls",ce.tls),f.setValue("imapStartTls",ce.startTls);const te=Ue(k.smtp.security);f.setValue("smtpHost",k.smtp.host),f.setValue("smtpPort",k.smtp.port),f.setValue("smtpTls",te.tls),f.setValue("smtpStartTls",te.startTls);const ae=f.getValues("email").trim(),Se=f.getValues("username")?.trim();ae&&!Se&&f.setValue("username",ae)},L=I?.passwordHelp.text,ye=Pt(b.data?.imapError,L),Z=Pt(b.data?.smtpError,L);return(t?Or(t):!1)&&d?i.jsx(Et,{isOpen:e,onClose:s,title:"Edit Account",footer:i.jsx(se,{type:"button",variant:"secondary",onClick:s,children:"Close"}),children:i.jsxs("div",{className:"space-y-6",children:[i.jsxs("section",{children:[i.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Microsoft 365 Account"}),i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"rounded-md border border-line bg-surface-sunken px-3 py-2.5 text-sm text-fg-muted",children:[i.jsx("span",{className:"block text-2xs font-medium uppercase tracking-wider text-fg-subtle mb-1",children:"Email"}),i.jsx("span",{className:"text-fg",children:t?.email})]}),i.jsxs("div",{className:"rounded-md border border-line bg-surface-sunken px-3 py-2.5 text-sm text-fg-muted",children:[i.jsx("span",{className:"block text-2xs font-medium uppercase tracking-wider text-fg-subtle mb-1",children:"Authentication"}),i.jsx("span",{className:"text-fg",children:"Microsoft OAuth (XOAUTH2)"})]}),i.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."})]})]}),d&&i.jsxs("section",{children:[i.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Signature"}),i.jsx("div",{className:"space-y-3",children:i.jsxs("div",{children:[i.jsx("label",{htmlFor:"email-sig-view",className:"text-sm font-medium mb-1.5 block",children:"Email Signature"}),i.jsx("textarea",{id:"email-sig-view",value:W,onChange:p=>ee(p.target.value),onBlur:A,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..."}),i.jsx("p",{className:"text-xs text-fg-muted mt-1",children:le?"Saving signature...":"This signature will be appended to new emails."})]})})]})]})}):i.jsx(Et,{isOpen:e,onClose:s,title:d?"Edit Account":"Add Account",footer:i.jsxs(i.Fragment,{children:[i.jsx(se,{type:"button",variant:"secondary",onClick:s,children:"Cancel"}),i.jsx(se,{type:"submit",form:"account-form",variant:"primary",disabled:oe,children:oe?"Saving...":"Save Account"})]}),children:i.jsxs("form",{id:"account-form",onSubmit:E,className:"space-y-6",children:[i.jsxs("section",{children:[i.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Account Information"}),i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{children:[i.jsx("label",{htmlFor:"account-provider",className:"text-sm font-medium mb-1.5 block",children:"Provider"}),i.jsxs(Ws,{id:"account-provider",value:j,onChange:p=>w(p.target.value),children:[i.jsx("option",{value:"",children:"Custom / other"}),qs.map(p=>i.jsx("option",{value:p.id,children:p.label},p.id))]}),i.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."})]}),i.jsxs("div",{children:[i.jsx("label",{htmlFor:"account-email",className:"text-sm font-medium mb-1.5 block",children:"Email Address"}),i.jsx(de,{id:"account-email",...f.register("email"),placeholder:"alice@example.com"}),f.formState.errors.email&&i.jsx("p",{className:"text-sm text-danger mt-1",children:f.formState.errors.email.message})]}),i.jsxs("div",{children:[i.jsx("label",{htmlFor:"account-displayName",className:"text-sm font-medium mb-1.5 block",children:"Display name (optional)"}),i.jsx(de,{id:"account-displayName",...f.register("displayName"),placeholder:"Alice"}),i.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."})]}),i.jsxs("div",{children:[i.jsx("label",{htmlFor:"account-username",className:"text-sm font-medium mb-1.5 block",children:"Username"}),i.jsx(de,{id:"account-username",...f.register("username"),placeholder:"Same as email if empty"})]}),i.jsxs("div",{children:[i.jsx("label",{htmlFor:"account-password",className:"text-sm font-medium mb-1.5 block",children:"Password"}),i.jsx(de,{id:"account-password",...f.register("password",{onChange:()=>u(!0)}),type:"password",onFocus:()=>{d&&!n&&(f.setValue("password",""),u(!0))},placeholder:d?"Leave empty to keep current":""}),f.formState.errors.password&&i.jsx("p",{className:"text-sm text-danger mt-1",children:f.formState.errors.password.message}),I&&i.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[I.passwordHelp.text," ",i.jsx("a",{href:I.passwordHelp.url,target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline",children:"Get an app password"})]})]})]})]}),i.jsxs("section",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider",children:"Incoming Mail (IMAP)"}),I&&i.jsx("button",{type:"button",onClick:()=>H(p=>!p),className:"text-xs text-fg-muted hover:text-fg transition-colors",children:V?"Use preset settings":"Advanced"})]}),C&&i.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."]}),i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{children:[i.jsx("label",{htmlFor:"imap-host",className:"text-sm font-medium mb-1.5 block",children:"Server"}),i.jsx(de,{id:"imap-host",...f.register("imapHost"),readOnly:C,placeholder:"imap.example.com"}),f.formState.errors.imapHost&&i.jsx("p",{className:"text-sm text-danger mt-1",children:f.formState.errors.imapHost.message})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx("label",{htmlFor:"imap-port",className:"text-sm font-medium mb-1.5 block",children:"Port"}),i.jsx(de,{id:"imap-port",...f.register("imapPort"),readOnly:C,type:"number"})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-sm font-medium mb-1.5 block",children:"Security"}),i.jsxs("div",{className:"space-y-1.5 mt-2",children:[i.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[i.jsx("input",{type:"radio",disabled:C,checked:f.watch("imapTls"),onChange:()=>_("tls")}),"TLS (Port 993)"]}),i.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[i.jsx("input",{type:"radio",disabled:C,checked:!f.watch("imapTls")&&f.watch("imapStartTls"),onChange:()=>_("starttls")}),"STARTTLS (Port 143)"]}),i.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[i.jsx("input",{type:"radio",disabled:C,checked:!f.watch("imapTls")&&!f.watch("imapStartTls"),onChange:()=>_("none")}),"None (Unencrypted)"]})]})]})]}),i.jsx(se,{type:"button",variant:"secondary",onClick:J,disabled:b.isPending,className:"w-full",icon:b.isPending?i.jsx(et,{className:"size-4 animate-spin"}):void 0,children:b.isPending?"Testing...":"Test IMAP Connection"}),b.data&&i.jsxs("div",{className:St("p-2 rounded-md text-sm",b.data.imapSuccess?"bg-positive/10 text-positive":"bg-danger-soft text-danger"),children:[b.data.imapSuccess?i.jsx(_t,{className:"inline size-4 mr-1"}):i.jsx(Oe,{className:"inline size-4 mr-1"}),b.data.imapSuccess?"IMAP Connected":ye]})]})]}),i.jsxs("section",{ref:N,"data-testid":"smtp-section",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider",children:"Outgoing Mail (SMTP)"}),!C&&i.jsx("button",{type:"button",onClick:$,disabled:!f.watch("imapHost"),className:"text-xs text-fg-muted hover:text-fg transition-colors disabled:opacity-50",children:"Pre-fill from IMAP"})]}),i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{children:[i.jsx("label",{htmlFor:"smtp-host",className:"text-sm font-medium mb-1.5 block",children:"Server"}),i.jsx(de,{id:"smtp-host",...f.register("smtpHost"),readOnly:C,placeholder:"smtp.example.com"})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx("label",{htmlFor:"smtp-port",className:"text-sm font-medium mb-1.5 block",children:"Port"}),i.jsx(de,{id:"smtp-port",...f.register("smtpPort"),readOnly:C,type:"number"})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-sm font-medium mb-1.5 block",children:"Security"}),i.jsxs("div",{className:"space-y-1.5 mt-2",children:[i.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[i.jsx("input",{type:"radio",disabled:C,checked:f.watch("smtpTls")===!0,onChange:()=>D("tls")}),"TLS (Port 465)"]}),i.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[i.jsx("input",{type:"radio",disabled:C,checked:!f.watch("smtpTls")&&f.watch("smtpStartTls")===!0,onChange:()=>D("starttls")}),"STARTTLS (Port 587)"]}),i.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[i.jsx("input",{type:"radio",disabled:C,checked:!f.watch("smtpTls")&&!f.watch("smtpStartTls"),onChange:()=>D("none")}),"None (Unencrypted)"]})]})]})]}),i.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[i.jsx("input",{type:"checkbox",...f.register("useDifferentSmtpCreds")}),"Use different credentials for SMTP"]}),f.watch("useDifferentSmtpCreds")&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{children:[i.jsx("label",{htmlFor:"smtp-username",className:"text-sm font-medium mb-1.5 block",children:"SMTP Username"}),i.jsx(de,{id:"smtp-username",...f.register("smtpUsername")})]}),i.jsxs("div",{children:[i.jsx("label",{htmlFor:"smtp-password",className:"text-sm font-medium mb-1.5 block",children:"SMTP Password"}),i.jsx(de,{id:"smtp-password",...f.register("smtpPassword"),type:"password"})]})]}),i.jsx(se,{type:"button",variant:"secondary",onClick:M,disabled:b.isPending||!f.watch("smtpHost"),className:"w-full",icon:b.isPending?i.jsx(et,{className:"size-4 animate-spin"}):void 0,children:b.isPending?"Testing...":"Test SMTP Connection"}),b.data?.smtpSuccess!==void 0&&i.jsxs("div",{className:St("p-2 rounded-md text-sm",b.data.smtpSuccess?"bg-positive/10 text-positive":"bg-danger-soft text-danger"),children:[b.data.smtpSuccess?i.jsx(_t,{className:"inline size-4 mr-1"}):i.jsx(Oe,{className:"inline size-4 mr-1"}),b.data.smtpSuccess?"SMTP Connected":Z]})]})]}),d&&i.jsxs("section",{children:[i.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Signature"}),i.jsx("div",{className:"space-y-3",children:i.jsxs("div",{children:[i.jsx("label",{htmlFor:"email-sig-edit",className:"text-sm font-medium mb-1.5 block",children:"Email Signature"}),i.jsx("textarea",{id:"email-sig-edit",value:W,onChange:p=>ee(p.target.value),onBlur:A,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..."}),i.jsx("p",{className:"text-xs text-fg-muted mt-1",children:le?"Saving signature...":"This signature will be appended to new emails."})]})})]})]})})};function Wt({open:e,onClose:s,accountEmail:t,signOut:a}){const[c,d]=O.useState(""),[n,u]=O.useState(!1),[j,P]=O.useState(!1),V=Ne({...Es(),onSuccess:()=>{P(!0),setTimeout(()=>a(),2e3)}}),H=Ne(ks()),I=()=>{V.isPending||(d(""),u(!1),P(!1),V.reset(),H.reset(),s())},C=()=>{if(c.trim().toLowerCase()!==t.toLowerCase()){u(!0);return}u(!1),V.mutate({body:{confirmEmail:c.trim()}})};return i.jsxs(Zt,{open:e,onClose:I,title:"Delete your Remit account",children:[i.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[i.jsx(nt,{className:"size-4 shrink-0 text-danger"}),i.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:"Delete your Remit account"}),i.jsx(se,{variant:"ghost",size:"sm",icon:i.jsx(Oe,{className:"size-3.5"}),onClick:I,"aria-label":"Cancel"})]}),j?i.jsxs("div",{className:"px-5 py-6 text-sm text-fg-muted",children:[i.jsx("p",{className:"font-medium text-fg",children:"Account deletion scheduled."}),i.jsx("p",{className:"mt-1",children:"Your data will be erased shortly. Signing you out…"})]}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"space-y-4 px-5 py-4 text-sm text-fg-muted",children:[i.jsx("p",{children:"This permanently erases everything Remit holds for you:"}),i.jsxs("ul",{className:"space-y-1.5 text-xs",children:[i.jsxs("li",{className:"flex gap-2",children:[i.jsx("span",{className:"text-danger",children:"•"}),"All connected accounts disconnected and access tokens revoked."]}),i.jsxs("li",{className:"flex gap-2",children:[i.jsx("span",{className:"text-danger",children:"•"}),"Synced mail cache and search index."]}),i.jsxs("li",{className:"flex gap-2",children:[i.jsx("span",{className:"text-danger",children:"•"}),"AI history and insights."]}),i.jsxs("li",{className:"flex gap-2",children:[i.jsx("span",{className:"text-danger",children:"•"}),"Preferences and rules."]})]}),i.jsxs("div",{className:"rounded-sm border border-line bg-surface-sunken px-3 py-2 text-xs",children:[i.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."]}),i.jsxs("div",{className:"text-xs",children:[i.jsxs("button",{type:"button",onClick:()=>H.mutate({}),"aria-busy":H.isPending,className:"inline-flex items-center gap-1.5 font-medium text-accent hover:underline",children:[i.jsx(Xs,{className:"size-3.5"}),H.isPending?"Requesting export…":"Export my data first"]}),H.isSuccess&&i.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."}),H.isError&&i.jsx("p",{className:"mt-1.5 text-danger",role:"alert",children:"Couldn't start the export. Please try again."})]}),i.jsxs("div",{children:[i.jsxs("label",{htmlFor:"confirm-remit-email",className:"mb-1 block text-xs font-medium text-fg",children:["Type"," ",i.jsx("span",{className:"font-mono text-fg-muted",children:t})," ","to confirm"]}),i.jsx(de,{id:"confirm-remit-email",type:"email",placeholder:t,value:c,onChange:N=>{d(N.target.value),n&&u(!1),V.isError&&V.reset()},autoComplete:"off"}),n&&i.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."}),V.isError&&i.jsx("p",{className:"mt-1.5 text-xs text-danger",role:"alert",children:V.error instanceof Error?V.error.message:"Something went wrong. Please try again."})]})]}),i.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[i.jsx(se,{variant:"secondary",size:"sm",onClick:I,children:"Cancel"}),i.jsx(se,{variant:"danger",size:"sm",onClick:C,"aria-busy":V.isPending,children:V.isPending?"Deleting…":"Delete everything"})]})]})]})}function Lr(e){const{Account:s}=Vs();return i.jsx(s,{fallback:i.jsx(Wt,{...e,accountEmail:"",signOut:()=>{}}),children:({email:t,signOut:a})=>i.jsx(Wt,{...e,accountEmail:t??"",signOut:a})})}function Hr(){const[e,s]=O.useState(!1);return i.jsxs("section",{className:"mt-8 border-t border-line pt-6",children:[i.jsx(Js,{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:i.jsx(se,{variant:"danger",size:"sm",onClick:()=>s(!0),children:"Delete your Remit account"})}),i.jsx(Lr,{open:e,onClose:()=>s(!1)})]})}function zr(e){const s=e.toLowerCase();return s==="access_denied"?"You cancelled the sign-in.":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.`}function Br(e){const s=e.split("@")[0]??"";return s?s.split(/[._-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" "):e}function qr(e){const s=e.displayName?.trim();return s||Br(e.email)}function $r(e){if(!e.lastSyncAt)return"never synced";const s=Zs(e.lastSyncAt);return s?`synced ${s}`:"never synced"}function Kt(e){return e.muted?.value?"muted":e.lastError?"error":e.connectionState==="authenticated"?"healthy":"error"}function Wr(e){return e.connectionState==="reauth_required"}const Kr=i.jsxs("div",{className:"space-y-3",children:[i.jsxs("p",{children:[i.jsx("strong",{className:"text-fg",children:"Sync health"})," shows the IMAP connection state and the last successful sync per account."]}),i.jsxs("p",{children:[i.jsx("strong",{className:"text-fg",children:"Error"})," means the last connection attempt failed — the raw server response is shown on the card. Reconnect re-runs the connection test from the add-account wizard."]}),i.jsxs("p",{children:[i.jsx("strong",{className:"text-fg",children:"Muted"})," accounts keep syncing but stay out of the daily brief and unified counts."]})]}),Gr=()=>i.jsx("div",{className:"space-y-3",role:"status","aria-busy":"true","aria-label":"Loading accounts",children:["skeleton-0","skeleton-1"].map(e=>i.jsx("div",{className:"rounded-sm border border-line bg-surface animate-pulse p-4",children:i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"size-10 rounded-full bg-surface-sunken"}),i.jsxs("div",{className:"flex-1 space-y-2",children:[i.jsx("div",{className:"h-4 bg-surface-sunken rounded w-1/3"}),i.jsx("div",{className:"h-3 bg-surface-sunken rounded w-2/3"})]})]})},e))});function ci(){const e=Nt.useSearch(),s=Ds({from:Nt.fullPath}),[t,a]=O.useState(!0),[c,d]=O.useState(!1),[n,u]=O.useState(!1),[j,P]=O.useState(null),[V,H]=O.useState(!1),[I,C]=O.useState(null),[N,f]=O.useState(null),[b,ie]=O.useState(null),[T,J]=O.useState(null),M=Yt(),{data:E,isPending:oe,isError:re,error:pe,refetch:le}=Fs(Cs());O.useEffect(()=>{e.editAccountId&&(P(e.editAccountId),H(!!e.focusSmtp),s({search:{editAccountId:void 0,focusSmtp:void 0,connected:e.connected,oauthError:e.oauthError},replace:!0}))},[e.editAccountId,e.focusSmtp,s,e.connected,e.oauthError]),O.useEffect(()=>{e.connected&&(f("Account connected successfully."),P(e.connected),M.invalidateQueries({queryKey:Fe()}),s({search:{connected:void 0,oauthError:void 0,editAccountId:void 0,focusSmtp:void 0},replace:!0}))},[e.connected,s,M]),O.useEffect(()=>{e.oauthError&&(ie(zr(e.oauthError)),s({search:{oauthError:void 0,connected:void 0,editAccountId:void 0,focusSmtp:void 0},replace:!0}))},[e.oauthError,s]);const W=Ne({...Os(),onSuccess:w=>{window.location.assign(w.authorizationUrl)},onError:w=>{ie(w instanceof Error?w.message:"Failed to start reconnect"),J(null)}}),ee=Ne({...Is(),onSuccess:()=>{M.invalidateQueries({queryKey:Fe()}),C(null)}}),A=E?.accounts.find(w=>w.accountId===I),_=E?.accounts.find(w=>w.accountId===j),D=()=>{d(!1),u(!1),P(null),H(!1)},$=w=>{const L=Us[w];L&&s({to:L})};return i.jsxs(zs,{items:Ms,activeId:"accounts",title:"Accounts",description:"Every account keeps syncing — muted ones just stay out of unified views.",help:Kr,helpOpen:t,onToggleHelp:()=>a(w=>!w),onSelect:$,onBackToMail:()=>{s({to:"/mail"})},children:[N&&i.jsx(Tt,{tone:"success",variant:"soft","data-testid":"oauth-success-banner",onDismiss:()=>f(null),children:N}),b&&i.jsx(Tt,{tone:"danger",variant:"soft","data-testid":"oauth-error-banner",onDismiss:()=>ie(null),children:b}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(Rs,{tone:"neutral",children:oe||re?"accounts":`${E.accounts.length} ${E.accounts.length===1?"account":"accounts"}`}),i.jsx(se,{variant:"primary",size:"sm",icon:i.jsx(Vt,{className:"size-3.5"}),onClick:()=>u(!0),children:"Add account"})]}),oe?i.jsx(Gr,{}):re?i.jsx(Ys,{title:"Couldn't load accounts",error:pe,onRetry:()=>{le()}}):E.accounts.length===0?i.jsxs("div",{className:"py-12 text-sm text-fg-muted","data-testid":"accounts-empty",children:[i.jsx("p",{className:"mb-3",children:"No accounts configured."}),i.jsx(se,{variant:"primary",size:"sm",icon:i.jsx(Vt,{className:"size-3.5"}),onClick:()=>u(!0),children:"Add your first account"})]}):i.jsx("div",{className:"space-y-3",children:E.accounts.map(w=>{const L=Wr(w),ye=w.authType==="oauthMicrosoft",Z=T===w.accountId&&W.isPending,ve=L&&ye?{label:"Reconnect",variant:"secondary",busy:Z,busyLabel:"Redirecting…",onClick:()=>{J(w.accountId),W.mutate({body:{email:w.email}})}}:Kt(w)==="error"?{label:"Reconnect",variant:"secondary",onClick:()=>P(w.accountId)}:{label:"Manage",variant:"ghost",onClick:()=>P(w.accountId)},p=i.jsx(Hs,{actions:[ve],destructive:{label:"Delete account",iconOnly:!0,icon:i.jsx(Qs,{className:"size-3.5"}),onClick:()=>C(w.accountId)}});return i.jsx(Bs,{label:qr(w),email:w.email,connector:ye?"Microsoft 365":"IMAP",syncLabel:$r(w),state:Kt(w),errorDetail:L?"Re-authentication required":w.lastError,trailing:p},w.accountId)})}),n&&i.jsx("div",{className:"fixed inset-0 z-40 overflow-auto bg-canvas",children:i.jsx($s,{skipWelcome:!0,onComplete:()=>{u(!1),M.invalidateQueries({queryKey:Fe()})},onCancel:()=>u(!1)})}),i.jsx(Ur,{isOpen:c||!!j,account:_,focusSmtp:V,onClose:D}),i.jsxs(Zt,{open:!!I,onClose:()=>C(null),title:"Delete account",children:[i.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[i.jsx(nt,{className:"size-4 shrink-0 text-danger"}),i.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:"Delete account"}),i.jsx(se,{variant:"ghost",size:"sm",icon:i.jsx(Oe,{className:"size-3.5"}),onClick:()=>C(null),"aria-label":"Cancel"})]}),i.jsxs("div",{className:"space-y-3 px-5 py-4 text-sm text-fg-muted",children:[i.jsx("p",{className:"text-center text-lg font-medium text-fg",children:"Are you sure?"}),A&&i.jsx("p",{className:"text-center",children:A.email}),i.jsxs("ul",{className:"list-inside list-disc space-y-1",children:[i.jsx("li",{children:"Remove the account from your settings"}),i.jsx("li",{children:"Stop syncing mail for this account"}),i.jsx("li",{children:"Delete all associated data (within 24 hours)"})]})]}),i.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[i.jsx(se,{variant:"secondary",size:"sm",onClick:()=>C(null),children:"Cancel"}),i.jsx(se,{variant:"danger",size:"sm","aria-busy":ee.isPending,icon:ee.isPending?i.jsx(et,{className:"size-3.5 animate-spin"}):void 0,onClick:()=>{ee.isPending||I&&ee.mutate({path:{accountId:I}})},children:ee.isPending?"Deleting…":"Delete account"})]})]}),i.jsx(Hr,{})]})}export{ci as component,zr as mapOauthError};
@@ -1 +0,0 @@
1
- import{j as e,d as b,B as j,a0 as N,r as x,aa as u,ah as y,bg as v,bh as S,a1 as I}from"./index-DFBCf_Ns.js";import{S as T}from"./settings-screen-D48k5Bt1.js";import{f as E,N as O,a as w,c as F,d as k}from"./filter-status-B3jGvEFY.js";import{T as A}from"./trash-2-l_BkiFgy.js";import{E as h}from"./ErrorState-ozcCp-cA.js";import{g as D}from"./folder-roles-XnseeyyD.js";import"./avatar-K4mVDmMa.js";import"./useMutation-driganVD.js";function M({filters:a,mailboxName:i,onDelete:d,deletingFilterId:r,now:c=Date.now()}){return a.length===0?e.jsx("p",{className:"py-6 text-sm text-fg-muted",children:"No filters yet. Select a few messages in the inbox and choose Organize to make one."}):e.jsx("ul",{className:"divide-y divide-line rounded-md border border-line",children:a.map(t=>{const o=E(t,c),n=o==="Expired",l=t.actionMailboxId!==O?i(t.actionMailboxId):void 0,s=w(t.expiresAt);return e.jsxs("li",{className:"flex items-start gap-3 px-3 py-2.5",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`truncate text-sm font-medium ${n?"text-fg-muted":"text-fg"}`,children:t.name}),e.jsx(b,{tone:n?"neutral":"positive",dot:!0,children:o})]}),e.jsxs("p",{className:"mt-0.5 text-xs text-fg-subtle",children:[l?`Moves matches to ${l}`:"No move action",t.scope==="Temporary"&&s?n?` · expired ${s}`:` · until ${s}`:t.scope==="Standing"?" · always":""]})]}),e.jsx(j,{variant:"ghost",size:"sm",icon:e.jsx(A,{className:"size-4 text-danger"}),onClick:()=>d(t.filterId),disabled:r===t.filterId,"aria-label":`Delete filter ${t.name}`})]},t.filterId)})})}const $=e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{children:["Filters are the standing rules Organize creates. A"," ",e.jsx("strong",{children:"Standing"})," filter keeps working on new mail; a"," ",e.jsx("strong",{children:"Temporary"})," one stops on its own at the date you picked."]}),e.jsx("p",{children:"An expired filter isn't deleted the instant it lapses — it stays here, marked Expired, so you can see what it did and when it stopped."})]});function C({account:a}){const i=a.accountId,{filters:d,isPending:r,isError:c,error:t,refetch:o}=F(i),{deleteFilter:n,deletingFilterId:l}=k(i),{data:s}=u({...I({path:{accountId:i}}),staleTime:1/0}),m=x.useCallback(g=>{const p=s?.items.find(f=>f.mailboxId===g);return p?D(p.fullPath):void 0},[s?.items]);return e.jsxs("section",{className:"space-y-2",children:[e.jsx("h2",{className:"text-sm font-semibold text-fg",children:a.email}),r?e.jsx("div",{className:"h-16 animate-pulse rounded-md border border-line bg-surface","aria-busy":"true","aria-label":`Loading filters for ${a.email}`}):c?e.jsx(h,{variant:"inline",title:`Couldn't load filters for ${a.email}`,error:t,onRetry:()=>{o()}}):e.jsx(M,{filters:d,mailboxName:m,onDelete:n,deletingFilterId:l})]})}function Q(){const a=N(),[i,d]=x.useState(!0),{data:r,isPending:c,isError:t,error:o,refetch:n}=u(y()),l=s=>{const m=S[s];m&&a({to:m})};return e.jsx(T,{items:v,activeId:"filters",title:"Filters",description:"Standing and temporary rules created by Organize, per account.",help:$,helpOpen:i,onToggleHelp:()=>d(s=>!s),onSelect:l,onBackToMail:()=>{a({to:"/mail"})},children:c?e.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":"Loading accounts"}):t?e.jsx(h,{title:"Couldn't load accounts",error:o,onRetry:()=>{n()}}):r.accounts.length===0?e.jsx("p",{className:"py-12 text-sm text-fg-muted",children:"No accounts configured."}):e.jsx("div",{className:"space-y-8",children:r.accounts.map(s=>e.jsx(C,{account:s},s.accountId))})})}export{Q as component};
@@ -1 +0,0 @@
1
- import{a as t,j as e,i as r,O as i}from"./index-DFBCf_Ns.js";import{T as n}from"./trash-2-l_BkiFgy.js";import{S as c}from"./star-cNw1G8pR.js";const h=t("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);const o=t("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const j=t("Folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const l=t("Mails",[["rect",{width:"16",height:"13",x:"6",y:"4",rx:"2",key:"1drq3f"}],["path",{d:"m22 7-7.1 3.78c-.57.3-1.23.3-1.8 0L6 7",key:"xn252p"}],["path",{d:"M2 8v11c0 1.1.9 2 2 2h14",key:"n13cji"}]]);const p=t("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]),d={inbox:"Inbox",drafts:"Drafts",sent:"Sent",archive:"Archive",junk:"Spam",trash:"Trash",flagged:"Starred",all:"All Mail"};function u(a){return d[a]}function f(a){const s=a.split("/");return s[s.length-1]||a}const x=new Set(["all","flagged"]);function m(a){return x.has(a)}const k=new Set(["[Gmail]","[Google Mail]"]);function S(a){if(a.role)return m(a.role)?void 0:u(a.role);if(a.providerPath&&!k.has(a.providerPath.split("/")[0]))return f(a.providerPath)}function A(a){return a==="inbox"?e.jsx(r,{className:"size-4"}):a==="drafts"?e.jsx(o,{className:"size-4"}):a==="sent"?e.jsx(p,{className:"size-4"}):a==="archive"?e.jsx(h,{className:"size-4"}):a==="junk"?e.jsx(i,{className:"size-4"}):a==="trash"?e.jsx(n,{className:"size-4"}):a==="flagged"?e.jsx(c,{className:"size-4"}):e.jsx(l,{className:"size-4"})}export{h as A,j as F,l as M,p as S,o as a,f as b,u as c,S as p,A as r};
@@ -1 +0,0 @@
1
- const o={Inbox:"inbox",Drafts:"drafts",Sent:"sent",Archive:"archive",Junk:"junk",Trash:"trash",All:"all",Flagged:"flagged"},d={inbox:"Inbox",drafts:"Drafts",sent:"Sent",archive:"Archive",junk:"Junk",trash:"Trash",all:"All",flagged:"Flagged"},r=["inbox","flagged","drafts","sent","archive","all","junk","trash"];function c(a){const n=new Map,s=[...a].sort((e,t)=>r.indexOf(o[e.role])-r.indexOf(o[t.role]));for(const e of s){if(!e.mailboxId||n.has(e.mailboxId))continue;const t=o[e.role];t&&n.set(e.mailboxId,t)}return n}const i=a=>{const n=a.split("/");return n[n.length-1]||a};function f(a,n,s){const e=a.displayNameOverride?.trim();if(e)return e;const t=i(a.fullPath);return!n||!s?t:s(`sidebar.${n}`,t)}const l=new Set(["sent","drafts","trash"]),b=a=>a===void 0||!l.has(a);export{o as C,d as N,r as R,c as b,i as g,f as l,b as s};
@@ -1 +0,0 @@
1
- import{j as e,r as v,m as I,B as S,a0 as A,aa as j,ah as E,bg as R,bh as k,A as L,a1 as P,b2 as T,bs as _,ar as w,bt as M,g as F}from"./index-DFBCf_Ns.js";import{F as D,b as y,r as $,c as Q}from"./folder-role-CCoF_M_n.js";import{S as B,C as G}from"./select-u4cRyFjX.js";import{S as H}from"./settings-screen-D48k5Bt1.js";import{u as N}from"./useMutation-driganVD.js";import{E as O}from"./ErrorState-ozcCp-cA.js";import{C as K,N as q}from"./folder-roles-XnseeyyD.js";import"./trash-2-l_BkiFgy.js";import"./star-cNw1G8pR.js";import"./avatar-K4mVDmMa.js";const z=["inbox","drafts","sent","archive","junk","trash"],x="";function V(a){const r=a.messageCount===1?"msg":"msgs";return`${y(a.providerPath)} · ${a.messageCount} ${r}`}function J({role:a,folders:r,appointedId:n,displayName:l,onAppoint:m,onRename:p}){const[c,d]=v.useState(l),s=r.find(i=>i.mailboxId===n)??null,t=Q(a),u=s!=null&&c.trim()!==l.trim();return e.jsxs("div",{className:"flex flex-col gap-1 border-b border-line px-row-inset py-2.5 last:border-b-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"flex w-28 shrink-0 items-center gap-2 text-sm font-medium text-fg",children:[$(a),t]}),e.jsxs(B,{className:"w-56 shrink-0",value:n??x,"aria-label":`Folder for ${t}`,onChange:i=>m(a,i.target.value===x?null:i.target.value),children:[e.jsx("option",{value:x,children:"None"}),r.map(i=>e.jsx("option",{value:i.mailboxId,children:V(i)},i.mailboxId))]}),s&&e.jsxs(e.Fragment,{children:[e.jsx(I,{className:"flex-1",value:c,placeholder:t,"aria-label":`Display name for ${t}`,onChange:i=>d(i.target.value)}),u&&e.jsx(S,{variant:"ghost",size:"sm",className:"shrink-0",icon:e.jsx(G,{className:"size-4"}),"aria-label":"Save display name",onClick:()=>p(s.mailboxId,c)})]})]}),s&&e.jsxs("span",{className:"truncate pl-[7.5rem] text-2xs text-fg-subtle",title:s.providerPath,children:[s.providerPath," · ",s.messageCount," ",s.messageCount===1?"message":"messages"]})]})}function U({accountEmail:a,folders:r,appointments:n,displayNames:l={},onAppoint:m,onRename:p}){const c=new Set(Object.values(n).filter(s=>s!=null)),d=r.filter(s=>!c.has(s.mailboxId));return e.jsxs("section",{className:"space-y-3",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsxs("h2",{className:"text-sm font-semibold text-fg",children:["Folder roles — ",a]}),e.jsx("p",{className:"text-xs text-fg-muted",children:"Each role points to one folder. Pick the folder that holds the mail — the counts help you tell real folders from empty look-alikes. Appointing a folder here removes it from any other role."})]}),e.jsx("div",{className:"rounded-sm border border-line bg-surface",children:z.map(s=>{const t=n[s]??null;return e.jsx(J,{role:s,folders:r,appointedId:t,displayName:t?l[t]??"":"",onAppoint:m,onRename:p},s)})}),d.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h3",{className:"text-xs font-medium text-fg-muted",children:"Other folders"}),e.jsx("ul",{className:"rounded-sm border border-line bg-surface",children:d.map(s=>e.jsxs("li",{className:"flex items-center gap-2 border-b border-line px-row-inset py-2 text-sm text-fg last:border-b-0",children:[e.jsx(D,{className:"size-4 shrink-0 text-fg-subtle"}),e.jsx("span",{className:"truncate",children:y(s.providerPath)}),e.jsxs("span",{className:"ml-auto shrink-0 text-2xs text-fg-subtle",children:[s.messageCount," ",s.messageCount===1?"message":"messages"]})]},s.mailboxId))})]})]})}const W=e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{children:"Each canonical role — Inbox, Drafts, Sent, Archive, Spam, Trash — points at one of your account's real folders. Pick the one that actually holds the mail; the message counts tell real folders from empty look-alikes."}),e.jsx("p",{children:`Appointing a folder to a role here doesn't touch any other role, and doesn't move or rename anything on the server — it just tells Remit which folder to treat as e.g. "Drafts" everywhere (sidebar, unread badges, the compose flow).`}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Display name"})," renames the appointed folder for the sidebar. Leave it blank to use the role's canonical name."]})]});function X({account:a}){const r=L(),n=a.accountId,{data:l,isPending:m,isError:p,error:c,refetch:d}=j(P({path:{accountId:n}})),s=N({..._(),onSuccess:()=>{r.invalidateQueries({queryKey:T()})}}),t=N({...M(),onSuccess:()=>{r.invalidateQueries({queryKey:w({path:{accountId:n}})})}}),u=(o,h)=>{s.mutate({path:{accountId:n,role:q[o]},body:{mailboxId:h}})},i=(o,h)=>{const b=h.trim();t.mutate({path:{accountId:n,mailboxId:o},body:{displayNameOverride:b===""?null:b}})};if(m)return e.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":`Loading folders for ${a.email}`});if(p)return e.jsx(O,{variant:"inline",title:`Couldn't load folders for ${a.email}`,error:c,onRetry:()=>{d()}});const C=l.items.map(o=>({mailboxId:o.mailboxId,providerPath:o.fullPath,messageCount:o.messageCount})),f={};for(const o of a.folderAppointments){const h=K[o.role];h&&(f[h]=o.mailboxId??null)}const g={};for(const o of l.items)o.displayNameOverride&&(g[o.mailboxId]=o.displayNameOverride);return e.jsxs("div",{className:"space-y-2",children:[(s.isError||t.isError)&&e.jsx(F,{tone:"danger",variant:"soft",children:"Couldn't save that change. Please try again."}),e.jsx(U,{accountEmail:a.email,folders:C,appointments:f,displayNames:g,onAppoint:u,onRename:i})]})}function le(){const a=A(),[r,n]=v.useState(!0),{data:l,isPending:m,isError:p,error:c,refetch:d}=j(E()),s=t=>{const u=k[t];u&&a({to:u})};return e.jsx(H,{items:R,activeId:"folders",title:"Folder roles",description:"Appoint which real folder fills each canonical role, per account.",help:W,helpOpen:r,onToggleHelp:()=>n(t=>!t),onSelect:s,onBackToMail:()=>{a({to:"/mail"})},children:m?e.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":"Loading accounts"}):p?e.jsx(O,{title:"Couldn't load accounts",error:c,onRetry:()=>{d()}}):l.accounts.length===0?e.jsx("p",{className:"py-12 text-sm text-fg-muted",children:"No accounts configured."}):e.jsx("div",{className:"space-y-8",children:l.accounts.map(t=>e.jsx(X,{account:t},t.accountId))})})}export{le as component};
@@ -1 +0,0 @@
1
- import{j as t,b3 as o}from"./index-DFBCf_Ns.js";const n=()=>t.jsx(o,{to:"/settings/accounts"});export{n as component};