@remit/web-client-dist 0.0.134 → 0.0.136

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 (47) hide show
  1. package/assets/{ComposeBody-Bb-eV7oX.js → ComposeBody-5KqS6Ij5.js} +3 -3
  2. package/assets/{ErrorState-DaIYWAtU.js → ErrorState-P3tyjYd6.js} +1 -1
  3. package/assets/OnboardingWizard-BtgUIapF.js +1 -0
  4. package/assets/{account-form-helpers-C1-XCp2v.js → account-form-helpers-DKi90s1d.js} +1 -1
  5. package/assets/accounts-DVe_U34F.js +1 -0
  6. package/assets/{advanced-hyewI6NP.js → advanced-BJudDEtv.js} +1 -1
  7. package/assets/{appearance-CEbzMr1T.js → appearance-B9BfHWr3.js} +1 -1
  8. package/assets/{avatar-WAi3XoGV.js → avatar-CR0MjNQb.js} +1 -1
  9. package/assets/{browser-ponyfill-odsmUzM4.js → browser-ponyfill-D4K5nA2g.js} +1 -1
  10. package/assets/{circle-check-Ccc0DpRT.js → circle-check-CQc7Z-g_.js} +1 -1
  11. package/assets/{download-B21Knqu2.js → download-BwZZ6fHn.js} +1 -1
  12. package/assets/filters-BqQU0AaG.js +1 -0
  13. package/assets/{flagged-CWyvtGeg.js → flagged-wi9oE00y.js} +1 -1
  14. package/assets/folders-xo8V7q4o.js +1 -0
  15. package/assets/index-BppznZgS.js +1 -0
  16. package/assets/{index-ChxiTmNG.css → index-d_OAoL-b.css} +1 -1
  17. package/assets/{index-DFY6-7Ge.js → index-mw9-5Sfa.js} +1 -1
  18. package/assets/index-y4HM-c82.js +295 -0
  19. package/assets/{kbd-BKNut3M9.js → kbd-ggO-xzUV.js} +1 -1
  20. package/assets/mail-CXuKcONg.js +118 -0
  21. package/assets/move-mailbox-picker-DjM7YNDC.js +1 -0
  22. package/assets/move-targets-B73391KU.js +1 -0
  23. package/assets/onboarding-BxdiSSnh.js +1 -0
  24. package/assets/{rotate-ccw-EQBbw3Gs.js → rotate-ccw-Dqu0WVzd.js} +1 -1
  25. package/assets/search-BDq8flHN.js +1 -0
  26. package/assets/senders-CMInGGgI.js +1 -0
  27. package/assets/settings-DOa_f_nW.js +1 -0
  28. package/assets/{settings-screen-6C3zeyy1.js → settings-screen-Bv6OlQNg.js} +1 -1
  29. package/assets/{suggested-vips-BvoEfJ52.js → suggested-vips-ikj4fiec.js} +1 -1
  30. package/assets/useDebouncedValue-BfSwxm-5.js +1 -0
  31. package/assets/useRulePreview-CNOJHtad.js +1 -0
  32. package/assets/{useSignature-B22ZnEj4.js → useSignature-BhNCrBVz.js} +1 -1
  33. package/index.html +2 -2
  34. package/package.json +1 -1
  35. package/assets/OnboardingWizard-74ApF1TM.js +0 -1
  36. package/assets/accounts-BCrN_WZY.js +0 -1
  37. package/assets/filters-Tqa-_zb9.js +0 -1
  38. package/assets/folder-DOSErHSR.js +0 -1
  39. package/assets/folders-CLWqJfFM.js +0 -1
  40. package/assets/index-DsR4Mk7n.js +0 -295
  41. package/assets/index-aL9qdiwR.js +0 -1
  42. package/assets/mail-BMBn_nLi.js +0 -118
  43. package/assets/onboarding-yY91msSU.js +0 -1
  44. package/assets/senders-DKiu2US4.js +0 -1
  45. package/assets/settings-BGBibXai.js +0 -1
  46. package/assets/useDebouncedValue-C_J4lOpx.js +0 -1
  47. package/assets/useRulePreview-Ct7Q8uG2.js +0 -1
