@remit/web-client-dist 0.0.253 → 0.0.255

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 (42) hide show
  1. package/assets/{ComposeBody-bNorSK-e.js → ComposeBody-BIAvZG37.js} +1 -1
  2. package/assets/{ConfirmDialog-phFT2zeT.js → ConfirmDialog-CJ_XGjU-.js} +1 -1
  3. package/assets/{ErrorState-D-aU8-M8.js → ErrorState-DqWIlgtd.js} +1 -1
  4. package/assets/{OnboardingWizard-hUgmYN_e.js → OnboardingWizard-DCE5PCFq.js} +1 -1
  5. package/assets/{account-form-helpers-BurFV5b5.js → account-form-helpers-DNDWmbrn.js} +1 -1
  6. package/assets/{accounts-C3hzcEZ8.js → accounts-J2_EhP28.js} +1 -1
  7. package/assets/{advanced-Dnpou7pm.js → advanced-DYOwQgGv.js} +1 -1
  8. package/assets/{appearance-DA5Fih_L.js → appearance-BbzTC-CD.js} +1 -1
  9. package/assets/{avatar-B2H0LXl_.js → avatar-DOyRPkhZ.js} +1 -1
  10. package/assets/{browser-ponyfill-C3w9RnT7.js → browser-ponyfill-DZZhSBoU.js} +1 -1
  11. package/assets/{circle-check-Sb0372DS.js → circle-check-DGaawOz1.js} +1 -1
  12. package/assets/{download-BBE_2uGx.js → download-VI7mAT7H.js} +1 -1
  13. package/assets/filters-CsA7Sgb_.js +1 -0
  14. package/assets/{flagged-Bj2Mg0d1.js → flagged-j7oJnC3S.js} +1 -1
  15. package/assets/folders-D44G1nyv.js +1 -0
  16. package/assets/index-BQN8gJvD.js +1 -0
  17. package/assets/{index-DPey6jym.css → index-BmBkz8X4.css} +1 -1
  18. package/assets/{index-Bjxf9SCP.js → index-C78eRKoR.js} +1 -1
  19. package/assets/{index-aOUXxkZn.js → index-j6RdmczT.js} +64 -64
  20. package/assets/{kbd-BVeb060c.js → kbd-B-AE9TsK.js} +1 -1
  21. package/assets/{labels-DTtgsjEX.js → labels-DAL6Ur0a.js} +1 -1
  22. package/assets/{mail-NzXdSIyF.js → mail-CsP3YU3W.js} +5 -5
  23. package/assets/move-options-D52G-uJK.js +1 -0
  24. package/assets/{onboarding-BZx17JBT.js → onboarding-BKlf_MY3.js} +1 -1
  25. package/assets/pencil-DraoEE9I.js +1 -0
  26. package/assets/{senders-CGEhOLZy.js → senders-pHAEksGF.js} +1 -1
  27. package/assets/settings-D3QZLMHk.js +1 -0
  28. package/assets/{settings-screen-BVzayABo.js → settings-screen-U0TK5NNm.js} +1 -1
  29. package/assets/{shield-check-KXl6adeq.js → shield-check-BVcJW4KM.js} +1 -1
  30. package/assets/{suggested-vips-C5KQYcWq.js → suggested-vips-xqmglNrN.js} +1 -1
  31. package/assets/{useDebouncedValue-CkJIieJj.js → useDebouncedValue-CtjcJZ09.js} +1 -1
  32. package/assets/{useFilters-cKnHkpoA.js → useFilters-AnPyolm2.js} +1 -1
  33. package/assets/{useLabels-MXpcXbeo.js → useLabels-Bi23tsav.js} +1 -1
  34. package/assets/{useSignature-DWEOWDFd.js → useSignature-D1IZUB-t.js} +1 -1
  35. package/index.html +2 -2
  36. package/package.json +1 -1
  37. package/assets/filters-DTYaA0Dw.js +0 -1
  38. package/assets/folders-BiIFdsuL.js +0 -1
  39. package/assets/index-CvJPY2Hw.js +0 -1
  40. package/assets/move-options-9AJl6K6-.js +0 -1
  41. package/assets/move-targets-DssqZI4G.js +0 -1
  42. package/assets/settings-Diewhouy.js +0 -1
