@remit/web-client-dist 0.0.276 → 0.0.278

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 (43) hide show
  1. package/assets/{ComposeBody-DNv4lKVg.js → ComposeBody-CGaFXLXO.js} +1 -1
  2. package/assets/{ConfirmDialog-6u-So5Mj.js → ConfirmDialog-D1GP_3aW.js} +1 -1
  3. package/assets/{ErrorState-Bkp1gXXl.js → ErrorState-DOPmctB8.js} +1 -1
  4. package/assets/OnboardingWizard-KpL3Flre.js +1 -0
  5. package/assets/{account-form-helpers-CiMqlmbr.js → account-form-helpers-BtEbVGlC.js} +1 -1
  6. package/assets/accounts-BbS1gUvn.js +1 -0
  7. package/assets/{advanced-BO6zq6kP.js → advanced-BQ5c8qQg.js} +1 -1
  8. package/assets/{appearance-BfWb9_Fy.js → appearance-CCfoO8NF.js} +1 -1
  9. package/assets/{avatar-lSR-nesO.js → avatar-BfeCM0ty.js} +1 -1
  10. package/assets/{browser-ponyfill-BsjencOU.js → browser-ponyfill-CO7eFWgc.js} +1 -1
  11. package/assets/{circle-check-DsCOkSSM.js → circle-check-1cT30g5M.js} +1 -1
  12. package/assets/{download-COLZC06N.js → download-nDWPlRSK.js} +1 -1
  13. package/assets/{filters-D07T8xAp.js → filters-BhPjGxPr.js} +1 -1
  14. package/assets/{flagged-CAKOVrfq.js → flagged-BQY9gPz8.js} +1 -1
  15. package/assets/{folders-C0VzmNT5.js → folders-DyBFI3Tm.js} +1 -1
  16. package/assets/{index-CUqn72uM.js → index-BrioO4Hk.js} +1 -1
  17. package/assets/{index-CiEaS41j.js → index-CDilPMTC.js} +6 -6
  18. package/assets/index-D58sWyFv.js +1 -0
  19. package/assets/{index-BVVs8455.css → index-DidEu5F1.css} +1 -1
  20. package/assets/{kbd-FhAgSVFv.js → kbd-DbB18g8y.js} +1 -1
  21. package/assets/{labels-fkQCQumy.js → labels-CBAWoK_y.js} +1 -1
  22. package/assets/mail-DOmqnNpl.js +118 -0
  23. package/assets/{move-options-B90_Im78.js → move-options-Dncnrti5.js} +1 -1
  24. package/assets/{onboarding-pxm_CHBN.js → onboarding-XmEZjouH.js} +1 -1
  25. package/assets/{pencil-Bi_EFx_h.js → pencil-DaILYptf.js} +1 -1
  26. package/assets/{senders-Dl4Tys8e.js → senders-BhIqHZ1t.js} +1 -1
  27. package/assets/settings-screen-g9f_NsNO.js +1 -0
  28. package/assets/settings-uyRxT3II.js +1 -0
  29. package/assets/{shield-check-D9OTHLzn.js → shield-check-Do1pWgR9.js} +1 -1
  30. package/assets/{suggested-vips-C5XozfMP.js → suggested-vips-B8m7cmNx.js} +1 -1
  31. package/assets/{useDebouncedValue-Ba-QrX22.js → useDebouncedValue-BMXcQvkf.js} +1 -1
  32. package/assets/useFilters-BX9qJseE.js +1 -0
  33. package/assets/{useLabels-D5Ao5ySk.js → useLabels-THHDGeof.js} +1 -1
  34. package/assets/{useSignature-BsS3enZI.js → useSignature-CfRLggZS.js} +1 -1
  35. package/index.html +3 -3
  36. package/package.json +1 -1
  37. package/assets/OnboardingWizard-C0UwUPbi.js +0 -1
  38. package/assets/accounts-x6guxeAK.js +0 -1
  39. package/assets/index-CrWgKt9k.js +0 -1
  40. package/assets/mail-4Em6VBK7.js +0 -118
  41. package/assets/settings-DVvZvPYc.js +0 -1
  42. package/assets/settings-screen-DbXrcUiB.js +0 -1
  43. package/assets/useFilters-CIuLf8B3.js +0 -1