@@ -1 +0,0 @@
1
- import{j as i,z as nt,r as O,b as jt,X as Oe,R as X,$ as Gt,at as Ne,bq as Ns,bo as Fe,br as Ts,bs as As,B as se,bt as _s,y as de,i as et,h as St,ah as wt,bu as Es,bv as ke,bw as be,bx as Nt,ai as Ps,by as Vs,bz as ks,D as Yt,bA as Tt,ae as Ds,aq as Fs,ay as Cs,bB as Os,bC as Is,bD as Rs,k as At,d as Ms,bE as _t,bF as Us,T as Ls}from"./index-DsR4Mk7n.js";import{u as Hs,R as zs}from"./useSignature-B22ZnEj4.js";import{S as Bs,A as qs}from"./settings-screen-6C3zeyy1.js";import{g as Et,P as $s,s as Ue,O as Ws}from"./OnboardingWizard-74ApF1TM.js";import{c as Ks,b as Pt,d as Gs}from"./account-form-helpers-C1-XCp2v.js";import{D as Ys}from"./download-B21Knqu2.js";import{E as Zs}from"./ErrorState-DaIYWAtU.js";import{e as Qs}from"./format-B6Elex-n.js";import"./avatar-WAi3XoGV.js";import"./kbd-BKNut3M9.js";function Xs({title:e,description:s,action:t}){return i.jsxs("div",{className:"rounded-sm border border-danger/50",children:[i.jsxs("div",{className:"flex items-center gap-2 border-b border-danger/30 bg-danger-soft px-row-inset py-2",children:[i.jsx(nt,{className:"size-4 text-danger"}),i.jsx("h2",{className:"text-sm font-semibold text-danger",children:"Danger zone"})]}),i.jsxs("div",{className:"flex flex-col gap-3 px-row-inset py-3 sm:flex-row sm:items-center sm:justify-between sm:gap-4",children:[i.jsxs("div",{className:"min-w-0",children:[i.jsx("div",{className:"text-sm font-medium text-fg",children:e}),i.jsx("p",{className:"text-xs text-fg-muted",children:s})]}),i.jsx("div",{className:"shrink-0",children:t})]})]})}function Vt({isOpen:e,onClose:s,title:t,children:a,footer:c}){return O.useEffect(()=>{if(!e)return;const d=n=>{n.key==="Escape"&&s()};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[e,s]),i.jsxs(i.Fragment,{children:[i.jsx("div",{className:jt("fixed inset-0 z-40 bg-black/30 transition-opacity",e?"opacity-100":"pointer-events-none opacity-0"),onClick:s,"aria-hidden":"true"}),i.jsxs("div",{className:jt("fixed top-0 right-0 z-50 h-full w-full border-l border-line bg-canvas shadow-xl sm:w-[400px] sm:max-w-[90vw]","transform transition-transform duration-200 ease-out",e?"translate-x-0":"pointer-events-none translate-x-full"),role:"dialog","aria-modal":"true","aria-hidden":!e,inert:!e,"aria-labelledby":"slide-panel-title",children:[i.jsxs("div",{className:"flex h-14 items-center justify-between border-b border-line px-4",children:[i.jsx("h2",{id:"slide-panel-title",className:"font-semibold",children:t}),i.jsx("button",{type:"button",onClick:s,className:"rounded-md p-1.5 transition-colors hover:bg-surface-raised","aria-label":"Close",children:i.jsx(Oe,{className:"size-5"})})]}),i.jsxs("div",{className:"flex h-[calc(100%-3.5rem)] flex-col",children:[i.jsx("div",{className:"flex-1 overflow-auto p-4",children:a}),c&&i.jsx("div",{className:"flex justify-end gap-3 border-t border-line bg-canvas p-4",children:c})]})]})]})}var Ie=e=>e.type==="checkbox",je=e=>e instanceof Date,G=e=>e==null;const ot=e=>typeof e=="object";var z=e=>!G(e)&&!Array.isArray(e)&&ot(e)&&!je(e),Js=e=>z(e)&&e.target?Ie(e.target)?e.target.checked:e.target.value:e,er=(e,s)=>s.split(".").some((t,a,c)=>!isNaN(Number(t))&&e.has(c.slice(0,a).join("."))),Zt=e=>{const s=e.constructor&&e.constructor.prototype;return z(s)&&s.hasOwnProperty("isPrototypeOf")},$e=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function B(e){if(e instanceof Date)return new Date(e);const s=typeof FileList<"u"&&e instanceof FileList;if($e&&(e instanceof Blob||s))return e;const t=Array.isArray(e);if(!t&&!(z(e)&&Zt(e)))return e;const a=t?[]:Object.create(Object.getPrototypeOf(e));for(const c in e)Object.prototype.hasOwnProperty.call(e,c)&&(a[c]=B(e[c]));return a}const Ae={BLUR:"blur",FOCUS_OUT:"focusout",SUBMIT:"submit",TRIGGER:"trigger",VALID:"valid"},fe={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},ue={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},Qt="root",lt=["__proto__","constructor","prototype"],tr=/^\w*$/;var Re=e=>tr.test(e),M=e=>e===void 0;const sr=/[.[\]'"]/;var We=e=>e.split(sr).filter(Boolean),g=(e,s,t)=>{if(!s||!z(e))return t;const a=Re(s)?[s]:We(s);if(a.some(d=>lt.includes(d)))return t;const c=a.reduce((d,n)=>G(d)?void 0:d[n],e);return M(c)||c===e?M(e[s])?t:e[s]:c},me=e=>typeof e=="boolean",ne=e=>typeof e=="function",F=(e,s,t)=>{let a=-1;const c=Re(s)?[s]:We(s),d=c.length,n=d-1;for(;++a<d;){const u=c[a];let j=t;if(a!==n){const E=e[u];j=z(E)||Array.isArray(E)?E:isNaN(+c[a+1])?{}:[]}if(lt.includes(u))return;e[u]=j,e=e[u]}};const rr=X.createContext(null);rr.displayName="HookFormControlContext";var ir=(e,s,t,a=!0)=>{const c={};for(const d in e)Object.defineProperty(c,d,{get:()=>{const n=d;return s._proxyFormState[n]!==fe.all&&(s._proxyFormState[n]=!a||fe.all),e[n]}});return c};const ar=$e?X.useLayoutEffect:X.useEffect;var Y=e=>typeof e=="string",nr=(e,s,t,a,c)=>Y(e)?(a&&s.watch.add(e),g(t,e,c)):Array.isArray(e)?e.map(d=>(a&&s.watch.add(d),g(t,d))):(a&&(s.watchAll=!0),t),tt=e=>G(e)||!ot(e);const kt=(e,s)=>s.length===0&&!Array.isArray(e)&&!Zt(e);function he(e,s,t=new WeakMap){if(e===s)return!0;if(tt(e)||tt(s))return Object.is(e,s);if(je(e)&&je(s))return Object.is(e.getTime(),s.getTime());const a=Object.keys(e),c=Object.keys(s);if(a.length!==c.length)return!1;if(kt(e,a)||kt(s,c))return Object.is(e,s);if(!a.length&&Array.isArray(e)!==Array.isArray(s))return!1;const d=t.get(e);if(d&&d.has(s))return!0;if(d)d.add(s);else{const n=new WeakSet;n.add(s),t.set(e,n)}for(const n of a){const u=e[n];if(!(n in s))return!1;if(n!=="ref"){const j=s[n];if(je(u)&&je(j)||(z(u)||Array.isArray(u))&&(z(j)||Array.isArray(j))?!he(u,j,t):!Object.is(u,j))return!1}}return!0}var Le=e=>({isOnSubmit:!e||e===fe.onSubmit,isOnBlur:e===fe.onBlur,isOnChange:e===fe.onChange,isOnAll:e===fe.all,isOnTouch:e===fe.onTouched}),Qe=(e,s,t)=>{if(t)return!1;if(s.watchAll||s.watch.has(e))return!0;for(const a of s.watch)if(e.startsWith(a)&&e.charAt(a.length)===".")return!0;return!1};const Ce=(e,s,t,a)=>{for(const c of t||Object.keys(e)){const d=g(e,c);if(d){const{_f:n,...u}=d;if(n){if(n.refs&&n.refs[0]&&s(n.refs[0],c)&&!a)return!0;if(n.ref&&s(n.ref,n.name)&&!a)return!0;if(Ce(u,s))break}else if(z(u)&&Ce(u,s))break}}};var Dt=(e,s,t)=>{const a=g(e,t),c=Array.isArray(a)?a:[];return F(c,Qt,s[t]),F(e,t,c),e},K=e=>z(e)&&!Object.keys(e).length,ct=e=>e.type==="file",Be=e=>{if(!$e)return!1;const s=e?e.ownerDocument:0;return e instanceof(s&&s.defaultView?s.defaultView.HTMLElement:HTMLElement)},dt=e=>e.type==="radio",qe=e=>e instanceof RegExp,ut=(e,s,t,a,c)=>s?{...t[e],types:{...t[e]&&t[e].types?t[e].types:{},[a]:c||!0}}:{};const Ft={value:!1,isValid:!1},Ct={value:!0,isValid:!0};var Xt=e=>{if(Array.isArray(e)){if(e.length>1){const s=e.filter(t=>t&&t.checked&&!t.disabled).map(t=>t.value);return{value:s,isValid:!!s.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!M(e[0].attributes.value)?M(e[0].value)||e[0].value===""?Ct:{value:e[0].value,isValid:!0}:Ct:Ft}return Ft};const Ot={isValid:!1,value:null};var Jt=e=>Array.isArray(e)?e.reduce((s,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:s,Ot):Ot;function It(e,s,t="validate"){if(Y(e)||Array.isArray(e)&&e.every(Y)||me(e)&&!e)return{type:t,message:Y(e)?e:"",ref:s}}var _e=e=>z(e)&&!qe(e)?e:{value:e,message:""},Rt=async(e,s,t,a,c,d)=>{const{ref:n,refs:u,required:j,maxLength:E,minLength:P,min:H,max:I,pattern:C,validate:N,name:f,valueAsNumber:b,mount:ie}=e._f,T=g(t,f);if(!ie||s.has(f))return{};const J=u?u[0]:n,R=A=>{if(c&&J.reportValidity){const _=me(A)?"":A||"";u?u.forEach(D=>D.setCustomValidity(_)):J.setCustomValidity(_),J.reportValidity()}},V={},oe=dt(n),re=Ie(n),pe=oe||re,le=(b||ct(n))&&M(n.value)&&M(T)||Be(n)&&n.value===""||T===""||Array.isArray(T)&&!T.length,W=ut.bind(null,f,a,V),ee=(A,_,D,$=ue.maxLength,w=ue.minLength)=>{const L=A?_:D;V[f]={type:A?$:w,message:L,ref:n,...W(A?$:w,L)}};if(d?!Array.isArray(T)||!T.length:j&&(!pe&&(le||G(T))||me(T)&&!T||re&&!Xt(u).isValid||oe&&!Jt(u).isValid)){const{value:A,message:_}=Y(j)?{value:!!j,message:j}:_e(j);if(A&&(V[f]={type:ue.required,message:_,ref:J,...W(ue.required,_)},!a))return R(_),V}if(!le&&(!G(H)||!G(I))){let A,_;const D=_e(I),$=_e(H);if(!G(T)&&!isNaN(T)){const w=n.valueAsNumber||T&&+T;G(D.value)||(A=w>D.value),G($.value)||(_=w<$.value)}else{const w=n.valueAsDate||new Date(T),L=ve=>new Date(new Date().toDateString()+" "+ve),ye=n.type=="time",Z=n.type=="week";Y(D.value)&&T&&(A=ye?L(T)>L(D.value):Z?T>D.value:w>new Date(D.value)),Y($.value)&&T&&(_=ye?L(T)<L($.value):Z?T<$.value:w<new Date($.value))}if((A||_)&&(ee(!!A,D.message,$.message,ue.max,ue.min),!a))return R(V[f].message),V}if((E||P)&&!le&&(Y(T)||d&&Array.isArray(T))){const A=_e(E),_=_e(P),D=!G(A.value)&&T.length>+A.value,$=!G(_.value)&&T.length<+_.value;if((D||$)&&(ee(D,A.message,_.message),!a))return R(V[f].message),V}if(C&&!le&&Y(T)){const{value:A,message:_}=_e(C);if(qe(A)&&!T.match(A)&&(V[f]={type:ue.pattern,message:_,ref:n,...W(ue.pattern,_)},!a))return R(_),V}if(N){if(ne(N)){const A=await N(T,t),_=It(A,J);if(_&&(V[f]={..._,...W(ue.validate,_.message)},!a))return R(_.message),V}else if(z(N)){let A={};for(const _ in N){if(!K(A)&&!a)break;const D=It(await N[_](T,t),J,_);D&&(A={...D,...W(_,D.message)},R(D.message),a&&(V[f]=A))}if(!K(A)&&(V[f]={ref:J,...A},!a))return V}}return R(!0),V},ze=e=>Array.isArray(e)?e:[e],es=e=>Array.isArray(e)?e.filter(Boolean):[];function or(e,s){const t=s.slice(0,-1).length;let a=0;for(;a<t;){if(G(e)){e=void 0;break}e=e[s[a]],a++}return e}function lr(e){for(const s in e)if(e.hasOwnProperty(s)&&!M(e[s]))return!1;return!0}function q(e,s){if(Y(s)&&Object.prototype.hasOwnProperty.call(e,s))return delete e[s],e;const t=Array.isArray(s)?s:Re(s)?[s]:We(s);if(t.some(n=>lt.includes(String(n))))return e;const a=t.length===1?e:or(e,t),c=t.length-1,d=t[c];return a&&delete a[d],c!==0&&(z(a)&&K(a)||Array.isArray(a)&&lr(a))&&q(e,t.slice(0,-1)),e}const ts=e=>{const s={};for(const t of Object.keys(e))if(ot(e[t])&&e[t]!==null&&!je(e[t])){const a=ts(e[t]);for(const c of Object.keys(a))s[`${t}.${c}`]=a[c]}else s[t]=e[t];return s},cr=X.createContext(null);cr.displayName="HookFormContext";var Mt=()=>{let e=[];return{get observers(){return e},next:c=>{for(const d of e)d.next&&d.next(c)},subscribe:c=>(e.push(c),{unsubscribe:()=>{e=e.filter(d=>d!==c)}}),unsubscribe:()=>{e=[]}}};function ss(e,s){const t={};for(const a in e)if(e.hasOwnProperty(a)){const c=e[a],d=s[a];if(c&&z(c)&&d){const n=ss(c,d);z(n)&&(t[a]=n)}else e[a]&&(t[a]=d)}return t}var rs=e=>e.type==="select-multiple",dr=e=>dt(e)||Ie(e),Xe=e=>Be(e)&&e.isConnected,ur=e=>{for(const s in e)if(ne(e[s]))return!0;return!1};function is(e){return Array.isArray(e)||z(e)&&!ur(e)}function as(e){return!!(e&&"_f"in e)}function ns(e){return Array.isArray(e)?!e.some(s=>!M(s)):!Object.keys(e).length}function st(e,s){Array.isArray(e)?e[s]=void 0:delete e[s]}function rt(e,s={},t){for(const a in e){const c=e[a],d=t&&t[a];is(c)&&(!Array.isArray(c)||!as(d))?(s[a]=Array.isArray(c)?[]:{},rt(c,s[a],d),ns(s[a])&&st(s,a)):M(c)||(s[a]=!0)}return s}function we(e,s,t,a){t||(t=rt(s,{},a));for(const c in e){const d=e[c],n=a&&a[c];is(d)&&(!Array.isArray(d)||!as(n))?(M(s)||tt(t[c])?t[c]=rt(d,Array.isArray(d)?[]:{},n):we(d,G(s)?{}:s[c],t[c],n),ns(t[c])&&st(t,c)):he(d,s[c])?st(t,c):t[c]=!0}return t}var os=(e,{valueAsNumber:s,valueAsDate:t,setValueAs:a})=>M(e)?e:s?e===""?NaN:e&&+e:t&&Y(e)?new Date(e):a?a(e):e;function Ut(e){const s=e.ref;return ct(s)?s.files:dt(s)?Jt(e.refs).value:rs(s)?[...s.selectedOptions].map(({value:t})=>t):Ie(s)?Xt(e.refs).value:os(M(s.value)?e.ref.value:s.value,e)}var fr=(e,s,t,a)=>{const c={};for(const d of e){const n=g(s,d);n&&F(c,d,n._f)}return{criteriaMode:t,names:[...e],fields:c,shouldUseNativeValidation:a}},De=e=>M(e)?e:qe(e)?e.source:z(e)?qe(e.value)?e.value.source:e.value:e;const Lt="AsyncFunction";var mr=e=>{if(!e||!e.validate)return!1;if(ne(e.validate))return e.validate.constructor.name===Lt;if(z(e.validate)){for(const s in e.validate)if(e.validate[s].constructor.name===Lt)return!0}return!1},hr=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function Ht(e,s,t){const a=g(e,t);if(a||Re(t))return{error:a,name:t};const c=t.split(".");for(;c.length;){const d=c.join("."),n=g(s,d),u=g(e,d);if(n&&!Array.isArray(n)&&t!==d)return{name:t};if(u&&u.type)return{name:d,error:u};if(u&&u.root&&u.root.type)return{name:`${d}.root`,error:u.root};c.pop()}return{name:t}}var pr=(e,s,t,a)=>{t(e);const{name:c,...d}=e,n=Object.keys(d);return!n.length||a&&n.length>=Object.keys(s).length||n.find(u=>s[u]===(!a||fe.all))},yr=(e,s,t)=>!e||!s||e===s||ze(e).some(a=>a&&(t?a===s||a.startsWith(s+"."):a.startsWith(s)||s.startsWith(a))),xr=(e,s,t,a,c)=>c.isOnAll?!1:!t&&c.isOnTouch?!(s||e):(t?a.isOnBlur:c.isOnBlur)?!e:(t?a.isOnChange:c.isOnChange)?e:!0,gr=(e,s)=>!es(g(e,s)).length&&q(e,s);const vr={mode:fe.onSubmit,reValidateMode:fe.onChange,shouldFocusError:!0},Je="form",ls={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function br(e={}){let s={...vr,...e},t={...B(ls),isLoading:ne(s.defaultValues),errors:s.errors||{},disabled:s.disabled||!1},a={},c=z(s.defaultValues)||z(s.values)?B(s.defaultValues||s.values)||{}:{},d=s.shouldUnregister?{}:B(c),n={action:!1,mount:!1,watch:!1,keepIsValid:!1},u={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set,registerName:new Set};const j={},E={};let P=0,H=Le(s.mode),I=Le(s.reValidateMode);const C={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},N={...C};let f={...N};const b={array:Mt(),state:Mt()};let ie=0;const T=s.criteriaMode===fe.all,J=(r,o)=>l=>{clearTimeout(E[r]),E[r]=setTimeout(o,l)},R=async r=>{if(!n.keepIsValid&&!s.disabled&&(N.isValid||f.isValid||r)){const o=++ie;let l;s.resolver?(l=K((await D()).errors),o===ie&&V()):l=await L({fields:a,onlyCheckValid:!0,eventType:Ae.VALID}),o===ie&&l!==t.isValid&&b.state.next({isValid:l})}},V=(r,o)=>{!s.disabled&&(N.isValidating||N.validatingFields||f.isValidating||f.validatingFields)&&((r||Array.from(u.mount)).forEach(l=>{l&&(o?F(t.validatingFields,l,o):q(t.validatingFields,l))}),b.state.next({validatingFields:t.validatingFields,isValidating:!K(t.validatingFields)}))},oe=()=>{t.dirtyFields=we(c,d,void 0,a)},re=(r,o=[],l,m,h=!0,x=!0)=>{if(m&&l&&!s.disabled){if(n.action=!0,x&&Array.isArray(g(a,r))){const y=l(g(a,r),m.argA,m.argB);h&&F(a,r,y)}if(x&&Array.isArray(g(t.errors,r))){const y=l(g(t.errors,r),m.argA,m.argB);h&&F(t.errors,r,y),gr(t.errors,r)}if((N.touchedFields||f.touchedFields)&&x&&Array.isArray(g(t.touchedFields,r))){const y=l(g(t.touchedFields,r),m.argA,m.argB);h&&F(t.touchedFields,r,y)}(N.dirtyFields||f.dirtyFields)&&oe(),b.state.next({name:r,isDirty:Z(r,o),dirtyFields:t.dirtyFields,errors:t.errors,isValid:t.isValid})}else F(d,r,o)},pe=(r,o)=>{F(t.errors,r,o),t.errors={...t.errors},b.state.next({errors:t.errors})},le=r=>{t.errors=r,b.state.next({errors:t.errors,isValid:!1})},W=r=>{const o=Re(r)?[r]:We(r);let l=d,m=c;for(let h=0;h<o.length-1;h++){const x=o[h];if(l=G(l)?l:l[x],m=G(m)?m:m[x],l===null&&m!==null)return!0}return!1},ee=(r,o,l,m)=>{const h=g(a,r);if(h){if(W(r))return;const x=M(g(d,r)),y=g(d,r,M(l)?g(c,r):l);M(y)||m&&m.defaultChecked||o?F(d,r,o?y:Ut(h._f)):k(r,y),n.mount&&!n.action&&(R(),x&&t.isDirty&&(N.isDirty||f.isDirty)&&(Z()||(t.isDirty=!1,b.state.next({...t}))),e.shouldUnregister&&x&&!M(g(d,r))&&Qe(r,u)&&(n.watch=!0))}},A=(r,o,l,m,h)=>{let x=!1,y=!1;const v={name:r};if(!s.disabled||m===!0){if(!l||m){const S=he(g(c,r),o);(N.isDirty||f.isDirty)&&(y=t.isDirty,t.isDirty=v.isDirty=!S||Z(),x=y!==v.isDirty),y=!!g(t.dirtyFields,r),S!==t.isDirty?t.dirtyFields=we(c,d,void 0,a):S?q(t.dirtyFields,r):F(t.dirtyFields,r,!0),v.dirtyFields=t.dirtyFields,x=x||(N.dirtyFields||f.dirtyFields)&&y!==!S}if(l){const S=g(t.touchedFields,r);S||(F(t.touchedFields,r,l),v.touchedFields=t.touchedFields,x=x||(N.touchedFields||f.touchedFields)&&S!==l)}x&&h&&b.state.next(v)}return x?v:{}},_=(r,o,l,m)=>{const h=g(t.errors,r),x=(N.isValid||f.isValid)&&me(o)&&t.isValid!==o;if(s.delayError&&l?(j[r]=J(r,()=>pe(r,l)),j[r](s.delayError)):(clearTimeout(E[r]),delete j[r],l?F(t.errors,r,l):q(t.errors,r),t.errors={...t.errors}),(l?!he(h,l):h)||!K(m)||x){const y={...m,...x&&me(o)?{isValid:o}:{},errors:t.errors,name:r};t={...t,...y},b.state.next(y)}},D=async r=>(V(r,!0),await s.resolver(d,s.context,fr(r||u.mount,a,s.criteriaMode,s.shouldUseNativeValidation))),$=async r=>{const{errors:o}=await D(r);if(V(r),r){for(const l of r){const m=g(o,l);m?u.array.has(l)&&z(m)&&!Object.keys(m).some(h=>!Number.isNaN(Number(h)))?Dt(t.errors,{[l]:m},l):F(t.errors,l,m):q(t.errors,l)}t.errors={...t.errors}}else t.errors=o;return o},w=async({name:r,eventType:o})=>{if(e.validate){const l=await e.validate({formValues:d,formState:t,name:r,eventType:o});if(z(l))for(const m in l){const h=l[m];h&&Me(`${Je}.${m}`,{message:Y(h.message)?h.message:"",type:h.type||ue.validate})}else Y(l)||!l?Me(Je,{message:l||"",type:ue.validate}):mt(Je);return l}return!0},L=async({fields:r,onlyCheckValid:o,name:l,eventType:m,context:h={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(h.runRootValidation=!0,!await w({name:l,eventType:m})&&(h.valid=!1,o)))return h.valid;for(const x in r){const y=r[x];if(y){const{_f:v,...S}=y;if(v){const U=u.array.has(v.name),Q=y._f&&mr(y._f),xe=N.validatingFields||N.isValidating||f.validatingFields||f.isValidating;Q&&xe&&V([v.name],!0);const ge=await Rt(y,u.disabled,d,T,s.shouldUseNativeValidation&&!o,U);if(Q&&xe&&V([v.name]),ge[v.name]&&(h.valid=!1,o)||(!o&&(g(ge,v.name)?U?Dt(t.errors,ge,v.name):F(t.errors,v.name,ge[v.name]):q(t.errors,v.name)),e.shouldUseNativeValidation&&ge[v.name]))break}!K(S)&&await L({context:h,onlyCheckValid:o,fields:S,name:x,eventType:m})}}return h.valid},ye=()=>{for(const r of u.unMount){const o=g(a,r);o&&(o._f.refs?o._f.refs.every(l=>!Xe(l)):!Xe(o._f.ref))&&Ge(r)}u.unMount=new Set},Z=(r,o)=>(r&&o&&F(d,r,o),!he(n.mount?d:c,c)),ve=(r,o,l)=>nr(r,u,{...n.mount?d:M(o)?c:Y(r)?{[r]:o}:o},l,o),p=r=>es(g(n.mount?d:c,r,s.shouldUnregister?g(c,r,[]):[])),k=(r,o,l={},m=!1,h=!1)=>{const x=g(a,r);let y=o;if(x){const v=x._f;v&&(!v.disabled&&F(d,r,os(o,v)),y=Be(v.ref)&&G(o)?"":o,rs(v.ref)?[...v.ref.options].forEach(S=>S.selected=y.includes(S.value)):v.refs?Ie(v.ref)?v.refs.forEach(S=>{(!S.defaultChecked||!S.disabled)&&(Array.isArray(y)?S.checked=!!y.find(U=>U===S.value):S.checked=y===S.value||!!y)}):v.refs.forEach(S=>S.checked=S.value===y):ct(v.ref)?v.ref.value="":(v.ref.value=y,!v.ref.type&&!h&&b.state.next({name:r,values:m?d:B(d)})))}(l.shouldDirty||l.shouldTouch)&&A(r,y,l.shouldTouch,l.shouldDirty,!h),l.shouldValidate&&Ke(r,{delayError:l.delayError})},ce=(r,o,l,m=!1,h=!1)=>{for(const x in o){if(!o.hasOwnProperty(x))return;const y=o[x],v=r+"."+x,S=g(a,v);(u.array.has(r)||z(y)||S&&!S._f)&&!je(y)?ce(v,y,l,m,h):k(v,y,l,m,h)}},te=(r,o,l,m,h=!1)=>{const x=g(a,r),y=u.array.has(r),v=m?o:B(o),S=g(d,r),U=he(S,v);if(U||F(d,r,v),y)b.array.next({name:r,values:m?d:B(d)}),(N.isDirty||N.dirtyFields||f.isDirty||f.dirtyFields)&&l.shouldDirty&&(oe(),h||b.state.next({name:r,dirtyFields:t.dirtyFields,isDirty:Z(r,v)}));else{const Q=Array.isArray(v)&&!v.length||K(v);!x||x._f||G(v)||Q?k(r,v,l,m,h):ce(r,v,l,m,h)}if(!U&&!h){const Q=Qe(r,u),xe=m?d:B(d);b.state.next({...Q&&t,name:n.mount||Q?r:void 0,values:xe})}},ae=(r,o,l={})=>te(r,o,l,!1),Se=(r,o={})=>{const l=ne(r)?r(d):r;if(!he(d,l)){d={...d,...l};const m=ts(l);for(const h of u.mount)h in m&&te(h,m[h],o,!0,!0);b.state.next({...t,name:void 0,type:void 0,...P?{values:d}:{}}),o.shouldValidate&&R()}},Ee=async r=>{n.mount=!0;const o=r.target;let l=o.name,m=!0;const h=g(a,l),x=y=>{m=Number.isNaN(y)||je(y)&&isNaN(y.getTime())||he(y,g(d,l,y))};if(h){let y,v;const S=o.type?Ut(h._f):Js(r),U=r.type===Ae.BLUR||r.type===Ae.FOCUS_OUT,Q=!hr(h._f)&&!e.validate&&!s.resolver&&!g(t.errors,l)&&!h._f.deps,xe=Q||xr(U,g(t.touchedFields,l),t.isSubmitted,I,H),ge=Qe(l,u,U);if(F(d,l,S),U){if(!o||!o.readOnly){h._f.onBlur&&h._f.onBlur(r);const Ve=j[l];Ve&&Ve(0)}}else h._f.onChange&&h._f.onChange(r);const Pe=A(l,S,U),Ss=!K(Pe)||ge;if(!U&&b.state.next({name:l,type:r.type,...P?{values:B(d)}:{}}),xe)return(!Q||!t.isValid)&&(N.isValid||f.isValid)&&(s.mode==="onBlur"?U&&R():U||R()),Ss&&b.state.next({name:l,...ge?{}:Pe});if(!s.resolver&&e.validate&&await w({name:l,eventType:r.type}),!U&&ge&&b.state.next({...t}),s.resolver){const{errors:Ve}=await D([l]);if(V([l]),x(S),!m){!K(Pe)&&b.state.next(Pe);return}const ws=Ht(t.errors,a,l),bt=Ht(Ve,a,ws.name||l);y=bt.error,l=bt.name,v=K(Ve)}else V([l],!0),y=(await Rt(h,u.disabled,d,T,s.shouldUseNativeValidation))[l],V([l]),x(S),m&&(y?v=!1:(N.isValid||f.isValid)&&(v=await L({fields:a,onlyCheckValid:!0,name:l,eventType:r.type})));m&&(h._f.deps&&(!Array.isArray(h._f.deps)||h._f.deps.length>0)&&Ke(h._f.deps),_(l,v,y,Pe))}},Te=(r,o)=>{if(g(t.errors,o)&&r.focus)return r.focus(),1},Ke=async(r,o={})=>{let l,m;const h=ze(r);if(s.resolver){const x=await $(M(r)?r:h);l=K(x),m=r?!h.some(y=>g(x,y)):l}else r?(m=(await Promise.all(h.map(async x=>{const y=g(a,x);return await L({fields:y&&y._f?{[x]:y}:y,eventType:Ae.TRIGGER})}))).every(Boolean),!(!m&&!t.isValid)&&R()):m=l=await L({fields:a,name:r,eventType:Ae.TRIGGER});if(o.delayError&&s.delayError&&Y(r)){const x=g(t.errors,r);x?(q(t.errors,r),j[r]=J(r,()=>pe(r,x)),j[r](s.delayError)):(clearTimeout(E[r]),delete j[r])}return b.state.next({...!Y(r)||(N.isValid||f.isValid)&&l!==t.isValid?{}:{name:r},...s.resolver||!r?{isValid:l}:{},errors:t.errors}),o.shouldFocus&&!m&&Ce(a,Te,r?h:u.mount),m},ps=(r,o)=>{let l={...n.mount?d:c};return o&&(l=ss(o.dirtyFields?t.dirtyFields:t.touchedFields,l)),M(r)?l:Y(r)?g(l,r):r.map(m=>g(l,m))},ft=(r,o)=>({invalid:!!g((o||t).errors,r),isDirty:!!g((o||t).dirtyFields,r),error:g((o||t).errors,r),isValidating:!!g(t.validatingFields,r),isTouched:!!g((o||t).touchedFields,r)}),mt=r=>{const o=r?ze(r):void 0;o?.forEach(l=>q(t.errors,l)),o?o.forEach(l=>{b.state.next({name:l,errors:t.errors})}):b.state.next({errors:{}})},Me=(r,o,l)=>{const m=(g(a,r,{_f:{}})._f||{}).ref,h=g(t.errors,r)||{},{ref:x,message:y,type:v,...S}=h;F(t.errors,r,{...S,...o,ref:m}),b.state.next({name:r,errors:t.errors,isValid:!1}),l&&l.shouldFocus&&m&&m.focus&&m.focus()},ys=(r,o)=>{if(ne(r)){P++;const{unsubscribe:l}=b.state.subscribe({next:h=>"values"in h&&r(h.values||ve(void 0,o),h)});let m=!1;return{unsubscribe:()=>{m||(m=!0,P--,l())}}}return ve(r,o,!0)},ht=r=>{var o;const l=!!(!((o=r.formState)===null||o===void 0)&&o.values);l&&P++;const{unsubscribe:m}=b.state.subscribe({next:x=>{if(yr(r.name,x.name,r.exact)&&pr(x,r.formState||N,js,r.reRenderRoot)){const y={...d};r.callback({values:y,...t,...x,defaultValues:c})}}});if(!l)return m;let h=!1;return()=>{h||(h=!0,P--,m())}},xs=r=>(n.mount=!0,f={...f,...r.formState},ht({...r,formState:{...C,...r.formState}})),Ge=(r,o={})=>{for(const l of r?ze(r):u.mount)u.mount.delete(l),u.array.delete(l),o.keepValue||(q(a,l),q(d,l)),!o.keepError&&q(t.errors,l),!o.keepDirty&&q(t.dirtyFields,l),!o.keepTouched&&q(t.touchedFields,l),!o.keepIsValidating&&q(t.validatingFields,l),!s.shouldUnregister&&!o.keepDefaultValue&&q(c,l);b.state.next({values:B(d)}),b.state.next({...t,...o.keepDirty?{isDirty:Z()}:{}}),!o.keepIsValid&&R()},pt=({disabled:r,name:o})=>{if(me(r)&&n.mount||r||u.disabled.has(o)){const h=u.disabled.has(o)!==!!r;r?u.disabled.add(o):u.disabled.delete(o),h&&n.mount&&!n.action&&R()}},Ye=(r,o={})=>{let l=g(a,r);const m=me(o.disabled)||me(s.disabled),h=!u.registerName.has(r)&&l&&l._f&&!l._f.mount;return F(a,r,{...l||{},_f:{...l&&l._f?l._f:{ref:{name:r}},name:r,mount:!0,...o}}),u.mount.add(r),l&&!h?pt({disabled:me(o.disabled)?o.disabled:s.disabled,name:r}):ee(r,!0,o.value),{...m?{disabled:o.disabled||s.disabled}:{},...s.progressive?{required:!!o.required,min:De(o.min),max:De(o.max),minLength:De(o.minLength),maxLength:De(o.maxLength),pattern:De(o.pattern)}:{},name:r,onChange:Ee,onBlur:Ee,ref:x=>{if(x){u.registerName.add(r),Ye(r,o),u.registerName.delete(r),l=g(a,r);const y=M(x.value)&&x.querySelectorAll&&x.querySelectorAll("input,select,textarea")[0]||x,v=dr(y),S=l._f.refs||[];if(v?S.find(U=>U===y):y===l._f.ref)return;F(a,r,{_f:{...l._f,...v?{refs:[...S.filter(Xe),y,...Array.isArray(g(c,r))?[{}]:[]],ref:{type:y.type,name:r}}:{ref:y}}}),ee(r,!1,void 0,y)}else l=g(a,r,{}),l._f&&(l._f.mount=!1),(s.shouldUnregister||o.shouldUnregister)&&!(er(u.array,r)&&n.action)&&u.unMount.add(r)}}},Ze=()=>s.shouldFocusError&&!s.shouldUseNativeValidation&&Ce(a,Te,u.mount),gs=r=>{me(r)&&(b.state.next({disabled:r}),Ce(a,(o,l)=>{const m=g(a,l);m&&(o.disabled=m._f.disabled||r,Array.isArray(m._f.refs)&&m._f.refs.forEach(h=>{h.disabled=m._f.disabled||r}))},0,!1))},yt=(r,o)=>async l=>{let m;l&&(l.preventDefault&&l.preventDefault(),l.persist&&l.persist());let h=B(d);if(b.state.next({isSubmitting:!0}),s.resolver){const{errors:x,values:y}=await D();V(),t.errors=x,h=B(y)}else await L({fields:a,eventType:Ae.SUBMIT});if(u.disabled.size)for(const x of u.disabled)q(h,x);if(q(t.errors,Qt),K(t.errors)){b.state.next({errors:{}});try{await r(h,l)}catch(x){m=x}}else o&&await o({...t.errors},l),Ze(),setTimeout(Ze);if(b.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:K(t.errors)&&!m,submitCount:t.submitCount+1,errors:t.errors}),m)throw m},vs=(r,o={})=>{g(a,r)&&(M(o.defaultValue)?ae(r,B(g(c,r))):(ae(r,o.defaultValue),F(c,r,B(o.defaultValue))),o.keepTouched||q(t.touchedFields,r),o.keepDirty||(q(t.dirtyFields,r),t.isDirty=o.defaultValue?Z(r,B(g(c,r))):Z()),o.keepError||(q(t.errors,r),N.isValid&&R()),b.state.next({...t}))},xt=(r,o={})=>{const l=r?B(r):c,m=B(l),h=K(r),x=m,y=a;if(o.keepDefaultValues||(c=l),!o.keepValues){if(o.keepDirtyValues){const v=new Set([...u.mount,...Object.keys(we(c,d,void 0,y))]);for(const S of Array.from(v)){const U=g(t.dirtyFields,S),Q=g(d,S),xe=g(x,S);U&&!M(Q)?F(x,S,Q):!U&&!M(xe)&&ae(S,xe)}}else{if($e&&M(r))for(const v of u.mount){const S=g(a,v);if(S&&S._f){const U=Array.isArray(S._f.refs)?S._f.refs[0]:S._f.ref;if(Be(U)){const Q=U.closest("form");if(Q){Q.reset();break}}}}if(o.keepFieldsRef)for(const v of u.mount)ae(v,g(x,v));else a={}}if(s.shouldUnregister){if(d=o.keepDefaultValues?B(c):{},o.keepFieldsRef)for(const v of u.mount)F(d,v,g(x,v))}else d=B(x);b.array.next({values:{...x}}),b.state.next({name:void 0,type:void 0,values:{...x}})}u={mount:o.keepDirtyValues?u.mount:new Set,unMount:new Set,array:new Set,registerName:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},n.mount=!N.isValid||!!o.keepIsValid||!!o.keepDirtyValues||!s.shouldUnregister&&!K(x),n.watch=!!s.shouldUnregister,n.keepIsValid=!!o.keepIsValid,n.action=!1,o.keepErrors||(t.errors={}),b.state.next({submitCount:o.keepSubmitCount?t.submitCount:0,isDirty:h?!1:o.keepDirty?t.isDirty:o.keepValues?Z():!!(o.keepDefaultValues&&!he(r,c)),isSubmitted:o.keepIsSubmitted?t.isSubmitted:!1,dirtyFields:h?{}:o.keepDirtyValues?o.keepDefaultValues&&d?we(c,d,void 0,y):t.dirtyFields:o.keepDefaultValues&&r?we(c,r,void 0,y):o.keepDirty?t.dirtyFields:{},touchedFields:o.keepTouched?t.touchedFields:{},errors:o.keepErrors?t.errors:{},isSubmitSuccessful:o.keepIsSubmitSuccessful?t.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:c})},gt=(r,o)=>xt(ne(r)?r(d):r,{...s.resetOptions,...o}),bs=(r,o={})=>{const l=g(a,r),m=l&&l._f;if(m){const h=m.refs?m.refs[0]:m.ref;h.focus&&setTimeout(()=>{h.focus(),o.shouldSelect&&ne(h.select)&&h.select()})}},js=r=>{const{name:o,type:l,values:m,...h}=r;t={...t,...h}},vt={control:{register:Ye,unregister:Ge,getFieldState:ft,handleSubmit:yt,setError:Me,_subscribe:ht,_runSchema:D,_updateIsValidating:V,_focusError:Ze,_getWatch:ve,_getDirty:Z,_setValid:R,_setFieldArray:re,_setDisabledField:pt,_setErrors:le,_getFieldArray:p,_reset:xt,_resetDefaultValues:()=>ne(s.defaultValues)&&s.defaultValues().then(r=>{gt(r,s.resetOptions),b.state.next({isLoading:!1})}),_removeUnmounted:ye,_disableForm:gs,_subjects:b,_proxyFormState:N,get _fields(){return a},get _formValues(){return d},get _state(){return n},set _state(r){n=r},get _defaultValues(){return c},get _names(){return u},set _names(r){u=r},get _formState(){return t},get _options(){return s},set _options(r){s={...s,...r},H=Le(s.mode),I=Le(s.reValidateMode)}},subscribe:xs,trigger:Ke,register:Ye,handleSubmit:yt,watch:ys,setValue:ae,setValues:Se,getValues:ps,reset:gt,resetField:vs,resetDefaultValues:(r,o={})=>{if(c=B(r),!o.keepDirty){const l=we(c,d,void 0,a);t.dirtyFields=l,t.isDirty=!K(l)}o.keepIsValid||R(),b.state.next({...t,defaultValues:c})},clearErrors:mt,unregister:Ge,setError:Me,setFocus:bs,getFieldState:ft};return{...vt,formControl:vt}}function jr(e={}){const s=X.useRef(void 0),t=X.useRef(void 0),a=X.useRef(e.formControl),[c,d]=X.useState(()=>({...B(ls),isLoading:ne(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1,defaultValues:ne(e.defaultValues)?void 0:e.defaultValues}));if(!s.current||e.formControl&&a.current!==e.formControl)if(a.current=e.formControl,e.formControl)s.current={...e.formControl,formState:c},e.defaultValues&&!ne(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:u,...j}=br(e);s.current={...j,formState:c}}const n=s.current.control;return n._options=e,ar(()=>{const u=n._subscribe({formState:n._proxyFormState,callback:()=>d({...n._formState,defaultValues:n._defaultValues}),reRenderRoot:!0});return d(j=>({...j,isReady:!0})),n._formState.isReady=!0,u},[n]),X.useEffect(()=>n._disableForm(e.disabled),[n,e.disabled]),X.useEffect(()=>{e.mode&&(n._options.mode=e.mode),e.reValidateMode&&(n._options.reValidateMode=e.reValidateMode)},[n,e.mode,e.reValidateMode]),X.useEffect(()=>{e.errors&&(n._setErrors(e.errors),n._focusError())},[n,e.errors]),X.useEffect(()=>{e.shouldUnregister&&n._subjects.state.next({values:n._getWatch()})},[n,e.shouldUnregister]),X.useEffect(()=>{if(n._proxyFormState.isDirty){const u=n._getDirty();u!==c.isDirty&&n._subjects.state.next({isDirty:u})}},[n,c.isDirty]),X.useEffect(()=>{var u;e.values&&!he(e.values,t.current)?(n._reset(e.values,{keepFieldsRef:!0,...n._options.resetOptions}),!((u=n._options.resetOptions)===null||u===void 0)&&u.keepIsValid||n._setValid(),t.current=e.values,d(j=>({...j}))):n._resetDefaultValues()},[n,e.values]),X.useEffect(()=>{n._state.mount||(n._setValid(),n._state.mount=!0),n._state.watch&&(n._state.watch=!1,n._subjects.state.next({...n._formState})),n._removeUnmounted()}),s.current.formState=X.useMemo(()=>ir(c,n),[n,c]),s.current}const zt=(e,s,t)=>{if(e&&"reportValidity"in e){const a=g(t,s);e.setCustomValidity(a&&a.message||""),e.reportValidity()}},it=(e,s)=>{for(const t in s.fields){const a=s.fields[t];a&&a.ref&&"reportValidity"in a.ref?zt(a.ref,t,e):a&&a.refs&&a.refs.forEach(c=>zt(c,t,e))}},Bt=(e,s)=>{s.shouldUseNativeValidation&&it(e,s);const t={};for(const a in e){const c=g(s.fields,a),d=Object.assign(e[a]||{},{ref:c&&c.ref});if(Sr(s.names||Object.keys(e),a)){const n=Object.assign({},g(t,a));F(n,"root",d),F(t,a,n)}else F(t,a,d)}return t},Sr=(e,s)=>{const t=qt(s).replace(/[.*+?^${}()|\\]/g,"\\$&");return e.some(a=>qt(a).match(`^${t}\\.\\d+`))};function qt(e){return e.replace(/[\[\]]/g,"")}function cs(e,s,t){function a(u,j){var E;Object.defineProperty(u,"_zod",{value:u._zod??{},enumerable:!1}),(E=u._zod).traits??(E.traits=new Set),u._zod.traits.add(e),s(u,j);for(const P in n.prototype)P in u||Object.defineProperty(u,P,{value:n.prototype[P].bind(u)});u._zod.constr=n,u._zod.def=j}const c=t?.Parent??Object;class d extends c{}Object.defineProperty(d,"name",{value:e});function n(u){var j;const E=t?.Parent?new d:this;a(E,u),(j=E._zod).deferred??(j.deferred=[]);for(const P of E._zod.deferred)P();return E}return Object.defineProperty(n,"init",{value:a}),Object.defineProperty(n,Symbol.hasInstance,{value:u=>t?.Parent&&u instanceof t.Parent?!0:u?._zod?.traits?.has(e)}),Object.defineProperty(n,"name",{value:e}),n}class wr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const Nr={};function ds(e){return Nr}function Tr(e,s){return typeof s=="bigint"?s.toString():s}const us=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function He(e){return typeof e=="string"?e:e?.message}function fs(e,s,t){const a={...e,path:e.path??[]};if(!e.message){const c=He(e.inst?._zod.def?.error?.(e))??He(s?.error?.(e))??He(t.customError?.(e))??He(t.localeError?.(e))??"Invalid input";a.message=c}return delete a.inst,delete a.continue,s?.reportInput||delete a.input,a}const ms=(e,s)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:s,enumerable:!1}),Object.defineProperty(e,"message",{get(){return JSON.stringify(s,Tr,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Ar=cs("$ZodError",ms),hs=cs("$ZodError",ms,{Parent:Error}),_r=e=>(s,t,a,c)=>{const d=a?Object.assign(a,{async:!1}):{async:!1},n=s._zod.run({value:t,issues:[]},d);if(n instanceof Promise)throw new wr;if(n.issues.length){const u=new(c?.Err??e)(n.issues.map(j=>fs(j,d,ds())));throw us(u,c?.callee),u}return n.value},Er=_r(hs),Pr=e=>async(s,t,a,c)=>{const d=a?Object.assign(a,{async:!0}):{async:!0};let n=s._zod.run({value:t,issues:[]},d);if(n instanceof Promise&&(n=await n),n.issues.length){const u=new(c?.Err??e)(n.issues.map(j=>fs(j,d,ds())));throw us(u,c?.callee),u}return n.value},Vr=Pr(hs);function at(){return at=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var t=arguments[s];for(var a in t)({}).hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e},at.apply(null,arguments)}function $t(e,s){try{var t=e()}catch(a){return s(a)}return t&&t.then?t.then(void 0,s):t}function kr(e,s){for(var t={};e.length;){var a=e[0],c=a.code,d=a.message,n=a.path.join(".");if(!t[n])if("unionErrors"in a){var u=a.unionErrors[0].errors[0];t[n]={message:u.message,type:u.code}}else t[n]={message:d,type:c};if("unionErrors"in a&&a.unionErrors.forEach(function(P){return P.errors.forEach(function(H){return e.push(H)})}),s){var j=t[n].types,E=j&&j[a.code];t[n]=ut(n,s,t,c,E?[].concat(E,a.message):a.message)}e.shift()}return t}function Dr(e,s){for(var t={},a=function(){var c=e[0],d=c.code,n=c.message,u=c.path.join(".");if(!t[u])if(c.code==="invalid_union"&&c.errors.length>0){var j=c.errors[0][0];t[u]={message:j.message,type:j.code}}else t[u]={message:n,type:d};if(c.code==="invalid_union"&&c.errors.forEach(function(H){return H.forEach(function(I){return e.push(at({},I,{path:[].concat(c.path,I.path)}))})}),s){var E=t[u].types,P=E&&E[c.code];t[u]=ut(u,s,t,d,P?[].concat(P,c.message):c.message)}e.shift()};e.length;)a();return t}function Fr(e,s,t){if(t===void 0&&(t={}),(function(a){return"_def"in a&&typeof a._def=="object"&&"typeName"in a._def})(e))return function(a,c,d){try{return Promise.resolve($t(function(){return Promise.resolve(e[t.mode==="sync"?"parse":"parseAsync"](a,s)).then(function(n){return d.shouldUseNativeValidation&&it({},d),{errors:{},values:t.raw?Object.assign({},a):n}})},function(n){if((function(u){return Array.isArray(u?.issues)})(n))return{values:{},errors:Bt(kr(n.errors,!d.shouldUseNativeValidation&&d.criteriaMode==="all"),d)};throw n}))}catch(n){return Promise.reject(n)}};if((function(a){return"_zod"in a&&typeof a._zod=="object"})(e))return function(a,c,d){try{return Promise.resolve($t(function(){return Promise.resolve((t.mode==="sync"?Er:Vr)(e,a,s)).then(function(n){return d.shouldUseNativeValidation&&it({},d),{errors:{},values:t.raw?Object.assign({},a):n}})},function(n){if((function(u){return u instanceof Ar})(n))return{values:{},errors:Bt(Dr(n.issues,!d.shouldUseNativeValidation&&d.criteriaMode==="all"),d)};throw n}))}catch(n){return Promise.reject(n)}};throw new Error("Invalid input: not a Zod schema")}const Cr=e=>e.authType==="oauthMicrosoft",Or="••••••••••",Ir=e=>{const s=e.smtpUsername?.trim();return s?s!==e.username:!1},Rr=Es({email:be().email().min(1,"Email is required"),displayName:be().optional(),username:be().optional(),password:be().optional(),imapHost:be().min(1,"IMAP host is required"),imapPort:Nt.number().int().min(1).max(65535),imapTls:ke(),imapStartTls:ke(),smtpHost:be().optional(),smtpPort:Nt.number().int().min(1).max(65535).optional(),smtpTls:ke().optional(),smtpStartTls:ke().optional(),smtpUsername:be().optional(),smtpPassword:be().optional(),useDifferentSmtpCreds:ke().optional()}),Mr=({isOpen:e,onClose:s,account:t,focusSmtp:a})=>{const c=Gt(),d=!!t,[n,u]=O.useState(!1),[j,E]=O.useState(""),[P,H]=O.useState(!1),I=Et(j),C=!!I&&!P,N=O.useRef(null),f=jr({resolver:Fr(Rr),defaultValues:{email:"",displayName:"",username:"",password:"",imapHost:"",imapPort:993,imapTls:!0,imapStartTls:!1,smtpHost:"",smtpPort:587,smtpTls:!1,smtpStartTls:!0,useDifferentSmtpCreds:!1}});O.useEffect(()=>{if(t){const p=Ir(t);f.reset({email:t.email,displayName:t.displayName||"",username:t.username||"",password:Or,imapHost:t.imapHost,imapPort:t.imapPort,imapTls:t.imapTls,imapStartTls:t.imapStartTls,smtpHost:t.smtpHost||"",smtpPort:t.smtpPort||587,smtpTls:t.smtpTls||!1,smtpStartTls:t.smtpStartTls||!0,smtpUsername:p&&t.smtpUsername||"",smtpPassword:"",useDifferentSmtpCreds:p}),u(!1)}else f.reset({email:"",displayName:"",username:"",password:"",imapHost:"",imapPort:993,imapTls:!0,imapStartTls:!1,smtpHost:"",smtpPort:587,smtpTls:!1,smtpStartTls:!0,useDifferentSmtpCreds:!1}),u(!1)},[t,f]);const b=Ne({...Ns()}),ie=Ne({...Ts(),onSuccess:()=>{c.invalidateQueries({queryKey:Fe()}),s()}}),T=Ne({...As(),onSuccess:()=>{c.invalidateQueries({queryKey:Fe()}),s()}}),J=()=>{const p=f.getValues(),k=d&&!n;b.mutate({body:{accountId:k?t?.accountId:void 0,username:p.username||p.email,password:k?void 0:p.password||void 0,imapHost:p.imapHost,imapPort:Number(p.imapPort),imapTls:p.imapTls,imapStartTls:p.imapStartTls}})},R=()=>{const p=f.getValues(),k=d&&!n;b.mutate({body:{accountId:k?t?.accountId:void 0,username:p.username||p.email,password:k?void 0:p.password||void 0,imapHost:p.imapHost,imapPort:Number(p.imapPort),imapTls:p.imapTls,imapStartTls:p.imapStartTls,smtpHost:p.smtpHost||void 0,smtpPort:p.smtpPort?Number(p.smtpPort):void 0,smtpTls:p.smtpTls,smtpStartTls:p.smtpStartTls,smtpUsername:p.useDifferentSmtpCreds?p.smtpUsername:void 0,smtpPassword:p.useDifferentSmtpCreds?p.smtpPassword:void 0}})},V=f.handleSubmit(p=>{if(!d&&!p.password){f.setError("password",{message:"Password is required"});return}const k=Ks({imapHost:p.imapHost,smtpHost:p.smtpHost,smtpPort:p.smtpPort,smtpTls:p.smtpTls,smtpStartTls:p.smtpStartTls});k&&(f.setValue("smtpHost",k.smtpHost),f.setValue("smtpPort",k.smtpPort),f.setValue("smtpTls",k.smtpTls),f.setValue("smtpStartTls",k.smtpStartTls));const ce=k?.smtpHost??p.smtpHost,te=k?.smtpPort??p.smtpPort,ae=k?.smtpTls??p.smtpTls,Se=k?.smtpStartTls??p.smtpStartTls,Ee={email:p.email,displayName:p.displayName?.trim()||void 0,username:p.username||void 0,imapHost:p.imapHost,imapPort:Number(p.imapPort),imapTls:p.imapTls,imapStartTls:p.imapStartTls,smtpHost:ce||void 0,smtpPort:te?Number(te):void 0,smtpTls:ae,smtpStartTls:Se,smtpUsername:p.useDifferentSmtpCreds&&p.smtpUsername||void 0,smtpPassword:p.useDifferentSmtpCreds&&p.smtpPassword||void 0};if(d&&t){const Te={...Ee,password:n?p.password:void 0};T.mutate({path:{accountId:t.accountId},body:Te})}else{const Te={...Ee,password:p.password};ie.mutate({body:Te})}}),oe=ie.isPending||T.isPending,{signature:re,setSignature:pe,isSaving:le}=Hs(t?.accountId),[W,ee]=O.useState(re.plainText);O.useEffect(()=>{ee(re.plainText)},[re.plainText]),O.useEffect(()=>{if(!e||!a)return;const p=N.current;if(!p)return;const k=window.setTimeout(()=>{p.scrollIntoView({behavior:"smooth",block:"start"})},250);return()=>window.clearTimeout(k)},[e,a]);const A=O.useCallback(()=>{W!==re.plainText&&pe(W,W)},[W,re.plainText,pe]),_=p=>{const{tls:k,startTls:ce}=Ue(p);f.setValue("imapTls",k),f.setValue("imapStartTls",ce);const te=f.getValues("imapPort");(te===993||te===143)&&f.setValue("imapPort",p==="tls"?993:143)},D=p=>{const{tls:k,startTls:ce}=Ue(p);f.setValue("smtpTls",k),f.setValue("smtpStartTls",ce);const te=f.getValues("smtpPort");if(te===465||te===587||te===25){const Se=p==="tls"?465:p==="starttls"?587:25;f.setValue("smtpPort",Se)}},$=()=>{const p=f.getValues("imapHost");f.setValue("smtpHost",Gs(p)),f.setValue("smtpTls",!1),f.setValue("smtpStartTls",!0),f.setValue("smtpPort",587)},w=p=>{E(p),H(!1);const k=Et(p);if(!k)return;const ce=Ue(k.imap.security);f.setValue("imapHost",k.imap.host),f.setValue("imapPort",k.imap.port),f.setValue("imapTls",ce.tls),f.setValue("imapStartTls",ce.startTls);const te=Ue(k.smtp.security);f.setValue("smtpHost",k.smtp.host),f.setValue("smtpPort",k.smtp.port),f.setValue("smtpTls",te.tls),f.setValue("smtpStartTls",te.startTls);const ae=f.getValues("email").trim(),Se=f.getValues("username")?.trim();ae&&!Se&&f.setValue("username",ae)},L=I?.passwordHelp.text,ye=Pt(b.data?.imapError,L),Z=Pt(b.data?.smtpError,L);return(t?Cr(t):!1)&&d?i.jsx(Vt,{isOpen:e,onClose:s,title:"Edit Account",footer:i.jsx(se,{type:"button",variant:"secondary",onClick:s,children:"Close"}),children:i.jsxs("div",{className:"space-y-6",children:[i.jsxs("section",{children:[i.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Microsoft 365 Account"}),i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"rounded-md border border-line bg-surface-sunken px-3 py-2.5 text-sm text-fg-muted",children:[i.jsx("span",{className:"block text-2xs font-medium uppercase tracking-wider text-fg-subtle mb-1",children:"Email"}),i.jsx("span",{className:"text-fg",children:t?.email})]}),i.jsxs("div",{className:"rounded-md border border-line bg-surface-sunken px-3 py-2.5 text-sm text-fg-muted",children:[i.jsx("span",{className:"block text-2xs font-medium uppercase tracking-wider text-fg-subtle mb-1",children:"Authentication"}),i.jsx("span",{className:"text-fg",children:"Microsoft OAuth (XOAUTH2)"})]}),i.jsx("p",{className:"text-xs text-fg-muted",children:"Server settings are managed automatically for Microsoft 365 accounts. To update credentials, use the Reconnect button."})]})]}),d&&i.jsxs("section",{children:[i.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Signature"}),i.jsx("div",{className:"space-y-3",children:i.jsxs("div",{children:[i.jsx("label",{htmlFor:"email-sig-view",className:"text-sm font-medium mb-1.5 block",children:"Email Signature"}),i.jsx("textarea",{id:"email-sig-view",value:W,onChange:p=>ee(p.target.value),onBlur:A,rows:5,className:"w-full px-3 py-2 border border-line rounded-md bg-surface-sunken text-sm text-fg placeholder:text-fg-subtle focus-within:border-line-strong focus-within:ring-2 focus-within:ring-ring/30 transition-colors resize-y outline-none",placeholder:"Enter your email signature..."}),i.jsx("p",{className:"text-xs text-fg-muted mt-1",children:le?"Saving signature...":"This signature will be appended to new emails."})]})})]})]})}):i.jsx(Vt,{isOpen:e,onClose:s,title:d?"Edit Account":"Add Account",footer:i.jsxs(i.Fragment,{children:[i.jsx(se,{type:"button",variant:"secondary",onClick:s,children:"Cancel"}),i.jsx(se,{type:"submit",form:"account-form",variant:"primary",disabled:oe,children:oe?"Saving...":"Save Account"})]}),children:i.jsxs("form",{id:"account-form",onSubmit:V,className:"space-y-6",children:[i.jsxs("section",{children:[i.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Account Information"}),i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{children:[i.jsx("label",{htmlFor:"account-provider",className:"text-sm font-medium mb-1.5 block",children:"Provider"}),i.jsxs(_s,{id:"account-provider",value:j,onChange:p=>w(p.target.value),children:[i.jsx("option",{value:"",children:"Custom / other"}),$s.map(p=>i.jsx("option",{value:p.id,children:p.label},p.id))]}),i.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Pick your email provider to fill in server settings automatically, or choose Custom to enter them by hand."})]}),i.jsxs("div",{children:[i.jsx("label",{htmlFor:"account-email",className:"text-sm font-medium mb-1.5 block",children:"Email Address"}),i.jsx(de,{id:"account-email",...f.register("email"),placeholder:"alice@example.com"}),f.formState.errors.email&&i.jsx("p",{className:"text-sm text-danger mt-1",children:f.formState.errors.email.message})]}),i.jsxs("div",{children:[i.jsx("label",{htmlFor:"account-displayName",className:"text-sm font-medium mb-1.5 block",children:"Display name (optional)"}),i.jsx(de,{id:"account-displayName",...f.register("displayName"),placeholder:"Alice"}),i.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"What to call this account in Remit. Leave blank to use a name derived from the address."})]}),i.jsxs("div",{children:[i.jsx("label",{htmlFor:"account-username",className:"text-sm font-medium mb-1.5 block",children:"Username"}),i.jsx(de,{id:"account-username",...f.register("username"),placeholder:"Same as email if empty"})]}),i.jsxs("div",{children:[i.jsx("label",{htmlFor:"account-password",className:"text-sm font-medium mb-1.5 block",children:"Password"}),i.jsx(de,{id:"account-password",...f.register("password",{onChange:()=>u(!0)}),type:"password",onFocus:()=>{d&&!n&&(f.setValue("password",""),u(!0))},placeholder:d?"Leave empty to keep current":""}),f.formState.errors.password&&i.jsx("p",{className:"text-sm text-danger mt-1",children:f.formState.errors.password.message}),I&&i.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[I.passwordHelp.text," ",i.jsx("a",{href:I.passwordHelp.url,target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline",children:"Get an app password"})]})]})]})]}),i.jsxs("section",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider",children:"Incoming Mail (IMAP)"}),I&&i.jsx("button",{type:"button",onClick:()=>H(p=>!p),className:"text-xs text-fg-muted hover:text-fg transition-colors",children:P?"Use preset settings":"Advanced"})]}),C&&i.jsxs("p",{className:"text-xs text-fg-muted mb-3",children:["Server settings are pre-filled for ",I?.label," and locked. Choose Advanced to edit them by hand."]}),i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{children:[i.jsx("label",{htmlFor:"imap-host",className:"text-sm font-medium mb-1.5 block",children:"Server"}),i.jsx(de,{id:"imap-host",...f.register("imapHost"),readOnly:C,placeholder:"imap.example.com"}),f.formState.errors.imapHost&&i.jsx("p",{className:"text-sm text-danger mt-1",children:f.formState.errors.imapHost.message})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx("label",{htmlFor:"imap-port",className:"text-sm font-medium mb-1.5 block",children:"Port"}),i.jsx(de,{id:"imap-port",...f.register("imapPort"),readOnly:C,type:"number"})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-sm font-medium mb-1.5 block",children:"Security"}),i.jsxs("div",{className:"space-y-1.5 mt-2",children:[i.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[i.jsx("input",{type:"radio",disabled:C,checked:f.watch("imapTls"),onChange:()=>_("tls")}),"TLS (Port 993)"]}),i.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[i.jsx("input",{type:"radio",disabled:C,checked:!f.watch("imapTls")&&f.watch("imapStartTls"),onChange:()=>_("starttls")}),"STARTTLS (Port 143)"]}),i.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[i.jsx("input",{type:"radio",disabled:C,checked:!f.watch("imapTls")&&!f.watch("imapStartTls"),onChange:()=>_("none")}),"None (Unencrypted)"]})]})]})]}),i.jsx(se,{type:"button",variant:"secondary",onClick:J,disabled:b.isPending,className:"w-full",icon:b.isPending?i.jsx(et,{className:"size-4 animate-spin"}):void 0,children:b.isPending?"Testing...":"Test IMAP Connection"}),b.data&&i.jsxs("div",{className:wt("p-2 rounded-md text-sm",b.data.imapSuccess?"bg-positive/10 text-positive":"bg-danger-soft text-danger"),children:[b.data.imapSuccess?i.jsx(St,{className:"inline size-4 mr-1"}):i.jsx(Oe,{className:"inline size-4 mr-1"}),b.data.imapSuccess?"IMAP Connected":ye]})]})]}),i.jsxs("section",{ref:N,"data-testid":"smtp-section",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider",children:"Outgoing Mail (SMTP)"}),!C&&i.jsx("button",{type:"button",onClick:$,disabled:!f.watch("imapHost"),className:"text-xs text-fg-muted hover:text-fg transition-colors disabled:opacity-50",children:"Pre-fill from IMAP"})]}),i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{children:[i.jsx("label",{htmlFor:"smtp-host",className:"text-sm font-medium mb-1.5 block",children:"Server"}),i.jsx(de,{id:"smtp-host",...f.register("smtpHost"),readOnly:C,placeholder:"smtp.example.com"})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx("label",{htmlFor:"smtp-port",className:"text-sm font-medium mb-1.5 block",children:"Port"}),i.jsx(de,{id:"smtp-port",...f.register("smtpPort"),readOnly:C,type:"number"})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-sm font-medium mb-1.5 block",children:"Security"}),i.jsxs("div",{className:"space-y-1.5 mt-2",children:[i.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[i.jsx("input",{type:"radio",disabled:C,checked:f.watch("smtpTls")===!0,onChange:()=>D("tls")}),"TLS (Port 465)"]}),i.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[i.jsx("input",{type:"radio",disabled:C,checked:!f.watch("smtpTls")&&f.watch("smtpStartTls")===!0,onChange:()=>D("starttls")}),"STARTTLS (Port 587)"]}),i.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[i.jsx("input",{type:"radio",disabled:C,checked:!f.watch("smtpTls")&&!f.watch("smtpStartTls"),onChange:()=>D("none")}),"None (Unencrypted)"]})]})]})]}),i.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[i.jsx("input",{type:"checkbox",...f.register("useDifferentSmtpCreds")}),"Use different credentials for SMTP"]}),f.watch("useDifferentSmtpCreds")&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{children:[i.jsx("label",{htmlFor:"smtp-username",className:"text-sm font-medium mb-1.5 block",children:"SMTP Username"}),i.jsx(de,{id:"smtp-username",...f.register("smtpUsername")})]}),i.jsxs("div",{children:[i.jsx("label",{htmlFor:"smtp-password",className:"text-sm font-medium mb-1.5 block",children:"SMTP Password"}),i.jsx(de,{id:"smtp-password",...f.register("smtpPassword"),type:"password"})]})]}),i.jsx(se,{type:"button",variant:"secondary",onClick:R,disabled:b.isPending||!f.watch("smtpHost"),className:"w-full",icon:b.isPending?i.jsx(et,{className:"size-4 animate-spin"}):void 0,children:b.isPending?"Testing...":"Test SMTP Connection"}),b.data?.smtpSuccess!==void 0&&i.jsxs("div",{className:wt("p-2 rounded-md text-sm",b.data.smtpSuccess?"bg-positive/10 text-positive":"bg-danger-soft text-danger"),children:[b.data.smtpSuccess?i.jsx(St,{className:"inline size-4 mr-1"}):i.jsx(Oe,{className:"inline size-4 mr-1"}),b.data.smtpSuccess?"SMTP Connected":Z]})]})]}),d&&i.jsxs("section",{children:[i.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Signature"}),i.jsx("div",{className:"space-y-3",children:i.jsxs("div",{children:[i.jsx("label",{htmlFor:"email-sig-edit",className:"text-sm font-medium mb-1.5 block",children:"Email Signature"}),i.jsx("textarea",{id:"email-sig-edit",value:W,onChange:p=>ee(p.target.value),onBlur:A,rows:5,className:"w-full px-3 py-2 border border-line rounded-md bg-surface-sunken text-sm text-fg placeholder:text-fg-subtle focus-within:border-line-strong focus-within:ring-2 focus-within:ring-ring/30 transition-colors resize-y outline-none",placeholder:"Enter your email signature..."}),i.jsx("p",{className:"text-xs text-fg-muted mt-1",children:le?"Saving signature...":"This signature will be appended to new emails."})]})})]})]})})};function Wt({open:e,onClose:s,accountEmail:t,signOut:a}){const[c,d]=O.useState(""),[n,u]=O.useState(!1),[j,E]=O.useState(!1),P=Ne({...Vs(),onSuccess:()=>{E(!0),setTimeout(()=>a(),2e3)}}),H=Ne(ks()),I=()=>{P.isPending||(d(""),u(!1),E(!1),P.reset(),H.reset(),s())},C=()=>{if(c.trim().toLowerCase()!==t.toLowerCase()){u(!0);return}u(!1),P.mutate({body:{confirmEmail:c.trim()}})};return i.jsxs(Yt,{open:e,onClose:I,title:"Delete your Remit account",children:[i.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[i.jsx(nt,{className:"size-4 shrink-0 text-danger"}),i.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:"Delete your Remit account"}),i.jsx(se,{variant:"ghost",size:"sm",icon:i.jsx(Oe,{className:"size-3.5"}),onClick:I,"aria-label":"Cancel"})]}),j?i.jsxs("div",{className:"px-5 py-6 text-sm text-fg-muted",children:[i.jsx("p",{className:"font-medium text-fg",children:"Account deletion scheduled."}),i.jsx("p",{className:"mt-1",children:"Your data will be erased shortly. Signing you out…"})]}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"space-y-4 px-5 py-4 text-sm text-fg-muted",children:[i.jsx("p",{children:"This permanently erases everything Remit holds for you:"}),i.jsxs("ul",{className:"space-y-1.5 text-xs",children:[i.jsxs("li",{className:"flex gap-2",children:[i.jsx("span",{className:"text-danger",children:"•"}),"All connected accounts disconnected and access tokens revoked."]}),i.jsxs("li",{className:"flex gap-2",children:[i.jsx("span",{className:"text-danger",children:"•"}),"Synced mail cache and search index."]}),i.jsxs("li",{className:"flex gap-2",children:[i.jsx("span",{className:"text-danger",children:"•"}),"AI history and insights."]}),i.jsxs("li",{className:"flex gap-2",children:[i.jsx("span",{className:"text-danger",children:"•"}),"Preferences and rules."]})]}),i.jsxs("div",{className:"rounded-sm border border-line bg-surface-sunken px-3 py-2 text-xs",children:[i.jsx("strong",{className:"text-fg",children:"Your mail at Gmail / IMAP is not deleted."})," ","This only removes Remit's copy and its access — the mail stays in your provider mailboxes."]}),i.jsxs("div",{className:"text-xs",children:[i.jsxs("button",{type:"button",onClick:()=>H.mutate({}),"aria-busy":H.isPending,className:"inline-flex items-center gap-1.5 font-medium text-accent hover:underline",children:[i.jsx(Ys,{className:"size-3.5"}),H.isPending?"Requesting export…":"Export my data first"]}),H.isSuccess&&i.jsx("p",{className:"mt-1.5 text-fg-muted",role:"status",children:"Export requested. We'll prepare a ZIP of your mail — find it under your data exports when it's ready."}),H.isError&&i.jsx("p",{className:"mt-1.5 text-danger",role:"alert",children:"Couldn't start the export. Please try again."})]}),i.jsxs("div",{children:[i.jsxs("label",{htmlFor:"confirm-remit-email",className:"mb-1 block text-xs font-medium text-fg",children:["Type"," ",i.jsx("span",{className:"font-mono text-fg-muted",children:t})," ","to confirm"]}),i.jsx(de,{id:"confirm-remit-email",type:"email",placeholder:t,value:c,onChange:N=>{d(N.target.value),n&&u(!1),P.isError&&P.reset()},autoComplete:"off"}),n&&i.jsx("p",{className:"mt-1.5 text-xs text-danger",role:"alert",children:"That doesn't match your account email. Type it exactly to confirm."}),P.isError&&i.jsx("p",{className:"mt-1.5 text-xs text-danger",role:"alert",children:P.error instanceof Error?P.error.message:"Something went wrong. Please try again."})]})]}),i.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[i.jsx(se,{variant:"secondary",size:"sm",onClick:I,children:"Cancel"}),i.jsx(se,{variant:"danger",size:"sm",onClick:C,"aria-busy":P.isPending,children:P.isPending?"Deleting…":"Delete everything"})]})]})]})}function Ur(e){const{Account:s}=Ps();return i.jsx(s,{fallback:i.jsx(Wt,{...e,accountEmail:"",signOut:()=>{}}),children:({email:t,signOut:a})=>i.jsx(Wt,{...e,accountEmail:t??"",signOut:a})})}function Lr(){const[e,s]=O.useState(!1);return i.jsxs("section",{className:"mt-8 border-t border-line pt-6",children:[i.jsx(Xs,{title:"Delete your Remit account",description:"Disconnects every account and erases Remit's copy of your mail, insights and preferences. Your mail at the providers is untouched.",action:i.jsx(se,{variant:"danger",size:"sm",onClick:()=>s(!0),children:"Delete your Remit account"})}),i.jsx(Ur,{open:e,onClose:()=>s(!1)})]})}function Hr(e){const s=e.toLowerCase();return s==="access_denied"?"You cancelled the sign-in.":s==="consent_required"||s.includes("admin_consent")||s.includes("interaction_required")?"Your organisation's admin needs to approve Remit. Ask your IT admin to grant the required permissions.":s.includes("imap_disabled")||s.includes("imap disabled")?"IMAP is disabled for this account. Ask your admin to enable IMAP access in the Microsoft 365 admin centre.":`Sign-in failed: ${e}. Please try again.`}function zr(e){const s=e.split("@")[0]??"";return s?s.split(/[._-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" "):e}function Br(e){const s=e.displayName?.trim();return s||zr(e.email)}function qr(e){if(!e.lastSyncAt)return"never synced";const s=Qs(e.lastSyncAt);return s?`synced ${s}`:"never synced"}function Kt(e){return e.muted?.value?"muted":e.lastError?"error":e.connectionState==="authenticated"?"healthy":"error"}function $r(e){return e.connectionState==="reauth_required"}const Wr=i.jsxs("div",{className:"space-y-3",children:[i.jsxs("p",{children:[i.jsx("strong",{className:"text-fg",children:"Sync health"})," shows the IMAP connection state and the last successful sync per account."]}),i.jsxs("p",{children:[i.jsx("strong",{className:"text-fg",children:"Error"})," means the last connection attempt failed — the raw server response is shown on the card. Reconnect re-runs the connection test from the add-account wizard."]}),i.jsxs("p",{children:[i.jsx("strong",{className:"text-fg",children:"Muted"})," accounts keep syncing but stay out of the daily brief and unified counts."]})]}),Kr=()=>i.jsx("div",{className:"space-y-3",role:"status","aria-busy":"true","aria-label":"Loading accounts",children:["skeleton-0","skeleton-1"].map(e=>i.jsx("div",{className:"rounded-sm border border-line bg-surface animate-pulse p-4",children:i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"size-10 rounded-full bg-surface-sunken"}),i.jsxs("div",{className:"flex-1 space-y-2",children:[i.jsx("div",{className:"h-4 bg-surface-sunken rounded w-1/3"}),i.jsx("div",{className:"h-3 bg-surface-sunken rounded w-2/3"})]})]})},e))});function ni(){const e=Tt.useSearch(),s=Ds({from:Tt.fullPath}),[t,a]=O.useState(!0),[c,d]=O.useState(!1),[n,u]=O.useState(!1),[j,E]=O.useState(null),[P,H]=O.useState(!1),[I,C]=O.useState(null),[N,f]=O.useState(null),[b,ie]=O.useState(null),[T,J]=O.useState(null),R=Gt(),{data:V,isPending:oe,isError:re,error:pe,refetch:le}=Fs(Cs());O.useEffect(()=>{e.editAccountId&&(E(e.editAccountId),H(!!e.focusSmtp),s({search:{editAccountId:void 0,focusSmtp:void 0,connected:e.connected,oauthError:e.oauthError},replace:!0}))},[e.editAccountId,e.focusSmtp,s,e.connected,e.oauthError]),O.useEffect(()=>{e.connected&&(f("Account connected successfully."),E(e.connected),R.invalidateQueries({queryKey:Fe()}),s({search:{connected:void 0,oauthError:void 0,editAccountId:void 0,focusSmtp:void 0},replace:!0}))},[e.connected,s,R]),O.useEffect(()=>{e.oauthError&&(ie(Hr(e.oauthError)),s({search:{oauthError:void 0,connected:void 0,editAccountId:void 0,focusSmtp:void 0},replace:!0}))},[e.oauthError,s]);const W=Ne({...Os(),onSuccess:w=>{window.location.assign(w.authorizationUrl)},onError:w=>{ie(w instanceof Error?w.message:"Failed to start reconnect"),J(null)}}),ee=Ne({...Is(),onSuccess:()=>{R.invalidateQueries({queryKey:Fe()}),C(null)}}),A=V?.accounts.find(w=>w.accountId===I),_=V?.accounts.find(w=>w.accountId===j),D=()=>{d(!1),u(!1),E(null),H(!1)},$=w=>{const L=Us[w];L&&s({to:L})};return i.jsxs(Bs,{items:Rs,activeId:"accounts",title:"Accounts",description:"Every account keeps syncing — muted ones just stay out of unified views.",help:Wr,helpOpen:t,onToggleHelp:()=>a(w=>!w),onSelect:$,onBackToMail:()=>{s({to:"/mail"})},children:[N&&i.jsx(At,{tone:"success",variant:"soft","data-testid":"oauth-success-banner",onDismiss:()=>f(null),children:N}),b&&i.jsx(At,{tone:"danger",variant:"soft","data-testid":"oauth-error-banner",onDismiss:()=>ie(null),children:b}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(Ms,{tone:"neutral",children:oe||re?"accounts":`${V.accounts.length} ${V.accounts.length===1?"account":"accounts"}`}),i.jsx(se,{variant:"primary",size:"sm",icon:i.jsx(_t,{className:"size-3.5"}),onClick:()=>u(!0),children:"Add account"})]}),oe?i.jsx(Kr,{}):re?i.jsx(Zs,{title:"Couldn't load accounts",error:pe,onRetry:()=>{le()}}):V.accounts.length===0?i.jsxs("div",{className:"py-12 text-sm text-fg-muted","data-testid":"accounts-empty",children:[i.jsx("p",{className:"mb-3",children:"No accounts configured."}),i.jsx(se,{variant:"primary",size:"sm",icon:i.jsx(_t,{className:"size-3.5"}),onClick:()=>u(!0),children:"Add your first account"})]}):i.jsx("div",{className:"space-y-3",children:V.accounts.map(w=>{const L=$r(w),ye=w.authType==="oauthMicrosoft",Z=T===w.accountId&&W.isPending,ve=L&&ye?{label:"Reconnect",variant:"secondary",busy:Z,busyLabel:"Redirecting…",onClick:()=>{J(w.accountId),W.mutate({body:{email:w.email}})}}:Kt(w)==="error"?{label:"Reconnect",variant:"secondary",onClick:()=>E(w.accountId)}:{label:"Manage",variant:"ghost",onClick:()=>E(w.accountId)},p=i.jsx(zs,{actions:[ve],destructive:{label:"Delete account",iconOnly:!0,icon:i.jsx(Ls,{className:"size-3.5"}),onClick:()=>C(w.accountId)}});return i.jsx(qs,{label:Br(w),email:w.email,connector:ye?"Microsoft 365":"IMAP",syncLabel:qr(w),state:Kt(w),errorDetail:L?"Re-authentication required":w.lastError,trailing:p},w.accountId)})}),n&&i.jsx("div",{className:"fixed inset-0 z-40 overflow-auto bg-canvas",children:i.jsx(Ws,{skipWelcome:!0,onComplete:()=>{u(!1),R.invalidateQueries({queryKey:Fe()})},onCancel:()=>u(!1)})}),i.jsx(Mr,{isOpen:c||!!j,account:_,focusSmtp:P,onClose:D}),i.jsxs(Yt,{open:!!I,onClose:()=>C(null),title:"Delete account",children:[i.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[i.jsx(nt,{className:"size-4 shrink-0 text-danger"}),i.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:"Delete account"}),i.jsx(se,{variant:"ghost",size:"sm",icon:i.jsx(Oe,{className:"size-3.5"}),onClick:()=>C(null),"aria-label":"Cancel"})]}),i.jsxs("div",{className:"space-y-3 px-5 py-4 text-sm text-fg-muted",children:[i.jsx("p",{className:"text-center text-lg font-medium text-fg",children:"Are you sure?"}),A&&i.jsx("p",{className:"text-center",children:A.email}),i.jsxs("ul",{className:"list-inside list-disc space-y-1",children:[i.jsx("li",{children:"Remove the account from your settings"}),i.jsx("li",{children:"Stop syncing mail for this account"}),i.jsx("li",{children:"Delete all associated data (within 24 hours)"})]})]}),i.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[i.jsx(se,{variant:"secondary",size:"sm",onClick:()=>C(null),children:"Cancel"}),i.jsx(se,{variant:"danger",size:"sm","aria-busy":ee.isPending,icon:ee.isPending?i.jsx(et,{className:"size-3.5 animate-spin"}):void 0,onClick:()=>{ee.isPending||I&&ee.mutate({path:{accountId:I}})},children:ee.isPending?"Deleting…":"Delete account"})]})]}),i.jsx(Lr,{})]})}export{ni as component,Hr as mapOauthError};
@@ -1 +0,0 @@
1
- import{$ as q,at as K,bR as Q,bS as G,r as h,j as e,bT as H,aZ as V,i as M,B as j,D as J,d as W,bU as Y,T as Z,ae as X,aq as I,ay as ee,bD as te,bF as se,af as ae,aO as O}from"./index-DsR4Mk7n.js";import{S as ie}from"./settings-screen-6C3zeyy1.js";import{l as ne,N as F,d as re,r as le,e as oe,S as D,g as ce,n as de,u as me,B as ue,m as xe,o as pe,p as fe,q as he,b as ge}from"./useRulePreview-Ct7Q8uG2.js";import{C as w}from"./circle-check-Ccc0DpRT.js";import{E as T}from"./ErrorState-DaIYWAtU.js";import"./avatar-WAi3XoGV.js";const ve=(t,s)=>{const n=q(),a=K({...G(),onSuccess:()=>{t&&(n.invalidateQueries({queryKey:ne(t)}),s&&n.invalidateQueries({queryKey:Q({path:{accountId:t,filterId:s}})}))}}),{mutate:r}=a;return{updateFilter:h.useCallback(d=>{!t||!s||r({path:{accountId:t,filterId:s},body:d})},[t,s,r]),isPending:a.isPending,isSuccess:a.isSuccess,isError:a.isError,error:a.error,reset:a.reset}},je=(t,s=!1)=>({clauses:t.literalClauses.map((a,r)=>({id:`clause-${r}`,field:a.field,value:a.value})),matchOperator:t.matchOperator==="And"?"all":"any",widen:t.hasAnchor?{anchorCount:1,...s?{inactive:!0}:{}}:void 0,moveMailboxId:t.actionMailboxId!==F?t.actionMailboxId:void 0,scope:t.scope==="Temporary"?"until":"standing",until:t.scope==="Temporary"?ye(t.expiresAt):void 0,name:t.name}),ye=t=>{if(!t)return"";const s=Date.parse(t);if(Number.isNaN(s))return"";const n=new Date(s),a=r=>String(r).padStart(2,"0");return`${n.getFullYear()}-${a(n.getMonth()+1)}-${a(n.getDate())}`},E=t=>JSON.stringify({clauses:t.clauses.map(s=>[s.field,s.value]),operator:t.matchOperator,move:t.moveMailboxId??null,widen:t.widen?t.widen.inactive?"inactive":"active":"none"}),k=(t,s)=>E(t)!==E(s),be=(t,s)=>{const n={},a=(t.name??"").trim();return a!==(s.name??"").trim()&&(n.name=a),k(t,s)&&(n.matchOperator=t.matchOperator==="all"?"And":"Or",n.literalClauses=t.clauses.map(r=>({field:r.field,value:r.value})),n.actionMailboxId=t.moveMailboxId??F),n};function Ne({accountId:t,filter:s,folders:n,semanticUnavailable:a=!1,onClose:r}){const x=h.useMemo(()=>je(s,a),[s,a]),[d,l]=h.useState(x),[m,c]=h.useState(),[p,f]=h.useState(!1),b=h.useRef(0),y=re(t,le(d)),g=ve(t,s.filterId),u=oe(t),N=()=>c({mode:"add",draft:{field:D[0],value:""}}),C=o=>{const i=d.clauses.find(v=>v.id===o);i&&c({mode:"edit",clauseId:o,draft:{field:i.field,value:i.value}})},A=o=>c(i=>i&&{...i,draft:{...i.draft,field:o}}),R=o=>c(i=>i&&{...i,draft:{...i.draft,value:o}}),P=()=>{if(!m)return;const o=m.draft.field,i=de(o,m.draft.value);i!==""&&(l(v=>m.mode==="edit"&&m.clauseId?{...v,clauses:v.clauses.map(S=>S.id===m.clauseId?{id:S.id,field:o,value:i}:S)}:(b.current+=1,{...v,clauses:[...v.clauses,{id:`new-${b.current}`,field:o,value:i}]})),c(void 0))},$=o=>l(i=>({...i,clauses:i.clauses.filter(v=>v.id!==o)})),z=o=>l(i=>({...i,matchOperator:o})),L=o=>l(i=>({...i,moveMailboxId:o||void 0})),_=o=>l(i=>({...i,name:o})),B=()=>{const o=k(d,x),i=be(d,x);if(Object.keys(i).length===0){r();return}f(o),g.updateFilter(i)},U=()=>u.start(ce(d));return u.isStarting||u.isRunning||u.isDone?e.jsx(we,{progress:u.progress,isDone:u.isDone,onClose:r}):g.isPending?e.jsx(Ce,{}):g.isError?e.jsx(Oe,{onRetry:g.reset,onClose:r}):g.isSuccess?p?e.jsx(Fe,{preview:H(y),blocked:y.status!=="ready"||y.stale===!0,onReapply:U,onClose:r}):e.jsx(Se,{onClose:r}):e.jsx(V,{rule:d,folders:n,preview:y,semanticAvailable:!1,clauseFields:D,lifecycleLocked:!0,clauseEdit:m,onStartAddClause:N,onStartEditClause:C,onRemoveClause:$,onChangeDraftField:A,onChangeDraftValue:R,onSubmitClause:P,onCancelClause:()=>c(void 0),onChangeMatchOperator:z,onChangeMove:L,onChangeName:_,onCommit:B,onCancel:r})}function Ce(){return e.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[e.jsx(M,{className:"size-8 animate-spin text-accent-2"}),e.jsx("p",{className:"text-sm font-medium text-fg",children:"Saving changes…"})]})}function Se({onClose:t}){return e.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[e.jsx(w,{className:"size-8 text-positive"}),e.jsx("p",{className:"text-sm font-medium text-fg",children:"Filter updated"}),e.jsx(j,{variant:"primary",onClick:t,className:"mt-2",children:"Done"})]})}function Fe({preview:t,blocked:s,onReapply:n,onClose:a}){return e.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[e.jsx(w,{className:"size-8 text-positive"}),e.jsx("p",{className:"text-sm font-medium text-fg",children:"Rule saved"}),e.jsxs("p",{className:"max-w-xs text-xs text-fg-muted",children:["New mail follows the rule automatically. ",t," — move the mail already in your mailbox too?"]}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx(j,{variant:"primary",onClick:n,disabled:s,children:"Move existing mail"}),e.jsx(j,{variant:"ghost",onClick:a,children:"Not now"})]})]})}function we({progress:t,isDone:s,onClose:n}){const a=t.state==="Failed";return e.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[s?a?e.jsx("span",{className:"text-sm font-semibold text-danger",children:"Move failed"}):e.jsx(w,{className:"size-8 text-positive"}):e.jsx(M,{className:"size-8 animate-spin text-accent-2"}),!s&&e.jsx("p",{className:"text-sm font-medium text-fg",children:"Moving existing mail…"}),s&&!a&&e.jsxs("div",{className:"text-sm text-fg",children:[e.jsx("p",{className:"font-medium",children:"Done"}),e.jsxs("p",{className:"mt-1 text-xs text-fg-muted",children:[t.appliedCount," of ",t.matchedCount," moved",t.failedCount>0?` · ${t.failedCount} failed`:"","."]})]}),s&&a&&e.jsx("p",{className:"max-w-xs text-xs text-fg-muted",children:t.errorMessage||"Something went wrong. Please try again."}),s&&e.jsx(j,{variant:"primary",onClick:n,className:"mt-2",children:"Done"})]})}function Oe({onRetry:t,onClose:s}){return e.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[e.jsx("p",{className:"text-sm font-medium text-danger",children:"Couldn't save changes"}),e.jsx("p",{className:"max-w-xs text-xs text-fg-muted",children:"Please try again."}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx(j,{variant:"primary",onClick:t,children:"Try again"}),e.jsx(j,{variant:"ghost",onClick:s,children:"Not now"})]})]})}function De({accountId:t,filter:s,folders:n,semanticUnavailable:a,onClose:r}){const x=me(),d=e.jsx(Ne,{accountId:t,filter:s,folders:n,semanticUnavailable:a,onClose:r});return x?e.jsx(J,{open:!0,onClose:r,title:"Filter rule",children:d}):e.jsx(ue,{open:!0,onClose:r,dismissLabel:"Dismiss filter rule",children:d})}function Ee({filters:t,mailboxName:s,onEdit:n,onDelete:a,deletingFilterId:r,semanticUnavailable:x=!1,now:d=Date.now()}){return t.length===0?e.jsx("p",{className:"py-6 text-sm text-fg-muted",children:"No filters yet. Select a few messages in the inbox and choose Organize to make one."}):e.jsx("ul",{className:"divide-y divide-line rounded-md border border-line",children:t.map(l=>{const m=xe(l,d),c=m==="Expired",p=l.actionMailboxId!==F?s(l.actionMailboxId):void 0,f=pe(l.expiresAt);return e.jsxs("li",{className:"flex items-start gap-3 px-3 py-2.5",children:[e.jsxs("button",{type:"button",onClick:()=>n(l.filterId),"aria-label":`Edit filter ${l.name}`,className:"min-w-0 flex-1 rounded-sm text-left hover:opacity-80",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`truncate text-sm font-medium ${c?"text-fg-muted":"text-fg"}`,children:l.name}),e.jsx(W,{tone:c?"neutral":"positive",dot:!0,children:m})]}),e.jsxs("p",{className:"mt-0.5 text-xs text-fg-subtle",children:[p?`Moves matches to ${p}`:"No move action",l.scope==="Temporary"&&f?c?` · expired ${f}`:` · until ${f}`:l.scope==="Standing"?" · always":""]}),l.hasAnchor&&e.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:e.jsx(Y,{widen:{anchorCount:1,...x?{inactive:!0}:{}}})})]}),e.jsx(j,{variant:"ghost",size:"sm",icon:e.jsx(Z,{className:"size-4 text-danger"}),onClick:()=>a(l.filterId),disabled:r===l.filterId,"aria-label":`Delete filter ${l.name}`})]},l.filterId)})})}const Me=e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{children:["Filters are the standing rules Organize creates. A"," ",e.jsx("strong",{children:"Standing"})," filter keeps working on new mail; a"," ",e.jsx("strong",{children:"Temporary"})," one stops on its own at the date you picked."]}),e.jsx("p",{children:"An expired filter isn't deleted the instant it lapses — it stays here, marked Expired, so you can see what it did and when it stopped."})]});function Ie({account:t}){const s=t.accountId,{filters:n,isPending:a,isError:r,error:x,refetch:d}=fe(s),{deleteFilter:l,deletingFilterId:m}=he(s),[c,p]=h.useState(),{data:f}=I({...ae({path:{accountId:s}}),staleTime:1/0}),b=h.useCallback(u=>{const N=f?.items.find(C=>C.mailboxId===u);return N?O(N.fullPath):void 0},[f?.items]),y=h.useMemo(()=>ge(f?.items??[]).map(u=>({id:u.mailboxId,label:O(u.fullPath)})),[f?.items]),g=n.find(u=>u.filterId===c);return e.jsxs("section",{className:"space-y-2",children:[e.jsx("h2",{className:"text-sm font-semibold text-fg",children:t.email}),g&&e.jsx(De,{accountId:s,filter:g,folders:y,onClose:()=>p(void 0)}),a?e.jsx("div",{className:"h-16 animate-pulse rounded-md border border-line bg-surface","aria-busy":"true","aria-label":`Loading filters for ${t.email}`}):r?e.jsx(T,{variant:"inline",title:`Couldn't load filters for ${t.email}`,error:x,onRetry:()=>{d()}}):e.jsx(Ee,{filters:n,mailboxName:b,onEdit:p,onDelete:l,deletingFilterId:m})]})}function ze(){const t=X(),[s,n]=h.useState(!0),{data:a,isPending:r,isError:x,error:d,refetch:l}=I(ee()),m=c=>{const p=se[c];p&&t({to:p})};return e.jsx(ie,{items:te,activeId:"filters",title:"Filters",description:"Standing and temporary rules created by Organize, per account.",help:Me,helpOpen:s,onToggleHelp:()=>n(c=>!c),onSelect:m,onBackToMail:()=>{t({to:"/mail"})},children:r?e.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":"Loading accounts"}):x?e.jsx(T,{title:"Couldn't load accounts",error:d,onRetry:()=>{l()}}):a.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:a.accounts.map(c=>e.jsx(Ie,{account:c},c.accountId))})})}export{ze as component};
@@ -1 +0,0 @@
1
- import{a}from"./index-DsR4Mk7n.js";const o=a("Folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);export{o as F};
@@ -1 +0,0 @@
1
- import{j as e,c0 as v,r as y,c1 as C,bt as S,y as A,B as E,h as k,c2 as R,ae as L,aq as j,ay as P,bD as T,bF as _,$ as w,af as F,at as N,bo as M,c3 as D,aJ as $,c4 as Q,c5 as B,k as q,c6 as G}from"./index-DsR4Mk7n.js";import{F as H}from"./folder-DOSErHSR.js";import{S as K}from"./settings-screen-6C3zeyy1.js";import{E as O}from"./ErrorState-DaIYWAtU.js";import"./avatar-WAi3XoGV.js";const z=["inbox","drafts","sent","archive","junk","trash"],x="";function V(a){const n=a.messageCount===1?"msg":"msgs";return`${v(a.providerPath)} · ${a.messageCount} ${n}`}function J({role:a,folders:n,appointedId:r,displayName:i,onAppoint:m,onRename:p}){const[c,d]=y.useState(i),s=n.find(l=>l.mailboxId===r)??null,t=R(a),u=s!=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:[C(a),t]}),e.jsxs(S,{className:"w-56 shrink-0",value:r??x,"aria-label":`Folder for ${t}`,onChange:l=>m(a,l.target.value===x?null:l.target.value),children:[e.jsx("option",{value:x,children:"None"}),n.map(l=>e.jsx("option",{value:l.mailboxId,children:V(l)},l.mailboxId))]}),s&&e.jsxs(e.Fragment,{children:[e.jsx(A,{className:"flex-1",value:c,placeholder:t,"aria-label":`Display name for ${t}`,onChange:l=>d(l.target.value)}),u&&e.jsx(E,{variant:"ghost",size:"sm",className:"shrink-0",icon:e.jsx(k,{className:"size-4"}),"aria-label":"Save display name",onClick:()=>p(s.mailboxId,c)})]})]}),s&&e.jsxs("span",{className:"truncate pl-[7.5rem] text-2xs text-fg-subtle",title:s.providerPath,children:[s.providerPath," · ",s.messageCount," ",s.messageCount===1?"message":"messages"]})]})}function U({accountEmail:a,folders:n,appointments:r,displayNames:i={},onAppoint:m,onRename:p}){const c=new Set(Object.values(r).filter(s=>s!=null)),d=n.filter(s=>!c.has(s.mailboxId));return e.jsxs("section",{className:"space-y-3",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsxs("h2",{className:"text-sm font-semibold text-fg",children:["Folder roles — ",a]}),e.jsx("p",{className:"text-xs text-fg-muted",children:"Each role points to one folder. Pick the folder that holds the mail — the counts help you tell real folders from empty look-alikes. Appointing a folder here removes it from any other role."})]}),e.jsx("div",{className:"rounded-sm border border-line bg-surface",children:z.map(s=>{const t=r[s]??null;return e.jsx(J,{role:s,folders:n,appointedId:t,displayName:t?i[t]??"":"",onAppoint:m,onRename:p},s)})}),d.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h3",{className:"text-xs font-medium text-fg-muted",children:"Other folders"}),e.jsx("ul",{className:"rounded-sm border border-line bg-surface",children:d.map(s=>e.jsxs("li",{className:"flex items-center gap-2 border-b border-line px-row-inset py-2 text-sm text-fg last:border-b-0",children:[e.jsx(H,{className:"size-4 shrink-0 text-fg-subtle"}),e.jsx("span",{className:"truncate",children:v(s.providerPath)}),e.jsxs("span",{className:"ml-auto shrink-0 text-2xs text-fg-subtle",children:[s.messageCount," ",s.messageCount===1?"message":"messages"]})]},s.mailboxId))})]})]})}const W=e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{children:"Each canonical role — Inbox, Drafts, Sent, Archive, Spam, Trash — points at one of your account's real folders. Pick the one that actually holds the mail; the message counts tell real folders from empty look-alikes."}),e.jsx("p",{children:`Appointing a folder to a role here doesn't touch any other role, and doesn't move or rename anything on the server — it just tells Remit which folder to treat as e.g. "Drafts" everywhere (sidebar, unread badges, the compose flow).`}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Display name"})," renames the appointed folder for the sidebar. Leave it blank to use the role's canonical name."]})]});function X({account:a}){const n=w(),r=a.accountId,{data:i,isPending:m,isError:p,error:c,refetch:d}=j(F({path:{accountId:r}})),s=N({...D(),onSuccess:()=>{n.invalidateQueries({queryKey:M()})}}),t=N({...Q(),onSuccess:()=>{n.invalidateQueries({queryKey:$({path:{accountId:r}})})}}),u=(o,h)=>{s.mutate({path:{accountId:r,role:G[o]},body:{mailboxId:h}})},l=(o,h)=>{const b=h.trim();t.mutate({path:{accountId:r,mailboxId:o},body:{displayNameOverride:b===""?null:b}})};if(m)return e.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":`Loading folders for ${a.email}`});if(p)return e.jsx(O,{variant:"inline",title:`Couldn't load folders for ${a.email}`,error:c,onRetry:()=>{d()}});const I=i.items.map(o=>({mailboxId:o.mailboxId,providerPath:o.fullPath,messageCount:o.messageCount})),f={};for(const o of a.folderAppointments){const h=B[o.role];h&&(f[h]=o.mailboxId??null)}const g={};for(const o of i.items)o.displayNameOverride&&(g[o.mailboxId]=o.displayNameOverride);return e.jsxs("div",{className:"space-y-2",children:[(s.isError||t.isError)&&e.jsx(q,{tone:"danger",variant:"soft",children:"Couldn't save that change. Please try again."}),e.jsx(U,{accountEmail:a.email,folders:I,appointments:f,displayNames:g,onAppoint:u,onRename:l})]})}function te(){const a=L(),[n,r]=y.useState(!0),{data:i,isPending:m,isError:p,error:c,refetch:d}=j(P()),s=t=>{const u=_[t];u&&a({to:u})};return e.jsx(K,{items:T,activeId:"folders",title:"Folder roles",description:"Appoint which real folder fills each canonical role, per account.",help:W,helpOpen:n,onToggleHelp:()=>r(t=>!t),onSelect:s,onBackToMail:()=>{a({to:"/mail"})},children:m?e.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":"Loading accounts"}):p?e.jsx(O,{title:"Couldn't load accounts",error:c,onRetry:()=>{d()}}):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(t=>e.jsx(X,{account:t},t.accountId))})})}export{te as component};