@remit/web-client-dist 0.0.294 → 0.0.296

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/assets/{ComposeBody-BNkTo3di.js → ComposeBody-DWkdEkqR.js} +2 -2
  2. package/assets/{ConfirmDialog-D7k6ug53.js → ConfirmDialog-BJo9D9jL.js} +1 -1
  3. package/assets/{ErrorState-Dzd1dG4I.js → ErrorState-CYMKMK-m.js} +1 -1
  4. package/assets/{OnboardingWizard-BpT-bh4F.js → OnboardingWizard-DiNp39Ly.js} +1 -1
  5. package/assets/{account-form-helpers-qliPkUSX.js → account-form-helpers-C6QgTBuy.js} +1 -1
  6. package/assets/{accounts-Dr5dvRkY.js → accounts-DrrxLu-A.js} +1 -1
  7. package/assets/{advanced-_VkDmMlU.js → advanced-ClKJ3X6O.js} +1 -1
  8. package/assets/{appearance-Dlq-rqJH.js → appearance-8lqa5Vua.js} +1 -1
  9. package/assets/{avatar-DLXozspI.js → avatar-VNDJ5A43.js} +1 -1
  10. package/assets/{browser-ponyfill-CQs4BAYO.js → browser-ponyfill-DvwMi_jg.js} +1 -1
  11. package/assets/{circle-check-D2h8K7Na.js → circle-check-pM99trgf.js} +1 -1
  12. package/assets/{download-C2ROFXkI.js → download-C3FtIMt9.js} +1 -1
  13. package/assets/{filters-BJI1dh_r.js → filters-Dux80wCX.js} +1 -1
  14. package/assets/{flagged-DRjvHDq-.js → flagged-BEsB_wRe.js} +1 -1
  15. package/assets/{folders-C7AH9iG6.js → folders-cKlRSWFA.js} +1 -1
  16. package/assets/{index-YsPo3AJf.css → index-Bp4WnjS6.css} +1 -1
  17. package/assets/{index-Z0KvXoPD.js → index-CFFTFBUh.js} +8 -8
  18. package/assets/{index-C9ePclcf.js → index-DZC9weAQ.js} +1 -1
  19. package/assets/index-bi7nSm8_.js +1 -0
  20. package/assets/{kbd-D5tq3erg.js → kbd-YJVHKonD.js} +1 -1
  21. package/assets/{labels-DydGRuJL.js → labels-AWXTmNVS.js} +1 -1
  22. package/assets/mail-KIW9IAGs.js +118 -0
  23. package/assets/move-options-D9t3Mojn.js +1 -0
  24. package/assets/{onboarding-Vs6qHdhJ.js → onboarding-BZ6X6xkU.js} +1 -1
  25. package/assets/{pencil-1bcPjRI2.js → pencil-X6z3x2NK.js} +1 -1
  26. package/assets/{senders-CGvgSCbU.js → senders-C1UIALFk.js} +1 -1
  27. package/assets/settings-B1pbwg2l.js +1 -0
  28. package/assets/{settings-screen-BEVDEgSL.js → settings-screen-CR4yq1NM.js} +1 -1
  29. package/assets/{shield-check-BHrnoPQT.js → shield-check-BSX7wD7V.js} +1 -1
  30. package/assets/{suggested-vips-CPWuzllJ.js → suggested-vips-2b3eZkLi.js} +1 -1
  31. package/assets/{useDebouncedValue-DRN7AoJj.js → useDebouncedValue-BD9ZdStj.js} +1 -1
  32. package/assets/{useFilters-BycxlYbK.js → useFilters-DyThnXyZ.js} +1 -1
  33. package/assets/{useLabels-C4ptFWUb.js → useLabels-CdFZ8p_J.js} +1 -1
  34. package/assets/{useSignature-D4dw99i4.js → useSignature-BQhyovyz.js} +1 -1
  35. package/index.html +2 -2
  36. package/package.json +1 -1
  37. package/assets/index-CBC27r1L.js +0 -1
  38. package/assets/mail-D_5lBTom.js +0 -118
  39. package/assets/move-options-D5dV78-q.js +0 -1
  40. package/assets/settings-CO9VbgjK.js +0 -1
