@remit/web-client-dist 0.0.199 → 0.0.201

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 (38) hide show
  1. package/assets/{ComposeBody-CD1DhNI2.js → ComposeBody-CJwQ-5ri.js} +1 -1
  2. package/assets/{ConfirmDialog-buKQ0lNM.js → ConfirmDialog-Bv82OMuZ.js} +1 -1
  3. package/assets/{ErrorState-CFWFzlbC.js → ErrorState-Bohf_-oR.js} +1 -1
  4. package/assets/{OnboardingWizard-DlmEnK6q.js → OnboardingWizard-DHXggzOL.js} +1 -1
  5. package/assets/{account-form-helpers-DBIIITva.js → account-form-helpers-BpOwqwNr.js} +1 -1
  6. package/assets/{accounts-DVgV7PcS.js → accounts-acXs4eC4.js} +1 -1
  7. package/assets/{advanced-v8j9k2Hj.js → advanced-B7NoXsKD.js} +1 -1
  8. package/assets/{appearance-DRNC46S6.js → appearance-Dhv_uAhj.js} +1 -1
  9. package/assets/{avatar-BZ2Ic3iH.js → avatar-Czt2WUmG.js} +1 -1
  10. package/assets/{browser-ponyfill-C6013doW.js → browser-ponyfill-BVkCMLYU.js} +1 -1
  11. package/assets/{circle-check-C0-tV1lm.js → circle-check-CegrtM_f.js} +1 -1
  12. package/assets/{download-DV17Fwnd.js → download-BU_VLvDl.js} +1 -1
  13. package/assets/{filters-D_f8Cc2s.js → filters-CQIcTi4-.js} +1 -1
  14. package/assets/{flagged-C57j3xjD.js → flagged-BjEnVwwW.js} +1 -1
  15. package/assets/{folders-CKxRlym2.js → folders-CDkO7bp3.js} +1 -1
  16. package/assets/{index-CSeyPyIJ.js → index-B_o2k4vi.js} +1 -1
  17. package/assets/index-CCN_kElr.js +1 -0
  18. package/assets/{index-Bq9-ElVU.js → index-CjjdPqU1.js} +4 -4
  19. package/assets/{kbd-ByPIrxyK.js → kbd-BqaI8uDF.js} +1 -1
  20. package/assets/{labels-DnTbq3Lk.js → labels-CG1STcSC.js} +1 -1
  21. package/assets/{mail-SEuuJuyc.js → mail-DFpibu0-.js} +3 -3
  22. package/assets/{move-mailbox-picker-cazFNbBd.js → move-mailbox-picker-D_V1MWbw.js} +1 -1
  23. package/assets/{move-targets-BwkC3Ixo.js → move-targets-BNX20jB1.js} +1 -1
  24. package/assets/{onboarding-B6_X3Gfe.js → onboarding-BNGNPdEA.js} +1 -1
  25. package/assets/{search-BvtA8qSj.js → search-BEDItR13.js} +1 -1
  26. package/assets/{senders-sL_1szxE.js → senders-be4RszaY.js} +1 -1
  27. package/assets/settings-DNL4mY8Z.js +1 -0
  28. package/assets/{settings-screen-Dio597Ai.js → settings-screen-Bg_B152C.js} +1 -1
  29. package/assets/{shield-check-C63Sk23j.js → shield-check-h-icaSBd.js} +1 -1
  30. package/assets/{suggested-vips-Do3IHSv2.js → suggested-vips-BGKAB2ch.js} +1 -1
  31. package/assets/{useDebouncedValue-DHwUx0cO.js → useDebouncedValue-DHKoiyoD.js} +1 -1
  32. package/assets/{useLabels-C1bVawld.js → useLabels-CuOu4bk3.js} +1 -1
  33. package/assets/{useRulePreview-iSy71i5G.js → useRulePreview-2A1FYSkL.js} +1 -1
  34. package/assets/{useSignature-BLkEvXD0.js → useSignature-BkpaxHOZ.js} +1 -1
  35. package/index.html +1 -1
  36. package/package.json +1 -1
  37. package/assets/index-D0DiL8eZ.js +0 -1
  38. package/assets/settings-CcDq-vci.js +0 -1