@@ -0,0 +1 @@
1
+ import{aa as S,aA as C,aq as I,aD as L,aW as _,cH as A,r as b,a$ as x,av as D,ar as T,cI as v,aw as N}from"./index-j6RdmczT.js";const w={synced:"synced",failed:"failed"},W={uncategorized:"uncategorized",personal:"personal",newsletter:"newsletter",marketing:"marketing",automated:"automated",transactional:"transactional",social:"social"},Z={MoveToInbox:"MoveToInbox",MoveToJunk:"MoveToJunk"},F=3e4,k=1e3,$="The folder couldn't be created on the mail server. Please try again.",R="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=F,pollIntervalMs:n=k,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($);if(l()>=s)throw new Error(R);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 j(e){const t=S(),{data:a}=C({...I({path:{accountId:e??""}}),enabled:!!e}),o=L({...A(),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??"/",p=z({name:s,delimiter:h,parent:y,existingPaths:u.map(E=>E.fullPath)});if(p)throw new Error(p);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 ee=()=>{const{t:e}=D("mail",{useSuspense:!1});return b.useCallback((t,a)=>e(t,{defaultValue:a}),[e])},te=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))},q=(e,t)=>t.find(a=>a.mailboxId!=null&&a.mailboxId===e)?.role;function ae(e,t,a){if(X(e.fullPath))return{deletable:!1,reason:"inbox",message:"The inbox can't be deleted."};const o=q(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 U(e,t){return e.filter(a=>a.mailboxId!==t)}function oe(e){return{total:e,moved:0,phase:e===0?"moved":"moving"}}function ne(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 re(e,t){return{...e,phase:"failed",error:t}}function ie(e){return`Moved ${e.moved} of ${e.total}`}function se(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=v.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)?v.indexOf(a.get(n.mailboxId)??"inbox"):g,s=a.has(r.mailboxId)?v.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})})},le=e=>e[0]?.hierarchyDelimiter??"/",ce=({mailboxes:e,folderAppointments:t,currentMailboxId:a,excludeMailboxId:o,translator:n})=>{const r=H(e,t),l=T(t);return(o?U(r,o):r).map(i=>({id:i.mailboxId,label:N(i,l.get(i.mailboxId),n),path:i.fullPath,isCurrent:i.mailboxId===a}))};export{W as M,Z as P,j as a,ce as b,oe as c,re as d,ne as e,le as f,te as g,ae as h,se as i,ie as m,ee as u};
@@ -1 +1 @@
1
- import{bT as t,az as r,aa as a,r as i,j as s}from"./index-aOUXxkZn.js";import{O as c}from"./OnboardingWizard-hUgmYN_e.js";import"./kbd-BVeb060c.js";import"./account-form-helpers-BurFV5b5.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,az as r,aa as a,r as i,j as s}from"./index-j6RdmczT.js";import{O as c}from"./OnboardingWizard-DCE5PCFq.js";import"./kbd-B-AE9TsK.js";import"./account-form-helpers-DNDWmbrn.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};
@@ -0,0 +1 @@
1
+ import{a}from"./index-j6RdmczT.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 A,bZ as L,v as O,ca as $,aA as I,cP as q,aa as k,aD as C,cQ as M,b1 as P,B as S,S as Q,aH as R,X as B}from"./index-aOUXxkZn.js";import{K as m}from"./kbd-BVeb060c.js";import{S as G,a as E}from"./settings-screen-BVzayABo.js";import{E as V}from"./ErrorState-D-aU8-M8.js";import{u as D}from"./useDebouncedValue-CkJIieJj.js";import{d as K}from"./format-CKZmh-Ru.js";import"./avatar-B2H0LXl_.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"},F=e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"VIP"})," senders get priority surface in the daily brief and notification escalation, even when an account is quiet."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Muted"})," senders never notify and stay out of the brief. Their mail still syncs and stays searchable."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Blocked"})," senders never load images and go straight to junk."]}),e.jsxs("p",{children:["Tip: flag from the keyboard on any message — ",e.jsx(m,{children:"v"})," VIP,"," ",e.jsx(m,{children:"m"})," mute, ",e.jsx(m,{children:"b"})," block. Every rule an automation creates shows up here and can be removed."]})]});function H({query:t,onCount:r}){const{data:x,isPending:a,isError:d,error:y}=I(q()),g=k(),i=C({...P(),onSettled:()=>{g.invalidateQueries({queryKey:M()})}}),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=D(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:A,activeId:"senders",title:"Senders & Rules",description:"Per-sender preferences — set with one key from any message, managed here.",flush:!0,help:F,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(L,{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 A,bZ as L,v as O,ca as $,aA as I,cP as q,aa as k,aD as C,cQ as M,b1 as P,B as S,S as Q,aH as R,X as B}from"./index-j6RdmczT.js";import{K as m}from"./kbd-B-AE9TsK.js";import{S as G,a as E}from"./settings-screen-U0TK5NNm.js";import{E as V}from"./ErrorState-DqWIlgtd.js";import{u as D}from"./useDebouncedValue-CtjcJZ09.js";import{d as K}from"./format-CKZmh-Ru.js";import"./avatar-DOyRPkhZ.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"},F=e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"VIP"})," senders get priority surface in the daily brief and notification escalation, even when an account is quiet."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Muted"})," senders never notify and stay out of the brief. Their mail still syncs and stays searchable."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Blocked"})," senders never load images and go straight to junk."]}),e.jsxs("p",{children:["Tip: flag from the keyboard on any message — ",e.jsx(m,{children:"v"})," VIP,"," ",e.jsx(m,{children:"m"})," mute, ",e.jsx(m,{children:"b"})," block. Every rule an automation creates shows up here and can be removed."]})]});function H({query:t,onCount:r}){const{data:x,isPending:a,isError:d,error:y}=I(q()),g=k(),i=C({...P(),onSettled:()=>{g.invalidateQueries({queryKey:M()})}}),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=D(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:A,activeId:"senders",title:"Senders & Rules",description:"Per-sender preferences — set with one key from any message, managed here.",flush:!0,help:F,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(L,{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{j as t,bS as o}from"./index-j6RdmczT.js";const n=()=>t.jsx(o,{});export{n as component};
@@ -1 +1 @@
1
- import{a as z,r as g,j as e,d as m,B as x,X as j,e as S}from"./index-aOUXxkZn.js";import{M as B,C as N,A as w}from"./avatar-B2H0LXl_.js";const v=z("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);function L({items:l,activeId:t,title:i,description:n,children:r,help:s,helpOpen:d=!0,flush:o,onSelect:k,onToggleHelp:f,onBackToMail:h}){const[y,c]=g.useState(!1),[u,C]=g.useState(!1),b=!!s&&d,p=e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 pt-3 pb-1 text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Settings"}),e.jsx("nav",{className:"flex-1 overflow-y-auto px-2 py-1",children:l.map(a=>e.jsxs("button",{type:"button",onClick:()=>{k?.(a.id),c(!1)},className:m("flex min-h-11 w-full items-center gap-2 rounded-md px-2 py-1 text-left text-sm transition-colors lg:min-h-0",a.id===t?"bg-accent-2-soft font-medium text-accent-2":"text-fg-muted hover:bg-surface hover:text-fg"),children:[a.icon&&e.jsx("span",{className:m("shrink-0",a.id===t?"text-accent-2":"text-fg-subtle"),children:a.icon}),a.label]},a.id))})]});return e.jsxs("div",{className:"flex h-dvh w-full overflow-hidden bg-canvas font-sans text-fg",children:[e.jsxs("aside",{className:"hidden w-60 shrink-0 flex-col border-r border-line bg-surface-sunken lg:flex",children:[e.jsx("div",{className:"flex h-pane-header shrink-0 items-center border-b border-line px-2",children:e.jsxs("button",{type:"button",onClick:h,className:"flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-sm text-fg-muted hover:bg-surface hover:text-fg",children:[e.jsx(v,{className:"size-4 text-fg-subtle"}),"Back to mail"]})}),p]}),y&&e.jsxs("div",{className:"fixed inset-0 z-50 flex lg:hidden",children:[e.jsx("button",{type:"button","aria-label":"Close menu",className:"absolute inset-0 bg-canvas/60",onClick:()=>c(!1)}),e.jsxs("aside",{className:"relative flex w-72 max-w-[85%] flex-col border-r border-line bg-surface-sunken",children:[e.jsxs("div",{className:"flex h-pane-header shrink-0 items-center justify-between border-b border-line px-2",children:[e.jsxs("button",{type:"button",onClick:()=>{h?.(),c(!1)},className:"flex items-center gap-2 rounded-md px-2 py-1 text-left text-sm text-fg-muted hover:bg-surface hover:text-fg",children:[e.jsx(v,{className:"size-4 text-fg-subtle"}),"Back to mail"]}),e.jsx(x,{variant:"ghost",size:"sm",icon:e.jsx(j,{className:"size-4"}),onClick:()=>c(!1),"aria-label":"Close menu"})]}),p]})]}),e.jsxs("main",{className:"flex min-w-0 flex-1 flex-col",children:[e.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-3 border-b border-line px-3 lg:px-5",children:[e.jsx(x,{variant:"ghost",size:"sm",icon:e.jsx(B,{className:"size-4"}),className:"lg:hidden",onClick:()=>c(!0),"aria-label":"Open settings menu"}),e.jsx("h1",{className:"text-md font-semibold text-fg",children:i}),n&&e.jsx("p",{className:"hidden min-w-0 truncate text-xs text-fg-subtle lg:block",children:n}),s&&e.jsx(x,{variant:"ghost",size:"sm",icon:e.jsx(N,{className:"size-4"}),className:"ml-auto lg:hidden",onClick:()=>C(a=>!a),"aria-label":"Tips","aria-expanded":u}),s&&!b&&e.jsx(x,{variant:"ghost",size:"sm",icon:e.jsx(N,{className:"size-4"}),className:"hidden ml-auto lg:inline-flex",onClick:f,"aria-label":"Show tips"})]}),s&&u&&e.jsx("div",{className:"border-b border-line bg-surface-sunken px-row-inset py-3 text-xs leading-relaxed text-fg-muted lg:hidden",children:s}),o?e.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:r}):e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:e.jsx("div",{className:"max-w-2xl px-3 py-5 lg:px-5",children:e.jsx("div",{className:"space-y-5",children:r})})})]}),b&&e.jsxs("aside",{className:"hidden w-64 shrink-0 flex-col border-l border-line bg-surface-sunken lg:flex",children:[e.jsxs("header",{className:"flex h-pane-header shrink-0 items-center justify-between border-b border-line px-row-inset",children:[e.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Tips & tricks"}),e.jsx(x,{variant:"ghost",size:"sm",icon:e.jsx(j,{className:"size-3.5"}),onClick:f,"aria-label":"Collapse tips"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-row-inset py-3 text-xs leading-relaxed text-fg-muted",children:s})]})]})}function E({name:l,email:t,meta:i,caption:n,danger:r,trailing:s}){return e.jsxs("div",{className:"flex items-center gap-3 px-row-inset py-2 hover:bg-surface-sunken",children:[e.jsx("span",{className:m(r&&"rounded-full ring-2 ring-danger/40"),children:e.jsx(w,{name:l,email:t,size:"sm"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-col gap-0 sm:flex-row sm:items-baseline sm:gap-2",children:[e.jsx("span",{className:"truncate text-sm font-medium text-fg",children:l}),e.jsx("span",{className:"truncate text-2xs text-fg-subtle",children:t})]}),e.jsxs("div",{className:"text-xs text-fg-subtle",children:[i,n&&e.jsxs("span",{className:"text-fg-muted",children:[" · ",n]})]})]}),s&&e.jsx("div",{className:"shrink-0",children:s})]})}const O={healthy:{tone:"positive",label:"healthy"},error:{tone:"danger",label:"error"},muted:{tone:"neutral",label:"muted"}};function F({label:l,email:t,connector:i,syncLabel:n,state:r,errorDetail:s,trailing:d}){const o=O[r];return e.jsxs("div",{className:m("rounded-sm border border-line bg-surface",r==="muted"&&"opacity-65"),children:[e.jsxs("div",{className:"flex flex-col gap-3 px-row-inset py-3 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx(w,{name:l,email:t,size:"md"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-semibold text-fg",children:l}),e.jsx(S,{tone:o.tone,dot:!0,children:o.label})]}),e.jsxs("div",{className:"truncate text-xs text-fg-subtle",children:[t," · ",i," · ",n]})]})]}),d&&e.jsx("div",{className:"shrink-0",children:d})]}),s&&e.jsx("div",{className:"border-t border-line px-row-inset py-2",children:e.jsx("code",{className:"block rounded-xs bg-danger-soft px-2 py-1 text-2xs text-danger",children:s})})]})}export{F as A,L as S,E as a};
1
+ import{a as z,r as g,j as e,d as m,B as x,X as j,e as S}from"./index-j6RdmczT.js";import{M as B,C as N,A as w}from"./avatar-DOyRPkhZ.js";const v=z("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);function L({items:l,activeId:t,title:i,description:n,children:r,help:s,helpOpen:d=!0,flush:o,onSelect:k,onToggleHelp:f,onBackToMail:h}){const[y,c]=g.useState(!1),[u,C]=g.useState(!1),b=!!s&&d,p=e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 pt-3 pb-1 text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Settings"}),e.jsx("nav",{className:"flex-1 overflow-y-auto px-2 py-1",children:l.map(a=>e.jsxs("button",{type:"button",onClick:()=>{k?.(a.id),c(!1)},className:m("flex min-h-11 w-full items-center gap-2 rounded-md px-2 py-1 text-left text-sm transition-colors lg:min-h-0",a.id===t?"bg-accent-2-soft font-medium text-accent-2":"text-fg-muted hover:bg-surface hover:text-fg"),children:[a.icon&&e.jsx("span",{className:m("shrink-0",a.id===t?"text-accent-2":"text-fg-subtle"),children:a.icon}),a.label]},a.id))})]});return e.jsxs("div",{className:"flex h-dvh w-full overflow-hidden bg-canvas font-sans text-fg",children:[e.jsxs("aside",{className:"hidden w-60 shrink-0 flex-col border-r border-line bg-surface-sunken lg:flex",children:[e.jsx("div",{className:"flex h-pane-header shrink-0 items-center border-b border-line px-2",children:e.jsxs("button",{type:"button",onClick:h,className:"flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-sm text-fg-muted hover:bg-surface hover:text-fg",children:[e.jsx(v,{className:"size-4 text-fg-subtle"}),"Back to mail"]})}),p]}),y&&e.jsxs("div",{className:"fixed inset-0 z-50 flex lg:hidden",children:[e.jsx("button",{type:"button","aria-label":"Close menu",className:"absolute inset-0 bg-canvas/60",onClick:()=>c(!1)}),e.jsxs("aside",{className:"relative flex w-72 max-w-[85%] flex-col border-r border-line bg-surface-sunken",children:[e.jsxs("div",{className:"flex h-pane-header shrink-0 items-center justify-between border-b border-line px-2",children:[e.jsxs("button",{type:"button",onClick:()=>{h?.(),c(!1)},className:"flex items-center gap-2 rounded-md px-2 py-1 text-left text-sm text-fg-muted hover:bg-surface hover:text-fg",children:[e.jsx(v,{className:"size-4 text-fg-subtle"}),"Back to mail"]}),e.jsx(x,{variant:"ghost",size:"sm",icon:e.jsx(j,{className:"size-4"}),onClick:()=>c(!1),"aria-label":"Close menu"})]}),p]})]}),e.jsxs("main",{className:"flex min-w-0 flex-1 flex-col",children:[e.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-3 border-b border-line px-3 lg:px-5",children:[e.jsx(x,{variant:"ghost",size:"sm",icon:e.jsx(B,{className:"size-4"}),className:"lg:hidden",onClick:()=>c(!0),"aria-label":"Open settings menu"}),e.jsx("h1",{className:"text-md font-semibold text-fg",children:i}),n&&e.jsx("p",{className:"hidden min-w-0 truncate text-xs text-fg-subtle lg:block",children:n}),s&&e.jsx(x,{variant:"ghost",size:"sm",icon:e.jsx(N,{className:"size-4"}),className:"ml-auto lg:hidden",onClick:()=>C(a=>!a),"aria-label":"Tips","aria-expanded":u}),s&&!b&&e.jsx(x,{variant:"ghost",size:"sm",icon:e.jsx(N,{className:"size-4"}),className:"hidden ml-auto lg:inline-flex",onClick:f,"aria-label":"Show tips"})]}),s&&u&&e.jsx("div",{className:"border-b border-line bg-surface-sunken px-row-inset py-3 text-xs leading-relaxed text-fg-muted lg:hidden",children:s}),o?e.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:r}):e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:e.jsx("div",{className:"max-w-2xl px-3 py-5 lg:px-5",children:e.jsx("div",{className:"space-y-5",children:r})})})]}),b&&e.jsxs("aside",{className:"hidden w-64 shrink-0 flex-col border-l border-line bg-surface-sunken lg:flex",children:[e.jsxs("header",{className:"flex h-pane-header shrink-0 items-center justify-between border-b border-line px-row-inset",children:[e.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Tips & tricks"}),e.jsx(x,{variant:"ghost",size:"sm",icon:e.jsx(j,{className:"size-3.5"}),onClick:f,"aria-label":"Collapse tips"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-row-inset py-3 text-xs leading-relaxed text-fg-muted",children:s})]})]})}function E({name:l,email:t,meta:i,caption:n,danger:r,trailing:s}){return e.jsxs("div",{className:"flex items-center gap-3 px-row-inset py-2 hover:bg-surface-sunken",children:[e.jsx("span",{className:m(r&&"rounded-full ring-2 ring-danger/40"),children:e.jsx(w,{name:l,email:t,size:"sm"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-col gap-0 sm:flex-row sm:items-baseline sm:gap-2",children:[e.jsx("span",{className:"truncate text-sm font-medium text-fg",children:l}),e.jsx("span",{className:"truncate text-2xs text-fg-subtle",children:t})]}),e.jsxs("div",{className:"text-xs text-fg-subtle",children:[i,n&&e.jsxs("span",{className:"text-fg-muted",children:[" · ",n]})]})]}),s&&e.jsx("div",{className:"shrink-0",children:s})]})}const O={healthy:{tone:"positive",label:"healthy"},error:{tone:"danger",label:"error"},muted:{tone:"neutral",label:"muted"}};function F({label:l,email:t,connector:i,syncLabel:n,state:r,errorDetail:s,trailing:d}){const o=O[r];return e.jsxs("div",{className:m("rounded-sm border border-line bg-surface",r==="muted"&&"opacity-65"),children:[e.jsxs("div",{className:"flex flex-col gap-3 px-row-inset py-3 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx(w,{name:l,email:t,size:"md"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-semibold text-fg",children:l}),e.jsx(S,{tone:o.tone,dot:!0,children:o.label})]}),e.jsxs("div",{className:"truncate text-xs text-fg-subtle",children:[t," · ",i," · ",n]})]})]}),d&&e.jsx("div",{className:"shrink-0",children:d})]}),s&&e.jsx("div",{className:"border-t border-line px-row-inset py-2",children:e.jsx("code",{className:"block rounded-xs bg-danger-soft px-2 py-1 text-2xs text-danger",children:s})})]})}export{F as A,L as S,E as a};
@@ -1 +1 @@
1
- import{a as e}from"./index-aOUXxkZn.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-j6RdmczT.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-aOUXxkZn.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-j6RdmczT.js";const o=()=>t.jsx(e,{to:"/settings/senders",replace:!0});export{o as component};
@@ -1 +1 @@
1
- import{r as o}from"./index-aOUXxkZn.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-j6RdmczT.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 +1 @@
1
- import{r as c,j as M,d as w,aD as y,cr as T,aA as E,cs as z,bm as k,ct as R,cu as _,aa as N,cv as Y,cw as $,cx as j}from"./index-aOUXxkZn.js";const J=320,H="cubic-bezier(0.32, 0.9, 0.3, 1)",B=.5,U=.4,Q=360;function K(e){return Math.sign(e)*Math.sqrt(Math.abs(e))*4}function ce({open:e,onClose:t,children:r,dismissLabel:s="Dismiss"}){const i=c.useRef(null),[n,a]=c.useState(Q),[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 L=S<0?K(S):S;m(L)},[]),d=c.useCallback(()=>{const o=u.current;if(u.current=null,!o)return;const p=o.lastY-o.startY,S=o.velocity>B||p>n*U;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:w("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:w("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 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 q=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},le=()=>q("(min-width: 1024px)"),ue=(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"},de=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"})},D=(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",me=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}),fe=({mode:e,ruleScope:t})=>t==="standing"?"standing":t==="until"?"temporary":e==="selected"?"just-these":"all-like-these",pe=({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"?D(a??""):void 0}),A=(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}:{}}),W=new Set(["Complete","Failed"]),I=e=>e!==void 0&&W.has(e),V=1e3,G=15e3,X=e=>{const t=Math.max(0,e),r=V*2**t;return Math.min(r,G)},Z=(e,t,r)=>{if(e)return{kind:r?"restartFailed":"startFailed",error:e};if(t)return{kind:"statusUnreadable",error:t}},he=e=>{const[t,r]=c.useState(),s=y({...T(),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 I(x)?!1:X(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=I(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:Z(s.error,n.error,!!u)}},ge=["From","Subject","HasWords","ListId","FromDomain"],ee=e=>{const t=e.trim(),r=t.match(/<([^>]+)>/);return(r?r[1]:t).trim().toLowerCase()},be=(e,t)=>e==="ListId"?ee(t):t.trim(),te=e=>e==="all"?"And":"Or",re=(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:te(e.matchOperator),literalClauses:s}},se=e=>e.anchorMessageId!==void 0||!e.literalClauses.some(t=>t.field==="HasWords"),ne=e=>JSON.stringify({anchor:e.anchorMessageId??null,operator:e.matchOperator,clauses:e.literalClauses.map(t=>`${t.field} ${t.value}`)}),ve=(e,t)=>{const r=re(e,t);return{...r.anchorMessageId?{anchorMessageId:r.anchorMessageId}:{},matchOperator:r.matchOperator,literalClauses:r.literalClauses,moveMailboxId:e.moveMailboxId,labelId:e.labelId,expiresAt:e.scope==="until"?D(e.until??""):void 0}},ae=(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},ie=350,Se=(e,t,r)=>{const s=y(k()),{mutateAsync:i}=s,n=ne(t),[a,l]=c.useState(()=>({})),m=c.useRef(t);m.current=t;const u=c.useRef(n),f=se(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}))})},ie);return()=>clearTimeout(b)},[e,f,n,a.previewedSignature,a.errorSignature,i]),f?{count:ae(a,n),matchedIds:a.previewedSignature===n?a.matchedIds??[]:[]}:{count:{status:"error",reason:R},matchedIds:[]}},F=e=>$({path:{accountId:e}}),Me=e=>{const t=E({..._({path:{accountId:e??""}}),enabled:!!e});return{filters:t.data?.items??[],isPending:t.isPending,isError:t.isError,error:t.error,refetch:t.refetch}},xe=e=>{const t=N(),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:A(l,m,u)})},[e,s]),a=c.useCallback(async(l,m,u)=>e?i({path:{accountId:e},body:A(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}},Ce=e=>{const t=N(),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{ce as B,C as N,ge as S,q as a,P as b,Se as c,he as d,xe as e,pe as f,me as g,F as h,ve as i,ue as j,de as k,Me as l,Ce as m,be as n,fe as o,D as p,re as r,le as u};
1
+ import{r as c,j as M,d as w,aD as y,cr as T,aA as E,cs as z,bm as k,ct as R,cu as _,aa as N,cv as Y,cw as $,cx as j}from"./index-j6RdmczT.js";const J=320,H="cubic-bezier(0.32, 0.9, 0.3, 1)",B=.5,U=.4,Q=360;function K(e){return Math.sign(e)*Math.sqrt(Math.abs(e))*4}function ce({open:e,onClose:t,children:r,dismissLabel:s="Dismiss"}){const i=c.useRef(null),[n,a]=c.useState(Q),[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 L=S<0?K(S):S;m(L)},[]),d=c.useCallback(()=>{const o=u.current;if(u.current=null,!o)return;const p=o.lastY-o.startY,S=o.velocity>B||p>n*U;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:w("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:w("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 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 q=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},le=()=>q("(min-width: 1024px)"),ue=(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"},de=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"})},D=(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",me=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}),fe=({mode:e,ruleScope:t})=>t==="standing"?"standing":t==="until"?"temporary":e==="selected"?"just-these":"all-like-these",pe=({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"?D(a??""):void 0}),A=(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}:{}}),W=new Set(["Complete","Failed"]),I=e=>e!==void 0&&W.has(e),V=1e3,G=15e3,X=e=>{const t=Math.max(0,e),r=V*2**t;return Math.min(r,G)},Z=(e,t,r)=>{if(e)return{kind:r?"restartFailed":"startFailed",error:e};if(t)return{kind:"statusUnreadable",error:t}},he=e=>{const[t,r]=c.useState(),s=y({...T(),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 I(x)?!1:X(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=I(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:Z(s.error,n.error,!!u)}},ge=["From","Subject","HasWords","ListId","FromDomain"],ee=e=>{const t=e.trim(),r=t.match(/<([^>]+)>/);return(r?r[1]:t).trim().toLowerCase()},be=(e,t)=>e==="ListId"?ee(t):t.trim(),te=e=>e==="all"?"And":"Or",re=(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:te(e.matchOperator),literalClauses:s}},se=e=>e.anchorMessageId!==void 0||!e.literalClauses.some(t=>t.field==="HasWords"),ne=e=>JSON.stringify({anchor:e.anchorMessageId??null,operator:e.matchOperator,clauses:e.literalClauses.map(t=>`${t.field} ${t.value}`)}),ve=(e,t)=>{const r=re(e,t);return{...r.anchorMessageId?{anchorMessageId:r.anchorMessageId}:{},matchOperator:r.matchOperator,literalClauses:r.literalClauses,moveMailboxId:e.moveMailboxId,labelId:e.labelId,expiresAt:e.scope==="until"?D(e.until??""):void 0}},ae=(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},ie=350,Se=(e,t,r)=>{const s=y(k()),{mutateAsync:i}=s,n=ne(t),[a,l]=c.useState(()=>({})),m=c.useRef(t);m.current=t;const u=c.useRef(n),f=se(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}))})},ie);return()=>clearTimeout(b)},[e,f,n,a.previewedSignature,a.errorSignature,i]),f?{count:ae(a,n),matchedIds:a.previewedSignature===n?a.matchedIds??[]:[]}:{count:{status:"error",reason:R},matchedIds:[]}},F=e=>$({path:{accountId:e}}),Me=e=>{const t=E({..._({path:{accountId:e??""}}),enabled:!!e});return{filters:t.data?.items??[],isPending:t.isPending,isError:t.isError,error:t.error,refetch:t.refetch}},xe=e=>{const t=N(),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:A(l,m,u)})},[e,s]),a=c.useCallback(async(l,m,u)=>e?i({path:{accountId:e},body:A(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}},Ce=e=>{const t=N(),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{ce as B,C as N,ge as S,q as a,P as b,Se as c,he as d,xe as e,pe as f,me as g,F as h,ve as i,ue as j,de as k,Me as l,Ce as m,be as n,fe as o,D as p,re as r,le as u};
@@ -1 +1 @@
1
- import{aA as L,cK as p,aa as n,aD as l,cL as d,r as o,cM as c,cN as y,cO as g}from"./index-aOUXxkZn.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{aA as L,cK as p,aa as n,aD as l,cL as d,r as o,cM as c,cN as y,cO as g}from"./index-j6RdmczT.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,aM as C,aA as h,aL as j,aD as L,aQ as k,bT as T,bX as E}from"./index-aOUXxkZn.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 M({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:""},S=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{M as R,S as u};
1
+ import{r as y,j as i,B as u,d as m,L as p,aa as x,aM as C,aA as h,aL as j,aD as L,aQ as k,bT as T,bX as E}from"./index-j6RdmczT.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 M({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:""},S=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{M as R,S as u};
package/index.html CHANGED
@@ -31,8 +31,8 @@
31
31
  } catch (_) {}
32
32
  })();