@@ -1,4 +1,4 @@
1
- import{a as vo,r as L,j,a0 as Dc}from"./index-Z0KvXoPD.js";import{s as Zu,U as sg}from"./mail-D_5lBTom.js";import"./pencil-1bcPjRI2.js";import"./avatar-DLXozspI.js";import"./kbd-D5tq3erg.js";import"./shield-check-BHrnoPQT.js";import"./account-form-helpers-qliPkUSX.js";import"./useSignature-D4dw99i4.js";import"./useDebouncedValue-DRN7AoJj.js";import"./useFilters-BycxlYbK.js";import"./ErrorState-Dzd1dG4I.js";import"./format-CKZmh-Ru.js";import"./move-options-D5dV78-q.js";import"./useLabels-C4ptFWUb.js";import"./ConfirmDialog-D7k6ug53.js";import"./circle-check-D2h8K7Na.js";const lg=vo("Bold",[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]]);const cg=vo("Italic",[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]]);const ag=vo("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);const ug=vo("Quote",[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]]);const fg=vo("Redo2",[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]]),tf=L.createContext(null);function dg(n,t){return{getTheme:function(){return t??null}}}function oe(){const n=L.useContext(tf);return n==null&&(function(t,...e){const r=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",t);for(const i of e)o.append("v",i);throw r.search=o.toString(),Error(`Minified Lexical error #${t}; visit ${r.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)})(8),n}function $(n,...t){const e=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",n);for(const o of t)r.append("v",o);throw e.search=r.toString(),Error(`Minified Lexical error #${n}; visit ${e.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function ef(n,...t){const e=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",n);for(const o of t)r.append("v",o);e.search=r.toString(),console.warn(`Minified Lexical warning #${n}; visit ${e.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const Vt=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,hg=Vt&&"documentMode"in document?document.documentMode:null,Ne=Vt&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),Oe=Vt&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),xr=!(!Vt||!("InputEvent"in window)||hg)&&"getTargetRanges"in new window.InputEvent("input"),mn=Vt&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,nf=Vt&&/Android/.test(navigator.userAgent),No=Vt&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent)&&!nf,rf=Vt&&/^(?=.*Chrome).*/i.test(navigator.userAgent),ci=Vt&&nf&&rf,To=Vt&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&Ne&&!rf,gg=0,pg=1,mg=2,zs=1,Bs=2,Ws=4,Us=8,_g=16,ps=32,ms=64,Rl=128,yg=1,xg=2,Cg=3,Sg=4,bg=5,vg=6,so=No||mn||To?" ":"​",En=`
1
+ import{a as vo,r as L,j,a0 as Dc}from"./index-CFFTFBUh.js";import{s as Zu,U as sg}from"./mail-KIW9IAGs.js";import"./pencil-X6z3x2NK.js";import"./avatar-VNDJ5A43.js";import"./kbd-YJVHKonD.js";import"./shield-check-BSX7wD7V.js";import"./account-form-helpers-C6QgTBuy.js";import"./useSignature-BQhyovyz.js";import"./useDebouncedValue-BD9ZdStj.js";import"./useFilters-DyThnXyZ.js";import"./ErrorState-CYMKMK-m.js";import"./format-CKZmh-Ru.js";import"./move-options-D9t3Mojn.js";import"./download-C3FtIMt9.js";import"./useLabels-CdFZ8p_J.js";import"./ConfirmDialog-BJo9D9jL.js";import"./circle-check-pM99trgf.js";const lg=vo("Bold",[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]]);const cg=vo("Italic",[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]]);const ag=vo("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);const ug=vo("Quote",[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]]);const fg=vo("Redo2",[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]]),tf=L.createContext(null);function dg(n,t){return{getTheme:function(){return t??null}}}function oe(){const n=L.useContext(tf);return n==null&&(function(t,...e){const r=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",t);for(const i of e)o.append("v",i);throw r.search=o.toString(),Error(`Minified Lexical error #${t}; visit ${r.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)})(8),n}function $(n,...t){const e=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",n);for(const o of t)r.append("v",o);throw e.search=r.toString(),Error(`Minified Lexical error #${n}; visit ${e.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function ef(n,...t){const e=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",n);for(const o of t)r.append("v",o);e.search=r.toString(),console.warn(`Minified Lexical warning #${n}; visit ${e.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const Vt=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,hg=Vt&&"documentMode"in document?document.documentMode:null,Ne=Vt&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),Oe=Vt&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),xr=!(!Vt||!("InputEvent"in window)||hg)&&"getTargetRanges"in new window.InputEvent("input"),mn=Vt&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,nf=Vt&&/Android/.test(navigator.userAgent),No=Vt&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent)&&!nf,rf=Vt&&/^(?=.*Chrome).*/i.test(navigator.userAgent),ci=Vt&&nf&&rf,To=Vt&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&Ne&&!rf,gg=0,pg=1,mg=2,zs=1,Bs=2,Ws=4,Us=8,_g=16,ps=32,ms=64,Rl=128,yg=1,xg=2,Cg=3,Sg=4,bg=5,vg=6,so=No||mn||To?" ":"​",En=`
2
2
 
3
3
  `,Ll=Oe?" ":so,nn={bold:1,capitalize:1024,code:16,highlight:Rl,italic:2,lowercase:256,strikethrough:4,subscript:32,superscript:64,underline:8,uppercase:512},Ng={directionless:1,unmergeable:2},ai={center:2,end:6,justify:4,left:1,right:3,start:5},Tg={[xg]:"center",[vg]:"end",[Sg]:"justify",[yg]:"left",[Cg]:"right",[bg]:"start"},kg={normal:0,segmented:2,token:1},wg={[gg]:"normal",[mg]:"segmented",[pg]:"token"},Pc="$config";function Rc(){return St()._blockCursorElement}function Eg(n){return n!==null&&n.nodeType===1&&n.hasAttribute("data-lexical-slot")}let of=class Xo{element;before;after;constructor(t,e,r){this.element=t,this.before=e||null,this.after=r||null}withBefore(t){return new Xo(this.element,t,this.after)}withAfter(t){return new Xo(this.element,this.before,t)}withElement(t){return this.element===t?this:new Xo(t,this.before,this.after)}insertChild(t){const e=this.getInsertionAnchor();return e!==null&&e.parentElement!==this.element&&$(357),this.element.insertBefore(t,e),this}removeChild(t){return t.parentElement!==this.element&&$(358),this.element.removeChild(t),this}replaceChild(t,e){return e.parentElement!==this.element&&$(359),this.element.replaceChild(t,e),this}getFirstChild(){const t=this.getFirstChildAnchor(),e=t?t.nextSibling:this.element.firstChild;return e===this.getInsertionAnchor()?null:e}getFirstChildAnchor(){return this.after}resolveLeafPosition(t,e,r){if(this.element===t)return e===t&&r===0?"before":"after";const o=Lc(t,this.element);if(o===null)return"after";const i=Array.prototype.indexOf.call(t.childNodes,o);if(i<0)return"after";if(e===t)return r<=i?"before":"after";const s=Lc(t,e);if(s===null)return"after";const l=Array.prototype.indexOf.call(t.childNodes,s);return l>=0&&l<=i?"before":"after"}getInsertionAnchor(){return this.before}};function Lc(n,t){let e=t;for(;e!==null&&e.parentNode!==n;)e=e.parentNode;return e}let sf=class Go extends of{withBefore(t){return new Go(this.element,t,this.after)}withAfter(t){return new Go(this.element,this.before,t)}withElement(t){return this.element===t?this:new Go(t,this.before,this.after)}getInsertionAnchor(){return super.getInsertionAnchor()||this.getManagedLineBreak()}getFirstChildAnchor(){let t=super.getFirstChildAnchor(),e=t?t.nextSibling:this.element.firstChild;for(;Eg(e);)t=e,e=e.nextSibling;const r=t?t.nextSibling:this.element.firstChild;return r!==null&&r===Rc()?r:t}getManagedLineBreak(){return this.element.__lexicalLineBreak||null}setManagedLineBreak(t){if(this.element.__lexicalLastChildKind=t,t===null)this.removeManagedLineBreak();else{const e=t==="decorator"&&(To||mn||No);this.insertManagedLineBreak(e)}}removeManagedLineBreak(){const t=this.getManagedLineBreak();if(t){const e=this.element,r=t.nodeName==="IMG"?t.nextSibling:null;r&&e.removeChild(r),e.removeChild(t),e.__lexicalLineBreak=void 0}}insertManagedLineBreak(t){const e=this.getManagedLineBreak();if(e){if(t===(e.nodeName==="IMG"))return;this.removeManagedLineBreak()}const r=this.element,o=this.before,i=Z().createElement("br");if(i.setAttribute("data-lexical-managed-linebreak","true"),r.insertBefore(i,o),t){const s=Z().createElement("img");s.setAttribute("data-lexical-managed-linebreak","true"),s.style.setProperty("display","inline","important"),s.style.setProperty("border","0px","important"),s.style.setProperty("margin","0px","important"),s.alt="",r.insertBefore(s,i),r.__lexicalLineBreak=s}else r.__lexicalLineBreak=i}getFirstChildOffset(){const t=this.getFirstChild(),e=this.getInsertionAnchor();let r=0;for(let o=this.element.firstChild;o!==null&&o!==t&&o!==e;o=o.nextSibling)r++;return r}resolveChildIndex(t,e,r,o){if(r===this.element){const c=this.getFirstChildOffset(),a=Rc(),u=this.element.childNodes,f=Math.min(o,u.length);let d=0;for(let h=c;h<f;h++)u[h]!==a&&d++;return[t,Math.min(d,t.getChildrenSize())]}const i=Ic(e,r);i.push(o);const s=Ic(e,this.element);let l=t.getIndexWithinParent();for(let c=0;c<s.length;c++){const a=i[c],u=s[c];if(a===void 0||a<u)break;if(a>u){l+=1;break}}return[t.getParentOrThrow(),l]}};function Ic(n,t){const e=[];let r=t;for(;r!==n&&r!==null;r=r.parentNode){let o=0;for(let i=r.previousSibling;i!==null;i=i.previousSibling)o++;e.push(o)}return r!==n&&$(225),e.reverse()}let lf;try{lf="0.49.0+prod.esm"}catch{}const cf=lf??'"<unknown>+source"';let Ur=class{_front=new Set;_back=new Set;_cache;get size(){return this._front.size+this._back.size}addBack(t){return delete this._cache,this._front.has(t)||this._back.add(t),this}addFront(t){return delete this._cache,this._back.has(t)||this._front.add(t),this}delete(t){return delete this._cache,this._front.delete(t)||this._back.delete(t)}toArray(){const t=Array.from(this._front).reverse();for(const e of this._back)t.push(e);return t}toReadonlyArray(){return this._cache=this._cache||this.toArray(),this._cache}[Symbol.iterator](){return this.toReadonlyArray()[Symbol.iterator]()}};const Nn=null;function af(n,t=1e3){return n instanceof js?n.clone():n.size<t?new Map(n):new js().init(new Map(n),void 0,n.size)}let js=class uf{_mutable=!1;_old=void 0;_nursery=void 0;_size=0;clone(){return this._mutable=!1,new uf().init(this._old,this._nursery,this._size)}init(t,e,r){return this._old=t,this._nursery=e,this._size=r,this}get size(){return this._size}has(t){return this.get(t)!==void 0}getWithTombstone(t){const e=this._nursery&&this._nursery.get(t);return e!==void 0?e:this._old&&this._old.get(t)}get(t){const e=this.getWithTombstone(t);return e===Nn?void 0:e}shouldCompact(){return this._nursery!==void 0&&2*this._nursery.size>this._size}getNursery(){return this._mutable&&this._nursery||(this.compact(),this._nursery=new Map(this._nursery),this._mutable=!0),this._nursery}compact(t=!1){if(this._nursery&&this._nursery.size>0&&(t||this.shouldCompact())){const e=new Map(this._old);for(const[r,o]of this._nursery)o!==Nn?e.set(r,o):e.delete(r);this._old=e,this._nursery=void 0}return this._mutable=!1,this}set(t,e){const r=this.getWithTombstone(t);if(r===e)return this;const o=this.getNursery();return r!==Nn&&r!==void 0||(this._size++,r===Nn&&o.delete(t)),o.set(t,e),this}delete(t){const e=this.has(t);return e&&(this.getNursery().set(t,Nn),this._size--),e}getOrInsert(t,e){const r=this.get(t);return r!==void 0?r:(this.set(t,e),e)}getOrInsertComputed(t,e){const r=this.get(t);if(r!==void 0)return r;const o=e(t);return this.set(t,o),o}clear(){this._mutable=!1,this._old=void 0,this._nursery=void 0,this._size=0}*keys(){for(const t of this.entries())yield t[0]}*values(){for(const t of this.entries())yield t[1]}*entries(){const t=this._nursery,e=this._old;if(e)for(const r of e){const o=r[0],i=t?t.get(o):void 0;i!==Nn&&(i!==void 0&&(r[1]=i),yield r)}if(t)for(const r of t)r[1]===Nn||e&&e.has(r[0])||(yield r)}forEach(t,e){e!==void 0&&(t=t.bind(e));for(const[r,o]of this.entries())t(o,r,this)}get[Symbol.toStringTag](){return"GenMap"}[Symbol.iterator](){return this.entries()}};function ui(n,t,e,r,o,i){if(C(n)){let s=n.getFirstChild();for(;s!==null;){const l=s.__key;s.__parent===t&&((C(s)||tn(s)&&s.__slots!==null)&&ui(s,l,e,r,o,i),e.has(l)||i.delete(l),o.push(l)),s=s.getNextSibling()}}for(const s of tn(n)&&n.__slots!==null?n.__slots.values():[]){const l=r.get(s);l!==void 0&&Ln(l)&&l.__slotHost===t&&((C(l)||tn(l)&&l.__slots!==null)&&ui(l,s,e,r,o,i),e.has(s)||i.delete(s),o.push(s))}}let Hs=!1,Il=0;function $g(n){Il=n.timeStamp}function _s(n,t,e){const r=n.nodeName==="BR",o=t.__lexicalLineBreak;return o&&(n===o||r&&n.previousSibling===o)||r&&Ir(n,e)!==void 0}function Og(n,t,e){const r=Dt(se(e)),o=r&&re(r,e._rootElement);let i=null,s=null;o!==null&&o.anchorNode===n&&(i=o.anchorOffset,s=o.focusOffset);const l=n.nodeValue;l!==null&&sc(t,l,i,s,!1)}function Ag(n,t,e){if(w(n)){const r=n.anchor.getNode();if(r.is(e)&&n.format!==r.getFormat())return!1}return ie(t)&&e.isAttached()}function Mg(n,t,e){for(let r=n;r&&!Ld(r);r=jn(r)){const o=Ir(r,t);if(o!==void 0){const i=tt(o,e);if(i)return G(i)||!B(r)?void 0:[r,i]}}}function ff(n,t,e){Hs=!0;const r=performance.now()-Il>100;try{me(n,()=>{const o=A()||(function(f){return f.read("latest",()=>{const d=A();return d!==null?d.clone():null})})(n),i=new Map,s=n._editorState,l=n._blockCursorElement;let c=!1,a="";for(let f=0;f<t.length;f++){const d=t[f],h=d.type,g=d.target,_=Mg(g,n,s);if(!_)continue;const[p,m]=_;if(h==="characterData")r&&O(m)&&ie(g)&&Ag(o,g,m)&&Og(g,m,n);else if(h==="childList"){c=!0;const y=d.addedNodes;for(let T=0;T<y.length;T++){const v=y[T],N=bd(v),S=v.parentNode;if(!(S==null||v===l||N!==null||_s(v,S,n)||n._slotsUsed&&B(v)&&v.hasAttribute("data-lexical-slot")||Ld(v))){if(Oe){const k=(B(v)?v.innerText:null)||v.nodeValue;k&&(a+=k)}S.removeChild(v)}}const x=d.removedNodes,b=x.length;if(b>0){let T=0;for(let v=0;v<b;v++){const N=x[v];(_s(N,g,n)||l===N)&&(g.appendChild(N),T++)}b!==T&&i.set(p,m)}}}if(i.size>0)for(const[f,d]of i)d.reconcileObservedMutation(f,n);const u=e.takeRecords();if(u.length>0){for(let f=0;f<u.length;f++){const d=u[f],h=d.addedNodes,g=d.target;for(let _=0;_<h.length;_++){const p=h[_],m=p.parentNode;m==null||p.nodeName!=="BR"||_s(p,g,n)||m.removeChild(p)}}e.takeRecords()}o!==null&&(c&&gt(o),Oe&&Ed(n)&&o.insertRawText(a))})}finally{Hs=!1}}function df(n){const t=n._observer;t!==null&&ff(n,t.takeRecords(),t)}function hf(n){(function(t){Il===0&&se(t).addEventListener("textInput",$g,!0)})(n),n._observer=new MutationObserver((t,e)=>{ff(n,t,e)})}const Kc="latest";let Fg=class{key;parse;unparse;isEqual;defaultValue;resetOnCopyNode;constructor(t,e){this.key=t,this.parse=e.parse.bind(e),this.unparse=(e.unparse||Rg).bind(e),this.isEqual=(e.isEqual||Object.is).bind(e),this.defaultValue=this.parse(void 0),this.resetOnCopyNode=e.resetOnCopyNode||!1}};function ko(n,t){return new Fg(n,t)}function wo(n,t,e=Kc){const r=(e===Kc?n.getLatest():n).__state;return r?r.getValue(t):t.defaultValue}function ar(n,t,e){let r;if(Pt(),typeof e=="function"){const i=n.getLatest(),s=wo(i,t);if(r=e(s),t.isEqual(s,r))return i}else r=e;const o=n.getWritable();return pf(o).updateFromKnown(t,r),o}function Dg(n){const t=new Map,e=new Set;for(const{ownNodeConfig:r}of dc(typeof n=="function"?n:n.replace))if(r&&r.stateConfigs)for(const o of r.stateConfigs){let i;"stateConfig"in o?(i=o.stateConfig,o.flat&&e.add(i.key)):i=o,t.set(i.key,i)}return{flatKeys:e,sharedConfigMap:t}}const zc=new Set(["__proto__","constructor","prototype"]);let Pg=class gf{node;knownState;unknownState;sharedNodeState;size;constructor(t,e,r=void 0,o=new Map,i=void 0){this.node=t,this.sharedNodeState=e,this.unknownState=r,this.knownState=o;const{sharedConfigMap:s}=this.sharedNodeState,l=i!==void 0?i:(function(c,a,u){let f=u.size;if(a)for(const d in a){const h=c.get(d);h&&u.has(h)||f++}return f})(s,r,o);this.size=l}getValue(t){const e=this.knownState.get(t);if(e!==void 0)return e;this.sharedNodeState.sharedConfigMap.set(t.key,t);let r=t.defaultValue;if(this.unknownState&&t.key in this.unknownState){const o=this.unknownState[t.key];o!==void 0&&(r=t.parse(o)),this.updateFromKnown(t,r)}return r}getInternalState(){return[this.unknownState,this.knownState]}toJSON(){const t={...this.unknownState},e={};for(const[r,o]of this.knownState)r.isEqual(o,r.defaultValue)?delete t[r.key]:t[r.key]=r.unparse(o);for(const r of this.sharedNodeState.flatKeys)r in t&&(e[r]=t[r],delete t[r]);return Bc(t)&&(e.$=t),e}getWritable(t){if(this.node===t)return this;const{sharedNodeState:e,unknownState:r}=this,o=new Map(this.knownState);return new gf(t,e,(function(i,s,l){let c;if(l)for(const[a,u]of Object.entries(l)){if(zc.has(a))continue;const f=i.get(a);f?s.has(f)||s.set(f,f.parse(u)):(c=c||{},c[a]=u)}return c})(e.sharedConfigMap,o,r),o,this.size)}resetOnCopyNode(){for(const t of this.knownState.keys())t.resetOnCopyNode&&this.knownState.set(t,t.defaultValue);return this}updateFromKnown(t,e){const r=t.key;this.sharedNodeState.sharedConfigMap.set(r,t);const{knownState:o,unknownState:i}=this;o.has(t)||i&&r in i||(i&&(delete i[r],this.unknownState=Bc(i)),this.size++),o.set(t,e)}updateFromUnknown(t,e){if(zc.has(t))return;const r=this.sharedNodeState.sharedConfigMap.get(t);r?this.updateFromKnown(r,r.parse(e)):(this.unknownState=this.unknownState||{},t in this.unknownState||this.size++,this.unknownState[t]=e)}updateFromJSON(t){const{knownState:e}=this;for(const r of e.keys())e.set(r,r.defaultValue);if(this.size=e.size,this.unknownState=void 0,t)for(const[r,o]of Object.entries(t))this.updateFromUnknown(r,o)}};function pf(n){const t=n.getWritable(),e=t.__state?t.__state.getWritable(t):new Pg(t,mf(t));return t.__state=e,e}function mf(n){return n.__state?n.__state.sharedNodeState:xd(St(),n.getType()).sharedNodeState}function Bc(n){if(n)for(const t in n)return n}function Rg(n){return n}function Wc(n,t,e){for(const[r,o]of t.knownState){if(n.has(r.key))continue;n.add(r.key);const i=e?e.getValue(r):r.defaultValue;if(i!==o&&!r.isEqual(i,o))return!0}return!1}function Uc(n,t,e){const{unknownState:r}=t,o=e?e.unknownState:void 0;if(r){for(const[i,s]of Object.entries(r))if(!n.has(i)&&(n.add(i),s!==(o?o[i]:void 0)))return!0}return!1}function jc(n,t){const e=n.__state;return e&&e.node===n?e.getWritable(t):e}function Hc(n,t){const e=n.__mode,r=n.__format,o=n.__style,i=t.__mode,s=t.__format,l=t.__style,c=n.__state,a=t.__state;return(e===null||e===i)&&(r===null||r===s)&&(o===null||o===l)&&(n.__state===null||c===a||(function(u,f){if(u===f)return!0;const d=new Set;return!(u&&Wc(d,u,f)||f&&Wc(d,f,u)||u&&Uc(d,u,f)||f&&Uc(d,f,u))})(c,a))}function Jc(n,t){const e=n.mergeWithSibling(t),r=ft()._normalizedNodes;return r.add(n.__key),r.add(t.__key),e}function qc(n){let t,e,r=n;if(r.__text!==""||!r.isSimpleText()||r.isUnmergeable()){for(;(t=r.getPreviousSibling())!==null&&O(t)&&t.isSimpleText()&&!t.isUnmergeable();){if(t.__text!==""){if(Hc(t,r)){r=Jc(t,r);break}break}t.remove()}for(;(e=r.getNextSibling())!==null&&O(e)&&e.isSimpleText()&&!e.isUnmergeable();){if(e.__text!==""){if(Hc(r,e)){r=Jc(r,e);break}break}e.remove()}}else r.remove()}function De(n){return Vc(n.anchor),Vc(n.focus),n}function Vc(n){for(;n.type==="element";){const t=n.getNode(),e=n.offset;let r,o;if(e===t.getChildrenSize()?(r=t.getChildAtIndex(e-1),o=!0):(r=t.getChildAtIndex(e),o=!1),O(r)){n.set(r.__key,o?r.getTextContentSize():0,"text",!0);break}if(!C(r))break;n.set(r.__key,o?r.getChildrenSize():0,"element",!0)}}const lo=Symbol.for("@lexical/CachedTextSize");function Yc(n,t){return qs.read(()=>{let e=0,r=n;for(let o=0;o<t&&r!==null;o++){const i=Te.get(r);if(i===void 0&&$(345,r),C(i)){const s=Nt.get(r);if(s!==void 0&&C(s)&&s.__parent!==i.__parent)e+=i.getTextContentSize();else{const l=Mn.get(r),c=l&&l.__lexicalTextContent;typeof c!="string"&&$(346,i.getType()),e+=c.length}o<t-1&&!i.isInline()&&(e+=2)}else{const s=i[lo];s===void 0&&$(347,i.getType(),r),e+=s}r=i.__next}return e},{editor:lt})}function _f(n){C(n)||n[lo]===void 0&&(n[lo]=O(n)?n.__text.length:n.getTextContentSize())}const Lg=4;let co,lt,ao,Q="",Tt=null,jt=null,Kt=null;function Pe(){return{firstTextKey:Kt,format:Tt,style:jt}}function de(n){n.firstTextKey!==null&&(Tt=n.format,jt=n.style,Kt=n.firstTextKey)}function Js(n){if(Kt!==null)return;const t=n.__lexicalFirstTextKey;if(t===void 0&&$(348),t===null)return;const e=Nt.get(t);O(e)&&(Tt=e.getFormat(),jt=e.getStyle(),Kt=t)}let Bi,to,eo,Te,qs,Nt,Mn,Vs,uo,Fn,Ge=!1,fi=!1;function fn(n,t){const e=Te.get(n),r=Nt.has(n);if(t!==null){const o=Zs(n);o.parentNode===t&&t.removeChild(o)}if(!r){if(lt._keyToDOMMap.delete(n),C(e)){const o=Oi(e,Te);Ys(o,0,o.length-1,null)}if(e!==void 0){for(const o of le(e).values()){const i=Gs(o);fn(o,null),i!==null&&i.remove()}lc(uo,ao,Bi,e,"destroyed")}}}function Ys(n,t,e,r){for(let o=t;o<=e;++o){const i=n[o];i!==void 0&&fn(i,r)}}function Tn(n,t){n.setProperty("text-align",t)}const Ig="40px";function yf(n,t){const e=co.theme.indent;if(typeof e=="string"){const r=n.classList.contains(e);t>0&&!r?n.classList.add(e):t<1&&r&&n.classList.remove(e)}n.style.setProperty("padding-inline-start",t===0?"":`calc(${t} * var(--lexical-indent-base-value, ${Ig}))`)}function xf(n,t){const e=n.style;t===0?Tn(e,""):t===1?Tn(e,"left"):t===2?Tn(e,"center"):t===3?Tn(e,"right"):t===4?Tn(e,"justify"):t===5?Tn(e,"start"):t===6&&Tn(e,"end")}function Xs(n,t){const e=(function(r){const o=r.__dir;if(o!==null)return o;if(Et(r))return null;const i=r.getParent();return i===null||xt(i)&&i.__dir===null?"auto":null})(t);e!==null?n.dir=e:n.removeAttribute("dir")}function Cf(n){const t=Z().createElement("div");return t.setAttribute("data-lexical-slot",n),t.style.display="none",t}function Sf(n,t,e){t||n.contentEditable==="false"?Vp(e,lt):e.removeAttribute("contenteditable")}function Xc(n,t,e){const r=Q,o=Pe();Q="";let i="";const s=G(n);for(const[l,c]of e){const a=Cf(l);Sf(t,s,a),t.appendChild(a),Q="";const u=Pe();dn(c,Se(n,a,lt)),de(u),bf(n,l,t,a),i+=Q}return de(o),Q=r,i}function le(n){return tn(n)&&n.__slots!==null?n.__slots:zd}function bf(n,t,e,r){const o=Fn.$getSlotTargetElement(n,t,e,lt);o!==null&&(r.parentElement!==o&&o.appendChild(r),r.style.display="")}function Gs(n){const t=Mn.get(n);return t!==void 0?t.parentElement:null}function Gc(n,t,e){const r=le(n),o=le(t);for(const[u,f]of r)if(!o.has(u)){const d=Gs(f);fn(f,null),d!==null&&d.remove()}const i=Q,s=Pe();let l="",c=null;const a=G(t);for(const[u,f]of o){const d=r.get(u);let h=d!==void 0?Gs(d):null;Q="";const g=Pe();if(h===null){h=Cf(u);let _=null;for(const p of e.children)if(!p.hasAttribute("data-lexical-slot")){_=p;break}e.insertBefore(h,_),dn(f,Se(t,h,lt))}else d===f?Xe(f,h):(d!==void 0&&fn(d,h),dn(f,Se(t,h,lt)));if(de(g),Sf(e,a,h),bf(t,u,e,h),l+=Q,h.parentElement===e){const _=c===null?e.firstChild:c.nextSibling;_!==h&&e.insertBefore(h,_),c=h}}return de(s),Q=i,l}function dn(n,t){const e=Nt.get(n);if(e===void 0&&$(60),t!==null){const o=Te.get(n);if(o!==void 0){const i=Mn.get(n);if(i!==void 0){const s=Ln(o)?o.__slotHost:null,l=Ln(e)?e.__slotHost:null,c=o.__parent!==e.__parent||s!==l,a=l!==null&&i.parentElement!==t.element;if(c||a)return t.insertChild(i),Xe(n,t.element)}}}const r=Fn.$createDOM(e,lt);if((function(o,i,s){const l=s._keyToDOMMap;vd(i,s,o),l.set(o,i)})(n,r,lt),O(e)?r.setAttribute("data-lexical-text","true"):G(e)&&(r.setAttribute("data-lexical-decorator","true"),Ei(r,{captureSelection:!0})),C(e)){const o=e.__indent,i=e.__size;Xs(r,e),o!==0&&yf(r,o);const s=le(e),l=s.size>0?Xc(e,r,s):"";if(i===0)r.__lexicalTextContent=l,r.__lexicalFirstTextKey=null,Q+=l,s.size>0&&(r.__lexicalSlotTextLength=l.length);else{const a=Q,u=i-1;if(Qs(Oi(e,Nt),e,0,u,Se(e,r,lt)),l!==""){const f=r.__lexicalTextContent||"";r.__lexicalTextContent=l+f,Q=a+l+f}s.size>0&&(r.__lexicalSlotTextLength=l.length)}const c=e.__format;c!==0&&xf(r,c),e.isInline()||vf(null,e,r)}else{const o=e.getTextContent();if(G(e)){const i=e.decorate(lt,co);i!==null&&Nf(n,i),r.contentEditable="false";const s=le(e);s.size>0&&Xc(e,r,s)}Q+=o}return t!==null&&t.insertChild(r),Fn.$decorateDOM(e,null,r,lt),_f(e),lc(uo,ao,Bi,e,"created"),r}function Qs(n,t,e,r,o){const i=Q,s=Pe();Q="",Tt=null,jt=null,Kt=null;let l=e;for(;l<=r;++l){const a=Pe();dn(n[l],o);const u=Nt.get(n[l]);u!==null&&O(u)?Tt===null&&(Tt=u.getFormat(),jt=u.getStyle(),Kt=u.__key):C(u)&&l<r&&!u.isInline()&&(Q+=En),de(a)}const c=lt._keyToDOMMap.get(t.__key);c===void 0&&$(349,t.__key),c.__lexicalTextContent=Q,c.__lexicalFirstTextKey=Kt,Q=i+Q,de(s)}function vf(n,t,e){const r=Se(t,e,lt),o=r.element.__lexicalLastChildKind??null,i=(function(s,l){if(s){const c=s.__last;if(c){const a=l.get(c);if(a)return It(a)?"line-break":G(a)&&a.isInline()?"decorator":null}return le(s).size>0?null:"empty"}return null})(t,Nt);o!==i&&r.setManagedLineBreak(i)}function Kg(n,t,e){var r;Tt=null,jt=null,Kt=null,(function(o,i,s){const l=Q,c=o.__size,a=i.__size;Q="";const u=s.element,f=lt._keyToDOMMap.get(i.__key);f===void 0&&$(351,i.__key);const d=a-c;if(!Ge&&Math.abs(d)<=1&&c>=Lg&&o.__first===i.__first&&(d!==0||!lt._cloneNotNeeded.has(o.__key))){const h=f.__lexicalTextContent,g=Vs.get(o.__key);if(!Ge&&typeof h=="string"&&g!==void 0){const _=(function(p,m){const y=m.size;if(y===0||y>=p.__size)return null;let x=p.__last,b=null,T=0;for(;x!==null&&T<y;){if(!m.has(x))return null;b=x;const v=Nt.get(x);if(v===void 0)return null;x=v.__prev,T++}return T!==y||x!==null&&m.has(x)?null:b})(i,g);if(_!==null){const p=g.size;if(d===0){const m=Yc(_,p);let y=_,x=0;for(;y!==null&&x<p;){const S=Nt.get(y);if(S===void 0)break;const k=Pe();Xe(y,u),O(S)&&Tt===null&&(Tt=S.getFormat(),jt=S.getStyle(),Kt=S.__key),de(k),y=S.__next,x++}let b="";for(y=_,x=0;y!==null&&x<p;){const S=Nt.get(y);if(S===void 0)break;let k;if(C(S)){const M=lt._keyToDOMMap.get(y),E=M&&M.__lexicalTextContent;typeof E!="string"&&$(352,S.getType()),k=E}else k=S.getTextContent();b+=k,x<p-1&&C(S)&&!S.isInline()&&(b+=En),y=S.__next,x++}const T=f.__lexicalSlotTextLength||0,v=T>0?h.slice(T):h,N=v.slice(0,v.length-m)+b;return f.__lexicalTextContent=N,Q=l+N,void Qc(i,f,g)}if((function(m,y,x,b,T,v,N,S){if(S!==1&&S!==-1||N!==(S===1?2:1))return!1;const M=N-S;let E=m.__last;for(let it=0;it<M-1;it++){if(E===null)return!1;const Mt=Te.get(E);if(Mt===void 0)return!1;E=Mt.__prev}if(E===null)return!1;const F=Nt.get(v),R=Te.get(E);if(F===void 0||R===void 0||F.__prev!==R.__prev)return!1;const z=[];let q=v;for(let it=0;it<N;it++){if(q===null)return!1;z.push(q);const Mt=Nt.get(q);q=Mt?Mt.__next:null}const ot=[];q=E;for(let it=0;it<M;it++){if(q===null)return!1;ot.push(q);const Mt=Te.get(q);q=Mt?Mt.__next:null}const ct=new Set(ot),st=new Set(z),I=[];let P=0,W=0;for(;P<M&&W<N;)if(z[W]===ot[P])I.push({key:z[W],kind:"reconcile"}),P++,W++;else if(st.has(ot[P])){if(ct.has(z[W]))return!1;I.push({key:z[W],kind:"create",nextIndex:W}),W++}else I.push({key:ot[P],kind:"destroy"}),P++;for(;P<M;)I.push({key:ot[P++],kind:"destroy"});for(;W<N;)I.push({key:z[W],kind:"create",nextIndex:W}),W++;const at=Yc(E,M);for(const it of I){const Mt=Pe();if(it.kind==="reconcile")Xe(it.key,x.element);else if(it.kind==="destroy")fn(it.key,x.element);else{let ue=null;for(let Yn=it.nextIndex+1;Yn<N;Yn++){const Wr=lt._keyToDOMMap.get(z[Yn]);if(Wr!==void 0){ue=Wr;break}}dn(it.key,x.withBefore(ue??x.before))}if(it.kind!=="destroy"){const ue=Nt.get(it.key);ue&&O(ue)&&Tt===null&&(Tt=ue.getFormat(),jt=ue.getStyle(),Kt=ue.__key)}de(Mt)}let nt="";for(let it=0;it<N;it++){const Mt=Nt.get(z[it]);if(Mt===void 0)return!1;let ue;if(C(Mt)){const Yn=lt._keyToDOMMap.get(z[it]),Wr=Yn&&Yn.__lexicalTextContent;typeof Wr!="string"&&$(350,Mt.getType()),ue=Wr}else ue=Mt.getTextContent();nt+=ue,it<N-1&&C(Mt)&&!Mt.isInline()&&(nt+=En)}const At=b.__lexicalSlotTextLength||0,ae=At>0?T.slice(At):T;return b.__lexicalTextContent=ae.slice(0,ae.length-at)+nt,!0})(o,0,s,f,h,_,p,d)){const m=f.__lexicalTextContent;return typeof m!="string"&&$(353),Q=l+m,void Qc(i,f,g)}}}if(d===0){let _=o.__first,p=0;for(;_!==null;){const m=Nt.get(_);if(m===void 0)break;const y=Ge||eo.has(_)||to.has(_),x=Pe();if(y)Xe(_,u);else{let b,T;if(C(m)){T=Mn.get(_);const v=T&&T.__lexicalTextContent;typeof v!="string"&&$(354,m.getType()),b=v}else b=m.getTextContent();Q+=b,T!==void 0&&Js(T)}O(m)?Tt===null&&(Tt=m.getFormat(),jt=m.getStyle(),Kt=m.__key):C(m)&&p<a-1&&!m.isInline()&&(Q+=En),de(x),_=m.__next,p++}return f.__lexicalTextContent=Q,f.__lexicalFirstTextKey=Kt,void(Q=l+Q)}}if(c===1&&a===1){const h=o.__first,g=i.__first;if(h===g)Xe(h,u);else{const p=Zs(h),m=dn(g,null);try{p.parentNode===u?u.replaceChild(m,p):s.insertChild(m)}catch(y){if(typeof y=="object"&&y!=null){const x=`${y.toString()} Parent: ${u.tagName}, new child: {tag: ${m.tagName} key: ${g}}, old child: {tag: ${p.tagName}, key: ${h}}.`;throw new Error(x)}throw y}fn(h,null)}const _=Nt.get(g);O(_)&&Tt===null&&(Tt=_.getFormat(),jt=_.getStyle(),Kt=_.__key)}else{const h=Oi(o,Te),g=Oi(i,Nt);if(h.length!==c&&$(227),g.length!==a&&$(228),c===0)a!==0&&Qs(g,i,0,a-1,s);else if(a===0){if(c!==0){const _=s.after==null&&s.before==null&&le(i).size===0&&s.element.__lexicalLineBreak==null;Ys(h,0,c-1,_?null:u),_&&(u.textContent="")}}else(function(_,p,m,y,x,b){const T=y-1,v=x-1;let N,S,k=b.getFirstChild(),M=0,E=0;for(;M<=T&&E<=v;){const z=p[M],q=m[E],ot=Pe();if(z===q)k=ys(Xe(q,b.element)),M++,E++;else{if(S===void 0&&(S=Zc(m,E)),N===void 0)N=Zc(p,M);else if(!N.has(z)){M++,de(ot);continue}if(!S.has(z)){k=ys(Zs(z)),fn(z,b.element),M++,N.delete(z),de(ot);continue}if(N.has(q)){const st=Tr(lt,q);st!==k&&b.withBefore(k??b.before).insertChild(st),k=ys(Xe(q,b.element)),M++,E++}else dn(q,b.withBefore(k??b.before)),E++}const ct=Nt.get(q);ct!==null&&O(ct)?Tt===null&&(Tt=ct.getFormat(),jt=ct.getStyle(),Kt=ct.__key):C(ct)&&E<=v&&!ct.isInline()&&(Q+=En),de(ot)}const F=M>T,R=E>v;if(F&&!R){const z=m[v+1],q=z===void 0?null:lt.getElementByKey(z);Qs(m,_,E,v,b.withBefore(q??b.before))}else R&&!F&&Ys(p,M,T,b.element)})(i,h,g,c,a,s)}f.__lexicalTextContent=Q,f.__lexicalFirstTextKey=Kt,Q=l+Q})(n,t,Se(t,e,lt)),xt(t)||(r=t,Tt==null||Tt===r.__textFormat||fi||r.setTextFormat(Tt),(function(o){jt==null||jt===o.__textStyle||fi||o.setTextStyle(jt)})(t))}function Qc(n,t,e){const r=t.__lexicalFirstTextKey;if(r!=null){const o=n.__key;let i=r;for(;i!==null;){const s=Nt.get(i);if(s===void 0){i=null;break}if(s.__parent===o)break;i=s.__parent}if(i!==null&&!e.has(i)){const s=Nt.get(r);if(O(s))return Tt=s.getFormat(),void(jt=s.getStyle())}}t.__lexicalFirstTextKey=Kt}function Xe(n,t){const e=Te.get(n);let r=Nt.get(n);e!==void 0&&r!==void 0||$(61);const o=Ge||eo.has(n)||to.has(n),i=Tr(lt,n);if(e===r&&!o){let s;if(C(e)){const l=i.__lexicalTextContent;typeof l!="string"&&$(355,e.getType()),s=l,Js(i)}else s=e.getTextContent();return Q+=s,i}if(e!==r&&o&&lc(uo,ao,Bi,r,"updated"),Fn.$updateDOM(r,e,i,lt)){const s=dn(n,null);return t===null&&$(62),t.replaceChild(s,i),fn(n,null),s}if(C(e)){C(r)||$(334,n);const s=r.__indent;(Ge||s!==e.__indent)&&yf(i,s);const l=r.__format;(Ge||l!==e.__format)&&xf(i,l);const c=o&&(le(r).size>0||le(e).size>0)?Gc(e,r,i):"";if(o){const a=Q;if(Kg(e,r,i),Et(r)||r.isInline()||vf(0,r,i),c!==""){const u=i.__lexicalTextContent||"";i.__lexicalTextContent=c+u,Q=a+c+u,i.__lexicalSlotTextLength=c.length}else(le(r).size>0||le(e).size>0)&&(i.__lexicalSlotTextLength=0)}else{const a=i.__lexicalTextContent;typeof a!="string"&&$(356,e.getType()),Q+=a,Js(i)}if((Ge||r.__dir!==e.__dir||r.__parent!==e.__parent)&&(Xs(i,r),Et(r)&&!Ge))for(const a of r.getChildren())C(a)&&Xs(Tr(lt,a.getKey()),a)}else{const s=r.getTextContent();if(G(r)){const l=r.decorate(lt,co);l!==null&&Nf(n,l),o&&(le(r).size>0||le(e).size>0)&&Gc(e,r,i)}Q+=s}if(!fi&&Et(r)){const s=r.getLatest();if(s.__cachedText!==Q){const l=s.getWritable();l.__cachedText=Q,r=l}}return Fn.$decorateDOM(r,e,i,lt),_f(r),i}function Nf(n,t){let e=lt._pendingDecorators;const r=lt._decorators;if(e===null){if(r[n]===t)return;e=Nd(lt)}e[n]=t}function ys(n){let t=n.nextSibling;return t!==null&&t===lt._blockCursorElement&&(t=t.nextSibling),t}function Zc(n,t){const e=new Set;for(let r=t;r<n.length;r++)e.add(n[r]);return e}function zg(n,t,e,r,o,i){Q="",Tt=null,jt=null,Kt=null,Ge=r===2,lt=e,co=e._config,Fn=e._config.dom||vi,ao=e._nodes,Bi=lt._listeners.mutation,to=o,eo=i,Te=n._nodeMap,qs=n,Nt=t._nodeMap,fi=t._readOnly,Mn=af(e._keyToDOMMap),Vs=(function(){const l=new Map,c=a=>{for(const u of a){const f=Nt.get(u);if(f===void 0)continue;const d=f.__parent;if(d===null)continue;let h=l.get(d);h===void 0&&(h=new Set,l.set(d,h)),h.add(u)}};return c(to.keys()),c(eo),l})();const s=new Map;return uo=s,Xe("root",null),lt=void 0,ao=void 0,to=void 0,eo=void 0,Te=void 0,qs=void 0,Nt=void 0,co=void 0,Mn=void 0,Vs=void 0,uo=void 0,Fn=vi,s}function Zs(n){const t=Mn.get(n);return t===void 0&&$(75,n),t}function K(n){return{type:n}}const Re=K("SELECTION_CHANGE_COMMAND"),Tf=K("SELECTION_INSERT_CLIPBOARD_NODES_COMMAND"),Wi=K("CLICK_COMMAND"),kf=K("BEFORE_INPUT_COMMAND"),wf=K("INPUT_COMMAND"),Ef=K("COMPOSITION_START_COMMAND"),$f=K("COMPOSITION_END_COMMAND"),hn=K("DELETE_CHARACTER_COMMAND"),ur=K("INSERT_LINE_BREAK_COMMAND"),Dn=K("INSERT_PARAGRAPH_COMMAND"),On=K("CONTROLLED_TEXT_INSERTION_COMMAND"),Rr=K("PASTE_COMMAND"),Qo=K("REMOVE_TEXT_COMMAND"),Cr=K("DELETE_WORD_COMMAND"),Sr=K("DELETE_LINE_COMMAND"),ke=K("FORMAT_TEXT_COMMAND"),Bg=K("SET_TEXT_FORMAT_COMMAND"),Ui=K("UNDO_COMMAND"),ji=K("REDO_COMMAND"),Kl=K("KEYDOWN_COMMAND"),zl=K("KEY_ARROW_RIGHT_COMMAND"),Of=K("MOVE_TO_END"),Bl=K("KEY_ARROW_LEFT_COMMAND"),Af=K("MOVE_TO_START"),Wl=K("KEY_ARROW_UP_COMMAND"),Ul=K("KEY_ARROW_DOWN_COMMAND"),di=K("KEY_ENTER_COMMAND"),Mf=K("KEY_SPACE_COMMAND"),Hi=K("KEY_BACKSPACE_COMMAND"),jl=K("KEY_ESCAPE_COMMAND"),Hl=K("KEY_DELETE_COMMAND"),Jl=K("KEY_TAB_COMMAND"),Wg=K("INSERT_TAB_COMMAND"),Ug=K("INDENT_CONTENT_COMMAND"),ta=K("OUTDENT_CONTENT_COMMAND"),Ff=K("DROP_COMMAND"),Df=K("FORMAT_ELEMENT_COMMAND"),Pf=K("DRAGSTART_COMMAND"),Rf=K("DRAGOVER_COMMAND"),jg=K("DRAGEND_COMMAND"),Eo=K("COPY_COMMAND"),Ji=K("CUT_COMMAND"),ql=K("SELECT_ALL_COMMAND"),Hg=K("CLEAR_EDITOR_COMMAND"),Jg=K("CLEAR_HISTORY_COMMAND"),Yr=K("CAN_REDO_COMMAND"),Xr=K("CAN_UNDO_COMMAND"),Lf=K("FOCUS_COMMAND"),qg=K("BLUR_COMMAND"),Vg=K("KEY_MODIFIER_COMMAND");function Yg(n){const t=new Map;return{dispose(){for(const e of t.values())e.dispose();t.clear()},register(e,r){let o=t.get(e);o===void 0&&(o={dispose:n(e,r),holders:new Set},t.set(e,o));const i=()=>{const s=t.get(e);s&&s.holders.delete(i)&&s.holders.size===0&&(t.delete(e),s.dispose())};return o.holders.add(i),i}}}function no(n,t,e,r){return n.addEventListener(t,e,r),n.removeEventListener.bind(n,t,e,r)}const qe=Object.freeze({}),tl=[["keydown",function(n,t){const e=t._inputState;e.lastKeyDownTimeStamp=n.timeStamp,e.lastKeyCode=n.key,n.key!=="Backspace"&&fo(e),!t.isComposing()&&D(t,Kl,n)}],["pointerdown",function(n,t){const e=Rn(n),r=n.pointerType;Ae(e)&&r!=="touch"&&r!=="pen"&&n.button===0&&me(t,()=>{$i(e,t)||(t._inputState.isSelectionChangeFromMouseDown=!0)})}],["compositionstart",function(n,t){D(t,Ef,n)}],["compositionend",function(n,t){const e=t._inputState;Oe?e.compositionPhase="ending-firefox":mn||!No&&!To?D(t,$f,n):(e.compositionPhase="ending-safari",e.compositionEndData=n.data)}],["input",function(n,t){n.stopPropagation();const e=t._inputState;fo(e),me(t,()=>{Bf(n,t)||t.dispatchCommand(wf,n)},{event:n}),e.unprocessedBeforeInputData=null}],["click",function(n,t){me(t,()=>{const e=A(),r=Dt(se(t)),o=ce();if(r){if(w(e)){const i=e.anchor,s=i.getNode();i.type==="element"&&i.offset===0&&e.isCollapsed()&&!Et(s)&&Ct().getChildrenSize()===1&&s.getTopLevelElementOrThrow().isEmpty()&&o!==null&&e.is(o)&&(r.removeAllRanges(),e.dirty=!0)}else if(n.pointerType==="touch"||n.pointerType==="pen"){const i=re(r,t._rootElement).anchorNode;(B(i)||ie(i))&&gt(go(o,r,t,n))}}if(Oe&&r!==null&&r.rangeCount===0){const i=t._rootElement;if(i!==null&&n.target===i){const s=n.clientY;let l=i.childNodes.length;for(let a=0;a<i.childNodes.length;a++){const u=i.childNodes[a];if(B(u)){const f=u.getBoundingClientRect();if(s<=(f.top+f.bottom)/2){l=a;break}}}r.setBaseAndExtent(i,l,i,l);const c=go(o,r,t,n);c!==null?gt(c):r.removeAllRanges()}}D(t,Wi,n)})}],["cut",qe],["copy",qe],["dragstart",qe],["dragover",qe],["dragend",qe],["paste",qe],["focus",qe],["blur",qe],["drop",qe]];xr&&tl.push(["beforeinput",(n,t)=>(function(e,r){const o=e.inputType;o==="deleteCompositionText"||Oe&&Ed(r)||o!=="insertCompositionText"&&me(r,()=>{Bf(e,r)||D(r,kf,e)},{event:e})})(n,t)]);const el=new WeakMap,hi=new WeakMap,Xg=Yg(n=>(n.addEventListener("selectionchange",ia),()=>n.removeEventListener("selectionchange",ia)));function If(n,t,e,r,o,i){const s=n.anchor,l=n.focus,c=s.getNode(),a=ft();let u;if(i!==void 0)u=i;else{const _=Dt(se(a));u=_!==null?re(_,a._rootElement):null}const f=u!==null?u.anchorNode:null,d=s.key,h=a.getElementByKey(d),g=e.length;return d!==l.key||!O(c)||(!o&&(!xr||a._inputState.lastBeforeInputInsertTextTimeStamp<r+50)||c.isDirty()&&g<2||Td(e))&&s.offset!==l.offset&&!c.isComposing()||_e(c)||c.isDirty()&&g>1||(o||!xr)&&h!==null&&!c.isComposing()&&f!==pn(c,h,a)||u!==null&&t!==null&&(!t.collapsed||t.startContainer!==u.anchorNode||t.startOffset!==u.anchorOffset)||!c.isComposing()&&(c.getFormat()!==n.format||c.getStyle()!==n.style)||(function(_,p){if(p.isSegmented())return!0;if(!_.isCollapsed())return!1;const m=_.anchor.offset,y=p.getParentOrThrow(),x=Ni(p);return m===0?!p.canInsertTextBefore()||!y.canInsertTextBefore()&&!p.isComposing()||x||(function(b){const T=b.getPreviousSibling();return(O(T)||C(T)&&T.isInline())&&!T.canInsertTextAfter()})(p):m===p.getTextContentSize()&&(!p.canInsertTextAfter()||!y.canInsertTextAfter()&&!p.isComposing()||x)})(n,c)}function ea(n,t){return ie(n)&&n.nodeValue!==null&&t!==0&&t!==n.nodeValue.length}function na(n,t,e){const{anchorNode:r,anchorOffset:o,focusNode:i,focusOffset:s}=re(n,t._rootElement),l=t._inputState;l.isSelectionChangeFromDOMUpdate&&(l.isSelectionChangeFromDOMUpdate=!1,ea(r,o)&&ea(i,s)&&!l.postDeleteSelectionToRestore)||me(t,()=>{if(!e)return void gt(null);if(!Oo(t,r,i))return;let c=A();if(l.postDeleteSelectionToRestore&&w(c)&&c.isCollapsed()){const a=c.anchor,u=l.postDeleteSelectionToRestore.anchor;(a.key===u.key&&a.offset===u.offset+1||a.offset===1&&u.getNode().is(a.getNode().getPreviousSibling()))&&(c=l.postDeleteSelectionToRestore.clone(),gt(c))}if(l.postDeleteSelectionToRestore=null,w(c)){const a=c.anchor,u=a.getNode();if(c.isCollapsed()){n.type==="Range"&&r===i&&(c.dirty=!0);const f=se(t).event,d=f?f.timeStamp:performance.now(),{format:h,style:g,offset:_,key:p,timeStamp:m}=l.collapsedSelectionFormat,y=Ct(),x=t.isComposing()===!1&&y.getTextContent()==="";if(d<m+200&&a.offset===_&&a.key===p)Zo(c,h,g);else if(a.type==="text")O(u)||$(141),Kf(c,u);else if(a.type==="element"&&!x){C(u)||$(259);const b=a.getNode();b.isEmpty()?(function(T,v){const N=v.getTextFormat(),S=v.getTextStyle();Zo(T,N,S)})(c,b):Zo(c,c.format,"")}}else{const f=a.key,d=c.focus.key,h=c.getNodes(),g=h.length,_=c.isBackward(),p=_?s:o,m=_?o:s,y=_?d:f,x=_?f:d;let b=2047,T=!1;for(let v=0;v<g;v++){const N=h[v],S=N.getTextContentSize();if(O(N)&&S!==0&&!(v===0&&N.__key===y&&p===S||v===g-1&&N.__key===x&&m===0)&&(T=!0,b&=N.getFormat(),b===0))break}c.format=T?b:0}}D(t,Re)})}function Zo(n,t,e){n.format===t&&n.style===e||(n.format=t,n.style=e,n.dirty=!0)}function Kf(n,t){Zo(n,t.getFormat(),t.getStyle())}function zf(n){if(!n.getTargetRanges)return null;const t=n.getTargetRanges();return t.length===0?null:t[0]}function ra(n){const{lastKeyCode:t}=ft()._inputState;if(n==null||n.length<=1||t==null)return;const e=t.length===1?t:t==="Enter"?`
4
4
  `:t==="Tab"?" ":null;if(!e)return;const r=A();if(!w(r)||!r.isCollapsed())return;const o=r.anchor.getNode();if(!O(o))return;const{offset:i}=r.anchor;if(o.getTextContentSize()===i){const s=o.getNextSibling();if(e===`
@@ -22,4 +22,4 @@ import{a as vo,r as L,j,a0 as Dc}from"./index-Z0KvXoPD.js";import{s as Zu,U as s
22
22
  `)}ar(s,Vu,c);const u=wt(l);s.append(u),n.append(s)}else t&&eg(u=>te(u?u[2]:void 0))(n,t,e,i)},type:"multiline-element"},Vx={dependencies:[qn,vn],export:(n,t,e)=>Y(n)?Fc(n,t,0,e):null,regExp:Ix,replace:ng("bullet"),triggerOnEnter:!0,type:"element"},Yx={dependencies:[qn,vn],export:(n,t,e)=>Y(n)?Fc(n,t,0,e):null,regExp:Lx,replace:ng("number"),triggerOnEnter:!0,type:"element"},Xx={format:["code"],tag:"`",type:"text-format"},Gx={format:["highlight"],tag:"==",type:"text-format"},Qx={format:["bold","italic"],tag:"***",type:"text-format"},Zx={format:["bold","italic"],intraword:!1,tag:"___",type:"text-format"},tC={format:["bold"],tag:"**",type:"text-format"},eC={format:["bold"],intraword:!1,tag:"__",type:"text-format"},nC={format:["strikethrough"],tag:"~~",type:"text-format"},rC={format:["italic"],tag:"*",type:"text-format"},oC={format:["italic"],intraword:!1,tag:"_",type:"text-format"},iC={dependencies:[xn],export:(n,t,e)=>{if(!Qt(n)||ir(n))return null;const r=t(n);let o=n.getTitle();return o!=null&&(o=o.replace(/([\\"])/g,"\\$1")),o?`[${r}](${n.getURL()} "${o}")`:`[${r}](${n.getURL()})`},importRegExp:/(?:\[(.+?)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))/,regExp:/(?:\[([^[\]]*(?:\[[^[\]]*\][^[\]]*)*)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))$/,replace:(n,t)=>{if(U(n,Qt))return;const[,e,r,o]=t,i=r!=null?qu(r):void 0,s=o!=null?qu(o):void 0,l=bo(i,{title:s}),c=e.split("[").length-1,a=e.split("]").length-1;let u=e,f="";if(c<a)return;if(c>a){const h=e.split("[");f="["+h[0],u=h.slice(1).join("[")}const d=wt(u);return d.setFormat(n.getFormat()),l.append(d),n.replace(l),f&&l.insertBefore(wt(f)),d},trigger:")",type:"text-match"},sC=[Jx,qx,Vx,Yx],lC=[li],cC=[Xx,Qx,Zx,tC,eC,Gx,rC,oC,nC],aC=[iC],rg=[...sC,...lC,...cC,...aC];function uC(n,t,e,r,o){for(const i of t){if(!i.export)continue;const s=i.export(n,l=>zi(l,e,r,void 0,void 0,o));if(s!=null)return s}return C(n)?zi(n,e,r,void 0,void 0,o):G(n)?n.getTextContent():null}function zi(n,t,e,r,o,i=!1){const s=[],l=n.getChildren();r||(r=[]),o||(o=[]);t:for(const c of l){for(const a of e){if(!a.export)continue;const u=a.export(c,f=>zi(f,t,e,r,[...o,...r],i),(f,d)=>Yu(f,d,t,r,o,i));if(u!=null){s.push(u);continue t}}It(c)?s.push(fC(c)):O(c)?s.push(Yu(c,c.getTextContent(),t,r,o,i)):C(c)?s.push(zi(c,t,e,r,o,i)):G(c)&&s.push(c.getTextContent())}return s.join("")}function fC(n){return wo(n,tg)+`
23
23
  `}function Yu(n,t,e,r,o,i=!1){const s=n.hasFormat("code");let l,c,a,u,f=t;if(s||(f=i?f.replace(/([*_`~])/g,"\\$1"):f.replace(/([*_`~\\])/g,"\\$1")),s){const{fence:y,padded:x}=(function(b){const T=b.match(/`+/g),v=T?Math.max(...T.map(N=>N.length)):0;return{fence:"`".repeat(v+1),padded:b.length===0||b.includes("`")||/^\s/.test(b)&&/\s$/.test(b)?` ${b} `:b}})(t);l="",a="",c=y+x+y,u=!1}else{const y=f.match(/^(\s*)(.*?)(\s*)$/s)||["","",f,""];l=y[1],c=y[2],a=y[3],u=c===""}let d="",h="",g="";const _=Xu(n,!0),p=Xu(n,!1),m=new Set;for(const y of e){const x=y.format[0],b=y.tag;x!=="code"&&Gu(n,x)&&!m.has(x)&&(m.add(x),Gu(_,x)&&r.find(T=>T.tag===b)||(r.push({format:x,tag:b}),d+=b))}for(let y=0;y<r.length;y++){const x=Pl(n,r[y].format),b=Pl(p,r[y].format);if(x&&b)continue;const T=[...r];for(;T.length>y;){const v=T.pop();o&&v&&o.find(N=>N.tag===v.tag)||(v&&typeof v.tag=="string"&&(x?b||(g+=v.tag):h+=v.tag),r.pop())}break}return u&&!n.hasFormat("code")?h+f:h+l+d+c+g+a}function Xu(n,t){const e=t?n.getPreviousSibling():n.getNextSibling();return O(e)?e:null}function Pl(n,t){return O(n)&&n.hasFormat(t)}function Gu(n,t){return!!Pl(n,t)&&(t==="code"||!n||!/^\s*$/.test(n.getTextContent()))}function dC(n=rg,t,e=!1){return(function(o,i=!1){const s=Px(o),l=[...s.multilineElement,...s.element],c=!i,a=s.textFormat.filter(u=>u.format.length===1).sort((u,f)=>Number(u.format.includes("code"))-Number(f.format.includes("code")));return u=>{const f=[],d=(u||Ct()).getChildren();for(let h=0;h<d.length;h++){const g=d[h],_=uC(g,l,a,s.textMatch,i);_!=null&&f.push(c&&h>0&&!Ju(g)&&!Ju(d[h-1])?`
24
24
  `.concat(_):_)}return f.join(`
25
- `)}})(n,e)(t)}const og=(n,t)=>{const e=new DOMParser().parseFromString(Zu(t),"text/html");return kh(n,e)},hC=n=>({html:Zu(wh(n,null)),text:dC(rg)});function Qu(n,t){return n.read("latest",()=>{const e=tt(t);return e!==null&&e.isSelected()})}function gC(n){const[t]=oe(),[e,r]=L.useState(()=>Qu(t,n));return L.useEffect(()=>{let o=!0;const i=t.registerUpdateListener(()=>{o&&r(Qu(t,n))});return()=>{o=!1,i()}},[t,n]),[e,L.useCallback(o=>{t.update(()=>{let i=A();dt(i)||(i=ho(),gt(i)),dt(i)&&(o?i.add(n):i.delete(n))})},[t,n]),L.useCallback(()=>{t.update(()=>{const o=A();dt(o)&&o.clear()})},[t])]}function pC({nodeKey:n}){const[t]=oe(),[e,r,o]=gC(n);return L.useEffect(()=>qt(t.registerCommand(Wi,i=>{const s=t.getElementByKey(n);return Rn(i)===s&&(i.shiftKey||o(),r(!e),!0)},he)),[o,t,e,n,r]),L.useEffect(()=>{const i=t.getElementByKey(n),s=t._config.theme.hrSelected??"selected";i!==null&&(e?kt(i,s):We(i,s))},[t,e,n]),null}class ig extends bc{$config(){return this.config("horizontalrule",{importDOM:{hr:()=>({conversion:mC,priority:0})}})}decorate(){return j.jsx(pC,{nodeKey:this.__key})}}function mC(){return{node:_C()}}function _C(){return Gt(new ig)}const yC=[cs,ls,qn,vn,xn,wc,Pr,as,Vn,gs,Mc,ig],xC={code:"block my-2 rounded bg-surface-sunken p-2 font-mono text-xs whitespace-pre-wrap",heading:{h1:"mt-3 mb-1 text-xl font-semibold",h2:"mt-3 mb-1 text-lg font-semibold",h3:"mt-2 mb-1 text-base font-semibold",h4:"mt-2 mb-1 text-sm font-semibold",h5:"mt-2 mb-1 text-sm font-semibold",h6:"mt-2 mb-1 text-xs font-semibold uppercase tracking-wide"},hr:"my-3 border-t border-line",link:"text-accent underline",list:{listitem:"ml-2",nested:{listitem:"list-none"},ol:"my-1 list-decimal pl-6",ul:"my-1 list-disc pl-6"},paragraph:"my-1",quote:"my-1 border-l-2 border-fg-subtle/30 pl-3 text-fg-muted [&_p]:my-0.5",table:"my-2 w-full table-fixed border-collapse",tableCell:"border border-line px-2 py-1 align-top",tableCellHeader:"bg-surface-sunken font-semibold",text:{bold:"font-semibold",code:"rounded bg-surface-sunken px-1 font-mono text-xs",italic:"italic",strikethrough:"line-through",underline:"underline"}},rr=({isActive:n,onClick:t,children:e,title:r})=>j.jsx("button",{type:"button",onMouseDown:o=>{o.preventDefault(),t()},title:r,"aria-label":r,"aria-pressed":n,className:`p-1.5 rounded transition-colors ${n?"text-fg bg-accent-2-soft":"text-fg-muted hover:text-fg hover:bg-surface-raised"}`,children:e}),CC={bold:!1,italic:!1,quote:!1,link:null,canUndo:!1,canRedo:!1},SC=()=>{const[n]=oe(),[t,e]=L.useState(CC),[r,o]=L.useState(null),i=L.useRef(null),s=L.useCallback(()=>{const a=A();if(!w(a))return;const u=a.anchor.getNode(),f=U(u,Qt),d=U(u,wl);e(h=>({...h,bold:a.hasFormat("bold"),italic:a.hasFormat("italic"),quote:d!==null,link:Qt(f)?f.getURL():null}))},[]);L.useEffect(()=>qt(n.registerUpdateListener(({editorState:a})=>{a.read(s)}),n.registerCommand(Re,()=>(s(),!1),he),n.registerCommand(Xr,a=>(e(u=>({...u,canUndo:a})),!1),he),n.registerCommand(Yr,a=>(e(u=>({...u,canRedo:a})),!1),he)),[n,s]),L.useEffect(()=>{r!==null&&i.current?.focus()},[r]);const l=()=>{n.update(()=>{const a=A();w(a)&&Tm(a,()=>t.quote?V():Br())})},c=a=>{const u=a.trim();n.dispatchCommand(xl,u===""?null:u),o(null),n.focus()};return j.jsxs("div",{className:"border-b border-line",children:[j.jsxs("div",{className:"flex items-center gap-0.5 px-3 py-1",children:[j.jsx(rr,{isActive:t.bold,onClick:()=>n.dispatchCommand(ke,"bold"),title:"Bold (Ctrl+B)",children:j.jsx(lg,{className:"size-4"})}),j.jsx(rr,{isActive:t.italic,onClick:()=>n.dispatchCommand(ke,"italic"),title:"Italic (Ctrl+I)",children:j.jsx(cg,{className:"size-4"})}),j.jsx(rr,{isActive:t.link!==null,onClick:()=>o(t.link??"https://"),title:"Link (Ctrl+K)",children:j.jsx(ag,{className:"size-4"})}),j.jsx(rr,{isActive:t.quote,onClick:l,title:"Blockquote",children:j.jsx(ug,{className:"size-4"})}),j.jsx("div",{className:"mx-1.5 h-4 w-px bg-line"}),j.jsx(rr,{isActive:!1,onClick:()=>n.dispatchCommand(Ui,void 0),title:"Undo (Ctrl+Z)",children:j.jsx(sg,{className:`size-4 ${t.canUndo?"":"opacity-40"}`})}),j.jsx(rr,{isActive:!1,onClick:()=>n.dispatchCommand(ji,void 0),title:"Redo (Ctrl+Y)",children:j.jsx(fg,{className:`size-4 ${t.canRedo?"":"opacity-40"}`})})]}),r!==null&&j.jsxs("div",{className:"flex items-center gap-2 border-t border-line px-3 py-1.5",children:[j.jsx("input",{ref:i,type:"url",value:r,"aria-label":"Link address",placeholder:"https://example.com",className:"min-w-0 flex-1 bg-transparent text-sm text-fg outline-none placeholder:text-fg-subtle",onChange:a=>o(a.target.value),onKeyDown:a=>{a.key==="Enter"&&(a.preventDefault(),c(r)),a.key==="Escape"&&(a.preventDefault(),o(null),n.focus())}}),j.jsx("button",{type:"button",className:"text-xs text-accent hover:underline",onClick:()=>c(r),children:"Apply"}),t.link!==null&&j.jsx("button",{type:"button",className:"text-xs text-fg-muted hover:text-fg",onClick:()=>c(""),children:"Remove"})]})]})},bC=()=>{const[n]=oe(),t=L.useRef(!1);return L.useEffect(()=>qt(n.registerCommand(Kl,e=>((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()==="v"&&(t.current=e.shiftKey),!1),he),n.registerCommand(Rr,e=>{if(!(e instanceof ClipboardEvent))return!1;const r=e.clipboardData;if(!r)return!1;const o=t.current;if(t.current=!1,o){const s=A();return w(s)?(e.preventDefault(),s.insertRawText(r.getData("text/plain")),!0):!1}const i=r.getData("text/html");return i?(e.preventDefault(),Xl(og(n,i)),!0):!1},md)),[n]),null},vC=({onChange:n})=>{const[t]=oe(),e=L.useRef(n);return L.useEffect(()=>{e.current=n},[n]),L.useEffect(()=>{const r=()=>e.current(t.read(()=>hC(t)));return r(),t.registerUpdateListener(({dirtyElements:o,dirtyLeaves:i})=>{o.size===0&&i.size===0||r()})},[t]),null},NC=({enabled:n})=>{const[t]=oe();return L.useEffect(()=>{if(!n)return;const e=setTimeout(()=>t.focus(),0);return()=>clearTimeout(e)},[t,n]),null},TC=n=>t=>{const e=og(t,n);e.length!==0&&(Ct().select(),Xl(e))},kC=({initialHtml:n,onChange:t,onSubmit:e,autoFocus:r=!1,placeholder:o="Write your message…",ariaLabel:i="Message body"})=>j.jsxs(dm,{initialConfig:{namespace:"compose",nodes:yC,theme:xC,editorState:n?TC(n):void 0,onError:s=>{throw s}},children:[j.jsxs("div",{className:"flex shrink-0 grow flex-col",children:[j.jsx(SC,{}),j.jsx("div",{className:"relative flex shrink-0 grow flex-col",children:j.jsx(zy,{contentEditable:j.jsx(ym,{"aria-label":i,"aria-placeholder":o,"data-testid":"compose-body",className:"min-h-[120px] w-full shrink-0 grow bg-canvas px-3 py-2 text-sm text-fg outline-none",placeholder:j.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 px-3 py-2 text-sm text-fg-subtle",children:o}),onKeyDown:s=>{e&&(!(s.metaKey||s.ctrlKey)||s.key!=="Enter"||(s.preventDefault(),e()))}}),ErrorBoundary:bm})})]}),j.jsx(r_,{}),j.jsx(ay,{}),j.jsx(Y_,{}),j.jsx(bx,{}),j.jsx(bC,{}),j.jsx(NC,{enabled:r}),t&&j.jsx(vC,{onChange:t})]}),QC=({initialHtml:n,onChange:t,onSubmit:e,autoFocus:r})=>j.jsx(kC,{initialHtml:n,onChange:t,onSubmit:e,autoFocus:r});export{QC as ComposeBody};
25
+ `)}})(n,e)(t)}const og=(n,t)=>{const e=new DOMParser().parseFromString(Zu(t),"text/html");return kh(n,e)},hC=n=>({html:Zu(wh(n,null)),text:dC(rg)});function Qu(n,t){return n.read("latest",()=>{const e=tt(t);return e!==null&&e.isSelected()})}function gC(n){const[t]=oe(),[e,r]=L.useState(()=>Qu(t,n));return L.useEffect(()=>{let o=!0;const i=t.registerUpdateListener(()=>{o&&r(Qu(t,n))});return()=>{o=!1,i()}},[t,n]),[e,L.useCallback(o=>{t.update(()=>{let i=A();dt(i)||(i=ho(),gt(i)),dt(i)&&(o?i.add(n):i.delete(n))})},[t,n]),L.useCallback(()=>{t.update(()=>{const o=A();dt(o)&&o.clear()})},[t])]}function pC({nodeKey:n}){const[t]=oe(),[e,r,o]=gC(n);return L.useEffect(()=>qt(t.registerCommand(Wi,i=>{const s=t.getElementByKey(n);return Rn(i)===s&&(i.shiftKey||o(),r(!e),!0)},he)),[o,t,e,n,r]),L.useEffect(()=>{const i=t.getElementByKey(n),s=t._config.theme.hrSelected??"selected";i!==null&&(e?kt(i,s):We(i,s))},[t,e,n]),null}class ig extends bc{$config(){return this.config("horizontalrule",{importDOM:{hr:()=>({conversion:mC,priority:0})}})}decorate(){return j.jsx(pC,{nodeKey:this.__key})}}function mC(){return{node:_C()}}function _C(){return Gt(new ig)}const yC=[cs,ls,qn,vn,xn,wc,Pr,as,Vn,gs,Mc,ig],xC={code:"block my-2 rounded bg-surface-sunken p-2 font-mono text-xs whitespace-pre-wrap",heading:{h1:"mt-3 mb-1 text-xl font-semibold",h2:"mt-3 mb-1 text-lg font-semibold",h3:"mt-2 mb-1 text-base font-semibold",h4:"mt-2 mb-1 text-sm font-semibold",h5:"mt-2 mb-1 text-sm font-semibold",h6:"mt-2 mb-1 text-xs font-semibold uppercase tracking-wide"},hr:"my-3 border-t border-line",link:"text-accent underline",list:{listitem:"ml-2",nested:{listitem:"list-none"},ol:"my-1 list-decimal pl-6",ul:"my-1 list-disc pl-6"},paragraph:"my-1",quote:"my-1 border-l-2 border-fg-subtle/30 pl-3 text-fg-muted [&_p]:my-0.5",table:"my-2 w-full table-fixed border-collapse",tableCell:"border border-line px-2 py-1 align-top",tableCellHeader:"bg-surface-sunken font-semibold",text:{bold:"font-semibold",code:"rounded bg-surface-sunken px-1 font-mono text-xs",italic:"italic",strikethrough:"line-through",underline:"underline"}},rr=({isActive:n,onClick:t,children:e,title:r})=>j.jsx("button",{type:"button",onMouseDown:o=>{o.preventDefault(),t()},title:r,"aria-label":r,"aria-pressed":n,className:`p-1.5 rounded transition-colors ${n?"text-fg bg-accent-2-soft":"text-fg-muted hover:text-fg hover:bg-surface-raised"}`,children:e}),CC={bold:!1,italic:!1,quote:!1,link:null,canUndo:!1,canRedo:!1},SC=()=>{const[n]=oe(),[t,e]=L.useState(CC),[r,o]=L.useState(null),i=L.useRef(null),s=L.useCallback(()=>{const a=A();if(!w(a))return;const u=a.anchor.getNode(),f=U(u,Qt),d=U(u,wl);e(h=>({...h,bold:a.hasFormat("bold"),italic:a.hasFormat("italic"),quote:d!==null,link:Qt(f)?f.getURL():null}))},[]);L.useEffect(()=>qt(n.registerUpdateListener(({editorState:a})=>{a.read(s)}),n.registerCommand(Re,()=>(s(),!1),he),n.registerCommand(Xr,a=>(e(u=>({...u,canUndo:a})),!1),he),n.registerCommand(Yr,a=>(e(u=>({...u,canRedo:a})),!1),he)),[n,s]),L.useEffect(()=>{r!==null&&i.current?.focus()},[r]);const l=()=>{n.update(()=>{const a=A();w(a)&&Tm(a,()=>t.quote?V():Br())})},c=a=>{const u=a.trim();n.dispatchCommand(xl,u===""?null:u),o(null),n.focus()};return j.jsxs("div",{className:"border-b border-line",children:[j.jsxs("div",{className:"flex items-center gap-0.5 px-3 py-1",children:[j.jsx(rr,{isActive:t.bold,onClick:()=>n.dispatchCommand(ke,"bold"),title:"Bold (Ctrl+B)",children:j.jsx(lg,{className:"size-4"})}),j.jsx(rr,{isActive:t.italic,onClick:()=>n.dispatchCommand(ke,"italic"),title:"Italic (Ctrl+I)",children:j.jsx(cg,{className:"size-4"})}),j.jsx(rr,{isActive:t.link!==null,onClick:()=>o(t.link??"https://"),title:"Link (Ctrl+K)",children:j.jsx(ag,{className:"size-4"})}),j.jsx(rr,{isActive:t.quote,onClick:l,title:"Blockquote",children:j.jsx(ug,{className:"size-4"})}),j.jsx("div",{className:"mx-1.5 h-4 w-px bg-line"}),j.jsx(rr,{isActive:!1,onClick:()=>n.dispatchCommand(Ui,void 0),title:"Undo (Ctrl+Z)",children:j.jsx(sg,{className:`size-4 ${t.canUndo?"":"opacity-40"}`})}),j.jsx(rr,{isActive:!1,onClick:()=>n.dispatchCommand(ji,void 0),title:"Redo (Ctrl+Y)",children:j.jsx(fg,{className:`size-4 ${t.canRedo?"":"opacity-40"}`})})]}),r!==null&&j.jsxs("div",{className:"flex items-center gap-2 border-t border-line px-3 py-1.5",children:[j.jsx("input",{ref:i,type:"url",value:r,"aria-label":"Link address",placeholder:"https://example.com",className:"min-w-0 flex-1 bg-transparent text-sm text-fg outline-none placeholder:text-fg-subtle",onChange:a=>o(a.target.value),onKeyDown:a=>{a.key==="Enter"&&(a.preventDefault(),c(r)),a.key==="Escape"&&(a.preventDefault(),o(null),n.focus())}}),j.jsx("button",{type:"button",className:"text-xs text-accent hover:underline",onClick:()=>c(r),children:"Apply"}),t.link!==null&&j.jsx("button",{type:"button",className:"text-xs text-fg-muted hover:text-fg",onClick:()=>c(""),children:"Remove"})]})]})},bC=()=>{const[n]=oe(),t=L.useRef(!1);return L.useEffect(()=>qt(n.registerCommand(Kl,e=>((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()==="v"&&(t.current=e.shiftKey),!1),he),n.registerCommand(Rr,e=>{if(!(e instanceof ClipboardEvent))return!1;const r=e.clipboardData;if(!r)return!1;const o=t.current;if(t.current=!1,o){const s=A();return w(s)?(e.preventDefault(),s.insertRawText(r.getData("text/plain")),!0):!1}const i=r.getData("text/html");return i?(e.preventDefault(),Xl(og(n,i)),!0):!1},md)),[n]),null},vC=({onChange:n})=>{const[t]=oe(),e=L.useRef(n);return L.useEffect(()=>{e.current=n},[n]),L.useEffect(()=>{const r=()=>e.current(t.read(()=>hC(t)));return r(),t.registerUpdateListener(({dirtyElements:o,dirtyLeaves:i})=>{o.size===0&&i.size===0||r()})},[t]),null},NC=({enabled:n})=>{const[t]=oe();return L.useEffect(()=>{if(!n)return;const e=setTimeout(()=>t.focus(),0);return()=>clearTimeout(e)},[t,n]),null},TC=n=>t=>{const e=og(t,n);e.length!==0&&(Ct().select(),Xl(e))},kC=({initialHtml:n,onChange:t,onSubmit:e,autoFocus:r=!1,placeholder:o="Write your message…",ariaLabel:i="Message body"})=>j.jsxs(dm,{initialConfig:{namespace:"compose",nodes:yC,theme:xC,editorState:n?TC(n):void 0,onError:s=>{throw s}},children:[j.jsxs("div",{className:"flex shrink-0 grow flex-col",children:[j.jsx(SC,{}),j.jsx("div",{className:"relative flex shrink-0 grow flex-col",children:j.jsx(zy,{contentEditable:j.jsx(ym,{"aria-label":i,"aria-placeholder":o,"data-testid":"compose-body",className:"min-h-[120px] w-full shrink-0 grow bg-canvas px-3 py-2 text-sm text-fg outline-none",placeholder:j.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 px-3 py-2 text-sm text-fg-subtle",children:o}),onKeyDown:s=>{e&&(!(s.metaKey||s.ctrlKey)||s.key!=="Enter"||(s.preventDefault(),e()))}}),ErrorBoundary:bm})})]}),j.jsx(r_,{}),j.jsx(ay,{}),j.jsx(Y_,{}),j.jsx(bx,{}),j.jsx(bC,{}),j.jsx(NC,{enabled:r}),t&&j.jsx(vC,{onChange:t})]}),ZC=({initialHtml:n,onChange:t,onSubmit:e,autoFocus:r})=>j.jsx(kC,{initialHtml:n,onChange:t,onSubmit:e,autoFocus:r});export{ZC as ComposeBody};
@@ -1 +1 @@
1
- import{r as a,j as t,at as o}from"./index-Z0KvXoPD.js";const g=({isOpen:s,title:i,description:l,confirmLabel:d,cancelLabel:u="Cancel",destructive:m=!1,isBusy:f=!1,onConfirm:x,onCancel:r})=>{const c=a.useRef(null),n=a.useCallback(e=>{e.key==="Escape"&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),r())},[r]);return a.useEffect(()=>{if(s)return window.addEventListener("keydown",n,!0),()=>window.removeEventListener("keydown",n,!0)},[s,n]),a.useEffect(()=>{s&&c.current?.focus()},[s]),s?t.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[t.jsx("div",{className:"absolute inset-0 bg-canvas/80 backdrop-blur-sm","aria-hidden":"true",onClick:r}),t.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"),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:[t.jsx("h2",{className:"text-lg font-semibold",children:i}),l&&t.jsx("p",{className:"mt-2 text-sm text-fg-muted",children:l}),t.jsxs("div",{className:"mt-6 flex items-center justify-end gap-2",children:[t.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:u}),t.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",m?"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{g as C};
1
+ import{r as a,j as t,at as o}from"./index-CFFTFBUh.js";const g=({isOpen:s,title:i,description:l,confirmLabel:d,cancelLabel:u="Cancel",destructive:m=!1,isBusy:f=!1,onConfirm:x,onCancel:r})=>{const c=a.useRef(null),n=a.useCallback(e=>{e.key==="Escape"&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),r())},[r]);return a.useEffect(()=>{if(s)return window.addEventListener("keydown",n,!0),()=>window.removeEventListener("keydown",n,!0)},[s,n]),a.useEffect(()=>{s&&c.current?.focus()},[s]),s?t.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[t.jsx("div",{className:"absolute inset-0 bg-canvas/80 backdrop-blur-sm","aria-hidden":"true",onClick:r}),t.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"),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:[t.jsx("h2",{className:"text-lg font-semibold",children:i}),l&&t.jsx("p",{className:"mt-2 text-sm text-fg-muted",children:l}),t.jsxs("div",{className:"mt-6 flex items-center justify-end gap-2",children:[t.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:u}),t.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",m?"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{g as C};
@@ -1 +1 @@
1
- import{j as t,g as r}from"./index-Z0KvXoPD.js";const d=e=>e instanceof Error?e.message:typeof e=="string"?e:typeof e=="object"&&e!==null&&"message"in e&&typeof e.message=="string"?e.message:"An unexpected error occurred",l=({title:e="Couldn't load content",error:a,onRetry:s,variant:i="block"})=>{const n=d(a);return i==="inline"?t.jsxs("div",{role:"alert",className:"flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-sm",children:[t.jsx(r,{className:"size-4 shrink-0 text-danger mt-0.5","aria-hidden":"true"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"font-medium text-danger",children:e}),t.jsx("p",{className:"text-fg-muted mt-0.5 break-words",children:n})]}),s&&t.jsx("button",{type:"button",onClick:s,className:"shrink-0 text-sm font-medium text-accent hover:underline",children:"Retry"})]}):t.jsxs("div",{role:"alert",className:"flex flex-col items-center justify-center gap-3 p-8 text-center",children:[t.jsx(r,{className:"size-8 text-danger","aria-hidden":"true"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium text-danger",children:e}),t.jsx("p",{className:"text-sm text-fg-muted mt-1 break-words",children:n})]}),s&&t.jsx("button",{type:"button",onClick:s,className:"inline-flex items-center rounded-md border border-line bg-canvas px-4 py-2 text-sm font-medium hover:bg-surface-raised transition-colors",children:"Retry"})]})};export{l as E,d as f};
1
+ import{j as t,g as r}from"./index-CFFTFBUh.js";const d=e=>e instanceof Error?e.message:typeof e=="string"?e:typeof e=="object"&&e!==null&&"message"in e&&typeof e.message=="string"?e.message:"An unexpected error occurred",l=({title:e="Couldn't load content",error:a,onRetry:s,variant:i="block"})=>{const n=d(a);return i==="inline"?t.jsxs("div",{role:"alert",className:"flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-sm",children:[t.jsx(r,{className:"size-4 shrink-0 text-danger mt-0.5","aria-hidden":"true"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"font-medium text-danger",children:e}),t.jsx("p",{className:"text-fg-muted mt-0.5 break-words",children:n})]}),s&&t.jsx("button",{type:"button",onClick:s,className:"shrink-0 text-sm font-medium text-accent hover:underline",children:"Retry"})]}):t.jsxs("div",{role:"alert",className:"flex flex-col items-center justify-center gap-3 p-8 text-center",children:[t.jsx(r,{className:"size-8 text-danger","aria-hidden":"true"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium text-danger",children:e}),t.jsx("p",{className:"text-sm text-fg-muted mt-1 break-words",children:n})]}),s&&t.jsx("button",{type:"button",onClick:s,className:"inline-flex items-center rounded-md border border-line bg-canvas px-4 py-2 text-sm font-medium hover:bg-surface-raised transition-colors",children:"Retry"})]})};export{l as E,d as f};
@@ -1 +1 @@
1
- import{a as re,j as e,d as z,c0 as V,l as oe,r as i,e as he,cf as I,c1 as F,ab as xe,aJ as Q,bX as fe,b_ as ye,aG as X,av as Y,aR as ne,B as C,L as D,bZ as ge,c2 as ve,G as q,ca as be,q as je}from"./index-Z0KvXoPD.js";import{K as Se}from"./kbd-D5tq3erg.js";import{c as we,M as ke}from"./account-form-helpers-qliPkUSX.js";const K=re("AtSign",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]]);const Ce=re("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);function Ne({url:t}){return e.jsxs("p",{className:"text-2xs text-fg-subtle",children:["Stored encrypted, used only to connect to your mail server."," ",t?e.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"How to create an app password"}):e.jsx("span",{children:"Check your provider's help for app password instructions."})]})}function Ee({raised:t,className:o,...s}){return e.jsx("div",{className:z("rounded-sm border border-line bg-surface",t?"bg-surface-raised shadow-sm":"",o),...s})}function J({value:t,defaultValue:o,onValueChange:s,...a}){return s?e.jsxs(V,{value:t,onChange:n=>s(n.target.value),...a,children:[e.jsx("option",{value:"tls",children:"TLS/SSL"}),e.jsx("option",{value:"starttls",children:"STARTTLS"}),e.jsx("option",{value:"none",children:"None (insecure)"})]}):e.jsxs(V,{defaultValue:o??t,...a,children:[e.jsx("option",{value:"tls",children:"TLS/SSL"}),e.jsx("option",{value:"starttls",children:"STARTTLS"}),e.jsx("option",{value:"none",children:"None (insecure)"})]})}function G(t){return{tls:t==="tls",startTls:t==="starttls"}}function Te({steps:t,activeStep:o}){return e.jsx("ol",{className:"flex items-center gap-1",children:t.map((s,a)=>{const n=a<o,r=a===o;return e.jsxs("li",{className:"flex items-center gap-1",children:[a>0&&e.jsx("span",{className:"h-px w-5 bg-line","aria-hidden":!0}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:z("flex size-5 items-center justify-center rounded-full text-2xs font-semibold tabular-nums",n&&"bg-accent text-accent-fg",r&&"bg-accent-soft text-accent ring-1 ring-accent",!n&&!r&&"bg-surface-sunken text-fg-subtle"),children:n?e.jsx(oe,{className:"size-3"}):a+1}),e.jsx("span",{className:z("hidden text-2xs sm:inline",r?"font-medium text-fg":"text-fg-subtle"),children:s})]})]},s)})})}function L({steps:t,activeStep:o,title:s,subtitle:a,children:n,footer:r,hideSteps:u}){return e.jsxs("div",{className:"flex min-h-dvh w-full flex-col items-center overflow-y-auto bg-canvas pb-[max(2rem,env(safe-area-inset-bottom,0px))] pl-[max(2rem,env(safe-area-inset-left,0px))] pr-[max(2rem,env(safe-area-inset-right,0px))] pt-[max(2rem,env(safe-area-inset-top,0px))] font-sans text-fg sm:pt-[30vh]",children:[!u&&e.jsx("div",{className:"mb-5 w-full max-w-xl",children:e.jsx(Te,{steps:t,activeStep:o})}),e.jsxs(Ee,{raised:!0,className:"w-full max-w-xl",children:[e.jsxs("div",{className:"px-5 pt-5",children:[e.jsx("h1",{className:"text-xl font-semibold text-fg",children:s}),a&&e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:a})]}),e.jsx("div",{className:"px-5 py-5",children:n}),r&&e.jsx("div",{className:"flex items-center justify-between gap-3 border-t border-line px-5 py-3",children:r})]})]})}const Pe="Coming soon — use IMAP for now.";function W({name:t,description:o,icon:s,comingSoon:a,selected:n,onSelect:r}){const[u,h]=i.useState(!1),c=()=>{if(r){r();return}a&&h(!0)};return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("button",{type:"button",onClick:c,"aria-disabled":a||void 0,className:z("flex flex-col items-start gap-2 rounded-sm border p-3 text-left transition-colors",n?"border-accent-2 bg-accent-2-soft":"border-line bg-surface hover:border-line-strong",a&&"opacity-55"),children:[e.jsx("span",{className:z("text-fg-muted",n&&"text-accent-2"),children:s}),e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold text-fg",children:t}),a&&e.jsx("span",{className:"rounded-full bg-surface-sunken px-1.5 py-0.5 text-2xs text-fg-subtle",children:"soon"})]}),e.jsx("span",{className:"text-xs text-fg-subtle",children:o})]}),u&&e.jsx("p",{className:"text-2xs text-fg-subtle",children:Pe})]})}function Z({legend:t,badge:o,host:s,port:a,security:n,readOnly:r,onHostChange:u,onPortChange:h,onSecurityChange:c,hostPlaceholder:v,portPlaceholder:j}){const S=i.useId(),y=i.useId(),w=i.useId();return e.jsxs("fieldset",{children:[e.jsxs("legend",{className:"flex items-center gap-2 text-sm font-semibold text-fg",children:[t,o&&e.jsx(he,{tone:o.tone,children:o.label})]}),e.jsxs("div",{className:"mt-2 grid grid-cols-1 gap-3 sm:grid-cols-[1fr_6rem_8rem] sm:gap-2",children:[e.jsxs("div",{children:[e.jsx(I,{htmlFor:S,children:"Host"}),u?e.jsx(F,{id:S,readOnly:r,value:s,onChange:x=>u(x.target.value),placeholder:v}):e.jsx(F,{id:S,readOnly:r,defaultValue:s,placeholder:v})]}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:y,children:"Port"}),h?e.jsx(F,{id:y,readOnly:r,value:a,onChange:x=>h(x.target.value),placeholder:j}):e.jsx(F,{id:y,readOnly:r,defaultValue:a,placeholder:j})]}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:w,children:"Security"}),c?e.jsx(J,{id:w,value:n,onValueChange:c}):e.jsx(J,{id:w,defaultValue:n})]})]})]})}function _({label:t,detail:o,state:s}){return e.jsxs("div",{className:"flex items-start gap-3 py-2",children:[e.jsxs("span",{className:z("mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full text-2xs",s==="ok"&&"bg-positive text-accent-fg",s==="failed"&&"bg-danger text-accent-fg",s==="running"&&"border border-accent text-accent",s==="pending"&&"border border-line text-fg-subtle"),children:[s==="ok"&&e.jsx(oe,{className:"size-3"}),s==="failed"&&"!",s==="running"&&e.jsx("span",{className:"size-2 animate-pulse rounded-full bg-accent"})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:z("text-sm",s==="failed"?"font-medium text-danger":"text-fg"),children:t}),o&&e.jsx("div",{className:"mt-0.5 text-xs text-fg-subtle",children:o})]})]})}const Ae=(t,o)=>{const s=i.useRef(o);s.current=o,i.useEffect(()=>{if(!t)return;const a=()=>{document.visibilityState==="visible"&&s.current()};return document.addEventListener("visibilitychange",a),window.addEventListener("pageshow",a),()=>{document.removeEventListener("visibilitychange",a),window.removeEventListener("pageshow",a)}},[t])},Ie={"gmail.com":{imap:{host:"imap.gmail.com",port:993,security:"tls"},smtp:{host:"smtp.gmail.com",port:587,security:"starttls"},source:"provider-table"},"googlemail.com":{imap:{host:"imap.gmail.com",port:993,security:"tls"},smtp:{host:"smtp.gmail.com",port:587,security:"starttls"},source:"provider-table"},"outlook.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"hotmail.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"live.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"msn.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"icloud.com":{imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},source:"provider-table"},"me.com":{imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},source:"provider-table"},"mac.com":{imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},source:"provider-table"},"fastmail.com":{imap:{host:"imap.fastmail.com",port:993,security:"tls"},smtp:{host:"smtp.fastmail.com",port:465,security:"tls"},source:"provider-table"},"fastmail.fm":{imap:{host:"imap.fastmail.com",port:993,security:"tls"},smtp:{host:"smtp.fastmail.com",port:465,security:"tls"},source:"provider-table"},"yahoo.com":{imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},source:"provider-table"},"yahoo.co.uk":{imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},source:"provider-table"},"ymail.com":{imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},source:"provider-table"},"aol.com":{imap:{host:"imap.aol.com",port:993,security:"tls"},smtp:{host:"smtp.aol.com",port:465,security:"tls"},source:"provider-table"},"zoho.com":{imap:{host:"imap.zoho.com",port:993,security:"tls"},smtp:{host:"smtp.zoho.com",port:465,security:"tls"},source:"provider-table"},"gmx.com":{imap:{host:"imap.gmx.com",port:993,security:"tls"},smtp:{host:"smtp.gmx.com",port:587,security:"starttls"},source:"provider-table"},"gmx.net":{imap:{host:"imap.gmx.net",port:993,security:"tls"},smtp:{host:"mail.gmx.net",port:587,security:"starttls"},source:"provider-table"},"gmx.de":{imap:{host:"imap.gmx.net",port:993,security:"tls"},smtp:{host:"mail.gmx.net",port:587,security:"starttls"},source:"provider-table"},"web.de":{imap:{host:"imap.web.de",port:993,security:"tls"},smtp:{host:"smtp.web.de",port:587,security:"starttls"},source:"provider-table"},"mail.com":{imap:{host:"imap.mail.com",port:993,security:"tls"},smtp:{host:"smtp.mail.com",port:465,security:"tls"},source:"provider-table"},"hey.com":{imap:{host:"imap.hey.com",port:993,security:"tls"},smtp:{host:"smtp.hey.com",port:465,security:"tls"},source:"provider-table"},"tutanota.com":{imap:{host:"mail.tutanota.com",port:993,security:"tls"},smtp:{host:"mail.tutanota.com",port:465,security:"tls"},source:"provider-table"},"tuta.io":{imap:{host:"mail.tutanota.com",port:993,security:"tls"},smtp:{host:"mail.tutanota.com",port:465,security:"tls"},source:"provider-table"},"posteo.de":{imap:{host:"posteo.de",port:993,security:"tls"},smtp:{host:"posteo.de",port:465,security:"tls"},source:"provider-table"},"runbox.com":{imap:{host:"imap.runbox.com",port:993,security:"tls"},smtp:{host:"smtp.runbox.com",port:587,security:"starttls"},source:"provider-table"},"mailbox.org":{imap:{host:"imap.mailbox.org",port:993,security:"tls"},smtp:{host:"smtp.mailbox.org",port:465,security:"tls"},source:"provider-table"},"hushmail.com":{imap:{host:"imap.hushmail.com",port:993,security:"tls"},smtp:{host:"smtp.hushmail.com",port:465,security:"tls"},source:"provider-table"}},Le={"gmail.com":"https://support.google.com/accounts/answer/185833","googlemail.com":"https://support.google.com/accounts/answer/185833","yahoo.com":"https://help.yahoo.com/kb/generate-manage-third-party-passwords-sln15241.html","icloud.com":"https://support.apple.com/en-us/102654","me.com":"https://support.apple.com/en-us/102654","mac.com":"https://support.apple.com/en-us/102654","fastmail.com":"https://www.fastmail.help/hc/en-us/articles/360058752854","fastmail.fm":"https://www.fastmail.help/hc/en-us/articles/360058752854","outlook.com":"https://support.microsoft.com/en-us/account-billing/manage-app-passwords-for-two-step-verification-d6dc8c6d-4bf7-4851-ad95-6d07799387e9","hotmail.com":"https://support.microsoft.com/en-us/account-billing/manage-app-passwords-for-two-step-verification-d6dc8c6d-4bf7-4851-ad95-6d07799387e9","zoho.com":"https://help.zoho.com/portal/en/kb/zoho-mail/client-configuration/imap-access/articles/zoho-mail-app-passwords"};function ae(t){try{const s=new DOMParser().parseFromString(t,"application/xml");if(s.querySelector("parsererror"))return null;const a=s.querySelectorAll("incomingServer[type='imap']"),n=s.querySelectorAll("outgoingServer[type='smtp']");if(!a.length||!n.length)return null;const r=a[0],u=n[0],h=r.querySelector("hostname")?.textContent?.trim(),c=r.querySelector("port")?.textContent?.trim(),v=r.querySelector("socketType")?.textContent?.trim().toUpperCase(),j=u.querySelector("hostname")?.textContent?.trim(),S=u.querySelector("port")?.textContent?.trim(),y=u.querySelector("socketType")?.textContent?.trim().toUpperCase();if(!h||!c||!j||!S)return null;const w=x=>x==="SSL"||x==="TLS"||x==="SSL/TLS"?"tls":x==="STARTTLS"?"starttls":"none";return{imap:{host:h,port:Number.parseInt(c,10),security:w(v)},smtp:{host:j,port:Number.parseInt(S,10),security:w(y)},source:"mozilla-autoconfig"}}catch{return null}}async function Me(t,o){try{const s=`https://autoconfig.thunderbird.net/v1.1/${t}`,a=await fetch(s,{signal:o});if(!a.ok)return null;const n=await a.text(),r=ae(n);return r||null}catch{return null}}async function Fe(t,o){try{const s=`https://autoconfig.${t}/mail/config-v1.1.xml`,a=await fetch(s,{signal:o});if(!a.ok)return null;const n=await a.text(),r=ae(n);return r?{...r,source:"domain-autoconfig"}:null}catch{return null}}function Re(t){return{imap:{host:`imap.${t}`,port:993,security:"tls"},smtp:{host:`smtp.${t}`,port:587,security:"starttls"},source:"heuristic"}}async function Oe(t,o=1500){const s=t.indexOf("@");if(s===-1)return null;const a=t.slice(s+1).toLowerCase();if(!a)return null;const n=Ie[a];if(n)return n;const r=new AbortController,u=setTimeout(()=>r.abort(),o);try{const h=await Me(a,r.signal);if(h)return h;const c=await Fe(a,r.signal);if(c)return c}finally{clearTimeout(u)}return Re(a)}function ze(t){const o=t.indexOf("@");return o===-1?"Looking up server settings…":`Looking up settings for ${t.slice(o+1)}…`}function ie(t){const o=t.indexOf("@");if(o===-1)return;const s=t.slice(o+1).toLowerCase();return Le[s]}const ce=[{id:"icloud",label:"iCloud",username:"full-email",imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},passwordHelp:{text:"iCloud requires an app-specific password, not your Apple ID password. Generate one under Sign-In & Security → App-Specific Passwords.",url:"https://support.apple.com/en-us/102654"}},{id:"yahoo",label:"Yahoo",username:"full-email",imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},passwordHelp:{text:"Yahoo requires an app password, not your login password. Generate one under Account Security.",url:"https://help.yahoo.com/kb/generate-manage-third-party-passwords-sln15241.html"}},{id:"aol",label:"AOL",username:"full-email",imap:{host:"imap.aol.com",port:993,security:"tls"},smtp:{host:"smtp.aol.com",port:465,security:"tls"},passwordHelp:{text:"AOL requires an app password, not your login password. Generate one under Account Security.",url:"https://login.aol.com/account/security"}},{id:"fastmail",label:"Fastmail",username:"full-email",imap:{host:"imap.fastmail.com",port:993,security:"tls"},smtp:{host:"smtp.fastmail.com",port:465,security:"tls"},passwordHelp:{text:"Fastmail requires an app password, not your login password. Create one under Settings → Privacy & Security → App passwords.",url:"https://www.fastmail.help/hc/en-us/articles/360058752854"}}];function ee(t){return ce.find(o=>o.id===t)}const _e={"icloud.com":"icloud","me.com":"icloud","mac.com":"icloud","yahoo.com":"yahoo","yahoo.co.uk":"yahoo","ymail.com":"yahoo","aol.com":"aol","fastmail.com":"fastmail","fastmail.fm":"fastmail"};function He(t){const o=t.indexOf("@");if(o===-1)return"";const s=t.slice(o+1).toLowerCase();return _e[s]??""}const M=["Connector","Address","Servers","Credentials","Test","Sync"],R={connector:0,address:1,servers:2,credentials:3,test:4,sync:5},te={host:"",port:993,security:"tls"},se={host:"",port:587,security:"starttls"};function $e({onStart:t}){return i.useEffect(()=>{const o=s=>{s.key==="Enter"&&t()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[t]),e.jsx(L,{steps:M,activeStep:0,hideSteps:!0,title:"Welcome to Remit",subtitle:"One inbox for all your mail, with context about every message.",footer:e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-2xs text-fg-subtle",children:[e.jsx(Se,{children:"Enter"})," to continue"]}),e.jsx(C,{variant:"primary",onClick:t,children:"Add your first account"})]}),children:e.jsxs("div",{className:"flex flex-col items-start py-5",children:[e.jsx("span",{className:"flex size-14 items-center justify-center rounded-md bg-accent-soft",children:e.jsx(ke,{className:"size-7 text-accent"})}),e.jsx("p",{className:"mt-5 max-w-sm text-sm leading-relaxed text-fg-muted",children:"Remit syncs your existing mailboxes and tells you who is really writing to you — sender history, authenticity checks, and similar messages, right next to every email."})]})})}function De({onContinue:t,onMicrosoft:o,onBack:s,showBack:a}){const[n,r]=i.useState("imap");i.useEffect(()=>{const h=c=>{c.key==="Enter"&&(n==="microsoft"?o():t()),c.key==="Escape"&&s()};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[t,o,s,n]);const u=()=>{n==="microsoft"?o():t()};return e.jsx(L,{steps:M,activeStep:R.connector,title:"How does this account connect?",subtitle:"Choose a sign-in method. IMAP works with any provider.",footer:e.jsxs(e.Fragment,{children:[a?e.jsx(C,{variant:"ghost",onClick:s,children:"Back"}):e.jsx("span",{}),e.jsx(C,{variant:"primary",onClick:u,children:n==="microsoft"?"Continue with Microsoft":"Continue with IMAP"})]}),children:e.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[e.jsx(W,{name:"IMAP / SMTP",description:"Any mail provider — Fastmail, iCloud, your own server.",icon:e.jsx(Ce,{className:"size-5"}),selected:n==="imap",onSelect:()=>r("imap")}),e.jsx(W,{name:"Gmail",description:"Sign in with Google. No app passwords.",icon:e.jsx(K,{className:"size-5"}),comingSoon:!0}),e.jsx(W,{name:"Outlook / Microsoft 365",description:"Sign in with Microsoft. Works with Outlook.com and work accounts.",icon:e.jsx(je,{className:"size-5"}),selected:n==="microsoft",onSelect:()=>r("microsoft")})]})})}function qe({onBack:t,onConnected:o}){const[s,a]=i.useState(""),[n,r]=i.useState(null),[u,h]=i.useState(!1),[c,v]=i.useState(!1),j=i.useRef(!0);i.useEffect(()=>(j.current=!0,()=>{j.current=!1}),[]);const S=i.useRef(new Set),{refetch:y}=X(ne()),w=Q({...be(),onSuccess:p=>{j.current&&(h(!0),window.location.assign(p.authorizationUrl))},onError:p=>{v(!1),r(p instanceof Error?p.message:"Failed to start sign-in")}});Ae(u,i.useCallback(()=>{v(!1),y().then(({data:p,isError:m})=>{if(!j.current)return;if(m||!p){r("Couldn't check whether the sign-in finished. Open Settings › Accounts to see whether the account is connected.");return}r(null);const N=p.accounts.find(b=>!S.current.has(b.accountId));N&&o(N.accountId)})},[y,o]));const x=c||w.isPending,f=()=>{x||(r(null),v(!0),y().then(({data:p,isError:m})=>{if(j.current){if(m||!p){v(!1),r("Couldn't read this instance's accounts, so sign-in can't be tracked. Check your connection and try again.");return}S.current=new Set(p.accounts.map(N=>N.accountId)),w.mutate({body:{email:s.trim()||void 0}})}}))},l=i.useRef(f);return l.current=f,i.useEffect(()=>{const p=m=>{m.key==="Enter"&&l.current(),m.key==="Escape"&&t()};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[t]),e.jsx(L,{steps:M,activeStep:R.connector,title:"Sign in with Microsoft",subtitle:"You'll be redirected to Microsoft to sign in securely.",footer:e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:t,children:"Back"}),e.jsx(C,{variant:"primary",onClick:f,disabled:x,icon:x?e.jsx(D,{className:"size-4 animate-spin"}):void 0,children:x?"Redirecting…":u?"Start over":"Sign in with Microsoft"})]}),children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(I,{htmlFor:"microsoft-email",children:"Email address (optional)"}),e.jsx(F,{id:"microsoft-email",icon:e.jsx(K,{className:"size-4"}),placeholder:"you@outlook.com",value:s,onChange:p=>a(p.target.value),type:"email",autoComplete:"email"}),e.jsx("p",{className:"mt-1.5 text-2xs text-fg-subtle",children:"Pre-fills the Microsoft sign-in form. Leave blank to choose on the Microsoft page."})]}),u&&e.jsx(q,{tone:"info",children:"Waiting for Microsoft. Finish signing in — this window carries on the moment the account is connected, wherever you finished."}),n&&e.jsx(q,{tone:"danger",children:n})]})})}function Ge({initialEmail:t,initialDisplayName:o,onContinue:s,onBack:a}){const[n,r]=i.useState(t),[u,h]=i.useState(o),[c,v]=i.useState(!1),[j,S]=i.useState(""),[y,w]=i.useState(null),x=i.useCallback(async()=>{const f=n.trim();if(!f.includes("@")||!f.includes(".")){w("Enter a valid email address.");return}w(null),v(!0),S(ze(f));try{const l=await Oe(f);s(f,u.trim(),l)}finally{v(!1)}},[n,u,s]);return i.useEffect(()=>{const f=l=>{l.key==="Enter"&&!c&&x(),l.key==="Escape"&&a()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[x,c,a]),e.jsx(L,{steps:M,activeStep:R.address,title:"What's the email address?",subtitle:"We'll detect the server settings for you.",footer:e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:a,children:"Back"}),e.jsx(C,{variant:"primary",disabled:c,onClick:()=>{x()},children:"Continue"})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(I,{htmlFor:"onboarding-email",children:"Email address"}),e.jsx(F,{id:"onboarding-email",icon:e.jsx(K,{className:"size-4"}),placeholder:"you@example.com",value:n,onChange:f=>{r(f.target.value),w(null)},type:"email",autoComplete:"email"})]}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:"onboarding-display-name",children:"Display name (optional)"}),e.jsx(F,{id:"onboarding-display-name",placeholder:"Alice",value:u,onChange:f=>h(f.target.value)}),e.jsx("p",{className:"mt-1.5 text-2xs text-fg-subtle",children:"What to call this account in Remit. Leave blank to use a name derived from the address."})]}),c&&e.jsxs("div",{className:"mt-3 flex items-center gap-2 text-xs text-fg-muted",children:[e.jsx(D,{className:"size-3.5 animate-spin text-accent"}),j]}),y&&!c&&e.jsx("div",{className:"mt-3",children:e.jsx(q,{tone:"danger",children:y})})]})})}function Be({email:t,imapConfig:o,smtpConfig:s,discovered:a,onContinue:n,onBack:r,onChange:u}){const[h,c]=i.useState(o),[v,j]=i.useState(s),[S,y]=i.useState(()=>He(t)),[w,x]=i.useState(!1),[f,l]=i.useState(null),p=ee(S),m=p!==void 0&&!w,N=i.useCallback(g=>{y(g),x(!1),l(null);const d=ee(g);d&&(c({host:d.imap.host,port:d.imap.port,security:d.imap.security}),j({host:d.smtp.host,port:d.smtp.port,security:d.smtp.security}))},[]);i.useEffect(()=>{u(h,v)},[h,v,u]);const b=h.host.trim()!=="",k=i.useCallback(()=>{if(!b){l("Enter the IMAP host.");return}l(null),n()},[b,n]);i.useEffect(()=>{const g=d=>{d.key==="Enter"&&k(),d.key==="Escape"&&r()};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[k,r]);const T=t.split("@")[1]??"your domain",O=p?"Pick your provider to fill in the right settings — or choose Custom to enter them by hand.":a?"Found via autodiscovery — adjust anything that looks off.":`We couldn't detect settings for ${T} — enter them manually.`,P=m?{label:"preset",tone:"neutral"}:!p&&a?{label:"detected",tone:"positive"}:void 0,A=p?.passwordHelp.url??ie(t);return e.jsx(L,{steps:M,activeStep:R.servers,title:"Confirm server settings",subtitle:O,footer:e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:r,children:"Back"}),e.jsx(C,{variant:"primary",onClick:k,children:"Continue"})]}),children:e.jsxs("div",{className:"space-y-5",children:[f&&e.jsx(q,{tone:"danger",children:f}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:"provider-select",children:"Provider"}),e.jsxs(V,{id:"provider-select",value:S,onChange:g=>N(g.target.value),children:[e.jsx("option",{value:"",children:"Custom / other"}),ce.map(g=>e.jsx("option",{value:g.id,children:g.label},g.id))]}),p&&e.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:m?e.jsxs(e.Fragment,{children:["Server settings are pre-filled for ",p.label," and locked."," ",e.jsx("button",{type:"button",className:"text-accent underline",onClick:()=>x(!0),children:"Advanced"})," ","lets you edit them by hand."]}):e.jsxs(e.Fragment,{children:["Editing ",p.label,"'s settings by hand."]})})]}),e.jsx(Z,{legend:"IMAP — incoming",badge:P,readOnly:m,host:h.host,port:String(h.port),security:h.security,hostPlaceholder:"imap.example.com",portPlaceholder:"993",onHostChange:g=>{c(d=>({...d,host:g})),l(null)},onPortChange:g=>c(d=>({...d,port:Number(g)})),onSecurityChange:g=>c(d=>({...d,security:g}))}),e.jsx("p",{className:"text-2xs text-fg-subtle",children:"Sending (SMTP) is optional — leave it blank to set up a receive-only account and add sending later in Settings."}),e.jsx(Z,{legend:"SMTP — outgoing (optional)",badge:P,readOnly:m,host:v.host,port:String(v.port),security:v.security,hostPlaceholder:"smtp.example.com",portPlaceholder:"587",onHostChange:g=>{j(d=>({...d,host:g})),l(null)},onPortChange:g=>j(d=>({...d,port:Number(g)})),onSecurityChange:g=>j(d=>({...d,security:g}))}),p&&e.jsxs("p",{className:"text-2xs text-fg-subtle",children:[p.passwordHelp.text," ",A&&e.jsx("a",{href:A,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"Get an app password"})]})]})})}function Ue({email:t,username:o,password:s,onContinue:a,onBack:n,onChange:r}){const[u,h]=i.useState(o||t),[c,v]=i.useState(s),[j,S]=i.useState(null),y=t.split("@")[1]??"",w=ie(t),x=u.trim()!==""&&c.trim()!=="";i.useEffect(()=>{r(u,c)},[u,c,r]);const f=i.useCallback(()=>{if(!x){S("Enter your username and password.");return}S(null),a()},[x,a]);return i.useEffect(()=>{const l=p=>{p.key==="Enter"&&f(),p.key==="Escape"&&n()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[f,n]),e.jsx(L,{steps:M,activeStep:R.credentials,title:`Sign in to ${y||"your mail server"}`,subtitle:"Many providers require an app password instead of your normal one.",footer:e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:n,children:"Back"}),e.jsx(C,{variant:"primary",onClick:f,children:"Test connection"})]}),children:e.jsxs("div",{className:"space-y-3",children:[j&&e.jsx("div",{className:"rounded-md bg-danger-soft px-3 py-2 text-sm text-danger",children:j}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:"credentials-username",children:"Username"}),e.jsx(F,{id:"credentials-username",value:u,onChange:l=>{h(l.target.value),S(null)},autoComplete:"username"})]}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:"credentials-password",children:"Password or app password"}),e.jsx(ve,{id:"credentials-password",value:c,onChange:l=>{v(l.target.value),S(null)},autoComplete:"current-password"})]}),e.jsx(Ne,{url:w})]})})}function We({email:t,imapConfig:o,smtpConfig:s,username:a,password:n,onSuccess:r,onBackToCredentials:u,onBackToServers:h}){const[c,v]=i.useState({imapState:"running",smtpState:"pending",phase:"running"}),[j,S]=i.useState(0),y=s.host.trim()!=="",w=G(o.security),x=G(s.security),f=Q({...ge()});i.useEffect(()=>{let m=!1;const N=[];return v({imapState:"running",smtpState:"pending",phase:"running"}),f.mutate({body:{username:a,password:n,imapHost:o.host,imapPort:o.port,imapTls:w.tls,imapStartTls:w.startTls,smtpHost:s.host,smtpPort:s.port,smtpTls:x.tls,smtpStartTls:x.startTls}},{onSuccess:b=>{if(m)return;const k=b.imapSuccess,T=y?b.smtpSuccess:!0;v({imapState:k?"ok":"failed",smtpState:y?"running":"ok",imapDetail:k?`Connected — ${o.host}:${o.port}`:b.imapError,phase:"running"}),N.push(window.setTimeout(()=>{if(m)return;const O=A=>{const g=A?.toLowerCase()??"";return g.includes("auth")||g.includes("login")||g.includes("535")||g.includes("credential")},P=!k&&O(b.imapError)||k&&y&&!b.smtpSuccess&&O(b.smtpError);v({imapState:k?"ok":"failed",smtpState:y?b.smtpSuccess?"ok":"failed":"ok",imapDetail:k?`Connected — ${o.host}:${o.port}`:b.imapError,smtpDetail:y?b.smtpSuccess?`Connected — ${s.host}:${s.port}`:b.smtpError:"Not set up — receive-only",rawError:k?y&&!b.smtpSuccess?b.smtpError:void 0:b.imapError,phase:k&&T?"success":P?"auth-failure":"network-failure"}),k&&T&&N.push(window.setTimeout(()=>{m||r()},800))},400))},onError:b=>{if(m)return;const k=b instanceof Error?b.message:"Connection failed";v({imapState:"failed",smtpState:"failed",imapDetail:k,smtpDetail:k,rawError:k,phase:"network-failure"})}}),()=>{m=!0;for(const b of N)window.clearTimeout(b)}},[j]);const{phase:l}=c;i.useEffect(()=>{const m=N=>{N.key==="Escape"&&(l==="auth-failure"?u():l==="network-failure"&&h())};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[l,u,h]);const p=l==="auth-failure"?e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:u,children:"Back to credentials"}),e.jsx(C,{variant:"primary",onClick:()=>S(m=>m+1),children:"Retry"})]}):l==="network-failure"?e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:h,children:"Back to servers"}),e.jsx(C,{variant:"primary",onClick:()=>S(m=>m+1),children:"Retry"})]}):l==="success"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"Connection verified"}),e.jsx(C,{variant:"primary",onClick:r,children:"Start syncing"})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"Testing…"}),e.jsx("span",{})]});return e.jsx(L,{steps:M,activeStep:R.test,title:"Testing the connection",subtitle:`Checking ${t}`,footer:p,children:e.jsxs("div",{className:"divide-y divide-line",children:[e.jsx(_,{label:`IMAP — ${o.host}:${o.port}`,detail:c.imapDetail,state:c.imapState}),e.jsx(_,{label:y?`SMTP — ${s.host}:${s.port}`:"SMTP — sending",detail:y?c.smtpDetail:"Not set up — you can add sending later in Settings",state:c.smtpState}),(l==="auth-failure"||l==="network-failure")&&c.rawError&&e.jsxs("div",{className:"py-3",children:[l==="auth-failure"&&e.jsx("p",{className:"mb-2 text-xs text-fg-muted",children:"Check your password — many providers require an app password."}),e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:c.rawError})]})]})})}const Ve=2e4;function Xe({email:t,displayName:o,imapConfig:s,smtpConfig:a,username:n,password:r,onGoToInbox:u}){const h=xe(),[c,v]=i.useState(null),[j,S]=i.useState(null),y=i.useRef(!1),w=G(s.security),x=G(a.security),f=Q({...ye(),onSuccess:E=>{v(E.accountId),h.invalidateQueries({queryKey:fe()})},onError:E=>{S(E instanceof Error?E.message:"Failed to create account")}});i.useEffect(()=>{if(y.current)return;y.current=!0;const E=a.host.trim()!=="",H=we({imapHost:s.host,smtpHost:a.host,smtpPort:a.port}),$=E?H??{smtpHost:a.host,smtpPort:a.port,smtpTls:x.tls,smtpStartTls:x.startTls}:null;f.mutate({body:{email:t,displayName:o||void 0,username:n!==t?n:void 0,password:r,imapHost:s.host,imapPort:s.port,imapTls:w.tls,imapStartTls:w.startTls,smtpHost:$?.smtpHost||void 0,smtpPort:$?.smtpPort||void 0,smtpTls:$?.smtpTls??!1,smtpStartTls:$?.smtpStartTls??!1}})},[]);const{data:l,isError:p}=X({...Y({path:{accountId:c??""}}),enabled:!!c,refetchInterval:E=>{const H=E.state.data?.syncPhase;return H==="complete"||H==="error"?!1:2e3}}),m=l?.syncPhase==="error",{data:N}=X({...ne(),enabled:!!c&&m}),b=N?.accounts.find(E=>E.accountId===c)?.lastError,k=l?.mailboxes.find(E=>E.fullPath==="INBOX"||E.fullPath==="Inbox"),T=l?.mailboxCountTotal??0,O=l?.mailboxCountSynced??0,P=k?.messagesTotal??0,A=k?.messagesSynced??0,g=P>0?A/P:0,d=l?.syncPhase,le=m?"failed":d==="idle"||d===void 0||d==="discovering_mailboxes"?"running":T>0?"ok":"running",B=m?"failed":!d||d==="idle"||d==="discovering_mailboxes"?"pending":d==="syncing_inbox"||d==="syncing_others"?"running":"ok",U=m?"failed":!d||d==="idle"||d==="discovering_mailboxes"||d==="syncing_inbox"?"pending":d==="syncing_others"?"running":"ok",me=A>0||k?.phase==="complete"||d==="complete"||m,[ue,de]=i.useState(!1);i.useEffect(()=>{if(!c)return;const E=setTimeout(()=>de(!0),Ve);return()=>clearTimeout(E)},[c]);const pe=!!c&&(me||p||ue);return j?e.jsx(L,{steps:M,activeStep:R.sync,title:"Couldn't create account",subtitle:"Something went wrong saving your account.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{}),e.jsx(C,{variant:"primary",onClick:()=>{y.current=!1,S(null),f.mutate({body:{email:t,displayName:o||void 0,username:n!==t?n:void 0,password:r,imapHost:s.host,imapPort:s.port,imapTls:w.tls,imapStartTls:w.startTls,smtpHost:a.host||void 0,smtpPort:a.port||void 0,smtpTls:x.tls,smtpStartTls:x.startTls}})},children:"Retry"})]}),children:e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:j})}):e.jsx(L,{steps:M,activeStep:R.sync,title:`Syncing ${t}`,subtitle:"Newest mail first — you can start reading right away.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"Sync continues in the background"}),pe?e.jsx(C,{variant:"primary",onClick:()=>c&&u(c),children:"Go to inbox"}):e.jsx(C,{variant:"primary",disabled:!0,icon:e.jsx(D,{className:"size-3.5 animate-spin"}),children:"Getting your mail…"})]}),children:f.isPending?e.jsxs("div",{className:"flex items-center gap-2 py-4 text-sm text-fg-muted",children:[e.jsx(D,{className:"size-4 animate-spin text-accent"}),"Creating your account…"]}):e.jsxs("div",{className:"space-y-3",children:[P>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-baseline justify-between text-xs",children:[e.jsx("span",{className:"font-medium text-fg",children:"INBOX"}),e.jsxs("span",{className:"text-fg-subtle tabular-nums",children:[A.toLocaleString()," / ",P.toLocaleString()," ","messages"]})]}),e.jsx("div",{className:"mt-1 h-1.5 overflow-hidden rounded-full bg-surface-sunken",children:e.jsx("div",{className:"h-full rounded-full bg-accent transition-all duration-500",style:{width:`${Math.max(2,g*100)}%`}})})]}),e.jsxs("div",{className:"divide-y divide-line",children:[e.jsx(_,{label:"Mailboxes discovered",detail:T>0?`${T} mailbox${T===1?"":"es"} found`:"Discovering…",state:le}),e.jsx(_,{label:"INBOX",detail:B==="ok"?`${A.toLocaleString()} messages synced`:B==="running"?"Syncing newest first…":"Queued",state:B}),O>1||d==="syncing_others"||d==="complete"?e.jsx(_,{label:"Other mailboxes",detail:U==="ok"?`${O-1} mailboxes synced`:U==="running"?"Syncing…":"Queued",state:U}):null]}),m&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("p",{className:"text-xs text-danger",children:["Sync stalled. The account is still active —"," ",e.jsx("button",{type:"button",className:"underline",onClick:()=>{h.invalidateQueries({queryKey:Y({path:{accountId:c??""}}).queryKey})},children:"retry"})]}),b&&e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:b})]})]})})}function Je({skipWelcome:t=!1,onComplete:o,onCancel:s}){const[a,n]=i.useState(t?"connector":"welcome"),[r,u]=i.useState({email:"",displayName:"",imapConfig:te,smtpConfig:se,username:"",password:"",discoveryResult:null,discovered:!1,createdAccountId:null}),h=i.useCallback(()=>n("connector"),[]),c=i.useCallback(()=>n("address"),[]),v=i.useCallback(()=>n("microsoft-email"),[]),j=i.useCallback(()=>{t?s?.():n("welcome")},[t,s]),S=i.useCallback((l,p,m)=>{let N=te,b=se,k=!1;m&&(k=m.source!=="heuristic",N={host:m.imap.host,port:m.imap.port,security:m.imap.security},b={host:m.smtp.host,port:m.smtp.port,security:m.smtp.security}),u(T=>({...T,email:l,displayName:p,imapConfig:N,smtpConfig:b,discoveryResult:m,discovered:k,username:l})),n("servers")},[]),y=i.useCallback((l,p)=>{u(m=>({...m,imapConfig:l,smtpConfig:p}))},[]),w=i.useCallback((l,p)=>{u(m=>({...m,username:l,password:p}))},[]),x=i.useCallback(()=>n("sync"),[]),f=i.useCallback(l=>{o(l)},[o]);switch(a){case"welcome":return e.jsx($e,{onStart:h});case"connector":return e.jsx(De,{onContinue:c,onMicrosoft:v,onBack:j,showBack:!t});case"microsoft-email":return e.jsx(qe,{onBack:()=>n("connector"),onConnected:f});case"address":return e.jsx(Ge,{initialEmail:r.email,initialDisplayName:r.displayName,onContinue:S,onBack:()=>n("connector")});case"servers":return e.jsx(Be,{email:r.email,imapConfig:r.imapConfig,smtpConfig:r.smtpConfig,discovered:r.discovered,onContinue:()=>n("credentials"),onBack:()=>n("address"),onChange:y});case"credentials":return e.jsx(Ue,{email:r.email,username:r.username,password:r.password,onContinue:()=>n("test"),onBack:()=>n("servers"),onChange:w});case"test":return e.jsx(We,{email:r.email,imapConfig:r.imapConfig,smtpConfig:r.smtpConfig,username:r.username,password:r.password,onSuccess:x,onBackToCredentials:()=>n("credentials"),onBackToServers:()=>n("servers")});case"sync":return e.jsx(Xe,{email:r.email,displayName:r.displayName,imapConfig:r.imapConfig,smtpConfig:r.smtpConfig,username:r.username,password:r.password,onGoToInbox:f})}}export{Je as O,ce as P,ee as g,G as s,Ae as u};
1
+ import{a as re,j as e,d as z,c0 as V,l as oe,r as i,e as he,cf as I,c1 as F,ab as xe,aJ as Q,bX as fe,b_ as ye,aG as X,av as Y,aR as ne,B as C,L as D,bZ as ge,c2 as ve,G as q,ca as be,q as je}from"./index-CFFTFBUh.js";import{K as Se}from"./kbd-YJVHKonD.js";import{c as we,M as ke}from"./account-form-helpers-C6QgTBuy.js";const K=re("AtSign",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]]);const Ce=re("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);function Ne({url:t}){return e.jsxs("p",{className:"text-2xs text-fg-subtle",children:["Stored encrypted, used only to connect to your mail server."," ",t?e.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"How to create an app password"}):e.jsx("span",{children:"Check your provider's help for app password instructions."})]})}function Ee({raised:t,className:o,...s}){return e.jsx("div",{className:z("rounded-sm border border-line bg-surface",t?"bg-surface-raised shadow-sm":"",o),...s})}function J({value:t,defaultValue:o,onValueChange:s,...a}){return s?e.jsxs(V,{value:t,onChange:n=>s(n.target.value),...a,children:[e.jsx("option",{value:"tls",children:"TLS/SSL"}),e.jsx("option",{value:"starttls",children:"STARTTLS"}),e.jsx("option",{value:"none",children:"None (insecure)"})]}):e.jsxs(V,{defaultValue:o??t,...a,children:[e.jsx("option",{value:"tls",children:"TLS/SSL"}),e.jsx("option",{value:"starttls",children:"STARTTLS"}),e.jsx("option",{value:"none",children:"None (insecure)"})]})}function G(t){return{tls:t==="tls",startTls:t==="starttls"}}function Te({steps:t,activeStep:o}){return e.jsx("ol",{className:"flex items-center gap-1",children:t.map((s,a)=>{const n=a<o,r=a===o;return e.jsxs("li",{className:"flex items-center gap-1",children:[a>0&&e.jsx("span",{className:"h-px w-5 bg-line","aria-hidden":!0}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:z("flex size-5 items-center justify-center rounded-full text-2xs font-semibold tabular-nums",n&&"bg-accent text-accent-fg",r&&"bg-accent-soft text-accent ring-1 ring-accent",!n&&!r&&"bg-surface-sunken text-fg-subtle"),children:n?e.jsx(oe,{className:"size-3"}):a+1}),e.jsx("span",{className:z("hidden text-2xs sm:inline",r?"font-medium text-fg":"text-fg-subtle"),children:s})]})]},s)})})}function L({steps:t,activeStep:o,title:s,subtitle:a,children:n,footer:r,hideSteps:u}){return e.jsxs("div",{className:"flex min-h-dvh w-full flex-col items-center overflow-y-auto bg-canvas pb-[max(2rem,env(safe-area-inset-bottom,0px))] pl-[max(2rem,env(safe-area-inset-left,0px))] pr-[max(2rem,env(safe-area-inset-right,0px))] pt-[max(2rem,env(safe-area-inset-top,0px))] font-sans text-fg sm:pt-[30vh]",children:[!u&&e.jsx("div",{className:"mb-5 w-full max-w-xl",children:e.jsx(Te,{steps:t,activeStep:o})}),e.jsxs(Ee,{raised:!0,className:"w-full max-w-xl",children:[e.jsxs("div",{className:"px-5 pt-5",children:[e.jsx("h1",{className:"text-xl font-semibold text-fg",children:s}),a&&e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:a})]}),e.jsx("div",{className:"px-5 py-5",children:n}),r&&e.jsx("div",{className:"flex items-center justify-between gap-3 border-t border-line px-5 py-3",children:r})]})]})}const Pe="Coming soon — use IMAP for now.";function W({name:t,description:o,icon:s,comingSoon:a,selected:n,onSelect:r}){const[u,h]=i.useState(!1),c=()=>{if(r){r();return}a&&h(!0)};return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("button",{type:"button",onClick:c,"aria-disabled":a||void 0,className:z("flex flex-col items-start gap-2 rounded-sm border p-3 text-left transition-colors",n?"border-accent-2 bg-accent-2-soft":"border-line bg-surface hover:border-line-strong",a&&"opacity-55"),children:[e.jsx("span",{className:z("text-fg-muted",n&&"text-accent-2"),children:s}),e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold text-fg",children:t}),a&&e.jsx("span",{className:"rounded-full bg-surface-sunken px-1.5 py-0.5 text-2xs text-fg-subtle",children:"soon"})]}),e.jsx("span",{className:"text-xs text-fg-subtle",children:o})]}),u&&e.jsx("p",{className:"text-2xs text-fg-subtle",children:Pe})]})}function Z({legend:t,badge:o,host:s,port:a,security:n,readOnly:r,onHostChange:u,onPortChange:h,onSecurityChange:c,hostPlaceholder:v,portPlaceholder:j}){const S=i.useId(),y=i.useId(),w=i.useId();return e.jsxs("fieldset",{children:[e.jsxs("legend",{className:"flex items-center gap-2 text-sm font-semibold text-fg",children:[t,o&&e.jsx(he,{tone:o.tone,children:o.label})]}),e.jsxs("div",{className:"mt-2 grid grid-cols-1 gap-3 sm:grid-cols-[1fr_6rem_8rem] sm:gap-2",children:[e.jsxs("div",{children:[e.jsx(I,{htmlFor:S,children:"Host"}),u?e.jsx(F,{id:S,readOnly:r,value:s,onChange:x=>u(x.target.value),placeholder:v}):e.jsx(F,{id:S,readOnly:r,defaultValue:s,placeholder:v})]}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:y,children:"Port"}),h?e.jsx(F,{id:y,readOnly:r,value:a,onChange:x=>h(x.target.value),placeholder:j}):e.jsx(F,{id:y,readOnly:r,defaultValue:a,placeholder:j})]}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:w,children:"Security"}),c?e.jsx(J,{id:w,value:n,onValueChange:c}):e.jsx(J,{id:w,defaultValue:n})]})]})]})}function _({label:t,detail:o,state:s}){return e.jsxs("div",{className:"flex items-start gap-3 py-2",children:[e.jsxs("span",{className:z("mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full text-2xs",s==="ok"&&"bg-positive text-accent-fg",s==="failed"&&"bg-danger text-accent-fg",s==="running"&&"border border-accent text-accent",s==="pending"&&"border border-line text-fg-subtle"),children:[s==="ok"&&e.jsx(oe,{className:"size-3"}),s==="failed"&&"!",s==="running"&&e.jsx("span",{className:"size-2 animate-pulse rounded-full bg-accent"})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:z("text-sm",s==="failed"?"font-medium text-danger":"text-fg"),children:t}),o&&e.jsx("div",{className:"mt-0.5 text-xs text-fg-subtle",children:o})]})]})}const Ae=(t,o)=>{const s=i.useRef(o);s.current=o,i.useEffect(()=>{if(!t)return;const a=()=>{document.visibilityState==="visible"&&s.current()};return document.addEventListener("visibilitychange",a),window.addEventListener("pageshow",a),()=>{document.removeEventListener("visibilitychange",a),window.removeEventListener("pageshow",a)}},[t])},Ie={"gmail.com":{imap:{host:"imap.gmail.com",port:993,security:"tls"},smtp:{host:"smtp.gmail.com",port:587,security:"starttls"},source:"provider-table"},"googlemail.com":{imap:{host:"imap.gmail.com",port:993,security:"tls"},smtp:{host:"smtp.gmail.com",port:587,security:"starttls"},source:"provider-table"},"outlook.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"hotmail.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"live.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"msn.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"icloud.com":{imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},source:"provider-table"},"me.com":{imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},source:"provider-table"},"mac.com":{imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},source:"provider-table"},"fastmail.com":{imap:{host:"imap.fastmail.com",port:993,security:"tls"},smtp:{host:"smtp.fastmail.com",port:465,security:"tls"},source:"provider-table"},"fastmail.fm":{imap:{host:"imap.fastmail.com",port:993,security:"tls"},smtp:{host:"smtp.fastmail.com",port:465,security:"tls"},source:"provider-table"},"yahoo.com":{imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},source:"provider-table"},"yahoo.co.uk":{imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},source:"provider-table"},"ymail.com":{imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},source:"provider-table"},"aol.com":{imap:{host:"imap.aol.com",port:993,security:"tls"},smtp:{host:"smtp.aol.com",port:465,security:"tls"},source:"provider-table"},"zoho.com":{imap:{host:"imap.zoho.com",port:993,security:"tls"},smtp:{host:"smtp.zoho.com",port:465,security:"tls"},source:"provider-table"},"gmx.com":{imap:{host:"imap.gmx.com",port:993,security:"tls"},smtp:{host:"smtp.gmx.com",port:587,security:"starttls"},source:"provider-table"},"gmx.net":{imap:{host:"imap.gmx.net",port:993,security:"tls"},smtp:{host:"mail.gmx.net",port:587,security:"starttls"},source:"provider-table"},"gmx.de":{imap:{host:"imap.gmx.net",port:993,security:"tls"},smtp:{host:"mail.gmx.net",port:587,security:"starttls"},source:"provider-table"},"web.de":{imap:{host:"imap.web.de",port:993,security:"tls"},smtp:{host:"smtp.web.de",port:587,security:"starttls"},source:"provider-table"},"mail.com":{imap:{host:"imap.mail.com",port:993,security:"tls"},smtp:{host:"smtp.mail.com",port:465,security:"tls"},source:"provider-table"},"hey.com":{imap:{host:"imap.hey.com",port:993,security:"tls"},smtp:{host:"smtp.hey.com",port:465,security:"tls"},source:"provider-table"},"tutanota.com":{imap:{host:"mail.tutanota.com",port:993,security:"tls"},smtp:{host:"mail.tutanota.com",port:465,security:"tls"},source:"provider-table"},"tuta.io":{imap:{host:"mail.tutanota.com",port:993,security:"tls"},smtp:{host:"mail.tutanota.com",port:465,security:"tls"},source:"provider-table"},"posteo.de":{imap:{host:"posteo.de",port:993,security:"tls"},smtp:{host:"posteo.de",port:465,security:"tls"},source:"provider-table"},"runbox.com":{imap:{host:"imap.runbox.com",port:993,security:"tls"},smtp:{host:"smtp.runbox.com",port:587,security:"starttls"},source:"provider-table"},"mailbox.org":{imap:{host:"imap.mailbox.org",port:993,security:"tls"},smtp:{host:"smtp.mailbox.org",port:465,security:"tls"},source:"provider-table"},"hushmail.com":{imap:{host:"imap.hushmail.com",port:993,security:"tls"},smtp:{host:"smtp.hushmail.com",port:465,security:"tls"},source:"provider-table"}},Le={"gmail.com":"https://support.google.com/accounts/answer/185833","googlemail.com":"https://support.google.com/accounts/answer/185833","yahoo.com":"https://help.yahoo.com/kb/generate-manage-third-party-passwords-sln15241.html","icloud.com":"https://support.apple.com/en-us/102654","me.com":"https://support.apple.com/en-us/102654","mac.com":"https://support.apple.com/en-us/102654","fastmail.com":"https://www.fastmail.help/hc/en-us/articles/360058752854","fastmail.fm":"https://www.fastmail.help/hc/en-us/articles/360058752854","outlook.com":"https://support.microsoft.com/en-us/account-billing/manage-app-passwords-for-two-step-verification-d6dc8c6d-4bf7-4851-ad95-6d07799387e9","hotmail.com":"https://support.microsoft.com/en-us/account-billing/manage-app-passwords-for-two-step-verification-d6dc8c6d-4bf7-4851-ad95-6d07799387e9","zoho.com":"https://help.zoho.com/portal/en/kb/zoho-mail/client-configuration/imap-access/articles/zoho-mail-app-passwords"};function ae(t){try{const s=new DOMParser().parseFromString(t,"application/xml");if(s.querySelector("parsererror"))return null;const a=s.querySelectorAll("incomingServer[type='imap']"),n=s.querySelectorAll("outgoingServer[type='smtp']");if(!a.length||!n.length)return null;const r=a[0],u=n[0],h=r.querySelector("hostname")?.textContent?.trim(),c=r.querySelector("port")?.textContent?.trim(),v=r.querySelector("socketType")?.textContent?.trim().toUpperCase(),j=u.querySelector("hostname")?.textContent?.trim(),S=u.querySelector("port")?.textContent?.trim(),y=u.querySelector("socketType")?.textContent?.trim().toUpperCase();if(!h||!c||!j||!S)return null;const w=x=>x==="SSL"||x==="TLS"||x==="SSL/TLS"?"tls":x==="STARTTLS"?"starttls":"none";return{imap:{host:h,port:Number.parseInt(c,10),security:w(v)},smtp:{host:j,port:Number.parseInt(S,10),security:w(y)},source:"mozilla-autoconfig"}}catch{return null}}async function Me(t,o){try{const s=`https://autoconfig.thunderbird.net/v1.1/${t}`,a=await fetch(s,{signal:o});if(!a.ok)return null;const n=await a.text(),r=ae(n);return r||null}catch{return null}}async function Fe(t,o){try{const s=`https://autoconfig.${t}/mail/config-v1.1.xml`,a=await fetch(s,{signal:o});if(!a.ok)return null;const n=await a.text(),r=ae(n);return r?{...r,source:"domain-autoconfig"}:null}catch{return null}}function Re(t){return{imap:{host:`imap.${t}`,port:993,security:"tls"},smtp:{host:`smtp.${t}`,port:587,security:"starttls"},source:"heuristic"}}async function Oe(t,o=1500){const s=t.indexOf("@");if(s===-1)return null;const a=t.slice(s+1).toLowerCase();if(!a)return null;const n=Ie[a];if(n)return n;const r=new AbortController,u=setTimeout(()=>r.abort(),o);try{const h=await Me(a,r.signal);if(h)return h;const c=await Fe(a,r.signal);if(c)return c}finally{clearTimeout(u)}return Re(a)}function ze(t){const o=t.indexOf("@");return o===-1?"Looking up server settings…":`Looking up settings for ${t.slice(o+1)}…`}function ie(t){const o=t.indexOf("@");if(o===-1)return;const s=t.slice(o+1).toLowerCase();return Le[s]}const ce=[{id:"icloud",label:"iCloud",username:"full-email",imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},passwordHelp:{text:"iCloud requires an app-specific password, not your Apple ID password. Generate one under Sign-In & Security → App-Specific Passwords.",url:"https://support.apple.com/en-us/102654"}},{id:"yahoo",label:"Yahoo",username:"full-email",imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},passwordHelp:{text:"Yahoo requires an app password, not your login password. Generate one under Account Security.",url:"https://help.yahoo.com/kb/generate-manage-third-party-passwords-sln15241.html"}},{id:"aol",label:"AOL",username:"full-email",imap:{host:"imap.aol.com",port:993,security:"tls"},smtp:{host:"smtp.aol.com",port:465,security:"tls"},passwordHelp:{text:"AOL requires an app password, not your login password. Generate one under Account Security.",url:"https://login.aol.com/account/security"}},{id:"fastmail",label:"Fastmail",username:"full-email",imap:{host:"imap.fastmail.com",port:993,security:"tls"},smtp:{host:"smtp.fastmail.com",port:465,security:"tls"},passwordHelp:{text:"Fastmail requires an app password, not your login password. Create one under Settings → Privacy & Security → App passwords.",url:"https://www.fastmail.help/hc/en-us/articles/360058752854"}}];function ee(t){return ce.find(o=>o.id===t)}const _e={"icloud.com":"icloud","me.com":"icloud","mac.com":"icloud","yahoo.com":"yahoo","yahoo.co.uk":"yahoo","ymail.com":"yahoo","aol.com":"aol","fastmail.com":"fastmail","fastmail.fm":"fastmail"};function He(t){const o=t.indexOf("@");if(o===-1)return"";const s=t.slice(o+1).toLowerCase();return _e[s]??""}const M=["Connector","Address","Servers","Credentials","Test","Sync"],R={connector:0,address:1,servers:2,credentials:3,test:4,sync:5},te={host:"",port:993,security:"tls"},se={host:"",port:587,security:"starttls"};function $e({onStart:t}){return i.useEffect(()=>{const o=s=>{s.key==="Enter"&&t()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[t]),e.jsx(L,{steps:M,activeStep:0,hideSteps:!0,title:"Welcome to Remit",subtitle:"One inbox for all your mail, with context about every message.",footer:e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-2xs text-fg-subtle",children:[e.jsx(Se,{children:"Enter"})," to continue"]}),e.jsx(C,{variant:"primary",onClick:t,children:"Add your first account"})]}),children:e.jsxs("div",{className:"flex flex-col items-start py-5",children:[e.jsx("span",{className:"flex size-14 items-center justify-center rounded-md bg-accent-soft",children:e.jsx(ke,{className:"size-7 text-accent"})}),e.jsx("p",{className:"mt-5 max-w-sm text-sm leading-relaxed text-fg-muted",children:"Remit syncs your existing mailboxes and tells you who is really writing to you — sender history, authenticity checks, and similar messages, right next to every email."})]})})}function De({onContinue:t,onMicrosoft:o,onBack:s,showBack:a}){const[n,r]=i.useState("imap");i.useEffect(()=>{const h=c=>{c.key==="Enter"&&(n==="microsoft"?o():t()),c.key==="Escape"&&s()};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[t,o,s,n]);const u=()=>{n==="microsoft"?o():t()};return e.jsx(L,{steps:M,activeStep:R.connector,title:"How does this account connect?",subtitle:"Choose a sign-in method. IMAP works with any provider.",footer:e.jsxs(e.Fragment,{children:[a?e.jsx(C,{variant:"ghost",onClick:s,children:"Back"}):e.jsx("span",{}),e.jsx(C,{variant:"primary",onClick:u,children:n==="microsoft"?"Continue with Microsoft":"Continue with IMAP"})]}),children:e.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[e.jsx(W,{name:"IMAP / SMTP",description:"Any mail provider — Fastmail, iCloud, your own server.",icon:e.jsx(Ce,{className:"size-5"}),selected:n==="imap",onSelect:()=>r("imap")}),e.jsx(W,{name:"Gmail",description:"Sign in with Google. No app passwords.",icon:e.jsx(K,{className:"size-5"}),comingSoon:!0}),e.jsx(W,{name:"Outlook / Microsoft 365",description:"Sign in with Microsoft. Works with Outlook.com and work accounts.",icon:e.jsx(je,{className:"size-5"}),selected:n==="microsoft",onSelect:()=>r("microsoft")})]})})}function qe({onBack:t,onConnected:o}){const[s,a]=i.useState(""),[n,r]=i.useState(null),[u,h]=i.useState(!1),[c,v]=i.useState(!1),j=i.useRef(!0);i.useEffect(()=>(j.current=!0,()=>{j.current=!1}),[]);const S=i.useRef(new Set),{refetch:y}=X(ne()),w=Q({...be(),onSuccess:p=>{j.current&&(h(!0),window.location.assign(p.authorizationUrl))},onError:p=>{v(!1),r(p instanceof Error?p.message:"Failed to start sign-in")}});Ae(u,i.useCallback(()=>{v(!1),y().then(({data:p,isError:m})=>{if(!j.current)return;if(m||!p){r("Couldn't check whether the sign-in finished. Open Settings › Accounts to see whether the account is connected.");return}r(null);const N=p.accounts.find(b=>!S.current.has(b.accountId));N&&o(N.accountId)})},[y,o]));const x=c||w.isPending,f=()=>{x||(r(null),v(!0),y().then(({data:p,isError:m})=>{if(j.current){if(m||!p){v(!1),r("Couldn't read this instance's accounts, so sign-in can't be tracked. Check your connection and try again.");return}S.current=new Set(p.accounts.map(N=>N.accountId)),w.mutate({body:{email:s.trim()||void 0}})}}))},l=i.useRef(f);return l.current=f,i.useEffect(()=>{const p=m=>{m.key==="Enter"&&l.current(),m.key==="Escape"&&t()};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[t]),e.jsx(L,{steps:M,activeStep:R.connector,title:"Sign in with Microsoft",subtitle:"You'll be redirected to Microsoft to sign in securely.",footer:e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:t,children:"Back"}),e.jsx(C,{variant:"primary",onClick:f,disabled:x,icon:x?e.jsx(D,{className:"size-4 animate-spin"}):void 0,children:x?"Redirecting…":u?"Start over":"Sign in with Microsoft"})]}),children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(I,{htmlFor:"microsoft-email",children:"Email address (optional)"}),e.jsx(F,{id:"microsoft-email",icon:e.jsx(K,{className:"size-4"}),placeholder:"you@outlook.com",value:s,onChange:p=>a(p.target.value),type:"email",autoComplete:"email"}),e.jsx("p",{className:"mt-1.5 text-2xs text-fg-subtle",children:"Pre-fills the Microsoft sign-in form. Leave blank to choose on the Microsoft page."})]}),u&&e.jsx(q,{tone:"info",children:"Waiting for Microsoft. Finish signing in — this window carries on the moment the account is connected, wherever you finished."}),n&&e.jsx(q,{tone:"danger",children:n})]})})}function Ge({initialEmail:t,initialDisplayName:o,onContinue:s,onBack:a}){const[n,r]=i.useState(t),[u,h]=i.useState(o),[c,v]=i.useState(!1),[j,S]=i.useState(""),[y,w]=i.useState(null),x=i.useCallback(async()=>{const f=n.trim();if(!f.includes("@")||!f.includes(".")){w("Enter a valid email address.");return}w(null),v(!0),S(ze(f));try{const l=await Oe(f);s(f,u.trim(),l)}finally{v(!1)}},[n,u,s]);return i.useEffect(()=>{const f=l=>{l.key==="Enter"&&!c&&x(),l.key==="Escape"&&a()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[x,c,a]),e.jsx(L,{steps:M,activeStep:R.address,title:"What's the email address?",subtitle:"We'll detect the server settings for you.",footer:e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:a,children:"Back"}),e.jsx(C,{variant:"primary",disabled:c,onClick:()=>{x()},children:"Continue"})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(I,{htmlFor:"onboarding-email",children:"Email address"}),e.jsx(F,{id:"onboarding-email",icon:e.jsx(K,{className:"size-4"}),placeholder:"you@example.com",value:n,onChange:f=>{r(f.target.value),w(null)},type:"email",autoComplete:"email"})]}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:"onboarding-display-name",children:"Display name (optional)"}),e.jsx(F,{id:"onboarding-display-name",placeholder:"Alice",value:u,onChange:f=>h(f.target.value)}),e.jsx("p",{className:"mt-1.5 text-2xs text-fg-subtle",children:"What to call this account in Remit. Leave blank to use a name derived from the address."})]}),c&&e.jsxs("div",{className:"mt-3 flex items-center gap-2 text-xs text-fg-muted",children:[e.jsx(D,{className:"size-3.5 animate-spin text-accent"}),j]}),y&&!c&&e.jsx("div",{className:"mt-3",children:e.jsx(q,{tone:"danger",children:y})})]})})}function Be({email:t,imapConfig:o,smtpConfig:s,discovered:a,onContinue:n,onBack:r,onChange:u}){const[h,c]=i.useState(o),[v,j]=i.useState(s),[S,y]=i.useState(()=>He(t)),[w,x]=i.useState(!1),[f,l]=i.useState(null),p=ee(S),m=p!==void 0&&!w,N=i.useCallback(g=>{y(g),x(!1),l(null);const d=ee(g);d&&(c({host:d.imap.host,port:d.imap.port,security:d.imap.security}),j({host:d.smtp.host,port:d.smtp.port,security:d.smtp.security}))},[]);i.useEffect(()=>{u(h,v)},[h,v,u]);const b=h.host.trim()!=="",k=i.useCallback(()=>{if(!b){l("Enter the IMAP host.");return}l(null),n()},[b,n]);i.useEffect(()=>{const g=d=>{d.key==="Enter"&&k(),d.key==="Escape"&&r()};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[k,r]);const T=t.split("@")[1]??"your domain",O=p?"Pick your provider to fill in the right settings — or choose Custom to enter them by hand.":a?"Found via autodiscovery — adjust anything that looks off.":`We couldn't detect settings for ${T} — enter them manually.`,P=m?{label:"preset",tone:"neutral"}:!p&&a?{label:"detected",tone:"positive"}:void 0,A=p?.passwordHelp.url??ie(t);return e.jsx(L,{steps:M,activeStep:R.servers,title:"Confirm server settings",subtitle:O,footer:e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:r,children:"Back"}),e.jsx(C,{variant:"primary",onClick:k,children:"Continue"})]}),children:e.jsxs("div",{className:"space-y-5",children:[f&&e.jsx(q,{tone:"danger",children:f}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:"provider-select",children:"Provider"}),e.jsxs(V,{id:"provider-select",value:S,onChange:g=>N(g.target.value),children:[e.jsx("option",{value:"",children:"Custom / other"}),ce.map(g=>e.jsx("option",{value:g.id,children:g.label},g.id))]}),p&&e.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:m?e.jsxs(e.Fragment,{children:["Server settings are pre-filled for ",p.label," and locked."," ",e.jsx("button",{type:"button",className:"text-accent underline",onClick:()=>x(!0),children:"Advanced"})," ","lets you edit them by hand."]}):e.jsxs(e.Fragment,{children:["Editing ",p.label,"'s settings by hand."]})})]}),e.jsx(Z,{legend:"IMAP — incoming",badge:P,readOnly:m,host:h.host,port:String(h.port),security:h.security,hostPlaceholder:"imap.example.com",portPlaceholder:"993",onHostChange:g=>{c(d=>({...d,host:g})),l(null)},onPortChange:g=>c(d=>({...d,port:Number(g)})),onSecurityChange:g=>c(d=>({...d,security:g}))}),e.jsx("p",{className:"text-2xs text-fg-subtle",children:"Sending (SMTP) is optional — leave it blank to set up a receive-only account and add sending later in Settings."}),e.jsx(Z,{legend:"SMTP — outgoing (optional)",badge:P,readOnly:m,host:v.host,port:String(v.port),security:v.security,hostPlaceholder:"smtp.example.com",portPlaceholder:"587",onHostChange:g=>{j(d=>({...d,host:g})),l(null)},onPortChange:g=>j(d=>({...d,port:Number(g)})),onSecurityChange:g=>j(d=>({...d,security:g}))}),p&&e.jsxs("p",{className:"text-2xs text-fg-subtle",children:[p.passwordHelp.text," ",A&&e.jsx("a",{href:A,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"Get an app password"})]})]})})}function Ue({email:t,username:o,password:s,onContinue:a,onBack:n,onChange:r}){const[u,h]=i.useState(o||t),[c,v]=i.useState(s),[j,S]=i.useState(null),y=t.split("@")[1]??"",w=ie(t),x=u.trim()!==""&&c.trim()!=="";i.useEffect(()=>{r(u,c)},[u,c,r]);const f=i.useCallback(()=>{if(!x){S("Enter your username and password.");return}S(null),a()},[x,a]);return i.useEffect(()=>{const l=p=>{p.key==="Enter"&&f(),p.key==="Escape"&&n()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[f,n]),e.jsx(L,{steps:M,activeStep:R.credentials,title:`Sign in to ${y||"your mail server"}`,subtitle:"Many providers require an app password instead of your normal one.",footer:e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:n,children:"Back"}),e.jsx(C,{variant:"primary",onClick:f,children:"Test connection"})]}),children:e.jsxs("div",{className:"space-y-3",children:[j&&e.jsx("div",{className:"rounded-md bg-danger-soft px-3 py-2 text-sm text-danger",children:j}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:"credentials-username",children:"Username"}),e.jsx(F,{id:"credentials-username",value:u,onChange:l=>{h(l.target.value),S(null)},autoComplete:"username"})]}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:"credentials-password",children:"Password or app password"}),e.jsx(ve,{id:"credentials-password",value:c,onChange:l=>{v(l.target.value),S(null)},autoComplete:"current-password"})]}),e.jsx(Ne,{url:w})]})})}function We({email:t,imapConfig:o,smtpConfig:s,username:a,password:n,onSuccess:r,onBackToCredentials:u,onBackToServers:h}){const[c,v]=i.useState({imapState:"running",smtpState:"pending",phase:"running"}),[j,S]=i.useState(0),y=s.host.trim()!=="",w=G(o.security),x=G(s.security),f=Q({...ge()});i.useEffect(()=>{let m=!1;const N=[];return v({imapState:"running",smtpState:"pending",phase:"running"}),f.mutate({body:{username:a,password:n,imapHost:o.host,imapPort:o.port,imapTls:w.tls,imapStartTls:w.startTls,smtpHost:s.host,smtpPort:s.port,smtpTls:x.tls,smtpStartTls:x.startTls}},{onSuccess:b=>{if(m)return;const k=b.imapSuccess,T=y?b.smtpSuccess:!0;v({imapState:k?"ok":"failed",smtpState:y?"running":"ok",imapDetail:k?`Connected — ${o.host}:${o.port}`:b.imapError,phase:"running"}),N.push(window.setTimeout(()=>{if(m)return;const O=A=>{const g=A?.toLowerCase()??"";return g.includes("auth")||g.includes("login")||g.includes("535")||g.includes("credential")},P=!k&&O(b.imapError)||k&&y&&!b.smtpSuccess&&O(b.smtpError);v({imapState:k?"ok":"failed",smtpState:y?b.smtpSuccess?"ok":"failed":"ok",imapDetail:k?`Connected — ${o.host}:${o.port}`:b.imapError,smtpDetail:y?b.smtpSuccess?`Connected — ${s.host}:${s.port}`:b.smtpError:"Not set up — receive-only",rawError:k?y&&!b.smtpSuccess?b.smtpError:void 0:b.imapError,phase:k&&T?"success":P?"auth-failure":"network-failure"}),k&&T&&N.push(window.setTimeout(()=>{m||r()},800))},400))},onError:b=>{if(m)return;const k=b instanceof Error?b.message:"Connection failed";v({imapState:"failed",smtpState:"failed",imapDetail:k,smtpDetail:k,rawError:k,phase:"network-failure"})}}),()=>{m=!0;for(const b of N)window.clearTimeout(b)}},[j]);const{phase:l}=c;i.useEffect(()=>{const m=N=>{N.key==="Escape"&&(l==="auth-failure"?u():l==="network-failure"&&h())};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[l,u,h]);const p=l==="auth-failure"?e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:u,children:"Back to credentials"}),e.jsx(C,{variant:"primary",onClick:()=>S(m=>m+1),children:"Retry"})]}):l==="network-failure"?e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:h,children:"Back to servers"}),e.jsx(C,{variant:"primary",onClick:()=>S(m=>m+1),children:"Retry"})]}):l==="success"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"Connection verified"}),e.jsx(C,{variant:"primary",onClick:r,children:"Start syncing"})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"Testing…"}),e.jsx("span",{})]});return e.jsx(L,{steps:M,activeStep:R.test,title:"Testing the connection",subtitle:`Checking ${t}`,footer:p,children:e.jsxs("div",{className:"divide-y divide-line",children:[e.jsx(_,{label:`IMAP — ${o.host}:${o.port}`,detail:c.imapDetail,state:c.imapState}),e.jsx(_,{label:y?`SMTP — ${s.host}:${s.port}`:"SMTP — sending",detail:y?c.smtpDetail:"Not set up — you can add sending later in Settings",state:c.smtpState}),(l==="auth-failure"||l==="network-failure")&&c.rawError&&e.jsxs("div",{className:"py-3",children:[l==="auth-failure"&&e.jsx("p",{className:"mb-2 text-xs text-fg-muted",children:"Check your password — many providers require an app password."}),e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:c.rawError})]})]})})}const Ve=2e4;function Xe({email:t,displayName:o,imapConfig:s,smtpConfig:a,username:n,password:r,onGoToInbox:u}){const h=xe(),[c,v]=i.useState(null),[j,S]=i.useState(null),y=i.useRef(!1),w=G(s.security),x=G(a.security),f=Q({...ye(),onSuccess:E=>{v(E.accountId),h.invalidateQueries({queryKey:fe()})},onError:E=>{S(E instanceof Error?E.message:"Failed to create account")}});i.useEffect(()=>{if(y.current)return;y.current=!0;const E=a.host.trim()!=="",H=we({imapHost:s.host,smtpHost:a.host,smtpPort:a.port}),$=E?H??{smtpHost:a.host,smtpPort:a.port,smtpTls:x.tls,smtpStartTls:x.startTls}:null;f.mutate({body:{email:t,displayName:o||void 0,username:n!==t?n:void 0,password:r,imapHost:s.host,imapPort:s.port,imapTls:w.tls,imapStartTls:w.startTls,smtpHost:$?.smtpHost||void 0,smtpPort:$?.smtpPort||void 0,smtpTls:$?.smtpTls??!1,smtpStartTls:$?.smtpStartTls??!1}})},[]);const{data:l,isError:p}=X({...Y({path:{accountId:c??""}}),enabled:!!c,refetchInterval:E=>{const H=E.state.data?.syncPhase;return H==="complete"||H==="error"?!1:2e3}}),m=l?.syncPhase==="error",{data:N}=X({...ne(),enabled:!!c&&m}),b=N?.accounts.find(E=>E.accountId===c)?.lastError,k=l?.mailboxes.find(E=>E.fullPath==="INBOX"||E.fullPath==="Inbox"),T=l?.mailboxCountTotal??0,O=l?.mailboxCountSynced??0,P=k?.messagesTotal??0,A=k?.messagesSynced??0,g=P>0?A/P:0,d=l?.syncPhase,le=m?"failed":d==="idle"||d===void 0||d==="discovering_mailboxes"?"running":T>0?"ok":"running",B=m?"failed":!d||d==="idle"||d==="discovering_mailboxes"?"pending":d==="syncing_inbox"||d==="syncing_others"?"running":"ok",U=m?"failed":!d||d==="idle"||d==="discovering_mailboxes"||d==="syncing_inbox"?"pending":d==="syncing_others"?"running":"ok",me=A>0||k?.phase==="complete"||d==="complete"||m,[ue,de]=i.useState(!1);i.useEffect(()=>{if(!c)return;const E=setTimeout(()=>de(!0),Ve);return()=>clearTimeout(E)},[c]);const pe=!!c&&(me||p||ue);return j?e.jsx(L,{steps:M,activeStep:R.sync,title:"Couldn't create account",subtitle:"Something went wrong saving your account.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{}),e.jsx(C,{variant:"primary",onClick:()=>{y.current=!1,S(null),f.mutate({body:{email:t,displayName:o||void 0,username:n!==t?n:void 0,password:r,imapHost:s.host,imapPort:s.port,imapTls:w.tls,imapStartTls:w.startTls,smtpHost:a.host||void 0,smtpPort:a.port||void 0,smtpTls:x.tls,smtpStartTls:x.startTls}})},children:"Retry"})]}),children:e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:j})}):e.jsx(L,{steps:M,activeStep:R.sync,title:`Syncing ${t}`,subtitle:"Newest mail first — you can start reading right away.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"Sync continues in the background"}),pe?e.jsx(C,{variant:"primary",onClick:()=>c&&u(c),children:"Go to inbox"}):e.jsx(C,{variant:"primary",disabled:!0,icon:e.jsx(D,{className:"size-3.5 animate-spin"}),children:"Getting your mail…"})]}),children:f.isPending?e.jsxs("div",{className:"flex items-center gap-2 py-4 text-sm text-fg-muted",children:[e.jsx(D,{className:"size-4 animate-spin text-accent"}),"Creating your account…"]}):e.jsxs("div",{className:"space-y-3",children:[P>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-baseline justify-between text-xs",children:[e.jsx("span",{className:"font-medium text-fg",children:"INBOX"}),e.jsxs("span",{className:"text-fg-subtle tabular-nums",children:[A.toLocaleString()," / ",P.toLocaleString()," ","messages"]})]}),e.jsx("div",{className:"mt-1 h-1.5 overflow-hidden rounded-full bg-surface-sunken",children:e.jsx("div",{className:"h-full rounded-full bg-accent transition-all duration-500",style:{width:`${Math.max(2,g*100)}%`}})})]}),e.jsxs("div",{className:"divide-y divide-line",children:[e.jsx(_,{label:"Mailboxes discovered",detail:T>0?`${T} mailbox${T===1?"":"es"} found`:"Discovering…",state:le}),e.jsx(_,{label:"INBOX",detail:B==="ok"?`${A.toLocaleString()} messages synced`:B==="running"?"Syncing newest first…":"Queued",state:B}),O>1||d==="syncing_others"||d==="complete"?e.jsx(_,{label:"Other mailboxes",detail:U==="ok"?`${O-1} mailboxes synced`:U==="running"?"Syncing…":"Queued",state:U}):null]}),m&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("p",{className:"text-xs text-danger",children:["Sync stalled. The account is still active —"," ",e.jsx("button",{type:"button",className:"underline",onClick:()=>{h.invalidateQueries({queryKey:Y({path:{accountId:c??""}}).queryKey})},children:"retry"})]}),b&&e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:b})]})]})})}function Je({skipWelcome:t=!1,onComplete:o,onCancel:s}){const[a,n]=i.useState(t?"connector":"welcome"),[r,u]=i.useState({email:"",displayName:"",imapConfig:te,smtpConfig:se,username:"",password:"",discoveryResult:null,discovered:!1,createdAccountId:null}),h=i.useCallback(()=>n("connector"),[]),c=i.useCallback(()=>n("address"),[]),v=i.useCallback(()=>n("microsoft-email"),[]),j=i.useCallback(()=>{t?s?.():n("welcome")},[t,s]),S=i.useCallback((l,p,m)=>{let N=te,b=se,k=!1;m&&(k=m.source!=="heuristic",N={host:m.imap.host,port:m.imap.port,security:m.imap.security},b={host:m.smtp.host,port:m.smtp.port,security:m.smtp.security}),u(T=>({...T,email:l,displayName:p,imapConfig:N,smtpConfig:b,discoveryResult:m,discovered:k,username:l})),n("servers")},[]),y=i.useCallback((l,p)=>{u(m=>({...m,imapConfig:l,smtpConfig:p}))},[]),w=i.useCallback((l,p)=>{u(m=>({...m,username:l,password:p}))},[]),x=i.useCallback(()=>n("sync"),[]),f=i.useCallback(l=>{o(l)},[o]);switch(a){case"welcome":return e.jsx($e,{onStart:h});case"connector":return e.jsx(De,{onContinue:c,onMicrosoft:v,onBack:j,showBack:!t});case"microsoft-email":return e.jsx(qe,{onBack:()=>n("connector"),onConnected:f});case"address":return e.jsx(Ge,{initialEmail:r.email,initialDisplayName:r.displayName,onContinue:S,onBack:()=>n("connector")});case"servers":return e.jsx(Be,{email:r.email,imapConfig:r.imapConfig,smtpConfig:r.smtpConfig,discovered:r.discovered,onContinue:()=>n("credentials"),onBack:()=>n("address"),onChange:y});case"credentials":return e.jsx(Ue,{email:r.email,username:r.username,password:r.password,onContinue:()=>n("test"),onBack:()=>n("servers"),onChange:w});case"test":return e.jsx(We,{email:r.email,imapConfig:r.imapConfig,smtpConfig:r.smtpConfig,username:r.username,password:r.password,onSuccess:x,onBackToCredentials:()=>n("credentials"),onBackToServers:()=>n("servers")});case"sync":return e.jsx(Xe,{email:r.email,displayName:r.displayName,imapConfig:r.imapConfig,smtpConfig:r.smtpConfig,username:r.username,password:r.password,onGoToInbox:f})}}export{Je as O,ce as P,ee as g,G as s,Ae as u};
@@ -1 +1 @@
1
- import{a as s}from"./index-Z0KvXoPD.js";const u=s("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]),o=587,i=!1,e=!0,c=t=>t.replace(/^imap\./i,"smtp."),a=t=>{if((t.smtpHost?.trim()??"").length>0)return null;const n=t.imapHost.trim();return n.length===0?null:{smtpHost:c(n),smtpPort:o,smtpTls:i,smtpStartTls:e}},m=t=>{const r=t?.toLowerCase()??"";return r.includes("auth")||r.includes("login")||r.includes("535")||r.includes("credential")},l=(t,r)=>!t||!r||!m(t)?t:`${t} — ${r}`,d=t=>t.smtpEnabled!==!0;export{u as M,d as a,l as b,a as c,c as d};
1
+ import{a as s}from"./index-CFFTFBUh.js";const u=s("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]),o=587,i=!1,e=!0,c=t=>t.replace(/^imap\./i,"smtp."),a=t=>{if((t.smtpHost?.trim()??"").length>0)return null;const n=t.imapHost.trim();return n.length===0?null:{smtpHost:c(n),smtpPort:o,smtpTls:i,smtpStartTls:e}},m=t=>{const r=t?.toLowerCase()??"";return r.includes("auth")||r.includes("login")||r.includes("535")||r.includes("credential")},l=(t,r)=>!t||!r||!m(t)?t:`${t} — ${r}`,d=t=>t.smtpEnabled!==!0;export{u as M,d as a,l as b,a as c,c as d};