@@ -1 +1 @@
1
- import{$ as Z,at as X,bZ as ee,b_ as te,r as f,j as t,b$ as ae,b0 as se,L as k,B as C,D as ie,d as ne,c0 as re,i as oe,T as le,ae as ce,aq as A,aA as de,bM as me,bO as ue,af as xe,aQ as O}from"./index-Bq9-ElVU.js";import{S as pe}from"./settings-screen-Dio597Ai.js";import{p as fe,N as S,q as he,c as ge,r as ve,d as be,S as D,f as ye,n as je,u as Ne,B as Ce,t as Se,v as Ie,w as Fe,x as we}from"./useRulePreview-iSy71i5G.js";import{u as Me,b as Ee}from"./move-targets-BwkC3Ixo.js";import{a as Oe,u as De}from"./useLabels-C1bVawld.js";import{C as E}from"./circle-check-C0-tV1lm.js";import{E as R}from"./ErrorState-CFWFzlbC.js";import"./avatar-BZ2Ic3iH.js";const Le=(e,a)=>{const n=Z(),i=X({...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(p=>{!e||!a||l({path:{accountId:e,filterId:a},body:p})},[e,a,l]),isPending:i.isPending,isSuccess:i.isSuccess,isError:i.isError,error:i.error,reset:i.reset}},Te=(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"?ke(e.expiresAt):void 0,name:e.name}),ke=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),T=e=>JSON.stringify({scope:e.scope==="until"?"until":"standing",until:e.scope==="until"?e.until??"":""}),$=(e,a)=>T(e)!==T(a),Ae=(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 p=f.useMemo(()=>Te(a,l),[a,l]),[m,r]=f.useState(p),[c,u]=f.useState(),[h,g]=f.useState(!1),b=f.useRef(0),N=ge(e,ve(m)),v=Le(e,a.filterId),y=be(e),{createFolder:I}=Me(e),{createLabel:x}=Oe(e),F=async o=>{const s=await x(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(M=>M.id===c.clauseId?{id:M.id,field:o,value:s}:M)}:(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,p)||$(m,p),s=Ae(m,p);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(k,{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(E,{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(E,{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(E,{className:"size-8 text-positive"}):t.jsx(k,{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 p=Ne(),m=t.jsx(Re,{accountId:e,filter:a,folders:n,labels:i,semanticUnavailable:l,onClose:d});return p?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:p=!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,...p?{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:p}=Fe(a),{deleteFilter:m,deletingFilterId:r}=we(a),[c,u]=f.useState(),{data:h}=A({...xe({path:{accountId:a}}),staleTime:1/0}),g=f.useCallback(x=>{const F=h?.items.find(w=>w.mailboxId===x);return F?O(F.fullPath):void 0},[h?.items]),b=f.useMemo(()=>Ee(h?.items??[]).map(x=>({id:x.mailboxId,label:O(x.fullPath)})),[h?.items]),{labels:N}=De(a),v=f.useMemo(()=>N.map(x=>({id:x.labelId,name:x.name,color:x.color})),[N]),y=f.useMemo(()=>new Map(v.map(x=>[x.id,x])),[v]),I=n.find(x=>x.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:()=>{p()}}):t.jsx(Ke,{filters:n,mailboxName:g,labelById:y,onEdit:u,onDelete:m,deletingFilterId:r})]})}function et(){const e=ce(),[a,n]=f.useState(!0),{data:i,isPending:l,isError:d,error:p,refetch:m}=A(de()),r=c=>{const u=ue[c];u&&e({to:u})};return t.jsx(pe,{items:me,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:p,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{et as component};
1
+ import{$ as Z,at as X,bZ as ee,b_ as te,r as f,j as t,b$ as ae,b0 as se,L as k,B as C,D as ie,d as ne,c0 as re,i as oe,T as le,ae as ce,aq as A,aA as de,bM as me,bO as ue,af as xe,aQ as O}from"./index-CjjdPqU1.js";import{S as pe}from"./settings-screen-Bg_B152C.js";import{p as fe,N as S,q as he,c as ge,r as ve,d as be,S as D,f as ye,n as je,u as Ne,B as Ce,t as Se,v as Ie,w as Fe,x as we}from"./useRulePreview-2A1FYSkL.js";import{u as Me,b as Ee}from"./move-targets-BNX20jB1.js";import{a as Oe,u as De}from"./useLabels-CuOu4bk3.js";import{C as E}from"./circle-check-CegrtM_f.js";import{E as R}from"./ErrorState-Bohf_-oR.js";import"./avatar-Czt2WUmG.js";const Le=(e,a)=>{const n=Z(),i=X({...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(p=>{!e||!a||l({path:{accountId:e,filterId:a},body:p})},[e,a,l]),isPending:i.isPending,isSuccess:i.isSuccess,isError:i.isError,error:i.error,reset:i.reset}},Te=(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"?ke(e.expiresAt):void 0,name:e.name}),ke=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),T=e=>JSON.stringify({scope:e.scope==="until"?"until":"standing",until:e.scope==="until"?e.until??"":""}),$=(e,a)=>T(e)!==T(a),Ae=(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 p=f.useMemo(()=>Te(a,l),[a,l]),[m,r]=f.useState(p),[c,u]=f.useState(),[h,g]=f.useState(!1),b=f.useRef(0),N=ge(e,ve(m)),v=Le(e,a.filterId),y=be(e),{createFolder:I}=Me(e),{createLabel:x}=Oe(e),F=async o=>{const s=await x(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(M=>M.id===c.clauseId?{id:M.id,field:o,value:s}:M)}:(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,p)||$(m,p),s=Ae(m,p);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(k,{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(E,{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(E,{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(E,{className:"size-8 text-positive"}):t.jsx(k,{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 p=Ne(),m=t.jsx(Re,{accountId:e,filter:a,folders:n,labels:i,semanticUnavailable:l,onClose:d});return p?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:p=!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,...p?{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:p}=Fe(a),{deleteFilter:m,deletingFilterId:r}=we(a),[c,u]=f.useState(),{data:h}=A({...xe({path:{accountId:a}}),staleTime:1/0}),g=f.useCallback(x=>{const F=h?.items.find(w=>w.mailboxId===x);return F?O(F.fullPath):void 0},[h?.items]),b=f.useMemo(()=>Ee(h?.items??[]).map(x=>({id:x.mailboxId,label:O(x.fullPath)})),[h?.items]),{labels:N}=De(a),v=f.useMemo(()=>N.map(x=>({id:x.labelId,name:x.name,color:x.color})),[N]),y=f.useMemo(()=>new Map(v.map(x=>[x.id,x])),[v]),I=n.find(x=>x.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:()=>{p()}}):t.jsx(Ke,{filters:n,mailboxName:g,labelById:y,onEdit:u,onDelete:m,deletingFilterId:r})]})}function et(){const e=ce(),[a,n]=f.useState(!0),{data:i,isPending:l,isError:d,error:p,refetch:m}=A(de()),r=c=>{const u=ue[c];u&&e({to:u})};return t.jsx(pe,{items:me,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:p,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{et as component};
@@ -1 +1 @@
1
- import{j as r}from"./index-Bq9-ElVU.js";import{E as o}from"./ErrorState-CFWFzlbC.js";const l=({error:t,reset:e})=>r.jsx("div",{className:"flex h-full items-center justify-center bg-canvas p-4",children:r.jsx(o,{title:"Couldn't load your starred mail",error:t,onRetry:e})});export{l as errorComponent};
1
+ import{j as r}from"./index-CjjdPqU1.js";import{E as o}from"./ErrorState-Bohf_-oR.js";const l=({error:t,reset:e})=>r.jsx("div",{className:"flex h-full items-center justify-center bg-canvas p-4",children:r.jsx(o,{title:"Couldn't load your starred mail",error:t,onRetry:e})});export{l as errorComponent};
@@ -1 +1 @@
1
- import{j as e,c7 as B,r as f,c8 as Y,bB as q,b7 as Q,B as C,k as ee,c9 as te,$ as K,aL as V,bw as G,ca as se,cb as ae,bg as re,bl as H,aQ as F,L as R,l as L,T as S,D as ne,z as le,X as oe,ae as ie,aq as W,aA as ce,bM as de,bO as me,af as ue,at as $,cc as xe,cd as he,ce as fe,cf as pe}from"./index-Bq9-ElVU.js";import{a as ge,F as be,M as ve}from"./move-mailbox-picker-cazFNbBd.js";import{S as je}from"./settings-screen-Dio597Ai.js";import{u as X,b as ye,v as Ne,c as Ce}from"./move-targets-BwkC3Ixo.js";import{E as Z}from"./ErrorState-CFWFzlbC.js";import"./search-BvtA8qSj.js";import"./avatar-BZ2Ic3iH.js";const ke=["inbox","drafts","sent","archive","junk","trash"],T="";function Me(t){const a=t.messageCount===1?"msg":"msgs";return`${B(t.providerPath)} · ${t.messageCount} ${a}`}function we({role:t,folders:a,appointedId:s,displayName:n,onAppoint:d,onRename:o}){const[x,c]=f.useState(n),r=a.find(m=>m.mailboxId===s)??null,l=te(t),h=r!=null&&x.trim()!==n.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:[Y(t),l]}),e.jsxs(q,{className:"w-56 shrink-0",value:s??T,"aria-label":`Folder for ${l}`,onChange:m=>d(t,m.target.value===T?null:m.target.value),children:[e.jsx("option",{value:T,children:"None"}),a.map(m=>e.jsx("option",{value:m.mailboxId,children:Me(m)},m.mailboxId))]}),r&&e.jsxs(e.Fragment,{children:[e.jsx(Q,{className:"flex-1",value:x,placeholder:l,"aria-label":`Display name for ${l}`,onChange:m=>c(m.target.value)}),h&&e.jsx(C,{variant:"ghost",size:"sm",className:"shrink-0",icon:e.jsx(ee,{className:"size-4"}),"aria-label":"Save display name",onClick:()=>o(r.mailboxId,x)})]})]}),r&&e.jsxs("span",{className:"truncate pl-[7.5rem] text-2xs text-fg-subtle",title:r.providerPath,children:[r.providerPath," · ",r.messageCount," ",r.messageCount===1?"message":"messages"]})]})}function Ie({accountEmail:t,folders:a,appointments:s,displayNames:n={},onAppoint:d,onRename:o}){const x=new Set(Object.values(s).filter(r=>r!=null)),c=a.filter(r=>!x.has(r.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 — ",t]}),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:ke.map(r=>{const l=s[r]??null;return e.jsx(we,{role:r,folders:a,appointedId:l,displayName:l?n[l]??"":"",onAppoint:d,onRename:o},r)})}),c.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:c.map(r=>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(ge,{className:"size-4 shrink-0 text-fg-subtle"}),e.jsx("span",{className:"truncate",children:B(r.providerPath)}),e.jsxs("span",{className:"ml-auto shrink-0 text-2xs text-fg-subtle",children:[r.messageCount," ",r.messageCount===1?"message":"messages"]})]},r.mailboxId))})]})]})}const Pe=100,De=t=>t.trim().toLowerCase()==="inbox",Oe=(t,a)=>{const s=`${t.fullPath}${t.hierarchyDelimiter}`;return a.some(n=>n.mailboxId!==t.mailboxId&&n.fullPath.startsWith(s))},Se=(t,a)=>a.find(s=>s.mailboxId!=null&&s.mailboxId===t)?.role;function Ee(t,a,s){if(De(t.fullPath))return{deletable:!1,reason:"inbox",message:"The inbox can't be deleted."};const n=Se(t.mailboxId,s);return n?{deletable:!1,reason:"role",message:`This folder is your ${n} folder. Reassign that role before deleting it.`}:Oe(t,a)?{deletable:!1,reason:"children",message:"This folder has subfolders. Delete them first."}:{deletable:!0}}function Te(t,a){return t.filter(s=>s.mailboxId!==a)}function Ae(t){return{total:t,moved:0,phase:t===0?"moved":"moving"}}function Fe(t,a){if(t.phase!=="moving")return t;const s=Math.min(t.total,t.moved+Math.max(0,a));return{...t,moved:s,phase:s>=t.total?"moved":"moving"}}function O(t,a){return{...t,phase:"failed",error:a}}function z(t){return`Moved ${t.moved} of ${t.total}`}function _(t){return t>0?"choose-fate":"confirm-empty"}const J=50,Le=t=>t instanceof Error?t.message:"Something went wrong.",P=t=>t.then(a=>({ok:!0,value:a}),a=>({ok:!1,error:Le(a)})),Re=async(t,a,s,n)=>{const d=[];let o;for(let x=0;x<J;x+=1){if(n.aborted)return d;const{data:c}=await H({path:{mailboxId:t},query:{order:"desc",continuationToken:o},throwOnError:!0});for(const r of c.items)if(!r.isDeleted&&!a.has(r.messageId)&&!d.includes(r.messageId)&&(d.push(r.messageId),d.length>=s))return d;if(!c.continuationToken)break;o=c.continuationToken}return d},$e=async(t,a)=>{let s=0,n;for(let d=0;d<J;d+=1){if(a.aborted)return s;const{data:o}=await H({path:{mailboxId:t},query:{order:"desc",continuationToken:n},throwOnError:!0});for(const x of o.items)x.isDeleted||(s+=1);if(!o.continuationToken)break;n=o.continuationToken}return s};function ze({accountId:t,mailboxId:a,onDeleted:s}){const n=K(),[d,o]=f.useState("idle"),[x,c]=f.useState(null),[r,l]=f.useState(),h=f.useRef(null),m=f.useCallback(()=>{n.invalidateQueries({queryKey:V({path:{accountId:t}})}),n.invalidateQueries({queryKey:G()})},[n,t]),j=f.useCallback(async()=>{o("deleting");const i=await P(se({path:{accountId:t,mailboxId:a},throwOnError:!0}));if(!i.ok){l(i.error),o("error");return}m(),o("done"),s()},[t,a,m,s]),k=f.useCallback(()=>ae({path:{accountId:t},throwOnError:!0}).then(({data:i})=>i.items.find(p=>p.mailboxId===a)?.messageCount??0),[t,a]),u=f.useCallback(()=>{h.current?.abort()},[]),M=f.useCallback(async i=>{const p=new AbortController;h.current=p;const{signal:g}=p;o("moving"),l(void 0);const I=await P(k());if(g.aborted)return;if(!I.ok){l(I.error),o("error");return}let b=Ae(I.value);c(b);const v=new Set;for(;;){if(g.aborted)return;const N=await P(Re(a,v,Pe,g));if(g.aborted)return;if(!N.ok){b=O(b,N.error),c(b),l(N.error),o("error");return}const D=N.value;if(D.length===0)break;const E=await P(re({body:{messageIds:D,destinationMailboxId:i},throwOnError:!0}));if(g.aborted)return;if(!E.ok){b=O(b,E.error),c(b),l(E.error),o("error");return}for(const U of D)v.add(U);b=Fe(b,D.length),c(b)}const w=await P($e(a,g));if(!g.aborted){if(!w.ok){b=O(b,w.error),c(b),l(w.error),o("error");return}if(w.value>0){const N=`${w.value} ${w.value===1?"email is":"emails are"} still syncing. Re-open delete to finish removing this folder.`;b=O(b,N),c(b),l(N),o("error"),m();return}await j()}},[a,k,j,m]),y=f.useCallback(()=>{h.current?.abort(),h.current=null,o("idle"),c(null),l(void 0)},[]);return{phase:d,progress:x,errorMessage:r,deleteMailbox:j,moveThenDelete:M,cancel:u,reset:y}}const _e=t=>t.displayNameOverride?.trim()||F(t.fullPath),A=t=>`${t} ${t===1?"email":"emails"}`;function Be({open:t,accountId:a,folder:s,mailboxes:n,appointments:d,onClose:o}){const[x,c]=f.useState(()=>_(s.messageCount)),{createFolder:r}=X(a),{phase:l,progress:h,errorMessage:m,deleteMailbox:j,moveThenDelete:k,cancel:u,reset:M}=ze({accountId:a,mailboxId:s.mailboxId,onDeleted:o});f.useEffect(()=>{t&&(c(_(s.messageCount)),M())},[t,s.messageCount,M]),f.useEffect(()=>u,[u]);const y=f.useCallback(()=>{u(),o()},[u,o]),i=f.useMemo(()=>Te(ye(n,d),s.mailboxId).map(v=>({id:v.mailboxId,label:F(v.fullPath),searchValue:v.fullPath})),[n,d,s.mailboxId]),p=async(v,w)=>{const N=await r(v,w);return{id:N.id,label:N.label}};if(!t)return null;const g=_e(s),I=`Delete ${g}`,b=l==="moving"?e.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[e.jsx(R,{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:h?z(h):"Moved 0 of 0"})]}):l==="deleting"||l==="done"?e.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[e.jsx(R,{className:"size-8 animate-spin text-accent-2"}),e.jsx("p",{className:"text-sm font-medium text-fg",children:"Deleting folder…"})]}):l==="error"?e.jsxs("div",{className:"space-y-4 px-5 py-4",children:[e.jsx(L,{tone:"danger",variant:"soft",children:m??"Something went wrong. Please try again."}),h&&e.jsxs("p",{className:"text-xs text-fg-muted",children:[z(h),". Already-moved emails stay moved — re-open delete to continue with the rest."]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(C,{variant:"secondary",size:"sm",onClick:y,children:"Close"})})]}):x==="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:g}),"? 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(C,{variant:"secondary",size:"sm",onClick:y,children:"Cancel"}),e.jsx(C,{variant:"danger",size:"sm",icon:e.jsx(S,{className:"size-3.5"}),onClick:()=>j(),children:"Delete folder"})]})]}):x==="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:g})," holds"," ",A(s.messageCount),". What should happen to them?"]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("button",{type:"button",onClick:()=>c("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(S,{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:()=>c("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(be,{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(C,{variant:"secondary",size:"sm",onClick:y,children:"Cancel"})})]}):x==="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:g})," and its"," ",A(s.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(C,{variant:"secondary",size:"sm",onClick:()=>c("choose-fate"),children:"Back"}),e.jsx(C,{variant:"danger",size:"sm",icon:e.jsx(S,{className:"size-3.5"}),onClick:()=>j(),children:"Delete folder and emails"})]})]}):e.jsxs("div",{className:"flex h-80 flex-col",children:[e.jsxs("p",{className:"px-5 pt-4 text-sm text-fg-muted",children:["Move the ",A(s.messageCount)," in"," ",e.jsx("strong",{className:"text-fg",children:g})," to:"]}),e.jsx("div",{className:"min-h-0 flex-1 px-2 py-2",children:e.jsx(ve,{mailboxes:i,onSelect:v=>k(v),onCreateFolder:p,onCancel:()=>c("choose-fate"),labels:{searchPlaceholder:"Move emails to…",optionLabel:v=>`Move to ${v}`,createLabel:v=>`Create "${v}"`}})})]});return e.jsxs(ne,{open:t,onClose:y,title:I,children:[e.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[e.jsx(le,{className:"size-4 shrink-0 text-danger"}),e.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:I}),e.jsx(C,{variant:"ghost",size:"sm",icon:e.jsx(oe,{className:"size-3.5"}),onClick:y,"aria-label":"Cancel"})]}),b]})}const qe=e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{children:"Each canonical role — Inbox, Drafts, Sent, Archive, Spam, Trash — points at one of your account's real folders. Pick the one that actually holds the mail; the message counts tell real folders from empty look-alikes."}),e.jsx("p",{children:`Appointing a folder to a role here doesn't touch any other role, and doesn't move or rename anything on the server — it just tells Remit which folder to treat as e.g. "Drafts" everywhere (sidebar, unread badges, the compose flow).`}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Display name"})," renames the appointed folder for the sidebar. Leave it blank to use the role's canonical name."]})]});function Qe({accountId:t,mailboxes:a}){const{mutation:s}=X(t),[n,d]=f.useState(""),[o,x]=f.useState(""),[c,r]=f.useState(),l=a[0]?.hierarchyDelimiter??"/",h=a.find(u=>u.mailboxId===o),m=h?{fullPath:h.fullPath,hierarchyDelimiter:h.hierarchyDelimiter}:void 0,j=m?.hierarchyDelimiter??l,k=()=>{const u=Ne({name:n,delimiter:j,parent:m,existingPaths:a.map(M=>M.fullPath)});if(u){r(u);return}r(void 0),s.mutate({path:{accountId:t},body:{fullPath:Ce(n,m),namespaceType:"personal"}},{onSuccess:()=>{d(""),x("")}})};return e.jsxs("div",{className:"space-y-2 rounded-sm border border-line bg-surface p-3",children:[e.jsx("p",{className:"text-sm font-medium text-fg",children:"New folder"}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-end",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx("span",{className:"text-xs text-fg-muted",children:"Name"}),e.jsx(Q,{value:n,onChange:u=>{d(u.target.value),c&&r(void 0)},placeholder:"e.g. Receipts","aria-label":"Folder name",onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),k())}})]}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx("span",{className:"text-xs text-fg-muted",children:"Inside (optional)"}),e.jsxs(q,{value:o,onChange:u=>x(u.target.value),"aria-label":"Parent folder",children:[e.jsx("option",{value:"",children:"No parent — top level"}),a.map(u=>e.jsx("option",{value:u.mailboxId,children:u.fullPath},u.mailboxId))]})]}),e.jsx(C,{variant:"primary",onClick:k,disabled:s.isPending||n.trim()==="",children:s.isPending?"Creating…":"Create folder"})]}),c&&e.jsx("p",{className:"text-xs text-danger",role:"alert",children:c}),s.isError&&e.jsx(L,{tone:"danger",variant:"soft",children:"Couldn't create that folder. Please try again."})]})}function Ke({account:t}){const a=K(),s=t.accountId,{data:n,isPending:d,isError:o,error:x,refetch:c}=W(ue({path:{accountId:s}})),r=$({...xe(),onSuccess:()=>{a.invalidateQueries({queryKey:G()})}}),l=$({...he(),onSuccess:()=>{a.invalidateQueries({queryKey:V({path:{accountId:s}})})}}),[h,m]=f.useState(),j=(i,p)=>{r.mutate({path:{accountId:s,role:pe[i]},body:{mailboxId:p}})},k=(i,p)=>{const g=p.trim();l.mutate({path:{accountId:s,mailboxId:i},body:{displayNameOverride:g===""?null:g}})};if(d)return e.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":`Loading folders for ${t.email}`});if(o)return e.jsx(Z,{variant:"inline",title:`Couldn't load folders for ${t.email}`,error:x,onRetry:()=>{c()}});const u=n.items.map(i=>({mailboxId:i.mailboxId,providerPath:i.fullPath,messageCount:i.messageCount})),M={};for(const i of t.folderAppointments){const p=fe[i.role];p&&(M[p]=i.mailboxId??null)}const y={};for(const i of n.items)i.displayNameOverride&&(y[i.mailboxId]=i.displayNameOverride);return e.jsxs("div",{className:"space-y-2",children:[(r.isError||l.isError)&&e.jsx(L,{tone:"danger",variant:"soft",children:"Couldn't save that change. Please try again."}),e.jsx(Ie,{accountEmail:t.email,folders:u,appointments:M,displayNames:y,onAppoint:j,onRename:k}),e.jsx(Qe,{accountId:s,mailboxes:n.items}),e.jsx("ul",{className:"space-y-1","aria-label":`All folders for ${t.email}`,children:n.items.map(i=>{const p=Ee(i,n.items,t.folderAppointments),g=F(i.fullPath);return e.jsxs("li",{className:"flex items-center gap-2 rounded-sm px-2 py-1 text-sm text-fg",children:[e.jsx("span",{className:"truncate",children:g}),e.jsx("span",{className:"ml-auto shrink-0 text-xs text-fg-muted",children:i.fullPath}),e.jsx(C,{variant:"ghost",size:"sm",icon:e.jsx(S,{className:"size-3.5"}),"aria-label":`Delete ${g}`,disabled:!p.deletable,title:p.deletable?void 0:p.message,onClick:()=>m(i.mailboxId),className:p.deletable?void 0:"opacity-40"})]},i.mailboxId)})}),h&&(()=>{const i=n.items.find(p=>p.mailboxId===h);return i?e.jsx(Be,{open:!0,accountId:s,folder:i,mailboxes:n.items,appointments:t.folderAppointments,onClose:()=>m(void 0)}):null})()]})}function Ue(){const t=ie(),[a,s]=f.useState(!0),{data:n,isPending:d,isError:o,error:x,refetch:c}=W(ce()),r=l=>{const h=me[l];h&&t({to:h})};return e.jsx(je,{items:de,activeId:"folders",title:"Folder roles",description:"Appoint which real folder fills each canonical role, per account.",help:qe,helpOpen:a,onToggleHelp:()=>s(l=>!l),onSelect:r,onBackToMail:()=>{t({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"}):o?e.jsx(Z,{title:"Couldn't load accounts",error:x,onRetry:()=>{c()}}):n.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:n.accounts.map(l=>e.jsx(Ke,{account:l},l.accountId))})})}export{Ue as component};
1
+ import{j as e,c7 as B,r as f,c8 as Y,bB as q,b7 as Q,B as C,k as ee,c9 as te,$ as K,aL as V,bw as G,ca as se,cb as ae,bg as re,bl as H,aQ as F,L as R,l as L,T as S,D as ne,z as le,X as oe,ae as ie,aq as W,aA as ce,bM as de,bO as me,af as ue,at as $,cc as xe,cd as he,ce as fe,cf as pe}from"./index-CjjdPqU1.js";import{a as ge,F as be,M as ve}from"./move-mailbox-picker-D_V1MWbw.js";import{S as je}from"./settings-screen-Bg_B152C.js";import{u as X,b as ye,v as Ne,c as Ce}from"./move-targets-BNX20jB1.js";import{E as Z}from"./ErrorState-Bohf_-oR.js";import"./search-BEDItR13.js";import"./avatar-Czt2WUmG.js";const ke=["inbox","drafts","sent","archive","junk","trash"],T="";function Me(t){const a=t.messageCount===1?"msg":"msgs";return`${B(t.providerPath)} · ${t.messageCount} ${a}`}function we({role:t,folders:a,appointedId:s,displayName:n,onAppoint:d,onRename:o}){const[x,c]=f.useState(n),r=a.find(m=>m.mailboxId===s)??null,l=te(t),h=r!=null&&x.trim()!==n.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:[Y(t),l]}),e.jsxs(q,{className:"w-56 shrink-0",value:s??T,"aria-label":`Folder for ${l}`,onChange:m=>d(t,m.target.value===T?null:m.target.value),children:[e.jsx("option",{value:T,children:"None"}),a.map(m=>e.jsx("option",{value:m.mailboxId,children:Me(m)},m.mailboxId))]}),r&&e.jsxs(e.Fragment,{children:[e.jsx(Q,{className:"flex-1",value:x,placeholder:l,"aria-label":`Display name for ${l}`,onChange:m=>c(m.target.value)}),h&&e.jsx(C,{variant:"ghost",size:"sm",className:"shrink-0",icon:e.jsx(ee,{className:"size-4"}),"aria-label":"Save display name",onClick:()=>o(r.mailboxId,x)})]})]}),r&&e.jsxs("span",{className:"truncate pl-[7.5rem] text-2xs text-fg-subtle",title:r.providerPath,children:[r.providerPath," · ",r.messageCount," ",r.messageCount===1?"message":"messages"]})]})}function Ie({accountEmail:t,folders:a,appointments:s,displayNames:n={},onAppoint:d,onRename:o}){const x=new Set(Object.values(s).filter(r=>r!=null)),c=a.filter(r=>!x.has(r.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 — ",t]}),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:ke.map(r=>{const l=s[r]??null;return e.jsx(we,{role:r,folders:a,appointedId:l,displayName:l?n[l]??"":"",onAppoint:d,onRename:o},r)})}),c.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:c.map(r=>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(ge,{className:"size-4 shrink-0 text-fg-subtle"}),e.jsx("span",{className:"truncate",children:B(r.providerPath)}),e.jsxs("span",{className:"ml-auto shrink-0 text-2xs text-fg-subtle",children:[r.messageCount," ",r.messageCount===1?"message":"messages"]})]},r.mailboxId))})]})]})}const Pe=100,De=t=>t.trim().toLowerCase()==="inbox",Oe=(t,a)=>{const s=`${t.fullPath}${t.hierarchyDelimiter}`;return a.some(n=>n.mailboxId!==t.mailboxId&&n.fullPath.startsWith(s))},Se=(t,a)=>a.find(s=>s.mailboxId!=null&&s.mailboxId===t)?.role;function Ee(t,a,s){if(De(t.fullPath))return{deletable:!1,reason:"inbox",message:"The inbox can't be deleted."};const n=Se(t.mailboxId,s);return n?{deletable:!1,reason:"role",message:`This folder is your ${n} folder. Reassign that role before deleting it.`}:Oe(t,a)?{deletable:!1,reason:"children",message:"This folder has subfolders. Delete them first."}:{deletable:!0}}function Te(t,a){return t.filter(s=>s.mailboxId!==a)}function Ae(t){return{total:t,moved:0,phase:t===0?"moved":"moving"}}function Fe(t,a){if(t.phase!=="moving")return t;const s=Math.min(t.total,t.moved+Math.max(0,a));return{...t,moved:s,phase:s>=t.total?"moved":"moving"}}function O(t,a){return{...t,phase:"failed",error:a}}function z(t){return`Moved ${t.moved} of ${t.total}`}function _(t){return t>0?"choose-fate":"confirm-empty"}const J=50,Le=t=>t instanceof Error?t.message:"Something went wrong.",P=t=>t.then(a=>({ok:!0,value:a}),a=>({ok:!1,error:Le(a)})),Re=async(t,a,s,n)=>{const d=[];let o;for(let x=0;x<J;x+=1){if(n.aborted)return d;const{data:c}=await H({path:{mailboxId:t},query:{order:"desc",continuationToken:o},throwOnError:!0});for(const r of c.items)if(!r.isDeleted&&!a.has(r.messageId)&&!d.includes(r.messageId)&&(d.push(r.messageId),d.length>=s))return d;if(!c.continuationToken)break;o=c.continuationToken}return d},$e=async(t,a)=>{let s=0,n;for(let d=0;d<J;d+=1){if(a.aborted)return s;const{data:o}=await H({path:{mailboxId:t},query:{order:"desc",continuationToken:n},throwOnError:!0});for(const x of o.items)x.isDeleted||(s+=1);if(!o.continuationToken)break;n=o.continuationToken}return s};function ze({accountId:t,mailboxId:a,onDeleted:s}){const n=K(),[d,o]=f.useState("idle"),[x,c]=f.useState(null),[r,l]=f.useState(),h=f.useRef(null),m=f.useCallback(()=>{n.invalidateQueries({queryKey:V({path:{accountId:t}})}),n.invalidateQueries({queryKey:G()})},[n,t]),j=f.useCallback(async()=>{o("deleting");const i=await P(se({path:{accountId:t,mailboxId:a},throwOnError:!0}));if(!i.ok){l(i.error),o("error");return}m(),o("done"),s()},[t,a,m,s]),k=f.useCallback(()=>ae({path:{accountId:t},throwOnError:!0}).then(({data:i})=>i.items.find(p=>p.mailboxId===a)?.messageCount??0),[t,a]),u=f.useCallback(()=>{h.current?.abort()},[]),M=f.useCallback(async i=>{const p=new AbortController;h.current=p;const{signal:g}=p;o("moving"),l(void 0);const I=await P(k());if(g.aborted)return;if(!I.ok){l(I.error),o("error");return}let b=Ae(I.value);c(b);const v=new Set;for(;;){if(g.aborted)return;const N=await P(Re(a,v,Pe,g));if(g.aborted)return;if(!N.ok){b=O(b,N.error),c(b),l(N.error),o("error");return}const D=N.value;if(D.length===0)break;const E=await P(re({body:{messageIds:D,destinationMailboxId:i},throwOnError:!0}));if(g.aborted)return;if(!E.ok){b=O(b,E.error),c(b),l(E.error),o("error");return}for(const U of D)v.add(U);b=Fe(b,D.length),c(b)}const w=await P($e(a,g));if(!g.aborted){if(!w.ok){b=O(b,w.error),c(b),l(w.error),o("error");return}if(w.value>0){const N=`${w.value} ${w.value===1?"email is":"emails are"} still syncing. Re-open delete to finish removing this folder.`;b=O(b,N),c(b),l(N),o("error"),m();return}await j()}},[a,k,j,m]),y=f.useCallback(()=>{h.current?.abort(),h.current=null,o("idle"),c(null),l(void 0)},[]);return{phase:d,progress:x,errorMessage:r,deleteMailbox:j,moveThenDelete:M,cancel:u,reset:y}}const _e=t=>t.displayNameOverride?.trim()||F(t.fullPath),A=t=>`${t} ${t===1?"email":"emails"}`;function Be({open:t,accountId:a,folder:s,mailboxes:n,appointments:d,onClose:o}){const[x,c]=f.useState(()=>_(s.messageCount)),{createFolder:r}=X(a),{phase:l,progress:h,errorMessage:m,deleteMailbox:j,moveThenDelete:k,cancel:u,reset:M}=ze({accountId:a,mailboxId:s.mailboxId,onDeleted:o});f.useEffect(()=>{t&&(c(_(s.messageCount)),M())},[t,s.messageCount,M]),f.useEffect(()=>u,[u]);const y=f.useCallback(()=>{u(),o()},[u,o]),i=f.useMemo(()=>Te(ye(n,d),s.mailboxId).map(v=>({id:v.mailboxId,label:F(v.fullPath),searchValue:v.fullPath})),[n,d,s.mailboxId]),p=async(v,w)=>{const N=await r(v,w);return{id:N.id,label:N.label}};if(!t)return null;const g=_e(s),I=`Delete ${g}`,b=l==="moving"?e.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[e.jsx(R,{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:h?z(h):"Moved 0 of 0"})]}):l==="deleting"||l==="done"?e.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[e.jsx(R,{className:"size-8 animate-spin text-accent-2"}),e.jsx("p",{className:"text-sm font-medium text-fg",children:"Deleting folder…"})]}):l==="error"?e.jsxs("div",{className:"space-y-4 px-5 py-4",children:[e.jsx(L,{tone:"danger",variant:"soft",children:m??"Something went wrong. Please try again."}),h&&e.jsxs("p",{className:"text-xs text-fg-muted",children:[z(h),". Already-moved emails stay moved — re-open delete to continue with the rest."]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(C,{variant:"secondary",size:"sm",onClick:y,children:"Close"})})]}):x==="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:g}),"? 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(C,{variant:"secondary",size:"sm",onClick:y,children:"Cancel"}),e.jsx(C,{variant:"danger",size:"sm",icon:e.jsx(S,{className:"size-3.5"}),onClick:()=>j(),children:"Delete folder"})]})]}):x==="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:g})," holds"," ",A(s.messageCount),". What should happen to them?"]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("button",{type:"button",onClick:()=>c("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(S,{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:()=>c("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(be,{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(C,{variant:"secondary",size:"sm",onClick:y,children:"Cancel"})})]}):x==="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:g})," and its"," ",A(s.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(C,{variant:"secondary",size:"sm",onClick:()=>c("choose-fate"),children:"Back"}),e.jsx(C,{variant:"danger",size:"sm",icon:e.jsx(S,{className:"size-3.5"}),onClick:()=>j(),children:"Delete folder and emails"})]})]}):e.jsxs("div",{className:"flex h-80 flex-col",children:[e.jsxs("p",{className:"px-5 pt-4 text-sm text-fg-muted",children:["Move the ",A(s.messageCount)," in"," ",e.jsx("strong",{className:"text-fg",children:g})," to:"]}),e.jsx("div",{className:"min-h-0 flex-1 px-2 py-2",children:e.jsx(ve,{mailboxes:i,onSelect:v=>k(v),onCreateFolder:p,onCancel:()=>c("choose-fate"),labels:{searchPlaceholder:"Move emails to…",optionLabel:v=>`Move to ${v}`,createLabel:v=>`Create "${v}"`}})})]});return e.jsxs(ne,{open:t,onClose:y,title:I,children:[e.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[e.jsx(le,{className:"size-4 shrink-0 text-danger"}),e.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:I}),e.jsx(C,{variant:"ghost",size:"sm",icon:e.jsx(oe,{className:"size-3.5"}),onClick:y,"aria-label":"Cancel"})]}),b]})}const qe=e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{children:"Each canonical role — Inbox, Drafts, Sent, Archive, Spam, Trash — points at one of your account's real folders. Pick the one that actually holds the mail; the message counts tell real folders from empty look-alikes."}),e.jsx("p",{children:`Appointing a folder to a role here doesn't touch any other role, and doesn't move or rename anything on the server — it just tells Remit which folder to treat as e.g. "Drafts" everywhere (sidebar, unread badges, the compose flow).`}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Display name"})," renames the appointed folder for the sidebar. Leave it blank to use the role's canonical name."]})]});function Qe({accountId:t,mailboxes:a}){const{mutation:s}=X(t),[n,d]=f.useState(""),[o,x]=f.useState(""),[c,r]=f.useState(),l=a[0]?.hierarchyDelimiter??"/",h=a.find(u=>u.mailboxId===o),m=h?{fullPath:h.fullPath,hierarchyDelimiter:h.hierarchyDelimiter}:void 0,j=m?.hierarchyDelimiter??l,k=()=>{const u=Ne({name:n,delimiter:j,parent:m,existingPaths:a.map(M=>M.fullPath)});if(u){r(u);return}r(void 0),s.mutate({path:{accountId:t},body:{fullPath:Ce(n,m),namespaceType:"personal"}},{onSuccess:()=>{d(""),x("")}})};return e.jsxs("div",{className:"space-y-2 rounded-sm border border-line bg-surface p-3",children:[e.jsx("p",{className:"text-sm font-medium text-fg",children:"New folder"}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-end",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx("span",{className:"text-xs text-fg-muted",children:"Name"}),e.jsx(Q,{value:n,onChange:u=>{d(u.target.value),c&&r(void 0)},placeholder:"e.g. Receipts","aria-label":"Folder name",onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),k())}})]}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx("span",{className:"text-xs text-fg-muted",children:"Inside (optional)"}),e.jsxs(q,{value:o,onChange:u=>x(u.target.value),"aria-label":"Parent folder",children:[e.jsx("option",{value:"",children:"No parent — top level"}),a.map(u=>e.jsx("option",{value:u.mailboxId,children:u.fullPath},u.mailboxId))]})]}),e.jsx(C,{variant:"primary",onClick:k,disabled:s.isPending||n.trim()==="",children:s.isPending?"Creating…":"Create folder"})]}),c&&e.jsx("p",{className:"text-xs text-danger",role:"alert",children:c}),s.isError&&e.jsx(L,{tone:"danger",variant:"soft",children:"Couldn't create that folder. Please try again."})]})}function Ke({account:t}){const a=K(),s=t.accountId,{data:n,isPending:d,isError:o,error:x,refetch:c}=W(ue({path:{accountId:s}})),r=$({...xe(),onSuccess:()=>{a.invalidateQueries({queryKey:G()})}}),l=$({...he(),onSuccess:()=>{a.invalidateQueries({queryKey:V({path:{accountId:s}})})}}),[h,m]=f.useState(),j=(i,p)=>{r.mutate({path:{accountId:s,role:pe[i]},body:{mailboxId:p}})},k=(i,p)=>{const g=p.trim();l.mutate({path:{accountId:s,mailboxId:i},body:{displayNameOverride:g===""?null:g}})};if(d)return e.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":`Loading folders for ${t.email}`});if(o)return e.jsx(Z,{variant:"inline",title:`Couldn't load folders for ${t.email}`,error:x,onRetry:()=>{c()}});const u=n.items.map(i=>({mailboxId:i.mailboxId,providerPath:i.fullPath,messageCount:i.messageCount})),M={};for(const i of t.folderAppointments){const p=fe[i.role];p&&(M[p]=i.mailboxId??null)}const y={};for(const i of n.items)i.displayNameOverride&&(y[i.mailboxId]=i.displayNameOverride);return e.jsxs("div",{className:"space-y-2",children:[(r.isError||l.isError)&&e.jsx(L,{tone:"danger",variant:"soft",children:"Couldn't save that change. Please try again."}),e.jsx(Ie,{accountEmail:t.email,folders:u,appointments:M,displayNames:y,onAppoint:j,onRename:k}),e.jsx(Qe,{accountId:s,mailboxes:n.items}),e.jsx("ul",{className:"space-y-1","aria-label":`All folders for ${t.email}`,children:n.items.map(i=>{const p=Ee(i,n.items,t.folderAppointments),g=F(i.fullPath);return e.jsxs("li",{className:"flex items-center gap-2 rounded-sm px-2 py-1 text-sm text-fg",children:[e.jsx("span",{className:"truncate",children:g}),e.jsx("span",{className:"ml-auto shrink-0 text-xs text-fg-muted",children:i.fullPath}),e.jsx(C,{variant:"ghost",size:"sm",icon:e.jsx(S,{className:"size-3.5"}),"aria-label":`Delete ${g}`,disabled:!p.deletable,title:p.deletable?void 0:p.message,onClick:()=>m(i.mailboxId),className:p.deletable?void 0:"opacity-40"})]},i.mailboxId)})}),h&&(()=>{const i=n.items.find(p=>p.mailboxId===h);return i?e.jsx(Be,{open:!0,accountId:s,folder:i,mailboxes:n.items,appointments:t.folderAppointments,onClose:()=>m(void 0)}):null})()]})}function Ue(){const t=ie(),[a,s]=f.useState(!0),{data:n,isPending:d,isError:o,error:x,refetch:c}=W(ce()),r=l=>{const h=me[l];h&&t({to:h})};return e.jsx(je,{items:de,activeId:"folders",title:"Folder roles",description:"Appoint which real folder fills each canonical role, per account.",help:qe,helpOpen:a,onToggleHelp:()=>s(l=>!l),onSelect:r,onBackToMail:()=>{t({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"}):o?e.jsx(Z,{title:"Couldn't load accounts",error:x,onRetry:()=>{c()}}):n.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:n.accounts.map(l=>e.jsx(Ke,{account:l},l.accountId))})})}export{Ue as component};
@@ -1 +1 @@
1
- import{j as r}from"./index-Bq9-ElVU.js";import{E as t}from"./ErrorState-CFWFzlbC.js";const n=({error:e,reset:o})=>r.jsx("div",{className:"flex h-full items-center justify-center bg-canvas p-4",children:r.jsx(t,{title:"Couldn't load your mailboxes",error:e,onRetry:o})});export{n as errorComponent};
1
+ import{j as r}from"./index-CjjdPqU1.js";import{E as t}from"./ErrorState-Bohf_-oR.js";const n=({error:e,reset:o})=>r.jsx("div",{className:"flex h-full items-center justify-center bg-canvas p-4",children:r.jsx(t,{title:"Couldn't load your mailboxes",error:e,onRetry:o})});export{n as errorComponent};
@@ -0,0 +1 @@
1
+ import{j as t,bx as o}from"./index-CjjdPqU1.js";const n=()=>t.jsx(o,{to:"/settings/accounts"});export{n as component};