@remit/web-client-dist 0.0.309 → 0.0.310
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.
- package/assets/{ErrorState-CoYNTNJq.js → ErrorState-DiX_zNTK.js} +1 -1
- package/assets/{OnboardingWizard-C6uaYNpR.js → OnboardingWizard-r-N3eGPg.js} +1 -1
- package/assets/{account-form-helpers-BqRAFw9h.js → account-form-helpers-BHUowns0.js} +1 -1
- package/assets/{accounts-D4OtZ41r.js → accounts-B4-7wVt4.js} +1 -1
- package/assets/{advanced-CLPJC7oW.js → advanced-Dlyjnb6l.js} +1 -1
- package/assets/{appearance-D9JbZ1CF.js → appearance-Drfetqy5.js} +1 -1
- package/assets/{avatar-no7z5maH.js → avatar-Ci3CMhdo.js} +1 -1
- package/assets/{browser-ponyfill-ClKzhM_I.js → browser-ponyfill-BhnZT7aq.js} +2 -2
- package/assets/{circle-check-BwajEOAH.js → circle-check-BM6iE_RP.js} +1 -1
- package/assets/{confirm-dialog-DPRgwpsP.js → confirm-dialog-F7nDmx5t.js} +1 -1
- package/assets/{download-C4twhQsf.js → download-Bg6cLSAV.js} +1 -1
- package/assets/{filters-BBCPnnZ1.js → filters-CsWlycJW.js} +1 -1
- package/assets/{flagged-Cujm8pvv.js → flagged-CuV2oZw_.js} +1 -1
- package/assets/{folders-BzM2UocM.js → folders-Dg7RilCS.js} +1 -1
- package/assets/{index-BLRngKEP.js → index-BSJKHoKS.js} +1 -1
- package/assets/index-dsr8I39S.js +1 -0
- package/assets/{index-DAzmnDmQ.js → index-xOALrEh8.js} +59 -59
- package/assets/{kbd-CJO6TTXi.js → kbd-C00o9L4B.js} +1 -1
- package/assets/{labels-DzYgbLjQ.js → labels-pEUVx_Ue.js} +1 -1
- package/assets/{mail-DWCiR4Nu.js → mail-Chm12_Xz.js} +14 -14
- package/assets/{move-options-peU5H7WV.js → move-options-B2c-WWEl.js} +1 -1
- package/assets/{onboarding-Cj7kSn2_.js → onboarding-DKy8Q5MV.js} +1 -1
- package/assets/{pencil-BYhgO1mk.js → pencil-CZK87pI9.js} +1 -1
- package/assets/{rich-text-DUirdWcq.js → rich-text-CoTs3nIc.js} +1 -1
- package/assets/{senders-Bf6ohezs.js → senders-p6LBrcYb.js} +1 -1
- package/assets/settings-C2TANSwS.js +1 -0
- package/assets/{settings-screen-BukG_Ts5.js → settings-screen-C7xmJsXG.js} +1 -1
- package/assets/{shield-check-AWXIQWep.js → shield-check-CdES_QdC.js} +1 -1
- package/assets/{suggested-vips-DxCcVYyq.js → suggested-vips-BQoY6-Yl.js} +1 -1
- package/assets/{useDebouncedValue-DY8PZXql.js → useDebouncedValue-Ck8McJvG.js} +1 -1
- package/assets/{useFilters-BmXXLu1U.js → useFilters-DMt8Gx-P.js} +1 -1
- package/assets/{useLabels-CnYv6kWo.js → useLabels-oSXOt6KZ.js} +1 -1
- package/assets/{useSignature-BZ6jdf71.js → useSignature-BQN3IL24.js} +1 -1
- package/index.html +1 -1
- package/package.json +1 -1
- package/assets/index-B9LE6IYn.js +0 -1
- package/assets/settings-Dr2CVHK2.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as r,c3 as ke,B as ee,S as ks,X as Ve,c4 as Vs,c5 as Ds,G as dt,r as C,d as Nt,R as J,af as ut,aT as Cs,aK as Jt,aS as es,a_ as Fs,aN as Se,aY as Os,c1 as Te,c6 as ts,c7 as Is,c8 as Rs,c9 as Ms,ca as ve,cb as Tt,L as at,l as At,ax as _t,cc as Ls,cd as Ie,ce as be,cf as Et,ay as Us,cg as Hs,ch as zs,D as ss,ci as Pt,au as Bs,cj as qs,ck as $s,cl as Ws,N as kt,e as Ks,cm as Vt,cn as Gs,T as Ys}from"./index-DAzmnDmQ.js";import{u as Qs,R as Zs}from"./useSignature-BZ6jdf71.js";import{S as Xs,A as Js}from"./settings-screen-BukG_Ts5.js";import{g as Dt,P as er,s as Be,u as tr,O as sr}from"./OnboardingWizard-C6uaYNpR.js";import{c as rr,b as Ct,d as ar}from"./account-form-helpers-BqRAFw9h.js";import{D as ir}from"./download-C4twhQsf.js";import{E as nr}from"./ErrorState-CoYNTNJq.js";import{e as or}from"./format-CKZmh-Ru.js";import"./avatar-no7z5maH.js";import"./kbd-CJO6TTXi.js";const lr=e=>{const s=new Set(e.map(Vs));return Ds.map(t=>t.tag).filter(t=>!s.has(t)).sort((t,i)=>ke(t).localeCompare(ke(i)))},cr=({value:e,onChange:s,busy:t=!1})=>{const i=lr(e);return r.jsxs("div",{className:"space-y-2","data-testid":"compose-language-setting",children:[r.jsx("ul",{className:"space-y-1",children:e.map((o,d)=>r.jsxs("li",{"data-testid":`compose-language-row-${o}`,className:"flex items-center gap-2 rounded-md border border-line bg-surface-sunken px-3 py-1.5",children:[r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-fg",lang:o,children:ke(o)}),d===0?r.jsx("span",{className:"shrink-0 text-2xs uppercase tracking-wider text-fg-subtle",children:"Default"}):r.jsx(ee,{variant:"ghost",size:"sm",icon:r.jsx(ks,{className:"size-3.5"}),disabled:t,"aria-label":`Write new messages in ${ke(o)} by default`,onClick:()=>s([o,...e.filter(n=>n!==o)]),children:"Default"}),r.jsx(ee,{variant:"ghost",size:"sm",icon:r.jsx(Ve,{className:"size-3.5"}),disabled:t||e.length===1,"aria-label":`Remove ${ke(o)}`,onClick:()=>s(e.filter(n=>n!==o))})]},o))}),r.jsxs("select",{"aria-label":"Add a language",value:"",disabled:t||i.length===0,onChange:o=>{o.target.value!==""&&s([...e,o.target.value])},className:"w-full rounded-md border border-line bg-surface-sunken px-3 py-2 text-sm text-fg outline-none transition-colors focus-within:border-line-strong focus-within:ring-2 focus-within:ring-ring/30",children:[r.jsx("option",{value:"",children:"Add a language…"}),i.map(o=>r.jsx("option",{value:o,children:ke(o)},o))]}),r.jsx("p",{className:"text-xs text-fg-muted",children:"A message is tagged with the language you write it in, picked from this list. Your browser, not this app, decides which dictionaries it spellchecks against — add the language there too to get its underlines."})]})};function dr({title:e,description:s,action:t}){return r.jsxs("div",{className:"rounded-sm border border-danger/50",children:[r.jsxs("div",{className:"flex items-center gap-2 border-b border-danger/30 bg-danger-soft px-row-inset py-2",children:[r.jsx(dt,{className:"size-4 text-danger"}),r.jsx("h2",{className:"text-sm font-semibold text-danger",children:"Danger zone"})]}),r.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:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"text-sm font-medium text-fg",children:e}),r.jsx("p",{className:"text-xs text-fg-muted",children:s})]}),r.jsx("div",{className:"shrink-0",children:t})]})]})}function Ft({isOpen:e,onClose:s,title:t,children:i,footer:o}){return C.useEffect(()=>{if(!e)return;const d=n=>{n.key==="Escape"&&s()};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[e,s]),r.jsxs(r.Fragment,{children:[r.jsx("div",{className:Nt("fixed inset-0 z-40 bg-black/30 transition-opacity",e?"opacity-100":"pointer-events-none opacity-0"),onClick:s,"aria-hidden":"true"}),r.jsxs("div",{className:Nt("safe-area-frame 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:[r.jsxs("div",{className:"flex h-14 items-center justify-between border-b border-line px-4",children:[r.jsx("h2",{id:"slide-panel-title",className:"font-semibold",children:t}),r.jsx("button",{type:"button",onClick:s,className:"rounded-md p-1.5 transition-colors hover:bg-surface-raised","aria-label":"Close",children:r.jsx(Ve,{className:"size-5"})})]}),r.jsxs("div",{className:"flex h-[calc(100%-3.5rem)] flex-col",children:[r.jsx("div",{className:"flex-1 overflow-auto p-4",children:i}),o&&r.jsx("div",{className:"flex justify-end gap-3 border-t border-line bg-canvas p-4",children:o})]})]})]})}var Le=e=>e.type==="checkbox",je=e=>e instanceof Date,Y=e=>e==null;const ft=e=>typeof e=="object";var z=e=>!Y(e)&&!Array.isArray(e)&&ft(e)&&!je(e),ur=e=>z(e)&&e.target?Le(e.target)?e.target.checked:e.target.value:e,fr=(e,s)=>s.split(".").some((t,i,o)=>!isNaN(Number(t))&&e.has(o.slice(0,i).join("."))),rs=e=>{const s=e.constructor&&e.constructor.prototype;return z(s)&&s.hasOwnProperty("isPrototypeOf")},Ye=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(Ye&&(e instanceof Blob||s))return e;const t=Array.isArray(e);if(!t&&!(z(e)&&rs(e)))return e;const i=t?[]:Object.create(Object.getPrototypeOf(e));for(const o in e)Object.prototype.hasOwnProperty.call(e,o)&&(i[o]=B(e[o]));return i}const Ee={BLUR:"blur",FOCUS_OUT:"focusout",SUBMIT:"submit",TRIGGER:"trigger",VALID:"valid"},ue={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},de={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},as="root",mt=["__proto__","constructor","prototype"],mr=/^\w*$/;var Ue=e=>mr.test(e),L=e=>e===void 0;const hr=/[.[\]'"]/;var Qe=e=>e.split(hr).filter(Boolean),y=(e,s,t)=>{if(!s||!z(e))return t;const i=Ue(s)?[s]:Qe(s);if(i.some(d=>mt.includes(d)))return t;const o=i.reduce((d,n)=>Y(d)?void 0:d[n],e);return L(o)||o===e?L(e[s])?t:e[s]:o},me=e=>typeof e=="boolean",ie=e=>typeof e=="function",F=(e,s,t)=>{let i=-1;const o=Ue(s)?[s]:Qe(s),d=o.length,n=d-1;for(;++i<d;){const u=o[i];let j=t;if(i!==n){const _=e[u];j=z(_)||Array.isArray(_)?_:isNaN(+o[i+1])?{}:[]}if(mt.includes(u))return;e[u]=j,e=e[u]}};const pr=J.createContext(null);pr.displayName="HookFormControlContext";var gr=(e,s,t,i=!0)=>{const o={};for(const d in e)Object.defineProperty(o,d,{get:()=>{const n=d;return s._proxyFormState[n]!==ue.all&&(s._proxyFormState[n]=!i||ue.all),e[n]}});return o};const xr=Ye?J.useLayoutEffect:J.useEffect;var Q=e=>typeof e=="string",yr=(e,s,t,i,o)=>Q(e)?(i&&s.watch.add(e),y(t,e,o)):Array.isArray(e)?e.map(d=>(i&&s.watch.add(d),y(t,d))):(i&&(s.watchAll=!0),t),it=e=>Y(e)||!ft(e);const Ot=(e,s)=>s.length===0&&!Array.isArray(e)&&!rs(e);function he(e,s,t=new WeakMap){if(e===s)return!0;if(it(e)||it(s))return Object.is(e,s);if(je(e)&&je(s))return Object.is(e.getTime(),s.getTime());const i=Object.keys(e),o=Object.keys(s);if(i.length!==o.length)return!1;if(Ot(e,i)||Ot(s,o))return Object.is(e,s);if(!i.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 i){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 qe=e=>({isOnSubmit:!e||e===ue.onSubmit,isOnBlur:e===ue.onBlur,isOnChange:e===ue.onChange,isOnAll:e===ue.all,isOnTouch:e===ue.onTouched}),tt=(e,s,t)=>{if(t)return!1;if(s.watchAll||s.watch.has(e))return!0;for(const i of s.watch)if(e.startsWith(i)&&e.charAt(i.length)===".")return!0;return!1};const Me=(e,s,t,i)=>{for(const o of t||Object.keys(e)){const d=y(e,o);if(d){const{_f:n,...u}=d;if(n){if(n.refs&&n.refs[0]&&s(n.refs[0],o)&&!i)return!0;if(n.ref&&s(n.ref,n.name)&&!i)return!0;if(Me(u,s))break}else if(z(u)&&Me(u,s))break}}};var It=(e,s,t)=>{const i=y(e,t),o=Array.isArray(i)?i:[];return F(o,as,s[t]),F(e,t,o),e},G=e=>z(e)&&!Object.keys(e).length,ht=e=>e.type==="file",Ke=e=>{if(!Ye)return!1;const s=e?e.ownerDocument:0;return e instanceof(s&&s.defaultView?s.defaultView.HTMLElement:HTMLElement)},pt=e=>e.type==="radio",Ge=e=>e instanceof RegExp,gt=(e,s,t,i,o)=>s?{...t[e],types:{...t[e]&&t[e].types?t[e].types:{},[i]:o||!0}}:{};const Rt={value:!1,isValid:!1},Mt={value:!0,isValid:!0};var is=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&&!L(e[0].attributes.value)?L(e[0].value)||e[0].value===""?Mt:{value:e[0].value,isValid:!0}:Mt:Rt}return Rt};const Lt={isValid:!1,value:null};var ns=e=>Array.isArray(e)?e.reduce((s,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:s,Lt):Lt;function Ut(e,s,t="validate"){if(Q(e)||Array.isArray(e)&&e.every(Q)||me(e)&&!e)return{type:t,message:Q(e)?e:"",ref:s}}var Pe=e=>z(e)&&!Ge(e)?e:{value:e,message:""},Ht=async(e,s,t,i,o,d)=>{const{ref:n,refs:u,required:j,maxLength:_,minLength:E,min:H,max:M,pattern:O,validate:A,name:f,valueAsNumber:b,mount:ae}=e._f,N=y(t,f);if(!ae||s.has(f))return{};const W=u?u[0]:n,I=P=>{if(o&&W.reportValidity){const k=me(P)?"":P||"";u?u.forEach(D=>D.setCustomValidity(k)):W.setCustomValidity(k),W.reportValidity()}},T={},ne=pt(n),re=Le(n),pe=ne||re,oe=(b||ht(n))&&L(n.value)&&L(N)||Ke(n)&&n.value===""||N===""||Array.isArray(N)&&!N.length,K=gt.bind(null,f,i,T),te=(P,k,D,$=de.maxLength,w=de.minLength)=>{const R=P?k:D;T[f]={type:P?$:w,message:R,ref:n,...K(P?$:w,R)}};if(d?!Array.isArray(N)||!N.length:j&&(!pe&&(oe||Y(N))||me(N)&&!N||re&&!is(u).isValid||ne&&!ns(u).isValid)){const{value:P,message:k}=Q(j)?{value:!!j,message:j}:Pe(j);if(P&&(T[f]={type:de.required,message:k,ref:W,...K(de.required,k)},!i))return I(k),T}if(!oe&&(!Y(H)||!Y(M))){let P,k;const D=Pe(M),$=Pe(H);if(!Y(N)&&!isNaN(N)){const w=n.valueAsNumber||N&&+N;Y(D.value)||(P=w>D.value),Y($.value)||(k=w<$.value)}else{const w=n.valueAsDate||new Date(N),R=ge=>new Date(new Date().toDateString()+" "+ge),le=n.type=="time",Z=n.type=="week";Q(D.value)&&N&&(P=le?R(N)>R(D.value):Z?N>D.value:w>new Date(D.value)),Q($.value)&&N&&(k=le?R(N)<R($.value):Z?N<$.value:w<new Date($.value))}if((P||k)&&(te(!!P,D.message,$.message,de.max,de.min),!i))return I(T[f].message),T}if((_||E)&&!oe&&(Q(N)||d&&Array.isArray(N))){const P=Pe(_),k=Pe(E),D=!Y(P.value)&&N.length>+P.value,$=!Y(k.value)&&N.length<+k.value;if((D||$)&&(te(D,P.message,k.message),!i))return I(T[f].message),T}if(O&&!oe&&Q(N)){const{value:P,message:k}=Pe(O);if(Ge(P)&&!N.match(P)&&(T[f]={type:de.pattern,message:k,ref:n,...K(de.pattern,k)},!i))return I(k),T}if(A){if(ie(A)){const P=await A(N,t),k=Ut(P,W);if(k&&(T[f]={...k,...K(de.validate,k.message)},!i))return I(k.message),T}else if(z(A)){let P={};for(const k in A){if(!G(P)&&!i)break;const D=Ut(await A[k](N,t),W,k);D&&(P={...D,...K(k,D.message)},I(D.message),i&&(T[f]=P))}if(!G(P)&&(T[f]={ref:W,...P},!i))return T}}return I(!0),T},We=e=>Array.isArray(e)?e:[e],os=e=>Array.isArray(e)?e.filter(Boolean):[];function vr(e,s){const t=s.slice(0,-1).length;let i=0;for(;i<t;){if(Y(e)){e=void 0;break}e=e[s[i]],i++}return e}function br(e){for(const s in e)if(e.hasOwnProperty(s)&&!L(e[s]))return!1;return!0}function q(e,s){if(Q(s)&&Object.prototype.hasOwnProperty.call(e,s))return delete e[s],e;const t=Array.isArray(s)?s:Ue(s)?[s]:Qe(s);if(t.some(n=>mt.includes(String(n))))return e;const i=t.length===1?e:vr(e,t),o=t.length-1,d=t[o];return i&&delete i[d],o!==0&&(z(i)&&G(i)||Array.isArray(i)&&br(i))&&q(e,t.slice(0,-1)),e}const ls=e=>{const s={};for(const t of Object.keys(e))if(ft(e[t])&&e[t]!==null&&!je(e[t])){const i=ls(e[t]);for(const o of Object.keys(i))s[`${t}.${o}`]=i[o]}else s[t]=e[t];return s},jr=J.createContext(null);jr.displayName="HookFormContext";var zt=()=>{let e=[];return{get observers(){return e},next:o=>{for(const d of e)d.next&&d.next(o)},subscribe:o=>(e.push(o),{unsubscribe:()=>{e=e.filter(d=>d!==o)}}),unsubscribe:()=>{e=[]}}};function cs(e,s){const t={};for(const i in e)if(e.hasOwnProperty(i)){const o=e[i],d=s[i];if(o&&z(o)&&d){const n=cs(o,d);z(n)&&(t[i]=n)}else e[i]&&(t[i]=d)}return t}var ds=e=>e.type==="select-multiple",Sr=e=>pt(e)||Le(e),st=e=>Ke(e)&&e.isConnected,wr=e=>{for(const s in e)if(ie(e[s]))return!0;return!1};function us(e){return Array.isArray(e)||z(e)&&!wr(e)}function fs(e){return!!(e&&"_f"in e)}function ms(e){return Array.isArray(e)?!e.some(s=>!L(s)):!Object.keys(e).length}function nt(e,s){Array.isArray(e)?e[s]=void 0:delete e[s]}function ot(e,s={},t){for(const i in e){const o=e[i],d=t&&t[i];us(o)&&(!Array.isArray(o)||!fs(d))?(s[i]=Array.isArray(o)?[]:{},ot(o,s[i],d),ms(s[i])&&nt(s,i)):L(o)||(s[i]=!0)}return s}function Ne(e,s,t,i){t||(t=ot(s,{},i));for(const o in e){const d=e[o],n=i&&i[o];us(d)&&(!Array.isArray(d)||!fs(n))?(L(s)||it(t[o])?t[o]=ot(d,Array.isArray(d)?[]:{},n):Ne(d,Y(s)?{}:s[o],t[o],n),ms(t[o])&&nt(t,o)):he(d,s[o])?nt(t,o):t[o]=!0}return t}var hs=(e,{valueAsNumber:s,valueAsDate:t,setValueAs:i})=>L(e)?e:s?e===""?NaN:e&&+e:t&&Q(e)?new Date(e):i?i(e):e;function Bt(e){const s=e.ref;return ht(s)?s.files:pt(s)?ns(e.refs).value:ds(s)?[...s.selectedOptions].map(({value:t})=>t):Le(s)?is(e.refs).value:hs(L(s.value)?e.ref.value:s.value,e)}var Nr=(e,s,t,i)=>{const o={};for(const d of e){const n=y(s,d);n&&F(o,d,n._f)}return{criteriaMode:t,names:[...e],fields:o,shouldUseNativeValidation:i}},Re=e=>L(e)?e:Ge(e)?e.source:z(e)?Ge(e.value)?e.value.source:e.value:e;const qt="AsyncFunction";var Tr=e=>{if(!e||!e.validate)return!1;if(ie(e.validate))return e.validate.constructor.name===qt;if(z(e.validate)){for(const s in e.validate)if(e.validate[s].constructor.name===qt)return!0}return!1},Ar=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function $t(e,s,t){const i=y(e,t);if(i||Ue(t))return{error:i,name:t};const o=t.split(".");for(;o.length;){const d=o.join("."),n=y(s,d),u=y(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};o.pop()}return{name:t}}var _r=(e,s,t,i)=>{t(e);const{name:o,...d}=e,n=Object.keys(d);return!n.length||i&&n.length>=Object.keys(s).length||n.find(u=>s[u]===(!i||ue.all))},Er=(e,s,t)=>!e||!s||e===s||We(e).some(i=>i&&(t?i===s||i.startsWith(s+"."):i.startsWith(s)||s.startsWith(i))),Pr=(e,s,t,i,o)=>o.isOnAll?!1:!t&&o.isOnTouch?!(s||e):(t?i.isOnBlur:o.isOnBlur)?!e:(t?i.isOnChange:o.isOnChange)?e:!0,kr=(e,s)=>!os(y(e,s)).length&&q(e,s);const Vr={mode:ue.onSubmit,reValidateMode:ue.onChange,shouldFocusError:!0},rt="form",ps={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function Dr(e={}){let s={...Vr,...e},t={...B(ps),isLoading:ie(s.defaultValues),errors:s.errors||{},disabled:s.disabled||!1},i={},o=z(s.defaultValues)||z(s.values)?B(s.defaultValues||s.values)||{}:{},d=s.shouldUnregister?{}:B(o),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={},_={};let E=0,H=qe(s.mode),M=qe(s.reValidateMode);const O={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},A={...O};let f={...A};const b={array:zt(),state:zt()};let ae=0;const N=s.criteriaMode===ue.all,W=(a,l)=>c=>{clearTimeout(_[a]),_[a]=setTimeout(l,c)},I=async a=>{if(!n.keepIsValid&&!s.disabled&&(A.isValid||f.isValid||a)){const l=++ae;let c;s.resolver?(c=G((await D()).errors),l===ae&&T()):c=await R({fields:i,onlyCheckValid:!0,eventType:Ee.VALID}),l===ae&&c!==t.isValid&&b.state.next({isValid:c})}},T=(a,l)=>{!s.disabled&&(A.isValidating||A.validatingFields||f.isValidating||f.validatingFields)&&((a||Array.from(u.mount)).forEach(c=>{c&&(l?F(t.validatingFields,c,l):q(t.validatingFields,c))}),b.state.next({validatingFields:t.validatingFields,isValidating:!G(t.validatingFields)}))},ne=()=>{t.dirtyFields=Ne(o,d,void 0,i)},re=(a,l=[],c,m,h=!0,x=!0)=>{if(m&&c&&!s.disabled){if(n.action=!0,x&&Array.isArray(y(i,a))){const g=c(y(i,a),m.argA,m.argB);h&&F(i,a,g)}if(x&&Array.isArray(y(t.errors,a))){const g=c(y(t.errors,a),m.argA,m.argB);h&&F(t.errors,a,g),kr(t.errors,a)}if((A.touchedFields||f.touchedFields)&&x&&Array.isArray(y(t.touchedFields,a))){const g=c(y(t.touchedFields,a),m.argA,m.argB);h&&F(t.touchedFields,a,g)}(A.dirtyFields||f.dirtyFields)&&ne(),b.state.next({name:a,isDirty:Z(a,l),dirtyFields:t.dirtyFields,errors:t.errors,isValid:t.isValid})}else F(d,a,l)},pe=(a,l)=>{F(t.errors,a,l),t.errors={...t.errors},b.state.next({errors:t.errors})},oe=a=>{t.errors=a,b.state.next({errors:t.errors,isValid:!1})},K=a=>{const l=Ue(a)?[a]:Qe(a);let c=d,m=o;for(let h=0;h<l.length-1;h++){const x=l[h];if(c=Y(c)?c:c[x],m=Y(m)?m:m[x],c===null&&m!==null)return!0}return!1},te=(a,l,c,m)=>{const h=y(i,a);if(h){if(K(a))return;const x=L(y(d,a)),g=y(d,a,L(c)?y(o,a):c);L(g)||m&&m.defaultChecked||l?F(d,a,l?g:Bt(h._f)):De(a,g),n.mount&&!n.action&&(I(),x&&t.isDirty&&(A.isDirty||f.isDirty)&&(Z()||(t.isDirty=!1,b.state.next({...t}))),e.shouldUnregister&&x&&!L(y(d,a))&&tt(a,u)&&(n.watch=!0))}},P=(a,l,c,m,h)=>{let x=!1,g=!1;const v={name:a};if(!s.disabled||m===!0){if(!c||m){const S=he(y(o,a),l);(A.isDirty||f.isDirty)&&(g=t.isDirty,t.isDirty=v.isDirty=!S||Z(),x=g!==v.isDirty),g=!!y(t.dirtyFields,a),S!==t.isDirty?t.dirtyFields=Ne(o,d,void 0,i):S?q(t.dirtyFields,a):F(t.dirtyFields,a,!0),v.dirtyFields=t.dirtyFields,x=x||(A.dirtyFields||f.dirtyFields)&&g!==!S}if(c){const S=y(t.touchedFields,a);S||(F(t.touchedFields,a,c),v.touchedFields=t.touchedFields,x=x||(A.touchedFields||f.touchedFields)&&S!==c)}x&&h&&b.state.next(v)}return x?v:{}},k=(a,l,c,m)=>{const h=y(t.errors,a),x=(A.isValid||f.isValid)&&me(l)&&t.isValid!==l;if(s.delayError&&c?(j[a]=W(a,()=>pe(a,c)),j[a](s.delayError)):(clearTimeout(_[a]),delete j[a],c?F(t.errors,a,c):q(t.errors,a),t.errors={...t.errors}),(c?!he(h,c):h)||!G(m)||x){const g={...m,...x&&me(l)?{isValid:l}:{},errors:t.errors,name:a};t={...t,...g},b.state.next(g)}},D=async a=>(T(a,!0),await s.resolver(d,s.context,Nr(a||u.mount,i,s.criteriaMode,s.shouldUseNativeValidation))),$=async a=>{const{errors:l}=await D(a);if(T(a),a){for(const c of a){const m=y(l,c);m?u.array.has(c)&&z(m)&&!Object.keys(m).some(h=>!Number.isNaN(Number(h)))?It(t.errors,{[c]:m},c):F(t.errors,c,m):q(t.errors,c)}t.errors={...t.errors}}else t.errors=l;return l},w=async({name:a,eventType:l})=>{if(e.validate){const c=await e.validate({formValues:d,formState:t,name:a,eventType:l});if(z(c))for(const m in c){const h=c[m];h&&ze(`${rt}.${m}`,{message:Q(h.message)?h.message:"",type:h.type||de.validate})}else Q(c)||!c?ze(rt,{message:c||"",type:de.validate}):_e(rt);return c}return!0},R=async({fields:a,onlyCheckValid:l,name:c,eventType:m,context:h={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(h.runRootValidation=!0,!await w({name:c,eventType:m})&&(h.valid=!1,l)))return h.valid;for(const x in a){const g=a[x];if(g){const{_f:v,...S}=g;if(v){const U=u.array.has(v.name),X=g._f&&Tr(g._f),xe=A.validatingFields||A.isValidating||f.validatingFields||f.isValidating;X&&xe&&T([v.name],!0);const ye=await Ht(g,u.disabled,d,N,s.shouldUseNativeValidation&&!l,U);if(X&&xe&&T([v.name]),ye[v.name]&&(h.valid=!1,l)||(!l&&(y(ye,v.name)?U?It(t.errors,ye,v.name):F(t.errors,v.name,ye[v.name]):q(t.errors,v.name)),e.shouldUseNativeValidation&&ye[v.name]))break}!G(S)&&await R({context:h,onlyCheckValid:l,fields:S,name:x,eventType:m})}}return h.valid},le=()=>{for(const a of u.unMount){const l=y(i,a);l&&(l._f.refs?l._f.refs.every(c=>!st(c)):!st(l._f.ref))&&Xe(a)}u.unMount=new Set},Z=(a,l)=>(a&&l&&F(d,a,l),!he(n.mount?d:o,o)),ge=(a,l,c)=>yr(a,u,{...n.mount?d:L(l)?o:Q(a)?{[a]:l}:l},c,l),Ae=a=>os(y(n.mount?d:o,a,s.shouldUnregister?y(o,a,[]):[])),De=(a,l,c={},m=!1,h=!1)=>{const x=y(i,a);let g=l;if(x){const v=x._f;v&&(!v.disabled&&F(d,a,hs(l,v)),g=Ke(v.ref)&&Y(l)?"":l,ds(v.ref)?[...v.ref.options].forEach(S=>S.selected=g.includes(S.value)):v.refs?Le(v.ref)?v.refs.forEach(S=>{(!S.defaultChecked||!S.disabled)&&(Array.isArray(g)?S.checked=!!g.find(U=>U===S.value):S.checked=g===S.value||!!g)}):v.refs.forEach(S=>S.checked=S.value===g):ht(v.ref)?v.ref.value="":(v.ref.value=g,!v.ref.type&&!h&&b.state.next({name:a,values:m?d:B(d)})))}(c.shouldDirty||c.shouldTouch)&&P(a,g,c.shouldTouch,c.shouldDirty,!h),c.shouldValidate&&fe(a,{delayError:c.delayError})},He=(a,l,c,m=!1,h=!1)=>{for(const x in l){if(!l.hasOwnProperty(x))return;const g=l[x],v=a+"."+x,S=y(i,v);(u.array.has(a)||z(g)||S&&!S._f)&&!je(g)?He(v,g,c,m,h):De(v,g,c,m,h)}},Ze=(a,l,c,m,h=!1)=>{const x=y(i,a),g=u.array.has(a),v=m?l:B(l),S=y(d,a),U=he(S,v);if(U||F(d,a,v),g)b.array.next({name:a,values:m?d:B(d)}),(A.isDirty||A.dirtyFields||f.isDirty||f.dirtyFields)&&c.shouldDirty&&(ne(),h||b.state.next({name:a,dirtyFields:t.dirtyFields,isDirty:Z(a,v)}));else{const X=Array.isArray(v)&&!v.length||G(v);!x||x._f||Y(v)||X?De(a,v,c,m,h):He(a,v,c,m,h)}if(!U&&!h){const X=tt(a,u),xe=m?d:B(d);b.state.next({...X&&t,name:n.mount||X?a:void 0,values:xe})}},p=(a,l,c={})=>Ze(a,l,c,!1),V=(a,l={})=>{const c=ie(a)?a(d):a;if(!he(d,c)){d={...d,...c};const m=ls(c);for(const h of u.mount)h in m&&Ze(h,m[h],l,!0,!0);b.state.next({...t,name:void 0,type:void 0,...E?{values:d}:{}}),l.shouldValidate&&I()}},ce=async a=>{n.mount=!0;const l=a.target;let c=l.name,m=!0;const h=y(i,c),x=g=>{m=Number.isNaN(g)||je(g)&&isNaN(g.getTime())||he(g,y(d,c,g))};if(h){let g,v;const S=l.type?Bt(h._f):ur(a),U=a.type===Ee.BLUR||a.type===Ee.FOCUS_OUT,X=!Ar(h._f)&&!e.validate&&!s.resolver&&!y(t.errors,c)&&!h._f.deps,xe=X||Pr(U,y(t.touchedFields,c),t.isSubmitted,M,H),ye=tt(c,u,U);if(F(d,c,S),U){if(!l||!l.readOnly){h._f.onBlur&&h._f.onBlur(a);const Oe=j[c];Oe&&Oe(0)}}else h._f.onChange&&h._f.onChange(a);const Fe=P(c,S,U),Es=!G(Fe)||ye;if(!U&&b.state.next({name:c,type:a.type,...E?{values:B(d)}:{}}),xe)return(!X||!t.isValid)&&(A.isValid||f.isValid)&&(s.mode==="onBlur"?U&&I():U||I()),Es&&b.state.next({name:c,...ye?{}:Fe});if(!s.resolver&&e.validate&&await w({name:c,eventType:a.type}),!U&&ye&&b.state.next({...t}),s.resolver){const{errors:Oe}=await D([c]);if(T([c]),x(S),!m){!G(Fe)&&b.state.next(Fe);return}const Ps=$t(t.errors,i,c),wt=$t(Oe,i,Ps.name||c);g=wt.error,c=wt.name,v=G(Oe)}else T([c],!0),g=(await Ht(h,u.disabled,d,N,s.shouldUseNativeValidation))[c],T([c]),x(S),m&&(g?v=!1:(A.isValid||f.isValid)&&(v=await R({fields:i,onlyCheckValid:!0,name:c,eventType:a.type})));m&&(h._f.deps&&(!Array.isArray(h._f.deps)||h._f.deps.length>0)&&fe(h._f.deps),k(c,v,g,Fe))}},se=(a,l)=>{if(y(t.errors,l)&&a.focus)return a.focus(),1},fe=async(a,l={})=>{let c,m;const h=We(a);if(s.resolver){const x=await $(L(a)?a:h);c=G(x),m=a?!h.some(g=>y(x,g)):c}else a?(m=(await Promise.all(h.map(async x=>{const g=y(i,x);return await R({fields:g&&g._f?{[x]:g}:g,eventType:Ee.TRIGGER})}))).every(Boolean),!(!m&&!t.isValid)&&I()):m=c=await R({fields:i,name:a,eventType:Ee.TRIGGER});if(l.delayError&&s.delayError&&Q(a)){const x=y(t.errors,a);x?(q(t.errors,a),j[a]=W(a,()=>pe(a,x)),j[a](s.delayError)):(clearTimeout(_[a]),delete j[a])}return b.state.next({...!Q(a)||(A.isValid||f.isValid)&&c!==t.isValid?{}:{name:a},...s.resolver||!a?{isValid:c}:{},errors:t.errors}),l.shouldFocus&&!m&&Me(i,se,a?h:u.mount),m},we=(a,l)=>{let c={...n.mount?d:o};return l&&(c=cs(l.dirtyFields?t.dirtyFields:t.touchedFields,c)),L(a)?c:Q(a)?y(c,a):a.map(m=>y(c,m))},Ce=(a,l)=>({invalid:!!y((l||t).errors,a),isDirty:!!y((l||t).dirtyFields,a),error:y((l||t).errors,a),isValidating:!!y(t.validatingFields,a),isTouched:!!y((l||t).touchedFields,a)}),_e=a=>{const l=a?We(a):void 0;l?.forEach(c=>q(t.errors,c)),l?l.forEach(c=>{b.state.next({name:c,errors:t.errors})}):b.state.next({errors:{}})},ze=(a,l,c)=>{const m=(y(i,a,{_f:{}})._f||{}).ref,h=y(t.errors,a)||{},{ref:x,message:g,type:v,...S}=h;F(t.errors,a,{...S,...l,ref:m}),b.state.next({name:a,errors:t.errors,isValid:!1}),c&&c.shouldFocus&&m&&m.focus&&m.focus()},Ss=(a,l)=>{if(ie(a)){E++;const{unsubscribe:c}=b.state.subscribe({next:h=>"values"in h&&a(h.values||ge(void 0,l),h)});let m=!1;return{unsubscribe:()=>{m||(m=!0,E--,c())}}}return ge(a,l,!0)},xt=a=>{var l;const c=!!(!((l=a.formState)===null||l===void 0)&&l.values);c&&E++;const{unsubscribe:m}=b.state.subscribe({next:x=>{if(Er(a.name,x.name,a.exact)&&_r(x,a.formState||A,_s,a.reRenderRoot)){const g={...d};a.callback({values:g,...t,...x,defaultValues:o})}}});if(!c)return m;let h=!1;return()=>{h||(h=!0,E--,m())}},ws=a=>(n.mount=!0,f={...f,...a.formState},xt({...a,formState:{...O,...a.formState}})),Xe=(a,l={})=>{for(const c of a?We(a):u.mount)u.mount.delete(c),u.array.delete(c),l.keepValue||(q(i,c),q(d,c)),!l.keepError&&q(t.errors,c),!l.keepDirty&&q(t.dirtyFields,c),!l.keepTouched&&q(t.touchedFields,c),!l.keepIsValidating&&q(t.validatingFields,c),!s.shouldUnregister&&!l.keepDefaultValue&&q(o,c);b.state.next({values:B(d)}),b.state.next({...t,...l.keepDirty?{isDirty:Z()}:{}}),!l.keepIsValid&&I()},yt=({disabled:a,name:l})=>{if(me(a)&&n.mount||a||u.disabled.has(l)){const h=u.disabled.has(l)!==!!a;a?u.disabled.add(l):u.disabled.delete(l),h&&n.mount&&!n.action&&I()}},Je=(a,l={})=>{let c=y(i,a);const m=me(l.disabled)||me(s.disabled),h=!u.registerName.has(a)&&c&&c._f&&!c._f.mount;return F(i,a,{...c||{},_f:{...c&&c._f?c._f:{ref:{name:a}},name:a,mount:!0,...l}}),u.mount.add(a),c&&!h?yt({disabled:me(l.disabled)?l.disabled:s.disabled,name:a}):te(a,!0,l.value),{...m?{disabled:l.disabled||s.disabled}:{},...s.progressive?{required:!!l.required,min:Re(l.min),max:Re(l.max),minLength:Re(l.minLength),maxLength:Re(l.maxLength),pattern:Re(l.pattern)}:{},name:a,onChange:ce,onBlur:ce,ref:x=>{if(x){u.registerName.add(a),Je(a,l),u.registerName.delete(a),c=y(i,a);const g=L(x.value)&&x.querySelectorAll&&x.querySelectorAll("input,select,textarea")[0]||x,v=Sr(g),S=c._f.refs||[];if(v?S.find(U=>U===g):g===c._f.ref)return;F(i,a,{_f:{...c._f,...v?{refs:[...S.filter(st),g,...Array.isArray(y(o,a))?[{}]:[]],ref:{type:g.type,name:a}}:{ref:g}}}),te(a,!1,void 0,g)}else c=y(i,a,{}),c._f&&(c._f.mount=!1),(s.shouldUnregister||l.shouldUnregister)&&!(fr(u.array,a)&&n.action)&&u.unMount.add(a)}}},et=()=>s.shouldFocusError&&!s.shouldUseNativeValidation&&Me(i,se,u.mount),Ns=a=>{me(a)&&(b.state.next({disabled:a}),Me(i,(l,c)=>{const m=y(i,c);m&&(l.disabled=m._f.disabled||a,Array.isArray(m._f.refs)&&m._f.refs.forEach(h=>{h.disabled=m._f.disabled||a}))},0,!1))},vt=(a,l)=>async c=>{let m;c&&(c.preventDefault&&c.preventDefault(),c.persist&&c.persist());let h=B(d);if(b.state.next({isSubmitting:!0}),s.resolver){const{errors:x,values:g}=await D();T(),t.errors=x,h=B(g)}else await R({fields:i,eventType:Ee.SUBMIT});if(u.disabled.size)for(const x of u.disabled)q(h,x);if(q(t.errors,as),G(t.errors)){b.state.next({errors:{}});try{await a(h,c)}catch(x){m=x}}else l&&await l({...t.errors},c),et(),setTimeout(et);if(b.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:G(t.errors)&&!m,submitCount:t.submitCount+1,errors:t.errors}),m)throw m},Ts=(a,l={})=>{y(i,a)&&(L(l.defaultValue)?p(a,B(y(o,a))):(p(a,l.defaultValue),F(o,a,B(l.defaultValue))),l.keepTouched||q(t.touchedFields,a),l.keepDirty||(q(t.dirtyFields,a),t.isDirty=l.defaultValue?Z(a,B(y(o,a))):Z()),l.keepError||(q(t.errors,a),A.isValid&&I()),b.state.next({...t}))},bt=(a,l={})=>{const c=a?B(a):o,m=B(c),h=G(a),x=m,g=i;if(l.keepDefaultValues||(o=c),!l.keepValues){if(l.keepDirtyValues){const v=new Set([...u.mount,...Object.keys(Ne(o,d,void 0,g))]);for(const S of Array.from(v)){const U=y(t.dirtyFields,S),X=y(d,S),xe=y(x,S);U&&!L(X)?F(x,S,X):!U&&!L(xe)&&p(S,xe)}}else{if(Ye&&L(a))for(const v of u.mount){const S=y(i,v);if(S&&S._f){const U=Array.isArray(S._f.refs)?S._f.refs[0]:S._f.ref;if(Ke(U)){const X=U.closest("form");if(X){X.reset();break}}}}if(l.keepFieldsRef)for(const v of u.mount)p(v,y(x,v));else i={}}if(s.shouldUnregister){if(d=l.keepDefaultValues?B(o):{},l.keepFieldsRef)for(const v of u.mount)F(d,v,y(x,v))}else d=B(x);b.array.next({values:{...x}}),b.state.next({name:void 0,type:void 0,values:{...x}})}u={mount:l.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=!A.isValid||!!l.keepIsValid||!!l.keepDirtyValues||!s.shouldUnregister&&!G(x),n.watch=!!s.shouldUnregister,n.keepIsValid=!!l.keepIsValid,n.action=!1,l.keepErrors||(t.errors={}),b.state.next({submitCount:l.keepSubmitCount?t.submitCount:0,isDirty:h?!1:l.keepDirty?t.isDirty:l.keepValues?Z():!!(l.keepDefaultValues&&!he(a,o)),isSubmitted:l.keepIsSubmitted?t.isSubmitted:!1,dirtyFields:h?{}:l.keepDirtyValues?l.keepDefaultValues&&d?Ne(o,d,void 0,g):t.dirtyFields:l.keepDefaultValues&&a?Ne(o,a,void 0,g):l.keepDirty?t.dirtyFields:{},touchedFields:l.keepTouched?t.touchedFields:{},errors:l.keepErrors?t.errors:{},isSubmitSuccessful:l.keepIsSubmitSuccessful?t.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:o})},jt=(a,l)=>bt(ie(a)?a(d):a,{...s.resetOptions,...l}),As=(a,l={})=>{const c=y(i,a),m=c&&c._f;if(m){const h=m.refs?m.refs[0]:m.ref;h.focus&&setTimeout(()=>{h.focus(),l.shouldSelect&&ie(h.select)&&h.select()})}},_s=a=>{const{name:l,type:c,values:m,...h}=a;t={...t,...h}},St={control:{register:Je,unregister:Xe,getFieldState:Ce,handleSubmit:vt,setError:ze,_subscribe:xt,_runSchema:D,_updateIsValidating:T,_focusError:et,_getWatch:ge,_getDirty:Z,_setValid:I,_setFieldArray:re,_setDisabledField:yt,_setErrors:oe,_getFieldArray:Ae,_reset:bt,_resetDefaultValues:()=>ie(s.defaultValues)&&s.defaultValues().then(a=>{jt(a,s.resetOptions),b.state.next({isLoading:!1})}),_removeUnmounted:le,_disableForm:Ns,_subjects:b,_proxyFormState:A,get _fields(){return i},get _formValues(){return d},get _state(){return n},set _state(a){n=a},get _defaultValues(){return o},get _names(){return u},set _names(a){u=a},get _formState(){return t},get _options(){return s},set _options(a){s={...s,...a},H=qe(s.mode),M=qe(s.reValidateMode)}},subscribe:ws,trigger:fe,register:Je,handleSubmit:vt,watch:Ss,setValue:p,setValues:V,getValues:we,reset:jt,resetField:Ts,resetDefaultValues:(a,l={})=>{if(o=B(a),!l.keepDirty){const c=Ne(o,d,void 0,i);t.dirtyFields=c,t.isDirty=!G(c)}l.keepIsValid||I(),b.state.next({...t,defaultValues:o})},clearErrors:_e,unregister:Xe,setError:ze,setFocus:As,getFieldState:Ce};return{...St,formControl:St}}function Cr(e={}){const s=J.useRef(void 0),t=J.useRef(void 0),i=J.useRef(e.formControl),[o,d]=J.useState(()=>({...B(ps),isLoading:ie(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1,defaultValues:ie(e.defaultValues)?void 0:e.defaultValues}));if(!s.current||e.formControl&&i.current!==e.formControl)if(i.current=e.formControl,e.formControl)s.current={...e.formControl,formState:o},e.defaultValues&&!ie(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:u,...j}=Dr(e);s.current={...j,formState:o}}const n=s.current.control;return n._options=e,xr(()=>{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]),J.useEffect(()=>n._disableForm(e.disabled),[n,e.disabled]),J.useEffect(()=>{e.mode&&(n._options.mode=e.mode),e.reValidateMode&&(n._options.reValidateMode=e.reValidateMode)},[n,e.mode,e.reValidateMode]),J.useEffect(()=>{e.errors&&(n._setErrors(e.errors),n._focusError())},[n,e.errors]),J.useEffect(()=>{e.shouldUnregister&&n._subjects.state.next({values:n._getWatch()})},[n,e.shouldUnregister]),J.useEffect(()=>{if(n._proxyFormState.isDirty){const u=n._getDirty();u!==o.isDirty&&n._subjects.state.next({isDirty:u})}},[n,o.isDirty]),J.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]),J.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=J.useMemo(()=>gr(o,n),[n,o]),s.current}const Wt=(e,s,t)=>{if(e&&"reportValidity"in e){const i=y(t,s);e.setCustomValidity(i&&i.message||""),e.reportValidity()}},lt=(e,s)=>{for(const t in s.fields){const i=s.fields[t];i&&i.ref&&"reportValidity"in i.ref?Wt(i.ref,t,e):i&&i.refs&&i.refs.forEach(o=>Wt(o,t,e))}},Kt=(e,s)=>{s.shouldUseNativeValidation&<(e,s);const t={};for(const i in e){const o=y(s.fields,i),d=Object.assign(e[i]||{},{ref:o&&o.ref});if(Fr(s.names||Object.keys(e),i)){const n=Object.assign({},y(t,i));F(n,"root",d),F(t,i,n)}else F(t,i,d)}return t},Fr=(e,s)=>{const t=Gt(s).replace(/[.*+?^${}()|\\]/g,"\\$&");return e.some(i=>Gt(i).match(`^${t}\\.\\d+`))};function Gt(e){return e.replace(/[\[\]]/g,"")}function gs(e,s,t){function i(u,j){var _;Object.defineProperty(u,"_zod",{value:u._zod??{},enumerable:!1}),(_=u._zod).traits??(_.traits=new Set),u._zod.traits.add(e),s(u,j);for(const E in n.prototype)E in u||Object.defineProperty(u,E,{value:n.prototype[E].bind(u)});u._zod.constr=n,u._zod.def=j}const o=t?.Parent??Object;class d extends o{}Object.defineProperty(d,"name",{value:e});function n(u){var j;const _=t?.Parent?new d:this;i(_,u),(j=_._zod).deferred??(j.deferred=[]);for(const E of _._zod.deferred)E();return _}return Object.defineProperty(n,"init",{value:i}),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 Or extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const Ir={};function xs(e){return Ir}function Rr(e,s){return typeof s=="bigint"?s.toString():s}const ys=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function $e(e){return typeof e=="string"?e:e?.message}function vs(e,s,t){const i={...e,path:e.path??[]};if(!e.message){const o=$e(e.inst?._zod.def?.error?.(e))??$e(s?.error?.(e))??$e(t.customError?.(e))??$e(t.localeError?.(e))??"Invalid input";i.message=o}return delete i.inst,delete i.continue,s?.reportInput||delete i.input,i}const bs=(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,Rr,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Mr=gs("$ZodError",bs),js=gs("$ZodError",bs,{Parent:Error}),Lr=e=>(s,t,i,o)=>{const d=i?Object.assign(i,{async:!1}):{async:!1},n=s._zod.run({value:t,issues:[]},d);if(n instanceof Promise)throw new Or;if(n.issues.length){const u=new(o?.Err??e)(n.issues.map(j=>vs(j,d,xs())));throw ys(u,o?.callee),u}return n.value},Ur=Lr(js),Hr=e=>async(s,t,i,o)=>{const d=i?Object.assign(i,{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(o?.Err??e)(n.issues.map(j=>vs(j,d,xs())));throw ys(u,o?.callee),u}return n.value},zr=Hr(js);function ct(){return ct=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var t=arguments[s];for(var i in t)({}).hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},ct.apply(null,arguments)}function Yt(e,s){try{var t=e()}catch(i){return s(i)}return t&&t.then?t.then(void 0,s):t}function Br(e,s){for(var t={};e.length;){var i=e[0],o=i.code,d=i.message,n=i.path.join(".");if(!t[n])if("unionErrors"in i){var u=i.unionErrors[0].errors[0];t[n]={message:u.message,type:u.code}}else t[n]={message:d,type:o};if("unionErrors"in i&&i.unionErrors.forEach(function(E){return E.errors.forEach(function(H){return e.push(H)})}),s){var j=t[n].types,_=j&&j[i.code];t[n]=gt(n,s,t,o,_?[].concat(_,i.message):i.message)}e.shift()}return t}function qr(e,s){for(var t={},i=function(){var o=e[0],d=o.code,n=o.message,u=o.path.join(".");if(!t[u])if(o.code==="invalid_union"&&o.errors.length>0){var j=o.errors[0][0];t[u]={message:j.message,type:j.code}}else t[u]={message:n,type:d};if(o.code==="invalid_union"&&o.errors.forEach(function(H){return H.forEach(function(M){return e.push(ct({},M,{path:[].concat(o.path,M.path)}))})}),s){var _=t[u].types,E=_&&_[o.code];t[u]=gt(u,s,t,d,E?[].concat(E,o.message):o.message)}e.shift()};e.length;)i();return t}function $r(e,s,t){if(t===void 0&&(t={}),(function(i){return"_def"in i&&typeof i._def=="object"&&"typeName"in i._def})(e))return function(i,o,d){try{return Promise.resolve(Yt(function(){return Promise.resolve(e[t.mode==="sync"?"parse":"parseAsync"](i,s)).then(function(n){return d.shouldUseNativeValidation&<({},d),{errors:{},values:t.raw?Object.assign({},i):n}})},function(n){if((function(u){return Array.isArray(u?.issues)})(n))return{values:{},errors:Kt(Br(n.errors,!d.shouldUseNativeValidation&&d.criteriaMode==="all"),d)};throw n}))}catch(n){return Promise.reject(n)}};if((function(i){return"_zod"in i&&typeof i._zod=="object"})(e))return function(i,o,d){try{return Promise.resolve(Yt(function(){return Promise.resolve((t.mode==="sync"?Ur:zr)(e,i,s)).then(function(n){return d.shouldUseNativeValidation&<({},d),{errors:{},values:t.raw?Object.assign({},i):n}})},function(n){if((function(u){return u instanceof Mr})(n))return{values:{},errors:Kt(qr(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 Wr=e=>{const s=ut(),{pushError:t}=Cs(),{data:i}=Jt({...es(),staleTime:1/0}),o=i?.accounts.find(j=>j.accountId===e)?.composeLanguages,d=C.useMemo(()=>o&&o.length>0?[...o]:Fs(navigator.languages),[o]),n=Se({...ts(),onSuccess:()=>{s.invalidateQueries({queryKey:Te()})},onError:j=>{t(Os("Couldn't save languages","The writing languages weren't saved.",j))}}),u=C.useCallback(j=>{e&&n.mutate({path:{accountId:e},body:{composeLanguages:j}})},[e,n]);return{languages:d,setLanguages:u,isSaving:n.isPending}},Kr=e=>e.authType==="oauthMicrosoft",Gr="••••••••••",Yr=e=>{const s=e.smtpUsername?.trim();return s?s!==e.username:!1},Qr=Ls({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:Et.number().int().min(1).max(65535),imapTls:Ie(),imapStartTls:Ie(),smtpHost:be().optional(),smtpPort:Et.number().int().min(1).max(65535).optional(),smtpTls:Ie().optional(),smtpStartTls:Ie().optional(),smtpUsername:be().optional(),smtpPassword:be().optional(),useDifferentSmtpCreds:Ie().optional()}),Zr=({isOpen:e,onClose:s,account:t,focusSmtp:i})=>{const o=ut(),d=!!t,[n,u]=C.useState(!1),[j,_]=C.useState(""),[E,H]=C.useState(!1),M=Dt(j),O=!!M&&!E,A=C.useRef(null),f=Cr({resolver:$r(Qr),defaultValues:{email:"",displayName:"",username:"",password:"",imapHost:"",imapPort:993,imapTls:!0,imapStartTls:!1,smtpHost:"",smtpPort:587,smtpTls:!1,smtpStartTls:!0,useDifferentSmtpCreds:!1}});C.useEffect(()=>{if(t){const p=Yr(t);f.reset({email:t.email,displayName:t.displayName||"",username:t.username||"",password:Gr,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=Se({...Is()}),ae=Se({...Rs(),onSuccess:()=>{o.invalidateQueries({queryKey:Te()}),s()}}),N=Se({...ts(),onSuccess:()=>{o.invalidateQueries({queryKey:Te()}),s()}}),W=()=>{const p=f.getValues(),V=d&&!n;b.mutate({body:{accountId:V?t?.accountId:void 0,username:p.username||p.email,password:V?void 0:p.password||void 0,imapHost:p.imapHost,imapPort:Number(p.imapPort),imapTls:p.imapTls,imapStartTls:p.imapStartTls}})},I=()=>{const p=f.getValues(),V=d&&!n;b.mutate({body:{accountId:V?t?.accountId:void 0,username:p.username||p.email,password:V?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}})},T=f.handleSubmit(p=>{if(!d&&!p.password){f.setError("password",{message:"Password is required"});return}const V=rr({imapHost:p.imapHost,smtpHost:p.smtpHost,smtpPort:p.smtpPort,smtpTls:p.smtpTls,smtpStartTls:p.smtpStartTls});V&&(f.setValue("smtpHost",V.smtpHost),f.setValue("smtpPort",V.smtpPort),f.setValue("smtpTls",V.smtpTls),f.setValue("smtpStartTls",V.smtpStartTls));const ce=V?.smtpHost??p.smtpHost,se=V?.smtpPort??p.smtpPort,fe=V?.smtpTls??p.smtpTls,we=V?.smtpStartTls??p.smtpStartTls,Ce={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:se?Number(se):void 0,smtpTls:fe,smtpStartTls:we,smtpUsername:p.useDifferentSmtpCreds&&p.smtpUsername||void 0,smtpPassword:p.useDifferentSmtpCreds&&p.smtpPassword||void 0};if(d&&t){const _e={...Ce,password:n?p.password:void 0};N.mutate({path:{accountId:t.accountId},body:_e})}else{const _e={...Ce,password:p.password};ae.mutate({body:_e})}}),ne=ae.isPending||N.isPending,{signature:re,setSignature:pe,isSaving:oe}=Qs(t?.accountId),[K,te]=C.useState(re.plainText),{languages:P,setLanguages:k,isSaving:D}=Wr(t?.accountId),$=r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Writing languages"}),r.jsx(cr,{value:P,onChange:k,busy:D})]});C.useEffect(()=>{te(re.plainText)},[re.plainText]),C.useEffect(()=>{if(!e||!i)return;const p=A.current;if(!p)return;const V=window.setTimeout(()=>{p.scrollIntoView({behavior:"smooth",block:"start"})},250);return()=>window.clearTimeout(V)},[e,i]);const w=C.useCallback(()=>{K!==re.plainText&&pe(K,K)},[K,re.plainText,pe]),R=p=>{const{tls:V,startTls:ce}=Be(p);f.setValue("imapTls",V),f.setValue("imapStartTls",ce);const se=f.getValues("imapPort");(se===993||se===143)&&f.setValue("imapPort",p==="tls"?993:143)},le=p=>{const{tls:V,startTls:ce}=Be(p);f.setValue("smtpTls",V),f.setValue("smtpStartTls",ce);const se=f.getValues("smtpPort");if(se===465||se===587||se===25){const we=p==="tls"?465:p==="starttls"?587:25;f.setValue("smtpPort",we)}},Z=()=>{const p=f.getValues("imapHost");f.setValue("smtpHost",ar(p)),f.setValue("smtpTls",!1),f.setValue("smtpStartTls",!0),f.setValue("smtpPort",587)},ge=p=>{_(p),H(!1);const V=Dt(p);if(!V)return;const ce=Be(V.imap.security);f.setValue("imapHost",V.imap.host),f.setValue("imapPort",V.imap.port),f.setValue("imapTls",ce.tls),f.setValue("imapStartTls",ce.startTls);const se=Be(V.smtp.security);f.setValue("smtpHost",V.smtp.host),f.setValue("smtpPort",V.smtp.port),f.setValue("smtpTls",se.tls),f.setValue("smtpStartTls",se.startTls);const fe=f.getValues("email").trim(),we=f.getValues("username")?.trim();fe&&!we&&f.setValue("username",fe)},Ae=M?.passwordHelp.text,De=Ct(b.data?.imapError,Ae),He=Ct(b.data?.smtpError,Ae);return(t?Kr(t):!1)&&d?r.jsx(Ft,{isOpen:e,onClose:s,title:"Edit Account",footer:r.jsx(ee,{type:"button",variant:"secondary",onClick:s,children:"Close"}),children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Microsoft 365 Account"}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"rounded-md border border-line bg-surface-sunken px-3 py-2.5 text-sm text-fg-muted",children:[r.jsx("span",{className:"block text-2xs font-medium uppercase tracking-wider text-fg-subtle mb-1",children:"Email"}),r.jsx("span",{className:"text-fg",children:t?.email})]}),r.jsxs("div",{className:"rounded-md border border-line bg-surface-sunken px-3 py-2.5 text-sm text-fg-muted",children:[r.jsx("span",{className:"block text-2xs font-medium uppercase tracking-wider text-fg-subtle mb-1",children:"Authentication"}),r.jsx("span",{className:"text-fg",children:"Microsoft OAuth (XOAUTH2)"})]}),r.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&&r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Signature"}),r.jsx("div",{className:"space-y-3",children:r.jsxs("div",{children:[r.jsx("label",{htmlFor:"email-sig-view",className:"text-sm font-medium mb-1.5 block",children:"Email Signature"}),r.jsx("textarea",{id:"email-sig-view",value:K,onChange:p=>te(p.target.value),onBlur:w,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..."}),r.jsx("p",{className:"text-xs text-fg-muted mt-1",children:oe?"Saving signature...":"This signature will be appended to new emails."})]})})]}),d&&$]})}):r.jsx(Ft,{isOpen:e,onClose:s,title:d?"Edit Account":"Add Account",footer:r.jsxs(r.Fragment,{children:[r.jsx(ee,{type:"button",variant:"secondary",onClick:s,children:"Cancel"}),r.jsx(ee,{type:"submit",form:"account-form",variant:"primary",disabled:ne,children:ne?"Saving...":"Save Account"})]}),children:r.jsxs("form",{id:"account-form",onSubmit:T,className:"space-y-6",children:[r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Account Information"}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-provider",className:"text-sm font-medium mb-1.5 block",children:"Provider"}),r.jsxs(Ms,{id:"account-provider",value:j,onChange:p=>ge(p.target.value),children:[r.jsx("option",{value:"",children:"Custom / other"}),er.map(p=>r.jsx("option",{value:p.id,children:p.label},p.id))]}),r.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."})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-email",className:"text-sm font-medium mb-1.5 block",children:"Email Address"}),r.jsx(ve,{id:"account-email",...f.register("email"),placeholder:"alice@example.com"}),f.formState.errors.email&&r.jsx("p",{className:"text-sm text-danger mt-1",children:f.formState.errors.email.message})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-displayName",className:"text-sm font-medium mb-1.5 block",children:"Display name (optional)"}),r.jsx(ve,{id:"account-displayName",...f.register("displayName"),placeholder:"Alice"}),r.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."})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-username",className:"text-sm font-medium mb-1.5 block",children:"Username"}),r.jsx(ve,{id:"account-username",...f.register("username"),placeholder:"Same as email if empty"})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-password",className:"text-sm font-medium mb-1.5 block",children:"Password"}),r.jsx(Tt,{id:"account-password",...f.register("password",{onChange:()=>u(!0)}),onFocus:()=>{d&&!n&&(f.setValue("password",""),u(!0))},placeholder:d?"Leave empty to keep current":""}),f.formState.errors.password&&r.jsx("p",{className:"text-sm text-danger mt-1",children:f.formState.errors.password.message}),M&&r.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[M.passwordHelp.text," ",r.jsx("a",{href:M.passwordHelp.url,target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline",children:"Get an app password"})]})]})]})]}),r.jsxs("section",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider",children:"Incoming Mail (IMAP)"}),M&&r.jsx("button",{type:"button",onClick:()=>H(p=>!p),className:"text-xs text-fg-muted hover:text-fg transition-colors",children:E?"Use preset settings":"Advanced"})]}),O&&r.jsxs("p",{className:"text-xs text-fg-muted mb-3",children:["Server settings are pre-filled for ",M?.label," and locked. Choose Advanced to edit them by hand."]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"imap-host",className:"text-sm font-medium mb-1.5 block",children:"Server"}),r.jsx(ve,{id:"imap-host",...f.register("imapHost"),readOnly:O,placeholder:"imap.example.com"}),f.formState.errors.imapHost&&r.jsx("p",{className:"text-sm text-danger mt-1",children:f.formState.errors.imapHost.message})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"imap-port",className:"text-sm font-medium mb-1.5 block",children:"Port"}),r.jsx(ve,{id:"imap-port",...f.register("imapPort"),readOnly:O,type:"number"})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-sm font-medium mb-1.5 block",children:"Security"}),r.jsxs("div",{className:"space-y-1.5 mt-2",children:[r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:O,checked:f.watch("imapTls"),onChange:()=>R("tls")}),"TLS (Port 993)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:O,checked:!f.watch("imapTls")&&f.watch("imapStartTls"),onChange:()=>R("starttls")}),"STARTTLS (Port 143)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:O,checked:!f.watch("imapTls")&&!f.watch("imapStartTls"),onChange:()=>R("none")}),"None (Unencrypted)"]})]})]})]}),r.jsx(ee,{type:"button",variant:"secondary",onClick:W,disabled:b.isPending,className:"w-full",icon:b.isPending?r.jsx(at,{className:"size-4 animate-spin"}):void 0,children:b.isPending?"Testing...":"Test IMAP Connection"}),b.data&&r.jsxs("div",{className:_t("p-2 rounded-md text-sm",b.data.imapSuccess?"bg-positive/10 text-positive":"bg-danger-soft text-danger"),children:[b.data.imapSuccess?r.jsx(At,{className:"inline size-4 mr-1"}):r.jsx(Ve,{className:"inline size-4 mr-1"}),b.data.imapSuccess?"IMAP Connected":De]})]})]}),r.jsxs("section",{ref:A,"data-testid":"smtp-section",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider",children:"Outgoing Mail (SMTP)"}),!O&&r.jsx("button",{type:"button",onClick:Z,disabled:!f.watch("imapHost"),className:"text-xs text-fg-muted hover:text-fg transition-colors disabled:opacity-50",children:"Pre-fill from IMAP"})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"smtp-host",className:"text-sm font-medium mb-1.5 block",children:"Server"}),r.jsx(ve,{id:"smtp-host",...f.register("smtpHost"),readOnly:O,placeholder:"smtp.example.com"})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"smtp-port",className:"text-sm font-medium mb-1.5 block",children:"Port"}),r.jsx(ve,{id:"smtp-port",...f.register("smtpPort"),readOnly:O,type:"number"})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-sm font-medium mb-1.5 block",children:"Security"}),r.jsxs("div",{className:"space-y-1.5 mt-2",children:[r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:O,checked:f.watch("smtpTls")===!0,onChange:()=>le("tls")}),"TLS (Port 465)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:O,checked:!f.watch("smtpTls")&&f.watch("smtpStartTls")===!0,onChange:()=>le("starttls")}),"STARTTLS (Port 587)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:O,checked:!f.watch("smtpTls")&&!f.watch("smtpStartTls"),onChange:()=>le("none")}),"None (Unencrypted)"]})]})]})]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"checkbox",...f.register("useDifferentSmtpCreds")}),"Use different credentials for SMTP"]}),f.watch("useDifferentSmtpCreds")&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"smtp-username",className:"text-sm font-medium mb-1.5 block",children:"SMTP Username"}),r.jsx(ve,{id:"smtp-username",...f.register("smtpUsername")})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"smtp-password",className:"text-sm font-medium mb-1.5 block",children:"SMTP Password"}),r.jsx(Tt,{id:"smtp-password",...f.register("smtpPassword")})]})]}),r.jsx(ee,{type:"button",variant:"secondary",onClick:I,disabled:b.isPending||!f.watch("smtpHost"),className:"w-full",icon:b.isPending?r.jsx(at,{className:"size-4 animate-spin"}):void 0,children:b.isPending?"Testing...":"Test SMTP Connection"}),b.data?.smtpSuccess!==void 0&&r.jsxs("div",{className:_t("p-2 rounded-md text-sm",b.data.smtpSuccess?"bg-positive/10 text-positive":"bg-danger-soft text-danger"),children:[b.data.smtpSuccess?r.jsx(At,{className:"inline size-4 mr-1"}):r.jsx(Ve,{className:"inline size-4 mr-1"}),b.data.smtpSuccess?"SMTP Connected":He]})]})]}),d&&r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Signature"}),r.jsx("div",{className:"space-y-3",children:r.jsxs("div",{children:[r.jsx("label",{htmlFor:"email-sig-edit",className:"text-sm font-medium mb-1.5 block",children:"Email Signature"}),r.jsx("textarea",{id:"email-sig-edit",value:K,onChange:p=>te(p.target.value),onBlur:w,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..."}),r.jsx("p",{className:"text-xs text-fg-muted mt-1",children:oe?"Saving signature...":"This signature will be appended to new emails."})]})})]}),d&&$]})})};function Qt({open:e,onClose:s,accountEmail:t,signOut:i}){const[o,d]=C.useState(""),[n,u]=C.useState(!1),[j,_]=C.useState(!1),E=Se({...Hs(),onSuccess:()=>{_(!0),setTimeout(()=>i(),2e3)}}),H=Se(zs()),M=()=>{E.isPending||(d(""),u(!1),_(!1),E.reset(),H.reset(),s())},O=()=>{if(o.trim().toLowerCase()!==t.toLowerCase()){u(!0);return}u(!1),E.mutate({body:{confirmEmail:o.trim()}})};return r.jsxs(ss,{open:e,onClose:M,title:"Delete your Remit account",children:[r.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[r.jsx(dt,{className:"size-4 shrink-0 text-danger"}),r.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:"Delete your Remit account"}),r.jsx(ee,{variant:"ghost",size:"sm",icon:r.jsx(Ve,{className:"size-3.5"}),onClick:M,"aria-label":"Cancel"})]}),j?r.jsxs("div",{className:"px-5 py-6 text-sm text-fg-muted",children:[r.jsx("p",{className:"font-medium text-fg",children:"Account deletion scheduled."}),r.jsx("p",{className:"mt-1",children:"Your data will be erased shortly. Signing you out…"})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"space-y-4 px-5 py-4 text-sm text-fg-muted",children:[r.jsx("p",{children:"This permanently erases everything Remit holds for you:"}),r.jsxs("ul",{className:"space-y-1.5 text-xs",children:[r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"text-danger",children:"•"}),"All connected accounts disconnected and access tokens revoked."]}),r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"text-danger",children:"•"}),"Synced mail cache and search index."]}),r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"text-danger",children:"•"}),"AI history and insights."]}),r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"text-danger",children:"•"}),"Preferences and rules."]})]}),r.jsxs("div",{className:"rounded-sm border border-line bg-surface-sunken px-3 py-2 text-xs",children:[r.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."]}),r.jsxs("div",{className:"text-xs",children:[r.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:[r.jsx(ir,{className:"size-3.5"}),H.isPending?"Requesting export…":"Export my data first"]}),H.isSuccess&&r.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&&r.jsx("p",{className:"mt-1.5 text-danger",role:"alert",children:"Couldn't start the export. Please try again."})]}),r.jsxs("div",{children:[r.jsxs("label",{htmlFor:"confirm-remit-email",className:"mb-1 block text-xs font-medium text-fg",children:["Type"," ",r.jsx("span",{className:"font-mono text-fg-muted",children:t})," ","to confirm"]}),r.jsx(ve,{id:"confirm-remit-email",type:"email",placeholder:t,value:o,onChange:A=>{d(A.target.value),n&&u(!1),E.isError&&E.reset()},autoComplete:"off"}),n&&r.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."}),E.isError&&r.jsx("p",{className:"mt-1.5 text-xs text-danger",role:"alert",children:E.error instanceof Error?E.error.message:"Something went wrong. Please try again."})]})]}),r.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[r.jsx(ee,{variant:"secondary",size:"sm",onClick:M,children:"Cancel"}),r.jsx(ee,{variant:"danger",size:"sm",onClick:O,"aria-busy":E.isPending,children:E.isPending?"Deleting…":"Delete everything"})]})]})]})}function Xr(e){const{Account:s}=Us();return r.jsx(s,{fallback:r.jsx(Qt,{...e,accountEmail:"",signOut:()=>{}}),children:({email:t,signOut:i})=>r.jsx(Qt,{...e,accountEmail:t??"",signOut:i})})}function Jr(){const[e,s]=C.useState(!1);return r.jsxs("section",{className:"mt-8 border-t border-line pt-6",children:[r.jsx(dr,{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:r.jsx(ee,{variant:"danger",size:"sm",onClick:()=>s(!0),children:"Delete your Remit account"})}),r.jsx(Xr,{open:e,onClose:()=>s(!1)})]})}function ea(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 ta(e){const s=e.split("@")[0]??"";return s?s.split(/[._-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" "):e}function sa(e){const s=e.displayName?.trim();return s||ta(e.email)}function ra(e){if(!e.lastSyncAt)return"never synced";const s=or(e.lastSyncAt);return s?`synced ${s}`:"never synced"}function Zt(e){return e.muted?.value?"muted":e.lastError?"error":e.connectionState==="authenticated"?"healthy":"error"}function Xt(e){return e.connectionState==="reauth_required"}const aa=r.jsxs("div",{className:"space-y-3",children:[r.jsxs("p",{children:[r.jsx("strong",{className:"text-fg",children:"Sync health"})," shows the IMAP connection state and the last successful sync per account."]}),r.jsxs("p",{children:[r.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."]}),r.jsxs("p",{children:[r.jsx("strong",{className:"text-fg",children:"Muted"})," accounts keep syncing but stay out of the daily brief and unified counts."]})]}),ia=()=>r.jsx("div",{className:"space-y-3",role:"status","aria-busy":"true","aria-label":"Loading accounts",children:["skeleton-0","skeleton-1"].map(e=>r.jsx("div",{className:"rounded-sm border border-line bg-surface animate-pulse p-4",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"size-10 rounded-full bg-surface-sunken"}),r.jsxs("div",{className:"flex-1 space-y-2",children:[r.jsx("div",{className:"h-4 bg-surface-sunken rounded w-1/3"}),r.jsx("div",{className:"h-3 bg-surface-sunken rounded w-2/3"})]})]})},e))});function ya(){const e=Pt.useSearch(),s=Bs({from:Pt.fullPath}),[t,i]=C.useState(!0),[o,d]=C.useState(!1),[n,u]=C.useState(!1),[j,_]=C.useState(null),[E,H]=C.useState(!1),[M,O]=C.useState(null),[A,f]=C.useState(null),[b,ae]=C.useState(null),[N,W]=C.useState(null),I=ut(),{data:T,isPending:ne,isError:re,error:pe,refetch:oe}=Jt(es());C.useEffect(()=>{e.editAccountId&&(_(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]),C.useEffect(()=>{e.connected&&(f("Account connected successfully."),_(e.connected),I.invalidateQueries({queryKey:Te()}),s({search:{connected:void 0,oauthError:void 0,editAccountId:void 0,focusSmtp:void 0},replace:!0}))},[e.connected,s,I]),C.useEffect(()=>{e.oauthError&&(ae(ea(e.oauthError)),W(null),s({search:{oauthError:void 0,connected:void 0,editAccountId:void 0,focusSmtp:void 0},replace:!0}))},[e.oauthError,s]),tr(N!==null,()=>{I.invalidateQueries({queryKey:Te()})}),C.useEffect(()=>{if(!N||!T)return;const w=T.accounts.find(R=>R.accountId===N);(!w||!Xt(w))&&W(null)},[T,N]);const K=Se({...qs(),onSuccess:w=>{window.location.assign(w.authorizationUrl)},onError:w=>{ae(w instanceof Error?w.message:"Failed to start reconnect"),W(null)}}),te=Se({...$s(),onSuccess:()=>{I.invalidateQueries({queryKey:Te()}),O(null)}}),P=T?.accounts.find(w=>w.accountId===M),k=T?.accounts.find(w=>w.accountId===j),D=()=>{d(!1),u(!1),_(null),H(!1)},$=w=>{const R=Gs[w];R&&s({to:R})};return r.jsxs(Xs,{items:Ws,activeId:"accounts",title:"Accounts",description:"Every account keeps syncing — muted ones just stay out of unified views.",help:aa,helpOpen:t,onToggleHelp:()=>i(w=>!w),onSelect:$,onBackToMail:()=>{s({to:"/mail"})},children:[A&&r.jsx(kt,{tone:"success",variant:"soft","data-testid":"oauth-success-banner",onDismiss:()=>f(null),children:A}),b&&r.jsx(kt,{tone:"danger",variant:"soft","data-testid":"oauth-error-banner",onDismiss:()=>ae(null),children:b}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Ks,{tone:"neutral",children:ne||re?"accounts":`${T.accounts.length} ${T.accounts.length===1?"account":"accounts"}`}),r.jsx(ee,{variant:"primary",size:"sm",icon:r.jsx(Vt,{className:"size-3.5"}),onClick:()=>u(!0),children:"Add account"})]}),ne?r.jsx(ia,{}):re?r.jsx(nr,{title:"Couldn't load accounts",error:pe,onRetry:()=>{oe()}}):T.accounts.length===0?r.jsxs("div",{className:"py-12 text-sm text-fg-muted","data-testid":"accounts-empty",children:[r.jsx("p",{className:"mb-3",children:"No accounts configured."}),r.jsx(ee,{variant:"primary",size:"sm",icon:r.jsx(Vt,{className:"size-3.5"}),onClick:()=>u(!0),children:"Add your first account"})]}):r.jsx("div",{className:"space-y-3",children:T.accounts.map(w=>{const R=Xt(w),le=w.authType==="oauthMicrosoft",Z=N===w.accountId&&K.isPending,ge=R&&le?{label:"Reconnect",variant:"secondary",busy:Z,busyLabel:"Redirecting…",onClick:()=>{W(w.accountId),K.mutate({body:{email:w.email}})}}:Zt(w)==="error"?{label:"Reconnect",variant:"secondary",onClick:()=>_(w.accountId)}:{label:"Manage",variant:"ghost",onClick:()=>_(w.accountId)},Ae=r.jsx(Zs,{actions:[ge],destructive:{label:"Delete account",iconOnly:!0,icon:r.jsx(Ys,{className:"size-3.5"}),onClick:()=>O(w.accountId)}});return r.jsx(Js,{label:sa(w),email:w.email,connector:le?"Microsoft 365":"IMAP",syncLabel:ra(w),state:Zt(w),errorDetail:R?"Re-authentication required":w.lastError,trailing:Ae},w.accountId)})}),n&&r.jsx("div",{className:"fixed inset-0 z-40 overflow-auto bg-canvas",children:r.jsx(sr,{skipWelcome:!0,onComplete:()=>{u(!1),I.invalidateQueries({queryKey:Te()})},onCancel:()=>u(!1)})}),r.jsx(Zr,{isOpen:o||!!j,account:k,focusSmtp:E,onClose:D}),r.jsxs(ss,{open:!!M,onClose:()=>O(null),title:"Delete account",children:[r.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[r.jsx(dt,{className:"size-4 shrink-0 text-danger"}),r.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:"Delete account"}),r.jsx(ee,{variant:"ghost",size:"sm",icon:r.jsx(Ve,{className:"size-3.5"}),onClick:()=>O(null),"aria-label":"Cancel"})]}),r.jsxs("div",{className:"space-y-3 px-5 py-4 text-sm text-fg-muted",children:[r.jsx("p",{className:"text-center text-lg font-medium text-fg",children:"Are you sure?"}),P&&r.jsx("p",{className:"text-center",children:P.email}),r.jsxs("ul",{className:"list-inside list-disc space-y-1",children:[r.jsx("li",{children:"Remove the account from your settings"}),r.jsx("li",{children:"Stop syncing mail for this account"}),r.jsx("li",{children:"Delete all associated data (within 24 hours)"})]})]}),r.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[r.jsx(ee,{variant:"secondary",size:"sm",onClick:()=>O(null),children:"Cancel"}),r.jsx(ee,{variant:"danger",size:"sm","aria-busy":te.isPending,icon:te.isPending?r.jsx(at,{className:"size-3.5 animate-spin"}):void 0,onClick:()=>{te.isPending||M&&te.mutate({path:{accountId:M}})},children:te.isPending?"Deleting…":"Delete account"})]})]}),r.jsx(Jr,{})]})}export{ya as component,ea as mapOauthError};
|
|
1
|
+
import{j as r,c5 as ke,B as ee,S as ks,X as Ve,c6 as Vs,c7 as Ds,G as dt,r as C,d as Nt,R as J,af as ut,aT as Cs,aK as Jt,aS as es,a_ as Fs,aN as Se,aY as Os,c3 as Te,c8 as ts,c9 as Is,ca as Rs,cb as Ms,cc as ve,cd as Tt,L as at,l as At,ax as _t,ce as Ls,cf as Ie,cg as be,ch as Et,ay as Us,ci as Hs,cj as zs,D as ss,ck as Pt,au as Bs,cl as qs,cm as $s,cn as Ws,N as kt,e as Ks,co as Vt,cp as Gs,T as Ys}from"./index-xOALrEh8.js";import{u as Qs,R as Zs}from"./useSignature-BQN3IL24.js";import{S as Xs,A as Js}from"./settings-screen-C7xmJsXG.js";import{g as Dt,P as er,s as Be,u as tr,O as sr}from"./OnboardingWizard-r-N3eGPg.js";import{c as rr,b as Ct,d as ar}from"./account-form-helpers-BHUowns0.js";import{D as ir}from"./download-Bg6cLSAV.js";import{E as nr}from"./ErrorState-DiX_zNTK.js";import{e as or}from"./format-CKZmh-Ru.js";import"./avatar-Ci3CMhdo.js";import"./kbd-C00o9L4B.js";const lr=e=>{const s=new Set(e.map(Vs));return Ds.map(t=>t.tag).filter(t=>!s.has(t)).sort((t,i)=>ke(t).localeCompare(ke(i)))},cr=({value:e,onChange:s,busy:t=!1})=>{const i=lr(e);return r.jsxs("div",{className:"space-y-2","data-testid":"compose-language-setting",children:[r.jsx("ul",{className:"space-y-1",children:e.map((o,d)=>r.jsxs("li",{"data-testid":`compose-language-row-${o}`,className:"flex items-center gap-2 rounded-md border border-line bg-surface-sunken px-3 py-1.5",children:[r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-fg",lang:o,children:ke(o)}),d===0?r.jsx("span",{className:"shrink-0 text-2xs uppercase tracking-wider text-fg-subtle",children:"Default"}):r.jsx(ee,{variant:"ghost",size:"sm",icon:r.jsx(ks,{className:"size-3.5"}),disabled:t,"aria-label":`Write new messages in ${ke(o)} by default`,onClick:()=>s([o,...e.filter(n=>n!==o)]),children:"Default"}),r.jsx(ee,{variant:"ghost",size:"sm",icon:r.jsx(Ve,{className:"size-3.5"}),disabled:t||e.length===1,"aria-label":`Remove ${ke(o)}`,onClick:()=>s(e.filter(n=>n!==o))})]},o))}),r.jsxs("select",{"aria-label":"Add a language",value:"",disabled:t||i.length===0,onChange:o=>{o.target.value!==""&&s([...e,o.target.value])},className:"w-full rounded-md border border-line bg-surface-sunken px-3 py-2 text-sm text-fg outline-none transition-colors focus-within:border-line-strong focus-within:ring-2 focus-within:ring-ring/30",children:[r.jsx("option",{value:"",children:"Add a language…"}),i.map(o=>r.jsx("option",{value:o,children:ke(o)},o))]}),r.jsx("p",{className:"text-xs text-fg-muted",children:"A message is tagged with the language you write it in, picked from this list. Your browser, not this app, decides which dictionaries it spellchecks against — add the language there too to get its underlines."})]})};function dr({title:e,description:s,action:t}){return r.jsxs("div",{className:"rounded-sm border border-danger/50",children:[r.jsxs("div",{className:"flex items-center gap-2 border-b border-danger/30 bg-danger-soft px-row-inset py-2",children:[r.jsx(dt,{className:"size-4 text-danger"}),r.jsx("h2",{className:"text-sm font-semibold text-danger",children:"Danger zone"})]}),r.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:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"text-sm font-medium text-fg",children:e}),r.jsx("p",{className:"text-xs text-fg-muted",children:s})]}),r.jsx("div",{className:"shrink-0",children:t})]})]})}function Ft({isOpen:e,onClose:s,title:t,children:i,footer:o}){return C.useEffect(()=>{if(!e)return;const d=n=>{n.key==="Escape"&&s()};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[e,s]),r.jsxs(r.Fragment,{children:[r.jsx("div",{className:Nt("fixed inset-0 z-40 bg-black/30 transition-opacity",e?"opacity-100":"pointer-events-none opacity-0"),onClick:s,"aria-hidden":"true"}),r.jsxs("div",{className:Nt("safe-area-frame 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:[r.jsxs("div",{className:"flex h-14 items-center justify-between border-b border-line px-4",children:[r.jsx("h2",{id:"slide-panel-title",className:"font-semibold",children:t}),r.jsx("button",{type:"button",onClick:s,className:"rounded-md p-1.5 transition-colors hover:bg-surface-raised","aria-label":"Close",children:r.jsx(Ve,{className:"size-5"})})]}),r.jsxs("div",{className:"flex h-[calc(100%-3.5rem)] flex-col",children:[r.jsx("div",{className:"flex-1 overflow-auto p-4",children:i}),o&&r.jsx("div",{className:"flex justify-end gap-3 border-t border-line bg-canvas p-4",children:o})]})]})]})}var Le=e=>e.type==="checkbox",je=e=>e instanceof Date,Y=e=>e==null;const ft=e=>typeof e=="object";var z=e=>!Y(e)&&!Array.isArray(e)&&ft(e)&&!je(e),ur=e=>z(e)&&e.target?Le(e.target)?e.target.checked:e.target.value:e,fr=(e,s)=>s.split(".").some((t,i,o)=>!isNaN(Number(t))&&e.has(o.slice(0,i).join("."))),rs=e=>{const s=e.constructor&&e.constructor.prototype;return z(s)&&s.hasOwnProperty("isPrototypeOf")},Ye=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(Ye&&(e instanceof Blob||s))return e;const t=Array.isArray(e);if(!t&&!(z(e)&&rs(e)))return e;const i=t?[]:Object.create(Object.getPrototypeOf(e));for(const o in e)Object.prototype.hasOwnProperty.call(e,o)&&(i[o]=B(e[o]));return i}const Ee={BLUR:"blur",FOCUS_OUT:"focusout",SUBMIT:"submit",TRIGGER:"trigger",VALID:"valid"},ue={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},de={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},as="root",mt=["__proto__","constructor","prototype"],mr=/^\w*$/;var Ue=e=>mr.test(e),L=e=>e===void 0;const hr=/[.[\]'"]/;var Qe=e=>e.split(hr).filter(Boolean),y=(e,s,t)=>{if(!s||!z(e))return t;const i=Ue(s)?[s]:Qe(s);if(i.some(d=>mt.includes(d)))return t;const o=i.reduce((d,n)=>Y(d)?void 0:d[n],e);return L(o)||o===e?L(e[s])?t:e[s]:o},me=e=>typeof e=="boolean",ie=e=>typeof e=="function",F=(e,s,t)=>{let i=-1;const o=Ue(s)?[s]:Qe(s),d=o.length,n=d-1;for(;++i<d;){const u=o[i];let j=t;if(i!==n){const _=e[u];j=z(_)||Array.isArray(_)?_:isNaN(+o[i+1])?{}:[]}if(mt.includes(u))return;e[u]=j,e=e[u]}};const pr=J.createContext(null);pr.displayName="HookFormControlContext";var gr=(e,s,t,i=!0)=>{const o={};for(const d in e)Object.defineProperty(o,d,{get:()=>{const n=d;return s._proxyFormState[n]!==ue.all&&(s._proxyFormState[n]=!i||ue.all),e[n]}});return o};const xr=Ye?J.useLayoutEffect:J.useEffect;var Q=e=>typeof e=="string",yr=(e,s,t,i,o)=>Q(e)?(i&&s.watch.add(e),y(t,e,o)):Array.isArray(e)?e.map(d=>(i&&s.watch.add(d),y(t,d))):(i&&(s.watchAll=!0),t),it=e=>Y(e)||!ft(e);const Ot=(e,s)=>s.length===0&&!Array.isArray(e)&&!rs(e);function he(e,s,t=new WeakMap){if(e===s)return!0;if(it(e)||it(s))return Object.is(e,s);if(je(e)&&je(s))return Object.is(e.getTime(),s.getTime());const i=Object.keys(e),o=Object.keys(s);if(i.length!==o.length)return!1;if(Ot(e,i)||Ot(s,o))return Object.is(e,s);if(!i.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 i){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 qe=e=>({isOnSubmit:!e||e===ue.onSubmit,isOnBlur:e===ue.onBlur,isOnChange:e===ue.onChange,isOnAll:e===ue.all,isOnTouch:e===ue.onTouched}),tt=(e,s,t)=>{if(t)return!1;if(s.watchAll||s.watch.has(e))return!0;for(const i of s.watch)if(e.startsWith(i)&&e.charAt(i.length)===".")return!0;return!1};const Me=(e,s,t,i)=>{for(const o of t||Object.keys(e)){const d=y(e,o);if(d){const{_f:n,...u}=d;if(n){if(n.refs&&n.refs[0]&&s(n.refs[0],o)&&!i)return!0;if(n.ref&&s(n.ref,n.name)&&!i)return!0;if(Me(u,s))break}else if(z(u)&&Me(u,s))break}}};var It=(e,s,t)=>{const i=y(e,t),o=Array.isArray(i)?i:[];return F(o,as,s[t]),F(e,t,o),e},G=e=>z(e)&&!Object.keys(e).length,ht=e=>e.type==="file",Ke=e=>{if(!Ye)return!1;const s=e?e.ownerDocument:0;return e instanceof(s&&s.defaultView?s.defaultView.HTMLElement:HTMLElement)},pt=e=>e.type==="radio",Ge=e=>e instanceof RegExp,gt=(e,s,t,i,o)=>s?{...t[e],types:{...t[e]&&t[e].types?t[e].types:{},[i]:o||!0}}:{};const Rt={value:!1,isValid:!1},Mt={value:!0,isValid:!0};var is=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&&!L(e[0].attributes.value)?L(e[0].value)||e[0].value===""?Mt:{value:e[0].value,isValid:!0}:Mt:Rt}return Rt};const Lt={isValid:!1,value:null};var ns=e=>Array.isArray(e)?e.reduce((s,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:s,Lt):Lt;function Ut(e,s,t="validate"){if(Q(e)||Array.isArray(e)&&e.every(Q)||me(e)&&!e)return{type:t,message:Q(e)?e:"",ref:s}}var Pe=e=>z(e)&&!Ge(e)?e:{value:e,message:""},Ht=async(e,s,t,i,o,d)=>{const{ref:n,refs:u,required:j,maxLength:_,minLength:E,min:H,max:M,pattern:O,validate:A,name:f,valueAsNumber:b,mount:ae}=e._f,N=y(t,f);if(!ae||s.has(f))return{};const W=u?u[0]:n,I=P=>{if(o&&W.reportValidity){const k=me(P)?"":P||"";u?u.forEach(D=>D.setCustomValidity(k)):W.setCustomValidity(k),W.reportValidity()}},T={},ne=pt(n),re=Le(n),pe=ne||re,oe=(b||ht(n))&&L(n.value)&&L(N)||Ke(n)&&n.value===""||N===""||Array.isArray(N)&&!N.length,K=gt.bind(null,f,i,T),te=(P,k,D,$=de.maxLength,w=de.minLength)=>{const R=P?k:D;T[f]={type:P?$:w,message:R,ref:n,...K(P?$:w,R)}};if(d?!Array.isArray(N)||!N.length:j&&(!pe&&(oe||Y(N))||me(N)&&!N||re&&!is(u).isValid||ne&&!ns(u).isValid)){const{value:P,message:k}=Q(j)?{value:!!j,message:j}:Pe(j);if(P&&(T[f]={type:de.required,message:k,ref:W,...K(de.required,k)},!i))return I(k),T}if(!oe&&(!Y(H)||!Y(M))){let P,k;const D=Pe(M),$=Pe(H);if(!Y(N)&&!isNaN(N)){const w=n.valueAsNumber||N&&+N;Y(D.value)||(P=w>D.value),Y($.value)||(k=w<$.value)}else{const w=n.valueAsDate||new Date(N),R=ge=>new Date(new Date().toDateString()+" "+ge),le=n.type=="time",Z=n.type=="week";Q(D.value)&&N&&(P=le?R(N)>R(D.value):Z?N>D.value:w>new Date(D.value)),Q($.value)&&N&&(k=le?R(N)<R($.value):Z?N<$.value:w<new Date($.value))}if((P||k)&&(te(!!P,D.message,$.message,de.max,de.min),!i))return I(T[f].message),T}if((_||E)&&!oe&&(Q(N)||d&&Array.isArray(N))){const P=Pe(_),k=Pe(E),D=!Y(P.value)&&N.length>+P.value,$=!Y(k.value)&&N.length<+k.value;if((D||$)&&(te(D,P.message,k.message),!i))return I(T[f].message),T}if(O&&!oe&&Q(N)){const{value:P,message:k}=Pe(O);if(Ge(P)&&!N.match(P)&&(T[f]={type:de.pattern,message:k,ref:n,...K(de.pattern,k)},!i))return I(k),T}if(A){if(ie(A)){const P=await A(N,t),k=Ut(P,W);if(k&&(T[f]={...k,...K(de.validate,k.message)},!i))return I(k.message),T}else if(z(A)){let P={};for(const k in A){if(!G(P)&&!i)break;const D=Ut(await A[k](N,t),W,k);D&&(P={...D,...K(k,D.message)},I(D.message),i&&(T[f]=P))}if(!G(P)&&(T[f]={ref:W,...P},!i))return T}}return I(!0),T},We=e=>Array.isArray(e)?e:[e],os=e=>Array.isArray(e)?e.filter(Boolean):[];function vr(e,s){const t=s.slice(0,-1).length;let i=0;for(;i<t;){if(Y(e)){e=void 0;break}e=e[s[i]],i++}return e}function br(e){for(const s in e)if(e.hasOwnProperty(s)&&!L(e[s]))return!1;return!0}function q(e,s){if(Q(s)&&Object.prototype.hasOwnProperty.call(e,s))return delete e[s],e;const t=Array.isArray(s)?s:Ue(s)?[s]:Qe(s);if(t.some(n=>mt.includes(String(n))))return e;const i=t.length===1?e:vr(e,t),o=t.length-1,d=t[o];return i&&delete i[d],o!==0&&(z(i)&&G(i)||Array.isArray(i)&&br(i))&&q(e,t.slice(0,-1)),e}const ls=e=>{const s={};for(const t of Object.keys(e))if(ft(e[t])&&e[t]!==null&&!je(e[t])){const i=ls(e[t]);for(const o of Object.keys(i))s[`${t}.${o}`]=i[o]}else s[t]=e[t];return s},jr=J.createContext(null);jr.displayName="HookFormContext";var zt=()=>{let e=[];return{get observers(){return e},next:o=>{for(const d of e)d.next&&d.next(o)},subscribe:o=>(e.push(o),{unsubscribe:()=>{e=e.filter(d=>d!==o)}}),unsubscribe:()=>{e=[]}}};function cs(e,s){const t={};for(const i in e)if(e.hasOwnProperty(i)){const o=e[i],d=s[i];if(o&&z(o)&&d){const n=cs(o,d);z(n)&&(t[i]=n)}else e[i]&&(t[i]=d)}return t}var ds=e=>e.type==="select-multiple",Sr=e=>pt(e)||Le(e),st=e=>Ke(e)&&e.isConnected,wr=e=>{for(const s in e)if(ie(e[s]))return!0;return!1};function us(e){return Array.isArray(e)||z(e)&&!wr(e)}function fs(e){return!!(e&&"_f"in e)}function ms(e){return Array.isArray(e)?!e.some(s=>!L(s)):!Object.keys(e).length}function nt(e,s){Array.isArray(e)?e[s]=void 0:delete e[s]}function ot(e,s={},t){for(const i in e){const o=e[i],d=t&&t[i];us(o)&&(!Array.isArray(o)||!fs(d))?(s[i]=Array.isArray(o)?[]:{},ot(o,s[i],d),ms(s[i])&&nt(s,i)):L(o)||(s[i]=!0)}return s}function Ne(e,s,t,i){t||(t=ot(s,{},i));for(const o in e){const d=e[o],n=i&&i[o];us(d)&&(!Array.isArray(d)||!fs(n))?(L(s)||it(t[o])?t[o]=ot(d,Array.isArray(d)?[]:{},n):Ne(d,Y(s)?{}:s[o],t[o],n),ms(t[o])&&nt(t,o)):he(d,s[o])?nt(t,o):t[o]=!0}return t}var hs=(e,{valueAsNumber:s,valueAsDate:t,setValueAs:i})=>L(e)?e:s?e===""?NaN:e&&+e:t&&Q(e)?new Date(e):i?i(e):e;function Bt(e){const s=e.ref;return ht(s)?s.files:pt(s)?ns(e.refs).value:ds(s)?[...s.selectedOptions].map(({value:t})=>t):Le(s)?is(e.refs).value:hs(L(s.value)?e.ref.value:s.value,e)}var Nr=(e,s,t,i)=>{const o={};for(const d of e){const n=y(s,d);n&&F(o,d,n._f)}return{criteriaMode:t,names:[...e],fields:o,shouldUseNativeValidation:i}},Re=e=>L(e)?e:Ge(e)?e.source:z(e)?Ge(e.value)?e.value.source:e.value:e;const qt="AsyncFunction";var Tr=e=>{if(!e||!e.validate)return!1;if(ie(e.validate))return e.validate.constructor.name===qt;if(z(e.validate)){for(const s in e.validate)if(e.validate[s].constructor.name===qt)return!0}return!1},Ar=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function $t(e,s,t){const i=y(e,t);if(i||Ue(t))return{error:i,name:t};const o=t.split(".");for(;o.length;){const d=o.join("."),n=y(s,d),u=y(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};o.pop()}return{name:t}}var _r=(e,s,t,i)=>{t(e);const{name:o,...d}=e,n=Object.keys(d);return!n.length||i&&n.length>=Object.keys(s).length||n.find(u=>s[u]===(!i||ue.all))},Er=(e,s,t)=>!e||!s||e===s||We(e).some(i=>i&&(t?i===s||i.startsWith(s+"."):i.startsWith(s)||s.startsWith(i))),Pr=(e,s,t,i,o)=>o.isOnAll?!1:!t&&o.isOnTouch?!(s||e):(t?i.isOnBlur:o.isOnBlur)?!e:(t?i.isOnChange:o.isOnChange)?e:!0,kr=(e,s)=>!os(y(e,s)).length&&q(e,s);const Vr={mode:ue.onSubmit,reValidateMode:ue.onChange,shouldFocusError:!0},rt="form",ps={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function Dr(e={}){let s={...Vr,...e},t={...B(ps),isLoading:ie(s.defaultValues),errors:s.errors||{},disabled:s.disabled||!1},i={},o=z(s.defaultValues)||z(s.values)?B(s.defaultValues||s.values)||{}:{},d=s.shouldUnregister?{}:B(o),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={},_={};let E=0,H=qe(s.mode),M=qe(s.reValidateMode);const O={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},A={...O};let f={...A};const b={array:zt(),state:zt()};let ae=0;const N=s.criteriaMode===ue.all,W=(a,l)=>c=>{clearTimeout(_[a]),_[a]=setTimeout(l,c)},I=async a=>{if(!n.keepIsValid&&!s.disabled&&(A.isValid||f.isValid||a)){const l=++ae;let c;s.resolver?(c=G((await D()).errors),l===ae&&T()):c=await R({fields:i,onlyCheckValid:!0,eventType:Ee.VALID}),l===ae&&c!==t.isValid&&b.state.next({isValid:c})}},T=(a,l)=>{!s.disabled&&(A.isValidating||A.validatingFields||f.isValidating||f.validatingFields)&&((a||Array.from(u.mount)).forEach(c=>{c&&(l?F(t.validatingFields,c,l):q(t.validatingFields,c))}),b.state.next({validatingFields:t.validatingFields,isValidating:!G(t.validatingFields)}))},ne=()=>{t.dirtyFields=Ne(o,d,void 0,i)},re=(a,l=[],c,m,h=!0,x=!0)=>{if(m&&c&&!s.disabled){if(n.action=!0,x&&Array.isArray(y(i,a))){const g=c(y(i,a),m.argA,m.argB);h&&F(i,a,g)}if(x&&Array.isArray(y(t.errors,a))){const g=c(y(t.errors,a),m.argA,m.argB);h&&F(t.errors,a,g),kr(t.errors,a)}if((A.touchedFields||f.touchedFields)&&x&&Array.isArray(y(t.touchedFields,a))){const g=c(y(t.touchedFields,a),m.argA,m.argB);h&&F(t.touchedFields,a,g)}(A.dirtyFields||f.dirtyFields)&&ne(),b.state.next({name:a,isDirty:Z(a,l),dirtyFields:t.dirtyFields,errors:t.errors,isValid:t.isValid})}else F(d,a,l)},pe=(a,l)=>{F(t.errors,a,l),t.errors={...t.errors},b.state.next({errors:t.errors})},oe=a=>{t.errors=a,b.state.next({errors:t.errors,isValid:!1})},K=a=>{const l=Ue(a)?[a]:Qe(a);let c=d,m=o;for(let h=0;h<l.length-1;h++){const x=l[h];if(c=Y(c)?c:c[x],m=Y(m)?m:m[x],c===null&&m!==null)return!0}return!1},te=(a,l,c,m)=>{const h=y(i,a);if(h){if(K(a))return;const x=L(y(d,a)),g=y(d,a,L(c)?y(o,a):c);L(g)||m&&m.defaultChecked||l?F(d,a,l?g:Bt(h._f)):De(a,g),n.mount&&!n.action&&(I(),x&&t.isDirty&&(A.isDirty||f.isDirty)&&(Z()||(t.isDirty=!1,b.state.next({...t}))),e.shouldUnregister&&x&&!L(y(d,a))&&tt(a,u)&&(n.watch=!0))}},P=(a,l,c,m,h)=>{let x=!1,g=!1;const v={name:a};if(!s.disabled||m===!0){if(!c||m){const S=he(y(o,a),l);(A.isDirty||f.isDirty)&&(g=t.isDirty,t.isDirty=v.isDirty=!S||Z(),x=g!==v.isDirty),g=!!y(t.dirtyFields,a),S!==t.isDirty?t.dirtyFields=Ne(o,d,void 0,i):S?q(t.dirtyFields,a):F(t.dirtyFields,a,!0),v.dirtyFields=t.dirtyFields,x=x||(A.dirtyFields||f.dirtyFields)&&g!==!S}if(c){const S=y(t.touchedFields,a);S||(F(t.touchedFields,a,c),v.touchedFields=t.touchedFields,x=x||(A.touchedFields||f.touchedFields)&&S!==c)}x&&h&&b.state.next(v)}return x?v:{}},k=(a,l,c,m)=>{const h=y(t.errors,a),x=(A.isValid||f.isValid)&&me(l)&&t.isValid!==l;if(s.delayError&&c?(j[a]=W(a,()=>pe(a,c)),j[a](s.delayError)):(clearTimeout(_[a]),delete j[a],c?F(t.errors,a,c):q(t.errors,a),t.errors={...t.errors}),(c?!he(h,c):h)||!G(m)||x){const g={...m,...x&&me(l)?{isValid:l}:{},errors:t.errors,name:a};t={...t,...g},b.state.next(g)}},D=async a=>(T(a,!0),await s.resolver(d,s.context,Nr(a||u.mount,i,s.criteriaMode,s.shouldUseNativeValidation))),$=async a=>{const{errors:l}=await D(a);if(T(a),a){for(const c of a){const m=y(l,c);m?u.array.has(c)&&z(m)&&!Object.keys(m).some(h=>!Number.isNaN(Number(h)))?It(t.errors,{[c]:m},c):F(t.errors,c,m):q(t.errors,c)}t.errors={...t.errors}}else t.errors=l;return l},w=async({name:a,eventType:l})=>{if(e.validate){const c=await e.validate({formValues:d,formState:t,name:a,eventType:l});if(z(c))for(const m in c){const h=c[m];h&&ze(`${rt}.${m}`,{message:Q(h.message)?h.message:"",type:h.type||de.validate})}else Q(c)||!c?ze(rt,{message:c||"",type:de.validate}):_e(rt);return c}return!0},R=async({fields:a,onlyCheckValid:l,name:c,eventType:m,context:h={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(h.runRootValidation=!0,!await w({name:c,eventType:m})&&(h.valid=!1,l)))return h.valid;for(const x in a){const g=a[x];if(g){const{_f:v,...S}=g;if(v){const U=u.array.has(v.name),X=g._f&&Tr(g._f),xe=A.validatingFields||A.isValidating||f.validatingFields||f.isValidating;X&&xe&&T([v.name],!0);const ye=await Ht(g,u.disabled,d,N,s.shouldUseNativeValidation&&!l,U);if(X&&xe&&T([v.name]),ye[v.name]&&(h.valid=!1,l)||(!l&&(y(ye,v.name)?U?It(t.errors,ye,v.name):F(t.errors,v.name,ye[v.name]):q(t.errors,v.name)),e.shouldUseNativeValidation&&ye[v.name]))break}!G(S)&&await R({context:h,onlyCheckValid:l,fields:S,name:x,eventType:m})}}return h.valid},le=()=>{for(const a of u.unMount){const l=y(i,a);l&&(l._f.refs?l._f.refs.every(c=>!st(c)):!st(l._f.ref))&&Xe(a)}u.unMount=new Set},Z=(a,l)=>(a&&l&&F(d,a,l),!he(n.mount?d:o,o)),ge=(a,l,c)=>yr(a,u,{...n.mount?d:L(l)?o:Q(a)?{[a]:l}:l},c,l),Ae=a=>os(y(n.mount?d:o,a,s.shouldUnregister?y(o,a,[]):[])),De=(a,l,c={},m=!1,h=!1)=>{const x=y(i,a);let g=l;if(x){const v=x._f;v&&(!v.disabled&&F(d,a,hs(l,v)),g=Ke(v.ref)&&Y(l)?"":l,ds(v.ref)?[...v.ref.options].forEach(S=>S.selected=g.includes(S.value)):v.refs?Le(v.ref)?v.refs.forEach(S=>{(!S.defaultChecked||!S.disabled)&&(Array.isArray(g)?S.checked=!!g.find(U=>U===S.value):S.checked=g===S.value||!!g)}):v.refs.forEach(S=>S.checked=S.value===g):ht(v.ref)?v.ref.value="":(v.ref.value=g,!v.ref.type&&!h&&b.state.next({name:a,values:m?d:B(d)})))}(c.shouldDirty||c.shouldTouch)&&P(a,g,c.shouldTouch,c.shouldDirty,!h),c.shouldValidate&&fe(a,{delayError:c.delayError})},He=(a,l,c,m=!1,h=!1)=>{for(const x in l){if(!l.hasOwnProperty(x))return;const g=l[x],v=a+"."+x,S=y(i,v);(u.array.has(a)||z(g)||S&&!S._f)&&!je(g)?He(v,g,c,m,h):De(v,g,c,m,h)}},Ze=(a,l,c,m,h=!1)=>{const x=y(i,a),g=u.array.has(a),v=m?l:B(l),S=y(d,a),U=he(S,v);if(U||F(d,a,v),g)b.array.next({name:a,values:m?d:B(d)}),(A.isDirty||A.dirtyFields||f.isDirty||f.dirtyFields)&&c.shouldDirty&&(ne(),h||b.state.next({name:a,dirtyFields:t.dirtyFields,isDirty:Z(a,v)}));else{const X=Array.isArray(v)&&!v.length||G(v);!x||x._f||Y(v)||X?De(a,v,c,m,h):He(a,v,c,m,h)}if(!U&&!h){const X=tt(a,u),xe=m?d:B(d);b.state.next({...X&&t,name:n.mount||X?a:void 0,values:xe})}},p=(a,l,c={})=>Ze(a,l,c,!1),V=(a,l={})=>{const c=ie(a)?a(d):a;if(!he(d,c)){d={...d,...c};const m=ls(c);for(const h of u.mount)h in m&&Ze(h,m[h],l,!0,!0);b.state.next({...t,name:void 0,type:void 0,...E?{values:d}:{}}),l.shouldValidate&&I()}},ce=async a=>{n.mount=!0;const l=a.target;let c=l.name,m=!0;const h=y(i,c),x=g=>{m=Number.isNaN(g)||je(g)&&isNaN(g.getTime())||he(g,y(d,c,g))};if(h){let g,v;const S=l.type?Bt(h._f):ur(a),U=a.type===Ee.BLUR||a.type===Ee.FOCUS_OUT,X=!Ar(h._f)&&!e.validate&&!s.resolver&&!y(t.errors,c)&&!h._f.deps,xe=X||Pr(U,y(t.touchedFields,c),t.isSubmitted,M,H),ye=tt(c,u,U);if(F(d,c,S),U){if(!l||!l.readOnly){h._f.onBlur&&h._f.onBlur(a);const Oe=j[c];Oe&&Oe(0)}}else h._f.onChange&&h._f.onChange(a);const Fe=P(c,S,U),Es=!G(Fe)||ye;if(!U&&b.state.next({name:c,type:a.type,...E?{values:B(d)}:{}}),xe)return(!X||!t.isValid)&&(A.isValid||f.isValid)&&(s.mode==="onBlur"?U&&I():U||I()),Es&&b.state.next({name:c,...ye?{}:Fe});if(!s.resolver&&e.validate&&await w({name:c,eventType:a.type}),!U&&ye&&b.state.next({...t}),s.resolver){const{errors:Oe}=await D([c]);if(T([c]),x(S),!m){!G(Fe)&&b.state.next(Fe);return}const Ps=$t(t.errors,i,c),wt=$t(Oe,i,Ps.name||c);g=wt.error,c=wt.name,v=G(Oe)}else T([c],!0),g=(await Ht(h,u.disabled,d,N,s.shouldUseNativeValidation))[c],T([c]),x(S),m&&(g?v=!1:(A.isValid||f.isValid)&&(v=await R({fields:i,onlyCheckValid:!0,name:c,eventType:a.type})));m&&(h._f.deps&&(!Array.isArray(h._f.deps)||h._f.deps.length>0)&&fe(h._f.deps),k(c,v,g,Fe))}},se=(a,l)=>{if(y(t.errors,l)&&a.focus)return a.focus(),1},fe=async(a,l={})=>{let c,m;const h=We(a);if(s.resolver){const x=await $(L(a)?a:h);c=G(x),m=a?!h.some(g=>y(x,g)):c}else a?(m=(await Promise.all(h.map(async x=>{const g=y(i,x);return await R({fields:g&&g._f?{[x]:g}:g,eventType:Ee.TRIGGER})}))).every(Boolean),!(!m&&!t.isValid)&&I()):m=c=await R({fields:i,name:a,eventType:Ee.TRIGGER});if(l.delayError&&s.delayError&&Q(a)){const x=y(t.errors,a);x?(q(t.errors,a),j[a]=W(a,()=>pe(a,x)),j[a](s.delayError)):(clearTimeout(_[a]),delete j[a])}return b.state.next({...!Q(a)||(A.isValid||f.isValid)&&c!==t.isValid?{}:{name:a},...s.resolver||!a?{isValid:c}:{},errors:t.errors}),l.shouldFocus&&!m&&Me(i,se,a?h:u.mount),m},we=(a,l)=>{let c={...n.mount?d:o};return l&&(c=cs(l.dirtyFields?t.dirtyFields:t.touchedFields,c)),L(a)?c:Q(a)?y(c,a):a.map(m=>y(c,m))},Ce=(a,l)=>({invalid:!!y((l||t).errors,a),isDirty:!!y((l||t).dirtyFields,a),error:y((l||t).errors,a),isValidating:!!y(t.validatingFields,a),isTouched:!!y((l||t).touchedFields,a)}),_e=a=>{const l=a?We(a):void 0;l?.forEach(c=>q(t.errors,c)),l?l.forEach(c=>{b.state.next({name:c,errors:t.errors})}):b.state.next({errors:{}})},ze=(a,l,c)=>{const m=(y(i,a,{_f:{}})._f||{}).ref,h=y(t.errors,a)||{},{ref:x,message:g,type:v,...S}=h;F(t.errors,a,{...S,...l,ref:m}),b.state.next({name:a,errors:t.errors,isValid:!1}),c&&c.shouldFocus&&m&&m.focus&&m.focus()},Ss=(a,l)=>{if(ie(a)){E++;const{unsubscribe:c}=b.state.subscribe({next:h=>"values"in h&&a(h.values||ge(void 0,l),h)});let m=!1;return{unsubscribe:()=>{m||(m=!0,E--,c())}}}return ge(a,l,!0)},xt=a=>{var l;const c=!!(!((l=a.formState)===null||l===void 0)&&l.values);c&&E++;const{unsubscribe:m}=b.state.subscribe({next:x=>{if(Er(a.name,x.name,a.exact)&&_r(x,a.formState||A,_s,a.reRenderRoot)){const g={...d};a.callback({values:g,...t,...x,defaultValues:o})}}});if(!c)return m;let h=!1;return()=>{h||(h=!0,E--,m())}},ws=a=>(n.mount=!0,f={...f,...a.formState},xt({...a,formState:{...O,...a.formState}})),Xe=(a,l={})=>{for(const c of a?We(a):u.mount)u.mount.delete(c),u.array.delete(c),l.keepValue||(q(i,c),q(d,c)),!l.keepError&&q(t.errors,c),!l.keepDirty&&q(t.dirtyFields,c),!l.keepTouched&&q(t.touchedFields,c),!l.keepIsValidating&&q(t.validatingFields,c),!s.shouldUnregister&&!l.keepDefaultValue&&q(o,c);b.state.next({values:B(d)}),b.state.next({...t,...l.keepDirty?{isDirty:Z()}:{}}),!l.keepIsValid&&I()},yt=({disabled:a,name:l})=>{if(me(a)&&n.mount||a||u.disabled.has(l)){const h=u.disabled.has(l)!==!!a;a?u.disabled.add(l):u.disabled.delete(l),h&&n.mount&&!n.action&&I()}},Je=(a,l={})=>{let c=y(i,a);const m=me(l.disabled)||me(s.disabled),h=!u.registerName.has(a)&&c&&c._f&&!c._f.mount;return F(i,a,{...c||{},_f:{...c&&c._f?c._f:{ref:{name:a}},name:a,mount:!0,...l}}),u.mount.add(a),c&&!h?yt({disabled:me(l.disabled)?l.disabled:s.disabled,name:a}):te(a,!0,l.value),{...m?{disabled:l.disabled||s.disabled}:{},...s.progressive?{required:!!l.required,min:Re(l.min),max:Re(l.max),minLength:Re(l.minLength),maxLength:Re(l.maxLength),pattern:Re(l.pattern)}:{},name:a,onChange:ce,onBlur:ce,ref:x=>{if(x){u.registerName.add(a),Je(a,l),u.registerName.delete(a),c=y(i,a);const g=L(x.value)&&x.querySelectorAll&&x.querySelectorAll("input,select,textarea")[0]||x,v=Sr(g),S=c._f.refs||[];if(v?S.find(U=>U===g):g===c._f.ref)return;F(i,a,{_f:{...c._f,...v?{refs:[...S.filter(st),g,...Array.isArray(y(o,a))?[{}]:[]],ref:{type:g.type,name:a}}:{ref:g}}}),te(a,!1,void 0,g)}else c=y(i,a,{}),c._f&&(c._f.mount=!1),(s.shouldUnregister||l.shouldUnregister)&&!(fr(u.array,a)&&n.action)&&u.unMount.add(a)}}},et=()=>s.shouldFocusError&&!s.shouldUseNativeValidation&&Me(i,se,u.mount),Ns=a=>{me(a)&&(b.state.next({disabled:a}),Me(i,(l,c)=>{const m=y(i,c);m&&(l.disabled=m._f.disabled||a,Array.isArray(m._f.refs)&&m._f.refs.forEach(h=>{h.disabled=m._f.disabled||a}))},0,!1))},vt=(a,l)=>async c=>{let m;c&&(c.preventDefault&&c.preventDefault(),c.persist&&c.persist());let h=B(d);if(b.state.next({isSubmitting:!0}),s.resolver){const{errors:x,values:g}=await D();T(),t.errors=x,h=B(g)}else await R({fields:i,eventType:Ee.SUBMIT});if(u.disabled.size)for(const x of u.disabled)q(h,x);if(q(t.errors,as),G(t.errors)){b.state.next({errors:{}});try{await a(h,c)}catch(x){m=x}}else l&&await l({...t.errors},c),et(),setTimeout(et);if(b.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:G(t.errors)&&!m,submitCount:t.submitCount+1,errors:t.errors}),m)throw m},Ts=(a,l={})=>{y(i,a)&&(L(l.defaultValue)?p(a,B(y(o,a))):(p(a,l.defaultValue),F(o,a,B(l.defaultValue))),l.keepTouched||q(t.touchedFields,a),l.keepDirty||(q(t.dirtyFields,a),t.isDirty=l.defaultValue?Z(a,B(y(o,a))):Z()),l.keepError||(q(t.errors,a),A.isValid&&I()),b.state.next({...t}))},bt=(a,l={})=>{const c=a?B(a):o,m=B(c),h=G(a),x=m,g=i;if(l.keepDefaultValues||(o=c),!l.keepValues){if(l.keepDirtyValues){const v=new Set([...u.mount,...Object.keys(Ne(o,d,void 0,g))]);for(const S of Array.from(v)){const U=y(t.dirtyFields,S),X=y(d,S),xe=y(x,S);U&&!L(X)?F(x,S,X):!U&&!L(xe)&&p(S,xe)}}else{if(Ye&&L(a))for(const v of u.mount){const S=y(i,v);if(S&&S._f){const U=Array.isArray(S._f.refs)?S._f.refs[0]:S._f.ref;if(Ke(U)){const X=U.closest("form");if(X){X.reset();break}}}}if(l.keepFieldsRef)for(const v of u.mount)p(v,y(x,v));else i={}}if(s.shouldUnregister){if(d=l.keepDefaultValues?B(o):{},l.keepFieldsRef)for(const v of u.mount)F(d,v,y(x,v))}else d=B(x);b.array.next({values:{...x}}),b.state.next({name:void 0,type:void 0,values:{...x}})}u={mount:l.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=!A.isValid||!!l.keepIsValid||!!l.keepDirtyValues||!s.shouldUnregister&&!G(x),n.watch=!!s.shouldUnregister,n.keepIsValid=!!l.keepIsValid,n.action=!1,l.keepErrors||(t.errors={}),b.state.next({submitCount:l.keepSubmitCount?t.submitCount:0,isDirty:h?!1:l.keepDirty?t.isDirty:l.keepValues?Z():!!(l.keepDefaultValues&&!he(a,o)),isSubmitted:l.keepIsSubmitted?t.isSubmitted:!1,dirtyFields:h?{}:l.keepDirtyValues?l.keepDefaultValues&&d?Ne(o,d,void 0,g):t.dirtyFields:l.keepDefaultValues&&a?Ne(o,a,void 0,g):l.keepDirty?t.dirtyFields:{},touchedFields:l.keepTouched?t.touchedFields:{},errors:l.keepErrors?t.errors:{},isSubmitSuccessful:l.keepIsSubmitSuccessful?t.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:o})},jt=(a,l)=>bt(ie(a)?a(d):a,{...s.resetOptions,...l}),As=(a,l={})=>{const c=y(i,a),m=c&&c._f;if(m){const h=m.refs?m.refs[0]:m.ref;h.focus&&setTimeout(()=>{h.focus(),l.shouldSelect&&ie(h.select)&&h.select()})}},_s=a=>{const{name:l,type:c,values:m,...h}=a;t={...t,...h}},St={control:{register:Je,unregister:Xe,getFieldState:Ce,handleSubmit:vt,setError:ze,_subscribe:xt,_runSchema:D,_updateIsValidating:T,_focusError:et,_getWatch:ge,_getDirty:Z,_setValid:I,_setFieldArray:re,_setDisabledField:yt,_setErrors:oe,_getFieldArray:Ae,_reset:bt,_resetDefaultValues:()=>ie(s.defaultValues)&&s.defaultValues().then(a=>{jt(a,s.resetOptions),b.state.next({isLoading:!1})}),_removeUnmounted:le,_disableForm:Ns,_subjects:b,_proxyFormState:A,get _fields(){return i},get _formValues(){return d},get _state(){return n},set _state(a){n=a},get _defaultValues(){return o},get _names(){return u},set _names(a){u=a},get _formState(){return t},get _options(){return s},set _options(a){s={...s,...a},H=qe(s.mode),M=qe(s.reValidateMode)}},subscribe:ws,trigger:fe,register:Je,handleSubmit:vt,watch:Ss,setValue:p,setValues:V,getValues:we,reset:jt,resetField:Ts,resetDefaultValues:(a,l={})=>{if(o=B(a),!l.keepDirty){const c=Ne(o,d,void 0,i);t.dirtyFields=c,t.isDirty=!G(c)}l.keepIsValid||I(),b.state.next({...t,defaultValues:o})},clearErrors:_e,unregister:Xe,setError:ze,setFocus:As,getFieldState:Ce};return{...St,formControl:St}}function Cr(e={}){const s=J.useRef(void 0),t=J.useRef(void 0),i=J.useRef(e.formControl),[o,d]=J.useState(()=>({...B(ps),isLoading:ie(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1,defaultValues:ie(e.defaultValues)?void 0:e.defaultValues}));if(!s.current||e.formControl&&i.current!==e.formControl)if(i.current=e.formControl,e.formControl)s.current={...e.formControl,formState:o},e.defaultValues&&!ie(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:u,...j}=Dr(e);s.current={...j,formState:o}}const n=s.current.control;return n._options=e,xr(()=>{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]),J.useEffect(()=>n._disableForm(e.disabled),[n,e.disabled]),J.useEffect(()=>{e.mode&&(n._options.mode=e.mode),e.reValidateMode&&(n._options.reValidateMode=e.reValidateMode)},[n,e.mode,e.reValidateMode]),J.useEffect(()=>{e.errors&&(n._setErrors(e.errors),n._focusError())},[n,e.errors]),J.useEffect(()=>{e.shouldUnregister&&n._subjects.state.next({values:n._getWatch()})},[n,e.shouldUnregister]),J.useEffect(()=>{if(n._proxyFormState.isDirty){const u=n._getDirty();u!==o.isDirty&&n._subjects.state.next({isDirty:u})}},[n,o.isDirty]),J.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]),J.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=J.useMemo(()=>gr(o,n),[n,o]),s.current}const Wt=(e,s,t)=>{if(e&&"reportValidity"in e){const i=y(t,s);e.setCustomValidity(i&&i.message||""),e.reportValidity()}},lt=(e,s)=>{for(const t in s.fields){const i=s.fields[t];i&&i.ref&&"reportValidity"in i.ref?Wt(i.ref,t,e):i&&i.refs&&i.refs.forEach(o=>Wt(o,t,e))}},Kt=(e,s)=>{s.shouldUseNativeValidation&<(e,s);const t={};for(const i in e){const o=y(s.fields,i),d=Object.assign(e[i]||{},{ref:o&&o.ref});if(Fr(s.names||Object.keys(e),i)){const n=Object.assign({},y(t,i));F(n,"root",d),F(t,i,n)}else F(t,i,d)}return t},Fr=(e,s)=>{const t=Gt(s).replace(/[.*+?^${}()|\\]/g,"\\$&");return e.some(i=>Gt(i).match(`^${t}\\.\\d+`))};function Gt(e){return e.replace(/[\[\]]/g,"")}function gs(e,s,t){function i(u,j){var _;Object.defineProperty(u,"_zod",{value:u._zod??{},enumerable:!1}),(_=u._zod).traits??(_.traits=new Set),u._zod.traits.add(e),s(u,j);for(const E in n.prototype)E in u||Object.defineProperty(u,E,{value:n.prototype[E].bind(u)});u._zod.constr=n,u._zod.def=j}const o=t?.Parent??Object;class d extends o{}Object.defineProperty(d,"name",{value:e});function n(u){var j;const _=t?.Parent?new d:this;i(_,u),(j=_._zod).deferred??(j.deferred=[]);for(const E of _._zod.deferred)E();return _}return Object.defineProperty(n,"init",{value:i}),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 Or extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const Ir={};function xs(e){return Ir}function Rr(e,s){return typeof s=="bigint"?s.toString():s}const ys=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function $e(e){return typeof e=="string"?e:e?.message}function vs(e,s,t){const i={...e,path:e.path??[]};if(!e.message){const o=$e(e.inst?._zod.def?.error?.(e))??$e(s?.error?.(e))??$e(t.customError?.(e))??$e(t.localeError?.(e))??"Invalid input";i.message=o}return delete i.inst,delete i.continue,s?.reportInput||delete i.input,i}const bs=(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,Rr,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Mr=gs("$ZodError",bs),js=gs("$ZodError",bs,{Parent:Error}),Lr=e=>(s,t,i,o)=>{const d=i?Object.assign(i,{async:!1}):{async:!1},n=s._zod.run({value:t,issues:[]},d);if(n instanceof Promise)throw new Or;if(n.issues.length){const u=new(o?.Err??e)(n.issues.map(j=>vs(j,d,xs())));throw ys(u,o?.callee),u}return n.value},Ur=Lr(js),Hr=e=>async(s,t,i,o)=>{const d=i?Object.assign(i,{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(o?.Err??e)(n.issues.map(j=>vs(j,d,xs())));throw ys(u,o?.callee),u}return n.value},zr=Hr(js);function ct(){return ct=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var t=arguments[s];for(var i in t)({}).hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},ct.apply(null,arguments)}function Yt(e,s){try{var t=e()}catch(i){return s(i)}return t&&t.then?t.then(void 0,s):t}function Br(e,s){for(var t={};e.length;){var i=e[0],o=i.code,d=i.message,n=i.path.join(".");if(!t[n])if("unionErrors"in i){var u=i.unionErrors[0].errors[0];t[n]={message:u.message,type:u.code}}else t[n]={message:d,type:o};if("unionErrors"in i&&i.unionErrors.forEach(function(E){return E.errors.forEach(function(H){return e.push(H)})}),s){var j=t[n].types,_=j&&j[i.code];t[n]=gt(n,s,t,o,_?[].concat(_,i.message):i.message)}e.shift()}return t}function qr(e,s){for(var t={},i=function(){var o=e[0],d=o.code,n=o.message,u=o.path.join(".");if(!t[u])if(o.code==="invalid_union"&&o.errors.length>0){var j=o.errors[0][0];t[u]={message:j.message,type:j.code}}else t[u]={message:n,type:d};if(o.code==="invalid_union"&&o.errors.forEach(function(H){return H.forEach(function(M){return e.push(ct({},M,{path:[].concat(o.path,M.path)}))})}),s){var _=t[u].types,E=_&&_[o.code];t[u]=gt(u,s,t,d,E?[].concat(E,o.message):o.message)}e.shift()};e.length;)i();return t}function $r(e,s,t){if(t===void 0&&(t={}),(function(i){return"_def"in i&&typeof i._def=="object"&&"typeName"in i._def})(e))return function(i,o,d){try{return Promise.resolve(Yt(function(){return Promise.resolve(e[t.mode==="sync"?"parse":"parseAsync"](i,s)).then(function(n){return d.shouldUseNativeValidation&<({},d),{errors:{},values:t.raw?Object.assign({},i):n}})},function(n){if((function(u){return Array.isArray(u?.issues)})(n))return{values:{},errors:Kt(Br(n.errors,!d.shouldUseNativeValidation&&d.criteriaMode==="all"),d)};throw n}))}catch(n){return Promise.reject(n)}};if((function(i){return"_zod"in i&&typeof i._zod=="object"})(e))return function(i,o,d){try{return Promise.resolve(Yt(function(){return Promise.resolve((t.mode==="sync"?Ur:zr)(e,i,s)).then(function(n){return d.shouldUseNativeValidation&<({},d),{errors:{},values:t.raw?Object.assign({},i):n}})},function(n){if((function(u){return u instanceof Mr})(n))return{values:{},errors:Kt(qr(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 Wr=e=>{const s=ut(),{pushError:t}=Cs(),{data:i}=Jt({...es(),staleTime:1/0}),o=i?.accounts.find(j=>j.accountId===e)?.composeLanguages,d=C.useMemo(()=>o&&o.length>0?[...o]:Fs(navigator.languages),[o]),n=Se({...ts(),onSuccess:()=>{s.invalidateQueries({queryKey:Te()})},onError:j=>{t(Os("Couldn't save languages","The writing languages weren't saved.",j))}}),u=C.useCallback(j=>{e&&n.mutate({path:{accountId:e},body:{composeLanguages:j}})},[e,n]);return{languages:d,setLanguages:u,isSaving:n.isPending}},Kr=e=>e.authType==="oauthMicrosoft",Gr="••••••••••",Yr=e=>{const s=e.smtpUsername?.trim();return s?s!==e.username:!1},Qr=Ls({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:Et.number().int().min(1).max(65535),imapTls:Ie(),imapStartTls:Ie(),smtpHost:be().optional(),smtpPort:Et.number().int().min(1).max(65535).optional(),smtpTls:Ie().optional(),smtpStartTls:Ie().optional(),smtpUsername:be().optional(),smtpPassword:be().optional(),useDifferentSmtpCreds:Ie().optional()}),Zr=({isOpen:e,onClose:s,account:t,focusSmtp:i})=>{const o=ut(),d=!!t,[n,u]=C.useState(!1),[j,_]=C.useState(""),[E,H]=C.useState(!1),M=Dt(j),O=!!M&&!E,A=C.useRef(null),f=Cr({resolver:$r(Qr),defaultValues:{email:"",displayName:"",username:"",password:"",imapHost:"",imapPort:993,imapTls:!0,imapStartTls:!1,smtpHost:"",smtpPort:587,smtpTls:!1,smtpStartTls:!0,useDifferentSmtpCreds:!1}});C.useEffect(()=>{if(t){const p=Yr(t);f.reset({email:t.email,displayName:t.displayName||"",username:t.username||"",password:Gr,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=Se({...Is()}),ae=Se({...Rs(),onSuccess:()=>{o.invalidateQueries({queryKey:Te()}),s()}}),N=Se({...ts(),onSuccess:()=>{o.invalidateQueries({queryKey:Te()}),s()}}),W=()=>{const p=f.getValues(),V=d&&!n;b.mutate({body:{accountId:V?t?.accountId:void 0,username:p.username||p.email,password:V?void 0:p.password||void 0,imapHost:p.imapHost,imapPort:Number(p.imapPort),imapTls:p.imapTls,imapStartTls:p.imapStartTls}})},I=()=>{const p=f.getValues(),V=d&&!n;b.mutate({body:{accountId:V?t?.accountId:void 0,username:p.username||p.email,password:V?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}})},T=f.handleSubmit(p=>{if(!d&&!p.password){f.setError("password",{message:"Password is required"});return}const V=rr({imapHost:p.imapHost,smtpHost:p.smtpHost,smtpPort:p.smtpPort,smtpTls:p.smtpTls,smtpStartTls:p.smtpStartTls});V&&(f.setValue("smtpHost",V.smtpHost),f.setValue("smtpPort",V.smtpPort),f.setValue("smtpTls",V.smtpTls),f.setValue("smtpStartTls",V.smtpStartTls));const ce=V?.smtpHost??p.smtpHost,se=V?.smtpPort??p.smtpPort,fe=V?.smtpTls??p.smtpTls,we=V?.smtpStartTls??p.smtpStartTls,Ce={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:se?Number(se):void 0,smtpTls:fe,smtpStartTls:we,smtpUsername:p.useDifferentSmtpCreds&&p.smtpUsername||void 0,smtpPassword:p.useDifferentSmtpCreds&&p.smtpPassword||void 0};if(d&&t){const _e={...Ce,password:n?p.password:void 0};N.mutate({path:{accountId:t.accountId},body:_e})}else{const _e={...Ce,password:p.password};ae.mutate({body:_e})}}),ne=ae.isPending||N.isPending,{signature:re,setSignature:pe,isSaving:oe}=Qs(t?.accountId),[K,te]=C.useState(re.plainText),{languages:P,setLanguages:k,isSaving:D}=Wr(t?.accountId),$=r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Writing languages"}),r.jsx(cr,{value:P,onChange:k,busy:D})]});C.useEffect(()=>{te(re.plainText)},[re.plainText]),C.useEffect(()=>{if(!e||!i)return;const p=A.current;if(!p)return;const V=window.setTimeout(()=>{p.scrollIntoView({behavior:"smooth",block:"start"})},250);return()=>window.clearTimeout(V)},[e,i]);const w=C.useCallback(()=>{K!==re.plainText&&pe(K,K)},[K,re.plainText,pe]),R=p=>{const{tls:V,startTls:ce}=Be(p);f.setValue("imapTls",V),f.setValue("imapStartTls",ce);const se=f.getValues("imapPort");(se===993||se===143)&&f.setValue("imapPort",p==="tls"?993:143)},le=p=>{const{tls:V,startTls:ce}=Be(p);f.setValue("smtpTls",V),f.setValue("smtpStartTls",ce);const se=f.getValues("smtpPort");if(se===465||se===587||se===25){const we=p==="tls"?465:p==="starttls"?587:25;f.setValue("smtpPort",we)}},Z=()=>{const p=f.getValues("imapHost");f.setValue("smtpHost",ar(p)),f.setValue("smtpTls",!1),f.setValue("smtpStartTls",!0),f.setValue("smtpPort",587)},ge=p=>{_(p),H(!1);const V=Dt(p);if(!V)return;const ce=Be(V.imap.security);f.setValue("imapHost",V.imap.host),f.setValue("imapPort",V.imap.port),f.setValue("imapTls",ce.tls),f.setValue("imapStartTls",ce.startTls);const se=Be(V.smtp.security);f.setValue("smtpHost",V.smtp.host),f.setValue("smtpPort",V.smtp.port),f.setValue("smtpTls",se.tls),f.setValue("smtpStartTls",se.startTls);const fe=f.getValues("email").trim(),we=f.getValues("username")?.trim();fe&&!we&&f.setValue("username",fe)},Ae=M?.passwordHelp.text,De=Ct(b.data?.imapError,Ae),He=Ct(b.data?.smtpError,Ae);return(t?Kr(t):!1)&&d?r.jsx(Ft,{isOpen:e,onClose:s,title:"Edit Account",footer:r.jsx(ee,{type:"button",variant:"secondary",onClick:s,children:"Close"}),children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Microsoft 365 Account"}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"rounded-md border border-line bg-surface-sunken px-3 py-2.5 text-sm text-fg-muted",children:[r.jsx("span",{className:"block text-2xs font-medium uppercase tracking-wider text-fg-subtle mb-1",children:"Email"}),r.jsx("span",{className:"text-fg",children:t?.email})]}),r.jsxs("div",{className:"rounded-md border border-line bg-surface-sunken px-3 py-2.5 text-sm text-fg-muted",children:[r.jsx("span",{className:"block text-2xs font-medium uppercase tracking-wider text-fg-subtle mb-1",children:"Authentication"}),r.jsx("span",{className:"text-fg",children:"Microsoft OAuth (XOAUTH2)"})]}),r.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&&r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Signature"}),r.jsx("div",{className:"space-y-3",children:r.jsxs("div",{children:[r.jsx("label",{htmlFor:"email-sig-view",className:"text-sm font-medium mb-1.5 block",children:"Email Signature"}),r.jsx("textarea",{id:"email-sig-view",value:K,onChange:p=>te(p.target.value),onBlur:w,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..."}),r.jsx("p",{className:"text-xs text-fg-muted mt-1",children:oe?"Saving signature...":"This signature will be appended to new emails."})]})})]}),d&&$]})}):r.jsx(Ft,{isOpen:e,onClose:s,title:d?"Edit Account":"Add Account",footer:r.jsxs(r.Fragment,{children:[r.jsx(ee,{type:"button",variant:"secondary",onClick:s,children:"Cancel"}),r.jsx(ee,{type:"submit",form:"account-form",variant:"primary",disabled:ne,children:ne?"Saving...":"Save Account"})]}),children:r.jsxs("form",{id:"account-form",onSubmit:T,className:"space-y-6",children:[r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Account Information"}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-provider",className:"text-sm font-medium mb-1.5 block",children:"Provider"}),r.jsxs(Ms,{id:"account-provider",value:j,onChange:p=>ge(p.target.value),children:[r.jsx("option",{value:"",children:"Custom / other"}),er.map(p=>r.jsx("option",{value:p.id,children:p.label},p.id))]}),r.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."})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-email",className:"text-sm font-medium mb-1.5 block",children:"Email Address"}),r.jsx(ve,{id:"account-email",...f.register("email"),placeholder:"alice@example.com"}),f.formState.errors.email&&r.jsx("p",{className:"text-sm text-danger mt-1",children:f.formState.errors.email.message})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-displayName",className:"text-sm font-medium mb-1.5 block",children:"Display name (optional)"}),r.jsx(ve,{id:"account-displayName",...f.register("displayName"),placeholder:"Alice"}),r.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."})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-username",className:"text-sm font-medium mb-1.5 block",children:"Username"}),r.jsx(ve,{id:"account-username",...f.register("username"),placeholder:"Same as email if empty"})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-password",className:"text-sm font-medium mb-1.5 block",children:"Password"}),r.jsx(Tt,{id:"account-password",...f.register("password",{onChange:()=>u(!0)}),onFocus:()=>{d&&!n&&(f.setValue("password",""),u(!0))},placeholder:d?"Leave empty to keep current":""}),f.formState.errors.password&&r.jsx("p",{className:"text-sm text-danger mt-1",children:f.formState.errors.password.message}),M&&r.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[M.passwordHelp.text," ",r.jsx("a",{href:M.passwordHelp.url,target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline",children:"Get an app password"})]})]})]})]}),r.jsxs("section",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider",children:"Incoming Mail (IMAP)"}),M&&r.jsx("button",{type:"button",onClick:()=>H(p=>!p),className:"text-xs text-fg-muted hover:text-fg transition-colors",children:E?"Use preset settings":"Advanced"})]}),O&&r.jsxs("p",{className:"text-xs text-fg-muted mb-3",children:["Server settings are pre-filled for ",M?.label," and locked. Choose Advanced to edit them by hand."]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"imap-host",className:"text-sm font-medium mb-1.5 block",children:"Server"}),r.jsx(ve,{id:"imap-host",...f.register("imapHost"),readOnly:O,placeholder:"imap.example.com"}),f.formState.errors.imapHost&&r.jsx("p",{className:"text-sm text-danger mt-1",children:f.formState.errors.imapHost.message})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"imap-port",className:"text-sm font-medium mb-1.5 block",children:"Port"}),r.jsx(ve,{id:"imap-port",...f.register("imapPort"),readOnly:O,type:"number"})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-sm font-medium mb-1.5 block",children:"Security"}),r.jsxs("div",{className:"space-y-1.5 mt-2",children:[r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:O,checked:f.watch("imapTls"),onChange:()=>R("tls")}),"TLS (Port 993)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:O,checked:!f.watch("imapTls")&&f.watch("imapStartTls"),onChange:()=>R("starttls")}),"STARTTLS (Port 143)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:O,checked:!f.watch("imapTls")&&!f.watch("imapStartTls"),onChange:()=>R("none")}),"None (Unencrypted)"]})]})]})]}),r.jsx(ee,{type:"button",variant:"secondary",onClick:W,disabled:b.isPending,className:"w-full",icon:b.isPending?r.jsx(at,{className:"size-4 animate-spin"}):void 0,children:b.isPending?"Testing...":"Test IMAP Connection"}),b.data&&r.jsxs("div",{className:_t("p-2 rounded-md text-sm",b.data.imapSuccess?"bg-positive/10 text-positive":"bg-danger-soft text-danger"),children:[b.data.imapSuccess?r.jsx(At,{className:"inline size-4 mr-1"}):r.jsx(Ve,{className:"inline size-4 mr-1"}),b.data.imapSuccess?"IMAP Connected":De]})]})]}),r.jsxs("section",{ref:A,"data-testid":"smtp-section",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider",children:"Outgoing Mail (SMTP)"}),!O&&r.jsx("button",{type:"button",onClick:Z,disabled:!f.watch("imapHost"),className:"text-xs text-fg-muted hover:text-fg transition-colors disabled:opacity-50",children:"Pre-fill from IMAP"})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"smtp-host",className:"text-sm font-medium mb-1.5 block",children:"Server"}),r.jsx(ve,{id:"smtp-host",...f.register("smtpHost"),readOnly:O,placeholder:"smtp.example.com"})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"smtp-port",className:"text-sm font-medium mb-1.5 block",children:"Port"}),r.jsx(ve,{id:"smtp-port",...f.register("smtpPort"),readOnly:O,type:"number"})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-sm font-medium mb-1.5 block",children:"Security"}),r.jsxs("div",{className:"space-y-1.5 mt-2",children:[r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:O,checked:f.watch("smtpTls")===!0,onChange:()=>le("tls")}),"TLS (Port 465)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:O,checked:!f.watch("smtpTls")&&f.watch("smtpStartTls")===!0,onChange:()=>le("starttls")}),"STARTTLS (Port 587)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:O,checked:!f.watch("smtpTls")&&!f.watch("smtpStartTls"),onChange:()=>le("none")}),"None (Unencrypted)"]})]})]})]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"checkbox",...f.register("useDifferentSmtpCreds")}),"Use different credentials for SMTP"]}),f.watch("useDifferentSmtpCreds")&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"smtp-username",className:"text-sm font-medium mb-1.5 block",children:"SMTP Username"}),r.jsx(ve,{id:"smtp-username",...f.register("smtpUsername")})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"smtp-password",className:"text-sm font-medium mb-1.5 block",children:"SMTP Password"}),r.jsx(Tt,{id:"smtp-password",...f.register("smtpPassword")})]})]}),r.jsx(ee,{type:"button",variant:"secondary",onClick:I,disabled:b.isPending||!f.watch("smtpHost"),className:"w-full",icon:b.isPending?r.jsx(at,{className:"size-4 animate-spin"}):void 0,children:b.isPending?"Testing...":"Test SMTP Connection"}),b.data?.smtpSuccess!==void 0&&r.jsxs("div",{className:_t("p-2 rounded-md text-sm",b.data.smtpSuccess?"bg-positive/10 text-positive":"bg-danger-soft text-danger"),children:[b.data.smtpSuccess?r.jsx(At,{className:"inline size-4 mr-1"}):r.jsx(Ve,{className:"inline size-4 mr-1"}),b.data.smtpSuccess?"SMTP Connected":He]})]})]}),d&&r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Signature"}),r.jsx("div",{className:"space-y-3",children:r.jsxs("div",{children:[r.jsx("label",{htmlFor:"email-sig-edit",className:"text-sm font-medium mb-1.5 block",children:"Email Signature"}),r.jsx("textarea",{id:"email-sig-edit",value:K,onChange:p=>te(p.target.value),onBlur:w,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..."}),r.jsx("p",{className:"text-xs text-fg-muted mt-1",children:oe?"Saving signature...":"This signature will be appended to new emails."})]})})]}),d&&$]})})};function Qt({open:e,onClose:s,accountEmail:t,signOut:i}){const[o,d]=C.useState(""),[n,u]=C.useState(!1),[j,_]=C.useState(!1),E=Se({...Hs(),onSuccess:()=>{_(!0),setTimeout(()=>i(),2e3)}}),H=Se(zs()),M=()=>{E.isPending||(d(""),u(!1),_(!1),E.reset(),H.reset(),s())},O=()=>{if(o.trim().toLowerCase()!==t.toLowerCase()){u(!0);return}u(!1),E.mutate({body:{confirmEmail:o.trim()}})};return r.jsxs(ss,{open:e,onClose:M,title:"Delete your Remit account",children:[r.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[r.jsx(dt,{className:"size-4 shrink-0 text-danger"}),r.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:"Delete your Remit account"}),r.jsx(ee,{variant:"ghost",size:"sm",icon:r.jsx(Ve,{className:"size-3.5"}),onClick:M,"aria-label":"Cancel"})]}),j?r.jsxs("div",{className:"px-5 py-6 text-sm text-fg-muted",children:[r.jsx("p",{className:"font-medium text-fg",children:"Account deletion scheduled."}),r.jsx("p",{className:"mt-1",children:"Your data will be erased shortly. Signing you out…"})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"space-y-4 px-5 py-4 text-sm text-fg-muted",children:[r.jsx("p",{children:"This permanently erases everything Remit holds for you:"}),r.jsxs("ul",{className:"space-y-1.5 text-xs",children:[r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"text-danger",children:"•"}),"All connected accounts disconnected and access tokens revoked."]}),r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"text-danger",children:"•"}),"Synced mail cache and search index."]}),r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"text-danger",children:"•"}),"AI history and insights."]}),r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"text-danger",children:"•"}),"Preferences and rules."]})]}),r.jsxs("div",{className:"rounded-sm border border-line bg-surface-sunken px-3 py-2 text-xs",children:[r.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."]}),r.jsxs("div",{className:"text-xs",children:[r.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:[r.jsx(ir,{className:"size-3.5"}),H.isPending?"Requesting export…":"Export my data first"]}),H.isSuccess&&r.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&&r.jsx("p",{className:"mt-1.5 text-danger",role:"alert",children:"Couldn't start the export. Please try again."})]}),r.jsxs("div",{children:[r.jsxs("label",{htmlFor:"confirm-remit-email",className:"mb-1 block text-xs font-medium text-fg",children:["Type"," ",r.jsx("span",{className:"font-mono text-fg-muted",children:t})," ","to confirm"]}),r.jsx(ve,{id:"confirm-remit-email",type:"email",placeholder:t,value:o,onChange:A=>{d(A.target.value),n&&u(!1),E.isError&&E.reset()},autoComplete:"off"}),n&&r.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."}),E.isError&&r.jsx("p",{className:"mt-1.5 text-xs text-danger",role:"alert",children:E.error instanceof Error?E.error.message:"Something went wrong. Please try again."})]})]}),r.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[r.jsx(ee,{variant:"secondary",size:"sm",onClick:M,children:"Cancel"}),r.jsx(ee,{variant:"danger",size:"sm",onClick:O,"aria-busy":E.isPending,children:E.isPending?"Deleting…":"Delete everything"})]})]})]})}function Xr(e){const{Account:s}=Us();return r.jsx(s,{fallback:r.jsx(Qt,{...e,accountEmail:"",signOut:()=>{}}),children:({email:t,signOut:i})=>r.jsx(Qt,{...e,accountEmail:t??"",signOut:i})})}function Jr(){const[e,s]=C.useState(!1);return r.jsxs("section",{className:"mt-8 border-t border-line pt-6",children:[r.jsx(dr,{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:r.jsx(ee,{variant:"danger",size:"sm",onClick:()=>s(!0),children:"Delete your Remit account"})}),r.jsx(Xr,{open:e,onClose:()=>s(!1)})]})}function ea(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 ta(e){const s=e.split("@")[0]??"";return s?s.split(/[._-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" "):e}function sa(e){const s=e.displayName?.trim();return s||ta(e.email)}function ra(e){if(!e.lastSyncAt)return"never synced";const s=or(e.lastSyncAt);return s?`synced ${s}`:"never synced"}function Zt(e){return e.muted?.value?"muted":e.lastError?"error":e.connectionState==="authenticated"?"healthy":"error"}function Xt(e){return e.connectionState==="reauth_required"}const aa=r.jsxs("div",{className:"space-y-3",children:[r.jsxs("p",{children:[r.jsx("strong",{className:"text-fg",children:"Sync health"})," shows the IMAP connection state and the last successful sync per account."]}),r.jsxs("p",{children:[r.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."]}),r.jsxs("p",{children:[r.jsx("strong",{className:"text-fg",children:"Muted"})," accounts keep syncing but stay out of the daily brief and unified counts."]})]}),ia=()=>r.jsx("div",{className:"space-y-3",role:"status","aria-busy":"true","aria-label":"Loading accounts",children:["skeleton-0","skeleton-1"].map(e=>r.jsx("div",{className:"rounded-sm border border-line bg-surface animate-pulse p-4",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"size-10 rounded-full bg-surface-sunken"}),r.jsxs("div",{className:"flex-1 space-y-2",children:[r.jsx("div",{className:"h-4 bg-surface-sunken rounded w-1/3"}),r.jsx("div",{className:"h-3 bg-surface-sunken rounded w-2/3"})]})]})},e))});function ya(){const e=Pt.useSearch(),s=Bs({from:Pt.fullPath}),[t,i]=C.useState(!0),[o,d]=C.useState(!1),[n,u]=C.useState(!1),[j,_]=C.useState(null),[E,H]=C.useState(!1),[M,O]=C.useState(null),[A,f]=C.useState(null),[b,ae]=C.useState(null),[N,W]=C.useState(null),I=ut(),{data:T,isPending:ne,isError:re,error:pe,refetch:oe}=Jt(es());C.useEffect(()=>{e.editAccountId&&(_(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]),C.useEffect(()=>{e.connected&&(f("Account connected successfully."),_(e.connected),I.invalidateQueries({queryKey:Te()}),s({search:{connected:void 0,oauthError:void 0,editAccountId:void 0,focusSmtp:void 0},replace:!0}))},[e.connected,s,I]),C.useEffect(()=>{e.oauthError&&(ae(ea(e.oauthError)),W(null),s({search:{oauthError:void 0,connected:void 0,editAccountId:void 0,focusSmtp:void 0},replace:!0}))},[e.oauthError,s]),tr(N!==null,()=>{I.invalidateQueries({queryKey:Te()})}),C.useEffect(()=>{if(!N||!T)return;const w=T.accounts.find(R=>R.accountId===N);(!w||!Xt(w))&&W(null)},[T,N]);const K=Se({...qs(),onSuccess:w=>{window.location.assign(w.authorizationUrl)},onError:w=>{ae(w instanceof Error?w.message:"Failed to start reconnect"),W(null)}}),te=Se({...$s(),onSuccess:()=>{I.invalidateQueries({queryKey:Te()}),O(null)}}),P=T?.accounts.find(w=>w.accountId===M),k=T?.accounts.find(w=>w.accountId===j),D=()=>{d(!1),u(!1),_(null),H(!1)},$=w=>{const R=Gs[w];R&&s({to:R})};return r.jsxs(Xs,{items:Ws,activeId:"accounts",title:"Accounts",description:"Every account keeps syncing — muted ones just stay out of unified views.",help:aa,helpOpen:t,onToggleHelp:()=>i(w=>!w),onSelect:$,onBackToMail:()=>{s({to:"/mail"})},children:[A&&r.jsx(kt,{tone:"success",variant:"soft","data-testid":"oauth-success-banner",onDismiss:()=>f(null),children:A}),b&&r.jsx(kt,{tone:"danger",variant:"soft","data-testid":"oauth-error-banner",onDismiss:()=>ae(null),children:b}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Ks,{tone:"neutral",children:ne||re?"accounts":`${T.accounts.length} ${T.accounts.length===1?"account":"accounts"}`}),r.jsx(ee,{variant:"primary",size:"sm",icon:r.jsx(Vt,{className:"size-3.5"}),onClick:()=>u(!0),children:"Add account"})]}),ne?r.jsx(ia,{}):re?r.jsx(nr,{title:"Couldn't load accounts",error:pe,onRetry:()=>{oe()}}):T.accounts.length===0?r.jsxs("div",{className:"py-12 text-sm text-fg-muted","data-testid":"accounts-empty",children:[r.jsx("p",{className:"mb-3",children:"No accounts configured."}),r.jsx(ee,{variant:"primary",size:"sm",icon:r.jsx(Vt,{className:"size-3.5"}),onClick:()=>u(!0),children:"Add your first account"})]}):r.jsx("div",{className:"space-y-3",children:T.accounts.map(w=>{const R=Xt(w),le=w.authType==="oauthMicrosoft",Z=N===w.accountId&&K.isPending,ge=R&&le?{label:"Reconnect",variant:"secondary",busy:Z,busyLabel:"Redirecting…",onClick:()=>{W(w.accountId),K.mutate({body:{email:w.email}})}}:Zt(w)==="error"?{label:"Reconnect",variant:"secondary",onClick:()=>_(w.accountId)}:{label:"Manage",variant:"ghost",onClick:()=>_(w.accountId)},Ae=r.jsx(Zs,{actions:[ge],destructive:{label:"Delete account",iconOnly:!0,icon:r.jsx(Ys,{className:"size-3.5"}),onClick:()=>O(w.accountId)}});return r.jsx(Js,{label:sa(w),email:w.email,connector:le?"Microsoft 365":"IMAP",syncLabel:ra(w),state:Zt(w),errorDetail:R?"Re-authentication required":w.lastError,trailing:Ae},w.accountId)})}),n&&r.jsx("div",{className:"fixed inset-0 z-40 overflow-auto bg-canvas",children:r.jsx(sr,{skipWelcome:!0,onComplete:()=>{u(!1),I.invalidateQueries({queryKey:Te()})},onCancel:()=>u(!1)})}),r.jsx(Zr,{isOpen:o||!!j,account:k,focusSmtp:E,onClose:D}),r.jsxs(ss,{open:!!M,onClose:()=>O(null),title:"Delete account",children:[r.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[r.jsx(dt,{className:"size-4 shrink-0 text-danger"}),r.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:"Delete account"}),r.jsx(ee,{variant:"ghost",size:"sm",icon:r.jsx(Ve,{className:"size-3.5"}),onClick:()=>O(null),"aria-label":"Cancel"})]}),r.jsxs("div",{className:"space-y-3 px-5 py-4 text-sm text-fg-muted",children:[r.jsx("p",{className:"text-center text-lg font-medium text-fg",children:"Are you sure?"}),P&&r.jsx("p",{className:"text-center",children:P.email}),r.jsxs("ul",{className:"list-inside list-disc space-y-1",children:[r.jsx("li",{children:"Remove the account from your settings"}),r.jsx("li",{children:"Stop syncing mail for this account"}),r.jsx("li",{children:"Delete all associated data (within 24 hours)"})]})]}),r.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[r.jsx(ee,{variant:"secondary",size:"sm",onClick:()=>O(null),children:"Cancel"}),r.jsx(ee,{variant:"danger",size:"sm","aria-busy":te.isPending,icon:te.isPending?r.jsx(at,{className:"size-3.5 animate-spin"}):void 0,onClick:()=>{te.isPending||M&&te.mutate({path:{accountId:M}})},children:te.isPending?"Deleting…":"Delete account"})]})]}),r.jsx(Jr,{})]})}export{ya as component,ea as mapOauthError};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as v,j as e,D as C,cp as y,B as n,cq as f,r as g,G as m,N as z,L as j,e as R,cr as p,d as T,cs as S,bY as A,ct as I,cu as D,cv as L,au as M,cl as V,cn as _}from"./index-DAzmnDmQ.js";import{S as B}from"./settings-screen-BukG_Ts5.js";import{D as b}from"./download-C4twhQsf.js";import{R as N,C as U,S as Y}from"./shield-check-AWXIQWep.js";import{C as E}from"./circle-check-BwajEOAH.js";import"./avatar-no7z5maH.js";const H=v("CloudOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193",key:"yfwify"}],["path",{d:"M21.532 16.5A4.5 4.5 0 0 0 17.5 10h-1.79A7.008 7.008 0 0 0 10 5.07",key:"jlfiyv"}]]);const k=v("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]),O=["Remit restarts. Mail stops loading for about a minute and this page will lose its connection while that happens.","Nothing is sent, deleted or moved. Your mail stays at your provider.","If the new version does not come back up, the version you are running now is restored automatically."];function P({open:s,currentVersion:t,release:a,appliesSchemaMigration:r=!1,onClose:i,onConfirm:c}){return s?e.jsx(C,{open:!0,onClose:i,title:`Install Remit ${a.version}`,children:e.jsxs("div",{className:"flex max-h-[80vh] flex-col",children:[e.jsxs("header",{className:"space-y-1 border-b border-line px-4 py-3",children:[e.jsxs("h3",{className:"text-sm font-semibold text-fg",children:["Install Remit ",a.version,"?"]}),e.jsxs("p",{className:"text-xs text-fg-muted",children:["You are on ",t,". ",a.version," was released"," ",y(a.releasedAt),"."]})]}),e.jsxs("div",{className:"flex-1 space-y-3 overflow-auto px-4 py-3",children:[e.jsx("p",{className:"text-sm text-fg-muted",children:a.summary}),e.jsxs("ul",{className:"space-y-2",children:[O.map(d=>e.jsxs("li",{className:"flex gap-2 text-sm text-fg-muted",children:[e.jsx("span",{className:"mt-1.5 size-1.5 shrink-0 rounded-full bg-fg-subtle"}),e.jsx("span",{children:d})]},d)),r&&e.jsxs("li",{className:"flex gap-2 text-sm text-fg-muted",children:[e.jsx("span",{className:"mt-1.5 size-1.5 shrink-0 rounded-full bg-fg-subtle"}),e.jsx("span",{children:"This version updates the database while Remit is offline. The step forward cannot be undone by hand, but a failed start is still rolled back to the version and data you have now."})]})]}),e.jsx("p",{className:"text-xs text-fg-subtle",children:"Good moment for this: when you are not waiting on a message."})]}),e.jsxs("footer",{className:"flex flex-wrap items-center justify-end gap-2 border-t border-line px-4 py-3",children:[e.jsx(n,{variant:"ghost",size:"sm",onClick:i,children:"Not now"}),e.jsx(f,{variant:"secondary",size:"sm",external:!0,href:a.releaseNotesUrl,icon:e.jsx(k,{className:"size-3.5"}),children:"Release notes"}),e.jsx(n,{size:"sm",icon:e.jsx(b,{className:"size-3.5"}),onClick:c,children:"Install and restart"})]})]})}):null}function l({children:s,tone:t}){return e.jsx("div",{className:T("rounded-sm border bg-surface px-row-inset py-3",t==="danger"?"border-danger/50":"border-line"),children:s})}function q({state:s,onCheck:t,onInstall:a,onDismissResult:r,now:i=Date.now()}){const[c,d]=g.useState(null),h=s.status==="checking",o=s.status==="available",x=()=>{if(h){d("Already checking. The result appears here in a moment.");return}d(null),t()},u=()=>{if(!o&&s.status!=="rolledBack"&&s.status!=="abandoned"){d("There is no update to install. Check for updates first — if one is found it appears here.");return}d(null),a()},w=(()=>{switch(s.status){case"upToDate":return e.jsx(l,{children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(E,{className:"size-4 shrink-0 text-positive","aria-hidden":!0}),e.jsxs("p",{className:"text-sm text-fg",children:["Remit ",s.version," is the latest version.",e.jsxs("span",{className:"text-fg-subtle",children:[" ","Checked ",p(s.checkedAt,i),"."]})]})]}),e.jsx(n,{variant:"secondary",size:"sm",className:"shrink-0",onClick:x,children:"Check again"})]})});case"checking":return e.jsx(l,{children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(j,{className:"size-4 shrink-0 animate-spin text-fg-subtle","aria-hidden":!0}),e.jsxs("p",{className:"text-sm text-fg-muted",children:["Looking for a newer version. You are on ",s.version,"."]})]}),e.jsx(n,{variant:"secondary",size:"sm",className:"shrink-0",onClick:x,children:"Check again"})]})});case"neverChecked":return e.jsx(l,{children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[e.jsx(U,{className:"mt-0.5 size-4 shrink-0 text-fg-subtle","aria-hidden":!0}),e.jsxs("p",{className:"text-sm text-fg-muted",children:["No update check has run yet. Remit checks for updates on its own in the background.",s.lastCheckedAt!==void 0&&e.jsxs("span",{className:"text-fg-subtle",children:[" ","Last checked"," ",p(s.lastCheckedAt,i),"."]})]})]}),e.jsx(n,{variant:"secondary",size:"sm",className:"shrink-0",onClick:x,children:"Check now"})]})});case"checkFailed":return e.jsx(l,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(H,{className:"mt-0.5 size-4 shrink-0 text-fg-subtle","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("p",{className:"text-sm text-fg",children:"Could not reach the update source."}),e.jsx("p",{className:"text-xs text-fg-muted",children:s.reason}),e.jsxs("p",{className:"text-xs text-fg-subtle",children:["You are still on ",s.version," and it keeps working.",s.lastCheckedAt!==void 0&&e.jsxs(e.Fragment,{children:[" ","Last successful check"," ",p(s.lastCheckedAt,i),"."]})]})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(n,{variant:"secondary",size:"sm",onClick:x,children:"Try again"})})]})});case"available":return e.jsx(l,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"text-sm font-semibold text-fg",children:["Remit ",s.release.version]}),e.jsx(R,{tone:"accent",children:"update available"}),e.jsxs("span",{className:"text-2xs text-fg-subtle",children:["released ",y(s.release.releasedAt)," · you are on ",s.version]})]}),e.jsx("p",{className:"text-sm text-fg-muted",children:s.release.summary}),e.jsx("p",{className:"text-xs text-fg-subtle",children:"Installing restarts Remit, so mail stops loading for about a minute. If the new version does not come back up, the one you are running now is restored on its own."}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(n,{size:"sm",icon:e.jsx(b,{className:"size-3.5"}),onClick:u,children:["Install ",s.release.version]}),e.jsx(f,{variant:"secondary",size:"sm",external:!0,href:s.release.releaseNotesUrl,icon:e.jsx(k,{className:"size-3.5"}),children:"Release notes"})]})]})});case"applying":return e.jsx(l,{children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(j,{className:"size-4 shrink-0 animate-spin text-accent-2","aria-hidden":!0}),e.jsxs("p",{className:"text-sm text-fg-muted",children:["Installing Remit ",s.target,". The restart screen has the details."]})]})});case"succeeded":return e.jsx(z,{tone:"success",onDismiss:r,children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"font-semibold",children:["Updated to Remit ",s.version,"."]}),e.jsxs("p",{children:["You were on ",s.previousVersion,"."," ",e.jsx("a",{href:s.releaseNotesUrl,target:"_blank",rel:"noopener noreferrer",className:"underline",children:"See what changed"}),"."]})]})});case"rolledBack":return e.jsx(l,{tone:"danger",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(m,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("p",{className:"text-sm font-semibold text-fg",children:["Remit ",s.attemptedVersion," did not start. Remit reports that it put ",s.version," back."]}),e.jsxs("p",{className:"text-sm text-fg-muted",children:["You are running ",s.version," again. A failed update can still have changed things on the way — the log below is the only account of what it got as far as doing."]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-fg-subtle",children:"What Remit reported as the failure"}),e.jsx("code",{className:"block rounded-xs bg-danger-soft px-2 py-1 text-2xs text-danger",children:s.reason})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-fg-subtle",children:"Read the full log before trying again:"}),e.jsx("code",{className:"block rounded-xs bg-surface-sunken px-2 py-1 text-2xs text-fg-muted",children:s.logsCommand})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(n,{variant:"secondary",size:"sm",icon:e.jsx(N,{className:"size-3.5"}),onClick:u,children:["Try ",s.attemptedVersion," again"]}),e.jsxs(n,{variant:"ghost",size:"sm",onClick:r,children:["Stay on ",s.version]})]})]})});case"unreachable":return e.jsx(l,{tone:"danger",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(m,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("p",{className:"text-sm font-semibold text-fg",children:["Installing ",s.attemptedVersion," left the server unreachable."]}),e.jsx("p",{className:"text-sm text-fg-muted",children:"Remit has answered again since, but nothing here can say what happened during the silence."})]})]}),e.jsx("code",{className:"block rounded-xs bg-surface-sunken px-2 py-1 text-2xs text-fg-muted",children:s.logsCommand}),e.jsx("div",{className:"flex justify-end",children:e.jsx(n,{variant:"ghost",size:"sm",onClick:r,children:"Dismiss"})})]})});case"rollbackFailed":return e.jsx(l,{tone:"danger",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(m,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("p",{className:"text-sm font-semibold text-fg",children:["Remit ",s.attemptedVersion," did not start, and Remit could not put ",s.previousVersion," back."]}),e.jsx("p",{className:"text-sm text-fg-muted",children:"This is the one outcome Remit cannot resolve on its own. The server is in a half-changed state and needs you at a shell. The log below is the only account of where it stopped."})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-fg-subtle",children:"What Remit reported as the failure"}),e.jsx("code",{className:"block rounded-xs bg-danger-soft px-2 py-1 text-2xs text-danger",children:s.reason})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-fg-subtle",children:"Read the full log on the server:"}),e.jsx("code",{className:"block rounded-xs bg-surface-sunken px-2 py-1 text-2xs text-fg-muted",children:s.logsCommand})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(n,{variant:"ghost",size:"sm",onClick:r,children:"Dismiss"})})]})});case"abandoned":return e.jsx(l,{tone:"danger",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(m,{className:"mt-0.5 size-4 shrink-0 text-fg-subtle","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("p",{className:"text-sm font-semibold text-fg",children:["Remit ",s.attemptedVersion," was not installed. Nothing changed."]}),e.jsxs("p",{className:"text-sm text-fg-muted",children:["The update stopped before it altered anything. You are still running ",s.version,"."]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-fg-subtle",children:"What Remit reported"}),e.jsx("code",{className:"block rounded-xs bg-surface-sunken px-2 py-1 text-2xs text-fg-muted",children:s.reason})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-fg-subtle",children:"Read the full log before trying again:"}),e.jsx("code",{className:"block rounded-xs bg-surface-sunken px-2 py-1 text-2xs text-fg-muted",children:s.logsCommand})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(n,{variant:"secondary",size:"sm",icon:e.jsx(N,{className:"size-3.5"}),onClick:u,children:["Try ",s.attemptedVersion," again"]}),e.jsxs(n,{variant:"ghost",size:"sm",onClick:r,children:["Stay on ",s.version]})]})]})});default:return s}})();return e.jsxs("section",{className:"space-y-3",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Updates"}),e.jsx("p",{className:"text-xs text-fg-muted",children:"This Remit runs on your own server, so it updates when you say so. Your mail lives at your provider and is never touched by an update."})]}),w,c&&e.jsx("p",{role:"status",className:"text-xs text-fg-muted",children:c})]})}function G(){const{surface:s,release:t,currentVersion:a,appliesSchemaMigration:r,onCheck:i,install:c,onDismissResult:d}=S(),[h,o]=g.useState(!1);return s.status!=="ready"?null:e.jsxs(e.Fragment,{children:[e.jsx(q,{state:s.section,onCheck:i,onInstall:()=>o(!0),onDismissResult:d}),t&&a&&e.jsx(P,{open:h,currentVersion:a,release:t,appliesSchemaMigration:r,onClose:()=>o(!1),onConfirm:()=>{o(!1),c(t.version)}})]})}function F(){return A().tlsMode!=="internal"?null:e.jsxs("div",{className:"border-t border-line pt-4 mt-4",children:[e.jsx("p",{className:"text-sm font-medium text-fg mb-1",children:"TLS root certificate"}),e.jsx("p",{className:"text-sm text-fg-muted mb-2",children:"This deployment signs its own certificate. Import it into the trust store of each device you browse from, and the browser warning stops for good."}),e.jsx(f,{href:"/tls-root-ca.crt",download:!0,variant:"secondary",size:"sm",icon:e.jsx(Y,{className:"size-3.5"}),children:"Download root certificate"})]})}function W(s){try{return new Date(s).toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return s}}function $({sha:s=D,commitUrl:t=I,buildTime:a=L}){return e.jsxs("p",{className:"text-xs text-fg-subtle",children:["Version"," ",t?e.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"font-mono hover:text-fg-muted hover:underline",children:s}):e.jsx("span",{className:"font-mono",children:s})," · ",e.jsxs("span",{children:["Built ",W(a)]})]})}const J=e.jsx("div",{className:"space-y-3",children:e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Notification rules"}),", data export, and per-account diagnostics are coming in a future release."]})});function te(){const s=M(),[t,a]=g.useState(!0),r=i=>{const c=_[i];c&&s({to:c})};return e.jsxs(B,{items:V,activeId:"advanced",title:"Advanced",description:"Notification rules, export, and diagnostics.",help:J,helpOpen:t,onToggleHelp:()=>a(i=>!i),onSelect:r,onBackToMail:()=>{s({to:"/mail"})},children:[e.jsx(G,{}),e.jsx("p",{className:"text-sm text-fg-muted",children:"Notification rules, data export, and raw sync diagnostics are coming in a future release."}),e.jsx(F,{}),e.jsxs("div",{className:"border-t border-line pt-4 mt-4",children:[e.jsx("p",{className:"text-sm font-medium text-fg mb-1",children:"About"}),e.jsx($,{})]})]})}export{te as component};
|
|
1
|
+
import{a as v,j as e,D as C,cr as y,B as n,cs as f,r as g,G as m,N as z,L as j,e as R,ct as p,d as T,cu as S,b_ as A,cv as I,cw as _,cx as D,au as L,cn as M,cp as V}from"./index-xOALrEh8.js";import{S as B}from"./settings-screen-C7xmJsXG.js";import{D as b}from"./download-Bg6cLSAV.js";import{R as N,C as U,S as E}from"./shield-check-CdES_QdC.js";import{C as H}from"./circle-check-BM6iE_RP.js";import"./avatar-Ci3CMhdo.js";const Y=v("CloudOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193",key:"yfwify"}],["path",{d:"M21.532 16.5A4.5 4.5 0 0 0 17.5 10h-1.79A7.008 7.008 0 0 0 10 5.07",key:"jlfiyv"}]]);const k=v("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]),O=["Remit restarts. Mail stops loading for about a minute and this page will lose its connection while that happens.","Nothing is sent, deleted or moved. Your mail stays at your provider.","If the new version does not come back up, the version you are running now is restored automatically."];function P({open:s,currentVersion:t,release:a,appliesSchemaMigration:r=!1,onClose:i,onConfirm:c}){return s?e.jsx(C,{open:!0,onClose:i,title:`Install Remit ${a.version}`,children:e.jsxs("div",{className:"flex max-h-[80vh] flex-col",children:[e.jsxs("header",{className:"space-y-1 border-b border-line px-4 py-3",children:[e.jsxs("h3",{className:"text-sm font-semibold text-fg",children:["Install Remit ",a.version,"?"]}),e.jsxs("p",{className:"text-xs text-fg-muted",children:["You are on ",t,". ",a.version," was released"," ",y(a.releasedAt),"."]})]}),e.jsxs("div",{className:"flex-1 space-y-3 overflow-auto px-4 py-3",children:[e.jsx("p",{className:"text-sm text-fg-muted",children:a.summary}),e.jsxs("ul",{className:"space-y-2",children:[O.map(d=>e.jsxs("li",{className:"flex gap-2 text-sm text-fg-muted",children:[e.jsx("span",{className:"mt-1.5 size-1.5 shrink-0 rounded-full bg-fg-subtle"}),e.jsx("span",{children:d})]},d)),r&&e.jsxs("li",{className:"flex gap-2 text-sm text-fg-muted",children:[e.jsx("span",{className:"mt-1.5 size-1.5 shrink-0 rounded-full bg-fg-subtle"}),e.jsx("span",{children:"This version updates the database while Remit is offline. The step forward cannot be undone by hand, but a failed start is still rolled back to the version and data you have now."})]})]}),e.jsx("p",{className:"text-xs text-fg-subtle",children:"Good moment for this: when you are not waiting on a message."})]}),e.jsxs("footer",{className:"flex flex-wrap items-center justify-end gap-2 border-t border-line px-4 py-3",children:[e.jsx(n,{variant:"ghost",size:"sm",onClick:i,children:"Not now"}),e.jsx(f,{variant:"secondary",size:"sm",external:!0,href:a.releaseNotesUrl,icon:e.jsx(k,{className:"size-3.5"}),children:"Release notes"}),e.jsx(n,{size:"sm",icon:e.jsx(b,{className:"size-3.5"}),onClick:c,children:"Install and restart"})]})]})}):null}function l({children:s,tone:t}){return e.jsx("div",{className:T("rounded-sm border bg-surface px-row-inset py-3",t==="danger"?"border-danger/50":"border-line"),children:s})}function G({state:s,onCheck:t,onInstall:a,onDismissResult:r,now:i=Date.now()}){const[c,d]=g.useState(null),h=s.status==="checking",o=s.status==="available",x=()=>{if(h){d("Already checking. The result appears here in a moment.");return}d(null),t()},u=()=>{if(!o&&s.status!=="rolledBack"&&s.status!=="abandoned"){d("There is no update to install. Check for updates first — if one is found it appears here.");return}d(null),a()},w=(()=>{switch(s.status){case"upToDate":return e.jsx(l,{children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(H,{className:"size-4 shrink-0 text-positive","aria-hidden":!0}),e.jsxs("p",{className:"text-sm text-fg",children:["Remit ",s.version," is the latest version.",e.jsxs("span",{className:"text-fg-subtle",children:[" ","Checked ",p(s.checkedAt,i),"."]})]})]}),e.jsx(n,{variant:"secondary",size:"sm",className:"shrink-0",onClick:x,children:"Check again"})]})});case"checking":return e.jsx(l,{children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(j,{className:"size-4 shrink-0 animate-spin text-fg-subtle","aria-hidden":!0}),e.jsxs("p",{className:"text-sm text-fg-muted",children:["Looking for a newer version. You are on ",s.version,"."]})]}),e.jsx(n,{variant:"secondary",size:"sm",className:"shrink-0",onClick:x,children:"Check again"})]})});case"neverChecked":return e.jsx(l,{children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[e.jsx(U,{className:"mt-0.5 size-4 shrink-0 text-fg-subtle","aria-hidden":!0}),e.jsxs("p",{className:"text-sm text-fg-muted",children:["No update check has run yet. Remit checks for updates on its own in the background.",s.lastCheckedAt!==void 0&&e.jsxs("span",{className:"text-fg-subtle",children:[" ","Last checked"," ",p(s.lastCheckedAt,i),"."]})]})]}),e.jsx(n,{variant:"secondary",size:"sm",className:"shrink-0",onClick:x,children:"Check now"})]})});case"checkFailed":return e.jsx(l,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Y,{className:"mt-0.5 size-4 shrink-0 text-fg-subtle","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("p",{className:"text-sm text-fg",children:"Could not reach the update source."}),e.jsx("p",{className:"text-xs text-fg-muted",children:s.reason}),e.jsxs("p",{className:"text-xs text-fg-subtle",children:["You are still on ",s.version," and it keeps working.",s.lastCheckedAt!==void 0&&e.jsxs(e.Fragment,{children:[" ","Last successful check"," ",p(s.lastCheckedAt,i),"."]})]})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(n,{variant:"secondary",size:"sm",onClick:x,children:"Try again"})})]})});case"available":return e.jsx(l,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"text-sm font-semibold text-fg",children:["Remit ",s.release.version]}),e.jsx(R,{tone:"accent",children:"update available"}),e.jsxs("span",{className:"text-2xs text-fg-subtle",children:["released ",y(s.release.releasedAt)," · you are on ",s.version]})]}),e.jsx("p",{className:"text-sm text-fg-muted",children:s.release.summary}),e.jsx("p",{className:"text-xs text-fg-subtle",children:"Installing restarts Remit, so mail stops loading for about a minute. If the new version does not come back up, the one you are running now is restored on its own."}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(n,{size:"sm",icon:e.jsx(b,{className:"size-3.5"}),onClick:u,children:["Install ",s.release.version]}),e.jsx(f,{variant:"secondary",size:"sm",external:!0,href:s.release.releaseNotesUrl,icon:e.jsx(k,{className:"size-3.5"}),children:"Release notes"})]})]})});case"applying":return e.jsx(l,{children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(j,{className:"size-4 shrink-0 animate-spin text-accent-2","aria-hidden":!0}),e.jsxs("p",{className:"text-sm text-fg-muted",children:["Installing Remit ",s.target,". The restart screen has the details."]})]})});case"succeeded":return e.jsx(z,{tone:"success",onDismiss:r,children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"font-semibold",children:["Updated to Remit ",s.version,"."]}),e.jsxs("p",{children:["You were on ",s.previousVersion,"."," ",e.jsx("a",{href:s.releaseNotesUrl,target:"_blank",rel:"noopener noreferrer",className:"underline",children:"See what changed"}),"."]})]})});case"rolledBack":return e.jsx(l,{tone:"danger",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(m,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("p",{className:"text-sm font-semibold text-fg",children:["Remit ",s.attemptedVersion," did not start. Remit reports that it put ",s.version," back."]}),e.jsxs("p",{className:"text-sm text-fg-muted",children:["You are running ",s.version," again. A failed update can still have changed things on the way — the log below is the only account of what it got as far as doing."]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-fg-subtle",children:"What Remit reported as the failure"}),e.jsx("code",{className:"block rounded-xs bg-danger-soft px-2 py-1 text-2xs text-danger",children:s.reason})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-fg-subtle",children:"Read the full log before trying again:"}),e.jsx("code",{className:"block rounded-xs bg-surface-sunken px-2 py-1 text-2xs text-fg-muted",children:s.logsCommand})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(n,{variant:"secondary",size:"sm",icon:e.jsx(N,{className:"size-3.5"}),onClick:u,children:["Try ",s.attemptedVersion," again"]}),e.jsxs(n,{variant:"ghost",size:"sm",onClick:r,children:["Stay on ",s.version]})]})]})});case"unreachable":return e.jsx(l,{tone:"danger",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(m,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("p",{className:"text-sm font-semibold text-fg",children:["Installing ",s.attemptedVersion," left the server unreachable."]}),e.jsx("p",{className:"text-sm text-fg-muted",children:"Remit has answered again since, but nothing here can say what happened during the silence."})]})]}),e.jsx("code",{className:"block rounded-xs bg-surface-sunken px-2 py-1 text-2xs text-fg-muted",children:s.logsCommand}),e.jsx("div",{className:"flex justify-end",children:e.jsx(n,{variant:"ghost",size:"sm",onClick:r,children:"Dismiss"})})]})});case"rollbackFailed":return e.jsx(l,{tone:"danger",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(m,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("p",{className:"text-sm font-semibold text-fg",children:["Remit ",s.attemptedVersion," did not start, and Remit could not put ",s.previousVersion," back."]}),e.jsx("p",{className:"text-sm text-fg-muted",children:"This is the one outcome Remit cannot resolve on its own. The server is in a half-changed state and needs you at a shell. The log below is the only account of where it stopped."})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-fg-subtle",children:"What Remit reported as the failure"}),e.jsx("code",{className:"block rounded-xs bg-danger-soft px-2 py-1 text-2xs text-danger",children:s.reason})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-fg-subtle",children:"Read the full log on the server:"}),e.jsx("code",{className:"block rounded-xs bg-surface-sunken px-2 py-1 text-2xs text-fg-muted",children:s.logsCommand})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(n,{variant:"ghost",size:"sm",onClick:r,children:"Dismiss"})})]})});case"abandoned":return e.jsx(l,{tone:"danger",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(m,{className:"mt-0.5 size-4 shrink-0 text-fg-subtle","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("p",{className:"text-sm font-semibold text-fg",children:["Remit ",s.attemptedVersion," was not installed. Nothing changed."]}),e.jsxs("p",{className:"text-sm text-fg-muted",children:["The update stopped before it altered anything. You are still running ",s.version,"."]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-fg-subtle",children:"What Remit reported"}),e.jsx("code",{className:"block rounded-xs bg-surface-sunken px-2 py-1 text-2xs text-fg-muted",children:s.reason})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-fg-subtle",children:"Read the full log before trying again:"}),e.jsx("code",{className:"block rounded-xs bg-surface-sunken px-2 py-1 text-2xs text-fg-muted",children:s.logsCommand})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(n,{variant:"secondary",size:"sm",icon:e.jsx(N,{className:"size-3.5"}),onClick:u,children:["Try ",s.attemptedVersion," again"]}),e.jsxs(n,{variant:"ghost",size:"sm",onClick:r,children:["Stay on ",s.version]})]})]})});default:return s}})();return e.jsxs("section",{className:"space-y-3",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Updates"}),e.jsx("p",{className:"text-xs text-fg-muted",children:"This Remit runs on your own server, so it updates when you say so. Your mail lives at your provider and is never touched by an update."})]}),w,c&&e.jsx("p",{role:"status",className:"text-xs text-fg-muted",children:c})]})}function q(){const{surface:s,release:t,currentVersion:a,appliesSchemaMigration:r,onCheck:i,install:c,onDismissResult:d}=S(),[h,o]=g.useState(!1);return s.status!=="ready"?null:e.jsxs(e.Fragment,{children:[e.jsx(G,{state:s.section,onCheck:i,onInstall:()=>o(!0),onDismissResult:d}),t&&a&&e.jsx(P,{open:h,currentVersion:a,release:t,appliesSchemaMigration:r,onClose:()=>o(!1),onConfirm:()=>{o(!1),c(t.version)}})]})}function F(){return A().tlsMode!=="internal"?null:e.jsxs("div",{className:"border-t border-line pt-4 mt-4",children:[e.jsx("p",{className:"text-sm font-medium text-fg mb-1",children:"TLS root certificate"}),e.jsx("p",{className:"text-sm text-fg-muted mb-2",children:"This deployment signs its own certificate. Import it into the trust store of each device you browse from, and the browser warning stops for good."}),e.jsx(f,{href:"/tls-root-ca.crt",download:!0,variant:"secondary",size:"sm",icon:e.jsx(E,{className:"size-3.5"}),children:"Download root certificate"})]})}function W(s){try{return new Date(s).toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return s}}function $({sha:s=_,commitUrl:t=I,buildTime:a=D}){return e.jsxs("p",{className:"text-xs text-fg-subtle",children:["Version"," ",t?e.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"font-mono hover:text-fg-muted hover:underline",children:s}):e.jsx("span",{className:"font-mono",children:s})," · ",e.jsxs("span",{children:["Built ",W(a)]})]})}const J=e.jsx("div",{className:"space-y-3",children:e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Notification rules"}),", data export, and per-account diagnostics are coming in a future release."]})});function te(){const s=L(),[t,a]=g.useState(!0),r=i=>{const c=V[i];c&&s({to:c})};return e.jsxs(B,{items:M,activeId:"advanced",title:"Advanced",description:"Notification rules, export, and diagnostics.",help:J,helpOpen:t,onToggleHelp:()=>a(i=>!i),onSelect:r,onBackToMail:()=>{s({to:"/mail"})},children:[e.jsx(q,{}),e.jsx("p",{className:"text-sm text-fg-muted",children:"Notification rules, data export, and raw sync diagnostics are coming in a future release."}),e.jsx(F,{}),e.jsxs("div",{className:"border-t border-line pt-4 mt-4",children:[e.jsx("p",{className:"text-sm font-medium text-fg mb-1",children:"About"}),e.jsx($,{})]})]})}export{te as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{au as g,r as s,
|
|
1
|
+
import{au as g,r as s,cy as y,j as e,cn as u,cz as l,cp as S,cA as b}from"./index-xOALrEh8.js";import{S as j}from"./settings-screen-C7xmJsXG.js";import"./avatar-Ci3CMhdo.js";const o="remit.density";function T(){return typeof localStorage>"u"?"comfortable":localStorage.getItem(o)??"comfortable"}const v=e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Density"})," controls how much information fits on screen. Compact is great on smaller displays; Comfortable gives each item more breathing room."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Theme"})," switches between light, dark, and system-preference modes instantly. The change takes effect across the whole app immediately."]}),e.jsx("p",{className:"text-2xs text-fg-subtle",children:"Preferences are stored locally in this browser. Server-side sync is coming soon."})]});function I(){const a=g(),[i,c]=s.useState(!0),[r,m]=s.useState(T),[p,d]=s.useState(y),h=t=>{m(t),typeof localStorage<"u"&&localStorage.setItem(o,t)},f=t=>{d(t),b(t)},x=t=>{const n=S[t];n&&a({to:n})};return e.jsx(j,{items:u,activeId:"appearance",title:"Appearance",description:"Display density and colour theme — instant-apply.",help:v,helpOpen:i,onToggleHelp:()=>c(t=>!t),onSelect:x,onBackToMail:()=>{a({to:"/mail"})},children:e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-fg",children:"Density"}),e.jsx(l,{name:"density","aria-label":"Density",value:r,onChange:h,options:[{value:"comfortable",label:"Comfortable"},{value:"compact",label:"Compact"}]}),e.jsx("p",{className:"text-xs text-fg-subtle",children:"Controls the spacing of message rows in the mail list."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-fg",children:"Theme"}),e.jsx(l,{name:"theme","aria-label":"Theme",value:p,onChange:f,options:[{value:"system",label:"System"},{value:"light",label:"Light"},{value:"dark",label:"Dark"}]}),e.jsx("p",{className:"text-xs text-fg-subtle",children:"Applies immediately. System default follows your OS preference."})]})]})})}export{I as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as l,r as h,j as p,d as u}from"./index-
|
|
1
|
+
import{a as l,r as h,j as p,d as u}from"./index-xOALrEh8.js";const f=l("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const m=l("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]),y={sm:"size-7 text-2xs",md:"size-9 text-sm",lg:"size-11 text-md"},r=["oklch(0.6 0.08 150)","oklch(0.6 0.08 185)","oklch(0.6 0.08 215)","oklch(0.6 0.07 250)","oklch(0.6 0.07 310)","oklch(0.62 0.07 110)"],k="oklch(0.97 0.012 90)";function x(t){const e=t.trim().split(/\s+/).filter(Boolean);return e.length===0?"?":e.length===1?e[0].slice(0,2).toUpperCase():(e[0][0]+e[e.length-1][0]).toUpperCase()}function g({name:t,email:e,size:c="md",className:i}){const a=h.useMemo(()=>{const o=e??t;let s=0;for(let n=0;n<o.length;n++)s=s*31+o.charCodeAt(n)>>>0;return r[s%r.length]},[t,e]);return p.jsx("span",{className:u("inline-flex shrink-0 items-center justify-center rounded-full font-semibold select-none",y[c],i),style:{backgroundColor:a,color:k},"aria-hidden":!0,children:x(t)})}export{g as A,f as C,m as M};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`)===0?n.substr(1,n.length):n}).forEach(function(n){var s=n.split(":"),o=s.shift().trim();if(o){var g=s.join(":").trim();try{t.append(o,g)}catch(x){console.warn("Response "+x.message)}}}),t}U.call(w.prototype);function c(e,t){if(!(this instanceof c))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(t||(t={}),this.type="default",this.status=t.status===void 0?200:t.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=t.statusText===void 0?"":""+t.statusText,this.headers=new i(t.headers),this.url=t.url||"",this._initBody(e)}U.call(c.prototype),c.prototype.clone=function(){return new c(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new i(this.headers),url:this.url})},c.error=function(){var e=new c(null,{status:200,statusText:""});return e.ok=!1,e.status=0,e.type="error",e};var V=[301,302,303,307,308];c.redirect=function(e,t){if(V.indexOf(t)===-1)throw new RangeError("Invalid status code");return new c(null,{status:t,headers:{location:e}})},h.DOMException=a.DOMException;try{new h.DOMException}catch{h.DOMException=function(t,r){this.message=t,this.name=r;var n=Error(t);this.stack=n.stack},h.DOMException.prototype=Object.create(Error.prototype),h.DOMException.prototype.constructor=h.DOMException}function P(e,t){return new Promise(function(r,n){var s=new w(e,t);if(s.signal&&s.signal.aborted)return n(new h.DOMException("Aborted","AbortError"));var o=new XMLHttpRequest;function g(){o.abort()}o.onload=function(){var f={statusText:o.statusText,headers:G(o.getAllResponseHeaders()||"")};s.url.indexOf("file://")===0&&(o.status<200||o.status>599)?f.status=200:f.status=o.status,f.url="responseURL"in o?o.responseURL:f.headers.get("X-Request-URL");var m="response"in o?o.response:o.responseText;setTimeout(function(){r(new c(m,f))},0)},o.onerror=function(){setTimeout(function(){n(new TypeError("Network request failed"))},0)},o.ontimeout=function(){setTimeout(function(){n(new TypeError("Network request timed out"))},0)},o.onabort=function(){setTimeout(function(){n(new h.DOMException("Aborted","AbortError"))},0)};function x(f){try{return f===""&&a.location.href?a.location.href:f}catch{return f}}if(o.open(s.method,x(s.url),!0),s.credentials==="include"?o.withCredentials=!0:s.credentials==="omit"&&(o.withCredentials=!1),"responseType"in o&&(u.blob?o.responseType="blob":u.arrayBuffer&&(o.responseType="arraybuffer")),t&&typeof t.headers=="object"&&!(t.headers instanceof i||a.Headers&&t.headers instanceof a.Headers)){var j=[];Object.getOwnPropertyNames(t.headers).forEach(function(f){j.push(v(f)),o.setRequestHeader(f,T(t.headers[f]))}),s.headers.forEach(function(f,m){j.indexOf(m)===-1&&o.setRequestHeader(m,f)})}else s.headers.forEach(function(f,m){o.setRequestHeader(m,f)});s.signal&&(s.signal.addEventListener("abort",g),o.onreadystatechange=function(){o.readyState===4&&s.signal.removeEventListener("abort",g)}),o.send(typeof s._bodyInit>"u"?null:s._bodyInit)})}return P.polyfill=!0,a.fetch||(a.fetch=P,a.Headers=i,a.Request=w,a.Response=c),h.Headers=i,h.Request=w,h.Response=c,h.fetch=P,h})({})})(y),y.fetch.ponyfill=!0,delete y.fetch.polyfill;var l=b.fetch?b:y;d=l.fetch,d.default=l.fetch,d.fetch=l.fetch,d.Headers=l.Headers,d.Request=l.Request,d.Response=l.Response,_.exports=d})(E,E.exports)),E.exports}var S=
|
|
1
|
+
import{d4 as A,bZ as $}from"./index-xOALrEh8.js";function X(_,d){for(var b=0;b<d.length;b++){const y=d[b];if(typeof y!="string"&&!Array.isArray(y)){for(const l in y)if(l!=="default"&&!(l in _)){const p=Object.getOwnPropertyDescriptor(y,l);p&&Object.defineProperty(_,l,p.get?p:{enumerable:!0,get:()=>y[l]})}}}return Object.freeze(Object.defineProperty(_,Symbol.toStringTag,{value:"Module"}))}var E={exports:{}},H;function Z(){return H||(H=1,(function(_,d){var b=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof A<"u"&&A,y=(function(){function p(){this.fetch=!1,this.DOMException=b.DOMException}return p.prototype=b,new p})();(function(p){(function(h){var a=typeof p<"u"&&p||typeof self<"u"&&self||typeof A<"u"&&A||{},u={searchParams:"URLSearchParams"in a,iterable:"Symbol"in a&&"iterator"in Symbol,blob:"FileReader"in a&&"Blob"in a&&(function(){try{return new Blob,!0}catch{return!1}})(),formData:"FormData"in a,arrayBuffer:"ArrayBuffer"in a};function F(e){return e&&DataView.prototype.isPrototypeOf(e)}if(u.arrayBuffer)var q=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],C=ArrayBuffer.isView||function(e){return e&&q.indexOf(Object.prototype.toString.call(e))>-1};function v(e){if(typeof e!="string"&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||e==="")throw new TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function T(e){return typeof e!="string"&&(e=String(e)),e}function B(e){var t={next:function(){var r=e.shift();return{done:r===void 0,value:r}}};return u.iterable&&(t[Symbol.iterator]=function(){return t}),t}function i(e){this.map={},e instanceof i?e.forEach(function(t,r){this.append(r,t)},this):Array.isArray(e)?e.forEach(function(t){if(t.length!=2)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+t.length);this.append(t[0],t[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}i.prototype.append=function(e,t){e=v(e),t=T(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},i.prototype.delete=function(e){delete this.map[v(e)]},i.prototype.get=function(e){return e=v(e),this.has(e)?this.map[e]:null},i.prototype.has=function(e){return this.map.hasOwnProperty(v(e))},i.prototype.set=function(e,t){this.map[v(e)]=T(t)},i.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},i.prototype.keys=function(){var e=[];return this.forEach(function(t,r){e.push(r)}),B(e)},i.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),B(e)},i.prototype.entries=function(){var e=[];return this.forEach(function(t,r){e.push([r,t])}),B(e)},u.iterable&&(i.prototype[Symbol.iterator]=i.prototype.entries);function O(e){if(!e._noBody){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}}function D(e){return new Promise(function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}})}function I(e){var t=new FileReader,r=D(t);return t.readAsArrayBuffer(e),r}function M(e){var t=new FileReader,r=D(t),n=/charset=([A-Za-z0-9_-]+)/.exec(e.type),s=n?n[1]:"utf-8";return t.readAsText(e,s),r}function L(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n<t.length;n++)r[n]=String.fromCharCode(t[n]);return r.join("")}function R(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function U(){return this.bodyUsed=!1,this._initBody=function(e){this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?typeof e=="string"?this._bodyText=e:u.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:u.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:u.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():u.arrayBuffer&&u.blob&&F(e)?(this._bodyArrayBuffer=R(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):u.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||C(e))?this._bodyArrayBuffer=R(e):this._bodyText=e=Object.prototype.toString.call(e):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||(typeof e=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):u.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},u.blob&&(this.blob=function(){var e=O(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=O(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else{if(u.blob)return this.blob().then(I);throw new Error("could not read as ArrayBuffer")}},this.text=function(){var e=O(this);if(e)return e;if(this._bodyBlob)return M(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(L(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},u.formData&&(this.formData=function(){return this.text().then(z)}),this.json=function(){return this.text().then(JSON.parse)},this}var N=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function k(e){var t=e.toUpperCase();return N.indexOf(t)>-1?t:e}function w(e,t){if(!(this instanceof w))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');t=t||{};var r=t.body;if(e instanceof w){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new i(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,!r&&e._bodyInit!=null&&(r=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",(t.headers||!this.headers)&&(this.headers=new i(t.headers)),this.method=k(t.method||this.method||"GET"),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal||(function(){if("AbortController"in a){var o=new AbortController;return o.signal}})(),this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&r)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(r),(this.method==="GET"||this.method==="HEAD")&&(t.cache==="no-store"||t.cache==="no-cache")){var n=/([?&])_=[^&]*/;if(n.test(this.url))this.url=this.url.replace(n,"$1_="+new Date().getTime());else{var s=/\?/;this.url+=(s.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}w.prototype.clone=function(){return new w(this,{body:this._bodyInit})};function z(e){var t=new FormData;return e.trim().split("&").forEach(function(r){if(r){var n=r.split("="),s=n.shift().replace(/\+/g," "),o=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(s),decodeURIComponent(o))}}),t}function G(e){var t=new i,r=e.replace(/\r?\n[\t ]+/g," ");return r.split("\r").map(function(n){return n.indexOf(`
|
|
2
|
+
`)===0?n.substr(1,n.length):n}).forEach(function(n){var s=n.split(":"),o=s.shift().trim();if(o){var g=s.join(":").trim();try{t.append(o,g)}catch(x){console.warn("Response "+x.message)}}}),t}U.call(w.prototype);function c(e,t){if(!(this instanceof c))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(t||(t={}),this.type="default",this.status=t.status===void 0?200:t.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=t.statusText===void 0?"":""+t.statusText,this.headers=new i(t.headers),this.url=t.url||"",this._initBody(e)}U.call(c.prototype),c.prototype.clone=function(){return new c(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new i(this.headers),url:this.url})},c.error=function(){var e=new c(null,{status:200,statusText:""});return e.ok=!1,e.status=0,e.type="error",e};var V=[301,302,303,307,308];c.redirect=function(e,t){if(V.indexOf(t)===-1)throw new RangeError("Invalid status code");return new c(null,{status:t,headers:{location:e}})},h.DOMException=a.DOMException;try{new h.DOMException}catch{h.DOMException=function(t,r){this.message=t,this.name=r;var n=Error(t);this.stack=n.stack},h.DOMException.prototype=Object.create(Error.prototype),h.DOMException.prototype.constructor=h.DOMException}function P(e,t){return new Promise(function(r,n){var s=new w(e,t);if(s.signal&&s.signal.aborted)return n(new h.DOMException("Aborted","AbortError"));var o=new XMLHttpRequest;function g(){o.abort()}o.onload=function(){var f={statusText:o.statusText,headers:G(o.getAllResponseHeaders()||"")};s.url.indexOf("file://")===0&&(o.status<200||o.status>599)?f.status=200:f.status=o.status,f.url="responseURL"in o?o.responseURL:f.headers.get("X-Request-URL");var m="response"in o?o.response:o.responseText;setTimeout(function(){r(new c(m,f))},0)},o.onerror=function(){setTimeout(function(){n(new TypeError("Network request failed"))},0)},o.ontimeout=function(){setTimeout(function(){n(new TypeError("Network request timed out"))},0)},o.onabort=function(){setTimeout(function(){n(new h.DOMException("Aborted","AbortError"))},0)};function x(f){try{return f===""&&a.location.href?a.location.href:f}catch{return f}}if(o.open(s.method,x(s.url),!0),s.credentials==="include"?o.withCredentials=!0:s.credentials==="omit"&&(o.withCredentials=!1),"responseType"in o&&(u.blob?o.responseType="blob":u.arrayBuffer&&(o.responseType="arraybuffer")),t&&typeof t.headers=="object"&&!(t.headers instanceof i||a.Headers&&t.headers instanceof a.Headers)){var j=[];Object.getOwnPropertyNames(t.headers).forEach(function(f){j.push(v(f)),o.setRequestHeader(f,T(t.headers[f]))}),s.headers.forEach(function(f,m){j.indexOf(m)===-1&&o.setRequestHeader(m,f)})}else s.headers.forEach(function(f,m){o.setRequestHeader(m,f)});s.signal&&(s.signal.addEventListener("abort",g),o.onreadystatechange=function(){o.readyState===4&&s.signal.removeEventListener("abort",g)}),o.send(typeof s._bodyInit>"u"?null:s._bodyInit)})}return P.polyfill=!0,a.fetch||(a.fetch=P,a.Headers=i,a.Request=w,a.Response=c),h.Headers=i,h.Request=w,h.Response=c,h.fetch=P,h})({})})(y),y.fetch.ponyfill=!0,delete y.fetch.polyfill;var l=b.fetch?b:y;d=l.fetch,d.default=l.fetch,d.fetch=l.fetch,d.Headers=l.Headers,d.Request=l.Request,d.Response=l.Response,_.exports=d})(E,E.exports)),E.exports}var S=Z();const J=$(S),Q=X({__proto__:null,default:J},[S]);export{Q as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as c}from"./index-
|
|
1
|
+
import{a as c}from"./index-xOALrEh8.js";const r=c("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);export{r as C};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as n,j as e,
|
|
1
|
+
import{r as n,j as e,bR as b,d as o}from"./index-xOALrEh8.js";const h=({isOpen:s,title:i,description:l,confirmLabel:d,cancelLabel:m="Cancel",destructive:u=!1,isBusy:f=!1,onConfirm:x,onCancel:r})=>{const c=n.useRef(null),a=n.useCallback(t=>{t.key==="Escape"&&(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),r())},[r]);return n.useEffect(()=>{if(s)return window.addEventListener("keydown",a,!0),()=>window.removeEventListener("keydown",a,!0)},[s,a]),n.useEffect(()=>{if(!s)return;const t=document.activeElement instanceof HTMLElement?document.activeElement:null;return c.current?.focus(),()=>{t?.isConnected&&t.focus()}},[s]),s?e.jsxs("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",children:[e.jsx(b,{label:"Dismiss confirmation",onDismiss:r,className:"backdrop-blur-sm"}),e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":i,className:o("relative z-10 w-full max-w-sm","bg-surface border border-line rounded-sm shadow-lg","p-6"),children:[e.jsx("h2",{className:"text-lg font-semibold",children:i}),l&&e.jsx("p",{className:"mt-2 text-sm text-fg-muted",children:l}),e.jsxs("div",{className:"mt-6 flex items-center justify-end gap-2",children:[e.jsx("button",{ref:c,type:"button",onClick:r,className:o("min-h-11 inline-flex items-center justify-center px-4 rounded text-sm font-medium transition-colors","border border-line hover:bg-surface-raised"),children:m}),e.jsx("button",{type:"button",onClick:x,disabled:f,className:o("min-h-11 inline-flex items-center justify-center px-4 rounded text-sm font-medium transition-colors",u?"bg-danger text-canvas hover:bg-danger/90":"bg-accent text-accent-fg hover:bg-accent-hover","disabled:opacity-50 disabled:cursor-not-allowed"),children:d})]})]})]}):null};export{h as C};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as o}from"./index-
|
|
1
|
+
import{a as o}from"./index-xOALrEh8.js";const a=o("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);export{a as D};
|