@@ -1 +1 @@
1
- import{aa as E,aF as S,aq as I,aI as L,ax as _,cH as D,r as b,b3 as x,aC as A,ar as T,cI as p,aD as k}from"./index-CiEaS41j.js";const w={synced:"synced",failed:"failed"},W={uncategorized:"uncategorized",personal:"personal",newsletter:"newsletter",marketing:"marketing",automated:"automated",transactional:"transactional",social:"social"},Z={Lookalike:"Lookalike",Unrelated:"Unrelated"},j={MoveToInbox:"MoveToInbox",MoveToJunk:"MoveToJunk"},N=3e4,F=1e3,R="The folder couldn't be created on the mail server. Please try again.",$="The folder was created but the mail server hasn't confirmed it yet, so nothing was attached to it. It's in your folder list — try again in a moment.",B=(e,t)=>new Promise((a,o)=>{if(t?.aborted){o(t.reason);return}const n=setTimeout(()=>{t?.removeEventListener("abort",r),a()},e),r=()=>{clearTimeout(n),o(t?.reason)};t?.addEventListener("abort",r,{once:!0})});async function Y({fetchMailboxes:e,mailboxId:t,signal:a,timeoutMs:o=N,pollIntervalMs:n=F,delay:r=B,now:l=Date.now}){const s=l()+o;for(;;){a?.throwIfAborted();const c=(await e()).find(u=>u.mailboxId===t);if(c?.syncStatus===w.synced)return c;if(c?.syncStatus===w.failed)throw new Error(R);if(l()>=s)throw new Error($);await r(n,a)}}function O(e,t){const a=e.trim();return t?`${t.fullPath}${t.hierarchyDelimiter}${a}`:a}const P=(e,t)=>{const a=e.split(t);return a[0]?.toLowerCase()==="inbox"&&(a[0]="INBOX"),a.join(t)};function z({name:e,delimiter:t,parent:a,existingPaths:o}){const n=e.trim();if(n==="")return"Enter a folder name.";if(n.includes(t))return`A folder name can't contain "${t}".`;const r=P(O(n,a),t);if(o.some(s=>P(s,t)===r))return"A folder with that name already exists."}function ee(e){const t=E(),{data:a}=S({...I({path:{accountId:e??""}}),enabled:!!e}),o=L({...D(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:_({path:{accountId:e}})})}}),n=b.useRef(new Map),r=b.useCallback(async(s,i,c)=>{if(!e)throw new Error("No account to create the folder in. Pick messages from a single account first.");const u=a?.items??[],d=i?u.find(h=>h.fullPath===i):void 0;if(i&&!d)throw new Error(`Couldn't find the folder "${i}" to create this one inside.`);const y=d?{fullPath:d.fullPath,hierarchyDelimiter:d.hierarchyDelimiter}:void 0,f=O(s,y);let m=n.current.get(f);if(!m){const h=y?.hierarchyDelimiter??u[0]?.hierarchyDelimiter??"/",v=z({name:s,delimiter:h,parent:y,existingPaths:u.map(C=>C.fullPath)});if(v)throw new Error(v);m=(await o.mutateAsync({path:{accountId:e},body:{fullPath:f,namespaceType:"personal"}})).mailboxId,n.current.set(f,m)}const M=await Y({mailboxId:m,signal:c,fetchMailboxes:async()=>(await t.fetchQuery({...I({path:{accountId:e}}),staleTime:0})).items??[]});return n.current.delete(f),{id:M.mailboxId,label:x(M.fullPath),path:M.fullPath}},[o,e,a,t]);return{createFolder:b.useCallback((s,i)=>r(s,"",i),[r]),createFolderIn:r,mutation:o}}const te=()=>{const{t:e}=A("mail",{useSuspense:!1});return b.useCallback((t,a)=>e(t,{defaultValue:a}),[e])},ae=100,X=e=>e.trim().toLowerCase()==="inbox",Q=(e,t)=>{const a=`${e.fullPath}${e.hierarchyDelimiter}`;return t.some(o=>o.mailboxId!==e.mailboxId&&o.fullPath.startsWith(a))},U=(e,t)=>t.find(a=>a.mailboxId!=null&&a.mailboxId===e)?.role;function oe(e,t,a){if(X(e.fullPath))return{deletable:!1,reason:"inbox",message:"The inbox can't be deleted."};const o=U(e.mailboxId,a);return o?{deletable:!1,reason:"role",message:`This folder is your ${o} folder. Reassign that role before deleting it.`}:Q(e,t)?{deletable:!1,reason:"children",message:"This folder has subfolders. Delete them first."}:{deletable:!0}}function q(e,t){return e.filter(a=>a.mailboxId!==t)}function ne(e){return{total:e,moved:0,phase:e===0?"moved":"moving"}}function re(e,t){if(e.phase!=="moving")return e;const a=Math.min(e.total,e.moved+Math.max(0,t));return{...e,moved:a,phase:a>=e.total?"moved":"moving"}}function ie(e,t){return{...e,phase:"failed",error:t}}function se(e){return`Moved ${e.moved} of ${e.total}`}function le(e){return e>0?"choose-fate":"confirm-empty"}const V=new Set(["outbox","postvak uit","boîte d'envoi","postausgang","buzón de salida","posta in uscita","送信トレイ","送件匣","发件箱","skrzynka nadawcza"]),G=e=>{const t=x(e.fullPath).trim().toLowerCase();return V.has(t)},g=p.length,H=(e,t)=>{const a=T(t);return[...e.filter(n=>{const r=a.get(n.mailboxId);return r==="drafts"||r==="sent"?!1:!G(n)})].sort((n,r)=>{const l=a.has(n.mailboxId)?p.indexOf(a.get(n.mailboxId)??"inbox"):g,s=a.has(r.mailboxId)?p.indexOf(a.get(r.mailboxId)??"inbox"):g;return l!==s?l-s:x(n.fullPath).localeCompare(x(r.fullPath),void 0,{sensitivity:"base",numeric:!0})})},ce=e=>e[0]?.hierarchyDelimiter??"/",ue=({mailboxes:e,folderAppointments:t,currentMailboxId:a,excludeMailboxId:o,translator:n})=>{const r=H(e,t),l=T(t);return(o?q(r,o):r).map(i=>({id:i.mailboxId,label:k(i,l.get(i.mailboxId),n),path:i.fullPath,isCurrent:i.mailboxId===a}))};export{Z as D,W as M,j as P,ee as a,ue as b,ne as c,ie as d,re as e,ce as f,ae as g,oe as h,le as i,se as m,te as u};
1
+ import{aa as E,aF as S,aq as I,aI as L,ax as _,cH as D,r as b,b3 as x,aC as A,ar as T,cI as p,aD as k}from"./index-CDilPMTC.js";const w={synced:"synced",failed:"failed"},W={uncategorized:"uncategorized",personal:"personal",newsletter:"newsletter",marketing:"marketing",automated:"automated",transactional:"transactional",social:"social"},Z={Lookalike:"Lookalike",Unrelated:"Unrelated"},j={MoveToInbox:"MoveToInbox",MoveToJunk:"MoveToJunk"},N=3e4,F=1e3,R="The folder couldn't be created on the mail server. Please try again.",$="The folder was created but the mail server hasn't confirmed it yet, so nothing was attached to it. It's in your folder list — try again in a moment.",B=(e,t)=>new Promise((a,o)=>{if(t?.aborted){o(t.reason);return}const n=setTimeout(()=>{t?.removeEventListener("abort",r),a()},e),r=()=>{clearTimeout(n),o(t?.reason)};t?.addEventListener("abort",r,{once:!0})});async function Y({fetchMailboxes:e,mailboxId:t,signal:a,timeoutMs:o=N,pollIntervalMs:n=F,delay:r=B,now:l=Date.now}){const s=l()+o;for(;;){a?.throwIfAborted();const c=(await e()).find(u=>u.mailboxId===t);if(c?.syncStatus===w.synced)return c;if(c?.syncStatus===w.failed)throw new Error(R);if(l()>=s)throw new Error($);await r(n,a)}}function O(e,t){const a=e.trim();return t?`${t.fullPath}${t.hierarchyDelimiter}${a}`:a}const P=(e,t)=>{const a=e.split(t);return a[0]?.toLowerCase()==="inbox"&&(a[0]="INBOX"),a.join(t)};function z({name:e,delimiter:t,parent:a,existingPaths:o}){const n=e.trim();if(n==="")return"Enter a folder name.";if(n.includes(t))return`A folder name can't contain "${t}".`;const r=P(O(n,a),t);if(o.some(s=>P(s,t)===r))return"A folder with that name already exists."}function ee(e){const t=E(),{data:a}=S({...I({path:{accountId:e??""}}),enabled:!!e}),o=L({...D(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:_({path:{accountId:e}})})}}),n=b.useRef(new Map),r=b.useCallback(async(s,i,c)=>{if(!e)throw new Error("No account to create the folder in. Pick messages from a single account first.");const u=a?.items??[],d=i?u.find(h=>h.fullPath===i):void 0;if(i&&!d)throw new Error(`Couldn't find the folder "${i}" to create this one inside.`);const y=d?{fullPath:d.fullPath,hierarchyDelimiter:d.hierarchyDelimiter}:void 0,f=O(s,y);let m=n.current.get(f);if(!m){const h=y?.hierarchyDelimiter??u[0]?.hierarchyDelimiter??"/",v=z({name:s,delimiter:h,parent:y,existingPaths:u.map(C=>C.fullPath)});if(v)throw new Error(v);m=(await o.mutateAsync({path:{accountId:e},body:{fullPath:f,namespaceType:"personal"}})).mailboxId,n.current.set(f,m)}const M=await Y({mailboxId:m,signal:c,fetchMailboxes:async()=>(await t.fetchQuery({...I({path:{accountId:e}}),staleTime:0})).items??[]});return n.current.delete(f),{id:M.mailboxId,label:x(M.fullPath),path:M.fullPath}},[o,e,a,t]);return{createFolder:b.useCallback((s,i)=>r(s,"",i),[r]),createFolderIn:r,mutation:o}}const te=()=>{const{t:e}=A("mail",{useSuspense:!1});return b.useCallback((t,a)=>e(t,{defaultValue:a}),[e])},ae=100,X=e=>e.trim().toLowerCase()==="inbox",Q=(e,t)=>{const a=`${e.fullPath}${e.hierarchyDelimiter}`;return t.some(o=>o.mailboxId!==e.mailboxId&&o.fullPath.startsWith(a))},U=(e,t)=>t.find(a=>a.mailboxId!=null&&a.mailboxId===e)?.role;function oe(e,t,a){if(X(e.fullPath))return{deletable:!1,reason:"inbox",message:"The inbox can't be deleted."};const o=U(e.mailboxId,a);return o?{deletable:!1,reason:"role",message:`This folder is your ${o} folder. Reassign that role before deleting it.`}:Q(e,t)?{deletable:!1,reason:"children",message:"This folder has subfolders. Delete them first."}:{deletable:!0}}function q(e,t){return e.filter(a=>a.mailboxId!==t)}function ne(e){return{total:e,moved:0,phase:e===0?"moved":"moving"}}function re(e,t){if(e.phase!=="moving")return e;const a=Math.min(e.total,e.moved+Math.max(0,t));return{...e,moved:a,phase:a>=e.total?"moved":"moving"}}function ie(e,t){return{...e,phase:"failed",error:t}}function se(e){return`Moved ${e.moved} of ${e.total}`}function le(e){return e>0?"choose-fate":"confirm-empty"}const V=new Set(["outbox","postvak uit","boîte d'envoi","postausgang","buzón de salida","posta in uscita","送信トレイ","送件匣","发件箱","skrzynka nadawcza"]),G=e=>{const t=x(e.fullPath).trim().toLowerCase();return V.has(t)},g=p.length,H=(e,t)=>{const a=T(t);return[...e.filter(n=>{const r=a.get(n.mailboxId);return r==="drafts"||r==="sent"?!1:!G(n)})].sort((n,r)=>{const l=a.has(n.mailboxId)?p.indexOf(a.get(n.mailboxId)??"inbox"):g,s=a.has(r.mailboxId)?p.indexOf(a.get(r.mailboxId)??"inbox"):g;return l!==s?l-s:x(n.fullPath).localeCompare(x(r.fullPath),void 0,{sensitivity:"base",numeric:!0})})},ce=e=>e[0]?.hierarchyDelimiter??"/",ue=({mailboxes:e,folderAppointments:t,currentMailboxId:a,excludeMailboxId:o,translator:n})=>{const r=H(e,t),l=T(t);return(o?q(r,o):r).map(i=>({id:i.mailboxId,label:k(i,l.get(i.mailboxId),n),path:i.fullPath,isCurrent:i.mailboxId===a}))};export{Z as D,W as M,j as P,ee as a,ue as b,ne as c,ie as d,re as e,ce as f,ae as g,oe as h,le as i,se as m,te as u};
@@ -1 +1 @@
1
- import{bT as t,aw as r,aa as a,r as i,j as s}from"./index-CiEaS41j.js";import{O as c}from"./OnboardingWizard-C0UwUPbi.js";import"./kbd-FhAgSVFv.js";import"./account-form-helpers-CiMqlmbr.js";async function l(e){e.recordCompleted(),await e.queryClient.refetchQueries({queryKey:t()}),e.navigateToInbox()}function y(){const e=r(),o=a(),n=i.useCallback(m=>{l({queryClient:o,recordCompleted:()=>e.recordEvent("onboarding.completed"),navigateToInbox:()=>{window.location.assign("/mail")}})},[e,o]);return s.jsx(c,{skipWelcome:!1,onComplete:n})}export{y as component};
1
+ import{bT as t,aw as r,aa as a,r as i,j as s}from"./index-CDilPMTC.js";import{O as c}from"./OnboardingWizard-KpL3Flre.js";import"./kbd-DbB18g8y.js";import"./account-form-helpers-BtEbVGlC.js";async function l(e){e.recordCompleted(),await e.queryClient.refetchQueries({queryKey:t()}),e.navigateToInbox()}function y(){const e=r(),o=a(),n=i.useCallback(m=>{l({queryClient:o,recordCompleted:()=>e.recordEvent("onboarding.completed"),navigateToInbox:()=>{window.location.assign("/mail")}})},[e,o]);return s.jsx(c,{skipWelcome:!1,onComplete:n})}export{y as component};
@@ -1 +1 @@
1
- import{a}from"./index-CiEaS41j.js";const c=a("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);export{c as P};
1
+ import{a}from"./index-CDilPMTC.js";const c=a("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);export{c as P};
@@ -1 +1 @@
1
- import{j as e,d as N,ap as z,r as c,c8 as L,bZ as M,v as O,ca as $,aF as I,cP as q,aa as k,aI as C,cQ as A,b5 as P,B as S,S as Q,aM as R,X as B}from"./index-CiEaS41j.js";import{K as m}from"./kbd-FhAgSVFv.js";import{S as G,a as E}from"./settings-screen-DbXrcUiB.js";import{E as V}from"./ErrorState-Bkp1gXXl.js";import{u as F}from"./useDebouncedValue-Ba-QrX22.js";import{d as K}from"./format-CKZmh-Ru.js";import"./avatar-lSR-nesO.js";function _({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"},D=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:y}=I(q()),g=k(),i=C({...P(),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:y})}):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(E,{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(Q,{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=F(r.trim(),300),d=k(),[y,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=C({...P(),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,b=o?[`${t}`,o.setAt&&K(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&&y===s.addressId;return e.jsx(E,{name:s.displayName??s.normalizedEmail,email:s.normalizedEmail,danger:t==="blocked",meta:b,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 te(){const t=z(),[r,x]=c.useState("vip"),[a,d]=c.useState(""),[y,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(b=>({...b,vip:o}))},[]),j=c.useCallback((s,o)=>{l(s),u(b=>({...b,[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:D,helpOpen:y,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(_,{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(M,{icon:e.jsx(O,{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{te as component};
1
+ import{j as e,d as N,ap as z,r as c,c8 as L,bZ as M,v as O,ca as $,aF as I,cP as q,aa as k,aI as C,cQ as A,b5 as P,B as S,S as Q,aM as R,X as B}from"./index-CDilPMTC.js";import{K as m}from"./kbd-DbB18g8y.js";import{S as G,a as E}from"./settings-screen-g9f_NsNO.js";import{E as V}from"./ErrorState-DOPmctB8.js";import{u as F}from"./useDebouncedValue-BMXcQvkf.js";import{d as K}from"./format-CKZmh-Ru.js";import"./avatar-BfeCM0ty.js";function _({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"},D=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:y}=I(q()),g=k(),i=C({...P(),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:y})}):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(E,{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(Q,{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=F(r.trim(),300),d=k(),[y,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=C({...P(),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,b=o?[`${t}`,o.setAt&&K(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&&y===s.addressId;return e.jsx(E,{name:s.displayName??s.normalizedEmail,email:s.normalizedEmail,danger:t==="blocked",meta:b,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 te(){const t=z(),[r,x]=c.useState("vip"),[a,d]=c.useState(""),[y,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(b=>({...b,vip:o}))},[]),j=c.useCallback((s,o)=>{l(s),u(b=>({...b,[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:D,helpOpen:y,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(_,{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(M,{icon:e.jsx(O,{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{te as component};
@@ -0,0 +1 @@
1
+ import{a as z,r as j,j as e,d as f,B as i,X as N,e as S}from"./index-CDilPMTC.js";import{M as B,C as v,A as w}from"./avatar-BfeCM0ty.js";const h=z("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);function L({items:l,activeId:t,title:c,description:n,children:r,help:s,helpOpen:d=!0,flush:o,onSelect:k,onToggleHelp:u,onBackToMail:m}){const[y,x]=j.useState(!1),[b,C]=j.useState(!1),g=!!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),x(!1)},className:f("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:f("shrink-0",a.id===t?"text-accent-2":"text-fg-subtle"),children:a.icon}),a.label]},a.id))})]});return e.jsxs("div",{className:"safe-area-frame 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:m,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(h,{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:()=>x(!1)}),e.jsxs("aside",{className:"safe-area-frame 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:()=>{m?.(),x(!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(h,{className:"size-4 text-fg-subtle"}),"Back to mail"]}),e.jsx(i,{variant:"ghost",size:"sm",icon:e.jsx(N,{className:"size-4"}),onClick:()=>x(!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:[m&&e.jsx(i,{variant:"ghost",size:"sm",icon:e.jsx(h,{className:"size-4"}),className:"-ml-1 lg:hidden",onClick:m,"aria-label":"Back to mail"}),e.jsx(i,{variant:"ghost",size:"sm",icon:e.jsx(B,{className:"size-4"}),className:"lg:hidden",onClick:()=>x(!0),"aria-label":"Open settings menu"}),e.jsx("h1",{className:"text-md font-semibold text-fg",children:c}),n&&e.jsx("p",{className:"hidden min-w-0 truncate text-xs text-fg-subtle lg:block",children:n}),s&&e.jsx(i,{variant:"ghost",size:"sm",icon:e.jsx(v,{className:"size-4"}),className:"ml-auto lg:hidden",onClick:()=>C(a=>!a),"aria-label":"Tips","aria-expanded":b}),s&&!g&&e.jsx(i,{variant:"ghost",size:"sm",icon:e.jsx(v,{className:"size-4"}),className:"hidden ml-auto lg:inline-flex",onClick:u,"aria-label":"Show tips"})]}),s&&b&&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})})})]}),g&&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(i,{variant:"ghost",size:"sm",icon:e.jsx(N,{className:"size-3.5"}),onClick:u,"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:c,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:f(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:[c,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:c,syncLabel:n,state:r,errorDetail:s,trailing:d}){const o=O[r];return e.jsxs("div",{className:f("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," · ",c," · ",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};
@@ -0,0 +1 @@
1
+ import{j as t,bS as o}from"./index-CDilPMTC.js";const n=()=>t.jsx(o,{});export{n as component};
@@ -1 +1 @@
1
- import{a as e}from"./index-CiEaS41j.js";const c=e("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);const t=e("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);const o=e("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);export{c as C,t as R,o as S};
1
+ import{a as e}from"./index-CDilPMTC.js";const c=e("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);const t=e("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);const o=e("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);export{c as C,t as R,o as S};
@@ -1 +1 @@
1
- import{j as t,bU as e}from"./index-CiEaS41j.js";const o=()=>t.jsx(e,{to:"/settings/senders",replace:!0});export{o as component};
1
+ import{j as t,bU as e}from"./index-CDilPMTC.js";const o=()=>t.jsx(e,{to:"/settings/senders",replace:!0});export{o as component};
@@ -1 +1 @@
1
- import{r as o}from"./index-CiEaS41j.js";const n=(e,t)=>{const[r,u]=o.useState(e);return o.useEffect(()=>{const s=setTimeout(()=>u(e),t);return()=>clearTimeout(s)},[e,t]),r};export{n as u};
1
+ import{r as o}from"./index-CDilPMTC.js";const n=(e,t)=>{const[r,u]=o.useState(e);return o.useEffect(()=>{const s=setTimeout(()=>u(e),t);return()=>clearTimeout(s)},[e,t]),r};export{n as u};
@@ -0,0 +1 @@
1
+ import{r as c,j as M,d as I,aI as y,cr as L,aF as E,cs as z,bp as _,ct as k,cu as R,aa as D,cv as Y,cw as $,cx as j}from"./index-CDilPMTC.js";const J=320,H="cubic-bezier(0.32, 0.9, 0.3, 1)",U=.5,B=.4,K=360;function Q(e){return Math.sign(e)*Math.sqrt(Math.abs(e))*4}function ue({open:e,onClose:t,children:r,dismissLabel:s="Dismiss"}){const i=c.useRef(null),[n,a]=c.useState(K),[l,m]=c.useState(null);c.useLayoutEffect(()=>{const o=i.current;if(!o)return;const p=()=>a(o.offsetHeight);p();const v=new ResizeObserver(p);return v.observe(o),()=>v.disconnect()},[]);const u=c.useRef(null),f=c.useCallback(o=>{o.currentTarget.setPointerCapture(o.pointerId),u.current={startY:o.clientY,lastY:o.clientY,lastT:o.timeStamp,velocity:0,moved:!1},m(0)},[]),b=c.useCallback(o=>{const p=u.current;if(!p)return;const v=o.timeStamp-p.lastT;v>0&&(p.velocity=(o.clientY-p.lastY)/v),p.lastY=o.clientY,p.lastT=o.timeStamp;const S=o.clientY-p.startY;Math.abs(S)>4&&(p.moved=!0);const T=S<0?Q(S):S;m(T)},[]),d=c.useCallback(()=>{const o=u.current;if(u.current=null,!o)return;const p=o.lastY-o.startY,S=o.velocity>U||p>n*B;m(null),S&&t()},[n,t]),h=l!==null,g=e?l??0:n,x=Math.min(Math.max(1-g/n,0),1),O=h?"none":`transform ${J}ms ${H}`;return M.jsxs("div",{className:I("absolute inset-0 z-40 select-none overflow-hidden",e||h?"":"pointer-events-none"),children:[M.jsx("button",{type:"button","aria-label":s,tabIndex:-1,onClick:t,className:I("absolute inset-0 bg-black/40",x>0?"pointer-events-auto":"pointer-events-none"),style:{opacity:x*.6,transition:O.replace("transform","opacity")}}),M.jsxs("div",{ref:i,className:"absolute inset-x-0 bottom-0 flex max-h-[92%] flex-col rounded-t-3xl border-t border-line bg-surface pb-[env(safe-area-inset-bottom,0px)] shadow-2xl shadow-black/30",style:{transform:`translateY(${g}px)`,transition:O},children:[M.jsx("div",{role:"slider","aria-label":"Drag down to dismiss","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(x*100),tabIndex:0,onPointerDown:f,onPointerMove:b,onPointerUp:d,onPointerCancel:d,className:"flex cursor-grab touch-none justify-center pb-1 pt-2.5 active:cursor-grabbing",children:M.jsx("div",{className:"h-1 w-10 rounded-full bg-fg-subtle/40"})}),M.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:r})]})]})}const W=1024,q=`(min-width: ${W}px) and (not ((orientation: portrait) and (pointer: coarse)))`,V=e=>{const[t,r]=c.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(e).matches);return c.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const s=window.matchMedia(e),i=n=>r(n.matches);return r(s.matches),s.addEventListener("change",i),()=>s.removeEventListener("change",i)},[e]),t},de=()=>V(q),me=(e,t)=>{if(e.state==="Expired")return"Expired";if(e.scope!=="Temporary"||!e.expiresAt)return"Active";const r=Date.parse(e.expiresAt);return Number.isNaN(r)?"Active":r<=t?"Expired":"Active"},fe=e=>{if(!e)return;const t=Date.parse(e);if(!Number.isNaN(t))return new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})},N=(e,t=new Date)=>{if(!e)return;const r=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!r)return;const[,s,i,n]=r,a=new Date(Number(s),Number(i)-1,Number(n),23,59,59,0);if(Number.isNaN(a.getTime()))return;const l=-t.getTimezoneOffset(),m=l>=0?"+":"-",u=Math.abs(l),f=String(Math.floor(u/60)).padStart(2,"0"),b=String(u%60).padStart(2,"0"),d=h=>String(h).padStart(2,"0");return`${a.getFullYear()}-${d(a.getMonth()+1)}-${d(a.getDate())}T${d(a.getHours())}:${d(a.getMinutes())}:${d(a.getSeconds())}${m}${f}:${b}`},C="None",pe=e=>!e.literalClauses.some(t=>t.field==="HasWords"),P=e=>({...e.anchorMessageId?{anchorMessageId:e.anchorMessageId}:{},matchOperator:e.matchOperator,literalClauses:e.literalClauses,actionLabelId:e.labelId??C,actionMailboxId:e.moveMailboxId??C}),he=({mode:e,ruleScope:t})=>t==="standing"?"standing":t==="until"?"temporary":e==="selected"?"just-these":"all-like-these",ge=({mode:e,ruleScope:t,anchorMessageId:r,clauses:s,matchOperator:i,moveMailboxId:n,until:a})=>({...e==="similar"&&r?{anchorMessageId:r}:{},matchOperator:i==="all"?"And":"Or",literalClauses:s.map(l=>({field:l.field,value:l.value})),moveMailboxId:n,expiresAt:t==="until"?N(a??""):void 0}),w=(e,t,r)=>({name:r,scope:t==="standing"?"Standing":"Temporary",...t==="temporary"&&e.expiresAt?{expiresAt:e.expiresAt}:{},matchOperator:e.matchOperator,literalClauses:e.literalClauses,actionLabelId:e.labelId??C,actionMailboxId:e.moveMailboxId??C,...e.anchorMessageId?{anchorMessageId:e.anchorMessageId}:{}}),G=new Set(["Complete","Failed"]),A=e=>e!==void 0&&G.has(e),X=1e3,Z=15e3,ee=e=>{const t=Math.max(0,e),r=X*2**t;return Math.min(r,Z)},te=(e,t,r)=>{if(e)return{kind:r?"restartFailed":"startFailed",error:e};if(t)return{kind:"statusUnreadable",error:t}},be=e=>{const[t,r]=c.useState(),s=y({...L(),onSuccess:g=>r(g.organizeJobId)}),{mutate:i}=s,n=E({...z({path:{accountId:e??"",organizeJobId:t??""}}),enabled:!!e&&!!t,refetchInterval:g=>{const x=g.state.data?.state;return A(x)?!1:ee(g.state.dataUpdateCount)}}),a=c.useCallback(g=>{e&&i({path:{accountId:e},body:P(g)})},[e,i]),{refetch:l}=n,m=c.useCallback(()=>{l()},[l]),u=n.data,f=s.isPending?void 0:u,b=f?.state??s.data?.state,d=A(f?.state),h={state:b,matchedCount:f?.matchedCount??0,appliedCount:f?.appliedCount??0,failedCount:f?.failedCount??0,errorMessage:f?.errorMessage??""};return{start:a,refreshStatus:m,progress:h,isStarting:s.isPending,isRunning:!!t&&!d,isDone:d,failure:te(s.error,n.error,!!u)}},ve=["From","Subject","HasWords","ListId","FromDomain"],re=e=>{const t=e.trim(),r=t.match(/<([^>]+)>/);return(r?r[1]:t).trim().toLowerCase()},Se=(e,t)=>e==="ListId"?re(t):t.trim(),se=e=>e==="all"?"And":"Or",ne=(e,t)=>{const r=e.widen!==void 0&&!e.widen.inactive,s=e.clauses.map(i=>({field:i.field,value:i.value}));return{...r&&t?{anchorMessageId:t}:{},matchOperator:se(e.matchOperator),literalClauses:s}},ae=e=>e.anchorMessageId!==void 0||!e.literalClauses.some(t=>t.field==="HasWords"),ie=e=>JSON.stringify({anchor:e.anchorMessageId??null,operator:e.matchOperator,clauses:e.literalClauses.map(t=>`${t.field} ${t.value}`)}),Me=(e,t)=>{const r=ne(e,t);return{...r.anchorMessageId?{anchorMessageId:r.anchorMessageId}:{},matchOperator:r.matchOperator,literalClauses:r.literalClauses,moveMailboxId:e.moveMailboxId,labelId:e.labelId,expiresAt:e.scope==="until"?N(e.until??""):void 0}},oe=(e,t)=>e.error!==void 0&&e.errorSignature===t?{status:"error",reason:e.error}:e.count===void 0?{status:"loading"}:e.previewedSignature===t?{status:"ready",count:e.count}:{status:"ready",count:e.count,stale:!0},ce=350,xe=(e,t,r)=>{const s=y(_()),{mutateAsync:i}=s,n=ie(t),[a,l]=c.useState(()=>({})),m=c.useRef(t);m.current=t;const u=c.useRef(n),f=ae(t);return c.useEffect(()=>{if(!e||!f||n===a.previewedSignature||n===a.errorSignature)return;const b=setTimeout(()=>{const d=n;u.current=d,i({path:{accountId:e},body:P({...m.current})}).then(h=>{u.current===d&&l({count:h.matchedCount,matchedIds:h.messageIds,previewedSignature:d})}).catch(h=>{u.current===d&&l(g=>({...g,error:h instanceof Error?h.message:"Couldn't count matches.",errorSignature:d}))})},ce);return()=>clearTimeout(b)},[e,f,n,a.previewedSignature,a.errorSignature,i]),f?{count:oe(a,n),matchedIds:a.previewedSignature===n?a.matchedIds??[]:[]}:{count:{status:"error",reason:k},matchedIds:[]}},F=e=>$({path:{accountId:e}}),Ce=e=>{const t=E({...R({path:{accountId:e??""}}),enabled:!!e});return{filters:t.data?.items??[],isPending:t.isPending,isError:t.isError,error:t.error,refetch:t.refetch}},ye=e=>{const t=D(),r=y({...j(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:F(e)})}}),{mutate:s,mutateAsync:i}=r,n=c.useCallback((l,m,u)=>{e&&s({path:{accountId:e},body:w(l,m,u)})},[e,s]),a=c.useCallback(async(l,m,u)=>e?i({path:{accountId:e},body:w(l,m,u)}).then(()=>!0,()=>!1):!1,[e,i]);return{createFilter:n,createFilterAsync:a,isPending:r.isPending,isSuccess:r.isSuccess,isError:r.isError,error:r.error,reset:r.reset}},Oe=e=>{const t=D(),r=y({...Y(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:F(e)})}}),{mutate:s}=r;return{deleteFilter:c.useCallback(n=>{e&&s({path:{accountId:e,filterId:n}})},[e,s]),isPending:r.isPending,deletingFilterId:r.isPending?r.variables?.path.filterId:void 0}};export{ue as B,q as D,C as N,ve as S,V as a,P as b,xe as c,be as d,ye as e,ge as f,pe as g,F as h,Me as i,me as j,fe as k,Ce as l,Oe as m,Se as n,he as o,N as p,ne as r,de as u};
@@ -1 +1 @@
1
- import{aF as L,cK as p,aa as n,aI as l,cL as d,r as o,cM as c,cN as y,cO as g}from"./index-CiEaS41j.js";const u=e=>c({path:{accountId:e}}),f=e=>{const a=L({...p({path:{accountId:e??""}}),enabled:!!e});return{labels:a.data?.items??[],isPending:a.isPending,isError:a.isError,error:a.error,refetch:a.refetch}},m=e=>{const a=n(),t=l({...d(),onSuccess:()=>{e&&a.invalidateQueries({queryKey:u(e)})}}),{mutateAsync:r}=t;return{createLabel:o.useCallback((s,i="Default")=>e?r({path:{accountId:e},body:{name:s,color:i}}):Promise.reject(new Error("No account")),[e,r]),isPending:t.isPending,isError:t.isError,error:t.error,reset:t.reset}},h=e=>{const a=n(),t=l({...y(),onSuccess:()=>{e&&a.invalidateQueries({queryKey:u(e)})}}),{mutate:r}=t;return{updateLabel:o.useCallback((s,i)=>{e&&r({path:{accountId:e,labelId:s},body:i})},[e,r]),isPending:t.isPending,updatingLabelId:t.isPending?t.variables?.path.labelId:void 0}},C=e=>{const a=n(),t=l({...g(),onSuccess:()=>{e&&a.invalidateQueries({queryKey:u(e)})}}),{mutate:r}=t;return{deleteLabel:o.useCallback(s=>{e&&r({path:{accountId:e,labelId:s}})},[e,r]),isPending:t.isPending,deletingLabelId:t.isPending?t.variables?.path.labelId:void 0}};export{m as a,h as b,C as c,f as u};
1
+ import{aF as L,cK as p,aa as n,aI as l,cL as d,r as o,cM as c,cN as y,cO as g}from"./index-CDilPMTC.js";const u=e=>c({path:{accountId:e}}),f=e=>{const a=L({...p({path:{accountId:e??""}}),enabled:!!e});return{labels:a.data?.items??[],isPending:a.isPending,isError:a.isError,error:a.error,refetch:a.refetch}},m=e=>{const a=n(),t=l({...d(),onSuccess:()=>{e&&a.invalidateQueries({queryKey:u(e)})}}),{mutateAsync:r}=t;return{createLabel:o.useCallback((s,i="Default")=>e?r({path:{accountId:e},body:{name:s,color:i}}):Promise.reject(new Error("No account")),[e,r]),isPending:t.isPending,isError:t.isError,error:t.error,reset:t.reset}},h=e=>{const a=n(),t=l({...y(),onSuccess:()=>{e&&a.invalidateQueries({queryKey:u(e)})}}),{mutate:r}=t;return{updateLabel:o.useCallback((s,i)=>{e&&r({path:{accountId:e,labelId:s},body:i})},[e,r]),isPending:t.isPending,updatingLabelId:t.isPending?t.variables?.path.labelId:void 0}},C=e=>{const a=n(),t=l({...g(),onSuccess:()=>{e&&a.invalidateQueries({queryKey:u(e)})}}),{mutate:r}=t;return{deleteLabel:o.useCallback(s=>{e&&r({path:{accountId:e,labelId:s}})},[e,r]),isPending:t.isPending,deletingLabelId:t.isPending?t.variables?.path.labelId:void 0}};export{m as a,h as b,C as c,f as u};
@@ -1 +1 @@
1
- import{r as y,j as i,B as u,d as m,L as p,aa as x,aR as C,aF as h,aQ as j,aI as L,aV as k,bT as T,bX as E}from"./index-CiEaS41j.js";const t=()=>i.jsx(p,{className:"size-3.5 animate-spin"}),f=(s,n)=>n?i.jsx("span",{className:"sr-only",children:s}):s;function S({actions:s=[],destructive:n,className:l}){const[r,o]=y.useState(!1);return r&&n?.confirm?i.jsxs("div",{className:m("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?t():void 0,onClick:()=>{n.busy||n.onClick()},children:n.busy?n.busyLabel??"Working…":n.confirm.confirmLabel??n.label})]}):i.jsxs("div",{className:m("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?t():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?t():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:""},z=s=>{const n=x(),{pushError:l}=C(),{data:r}=h({...j(),staleTime:1/0}),o=y.useMemo(()=>{if(!s||!r)return c;const e=r.accounts.find(b=>b.accountId===s);return e?{html:e.signatureHtml??"",plainText:e.signaturePlainText??""}:c},[s,r]),a=L({...E(),onSuccess:()=>{n.invalidateQueries({queryKey:T()})},onError:e=>{l(k("Couldn't save signature","The signature wasn't saved.",e))}}),g=y.useCallback((e,b)=>{s&&a.mutate({path:{accountId:s},body:{signatureHtml:e,signaturePlainText:b}})},[s,a]);return{signature:o,setSignature:g,isSaving:a.isPending}};export{S as R,z as u};
1
+ import{r as y,j as i,B as u,d as m,L as p,aa as x,aR as C,aF as h,aQ as j,aI as L,aV as k,bT as T,bX as E}from"./index-CDilPMTC.js";const t=()=>i.jsx(p,{className:"size-3.5 animate-spin"}),f=(s,n)=>n?i.jsx("span",{className:"sr-only",children:s}):s;function S({actions:s=[],destructive:n,className:l}){const[r,o]=y.useState(!1);return r&&n?.confirm?i.jsxs("div",{className:m("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?t():void 0,onClick:()=>{n.busy||n.onClick()},children:n.busy?n.busyLabel??"Working…":n.confirm.confirmLabel??n.label})]}):i.jsxs("div",{className:m("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?t():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?t():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:""},z=s=>{const n=x(),{pushError:l}=C(),{data:r}=h({...j(),staleTime:1/0}),o=y.useMemo(()=>{if(!s||!r)return c;const e=r.accounts.find(b=>b.accountId===s);return e?{html:e.signatureHtml??"",plainText:e.signaturePlainText??""}:c},[s,r]),a=L({...E(),onSuccess:()=>{n.invalidateQueries({queryKey:T()})},onError:e=>{l(k("Couldn't save signature","The signature wasn't saved.",e))}}),g=y.useCallback((e,b)=>{s&&a.mutate({path:{accountId:s},body:{signatureHtml:e,signaturePlainText:b}})},[s,a]);return{signature:o,setSignature:g,isSaving:a.isPending}};export{S as R,z as u};
package/index.html CHANGED
@@ -2,7 +2,7 @@
2
2
  <html lang="en">
3
3
  <head>
4
4
  <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
6
6
  <title>Remit</title>
7
7
  <!--
8
8
  Installability. Keep in sync with harness/index.html, which is the
@@ -38,8 +38,8 @@
38
38
  } catch (_) {}
39
39
  })();
40
40
  </script>
41
- <script type="module" crossorigin src="/assets/index-CiEaS41j.js"></script>
42
- <link rel="stylesheet" crossorigin href="/assets/index-BVVs8455.css">
41
+ <script type="module" crossorigin src="/assets/index-CDilPMTC.js"></script>
42
+ <link rel="stylesheet" crossorigin href="/assets/index-DidEu5F1.css">
43
43
  </head>
44
44
  <body>
45
45
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/web-client-dist",
3
- "version": "0.0.276",
3
+ "version": "0.0.278",
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 ot,j as t,d as R,bY as W,l as rt,r as c,e as pt,cb as I,bZ as F,aa as ht,aI as V,bT as xt,bW as ft,aF as K,au as Y,aQ as yt,B as N,L as D,bV as gt,b_ as vt,E as Q,c6 as bt,o as jt}from"./index-CiEaS41j.js";import{K as St}from"./kbd-FhAgSVFv.js";import{c as wt,M as kt}from"./account-form-helpers-CiMqlmbr.js";const X=ot("AtSign",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]]);const Nt=ot("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);function Ct({url:e}){return t.jsxs("p",{className:"text-2xs text-fg-subtle",children:["Stored encrypted, used only to connect to your mail server."," ",e?t.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"How to create an app password"}):t.jsx("span",{children:"Check your provider's help for app password instructions."})]})}function Et({raised:e,className:r,...s}){return t.jsx("div",{className:R("rounded-sm border border-line bg-surface",e?"bg-surface-raised shadow-sm":"",r),...s})}function Z({value:e,defaultValue:r,onValueChange:s,...n}){return s?t.jsxs(W,{value:e,onChange:a=>s(a.target.value),...n,children:[t.jsx("option",{value:"tls",children:"TLS/SSL"}),t.jsx("option",{value:"starttls",children:"STARTTLS"}),t.jsx("option",{value:"none",children:"None (insecure)"})]}):t.jsxs(W,{defaultValue:r??e,...n,children:[t.jsx("option",{value:"tls",children:"TLS/SSL"}),t.jsx("option",{value:"starttls",children:"STARTTLS"}),t.jsx("option",{value:"none",children:"None (insecure)"})]})}function q(e){return{tls:e==="tls",startTls:e==="starttls"}}function Tt({steps:e,activeStep:r}){return t.jsx("ol",{className:"flex items-center gap-1",children:e.map((s,n)=>{const a=n<r,o=n===r;return t.jsxs("li",{className:"flex items-center gap-1",children:[n>0&&t.jsx("span",{className:"h-px w-5 bg-line","aria-hidden":!0}),t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:R("flex size-5 items-center justify-center rounded-full text-2xs font-semibold tabular-nums",a&&"bg-accent text-accent-fg",o&&"bg-accent-soft text-accent ring-1 ring-accent",!a&&!o&&"bg-surface-sunken text-fg-subtle"),children:a?t.jsx(rt,{className:"size-3"}):n+1}),t.jsx("span",{className:R("hidden text-2xs sm:inline",o?"font-medium text-fg":"text-fg-subtle"),children:s})]})]},s)})})}function L({steps:e,activeStep:r,title:s,subtitle:n,children:a,footer:o,hideSteps:l}){return t.jsxs("div",{className:"flex min-h-dvh w-full flex-col items-center overflow-y-auto bg-canvas px-8 pb-8 pt-8 font-sans text-fg sm:pt-[30vh]",children:[!l&&t.jsx("div",{className:"mb-5 w-full max-w-xl",children:t.jsx(Tt,{steps:e,activeStep:r})}),t.jsxs(Et,{raised:!0,className:"w-full max-w-xl",children:[t.jsxs("div",{className:"px-5 pt-5",children:[t.jsx("h1",{className:"text-xl font-semibold text-fg",children:s}),n&&t.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:n})]}),t.jsx("div",{className:"px-5 py-5",children:a}),o&&t.jsx("div",{className:"flex items-center justify-between gap-3 border-t border-line px-5 py-3",children:o})]})]})}const Pt="Coming soon — use IMAP for now.";function U({name:e,description:r,icon:s,comingSoon:n,selected:a,onSelect:o}){const[l,p]=c.useState(!1),i=()=>{if(o){o();return}n&&p(!0)};return t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsxs("button",{type:"button",onClick:i,"aria-disabled":n||void 0,className:R("flex flex-col items-start gap-2 rounded-sm border p-3 text-left transition-colors",a?"border-accent-2 bg-accent-2-soft":"border-line bg-surface hover:border-line-strong",n&&"opacity-55"),children:[t.jsx("span",{className:R("text-fg-muted",a&&"text-accent-2"),children:s}),t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-semibold text-fg",children:e}),n&&t.jsx("span",{className:"rounded-full bg-surface-sunken px-1.5 py-0.5 text-2xs text-fg-subtle",children:"soon"})]}),t.jsx("span",{className:"text-xs text-fg-subtle",children:r})]}),l&&t.jsx("p",{className:"text-2xs text-fg-subtle",children:Pt})]})}function J({legend:e,badge:r,host:s,port:n,security:a,readOnly:o,onHostChange:l,onPortChange:p,onSecurityChange:i,hostPlaceholder:f,portPlaceholder:w}){const b=c.useId(),y=c.useId(),j=c.useId();return t.jsxs("fieldset",{children:[t.jsxs("legend",{className:"flex items-center gap-2 text-sm font-semibold text-fg",children:[e,r&&t.jsx(pt,{tone:r.tone,children:r.label})]}),t.jsxs("div",{className:"mt-2 grid grid-cols-1 gap-3 sm:grid-cols-[1fr_6rem_8rem] sm:gap-2",children:[t.jsxs("div",{children:[t.jsx(I,{htmlFor:b,children:"Host"}),l?t.jsx(F,{id:b,readOnly:o,value:s,onChange:x=>l(x.target.value),placeholder:f}):t.jsx(F,{id:b,readOnly:o,defaultValue:s,placeholder:f})]}),t.jsxs("div",{children:[t.jsx(I,{htmlFor:y,children:"Port"}),p?t.jsx(F,{id:y,readOnly:o,value:n,onChange:x=>p(x.target.value),placeholder:w}):t.jsx(F,{id:y,readOnly:o,defaultValue:n,placeholder:w})]}),t.jsxs("div",{children:[t.jsx(I,{htmlFor:j,children:"Security"}),i?t.jsx(Z,{id:j,value:a,onValueChange:i}):t.jsx(Z,{id:j,defaultValue:a})]})]})]})}function _({label:e,detail:r,state:s}){return t.jsxs("div",{className:"flex items-start gap-3 py-2",children:[t.jsxs("span",{className:R("mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full text-2xs",s==="ok"&&"bg-positive text-accent-fg",s==="failed"&&"bg-danger text-accent-fg",s==="running"&&"border border-accent text-accent",s==="pending"&&"border border-line text-fg-subtle"),children:[s==="ok"&&t.jsx(rt,{className:"size-3"}),s==="failed"&&"!",s==="running"&&t.jsx("span",{className:"size-2 animate-pulse rounded-full bg-accent"})]}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:R("text-sm",s==="failed"?"font-medium text-danger":"text-fg"),children:e}),r&&t.jsx("div",{className:"mt-0.5 text-xs text-fg-subtle",children:r})]})]})}const At={"gmail.com":{imap:{host:"imap.gmail.com",port:993,security:"tls"},smtp:{host:"smtp.gmail.com",port:587,security:"starttls"},source:"provider-table"},"googlemail.com":{imap:{host:"imap.gmail.com",port:993,security:"tls"},smtp:{host:"smtp.gmail.com",port:587,security:"starttls"},source:"provider-table"},"outlook.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"hotmail.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"live.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"msn.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"icloud.com":{imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},source:"provider-table"},"me.com":{imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},source:"provider-table"},"mac.com":{imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},source:"provider-table"},"fastmail.com":{imap:{host:"imap.fastmail.com",port:993,security:"tls"},smtp:{host:"smtp.fastmail.com",port:465,security:"tls"},source:"provider-table"},"fastmail.fm":{imap:{host:"imap.fastmail.com",port:993,security:"tls"},smtp:{host:"smtp.fastmail.com",port:465,security:"tls"},source:"provider-table"},"yahoo.com":{imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},source:"provider-table"},"yahoo.co.uk":{imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},source:"provider-table"},"ymail.com":{imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},source:"provider-table"},"aol.com":{imap:{host:"imap.aol.com",port:993,security:"tls"},smtp:{host:"smtp.aol.com",port:465,security:"tls"},source:"provider-table"},"zoho.com":{imap:{host:"imap.zoho.com",port:993,security:"tls"},smtp:{host:"smtp.zoho.com",port:465,security:"tls"},source:"provider-table"},"gmx.com":{imap:{host:"imap.gmx.com",port:993,security:"tls"},smtp:{host:"smtp.gmx.com",port:587,security:"starttls"},source:"provider-table"},"gmx.net":{imap:{host:"imap.gmx.net",port:993,security:"tls"},smtp:{host:"mail.gmx.net",port:587,security:"starttls"},source:"provider-table"},"gmx.de":{imap:{host:"imap.gmx.net",port:993,security:"tls"},smtp:{host:"mail.gmx.net",port:587,security:"starttls"},source:"provider-table"},"web.de":{imap:{host:"imap.web.de",port:993,security:"tls"},smtp:{host:"smtp.web.de",port:587,security:"starttls"},source:"provider-table"},"mail.com":{imap:{host:"imap.mail.com",port:993,security:"tls"},smtp:{host:"smtp.mail.com",port:465,security:"tls"},source:"provider-table"},"hey.com":{imap:{host:"imap.hey.com",port:993,security:"tls"},smtp:{host:"smtp.hey.com",port:465,security:"tls"},source:"provider-table"},"tutanota.com":{imap:{host:"mail.tutanota.com",port:993,security:"tls"},smtp:{host:"mail.tutanota.com",port:465,security:"tls"},source:"provider-table"},"tuta.io":{imap:{host:"mail.tutanota.com",port:993,security:"tls"},smtp:{host:"mail.tutanota.com",port:465,security:"tls"},source:"provider-table"},"posteo.de":{imap:{host:"posteo.de",port:993,security:"tls"},smtp:{host:"posteo.de",port:465,security:"tls"},source:"provider-table"},"runbox.com":{imap:{host:"imap.runbox.com",port:993,security:"tls"},smtp:{host:"smtp.runbox.com",port:587,security:"starttls"},source:"provider-table"},"mailbox.org":{imap:{host:"imap.mailbox.org",port:993,security:"tls"},smtp:{host:"smtp.mailbox.org",port:465,security:"tls"},source:"provider-table"},"hushmail.com":{imap:{host:"imap.hushmail.com",port:993,security:"tls"},smtp:{host:"smtp.hushmail.com",port:465,security:"tls"},source:"provider-table"}},It={"gmail.com":"https://support.google.com/accounts/answer/185833","googlemail.com":"https://support.google.com/accounts/answer/185833","yahoo.com":"https://help.yahoo.com/kb/generate-manage-third-party-passwords-sln15241.html","icloud.com":"https://support.apple.com/en-us/102654","me.com":"https://support.apple.com/en-us/102654","mac.com":"https://support.apple.com/en-us/102654","fastmail.com":"https://www.fastmail.help/hc/en-us/articles/360058752854","fastmail.fm":"https://www.fastmail.help/hc/en-us/articles/360058752854","outlook.com":"https://support.microsoft.com/en-us/account-billing/manage-app-passwords-for-two-step-verification-d6dc8c6d-4bf7-4851-ad95-6d07799387e9","hotmail.com":"https://support.microsoft.com/en-us/account-billing/manage-app-passwords-for-two-step-verification-d6dc8c6d-4bf7-4851-ad95-6d07799387e9","zoho.com":"https://help.zoho.com/portal/en/kb/zoho-mail/client-configuration/imap-access/articles/zoho-mail-app-passwords"};function at(e){try{const s=new DOMParser().parseFromString(e,"application/xml");if(s.querySelector("parsererror"))return null;const n=s.querySelectorAll("incomingServer[type='imap']"),a=s.querySelectorAll("outgoingServer[type='smtp']");if(!n.length||!a.length)return null;const o=n[0],l=a[0],p=o.querySelector("hostname")?.textContent?.trim(),i=o.querySelector("port")?.textContent?.trim(),f=o.querySelector("socketType")?.textContent?.trim().toUpperCase(),w=l.querySelector("hostname")?.textContent?.trim(),b=l.querySelector("port")?.textContent?.trim(),y=l.querySelector("socketType")?.textContent?.trim().toUpperCase();if(!p||!i||!w||!b)return null;const j=x=>x==="SSL"||x==="TLS"||x==="SSL/TLS"?"tls":x==="STARTTLS"?"starttls":"none";return{imap:{host:p,port:Number.parseInt(i,10),security:j(f)},smtp:{host:w,port:Number.parseInt(b,10),security:j(y)},source:"mozilla-autoconfig"}}catch{return null}}async function Lt(e,r){try{const s=`https://autoconfig.thunderbird.net/v1.1/${e}`,n=await fetch(s,{signal:r});if(!n.ok)return null;const a=await n.text(),o=at(a);return o||null}catch{return null}}async function Mt(e,r){try{const s=`https://autoconfig.${e}/mail/config-v1.1.xml`,n=await fetch(s,{signal:r});if(!n.ok)return null;const a=await n.text(),o=at(a);return o?{...o,source:"domain-autoconfig"}:null}catch{return null}}function Ft(e){return{imap:{host:`imap.${e}`,port:993,security:"tls"},smtp:{host:`smtp.${e}`,port:587,security:"starttls"},source:"heuristic"}}async function Ot(e,r=1500){const s=e.indexOf("@");if(s===-1)return null;const n=e.slice(s+1).toLowerCase();if(!n)return null;const a=At[n];if(a)return a;const o=new AbortController,l=setTimeout(()=>o.abort(),r);try{const p=await Lt(n,o.signal);if(p)return p;const i=await Mt(n,o.signal);if(i)return i}finally{clearTimeout(l)}return Ft(n)}function zt(e){const r=e.indexOf("@");return r===-1?"Looking up server settings…":`Looking up settings for ${e.slice(r+1)}…`}function nt(e){const r=e.indexOf("@");if(r===-1)return;const s=e.slice(r+1).toLowerCase();return It[s]}const it=[{id:"icloud",label:"iCloud",username:"full-email",imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},passwordHelp:{text:"iCloud requires an app-specific password, not your Apple ID password. Generate one under Sign-In & Security → App-Specific Passwords.",url:"https://support.apple.com/en-us/102654"}},{id:"yahoo",label:"Yahoo",username:"full-email",imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},passwordHelp:{text:"Yahoo requires an app password, not your login password. Generate one under Account Security.",url:"https://help.yahoo.com/kb/generate-manage-third-party-passwords-sln15241.html"}},{id:"aol",label:"AOL",username:"full-email",imap:{host:"imap.aol.com",port:993,security:"tls"},smtp:{host:"smtp.aol.com",port:465,security:"tls"},passwordHelp:{text:"AOL requires an app password, not your login password. Generate one under Account Security.",url:"https://login.aol.com/account/security"}},{id:"fastmail",label:"Fastmail",username:"full-email",imap:{host:"imap.fastmail.com",port:993,security:"tls"},smtp:{host:"smtp.fastmail.com",port:465,security:"tls"},passwordHelp:{text:"Fastmail requires an app password, not your login password. Create one under Settings → Privacy & Security → App passwords.",url:"https://www.fastmail.help/hc/en-us/articles/360058752854"}}];function tt(e){return it.find(r=>r.id===e)}const Rt={"icloud.com":"icloud","me.com":"icloud","mac.com":"icloud","yahoo.com":"yahoo","yahoo.co.uk":"yahoo","ymail.com":"yahoo","aol.com":"aol","fastmail.com":"fastmail","fastmail.fm":"fastmail"};function _t(e){const r=e.indexOf("@");if(r===-1)return"";const s=e.slice(r+1).toLowerCase();return Rt[s]??""}const M=["Connector","Address","Servers","Credentials","Test","Sync"],O={connector:0,address:1,servers:2,credentials:3,test:4,sync:5},et={host:"",port:993,security:"tls"},st={host:"",port:587,security:"starttls"};function Ht({onStart:e}){return c.useEffect(()=>{const r=s=>{s.key==="Enter"&&e()};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[e]),t.jsx(L,{steps:M,activeStep:0,hideSteps:!0,title:"Welcome to Remit",subtitle:"One inbox for all your mail, with context about every message.",footer:t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:"text-2xs text-fg-subtle",children:[t.jsx(St,{children:"Enter"})," to continue"]}),t.jsx(N,{variant:"primary",onClick:e,children:"Add your first account"})]}),children:t.jsxs("div",{className:"flex flex-col items-start py-5",children:[t.jsx("span",{className:"flex size-14 items-center justify-center rounded-md bg-accent-soft",children:t.jsx(kt,{className:"size-7 text-accent"})}),t.jsx("p",{className:"mt-5 max-w-sm text-sm leading-relaxed text-fg-muted",children:"Remit syncs your existing mailboxes and tells you who is really writing to you — sender history, authenticity checks, and similar messages, right next to every email."})]})})}function $t({onContinue:e,onMicrosoft:r,onBack:s,showBack:n}){const[a,o]=c.useState("imap");c.useEffect(()=>{const p=i=>{i.key==="Enter"&&(a==="microsoft"?r():e()),i.key==="Escape"&&s()};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[e,r,s,a]);const l=()=>{a==="microsoft"?r():e()};return t.jsx(L,{steps:M,activeStep:O.connector,title:"How does this account connect?",subtitle:"Choose a sign-in method. IMAP works with any provider.",footer:t.jsxs(t.Fragment,{children:[n?t.jsx(N,{variant:"ghost",onClick:s,children:"Back"}):t.jsx("span",{}),t.jsx(N,{variant:"primary",onClick:l,children:a==="microsoft"?"Continue with Microsoft":"Continue with IMAP"})]}),children:t.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[t.jsx(U,{name:"IMAP / SMTP",description:"Any mail provider — Fastmail, iCloud, your own server.",icon:t.jsx(Nt,{className:"size-5"}),selected:a==="imap",onSelect:()=>o("imap")}),t.jsx(U,{name:"Gmail",description:"Sign in with Google. No app passwords.",icon:t.jsx(X,{className:"size-5"}),comingSoon:!0}),t.jsx(U,{name:"Outlook / Microsoft 365",description:"Sign in with Microsoft. Works with Outlook.com and work accounts.",icon:t.jsx(jt,{className:"size-5"}),selected:a==="microsoft",onSelect:()=>o("microsoft")})]})})}function Dt({onBack:e,onRedirecting:r}){const[s,n]=c.useState(""),[a,o]=c.useState(null),l=V({...bt(),onSuccess:i=>{r(),window.location.assign(i.authorizationUrl)},onError:i=>{o(i instanceof Error?i.message:"Failed to start sign-in")}}),p=()=>{o(null),l.mutate({body:{email:s.trim()||void 0}})};return c.useEffect(()=>{const i=f=>{f.key==="Enter"&&!l.isPending&&p(),f.key==="Escape"&&e()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[e,l.isPending]),t.jsx(L,{steps:M,activeStep:O.connector,title:"Sign in with Microsoft",subtitle:"You'll be redirected to Microsoft to sign in securely.",footer:t.jsxs(t.Fragment,{children:[t.jsx(N,{variant:"ghost",onClick:e,children:"Back"}),t.jsx(N,{variant:"primary",onClick:p,disabled:l.isPending,icon:l.isPending?t.jsx(D,{className:"size-4 animate-spin"}):void 0,children:l.isPending?"Redirecting…":"Sign in with Microsoft"})]}),children:t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{children:[t.jsx(I,{htmlFor:"microsoft-email",children:"Email address (optional)"}),t.jsx(F,{id:"microsoft-email",icon:t.jsx(X,{className:"size-4"}),placeholder:"you@outlook.com",value:s,onChange:i=>n(i.target.value),type:"email",autoComplete:"email"}),t.jsx("p",{className:"mt-1.5 text-2xs text-fg-subtle",children:"Pre-fills the Microsoft sign-in form. Leave blank to choose on the Microsoft page."})]}),a&&t.jsx(Q,{tone:"danger",children:a})]})})}function qt({initialEmail:e,initialDisplayName:r,onContinue:s,onBack:n}){const[a,o]=c.useState(e),[l,p]=c.useState(r),[i,f]=c.useState(!1),[w,b]=c.useState(""),[y,j]=c.useState(null),x=c.useCallback(async()=>{const g=a.trim();if(!g.includes("@")||!g.includes(".")){j("Enter a valid email address.");return}j(null),f(!0),b(zt(g));try{const m=await Ot(g);s(g,l.trim(),m)}finally{f(!1)}},[a,l,s]);return c.useEffect(()=>{const g=m=>{m.key==="Enter"&&!i&&x(),m.key==="Escape"&&n()};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[x,i,n]),t.jsx(L,{steps:M,activeStep:O.address,title:"What's the email address?",subtitle:"We'll detect the server settings for you.",footer:t.jsxs(t.Fragment,{children:[t.jsx(N,{variant:"ghost",onClick:n,children:"Back"}),t.jsx(N,{variant:"primary",disabled:i,onClick:()=>{x()},children:"Continue"})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx(I,{htmlFor:"onboarding-email",children:"Email address"}),t.jsx(F,{id:"onboarding-email",icon:t.jsx(X,{className:"size-4"}),placeholder:"you@example.com",value:a,onChange:g=>{o(g.target.value),j(null)},type:"email",autoComplete:"email"})]}),t.jsxs("div",{children:[t.jsx(I,{htmlFor:"onboarding-display-name",children:"Display name (optional)"}),t.jsx(F,{id:"onboarding-display-name",placeholder:"Alice",value:l,onChange:g=>p(g.target.value)}),t.jsx("p",{className:"mt-1.5 text-2xs text-fg-subtle",children:"What to call this account in Remit. Leave blank to use a name derived from the address."})]}),i&&t.jsxs("div",{className:"mt-3 flex items-center gap-2 text-xs text-fg-muted",children:[t.jsx(D,{className:"size-3.5 animate-spin text-accent"}),w]}),y&&!i&&t.jsx("div",{className:"mt-3",children:t.jsx(Q,{tone:"danger",children:y})})]})})}function Gt({email:e,imapConfig:r,smtpConfig:s,discovered:n,onContinue:a,onBack:o,onChange:l}){const[p,i]=c.useState(r),[f,w]=c.useState(s),[b,y]=c.useState(()=>_t(e)),[j,x]=c.useState(!1),[g,m]=c.useState(null),k=tt(b),d=k!==void 0&&!j,E=c.useCallback(h=>{y(h),x(!1),m(null);const u=tt(h);u&&(i({host:u.imap.host,port:u.imap.port,security:u.imap.security}),w({host:u.smtp.host,port:u.smtp.port,security:u.smtp.security}))},[]);c.useEffect(()=>{l(p,f)},[p,f,l]);const v=p.host.trim()!=="",S=c.useCallback(()=>{if(!v){m("Enter the IMAP host.");return}m(null),a()},[v,a]);c.useEffect(()=>{const h=u=>{u.key==="Enter"&&S(),u.key==="Escape"&&o()};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[S,o]);const T=e.split("@")[1]??"your domain",z=k?"Pick your provider to fill in the right settings — or choose Custom to enter them by hand.":n?"Found via autodiscovery — adjust anything that looks off.":`We couldn't detect settings for ${T} — enter them manually.`,P=d?{label:"preset",tone:"neutral"}:!k&&n?{label:"detected",tone:"positive"}:void 0,A=k?.passwordHelp.url??nt(e);return t.jsx(L,{steps:M,activeStep:O.servers,title:"Confirm server settings",subtitle:z,footer:t.jsxs(t.Fragment,{children:[t.jsx(N,{variant:"ghost",onClick:o,children:"Back"}),t.jsx(N,{variant:"primary",onClick:S,children:"Continue"})]}),children:t.jsxs("div",{className:"space-y-5",children:[g&&t.jsx(Q,{tone:"danger",children:g}),t.jsxs("div",{children:[t.jsx(I,{htmlFor:"provider-select",children:"Provider"}),t.jsxs(W,{id:"provider-select",value:b,onChange:h=>E(h.target.value),children:[t.jsx("option",{value:"",children:"Custom / other"}),it.map(h=>t.jsx("option",{value:h.id,children:h.label},h.id))]}),k&&t.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:d?t.jsxs(t.Fragment,{children:["Server settings are pre-filled for ",k.label," and locked."," ",t.jsx("button",{type:"button",className:"text-accent underline",onClick:()=>x(!0),children:"Advanced"})," ","lets you edit them by hand."]}):t.jsxs(t.Fragment,{children:["Editing ",k.label,"'s settings by hand."]})})]}),t.jsx(J,{legend:"IMAP — incoming",badge:P,readOnly:d,host:p.host,port:String(p.port),security:p.security,hostPlaceholder:"imap.example.com",portPlaceholder:"993",onHostChange:h=>{i(u=>({...u,host:h})),m(null)},onPortChange:h=>i(u=>({...u,port:Number(h)})),onSecurityChange:h=>i(u=>({...u,security:h}))}),t.jsx("p",{className:"text-2xs text-fg-subtle",children:"Sending (SMTP) is optional — leave it blank to set up a receive-only account and add sending later in Settings."}),t.jsx(J,{legend:"SMTP — outgoing (optional)",badge:P,readOnly:d,host:f.host,port:String(f.port),security:f.security,hostPlaceholder:"smtp.example.com",portPlaceholder:"587",onHostChange:h=>{w(u=>({...u,host:h})),m(null)},onPortChange:h=>w(u=>({...u,port:Number(h)})),onSecurityChange:h=>w(u=>({...u,security:h}))}),k&&t.jsxs("p",{className:"text-2xs text-fg-subtle",children:[k.passwordHelp.text," ",A&&t.jsx("a",{href:A,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"Get an app password"})]})]})})}function Bt({email:e,username:r,password:s,onContinue:n,onBack:a,onChange:o}){const[l,p]=c.useState(r||e),[i,f]=c.useState(s),[w,b]=c.useState(null),y=e.split("@")[1]??"",j=nt(e),x=l.trim()!==""&&i.trim()!=="";c.useEffect(()=>{o(l,i)},[l,i,o]);const g=c.useCallback(()=>{if(!x){b("Enter your username and password.");return}b(null),n()},[x,n]);return c.useEffect(()=>{const m=k=>{k.key==="Enter"&&g(),k.key==="Escape"&&a()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[g,a]),t.jsx(L,{steps:M,activeStep:O.credentials,title:`Sign in to ${y||"your mail server"}`,subtitle:"Many providers require an app password instead of your normal one.",footer:t.jsxs(t.Fragment,{children:[t.jsx(N,{variant:"ghost",onClick:a,children:"Back"}),t.jsx(N,{variant:"primary",onClick:g,children:"Test connection"})]}),children:t.jsxs("div",{className:"space-y-3",children:[w&&t.jsx("div",{className:"rounded-md bg-danger-soft px-3 py-2 text-sm text-danger",children:w}),t.jsxs("div",{children:[t.jsx(I,{htmlFor:"credentials-username",children:"Username"}),t.jsx(F,{id:"credentials-username",value:l,onChange:m=>{p(m.target.value),b(null)},autoComplete:"username"})]}),t.jsxs("div",{children:[t.jsx(I,{htmlFor:"credentials-password",children:"Password or app password"}),t.jsx(vt,{id:"credentials-password",value:i,onChange:m=>{f(m.target.value),b(null)},autoComplete:"current-password"})]}),t.jsx(Ct,{url:j})]})})}function Ut({email:e,imapConfig:r,smtpConfig:s,username:n,password:a,onSuccess:o,onBackToCredentials:l,onBackToServers:p}){const[i,f]=c.useState({imapState:"running",smtpState:"pending",phase:"running"}),[w,b]=c.useState(0),y=s.host.trim()!=="",j=q(r.security),x=q(s.security),g=V({...gt()});c.useEffect(()=>{let d=!1;const E=[];return f({imapState:"running",smtpState:"pending",phase:"running"}),g.mutate({body:{username:n,password:a,imapHost:r.host,imapPort:r.port,imapTls:j.tls,imapStartTls:j.startTls,smtpHost:s.host,smtpPort:s.port,smtpTls:x.tls,smtpStartTls:x.startTls}},{onSuccess:v=>{if(d)return;const S=v.imapSuccess,T=y?v.smtpSuccess:!0;f({imapState:S?"ok":"failed",smtpState:y?"running":"ok",imapDetail:S?`Connected — ${r.host}:${r.port}`:v.imapError,phase:"running"}),E.push(window.setTimeout(()=>{if(d)return;const z=A=>{const h=A?.toLowerCase()??"";return h.includes("auth")||h.includes("login")||h.includes("535")||h.includes("credential")},P=!S&&z(v.imapError)||S&&y&&!v.smtpSuccess&&z(v.smtpError);f({imapState:S?"ok":"failed",smtpState:y?v.smtpSuccess?"ok":"failed":"ok",imapDetail:S?`Connected — ${r.host}:${r.port}`:v.imapError,smtpDetail:y?v.smtpSuccess?`Connected — ${s.host}:${s.port}`:v.smtpError:"Not set up — receive-only",rawError:S?y&&!v.smtpSuccess?v.smtpError:void 0:v.imapError,phase:S&&T?"success":P?"auth-failure":"network-failure"}),S&&T&&E.push(window.setTimeout(()=>{d||o()},800))},400))},onError:v=>{if(d)return;const S=v instanceof Error?v.message:"Connection failed";f({imapState:"failed",smtpState:"failed",imapDetail:S,smtpDetail:S,rawError:S,phase:"network-failure"})}}),()=>{d=!0;for(const v of E)window.clearTimeout(v)}},[w]);const{phase:m}=i;c.useEffect(()=>{const d=E=>{E.key==="Escape"&&(m==="auth-failure"?l():m==="network-failure"&&p())};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[m,l,p]);const k=m==="auth-failure"?t.jsxs(t.Fragment,{children:[t.jsx(N,{variant:"ghost",onClick:l,children:"Back to credentials"}),t.jsx(N,{variant:"primary",onClick:()=>b(d=>d+1),children:"Retry"})]}):m==="network-failure"?t.jsxs(t.Fragment,{children:[t.jsx(N,{variant:"ghost",onClick:p,children:"Back to servers"}),t.jsx(N,{variant:"primary",onClick:()=>b(d=>d+1),children:"Retry"})]}):m==="success"?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-2xs text-fg-subtle",children:"Connection verified"}),t.jsx(N,{variant:"primary",onClick:o,children:"Start syncing"})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-2xs text-fg-subtle",children:"Testing…"}),t.jsx("span",{})]});return t.jsx(L,{steps:M,activeStep:O.test,title:"Testing the connection",subtitle:`Checking ${e}`,footer:k,children:t.jsxs("div",{className:"divide-y divide-line",children:[t.jsx(_,{label:`IMAP — ${r.host}:${r.port}`,detail:i.imapDetail,state:i.imapState}),t.jsx(_,{label:y?`SMTP — ${s.host}:${s.port}`:"SMTP — sending",detail:y?i.smtpDetail:"Not set up — you can add sending later in Settings",state:i.smtpState}),(m==="auth-failure"||m==="network-failure")&&i.rawError&&t.jsxs("div",{className:"py-3",children:[m==="auth-failure"&&t.jsx("p",{className:"mb-2 text-xs text-fg-muted",children:"Check your password — many providers require an app password."}),t.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:i.rawError})]})]})})}const Wt=2e4;function Vt({email:e,displayName:r,imapConfig:s,smtpConfig:n,username:a,password:o,onGoToInbox:l}){const p=ht(),[i,f]=c.useState(null),[w,b]=c.useState(null),y=c.useRef(!1),j=q(s.security),x=q(n.security),g=V({...ft(),onSuccess:C=>{f(C.accountId),p.invalidateQueries({queryKey:xt()})},onError:C=>{b(C instanceof Error?C.message:"Failed to create account")}});c.useEffect(()=>{if(y.current)return;y.current=!0;const C=n.host.trim()!=="",H=wt({imapHost:s.host,smtpHost:n.host,smtpPort:n.port}),$=C?H??{smtpHost:n.host,smtpPort:n.port,smtpTls:x.tls,smtpStartTls:x.startTls}:null;g.mutate({body:{email:e,displayName:r||void 0,username:a!==e?a:void 0,password:o,imapHost:s.host,imapPort:s.port,imapTls:j.tls,imapStartTls:j.startTls,smtpHost:$?.smtpHost||void 0,smtpPort:$?.smtpPort||void 0,smtpTls:$?.smtpTls??!1,smtpStartTls:$?.smtpStartTls??!1}})},[]);const{data:m,isError:k}=K({...Y({path:{accountId:i??""}}),enabled:!!i,refetchInterval:C=>{const H=C.state.data?.syncPhase;return H==="complete"||H==="error"?!1:2e3}}),d=m?.syncPhase==="error",{data:E}=K({...yt(),enabled:!!i&&d}),v=E?.accounts.find(C=>C.accountId===i)?.lastError,S=m?.mailboxes.find(C=>C.fullPath==="INBOX"||C.fullPath==="Inbox"),T=m?.mailboxCountTotal??0,z=m?.mailboxCountSynced??0,P=S?.messagesTotal??0,A=S?.messagesSynced??0,h=P>0?A/P:0,u=m?.syncPhase,ct=d?"failed":u==="idle"||u===void 0||u==="discovering_mailboxes"?"running":T>0?"ok":"running",G=d?"failed":!u||u==="idle"||u==="discovering_mailboxes"?"pending":u==="syncing_inbox"||u==="syncing_others"?"running":"ok",B=d?"failed":!u||u==="idle"||u==="discovering_mailboxes"||u==="syncing_inbox"?"pending":u==="syncing_others"?"running":"ok",lt=A>0||S?.phase==="complete"||u==="complete"||d,[mt,ut]=c.useState(!1);c.useEffect(()=>{if(!i)return;const C=setTimeout(()=>ut(!0),Wt);return()=>clearTimeout(C)},[i]);const dt=!!i&&(lt||k||mt);return w?t.jsx(L,{steps:M,activeStep:O.sync,title:"Couldn't create account",subtitle:"Something went wrong saving your account.",footer:t.jsxs(t.Fragment,{children:[t.jsx("span",{}),t.jsx(N,{variant:"primary",onClick:()=>{y.current=!1,b(null),g.mutate({body:{email:e,displayName:r||void 0,username:a!==e?a:void 0,password:o,imapHost:s.host,imapPort:s.port,imapTls:j.tls,imapStartTls:j.startTls,smtpHost:n.host||void 0,smtpPort:n.port||void 0,smtpTls:x.tls,smtpStartTls:x.startTls}})},children:"Retry"})]}),children:t.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:w})}):t.jsx(L,{steps:M,activeStep:O.sync,title:`Syncing ${e}`,subtitle:"Newest mail first — you can start reading right away.",footer:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-2xs text-fg-subtle",children:"Sync continues in the background"}),dt?t.jsx(N,{variant:"primary",onClick:()=>i&&l(i),children:"Go to inbox"}):t.jsx(N,{variant:"primary",disabled:!0,icon:t.jsx(D,{className:"size-3.5 animate-spin"}),children:"Getting your mail…"})]}),children:g.isPending?t.jsxs("div",{className:"flex items-center gap-2 py-4 text-sm text-fg-muted",children:[t.jsx(D,{className:"size-4 animate-spin text-accent"}),"Creating your account…"]}):t.jsxs("div",{className:"space-y-3",children:[P>0&&t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-baseline justify-between text-xs",children:[t.jsx("span",{className:"font-medium text-fg",children:"INBOX"}),t.jsxs("span",{className:"text-fg-subtle tabular-nums",children:[A.toLocaleString()," / ",P.toLocaleString()," ","messages"]})]}),t.jsx("div",{className:"mt-1 h-1.5 overflow-hidden rounded-full bg-surface-sunken",children:t.jsx("div",{className:"h-full rounded-full bg-accent transition-all duration-500",style:{width:`${Math.max(2,h*100)}%`}})})]}),t.jsxs("div",{className:"divide-y divide-line",children:[t.jsx(_,{label:"Mailboxes discovered",detail:T>0?`${T} mailbox${T===1?"":"es"} found`:"Discovering…",state:ct}),t.jsx(_,{label:"INBOX",detail:G==="ok"?`${A.toLocaleString()} messages synced`:G==="running"?"Syncing newest first…":"Queued",state:G}),z>1||u==="syncing_others"||u==="complete"?t.jsx(_,{label:"Other mailboxes",detail:B==="ok"?`${z-1} mailboxes synced`:B==="running"?"Syncing…":"Queued",state:B}):null]}),d&&t.jsxs("div",{className:"mt-2 space-y-2",children:[t.jsxs("p",{className:"text-xs text-danger",children:["Sync stalled. The account is still active —"," ",t.jsx("button",{type:"button",className:"underline",onClick:()=>{p.invalidateQueries({queryKey:Y({path:{accountId:i??""}}).queryKey})},children:"retry"})]}),v&&t.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:v})]})]})})}function Yt({skipWelcome:e=!1,onComplete:r,onCancel:s}){const[n,a]=c.useState(e?"connector":"welcome"),[o,l]=c.useState({email:"",displayName:"",imapConfig:et,smtpConfig:st,username:"",password:"",discoveryResult:null,discovered:!1,createdAccountId:null}),p=c.useCallback(()=>a("connector"),[]),i=c.useCallback(()=>a("address"),[]),f=c.useCallback(()=>a("microsoft-email"),[]),w=c.useCallback(()=>{e?s?.():a("welcome")},[e,s]),b=c.useCallback((m,k,d)=>{let E=et,v=st,S=!1;d&&(S=d.source!=="heuristic",E={host:d.imap.host,port:d.imap.port,security:d.imap.security},v={host:d.smtp.host,port:d.smtp.port,security:d.smtp.security}),l(T=>({...T,email:m,displayName:k,imapConfig:E,smtpConfig:v,discoveryResult:d,discovered:S,username:m})),a("servers")},[]),y=c.useCallback((m,k)=>{l(d=>({...d,imapConfig:m,smtpConfig:k}))},[]),j=c.useCallback((m,k)=>{l(d=>({...d,username:m,password:k}))},[]),x=c.useCallback(()=>a("sync"),[]),g=c.useCallback(m=>{r(m)},[r]);switch(n){case"welcome":return t.jsx(Ht,{onStart:p});case"connector":return t.jsx($t,{onContinue:i,onMicrosoft:f,onBack:w,showBack:!e});case"microsoft-email":return t.jsx(Dt,{onBack:()=>a("connector"),onRedirecting:()=>{}});case"address":return t.jsx(qt,{initialEmail:o.email,initialDisplayName:o.displayName,onContinue:b,onBack:()=>a("connector")});case"servers":return t.jsx(Gt,{email:o.email,imapConfig:o.imapConfig,smtpConfig:o.smtpConfig,discovered:o.discovered,onContinue:()=>a("credentials"),onBack:()=>a("address"),onChange:y});case"credentials":return t.jsx(Bt,{email:o.email,username:o.username,password:o.password,onContinue:()=>a("test"),onBack:()=>a("servers"),onChange:j});case"test":return t.jsx(Ut,{email:o.email,imapConfig:o.imapConfig,smtpConfig:o.smtpConfig,username:o.username,password:o.password,onSuccess:x,onBackToCredentials:()=>a("credentials"),onBackToServers:()=>a("servers")});case"sync":return t.jsx(Vt,{email:o.email,displayName:o.displayName,imapConfig:o.imapConfig,smtpConfig:o.smtpConfig,username:o.username,password:o.password,onGoToInbox:g})}}export{Yt as O,it as P,tt as g,q as s};
@@ -1 +0,0 @@
1
- import{j as i,Q as nt,r as O,d as jt,X as Oe,R as X,aa as Gt,aI as Ne,bV as Ts,bT as Fe,bW as As,bX as _s,B as se,bY as Ps,bZ as ge,b_ as St,L as et,l as wt,as as Nt,b$ as Vs,c0 as ke,c1 as be,c2 as Tt,at as Es,c3 as ks,c4 as Ds,D as Zt,c5 as At,ap as Fs,aF as Cs,aQ as Os,c6 as Is,c7 as Rs,c8 as Ms,E as _t,e as Us,c9 as Pt,ca as Ls,T as Hs}from"./index-CiEaS41j.js";import{u as zs,R as Bs}from"./useSignature-BsS3enZI.js";import{S as qs,A as $s}from"./settings-screen-DbXrcUiB.js";import{g as Vt,P as Ws,s as Ue,O as Ks}from"./OnboardingWizard-C0UwUPbi.js";import{c as Ys,b as Et,d as Gs}from"./account-form-helpers-CiMqlmbr.js";import{D as Zs}from"./download-COLZC06N.js";import{E as Qs}from"./ErrorState-Bkp1gXXl.js";import{e as Xs}from"./format-CKZmh-Ru.js";import"./avatar-lSR-nesO.js";import"./kbd-FhAgSVFv.js";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 kt({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,Y=e=>e==null;const ot=e=>typeof e=="object";var z=e=>!Y(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"},ue={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},de={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},Xt="root",lt=["__proto__","constructor","prototype"],sr=/^\w*$/;var Re=e=>sr.test(e),M=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=Re(s)?[s]:We(s);if(a.some(d=>lt.includes(d)))return t;const c=a.reduce((d,n)=>Y(d)?void 0:d[n],e);return M(c)||c===e?M(e[s])?t:e[s]:c},fe=e=>typeof e=="boolean",ne=e=>typeof e=="function",F=(e,s,t)=>{let a=-1;const c=Re(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]!==ue.all&&(s._proxyFormState[n]=!a||ue.all),e[n]}});return c};const nr=$e?X.useLayoutEffect:X.useEffect;var G=e=>typeof e=="string",or=(e,s,t,a,c)=>G(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=>Y(e)||!ot(e);const Dt=(e,s)=>s.length===0&&!Array.isArray(e)&&!Qt(e);function me(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(Dt(e,a)||Dt(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))?!me(u,j,t):!Object.is(u,j))return!1}}return!0}var Le=e=>({isOnSubmit:!e||e===ue.onSubmit,isOnBlur:e===ue.onBlur,isOnChange:e===ue.onChange,isOnAll:e===ue.all,isOnTouch:e===ue.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 Ft=(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 Ct={value:!1,isValid:!1},Ot={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&&!M(e[0].attributes.value)?M(e[0].value)||e[0].value===""?Ot:{value:e[0].value,isValid:!0}:Ot:Ct}return Ct};const It={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,It):It;function Rt(e,s,t="validate"){if(G(e)||Array.isArray(e)&&e.every(G)||fe(e)&&!e)return{type:t,message:G(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,R=A=>{if(c&&J.reportValidity){const _=fe(A)?"":A||"";u?u.forEach(D=>D.setCustomValidity(_)):J.setCustomValidity(_),J.reportValidity()}},E={},oe=dt(n),re=Ie(n),he=oe||re,le=(b||ct(n))&&M(n.value)&&M(T)||Be(n)&&n.value===""||T===""||Array.isArray(T)&&!T.length,W=ut.bind(null,f,a,E),ee=(A,_,D,$=de.maxLength,w=de.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&&(!he&&(le||Y(T))||fe(T)&&!T||re&&!Jt(u).isValid||oe&&!es(u).isValid)){const{value:A,message:_}=G(j)?{value:!!j,message:j}:_e(j);if(A&&(E[f]={type:de.required,message:_,ref:J,...W(de.required,_)},!a))return R(_),E}if(!le&&(!Y(H)||!Y(I))){let A,_;const D=_e(I),$=_e(H);if(!Y(T)&&!isNaN(T)){const w=n.valueAsNumber||T&&+T;Y(D.value)||(A=w>D.value),Y($.value)||(_=w<$.value)}else{const w=n.valueAsDate||new Date(T),L=ve=>new Date(new Date().toDateString()+" "+ve),pe=n.type=="time",Z=n.type=="week";G(D.value)&&T&&(A=pe?L(T)>L(D.value):Z?T>D.value:w>new Date(D.value)),G($.value)&&T&&(_=pe?L(T)<L($.value):Z?T<$.value:w<new Date($.value))}if((A||_)&&(ee(!!A,D.message,$.message,de.max,de.min),!a))return R(E[f].message),E}if((P||V)&&!le&&(G(T)||d&&Array.isArray(T))){const A=_e(P),_=_e(V),D=!Y(A.value)&&T.length>+A.value,$=!Y(_.value)&&T.length<+_.value;if((D||$)&&(ee(D,A.message,_.message),!a))return R(E[f].message),E}if(C&&!le&&G(T)){const{value:A,message:_}=_e(C);if(qe(A)&&!T.match(A)&&(E[f]={type:de.pattern,message:_,ref:n,...W(de.pattern,_)},!a))return R(_),E}if(N){if(ne(N)){const A=await N(T,t),_=Rt(A,J);if(_&&(E[f]={..._,...W(de.validate,_.message)},!a))return R(_.message),E}else if(z(N)){let A={};for(const _ in N){if(!K(A)&&!a)break;const D=Rt(await N[_](T,t),J,_);D&&(A={...D,...W(_,D.message)},R(D.message),a&&(E[f]=A))}if(!K(A)&&(E[f]={ref:J,...A},!a))return E}}return R(!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(Y(e)){e=void 0;break}e=e[s[a]],a++}return e}function cr(e){for(const s in e)if(e.hasOwnProperty(s)&&!M(e[s]))return!1;return!0}function q(e,s){if(G(s)&&Object.prototype.hasOwnProperty.call(e,s))return delete e[s],e;const t=Array.isArray(s)?s:Re(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 Ut=()=>{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=>!M(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)):M(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))?(M(s)||tt(t[c])?t[c]=rt(d,Array.isArray(d)?[]:{},n):we(d,Y(s)?{}:s[c],t[c],n),os(t[c])&&st(t,c)):me(d,s[c])?st(t,c):t[c]=!0}return t}var ls=(e,{valueAsNumber:s,valueAsDate:t,setValueAs:a})=>M(e)?e:s?e===""?NaN:e&&+e:t&&G(e)?new Date(e):a?a(e):e;function Lt(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(M(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=>M(e)?e:qe(e)?e.source:z(e)?qe(e.value)?e.value.source:e.value:e;const Ht="AsyncFunction";var hr=e=>{if(!e||!e.validate)return!1;if(ne(e.validate))return e.validate.constructor.name===Ht;if(z(e.validate)){for(const s in e.validate)if(e.validate[s].constructor.name===Ht)return!0}return!1},pr=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function zt(e,s,t){const a=g(e,t);if(a||Re(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||ue.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:ue.onSubmit,reValidateMode:ue.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:Ut(),state:Ut()};let ie=0;const T=s.criteriaMode===ue.all,J=(r,o)=>l=>{clearTimeout(P[r]),P[r]=setTimeout(o,l)},R=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)},he=(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=Re(r)?[r]:We(r);let l=d,m=c;for(let h=0;h<o.length-1;h++){const x=o[h];if(l=Y(l)?l:l[x],m=Y(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=M(g(d,r)),y=g(d,r,M(l)?g(c,r):l);M(y)||m&&m.defaultChecked||o?F(d,r,o?y:Lt(h._f)):k(r,y),n.mount&&!n.action&&(R(),x&&t.isDirty&&(N.isDirty||f.isDirty)&&(Z()||(t.isDirty=!1,b.state.next({...t}))),e.shouldUnregister&&x&&!M(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=me(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)&&fe(o)&&t.isValid!==o;if(s.delayError&&l?(j[r]=J(r,()=>he(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?!me(h,l):h)||!K(m)||x){const y={...m,...x&&fe(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)))?Ft(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&&Me(`${Je}.${m}`,{message:G(h.message)?h.message:"",type:h.type||de.validate})}else G(l)||!l?Me(Je,{message:l||"",type:de.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),ye=N.validatingFields||N.isValidating||f.validatingFields||f.isValidating;Q&&ye&&E([v.name],!0);const xe=await Mt(y,u.disabled,d,T,s.shouldUseNativeValidation&&!o,U);if(Q&&ye&&E([v.name]),xe[v.name]&&(h.valid=!1,o)||(!o&&(g(xe,v.name)?U?Ft(t.errors,xe,v.name):F(t.errors,v.name,xe[v.name]):q(t.errors,v.name)),e.shouldUseNativeValidation&&xe[v.name]))break}!K(S)&&await L({context:h,onlyCheckValid:o,fields:S,name:x,eventType:m})}}return h.valid},pe=()=>{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))&&Ye(r)}u.unMount=new Set},Z=(r,o)=>(r&&o&&F(d,r,o),!me(n.mount?d:c,c)),ve=(r,o,l)=>or(r,u,{...n.mount?d:M(o)?c:G(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)&&Y(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=me(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||Y(v)||Q?k(r,v,l,m,h):ce(r,v,l,m,h)}if(!U&&!h){const Q=Qe(r,u),ye=m?d:B(d);b.state.next({...Q&&t,name:n.mount||Q?r:void 0,values:ye})}},ae=(r,o,l={})=>te(r,o,l,!1),Se=(r,o={})=>{const l=ne(r)?r(d):r;if(!me(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&&R()}},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())||me(y,g(d,l,y))};if(h){let y,v;const S=o.type?Lt(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,ye=Q||gr(U,g(t.touchedFields,l),t.isSubmitted,I,H),xe=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)||xe;if(!U&&b.state.next({name:l,type:r.type,...V?{values:B(d)}:{}}),ye)return(!Q||!t.isValid)&&(N.isValid||f.isValid)&&(s.mode==="onBlur"?U&&R():U||R()),ws&&b.state.next({name:l,...xe?{}:Ve});if(!s.resolver&&e.validate&&await w({name:l,eventType:r.type}),!U&&xe&&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=zt(t.errors,a,l),bt=zt(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 $(M(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)&&R()):m=l=await L({fields:a,name:r,eventType:Ae.TRIGGER});if(o.delayError&&s.delayError&&G(r)){const x=g(t.errors,r);x?(q(t.errors,r),j[r]=J(r,()=>he(r,x)),j[r](s.delayError)):(clearTimeout(P[r]),delete j[r])}return b.state.next({...!G(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)),M(r)?l:G(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:{}})},Me=(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}})),Ye=(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&&R()},pt=({disabled:r,name:o})=>{if(fe(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&&R()}},Ge=(r,o={})=>{let l=g(a,r);const m=fe(o.disabled)||fe(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:fe(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),Ge(r,o),u.registerName.delete(r),l=g(a,r);const y=M(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=>{fe(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)&&(M(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&&R()),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),ye=g(x,S);U&&!M(Q)?F(x,S,Q):!U&&!M(ye)&&ae(S,ye)}}else{if($e&&M(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&&!me(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:Ge,unregister:Ye,getFieldState:ft,handleSubmit:yt,setError:Me,_subscribe:ht,_runSchema:D,_updateIsValidating:E,_focusError:Ze,_getWatch:ve,_getDirty:Z,_setValid:R,_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:pe,_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:Ge,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||R(),b.state.next({...t,defaultValues:c})},clearErrors:mt,unregister:Ye,setError:Me,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&&!me(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 Bt=(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?Bt(a.ref,t,e):a&&a.refs&&a.refs.forEach(c=>Bt(c,t,e))}},qt=(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=$t(s).replace(/[.*+?^${}()|\\]/g,"\\$&");return e.some(a=>$t(a).match(`^${t}\\.\\d+`))};function $t(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 Wt(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(Wt(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:qt(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(Wt(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:qt(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="••••••••••",Rr=e=>{const s=e.smtpUsername?.trim();return s?s!==e.username:!1},Mr=Vs({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:Tt.number().int().min(1).max(65535),imapTls:ke(),imapStartTls:ke(),smtpHost:be().optional(),smtpPort:Tt.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=Gt(),d=!!t,[n,u]=O.useState(!1),[j,P]=O.useState(""),[V,H]=O.useState(!1),I=Vt(j),C=!!I&&!V,N=O.useRef(null),f=Sr({resolver:Cr(Mr),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=Rr(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}})},R=()=>{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=Ys({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:he,isSaving:le}=zs(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&&he(W,W)},[W,re.plainText,he]),_=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=Vt(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,pe=Et(b.data?.imapError,L),Z=Et(b.data?.smtpError,L);return(t?Or(t):!1)&&d?i.jsx(kt,{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(kt,{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(Ps,{id:"account-provider",value:j,onChange:p=>w(p.target.value),children:[i.jsx("option",{value:"",children:"Custom / other"}),Ws.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(ge,{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(ge,{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(ge,{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(St,{id:"account-password",...f.register("password",{onChange:()=>u(!0)}),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(ge,{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(ge,{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:Nt("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(wt,{className:"inline size-4 mr-1"}):i.jsx(Oe,{className:"inline size-4 mr-1"}),b.data.imapSuccess?"IMAP Connected":pe]})]})]}),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(ge,{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(ge,{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(ge,{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(St,{id:"smtp-password",...f.register("smtpPassword")})]})]}),i.jsx(se,{type:"button",variant:"secondary",onClick:R,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:Nt("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(wt,{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 Kt({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({...ks(),onSuccess:()=>{P(!0),setTimeout(()=>a(),2e3)}}),H=Ne(Ds()),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(Zs,{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(ge,{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}=Es();return i.jsx(s,{fallback:i.jsx(Kt,{...e,accountEmail:"",signOut:()=>{}}),children:({email:t,signOut:a})=>i.jsx(Kt,{...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=Xs(e.lastSyncAt);return s?`synced ${s}`:"never synced"}function Yt(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."]})]}),Yr=()=>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 oi(){const e=At.useSearch(),s=Fs({from:At.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),R=Gt(),{data:E,isPending:oe,isError:re,error:he,refetch:le}=Cs(Os());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),R.invalidateQueries({queryKey:Fe()}),s({search:{connected:void 0,oauthError:void 0,editAccountId:void 0,focusSmtp:void 0},replace:!0}))},[e.connected,s,R]),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({...Is(),onSuccess:w=>{window.location.assign(w.authorizationUrl)},onError:w=>{ie(w instanceof Error?w.message:"Failed to start reconnect"),J(null)}}),ee=Ne({...Rs(),onSuccess:()=>{R.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=Ls[w];L&&s({to:L})};return i.jsxs(qs,{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(_t,{tone:"success",variant:"soft","data-testid":"oauth-success-banner",onDismiss:()=>f(null),children:N}),b&&i.jsx(_t,{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(Us,{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(Pt,{className:"size-3.5"}),onClick:()=>u(!0),children:"Add account"})]}),oe?i.jsx(Yr,{}):re?i.jsx(Qs,{title:"Couldn't load accounts",error:he,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(Pt,{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),pe=w.authType==="oauthMicrosoft",Z=T===w.accountId&&W.isPending,ve=L&&pe?{label:"Reconnect",variant:"secondary",busy:Z,busyLabel:"Redirecting…",onClick:()=>{J(w.accountId),W.mutate({body:{email:w.email}})}}:Yt(w)==="error"?{label:"Reconnect",variant:"secondary",onClick:()=>P(w.accountId)}:{label:"Manage",variant:"ghost",onClick:()=>P(w.accountId)},p=i.jsx(Bs,{actions:[ve],destructive:{label:"Delete account",iconOnly:!0,icon:i.jsx(Hs,{className:"size-3.5"}),onClick:()=>C(w.accountId)}});return i.jsx($s,{label:qr(w),email:w.email,connector:pe?"Microsoft 365":"IMAP",syncLabel:$r(w),state:Yt(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(Ks,{skipWelcome:!0,onComplete:()=>{u(!1),R.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{oi as component,zr as mapOauthError};
@@ -1 +0,0 @@
1
- import{j as t,bU as o}from"./index-CiEaS41j.js";const n=()=>t.jsx(o,{to:"/settings/accounts"});export{n as component};