33
33
  </script>
34
- <script type="module" crossorigin src="/assets/index-aOUXxkZn.js"></script>
35
- <link rel="stylesheet" crossorigin href="/assets/index-DPey6jym.css">
34
+ <script type="module" crossorigin src="/assets/index-j6RdmczT.js"></script>
35
+ <link rel="stylesheet" crossorigin href="/assets/index-BmBkz8X4.css">
36
36
  </head>
37
37
  <body>
38
38
  <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.253",
3
+ "version": "0.0.255",
4
4
  "description": "Built Remit web client — static assets and the default runtime config.",
5
5
  "files": [
6
6
  "**/*"
@@ -1 +0,0 @@
1
- import{aa as X,aD as Z,cm as ee,cn as te,r as f,j as t,co as ae,cp as se,L as A,B as C,D as ie,e as ne,cq as re,i as oe,T as le,aA as T,aq as ce,a$ as O,ap as de,aL as me,c8 as ue,ca as pe}from"./index-aOUXxkZn.js";import{S as xe}from"./settings-screen-BVzayABo.js";import{h as fe,N as S,p as he,c as ge,r as ve,d as be,S as D,i as ye,n as je,u as Ne,B as Ce,j as Se,k as Ie,l as Fe,m as we}from"./useFilters-cKnHkpoA.js";import{u as Ee,b as Me}from"./move-targets-DssqZI4G.js";import{a as Oe,u as De}from"./useLabels-MXpcXbeo.js";import{C as M}from"./circle-check-Sb0372DS.js";import{E as R}from"./ErrorState-D-aU8-M8.js";import"./avatar-B2H0LXl_.js";const Le=(e,a)=>{const n=X(),i=Z({...te(),onSuccess:()=>{e&&(n.invalidateQueries({queryKey:fe(e)}),a&&n.invalidateQueries({queryKey:ee({path:{accountId:e,filterId:a}})}))}}),{mutate:l}=i;return{updateFilter:f.useCallback(x=>{!e||!a||l({path:{accountId:e,filterId:a},body:x})},[e,a,l]),isPending:i.isPending,isSuccess:i.isSuccess,isError:i.isError,error:i.error,reset:i.reset}},ke=(e,a=!1)=>({clauses:e.literalClauses.map((i,l)=>({id:`clause-${l}`,field:i.field,value:i.value})),matchOperator:e.matchOperator==="And"?"all":"any",widen:e.hasAnchor?{anchorCount:1,...a?{inactive:!0}:{}}:void 0,moveMailboxId:e.actionMailboxId!==S?e.actionMailboxId:void 0,labelId:e.actionLabelId!==S?e.actionLabelId:void 0,scope:e.scope==="Temporary"?"until":"standing",until:e.scope==="Temporary"?Ae(e.expiresAt):void 0,name:e.name}),Ae=e=>{if(!e)return"";const a=Date.parse(e);if(Number.isNaN(a))return"";const n=new Date(a),i=l=>String(l).padStart(2,"0");return`${n.getFullYear()}-${i(n.getMonth()+1)}-${i(n.getDate())}`},L=e=>JSON.stringify({clauses:e.clauses.map(a=>[a.field,a.value]),operator:e.matchOperator,move:e.moveMailboxId??null,label:e.labelId??null,widen:e.widen?e.widen.inactive?"inactive":"active":"none"}),P=(e,a)=>L(e)!==L(a),k=e=>JSON.stringify({scope:e.scope==="until"?"until":"standing",until:e.scope==="until"?e.until??"":""}),$=(e,a)=>k(e)!==k(a),Te=(e,a)=>{const n={},i=(e.name??"").trim();return i!==(a.name??"").trim()&&(n.name=i),P(e,a)&&(n.matchOperator=e.matchOperator==="all"?"And":"Or",n.literalClauses=e.clauses.map(l=>({field:l.field,value:l.value})),n.actionMailboxId=e.moveMailboxId??S,n.actionLabelId=e.labelId??S),$(e,a)&&(n.scope=e.scope==="until"?"Temporary":"Standing",e.scope==="until"&&(n.expiresAt=he(e.until??""))),n};function Re({accountId:e,filter:a,folders:n,labels:i,semanticUnavailable:l=!1,onClose:d}){const x=f.useMemo(()=>ke(a,l),[a,l]),[m,r]=f.useState(x),[c,u]=f.useState(),[h,g]=f.useState(!1),b=f.useRef(0),{count:N}=ge(e,ve(m)),v=Le(e,a.filterId),y=be(e),{createFolder:I}=Ee(e),{createLabel:p}=Oe(e),F=async o=>{const s=await p(o);return{id:s.labelId,name:s.name,color:s.color}},w=()=>u({mode:"add",draft:{field:D[0],value:""}}),z=o=>{const s=m.clauses.find(j=>j.id===o);s&&u({mode:"edit",clauseId:o,draft:{field:s.field,value:s.value}})},_=o=>u(s=>s&&{...s,draft:{...s.draft,field:o}}),B=o=>u(s=>s&&{...s,draft:{...s.draft,value:o}}),U=()=>{if(!c)return;const o=c.draft.field,s=je(o,c.draft.value);s!==""&&(r(j=>c.mode==="edit"&&c.clauseId?{...j,clauses:j.clauses.map(E=>E.id===c.clauseId?{id:E.id,field:o,value:s}:E)}:(b.current+=1,{...j,clauses:[...j.clauses,{id:`new-${b.current}`,field:o,value:s}]})),u(void 0))},K=o=>r(s=>({...s,clauses:s.clauses.filter(j=>j.id!==o)})),q=o=>r(s=>({...s,matchOperator:o})),Q=o=>r(s=>({...s,moveMailboxId:o||void 0})),G=o=>r(s=>({...s,labelId:o||void 0})),H=o=>r(s=>({...s,name:o})),J=o=>r(s=>({...s,scope:o,until:o==="until"?s.until:void 0})),V=o=>r(s=>({...s,until:o})),W=()=>{const o=P(m,x)||$(m,x),s=Te(m,x);if(Object.keys(s).length===0){d();return}g(o),v.updateFilter(s)},Y=()=>y.start(ye(m));return y.isStarting||y.isRunning||y.isDone?t.jsx(_e,{progress:y.progress,isDone:y.isDone,onClose:d}):v.isPending?t.jsx(Pe,{}):v.isError?t.jsx(Be,{onRetry:v.reset,onClose:d}):v.isSuccess?h?t.jsx(ze,{preview:ae(N),blocked:N.status!=="ready"||N.stale===!0,onReapply:Y,onClose:d}):t.jsx($e,{onClose:d}):t.jsx(se,{rule:m,folders:n,labels:i,preview:N,semanticAvailable:!1,clauseFields:D,anchorLocked:!0,clauseEdit:c,onStartAddClause:w,onStartEditClause:z,onRemoveClause:K,onChangeDraftField:_,onChangeDraftValue:B,onSubmitClause:U,onCancelClause:()=>u(void 0),onChangeMatchOperator:q,onChangeMove:Q,onCreateFolder:I,onChangeLabel:G,onCreateLabel:F,onChangeName:H,onChangeScope:J,onChangeUntil:V,onCommit:W,onCancel:d})}function Pe(){return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[t.jsx(A,{className:"size-8 animate-spin text-accent-2"}),t.jsx("p",{className:"text-sm font-medium text-fg",children:"Saving changes…"})]})}function $e({onClose:e}){return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[t.jsx(M,{className:"size-8 text-positive"}),t.jsx("p",{className:"text-sm font-medium text-fg",children:"Filter updated"}),t.jsx(C,{variant:"primary",onClick:e,className:"mt-2",children:"Done"})]})}function ze({preview:e,blocked:a,onReapply:n,onClose:i}){return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[t.jsx(M,{className:"size-8 text-positive"}),t.jsx("p",{className:"text-sm font-medium text-fg",children:"Rule saved"}),t.jsxs("p",{className:"max-w-xs text-xs text-fg-muted",children:["New mail follows the rule automatically. ",e," — move the mail already in your mailbox too?"]}),t.jsxs("div",{className:"mt-2 flex gap-2",children:[t.jsx(C,{variant:"primary",onClick:n,disabled:a,children:"Move existing mail"}),t.jsx(C,{variant:"ghost",onClick:i,children:"Not now"})]})]})}function _e({progress:e,isDone:a,onClose:n}){const i=e.state==="Failed";return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[a?i?t.jsx("span",{className:"text-sm font-semibold text-danger",children:"Move failed"}):t.jsx(M,{className:"size-8 text-positive"}):t.jsx(A,{className:"size-8 animate-spin text-accent-2"}),!a&&t.jsx("p",{className:"text-sm font-medium text-fg",children:"Moving existing mail…"}),a&&!i&&t.jsxs("div",{className:"text-sm text-fg",children:[t.jsx("p",{className:"font-medium",children:"Done"}),t.jsxs("p",{className:"mt-1 text-xs text-fg-muted",children:[e.appliedCount," of ",e.matchedCount," moved",e.failedCount>0?` · ${e.failedCount} failed`:"","."]})]}),a&&i&&t.jsx("p",{className:"max-w-xs text-xs text-fg-muted",children:e.errorMessage||"Something went wrong. Please try again."}),a&&t.jsx(C,{variant:"primary",onClick:n,className:"mt-2",children:"Done"})]})}function Be({onRetry:e,onClose:a}){return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[t.jsx("p",{className:"text-sm font-medium text-danger",children:"Couldn't save changes"}),t.jsx("p",{className:"max-w-xs text-xs text-fg-muted",children:"Please try again."}),t.jsxs("div",{className:"mt-2 flex gap-2",children:[t.jsx(C,{variant:"primary",onClick:e,children:"Try again"}),t.jsx(C,{variant:"ghost",onClick:a,children:"Not now"})]})]})}function Ue({accountId:e,filter:a,folders:n,labels:i,semanticUnavailable:l,onClose:d}){const x=Ne(),m=t.jsx(Re,{accountId:e,filter:a,folders:n,labels:i,semanticUnavailable:l,onClose:d});return x?t.jsx(ie,{open:!0,onClose:d,title:"Filter rule",children:m}):t.jsx(Ce,{open:!0,onClose:d,dismissLabel:"Dismiss filter rule",children:m})}function Ke({filters:e,mailboxName:a,labelById:n,onEdit:i,onDelete:l,deletingFilterId:d,semanticUnavailable:x=!1,now:m=Date.now()}){return e.length===0?t.jsx("p",{className:"py-6 text-sm text-fg-muted",children:"No filters yet. Select a few messages in the inbox and choose Organize to make one."}):t.jsx("ul",{className:"divide-y divide-line rounded-md border border-line",children:e.map(r=>{const c=Se(r,m),u=c==="Expired",h=r.actionMailboxId!==S?a(r.actionMailboxId):void 0,g=r.actionLabelId!==S?n.get(r.actionLabelId):void 0,b=Ie(r.expiresAt);return t.jsxs("li",{className:"flex items-start gap-3 px-3 py-2.5",children:[t.jsxs("button",{type:"button",onClick:()=>i(r.filterId),"aria-label":`Edit filter ${r.name}`,className:"min-w-0 flex-1 rounded-sm text-left hover:opacity-80",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`truncate text-sm font-medium ${u?"text-fg-muted":"text-fg"}`,children:r.name}),t.jsx(ne,{tone:u?"neutral":"positive",dot:!0,children:c})]}),t.jsxs("p",{className:"mt-0.5 text-xs text-fg-subtle",children:[h?`Moves matches to ${h}`:"No move action",r.scope==="Temporary"&&b?u?` · expired ${b}`:` · until ${b}`:r.scope==="Standing"?" · always":""]}),(r.hasAnchor||g)&&t.jsxs("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:[r.hasAnchor&&t.jsx(re,{widen:{anchorCount:1,...x?{inactive:!0}:{}}}),g&&t.jsx(oe,{label:{labelId:g.id,name:g.name,color:g.color}})]})]}),t.jsx(C,{variant:"ghost",size:"sm",icon:t.jsx(le,{className:"size-4 text-danger"}),onClick:()=>l(r.filterId),disabled:d===r.filterId,"aria-label":`Delete filter ${r.name}`})]},r.filterId)})})}const qe=t.jsxs("div",{className:"space-y-3",children:[t.jsxs("p",{children:["Filters are the standing rules Organize creates. A"," ",t.jsx("strong",{children:"Standing"})," filter keeps working on new mail; a"," ",t.jsx("strong",{children:"Temporary"})," one stops on its own at the date you picked."]}),t.jsx("p",{children:"An expired filter isn't deleted the instant it lapses — it stays here, marked Expired, so you can see what it did and when it stopped."})]});function Qe({account:e}){const a=e.accountId,{filters:n,isPending:i,isError:l,error:d,refetch:x}=Fe(a),{deleteFilter:m,deletingFilterId:r}=we(a),[c,u]=f.useState(),{data:h}=T({...ce({path:{accountId:a}}),staleTime:1/0}),g=f.useCallback(p=>{const F=h?.items.find(w=>w.mailboxId===p);return F?O(F.fullPath):void 0},[h?.items]),b=f.useMemo(()=>Me(h?.items??[],e.folderAppointments).map(p=>({id:p.mailboxId,label:O(p.fullPath)})),[h?.items,e.folderAppointments]),{labels:N}=De(a),v=f.useMemo(()=>N.map(p=>({id:p.labelId,name:p.name,color:p.color})),[N]),y=f.useMemo(()=>new Map(v.map(p=>[p.id,p])),[v]),I=n.find(p=>p.filterId===c);return t.jsxs("section",{className:"space-y-2",children:[t.jsx("h2",{className:"text-sm font-semibold text-fg",children:e.email}),I&&t.jsx(Ue,{accountId:a,filter:I,folders:b,labels:v,onClose:()=>u(void 0)}),i?t.jsx("div",{className:"h-16 animate-pulse rounded-md border border-line bg-surface","aria-busy":"true","aria-label":`Loading filters for ${e.email}`}):l?t.jsx(R,{variant:"inline",title:`Couldn't load filters for ${e.email}`,error:d,onRetry:()=>{x()}}):t.jsx(Ke,{filters:n,mailboxName:g,labelById:y,onEdit:u,onDelete:m,deletingFilterId:r})]})}function et(){const e=de(),[a,n]=f.useState(!0),{data:i,isPending:l,isError:d,error:x,refetch:m}=T(me()),r=c=>{const u=pe[c];u&&e({to:u})};return t.jsx(xe,{items:ue,activeId:"filters",title:"Filters",description:"Standing and temporary rules created by Organize, per account.",help:qe,helpOpen:a,onToggleHelp:()=>n(c=>!c),onSelect:r,onBackToMail:()=>{e({to:"/mail"})},children:l?t.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":"Loading accounts"}):d?t.jsx(R,{title:"Couldn't load accounts",error:x,onRetry:()=>{m()}}):i.accounts.length===0?t.jsx("p",{className:"py-12 text-sm text-fg-muted",children:"No accounts configured."}):t.jsx("div",{className:"space-y-8",children:i.accounts.map(c=>t.jsx(Qe,{account:c},c.accountId))})})}export{Qe as AccountFilters,et as component};
@@ -1 +0,0 @@
1
- import{j as e,B as j,T as L,V as G,r as u,D as H,X as V,cb as ie,bZ as Y,t as le,cy as W,cz as ce,bY as de,l as me,cA as xe,aa as Z,aW as X,bT as J,cB as ue,cC as he,bi as fe,bI as U,aw as R,ar as ee,L as B,E as se,F as pe,Q as ge,ap as be,aA as te,aL as je,c8 as ve,ca as ye,aq as Ne,aD as q,cD as Ce,cE as ke,cF as Me,cG as we}from"./index-aOUXxkZn.js";import{P as Ie,a as Se,c as F,d as Ae,M as De,i as Q,u as ae,b as Oe,m as K,g as Ee}from"./move-options-9AJl6K6-.js";import{S as Te}from"./settings-screen-BVzayABo.js";import{u as re}from"./move-targets-DssqZI4G.js";import{E as ne}from"./ErrorState-D-aU8-M8.js";import"./avatar-B2H0LXl_.js";const Fe=({label:s,onRename:n,onDelete:t,deleteBlockedReason:i,renameLabel:d=c=>`Rename ${c}`,deleteLabel:r=c=>`Delete ${c}`})=>{const c=i?`${r(s)} — ${i}`:r(s);return e.jsxs("span",{className:"flex shrink-0 items-center gap-0.5 pr-2",children:[e.jsx(j,{variant:"ghost",size:"sm",icon:e.jsx(Ie,{className:"size-3.5"}),"aria-label":d(s),onClick:n}),e.jsx("span",{title:i,children:e.jsx(j,{variant:"ghost",size:"sm",icon:e.jsx(L,{className:"size-3.5"}),"aria-label":c,disabled:i!==void 0,onClick:t})})]})},Pe=({folders:s,onRename:n,onDelete:t,onCreateFolder:i,delimiter:d,labels:r})=>{const c=new Map(s.map(o=>[o.id,o]));return e.jsx(G,{folders:s,onCreateFolder:i,delimiter:d,labels:{treeAriaLabel:"Your folders",optionLabel:o=>o,...r},rowActions:o=>{const a=c.get(o.id);return a?e.jsx(Fe,{label:a.label,deleteBlockedReason:a.deleteBlockedReason,renameLabel:r?.rename,deleteLabel:r?.remove,onRename:()=>n(a),onDelete:()=>t(a)}):null}})},Le=({open:s,folderLabel:n,defaultLabel:t,name:i,onNameChange:d,onSubmit:r,onClose:c,pending:o=!1,error:a})=>{const l=u.useId(),p=`Rename ${n}`;return s?e.jsxs(H,{open:s,onClose:c,title:p,children:[e.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[e.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:p}),e.jsx(j,{variant:"ghost",size:"sm",icon:e.jsx(V,{className:"size-3.5"}),onClick:c,"aria-label":"Cancel"})]}),e.jsxs("div",{className:"space-y-3 px-5 py-4",children:[e.jsxs("div",{children:[e.jsx(ie,{htmlFor:l,children:"Folder name"}),e.jsx(Y,{id:l,value:i,placeholder:t,onChange:m=>d(m.target.value),onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),r())}})]}),e.jsxs("p",{className:"text-xs text-fg-muted",children:["Shown everywhere in Remit. Leave it blank to use"," ",e.jsx("span",{className:"font-medium text-fg",children:t}),"."]}),a&&e.jsx("p",{className:"text-xs text-danger",role:"alert",children:a})]}),e.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[e.jsx(j,{variant:"secondary",size:"sm",onClick:c,children:"Cancel"}),e.jsx(j,{variant:"primary",size:"sm",onClick:r,disabled:o,children:o?"Saving…":"Save name"})]})]}):null},Re=["inbox","drafts","sent","archive","junk","trash"],z="";function ze(s){const n=s.messageCount===1?"msg":"msgs";return`${W(s.providerPath)} · ${s.messageCount} ${n}`}function $e({role:s,folders:n,appointedId:t,displayName:i,onAppoint:d,onRename:r}){const[c,o]=u.useState(i),a=n.find(m=>m.mailboxId===t)??null,l=xe(s),p=a!=null&&c.trim()!==i.trim();return e.jsxs("div",{className:"flex flex-col gap-1 border-b border-line px-row-inset py-2.5 last:border-b-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"flex w-28 shrink-0 items-center gap-2 text-sm font-medium text-fg",children:[ce(s),l]}),e.jsxs(de,{className:"w-56 shrink-0",value:t??z,"aria-label":`Folder for ${l}`,onChange:m=>d(s,m.target.value===z?null:m.target.value),children:[e.jsx("option",{value:z,children:"None"}),n.map(m=>e.jsx("option",{value:m.mailboxId,children:ze(m)},m.mailboxId))]}),a&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{className:"flex-1",value:c,placeholder:l,"aria-label":`Display name for ${l}`,onChange:m=>o(m.target.value)}),p&&e.jsx(j,{variant:"ghost",size:"sm",className:"shrink-0",icon:e.jsx(me,{className:"size-4"}),"aria-label":"Save display name",onClick:()=>r(a.mailboxId,c)})]})]}),a&&e.jsxs("span",{className:"truncate pl-[7.5rem] text-2xs text-fg-subtle",title:a.providerPath,children:[a.providerPath," · ",a.messageCount," ",a.messageCount===1?"message":"messages"]})]})}function _e({accountEmail:s,folders:n,appointments:t,displayNames:i={},onAppoint:d,onRename:r}){const c=new Set(Object.values(t).filter(a=>a!=null)),o=n.filter(a=>!c.has(a.mailboxId));return e.jsxs("section",{className:"space-y-3",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsxs("h2",{className:"text-sm font-semibold text-fg",children:["Folder roles — ",s]}),e.jsx("p",{className:"text-xs text-fg-muted",children:"Each role points to one folder. Pick the folder that holds the mail — the counts help you tell real folders from empty look-alikes. Appointing a folder here removes it from any other role."})]}),e.jsx("div",{className:"rounded-sm border border-line bg-surface",children:Re.map(a=>{const l=t[a]??null;return e.jsx($e,{role:a,folders:n,appointedId:l,displayName:l?i[l]??"":"",onAppoint:d,onRename:r},a)})}),o.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h3",{className:"text-xs font-medium text-fg-muted",children:"Other folders"}),e.jsx("ul",{className:"rounded-sm border border-line bg-surface",children:o.map(a=>e.jsxs("li",{className:"flex items-center gap-2 border-b border-line px-row-inset py-2 text-sm text-fg last:border-b-0",children:[e.jsx(le,{className:"size-4 shrink-0 text-fg-subtle"}),e.jsx("span",{className:"truncate",children:W(a.providerPath)}),e.jsxs("span",{className:"ml-auto shrink-0 text-2xs text-fg-subtle",children:[a.messageCount," ",a.messageCount===1?"message":"messages"]})]},a.mailboxId))})]})]})}const oe=50,Be=s=>s instanceof Error?s.message:"Something went wrong.",T=s=>s.then(n=>({ok:!0,value:n}),n=>({ok:!1,error:Be(n)})),qe=async(s,n,t,i)=>{const d=[];let r;for(let c=0;c<oe;c+=1){if(i.aborted)return d;const{data:o}=await U({path:{mailboxId:s},query:{order:"desc",continuationToken:r},throwOnError:!0});for(const a of o.items)if(!a.isDeleted&&!n.has(a.messageId)&&!d.includes(a.messageId)&&(d.push(a.messageId),d.length>=t))return d;if(!o.continuationToken)break;r=o.continuationToken}return d},Qe=async(s,n)=>{let t=0,i;for(let d=0;d<oe;d+=1){if(n.aborted)return t;const{data:r}=await U({path:{mailboxId:s},query:{order:"desc",continuationToken:i},throwOnError:!0});for(const c of r.items)c.isDeleted||(t+=1);if(!r.continuationToken)break;i=r.continuationToken}return t};function Ke({accountId:s,mailboxId:n,onDeleted:t}){const i=Z(),[d,r]=u.useState("idle"),[c,o]=u.useState(null),[a,l]=u.useState(),p=u.useRef(null),m=u.useCallback(()=>{i.invalidateQueries({queryKey:X({path:{accountId:s}})}),i.invalidateQueries({queryKey:J()})},[i,s]),N=u.useCallback(async()=>{r("deleting");const b=await T(ue({path:{accountId:s,mailboxId:n},throwOnError:!0}));if(!b.ok){l(b.error),r("error");return}m(),r("done"),t()},[s,n,m,t]),C=u.useCallback(()=>he({path:{accountId:s},throwOnError:!0}).then(({data:b})=>b.items.find(g=>g.mailboxId===n)?.messageCount??0),[s,n]),E=u.useCallback(()=>{p.current?.abort()},[]),w=u.useCallback(async b=>{const g=new AbortController;p.current=g;const{signal:f}=g;r("moving"),l(void 0);const I=await T(C());if(f.aborted)return;if(!I.ok){l(I.error),r("error");return}let h=Se(I.value);o(h);const k=new Set;for(;;){if(f.aborted)return;const v=await T(qe(n,k,De,f));if(f.aborted)return;if(!v.ok){h=F(h,v.error),o(h),l(v.error),r("error");return}const M=v.value;if(M.length===0)break;const D=await T(fe({body:{messageIds:M,destinationMailboxId:b},throwOnError:!0}));if(f.aborted)return;if(!D.ok){h=F(h,D.error),o(h),l(D.error),r("error");return}for(const S of M)k.add(S);h=Ae(h,M.length),o(h)}const y=await T(Qe(n,f));if(!f.aborted){if(!y.ok){h=F(h,y.error),o(h),l(y.error),r("error");return}if(y.value>0){const v=`${y.value} ${y.value===1?"email is":"emails are"} still syncing. Re-open delete to finish removing this folder.`;h=F(h,v),o(h),l(v),r("error"),m();return}await N()}},[n,C,N,m]),O=u.useCallback(()=>{p.current?.abort(),p.current=null,r("idle"),o(null),l(void 0)},[]);return{phase:d,progress:c,errorMessage:a,deleteMailbox:N,moveThenDelete:w,cancel:E,reset:O}}const P=s=>`${s} ${s===1?"email":"emails"}`;function Ge({open:s,accountId:n,folder:t,mailboxes:i,appointments:d,onClose:r}){const[c,o]=u.useState(()=>Q(t.messageCount)),[a,l]=u.useState(),{createFolderIn:p}=re(n),m=ae(),{phase:N,progress:C,errorMessage:E,deleteMailbox:w,moveThenDelete:O,cancel:b,reset:g}=Ke({accountId:n,mailboxId:t.mailboxId,onDeleted:r});u.useEffect(()=>{s&&(o(Q(t.messageCount)),g())},[s,t.messageCount,g]),u.useEffect(()=>{s&&l(void 0)},[s]),u.useEffect(()=>b,[b]);const f=u.useCallback(()=>{b(),r()},[b,r]),I=u.useMemo(()=>Oe({mailboxes:i,folderAppointments:d,excludeMailboxId:t.mailboxId,translator:m}),[i,d,t.mailboxId,m]),h=I.find(M=>M.id===a),k=u.useMemo(()=>R(t,ee(d).get(t.mailboxId),m),[t,d,m]);if(!s)return null;const y=`Delete ${k}`,v=N==="moving"?e.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[e.jsx(B,{className:"size-8 animate-spin text-accent-2"}),e.jsx("p",{className:"text-sm font-medium text-fg",children:"Moving emails…"}),e.jsx("p",{className:"text-xs text-fg-muted",role:"status","aria-live":"polite",children:C?K(C):"Moved 0 of 0"})]}):N==="deleting"||N==="done"?e.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[e.jsx(B,{className:"size-8 animate-spin text-accent-2"}),e.jsx("p",{className:"text-sm font-medium text-fg",children:"Deleting folder…"})]}):N==="error"?e.jsxs("div",{className:"space-y-4 px-5 py-4",children:[e.jsx(se,{tone:"danger",variant:"soft",children:E??"Something went wrong. Please try again."}),C&&e.jsxs("p",{className:"text-xs text-fg-muted",children:[K(C),". Already-moved emails stay moved — re-open delete to continue with the rest."]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(j,{variant:"secondary",size:"sm",onClick:f,children:"Close"})})]}):c==="confirm-empty"?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-3 px-5 py-4 text-sm text-fg-muted",children:e.jsxs("p",{children:["Delete ",e.jsx("strong",{className:"text-fg",children:k}),"? This folder is empty and will be removed from the server."]})}),e.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[e.jsx(j,{variant:"secondary",size:"sm",onClick:f,children:"Cancel"}),e.jsx(j,{variant:"danger",size:"sm",icon:e.jsx(L,{className:"size-3.5"}),onClick:()=>w(),children:"Delete folder"})]})]}):c==="choose-fate"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-3 px-5 py-4 text-sm text-fg-muted",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:k})," holds"," ",P(t.messageCount),". What should happen to them?"]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("button",{type:"button",onClick:()=>o("confirm-delete-all"),className:"flex w-full items-center gap-3 rounded-sm border border-line px-3 py-2.5 text-left hover:bg-surface-raised",children:[e.jsx(L,{className:"size-4 shrink-0 text-danger"}),e.jsxs("span",{className:"flex-1",children:[e.jsx("span",{className:"block text-sm font-medium text-fg",children:"Delete them with the folder"}),e.jsx("span",{className:"block text-xs text-fg-muted",children:"The emails are removed from the server and can't be recovered."})]})]}),e.jsxs("button",{type:"button",onClick:()=>o("pick-destination"),className:"flex w-full items-center gap-3 rounded-sm border border-line px-3 py-2.5 text-left hover:bg-surface-raised",children:[e.jsx(pe,{className:"size-4 shrink-0 text-accent-2"}),e.jsxs("span",{className:"flex-1",children:[e.jsx("span",{className:"block text-sm font-medium text-fg",children:"Move them to another folder"}),e.jsx("span",{className:"block text-xs text-fg-muted",children:"Keep the emails, then delete the emptied folder."})]})]})]})]}),e.jsx("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:e.jsx(j,{variant:"secondary",size:"sm",onClick:f,children:"Cancel"})})]}):c==="confirm-delete-all"?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-3 px-5 py-4 text-sm text-fg-muted",children:e.jsxs("p",{children:["Delete ",e.jsx("strong",{className:"text-fg",children:k})," and its"," ",P(t.messageCount),"? The messages are removed from the server with the folder and can't be recovered."]})}),e.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[e.jsx(j,{variant:"secondary",size:"sm",onClick:()=>o("choose-fate"),children:"Back"}),e.jsx(j,{variant:"danger",size:"sm",icon:e.jsx(L,{className:"size-3.5"}),onClick:()=>w(),children:"Delete folder and emails"})]})]}):e.jsxs("div",{className:"flex h-[26rem] flex-col",children:[e.jsxs("p",{className:"px-5 pt-4 text-sm text-fg-muted",children:["Move the ",P(t.messageCount)," in"," ",e.jsx("strong",{className:"text-fg",children:k})," to:"]}),e.jsx("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:e.jsx(G,{folders:I,selectedId:a,delimiter:i[0]?.hierarchyDelimiter??"/",onSelect:l,onCreateFolder:p,onCancel:()=>{l(void 0),o("choose-fate")},labels:{filterPlaceholder:"Move emails to…"}})}),h&&e.jsx("footer",{className:"shrink-0 border-t border-line p-2",children:e.jsx(j,{variant:"danger",onClick:()=>O(h.id),className:"h-11 w-full font-semibold",children:e.jsx("span",{className:"truncate",children:`Move ${P(t.messageCount)} to ${h.label}`})})})]});return e.jsxs(H,{open:s,onClose:f,title:y,children:[e.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[e.jsx(ge,{className:"size-4 shrink-0 text-danger"}),e.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:y}),e.jsx(j,{variant:"ghost",size:"sm",icon:e.jsx(V,{className:"size-3.5"}),onClick:f,"aria-label":"Cancel"})]}),v]})}const He=e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{children:"Each canonical role — Inbox, Drafts, Sent, Archive, Spam, Trash — points at one of your account's real folders. Pick the one that actually holds the mail; the message counts tell real folders from empty look-alikes."}),e.jsx("p",{children:`Appointing a folder to a role here doesn't touch any other role, and doesn't move or rename anything on the server — it just tells Remit which folder to treat as e.g. "Drafts" everywhere (sidebar, unread badges, the compose flow).`}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Your folders"})," is the account's real hierarchy. Open a folder to see what's inside it, make a new one where you're looking, and rename or delete any of them from its row."]})]});function Ve({account:s}){const n=Z(),t=s.accountId,i=ae(),{data:d,isPending:r,isError:c,error:o,refetch:a}=te(Ne({path:{accountId:t}})),{createFolderIn:l}=re(t),p=q({...Ce(),onSuccess:()=>{n.invalidateQueries({queryKey:J()})}}),m=q({...ke(),onSuccess:()=>{n.invalidateQueries({queryKey:X({path:{accountId:t}})})}}),[N,C]=u.useState(),[E,w]=u.useState(),[O,b]=u.useState(""),g=u.useMemo(()=>d?.items??[],[d]),f=u.useMemo(()=>ee(s.folderAppointments),[s.folderAppointments]),I=u.useMemo(()=>g.map(x=>({id:x.mailboxId,label:R(x,f.get(x.mailboxId),i),path:x.fullPath,deleteBlockedReason:Ee(x,g,s.folderAppointments).message})),[g,f,i,s.folderAppointments]),h=(x,A)=>{p.mutate({path:{accountId:t,role:we[x]},body:{mailboxId:A}})},k=(x,A)=>{const _=A.trim();m.mutate({path:{accountId:t,mailboxId:x},body:{displayNameOverride:_===""?null:_}})};if(r)return e.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":`Loading folders for ${s.email}`});if(c)return e.jsx(ne,{variant:"inline",title:`Couldn't load folders for ${s.email}`,error:o,onRetry:()=>{a()}});const y=g.map(x=>({mailboxId:x.mailboxId,providerPath:x.fullPath,messageCount:x.messageCount})),v={};for(const x of s.folderAppointments){const A=Me[x.role];A&&(v[A]=x.mailboxId??null)}const M={};for(const x of g)x.displayNameOverride&&(M[x.mailboxId]=x.displayNameOverride);const D=x=>g.find(A=>A.mailboxId===x),S=D(E),$=D(N);return e.jsxs("div",{className:"space-y-4",children:[(p.isError||m.isError)&&e.jsx(se,{tone:"danger",variant:"soft",children:"Couldn't save that change. Please try again."}),e.jsx(_e,{accountEmail:s.email,folders:y,appointments:v,displayNames:M,onAppoint:h,onRename:k}),e.jsxs("section",{className:"space-y-1.5",children:[e.jsxs("h3",{className:"text-sm font-semibold text-fg",children:["Your folders — ",s.email]}),e.jsx("div",{className:"flex h-[28rem] flex-col overflow-hidden rounded-sm border border-line bg-surface",children:e.jsx(Pe,{folders:I,delimiter:g[0]?.hierarchyDelimiter??"/",onCreateFolder:l,onRename:x=>{w(x.id),b(D(x.id)?.displayNameOverride?.trim()??"")},onDelete:x=>C(x.id),labels:{treeAriaLabel:`All folders for ${s.email}`}})})]}),S&&e.jsx(Le,{open:!0,folderLabel:R(S,f.get(S.mailboxId),i),defaultLabel:R({fullPath:S.fullPath},f.get(S.mailboxId),i),name:O,onNameChange:b,pending:m.isPending,error:m.isError?"Couldn't save that name. Please try again.":void 0,onSubmit:()=>{const x=O.trim();m.mutate({path:{accountId:t,mailboxId:S.mailboxId},body:{displayNameOverride:x===""?null:x}},{onSuccess:()=>w(void 0)})},onClose:()=>w(void 0)}),$&&e.jsx(Ge,{open:!0,accountId:t,folder:$,mailboxes:g,appointments:s.folderAppointments,onClose:()=>C(void 0)})]})}function es(){const s=be(),[n,t]=u.useState(!0),{data:i,isPending:d,isError:r,error:c,refetch:o}=te(je()),a=l=>{const p=ye[l];p&&s({to:p})};return e.jsx(Te,{items:ve,activeId:"folders",title:"Folder roles",description:"Appoint which real folder fills each canonical role, per account.",help:He,helpOpen:n,onToggleHelp:()=>t(l=>!l),onSelect:a,onBackToMail:()=>{s({to:"/mail"})},children:d?e.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":"Loading accounts"}):r?e.jsx(ne,{title:"Couldn't load accounts",error:c,onRetry:()=>{o()}}):i.accounts.length===0?e.jsx("p",{className:"py-12 text-sm text-fg-muted",children:"No accounts configured."}):e.jsx("div",{className:"space-y-8",children:i.accounts.map(l=>e.jsx(Ve,{account:l},l.accountId))})})}export{es as component};
@@ -1 +0,0 @@
1
- import{j as t,bU as o}from"./index-aOUXxkZn.js";const n=()=>t.jsx(o,{to:"/settings/accounts"});export{n as component};
@@ -1 +0,0 @@
1
- import{a as r,av as u,r as d,ar as c,aw as m}from"./index-aOUXxkZn.js";import{b as f}from"./move-targets-DssqZI4G.js";const g=r("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"}]]),P=()=>{const{t:e}=u("mail",{useSuspense:!1});return d.useCallback((a,t)=>e(a,{defaultValue:t}),[e])},T=100,b=e=>e.trim().toLowerCase()==="inbox",h=(e,a)=>{const t=`${e.fullPath}${e.hierarchyDelimiter}`;return a.some(o=>o.mailboxId!==e.mailboxId&&o.fullPath.startsWith(t))},v=(e,a)=>a.find(t=>t.mailboxId!=null&&t.mailboxId===e)?.role;function y(e,a,t){if(b(e.fullPath))return{deletable:!1,reason:"inbox",message:"The inbox can't be deleted."};const o=v(e.mailboxId,t);return o?{deletable:!1,reason:"role",message:`This folder is your ${o} folder. Reassign that role before deleting it.`}:h(e,a)?{deletable:!1,reason:"children",message:"This folder has subfolders. Delete them first."}:{deletable:!0}}function x(e,a){return e.filter(t=>t.mailboxId!==a)}function C(e){return{total:e,moved:0,phase:e===0?"moved":"moving"}}function D(e,a){if(e.phase!=="moving")return e;const t=Math.min(e.total,e.moved+Math.max(0,a));return{...e,moved:t,phase:t>=e.total?"moved":"moving"}}function F(e,a){return{...e,phase:"failed",error:a}}function L(e){return`Moved ${e.moved} of ${e.total}`}function $(e){return e>0?"choose-fate":"confirm-empty"}const k=e=>e[0]?.hierarchyDelimiter??"/",E=({mailboxes:e,folderAppointments:a,currentMailboxId:t,excludeMailboxId:o,translator:i})=>{const l=f(e,a),s=c(a);return(o?x(l,o):l).map(n=>({id:n.mailboxId,label:m(n,s.get(n.mailboxId),i),path:n.fullPath,isCurrent:n.mailboxId===t}))};export{T as M,g as P,C as a,E as b,F as c,D as d,k as f,y as g,$ as i,L as m,P as u};
@@ -1 +0,0 @@
1
- import{aa as v,aA as _,aq as I,aD as g,aW as A,cH as L,r as M,a$ as h,ar as C,cI as p}from"./index-aOUXxkZn.js";const O={synced:"synced",failed:"failed"},q={uncategorized:"uncategorized",personal:"personal",newsletter:"newsletter",marketing:"marketing",automated:"automated",transactional:"transactional",social:"social"},U={MoveToInbox:"MoveToInbox",MoveToJunk:"MoveToJunk"},N=3e4,D=1e3,k="The folder couldn't be created on the mail server. Please try again.",R="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=(t,e)=>new Promise((a,n)=>{if(e?.aborted){n(e.reason);return}const o=setTimeout(()=>{e?.removeEventListener("abort",r),a()},t),r=()=>{clearTimeout(o),n(e?.reason)};e?.addEventListener("abort",r,{once:!0})});async function F({fetchMailboxes:t,mailboxId:e,signal:a,timeoutMs:n=N,pollIntervalMs:o=D,delay:r=B,now:s=Date.now}){const i=s()+n;for(;;){a?.throwIfAborted();const c=(await t()).find(u=>u.mailboxId===e);if(c?.syncStatus===O.synced)return c;if(c?.syncStatus===O.failed)throw new Error(k);if(s()>=i)throw new Error(R);await r(o,a)}}function S(t,e){const a=t.trim();return e?`${e.fullPath}${e.hierarchyDelimiter}${a}`:a}const P=(t,e)=>{const a=t.split(e);return a[0]?.toLowerCase()==="inbox"&&(a[0]="INBOX"),a.join(e)};function Y({name:t,delimiter:e,parent:a,existingPaths:n}){const o=t.trim();if(o==="")return"Enter a folder name.";if(o.includes(e))return`A folder name can't contain "${e}".`;const r=P(S(o,a),e);if(n.some(i=>P(i,e)===r))return"A folder with that name already exists."}function G(t){const e=v(),{data:a}=_({...I({path:{accountId:t??""}}),enabled:!!t}),n=g({...L(),onSuccess:()=>{t&&e.invalidateQueries({queryKey:A({path:{accountId:t}})})}}),o=M.useRef(new Map),r=M.useCallback(async(i,l,c)=>{if(!t)throw new Error("No account to create the folder in. Pick messages from a single account first.");const u=a?.items??[],d=l?u.find(b=>b.fullPath===l):void 0;if(l&&!d)throw new Error(`Couldn't find the folder "${l}" to create this one inside.`);const x=d?{fullPath:d.fullPath,hierarchyDelimiter:d.hierarchyDelimiter}:void 0,f=S(i,x);let m=o.current.get(f);if(!m){const b=x?.hierarchyDelimiter??u[0]?.hierarchyDelimiter??"/",w=Y({name:i,delimiter:b,parent:x,existingPaths:u.map(T=>T.fullPath)});if(w)throw new Error(w);m=(await n.mutateAsync({path:{accountId:t},body:{fullPath:f,namespaceType:"personal"}})).mailboxId,o.current.set(f,m)}const y=await F({mailboxId:m,signal:c,fetchMailboxes:async()=>(await e.fetchQuery({...I({path:{accountId:t}}),staleTime:0})).items??[]});return o.current.delete(f),{id:y.mailboxId,label:h(y.fullPath),path:y.fullPath}},[n,t,a,e]);return{createFolder:M.useCallback((i,l)=>r(i,"",l),[r]),createFolderIn:r,mutation:n}}const z=new Set(["outbox","postvak uit","boîte d'envoi","postausgang","buzón de salida","posta in uscita","送信トレイ","送件匣","发件箱","skrzynka nadawcza"]),X=t=>{const e=h(t.fullPath).trim().toLowerCase();return z.has(e)},E=p.length,J=(t,e)=>{const a=C(e);return[...t.filter(o=>{const r=a.get(o.mailboxId);return r==="drafts"||r==="sent"?!1:!X(o)})].sort((o,r)=>{const s=a.has(o.mailboxId)?p.indexOf(a.get(o.mailboxId)??"inbox"):E,i=a.has(r.mailboxId)?p.indexOf(a.get(r.mailboxId)??"inbox"):E;return s!==i?s-i:h(o.fullPath).localeCompare(h(r.fullPath),void 0,{sensitivity:"base",numeric:!0})})};export{q as M,U as P,J as b,G as u};
@@ -1 +0,0 @@
1
- import{j as t,bS as o}from"./index-aOUXxkZn.js";const n=()=>t.jsx(o,{});export{n as component};