panopticon-cli 0.6.6 → 0.6.7

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.
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/angular-html-Bp1-8yw7.js","assets/chunk-BEqpzyXh.js","assets/html-Dv3DVnHr.js","assets/css-BuARR_Qb.js","assets/javascript-DBCnrPrR.js","assets/angular-ts-Dc47XLpQ.js","assets/scss-Dl8-fX0q.js","assets/apl-BCQk3spK.js","assets/json-CdZYVWSM.js","assets/xml-C-aQor-e.js","assets/java-2Xsuzsw1.js","assets/astro-BPbMyfm1.js","assets/postcss-cZXfRCsF.js","assets/tsx-CwF67eOq.js","assets/typescript-BB21Zsih.js","assets/blade-Bij-_yC5.js","assets/html-derivative-tSjEs4-0.js","assets/sql-DZn-UGGv.js","assets/bsl-BODK--Fo.js","assets/sdbl-DOe8Nral.js","assets/c-oKNVj2rl.js","assets/cairo-BwpHIzLA.js","assets/python-BLpCXkJ6.js","assets/cobol-Dg5kg7hv.js","assets/coffee-3hfizWZM.js","assets/cpp-ULE387nU.js","assets/glsl-QoOzy-_r.js","assets/regexp-BloNfp_x.js","assets/crystal-Re5Pqbq7.js","assets/shellscript-CO-naGHU.js","assets/edge-CVs6JuhO.js","assets/elixir-vVBUmtB0.js","assets/elm-CJ1l6IcG.js","assets/erb-BhwFSwKc.js","assets/ruby-D9aJDC0S.js","assets/graphql-kqsYmXmx.js","assets/jsx-Dp3qsTLF.js","assets/haml-BQPi0z1w.js","assets/lua-BK1ZG2EC.js","assets/yaml-DkgEEdrA.js","assets/erlang-CjZU-VwD.js","assets/markdown-BFgBvytj.js","assets/fortran-fixed-form-CLgNuKMV.js","assets/fortran-free-form-CHQXX5JB.js","assets/fsharp-kVgJ9XJy.js","assets/gdresource-DDsMuL8p.js","assets/gdscript-DBkVGsC6.js","assets/gdshader-CWQhZP7Q.js","assets/git-commit-BKhxSJdF.js","assets/diff-G5H-0DNT.js","assets/git-rebase-f38O1g3a.js","assets/glimmer-js-ZD1Yvd1q.js","assets/glimmer-ts-bAi6wGX7.js","assets/hack-BgMu5Ipy.js","assets/handlebars-DPV5gbtW.js","assets/http-C4ysT5sQ.js","assets/hurl-DFMpPkw5.js","assets/csv-DPc9UZFt.js","assets/hxml-YehGxZ3T.js","assets/haxe-md5t_Y_E.js","assets/jinja-D5k2aV6r.js","assets/jison-DxRKYMci.js","assets/julia-C71yEfU9.js","assets/r-Oz8OzNPF.js","assets/just-CFLnnO7_.js","assets/perl-DhyBeoYG.js","assets/latex-vlM3VFwL.js","assets/tex-s1kBmY2H.js","assets/liquid-BfMw2dPx.js","assets/marko-C-FzIztO.js","assets/less-DwUMKQAG.js","assets/mdc-CpYiOYsD.js","assets/nextflow-C2lnptGp.js","assets/nextflow-groovy-DXLl8k8E.js","assets/nginx-C_FN4HXw.js","assets/nim-BsyQONjY.js","assets/php-CX--GDqC.js","assets/pug-BD4sRivj.js","assets/qml-CF1x2Id3.js","assets/razor-CIpRog1G.js","assets/csharp-BLhQzhUA.js","assets/rst-DEqAwrfS.js","assets/cmake-BmC4o4J9.js","assets/sas-D4Fr9SDG.js","assets/shaderlab-CCgEvKkt.js","assets/hlsl-CFf5czm3.js","assets/shellsession-Bh4VveDi.js","assets/soy-Cu-kYJAO.js","assets/sparql-DH0hFmAi.js","assets/turtle-BKcRDROw.js","assets/stata-BZdocy0T.js","assets/surrealql-D3TMbWym.js","assets/svelte-CD-ilbSU.js","assets/templ-DH5iy6rc.js","assets/go-DC_Zm44P.js","assets/ts-tags-CEZNZHfQ.js","assets/twig-D57SzOSi.js","assets/vue-B6oogzWX.js","assets/vue-html-v0GYjc-r.js","assets/vue-vine-CeA42ICb.js","assets/stylus-D69is74S.js","assets/xsl-C0dvDCZw.js"])))=>i.map(i=>d[i]);
2
- import{a as e,c as t,i as n,n as r,o as i,r as a,s as o,t as s}from"./index-ByLmYGhW.js";var c={}.hasOwnProperty;function l(e,t){let n=t||{};function r(t,...n){let i=r.invalid,a=r.handlers;if(t&&c.call(t,e)){let n=String(t[e]);i=c.call(a,n)?a[n]:r.unknown}if(i)return i.call(this,t,...n)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}var u=[`area`,`base`,`basefont`,`bgsound`,`br`,`col`,`command`,`embed`,`frame`,`hr`,`image`,`img`,`input`,`keygen`,`link`,`meta`,`param`,`source`,`track`,`wbr`],d=/["&'<>`]/g,f=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,p=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,m=/[|\\{}()[\]^$+*?.]/g,h=new WeakMap;function g(e,t){if(e=e.replace(t.subset?_(t.subset):d,r),t.subset||t.escapeOnly)return e;return e.replace(f,n).replace(p,r);function n(e,n,r){return t.format((e.charCodeAt(0)-55296)*1024+e.charCodeAt(1)-56320+65536,r.charCodeAt(n+2),t)}function r(e,n,r){return t.format(e.charCodeAt(0),r.charCodeAt(n+1),t)}}function _(e){let t=h.get(e);return t||(t=ee(e),h.set(e,t)),t}function ee(e){let t=[],n=-1;for(;++n<e.length;)t.push(e[n].replace(m,`\\$&`));return RegExp(`(?:`+t.join(`|`)+`)`,`g`)}var te=/[\dA-Fa-f]/;function ne(e,t,n){let r=`&#x`+e.toString(16).toUpperCase();return n&&t&&!te.test(String.fromCharCode(t))?r:r+`;`}var re=/\d/;function ie(e,t,n){let r=`&#`+String(e);return n&&t&&!re.test(String.fromCharCode(t))?r:r+`;`}var ae=`AElig.AMP.Aacute.Acirc.Agrave.Aring.Atilde.Auml.COPY.Ccedil.ETH.Eacute.Ecirc.Egrave.Euml.GT.Iacute.Icirc.Igrave.Iuml.LT.Ntilde.Oacute.Ocirc.Ograve.Oslash.Otilde.Ouml.QUOT.REG.THORN.Uacute.Ucirc.Ugrave.Uuml.Yacute.aacute.acirc.acute.aelig.agrave.amp.aring.atilde.auml.brvbar.ccedil.cedil.cent.copy.curren.deg.divide.eacute.ecirc.egrave.eth.euml.frac12.frac14.frac34.gt.iacute.icirc.iexcl.igrave.iquest.iuml.laquo.lt.macr.micro.middot.nbsp.not.ntilde.oacute.ocirc.ograve.ordf.ordm.oslash.otilde.ouml.para.plusmn.pound.quot.raquo.reg.sect.shy.sup1.sup2.sup3.szlig.thorn.times.uacute.ucirc.ugrave.uml.uuml.yacute.yen.yuml`.split(`.`),oe={nbsp:`\xA0`,iexcl:`¡`,cent:`¢`,pound:`£`,curren:`¤`,yen:`¥`,brvbar:`¦`,sect:`§`,uml:`¨`,copy:`©`,ordf:`ª`,laquo:`«`,not:`¬`,shy:`­`,reg:`®`,macr:`¯`,deg:`°`,plusmn:`±`,sup2:`²`,sup3:`³`,acute:`´`,micro:`µ`,para:`¶`,middot:`·`,cedil:`¸`,sup1:`¹`,ordm:`º`,raquo:`»`,frac14:`¼`,frac12:`½`,frac34:`¾`,iquest:`¿`,Agrave:`À`,Aacute:`Á`,Acirc:`Â`,Atilde:`Ã`,Auml:`Ä`,Aring:`Å`,AElig:`Æ`,Ccedil:`Ç`,Egrave:`È`,Eacute:`É`,Ecirc:`Ê`,Euml:`Ë`,Igrave:`Ì`,Iacute:`Í`,Icirc:`Î`,Iuml:`Ï`,ETH:`Ð`,Ntilde:`Ñ`,Ograve:`Ò`,Oacute:`Ó`,Ocirc:`Ô`,Otilde:`Õ`,Ouml:`Ö`,times:`×`,Oslash:`Ø`,Ugrave:`Ù`,Uacute:`Ú`,Ucirc:`Û`,Uuml:`Ü`,Yacute:`Ý`,THORN:`Þ`,szlig:`ß`,agrave:`à`,aacute:`á`,acirc:`â`,atilde:`ã`,auml:`ä`,aring:`å`,aelig:`æ`,ccedil:`ç`,egrave:`è`,eacute:`é`,ecirc:`ê`,euml:`ë`,igrave:`ì`,iacute:`í`,icirc:`î`,iuml:`ï`,eth:`ð`,ntilde:`ñ`,ograve:`ò`,oacute:`ó`,ocirc:`ô`,otilde:`õ`,ouml:`ö`,divide:`÷`,oslash:`ø`,ugrave:`ù`,uacute:`ú`,ucirc:`û`,uuml:`ü`,yacute:`ý`,thorn:`þ`,yuml:`ÿ`,fnof:`ƒ`,Alpha:`Α`,Beta:`Β`,Gamma:`Γ`,Delta:`Δ`,Epsilon:`Ε`,Zeta:`Ζ`,Eta:`Η`,Theta:`Θ`,Iota:`Ι`,Kappa:`Κ`,Lambda:`Λ`,Mu:`Μ`,Nu:`Ν`,Xi:`Ξ`,Omicron:`Ο`,Pi:`Π`,Rho:`Ρ`,Sigma:`Σ`,Tau:`Τ`,Upsilon:`Υ`,Phi:`Φ`,Chi:`Χ`,Psi:`Ψ`,Omega:`Ω`,alpha:`α`,beta:`β`,gamma:`γ`,delta:`δ`,epsilon:`ε`,zeta:`ζ`,eta:`η`,theta:`θ`,iota:`ι`,kappa:`κ`,lambda:`λ`,mu:`μ`,nu:`ν`,xi:`ξ`,omicron:`ο`,pi:`π`,rho:`ρ`,sigmaf:`ς`,sigma:`σ`,tau:`τ`,upsilon:`υ`,phi:`φ`,chi:`χ`,psi:`ψ`,omega:`ω`,thetasym:`ϑ`,upsih:`ϒ`,piv:`ϖ`,bull:`•`,hellip:`…`,prime:`′`,Prime:`″`,oline:`‾`,frasl:`⁄`,weierp:`℘`,image:`ℑ`,real:`ℜ`,trade:`™`,alefsym:`ℵ`,larr:`←`,uarr:`↑`,rarr:`→`,darr:`↓`,harr:`↔`,crarr:`↵`,lArr:`⇐`,uArr:`⇑`,rArr:`⇒`,dArr:`⇓`,hArr:`⇔`,forall:`∀`,part:`∂`,exist:`∃`,empty:`∅`,nabla:`∇`,isin:`∈`,notin:`∉`,ni:`∋`,prod:`∏`,sum:`∑`,minus:`−`,lowast:`∗`,radic:`√`,prop:`∝`,infin:`∞`,ang:`∠`,and:`∧`,or:`∨`,cap:`∩`,cup:`∪`,int:`∫`,there4:`∴`,sim:`∼`,cong:`≅`,asymp:`≈`,ne:`≠`,equiv:`≡`,le:`≤`,ge:`≥`,sub:`⊂`,sup:`⊃`,nsub:`⊄`,sube:`⊆`,supe:`⊇`,oplus:`⊕`,otimes:`⊗`,perp:`⊥`,sdot:`⋅`,lceil:`⌈`,rceil:`⌉`,lfloor:`⌊`,rfloor:`⌋`,lang:`〈`,rang:`〉`,loz:`◊`,spades:`♠`,clubs:`♣`,hearts:`♥`,diams:`♦`,quot:`"`,amp:`&`,lt:`<`,gt:`>`,OElig:`Œ`,oelig:`œ`,Scaron:`Š`,scaron:`š`,Yuml:`Ÿ`,circ:`ˆ`,tilde:`˜`,ensp:` `,emsp:` `,thinsp:` `,zwnj:`‌`,zwj:`‍`,lrm:`‎`,rlm:`‏`,ndash:`–`,mdash:`—`,lsquo:`‘`,rsquo:`’`,sbquo:`‚`,ldquo:`“`,rdquo:`”`,bdquo:`„`,dagger:`†`,Dagger:`‡`,permil:`‰`,lsaquo:`‹`,rsaquo:`›`,euro:`€`},se=[`cent`,`copy`,`divide`,`gt`,`lt`,`not`,`para`,`times`],ce={}.hasOwnProperty,le={},ue;for(ue in oe)ce.call(oe,ue)&&(le[oe[ue]]=ue);var de=/[^\dA-Za-z]/;function fe(e,t,n,r){let i=String.fromCharCode(e);if(ce.call(le,i)){let e=le[i],a=`&`+e;return n&&ae.includes(e)&&!se.includes(e)&&(!r||t&&t!==61&&de.test(String.fromCharCode(t)))?a:a+`;`}return``}function pe(e,t,n){let r=ne(e,t,n.omitOptionalSemicolons),i;if((n.useNamedReferences||n.useShortestReferences)&&(i=fe(e,t,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!i)&&n.useShortestReferences){let i=ie(e,t,n.omitOptionalSemicolons);i.length<r.length&&(r=i)}return i&&(!n.useShortestReferences||i.length<r.length)?i:r}function v(e,t){return g(e,Object.assign({format:pe},t))}var me=/^>|^->|<!--|-->|--!>|<!-$/g,he=[`>`],ge=[`<`,`>`];function _e(e,t,n,r){return r.settings.bogusComments?`<?`+v(e.value,Object.assign({},r.settings.characterReferences,{subset:he}))+`>`:`<!--`+e.value.replace(me,i)+`-->`;function i(e){return v(e,Object.assign({},r.settings.characterReferences,{subset:ge}))}}function ve(e,t,n,r){return`<!`+(r.settings.upperDoctype?`DOCTYPE`:`doctype`)+(r.settings.tightDoctype?``:` `)+`html>`}var y=xe(1),ye=xe(-1),be=[];function xe(e){return t;function t(t,n,r){let i=t?t.children:be,a=(n||0)+e,s=i[a];if(!r)for(;s&&o(s);)a+=e,s=i[a];return s}}var Se={}.hasOwnProperty;function Ce(e){return t;function t(t,n,r){return Se.call(e,t.tagName)&&e[t.tagName](t,n,r)}}var we=Ce({body:De,caption:Te,colgroup:Te,dd:je,dt:Ae,head:Te,html:Ee,li:ke,optgroup:Ne,option:Pe,p:Oe,rp:Me,rt:Me,tbody:Ie,td:ze,tfoot:Le,th:ze,thead:Fe,tr:Re});function Te(e,t,n){let r=y(n,t,!0);return!r||r.type!==`comment`&&!(r.type===`text`&&o(r.value.charAt(0)))}function Ee(e,t,n){let r=y(n,t);return!r||r.type!==`comment`}function De(e,t,n){let r=y(n,t);return!r||r.type!==`comment`}function Oe(e,t,n){let r=y(n,t);return r?r.type===`element`&&(r.tagName===`address`||r.tagName===`article`||r.tagName===`aside`||r.tagName===`blockquote`||r.tagName===`details`||r.tagName===`div`||r.tagName===`dl`||r.tagName===`fieldset`||r.tagName===`figcaption`||r.tagName===`figure`||r.tagName===`footer`||r.tagName===`form`||r.tagName===`h1`||r.tagName===`h2`||r.tagName===`h3`||r.tagName===`h4`||r.tagName===`h5`||r.tagName===`h6`||r.tagName===`header`||r.tagName===`hgroup`||r.tagName===`hr`||r.tagName===`main`||r.tagName===`menu`||r.tagName===`nav`||r.tagName===`ol`||r.tagName===`p`||r.tagName===`pre`||r.tagName===`section`||r.tagName===`table`||r.tagName===`ul`):!n||!(n.type===`element`&&(n.tagName===`a`||n.tagName===`audio`||n.tagName===`del`||n.tagName===`ins`||n.tagName===`map`||n.tagName===`noscript`||n.tagName===`video`))}function ke(e,t,n){let r=y(n,t);return!r||r.type===`element`&&r.tagName===`li`}function Ae(e,t,n){let r=y(n,t);return!!(r&&r.type===`element`&&(r.tagName===`dt`||r.tagName===`dd`))}function je(e,t,n){let r=y(n,t);return!r||r.type===`element`&&(r.tagName===`dt`||r.tagName===`dd`)}function Me(e,t,n){let r=y(n,t);return!r||r.type===`element`&&(r.tagName===`rp`||r.tagName===`rt`)}function Ne(e,t,n){let r=y(n,t);return!r||r.type===`element`&&r.tagName===`optgroup`}function Pe(e,t,n){let r=y(n,t);return!r||r.type===`element`&&(r.tagName===`option`||r.tagName===`optgroup`)}function Fe(e,t,n){let r=y(n,t);return!!(r&&r.type===`element`&&(r.tagName===`tbody`||r.tagName===`tfoot`))}function Ie(e,t,n){let r=y(n,t);return!r||r.type===`element`&&(r.tagName===`tbody`||r.tagName===`tfoot`)}function Le(e,t,n){return!y(n,t)}function Re(e,t,n){let r=y(n,t);return!r||r.type===`element`&&r.tagName===`tr`}function ze(e,t,n){let r=y(n,t);return!r||r.type===`element`&&(r.tagName===`td`||r.tagName===`th`)}var Be=Ce({body:Ue,colgroup:We,head:He,html:Ve,tbody:Ge});function Ve(e){let t=y(e,-1);return!t||t.type!==`comment`}function He(e){let t=new Set;for(let n of e.children)if(n.type===`element`&&(n.tagName===`base`||n.tagName===`title`)){if(t.has(n.tagName))return!1;t.add(n.tagName)}let n=e.children[0];return!n||n.type===`element`}function Ue(e){let t=y(e,-1,!0);return!t||t.type!==`comment`&&!(t.type===`text`&&o(t.value.charAt(0)))&&!(t.type===`element`&&(t.tagName===`meta`||t.tagName===`link`||t.tagName===`script`||t.tagName===`style`||t.tagName===`template`))}function We(e,t,n){let r=ye(n,t),i=y(e,-1,!0);return n&&r&&r.type===`element`&&r.tagName===`colgroup`&&we(r,n.children.indexOf(r),n)?!1:!!(i&&i.type===`element`&&i.tagName===`col`)}function Ge(e,t,n){let r=ye(n,t),i=y(e,-1);return n&&r&&r.type===`element`&&(r.tagName===`thead`||r.tagName===`tbody`)&&we(r,n.children.indexOf(r),n)?!1:!!(i&&i.type===`element`&&i.tagName===`tr`)}var Ke={name:[[`
2
+ import{a as e,c as t,i as n,n as r,o as i,r as a,s as o,t as s}from"./index-CzFZIb87.js";var c={}.hasOwnProperty;function l(e,t){let n=t||{};function r(t,...n){let i=r.invalid,a=r.handlers;if(t&&c.call(t,e)){let n=String(t[e]);i=c.call(a,n)?a[n]:r.unknown}if(i)return i.call(this,t,...n)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}var u=[`area`,`base`,`basefont`,`bgsound`,`br`,`col`,`command`,`embed`,`frame`,`hr`,`image`,`img`,`input`,`keygen`,`link`,`meta`,`param`,`source`,`track`,`wbr`],d=/["&'<>`]/g,f=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,p=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,m=/[|\\{}()[\]^$+*?.]/g,h=new WeakMap;function g(e,t){if(e=e.replace(t.subset?_(t.subset):d,r),t.subset||t.escapeOnly)return e;return e.replace(f,n).replace(p,r);function n(e,n,r){return t.format((e.charCodeAt(0)-55296)*1024+e.charCodeAt(1)-56320+65536,r.charCodeAt(n+2),t)}function r(e,n,r){return t.format(e.charCodeAt(0),r.charCodeAt(n+1),t)}}function _(e){let t=h.get(e);return t||(t=ee(e),h.set(e,t)),t}function ee(e){let t=[],n=-1;for(;++n<e.length;)t.push(e[n].replace(m,`\\$&`));return RegExp(`(?:`+t.join(`|`)+`)`,`g`)}var te=/[\dA-Fa-f]/;function ne(e,t,n){let r=`&#x`+e.toString(16).toUpperCase();return n&&t&&!te.test(String.fromCharCode(t))?r:r+`;`}var re=/\d/;function ie(e,t,n){let r=`&#`+String(e);return n&&t&&!re.test(String.fromCharCode(t))?r:r+`;`}var ae=`AElig.AMP.Aacute.Acirc.Agrave.Aring.Atilde.Auml.COPY.Ccedil.ETH.Eacute.Ecirc.Egrave.Euml.GT.Iacute.Icirc.Igrave.Iuml.LT.Ntilde.Oacute.Ocirc.Ograve.Oslash.Otilde.Ouml.QUOT.REG.THORN.Uacute.Ucirc.Ugrave.Uuml.Yacute.aacute.acirc.acute.aelig.agrave.amp.aring.atilde.auml.brvbar.ccedil.cedil.cent.copy.curren.deg.divide.eacute.ecirc.egrave.eth.euml.frac12.frac14.frac34.gt.iacute.icirc.iexcl.igrave.iquest.iuml.laquo.lt.macr.micro.middot.nbsp.not.ntilde.oacute.ocirc.ograve.ordf.ordm.oslash.otilde.ouml.para.plusmn.pound.quot.raquo.reg.sect.shy.sup1.sup2.sup3.szlig.thorn.times.uacute.ucirc.ugrave.uml.uuml.yacute.yen.yuml`.split(`.`),oe={nbsp:`\xA0`,iexcl:`¡`,cent:`¢`,pound:`£`,curren:`¤`,yen:`¥`,brvbar:`¦`,sect:`§`,uml:`¨`,copy:`©`,ordf:`ª`,laquo:`«`,not:`¬`,shy:`­`,reg:`®`,macr:`¯`,deg:`°`,plusmn:`±`,sup2:`²`,sup3:`³`,acute:`´`,micro:`µ`,para:`¶`,middot:`·`,cedil:`¸`,sup1:`¹`,ordm:`º`,raquo:`»`,frac14:`¼`,frac12:`½`,frac34:`¾`,iquest:`¿`,Agrave:`À`,Aacute:`Á`,Acirc:`Â`,Atilde:`Ã`,Auml:`Ä`,Aring:`Å`,AElig:`Æ`,Ccedil:`Ç`,Egrave:`È`,Eacute:`É`,Ecirc:`Ê`,Euml:`Ë`,Igrave:`Ì`,Iacute:`Í`,Icirc:`Î`,Iuml:`Ï`,ETH:`Ð`,Ntilde:`Ñ`,Ograve:`Ò`,Oacute:`Ó`,Ocirc:`Ô`,Otilde:`Õ`,Ouml:`Ö`,times:`×`,Oslash:`Ø`,Ugrave:`Ù`,Uacute:`Ú`,Ucirc:`Û`,Uuml:`Ü`,Yacute:`Ý`,THORN:`Þ`,szlig:`ß`,agrave:`à`,aacute:`á`,acirc:`â`,atilde:`ã`,auml:`ä`,aring:`å`,aelig:`æ`,ccedil:`ç`,egrave:`è`,eacute:`é`,ecirc:`ê`,euml:`ë`,igrave:`ì`,iacute:`í`,icirc:`î`,iuml:`ï`,eth:`ð`,ntilde:`ñ`,ograve:`ò`,oacute:`ó`,ocirc:`ô`,otilde:`õ`,ouml:`ö`,divide:`÷`,oslash:`ø`,ugrave:`ù`,uacute:`ú`,ucirc:`û`,uuml:`ü`,yacute:`ý`,thorn:`þ`,yuml:`ÿ`,fnof:`ƒ`,Alpha:`Α`,Beta:`Β`,Gamma:`Γ`,Delta:`Δ`,Epsilon:`Ε`,Zeta:`Ζ`,Eta:`Η`,Theta:`Θ`,Iota:`Ι`,Kappa:`Κ`,Lambda:`Λ`,Mu:`Μ`,Nu:`Ν`,Xi:`Ξ`,Omicron:`Ο`,Pi:`Π`,Rho:`Ρ`,Sigma:`Σ`,Tau:`Τ`,Upsilon:`Υ`,Phi:`Φ`,Chi:`Χ`,Psi:`Ψ`,Omega:`Ω`,alpha:`α`,beta:`β`,gamma:`γ`,delta:`δ`,epsilon:`ε`,zeta:`ζ`,eta:`η`,theta:`θ`,iota:`ι`,kappa:`κ`,lambda:`λ`,mu:`μ`,nu:`ν`,xi:`ξ`,omicron:`ο`,pi:`π`,rho:`ρ`,sigmaf:`ς`,sigma:`σ`,tau:`τ`,upsilon:`υ`,phi:`φ`,chi:`χ`,psi:`ψ`,omega:`ω`,thetasym:`ϑ`,upsih:`ϒ`,piv:`ϖ`,bull:`•`,hellip:`…`,prime:`′`,Prime:`″`,oline:`‾`,frasl:`⁄`,weierp:`℘`,image:`ℑ`,real:`ℜ`,trade:`™`,alefsym:`ℵ`,larr:`←`,uarr:`↑`,rarr:`→`,darr:`↓`,harr:`↔`,crarr:`↵`,lArr:`⇐`,uArr:`⇑`,rArr:`⇒`,dArr:`⇓`,hArr:`⇔`,forall:`∀`,part:`∂`,exist:`∃`,empty:`∅`,nabla:`∇`,isin:`∈`,notin:`∉`,ni:`∋`,prod:`∏`,sum:`∑`,minus:`−`,lowast:`∗`,radic:`√`,prop:`∝`,infin:`∞`,ang:`∠`,and:`∧`,or:`∨`,cap:`∩`,cup:`∪`,int:`∫`,there4:`∴`,sim:`∼`,cong:`≅`,asymp:`≈`,ne:`≠`,equiv:`≡`,le:`≤`,ge:`≥`,sub:`⊂`,sup:`⊃`,nsub:`⊄`,sube:`⊆`,supe:`⊇`,oplus:`⊕`,otimes:`⊗`,perp:`⊥`,sdot:`⋅`,lceil:`⌈`,rceil:`⌉`,lfloor:`⌊`,rfloor:`⌋`,lang:`〈`,rang:`〉`,loz:`◊`,spades:`♠`,clubs:`♣`,hearts:`♥`,diams:`♦`,quot:`"`,amp:`&`,lt:`<`,gt:`>`,OElig:`Œ`,oelig:`œ`,Scaron:`Š`,scaron:`š`,Yuml:`Ÿ`,circ:`ˆ`,tilde:`˜`,ensp:` `,emsp:` `,thinsp:` `,zwnj:`‌`,zwj:`‍`,lrm:`‎`,rlm:`‏`,ndash:`–`,mdash:`—`,lsquo:`‘`,rsquo:`’`,sbquo:`‚`,ldquo:`“`,rdquo:`”`,bdquo:`„`,dagger:`†`,Dagger:`‡`,permil:`‰`,lsaquo:`‹`,rsaquo:`›`,euro:`€`},se=[`cent`,`copy`,`divide`,`gt`,`lt`,`not`,`para`,`times`],ce={}.hasOwnProperty,le={},ue;for(ue in oe)ce.call(oe,ue)&&(le[oe[ue]]=ue);var de=/[^\dA-Za-z]/;function fe(e,t,n,r){let i=String.fromCharCode(e);if(ce.call(le,i)){let e=le[i],a=`&`+e;return n&&ae.includes(e)&&!se.includes(e)&&(!r||t&&t!==61&&de.test(String.fromCharCode(t)))?a:a+`;`}return``}function pe(e,t,n){let r=ne(e,t,n.omitOptionalSemicolons),i;if((n.useNamedReferences||n.useShortestReferences)&&(i=fe(e,t,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!i)&&n.useShortestReferences){let i=ie(e,t,n.omitOptionalSemicolons);i.length<r.length&&(r=i)}return i&&(!n.useShortestReferences||i.length<r.length)?i:r}function v(e,t){return g(e,Object.assign({format:pe},t))}var me=/^>|^->|<!--|-->|--!>|<!-$/g,he=[`>`],ge=[`<`,`>`];function _e(e,t,n,r){return r.settings.bogusComments?`<?`+v(e.value,Object.assign({},r.settings.characterReferences,{subset:he}))+`>`:`<!--`+e.value.replace(me,i)+`-->`;function i(e){return v(e,Object.assign({},r.settings.characterReferences,{subset:ge}))}}function ve(e,t,n,r){return`<!`+(r.settings.upperDoctype?`DOCTYPE`:`doctype`)+(r.settings.tightDoctype?``:` `)+`html>`}var y=xe(1),ye=xe(-1),be=[];function xe(e){return t;function t(t,n,r){let i=t?t.children:be,a=(n||0)+e,s=i[a];if(!r)for(;s&&o(s);)a+=e,s=i[a];return s}}var Se={}.hasOwnProperty;function Ce(e){return t;function t(t,n,r){return Se.call(e,t.tagName)&&e[t.tagName](t,n,r)}}var we=Ce({body:De,caption:Te,colgroup:Te,dd:je,dt:Ae,head:Te,html:Ee,li:ke,optgroup:Ne,option:Pe,p:Oe,rp:Me,rt:Me,tbody:Ie,td:ze,tfoot:Le,th:ze,thead:Fe,tr:Re});function Te(e,t,n){let r=y(n,t,!0);return!r||r.type!==`comment`&&!(r.type===`text`&&o(r.value.charAt(0)))}function Ee(e,t,n){let r=y(n,t);return!r||r.type!==`comment`}function De(e,t,n){let r=y(n,t);return!r||r.type!==`comment`}function Oe(e,t,n){let r=y(n,t);return r?r.type===`element`&&(r.tagName===`address`||r.tagName===`article`||r.tagName===`aside`||r.tagName===`blockquote`||r.tagName===`details`||r.tagName===`div`||r.tagName===`dl`||r.tagName===`fieldset`||r.tagName===`figcaption`||r.tagName===`figure`||r.tagName===`footer`||r.tagName===`form`||r.tagName===`h1`||r.tagName===`h2`||r.tagName===`h3`||r.tagName===`h4`||r.tagName===`h5`||r.tagName===`h6`||r.tagName===`header`||r.tagName===`hgroup`||r.tagName===`hr`||r.tagName===`main`||r.tagName===`menu`||r.tagName===`nav`||r.tagName===`ol`||r.tagName===`p`||r.tagName===`pre`||r.tagName===`section`||r.tagName===`table`||r.tagName===`ul`):!n||!(n.type===`element`&&(n.tagName===`a`||n.tagName===`audio`||n.tagName===`del`||n.tagName===`ins`||n.tagName===`map`||n.tagName===`noscript`||n.tagName===`video`))}function ke(e,t,n){let r=y(n,t);return!r||r.type===`element`&&r.tagName===`li`}function Ae(e,t,n){let r=y(n,t);return!!(r&&r.type===`element`&&(r.tagName===`dt`||r.tagName===`dd`))}function je(e,t,n){let r=y(n,t);return!r||r.type===`element`&&(r.tagName===`dt`||r.tagName===`dd`)}function Me(e,t,n){let r=y(n,t);return!r||r.type===`element`&&(r.tagName===`rp`||r.tagName===`rt`)}function Ne(e,t,n){let r=y(n,t);return!r||r.type===`element`&&r.tagName===`optgroup`}function Pe(e,t,n){let r=y(n,t);return!r||r.type===`element`&&(r.tagName===`option`||r.tagName===`optgroup`)}function Fe(e,t,n){let r=y(n,t);return!!(r&&r.type===`element`&&(r.tagName===`tbody`||r.tagName===`tfoot`))}function Ie(e,t,n){let r=y(n,t);return!r||r.type===`element`&&(r.tagName===`tbody`||r.tagName===`tfoot`)}function Le(e,t,n){return!y(n,t)}function Re(e,t,n){let r=y(n,t);return!r||r.type===`element`&&r.tagName===`tr`}function ze(e,t,n){let r=y(n,t);return!r||r.type===`element`&&(r.tagName===`td`||r.tagName===`th`)}var Be=Ce({body:Ue,colgroup:We,head:He,html:Ve,tbody:Ge});function Ve(e){let t=y(e,-1);return!t||t.type!==`comment`}function He(e){let t=new Set;for(let n of e.children)if(n.type===`element`&&(n.tagName===`base`||n.tagName===`title`)){if(t.has(n.tagName))return!1;t.add(n.tagName)}let n=e.children[0];return!n||n.type===`element`}function Ue(e){let t=y(e,-1,!0);return!t||t.type!==`comment`&&!(t.type===`text`&&o(t.value.charAt(0)))&&!(t.type===`element`&&(t.tagName===`meta`||t.tagName===`link`||t.tagName===`script`||t.tagName===`style`||t.tagName===`template`))}function We(e,t,n){let r=ye(n,t),i=y(e,-1,!0);return n&&r&&r.type===`element`&&r.tagName===`colgroup`&&we(r,n.children.indexOf(r),n)?!1:!!(i&&i.type===`element`&&i.tagName===`col`)}function Ge(e,t,n){let r=ye(n,t),i=y(e,-1);return n&&r&&r.type===`element`&&(r.tagName===`thead`||r.tagName===`tbody`)&&we(r,n.children.indexOf(r),n)?!1:!!(i&&i.type===`element`&&i.tagName===`tr`)}var Ke={name:[[`
3
3
  \f\r &/=>`.split(``),`
4
4
  \f\r "&'/=>\``.split(``)],[`\0
5
5
  \f\r "&'/<=>`.split(``),`\0
@@ -172,7 +172,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
172
172
  `)})},children:[`Transcripts (`,p.transcripts.length,`)`]}),(0,L.jsxs)(`button`,{className:Y.badge,onClick:()=>o(!0),title:`Upload transcript or note`,children:[(0,L.jsx)(pr,{size:12}),`Upload`]}),(0,L.jsxs)(`button`,{className:`${Y.syncButton} `,onClick:async()=>{c(!0),u(null);try{let n=t?[t]:[`github`,`linear`,`rally`],r=0,a=null;for(let i of n)try{let n=await fetch(`/api/command-deck/planning/${e}/sync-discussions`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({tracker:i})});if(n.ok){let e=await n.json();r+=e.synced||0}else t&&(a=(await n.json().catch(()=>({error:`Sync failed`}))).error||`HTTP ${n.status}`)}catch{t&&(a=`Network error`)}u(a&&r===0?{message:a,isError:!0}:r>0?{message:`Synced ${r} — generating status...`,isError:!1}:{message:`No new discussions`,isError:!1}),f(!0);try{let t=await fetch(`/api/command-deck/planning/${e}/status-review`,{method:`POST`});if(t.ok){let e=await t.json(),n=e.cached;u(n?{message:r>0?`Synced ${r} (status unchanged)`:`No changes detected`,isError:!1}:r>0?{message:`Synced ${r} + status updated`,isError:!1}:{message:`Status updated`,isError:!1}),i({title:`Status Review${n?` (cached)`:``} — ${new Date(e.reviewedAt).toLocaleString()}`,content:e.statusReview})}else{let e=await t.json().catch(()=>({error:`Status review failed`}));r>0&&u({message:`Synced ${r} (status: ${e.error})`,isError:!1})}}catch(e){console.error(`Status review generation failed:`,e)}finally{f(!1)}m()}catch(e){console.error(`Sync failed:`,e),u({message:`Sync failed`,isError:!0})}finally{c(!1),setTimeout(()=>u(null),6e3)}},disabled:s||d,title:`Sync discussions and generate AI status review`,children:[(0,L.jsx)(Vn,{size:12,className:s||d?Y.spinning:``}),d?`Reviewing...`:s?`Syncing...`:`Sync`]}),l&&(0,L.jsx)(`span`,{className:Y.badge,style:{color:l.isError?`var(--mc-error, #ef4444)`:`var(--mc-success, #22c55e)`,fontSize:`0.7rem`,opacity:.9},children:l.message})]}),r&&(0,L.jsx)(pPe,{title:r.title,content:r.content,onClose:()=>i(null)}),a&&(0,L.jsx)(mPe,{issueId:e,onClose:()=>{o(!1),m()}})]})}async function _Pe(){let e=await fetch(`/api/deacon/status`);if(!e.ok)throw Error(`Failed to fetch deacon status`);return e.json()}async function vPe(){let e=await fetch(`/api/deacon/logs?limit=50`);if(!e.ok)throw Error(`Failed to fetch deacon logs`);return e.json()}function yPe(e){if(!e)return`never`;let t=Date.now()-new Date(e).getTime();if(t<0)return`just now`;let n=Math.floor(t/1e3);if(n<60)return`${n}s ago`;let r=Math.floor(n/60);return r<60?`${r}m ago`:`${Math.floor(r/60)}h ago`}function bPe(e){return e.consecutiveFailures>=3?`var(--mc-error)`:e.consecutiveFailures>0||e.lastForceKillTime&&Date.now()-new Date(e.lastForceKillTime).getTime()<300*1e3?`var(--mc-warning)`:`var(--mc-success)`}function xPe(e){return e.replace(`-agent`,``)}function SPe(e){try{return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}catch{return``}}var CPe={info:`var(--mc-text-muted)`,warn:`var(--mc-warning)`,action:`var(--mc-accent)`,error:`var(--mc-error)`},wPe={info:`INF`,warn:`WRN`,action:`ACT`,error:`ERR`};function TPe(){let[e,t]=(0,I.useState)(!1),[n,r]=(0,I.useState)(!1),i=(0,I.useRef)(null),{data:a}=rt({queryKey:[`deacon-status`],queryFn:_Pe,refetchInterval:15e3}),{data:o}=rt({queryKey:[`deacon-logs`],queryFn:vPe,refetchInterval:n?5e3:!1,enabled:n});if((0,I.useEffect)(()=>{n&&i.current&&i.current.scrollIntoView({behavior:`smooth`})},[o,n]),!a)return null;let s=Object.values(a.state.specialists||{}),c=a.lastPatrol?.actions||[],l=c.length>0,u=o?.logs||[];return(0,L.jsxs)(`div`,{className:Y.deaconPanel,children:[(0,L.jsxs)(`div`,{className:Y.deaconHeader,onClick:()=>t(!e),children:[(0,L.jsx)(Xn,{size:12,style:{color:a.isRunning?`var(--mc-success)`:`var(--mc-text-muted)`,flexShrink:0}}),(0,L.jsx)(`span`,{className:Y.deaconTitle,children:`Deacon`}),(0,L.jsx)(`span`,{className:Y.deaconMeta,children:a.isRunning?yPe(a.state.lastPatrol):`stopped`}),l&&(0,L.jsx)(`span`,{className:Y.deaconActionCount,children:c.length}),e?(0,L.jsx)(Tt,{size:12,style:{color:`var(--mc-text-muted)`,flexShrink:0}}):(0,L.jsx)(Et,{size:12,style:{color:`var(--mc-text-muted)`,flexShrink:0}})]}),(0,L.jsx)(`div`,{className:Y.deaconSpecialists,children:s.map(e=>(0,L.jsxs)(`div`,{className:Y.deaconSpecRow,children:[(0,L.jsx)(`span`,{className:Y.deaconSpecDot,style:{background:bPe(e)}}),(0,L.jsx)(`span`,{className:Y.deaconSpecName,children:xPe(e.specialistName)}),e.consecutiveFailures>0&&(0,L.jsxs)(`span`,{className:Y.deaconSpecFailures,children:[e.consecutiveFailures,`x`]})]},e.specialistName))}),e&&(0,L.jsxs)(L.Fragment,{children:[l&&(0,L.jsx)(`div`,{className:Y.deaconActions,children:c.map((e,t)=>(0,L.jsx)(`div`,{className:Y.deaconAction,children:e},t))}),(0,L.jsxs)(`div`,{className:Y.deaconLogToggle,onClick:e=>{e.stopPropagation(),r(!n)},children:[(0,L.jsx)(Wn,{size:10,style:{color:`var(--mc-text-muted)`,flexShrink:0}}),(0,L.jsx)(`span`,{children:n?`Hide logs`:`Show logs`})]}),n&&(0,L.jsxs)(`div`,{className:Y.deaconLogViewer,children:[u.length===0?(0,L.jsx)(`div`,{className:Y.deaconLogEmpty,children:`No logs yet — waiting for patrol cycle...`}):u.map((e,t)=>(0,L.jsxs)(`div`,{className:Y.deaconLogEntry,children:[(0,L.jsx)(`span`,{className:Y.deaconLogTime,children:SPe(e.timestamp)}),(0,L.jsx)(`span`,{className:Y.deaconLogLevel,style:{color:CPe[e.level]||`var(--mc-text-muted)`},children:wPe[e.level]||e.level}),(0,L.jsx)(`span`,{className:Y.deaconLogMessage,children:e.message})]},t)),(0,L.jsx)(`div`,{ref:i})]})]})]})}function tJ({issueId:e,isOpen:t,onClose:n}){let{data:r,isLoading:i,isFetching:a,error:o}=rt({queryKey:[`beads`,e],queryFn:async()=>{let t=await fetch(`/api/issues/${e}/beads`);if(!t.ok)throw Error(`Failed to fetch tasks`);return t.json()},enabled:t,staleTime:0,refetchOnMount:`always`});if(!t)return null;let s=r?.tasks?.filter(e=>e.status!==`closed`)||[],c=r?.tasks?.filter(e=>e.status===`closed`)||[];return(0,L.jsxs)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center`,children:[(0,L.jsx)(`div`,{className:`absolute inset-0 bg-black/70 backdrop-blur-sm`,onClick:n}),(0,L.jsxs)(`div`,{className:`relative bg-surface-raised rounded-xl shadow-2xl w-full max-w-lg mx-4 max-h-[70vh] overflow-hidden flex flex-col`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b border-divider`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(On,{className:`w-5 h-5 text-success`}),(0,L.jsxs)(`h2`,{className:`font-semibold text-content`,children:[`Tasks: `,e]})]}),(0,L.jsx)(`button`,{onClick:n,className:`p-1 text-content-subtle hover:text-content hover:bg-surface-overlay rounded transition-colors`,children:(0,L.jsx)(_r,{className:`w-5 h-5`})})]}),(0,L.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:[(i||a)&&!r?.tasks?.length&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[[1,2,3].map(e=>(0,L.jsxs)(`div`,{className:`flex items-start gap-3 p-3 rounded-lg border border-divider bg-surface-overlay/30 animate-pulse`,children:[(0,L.jsx)(`div`,{className:`w-4 h-4 bg-surface-emphasis rounded-full mt-0.5`}),(0,L.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,L.jsx)(`div`,{className:`h-4 bg-surface-emphasis rounded w-3/4`}),(0,L.jsx)(`div`,{className:`h-3 bg-surface-overlay rounded w-1/4`})]})]},e)),(0,L.jsxs)(`div`,{className:`flex items-center justify-center py-2 text-content-muted text-sm`,children:[(0,L.jsx)(kn,{className:`w-4 h-4 animate-spin mr-2`}),`Loading tasks from workspace...`]})]}),o&&(0,L.jsx)(`div`,{className:`text-destructive text-center py-8`,children:`Failed to load tasks`}),r&&r.tasks?.length===0&&!a&&(0,L.jsxs)(`div`,{className:`text-content-muted text-center py-8`,children:[(0,L.jsx)(On,{className:`w-8 h-8 mx-auto mb-2 opacity-50`}),(0,L.jsx)(`p`,{children:`No tasks created yet`}),(0,L.jsx)(`p`,{className:`text-xs mt-2`,children:`Tasks will appear here once created using beads.`})]}),r&&r.tasks?.length>0&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-4 text-xs text-content-subtle mb-3 pb-3 border-b border-divider`,children:[(0,L.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,L.jsx)(`div`,{className:`w-2 h-2 bg-primary rounded-full`}),s.length,` open`]}),(0,L.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,L.jsx)(At,{className:`w-3 h-3 text-success`}),c.length,` closed`]})]}),s.map(e=>(0,L.jsx)(nJ,{task:e},e.id)),c.length>0&&s.length>0&&(0,L.jsx)(`div`,{className:`text-xs text-content-muted mt-4 mb-2`,children:`Completed`}),c.map(e=>(0,L.jsx)(nJ,{task:e},e.id))]})]}),(0,L.jsxs)(`div`,{className:`px-4 py-3 border-t border-divider text-xs text-content-muted flex items-center justify-between`,children:[(0,L.jsxs)(`span`,{children:[r?.count||0,` task`,r?.count===1?``:`s`]}),(0,L.jsx)(`span`,{className:`text-content-subtle`,children:`Beads`})]})]})]})}function nJ({task:e}){let t={open:`bg-surface-overlay/50 border-divider-strong`,in_progress:`badge-bg-primary border-primary/40`,closed:`badge-bg-success border-success/30 opacity-60`},n={open:(0,L.jsx)(`div`,{className:`w-4 h-4 border-2 border-border rounded-full`}),in_progress:(0,L.jsx)(kn,{className:`w-4 h-4 text-primary animate-spin`}),closed:(0,L.jsx)(At,{className:`w-4 h-4 text-success`})};return(0,L.jsxs)(`div`,{className:`flex items-start gap-3 p-3 rounded-lg border ${t[e.status]}`,children:[(0,L.jsx)(`div`,{className:`mt-0.5`,children:n[e.status]}),(0,L.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,L.jsx)(`div`,{className:`text-sm text-content`,children:e.title}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mt-1 flex-wrap`,children:[(0,L.jsx)(`span`,{className:`text-xs text-content-muted`,children:e.id}),e.blockedBy.length>0&&(0,L.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-warning`,children:[(0,L.jsx)(Rt,{className:`w-3 h-3`}),`Blocked`]}),e.labels.filter(e=>e.startsWith(`difficulty:`)).map(e=>(0,L.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded ${e.includes(`simple`)||e.includes(`trivial`)?`badge-bg-success text-success`:e.includes(`medium`)?`badge-bg-warning text-warning`:e.includes(`complex`)||e.includes(`hard`)?`badge-bg-destructive text-destructive`:`bg-surface-overlay text-content-body`}`,children:e.replace(`difficulty:`,``)},e))]})]})]})}async function EPe(){let e=await fetch(`/api/conversations`);if(!e.ok)throw Error(`Failed to fetch conversations`);return e.json()}async function DPe(e){if(!(await fetch(`/api/conversations/${encodeURIComponent(e)}/archive`,{method:`POST`})).ok)throw Error(`Failed to archive conversation`)}function OPe({selectedConversation:e,onSelectConversation:t}){let n=He(),{data:r=[],isLoading:i}=rt({queryKey:[`conversations`],queryFn:EPe,refetchInterval:1e4}),a=it({mutationFn:DPe,onSuccess:(r,i)=>{n.invalidateQueries({queryKey:[`conversations`]}),e===i&&t(null)}});return i?(0,L.jsxs)(`div`,{className:Y.skeletonList,children:[(0,L.jsx)(`div`,{className:Y.skeletonItem}),(0,L.jsx)(`div`,{className:Y.skeletonItem})]}):r.length===0?(0,L.jsx)(`div`,{className:Y.conversationEmpty,children:`No conversations yet`}):(0,L.jsx)(`div`,{className:Y.conversationList,children:r.map(n=>(0,L.jsxs)(`button`,{className:`${Y.conversationItem} ${e===n.name?Y.conversationItemSelected:``}`,onClick:()=>t(n.name),title:n.name,children:[(0,L.jsx)(Ft,{size:7,className:Y.conversationDot,style:{fill:n.sessionAlive?`var(--mc-success)`:`var(--mc-text-muted)`,color:n.sessionAlive?`var(--mc-success)`:`var(--mc-text-muted)`}}),(0,L.jsx)(`span`,{className:Y.conversationName,children:n.title??n.name}),n.totalCost!==void 0&&n.totalCost>0&&(0,L.jsx)(`span`,{className:Y.featureCost,children:n.totalCost<.01?`<$0.01`:`$${n.totalCost.toFixed(2)}`}),(0,L.jsx)(`span`,{role:`button`,tabIndex:0,className:Y.conversationArchiveBtn,onClick:e=>{e.stopPropagation(),a.mutate(n.name)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.stopPropagation(),a.mutate(n.name))},title:`Archive conversation`,"aria-label":`Archive ${n.name}`,children:(0,L.jsx)(ut,{size:11})})]},n.id))})}function rJ(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o;n.key&&n.debug?.call(n)&&(o=Date.now());let s=e();if(!(s.length!==r.length||s.some((e,t)=>r[t]!==e)))return i;r=s;let c;if(n.key&&n.debug?.call(n)&&(c=Date.now()),i=t(...s),n.key&&n.debug?.call(n)){let e=Math.round((Date.now()-o)*100)/100,t=Math.round((Date.now()-c)*100)/100,r=t/16,i=(e,t)=>{for(e=String(e);e.length<t;)e=` `+e;return e};console.info(`%c⏱ ${i(t,5)} /${i(e,5)} ms`,`
173
173
  font-size: .6rem;
174
174
  font-weight: bold;
175
- color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n?.key)}return n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i}return o.updateDeps=e=>{r=e},o}function iJ(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var kPe=(e,t)=>Math.abs(e-t)<1.01,APe=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},aJ=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},jPe=e=>e,MPe=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let e=t;e<=n;e++)r.push(e);return r},NPe=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(aJ(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(aJ(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},oJ={passive:!0},sJ=typeof window>`u`?!0:`onscrollend`in window,PPe=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=0,a=e.options.useScrollendEvent&&sJ?()=>void 0:APe(r,()=>{t(i,!1)},e.options.isScrollingResetDelay),o=r=>()=>{let{horizontal:o,isRtl:s}=e.options;i=o?n.scrollLeft*(s&&-1||1):n.scrollTop,a(),t(i,r)},s=o(!0),c=o(!1);n.addEventListener(`scroll`,s,oJ);let l=e.options.useScrollendEvent&&sJ;return l&&n.addEventListener(`scrollend`,c,oJ),()=>{n.removeEventListener(`scroll`,s),l&&n.removeEventListener(`scrollend`,c)}},FPe=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},IPe=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;let o=e+t;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:o,behavior:n})},LPe=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([t,n])=>{n===void 0&&delete e[t]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:jPe,rangeExtractor:MPe,onChange:()=>{},measureElement:FPe,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...e}},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=rJ(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=rJ(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(e,t,n,r,i,a)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a}),{key:!1}),this.getMeasurements=rJ(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a},o)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let s=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1);let c=this.measurementsCache.slice(0,s),l=Array(a).fill(void 0);for(let e=0;e<s;e++){let t=c[e];t&&(l[t.lane]=e)}for(let i=s;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),s,u;if(a!==void 0&&this.options.lanes>1){s=a;let e=l[s],r=e===void 0?void 0:c[e];u=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?c[i-1]:this.getFurthestMeasurement(c,i);u=e?e.end+this.options.gap:t+n,s=e?e.lane:i%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(i,s)}let d=o.get(e),f=typeof d==`number`?d:this.options.estimateSize(i),p=u+f;c[i]={index:i,start:u,size:f,end:p,key:e,lane:s},l[s]=i}return this.measurementsCache=c,c},{key:!1,debug:()=>this.options.debug}),this.calculateRange=rJ(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?RPe({measurements:e,outerSize:t,scrollOffset:n,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=rJ(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{let n=this.measurementsCache[e];if(!n)return;let r=t-(this.itemSizeCache.get(n.key)??n.size);r!==0&&(this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?n.start<this.getScrollOffset()+this.scrollAdjustments:this.shouldAdjustScrollPositionOnItemSizeChange(n,r,this))&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=r,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(n.index),this.itemSizeCache=new Map(this.itemSizeCache.set(n.key,t)),this.notify(!1))},this.getVirtualItems=rJ(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length!==0)return iJ(t[cJ(0,t.length-1,e=>iJ(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t);this.scrollState={index:null,align:t,behavior:n,startedAt:this.now(),lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e;this.scrollState={index:null,align:`start`,behavior:t,startedAt:this.now(),lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1)t=e[e.length-1]?.end??0;else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&kPe(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.scrollState=null;return}}else this.scrollState.stableFrames=0,n&&(this.scrollState.lastTargetOffset=t,this.scrollState.behavior=`auto`,this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}));this.scheduleScrollReconcile()}},cJ=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function RPe({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){let i=e.length-1,a=t=>e[t].start;if(e.length<=r)return{startIndex:0,endIndex:i};let o=cJ(0,i,a,n),s=o;if(r===1)for(;s<i&&e[s].end<n+t;)s++;else if(r>1){let a=Array(r).fill(0);for(;s<i&&a.some(e=>e<n+t);){let t=e[s];a[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(i,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var lJ=typeof document<`u`?I.useLayoutEffect:I.useEffect;function zPe({useFlushSync:e=!0,...t}){let n=I.useReducer(()=>({}),{})[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,Er.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=I.useState(()=>new LPe(r));return i.setOptions(r),lJ(()=>i._didMount(),[]),lJ(()=>i._willUpdate()),i}function BPe(e){return zPe({observeElementRect:NPe,observeElementOffset:PPe,scrollToFn:IPe,...e})}var uJ=new class{map=new Map;constructor(e){this.capacity=e}get(e){let t=this.map.get(e);return t!==void 0&&(this.map.delete(e),this.map.set(e,t)),t}set(e,t){this.map.has(e)?this.map.delete(e):this.map.size>=this.capacity&&this.map.delete(this.map.keys().next().value),this.map.set(e,t)}}(500);function VPe(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=t*16777619>>>0;return t}function HPe(e,t){return`${VPe(e)}:${e.length}:${t}`}var dJ=null;async function UPe(){return dJ||=eR(()=>import(`./dist-BaQPC-c6.js`).then(e=>e.getSharedHighlighter({themes:[`github-dark`],langs:[]})),[]),dJ}async function WPe(e,t,n){let r=HPe(e,t);if(!n){let e=uJ.get(r);if(e!==void 0)return e}try{let i=(await UPe()).codeToHtml(e,{lang:t||`text`,theme:`github-light`});return n||uJ.set(r,i),i}catch{return`<pre><code>${e.replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}</code></pre>`}}var fJ=class extends I.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback:this.props.children}};function GPe({code:e,lang:t,isStreaming:n}){let[r,i]=(0,I.useState)(null),[a,o]=(0,I.useState)(!1),s=(0,I.useRef)(!1);(0,I.useEffect)(()=>(s.current=!1,WPe(e,t,n).then(e=>{s.current||i(e)}),()=>{s.current=!0}),[e,t,n]);let c=(0,I.useCallback)(()=>{navigator.clipboard.writeText(e).then(()=>{o(!0),setTimeout(()=>o(!1),2e3)})},[e]);return(0,L.jsxs)(`div`,{className:Y.codeBlock,children:[(0,L.jsx)(`button`,{className:Y.copyButton,onClick:c,title:`Copy code`,children:a?(0,L.jsx)(wt,{size:13}):(0,L.jsx)(Gt,{size:13})}),r?(0,L.jsx)(`div`,{className:Y.shikiOutput,dangerouslySetInnerHTML:{__html:r}}):(0,L.jsx)(`pre`,{className:Y.codePlain,children:(0,L.jsx)(`code`,{children:e})})]})}function KPe(e){return{pre({children:t}){let n=I.Children.toArray(t)[0];if(!I.isValidElement(n))return(0,L.jsx)(`pre`,{children:t});let r=n,i=r.props.className??``,a=/language-(\w+)/.exec(i)?.[1]??``,o=String(r.props.children??``).trimEnd();return(0,L.jsx)(fJ,{fallback:(0,L.jsx)(`pre`,{className:Y.codePlain,children:(0,L.jsx)(`code`,{children:o})}),children:(0,L.jsx)(GPe,{code:o,lang:a,isStreaming:e})})},a({href:e,children:t}){return(0,L.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:Y.mdLink,children:t})}}}var qPe=(0,I.memo)(function({text:e,isStreaming:t=!1}){let n=KPe(t);return(0,L.jsx)(fJ,{fallback:(0,L.jsx)(`pre`,{className:Y.mdFallback,children:e}),children:(0,L.jsx)(`div`,{className:Y.chatMarkdown,children:(0,L.jsx)(JP,{remarkPlugins:[VL],components:n,children:e})})})});function JPe(e,t){return[...e.map(e=>({id:e.id,kind:`message`,createdAt:e.createdAt,message:e})),...t.map(e=>({id:e.id,kind:`work`,createdAt:e.createdAt,entry:e}))].sort((e,t)=>e.createdAt.localeCompare(t.createdAt))}function YPe(e,t){let n=[],r=0;for(;r<e.length;){let t=e[r];if(t.kind===`work`){let i=[t.entry],a=r+1;for(;a<e.length&&e[a].kind===`work`;)i.push(e[a].entry),a++;n.push({kind:`work`,id:t.id,createdAt:t.createdAt,groupedEntries:i}),r=a}else n.push({kind:`message`,id:t.id,createdAt:t.createdAt,message:t.message}),r++}if(t){let t=e[e.length-1];n.push({kind:`working`,id:`working-indicator`,createdAt:t?.createdAt??null})}return n}var XPe=6;function ZPe(e,t=800){if(e.kind===`working`)return 40;if(e.kind===`work`)return 28+Math.min(e.groupedEntries.length,XPe)*32;let{message:n}=e;if(n.role===`user`){let e=Math.max(4,Math.floor((t*.8-32)/8.4));return 96+Math.max(1,Math.ceil(n.text.length/e))*22}let r=Math.max(20,Math.floor((t-8)/7.2));return 41+Math.max(1,Math.ceil(n.text.length/r))*22.75}var pJ=6,QPe=8,$Pe=64;function mJ(e){try{return new Date(e).toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}catch{return``}}function eFe(e,t){let n=new Date(t).getTime()-new Date(e).getTime();if(n<1e3)return`${n}ms`;let r=n/1e3;if(r<60)return`${r.toFixed(1)}s`;let i=Math.floor(r/60),a=Math.round(r%60);return a>0?`${i}m ${a}s`:`${i}m`}var tFe=(0,I.memo)(function({messages:e,workLog:t,streaming:n}){let r=(0,I.useRef)(null),i=(0,I.useRef)(null),[a,o]=(0,I.useState)(800),s=(0,I.useRef)(!0),[c,l]=(0,I.useState)(!1),u=YPe(JPe(e,t),n),d=Math.max(0,u.length-QPe),f=u.slice(0,d),p=u.slice(d),m=`width:${Math.round(a)}`,h=BPe({count:f.length,getScrollElement:()=>r.current,getItemKey:e=>`${m}:${f[e].id}`,estimateSize:e=>ZPe(f[e],a),measureElement:e=>e.getBoundingClientRect().height,useAnimationFrameWithResizeObserver:!0,overscan:8});(0,I.useLayoutEffect)(()=>{let e=r.current;if(!e)return;let t=new ResizeObserver(()=>o(e.clientWidth));return t.observe(e),()=>t.disconnect()},[]),(0,I.useLayoutEffect)(()=>{let e=i.current;if(!e)return;let t=new ResizeObserver(()=>{s.current&&r.current&&(r.current.scrollTop=r.current.scrollHeight)});return t.observe(e),()=>t.disconnect()},[]),(0,I.useEffect)(()=>{let e=r.current;!e||!s.current||(e.scrollTop=e.scrollHeight)},[u.length,n]);let g=(0,I.useCallback)(()=>{let e=r.current;e&&(e.scrollTop=e.scrollHeight,s.current=!0,l(!1))},[]),_=(0,I.useCallback)(()=>{let e=r.current;if(!e)return;let t=e.scrollHeight-e.clientHeight-e.scrollTop<=$Pe;s.current=t,l(!t)},[]),v=h.getVirtualItems();return(0,L.jsxs)(`div`,{style:{position:`relative`,flex:1,overflow:`hidden`,display:`flex`,flexDirection:`column`},children:[(0,L.jsx)(`div`,{ref:r,className:Y.messagesTimeline,onScroll:_,style:{flex:1},children:(0,L.jsxs)(`div`,{ref:i,className:Y.messagesTimelineInner,children:[f.length>0&&(0,L.jsx)(`div`,{style:{height:h.getTotalSize(),position:`relative`},children:v.map(e=>{let t=f[e.index];return(0,L.jsx)(`div`,{"data-index":e.index,ref:e=>{e&&h.measureElement(e)},style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${e.start}px)`},children:(0,L.jsx)(hJ,{row:t,isStreaming:n})},e.key)})}),p.map(e=>(0,L.jsx)(hJ,{row:e,isStreaming:n},e.id))]})}),c&&(0,L.jsxs)(`button`,{onClick:g,style:{position:`absolute`,bottom:12,right:16,zIndex:10,display:`flex`,alignItems:`center`,gap:4,padding:`6px 12px`,background:`var(--color-primary)`,color:`var(--color-primary-foreground)`,border:`none`,borderRadius:20,fontSize:12,fontWeight:700,cursor:`pointer`,boxShadow:`0 2px 8px rgba(0,0,0,0.25)`,opacity:.95},title:`Scroll to bottom`,children:[(0,L.jsx)(Tt,{size:14}),`Bottom`]})]})}),hJ=(0,I.memo)(function({row:e,isStreaming:t}){return e.kind===`working`?(0,L.jsx)(sFe,{startedAt:e.createdAt}):e.kind===`work`?(0,L.jsx)(iFe,{entries:e.groupedEntries}):e.message.role===`user`?(0,L.jsx)(nFe,{message:e.message}):(0,L.jsx)(rFe,{message:e.message,isStreaming:t})});function nFe({message:e}){return(0,L.jsx)(`div`,{className:Y.userMessageRow,children:(0,L.jsxs)(`div`,{className:Y.userMessageBubble,children:[(0,L.jsx)(`p`,{className:Y.userMessageText,children:e.text}),(0,L.jsx)(`span`,{className:Y.messageTimestamp,children:mJ(e.createdAt)})]})})}function rFe({message:e,isStreaming:t}){let n=e.completedAt?eFe(e.createdAt,e.completedAt):null;return(0,L.jsxs)(`div`,{className:Y.assistantMessageRow,children:[(0,L.jsx)(qPe,{text:e.text,isStreaming:t&&!e.completedAt}),(0,L.jsxs)(`div`,{className:Y.messageMetadata,children:[(0,L.jsx)(`span`,{className:Y.messageTimestamp,children:mJ(e.createdAt)}),n&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:Y.messageSeparator,children:`·`}),(0,L.jsx)(`span`,{className:Y.messageTimestamp,children:n})]})]})]})}function iFe({entries:e}){let[t,n]=(0,I.useState)(!1),r=t?e:e.slice(0,pJ),i=e.length>pJ;return(0,L.jsxs)(`div`,{className:Y.workLogGroup,children:[r.map(e=>(0,L.jsx)(oFe,{entry:e},e.id)),i&&!t&&(0,L.jsxs)(`button`,{className:Y.workLogExpandBtn,onClick:()=>n(!0),children:[(0,L.jsx)(Et,{size:12}),`Show `,e.length-pJ,` more`]}),t&&(0,L.jsxs)(`button`,{className:Y.workLogExpandBtn,onClick:()=>n(!1),children:[(0,L.jsx)(Tt,{size:12}),`Collapse`]})]})}var aFe=new Set([`Bash`,`bash`,`terminal`,`shell`]);function oFe({entry:e}){let[t,n]=(0,I.useState)(!1),r={thinking:`var(--mc-text-secondary)`,tool:`var(--mc-accent)`,info:`var(--mc-success)`,error:`var(--mc-error)`},i=aFe.has(e.toolTitle??e.label),a=!!e.result;return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:Y.workLogEntry,style:a?{cursor:`pointer`}:void 0,onClick:a?()=>n(e=>!e):void 0,children:[i?(0,L.jsx)(`span`,{className:Y.workLogTerminalIcon,style:{color:r[e.tone]},children:`>_`}):(0,L.jsx)(Ft,{size:6,style:{fill:r[e.tone],color:r[e.tone],flexShrink:0,marginTop:2}}),(0,L.jsx)(`span`,{className:Y.workLogLabel,children:e.toolTitle??e.label}),e.detail&&(0,L.jsxs)(`span`,{className:Y.workLogDetail,title:e.detail,children:[e.detail.slice(0,80),e.detail.length>80?`…`:``]}),a&&(0,L.jsx)(Et,{size:10,style:{flexShrink:0,marginLeft:`auto`,transition:`transform 0.15s`,transform:t?`rotate(90deg)`:`none`,color:`var(--mc-text-muted)`}})]}),t&&e.result&&(0,L.jsx)(`pre`,{className:Y.workLogResult,children:e.result})]})}function sFe({startedAt:e}){let[t,n]=(0,I.useState)(0),r=e?new Date(e).getTime():Date.now();return(0,I.useEffect)(()=>{let e=setInterval(()=>{n(Math.floor((Date.now()-r)/1e3))},1e3);return()=>clearInterval(e)},[r]),(0,L.jsxs)(`div`,{className:Y.workingIndicator,children:[(0,L.jsxs)(`span`,{className:Y.workingDots,children:[(0,L.jsx)(`span`,{}),(0,L.jsx)(`span`,{}),(0,L.jsx)(`span`,{})]}),(0,L.jsxs)(`span`,{className:Y.workingLabel,children:[`Working`,t>0?` for ${t}s`:`…`]})]})}function X(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function gJ(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);n.search=r.toString(),console.warn(`Minified Lexical warning #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}var _J=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,cFe=_J&&`documentMode`in document?document.documentMode:null,vJ=_J&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),yJ=_J&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),bJ=!(!_J||!(`InputEvent`in window)||cFe)&&`getTargetRanges`in new window.InputEvent(`input`),xJ=_J&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),SJ=_J&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,lFe=_J&&/Android/.test(navigator.userAgent),CJ=_J&&/^(?=.*Chrome).*/i.test(navigator.userAgent),wJ=_J&&lFe&&CJ,TJ=_J&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&vJ&&!CJ,uFe=0,dFe=1,fFe=2,pFe=1,mFe=2,hFe=3,gFe=4,_Fe=5,vFe=6,EJ=xJ||SJ||TJ?`\xA0`:`​`,DJ=`
175
+ color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n?.key)}return n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i}return o.updateDeps=e=>{r=e},o}function iJ(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var kPe=(e,t)=>Math.abs(e-t)<1.01,APe=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},aJ=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},jPe=e=>e,MPe=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let e=t;e<=n;e++)r.push(e);return r},NPe=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(aJ(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(aJ(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},oJ={passive:!0},sJ=typeof window>`u`?!0:`onscrollend`in window,PPe=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=0,a=e.options.useScrollendEvent&&sJ?()=>void 0:APe(r,()=>{t(i,!1)},e.options.isScrollingResetDelay),o=r=>()=>{let{horizontal:o,isRtl:s}=e.options;i=o?n.scrollLeft*(s&&-1||1):n.scrollTop,a(),t(i,r)},s=o(!0),c=o(!1);n.addEventListener(`scroll`,s,oJ);let l=e.options.useScrollendEvent&&sJ;return l&&n.addEventListener(`scrollend`,c,oJ),()=>{n.removeEventListener(`scroll`,s),l&&n.removeEventListener(`scrollend`,c)}},FPe=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},IPe=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;let o=e+t;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:o,behavior:n})},LPe=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([t,n])=>{n===void 0&&delete e[t]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:jPe,rangeExtractor:MPe,onChange:()=>{},measureElement:FPe,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...e}},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=rJ(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=rJ(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(e,t,n,r,i,a)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a}),{key:!1}),this.getMeasurements=rJ(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a},o)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let s=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1);let c=this.measurementsCache.slice(0,s),l=Array(a).fill(void 0);for(let e=0;e<s;e++){let t=c[e];t&&(l[t.lane]=e)}for(let i=s;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),s,u;if(a!==void 0&&this.options.lanes>1){s=a;let e=l[s],r=e===void 0?void 0:c[e];u=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?c[i-1]:this.getFurthestMeasurement(c,i);u=e?e.end+this.options.gap:t+n,s=e?e.lane:i%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(i,s)}let d=o.get(e),f=typeof d==`number`?d:this.options.estimateSize(i),p=u+f;c[i]={index:i,start:u,size:f,end:p,key:e,lane:s},l[s]=i}return this.measurementsCache=c,c},{key:!1,debug:()=>this.options.debug}),this.calculateRange=rJ(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?RPe({measurements:e,outerSize:t,scrollOffset:n,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=rJ(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{let n=this.measurementsCache[e];if(!n)return;let r=t-(this.itemSizeCache.get(n.key)??n.size);r!==0&&(this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?n.start<this.getScrollOffset()+this.scrollAdjustments:this.shouldAdjustScrollPositionOnItemSizeChange(n,r,this))&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=r,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(n.index),this.itemSizeCache=new Map(this.itemSizeCache.set(n.key,t)),this.notify(!1))},this.getVirtualItems=rJ(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length!==0)return iJ(t[cJ(0,t.length-1,e=>iJ(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t);this.scrollState={index:null,align:t,behavior:n,startedAt:this.now(),lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e;this.scrollState={index:null,align:`start`,behavior:t,startedAt:this.now(),lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1)t=e[e.length-1]?.end??0;else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&kPe(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.scrollState=null;return}}else this.scrollState.stableFrames=0,n&&(this.scrollState.lastTargetOffset=t,this.scrollState.behavior=`auto`,this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}));this.scheduleScrollReconcile()}},cJ=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function RPe({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){let i=e.length-1,a=t=>e[t].start;if(e.length<=r)return{startIndex:0,endIndex:i};let o=cJ(0,i,a,n),s=o;if(r===1)for(;s<i&&e[s].end<n+t;)s++;else if(r>1){let a=Array(r).fill(0);for(;s<i&&a.some(e=>e<n+t);){let t=e[s];a[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(i,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var lJ=typeof document<`u`?I.useLayoutEffect:I.useEffect;function zPe({useFlushSync:e=!0,...t}){let n=I.useReducer(()=>({}),{})[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,Er.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=I.useState(()=>new LPe(r));return i.setOptions(r),lJ(()=>i._didMount(),[]),lJ(()=>i._willUpdate()),i}function BPe(e){return zPe({observeElementRect:NPe,observeElementOffset:PPe,scrollToFn:IPe,...e})}var uJ=new class{map=new Map;constructor(e){this.capacity=e}get(e){let t=this.map.get(e);return t!==void 0&&(this.map.delete(e),this.map.set(e,t)),t}set(e,t){this.map.has(e)?this.map.delete(e):this.map.size>=this.capacity&&this.map.delete(this.map.keys().next().value),this.map.set(e,t)}}(500);function VPe(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=t*16777619>>>0;return t}function HPe(e,t){return`${VPe(e)}:${e.length}:${t}`}var dJ=null;async function UPe(){return dJ||=eR(()=>import(`./dist-CXaO6nOE.js`).then(e=>e.getSharedHighlighter({themes:[`github-dark`],langs:[]})),[]),dJ}async function WPe(e,t,n){let r=HPe(e,t);if(!n){let e=uJ.get(r);if(e!==void 0)return e}try{let i=(await UPe()).codeToHtml(e,{lang:t||`text`,theme:`github-light`});return n||uJ.set(r,i),i}catch{return`<pre><code>${e.replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}</code></pre>`}}var fJ=class extends I.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback:this.props.children}};function GPe({code:e,lang:t,isStreaming:n}){let[r,i]=(0,I.useState)(null),[a,o]=(0,I.useState)(!1),s=(0,I.useRef)(!1);(0,I.useEffect)(()=>(s.current=!1,WPe(e,t,n).then(e=>{s.current||i(e)}),()=>{s.current=!0}),[e,t,n]);let c=(0,I.useCallback)(()=>{navigator.clipboard.writeText(e).then(()=>{o(!0),setTimeout(()=>o(!1),2e3)})},[e]);return(0,L.jsxs)(`div`,{className:Y.codeBlock,children:[(0,L.jsx)(`button`,{className:Y.copyButton,onClick:c,title:`Copy code`,children:a?(0,L.jsx)(wt,{size:13}):(0,L.jsx)(Gt,{size:13})}),r?(0,L.jsx)(`div`,{className:Y.shikiOutput,dangerouslySetInnerHTML:{__html:r}}):(0,L.jsx)(`pre`,{className:Y.codePlain,children:(0,L.jsx)(`code`,{children:e})})]})}function KPe(e){return{pre({children:t}){let n=I.Children.toArray(t)[0];if(!I.isValidElement(n))return(0,L.jsx)(`pre`,{children:t});let r=n,i=r.props.className??``,a=/language-(\w+)/.exec(i)?.[1]??``,o=String(r.props.children??``).trimEnd();return(0,L.jsx)(fJ,{fallback:(0,L.jsx)(`pre`,{className:Y.codePlain,children:(0,L.jsx)(`code`,{children:o})}),children:(0,L.jsx)(GPe,{code:o,lang:a,isStreaming:e})})},a({href:e,children:t}){return(0,L.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:Y.mdLink,children:t})}}}var qPe=(0,I.memo)(function({text:e,isStreaming:t=!1}){let n=KPe(t);return(0,L.jsx)(fJ,{fallback:(0,L.jsx)(`pre`,{className:Y.mdFallback,children:e}),children:(0,L.jsx)(`div`,{className:Y.chatMarkdown,children:(0,L.jsx)(JP,{remarkPlugins:[VL],components:n,children:e})})})});function JPe(e,t){return[...e.map(e=>({id:e.id,kind:`message`,createdAt:e.createdAt,message:e})),...t.map(e=>({id:e.id,kind:`work`,createdAt:e.createdAt,entry:e}))].sort((e,t)=>e.createdAt.localeCompare(t.createdAt))}function YPe(e,t){let n=[],r=0;for(;r<e.length;){let t=e[r];if(t.kind===`work`){let i=[t.entry],a=r+1;for(;a<e.length&&e[a].kind===`work`;)i.push(e[a].entry),a++;n.push({kind:`work`,id:t.id,createdAt:t.createdAt,groupedEntries:i}),r=a}else n.push({kind:`message`,id:t.id,createdAt:t.createdAt,message:t.message}),r++}if(t){let t=e[e.length-1];n.push({kind:`working`,id:`working-indicator`,createdAt:t?.createdAt??null})}return n}var XPe=6;function ZPe(e,t=800){if(e.kind===`working`)return 40;if(e.kind===`work`)return 28+Math.min(e.groupedEntries.length,XPe)*32;let{message:n}=e;if(n.role===`user`){let e=Math.max(4,Math.floor((t*.8-32)/8.4));return 96+Math.max(1,Math.ceil(n.text.length/e))*22}let r=Math.max(20,Math.floor((t-8)/7.2));return 41+Math.max(1,Math.ceil(n.text.length/r))*22.75}var pJ=6,QPe=8,$Pe=64;function mJ(e){try{return new Date(e).toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}catch{return``}}function eFe(e,t){let n=new Date(t).getTime()-new Date(e).getTime();if(n<1e3)return`${n}ms`;let r=n/1e3;if(r<60)return`${r.toFixed(1)}s`;let i=Math.floor(r/60),a=Math.round(r%60);return a>0?`${i}m ${a}s`:`${i}m`}var tFe=(0,I.memo)(function({messages:e,workLog:t,streaming:n}){let r=(0,I.useRef)(null),i=(0,I.useRef)(null),[a,o]=(0,I.useState)(800),s=(0,I.useRef)(!0),[c,l]=(0,I.useState)(!1),u=YPe(JPe(e,t),n),d=Math.max(0,u.length-QPe),f=u.slice(0,d),p=u.slice(d),m=`width:${Math.round(a)}`,h=BPe({count:f.length,getScrollElement:()=>r.current,getItemKey:e=>`${m}:${f[e].id}`,estimateSize:e=>ZPe(f[e],a),measureElement:e=>e.getBoundingClientRect().height,useAnimationFrameWithResizeObserver:!0,overscan:8});(0,I.useLayoutEffect)(()=>{let e=r.current;if(!e)return;let t=new ResizeObserver(()=>o(e.clientWidth));return t.observe(e),()=>t.disconnect()},[]),(0,I.useLayoutEffect)(()=>{let e=i.current;if(!e)return;let t=new ResizeObserver(()=>{s.current&&r.current&&(r.current.scrollTop=r.current.scrollHeight)});return t.observe(e),()=>t.disconnect()},[]),(0,I.useEffect)(()=>{let e=r.current;!e||!s.current||(e.scrollTop=e.scrollHeight)},[u.length,n]);let g=(0,I.useCallback)(()=>{let e=r.current;e&&(e.scrollTop=e.scrollHeight,s.current=!0,l(!1))},[]),_=(0,I.useCallback)(()=>{let e=r.current;if(!e)return;let t=e.scrollHeight-e.clientHeight-e.scrollTop<=$Pe;s.current=t,l(!t)},[]),v=h.getVirtualItems();return(0,L.jsxs)(`div`,{style:{position:`relative`,flex:1,overflow:`hidden`,display:`flex`,flexDirection:`column`},children:[(0,L.jsx)(`div`,{ref:r,className:Y.messagesTimeline,onScroll:_,style:{flex:1},children:(0,L.jsxs)(`div`,{ref:i,className:Y.messagesTimelineInner,children:[f.length>0&&(0,L.jsx)(`div`,{style:{height:h.getTotalSize(),position:`relative`},children:v.map(e=>{let t=f[e.index];return(0,L.jsx)(`div`,{"data-index":e.index,ref:e=>{e&&h.measureElement(e)},style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${e.start}px)`},children:(0,L.jsx)(hJ,{row:t,isStreaming:n})},e.key)})}),p.map(e=>(0,L.jsx)(hJ,{row:e,isStreaming:n},e.id))]})}),c&&(0,L.jsxs)(`button`,{onClick:g,style:{position:`absolute`,bottom:12,right:16,zIndex:10,display:`flex`,alignItems:`center`,gap:4,padding:`6px 12px`,background:`var(--color-primary)`,color:`var(--color-primary-foreground)`,border:`none`,borderRadius:20,fontSize:12,fontWeight:700,cursor:`pointer`,boxShadow:`0 2px 8px rgba(0,0,0,0.25)`,opacity:.95},title:`Scroll to bottom`,children:[(0,L.jsx)(Tt,{size:14}),`Bottom`]})]})}),hJ=(0,I.memo)(function({row:e,isStreaming:t}){return e.kind===`working`?(0,L.jsx)(sFe,{startedAt:e.createdAt}):e.kind===`work`?(0,L.jsx)(iFe,{entries:e.groupedEntries}):e.message.role===`user`?(0,L.jsx)(nFe,{message:e.message}):(0,L.jsx)(rFe,{message:e.message,isStreaming:t})});function nFe({message:e}){return(0,L.jsx)(`div`,{className:Y.userMessageRow,children:(0,L.jsxs)(`div`,{className:Y.userMessageBubble,children:[(0,L.jsx)(`p`,{className:Y.userMessageText,children:e.text}),(0,L.jsx)(`span`,{className:Y.messageTimestamp,children:mJ(e.createdAt)})]})})}function rFe({message:e,isStreaming:t}){let n=e.completedAt?eFe(e.createdAt,e.completedAt):null;return(0,L.jsxs)(`div`,{className:Y.assistantMessageRow,children:[(0,L.jsx)(qPe,{text:e.text,isStreaming:t&&!e.completedAt}),(0,L.jsxs)(`div`,{className:Y.messageMetadata,children:[(0,L.jsx)(`span`,{className:Y.messageTimestamp,children:mJ(e.createdAt)}),n&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:Y.messageSeparator,children:`·`}),(0,L.jsx)(`span`,{className:Y.messageTimestamp,children:n})]})]})]})}function iFe({entries:e}){let[t,n]=(0,I.useState)(!1),r=t?e:e.slice(0,pJ),i=e.length>pJ;return(0,L.jsxs)(`div`,{className:Y.workLogGroup,children:[r.map(e=>(0,L.jsx)(oFe,{entry:e},e.id)),i&&!t&&(0,L.jsxs)(`button`,{className:Y.workLogExpandBtn,onClick:()=>n(!0),children:[(0,L.jsx)(Et,{size:12}),`Show `,e.length-pJ,` more`]}),t&&(0,L.jsxs)(`button`,{className:Y.workLogExpandBtn,onClick:()=>n(!1),children:[(0,L.jsx)(Tt,{size:12}),`Collapse`]})]})}var aFe=new Set([`Bash`,`bash`,`terminal`,`shell`]);function oFe({entry:e}){let[t,n]=(0,I.useState)(!1),r={thinking:`var(--mc-text-secondary)`,tool:`var(--mc-accent)`,info:`var(--mc-success)`,error:`var(--mc-error)`},i=aFe.has(e.toolTitle??e.label),a=!!e.result;return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:Y.workLogEntry,style:a?{cursor:`pointer`}:void 0,onClick:a?()=>n(e=>!e):void 0,children:[i?(0,L.jsx)(`span`,{className:Y.workLogTerminalIcon,style:{color:r[e.tone]},children:`>_`}):(0,L.jsx)(Ft,{size:6,style:{fill:r[e.tone],color:r[e.tone],flexShrink:0,marginTop:2}}),(0,L.jsx)(`span`,{className:Y.workLogLabel,children:e.toolTitle??e.label}),e.detail&&(0,L.jsxs)(`span`,{className:Y.workLogDetail,title:e.detail,children:[e.detail.slice(0,80),e.detail.length>80?`…`:``]}),a&&(0,L.jsx)(Et,{size:10,style:{flexShrink:0,marginLeft:`auto`,transition:`transform 0.15s`,transform:t?`rotate(90deg)`:`none`,color:`var(--mc-text-muted)`}})]}),t&&e.result&&(0,L.jsx)(`pre`,{className:Y.workLogResult,children:e.result})]})}function sFe({startedAt:e}){let[t,n]=(0,I.useState)(0),r=e?new Date(e).getTime():Date.now();return(0,I.useEffect)(()=>{let e=setInterval(()=>{n(Math.floor((Date.now()-r)/1e3))},1e3);return()=>clearInterval(e)},[r]),(0,L.jsxs)(`div`,{className:Y.workingIndicator,children:[(0,L.jsxs)(`span`,{className:Y.workingDots,children:[(0,L.jsx)(`span`,{}),(0,L.jsx)(`span`,{}),(0,L.jsx)(`span`,{})]}),(0,L.jsxs)(`span`,{className:Y.workingLabel,children:[`Working`,t>0?` for ${t}s`:`…`]})]})}function X(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function gJ(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);n.search=r.toString(),console.warn(`Minified Lexical warning #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}var _J=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,cFe=_J&&`documentMode`in document?document.documentMode:null,vJ=_J&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),yJ=_J&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),bJ=!(!_J||!(`InputEvent`in window)||cFe)&&`getTargetRanges`in new window.InputEvent(`input`),xJ=_J&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),SJ=_J&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,lFe=_J&&/Android/.test(navigator.userAgent),CJ=_J&&/^(?=.*Chrome).*/i.test(navigator.userAgent),wJ=_J&&lFe&&CJ,TJ=_J&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&vJ&&!CJ,uFe=0,dFe=1,fFe=2,pFe=1,mFe=2,hFe=3,gFe=4,_Fe=5,vFe=6,EJ=xJ||SJ||TJ?`\xA0`:`​`,DJ=`
176
176
 
177
177
  `,OJ=yJ?`\xA0`:EJ,kJ={bold:1,capitalize:1024,code:16,highlight:128,italic:2,lowercase:256,strikethrough:4,subscript:32,superscript:64,underline:8,uppercase:512},yFe={directionless:1,unmergeable:2},AJ={center:2,end:6,justify:4,left:1,right:3,start:5},bFe={[mFe]:`center`,[vFe]:`end`,[gFe]:`justify`,[pFe]:`left`,[hFe]:`right`,[_Fe]:`start`},xFe={normal:0,segmented:2,token:1},SFe={[uFe]:`normal`,[fFe]:`segmented`,[dFe]:`token`},jJ=`$config`;function MJ(e,t,n,r,i,a){let o=e.getFirstChild();for(;o!==null;){let e=o.__key;o.__parent===t&&(Q(o)&&MJ(o,e,n,r,i,a),n.has(e)||a.delete(e),i.push(e)),o=o.getNextSibling()}}var NJ=!1,PJ=0;function CFe(e){PJ=e.timeStamp}function FJ(e,t,n){let r=e.nodeName===`BR`,i=t.__lexicalLineBreak;return i&&(e===i||r&&e.previousSibling===i)||r&&PQ(e,n)!==void 0}function wFe(e,t,n){let r=_$(d$(n)),i=null,a=null;r!==null&&r.anchorNode===e&&(i=r.anchorOffset,a=r.focusOffset);let o=e.nodeValue;o!==null&&qQ(t,o,i,a,!1)}function TFe(e,t,n){if(Z(e)){let t=e.anchor.getNode();if(t.is(n)&&e.format!==t.getFormat())return!1}return TQ(t)&&n.isAttached()}function EFe(e,t,n,r){for(let i=e;i&&!RIe(i);i=o$(i)){let e=PQ(i,t);if(e!==void 0){let t=MQ(e,n);if(t)return eQ(t)||!v$(i)?void 0:[i,t]}else if(i===r)return[r,zQ(n)]}}function IJ(e,t,n){NJ=!0;let r=performance.now()-PJ>100;try{YZ(e,()=>{let i=vZ()||function(e){return e.getEditorState().read(()=>{let e=vZ();return e===null?null:e.clone()})}(e),a=new Map,o=e.getRootElement(),s=e._editorState,c=e._blockCursorElement,l=!1,u=``;for(let n=0;n<t.length;n++){let d=t[n],f=d.type,p=d.target,m=EFe(p,e,s,o);if(!m)continue;let[h,g]=m;if(f===`characterData`)r&&XX(g)&&TQ(p)&&TFe(i,p,g)&&wFe(p,g,e);else if(f===`childList`){l=!0;let t=d.addedNodes;for(let n=0;n<t.length;n++){let r=t[n],i=NQ(r),a=r.parentNode;if(a!=null&&r!==c&&i===null&&!FJ(r,a,e)){if(yJ){let e=(v$(r)?r.innerText:null)||r.nodeValue;e&&(u+=e)}a.removeChild(r)}}let n=d.removedNodes,r=n.length;if(r>0){let t=0;for(let i=0;i<r;i++){let r=n[i];(FJ(r,p,e)||c===r)&&(p.appendChild(r),t++)}r!==t&&a.set(h,g)}}}if(a.size>0)for(let[t,n]of a)n.reconcileObservedMutation(t,e);let d=n.takeRecords();if(d.length>0){for(let t=0;t<d.length;t++){let n=d[t],r=n.addedNodes,i=n.target;for(let t=0;t<r.length;t++){let n=r[t],a=n.parentNode;a==null||n.nodeName!==`BR`||FJ(n,i,e)||a.removeChild(n)}}n.takeRecords()}i!==null&&(l&&BQ(i),yJ&&i$(e)&&i.insertRawText(u))})}finally{NJ=!1}}function LJ(e){let t=e._observer;t!==null&&IJ(e,t.takeRecords(),t)}function RJ(e){(function(e){PJ===0&&d$(e).addEventListener(`textInput`,CFe,!0)})(e),e._observer=new MutationObserver((t,n)=>{IJ(e,t,n)})}var DFe=class{key;parse;unparse;isEqual;defaultValue;constructor(e,t){this.key=e,this.parse=t.parse.bind(t),this.unparse=(t.unparse||MFe).bind(t),this.isEqual=(t.isEqual||Object.is).bind(t),this.defaultValue=this.parse(void 0)}};function OFe(e,t){return new DFe(e,t)}function kFe(e){let t=new Map,n=new Set;for(let r=typeof e==`function`?e:e.replace;r.prototype&&r.prototype.getType!==void 0;r=Object.getPrototypeOf(r)){let{ownNodeConfig:e}=O$(r);if(e&&e.stateConfigs)for(let r of e.stateConfigs){let e;`stateConfig`in r?(e=r.stateConfig,r.flat&&n.add(e.key)):e=r,t.set(e.key,e)}}return{flatKeys:n,sharedConfigMap:t}}var AFe=class e{node;knownState;unknownState;sharedNodeState;size;constructor(e,t,n=void 0,r=new Map,i=void 0){this.node=e,this.sharedNodeState=t,this.unknownState=n,this.knownState=r;let{sharedConfigMap:a}=this.sharedNodeState;this.size=i===void 0?function(e,t,n){let r=n.size;if(t)for(let i in t){let t=e.get(i);t&&n.has(t)||r++}return r}(a,n,r):i}getValue(e){let t=this.knownState.get(e);if(t!==void 0)return t;this.sharedNodeState.sharedConfigMap.set(e.key,e);let n=e.defaultValue;if(this.unknownState&&e.key in this.unknownState){let t=this.unknownState[e.key];t!==void 0&&(n=e.parse(t)),this.updateFromKnown(e,n)}return n}getInternalState(){return[this.unknownState,this.knownState]}toJSON(){let e={...this.unknownState},t={};for(let[t,n]of this.knownState)t.isEqual(n,t.defaultValue)?delete e[t.key]:e[t.key]=t.unparse(n);for(let n of this.sharedNodeState.flatKeys)n in e&&(t[n]=e[n],delete e[n]);return BJ(e)&&(t.$=e),t}getWritable(t){if(this.node===t)return this;let{sharedNodeState:n,unknownState:r}=this,i=new Map(this.knownState);return new e(t,n,function(e,t,n){let r;if(n)for(let[i,a]of Object.entries(n)){let n=e.get(i);n?t.has(n)||t.set(n,n.parse(a)):(r||={},r[i]=a)}return r}(n.sharedConfigMap,i,r),i,this.size)}updateFromKnown(e,t){let n=e.key;this.sharedNodeState.sharedConfigMap.set(n,e);let{knownState:r,unknownState:i}=this;r.has(e)||i&&n in i||(i&&(delete i[n],this.unknownState=BJ(i)),this.size++),r.set(e,t)}updateFromUnknown(e,t){let n=this.sharedNodeState.sharedConfigMap.get(e);n?this.updateFromKnown(n,n.parse(t)):(this.unknownState=this.unknownState||{},e in this.unknownState||this.size++,this.unknownState[e]=t)}updateFromJSON(e){let{knownState:t}=this;for(let e of t.keys())t.set(e,e.defaultValue);if(this.size=t.size,this.unknownState=void 0,e)for(let[t,n]of Object.entries(e))this.updateFromUnknown(t,n)}};function jFe(e){let t=e.getWritable(),n=t.__state?t.__state.getWritable(t):new AFe(t,zJ(t));return t.__state=n,n}function zJ(e){return e.__state?e.__state.sharedNodeState:hQ(C$(),e.getType()).sharedNodeState}function BJ(e){if(e)for(let t in e)return e}function MFe(e){return e}function VJ(e,t,n){for(let[r,i]of t.knownState){if(e.has(r.key))continue;e.add(r.key);let t=n?n.getValue(r):r.defaultValue;if(t!==i&&!r.isEqual(t,i))return!0}return!1}function HJ(e,t,n){let{unknownState:r}=t,i=n?n.unknownState:void 0;if(r){for(let[t,n]of Object.entries(r))if(!e.has(t)&&(e.add(t),n!==(i?i[t]:void 0)))return!0}return!1}function UJ(e,t){let n=e.__state;return n&&n.node===e?n.getWritable(t):n}function WJ(e,t){let n=e.__mode,r=e.__format,i=e.__style,a=t.__mode,o=t.__format,s=t.__style,c=e.__state,l=t.__state;return(n===null||n===a)&&(r===null||r===o)&&(i===null||i===s)&&(e.__state===null||c===l||function(e,t){if(e===t)return!0;if(e&&t&&e.size!==t.size)return!1;let n=new Set;return!(e&&VJ(n,e,t)||t&&VJ(n,t,e)||e&&HJ(n,e,t)||t&&HJ(n,t,e))}(c,l))}function GJ(e,t){let n=e.mergeWithSibling(t),r=RZ()._normalizedNodes;return r.add(e.__key),r.add(t.__key),n}function KJ(e){let t,n,r=e;if(r.__text!==``||!r.isSimpleText()||r.isUnmergeable()){for(;(t=r.getPreviousSibling())!==null&&XX(t)&&t.isSimpleText()&&!t.isUnmergeable();){if(t.__text!==``){if(WJ(t,r)){r=GJ(t,r);break}break}t.remove()}for(;(n=r.getNextSibling())!==null&&XX(n)&&n.isSimpleText()&&!n.isUnmergeable();){if(n.__text!==``){if(WJ(r,n)){r=GJ(r,n);break}break}n.remove()}}else r.remove()}function qJ(e){return JJ(e.anchor),JJ(e.focus),e}function JJ(e){for(;e.type===`element`;){let t=e.getNode(),n=e.offset,r,i;if(n===t.getChildrenSize()?(r=t.getChildAtIndex(n-1),i=!0):(r=t.getChildAtIndex(n),i=!1),XX(r)){e.set(r.__key,i?r.getTextContentSize():0,`text`,!0);break}if(!Q(r))break;e.set(r.__key,i?r.getChildrenSize():0,`element`,!0)}}var YJ,XJ,ZJ,QJ,$J,eY,tY,nY,rY,iY,aY=``,oY=null,sY=null,cY=!1,lY=!1;function uY(e,t){let n=tY.get(e);if(t!==null){let n=TY(e);n.parentNode===t&&t.removeChild(n)}if(nY.has(e)||XJ._keyToDOMMap.delete(e),Q(n)){let e=bY(n,tY);dY(e,0,e.length-1,null)}n!==void 0&&n$(iY,ZJ,QJ,n,`destroyed`)}function dY(e,t,n,r){for(let i=t;i<=n;++i){let t=e[i];t!==void 0&&uY(t,r)}}function fY(e,t){e.setProperty(`text-align`,t)}var NFe=`40px`;function pY(e,t){let n=YJ.theme.indent;if(typeof n==`string`){let r=e.classList.contains(n);t>0&&!r?e.classList.add(n):t<1&&r&&e.classList.remove(n)}if(t===0)return void e.style.setProperty(`padding-inline-start`,``);let r=getComputedStyle(XJ._rootElement||e).getPropertyValue(`--lexical-indent-base-value`)||NFe;e.style.setProperty(`padding-inline-start`,`calc(${t} * ${r})`)}function mY(e,t){let n=e.style;t===0?fY(n,``):t===1?fY(n,`left`):t===2?fY(n,`center`):t===3?fY(n,`right`):t===4?fY(n,`justify`):t===5?fY(n,`start`):t===6&&fY(n,`end`)}function hY(e,t){let n=function(e){let t=e.__dir;if(t!==null)return t;if(nQ(e))return null;let n=e.getParentOrThrow();return nQ(n)&&n.__dir===null?`auto`:null}(t);n===null?e.removeAttribute(`dir`):e.dir=n}function gY(e,t){let n=nY.get(e);n===void 0&&X(60);let r=n.createDOM(YJ,XJ);if(function(e,t,n){let r=n._keyToDOMMap;(function(e,t,n){let r=`__lexicalKey_${t._key}`;e[r]=n})(t,n,e),r.set(e,t)}(e,r,XJ),XX(n)?r.setAttribute(`data-lexical-text`,`true`):eQ(n)&&r.setAttribute(`data-lexical-decorator`,`true`),Q(n)){let e=n.__indent,t=n.__size;if(hY(r,n),e!==0&&pY(r,e),t!==0){let e=t-1;_Y(bY(n,nY),n,0,e,n.getDOMSlot(r))}let i=n.__format;i!==0&&mY(r,i),n.isInline()||yY(null,n,r)}else{let t=n.getTextContent();if(eQ(n)){let t=n.decorate(XJ,YJ);t!==null&&SY(e,t),r.contentEditable=`false`}aY+=t}return t!==null&&t.insertChild(r),n$(iY,ZJ,QJ,n,`created`),r}function _Y(e,t,n,r,i){let a=aY;aY=``;let o=n;for(;o<=r;++o){gY(e[o],i);let t=nY.get(e[o]);t!==null&&XX(t)?oY===null&&(oY=t.getFormat(),sY=t.getStyle()):Q(t)&&o<r&&!t.isInline()&&(aY+=DJ)}i.element.__lexicalTextContent=aY,aY=a+aY}function vY(e,t){if(e){let n=e.__last;if(n){let e=t.get(n);if(e)return LX(e)?`line-break`:eQ(e)&&e.isInline()?`decorator`:null}return`empty`}return null}function yY(e,t,n){let r=vY(e,tY),i=vY(t,nY);r!==i&&t.getDOMSlot(n).setManagedLineBreak(i)}function PFe(e,t,n){var r;oY=null,sY=null,function(e,t,n){let r=aY,i=e.__size,a=t.__size;aY=``;let o=n.element;if(i===1&&a===1){let n=e.__first,r=t.__first;if(n===r)xY(n,o);else{let e=TY(n),t=gY(r,null);try{o.replaceChild(t,e)}catch(i){if(typeof i==`object`&&i){let a=`${i.toString()} Parent: ${o.tagName}, new child: {tag: ${t.tagName} key: ${r}}, old child: {tag: ${e.tagName}, key: ${n}}.`;throw Error(a)}throw i}uY(n,null)}let i=nY.get(r);XX(i)&&oY===null&&(oY=i.getFormat(),sY=i.getStyle())}else{let r=bY(e,tY),s=bY(t,nY);if(r.length!==i&&X(227),s.length!==a&&X(228),i===0)a!==0&&_Y(s,0,0,a-1,n);else if(a===0){if(i!==0){let e=n.after==null&&n.before==null&&n.element.__lexicalLineBreak==null;dY(r,0,i-1,e?null:o),e&&(o.textContent=``)}}else (function(e,t,n,r,i,a){let o=r-1,s=i-1,c,l,u=a.getFirstChild(),d=0,f=0;for(;d<=o&&f<=s;){let e=t[d],r=n[f];if(e===r)u=CY(xY(r,a.element)),d++,f++;else{if(l===void 0&&(l=wY(n,f)),c===void 0)c=wY(t,d);else if(!c.has(e)){d++;continue}if(!l.has(e)){u=CY(TY(e)),uY(e,a.element),d++,c.delete(e);continue}if(c.has(r)){let e=a$(XJ,r);e!==u&&a.withBefore(u).insertChild(e),u=CY(xY(r,a.element)),d++,f++}else gY(r,a.withBefore(u)),f++}let i=nY.get(r);i!==null&&XX(i)?oY===null&&(oY=i.getFormat(),sY=i.getStyle()):Q(i)&&f<=s&&!i.isInline()&&(aY+=DJ)}let p=d>o,m=f>s;if(p&&!m){let e=n[s+1],t=e===void 0?null:XJ.getElementByKey(e);_Y(n,0,f,s,a.withBefore(t))}else m&&!p&&dY(t,d,o,a.element)})(0,r,s,i,a,n)}o.__lexicalTextContent=aY,aY=r+aY}(e,t,t.getDOMSlot(n)),r=t,oY==null||oY===r.__textFormat||lY||r.setTextFormat(oY),function(e){sY==null||sY===e.__textStyle||lY||e.setTextStyle(sY)}(t)}function bY(e,t){let n=[],r=e.__first;for(;r!==null;){let e=t.get(r);e===void 0&&X(101),n.push(r),r=e.__next}return n}function xY(e,t){let n=tY.get(e),r=nY.get(e);n!==void 0&&r!==void 0||X(61);let i=cY||eY.has(e)||$J.has(e),a=a$(XJ,e);if(n===r&&!i){let e;if(Q(n)){let t=a.__lexicalTextContent;typeof t==`string`?e=t:(e=n.getTextContent(),a.__lexicalTextContent=e)}else e=n.getTextContent();return aY+=e,a}if(n!==r&&i&&n$(iY,ZJ,QJ,r,`updated`),r.updateDOM(n,a,YJ)){let n=gY(e,null);return t===null&&X(62),t.replaceChild(n,a),uY(e,null),n}if(Q(n)){Q(r)||X(334,e);let t=r.__indent;(cY||t!==n.__indent)&&pY(a,t);let o=r.__format;if((cY||o!==n.__format)&&mY(a,o),i)PFe(n,r,a),nQ(r)||r.isInline()||yY(n,r,a);else{let e=a.__lexicalTextContent,t;typeof e==`string`?t=e:(t=n.getTextContent(),a.__lexicalTextContent=t),aY+=t}if((cY||r.__dir!==n.__dir)&&(hY(a,r),nQ(r)&&!cY))for(let e of r.getChildren())Q(e)&&hY(a$(XJ,e.getKey()),e)}else{let t=r.getTextContent();if(eQ(r)){let t=r.decorate(XJ,YJ);t!==null&&SY(e,t)}aY+=t}if(!lY&&nQ(r)&&r.__cachedText!==aY){let e=r.getWritable();e.__cachedText=aY,r=e}return a}function SY(e,t){let n=XJ._pendingDecorators,r=XJ._decorators;if(n===null){if(r[e]===t)return;n=IQ(XJ)}n[e]=t}function CY(e){let t=e.nextSibling;return t!==null&&t===XJ._blockCursorElement&&(t=t.nextSibling),t}function wY(e,t){let n=new Set;for(let r=t;r<e.length;r++)n.add(e[r]);return n}function FFe(e,t,n,r,i,a){aY=``,cY=r===2,XJ=n,YJ=n._config,ZJ=n._nodes,QJ=XJ._listeners.mutation,$J=i,eY=a,tY=e._nodeMap,nY=t._nodeMap,lY=t._readOnly,rY=new Map(n._keyToDOMMap);let o=new Map;return iY=o,xY(`root`,null),XJ=void 0,ZJ=void 0,$J=void 0,eY=void 0,tY=void 0,nY=void 0,YJ=void 0,rY=void 0,iY=void 0,o}function TY(e){let t=rY.get(e);return t===void 0&&X(75,e),t}function EY(e){return{type:e}}var DY=EY(`SELECTION_CHANGE_COMMAND`),IFe=EY(`CLICK_COMMAND`),OY=EY(`BEFORE_INPUT_COMMAND`),kY=EY(`INPUT_COMMAND`),AY=EY(`COMPOSITION_START_COMMAND`),jY=EY(`COMPOSITION_END_COMMAND`),MY=EY(`DELETE_CHARACTER_COMMAND`),NY=EY(`INSERT_LINE_BREAK_COMMAND`),PY=EY(`INSERT_PARAGRAPH_COMMAND`),FY=EY(`CONTROLLED_TEXT_INSERTION_COMMAND`),IY=EY(`PASTE_COMMAND`),LY=EY(`REMOVE_TEXT_COMMAND`),RY=EY(`DELETE_WORD_COMMAND`),zY=EY(`DELETE_LINE_COMMAND`),BY=EY(`FORMAT_TEXT_COMMAND`),VY=EY(`UNDO_COMMAND`),HY=EY(`REDO_COMMAND`),UY=EY(`KEYDOWN_COMMAND`),WY=EY(`KEY_ARROW_RIGHT_COMMAND`),LFe=EY(`MOVE_TO_END`),GY=EY(`KEY_ARROW_LEFT_COMMAND`),RFe=EY(`MOVE_TO_START`),zFe=EY(`KEY_ARROW_UP_COMMAND`),BFe=EY(`KEY_ARROW_DOWN_COMMAND`),KY=EY(`KEY_ENTER_COMMAND`),VFe=EY(`KEY_SPACE_COMMAND`),qY=EY(`KEY_BACKSPACE_COMMAND`),HFe=EY(`KEY_ESCAPE_COMMAND`),JY=EY(`KEY_DELETE_COMMAND`),UFe=EY(`KEY_TAB_COMMAND`),YY=EY(`DROP_COMMAND`),XY=EY(`DRAGSTART_COMMAND`),WFe=EY(`DRAGOVER_COMMAND`),GFe=EY(`DRAGEND_COMMAND`),ZY=EY(`COPY_COMMAND`),QY=EY(`CUT_COMMAND`),$Y=EY(`SELECT_ALL_COMMAND`),KFe=EY(`CLEAR_EDITOR_COMMAND`),qFe=EY(`CLEAR_HISTORY_COMMAND`),eX=EY(`CAN_REDO_COMMAND`),tX=EY(`CAN_UNDO_COMMAND`),JFe=EY(`FOCUS_COMMAND`),YFe=EY(`BLUR_COMMAND`),XFe=EY(`KEY_MODIFIER_COMMAND`),nX=Object.freeze({}),rX=[[`keydown`,function(e,t){iX=e.timeStamp,aX=e.key,!t.isComposing()&&$(t,UY,e)}],[`pointerdown`,function(e,t){let n=e.target,r=e.pointerType;y$(n)&&r!==`touch`&&r!==`pen`&&e.button===0&&YZ(t,()=>{_Q(n)||(dX=!0)})}],[`compositionstart`,function(e,t){$(t,AY,e)}],[`compositionend`,function(e,t){yJ?pX=!0:SJ||!xJ&&!TJ?$(t,jY,e):(mX=!0,hX=e.data)}],[`input`,function(e,t){e.stopPropagation(),YZ(t,()=>{t.dispatchCommand(kY,e)},{event:e}),sX=null}],[`click`,function(e,t){YZ(t,()=>{let n=vZ(),r=_$(d$(t)),i=yZ();if(r){if(Z(n)){let t=n.anchor,a=t.getNode();if(t.type===`element`&&t.offset===0&&n.isCollapsed()&&!nQ(a)&&RQ().getChildrenSize()===1&&a.getTopLevelElementOrThrow().isEmpty()&&i!==null&&n.is(i))r.removeAllRanges(),n.dirty=!0;else if(e.detail===3&&!n.isCollapsed()&&a!==n.focus.getNode()){let e=k$(a,e=>Q(e)&&!e.isInline());Q(e)&&e.select(0)}}else if(e.pointerType===`touch`||e.pointerType===`pen`){let n=r.anchorNode;(v$(n)||TQ(n))&&BQ(_Z(i,r,t,e))}}$(t,IFe,e)})}],[`cut`,nX],[`copy`,nX],[`dragstart`,nX],[`dragover`,nX],[`dragend`,nX],[`paste`,nX],[`focus`,nX],[`blur`,nX],[`drop`,nX]];bJ&&rX.push([`beforeinput`,(e,t)=>function(e,t){let n=e.inputType;n===`deleteCompositionText`||yJ&&i$(t)||n!==`insertCompositionText`&&$(t,OY,e)}(e,t)]);var iX=0,aX=null,oX=0,sX=null,cX=new WeakMap,lX=new WeakMap,uX=!1,dX=!1,fX=!1,pX=!1,mX=!1,hX=``,gX=null,_X=[0,``,0,`root`,0];function vX(e,t,n,r,i){let a=e.anchor,o=e.focus,s=a.getNode(),c=RZ(),l=_$(d$(c)),u=l===null?null:l.anchorNode,d=a.key,f=c.getElementByKey(d),p=n.length;return d!==o.key||!XX(s)||(!i&&(!bJ||oX<r+50)||s.isDirty()&&p<2||HQ(n))&&a.offset!==o.offset&&!s.isComposing()||wQ(s)||s.isDirty()&&p>1||(i||!bJ)&&f!==null&&!s.isComposing()&&u!==EQ(f)||l!==null&&t!==null&&(!t.collapsed||t.startContainer!==l.anchorNode||t.startOffset!==l.anchorOffset)||!s.isComposing()&&(s.getFormat()!==e.format||s.getStyle()!==e.style)||function(e,t){if(t.isSegmented())return!0;if(!e.isCollapsed())return!1;let n=e.anchor.offset,r=t.getParentOrThrow(),i=CQ(t);return n===0?!t.canInsertTextBefore()||!r.canInsertTextBefore()&&!t.isComposing()||i||function(e){let t=e.getPreviousSibling();return(XX(t)||Q(t)&&t.isInline())&&!t.canInsertTextAfter()}(t):n===t.getTextContentSize()&&(!t.canInsertTextAfter()||!r.canInsertTextAfter()&&!t.isComposing()||i)}(e,s)}function yX(e,t){return TQ(e)&&e.nodeValue!==null&&t!==0&&t!==e.nodeValue.length}function bX(e,t,n){let{anchorNode:r,anchorOffset:i,focusNode:a,focusOffset:o}=e;uX&&(uX=!1,yX(r,i)&&yX(a,o)&&!gX)||YZ(t,()=>{if(!n)return void BQ(null);if(!yQ(t,r,a))return;let s=vZ();if(gX&&Z(s)&&s.isCollapsed()){let e=s.anchor,t=gX.anchor;(e.key===t.key&&e.offset===t.offset+1||e.offset===1&&t.getNode().is(e.getNode().getPreviousSibling()))&&(s=gX.clone(),BQ(s))}if(gX=null,Z(s)){let n=s.anchor,r=n.getNode();if(s.isCollapsed()){e.type===`Range`&&e.anchorNode===e.focusNode&&(s.dirty=!0);let i=d$(t).event,a=i?i.timeStamp:performance.now(),[o,c,l,u,d]=_X,f=RQ(),p=!1===t.isComposing()&&f.getTextContent()===``;if(a<d+200&&n.offset===l&&n.key===u)xX(s,o,c);else if(n.type===`text`)XX(r)||X(141),SX(s,r);else if(n.type===`element`&&!p){Q(r)||X(259);let e=n.getNode();e.isEmpty()?function(e,t){xX(e,t.getTextFormat(),t.getTextStyle())}(s,e):xX(s,0,``)}}else{let e=n.key,t=s.focus.key,r=s.getNodes(),a=r.length,c=s.isBackward(),l=c?o:i,u=c?i:o,d=c?t:e,f=c?e:t,p=2047,m=!1;for(let e=0;e<a;e++){let t=r[e],n=t.getTextContentSize();if(XX(t)&&n!==0&&!(e===0&&t.__key===d&&l===n||e===a-1&&t.__key===f&&u===0)&&(m=!0,p&=t.getFormat(),p===0))break}s.format=m?p:0}}$(t,DY,void 0)})}function xX(e,t,n){e.format===t&&e.style===n||(e.format=t,e.style=n,e.dirty=!0)}function SX(e,t){xX(e,t.getFormat(),t.getStyle())}function CX(e){if(!e.getTargetRanges)return null;let t=e.getTargetRanges();return t.length===0?null:t[0]}function ZFe(e){let t=e.inputType,n=CX(e),r=RZ(),i=vZ();if(t===`deleteContentBackward`){if(i===null){let e=yZ();if(!Z(e))return!0;BQ(e.clone())}if(Z(i)){let t=i.anchor.key===i.focus.key;if(a=e.timeStamp,aX===`MediaLast`&&a<iX+30&&r.isComposing()&&t){if(AQ(null),iX=0,setTimeout(()=>{YZ(r,()=>{AQ(null)})},30),Z(i)){let e=i.anchor.getNode();e.markDirty(),XX(e)||X(142),SX(i,e)}}else{AQ(null),e.preventDefault();let n=i.anchor.getNode(),a=n.getTextContent(),o=n.canInsertTextAfter(),s=i.anchor.offset===0&&i.focus.offset===a.length,c=wJ&&t&&!s&&o;if(c&&i.isCollapsed()&&(c=!eQ(kIe(i.anchor,!0))),!c){$(r,MY,!0);let e=vZ();wJ&&Z(e)&&e.isCollapsed()&&(gX=e,setTimeout(()=>gX=null))}}return!0}}var a;if(!Z(i))return!0;let o=e.data;sX!==null&&KQ(!1,r,sX),i.dirty&&sX===null||!i.isCollapsed()||nQ(i.anchor.getNode())||n===null||i.applyDOMRange(n),sX=null;let s=i.anchor,c=i.focus,l=s.getNode(),u=c.getNode();if(t===`insertText`||t===`insertTranspose`){if(o===`
178
178
  `)e.preventDefault(),$(r,NY,!1);else if(o===DJ)e.preventDefault(),$(r,PY,void 0);else if(o==null&&e.dataTransfer){let t=e.dataTransfer.getData(`text/plain`);e.preventDefault(),i.insertRawText(t)}else o!=null&&vX(i,n,o,e.timeStamp,!0)?(e.preventDefault(),$(r,FY,o)):sX=o;return oX=e.timeStamp,!0}switch(e.preventDefault(),t){case`insertFromYank`:case`insertFromDrop`:case`insertReplacementText`:$(r,FY,e);break;case`insertFromComposition`:AQ(null),$(r,FY,e);break;case`insertLineBreak`:AQ(null),$(r,NY,!1);break;case`insertParagraph`:AQ(null),fX&&!SJ?(fX=!1,$(r,NY,!1)):$(r,PY,void 0);break;case`insertFromPaste`:case`insertFromPasteAsQuotation`:$(r,IY,e);break;case`deleteByComposition`:(function(e,t){return e!==t||Q(e)||Q(t)||!CQ(e)||!CQ(t)})(l,u)&&$(r,LY,e);break;case`deleteByDrag`:case`deleteByCut`:$(r,LY,e);break;case`deleteContent`:$(r,MY,!1);break;case`deleteWordBackward`:$(r,RY,!0);break;case`deleteWordForward`:$(r,RY,!1);break;case`deleteHardLineBackward`:case`deleteSoftLineBackward`:$(r,zY,!0);break;case`deleteContentForward`:case`deleteHardLineForward`:case`deleteSoftLineForward`:$(r,zY,!1);break;case`formatStrikeThrough`:$(r,BY,`strikethrough`);break;case`formatBold`:$(r,BY,`bold`);break;case`formatItalic`:$(r,BY,`italic`);break;case`formatUnderline`:$(r,BY,`underline`);break;case`historyUndo`:$(r,VY,void 0);break;case`historyRedo`:$(r,HY,void 0)}return!0}function QFe(e){if(v$(e.target)&&_Q(e.target))return!0;let t=RZ(),n=vZ(),r=e.data,i=CX(e);if(r!=null&&Z(n)&&vX(n,i,r,e.timeStamp,!1)){pX&&=(wX(t,r),!1);let i=n.anchor.getNode(),a=_$(d$(t));if(a===null)return!0;let o=n.isBackward(),s=o?n.anchor.offset:n.focus.offset,c=o?n.focus.offset:n.anchor.offset;bJ&&!n.isCollapsed()&&XX(i)&&a.anchorNode!==null&&i.getTextContent().slice(0,s)+r+i.getTextContent().slice(s+c)===GQ(a.anchorNode)||$(t,FY,r);let l=r.length;yJ&&l>1&&e.inputType===`insertCompositionText`&&!t.isComposing()&&(n.anchor.offset-=l),wJ&&t.isComposing()&&(iX=0,AQ(null))}else KQ(!1,t,r===null?void 0:r),pX&&=(wX(t,r||void 0),!1);return function(){FZ(),LJ(RZ())}(),!0}function $Fe(e){let t=RZ(),n=vZ();if(Z(n)&&!t.isComposing()){let r=n.anchor,i=n.anchor.getNode();AQ(r.key),c$(iIe),(e.timeStamp<iX+30||r.type===`element`||!n.isCollapsed()||i.getFormat()!==n.format||XX(i)&&i.getStyle()!==n.style)&&$(t,FY,OJ)}return!0}function eIe(e){return wX(RZ(),e.data),c$(aIe),!0}function wX(e,t){let n=e._compositionKey;if(AQ(null),n!==null&&t!=null){if(t===``){let t=MQ(n),r=EQ(e.getElementByKey(n));if(r!==null&&r.nodeValue!==null&&XX(t)){let n=_$(d$(e)),i=null,a=null;n!==null&&n.anchorNode===r&&(i=n.anchorOffset,a=n.focusOffset),qQ(t,r.nodeValue,i,a,!0)}return}if(t[t.length-1]===`
@@ -183,7 +183,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
183
183
  `),l=!d.isEmpty();else if(l=!1,XX(d)){let e=d.getTextContent();d===t?d===n?r.type===`element`&&i.type===`element`&&i.offset!==r.offset||(e=o<s?e.slice(o,s):e.slice(s,o)):e=a?e.slice(o):e.slice(s):d===n&&(e=a?e.slice(0,s):e.slice(0,o)),c+=e}else !eQ(d)&&!LX(d)||d===n&&this.isCollapsed()||(c+=d.getTextContent())}return c}applyDOMRange(e){let t=RZ(),n=t.getEditorState()._selection,r=mZ(e.startContainer,e.startOffset,e.endContainer,e.endOffset,t,n);if(r===null)return;let[i,a]=r;this.anchor.set(i.key,i.offset,i.type,!0),this.focus.set(a.key,a.offset,a.type,!0),qJ(this)}clone(){let t=this.anchor,n=this.focus;return new e(tZ(t.key,t.offset,t.type),tZ(n.key,n.offset,n.type),this.format,this.style)}toggleFormat(e){this.format=DQ(this.format,e,null),this.dirty=!0}setFormat(e){this.format=e,this.dirty=!0}setStyle(e){this.style=e,this.dirty=!0}hasFormat(e){let t=kJ[e];return(this.format&t)!==0}insertRawText(e){let t=e.split(/(\r?\n|\t)/),n=[],r=t.length;for(let e=0;e<r;e++){let r=t[e];r===`
184
184
  `||r===`\r
185
185
  `?n.push(IX()):r===` `?n.push($X()):n.push(YX(r))}this.insertNodes(n)}insertText(e){let t=this.anchor,n=this.focus,r=this.format,i=this.style,a=t,o=n;!this.isCollapsed()&&n.isBefore(t)&&(a=n,o=t),a.type===`element`&&function(e,t,n,r){let i=e.getNode(),a=i.getChildAtIndex(e.offset),o=YX();if(o.setFormat(n),o.setStyle(r),lQ(a))a.splice(0,0,[o]);else{let e=nQ(i)?cQ().append(o):o;a===null?i.append(e):a.insertBefore(e)}e.is(t)&&t.set(o.__key,0,`text`),e.set(o.__key,0,`text`)}(a,o,r,i),o.type===`element`&&e1(o,o1($$(o,`next`)));let s=a.offset,c=o.offset,l=this.getNodes(),u=l.length,d=l[0];XX(d)||X(26);let f=d.getTextContent().length,p=d.getParentOrThrow(),m=l[u-1];if(u===1&&o.type===`element`&&(c=f,o.set(a.key,c,`text`)),this.isCollapsed()&&s===f&&(wQ(d)||!d.canInsertTextAfter()||!p.canInsertTextAfter()&&d.getNextSibling()===null)){let t=d.getNextSibling();if(XX(t)&&t.canInsertTextBefore()&&!wQ(t)||(t=YX(),t.setFormat(r),t.setStyle(i),p.canInsertTextAfter()?d.insertAfter(t):p.insertAfter(t)),t.select(0,0),d=t,e!==``)return void this.insertText(e)}else if(this.isCollapsed()&&s===0&&(wQ(d)||!d.canInsertTextBefore()||!p.canInsertTextBefore()&&d.getPreviousSibling()===null)){let t=d.getPreviousSibling();if(XX(t)&&!wQ(t)||(t=YX(),t.setFormat(r),p.canInsertTextBefore()?d.insertBefore(t):p.insertBefore(t)),t.select(),d=t,e!==``)return void this.insertText(e)}else if(d.isSegmented()&&s!==f){let e=YX(d.getTextContent());e.setFormat(r),d.replace(e),d=e}else if(!this.isCollapsed()&&e!==``){let t=m.getParent();if(!p.canInsertTextBefore()||!p.canInsertTextAfter()||Q(t)&&(!t.canInsertTextBefore()||!t.canInsertTextAfter()))return this.insertText(``),pZ(this.anchor,this.focus),void this.insertText(e)}if(u===1){if(CQ(d)){let t=YX(e);t.select(),d.replace(t);return}let t=d.getFormat(),n=d.getStyle();if(s!==c||t===r&&n===i){if(eZ(d)){let t=YX(e);t.setFormat(r),t.setStyle(i),t.select(),d.replace(t);return}}else{if(d.getTextContent()!==``){let t=YX(e);if(t.setFormat(r),t.setStyle(i),t.select(),s===0)d.insertBefore(t,!1);else{let[e]=d.splitText(s);e.insertAfter(t,!1)}t.isComposing()&&this.anchor.type===`text`&&(this.anchor.offset-=e.length);return}d.setFormat(r),d.setStyle(i)}let a=c-s;d=d.spliceText(s,a,e,!0),d.getTextContent()===``?d.remove():this.anchor.type===`text`&&(this.format=t,this.style=n,d.isComposing()&&(this.anchor.offset-=e.length))}else{let t=new Set([...d.getParentKeys(),...m.getParentKeys()]),n=Q(d)?d:d.getParentOrThrow(),r=Q(m)?m:m.getParentOrThrow(),i=m;if(!n.is(r)&&r.isInline())do i=r,r=r.getParentOrThrow();while(r.isInline());if(o.type===`text`&&(c!==0||m.getTextContent()===``)||o.type===`element`&&m.getIndexWithinParent()<c)if(XX(m)&&!CQ(m)&&c!==m.getTextContentSize()){if(m.isSegmented()){let e=YX(m.getTextContent());m.replace(e),m=e}nQ(o.getNode())||o.type!==`text`||(m=m.spliceText(0,c,``)),t.add(m.__key)}else{let e=m.getParentOrThrow();e.canBeEmpty()||e.getChildrenSize()!==1?m.remove():e.remove()}else t.add(m.__key);let a=r.getChildren(),p=new Set(l),h=n.is(r),g=n.isInline()&&d.getNextSibling()===null?n:d;for(let e=a.length-1;e>=0;e--){let t=a[e];if(t.is(d)||Q(t)&&t.isParentOf(d))break;t.isAttached()&&(!p.has(t)||t.is(i)?h||g.insertAfter(t,!1):t.remove())}if(!h){let e=r,n=null;for(;e!==null;){let r=e.getChildren(),i=r.length;(i===0||r[i-1].is(n))&&(t.delete(e.__key),n=e),e=e.getParent()}}if(CQ(d))if(s===f)d.select();else{let t=YX(e);t.select(),d.replace(t)}else d=d.spliceText(s,f-s,e,!0),d.getTextContent()===``?d.remove():this.anchor.type===`text`&&(this.format=d.getFormat(),this.style=d.getStyle(),d.isComposing()&&(this.anchor.offset-=e.length));for(let e=1;e<u;e++){let n=l[e],r=n.__key;t.has(r)||n.remove()}}}removeText(){let e=vZ()===this;t1(this,XIe(n1(this))),e&&vZ()!==this&&BQ(this)}formatText(e,t=null){if(this.isCollapsed())return this.toggleFormat(e),void AQ(null);let n=this.getNodes(),r=[];for(let e of n)XX(e)&&r.push(e);let i=t=>{n.forEach(n=>{if(Q(n)){let r=n.getFormatFlags(e,t);n.setTextFormat(r)}})},a=r.length;if(a===0)return this.toggleFormat(e),AQ(null),void i(t);let o=this.anchor,s=this.focus,c=this.isBackward(),l=c?s:o,u=c?o:s,d=0,f=r[0],p=l.type===`element`?0:l.offset;if(l.type===`text`&&p===f.getTextContentSize()&&(d=1,f=r[1],p=0),f==null)return;let m=f.getFormatFlags(e,t);i(m);let h=a-1,g=r[h],_=u.type===`text`?u.offset:g.getTextContentSize();if(f.is(g)){if(p===_)return;if(wQ(f)||p===0&&_===f.getTextContentSize())f.setFormat(m);else{let e=f.splitText(p,_),t=p===0?e[0]:e[1];t.setFormat(m),l.type===`text`&&l.set(t.__key,0,`text`),u.type===`text`&&u.set(t.__key,_-p,`text`)}this.format=m;return}p===0||wQ(f)||([,f]=f.splitText(p),p=0),f.setFormat(m);let v=g.getFormatFlags(e,m);_>0&&(_===g.getTextContentSize()||wQ(g)||([g]=g.splitText(_)),g.setFormat(v));for(let t=d+1;t<h;t++){let n=r[t],i=n.getFormatFlags(e,v);n.setFormat(i)}l.type===`text`&&l.set(f.__key,p,`text`),u.type===`text`&&u.set(g.__key,_,`text`),this.format=m|v}insertNodes(e){if(e.length===0)return;if(this.isCollapsed()||this.removeText(),this.anchor.key===`root`){this.insertParagraph();let t=vZ();return Z(t)||X(134),t.insertNodes(e)}let t=(this.isBackward()?this.focus:this.anchor).getNode(),n=k$(t,S$),r=e[e.length-1];if(Q(n)&&`__language`in n){if(`__language`in e[0])this.insertText(e[0].getTextContent());else{let t=EZ(this);n.splice(t,0,e),r.selectEnd()}return}if(!e.some(e=>(Q(e)||eQ(e))&&!e.isInline())){Q(n)||X(211,t.constructor.name,t.getType());let i=EZ(this);n.splice(i,0,e),r.selectEnd();return}let i=function(e){let t=cQ(),n=null;for(let r=0;r<e.length;r++){let i=e[r],a=LX(i);if(a||eQ(i)&&i.isInline()||Q(i)&&i.isInline()||XX(i)||i.isParentRequired()){if(n===null&&(n=i.createParentElementNode(),t.append(n),a))continue;n!==null&&n.append(i)}else t.append(i),n=null}return t}(e),a=i.getLastDescendant(),o=i.getChildren(),s=!Q(n)||!n.isEmpty()?this.insertParagraph():null,c=o[o.length-1],l=o[0];var u;Q(u=l)&&S$(u)&&!u.isEmpty()&&Q(n)&&(!n.isEmpty()||n.canMergeWhenEmpty())&&(Q(n)||X(211,t.constructor.name,t.getType()),n.append(...l.getChildren()),l=o[1]),l&&(n===null&&X(212,t.constructor.name,t.getType()),function(e,t){let n=t.getParentOrThrow().getLastChild(),r=t,i=[t];for(;r!==n;)r.getNextSibling()||X(140),r=r.getNextSibling(),i.push(r);let a=e;for(let e of i)a=a.insertAfter(e)}(n,l));let d=k$(a,S$);s&&Q(d)&&(s.canMergeWhenEmpty()||S$(c))&&(d.append(...s.getChildren()),s.remove()),Q(n)&&n.isEmpty()&&n.remove(),a.selectEnd();let f=Q(n)?n.getLastChild():null;LX(f)&&d!==n&&f.remove()}insertParagraph(){if(this.anchor.key===`root`){let e=cQ();return RQ().splice(this.anchor.offset,0,[e]),e.select(),e}let e=EZ(this),t=k$(this.anchor.getNode(),S$);Q(t)||X(213);let n=t.getChildAtIndex(e),r=n?[n,...n.getNextSiblings()]:[],i=t.insertNewAfter(this,!1);return i?(i.append(...r),i.selectStart(),i):null}insertLineBreak(e){let t=IX();if(this.insertNodes([t]),e){let e=t.getParentOrThrow(),n=t.getIndexWithinParent();e.select(n,n)}}extract(){let e=[...this.getNodes()],t=e.length,n=e[0],r=e[t-1],[i,a]=cZ(this),o=this.isBackward(),[s,c]=o?[this.focus,this.anchor]:[this.anchor,this.focus],[l,u]=o?[a,i]:[i,a];if(t===0)return[];if(t===1){if(XX(n)&&!this.isCollapsed()){let e=n.splitText(l,u),t=l===0?e[0]:e[1];return t?(s.set(t.getKey(),0,`text`),c.set(t.getKey(),t.getTextContentSize(),`text`),[t]):[]}return[n]}if(XX(n)&&(l===n.getTextContentSize()?e.shift():l!==0&&([,n]=n.splitText(l),e[0]=n,s.set(n.getKey(),0,`text`))),XX(r)){let t=r.getTextContent().length;u===0?e.pop():u!==t&&([r]=r.splitText(u),e[e.length-1]=r,c.set(r.getKey(),r.getTextContentSize(),`text`))}return e}modify(e,t,n){if(DZ(this,e,t,n))return;let r=e===`move`,i=RZ(),a=_$(d$(i));if(!a)return;let o=i._blockCursorElement,s=i._rootElement,c=this.focus.getNode();if(s===null||o===null||!Q(c)||c.isInline()||c.canBeEmpty()||g$(o,i,s),this.dirty){let e=a$(i,this.anchor.key),t=a$(i,this.focus.key);this.anchor.type===`text`&&(e=EQ(e)),this.focus.type===`text`&&(t=EQ(t)),e&&t&&wZ(a,e,this.anchor.offset,t,this.focus.offset)}if(function(e,t,n,r){e.modify(t,n,r)}(a,e,t?`backward`:`forward`,n),a.rangeCount>0){let e=a.getRangeAt(0),n=this.anchor.getNode(),i=nQ(n)?n:jIe(n);if(this.applyDOMRange(e),this.dirty=!0,!r){let n=this.getNodes(),r=[],o=!1;for(let e=0;e<n.length;e++){let t=n[e];l$(t,i)?r.push(t):o=!0}if(o&&r.length>0)if(t){let e=r[0];Q(e)?e.selectStart():e.getParentOrThrow().selectStart()}else{let e=r[r.length-1];Q(e)?e.selectEnd():e.getParentOrThrow().selectEnd()}a.anchorNode===e.startContainer&&a.anchorOffset===e.startOffset||function(e){let t=e.focus,n=e.anchor,r=n.key,i=n.offset,a=n.type;n.set(t.key,t.offset,t.type,!0),t.set(r,i,a,!0)}(this)}}n===`lineboundary`&&DZ(this,e,t,n,`decorators`)}forwardDeletion(e,t,n){if(!n&&(e.type===`element`&&Q(t)&&e.offset===t.getChildrenSize()||e.type===`text`&&e.offset===t.getTextContentSize())){let e=t.getParent(),n=t.getNextSibling()||(e===null?null:e.getNextSibling());if(Q(n)&&n.isShadowRoot())return!0}return!1}deleteCharacter(e){let t=this.isCollapsed();if(this.isCollapsed()){let t=this.anchor,n=t.getNode();if(this.forwardDeletion(t,n,e))return;let r=G$($$(t,e?`previous`:`next`));if(r.getTextSlices().every(e=>e===null||e.distance===0)){let e={type:`initial`};for(let t of r.iterNodeCarets(`shadowRoot`))if(R$(t)){if(!t.origin.isInline()){if(t.origin.isShadowRoot()){if(e.type===`merge-block`)break;if(Q(r.anchor.origin)&&r.anchor.origin.isEmpty()){let e=o1(t);t1(this,K$(e,e)),r.anchor.origin.remove()}return}e.type!==`merge-next-block`&&e.type!==`merge-block`||(e={block:e.block,caret:t,type:`merge-block`})}}else{if(e.type===`merge-block`)break;if(L$(t)){if(Q(t.origin)){if(t.origin.isInline()){if(!t.origin.isParentOf(r.anchor.origin))break}else e={block:t.origin,type:`merge-next-block`};continue}if(eQ(t.origin)){if(!t.origin.isIsolated())if(e.type===`merge-next-block`&&(t.origin.isKeyboardSelectable()||!t.origin.isInline())&&Q(r.anchor.origin)&&r.anchor.origin.isEmpty()){r.anchor.origin.remove();let e=gZ();e.add(t.origin.getKey()),BQ(e)}else t.origin.remove();return}break}}if(e.type===`merge-block`){let{caret:t,block:n}=e;return t1(this,K$(!t.origin.isEmpty()&&n.isEmpty()?r1(z$(n,t.direction)):r.anchor,t)),this.removeText()}}let i=this.focus;if(this.modify(`extend`,e,`character`),this.isCollapsed()){if(e&&t.offset===0&&lZ(this,t.getNode()))return}else{let r=i.type===`text`?i.getNode():null;if(n=t.type===`text`?t.getNode():null,r!==null&&r.isSegmented()){let t=i.offset,a=r.getTextContentSize();if(r.is(n)||e&&t!==a||!e&&t!==0)return void uZ(r,e,t)}else if(n!==null&&n.isSegmented()){let i=t.offset,a=n.getTextContentSize();if(n.is(r)||e&&i!==0||!e&&i!==a)return void uZ(n,e,i)}(function(e,t){let n=e.anchor,r=e.focus,i=n.getNode();if(i===r.getNode()&&n.type===`text`&&r.type===`text`){let e=n.offset,a=r.offset,o=e<a,s=o?e:a,c=o?a:e,l=c-1;s!==l&&(function(e){return!(HQ(e)||pIe(e))})(i.getTextContent().slice(s,c))&&(t?r.set(r.key,l,r.type):n.set(n.key,l,n.type))}})(this,e)}}if(this.removeText(),e&&!t&&this.isCollapsed()&&this.anchor.type===`element`&&this.anchor.offset===0){let e=this.anchor.getNode();e.isEmpty()&&nQ(e.getParent())&&e.getPreviousSibling()===null&&lZ(this,e)}}deleteLine(e){this.isCollapsed()&&this.modify(`extend`,e,`lineboundary`),this.isCollapsed()?this.deleteCharacter(e):this.removeText()}deleteWord(e){if(this.isCollapsed()){let t=this.anchor,n=t.getNode();if(this.forwardDeletion(t,n,e))return;this.modify(`extend`,e,`word`)}this.removeText()}isBackward(){return this.focus.isBefore(this.anchor)}getStartEndPoints(){return[this.anchor,this.focus]}};function oZ(e){return e instanceof iZ}function sZ(e){let t=e.offset;if(e.type===`text`)return t;let n=e.getNode();return t===n.getChildrenSize()?n.getTextContent().length:0}function cZ(e){let t=e.getStartEndPoints();if(t===null)return[0,0];let[n,r]=t;return n.type===`element`&&r.type===`element`&&n.key===r.key&&n.offset===r.offset?[0,0]:[sZ(n),sZ(r)]}function lZ(e,t){for(let n=t;n;n=n.getParent()){if(Q(n)){if(n.collapseAtStart(e))return!0;if(f$(n))break}if(n.getPreviousSibling())break}return!1}var pIe=(()=>{try{let e=RegExp(`\\p{Emoji}`,`u`),t=e.test.bind(e);if(t(`❤️`)&&t(`#️⃣`)&&t(`👍`))return t}catch{}return()=>!1})();function uZ(e,t,n){let r=e,i=r.getTextContent().split(/(?=\s)/g),a=i.length,o=0,s=0;for(let e=0;e<a;e++){let r=e===a-1;if(s=o,o+=i[e].length,t&&o===n||o>n||r){i.splice(e,1),r&&(s=void 0);break}}let c=i.join(``).trim();c===``?r.remove():(r.setTextContent(c),r.select(s,s))}function dZ(e,t,n,r){let i,a=t;if(v$(e)){let o=!1,s=e.childNodes,c=s.length,l=r._blockCursorElement;a===c&&(o=!0,a=c-1);let u=s[a],d=!1;if(u===l)u=s[a+1],d=!0;else if(l!==null){let n=l.parentNode;e===n&&t>Array.prototype.indexOf.call(n.children,l)&&a--}if(i=VQ(u),XX(i))a=V$(i,o?`next`:`previous`);else{let s=VQ(e);if(s===null)return null;if(Q(s)){let c=r.getElementByKey(s.getKey());c===null&&X(214);let l=s.getDOMSlot(c);[s,a]=l.resolveChildIndex(s,c,e,t),Q(s)||X(215),o&&a>=s.getChildrenSize()&&(a=Math.max(0,s.getChildrenSize()-1));let u=s.getChildAtIndex(a);if(Q(u)&&function(e,t,n){let r=e.getParent();return n===null||r===null||!r.canBeEmpty()||r!==n.getNode()}(u,0,n)){let e=o?u.getLastDescendant():u.getFirstDescendant();e===null?s=u:(u=e,s=Q(u)?u:u.getParentOrThrow()),a=0}XX(u)?(i=u,s=null,a=V$(u,o?`next`:`previous`)):u!==s&&o&&!d&&(Q(s)||X(216),a=Math.min(s.getChildrenSize(),a+1))}else{let n=s.getIndexWithinParent();a=t===0&&eQ(s)&&VQ(e)===s?n:n+1,s=s.getParentOrThrow()}if(Q(s))return tZ(s.__key,a,`element`)}}else i=VQ(e);return XX(i)?tZ(i.__key,V$(i,a,`clamp`),`text`):null}function fZ(e,t,n){let r=e.offset,i=e.getNode();if(r===0){let r=i.getPreviousSibling(),a=i.getParent();if(t){if((n||!t)&&r===null&&Q(a)&&a.isInline()){let t=a.getPreviousSibling();XX(t)&&e.set(t.__key,t.getTextContent().length,`text`)}}else Q(r)&&!n&&r.isInline()?e.set(r.__key,r.getChildrenSize(),`element`):XX(r)&&e.set(r.__key,r.getTextContent().length,`text`)}else if(r===i.getTextContent().length){let r=i.getNextSibling(),a=i.getParent();if(t&&Q(r)&&r.isInline())e.set(r.__key,0,`element`);else if((n||t)&&r===null&&Q(a)&&a.isInline()&&!a.canInsertTextAfter()){let t=a.getNextSibling();XX(t)&&e.set(t.__key,0,`text`)}}}function pZ(e,t,n){if(e.type===`text`&&t.type===`text`){let n=e.isBefore(t),r=e.is(t);fZ(e,n,r),fZ(t,!n,r),r&&t.set(e.key,e.offset,e.type)}}function mZ(e,t,n,r,i,a){if(e===null||n===null||!yQ(i,e,n))return null;let o=dZ(e,t,Z(a)?a.anchor:null,i);if(o===null)return null;let s=dZ(n,r,Z(a)?a.focus:null,i);if(s===null)return null;if(o.type===`element`&&s.type===`element`){let t=VQ(e),r=VQ(n);if(eQ(t)&&eQ(r))return null}return pZ(o,s),[o,s]}function hZ(e,t,n,r,i,a){let o=LZ(),s=new aZ(tZ(e,t,i),tZ(n,r,a),0,``);return s.dirty=!0,o._selection=s,s}function mIe(){return new aZ(tZ(`root`,0,`element`),tZ(`root`,0,`element`),0,``)}function gZ(){return new iZ(new Set)}function _Z(e,t,n,r){let i=n._window;if(i===null)return null;let a=r||i.event,o=a?a.type:void 0,s=o===`selectionchange`,c=!NJ&&(s||o===`beforeinput`||o===`compositionstart`||o===`compositionend`||o===`click`&&a&&a.detail===3||o===`drop`||o===void 0),l,u,d,f;if(Z(e)&&!c)return e.clone();if(t===null)return null;if(l=t.anchorNode,u=t.focusNode,d=t.anchorOffset,f=t.focusOffset,(s||o===void 0)&&Z(e)&&!yQ(n,l,u))return e.clone();let p=mZ(l,d,u,f,n,e);if(p===null)return null;let[m,h]=p,g=0,_=``;if(Z(e)){let t=e.anchor;if(m.key===t.key)g=e.format,_=e.style;else{let e=m.getNode();XX(e)?(g=e.getFormat(),_=e.getStyle()):Q(e)&&(g=e.getTextFormat(),_=e.getTextStyle())}}return new aZ(m,h,g,_)}function vZ(){return LZ()._selection}function yZ(){return RZ()._editorState._selection}function bZ(e,t,n,r=1){let i=e.anchor,a=e.focus,o=i.getNode(),s=a.getNode();if(!t.is(o)&&!t.is(s))return;let c=t.__key;if(e.isCollapsed()){let t=i.offset;if(n<=t&&r>0||n<t&&r<0){let n=Math.max(0,t+r);i.set(c,n,`element`),a.set(c,n,`element`),xZ(e)}}else{let o=e.isBackward(),s=o?a:i,l=s.getNode(),u=o?i:a,d=u.getNode();if(t.is(l)){let e=s.offset;(n<=e&&r>0||n<e&&r<0)&&s.set(c,Math.max(0,e+r),`element`)}if(t.is(d)){let e=u.offset;(n<=e&&r>0||n<e&&r<0)&&u.set(c,Math.max(0,e+r),`element`)}}xZ(e)}function xZ(e){let t=e.anchor,n=t.offset,r=e.focus,i=r.offset,a=t.getNode(),o=r.getNode();if(e.isCollapsed()){if(!Q(a))return;let e=a.getChildrenSize(),i=n>=e,o=i?a.getChildAtIndex(e-1):a.getChildAtIndex(n);if(XX(o)){let e=0;i&&(e=o.getTextContentSize()),t.set(o.__key,e,`text`),r.set(o.__key,e,`text`)}return}if(Q(a)){let e=a.getChildrenSize(),r=n>=e,i=r?a.getChildAtIndex(e-1):a.getChildAtIndex(n);if(XX(i)){let e=0;r&&(e=i.getTextContentSize()),t.set(i.__key,e,`text`)}}if(Q(o)){let e=o.getChildrenSize(),t=i>=e,n=t?o.getChildAtIndex(e-1):o.getChildAtIndex(i);if(XX(n)){let e=0;t&&(e=n.getTextContentSize()),r.set(n.__key,e,`text`)}}}function SZ(e,t,n,r,i){let a=null,o=0,s=null;r===null?i!==null&&(a=i.__key,XX(i)?s=`text`:Q(i)&&(s=`element`)):(a=r.__key,XX(r)?(o=r.getTextContentSize(),s=`text`):Q(r)&&(o=r.getChildrenSize(),s=`element`)),a!==null&&s!==null?e.set(a,o,s):(o=t.getIndexWithinParent(),o===-1&&(o=n.getChildrenSize()),e.set(n.__key,o,`element`))}function CZ(e,t,n,r,i){e.type===`text`?e.set(n,e.offset+(t?0:i),`text`):e.offset>r.getIndexWithinParent()&&e.set(e.key,e.offset-1,`element`)}function wZ(e,t,n,r,i){try{e.setBaseAndExtent(t,n,r,i)}catch{}}function TZ(e,t,n){let r=a$(e,t.getKey());if(Q(t)){let e=t.getDOMSlot(r);return[e.element,n+e.getFirstChildOffset()]}return[r,n]}function hIe(e,t,n,r,i,a,o){let s=r.anchorNode,c=r.focusNode,l=r.anchorOffset,u=r.focusOffset,d=document.activeElement;if(i.has(`collaboration`)&&d!==a||d!==null&&vQ(d))return;if(!Z(t))return void(e!==null&&yQ(n,s,c)&&r.removeAllRanges());let f=t.anchor,p=t.focus,m=f.getNode(),h=p.getNode(),[g,_]=TZ(n,m,f.offset),[v,y]=TZ(n,h,p.offset),b=t.format,x=t.style,S=t.isCollapsed(),C=g,w=v,T=!1;var E,D,O,k,A;if((f.type===`text`?(C=EQ(g),T=m.getFormat()!==b||m.getStyle()!==x):Z(e)&&e.anchor.type===`text`&&(T=!0),p.type===`text`&&(w=EQ(v)),C!==null&&w!==null)&&(S&&(e===null||T||Z(e)&&(e.format!==b||e.style!==x))&&(E=b,D=x,O=_,k=f.key,A=performance.now(),_X=[E,D,O,k,A]),l!==_||u!==y||s!==C||c!==w||r.type===`Range`&&S||(d!==null&&a.contains(d)||i.has(`skip-selection-focus`)||a.focus({preventScroll:!0}),f.type===`element`))){if(wZ(r,C,_,w,y),!yJ||!t.isCollapsed()||a===null||i.has(`skip-selection-focus`)||document.activeElement!==null&&a.contains(document.activeElement)||a.focus({preventScroll:!0}),!i.has(`skip-scroll-into-view`)&&t.isCollapsed()&&a!==null&&a===document.activeElement){let e=Z(t)&&t.anchor.type===`element`?C.childNodes[_]||null:r.rangeCount>0?r.getRangeAt(0):null;if(e!==null){let t;if(e instanceof Text){let n=document.createRange();n.selectNode(e),t=n.getBoundingClientRect()}else t=e.getBoundingClientRect();(function(e,t,n){let r=s$(n),i=u$(r);if(r===null||i===null)return;let{top:a,bottom:o}=t,s=0,c=0,l=n;for(;l!==null;){let t=l===r.body;if(t)s=0,c=d$(e).innerHeight;else{let e=l.getBoundingClientRect();s=e.top,c=e.bottom}let n=0;if(a<s?n=-(s-a):o>c&&(n=o-c),n!==0)if(t)i.scrollBy(0,n);else{let e=l.scrollTop;l.scrollTop+=n;let t=l.scrollTop-e;a-=t,o-=t}if(t)break;l=o$(l)}})(n,t,a)}}uX=!0}}function EZ(e){let t=e;e.isCollapsed()||t.removeText();let n=vZ();Z(n)&&(t=n),Z(t)||X(161);let r=t.anchor,i=r.getNode(),a=r.offset;for(;!S$(i);){let e=i;if([i,a]=gIe(i,a),e.is(i))break}return a}function gIe(e,t){let n=e.getParent();if(!n){let e=cQ();return RQ().append(e),e.select(),[RQ(),0]}if(XX(e)){let r=e.splitText(t);if(r.length===0)return[n,e.getIndexWithinParent()];let i=t===0?0:1;return[n,r[0].getIndexWithinParent()+i]}if(!Q(e)||t===0)return[n,e.getIndexWithinParent()];let r=e.getChildAtIndex(t);if(r){let n=new aZ(tZ(e.__key,t,`element`),tZ(e.__key,t,`element`),0,``),i=e.insertNewAfter(n);i&&i.append(r,...r.getNextSiblings())}return[n,e.getIndexWithinParent()+1]}function DZ(e,t,n,r,i=`decorators-and-blocks`){if(t===`move`&&r===`character`&&!e.isCollapsed()){let[t,r]=n===e.isBackward()?[e.focus,e.anchor]:[e.anchor,e.focus];return r.set(t.key,t.offset,t.type),!0}let a=$$(e.focus,n?`previous`:`next`),o=r===`lineboundary`,s=t===`move`,c=a,l=i===`decorators-and-blocks`;if(!s1(c)){for(let e of c){l=!1;let{origin:t}=e;if(!eQ(t)||t.isIsolated()||(c=e,!o||!t.isInline()))break}if(l)for(let e of G$(a).iterNodeCarets(t===`extend`?`shadowRoot`:`root`)){if(R$(e))e.origin.isInline()||(c=e);else{if(Q(e.origin))continue;eQ(e.origin)&&!e.origin.isInline()&&(c=e)}break}}if(c===a)return!1;if(s&&!o&&eQ(c.origin)&&c.origin.isKeyboardSelectable()){let e=gZ();return e.add(c.origin.getKey()),BQ(e),!0}return c=o1(c),s&&e1(e.anchor,c),e1(e.focus,c),l||!o}var OZ=null,kZ=null,AZ=!1,jZ=!1,MZ=0,NZ={characterData:!0,childList:!0,subtree:!0};function PZ(){return AZ||OZ!==null&&OZ._readOnly}function FZ(){AZ&&X(13)}function IZ(){MZ>99&&X(14)}function LZ(){return OZ===null&&X(195,zZ()),OZ}function RZ(){return kZ===null&&X(196,zZ()),kZ}function zZ(){let e=0,t=new Set,n=fQ.version;if(typeof window<`u`)for(let r of document.querySelectorAll(`[contenteditable]`)){let i=SQ(r);if(bQ(i))e++;else if(i){let e=String(i.constructor.version||`<0.17.1`);e===n&&(e+=` (separately built, likely a bundler configuration issue)`),t.add(e)}}let r=` Detected on the page: ${e} compatible editor(s) with version ${n}`;return t.size&&(r+=` and incompatible editors with versions ${Array.from(t).join(`, `)}`),r}function _Ie(){return kZ}function BZ(e,t,n){let r=t.__type,i=hQ(e,r),a=n.get(r);a===void 0&&(a=Array.from(i.transforms),n.set(r,a));let o=a.length;for(let e=0;e<o&&(a[e](t),t.isAttached());e++);}function VZ(e,t){return e!==void 0&&e.__key!==t&&e.isAttached()}function HZ(e,t){if(!t)return;let n=e._updateTags,r=t;Array.isArray(t)||(r=[t]);for(let e of r)n.add(e)}function UZ(e,t){let n=e.type,r=t.get(n);r===void 0&&X(17,n);let i=r.klass;e.type!==i.getType()&&X(18,i.name);let a=i.importJSON(e),o=e.children;if(Q(a)&&Array.isArray(o))for(let e=0;e<o.length;e++){let n=UZ(o[e],t);a.append(n)}return a}function WZ(e,t,n){let r=OZ,i=AZ,a=kZ;OZ=t,AZ=!0,kZ=e;try{return n()}finally{OZ=r,AZ=i,kZ=a}}function GZ(e,t){let n=e._pendingEditorState,r=e._rootElement,i=e._headless||r===null;if(n===null)return;let a=e._editorState,o=a._selection,s=n._selection,c=e._dirtyType!==0,l=OZ,u=AZ,d=kZ,f=e._updating,p=e._observer,m=null;if(e._pendingEditorState=null,e._editorState=n,!i&&c&&p!==null){kZ=e,OZ=n,AZ=!1,e._updating=!0;try{let t=e._dirtyType,r=e._dirtyElements,i=e._dirtyLeaves;p.disconnect(),m=FFe(a,n,e,t,r,i)}catch(t){if(t instanceof Error&&e._onError(t),jZ)throw t;uQ(e,null,r,n),RJ(e),e._dirtyType=2,jZ=!0,GZ(e,a),jZ=!1;return}finally{p.observe(r,NZ),e._updating=f,OZ=l,AZ=u,kZ=d}}n._readOnly||=!0;let h=e._dirtyLeaves,g=e._dirtyElements,_=e._normalizedNodes,v=e._updateTags,y=e._deferred;c&&(e._dirtyType=0,e._cloneNotNeeded.clear(),e._dirtyLeaves=new Set,e._dirtyElements=new Map,e._normalizedNodes=new Set,e._updateTags=new Set),function(e,t){let n=e._decorators,r=e._pendingDecorators||n,i=t._nodeMap,a;for(a in r)i.has(a)||(r===n&&(r=IQ(e)),delete r[a])}(e,n);let b=i?null:_$(d$(e));if(e._editable&&b!==null&&(c||s===null||s.dirty||!s.is(o))&&r!==null&&!v.has(`skip-dom-selection`)){kZ=e,OZ=n;try{if(p!==null&&p.disconnect(),c||s===null||s.dirty){let t=e._blockCursorElement;t!==null&&g$(t,e,r),hIe(o,s,e,b,v,r)}(function(e,t,n){let r=e._blockCursorElement;if(Z(n)&&n.isCollapsed()&&n.anchor.type===`element`&&t.contains(document.activeElement)){let i=n.anchor,a=i.getNode(),o=i.offset,s=!1,c=null;if(o===a.getChildrenSize())h$(a.getChildAtIndex(o-1))&&(s=!0);else{let t=a.getChildAtIndex(o);if(t!==null&&h$(t)){let n=t.getPreviousSibling();(n===null||h$(n))&&(s=!0,c=e.getElementByKey(t.__key))}}if(s){let n=e.getElementByKey(a.__key);r===null&&(e._blockCursorElement=r=function(e){let t=e.theme,n=document.createElement(`div`);n.contentEditable=`false`,n.setAttribute(`data-lexical-cursor`,`true`);let r=t.blockCursor;return r!==void 0&&(typeof r==`string`&&(r=t.blockCursor=d1(r)),r!==void 0&&n.classList.add(...r)),n}(e._config)),t.style.caretColor=`transparent`,c===null?n.appendChild(r):n.insertBefore(r,c);return}}r!==null&&g$(r,e,t)})(e,r,s)}finally{p!==null&&p.observe(r,NZ),kZ=d,OZ=l}}m!==null&&function(e,t,n,r,i){let a=Array.from(e._listeners.mutation),o=a.length;for(let e=0;e<o;e++){let[o,s]=a[e];for(let e of s){let a=t.get(e);a!==void 0&&o(a,{dirtyLeaves:r,prevEditorState:i,updateTags:n})}}}(e,m,v,h,a),Z(s)||s===null||o!==null&&o.is(s)||e.dispatchCommand(DY,void 0);let x=e._pendingDecorators;x!==null&&(e._decorators=x,e._pendingDecorators=null,KZ(`decorator`,e,!0,x)),function(e,t,n){let r=LQ(t),i=LQ(n);r!==i&&KZ(`textcontent`,e,!0,i)}(e,t||a,n),KZ(`update`,e,!0,{dirtyElements:g,dirtyLeaves:h,editorState:n,mutatedNodes:m,normalizedNodes:_,prevEditorState:t||a,tags:v}),function(e,t){if(e._deferred=[],t.length!==0){let n=e._updating;e._updating=!0;try{for(let e=0;e<t.length;e++)t[e]()}finally{e._updating=n}}}(e,y),function(e){let t=e._updates;if(t.length!==0){let n=t.shift();if(n){let[t,r]=n;JZ(e,t,r)}}}(e)}function KZ(e,t,n,...r){let i=t._updating;t._updating=n;try{let n=Array.from(t._listeners[e]);for(let e=0;e<n.length;e++)n[e].apply(null,r)}finally{t._updating=i}}function qZ(e,t){let n=e._updates,r=t||!1;for(;n.length!==0;){let t=n.shift();if(t){let[n,i]=t,a=e._pendingEditorState,o;i!==void 0&&(o=i.onUpdate,i.skipTransforms&&(r=!0),i.discrete&&(a===null&&X(191),a._flushSync=!0),o&&e._deferred.push(o),HZ(e,i.tag)),a==null?JZ(e,n,i):n()}}return r}function JZ(e,t,n){let r=e._updateTags,i,a=!1,o=!1;n!==void 0&&(i=n.onUpdate,HZ(e,n.tag),a=n.skipTransforms||!1,o=n.discrete||!1),i&&e._deferred.push(i);let s=e._editorState,c=e._pendingEditorState,l=!1;(c===null||c._readOnly)&&(c=e._pendingEditorState=rQ(c||s),l=!0),c._flushSync=o;let u=OZ,d=AZ,f=kZ,p=e._updating;OZ=c,AZ=!1,e._updating=!0,kZ=e;let m=e._headless||e.getRootElement()===null;mQ(null);try{l&&(m?s._selection!==null&&(c._selection=s._selection.clone()):c._selection=function(e,t){let n=e.getEditorState()._selection,r=_$(d$(e));return Z(n)||n==null?_Z(n,r,e,t):n.clone()}(e,n&&n.event||null));let r=e._compositionKey;t(),a=qZ(e,a),function(e,t){let n=t.getEditorState()._selection,r=e._selection;if(Z(r)){let e=r.anchor,t=r.focus,i;if(e.type===`text`&&(i=e.getNode(),i.selectionTransform(n,r)),t.type===`text`){let e=t.getNode();i!==e&&e.selectionTransform(n,r)}}}(c,e),e._dirtyType!==0&&(a?function(e,t){let n=t._dirtyLeaves,r=e._nodeMap;for(let e of n){let t=r.get(e);XX(t)&&t.isAttached()&&t.isSimpleText()&&!t.isUnmergeable()&&KJ(t)}}(c,e):function(e,t){let n=t._dirtyLeaves,r=t._dirtyElements,i=e._nodeMap,a=jQ(),o=new Map,s=n,c=s.size,l=r,u=l.size;for(;c>0||u>0;){if(c>0){t._dirtyLeaves=new Set;for(let e of s){let r=i.get(e);XX(r)&&r.isAttached()&&r.isSimpleText()&&!r.isUnmergeable()&&KJ(r),r!==void 0&&VZ(r,a)&&BZ(t,r,o),n.add(e)}if(s=t._dirtyLeaves,c=s.size,c>0){MZ++;continue}}t._dirtyLeaves=new Set,t._dirtyElements=new Map,l.delete(`root`)&&l.set(`root`,!0);for(let e of l){let n=e[0],s=e[1];if(r.set(n,s),!s)continue;let c=i.get(n);c!==void 0&&VZ(c,a)&&BZ(t,c,o)}s=t._dirtyLeaves,c=s.size,l=t._dirtyElements,u=l.size,MZ++}t._dirtyLeaves=n,t._dirtyElements=r}(c,e),qZ(e),function(e,t,n,r){let i=e._nodeMap,a=t._nodeMap,o=[];for(let[e]of r){let t=a.get(e);t!==void 0&&(t.isAttached()||(Q(t)&&MJ(t,e,i,a,o,r),i.has(e)||r.delete(e),o.push(e)))}for(let e of o)a.delete(e);for(let e of n){let t=a.get(e);t===void 0||t.isAttached()||(i.has(e)||n.delete(e),a.delete(e))}}(s,c,e._dirtyLeaves,e._dirtyElements)),r!==e._compositionKey&&(c._flushSync=!0);let i=c._selection;if(Z(i)){let e=c._nodeMap,t=i.anchor.key,n=i.focus.key;e.get(t)!==void 0&&e.get(n)!==void 0||X(19)}else oZ(i)&&i._nodes.size===0&&(c._selection=null)}catch(t){t instanceof Error&&e._onError(t),e._pendingEditorState=s,e._dirtyType=2,e._cloneNotNeeded.clear(),e._dirtyLeaves=new Set,e._dirtyElements.clear(),GZ(e);return}finally{OZ=u,AZ=d,kZ=f,e._updating=p,MZ=0}e._dirtyType!==0||e._deferred.length>0||function(e,t){let n=t.getEditorState()._selection,r=e._selection;if(r!==null){if(r.dirty||!r.is(n))return!0}else if(n!==null)return!0;return!1}(c,e)?c._flushSync?(c._flushSync=!1,GZ(e)):l&&wIe(()=>{GZ(e)}):(c._flushSync=!1,l&&(r.clear(),e._deferred=[],e._pendingEditorState=null))}function YZ(e,t,n){kZ===e&&n===void 0?t():JZ(e,t,n)}var vIe=class e{element;before;after;constructor(e,t,n){this.element=e,this.before=t||null,this.after=n||null}withBefore(t){return new e(this.element,t,this.after)}withAfter(t){return new e(this.element,this.before,t)}withElement(t){return this.element===t?this:new e(t,this.before,this.after)}insertChild(e){let t=this.before||this.getManagedLineBreak();return t!==null&&t.parentElement!==this.element&&X(222),this.element.insertBefore(e,t),this}removeChild(e){return e.parentElement!==this.element&&X(223),this.element.removeChild(e),this}replaceChild(e,t){return t.parentElement!==this.element&&X(224),this.element.replaceChild(e,t),this}getFirstChild(){let e=this.after?this.after.nextSibling:this.element.firstChild;return e===this.before||e===this.getManagedLineBreak()?null:e}getManagedLineBreak(){return this.element.__lexicalLineBreak||null}setManagedLineBreak(e){if(e===null)this.removeManagedLineBreak();else{let t=e===`decorator`&&(TJ||SJ||xJ);this.insertManagedLineBreak(t)}}removeManagedLineBreak(){let e=this.getManagedLineBreak();if(e){let t=this.element,n=e.nodeName===`IMG`?e.nextSibling:null;n&&t.removeChild(n),t.removeChild(e),t.__lexicalLineBreak=void 0}}insertManagedLineBreak(e){let t=this.getManagedLineBreak();if(t){if(e===(t.nodeName===`IMG`))return;this.removeManagedLineBreak()}let n=this.element,r=this.before,i=document.createElement(`br`);if(n.insertBefore(i,r),e){let e=document.createElement(`img`);e.setAttribute(`data-lexical-linebreak`,`true`),e.style.cssText=`display: inline !important; border: 0px !important; margin: 0px !important;`,e.alt=``,n.insertBefore(e,i),n.__lexicalLineBreak=e}else n.__lexicalLineBreak=i}getFirstChildOffset(){let e=0;for(let t=this.after;t!==null;t=t.previousSibling)e++;return e}resolveChildIndex(e,t,n,r){if(n===this.element){let t=this.getFirstChildOffset();return[e,Math.min(t+e.getChildrenSize(),Math.max(t,r))]}let i=XZ(t,n);i.push(r);let a=XZ(t,this.element),o=e.getIndexWithinParent();for(let e=0;e<a.length;e++){let t=i[e],n=a[e];if(t===void 0||t<n)break;if(t>n){o+=1;break}}return[e.getParentOrThrow(),o]}};function XZ(e,t){let n=[],r=t;for(;r!==e&&r!==null;r=r.parentNode){let e=0;for(let t=r.previousSibling;t!==null;t=t.previousSibling)e++;n.push(e)}return r!==e&&X(225),n.reverse()}var ZZ=class extends NX{__first;__last;__size;__format;__style;__indent;__dir;__textFormat;__textStyle;constructor(e){super(e),this.__first=null,this.__last=null,this.__size=0,this.__format=0,this.__style=``,this.__indent=0,this.__dir=null,this.__textFormat=0,this.__textStyle=``}afterCloneFrom(e){super.afterCloneFrom(e),this.__key===e.__key&&(this.__first=e.__first,this.__last=e.__last,this.__size=e.__size),this.__indent=e.__indent,this.__format=e.__format,this.__style=e.__style,this.__dir=e.__dir,this.__textFormat=e.__textFormat,this.__textStyle=e.__textStyle}getFormat(){return this.getLatest().__format}getFormatType(){return bFe[this.getFormat()]||``}getStyle(){return this.getLatest().__style}getIndent(){return this.getLatest().__indent}getChildren(){let e=[],t=this.getFirstChild();for(;t!==null;)e.push(t),t=t.getNextSibling();return e}getChildrenKeys(){let e=[],t=this.getFirstChild();for(;t!==null;)e.push(t.__key),t=t.getNextSibling();return e}getChildrenSize(){return this.getLatest().__size}isEmpty(){return this.getChildrenSize()===0}isDirty(){let e=RZ()._dirtyElements;return e!==null&&e.has(this.__key)}isLastChild(){let e=this.getLatest(),t=this.getParentOrThrow().getLastChild();return t!==null&&t.is(e)}getAllTextNodes(){let e=[],t=this.getFirstChild();for(;t!==null;){if(XX(t)&&e.push(t),Q(t)){let n=t.getAllTextNodes();e.push(...n)}t=t.getNextSibling()}return e}getFirstDescendant(){let e=this.getFirstChild();for(;Q(e);){let t=e.getFirstChild();if(t===null)break;e=t}return e}getLastDescendant(){let e=this.getLastChild();for(;Q(e);){let t=e.getLastChild();if(t===null)break;e=t}return e}getDescendantByIndex(e){let t=this.getChildren(),n=t.length;if(e>=n){let e=t[n-1];return Q(e)&&e.getLastDescendant()||e||null}let r=t[e];return Q(r)&&r.getFirstDescendant()||r||null}getFirstChild(){let e=this.getLatest().__first;return e===null?null:MQ(e)}getFirstChildOrThrow(){let e=this.getFirstChild();return e===null&&X(45,this.__key),e}getLastChild(){let e=this.getLatest().__last;return e===null?null:MQ(e)}getLastChildOrThrow(){let e=this.getLastChild();return e===null&&X(96,this.__key),e}getChildAtIndex(e){let t=this.getChildrenSize(),n,r;if(e<t/2){for(n=this.getFirstChild(),r=0;n!==null&&r<=e;){if(r===e)return n;n=n.getNextSibling(),r++}return null}for(n=this.getLastChild(),r=t-1;n!==null&&r>=e;){if(r===e)return n;n=n.getPreviousSibling(),r--}return null}getTextContent(){let e=``,t=this.getChildren(),n=t.length;for(let r=0;r<n;r++){let i=t[r];e+=i.getTextContent(),Q(i)&&r!==n-1&&!i.isInline()&&(e+=DJ)}return e}getTextContentSize(){let e=0,t=this.getChildren(),n=t.length;for(let r=0;r<n;r++){let i=t[r];e+=i.getTextContentSize(),Q(i)&&r!==n-1&&!i.isInline()&&(e+=2)}return e}getDirection(){return this.getLatest().__dir}getTextFormat(){return this.getLatest().__textFormat}hasFormat(e){if(e!==``){let t=AJ[e];return(this.getFormat()&t)!==0}return!1}hasTextFormat(e){let t=kJ[e];return(this.getTextFormat()&t)!==0}getFormatFlags(e,t){return DQ(this.getLatest().__textFormat,e,t)}getTextStyle(){return this.getLatest().__textStyle}select(e,t){FZ();let n=vZ(),r=e,i=t,a=this.getChildrenSize();if(!this.canBeEmpty()){if(e===0&&t===0){let e=this.getFirstChild();if(XX(e)||Q(e))return e.select(0,0)}else if(!(e!==void 0&&e!==a||t!==void 0&&t!==a)){let e=this.getLastChild();if(XX(e)||Q(e))return e.select()}}r===void 0&&(r=a),i===void 0&&(i=a);let o=this.__key;return Z(n)?(n.anchor.set(o,r,`element`),n.focus.set(o,i,`element`),n.dirty=!0,n):hZ(o,r,o,i,`element`,`element`)}selectStart(){let e=this.getFirstDescendant();return e?e.selectStart():this.select()}selectEnd(){let e=this.getLastDescendant();return e?e.selectEnd():this.select()}clear(){let e=this.getWritable();return this.getChildren().forEach(e=>e.remove()),e}append(...e){return this.splice(this.getChildrenSize(),0,e)}setDirection(e){let t=this.getWritable();return t.__dir=e,t}setFormat(e){return this.getWritable().__format=e===``?0:AJ[e],this}setStyle(e){return this.getWritable().__style=e||``,this}setTextFormat(e){let t=this.getWritable();return t.__textFormat=e,t}setTextStyle(e){let t=this.getWritable();return t.__textStyle=e,t}setIndent(e){return this.getWritable().__indent=e,this}splice(e,t,n){MX(this)&&X(324,this.__key,this.__type);let r=this.getChildrenSize(),i=this.getWritable();e+t<=r||X(226,String(e),String(t),String(r));let a=i.__key,o=[],s=[],c=this.getChildAtIndex(e+t),l=null,u=r-t+n.length;if(e!==0)if(e===r)l=this.getLastChild();else{let t=this.getChildAtIndex(e);t!==null&&(l=t.getPreviousSibling())}if(t>0){let e=l===null?this.getFirstChild():l.getNextSibling();for(let n=0;n<t;n++){e===null&&X(100);let t=e.getNextSibling(),n=e.__key;OQ(e.getWritable()),s.push(n),e=t}}let d=l;for(let e of n){d!==null&&e.is(d)&&(l=d=d.getPreviousSibling());let t=e.getWritable();t.__parent===a&&u--,OQ(t);let n=e.__key;if(d===null)i.__first=n,t.__prev=null;else{let e=d.getWritable();e.__next=n,t.__prev=e.__key}e.__key===a&&X(76),t.__parent=a,o.push(n),d=e}if(e+t===r)d!==null&&(d.getWritable().__next=null,i.__last=d.__key);else if(c!==null){let e=c.getWritable();if(d!==null){let t=d.getWritable();e.__prev=d.__key,t.__next=c.__key}else e.__prev=null}if(i.__size=u,s.length){let e=vZ();if(Z(e)){let t=new Set(s),n=new Set(o),{anchor:r,focus:i}=e;QZ(r,t,n)&&SZ(r,r.getNode(),this,l,c),QZ(i,t,n)&&SZ(i,i.getNode(),this,l,c),u!==0||this.canBeEmpty()||f$(this)||this.remove()}}return i}getDOMSlot(e){return new vIe(e)}exportDOM(e){let{element:t}=super.exportDOM(e);if(v$(t)){let e=this.getIndent();e>0&&(t.style.paddingInlineStart=40*e+`px`);let n=this.getDirection();n&&(t.dir=n)}return{element:t}}exportJSON(){let e={children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),...super.exportJSON()},t=this.getTextFormat(),n=this.getTextStyle();return t===0&&n===``||f$(this)||this.getChildren().some(XX)||(t!==0&&(e.textFormat=t),n!==``&&(e.textStyle=n)),e}updateFromJSON(e){return super.updateFromJSON(e).setFormat(e.format).setIndent(e.indent).setDirection(e.direction).setTextFormat(e.textFormat||0).setTextStyle(e.textStyle||``)}insertNewAfter(e,t){return null}canIndent(){return!0}collapseAtStart(e){return!1}excludeFromCopy(e){return!1}canReplaceWith(e){return!0}canInsertAfter(e){return!0}canBeEmpty(){return!0}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}isInline(){return!1}isShadowRoot(){return!1}canMergeWith(e){return!1}extractWithChild(e,t,n){return!1}canMergeWhenEmpty(){return!1}reconcileObservedMutation(e,t){let n=this.getDOMSlot(e),r=n.getFirstChild();for(let e=this.getFirstChild();e;e=e.getNextSibling()){let i=t.getElementByKey(e.getKey());i!==null&&(r==null?(n.insertChild(i),r=i):r!==i&&n.replaceChild(i,r),r=r.nextSibling)}}};function Q(e){return e instanceof ZZ}function QZ(e,t,n){let r=e.getNode();for(;r;){let e=r.__key;if(t.has(e)&&!n.has(e))return!0;r=r.getParent()}return!1}var $Z=class extends NX{decorate(e,t){return null}isIsolated(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}};function eQ(e){return e instanceof $Z}var tQ=class e extends ZZ{__cachedText;static getType(){return`root`}static clone(){return new e}constructor(){super(`root`),this.__cachedText=null}getTopLevelElementOrThrow(){X(51)}getTextContent(){let e=this.__cachedText;return!PZ()&&RZ()._dirtyType!==0||e===null?super.getTextContent():e}remove(){X(52)}replace(e){X(53)}insertBefore(e){X(54)}insertAfter(e){X(55)}updateDOM(e,t){return!1}splice(e,t,n){for(let e of n)Q(e)||eQ(e)||X(282);return super.splice(e,t,n)}static importJSON(e){return RQ().updateFromJSON(e)}collapseAtStart(){return!0}};function nQ(e){return e instanceof tQ}function rQ(e){return new oQ(new Map(e._nodeMap))}function iQ(){return new oQ(new Map([[`root`,new tQ]]))}function aQ(e){let t=e.exportJSON(),n=e.constructor;if(t.type!==n.getType()&&X(130,n.name),Q(e)){let r=t.children;Array.isArray(r)||X(59,n.name);let i=e.getChildren();for(let e=0;e<i.length;e++){let t=aQ(i[e]);r.push(t)}}return t}function yIe(e){return e instanceof oQ}var oQ=class e{_nodeMap;_selection;_flushSync;_readOnly;constructor(e,t){this._nodeMap=e,this._selection=t||null,this._flushSync=!1,this._readOnly=!1}isEmpty(){return this._nodeMap.size===1&&this._selection===null}read(e,t){return WZ(t&&t.editor||null,this,e)}clone(t){let n=new e(this._nodeMap,t===void 0?this._selection:t);return n._readOnly=!0,n}toJSON(){return WZ(null,this,()=>({root:aQ(RQ())}))}},bIe=class extends ZZ{static getType(){return`artificial`}createDOM(e){return document.createElement(`div`)}},sQ=class e extends ZZ{static getType(){return`paragraph`}static clone(t){return new e(t.__key)}createDOM(e){let t=document.createElement(`p`),n=t$(e.theme,`paragraph`);return n!==void 0&&t.classList.add(...n),t}updateDOM(e,t,n){return!1}static importDOM(){return{p:e=>({conversion:xIe,priority:0})}}exportDOM(e){let{element:t}=super.exportDOM(e);if(v$(t)){this.isEmpty()&&t.append(document.createElement(`br`));let e=this.getFormatType();e&&(t.style.textAlign=e)}return{element:t}}static importJSON(e){return cQ().updateFromJSON(e)}exportJSON(){let e=super.exportJSON();if(e.textFormat===void 0||e.textStyle===void 0){let t=this.getChildren().find(XX);t?(e.textFormat=t.getFormat(),e.textStyle=t.getStyle()):(e.textFormat=this.getTextFormat(),e.textStyle=this.getTextStyle())}return e}insertNewAfter(e,t){let n=cQ();n.setTextFormat(e.format),n.setTextStyle(e.style);let r=this.getDirection();return n.setDirection(r),n.setFormat(this.getFormatType()),n.setStyle(this.getStyle()),this.insertAfter(n,t),n}collapseAtStart(){let e=this.getChildren();if(e.length===0||XX(e[0])&&e[0].getTextContent().trim()===``){if(this.getNextSibling()!==null)return this.selectNext(),this.remove(),!0;if(this.getPreviousSibling()!==null)return this.selectPrevious(),this.remove(),!0}return!1}};function xIe(e){let t=cQ();if(e.style&&(t.setFormat(e.style.textAlign),LIe(e,t)),t.getFormatType()===``){let n=e.getAttribute(`align`);n&&n&&n in AJ&&t.setFormat(n)}return{node:t}}function cQ(){return p$(new sQ)}function lQ(e){return e instanceof sQ}function uQ(e,t,n,r){let i=e._keyToDOMMap;i.clear(),e._editorState=iQ(),e._pendingEditorState=r,e._compositionKey=null,e._dirtyType=0,e._cloneNotNeeded.clear(),e._dirtyLeaves=new Set,e._dirtyElements.clear(),e._normalizedNodes=new Set,e._updateTags=new Set,e._updates=[],e._blockCursorElement=null;let a=e._observer;a!==null&&(a.disconnect(),e._observer=null),t!==null&&(t.textContent=``),n!==null&&(n.textContent=``,i.set(`root`,n))}function SIe(e){let t=new Set,n=new Set,r=e;for(;r;){let{ownNodeConfig:e}=O$(r),i=r.transform;if(!n.has(i)){n.add(i);let e=r.transform();e&&t.add(e)}if(e){let n=e.$transform;n&&t.add(n),r=e.extends}else{let e=Object.getPrototypeOf(r);r=e.prototype instanceof NX&&e!==NX?e:void 0}}return t}function dQ(e){let t=e||{},n=_Ie(),r=t.theme||{},i=e===void 0?n:t.parentEditor||null,a=t.disableEvents||!1,o=iQ(),s=t.namespace||(i===null?WQ():i._config.namespace),c=t.editorState,l=[tQ,GX,FX,QX,sQ,bIe,...t.nodes||[]],{onError:u,html:d}=t,f=t.editable===void 0||t.editable,p;if(e===void 0&&n!==null)p=n._nodes;else{p=new Map;for(let e=0;e<l.length;e++){let t=l[e],n=null,r=null;if(typeof t!=`function`){let e=t;t=e.replace,n=e.with,r=e.withKlass||null}O$(t);let i=t.getType(),a=SIe(t);p.set(i,{exportDOM:d&&d.export?d.export.get(t):void 0,klass:t,replace:n,replaceWithKlass:r,sharedNodeState:kFe(l[e]),transforms:a})}}let m=new fQ(o,i,p,{disableEvents:a,namespace:s,theme:r},u||console.error,function(e,t){let n=new Map,r=new Set,i=e=>{Object.keys(e).forEach(t=>{let r=n.get(t);r===void 0&&(r=[],n.set(t,r)),r.push(e[t])})};return e.forEach(e=>{let t=e.klass.importDOM;if(t==null||r.has(t))return;r.add(t);let n=t.call(e.klass);n!==null&&i(n)}),t&&i(t),n}(p,d?d.import:void 0),f,e);return c!==void 0&&(m._pendingEditorState=c,m._dirtyType=2),function(e){e.registerCommand(OY,ZFe,0),e.registerCommand(kY,QFe,0),e.registerCommand(AY,$Fe,0),e.registerCommand(jY,eIe,0),e.registerCommand(UY,tIe,0)}(m),m}var fQ=class{static version;_headless;_parentEditor;_rootElement;_editorState;_pendingEditorState;_compositionKey;_deferred;_keyToDOMMap;_updates;_updating;_listeners;_commands;_nodes;_decorators;_pendingDecorators;_config;_dirtyType;_cloneNotNeeded;_dirtyLeaves;_dirtyElements;_normalizedNodes;_updateTags;_observer;_key;_onError;_htmlConversions;_window;_editable;_blockCursorElement;_createEditorArgs;constructor(e,t,n,r,i,a,o,s){this._createEditorArgs=s,this._parentEditor=t,this._rootElement=null,this._editorState=e,this._pendingEditorState=null,this._compositionKey=null,this._deferred=[],this._keyToDOMMap=new Map,this._updates=[],this._updating=!1,this._listeners={decorator:new Set,editable:new Set,mutation:new Map,root:new Set,textcontent:new Set,update:new Set},this._commands=new Map,this._config=r,this._nodes=n,this._decorators={},this._pendingDecorators=null,this._dirtyType=0,this._cloneNotNeeded=new Set,this._dirtyLeaves=new Set,this._dirtyElements=new Map,this._normalizedNodes=new Set,this._updateTags=new Set,this._observer=null,this._key=WQ(),this._onError=i,this._htmlConversions=a,this._editable=o,this._headless=t!==null&&t._headless,this._window=null,this._blockCursorElement=null}isComposing(){return this._compositionKey!=null}registerUpdateListener(e){let t=this._listeners.update;return t.add(e),()=>{t.delete(e)}}registerEditableListener(e){let t=this._listeners.editable;return t.add(e),()=>{t.delete(e)}}registerDecoratorListener(e){let t=this._listeners.decorator;return t.add(e),()=>{t.delete(e)}}registerTextContentListener(e){let t=this._listeners.textcontent;return t.add(e),()=>{t.delete(e)}}registerRootListener(e){let t=this._listeners.root;return e(this._rootElement,null),t.add(e),()=>{e(null,this._rootElement),t.delete(e)}}registerCommand(e,t,n){n===void 0&&X(35);let r=this._commands;r.has(e)||r.set(e,[new Set,new Set,new Set,new Set,new Set]);let i=r.get(e);i===void 0&&X(36,String(e));let a=i[n];return a.add(t),()=>{a.delete(t),i.every(e=>e.size===0)&&r.delete(e)}}registerMutationListener(e,t,n){let r=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(e)).klass,i=this._listeners.mutation,a=i.get(t);a===void 0&&(a=new Set,i.set(t,a)),a.add(r);let o=n&&n.skipInitialization;return o!==void 0&&o||this.initializeMutationListener(t,r),()=>{a.delete(r),a.size===0&&i.delete(t)}}getRegisteredNode(e){let t=this._nodes.get(e.getType());return t===void 0&&X(37,e.name),t}resolveRegisteredNodeAfterReplacements(e){for(;e.replaceWithKlass;)e=this.getRegisteredNode(e.replaceWithKlass);return e}initializeMutationListener(e,t){let n=this._editorState,r=T$(n).get(t.getType());if(!r)return;let i=new Map;for(let e of r.keys())i.set(e,`created`);i.size>0&&e(i,{dirtyLeaves:new Set,prevEditorState:n,updateTags:new Set([`registerMutationListener`])})}registerNodeTransformToKlass(e,t){let n=this.getRegisteredNode(e);return n.transforms.add(t),n}registerNodeTransform(e,t){let n=this.registerNodeTransformToKlass(e,t),r=[n],i=n.replaceWithKlass;if(i!=null){let e=this.registerNodeTransformToKlass(i,t);r.push(e)}return function(e,t){let n=T$(e.getEditorState()),r=[];for(let e of t){let t=n.get(e);t&&r.push(t)}r.length!==0&&e.update(()=>{for(let e of r)for(let t of e.keys()){let e=MQ(t);e&&e.markDirty()}},e._pendingEditorState===null?{tag:PX}:void 0)}(this,r.map(e=>e.klass.getType())),()=>{r.forEach(e=>e.transforms.delete(t))}}hasNode(e){return this._nodes.has(e.getType())}hasNodes(e){return e.every(this.hasNode.bind(this))}dispatchCommand(e,t){return $(this,e,t)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(e){let t=this._rootElement;if(e!==t){let n=t$(this._config.theme,`root`),r=this._pendingEditorState||this._editorState;if(this._rootElement=e,uQ(this,t,e,r),t!==null&&(this._config.disableEvents||nIe(t),n!=null&&t.classList.remove(...n)),e!==null){let t=u$(e),r=e.style;r.userSelect=`text`,r.whiteSpace=`pre-wrap`,r.wordBreak=`break-word`,e.setAttribute(`data-lexical-editor`,`true`),this._window=t,this._dirtyType=2,RJ(this),this._updateTags.add(PX),GZ(this),this._config.disableEvents||function(e,t){let n=e.ownerDocument;cX.set(e,n);let r=lX.get(n)??0;r<1&&n.addEventListener(`selectionchange`,DX),lX.set(n,r+1),e.__lexicalEditor=t;let i=TX(e);for(let n=0;n<rX.length;n++){let[r,a]=rX[n],o=typeof a==`function`?e=>{kX(e)||(OX(e),(t.isEditable()||r===`click`)&&a(e,t))}:e=>{if(kX(e))return;OX(e);let n=t.isEditable();switch(r){case`cut`:return n&&$(t,QY,e);case`copy`:return $(t,ZY,e);case`paste`:return n&&$(t,IY,e);case`dragstart`:return n&&$(t,XY,e);case`dragover`:return n&&$(t,WFe,e);case`dragend`:return n&&$(t,GFe,e);case`focus`:return n&&$(t,JFe,e);case`blur`:return n&&$(t,YFe,e);case`drop`:return n&&$(t,YY,e)}};e.addEventListener(r,o),i.push(()=>{e.removeEventListener(r,o)})}}(e,this),n!=null&&e.classList.add(...n)}else this._window=null,this._updateTags.add(PX),GZ(this);KZ(`root`,this,!1,e,t)}}getElementByKey(e){return this._keyToDOMMap.get(e)||null}getEditorState(){return this._editorState}setEditorState(e,t){e.isEmpty()&&X(38);let n=e;n._readOnly&&(n=rQ(e),n._selection=e._selection?e._selection.clone():null),LJ(this);let r=this._pendingEditorState,i=this._updateTags,a=t===void 0?null:t.tag;r===null||r.isEmpty()||(a!=null&&i.add(a),GZ(this)),this._pendingEditorState=n,this._dirtyType=2,this._dirtyElements.set(`root`,!1),this._compositionKey=null,a!=null&&i.add(a),this._updating||GZ(this)}parseEditorState(e,t){return function(e,t,n){let r=iQ(),i=OZ,a=AZ,o=kZ,s=t._dirtyElements,c=t._dirtyLeaves,l=t._cloneNotNeeded,u=t._dirtyType;t._dirtyElements=new Map,t._dirtyLeaves=new Set,t._cloneNotNeeded=new Set,t._dirtyType=0,OZ=r,AZ=!1,kZ=t,mQ(null);try{let i=t._nodes;UZ(e.root,i),n&&n(),r._readOnly=!0}catch(e){e instanceof Error&&t._onError(e)}finally{t._dirtyElements=s,t._dirtyLeaves=c,t._cloneNotNeeded=l,t._dirtyType=u,OZ=i,AZ=a,kZ=o}return r}(typeof e==`string`?JSON.parse(e):e,this,t)}read(e){return GZ(this),this.getEditorState().read(e,{editor:this})}update(e,t){(function(e,t,n){e._updating?e._updates.push([t,n]):JZ(e,t,n)})(this,e,t)}focus(e,t={}){let n=this._rootElement;n!==null&&(n.setAttribute(`autocapitalize`,`off`),YZ(this,()=>{let r=vZ(),i=RQ();r===null?i.getChildrenSize()!==0&&(t.defaultSelection===`rootStart`?i.selectStart():i.selectEnd()):r.dirty||BQ(r.clone()),c$(`focus`),AIe(()=>{n.removeAttribute(`autocapitalize`),e&&e()})}),this._pendingEditorState===null&&n.removeAttribute(`autocapitalize`))}blur(){let e=this._rootElement;e!==null&&e.blur();let t=_$(this._window);t!==null&&t.removeAllRanges()}isEditable(){return this._editable}setEditable(e){this._editable!==e&&(this._editable=e,KZ(`editable`,this,!0,e))}toJSON(){return{editorState:this._editorState.toJSON()}}};fQ.version=`0.41.0+prod.esm`;var pQ=null;function mQ(e){pQ=e}var CIe=1;function hQ(e,t){let n=gQ(e,t);return n===void 0&&X(30,t),n}function gQ(e,t){return e._nodes.get(t)}var wIe=typeof queueMicrotask==`function`?queueMicrotask:e=>{Promise.resolve().then(e)};function _Q(e){return eQ(FQ(e))}function vQ(e){let t=document.activeElement;if(!v$(t))return!1;let n=t.nodeName;return eQ(FQ(e))&&(n===`INPUT`||n===`TEXTAREA`||t.contentEditable===`true`&&SQ(t)==null)}function yQ(e,t,n){let r=e.getRootElement();try{return r!==null&&r.contains(t)&&r.contains(n)&&t!==null&&!vQ(t)&&xQ(t)===e}catch{return!1}}function bQ(e){return e instanceof fQ}function xQ(e){let t=e;for(;t!=null;){let e=SQ(t);if(bQ(e))return e;t=o$(t)}return null}function SQ(e){return e?e.__lexicalEditor:null}function CQ(e){return eZ(e)||e.isToken()}function wQ(e){return CQ(e)||e.isSegmented()}function TQ(e){return y$(e)&&e.nodeType===3}function TIe(e){return y$(e)&&e.nodeType===9}function EQ(e){let t=e;for(;t!=null;){if(TQ(t))return t;t=t.firstChild}return null}function DQ(e,t,n){let r=kJ[t];if(n!==null&&(e&r)===(n&r))return e;let i=e^r;return t===`subscript`?i&=~kJ.superscript:t===`superscript`?i&=~kJ.subscript:t===`lowercase`?(i&=~kJ.uppercase,i&=~kJ.capitalize):t===`uppercase`?(i&=~kJ.lowercase,i&=~kJ.capitalize):t===`capitalize`&&(i&=~kJ.lowercase,i&=~kJ.uppercase),i}function EIe(e,t){let n=function(){let e=pQ;return pQ=null,e}();if((t||=n&&n.__key)!=null)return void(e.__key=t);FZ(),IZ();let r=RZ(),i=LZ(),a=``+ CIe++;i._nodeMap.set(a,e),Q(e)?r._dirtyElements.set(a,!0):r._dirtyLeaves.add(a),r._cloneNotNeeded.add(a),r._dirtyType=1,e.__key=a}function OQ(e){let t=e.getParent();if(t!==null){let n=e.getWritable(),r=t.getWritable(),i=e.getPreviousSibling(),a=e.getNextSibling(),o=a===null?null:a.__key,s=i===null?null:i.__key,c=i===null?null:i.getWritable(),l=a===null?null:a.getWritable();i===null&&(r.__first=o),a===null&&(r.__last=s),c!==null&&(c.__next=o),l!==null&&(l.__prev=s),n.__prev=null,n.__next=null,n.__parent=null,r.__size--}}function kQ(e){IZ(),MX(e)&&X(323,e.__key,e.__type);let t=e.getLatest(),n=t.__parent,r=LZ(),i=RZ(),a=r._nodeMap,o=i._dirtyElements;n!==null&&function(e,t,n){let r=e;for(;r!==null;){if(n.has(r))return;let e=t.get(r);if(e===void 0)break;n.set(r,!1),r=e.__parent}}(n,a,o);let s=t.__key;i._dirtyType=1,Q(e)?o.set(s,!0):i._dirtyLeaves.add(s)}function AQ(e){FZ();let t=RZ(),n=t._compositionKey;if(e!==n){if(t._compositionKey=e,n!==null){let e=MQ(n);e!==null&&e.getWritable()}if(e!==null){let t=MQ(e);t!==null&&t.getWritable()}}}function jQ(){return PZ()?null:RZ()._compositionKey}function MQ(e,t){let n=(t||LZ())._nodeMap.get(e);return n===void 0?null:n}function NQ(e,t){let n=PQ(e,RZ());return n===void 0?null:MQ(n,t)}function PQ(e,t){return e[`__lexicalKey_${t._key}`]}function FQ(e,t){let n=e;for(;n!=null;){let e=NQ(n,t);if(e!==null)return e;n=o$(n)}return null}function IQ(e){let t=e._decorators,n=Object.assign({},t);return e._pendingDecorators=n,n}function LQ(e){return e.read(()=>RQ().getTextContent())}function RQ(){return zQ(LZ())}function zQ(e){return e._nodeMap.get(`root`)}function BQ(e){FZ();let t=LZ();e!==null&&(e.dirty=!0,e.setCachedNodes(null)),t._selection=e}function VQ(e){let t=RZ(),n=function(e,t){let n=e;for(;n!=null;){let e=PQ(n,t);if(e!==void 0)return e;n=o$(n)}return null}(e,t);return n===null?e===t.getRootElement()?MQ(`root`):null:MQ(n)}function HQ(e){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(e)}function UQ(e){let t=[],n=e;for(;n!==null;)t.push(n),n=n._parentEditor;return t}function WQ(){return Math.random().toString(36).replace(/[^a-z]+/g,``).substring(0,5)}function GQ(e){return TQ(e)?e.nodeValue:null}function KQ(e,t,n){let r=_$(d$(t));if(r===null)return;let i=r.anchorNode,{anchorOffset:a,focusOffset:o}=r;if(i!==null){let t=GQ(i),r=FQ(i);if(t!==null&&XX(r)){if((t===EJ||t===OJ)&&n){let e=n.length;t=n,a=e,o=e}t!==null&&qQ(r,t,a,o,e)}}}function qQ(e,t,n,r,i){let a=e;if(a.isAttached()&&(i||!a.isDirty())){let o=a.isComposing(),s=t;if((o||i)&&(t.endsWith(EJ)&&(s=t.slice(0,-EJ.length)),i)){let e=OJ,t;for(;(t=s.indexOf(e))!==-1;)s=s.slice(0,t)+s.slice(t+e.length),n!==null&&n>t&&(n=Math.max(t,n-e.length)),r!==null&&r>t&&(r=Math.max(t,r-e.length))}let c=a.getTextContent();if(i||s!==c){if(s===``){if(AQ(null),xJ||SJ||TJ)a.remove();else{let e=RZ();setTimeout(()=>{e.update(()=>{a.isAttached()&&a.remove()})},20)}return}let t=a.getParent(),i=yZ(),c=a.getTextContentSize(),l=jQ(),u=a.getKey();if(a.isToken()||l!==null&&u===l&&!o||Z(i)&&(t!==null&&!t.canInsertTextBefore()&&i.anchor.offset===0||i.anchor.key===e.__key&&i.anchor.offset===0&&!a.canInsertTextBefore()&&!o||i.focus.key===e.__key&&i.focus.offset===c&&!a.canInsertTextAfter()&&!o))return void a.markDirty();let d=vZ();if(!Z(d)||n===null||r===null)return void JQ(a,s,d);if(d.setTextNodeRange(a,n,a,r),a.isSegmented()){let e=YX(a.getTextContent());a.replace(e),a=e}JQ(a,s,d)}}}function JQ(e,t,n){if(e.setTextContent(t),Z(n)){let t=e.getKey();for(let r of[`anchor`,`focus`]){let i=n[r];i.type===`text`&&i.key===t&&(i.offset=V$(e,i.offset,`clamp`))}}}function YQ(e,t,n){let r=t[n]||!1;return r===`any`||r===e[n]}function DIe(e,t){return YQ(e,t,`altKey`)&&YQ(e,t,`ctrlKey`)&&YQ(e,t,`shiftKey`)&&YQ(e,t,`metaKey`)}function XQ(e,t,n){if(!DIe(e,n))return!1;if(e.key.toLowerCase()===t.toLowerCase())return!0;if(t.length>1||e.key.length===1&&e.key.charCodeAt(0)<=127)return!1;let r=`Key`+t.toUpperCase();return e.code===r}var ZQ={ctrlKey:!vJ,metaKey:vJ},QQ={altKey:vJ,ctrlKey:!vJ};function $Q(e){return e.key===`Backspace`}function e$(e){return XQ(e,`a`,ZQ)}function OIe(e){let t=RQ();if(Z(e)){let t=e.anchor,n=e.focus,r=t.getNode().getTopLevelElementOrThrow().getParentOrThrow();return t.set(r.getKey(),0,`element`),n.set(r.getKey(),r.getChildrenSize(),`element`),qJ(e),e}{let e=t.select(0,t.getChildrenSize());return BQ(qJ(e)),e}}function t$(e,t){e.__lexicalClassNameCache===void 0&&(e.__lexicalClassNameCache={});let n=e.__lexicalClassNameCache,r=n[t];if(r!==void 0)return r;let i=e[t];if(typeof i==`string`){let e=d1(i);return n[t]=e,e}return i}function n$(e,t,n,r,i){if(n.size===0)return;let a=r.__type,o=r.__key,s=t.get(a);s===void 0&&X(33,a);let c=s.klass,l=e.get(c);l===void 0&&(l=new Map,e.set(c,l));let u=l.get(o),d=u===`destroyed`&&i===`created`;(u===void 0||d)&&l.set(o,d?`updated`:i)}function r$(e,t,n){let r=e.getParent(),i=n,a=e;return r!==null&&(t&&n===0?(i=a.getIndexWithinParent(),a=r):t||n!==a.getChildrenSize()||(i=a.getIndexWithinParent()+1,a=r)),a.getChildAtIndex(t?i-1:i)}function kIe(e,t){let n=e.offset;if(e.type===`element`)return r$(e.getNode(),t,n);{let r=e.getNode();if(t&&n===0||!t&&n===r.getTextContentSize()){let e=t?r.getPreviousSibling():r.getNextSibling();return e===null?r$(r.getParentOrThrow(),t,r.getIndexWithinParent()+(t?0:1)):e}}return null}function i$(e){let t=d$(e).event,n=t&&t.inputType;return n===`insertFromPaste`||n===`insertFromPasteAsQuotation`}function $(e,t,n){return function(e,t,n){let r=UQ(e);for(let i=4;i>=0;i--)for(let a=0;a<r.length;a++){let o=r[a],s=o._commands.get(t);if(s!==void 0){let t=s[i];if(t!==void 0){let r=Array.from(t),i=r.length,a=!1;if(YZ(o,()=>{for(let t=0;t<i;t++)if(r[t](n,e))return void(a=!0)}),a)return a}}}return!1}(e,t,n)}function a$(e,t){let n=e._keyToDOMMap.get(t);return n===void 0&&X(75,t),n}function o$(e){let t=e.assignedSlot||e.parentElement;return b$(t)?t.host:t}function s$(e){return TIe(e)?e:v$(e)?e.ownerDocument:null}function c$(e){FZ(),RZ()._updateTags.add(e)}function AIe(e){FZ(),RZ()._deferred.push(e)}function l$(e,t){let n=e.getParent();for(;n!==null;){if(n.is(t))return!0;n=n.getParent()}return!1}function u$(e){let t=s$(e);return t?t.defaultView:null}function d$(e){let t=e._window;return t===null&&X(78),t}function jIe(e){let t=e.getParentOrThrow();for(;t!==null;){if(f$(t))return t;t=t.getParentOrThrow()}return t}function f$(e){return nQ(e)||Q(e)&&e.isShadowRoot()}function p$(e){let t=RZ(),n=e.getType(),r=gQ(t,n);r===void 0&&X(200,e.constructor.name,n);let{replace:i,replaceWithKlass:a}=r;if(i!==null){let t=i(e),r=t.constructor;return a===null?t instanceof e.constructor&&r!==e.constructor||X(202,r.name,r.getType(),e.constructor.name,n):t instanceof a||X(201,a.name,a.getType(),r.name,r.getType(),e.constructor.name,n),t.__key===e.__key&&X(203,e.constructor.name,n,r.name,r.getType()),t}return e}function m$(e,t){!nQ(e.getParent())||Q(t)||eQ(t)||X(99)}function MIe(e){let t=MQ(e);return t===null&&X(63,e),t}function h$(e){return(eQ(e)||Q(e)&&!e.canBeEmpty())&&!e.isInline()}function g$(e,t,n){n.style.removeProperty(`caret-color`),t._blockCursorElement=null;let r=e.parentElement;r!==null&&r.removeChild(e)}function _$(e){return _J?(e||window).getSelection():null}function NIe(e){let t=u$(e);return t?t.getSelection():null}function v$(e){return y$(e)&&e.nodeType===1}function y$(e){return typeof e==`object`&&!!e&&`nodeType`in e&&typeof e.nodeType==`number`}function b$(e){return y$(e)&&e.nodeType===11}function PIe(e){let t=new RegExp(/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|mark|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var|#text)$/,`i`);return e.nodeName.match(t)!==null}function x$(e){let t=new RegExp(/^(address|article|aside|blockquote|canvas|dd|div|dl|dt|fieldset|figcaption|figure|footer|form|h1|h2|h3|h4|h5|h6|header|hr|li|main|nav|noscript|ol|p|pre|section|table|td|tfoot|ul|video)$/,`i`);return e.nodeName.match(t)!==null}function S$(e){if(eQ(e)&&!e.isInline())return!0;if(!Q(e)||f$(e))return!1;let t=e.getFirstChild(),n=t===null||LX(t)||XX(t)||t.isInline();return!e.isInline()&&!1!==e.canBeEmpty()&&n}function C$(){return RZ()}var w$=new WeakMap,FIe=new Map;function T$(e){if(!e._readOnly&&e.isEmpty())return FIe;e._readOnly||X(192);let t=w$.get(e);return t||(t=function(e){let t=new Map;for(let[n,r]of e._nodeMap){let e=r.__type,i=t.get(e);i||(i=new Map,t.set(e,i)),i.set(n,r)}return t}(e),w$.set(e,t)),t}function E$(e){let t=e.constructor.clone(e);return t.afterCloneFrom(e),t}function IIe(e){return(t=E$(e))[jX]=!0,t;var t}function LIe(e,t){let n=parseInt(e.style.paddingInlineStart,10)||0,r=Math.round(n/40);t.setIndent(r)}function RIe(e){return!0===e.__lexicalUnmanaged}function D$(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)&&e[t]!==NX[t]}function O$(e){let t=jJ in e.prototype?e.prototype[jJ]():void 0,n=function(e){if(!(e===NX||e.prototype instanceof NX)){let t=`<unknown>`,n=`<unknown>`;try{t=e.getType()}catch{}try{fQ.version&&(n=JSON.parse(fQ.version))}catch{}X(290,e.name,t,n)}return e===$Z||e===ZZ||e===NX}(e),r=!n&&D$(e,`getType`)?e.getType():void 0,i,a=r;if(t)if(r)i=t[r];else for(let[e,n]of Object.entries(t))a=e,i=n;if(!n&&a&&(D$(e,`getType`)||(e.getType=()=>a),D$(e,`clone`)||(e.clone=t=>(mQ(t),new e)),D$(e,`importJSON`)||(e.importJSON=i&&i.$importJSON||(t=>new e().updateFromJSON(t))),!D$(e,`importDOM`)&&i)){let{importDOM:t}=i;t&&(e.importDOM=()=>t)}return{ownNodeConfig:i,ownNodeType:a}}function zIe(e){let t=C$();return FZ(),new(t.resolveRegisteredNodeAfterReplacements(t.getRegisteredNode(e))).klass}var k$=(e,t)=>{let n=e;for(;n!=null&&!nQ(n);){if(t(n))return n;n=n.getParent()}return null},BIe={next:`previous`,previous:`next`},A$=class{origin;constructor(e){this.origin=e}[Symbol.iterator](){return q$({hasNext:L$,initial:this.getAdjacentCaret(),map:e=>e,step:e=>e.getAdjacentCaret()})}getAdjacentCaret(){return z$(this.getNodeAtCaret(),this.direction)}getSiblingCaret(){return z$(this.origin,this.direction)}remove(){let e=this.getNodeAtCaret();return e&&e.remove(),this}replaceOrInsert(e,t){let n=this.getNodeAtCaret();return e.is(this.origin)||e.is(n)||(n===null?this.insert(e):n.replace(e,t)),this}splice(e,t,n=`next`){let r=n===this.direction?t:Array.from(t).reverse(),i=this,a=this.getParentAtCaret(),o=new Map;for(let t=i.getAdjacentCaret();t!==null&&o.size<e;t=t.getAdjacentCaret()){let e=t.origin.getWritable();o.set(e.getKey(),e)}for(let e of r){if(o.size>0){let t=i.getNodeAtCaret();if(t){if(o.delete(t.getKey()),o.delete(e.getKey()),!(t.is(e)||i.origin.is(e))){let n=e.getParent();n&&n.is(a)&&e.remove(),t.replace(e)}}else t===null&&X(263,Array.from(o).join(` `))}else i.insert(e);i=z$(e,this.direction)}for(let e of o.values())e.remove();return this}},j$=class e extends A${type=`child`;getLatest(){let e=this.origin.getLatest();return e===this.origin?this:U$(e,this.direction)}getParentCaret(e=`root`){return z$(N$(this.getParentAtCaret(),e),this.direction)}getFlipped(){let e=M$(this.direction);return z$(this.getNodeAtCaret(),e)||U$(this.origin,e)}getParentAtCaret(){return this.origin}getChildCaret(){return this}isSameNodeCaret(t){return t instanceof e&&this.direction===t.direction&&this.origin.is(t.origin)}isSamePointCaret(e){return this.isSameNodeCaret(e)}},VIe={root:nQ,shadowRoot:f$};function M$(e){return BIe[e]}function N$(e,t=`root`){return VIe[t](e)?null:e}var P$=class e extends A${type=`sibling`;getLatest(){let e=this.origin.getLatest();return e===this.origin?this:z$(e,this.direction)}getSiblingCaret(){return this}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return Q(this.origin)?U$(this.origin,this.direction):null}getParentCaret(e=`root`){return z$(N$(this.getParentAtCaret(),e),this.direction)}getFlipped(){let e=M$(this.direction);return z$(this.getNodeAtCaret(),e)||U$(this.origin.getParentOrThrow(),e)}isSamePointCaret(t){return t instanceof e&&this.direction===t.direction&&this.origin.is(t.origin)}isSameNodeCaret(t){return(t instanceof e||t instanceof F$)&&this.direction===t.direction&&this.origin.is(t.origin)}},F$=class e extends A${type=`text`;offset;constructor(e,t){super(e),this.offset=t}getLatest(){let e=this.origin.getLatest();return e===this.origin?this:B$(e,this.direction,this.offset)}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return null}getParentCaret(e=`root`){return z$(N$(this.getParentAtCaret(),e),this.direction)}getFlipped(){return B$(this.origin,M$(this.direction),this.offset)}isSamePointCaret(t){return t instanceof e&&this.direction===t.direction&&this.origin.is(t.origin)&&this.offset===t.offset}isSameNodeCaret(t){return(t instanceof P$||t instanceof e)&&this.direction===t.direction&&this.origin.is(t.origin)}getSiblingCaret(){return z$(this.origin,this.direction)}};function I$(e){return e instanceof F$}function L$(e){return e instanceof P$}function R$(e){return e instanceof j$}var HIe={next:class extends F${direction=`next`;getNodeAtCaret(){return this.origin.getNextSibling()}insert(e){return this.origin.insertAfter(e),this}},previous:class extends F${direction=`previous`;getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(e){return this.origin.insertBefore(e),this}}},UIe={next:class extends P${direction=`next`;getNodeAtCaret(){return this.origin.getNextSibling()}insert(e){return this.origin.insertAfter(e),this}},previous:class extends P${direction=`previous`;getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(e){return this.origin.insertBefore(e),this}}},WIe={next:class extends j${direction=`next`;getNodeAtCaret(){return this.origin.getFirstChild()}insert(e){return this.origin.splice(0,0,[e]),this}},previous:class extends j${direction=`previous`;getNodeAtCaret(){return this.origin.getLastChild()}insert(e){return this.origin.splice(this.origin.getChildrenSize(),0,[e]),this}}};function z$(e,t){return e?new UIe[t](e):null}function B$(e,t,n){return e?new HIe[t](e,V$(e,n)):null}function V$(e,t,n=`error`){let r=e.getTextContentSize(),i=t===`next`?r:t===`previous`?0:t;return(i<0||i>r)&&(n!==`clamp`&&gJ(284,String(t),String(r),e.getKey()),i=i<0?0:r),i}function H$(e,t){return new qIe(e,t)}function U$(e,t){return Q(e)?new WIe[t](e):null}function GIe(e){return e&&e.getChildCaret()||e}function W$(e){return e&&GIe(e.getAdjacentCaret())}var KIe=class e{type=`node-caret-range`;direction;anchor;focus;constructor(e,t,n){this.anchor=e,this.focus=t,this.direction=n}getLatest(){let t=this.anchor.getLatest(),n=this.focus.getLatest();return t===this.anchor&&n===this.focus?this:new e(t,n,this.direction)}isCollapsed(){return this.anchor.isSamePointCaret(this.focus)}getTextSlices(){let e=e=>{let t=this[e].getLatest();return I$(t)?function(e,t){let{direction:n,origin:r}=e;return H$(e,V$(r,t===`focus`?M$(n):n)-e.offset)}(t,e):null},t=e(`anchor`),n=e(`focus`);if(t&&n){let{caret:e}=t,{caret:r}=n;if(e.isSameNodeCaret(r))return[H$(e,r.offset-e.offset),null]}return[t,n]}iterNodeCarets(e=`root`){let t=I$(this.anchor)?this.anchor.getSiblingCaret():this.anchor.getLatest(),n=this.focus.getLatest(),r=I$(n),i=t=>t.isSameNodeCaret(n)?null:W$(t)||t.getParentCaret(e);return q$({hasNext:e=>e!==null&&!(r&&n.isSameNodeCaret(e)),initial:t.isSameNodeCaret(n)?null:i(t),map:e=>e,step:i})}[Symbol.iterator](){return this.iterNodeCarets(`root`)}},qIe=class{type=`slice`;caret;distance;constructor(e,t){this.caret=e,this.distance=t}getSliceIndices(){let{distance:e,caret:{offset:t}}=this,n=t+e;return n<t?[n,t]:[t,n]}getTextContent(){let[e,t]=this.getSliceIndices();return this.caret.origin.getTextContent().slice(e,t)}getTextContentSize(){return Math.abs(this.distance)}removeTextSlice(){let{caret:{origin:e,direction:t}}=this,[n,r]=this.getSliceIndices(),i=e.getTextContent();return B$(e.setTextContent(i.slice(0,n)+i.slice(r)),t,n)}};function G$(e){return K$(e,z$(RQ(),e.direction))}function JIe(e){return K$(e,e)}function K$(e,t){return e.direction!==t.direction&&X(265),new KIe(e,t,e.direction)}function q$(e){let{initial:t,hasNext:n,step:r,map:i}=e,a=t;return{[Symbol.iterator](){return this},next(){if(!n(a))return{done:!0,value:void 0};let e={done:!1,value:i(a)};return a=r(a),e}}}function J$(e,t){let n=Q$(e.origin,t.origin);switch(n===null&&X(275,e.origin.getKey(),t.origin.getKey()),n.type){case`same`:{let n=e.type===`text`,r=t.type===`text`;return n&&r?function(e,t){return Math.sign(e-t)}(e.offset,t.offset):e.type===t.type?0:n?-1:r?1:e.type===`child`?-1:1}case`ancestor`:return e.type===`child`?-1:1;case`descendant`:return t.type===`child`?1:-1;case`branch`:return Y$(n)}}function Y$(e){let{a:t,b:n}=e,r=t.__key,i=n.__key,a=t,o=n;for(;a&&o;a=a.getNextSibling(),o=o.getNextSibling()){if(a.__key===i)return-1;if(o.__key===r)return 1}return a===null?1:-1}function X$(e,t){return t.is(e)}function Z$(e){return Q(e)?[e.getLatest(),null]:[e.getParent(),e.getLatest()]}function Q$(e,t){if(e.is(t))return{commonAncestor:e,type:`same`};let n=new Map;for(let[t,r]=Z$(e);t;r=t,t=t.getParent())n.set(t,r);for(let[r,i]=Z$(t);r;i=r,r=r.getParent()){let a=n.get(r);if(a!==void 0)return a===null?(X$(e,r)||X(276),{commonAncestor:r,type:`ancestor`}):i===null?(X$(t,r)||X(277),{commonAncestor:r,type:`descendant`}):((Q(a)||X$(e,a))&&(Q(i)||X$(t,i))&&r.is(a.getParent())&&r.is(i.getParent())||X(278),{a,b:i,commonAncestor:r,type:`branch`})}return null}function $$(e,t){let{type:n,key:r,offset:i}=e,a=MIe(e.key);return n===`text`?(XX(a)||X(266,a.getType(),r),B$(a,t,i)):(Q(a)||X(267,a.getType(),r),ZIe(a,e.offset,t))}function e1(e,t){let{origin:n,direction:r}=t,i=r===`next`;I$(t)?e.set(n.getKey(),t.offset,`text`):L$(t)?XX(n)?e.set(n.getKey(),V$(n,r),`text`):e.set(n.getParentOrThrow().getKey(),n.getIndexWithinParent()+(i?1:0),`element`):(R$(t)&&Q(n)||X(268),e.set(n.getKey(),i?0:n.getChildrenSize(),`element`))}function YIe(e){let t=vZ(),n=Z(t)?t:mIe();return t1(n,e),BQ(n),n}function t1(e,t){e1(e.anchor,t.anchor),e1(e.focus,t.focus)}function n1(e){let{anchor:t,focus:n}=e,r=$$(t,`next`),i=$$(n,`next`),a=J$(r,i)<=0?`next`:`previous`;return K$(c1(r,a),c1(i,a))}function r1(e){let{direction:t,origin:n}=e,r=z$(n,M$(t)).getNodeAtCaret();return r?z$(r,t):U$(n.getParentOrThrow(),t)}function i1(e,t=`root`){let n=[e];for(let r=R$(e)?e.getParentCaret(t):e.getSiblingCaret();r!==null;r=r.getParentCaret(t))n.push(r1(r));return n}function a1(e){return!!e&&e.origin.isAttached()}function XIe(e,t=`removeEmptySlices`){if(e.isCollapsed())return e;let n=`root`,r=`next`,i=t,a=l1(e,r),o=i1(a.anchor,n),s=i1(a.focus.getFlipped(),n),c=new Set,l=[];for(let e of a.iterNodeCarets(n))if(R$(e))c.add(e.origin.getKey());else if(L$(e)){let{origin:t}=e;Q(t)&&!c.has(t.getKey())||l.push(t)}for(let e of l)e.remove();for(let e of a.getTextSlices()){if(!e)continue;let{origin:t}=e.caret,n=t.getTextContentSize(),a=r1(z$(t,r)),c=t.getMode();if(Math.abs(e.distance)===n&&i===`removeEmptySlices`||c===`token`&&e.distance!==0)a.remove();else if(e.distance!==0){i=`removeEmptySlices`;let t=e.removeTextSlice(),n=e.caret.origin;if(c===`segmented`){let e=t.origin,n=YX(e.getTextContent()).setStyle(e.getStyle()).setFormat(e.getFormat());a.replaceOrInsert(n),t=B$(n,r,t.offset)}n.is(o[0].origin)&&(o[0]=t),n.is(s[0].origin)&&(s[0]=t.getFlipped())}}let u,d;for(let e of o)if(a1(e)){u=o1(e);break}for(let e of s)if(a1(e)){d=o1(e);break}let f=function(e,t,n){if(!e||!t)return null;let r=e.getParentAtCaret(),i=t.getParentAtCaret();if(!r||!i)return null;let a=r.getParents().reverse();a.push(r);let o=i.getParents().reverse();o.push(i);let s=Math.min(a.length,o.length),c;for(c=0;c<s&&a[c]===o[c];c++);let l=(e,t)=>{let n;for(let r=c;r<e.length;r++){let i=e[r];if(f$(i))return;!n&&t(i)&&(n=i)}return n},u=l(a,S$),d=u&&l(o,e=>n.has(e.getKey())&&S$(e));return u&&d?[u,d]:null}(u,d,c);if(f){let[e,t]=f;U$(e,`previous`).splice(0,t.getChildren());let n=t.getParent();for(t.remove(!0);n&&n.isEmpty();){let e=n;n=n.getParent(),e.remove(!0)}}let p=[u,d,...o,...s].find(a1);if(p)return JIe(c1(o1(p),e.direction));X(269,JSON.stringify(o.map(e=>e.origin.__key)))}function o1(e){let t=function(e){let t=e;for(;R$(t);){let e=W$(t);if(!R$(e))break;t=e}return t}(e.getLatest()),{direction:n}=t;if(XX(t.origin))return I$(t)?t:B$(t.origin,n,n);let r=t.getAdjacentCaret();return L$(r)&&XX(r.origin)?B$(r.origin,n,M$(n)):t}function s1(e){return I$(e)&&e.offset!==V$(e.origin,e.direction)}function c1(e,t){return e.direction===t?e:e.getFlipped()}function l1(e,t){return e.direction===t?e:K$(c1(e.focus,t),c1(e.anchor,t))}function ZIe(e,t,n){let r=U$(e,`next`);for(let e=0;e<t;e++){let e=r.getAdjacentCaret();if(e===null)break;r=e}return c1(r,n)}function u1(e){return e}function QIe(e){return e}function $Ie(e,t){if(!t||e===t)return e;for(let n in t)if(e[n]!==t[n])return{...e,...t};return e}function d1(...e){let t=[];for(let n of e)if(n&&typeof n==`string`)for(let[e]of n.matchAll(/\S+/g))t.push(e);return t}function eLe(e,...t){let n=d1(...t);n.length>0&&e.classList.add(...n)}function f1(...e){return()=>{for(let t=e.length-1;t>=0;t--)e[t]();e.length=0}}var p1=(0,I.createContext)(null);function tLe(e,t){let n=null;return e!=null&&(n=e[1]),{getTheme:function(){return t??(n==null?null:n.getTheme())}}}function m1(){let e=(0,I.useContext)(p1);return e??function(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(8),e}var h1=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,nLe=h1?I.useLayoutEffect:I.useEffect,g1={tag:PX};function rLe({initialConfig:e,children:t}){let n=(0,I.useMemo)(()=>{let{theme:t,namespace:n,nodes:r,onError:i,editorState:a,html:o}=e,s=tLe(null,t),c=dQ({editable:e.editable,html:o,namespace:n,nodes:r,onError:e=>i(e,c),theme:t});return function(e,t){if(t!==null){if(t===void 0)e.update(()=>{let t=RQ();if(t.isEmpty()){let n=cQ();t.append(n);let r=h1?document.activeElement:null;(vZ()!==null||r!==null&&r===e.getRootElement())&&n.select()}},g1);else if(t!==null)switch(typeof t){case`string`:{let n=e.parseEditorState(t);e.setEditorState(n,g1);break}case`object`:e.setEditorState(t,g1);break;case`function`:e.update(()=>{RQ().isEmpty()&&t(e)},g1)}}}(c,a),[c,s]},[]);return nLe(()=>{let t=e.editable,[r]=n;r.setEditable(t===void 0||t)},[]),(0,L.jsx)(p1.Provider,{value:n,children:t})}var iLe=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0?I.useLayoutEffect:I.useEffect;function aLe(e){return{initialValueFn:()=>e.isEditable(),subscribe:t=>e.registerEditableListener(t)}}function oLe(){return function(e){let[t]=m1(),n=(0,I.useMemo)(()=>e(t),[t,e]),[r,i]=(0,I.useState)(()=>n.initialValueFn()),a=(0,I.useRef)(r);return iLe(()=>{let{initialValueFn:e,subscribe:t}=n,r=e();return a.current!==r&&(a.current=r,i(r)),t(e=>{a.current=e,i(e)})},[n,e]),r}(aLe)}function _1(e){let t=C$().getElementByKey(e.getKey());if(t===null)return null;let n=t.ownerDocument.defaultView;return n===null?null:n.getComputedStyle(t)}function sLe(e){return _1(nQ(e)?e:e.getParentOrThrow())}function cLe(e,t,n=`self`){let r=e.getStartEndPoints();if(t.isSelected(e)&&!wQ(t)&&r!==null){let[i,a]=r,o=e.isBackward(),s=i.getNode(),c=a.getNode(),l=t.is(s),u=t.is(c);if(l||u){let[r,i]=cZ(e),a=s.is(c),l=t.is(o?c:s),u=t.is(o?s:c),d,f=0;a?(f=r>i?i:r,d=r>i?r:i):l?(f=o?i:r,d=void 0):u&&(f=0,d=o?r:i);let p=t.__text.slice(f,d);p!==t.__text&&(n===`clone`&&(t=IIe(t)),t.__text=p)}}return t}function v1(e){let t=y1(e);return t!==null&&t.writingMode===`vertical-rl`}function y1(e){let t=e.anchor.getNode();return Q(t)?_1(t):sLe(t)}function b1(e,t){let n=v1(e)?!t:t;x1(e)&&(n=!n);let r=$$(e.focus,n?`previous`:`next`);if(s1(r))return!1;for(let e of G$(r)){if(R$(e))return!e.origin.isInline();if(!Q(e.origin)){if(eQ(e.origin))return!0;break}}return!1}function lLe(e,t,n,r){e.modify(t?`extend`:`move`,n,r)}function x1(e){let t=y1(e);return t!==null&&t.direction===`rtl`}function S1(e,t,n){let r=x1(e),i;i=v1(e)||r?!n:n,lLe(e,t,i,`character`)}var C1=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,uLe=C1&&`documentMode`in document?document.documentMode:null;C1&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),C1&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),!(!C1||!(`InputEvent`in window)||uLe)&&`getTargetRanges`in new window.InputEvent(`input`),C1&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),C1&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&window.MSStream,C1&&/Android/.test(navigator.userAgent),C1&&/^(?=.*Chrome).*/i.test(navigator.userAgent),C1&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent);function w1(e,t){return e!==null&&Object.getPrototypeOf(e).constructor.name===t.name}var dLe=Symbol.for(`preact-signals`);function T1(){if(k1>1)return void k1--;let e,t=!1;for(;D1!==void 0;){let n=D1;for(D1=void 0,A1++;n!==void 0;){let r=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&P1(n))try{n.c()}catch(n){t||=(e=n,!0)}n=r}}if(A1=0,k1--,t)throw e}var E1,D1;function O1(e){let t=E1;E1=void 0;try{return e()}finally{E1=t}}var k1=0,A1=0,j1=0;function M1(e){if(E1===void 0)return;let t=e.n;return t===void 0||t.t!==E1?(t={i:0,S:e,p:E1.s,n:void 0,t:E1,e:void 0,x:void 0,r:t},E1.s!==void 0&&(E1.s.n=t),E1.s=t,e.n=t,32&E1.f&&e.S(t),t):t.i===-1?(t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=E1.s,t.n=void 0,E1.s.n=t,E1.s=t),t):void 0}function N1(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}function P1(e){for(let t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function F1(e){for(let t=e.s;t!==void 0;t=t.n){let n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function I1(e){let t,n=e.s;for(;n!==void 0;){let e=n.p;n.i===-1?(n.S.U(n),e!==void 0&&(e.n=n.n),n.n!==void 0&&(n.n.p=e)):t=n,n.S.n=n.r,n.r!==void 0&&(n.r=void 0),n=e}e.s=t}function L1(e,t){N1.call(this,void 0),this.x=e,this.s=void 0,this.g=j1-1,this.f=4,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}function R1(e){let t=e.u;if(e.u=void 0,typeof t==`function`){k1++;let n=E1;E1=void 0;try{t()}catch(t){throw e.f&=-2,e.f|=8,z1(e),t}finally{E1=n,T1()}}}function z1(e){for(let t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,R1(e)}function fLe(e){if(E1!==this)throw Error(`Out-of-order effect`);I1(this),E1=e,this.f&=-2,8&this.f&&z1(this),T1()}function B1(e,t){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=t?.name}function pLe(e,t){let n=new B1(e,t);try{n.c()}catch(e){throw n.d(),e}let r=n.d.bind(n);return r[Symbol.dispose]=r,r}N1.prototype.brand=dLe,N1.prototype.h=function(){return!0},N1.prototype.S=function(e){let t=this.t;t!==e&&e.e===void 0&&(e.x=t,this.t=e,t===void 0?O1(()=>{var e;(e=this.W)==null||e.call(this)}):t.e=e)},N1.prototype.U=function(e){if(this.t!==void 0){let t=e.e,n=e.x;t!==void 0&&(t.x=n,e.e=void 0),n!==void 0&&(n.e=t,e.x=void 0),e===this.t&&(this.t=n,n===void 0&&O1(()=>{var e;(e=this.Z)==null||e.call(this)}))}},N1.prototype.subscribe=function(e){return pLe(()=>{let t=this.value,n=E1;E1=void 0;try{e(t)}finally{E1=n}},{name:`sub`})},N1.prototype.valueOf=function(){return this.value},N1.prototype.toString=function(){return this.value+``},N1.prototype.toJSON=function(){return this.value},N1.prototype.peek=function(){let e=E1;E1=void 0;try{return this.value}finally{E1=e}},Object.defineProperty(N1.prototype,`value`,{get(){let e=M1(this);return e!==void 0&&(e.i=this.i),this.v},set(e){if(e!==this.v){if(A1>100)throw Error(`Cycle detected`);this.v=e,this.i++,j1++,k1++;try{for(let e=this.t;e!==void 0;e=e.x)e.t.N()}finally{T1()}}}}),L1.prototype=new N1,L1.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===j1))return!0;if(this.g=j1,this.f|=1,this.i>0&&!P1(this))return this.f&=-2,!0;let e=E1;try{F1(this),E1=this;let e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return E1=e,I1(this),this.f&=-2,!0},L1.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(let e=this.s;e!==void 0;e=e.n)e.S.S(e)}N1.prototype.S.call(this,e)},L1.prototype.U=function(e){if(this.t!==void 0&&(N1.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(let e=this.s;e!==void 0;e=e.n)e.S.U(e)}},L1.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let e=this.t;e!==void 0;e=e.x)e.t.N()}},Object.defineProperty(L1.prototype,`value`,{get(){if(1&this.f)throw Error(`Cycle detected`);let e=M1(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}}),B1.prototype.c=function(){let e=this.S();try{if(8&this.f||this.x===void 0)return;let e=this.x();typeof e==`function`&&(this.u=e)}finally{e()}},B1.prototype.S=function(){if(1&this.f)throw Error(`Cycle detected`);this.f|=1,this.f&=-9,R1(this),F1(this),k1++;let e=E1;return E1=this,fLe.bind(this,e)},B1.prototype.N=function(){2&this.f||(this.f|=2,this.o=D1,D1=this)},B1.prototype.d=function(){this.f|=8,1&this.f||z1(this)},B1.prototype.dispose=function(){this.d()};function mLe(e){return(typeof e.nodes==`function`?e.nodes():e.nodes)||[]}OFe(`format`,{parse:e=>typeof e==`number`?e:0});function V1(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function H1(e,t){if(e&&t&&!Array.isArray(t)&&typeof e==`object`&&typeof t==`object`){let n=e,r=t;for(let e in r)n[e]=H1(n[e],r[e]);return e}return t}var U1=0,W1=1,G1=2,K1=3,q1=4,J1=5,Y1=6,X1=7;function Z1(e){return e.id===U1}function Q1(e){return e.id===G1}function hLe(e){return function(e){return e.id===W1}(e)||V1(305,String(e.id),String(W1)),Object.assign(e,{id:G1})}var gLe=new Set,_Le=class{builder;configs;_dependency;_peerNameSet;extension;state;_signal;constructor(e,t){this.builder=e,this.extension=t,this.configs=new Set,this.state={id:U1}}mergeConfigs(){let e=this.extension.config||{},t=this.extension.mergeConfig?this.extension.mergeConfig.bind(this.extension):$Ie;for(let n of this.configs)e=t(e,n);return e}init(e){let t=this.state;Q1(t)||V1(306,String(t.id));let n={getDependency:this.getInitDependency.bind(this),getDirectDependentNames:this.getDirectDependentNames.bind(this),getPeer:this.getInitPeer.bind(this),getPeerNameSet:this.getPeerNameSet.bind(this)},r={...n,getDependency:this.getDependency.bind(this),getInitResult:this.getInitResult.bind(this),getPeer:this.getPeer.bind(this)},i=function(e,t,n){return Object.assign(e,{config:t,id:K1,registerState:n})}(t,this.mergeConfigs(),n),a;this.state=i,this.extension.init&&(a=this.extension.init(e,i.config,n)),this.state=function(e,t,n){return Object.assign(e,{id:q1,initResult:t,registerState:n})}(i,a,r)}build(e){let t=this.state,n;t.id!==q1&&V1(307,String(t.id),String(J1)),this.extension.build&&(n=this.extension.build(e,t.config,t.registerState));let r={...t.registerState,getOutput:()=>n,getSignal:this.getSignal.bind(this)};this.state=function(e,t,n){return Object.assign(e,{id:J1,output:t,registerState:n})}(t,n,r)}register(e,t){this._signal=t;let n=this.state;n.id!==J1&&V1(308,String(n.id),String(J1));let r=this.extension.register&&this.extension.register(e,n.config,n.registerState);return this.state=function(e){return Object.assign(e,{id:Y1})}(n),()=>{let e=this.state;e.id!==X1&&V1(309,String(n.id),String(X1)),this.state=function(e){return Object.assign(e,{id:J1})}(e),r&&r()}}afterRegistration(e){let t=this.state,n;return t.id!==Y1&&V1(310,String(t.id),String(Y1)),this.extension.afterRegistration&&(n=this.extension.afterRegistration(e,t.config,t.registerState)),this.state=function(e){return Object.assign(e,{id:X1})}(t),n}getSignal(){return this._signal===void 0&&V1(311),this._signal}getInitResult(){this.extension.init===void 0&&V1(312,this.extension.name);let e=this.state;return function(e){return e.id>=q1}(e)||V1(313,String(e.id),String(q1)),e.initResult}getInitPeer(e){let t=this.builder.extensionNameMap.get(e);return t?t.getExtensionInitDependency():void 0}getExtensionInitDependency(){let e=this.state;return function(e){return e.id>=K1}(e)||V1(314,String(e.id),String(K1)),{config:e.config}}getPeer(e){let t=this.builder.extensionNameMap.get(e);return t?t.getExtensionDependency():void 0}getInitDependency(e){let t=this.builder.getExtensionRep(e);return t===void 0&&V1(315,this.extension.name,e.name),t.getExtensionInitDependency()}getDependency(e){let t=this.builder.getExtensionRep(e);return t===void 0&&V1(315,this.extension.name,e.name),t.getExtensionDependency()}getState(){let e=this.state;return function(e){return e.id>=X1}(e)||V1(316,String(e.id),String(X1)),e}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||gLe}getPeerNameSet(){let e=this._peerNameSet;return e||(e=new Set((this.extension.peerDependencies||[]).map(([e])=>e)),this._peerNameSet=e),e}getExtensionDependency(){if(!this._dependency){let e=this.state;(function(e){return e.id>=J1})(e)||V1(317,this.extension.name),this._dependency={config:e.config,init:e.initResult,output:e.output}}return this._dependency}},$1={tag:PX};function vLe(){let e=RQ();e.isEmpty()&&e.append(cQ())}var yLe=u1({config:QIe({setOptions:$1,updateOptions:$1}),init:({$initialEditorState:e=vLe})=>({$initialEditorState:e,initialized:!1}),afterRegistration(e,{updateOptions:t,setOptions:n},r){let i=r.getInitResult();if(!i.initialized){i.initialized=!0;let{$initialEditorState:r}=i;if(yIe(r))e.setEditorState(r,n);else if(typeof r==`function`)e.update(()=>{r(e)},t);else if(r&&(typeof r==`string`||typeof r==`object`)){let t=e.parseEditorState(r);e.setEditorState(t,n)}}return()=>{}},name:`@lexical/extension/InitialState`,nodes:[tQ,GX,FX,QX,sQ]}),e0=Symbol.for(`@lexical/extension/LexicalBuilder`);function t0(){}function bLe(e){throw e}function n0(e){return Array.isArray(e)?e:[e]}var r0=`0.41.0+prod.esm`,xLe=class e{roots;extensionNameMap;outgoingConfigEdges;incomingEdges;conflicts;_sortedExtensionReps;PACKAGE_VERSION;constructor(e){this.outgoingConfigEdges=new Map,this.incomingEdges=new Map,this.extensionNameMap=new Map,this.conflicts=new Map,this.PACKAGE_VERSION=r0,this.roots=e;for(let t of e)this.addExtension(t)}static fromExtensions(t){let n=[n0(yLe)];for(let e of t)n.push(n0(e));return new e(n)}static maybeFromEditor(t){let n=t[e0];return n&&(n.PACKAGE_VERSION!==r0&&V1(292,n.PACKAGE_VERSION,r0),n instanceof e||V1(293)),n}static fromEditor(t){let n=e.maybeFromEditor(t);return n===void 0&&V1(294),n}constructEditor(){let{$initialEditorState:e,onError:t,...n}=this.buildCreateEditorArgs(),r=Object.assign(dQ({...n,...t?{onError:e=>{t(e,r)}}:{}}),{[e0]:this});for(let e of this.sortedExtensionReps())e.build(r);return r}buildEditor(){let e=t0;function t(){try{e()}finally{e=t0}}let n=Object.assign(this.constructEditor(),{dispose:t,[Symbol.dispose]:t});return e=f1(this.registerEditor(n),()=>n.setRootElement(null)),n}hasExtensionByName(e){return this.extensionNameMap.has(e)}getExtensionRep(e){let t=this.extensionNameMap.get(e.name);if(t)return t.extension!==e&&V1(295,e.name),t}addEdge(e,t,n){let r=this.outgoingConfigEdges.get(e);r?r.set(t,n):this.outgoingConfigEdges.set(e,new Map([[t,n]]));let i=this.incomingEdges.get(t);i?i.add(e):this.incomingEdges.set(t,new Set([e]))}addExtension(e){this._sortedExtensionReps!==void 0&&V1(296);let[t]=n0(e);typeof t.name!=`string`&&V1(297,typeof t.name);let n=this.extensionNameMap.get(t.name);if(n!==void 0&&n.extension!==t&&V1(298,t.name),!n){n=new _Le(this,t),this.extensionNameMap.set(t.name,n);let e=this.conflicts.get(t.name);typeof e==`string`&&V1(299,t.name,e);for(let e of t.conflictsWith||[])this.extensionNameMap.has(e)&&V1(299,t.name,e),this.conflicts.set(e,t.name);for(let e of t.dependencies||[]){let n=n0(e);this.addEdge(t.name,n[0].name,n.slice(1)),this.addExtension(n)}for(let[e,n]of t.peerDependencies||[])this.addEdge(t.name,e,n?[n]:[])}}sortedExtensionReps(){if(this._sortedExtensionReps)return this._sortedExtensionReps;let e=[],t=(n,r)=>{let i=n.state;if(Q1(i))return;let a=n.extension.name;var o;Z1(i)||V1(300,a,r||`[unknown]`),Z1(o=i)||V1(304,String(o.id),String(U1)),i=Object.assign(o,{id:W1}),n.state=i;let s=this.outgoingConfigEdges.get(a);if(s)for(let e of s.keys()){let n=this.extensionNameMap.get(e);n&&t(n,a)}i=hLe(i),n.state=i,e.push(n)};for(let e of this.extensionNameMap.values())Z1(e.state)&&t(e);for(let t of e)for(let[e,n]of this.outgoingConfigEdges.get(t.extension.name)||[])if(n.length>0){let t=this.extensionNameMap.get(e);if(t)for(let e of n)t.configs.add(e)}for(let[e,...t]of this.roots)if(t.length>0){let n=this.extensionNameMap.get(e.name);n===void 0&&V1(301,e.name);for(let e of t)n.configs.add(e)}return this._sortedExtensionReps=e,this._sortedExtensionReps}registerEditor(e){let t=this.sortedExtensionReps(),n=new AbortController,r=[()=>n.abort()],i=n.signal;for(let n of t){let t=n.register(e,i);t&&r.push(t)}for(let n of t){let t=n.afterRegistration(e);t&&r.push(t)}return f1(...r)}buildCreateEditorArgs(){let e={},t=new Set,n=new Map,r=new Map,i={},a={},o=this.sortedExtensionReps();for(let s of o){let{extension:o}=s;if(o.onError!==void 0&&(e.onError=o.onError),o.disableEvents!==void 0&&(e.disableEvents=o.disableEvents),o.parentEditor!==void 0&&(e.parentEditor=o.parentEditor),o.editable!==void 0&&(e.editable=o.editable),o.namespace!==void 0&&(e.namespace=o.namespace),o.$initialEditorState!==void 0&&(e.$initialEditorState=o.$initialEditorState),o.nodes)for(let e of mLe(o)){if(typeof e!=`function`){let t=n.get(e.replace);t&&V1(302,o.name,e.replace.name,t.extension.name),n.set(e.replace,s)}t.add(e)}if(o.html){if(o.html.export)for(let[e,t]of o.html.export.entries())r.set(e,t);o.html.import&&Object.assign(i,o.html.import)}o.theme&&H1(a,o.theme)}Object.keys(a).length>0&&(e.theme=a),t.size&&(e.nodes=[...t]);let s=Object.keys(i).length>0,c=r.size>0;(s||c)&&(e.html={},s&&(e.html.import=i),c&&(e.html.export=r));for(let t of o)t.init(e);return e.onError||=bLe,e}},SLe=class e extends $Z{static getType(){return`horizontalrule`}static clone(t){return new e(t.__key)}static importJSON(e){return i0().updateFromJSON(e)}static importDOM(){return{hr:()=>({conversion:CLe,priority:0})}}exportDOM(){return{element:document.createElement(`hr`)}}createDOM(e){let t=document.createElement(`hr`);return eLe(t,e.theme.hr),t}getTextContent(){return`
186
- `}isInline(){return!1}updateDOM(){return!1}};function CLe(){return{node:i0()}}function i0(){return zIe(SLe)}var wLe=u1({name:`@lexical/react/ReactProvider`});function TLe(){return RQ().getTextContent()}function ELe(e,t=!0){if(e)return!1;let n=TLe();return t&&(n=n.trim()),n===``}function DLe(e){if(!ELe(e,!1))return!1;let t=RQ().getChildren(),n=t.length;if(n>1)return!1;for(let e=0;e<n;e++){let n=t[e];if(eQ(n))return!1;if(Q(n)){if(!lQ(n)||n.__indent!==0)return!1;let t=n.getChildren(),r=t.length;for(let n=0;n<r;n++){let n=t[e];if(!XX(n))return!1}}}return!0}function a0(e){return()=>DLe(e)}function OLe(e){let t=window.location.origin,n=n=>{if(n.origin!==t)return;let r=e.getRootElement();if(document.activeElement!==r)return;let i=n.data;if(typeof i==`string`){let t;try{t=JSON.parse(i)}catch{return}if(t&&t.protocol===`nuanria_messaging`&&t.type===`request`){let r=t.payload;if(r&&r.functionId===`makeChanges`){let t=r.args;if(t){let[r,i,a,o,s]=t;e.update(()=>{let e=vZ();if(Z(e)){let t=e.anchor,c=t.getNode(),l=0,u=0;if(XX(c)&&r>=0&&i>=0&&(l=r,u=r+i,e.setTextNodeRange(c,l,c,u)),l===u&&a===``||(e.insertRawText(a),c=t.getNode()),XX(c)){l=o,u=o+s;let t=c.getTextContentSize();l=l>t?t:l,u=u>t?t:u,e.setTextNodeRange(c,l,c,u)}n.stopImmediatePropagation()}})}}}}};return window.addEventListener(`message`,n,!0),()=>{window.removeEventListener(`message`,n,!0)}}function kLe(e,t){if(typeof document>`u`||typeof window>`u`&&global.window===void 0)throw Error(`To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.`);let n=document.createElement(`div`),r=RQ().getChildren();for(let i=0;i<r.length;i++)o0(e,r[i],n,t);return n.innerHTML}function o0(e,t,n,r=null){let i=r===null||t.isSelected(r),a=Q(t)&&t.excludeFromCopy(`html`),o=t;r!==null&&XX(t)&&(o=cLe(r,t,`clone`));let s=Q(o)?o.getChildren():[],c=gQ(e,o.getType()),l;l=c&&c.exportDOM!==void 0?c.exportDOM(e,o):o.exportDOM(e);let{element:u,after:d}=l;if(!u)return!1;let f=document.createDocumentFragment();for(let n=0;n<s.length;n++){let a=s[n],o=o0(e,a,f,r);!i&&Q(t)&&o&&t.extractWithChild(a,r,`html`)&&(i=!0)}if(i&&!a){if((v$(u)||b$(u))&&u.append(f),n.append(u),d){let e=d.call(o,u);e&&(b$(u)?u.replaceChildren(e):u.replaceWith(e))}}else n.append(f);return i}function ALe(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function jLe(e,t=vZ()){return t??ALe(166),Z(t)&&t.isCollapsed()||t.getNodes().length===0?``:kLe(e,t)}function s0(e,t){let n=e.getData(`text/plain`)||e.getData(`text/uri-list`);n!=null&&t.insertRawText(n)}var c0=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,MLe=c0&&`documentMode`in document?document.documentMode:null,NLe=c0&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),PLe=!(!c0||!(`InputEvent`in window)||MLe)&&`getTargetRanges`in new window.InputEvent(`input`),FLe=c0&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),l0=c0&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,ILe=c0&&/^(?=.*Chrome).*/i.test(navigator.userAgent),LLe=c0&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&NLe&&!ILe;function u0(e,t){t.update(()=>{if(e!==null){let n=w1(e,KeyboardEvent)?null:e.clipboardData,r=vZ();if(r!==null&&!r.isCollapsed()&&n!=null){e.preventDefault();let i=jLe(t);i!==null&&n.setData(`text/html`,i),n.setData(`text/plain`,r.getTextContent())}}})}function RLe(e){return f1(e.registerCommand(MY,e=>{let t=vZ();return!!Z(t)&&(t.deleteCharacter(e),!0)},0),e.registerCommand(RY,e=>{let t=vZ();return!!Z(t)&&(t.deleteWord(e),!0)},0),e.registerCommand(zY,e=>{let t=vZ();return!!Z(t)&&(t.deleteLine(e),!0)},0),e.registerCommand(FY,e=>{let t=vZ();if(!Z(t))return!1;if(typeof e==`string`)t.insertText(e);else{let n=e.dataTransfer;if(n!=null)s0(n,t);else{let n=e.data;n&&t.insertText(n)}}return!0},0),e.registerCommand(LY,()=>{let e=vZ();return!!Z(e)&&(e.removeText(),!0)},0),e.registerCommand(NY,e=>{let t=vZ();return!!Z(t)&&(t.insertLineBreak(e),!0)},0),e.registerCommand(PY,()=>{let e=vZ();return!!Z(e)&&(e.insertLineBreak(),!0)},0),e.registerCommand(GY,e=>{let t=vZ();if(!Z(t))return!1;let n=e,r=n.shiftKey;return!!b1(t,!0)&&(n.preventDefault(),S1(t,r,!0),!0)},0),e.registerCommand(WY,e=>{let t=vZ();if(!Z(t))return!1;let n=e,r=n.shiftKey;return!!b1(t,!1)&&(n.preventDefault(),S1(t,r,!1),!0)},0),e.registerCommand(qY,t=>!!Z(vZ())&&(!l0||navigator.language!==`ko-KR`)&&(t.preventDefault(),e.dispatchCommand(MY,!0)),0),e.registerCommand(JY,t=>!!Z(vZ())&&(t.preventDefault(),e.dispatchCommand(MY,!1)),0),e.registerCommand(KY,t=>{if(!Z(vZ()))return!1;if(t!==null){if((l0||FLe||LLe)&&PLe)return!1;t.preventDefault()}return e.dispatchCommand(NY,!1)},0),e.registerCommand($Y,()=>(OIe(),!0),0),e.registerCommand(ZY,t=>!!Z(vZ())&&(u0(t,e),!0),0),e.registerCommand(QY,t=>!!Z(vZ())&&(function(e,t){u0(e,t),t.update(()=>{let e=vZ();Z(e)&&e.removeText()})}(t,e),!0),0),e.registerCommand(IY,t=>!!Z(vZ())&&(function(e,t){e.preventDefault(),t.update(()=>{let t=vZ(),n=w1(e,ClipboardEvent)?e.clipboardData:null;n!=null&&Z(t)&&s0(n,t)},{tag:`paste`})}(t,e),!0),0),e.registerCommand(YY,e=>!!Z(vZ())&&(e.preventDefault(),!0),0),e.registerCommand(XY,e=>!!Z(vZ())&&(e.preventDefault(),!0),0))}function zLe(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}var d0=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0?I.useLayoutEffect:I.useEffect;function BLe({editor:e,ErrorBoundary:t}){return function(e,t){let[n,r]=(0,I.useState)(()=>e.getDecorators());return d0(()=>e.registerDecoratorListener(e=>{(0,Er.flushSync)(()=>{r(e)})}),[e]),(0,I.useEffect)(()=>{r(e.getDecorators())},[e]),(0,I.useMemo)(()=>{let r=[],i=Object.keys(n);for(let a=0;a<i.length;a++){let o=i[a],s=(0,L.jsx)(t,{onError:t=>e._onError(t),children:(0,L.jsx)(I.Suspense,{fallback:null,children:n[o]})}),c=e.getElementByKey(o);c!==null&&r.push((0,Er.createPortal)(s,c,o))}return r},[t,n,e])}(e,t)}function VLe({editor:e,ErrorBoundary:t}){return function(e){let t=xLe.maybeFromEditor(e);if(t&&t.hasExtensionByName(wLe.name)){for(let e of[`@lexical/plain-text`,`@lexical/rich-text`])t.hasExtensionByName(e)&&zLe(320,e);return!0}return!1}(e)?null:(0,L.jsx)(BLe,{editor:e,ErrorBoundary:t})}function f0(e){return e.getEditorState().read(a0(e.isComposing()))}function HLe({contentEditable:e,placeholder:t=null,ErrorBoundary:n}){let[r]=m1();return function(e){d0(()=>f1(RLe(e),OLe(e)),[e])}(r),(0,L.jsxs)(L.Fragment,{children:[e,(0,L.jsx)(ULe,{content:t}),(0,L.jsx)(VLe,{editor:r,ErrorBoundary:n})]})}function ULe({content:e}){let[t]=m1(),n=function(e){let[t,n]=(0,I.useState)(()=>f0(e));return d0(()=>{function t(){n(f0(e))}return t(),f1(e.registerUpdateListener(()=>{t()}),e.registerEditableListener(()=>{t()}))},[e]),t}(t),r=oLe();return n?typeof e==`function`?e(r):e:null}var p0=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0?I.useLayoutEffect:I.useEffect;function WLe({editor:e,ariaActiveDescendant:t,ariaAutoComplete:n,ariaControls:r,ariaDescribedBy:i,ariaErrorMessage:a,ariaExpanded:o,ariaInvalid:s,ariaLabel:c,ariaLabelledBy:l,ariaMultiline:u,ariaOwns:d,ariaRequired:f,autoCapitalize:p,className:m,id:h,role:g=`textbox`,spellCheck:_=!0,style:v,tabIndex:y,"data-testid":b,...x},S){let[C,w]=(0,I.useState)(e.isEditable()),T=(0,I.useCallback)(t=>{t&&t.ownerDocument&&t.ownerDocument.defaultView?e.setRootElement(t):e.setRootElement(null)},[e]),E=(0,I.useMemo)(()=>function(...e){return t=>{for(let n of e)typeof n==`function`?n(t):n!=null&&(n.current=t)}}(S,T),[T,S]);return p0(()=>(w(e.isEditable()),e.registerEditableListener(e=>{w(e)})),[e]),(0,L.jsx)(`div`,{"aria-activedescendant":C?t:void 0,"aria-autocomplete":C?n:`none`,"aria-controls":C?r:void 0,"aria-describedby":i,...a==null?{}:{"aria-errormessage":a},"aria-expanded":C&&g===`combobox`?!!o:void 0,...s==null?{}:{"aria-invalid":s},"aria-label":c,"aria-labelledby":l,"aria-multiline":u,"aria-owns":C?d:void 0,"aria-readonly":!C||void 0,"aria-required":f,autoCapitalize:p,className:m,contentEditable:C,"data-testid":b,id:h,ref:E,role:g,spellCheck:_,style:v,tabIndex:y,...x})}var GLe=(0,I.forwardRef)(WLe);function m0(e){return e.getEditorState().read(a0(e.isComposing()))}var KLe=(0,I.forwardRef)(qLe);function qLe(e,t){let{placeholder:n,...r}=e,[i]=m1();return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(GLe,{editor:i,...r,ref:t}),n!=null&&(0,L.jsx)(JLe,{editor:i,content:n})]})}function JLe({content:e,editor:t}){let n=function(e){let[t,n]=(0,I.useState)(()=>m0(e));return p0(()=>{function t(){n(m0(e))}return t(),f1(e.registerUpdateListener(()=>{t()}),e.registerEditableListener(()=>{t()}))},[e]),t}(t),[r,i]=(0,I.useState)(t.isEditable());if((0,I.useLayoutEffect)(()=>(i(t.isEditable()),t.registerEditableListener(e=>{i(e)})),[t]),!n)return null;let a=null;return typeof e==`function`?a=e(r):e!==null&&(a=e),a===null?null:(0,L.jsx)(`div`,{"aria-hidden":!0,children:a})}function YLe(e,t,n,r,i){if(e===null||n.size===0&&r.size===0&&!i)return 0;let a=t._selection,o=e._selection;if(i)return 1;if(!(Z(a)&&Z(o)&&o.isCollapsed()&&a.isCollapsed()))return 0;let s=function(e,t,n){let r=e._nodeMap,i=[];for(let e of t){let t=r.get(e);t!==void 0&&i.push(t)}for(let[e,t]of n){if(!t)continue;let n=r.get(e);n===void 0||nQ(n)||i.push(n)}return i}(t,n,r);if(s.length===0)return 0;if(s.length>1){let n=t._nodeMap,r=n.get(a.anchor.key),i=n.get(o.anchor.key);return r&&i&&!e._nodeMap.has(r.__key)&&XX(r)&&r.__text.length===1&&a.anchor.offset===1?2:0}let c=s[0],l=e._nodeMap.get(c.__key);if(!XX(l)||!XX(c)||l.__mode!==c.__mode)return 0;let u=l.__text,d=c.__text;if(u===d)return 0;let f=a.anchor,p=o.anchor;if(f.key!==p.key||f.type!==`text`)return 0;let m=f.offset,h=p.offset,g=d.length-u.length;return g===1&&h===m-1?2:g===-1&&h===m+1?3:g===-1&&h===m?4:0}function XLe(e,t){let n=Date.now(),r=0,i=Date.now(),a=0,o=null;return(s,c,l,u,d,f)=>{let p=Date.now();if(f.has(`composition-start`)&&(i=n,a=r,o=s),f.has(`historic`))return r=0,n=p,2;f.has(`composition-end`)&&o&&(n=i,r=a,s=o);let m=YLe(s,c,u,d,e.isComposing()),h=(()=>{let i=l===null||l.editor===e,a=f.has(rIe);if(!a&&i&&f.has(`history-merge`))return 0;if(m===1)return 2;if(s===null)return 1;let o=c._selection;if(!(u.size>0||d.size>0))return o===null?2:0;let h=typeof t==`number`?t:t.peek();return!1===a&&m!==0&&m===r&&p<n+h&&i||u.size===1&&function(e,t,n){let r=t._nodeMap.get(e),i=n._nodeMap.get(e),a=t._selection,o=n._selection;return!(Z(a)&&Z(o)&&a.anchor.type===`element`&&a.focus.type===`element`&&o.anchor.type===`text`&&o.focus.type===`text`||!XX(r)||!XX(i)||r.__parent!==i.__parent)&&JSON.stringify(t.read(()=>r.exportJSON()))===JSON.stringify(n.read(()=>i.exportJSON()))}(Array.from(u)[0],s,c)?0:1})();return n=p,r=m,h}}function h0(e){e.undoStack=[],e.redoStack=[],e.current=null}function ZLe(e,t,n){let r=XLe(e,n);return f1(e.registerCommand(VY,()=>(function(e,t){let n=t.redoStack,r=t.undoStack;if(r.length!==0){let i=t.current,a=r.pop();i!==null&&(n.push(i),e.dispatchCommand(eX,!0)),r.length===0&&e.dispatchCommand(tX,!1),t.current=a||null,a&&a.editor.setEditorState(a.editorState,{tag:`historic`})}}(e,t),!0),0),e.registerCommand(HY,()=>(function(e,t){let n=t.redoStack,r=t.undoStack;if(n.length!==0){let i=t.current;i!==null&&(r.push(i),e.dispatchCommand(tX,!0));let a=n.pop();n.length===0&&e.dispatchCommand(eX,!1),t.current=a||null,a&&a.editor.setEditorState(a.editorState,{tag:`historic`})}}(e,t),!0),0),e.registerCommand(KFe,()=>(h0(t),!1),0),e.registerCommand(qFe,()=>(h0(t),e.dispatchCommand(eX,!1),e.dispatchCommand(tX,!1),!0),0),e.registerUpdateListener(({editorState:n,prevEditorState:i,dirtyLeaves:a,dirtyElements:o,tags:s})=>{let c=t.current,l=t.redoStack,u=t.undoStack,d=c===null?null:c.editorState;if(c!==null&&n===d)return;let f=r(i,n,c,a,o,s);if(f===1)l.length!==0&&(t.redoStack=[],e.dispatchCommand(eX,!1)),c!==null&&(u.push({...c}),e.dispatchCommand(tX,!0));else if(f===2)return;t.current={editor:e,editorState:n}}))}function QLe(){return{current:null,redoStack:[],undoStack:[]}}function $Le({delay:e,externalHistoryState:t}){let[n]=m1();return function(e,t,n=1e3){let r=(0,I.useMemo)(()=>t||QLe(),[t]);(0,I.useEffect)(()=>ZLe(e,r,n),[n,e,r])}(n,t,e),null}var eRe=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0?I.useLayoutEffect:I.useEffect;function tRe({ignoreHistoryMergeTagChange:e=!0,ignoreSelectionChange:t=!1,onChange:n}){let[r]=m1();return eRe(()=>{if(n)return r.registerUpdateListener(({editorState:i,dirtyElements:a,dirtyLeaves:o,prevEditorState:s,tags:c})=>{t&&a.size===0&&o.size===0||e&&c.has(`history-merge`)||s.isEmpty()||n(i,r,c)})},[r,e,t,n]),null}function g0(e){return`conv-draft:${e}`}function nRe(e){try{return localStorage.getItem(g0(e))??``}catch{return``}}function rRe(e,t){try{t?localStorage.setItem(g0(e),t):localStorage.removeItem(g0(e))}catch{}}var _0=[{id:`model`,label:`/model`,description:`Switch the AI model for this conversation`,insert:`/model `},{id:`context`,label:`/context`,description:`Add context from a file or URL`,insert:`/context `},{id:`effort`,label:`/effort`,description:`Set effort level (low, medium, high)`,insert:`/effort `},{id:`cancel`,label:`/cancel`,description:`Cancel the current operation`,insert:`/cancel`}];function iRe({conversationName:e,onCommandKeyDown:t,onTextChange:n,onSlashKey:r}){let[i]=m1(),a=(0,I.useRef)(null);return(0,I.useEffect)(()=>i.registerCommand(KY,e=>e?.shiftKey?!1:(e?.preventDefault(),t(`Enter`),!0),3),[i,t]),(0,I.useEffect)(()=>{let e=i.getRootElement();if(!e)return;let t=t=>{if(t.key===`/`&&!t.ctrlKey&&!t.metaKey&&!t.altKey){let n=t.target;(n===e||e.contains(n))&&r()}};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[i,r]),(0,L.jsx)(tRe,{onChange:(0,I.useCallback)(()=>{i.read(()=>{let t=RQ().getTextContent();n(t),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{rRe(e,t)},300)})},[i,e,n])})}function aRe({editorRef:e}){let[t]=m1();return(0,I.useEffect)(()=>(e.current=t,()=>{e.current=null}),[t,e]),null}function oRe({commands:e,filter:t,selectedIndex:n,onSelect:r,onClose:i,anchorRect:a}){let o=e.filter(e=>e.label.toLowerCase().includes(t.toLowerCase())||e.description.toLowerCase().includes(t.toLowerCase()));if((0,I.useEffect)(()=>{let e=e=>{e.target.closest(`.${Y.slashMenu}`)||i()};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[i]),o.length===0)return null;let s=a?a.bottom+4:0,c=a?a.left:0;return(0,L.jsx)(`div`,{className:Y.slashMenu,style:{top:s,left:c},role:`listbox`,"aria-label":`Slash commands`,children:o.map((e,t)=>(0,L.jsxs)(`button`,{className:`${Y.slashMenuItem} ${t===n?Y.slashMenuItemSelected:``}`,onClick:()=>r(e),role:`option`,"aria-selected":t===n,children:[(0,L.jsx)(`span`,{className:Y.slashMenuLabel,children:e.label}),(0,L.jsx)(`span`,{className:Y.slashMenuDescription,children:e.description})]},e.id))})}function v0({conversationName:e,disabled:t=!1,placeholder:n=`Message Claude…`,onCommandKeyDown:r,editorRef:i,onChange:a}){let o=nRe(e),[s,c]=(0,I.useState)(o),[l,u]=(0,I.useState)(!1),[d,f]=(0,I.useState)(0),[p,m]=(0,I.useState)(null),[h,g]=(0,I.useState)(``),_={namespace:`composer:${e}`,onError:e=>console.error(`[ComposerPromptEditor]`,e),...o?{editorState:e=>{let t=RQ(),n=cQ();n.append(YX(o)),t.append(n)}}:{}},v=(0,I.useCallback)(e=>{c(e),a?.(e)},[a]),y=(0,I.useCallback)(()=>{let e=window.getSelection();e&&e.rangeCount>0&&m(e.getRangeAt(0).getBoundingClientRect()),u(!0),f(0),g(``)},[]),b=(0,I.useCallback)(e=>{let t=i?.current;t&&t.update(()=>{let t=RQ(),n=RQ().getTextContent(),r=n.endsWith(`/`)?n.slice(0,-1):n;t.clear();let i=cQ();i.append(YX(r+e.insert)),t.append(i)}),u(!1),f(0)},[i]),x=(0,I.useCallback)(()=>{u(!1),f(0)},[]);return(0,I.useEffect)(()=>{if(!l)return;let e=_0.filter(e=>e.label.toLowerCase().includes(h.toLowerCase())||e.description.toLowerCase().includes(h.toLowerCase()));if(e.length===0)return;let t=t=>{t.key===`ArrowDown`?(t.preventDefault(),f(t=>(t+1)%e.length)):t.key===`ArrowUp`?(t.preventDefault(),f(t=>(t-1+e.length)%e.length)):t.key===`Enter`?(t.preventDefault(),b(e[d])):t.key===`Escape`?(t.preventDefault(),x()):t.key===`Backspace`?g(e=>e.slice(0,-1)):t.key.length===1&&!t.ctrlKey&&!t.metaKey&&!t.altKey&&g(e=>e+t.key)};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[l,d,h,b,x]),(0,L.jsxs)(`div`,{style:{position:`relative`},children:[(0,L.jsx)(rLe,{initialConfig:_,children:(0,L.jsxs)(`div`,{className:`${Y.composerEditor} ${t?Y.composerEditorDisabled:``}`,children:[(0,L.jsx)(HLe,{contentEditable:(0,L.jsx)(KLe,{className:Y.composerEditable,"aria-placeholder":n,placeholder:()=>s?null:(0,L.jsx)(`div`,{className:Y.composerPlaceholder,children:n})}),ErrorBoundary:({children:e})=>(0,L.jsx)(L.Fragment,{children:e})}),(0,L.jsx)($Le,{}),(0,L.jsx)(iRe,{conversationName:e,onCommandKeyDown:r,onTextChange:v,onSlashKey:y}),i&&(0,L.jsx)(aRe,{editorRef:i})]})}),l&&(0,L.jsx)(oRe,{commands:_0,filter:h,selectedIndex:d,onSelect:b,onClose:x,anchorRect:p})]})}function sRe({className:e,style:t}){return(0,L.jsx)(`svg`,{className:e,style:t,preserveAspectRatio:`xMidYMid`,viewBox:`0 0 256 257`,fill:`currentColor`,"aria-hidden":`true`,children:(0,L.jsx)(`path`,{d:`m50.228 170.321 50.357-28.257.843-2.463-.843-1.361h-2.462l-8.426-.518-28.775-.778-24.952-1.037-24.175-1.296-6.092-1.297L0 125.796l.583-3.759 5.12-3.434 7.324.648 16.202 1.101 24.304 1.685 17.629 1.037 26.118 2.722h4.148l.583-1.685-1.426-1.037-1.101-1.037-25.147-17.045-27.22-18.017-14.258-10.37-7.713-5.25-3.888-4.925-1.685-10.758 7-7.713 9.397.649 2.398.648 9.527 7.323 20.35 15.75L94.817 91.9l3.889 3.24 1.555-1.102.195-.777-1.75-2.917-14.453-26.118-15.425-26.572-6.87-11.018-1.814-6.61c-.648-2.723-1.102-4.991-1.102-7.778l7.972-10.823L71.42 0 82.05 1.426l4.472 3.888 6.61 15.101 10.694 23.786 16.591 32.34 4.861 9.592 2.592 8.879.973 2.722h1.685v-1.556l1.36-18.211 2.528-22.36 2.463-28.776.843-8.1 4.018-9.722 7.971-5.25 6.222 2.981 5.12 7.324-.713 4.73-3.046 19.768-5.962 30.98-3.889 20.739h2.268l2.593-2.593 10.499-13.934 17.628-22.036 7.778-8.749 9.073-9.657 5.833-4.601h11.018l8.1 12.055-3.628 12.443-11.342 14.388-9.398 12.184-13.48 18.147-8.426 14.518.778 1.166 2.01-.194 30.46-6.481 16.462-2.982 19.637-3.37 8.88 4.148.971 4.213-3.5 8.62-20.998 5.184-24.628 4.926-36.682 8.685-.454.324.519.648 16.526 1.555 7.065.389h17.304l32.21 2.398 8.426 5.574 5.055 6.805-.843 5.184-12.962 6.611-17.498-4.148-40.83-9.721-14-3.5h-1.944v1.167l11.666 11.406 21.387 19.314 26.767 24.887 1.36 6.157-3.434 4.86-3.63-.518-23.526-17.693-9.073-7.972-20.545-17.304h-1.36v1.814l4.73 6.935 25.017 37.59 1.296 11.536-1.814 3.76-6.481 2.268-7.13-1.297-14.647-20.544-15.1-23.138-12.185-20.739-1.49.843-7.194 77.448-3.37 3.953-7.778 2.981-6.48-4.925-3.436-7.972 3.435-15.749 4.148-20.544 3.37-16.333 3.046-20.285 1.815-6.74-.13-.454-1.49.194-15.295 20.999-23.267 31.433-18.406 19.702-4.407 1.75-7.648-3.954.713-7.064 4.277-6.286 25.47-32.405 15.36-20.092 9.917-11.6-.065-1.686h-.583L44.07 198.125l-12.055 1.555-5.185-4.86.648-7.972 2.463-2.593 20.35-13.999-.064.065Z`})})}function cRe({provider:e,className:t,style:n}){return e===`anthropic`?(0,L.jsx)(sRe,{className:t,style:n}):null}var y0={"claude-opus-4-6":[`low`,`medium`,`high`,`max`],"claude-sonnet-4-6":[`low`,`medium`,`high`],"claude-haiku-4-5-20251001":[]},lRe={...y0},uRe={anthropic:`Anthropic`,openai:`OpenAI`,google:`Google`,zai:`Z.AI`,kimi:`Kimi`,minimax:`MiniMax`,openrouter:`OpenRouter`},dRe=[{provider:`anthropic`,label:`Anthropic`,usable:!0,models:[{id:`claude-opus-4-6`,label:`Claude Opus 4.6`,provider:`anthropic`,costDisplay:`$45/1M`,effortLevels:[`low`,`medium`,`high`,`max`]},{id:`claude-sonnet-4-6`,label:`Claude Sonnet 4.6`,provider:`anthropic`,costDisplay:`$15/1M`,effortLevels:[`low`,`medium`,`high`]},{id:`claude-haiku-4-5-20251001`,label:`Claude Haiku 4.5`,provider:`anthropic`,costDisplay:`$1/1M`,effortLevels:[]}]}],b0=`conv-composer-model`,fRe=`claude-opus-4-6`;function x0(){try{let e=localStorage.getItem(b0);if(e)return e}catch{}return fRe}function S0(e){return e===0?`FREE`:e<1?`$${e.toFixed(2)}/1M`:`$${Math.round(e)}/1M`}function C0({value:e,onChange:t,disabled:n=!1}){let[r,i]=(0,I.useState)(!1),[a,o]=(0,I.useState)(dRe),s=(0,I.useRef)(null);(0,I.useEffect)(()=>{async function n(){try{let[n,r,i]=await Promise.allSettled([fetch(`/api/settings/available-models`).then(e=>e.json()),fetch(`/api/settings/openrouter/models`).then(e=>e.json()),fetch(`/api/settings/claude-auth`).then(e=>e.json())]),a=n.status===`fulfilled`?n.value:{},s=a.usable??{},c=r.status===`fulfilled`?r.value:{models:[],favorites:[]},l=i.status===`fulfilled`?i.value:null,u=s.anthropic??!1,d=u?`key`:`noauth`,f;l?.loggedIn&&l.subscriptionType?(d=`sub`,f=l.subscriptionType.toUpperCase()):l?.hasAnthropicApiKey&&(d=`key`);let p=[];for(let[e,t]of Object.entries(a)){if(e===`openrouter`||e===`usable`||!Array.isArray(t)||t.length===0)continue;let n=e===`anthropic`?u:s[e]??!1;p.push({provider:e,label:uRe[e]??e,usable:n,models:t.map(t=>({id:t.id,label:t.name,provider:e,costDisplay:e===`anthropic`&&d===`sub`?void 0:S0(t.costPer1MTokens),effortLevels:lRe[t.id]??[],authMode:e===`anthropic`?d:void 0,authBadge:e===`anthropic`?f:void 0}))})}let m=c.favorites??[],h=(c.models??[]).filter(e=>m.includes(e.id));if(h.length>0&&p.push({provider:`openrouter`,label:`OpenRouter`,usable:s.openrouter??!1,models:h.map(e=>({id:e.id,label:e.name,provider:`openrouter`,costDisplay:S0(e.promptCostPer1M),effortLevels:e.supportsThinking?[`low`,`medium`,`high`]:[]}))}),p.length>0){o(p);let n=p.flatMap(e=>e.models).find(t=>t.id===e)?.provider;if(!(p.find(e=>e.provider===n)?.usable??!0)){let e=p.find(e=>e.usable&&e.models.length>0);if(e){let n=e.models[0];t(n.id,n.effortLevels),localStorage.setItem(b0,n.id)}}}}catch{}}n()},[]);let c=a.flatMap(e=>e.models).find(t=>t.id===e);(0,I.useEffect)(()=>{if(!r)return;function e(e){s.current&&!s.current.contains(e.target)&&i(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[r]);function l(e){t(e.id,e.effortLevels),localStorage.setItem(b0,e.id),i(!1)}let u=c?.label??e,d=c?.authBadge??null,f=c?.provider??``,[p,m]=(0,I.useState)({x:0,y:0});return(0,L.jsxs)(`div`,{ref:s,className:Y.pickerContainer,children:[(0,L.jsxs)(`button`,{className:Y.pickerBtn,onClick:e=>{if(!r){let t=e.currentTarget.getBoundingClientRect(),n=t.top>=300?t.top-4:t.bottom+4;m({x:t.left,y:n})}i(e=>!e)},disabled:n,type:`button`,children:[(0,L.jsx)(cRe,{provider:f,className:Y.pickerProviderIcon,style:f===`anthropic`?{color:`#d97757`}:void 0}),(0,L.jsx)(`span`,{className:Y.pickerLabel,children:u}),d&&(0,L.jsx)(`span`,{className:Y.pickerAuthBadge,children:d}),(0,L.jsx)(Tt,{size:10})]}),r&&(0,L.jsx)(`div`,{className:Y.pickerDropdown,style:{left:p.x,top:p.y},children:a.filter(e=>e.usable).map(t=>(0,L.jsxs)(`div`,{children:[a.filter(e=>e.usable).length>1&&(0,L.jsx)(`div`,{className:Y.pickerGroupHeader,children:t.label}),t.models.map(n=>(0,L.jsxs)(`button`,{className:`${Y.pickerOption} ${n.id===e?Y.pickerOptionActive:``}`,onClick:()=>l(n),type:`button`,children:[(0,L.jsx)(`span`,{className:Y.pickerOptionLabel,children:n.label}),n.authBadge&&t.usable&&(0,L.jsx)(`span`,{className:Y.pickerAuthBadge,children:n.authBadge}),n.costDisplay&&t.usable&&!n.authBadge&&(0,L.jsx)(`span`,{className:Y.pickerCostBadge,children:n.costDisplay})]},n.id))]},t.provider))})]})}var w0=[{id:`low`,label:`Low`},{id:`medium`,label:`Medium (default)`},{id:`high`,label:`High`},{id:`max`,label:`Max`}],T0=`conv-composer-effort`,pRe=`medium`;function E0(){try{let e=localStorage.getItem(T0);if(e&&w0.some(t=>t.id===e))return e}catch{}return pRe}function D0({value:e,onChange:t,disabled:n=!1,availableLevels:r}){let[i,a]=(0,I.useState)(!1),o=(0,I.useRef)(null),s=r!==void 0&&r.length===0,c=r&&r.length>0?w0.filter(e=>r.includes(e.id)):w0,l=c.find(t=>t.id===e)??c[0]??w0[1];(0,I.useEffect)(()=>{if(!i)return;function e(e){o.current&&!o.current.contains(e.target)&&a(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[i]);function u(e){t(e),localStorage.setItem(T0,e),a(!1)}return s?(0,L.jsx)(`div`,{className:Y.pickerContainer,children:(0,L.jsx)(`span`,{className:Y.pickerHint,children:`effort n/a for this model`})}):(0,L.jsxs)(`div`,{ref:o,className:Y.pickerContainer,children:[(0,L.jsxs)(`button`,{className:Y.pickerBtn,onClick:()=>a(e=>!e),disabled:n,type:`button`,children:[(0,L.jsx)(`span`,{className:Y.pickerLabel,children:l.label}),(0,L.jsx)(Tt,{size:11})]}),i&&(0,L.jsx)(`div`,{className:Y.pickerDropdown,children:c.map(t=>(0,L.jsx)(`button`,{className:`${Y.pickerOption} ${t.id===e?Y.pickerOptionActive:``}`,onClick:()=>u(t.id),type:`button`,children:t.label},t.id))})]})}async function mRe(e,t){let n=await fetch(`/api/conversations/${encodeURIComponent(e)}/switch-model`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({model:t})});if(!n.ok){let e=await n.text().catch(()=>``);throw Error(`Failed to switch model (${n.status})${e?`: ${e}`:``}`)}}async function O0(e,t){let n=await fetch(`/api/conversations/${encodeURIComponent(e)}/message`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({message:t})});if(!n.ok){let e=await n.text().catch(()=>``);throw Error(`Failed to send message (${n.status})${e?`: ${e}`:``}`)}}function hRe({conversation:e,onSend:t}){let[n,r]=(0,I.useState)(x0),[i,a]=(0,I.useState)(E0),[o,s]=(0,I.useState)(!1),[c,l]=(0,I.useState)(``),u=(0,I.useRef)(null),d=!e.sessionAlive||o,f=c.trim()===``,p=(0,I.useCallback)((t,n)=>{r(t),e.sessionAlive&&O0(e.name,`/model ${t}`).catch(e=>{console.error(`[ComposerFooter] Failed to send /model:`,e)})},[e.name,e.sessionAlive]),m=(0,I.useCallback)(async()=>{let r=u.current;if(!r){console.warn(`[ComposerFooter] handleSubmit: editor ref not ready`);return}if(d){console.warn(`[ComposerFooter] handleSubmit: isDisabled=true, sessionAlive=%s sending=%s`,e.sessionAlive,o);return}let i=``;if(r.read(()=>{i=RQ().getTextContent().trim()}),i){t?.(i),s(!0);try{n!==e.model&&e.sessionAlive&&(await mRe(e.name,n),await new Promise(e=>setTimeout(e,2e3))),await O0(e.name,i),r.update(()=>{RQ().clear()}),l(``)}catch(e){console.error(`[ComposerFooter] Failed to send:`,e),Br.error(e instanceof Error?e.message:`Failed to send message`)}finally{s(!1),r.focus()}}},[n,e.name,e.model,e.sessionAlive,o,d,t]),h=(0,I.useCallback)(e=>{e===`Enter`&&m()},[m]);return(0,L.jsx)(`div`,{className:Y.composerFooter,children:(0,L.jsxs)(`div`,{className:Y.composerBox,children:[(0,L.jsx)(v0,{conversationName:e.name,disabled:d,onCommandKeyDown:h,editorRef:u,onChange:l}),(0,L.jsxs)(`div`,{className:Y.composerToolbar,children:[(0,L.jsx)(C0,{value:n,onChange:p,disabled:d}),(0,L.jsx)(`div`,{className:Y.composerToolbarDivider}),(0,L.jsx)(D0,{value:i,onChange:a,disabled:!0,availableLevels:y0[n]}),(0,L.jsx)(`div`,{className:Y.composerToolbarSpacer}),(0,L.jsx)(`button`,{className:Y.sendButton,onClick:()=>void m(),disabled:f||d,type:`button`,title:`Send message (Enter)`,children:(0,L.jsx)(Kn,{size:16})})]})]})})}async function gRe(e,t,n){let r=await fetch(`/api/conversations/${encodeURIComponent(e)}/resume`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({model:t,effort:n})});if(!r.ok)throw Error(`Failed to resume conversation`);return r.json()}function _Re({conversation:e,onArchived:t}){let[n,r]=(0,I.useState)(`conversation`),[i,a]=(0,I.useState)(!1),[o,s]=(0,I.useState)(()=>e.model||`claude-opus-4-6`),c=He(),{data:l}=rt({queryKey:[`conversation-messages`,e.name],queryFn:()=>k0(e.name),refetchInterval:e.sessionAlive?2e3:!1}),u=l?.streaming??!1,d=it({mutationFn:()=>gRe(e.name,o),onSuccess:()=>{c.invalidateQueries({queryKey:[`conversations`]}),a(!0)}}),f=it({mutationFn:t=>fetch(`/api/conversations/${encodeURIComponent(e.name)}/switch-model`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({model:t})}).then(e=>{if(!e.ok)throw Error(`Failed to switch model`);return e.json()}),onSuccess:()=>{c.invalidateQueries({queryKey:[`conversations`]}),c.invalidateQueries({queryKey:[`conversation-messages`,e.name]})}}),p=(0,I.useCallback)(()=>{d.mutate()},[d]),m=(0,I.useCallback)(async()=>{try{await fetch(`/api/conversations/${encodeURIComponent(e.name)}/archive`,{method:`POST`}),c.invalidateQueries({queryKey:[`conversations`]}),t?.()}catch(e){console.error(`[ConversationPanel] Archive failed:`,e)}},[e.name,c,t]),h=(0,I.useCallback)(e=>{r(e)},[]),g=e.sessionAlive||i,_=e.sessionAlive?`var(--mc-success)`:`var(--mc-text-muted)`,v=e.sessionAlive?`active`:`ended`;return(0,L.jsxs)(`div`,{className:Y.conversationTerminal,children:[(0,L.jsxs)(`div`,{className:Y.conversationTerminalHeader,children:[(0,L.jsxs)(`span`,{className:Y.conversationTerminalTitle,children:[u&&(0,L.jsx)(kn,{size:14,className:Y.spinnerIcon}),e.title??e.name]}),(0,L.jsxs)(`span`,{className:Y.conversationTerminalStatus,children:[(0,L.jsx)(Ft,{size:7,style:{fill:_,color:_}}),v]}),g&&(0,L.jsxs)(`div`,{className:Y.viewToggle,children:[(0,L.jsx)(`button`,{className:`${Y.viewToggleBtn} ${n===`conversation`?Y.viewToggleBtnActive:``}`,onClick:()=>h(`conversation`),children:`Conversation`}),(0,L.jsx)(`button`,{className:`${Y.viewToggleBtn} ${n===`terminal`?Y.viewToggleBtnActive:``}`,onClick:()=>h(`terminal`),children:`Terminal`})]})]}),(0,L.jsxs)(`div`,{className:Y.conversationTerminalBody,children:[g&&n===`terminal`&&(0,L.jsx)(Ww,{sessionName:e.tmuxSession}),(n===`conversation`||!g)&&(0,L.jsx)(vRe,{conversation:e,onResume:g?void 0:p,onArchive:m,resumePending:d.isPending,modelPicker:(0,L.jsx)(C0,{value:o,onChange:e=>{s(e),f.mutate(e)}})})]})]})}async function k0(e){let t=await fetch(`/api/conversations/${encodeURIComponent(e)}/messages`);if(!t.ok)throw Error(`Failed to fetch messages`);return t.json()}function vRe({conversation:e,onResume:t,onArchive:n,resumePending:r,modelPicker:i}){let[a,o]=(0,I.useState)([]),s=(0,I.useRef)(0),{data:c,isLoading:l}=rt({queryKey:[`conversation-messages`,e.name],queryFn:()=>k0(e.name),refetchInterval:e.sessionAlive?2e3:!1}),u=c?.messages??[],d=c?.workLog??[],f=c?.streaming??!1,p=s.current+a.length,m=u.length>=p&&a.length>0,h=m?u:[...u,...a],g=(0,I.useCallback)(e=>{s.current=u.length,o([{id:`optimistic-${Date.now()}`,role:`user`,text:e,createdAt:new Date().toISOString()}])},[u.length]);(0,I.useEffect)(()=>{m&&o([])},[m]);let _=!l&&h.length===0&&e.sessionAlive,v=!l&&h.length===0&&!e.sessionAlive,y=h[h.length-1],b=e.sessionAlive&&h.length>0&&(f||y?.role===`user`);return(0,L.jsxs)(`div`,{className:Y.conversationView,children:[l?(0,L.jsx)(`div`,{className:Y.conversationConnecting,children:(0,L.jsx)(`span`,{children:`Loading…`})}):v?(0,L.jsxs)(`div`,{className:Y.conversationEmptyState,children:[(0,L.jsx)(`p`,{className:Y.conversationEmptyStateSubtitle,children:`This conversation has no saved history. The session may have ended before any messages were exchanged.`}),(0,L.jsxs)(`div`,{style:{display:`flex`,gap:8,marginTop:12,alignItems:`center`},children:[t&&(0,L.jsxs)(L.Fragment,{children:[i,(0,L.jsx)(`button`,{className:Y.conversationResumeBtn,onClick:t,disabled:r,children:r?`Resuming…`:`Resume Session`})]}),(0,L.jsx)(`button`,{className:Y.conversationArchiveBtnLarge,onClick:()=>n?.(),children:`Archive`})]})]}):_?(0,L.jsxs)(`div`,{className:Y.conversationEmptyState,children:[(0,L.jsx)(`p`,{className:Y.conversationEmptyStateTitle,children:`How can I help you?`}),(0,L.jsx)(`p`,{className:Y.conversationEmptyStateSubtitle,children:`Type a message below to start the conversation.`})]}):(0,L.jsx)(tFe,{messages:h,workLog:d,streaming:b}),t?(0,L.jsxs)(`div`,{className:Y.conversationResumeBar,children:[i,(0,L.jsx)(`button`,{className:Y.conversationResumeBtn,onClick:t,disabled:r,children:r?`Resuming…`:`Resume Session`})]}):(0,L.jsx)(hRe,{conversation:e,onSend:g})]})}async function yRe(e,t,n){let r=await fetch(`/api/conversations`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({message:e,model:t,effort:n})});if(!r.ok){let e=await r.json().catch(()=>({error:`Request failed`}));throw Error(e.error||`Failed to create conversation`)}return r.json()}function bRe({onPromoted:e}){let[t,n]=(0,I.useState)(x0),[r,i]=(0,I.useState)(()=>y0[x0()]??[`low`,`medium`,`high`]),[a,o]=(0,I.useState)(E0),[s,c]=(0,I.useState)(!1),[l,u]=(0,I.useState)(``),[d,f]=(0,I.useState)(null),p=(0,I.useRef)(null),m=(0,I.useMemo)(()=>`draft-${Date.now()}`,[]);(0,I.useEffect)(()=>{let e=setTimeout(()=>{p.current?.focus()},50);return()=>clearTimeout(e)},[]);let h=l.trim()===``;function g(e,t){n(e),i(t)}let _=(0,I.useCallback)(async()=>{let n=p.current;if(!n||s)return;let r=``;if(n.read(()=>{r=RQ().getTextContent().trim()}),r){c(!0),f(null);try{e(await yRe(r,t,a),r)}catch(e){console.error(`[DraftConversationPanel] Failed:`,e),f(e instanceof Error?e.message:`Failed to create conversation`),c(!1)}}},[t,a,e,s]),v=(0,I.useCallback)(e=>{e===`Enter`&&_()},[_]);return(0,L.jsxs)(`div`,{className:Y.conversationTerminal,children:[(0,L.jsx)(`div`,{className:Y.conversationTerminalHeader,children:(0,L.jsx)(`span`,{className:Y.conversationTerminalTitle,children:`New conversation`})}),(0,L.jsx)(`div`,{className:Y.conversationTerminalBody,children:(0,L.jsxs)(`div`,{className:Y.conversationView,children:[(0,L.jsxs)(`div`,{className:Y.conversationEmptyState,children:[(0,L.jsx)(`p`,{className:Y.conversationEmptyStateTitle,children:`How can I help you?`}),(0,L.jsx)(`p`,{className:Y.conversationEmptyStateSubtitle,children:`Type a message below to start the conversation.`})]}),(0,L.jsxs)(`div`,{className:Y.composerFooter,children:[(0,L.jsxs)(`div`,{className:Y.composerBox,children:[(0,L.jsx)(v0,{conversationName:m,disabled:s,onCommandKeyDown:v,editorRef:p,onChange:u}),(0,L.jsxs)(`div`,{className:Y.composerToolbar,children:[(0,L.jsx)(C0,{value:t,onChange:g,disabled:s}),(0,L.jsx)(D0,{value:a,onChange:o,disabled:s,availableLevels:r}),(0,L.jsx)(`div`,{className:Y.composerToolbarSpacer}),(0,L.jsx)(`button`,{className:Y.sendButton,onClick:()=>void _(),disabled:h||s,type:`button`,title:`Send message (Enter)`,children:(0,L.jsx)(Kn,{size:16})})]})]}),s&&(0,L.jsx)(`p`,{style:{color:`var(--mc-text-muted)`,fontSize:12,padding:`4px 8px`},children:`Starting session...`}),d&&(0,L.jsx)(`p`,{style:{color:`var(--mc-error)`,fontSize:12,padding:`4px 8px`},children:d})]})]})})]})}async function xRe(){let e=await fetch(`/api/conversations`);if(!e.ok)throw Error(`Failed to fetch conversations`);return e.json()}async function SRe(){let e=await fetch(`/api/command-deck/projects`);if(!e.ok)throw Error(`Failed to fetch projects`);return e.json()}async function CRe(){let e=await fetch(`/api/costs/by-issue`);if(!e.ok)throw Error(`Failed to fetch costs`);return e.json()}async function wRe(){let e=await fetch(`/api/version`);if(!e.ok)throw Error(`Failed to fetch version`);return e.json()}function TRe({issues:e=[]}){let[t,n]=(0,I.useState)(null),[r,i]=(0,I.useState)(null),[a,o]=(0,I.useState)(!1),[s,c]=(0,I.useState)(!1),[l,u]=(0,I.useState)(`conversations`),[d,f]=(0,I.useState)(()=>localStorage.getItem(`mc-sidebar-model`)||`minimax-4o-mini`),[p,m]=(0,I.useState)(0),[h,g]=(0,I.useState)(()=>{let e=localStorage.getItem(`mc-sidebar-width`);return e?Number(e):600}),_=(0,I.useRef)(!1),v=(0,I.useRef)(0),y=(0,I.useRef)(0),b=(0,I.useRef)(h),{data:x=[],isLoading:S}=rt({queryKey:[`command-deck-projects`],queryFn:SRe,refetchInterval:1e4}),{data:C}=rt({queryKey:[`costs-by-issue`],queryFn:CRe,refetchInterval:15e3}),{data:w}=rt({queryKey:[`version`],queryFn:wRe,staleTime:1/0}),T={},E={};for(let t of e)T[t.identifier.toLowerCase()]=t.title,T[t.identifier]=t.title;for(let e of C?.issues||[])E[e.issueId]=e.totalCost,E[e.issueId.toLowerCase()]=e.totalCost;let{data:D=[]}=rt({queryKey:[`conversations`],queryFn:xRe,refetchInterval:1e4});(0,I.useEffect)(()=>{D.length>0&&r===null&&i(D[0].name)},[D,r]);let O=(0,I.useCallback)(e=>{n(e),i(null),o(!1)},[]),k=(0,I.useCallback)(e=>{m(0),i(e),o(!1),e!==null&&n(null)},[]),A=(0,I.useCallback)(()=>{localStorage.setItem(`mc-sidebar-model`,d),localStorage.setItem(`conv-composer-model`,d),m(e=>e+1),o(!0),i(null),n(null),u(`conversations`)},[d]),j=He(),M=(0,I.useCallback)((e,t)=>{m(0),o(!1),i(e.name);let n={id:`optimistic-${Date.now()}`,role:`user`,text:t,createdAt:new Date().toISOString()};j.setQueryData([`conversation-messages`,e.name],{messages:[n],workLog:[],streaming:!0}),j.invalidateQueries({queryKey:[`conversations`]})},[j]),N=(0,I.useCallback)(e=>{_.current=!0,v.current=e.clientX,y.current=h,document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,e.preventDefault()},[h]);(0,I.useEffect)(()=>{let e=e=>{if(!_.current)return;let t=e.clientX-v.current,n=Math.max(240,Math.min(600,y.current+t));g(n),b.current=n},t=()=>{_.current&&localStorage.setItem(`mc-sidebar-width`,String(b.current)),_.current=!1,document.body.style.cursor=``,document.body.style.userSelect=``};return document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,t),()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,t)}},[]);let P=t?x.flatMap(e=>e.features).find(e=>e.issueId===t):null,ee=t?T[t.toLowerCase()]||T[t]||t:``;return(0,L.jsxs)(`div`,{className:Y.missionControl,children:[(0,L.jsxs)(`div`,{className:Y.layout,children:[(0,L.jsxs)(`div`,{className:Y.sidebar,style:{width:h,minWidth:h},children:[(0,L.jsxs)(`div`,{className:Y.sidebarHeader,children:[(0,L.jsxs)(`div`,{className:Y.sidebarHeaderRow,children:[(0,L.jsx)(`h2`,{className:Y.sidebarTitle,children:`Command Deck`}),l===`conversations`&&(0,L.jsxs)(`div`,{className:Y.sidebarHeaderGroup,children:[(0,L.jsx)(C0,{value:d,onChange:e=>{f(e),localStorage.setItem(`mc-sidebar-model`,e),localStorage.setItem(`conv-composer-model`,e)}}),(0,L.jsx)(`button`,{className:Y.conversationAddBtn,onClick:A,title:`New conversation`,"aria-label":`New conversation`,children:(0,L.jsx)(Bn,{size:13})})]})]}),(0,L.jsxs)(`div`,{className:Y.segmentControl,children:[(0,L.jsxs)(`button`,{className:`${Y.segmentButton} ${l===`conversations`?Y.segmentButtonActive:``}`,onClick:()=>u(`conversations`),children:[`Conversations`,(0,L.jsx)(`span`,{className:Y.segmentCount,children:D.length})]}),(0,L.jsxs)(`button`,{className:`${Y.segmentButton} ${l===`projects`?Y.segmentButtonActive:``}`,onClick:()=>u(`projects`),children:[`Projects`,(0,L.jsx)(`span`,{className:Y.segmentCount,children:x.reduce((e,t)=>e+t.features.length,0)})]})]})]}),(0,L.jsx)(`div`,{className:Y.projectTree,children:l===`conversations`?(0,L.jsx)(OPe,{selectedConversation:r,onSelectConversation:k}):S&&x.length===0?(0,L.jsxs)(`div`,{className:Y.skeletonList,children:[(0,L.jsx)(`div`,{className:Y.skeletonItem,style:{width:`60%`}}),(0,L.jsx)(`div`,{className:Y.skeletonItem,style:{width:`80%`}}),(0,L.jsx)(`div`,{className:Y.skeletonItem,style:{width:`45%`}}),(0,L.jsx)(`div`,{className:Y.skeletonItem,style:{width:`70%`}})]}):x.length===0?(0,L.jsx)(`div`,{className:Y.emptyProject,children:`No projects configured`}):x.map(e=>(0,L.jsx)($Ne,{name:e.name,features:e.features,selectedFeature:t,onSelectFeature:O,issueTitles:T,issueCosts:E},e.path))}),(0,L.jsx)(TPe,{}),w&&(0,L.jsx)(`div`,{className:Y.sidebarFooter,children:(0,L.jsxs)(`span`,{className:Y.versionLabel,children:[`v`,w.version]})})]}),(0,L.jsx)(`div`,{className:Y.resizeHandle,onMouseDown:N}),(0,L.jsx)(`div`,{className:Y.content,children:a?(0,L.jsx)(bRe,{onPromoted:M},p):r?(()=>{let e=D.find(e=>e.name===r);return e?(0,L.jsx)(_Re,{conversation:e,onArchived:()=>{i(null),j.invalidateQueries({queryKey:[`conversations`]})}},e.name):(0,L.jsx)(`div`,{className:Y.contentEmpty,children:(0,L.jsx)(`div`,{style:{textAlign:`center`},children:(0,L.jsx)(`p`,{children:`Loading session…`})})})})():t?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:Y.featureHeader,children:[(0,L.jsx)(`h1`,{className:Y.featureTitle,children:ee}),(0,L.jsx)(`span`,{className:Y.featureId,children:t}),P?.isShadow&&(0,L.jsx)(`span`,{className:Y.badge,style:{borderColor:`var(--mc-accent)`,color:`var(--mc-accent)`},children:`Shadow`})]}),(0,L.jsx)(gPe,{issueId:t,source:e.find(e=>e.identifier===t)?.source,onOpenBeads:()=>c(!0)}),(0,L.jsx)(fPe,{issueId:t,issues:e,featureData:P})]}):(0,L.jsx)(`div`,{className:Y.contentEmpty,children:(0,L.jsxs)(`div`,{style:{textAlign:`center`},children:[(0,L.jsx)(Ut,{size:48,style:{marginBottom:`var(--mc-space-4)`,opacity:.3}}),(0,L.jsx)(`p`,{children:`Select a feature to view activity`})]})})})]}),s&&t&&(0,L.jsx)(tJ,{issueId:t,isOpen:s,onClose:()=>c(!1)})]})}function ERe(){let e=He(),t=G_(nse);(0,I.useEffect)(()=>{t&&e.setQueryData([`resources`],t)},[t,e])}function DRe(e){return e>=85?`bg-destructive`:e>=60?`bg-warning`:`bg-success`}function A0({value:e,label:t,showValue:n=!0,className:r=``}){let i=Math.min(100,Math.max(0,e)),a=DRe(i);return(0,L.jsxs)(`div`,{className:`flex flex-col gap-0.5 ${r}`,children:[(t||n)&&(0,L.jsxs)(`div`,{className:`flex justify-between items-center`,children:[t&&(0,L.jsx)(`span`,{className:`text-xs text-content-subtle`,children:t}),n&&(0,L.jsxs)(`span`,{className:`text-xs text-content-subtle ml-auto`,children:[i.toFixed(1),`%`]})]}),(0,L.jsx)(`div`,{className:`h-1.5 bg-surface-overlay rounded-full overflow-hidden`,children:(0,L.jsx)(`div`,{className:`h-full rounded-full transition-all duration-500 ${a}`,style:{width:`${i}%`}})})]})}RW.register(_G,bG,GW,UW,BU,rG);function j0({data:e,color:t=`rgba(59,130,246,0.8)`,height:n=32,maxValue:r=100}){let i=(0,I.useRef)(null),a=(0,I.useRef)(null);return(0,I.useEffect)(()=>{let n=i.current;if(!n)return;let o={labels:e.map(()=>``),datasets:[{data:e,borderColor:t,borderWidth:1.5,fill:!0,backgroundColor:t.replace(/[\d.]+\)$/,`0.15)`),pointRadius:0,tension:.3}]},s={responsive:!1,animation:!1,plugins:{legend:{display:!1},tooltip:{enabled:!1}},scales:{x:{display:!1},y:{display:!1,min:0,max:r}}};return a.current?(a.current.data=o,a.current.update(`none`)):a.current=new RW(n,{type:`line`,data:o,options:s}),()=>{a.current?.destroy(),a.current=null}},[]),(0,I.useEffect)(()=>{a.current&&(a.current.data.labels=e.map(()=>``),a.current.data.datasets[0].data=e,a.current.update(`none`))},[e]),(0,L.jsx)(`canvas`,{ref:i,width:80,height:n,style:{display:`block`}})}function M0(e){return e>=1024**3?`${(e/1024**3).toFixed(1)}GiB`:e>=1024**2?`${(e/1024**2).toFixed(0)}MiB`:e>=1024?`${(e/1024).toFixed(0)}KiB`:`${e}B`}var ORe={running:`bg-success`,stopped:`bg-destructive`,unhealthy:`bg-warning`,restarting:`bg-warning`},kRe={running:`running`,stopped:`stopped`,unhealthy:`unhealthy`,restarting:`restarting`},ARe={healthy:`bg-success`,warning:`bg-warning`,stuck:`bg-warning`,dead:`bg-destructive`,stopped:`bg-surface-overlay`,starting:`bg-signal-review`,failed:`bg-destructive`};function jRe({container:e,history:t,onClick:n}){let r=e.cpuPercent>=85?`rgba(239,68,68,0.8)`:e.cpuPercent>=60?`rgba(234,179,8,0.8)`:`rgba(59,130,246,0.8)`;return(0,L.jsxs)(`button`,{onClick:()=>n(e),className:`w-full text-left bg-surface-raised border border-divider rounded-lg p-3 hover:border-primary/50 hover:bg-surface-overlay transition-colors`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,L.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${ORe[e.status]}`}),(0,L.jsx)(`span`,{className:`text-xs font-medium text-content truncate flex-1`,title:e.name,children:e.name}),(0,L.jsx)(`span`,{className:`text-xs text-content-subtle shrink-0`,children:kRe[e.status]})]}),(0,L.jsxs)(`div`,{className:`flex gap-2 items-end`,children:[(0,L.jsxs)(`div`,{className:`flex-1 space-y-1.5`,children:[(0,L.jsx)(A0,{value:e.cpuPercent,label:`CPU`}),(0,L.jsx)(A0,{value:e.memoryPercent,label:`MEM`}),e.memoryLimit>0&&(0,L.jsxs)(`div`,{className:`text-xs text-content-subtle`,children:[M0(e.memoryUsage),` / `,M0(e.memoryLimit)]})]}),t&&t.cpuPercent.length>1&&(0,L.jsx)(`div`,{className:`shrink-0`,children:(0,L.jsx)(j0,{data:t.cpuPercent,color:r,height:36})})]})]})}function MRe({agent:e,onNavigate:t}){return(0,L.jsxs)(`button`,{onClick:()=>t(e.id),className:`w-full text-left bg-surface-raised border border-divider rounded-lg p-3 hover:border-primary/50 hover:bg-surface-overlay transition-colors`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,L.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${ARe[e.status]}`}),(0,L.jsx)(`span`,{className:`text-xs font-medium text-content truncate flex-1`,title:e.issueId??e.id,children:e.issueId??e.id}),(0,L.jsx)(`span`,{className:`text-xs text-content-subtle shrink-0`,children:e.status})]}),(0,L.jsxs)(`div`,{className:`text-xs text-content-subtle space-y-0.5`,children:[(0,L.jsxs)(`div`,{className:`flex justify-between`,children:[(0,L.jsx)(`span`,{children:`Model`}),(0,L.jsx)(`span`,{className:`text-content`,children:e.model})]}),(0,L.jsxs)(`div`,{className:`flex justify-between`,children:[(0,L.jsx)(`span`,{children:`Runtime`}),(0,L.jsx)(`span`,{className:`text-content`,children:e.runtime})]}),e.consecutiveFailures>0&&(0,L.jsxs)(`div`,{className:`flex justify-between text-warning`,children:[(0,L.jsx)(`span`,{children:`Failures`}),(0,L.jsx)(`span`,{children:e.consecutiveFailures})]})]}),(0,L.jsx)(`div`,{className:`mt-1.5 text-xs text-primary`,children:`Click to view in Agents →`})]})}function N0(e){return e>=1024**3?`${(e/1024**3).toFixed(1)}GiB`:e>=1024**2?`${(e/1024**2).toFixed(0)}MiB`:e>=1024?`${(e/1024).toFixed(0)}KiB`:`${e}B`}async function NRe(e){let t=await fetch(`/api/resources/${e}/details`);if(!t.ok)throw Error(`Failed to fetch container details`);return t.json()}function PRe({container:e,history:t,onClose:n}){let[r,i]=(0,I.useState)(`overview`),{data:a}=rt({queryKey:[`container-details`,e.id],queryFn:()=>NRe(e.id),refetchInterval:r===`logs`?5e3:3e4});return(0,I.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[n]),(0,L.jsxs)(`div`,{className:`fixed inset-0 z-50 flex justify-end`,children:[(0,L.jsx)(`div`,{className:`absolute inset-0 bg-black/40`,onClick:n}),(0,L.jsxs)(`div`,{className:`relative w-full max-w-lg bg-surface-raised border-l border-divider flex flex-col shadow-2xl overflow-hidden`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-3 border-b border-divider shrink-0`,children:[(0,L.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full shrink-0 ${e.status===`running`?`bg-success`:e.status===`unhealthy`||e.status===`restarting`?`bg-warning`:`bg-destructive`}`}),(0,L.jsx)(`h2`,{className:`font-semibold text-content text-sm flex-1 truncate`,title:e.name,children:e.name}),a?.image&&(0,L.jsx)(`span`,{className:`text-xs text-content-subtle truncate max-w-[160px]`,title:a.image,children:a.image}),(0,L.jsx)(`button`,{onClick:n,className:`p-1 rounded hover:bg-surface-overlay text-content-subtle hover:text-content`,children:(0,L.jsx)(_r,{className:`w-4 h-4`})})]}),(0,L.jsx)(`div`,{className:`flex border-b border-divider shrink-0`,children:[{id:`overview`,label:`Overview`},{id:`logs`,label:`Logs`},{id:`ports-env`,label:`Ports & Env`}].map(e=>(0,L.jsx)(`button`,{onClick:()=>i(e.id),className:`px-4 py-2 text-xs transition-colors ${r===e.id?`text-primary border-b-2 border-primary -mb-px`:`text-content-subtle hover:text-content`}`,children:e.label},e.id))}),(0,L.jsxs)(`div`,{className:`flex-1 overflow-auto p-4`,children:[r===`overview`&&(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-xs font-semibold text-content-subtle uppercase tracking-wider mb-2`,children:`Current Usage`}),(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(A0,{value:e.cpuPercent,label:`CPU`}),(0,L.jsx)(A0,{value:e.memoryPercent,label:`Memory`}),e.memoryLimit>0&&(0,L.jsxs)(`div`,{className:`text-xs text-content-subtle text-right`,children:[N0(e.memoryUsage),` / `,N0(e.memoryLimit)]})]})]}),t.cpuPercent.length>1&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-xs font-semibold text-content-subtle uppercase tracking-wider mb-2`,children:`5-Min History`}),(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-xs text-content-subtle mb-1`,children:`CPU %`}),(0,L.jsx)(`div`,{className:`w-full`,children:(0,L.jsx)(j0,{data:t.cpuPercent,color:`rgba(59,130,246,0.8)`,height:40})})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-xs text-content-subtle mb-1`,children:`Memory %`}),(0,L.jsx)(`div`,{className:`w-full`,children:(0,L.jsx)(j0,{data:t.memoryPercent,color:`rgba(168,85,247,0.8)`,height:40})})]})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-xs font-semibold text-content-subtle uppercase tracking-wider mb-2`,children:`Network I/O`}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,L.jsxs)(`div`,{className:`bg-surface p-2 rounded`,children:[(0,L.jsx)(`div`,{className:`text-xs text-content-subtle`,children:`In`}),(0,L.jsx)(`div`,{className:`text-sm font-medium text-content`,children:N0(e.networkIn)})]}),(0,L.jsxs)(`div`,{className:`bg-surface p-2 rounded`,children:[(0,L.jsx)(`div`,{className:`text-xs text-content-subtle`,children:`Out`}),(0,L.jsx)(`div`,{className:`text-sm font-medium text-content`,children:N0(e.networkOut)})]})]})]}),a&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-xs font-semibold text-content-subtle uppercase tracking-wider mb-2`,children:`Container Info`}),(0,L.jsxs)(`dl`,{className:`space-y-1 text-xs`,children:[a.uptime&&(0,L.jsxs)(`div`,{className:`flex justify-between`,children:[(0,L.jsx)(`dt`,{className:`text-content-subtle`,children:`Uptime`}),(0,L.jsx)(`dd`,{className:`text-content`,children:a.uptime})]}),a.created&&(0,L.jsxs)(`div`,{className:`flex justify-between`,children:[(0,L.jsx)(`dt`,{className:`text-content-subtle`,children:`Created`}),(0,L.jsx)(`dd`,{className:`text-content`,children:new Date(a.created).toLocaleString()})]}),(0,L.jsxs)(`div`,{className:`flex justify-between`,children:[(0,L.jsx)(`dt`,{className:`text-content-subtle`,children:`Status`}),(0,L.jsx)(`dd`,{className:`text-content`,children:a.status})]})]})]})]}),r===`logs`&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-xs font-semibold text-content-subtle uppercase tracking-wider mb-2`,children:`Recent Logs (tail 100)`}),a?.logs?(0,L.jsx)(`pre`,{className:`text-xs text-content bg-surface p-3 rounded overflow-auto max-h-[600px] font-mono whitespace-pre-wrap break-all`,children:a.logs}):(0,L.jsx)(`div`,{className:`text-xs text-content-subtle text-center py-8`,children:`Loading logs…`})]}),r===`ports-env`&&(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-xs font-semibold text-content-subtle uppercase tracking-wider mb-2`,children:`Port Mappings`}),a?.ports?.length?(0,L.jsx)(`div`,{className:`space-y-1`,children:a.ports.map((e,t)=>(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,L.jsx)(`span`,{className:`text-content font-mono`,children:e.host}),(0,L.jsx)(`span`,{className:`text-content-subtle`,children:`→`}),(0,L.jsxs)(`span`,{className:`text-content font-mono`,children:[e.container,`/`,e.protocol]})]},t))}):(0,L.jsx)(`div`,{className:`text-xs text-content-subtle`,children:`No port mappings`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-xs font-semibold text-content-subtle uppercase tracking-wider mb-2`,children:`Environment Variables`}),a?.env?.length?(0,L.jsx)(`div`,{className:`space-y-0.5 max-h-80 overflow-auto`,children:a.env.map((e,t)=>{let[n,...r]=e.split(`=`),i=r.join(`=`),a=/token|secret|key|pass|pwd|auth/i.test(n??``);return(0,L.jsxs)(`div`,{className:`text-xs font-mono flex gap-1 flex-wrap`,children:[(0,L.jsx)(`span`,{className:`text-primary`,children:n}),(0,L.jsx)(`span`,{className:`text-content-subtle`,children:`=`}),(0,L.jsx)(`span`,{className:`text-content break-all`,children:a?`***`:i})]},t)})}):(0,L.jsx)(`div`,{className:`text-xs text-content-subtle`,children:`No environment variables`})]})]})]})]})]})}async function FRe(){let e=await fetch(`/api/resources`);if(!e.ok)throw Error(`Failed to fetch resources`);return e.json()}async function IRe(e){let t=await fetch(`/api/resources/${e}/history`);if(!t.ok)throw Error(`Failed to fetch history`);return t.json()}function LRe(e,t,n){if(n===`issue`){let n=new Map;for(let t of e){let e=t.name.match(/(?:feature[_-])?([A-Z]+-\d+)/i),r=e?e[1].toUpperCase():`__ungrouped__`,i=e?e[1].toUpperCase():`Ungrouped`;n.has(r)||n.set(r,{key:r,label:i,containers:[],agents:[]}),n.get(r).containers.push(t)}for(let e of t){let t=e.issueId??`__ungrouped__`,r=e.issueId??`Ungrouped`;n.has(t)||n.set(t,{key:t,label:r,containers:[],agents:[]}),n.get(t).agents.push(e)}return Array.from(n.values()).sort((e,t)=>e.label.localeCompare(t.label))}if(n===`type`)return[{key:`containers`,label:`Containers`,containers:e,agents:[]},{key:`agents`,label:`Agents`,containers:[],agents:t}].filter(e=>e.containers.length+e.agents.length>0);let r=new Map;for(let t of e)r.has(t.status)||r.set(t.status,{key:t.status,label:t.status.charAt(0).toUpperCase()+t.status.slice(1),containers:[],agents:[]}),r.get(t.status).containers.push(t);for(let e of t)r.has(e.status)||r.set(e.status,{key:e.status,label:e.status.charAt(0).toUpperCase()+e.status.slice(1),containers:[],agents:[]}),r.get(e.status).agents.push(e);return Array.from(r.values())}function RRe({onNavigateToAgents:e}){let[t,n]=(0,I.useState)(`issue`),[r,i]=(0,I.useState)(`all`),[a,o]=(0,I.useState)(null);ERe();let{data:s,isLoading:c,error:l}=rt({queryKey:[`resources`],queryFn:FRe,refetchInterval:3e4}),{data:u}=rt({queryKey:[`container-history`,a?.id],queryFn:()=>IRe(a.id),enabled:!!a,refetchInterval:3e4});if(c)return(0,L.jsx)(`div`,{className:`p-6 text-content-subtle text-sm`,children:`Loading resources…`});if(l)return(0,L.jsxs)(`div`,{className:`p-6 text-destructive text-sm`,children:[`Failed to load resources: `,l.message]});let d=s?.containers??[],f=s?.agents??[],p=r===`running`?d.filter(e=>e.status===`running`):d,m=LRe(p,f,t),h=p.length+f.length;return(0,L.jsxs)(`div`,{className:`h-full flex flex-col overflow-hidden`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3 px-6 py-3 border-b border-divider shrink-0`,children:[(0,L.jsx)(`h2`,{className:`text-sm font-semibold text-content`,children:`Resources`}),(0,L.jsxs)(`span`,{className:`text-xs text-content-subtle`,children:[h,` items`]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-1 ml-4`,children:[(0,L.jsx)(`span`,{className:`text-xs text-content-subtle mr-1`,children:`Group by:`}),[`issue`,`type`,`status`].map(e=>(0,L.jsx)(`button`,{onClick:()=>n(e),className:`px-2 py-0.5 rounded text-xs transition-colors ${t===e?`bg-primary text-white`:`text-content-subtle hover:text-content hover:bg-surface-overlay`}`,children:e.charAt(0).toUpperCase()+e.slice(1)},e))]}),(0,L.jsx)(`div`,{className:`flex items-center gap-1`,children:[`all`,`running`].map(e=>(0,L.jsx)(`button`,{onClick:()=>i(e),className:`px-2 py-0.5 rounded text-xs transition-colors ${r===e?`bg-surface-overlay text-content`:`text-content-subtle hover:text-content hover:bg-surface-overlay`}`,children:e===`all`?`All`:`Running only`},e))}),s?.updatedAt&&(0,L.jsxs)(`span`,{className:`ml-auto text-xs text-content-subtle`,children:[`Updated `,new Date(s.updatedAt).toLocaleTimeString()]})]}),(0,L.jsx)(`div`,{className:`flex-1 overflow-auto p-6`,children:h===0?(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-64 text-content-subtle`,children:[(0,L.jsx)(`div`,{className:`text-4xl mb-3`,children:`📦`}),(0,L.jsx)(`div`,{className:`text-sm`,children:`No containers or agents found`}),(0,L.jsx)(`div`,{className:`text-xs mt-1`,children:`Docker may not be running or no workspaces are active`})]}):(0,L.jsx)(`div`,{className:`space-y-6`,children:m.map(t=>(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`h3`,{className:`text-xs font-semibold text-content-subtle uppercase tracking-wider mb-3`,children:[t.label,(0,L.jsxs)(`span`,{className:`ml-2 font-normal text-content-subtle/60`,children:[`(`,t.containers.length+t.agents.length,`)`]})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3`,children:[t.containers.map(e=>(0,L.jsx)(jRe,{container:e,history:(s?.containers,void 0),onClick:o},e.id)),t.agents.map(t=>(0,L.jsx)(MRe,{agent:t,onNavigate:e},t.id))]})]},t.key))})}),a&&(0,L.jsx)(PRe,{container:a,history:u??{timestamps:[],cpuPercent:[],memoryPercent:[]},onClose:()=>o(null)})]})}var P0=(0,I.createContext)({});function F0(e){let t=(0,I.useRef)(null);return t.current===null&&(t.current=e()),t.current}var I0=(0,I.createContext)(null),L0=(0,I.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`}),zRe=class extends I.Component{getSnapshotBeforeUpdate(e){let t=this.props.childRef.current;if(t&&e.isPresent&&!this.props.isPresent){let e=this.props.sizeRef.current;e.height=t.offsetHeight||0,e.width=t.offsetWidth||0,e.top=t.offsetTop,e.left=t.offsetLeft}return null}componentDidUpdate(){}render(){return this.props.children}};function BRe({children:e,isPresent:t}){let n=(0,I.useId)(),r=(0,I.useRef)(null),i=(0,I.useRef)({width:0,height:0,top:0,left:0}),{nonce:a}=(0,I.useContext)(L0);return(0,I.useInsertionEffect)(()=>{let{width:e,height:o,top:s,left:c}=i.current;if(t||!r.current||!e||!o)return;r.current.dataset.motionPopId=n;let l=document.createElement(`style`);return a&&(l.nonce=a),document.head.appendChild(l),l.sheet&&l.sheet.insertRule(`
186
+ `}isInline(){return!1}updateDOM(){return!1}};function CLe(){return{node:i0()}}function i0(){return zIe(SLe)}var wLe=u1({name:`@lexical/react/ReactProvider`});function TLe(){return RQ().getTextContent()}function ELe(e,t=!0){if(e)return!1;let n=TLe();return t&&(n=n.trim()),n===``}function DLe(e){if(!ELe(e,!1))return!1;let t=RQ().getChildren(),n=t.length;if(n>1)return!1;for(let e=0;e<n;e++){let n=t[e];if(eQ(n))return!1;if(Q(n)){if(!lQ(n)||n.__indent!==0)return!1;let t=n.getChildren(),r=t.length;for(let n=0;n<r;n++){let n=t[e];if(!XX(n))return!1}}}return!0}function a0(e){return()=>DLe(e)}function OLe(e){let t=window.location.origin,n=n=>{if(n.origin!==t)return;let r=e.getRootElement();if(document.activeElement!==r)return;let i=n.data;if(typeof i==`string`){let t;try{t=JSON.parse(i)}catch{return}if(t&&t.protocol===`nuanria_messaging`&&t.type===`request`){let r=t.payload;if(r&&r.functionId===`makeChanges`){let t=r.args;if(t){let[r,i,a,o,s]=t;e.update(()=>{let e=vZ();if(Z(e)){let t=e.anchor,c=t.getNode(),l=0,u=0;if(XX(c)&&r>=0&&i>=0&&(l=r,u=r+i,e.setTextNodeRange(c,l,c,u)),l===u&&a===``||(e.insertRawText(a),c=t.getNode()),XX(c)){l=o,u=o+s;let t=c.getTextContentSize();l=l>t?t:l,u=u>t?t:u,e.setTextNodeRange(c,l,c,u)}n.stopImmediatePropagation()}})}}}}};return window.addEventListener(`message`,n,!0),()=>{window.removeEventListener(`message`,n,!0)}}function kLe(e,t){if(typeof document>`u`||typeof window>`u`&&global.window===void 0)throw Error(`To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.`);let n=document.createElement(`div`),r=RQ().getChildren();for(let i=0;i<r.length;i++)o0(e,r[i],n,t);return n.innerHTML}function o0(e,t,n,r=null){let i=r===null||t.isSelected(r),a=Q(t)&&t.excludeFromCopy(`html`),o=t;r!==null&&XX(t)&&(o=cLe(r,t,`clone`));let s=Q(o)?o.getChildren():[],c=gQ(e,o.getType()),l;l=c&&c.exportDOM!==void 0?c.exportDOM(e,o):o.exportDOM(e);let{element:u,after:d}=l;if(!u)return!1;let f=document.createDocumentFragment();for(let n=0;n<s.length;n++){let a=s[n],o=o0(e,a,f,r);!i&&Q(t)&&o&&t.extractWithChild(a,r,`html`)&&(i=!0)}if(i&&!a){if((v$(u)||b$(u))&&u.append(f),n.append(u),d){let e=d.call(o,u);e&&(b$(u)?u.replaceChildren(e):u.replaceWith(e))}}else n.append(f);return i}function ALe(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function jLe(e,t=vZ()){return t??ALe(166),Z(t)&&t.isCollapsed()||t.getNodes().length===0?``:kLe(e,t)}function s0(e,t){let n=e.getData(`text/plain`)||e.getData(`text/uri-list`);n!=null&&t.insertRawText(n)}var c0=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,MLe=c0&&`documentMode`in document?document.documentMode:null,NLe=c0&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),PLe=!(!c0||!(`InputEvent`in window)||MLe)&&`getTargetRanges`in new window.InputEvent(`input`),FLe=c0&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),l0=c0&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,ILe=c0&&/^(?=.*Chrome).*/i.test(navigator.userAgent),LLe=c0&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&NLe&&!ILe;function u0(e,t){t.update(()=>{if(e!==null){let n=w1(e,KeyboardEvent)?null:e.clipboardData,r=vZ();if(r!==null&&!r.isCollapsed()&&n!=null){e.preventDefault();let i=jLe(t);i!==null&&n.setData(`text/html`,i),n.setData(`text/plain`,r.getTextContent())}}})}function RLe(e){return f1(e.registerCommand(MY,e=>{let t=vZ();return!!Z(t)&&(t.deleteCharacter(e),!0)},0),e.registerCommand(RY,e=>{let t=vZ();return!!Z(t)&&(t.deleteWord(e),!0)},0),e.registerCommand(zY,e=>{let t=vZ();return!!Z(t)&&(t.deleteLine(e),!0)},0),e.registerCommand(FY,e=>{let t=vZ();if(!Z(t))return!1;if(typeof e==`string`)t.insertText(e);else{let n=e.dataTransfer;if(n!=null)s0(n,t);else{let n=e.data;n&&t.insertText(n)}}return!0},0),e.registerCommand(LY,()=>{let e=vZ();return!!Z(e)&&(e.removeText(),!0)},0),e.registerCommand(NY,e=>{let t=vZ();return!!Z(t)&&(t.insertLineBreak(e),!0)},0),e.registerCommand(PY,()=>{let e=vZ();return!!Z(e)&&(e.insertLineBreak(),!0)},0),e.registerCommand(GY,e=>{let t=vZ();if(!Z(t))return!1;let n=e,r=n.shiftKey;return!!b1(t,!0)&&(n.preventDefault(),S1(t,r,!0),!0)},0),e.registerCommand(WY,e=>{let t=vZ();if(!Z(t))return!1;let n=e,r=n.shiftKey;return!!b1(t,!1)&&(n.preventDefault(),S1(t,r,!1),!0)},0),e.registerCommand(qY,t=>!!Z(vZ())&&(!l0||navigator.language!==`ko-KR`)&&(t.preventDefault(),e.dispatchCommand(MY,!0)),0),e.registerCommand(JY,t=>!!Z(vZ())&&(t.preventDefault(),e.dispatchCommand(MY,!1)),0),e.registerCommand(KY,t=>{if(!Z(vZ()))return!1;if(t!==null){if((l0||FLe||LLe)&&PLe)return!1;t.preventDefault()}return e.dispatchCommand(NY,!1)},0),e.registerCommand($Y,()=>(OIe(),!0),0),e.registerCommand(ZY,t=>!!Z(vZ())&&(u0(t,e),!0),0),e.registerCommand(QY,t=>!!Z(vZ())&&(function(e,t){u0(e,t),t.update(()=>{let e=vZ();Z(e)&&e.removeText()})}(t,e),!0),0),e.registerCommand(IY,t=>!!Z(vZ())&&(function(e,t){e.preventDefault(),t.update(()=>{let t=vZ(),n=w1(e,ClipboardEvent)?e.clipboardData:null;n!=null&&Z(t)&&s0(n,t)},{tag:`paste`})}(t,e),!0),0),e.registerCommand(YY,e=>!!Z(vZ())&&(e.preventDefault(),!0),0),e.registerCommand(XY,e=>!!Z(vZ())&&(e.preventDefault(),!0),0))}function zLe(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}var d0=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0?I.useLayoutEffect:I.useEffect;function BLe({editor:e,ErrorBoundary:t}){return function(e,t){let[n,r]=(0,I.useState)(()=>e.getDecorators());return d0(()=>e.registerDecoratorListener(e=>{(0,Er.flushSync)(()=>{r(e)})}),[e]),(0,I.useEffect)(()=>{r(e.getDecorators())},[e]),(0,I.useMemo)(()=>{let r=[],i=Object.keys(n);for(let a=0;a<i.length;a++){let o=i[a],s=(0,L.jsx)(t,{onError:t=>e._onError(t),children:(0,L.jsx)(I.Suspense,{fallback:null,children:n[o]})}),c=e.getElementByKey(o);c!==null&&r.push((0,Er.createPortal)(s,c,o))}return r},[t,n,e])}(e,t)}function VLe({editor:e,ErrorBoundary:t}){return function(e){let t=xLe.maybeFromEditor(e);if(t&&t.hasExtensionByName(wLe.name)){for(let e of[`@lexical/plain-text`,`@lexical/rich-text`])t.hasExtensionByName(e)&&zLe(320,e);return!0}return!1}(e)?null:(0,L.jsx)(BLe,{editor:e,ErrorBoundary:t})}function f0(e){return e.getEditorState().read(a0(e.isComposing()))}function HLe({contentEditable:e,placeholder:t=null,ErrorBoundary:n}){let[r]=m1();return function(e){d0(()=>f1(RLe(e),OLe(e)),[e])}(r),(0,L.jsxs)(L.Fragment,{children:[e,(0,L.jsx)(ULe,{content:t}),(0,L.jsx)(VLe,{editor:r,ErrorBoundary:n})]})}function ULe({content:e}){let[t]=m1(),n=function(e){let[t,n]=(0,I.useState)(()=>f0(e));return d0(()=>{function t(){n(f0(e))}return t(),f1(e.registerUpdateListener(()=>{t()}),e.registerEditableListener(()=>{t()}))},[e]),t}(t),r=oLe();return n?typeof e==`function`?e(r):e:null}var p0=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0?I.useLayoutEffect:I.useEffect;function WLe({editor:e,ariaActiveDescendant:t,ariaAutoComplete:n,ariaControls:r,ariaDescribedBy:i,ariaErrorMessage:a,ariaExpanded:o,ariaInvalid:s,ariaLabel:c,ariaLabelledBy:l,ariaMultiline:u,ariaOwns:d,ariaRequired:f,autoCapitalize:p,className:m,id:h,role:g=`textbox`,spellCheck:_=!0,style:v,tabIndex:y,"data-testid":b,...x},S){let[C,w]=(0,I.useState)(e.isEditable()),T=(0,I.useCallback)(t=>{t&&t.ownerDocument&&t.ownerDocument.defaultView?e.setRootElement(t):e.setRootElement(null)},[e]),E=(0,I.useMemo)(()=>function(...e){return t=>{for(let n of e)typeof n==`function`?n(t):n!=null&&(n.current=t)}}(S,T),[T,S]);return p0(()=>(w(e.isEditable()),e.registerEditableListener(e=>{w(e)})),[e]),(0,L.jsx)(`div`,{"aria-activedescendant":C?t:void 0,"aria-autocomplete":C?n:`none`,"aria-controls":C?r:void 0,"aria-describedby":i,...a==null?{}:{"aria-errormessage":a},"aria-expanded":C&&g===`combobox`?!!o:void 0,...s==null?{}:{"aria-invalid":s},"aria-label":c,"aria-labelledby":l,"aria-multiline":u,"aria-owns":C?d:void 0,"aria-readonly":!C||void 0,"aria-required":f,autoCapitalize:p,className:m,contentEditable:C,"data-testid":b,id:h,ref:E,role:g,spellCheck:_,style:v,tabIndex:y,...x})}var GLe=(0,I.forwardRef)(WLe);function m0(e){return e.getEditorState().read(a0(e.isComposing()))}var KLe=(0,I.forwardRef)(qLe);function qLe(e,t){let{placeholder:n,...r}=e,[i]=m1();return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(GLe,{editor:i,...r,ref:t}),n!=null&&(0,L.jsx)(JLe,{editor:i,content:n})]})}function JLe({content:e,editor:t}){let n=function(e){let[t,n]=(0,I.useState)(()=>m0(e));return p0(()=>{function t(){n(m0(e))}return t(),f1(e.registerUpdateListener(()=>{t()}),e.registerEditableListener(()=>{t()}))},[e]),t}(t),[r,i]=(0,I.useState)(t.isEditable());if((0,I.useLayoutEffect)(()=>(i(t.isEditable()),t.registerEditableListener(e=>{i(e)})),[t]),!n)return null;let a=null;return typeof e==`function`?a=e(r):e!==null&&(a=e),a===null?null:(0,L.jsx)(`div`,{"aria-hidden":!0,children:a})}function YLe(e,t,n,r,i){if(e===null||n.size===0&&r.size===0&&!i)return 0;let a=t._selection,o=e._selection;if(i)return 1;if(!(Z(a)&&Z(o)&&o.isCollapsed()&&a.isCollapsed()))return 0;let s=function(e,t,n){let r=e._nodeMap,i=[];for(let e of t){let t=r.get(e);t!==void 0&&i.push(t)}for(let[e,t]of n){if(!t)continue;let n=r.get(e);n===void 0||nQ(n)||i.push(n)}return i}(t,n,r);if(s.length===0)return 0;if(s.length>1){let n=t._nodeMap,r=n.get(a.anchor.key),i=n.get(o.anchor.key);return r&&i&&!e._nodeMap.has(r.__key)&&XX(r)&&r.__text.length===1&&a.anchor.offset===1?2:0}let c=s[0],l=e._nodeMap.get(c.__key);if(!XX(l)||!XX(c)||l.__mode!==c.__mode)return 0;let u=l.__text,d=c.__text;if(u===d)return 0;let f=a.anchor,p=o.anchor;if(f.key!==p.key||f.type!==`text`)return 0;let m=f.offset,h=p.offset,g=d.length-u.length;return g===1&&h===m-1?2:g===-1&&h===m+1?3:g===-1&&h===m?4:0}function XLe(e,t){let n=Date.now(),r=0,i=Date.now(),a=0,o=null;return(s,c,l,u,d,f)=>{let p=Date.now();if(f.has(`composition-start`)&&(i=n,a=r,o=s),f.has(`historic`))return r=0,n=p,2;f.has(`composition-end`)&&o&&(n=i,r=a,s=o);let m=YLe(s,c,u,d,e.isComposing()),h=(()=>{let i=l===null||l.editor===e,a=f.has(rIe);if(!a&&i&&f.has(`history-merge`))return 0;if(m===1)return 2;if(s===null)return 1;let o=c._selection;if(!(u.size>0||d.size>0))return o===null?2:0;let h=typeof t==`number`?t:t.peek();return!1===a&&m!==0&&m===r&&p<n+h&&i||u.size===1&&function(e,t,n){let r=t._nodeMap.get(e),i=n._nodeMap.get(e),a=t._selection,o=n._selection;return!(Z(a)&&Z(o)&&a.anchor.type===`element`&&a.focus.type===`element`&&o.anchor.type===`text`&&o.focus.type===`text`||!XX(r)||!XX(i)||r.__parent!==i.__parent)&&JSON.stringify(t.read(()=>r.exportJSON()))===JSON.stringify(n.read(()=>i.exportJSON()))}(Array.from(u)[0],s,c)?0:1})();return n=p,r=m,h}}function h0(e){e.undoStack=[],e.redoStack=[],e.current=null}function ZLe(e,t,n){let r=XLe(e,n);return f1(e.registerCommand(VY,()=>(function(e,t){let n=t.redoStack,r=t.undoStack;if(r.length!==0){let i=t.current,a=r.pop();i!==null&&(n.push(i),e.dispatchCommand(eX,!0)),r.length===0&&e.dispatchCommand(tX,!1),t.current=a||null,a&&a.editor.setEditorState(a.editorState,{tag:`historic`})}}(e,t),!0),0),e.registerCommand(HY,()=>(function(e,t){let n=t.redoStack,r=t.undoStack;if(n.length!==0){let i=t.current;i!==null&&(r.push(i),e.dispatchCommand(tX,!0));let a=n.pop();n.length===0&&e.dispatchCommand(eX,!1),t.current=a||null,a&&a.editor.setEditorState(a.editorState,{tag:`historic`})}}(e,t),!0),0),e.registerCommand(KFe,()=>(h0(t),!1),0),e.registerCommand(qFe,()=>(h0(t),e.dispatchCommand(eX,!1),e.dispatchCommand(tX,!1),!0),0),e.registerUpdateListener(({editorState:n,prevEditorState:i,dirtyLeaves:a,dirtyElements:o,tags:s})=>{let c=t.current,l=t.redoStack,u=t.undoStack,d=c===null?null:c.editorState;if(c!==null&&n===d)return;let f=r(i,n,c,a,o,s);if(f===1)l.length!==0&&(t.redoStack=[],e.dispatchCommand(eX,!1)),c!==null&&(u.push({...c}),e.dispatchCommand(tX,!0));else if(f===2)return;t.current={editor:e,editorState:n}}))}function QLe(){return{current:null,redoStack:[],undoStack:[]}}function $Le({delay:e,externalHistoryState:t}){let[n]=m1();return function(e,t,n=1e3){let r=(0,I.useMemo)(()=>t||QLe(),[t]);(0,I.useEffect)(()=>ZLe(e,r,n),[n,e,r])}(n,t,e),null}var eRe=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0?I.useLayoutEffect:I.useEffect;function tRe({ignoreHistoryMergeTagChange:e=!0,ignoreSelectionChange:t=!1,onChange:n}){let[r]=m1();return eRe(()=>{if(n)return r.registerUpdateListener(({editorState:i,dirtyElements:a,dirtyLeaves:o,prevEditorState:s,tags:c})=>{t&&a.size===0&&o.size===0||e&&c.has(`history-merge`)||s.isEmpty()||n(i,r,c)})},[r,e,t,n]),null}function g0(e){return`conv-draft:${e}`}function nRe(e){try{return localStorage.getItem(g0(e))??``}catch{return``}}function rRe(e,t){try{t?localStorage.setItem(g0(e),t):localStorage.removeItem(g0(e))}catch{}}var _0=[{id:`model`,label:`/model`,description:`Switch the AI model for this conversation`,insert:`/model `},{id:`context`,label:`/context`,description:`Add context from a file or URL`,insert:`/context `},{id:`effort`,label:`/effort`,description:`Set effort level (low, medium, high)`,insert:`/effort `},{id:`cancel`,label:`/cancel`,description:`Cancel the current operation`,insert:`/cancel`}];function iRe({conversationName:e,onCommandKeyDown:t,onTextChange:n,onSlashKey:r}){let[i]=m1(),a=(0,I.useRef)(null);return(0,I.useEffect)(()=>i.registerCommand(KY,e=>e?.shiftKey?!1:(e?.preventDefault(),t(`Enter`),!0),3),[i,t]),(0,I.useEffect)(()=>{let e=i.getRootElement();if(!e)return;let t=t=>{if(t.key===`/`&&!t.ctrlKey&&!t.metaKey&&!t.altKey){let n=t.target;(n===e||e.contains(n))&&r()}};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[i,r]),(0,L.jsx)(tRe,{onChange:(0,I.useCallback)(()=>{i.read(()=>{let t=RQ().getTextContent();n(t),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{rRe(e,t)},300)})},[i,e,n])})}function aRe({editorRef:e}){let[t]=m1();return(0,I.useEffect)(()=>(e.current=t,()=>{e.current=null}),[t,e]),null}function oRe({commands:e,filter:t,selectedIndex:n,onSelect:r,onClose:i,anchorRect:a}){let o=e.filter(e=>e.label.toLowerCase().includes(t.toLowerCase())||e.description.toLowerCase().includes(t.toLowerCase()));if((0,I.useEffect)(()=>{let e=e=>{e.target.closest(`.${Y.slashMenu}`)||i()};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[i]),o.length===0)return null;let s=a?a.bottom+4:0,c=a?a.left:0;return(0,L.jsx)(`div`,{className:Y.slashMenu,style:{top:s,left:c},role:`listbox`,"aria-label":`Slash commands`,children:o.map((e,t)=>(0,L.jsxs)(`button`,{className:`${Y.slashMenuItem} ${t===n?Y.slashMenuItemSelected:``}`,onClick:()=>r(e),role:`option`,"aria-selected":t===n,children:[(0,L.jsx)(`span`,{className:Y.slashMenuLabel,children:e.label}),(0,L.jsx)(`span`,{className:Y.slashMenuDescription,children:e.description})]},e.id))})}function v0({conversationName:e,disabled:t=!1,placeholder:n=`Message Claude…`,onCommandKeyDown:r,editorRef:i,onChange:a}){let o=nRe(e),[s,c]=(0,I.useState)(o),[l,u]=(0,I.useState)(!1),[d,f]=(0,I.useState)(0),[p,m]=(0,I.useState)(null),[h,g]=(0,I.useState)(``),_={namespace:`composer:${e}`,onError:e=>console.error(`[ComposerPromptEditor]`,e),...o?{editorState:e=>{let t=RQ(),n=cQ();n.append(YX(o)),t.append(n)}}:{}},v=(0,I.useCallback)(e=>{c(e),a?.(e)},[a]),y=(0,I.useCallback)(()=>{let e=window.getSelection();e&&e.rangeCount>0&&m(e.getRangeAt(0).getBoundingClientRect()),u(!0),f(0),g(``)},[]),b=(0,I.useCallback)(e=>{let t=i?.current;t&&t.update(()=>{let t=RQ(),n=RQ().getTextContent(),r=n.endsWith(`/`)?n.slice(0,-1):n;t.clear();let i=cQ();i.append(YX(r+e.insert)),t.append(i)}),u(!1),f(0)},[i]),x=(0,I.useCallback)(()=>{u(!1),f(0)},[]);return(0,I.useEffect)(()=>{if(!l)return;let e=_0.filter(e=>e.label.toLowerCase().includes(h.toLowerCase())||e.description.toLowerCase().includes(h.toLowerCase()));if(e.length===0)return;let t=t=>{t.key===`ArrowDown`?(t.preventDefault(),f(t=>(t+1)%e.length)):t.key===`ArrowUp`?(t.preventDefault(),f(t=>(t-1+e.length)%e.length)):t.key===`Enter`?(t.preventDefault(),b(e[d])):t.key===`Escape`?(t.preventDefault(),x()):t.key===`Backspace`?g(e=>e.slice(0,-1)):t.key.length===1&&!t.ctrlKey&&!t.metaKey&&!t.altKey&&g(e=>e+t.key)};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[l,d,h,b,x]),(0,L.jsxs)(`div`,{style:{position:`relative`},children:[(0,L.jsx)(rLe,{initialConfig:_,children:(0,L.jsxs)(`div`,{className:`${Y.composerEditor} ${t?Y.composerEditorDisabled:``}`,children:[(0,L.jsx)(HLe,{contentEditable:(0,L.jsx)(KLe,{className:Y.composerEditable,"aria-placeholder":n,placeholder:()=>s?null:(0,L.jsx)(`div`,{className:Y.composerPlaceholder,children:n})}),ErrorBoundary:({children:e})=>(0,L.jsx)(L.Fragment,{children:e})}),(0,L.jsx)($Le,{}),(0,L.jsx)(iRe,{conversationName:e,onCommandKeyDown:r,onTextChange:v,onSlashKey:y}),i&&(0,L.jsx)(aRe,{editorRef:i})]})}),l&&(0,L.jsx)(oRe,{commands:_0,filter:h,selectedIndex:d,onSelect:b,onClose:x,anchorRect:p})]})}function sRe({className:e,style:t}){return(0,L.jsx)(`svg`,{className:e,style:t,preserveAspectRatio:`xMidYMid`,viewBox:`0 0 256 257`,fill:`currentColor`,"aria-hidden":`true`,children:(0,L.jsx)(`path`,{d:`m50.228 170.321 50.357-28.257.843-2.463-.843-1.361h-2.462l-8.426-.518-28.775-.778-24.952-1.037-24.175-1.296-6.092-1.297L0 125.796l.583-3.759 5.12-3.434 7.324.648 16.202 1.101 24.304 1.685 17.629 1.037 26.118 2.722h4.148l.583-1.685-1.426-1.037-1.101-1.037-25.147-17.045-27.22-18.017-14.258-10.37-7.713-5.25-3.888-4.925-1.685-10.758 7-7.713 9.397.649 2.398.648 9.527 7.323 20.35 15.75L94.817 91.9l3.889 3.24 1.555-1.102.195-.777-1.75-2.917-14.453-26.118-15.425-26.572-6.87-11.018-1.814-6.61c-.648-2.723-1.102-4.991-1.102-7.778l7.972-10.823L71.42 0 82.05 1.426l4.472 3.888 6.61 15.101 10.694 23.786 16.591 32.34 4.861 9.592 2.592 8.879.973 2.722h1.685v-1.556l1.36-18.211 2.528-22.36 2.463-28.776.843-8.1 4.018-9.722 7.971-5.25 6.222 2.981 5.12 7.324-.713 4.73-3.046 19.768-5.962 30.98-3.889 20.739h2.268l2.593-2.593 10.499-13.934 17.628-22.036 7.778-8.749 9.073-9.657 5.833-4.601h11.018l8.1 12.055-3.628 12.443-11.342 14.388-9.398 12.184-13.48 18.147-8.426 14.518.778 1.166 2.01-.194 30.46-6.481 16.462-2.982 19.637-3.37 8.88 4.148.971 4.213-3.5 8.62-20.998 5.184-24.628 4.926-36.682 8.685-.454.324.519.648 16.526 1.555 7.065.389h17.304l32.21 2.398 8.426 5.574 5.055 6.805-.843 5.184-12.962 6.611-17.498-4.148-40.83-9.721-14-3.5h-1.944v1.167l11.666 11.406 21.387 19.314 26.767 24.887 1.36 6.157-3.434 4.86-3.63-.518-23.526-17.693-9.073-7.972-20.545-17.304h-1.36v1.814l4.73 6.935 25.017 37.59 1.296 11.536-1.814 3.76-6.481 2.268-7.13-1.297-14.647-20.544-15.1-23.138-12.185-20.739-1.49.843-7.194 77.448-3.37 3.953-7.778 2.981-6.48-4.925-3.436-7.972 3.435-15.749 4.148-20.544 3.37-16.333 3.046-20.285 1.815-6.74-.13-.454-1.49.194-15.295 20.999-23.267 31.433-18.406 19.702-4.407 1.75-7.648-3.954.713-7.064 4.277-6.286 25.47-32.405 15.36-20.092 9.917-11.6-.065-1.686h-.583L44.07 198.125l-12.055 1.555-5.185-4.86.648-7.972 2.463-2.593 20.35-13.999-.064.065Z`})})}function cRe({provider:e,className:t,style:n}){return e===`anthropic`?(0,L.jsx)(sRe,{className:t,style:n}):null}var y0={"claude-opus-4-6":[`low`,`medium`,`high`,`max`],"claude-sonnet-4-6":[`low`,`medium`,`high`],"claude-haiku-4-5-20251001":[]},lRe={...y0},uRe={anthropic:`Anthropic`,openai:`OpenAI`,google:`Google`,zai:`Z.AI`,kimi:`Kimi`,minimax:`MiniMax`,openrouter:`OpenRouter`},dRe=[{provider:`anthropic`,label:`Anthropic`,usable:!0,models:[{id:`claude-opus-4-6`,label:`Claude Opus 4.6`,provider:`anthropic`,costDisplay:`$45/1M`,effortLevels:[`low`,`medium`,`high`,`max`]},{id:`claude-sonnet-4-6`,label:`Claude Sonnet 4.6`,provider:`anthropic`,costDisplay:`$15/1M`,effortLevels:[`low`,`medium`,`high`]},{id:`claude-haiku-4-5-20251001`,label:`Claude Haiku 4.5`,provider:`anthropic`,costDisplay:`$1/1M`,effortLevels:[]}]}],b0=`conv-composer-model`,fRe=`claude-opus-4-6`;function x0(){try{let e=localStorage.getItem(b0);if(e)return e}catch{}return fRe}function S0(e){return e===0?`FREE`:e<1?`$${e.toFixed(2)}/1M`:`$${Math.round(e)}/1M`}function C0({value:e,onChange:t,disabled:n=!1}){let[r,i]=(0,I.useState)(!1),[a,o]=(0,I.useState)(dRe),s=(0,I.useRef)(null);(0,I.useEffect)(()=>{async function n(){try{let[n,r,i]=await Promise.allSettled([fetch(`/api/settings/available-models`).then(e=>e.json()),fetch(`/api/settings/openrouter/models`).then(e=>e.json()),fetch(`/api/settings/claude-auth`).then(e=>e.json())]),a=n.status===`fulfilled`?n.value:{},s=a.usable??{},c=r.status===`fulfilled`?r.value:{models:[],favorites:[]},l=i.status===`fulfilled`?i.value:null,u=s.anthropic??!1,d=u?`key`:`noauth`,f;l?.loggedIn&&l.subscriptionType?(d=`sub`,f=l.subscriptionType.toUpperCase()):l?.hasAnthropicApiKey&&(d=`key`);let p=[];for(let[e,t]of Object.entries(a)){if(e===`openrouter`||e===`usable`||!Array.isArray(t)||t.length===0)continue;let n=e===`anthropic`?u:s[e]??!1;p.push({provider:e,label:uRe[e]??e,usable:n,models:t.map(t=>({id:t.id,label:t.name,provider:e,costDisplay:e===`anthropic`&&d===`sub`?void 0:S0(t.costPer1MTokens),effortLevels:lRe[t.id]??[],authMode:e===`anthropic`?d:void 0,authBadge:e===`anthropic`?f:void 0}))})}let m=c.favorites??[],h=(c.models??[]).filter(e=>m.includes(e.id));if(h.length>0&&p.push({provider:`openrouter`,label:`OpenRouter`,usable:s.openrouter??!1,models:h.map(e=>({id:e.id,label:e.name,provider:`openrouter`,costDisplay:S0(e.promptCostPer1M),effortLevels:e.supportsThinking?[`low`,`medium`,`high`]:[]}))}),p.length>0){o(p);let n=p.flatMap(e=>e.models).find(t=>t.id===e)?.provider;if(!(p.find(e=>e.provider===n)?.usable??!0)){let e=p.find(e=>e.usable&&e.models.length>0);if(e){let n=e.models[0];t(n.id,n.effortLevels),localStorage.setItem(b0,n.id)}}}}catch{}}n()},[]);let c=a.flatMap(e=>e.models).find(t=>t.id===e);(0,I.useEffect)(()=>{if(!r)return;function e(e){s.current&&!s.current.contains(e.target)&&i(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[r]);function l(e){t(e.id,e.effortLevels),localStorage.setItem(b0,e.id),i(!1)}let u=c?.label??e,d=c?.authBadge??null,f=c?.provider??``,[p,m]=(0,I.useState)({x:0,y:0});return(0,L.jsxs)(`div`,{ref:s,className:Y.pickerContainer,children:[(0,L.jsxs)(`button`,{className:Y.pickerBtn,onClick:e=>{if(!r){let t=e.currentTarget.getBoundingClientRect(),n=t.top>=300?t.top-4:t.bottom+4;m({x:t.left,y:n})}i(e=>!e)},disabled:n,type:`button`,children:[(0,L.jsx)(cRe,{provider:f,className:Y.pickerProviderIcon,style:f===`anthropic`?{color:`#d97757`}:void 0}),(0,L.jsx)(`span`,{className:Y.pickerLabel,children:u}),d&&(0,L.jsx)(`span`,{className:Y.pickerAuthBadge,children:d}),(0,L.jsx)(Tt,{size:10})]}),r&&(0,L.jsx)(`div`,{className:Y.pickerDropdown,style:{left:p.x,top:p.y},children:a.filter(e=>e.usable).map(t=>(0,L.jsxs)(`div`,{children:[a.filter(e=>e.usable).length>1&&(0,L.jsx)(`div`,{className:Y.pickerGroupHeader,children:t.label}),t.models.map(n=>(0,L.jsxs)(`button`,{className:`${Y.pickerOption} ${n.id===e?Y.pickerOptionActive:``}`,onClick:()=>l(n),type:`button`,children:[(0,L.jsx)(`span`,{className:Y.pickerOptionLabel,children:n.label}),n.authBadge&&t.usable&&(0,L.jsx)(`span`,{className:Y.pickerAuthBadge,children:n.authBadge}),n.costDisplay&&t.usable&&!n.authBadge&&(0,L.jsx)(`span`,{className:Y.pickerCostBadge,children:n.costDisplay})]},n.id))]},t.provider))})]})}var w0=[{id:`low`,label:`Low`},{id:`medium`,label:`Medium (default)`},{id:`high`,label:`High`},{id:`max`,label:`Max`}],T0=`conv-composer-effort`,pRe=`medium`;function E0(){try{let e=localStorage.getItem(T0);if(e&&w0.some(t=>t.id===e))return e}catch{}return pRe}function D0({value:e,onChange:t,disabled:n=!1,availableLevels:r}){let[i,a]=(0,I.useState)(!1),o=(0,I.useRef)(null),s=r!==void 0&&r.length===0,c=r&&r.length>0?w0.filter(e=>r.includes(e.id)):w0,l=c.find(t=>t.id===e)??c[0]??w0[1];(0,I.useEffect)(()=>{if(!i)return;function e(e){o.current&&!o.current.contains(e.target)&&a(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[i]);function u(e){t(e),localStorage.setItem(T0,e),a(!1)}return s?(0,L.jsx)(`div`,{className:Y.pickerContainer,children:(0,L.jsx)(`span`,{className:Y.pickerHint,children:`effort n/a for this model`})}):(0,L.jsxs)(`div`,{ref:o,className:Y.pickerContainer,children:[(0,L.jsxs)(`button`,{className:Y.pickerBtn,onClick:()=>a(e=>!e),disabled:n,type:`button`,children:[(0,L.jsx)(`span`,{className:Y.pickerLabel,children:l.label}),(0,L.jsx)(Tt,{size:11})]}),i&&(0,L.jsx)(`div`,{className:Y.pickerDropdown,children:c.map(t=>(0,L.jsx)(`button`,{className:`${Y.pickerOption} ${t.id===e?Y.pickerOptionActive:``}`,onClick:()=>u(t.id),type:`button`,children:t.label},t.id))})]})}async function mRe(e,t){let n=await fetch(`/api/conversations/${encodeURIComponent(e)}/switch-model`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({model:t})});if(!n.ok){let e=await n.text().catch(()=>``);throw Error(`Failed to switch model (${n.status})${e?`: ${e}`:``}`)}}async function O0(e,t){let n=await fetch(`/api/conversations/${encodeURIComponent(e)}/message`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({message:t})});if(!n.ok){let e=await n.text().catch(()=>``);throw Error(`Failed to send message (${n.status})${e?`: ${e}`:``}`)}}function hRe({conversation:e,onSend:t}){let[n,r]=(0,I.useState)(x0),[i,a]=(0,I.useState)(E0),[o,s]=(0,I.useState)(!1),[c,l]=(0,I.useState)(``),u=(0,I.useRef)(null),d=!e.sessionAlive||o,f=c.trim()===``,p=(0,I.useCallback)((t,n)=>{r(t),e.sessionAlive&&O0(e.name,`/model ${t}`).catch(e=>{console.error(`[ComposerFooter] Failed to send /model:`,e)})},[e.name,e.sessionAlive]),m=(0,I.useCallback)(async()=>{let r=u.current;if(!r){console.warn(`[ComposerFooter] handleSubmit: editor ref not ready`);return}if(d){console.warn(`[ComposerFooter] handleSubmit: isDisabled=true, sessionAlive=%s sending=%s`,e.sessionAlive,o);return}let i=``;if(r.read(()=>{i=RQ().getTextContent().trim()}),i){t?.(i),s(!0);try{n!==e.model&&e.sessionAlive&&(await mRe(e.name,n),await new Promise(e=>setTimeout(e,2e3))),await O0(e.name,i),r.update(()=>{RQ().clear()}),l(``)}catch(e){console.error(`[ComposerFooter] Failed to send:`,e),Br.error(e instanceof Error?e.message:`Failed to send message`)}finally{s(!1),r.focus()}}},[n,e.name,e.model,e.sessionAlive,o,d,t]),h=(0,I.useCallback)(e=>{e===`Enter`&&m()},[m]);return(0,L.jsx)(`div`,{className:Y.composerFooter,children:(0,L.jsxs)(`div`,{className:Y.composerBox,children:[(0,L.jsx)(v0,{conversationName:e.name,disabled:d,onCommandKeyDown:h,editorRef:u,onChange:l}),(0,L.jsxs)(`div`,{className:Y.composerToolbar,children:[(0,L.jsx)(C0,{value:n,onChange:p,disabled:d}),(0,L.jsx)(`div`,{className:Y.composerToolbarDivider}),(0,L.jsx)(D0,{value:i,onChange:a,disabled:!0,availableLevels:y0[n]}),(0,L.jsx)(`div`,{className:Y.composerToolbarSpacer}),(0,L.jsx)(`button`,{className:Y.sendButton,onClick:()=>void m(),disabled:f||d,type:`button`,title:`Send message (Enter)`,children:(0,L.jsx)(Kn,{size:16})})]})]})})}async function gRe(e,t,n){let r=await fetch(`/api/conversations/${encodeURIComponent(e)}/resume`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({model:t,effort:n})});if(!r.ok)throw Error(`Failed to resume conversation`);return r.json()}function _Re({conversation:e,onArchived:t}){let[n,r]=(0,I.useState)(`conversation`),[i,a]=(0,I.useState)(!1),[o,s]=(0,I.useState)(()=>e.model||`claude-opus-4-6`),c=He(),{data:l}=rt({queryKey:[`conversation-messages`,e.name],queryFn:()=>k0(e.name),refetchInterval:e.sessionAlive?2e3:!1}),u=l?.streaming??!1,d=it({mutationFn:()=>gRe(e.name,o),onSuccess:()=>{c.invalidateQueries({queryKey:[`conversations`]}),a(!0)}}),f=it({mutationFn:t=>fetch(`/api/conversations/${encodeURIComponent(e.name)}/switch-model`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({model:t})}).then(e=>{if(!e.ok)throw Error(`Failed to switch model`);return e.json()}),onSuccess:()=>{c.invalidateQueries({queryKey:[`conversations`]}),c.invalidateQueries({queryKey:[`conversation-messages`,e.name]})}}),p=(0,I.useCallback)(()=>{d.mutate()},[d]),m=(0,I.useCallback)(async()=>{try{await fetch(`/api/conversations/${encodeURIComponent(e.name)}/archive`,{method:`POST`}),c.invalidateQueries({queryKey:[`conversations`]}),t?.()}catch(e){console.error(`[ConversationPanel] Archive failed:`,e)}},[e.name,c,t]),h=(0,I.useCallback)(e=>{r(e)},[]),g=e.sessionAlive||i,_=e.sessionAlive?`var(--mc-success)`:`var(--mc-text-muted)`,v=e.sessionAlive?`active`:`ended`;return(0,L.jsxs)(`div`,{className:Y.conversationTerminal,children:[(0,L.jsxs)(`div`,{className:Y.conversationTerminalHeader,children:[(0,L.jsxs)(`span`,{className:Y.conversationTerminalTitle,children:[u&&(0,L.jsx)(kn,{size:14,className:Y.spinnerIcon}),e.title??e.name]}),(0,L.jsxs)(`span`,{className:Y.conversationTerminalStatus,children:[(0,L.jsx)(Ft,{size:7,style:{fill:_,color:_}}),v]}),g&&(0,L.jsxs)(`div`,{className:Y.viewToggle,children:[(0,L.jsx)(`button`,{className:`${Y.viewToggleBtn} ${n===`conversation`?Y.viewToggleBtnActive:``}`,onClick:()=>h(`conversation`),children:`Conversation`}),(0,L.jsx)(`button`,{className:`${Y.viewToggleBtn} ${n===`terminal`?Y.viewToggleBtnActive:``}`,onClick:()=>h(`terminal`),children:`Terminal`})]})]}),(0,L.jsxs)(`div`,{className:Y.conversationTerminalBody,children:[g&&n===`terminal`&&(0,L.jsx)(Ww,{sessionName:e.tmuxSession}),(n===`conversation`||!g)&&(0,L.jsx)(vRe,{conversation:e,onResume:g?void 0:p,onArchive:m,resumePending:d.isPending,modelPicker:(0,L.jsx)(C0,{value:o,onChange:e=>{s(e),f.mutate(e)}})})]})]})}async function k0(e){let t=await fetch(`/api/conversations/${encodeURIComponent(e)}/messages`);if(!t.ok)throw Error(`Failed to fetch messages`);return t.json()}function vRe({conversation:e,onResume:t,onArchive:n,resumePending:r,modelPicker:i}){let[a,o]=(0,I.useState)([]),s=(0,I.useRef)(0),{data:c,isLoading:l}=rt({queryKey:[`conversation-messages`,e.name],queryFn:()=>k0(e.name),refetchInterval:e.sessionAlive?2e3:!1}),u=c?.messages??[],d=c?.workLog??[],f=c?.streaming??!1,p=s.current+a.length,m=u.length>=p&&a.length>0,h=m?u:[...u,...a],g=(0,I.useCallback)(e=>{s.current=u.length,o([{id:`optimistic-${Date.now()}`,role:`user`,text:e,createdAt:new Date().toISOString()}])},[u.length]);(0,I.useEffect)(()=>{m&&o([])},[m]);let _=!l&&h.length===0&&e.sessionAlive,v=!l&&h.length===0&&!e.sessionAlive,y=h[h.length-1],b=e.sessionAlive&&h.length>0&&(f||y?.role===`user`);return(0,L.jsxs)(`div`,{className:Y.conversationView,children:[l?(0,L.jsx)(`div`,{className:Y.conversationConnecting,children:(0,L.jsx)(`span`,{children:`Loading…`})}):v?(0,L.jsxs)(`div`,{className:Y.conversationEmptyState,children:[(0,L.jsx)(`p`,{className:Y.conversationEmptyStateSubtitle,children:`This conversation has no saved history. The session may have ended before any messages were exchanged.`}),(0,L.jsxs)(`div`,{style:{display:`flex`,gap:8,marginTop:12,alignItems:`center`},children:[t&&(0,L.jsxs)(L.Fragment,{children:[i,(0,L.jsx)(`button`,{className:Y.conversationResumeBtn,onClick:t,disabled:r,children:r?`Resuming…`:`Resume Session`})]}),(0,L.jsx)(`button`,{className:Y.conversationArchiveBtnLarge,onClick:()=>n?.(),children:`Archive`})]})]}):_?(0,L.jsxs)(`div`,{className:Y.conversationEmptyState,children:[(0,L.jsx)(`p`,{className:Y.conversationEmptyStateTitle,children:`How can I help you?`}),(0,L.jsx)(`p`,{className:Y.conversationEmptyStateSubtitle,children:`Type a message below to start the conversation.`})]}):(0,L.jsx)(tFe,{messages:h,workLog:d,streaming:b}),t?(0,L.jsxs)(`div`,{className:Y.conversationResumeBar,children:[i,(0,L.jsx)(`button`,{className:Y.conversationResumeBtn,onClick:t,disabled:r,children:r?`Resuming…`:`Resume Session`})]}):(0,L.jsx)(hRe,{conversation:e,onSend:g})]})}async function yRe(e,t,n){let r=await fetch(`/api/conversations`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({message:e,model:t,effort:n})});if(!r.ok){let e=await r.json().catch(()=>({error:`Request failed`}));throw Error(e.error||`Failed to create conversation`)}return r.json()}function bRe({onPromoted:e}){let[t,n]=(0,I.useState)(x0),[r,i]=(0,I.useState)(()=>y0[x0()]??[`low`,`medium`,`high`]),[a,o]=(0,I.useState)(E0),[s,c]=(0,I.useState)(!1),[l,u]=(0,I.useState)(``),[d,f]=(0,I.useState)(null),p=(0,I.useRef)(null),m=(0,I.useMemo)(()=>`draft-${Date.now()}`,[]);(0,I.useEffect)(()=>{let e=setTimeout(()=>{p.current?.focus()},50);return()=>clearTimeout(e)},[]);let h=l.trim()===``;function g(e,t){n(e),i(t)}let _=(0,I.useCallback)(async()=>{let n=p.current;if(!n||s)return;let r=``;if(n.read(()=>{r=RQ().getTextContent().trim()}),r){c(!0),f(null);try{e(await yRe(r,t,a),r)}catch(e){console.error(`[DraftConversationPanel] Failed:`,e),f(e instanceof Error?e.message:`Failed to create conversation`),c(!1)}}},[t,a,e,s]),v=(0,I.useCallback)(e=>{e===`Enter`&&_()},[_]);return(0,L.jsxs)(`div`,{className:Y.conversationTerminal,children:[(0,L.jsx)(`div`,{className:Y.conversationTerminalHeader,children:(0,L.jsx)(`span`,{className:Y.conversationTerminalTitle,children:`New conversation`})}),(0,L.jsx)(`div`,{className:Y.conversationTerminalBody,children:(0,L.jsxs)(`div`,{className:Y.conversationView,children:[(0,L.jsxs)(`div`,{className:Y.conversationEmptyState,children:[(0,L.jsx)(`p`,{className:Y.conversationEmptyStateTitle,children:`How can I help you?`}),(0,L.jsx)(`p`,{className:Y.conversationEmptyStateSubtitle,children:`Type a message below to start the conversation.`})]}),(0,L.jsxs)(`div`,{className:Y.composerFooter,children:[(0,L.jsxs)(`div`,{className:Y.composerBox,children:[(0,L.jsx)(v0,{conversationName:m,disabled:s,onCommandKeyDown:v,editorRef:p,onChange:u}),(0,L.jsxs)(`div`,{className:Y.composerToolbar,children:[(0,L.jsx)(C0,{value:t,onChange:g,disabled:s}),(0,L.jsx)(D0,{value:a,onChange:o,disabled:s,availableLevels:r}),(0,L.jsx)(`div`,{className:Y.composerToolbarSpacer}),(0,L.jsx)(`button`,{className:Y.sendButton,onClick:()=>void _(),disabled:h||s,type:`button`,title:`Send message (Enter)`,children:(0,L.jsx)(Kn,{size:16})})]})]}),s&&(0,L.jsx)(`p`,{style:{color:`var(--mc-text-muted)`,fontSize:12,padding:`4px 8px`},children:`Starting session...`}),d&&(0,L.jsx)(`p`,{style:{color:`var(--mc-error)`,fontSize:12,padding:`4px 8px`},children:d})]})]})})]})}async function xRe(){let e=await fetch(`/api/conversations`);if(!e.ok)throw Error(`Failed to fetch conversations`);return e.json()}async function SRe(){let e=await fetch(`/api/command-deck/projects`);if(!e.ok)throw Error(`Failed to fetch projects`);return e.json()}async function CRe(){let e=await fetch(`/api/costs/by-issue`);if(!e.ok)throw Error(`Failed to fetch costs`);return e.json()}async function wRe(){let e=await fetch(`/api/version`);if(!e.ok)throw Error(`Failed to fetch version`);return e.json()}function TRe({issues:e=[]}){let[t,n]=(0,I.useState)(null),[r,i]=(0,I.useState)(null),[a,o]=(0,I.useState)(!1),[s,c]=(0,I.useState)(!1),[l,u]=(0,I.useState)(`conversations`),[d,f]=(0,I.useState)(`claude-sonnet-4-6`),[p,m]=(0,I.useState)(0),[h,g]=(0,I.useState)(()=>{let e=localStorage.getItem(`mc-sidebar-width`);return e?Number(e):600}),_=(0,I.useRef)(!1),v=(0,I.useRef)(0),y=(0,I.useRef)(0),b=(0,I.useRef)(h),{data:x=[],isLoading:S}=rt({queryKey:[`command-deck-projects`],queryFn:SRe,refetchInterval:1e4}),{data:C}=rt({queryKey:[`costs-by-issue`],queryFn:CRe,refetchInterval:15e3}),{data:w}=rt({queryKey:[`version`],queryFn:wRe,staleTime:1/0}),T={},E={};for(let t of e)T[t.identifier.toLowerCase()]=t.title,T[t.identifier]=t.title;for(let e of C?.issues||[])E[e.issueId]=e.totalCost,E[e.issueId.toLowerCase()]=e.totalCost;let{data:D=[]}=rt({queryKey:[`conversations`],queryFn:xRe,refetchInterval:1e4});(0,I.useEffect)(()=>{D.length>0&&r===null&&i(D[0].name)},[D,r]);let O=(0,I.useCallback)(e=>{n(e),i(null),o(!1)},[]),k=(0,I.useCallback)(e=>{m(0),i(e),o(!1),e!==null&&n(null)},[]),A=(0,I.useCallback)(()=>{localStorage.setItem(`mc-sidebar-model`,d),localStorage.setItem(`conv-composer-model`,d),m(e=>e+1),o(!0),i(null),n(null),u(`conversations`)},[d]),j=He(),M=(0,I.useCallback)((e,t)=>{m(0),o(!1),i(e.name);let n={id:`optimistic-${Date.now()}`,role:`user`,text:t,createdAt:new Date().toISOString()};j.setQueryData([`conversation-messages`,e.name],{messages:[n],workLog:[],streaming:!0}),j.invalidateQueries({queryKey:[`conversations`]})},[j]),N=(0,I.useCallback)(e=>{_.current=!0,v.current=e.clientX,y.current=h,document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,e.preventDefault()},[h]);(0,I.useEffect)(()=>{let e=e=>{if(!_.current)return;let t=e.clientX-v.current,n=Math.max(240,Math.min(600,y.current+t));g(n),b.current=n},t=()=>{_.current&&localStorage.setItem(`mc-sidebar-width`,String(b.current)),_.current=!1,document.body.style.cursor=``,document.body.style.userSelect=``};return document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,t),()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,t)}},[]);let P=t?x.flatMap(e=>e.features).find(e=>e.issueId===t):null,ee=t?T[t.toLowerCase()]||T[t]||t:``;return(0,L.jsxs)(`div`,{className:Y.missionControl,children:[(0,L.jsxs)(`div`,{className:Y.layout,children:[(0,L.jsxs)(`div`,{className:Y.sidebar,style:{width:h,minWidth:h},children:[(0,L.jsxs)(`div`,{className:Y.sidebarHeader,children:[(0,L.jsxs)(`div`,{className:Y.sidebarHeaderRow,children:[(0,L.jsx)(`h2`,{className:Y.sidebarTitle,children:`Command Deck`}),l===`conversations`&&(0,L.jsxs)(`div`,{className:Y.sidebarHeaderGroup,children:[(0,L.jsx)(C0,{value:d,onChange:e=>{f(e)}}),(0,L.jsx)(`button`,{className:Y.conversationAddBtn,onClick:A,title:`New conversation`,"aria-label":`New conversation`,children:(0,L.jsx)(Bn,{size:13})})]})]}),(0,L.jsxs)(`div`,{className:Y.segmentControl,children:[(0,L.jsxs)(`button`,{className:`${Y.segmentButton} ${l===`conversations`?Y.segmentButtonActive:``}`,onClick:()=>u(`conversations`),children:[`Conversations`,(0,L.jsx)(`span`,{className:Y.segmentCount,children:D.length})]}),(0,L.jsxs)(`button`,{className:`${Y.segmentButton} ${l===`projects`?Y.segmentButtonActive:``}`,onClick:()=>u(`projects`),children:[`Projects`,(0,L.jsx)(`span`,{className:Y.segmentCount,children:x.reduce((e,t)=>e+t.features.length,0)})]})]})]}),(0,L.jsx)(`div`,{className:Y.projectTree,children:l===`conversations`?(0,L.jsx)(OPe,{selectedConversation:r,onSelectConversation:k}):S&&x.length===0?(0,L.jsxs)(`div`,{className:Y.skeletonList,children:[(0,L.jsx)(`div`,{className:Y.skeletonItem,style:{width:`60%`}}),(0,L.jsx)(`div`,{className:Y.skeletonItem,style:{width:`80%`}}),(0,L.jsx)(`div`,{className:Y.skeletonItem,style:{width:`45%`}}),(0,L.jsx)(`div`,{className:Y.skeletonItem,style:{width:`70%`}})]}):x.length===0?(0,L.jsx)(`div`,{className:Y.emptyProject,children:`No projects configured`}):x.map(e=>(0,L.jsx)($Ne,{name:e.name,features:e.features,selectedFeature:t,onSelectFeature:O,issueTitles:T,issueCosts:E},e.path))}),(0,L.jsx)(TPe,{}),w&&(0,L.jsx)(`div`,{className:Y.sidebarFooter,children:(0,L.jsxs)(`span`,{className:Y.versionLabel,children:[`v`,w.version]})})]}),(0,L.jsx)(`div`,{className:Y.resizeHandle,onMouseDown:N}),(0,L.jsx)(`div`,{className:Y.content,children:a?(0,L.jsx)(bRe,{onPromoted:M},p):r?(()=>{let e=D.find(e=>e.name===r);return e?(0,L.jsx)(_Re,{conversation:e,onArchived:()=>{i(null),j.invalidateQueries({queryKey:[`conversations`]})}},e.name):(0,L.jsx)(`div`,{className:Y.contentEmpty,children:(0,L.jsx)(`div`,{style:{textAlign:`center`},children:(0,L.jsx)(`p`,{children:`Loading session…`})})})})():t?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:Y.featureHeader,children:[(0,L.jsx)(`h1`,{className:Y.featureTitle,children:ee}),(0,L.jsx)(`span`,{className:Y.featureId,children:t}),P?.isShadow&&(0,L.jsx)(`span`,{className:Y.badge,style:{borderColor:`var(--mc-accent)`,color:`var(--mc-accent)`},children:`Shadow`})]}),(0,L.jsx)(gPe,{issueId:t,source:e.find(e=>e.identifier===t)?.source,onOpenBeads:()=>c(!0)}),(0,L.jsx)(fPe,{issueId:t,issues:e,featureData:P})]}):(0,L.jsx)(`div`,{className:Y.contentEmpty,children:(0,L.jsxs)(`div`,{style:{textAlign:`center`},children:[(0,L.jsx)(Ut,{size:48,style:{marginBottom:`var(--mc-space-4)`,opacity:.3}}),(0,L.jsx)(`p`,{children:`Select a feature to view activity`})]})})})]}),s&&t&&(0,L.jsx)(tJ,{issueId:t,isOpen:s,onClose:()=>c(!1)})]})}function ERe(){let e=He(),t=G_(nse);(0,I.useEffect)(()=>{t&&e.setQueryData([`resources`],t)},[t,e])}function DRe(e){return e>=85?`bg-destructive`:e>=60?`bg-warning`:`bg-success`}function A0({value:e,label:t,showValue:n=!0,className:r=``}){let i=Math.min(100,Math.max(0,e)),a=DRe(i);return(0,L.jsxs)(`div`,{className:`flex flex-col gap-0.5 ${r}`,children:[(t||n)&&(0,L.jsxs)(`div`,{className:`flex justify-between items-center`,children:[t&&(0,L.jsx)(`span`,{className:`text-xs text-content-subtle`,children:t}),n&&(0,L.jsxs)(`span`,{className:`text-xs text-content-subtle ml-auto`,children:[i.toFixed(1),`%`]})]}),(0,L.jsx)(`div`,{className:`h-1.5 bg-surface-overlay rounded-full overflow-hidden`,children:(0,L.jsx)(`div`,{className:`h-full rounded-full transition-all duration-500 ${a}`,style:{width:`${i}%`}})})]})}RW.register(_G,bG,GW,UW,BU,rG);function j0({data:e,color:t=`rgba(59,130,246,0.8)`,height:n=32,maxValue:r=100}){let i=(0,I.useRef)(null),a=(0,I.useRef)(null);return(0,I.useEffect)(()=>{let n=i.current;if(!n)return;let o={labels:e.map(()=>``),datasets:[{data:e,borderColor:t,borderWidth:1.5,fill:!0,backgroundColor:t.replace(/[\d.]+\)$/,`0.15)`),pointRadius:0,tension:.3}]},s={responsive:!1,animation:!1,plugins:{legend:{display:!1},tooltip:{enabled:!1}},scales:{x:{display:!1},y:{display:!1,min:0,max:r}}};return a.current?(a.current.data=o,a.current.update(`none`)):a.current=new RW(n,{type:`line`,data:o,options:s}),()=>{a.current?.destroy(),a.current=null}},[]),(0,I.useEffect)(()=>{a.current&&(a.current.data.labels=e.map(()=>``),a.current.data.datasets[0].data=e,a.current.update(`none`))},[e]),(0,L.jsx)(`canvas`,{ref:i,width:80,height:n,style:{display:`block`}})}function M0(e){return e>=1024**3?`${(e/1024**3).toFixed(1)}GiB`:e>=1024**2?`${(e/1024**2).toFixed(0)}MiB`:e>=1024?`${(e/1024).toFixed(0)}KiB`:`${e}B`}var ORe={running:`bg-success`,stopped:`bg-destructive`,unhealthy:`bg-warning`,restarting:`bg-warning`},kRe={running:`running`,stopped:`stopped`,unhealthy:`unhealthy`,restarting:`restarting`},ARe={healthy:`bg-success`,warning:`bg-warning`,stuck:`bg-warning`,dead:`bg-destructive`,stopped:`bg-surface-overlay`,starting:`bg-signal-review`,failed:`bg-destructive`};function jRe({container:e,history:t,onClick:n}){let r=e.cpuPercent>=85?`rgba(239,68,68,0.8)`:e.cpuPercent>=60?`rgba(234,179,8,0.8)`:`rgba(59,130,246,0.8)`;return(0,L.jsxs)(`button`,{onClick:()=>n(e),className:`w-full text-left bg-surface-raised border border-divider rounded-lg p-3 hover:border-primary/50 hover:bg-surface-overlay transition-colors`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,L.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${ORe[e.status]}`}),(0,L.jsx)(`span`,{className:`text-xs font-medium text-content truncate flex-1`,title:e.name,children:e.name}),(0,L.jsx)(`span`,{className:`text-xs text-content-subtle shrink-0`,children:kRe[e.status]})]}),(0,L.jsxs)(`div`,{className:`flex gap-2 items-end`,children:[(0,L.jsxs)(`div`,{className:`flex-1 space-y-1.5`,children:[(0,L.jsx)(A0,{value:e.cpuPercent,label:`CPU`}),(0,L.jsx)(A0,{value:e.memoryPercent,label:`MEM`}),e.memoryLimit>0&&(0,L.jsxs)(`div`,{className:`text-xs text-content-subtle`,children:[M0(e.memoryUsage),` / `,M0(e.memoryLimit)]})]}),t&&t.cpuPercent.length>1&&(0,L.jsx)(`div`,{className:`shrink-0`,children:(0,L.jsx)(j0,{data:t.cpuPercent,color:r,height:36})})]})]})}function MRe({agent:e,onNavigate:t}){return(0,L.jsxs)(`button`,{onClick:()=>t(e.id),className:`w-full text-left bg-surface-raised border border-divider rounded-lg p-3 hover:border-primary/50 hover:bg-surface-overlay transition-colors`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,L.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${ARe[e.status]}`}),(0,L.jsx)(`span`,{className:`text-xs font-medium text-content truncate flex-1`,title:e.issueId??e.id,children:e.issueId??e.id}),(0,L.jsx)(`span`,{className:`text-xs text-content-subtle shrink-0`,children:e.status})]}),(0,L.jsxs)(`div`,{className:`text-xs text-content-subtle space-y-0.5`,children:[(0,L.jsxs)(`div`,{className:`flex justify-between`,children:[(0,L.jsx)(`span`,{children:`Model`}),(0,L.jsx)(`span`,{className:`text-content`,children:e.model})]}),(0,L.jsxs)(`div`,{className:`flex justify-between`,children:[(0,L.jsx)(`span`,{children:`Runtime`}),(0,L.jsx)(`span`,{className:`text-content`,children:e.runtime})]}),e.consecutiveFailures>0&&(0,L.jsxs)(`div`,{className:`flex justify-between text-warning`,children:[(0,L.jsx)(`span`,{children:`Failures`}),(0,L.jsx)(`span`,{children:e.consecutiveFailures})]})]}),(0,L.jsx)(`div`,{className:`mt-1.5 text-xs text-primary`,children:`Click to view in Agents →`})]})}function N0(e){return e>=1024**3?`${(e/1024**3).toFixed(1)}GiB`:e>=1024**2?`${(e/1024**2).toFixed(0)}MiB`:e>=1024?`${(e/1024).toFixed(0)}KiB`:`${e}B`}async function NRe(e){let t=await fetch(`/api/resources/${e}/details`);if(!t.ok)throw Error(`Failed to fetch container details`);return t.json()}function PRe({container:e,history:t,onClose:n}){let[r,i]=(0,I.useState)(`overview`),{data:a}=rt({queryKey:[`container-details`,e.id],queryFn:()=>NRe(e.id),refetchInterval:r===`logs`?5e3:3e4});return(0,I.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[n]),(0,L.jsxs)(`div`,{className:`fixed inset-0 z-50 flex justify-end`,children:[(0,L.jsx)(`div`,{className:`absolute inset-0 bg-black/40`,onClick:n}),(0,L.jsxs)(`div`,{className:`relative w-full max-w-lg bg-surface-raised border-l border-divider flex flex-col shadow-2xl overflow-hidden`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-3 border-b border-divider shrink-0`,children:[(0,L.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full shrink-0 ${e.status===`running`?`bg-success`:e.status===`unhealthy`||e.status===`restarting`?`bg-warning`:`bg-destructive`}`}),(0,L.jsx)(`h2`,{className:`font-semibold text-content text-sm flex-1 truncate`,title:e.name,children:e.name}),a?.image&&(0,L.jsx)(`span`,{className:`text-xs text-content-subtle truncate max-w-[160px]`,title:a.image,children:a.image}),(0,L.jsx)(`button`,{onClick:n,className:`p-1 rounded hover:bg-surface-overlay text-content-subtle hover:text-content`,children:(0,L.jsx)(_r,{className:`w-4 h-4`})})]}),(0,L.jsx)(`div`,{className:`flex border-b border-divider shrink-0`,children:[{id:`overview`,label:`Overview`},{id:`logs`,label:`Logs`},{id:`ports-env`,label:`Ports & Env`}].map(e=>(0,L.jsx)(`button`,{onClick:()=>i(e.id),className:`px-4 py-2 text-xs transition-colors ${r===e.id?`text-primary border-b-2 border-primary -mb-px`:`text-content-subtle hover:text-content`}`,children:e.label},e.id))}),(0,L.jsxs)(`div`,{className:`flex-1 overflow-auto p-4`,children:[r===`overview`&&(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-xs font-semibold text-content-subtle uppercase tracking-wider mb-2`,children:`Current Usage`}),(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(A0,{value:e.cpuPercent,label:`CPU`}),(0,L.jsx)(A0,{value:e.memoryPercent,label:`Memory`}),e.memoryLimit>0&&(0,L.jsxs)(`div`,{className:`text-xs text-content-subtle text-right`,children:[N0(e.memoryUsage),` / `,N0(e.memoryLimit)]})]})]}),t.cpuPercent.length>1&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-xs font-semibold text-content-subtle uppercase tracking-wider mb-2`,children:`5-Min History`}),(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-xs text-content-subtle mb-1`,children:`CPU %`}),(0,L.jsx)(`div`,{className:`w-full`,children:(0,L.jsx)(j0,{data:t.cpuPercent,color:`rgba(59,130,246,0.8)`,height:40})})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-xs text-content-subtle mb-1`,children:`Memory %`}),(0,L.jsx)(`div`,{className:`w-full`,children:(0,L.jsx)(j0,{data:t.memoryPercent,color:`rgba(168,85,247,0.8)`,height:40})})]})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-xs font-semibold text-content-subtle uppercase tracking-wider mb-2`,children:`Network I/O`}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,L.jsxs)(`div`,{className:`bg-surface p-2 rounded`,children:[(0,L.jsx)(`div`,{className:`text-xs text-content-subtle`,children:`In`}),(0,L.jsx)(`div`,{className:`text-sm font-medium text-content`,children:N0(e.networkIn)})]}),(0,L.jsxs)(`div`,{className:`bg-surface p-2 rounded`,children:[(0,L.jsx)(`div`,{className:`text-xs text-content-subtle`,children:`Out`}),(0,L.jsx)(`div`,{className:`text-sm font-medium text-content`,children:N0(e.networkOut)})]})]})]}),a&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-xs font-semibold text-content-subtle uppercase tracking-wider mb-2`,children:`Container Info`}),(0,L.jsxs)(`dl`,{className:`space-y-1 text-xs`,children:[a.uptime&&(0,L.jsxs)(`div`,{className:`flex justify-between`,children:[(0,L.jsx)(`dt`,{className:`text-content-subtle`,children:`Uptime`}),(0,L.jsx)(`dd`,{className:`text-content`,children:a.uptime})]}),a.created&&(0,L.jsxs)(`div`,{className:`flex justify-between`,children:[(0,L.jsx)(`dt`,{className:`text-content-subtle`,children:`Created`}),(0,L.jsx)(`dd`,{className:`text-content`,children:new Date(a.created).toLocaleString()})]}),(0,L.jsxs)(`div`,{className:`flex justify-between`,children:[(0,L.jsx)(`dt`,{className:`text-content-subtle`,children:`Status`}),(0,L.jsx)(`dd`,{className:`text-content`,children:a.status})]})]})]})]}),r===`logs`&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-xs font-semibold text-content-subtle uppercase tracking-wider mb-2`,children:`Recent Logs (tail 100)`}),a?.logs?(0,L.jsx)(`pre`,{className:`text-xs text-content bg-surface p-3 rounded overflow-auto max-h-[600px] font-mono whitespace-pre-wrap break-all`,children:a.logs}):(0,L.jsx)(`div`,{className:`text-xs text-content-subtle text-center py-8`,children:`Loading logs…`})]}),r===`ports-env`&&(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-xs font-semibold text-content-subtle uppercase tracking-wider mb-2`,children:`Port Mappings`}),a?.ports?.length?(0,L.jsx)(`div`,{className:`space-y-1`,children:a.ports.map((e,t)=>(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,L.jsx)(`span`,{className:`text-content font-mono`,children:e.host}),(0,L.jsx)(`span`,{className:`text-content-subtle`,children:`→`}),(0,L.jsxs)(`span`,{className:`text-content font-mono`,children:[e.container,`/`,e.protocol]})]},t))}):(0,L.jsx)(`div`,{className:`text-xs text-content-subtle`,children:`No port mappings`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-xs font-semibold text-content-subtle uppercase tracking-wider mb-2`,children:`Environment Variables`}),a?.env?.length?(0,L.jsx)(`div`,{className:`space-y-0.5 max-h-80 overflow-auto`,children:a.env.map((e,t)=>{let[n,...r]=e.split(`=`),i=r.join(`=`),a=/token|secret|key|pass|pwd|auth/i.test(n??``);return(0,L.jsxs)(`div`,{className:`text-xs font-mono flex gap-1 flex-wrap`,children:[(0,L.jsx)(`span`,{className:`text-primary`,children:n}),(0,L.jsx)(`span`,{className:`text-content-subtle`,children:`=`}),(0,L.jsx)(`span`,{className:`text-content break-all`,children:a?`***`:i})]},t)})}):(0,L.jsx)(`div`,{className:`text-xs text-content-subtle`,children:`No environment variables`})]})]})]})]})]})}async function FRe(){let e=await fetch(`/api/resources`);if(!e.ok)throw Error(`Failed to fetch resources`);return e.json()}async function IRe(e){let t=await fetch(`/api/resources/${e}/history`);if(!t.ok)throw Error(`Failed to fetch history`);return t.json()}function LRe(e,t,n){if(n===`issue`){let n=new Map;for(let t of e){let e=t.name.match(/(?:feature[_-])?([A-Z]+-\d+)/i),r=e?e[1].toUpperCase():`__ungrouped__`,i=e?e[1].toUpperCase():`Ungrouped`;n.has(r)||n.set(r,{key:r,label:i,containers:[],agents:[]}),n.get(r).containers.push(t)}for(let e of t){let t=e.issueId??`__ungrouped__`,r=e.issueId??`Ungrouped`;n.has(t)||n.set(t,{key:t,label:r,containers:[],agents:[]}),n.get(t).agents.push(e)}return Array.from(n.values()).sort((e,t)=>e.label.localeCompare(t.label))}if(n===`type`)return[{key:`containers`,label:`Containers`,containers:e,agents:[]},{key:`agents`,label:`Agents`,containers:[],agents:t}].filter(e=>e.containers.length+e.agents.length>0);let r=new Map;for(let t of e)r.has(t.status)||r.set(t.status,{key:t.status,label:t.status.charAt(0).toUpperCase()+t.status.slice(1),containers:[],agents:[]}),r.get(t.status).containers.push(t);for(let e of t)r.has(e.status)||r.set(e.status,{key:e.status,label:e.status.charAt(0).toUpperCase()+e.status.slice(1),containers:[],agents:[]}),r.get(e.status).agents.push(e);return Array.from(r.values())}function RRe({onNavigateToAgents:e}){let[t,n]=(0,I.useState)(`issue`),[r,i]=(0,I.useState)(`all`),[a,o]=(0,I.useState)(null);ERe();let{data:s,isLoading:c,error:l}=rt({queryKey:[`resources`],queryFn:FRe,refetchInterval:3e4}),{data:u}=rt({queryKey:[`container-history`,a?.id],queryFn:()=>IRe(a.id),enabled:!!a,refetchInterval:3e4});if(c)return(0,L.jsx)(`div`,{className:`p-6 text-content-subtle text-sm`,children:`Loading resources…`});if(l)return(0,L.jsxs)(`div`,{className:`p-6 text-destructive text-sm`,children:[`Failed to load resources: `,l.message]});let d=s?.containers??[],f=s?.agents??[],p=r===`running`?d.filter(e=>e.status===`running`):d,m=LRe(p,f,t),h=p.length+f.length;return(0,L.jsxs)(`div`,{className:`h-full flex flex-col overflow-hidden`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3 px-6 py-3 border-b border-divider shrink-0`,children:[(0,L.jsx)(`h2`,{className:`text-sm font-semibold text-content`,children:`Resources`}),(0,L.jsxs)(`span`,{className:`text-xs text-content-subtle`,children:[h,` items`]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-1 ml-4`,children:[(0,L.jsx)(`span`,{className:`text-xs text-content-subtle mr-1`,children:`Group by:`}),[`issue`,`type`,`status`].map(e=>(0,L.jsx)(`button`,{onClick:()=>n(e),className:`px-2 py-0.5 rounded text-xs transition-colors ${t===e?`bg-primary text-white`:`text-content-subtle hover:text-content hover:bg-surface-overlay`}`,children:e.charAt(0).toUpperCase()+e.slice(1)},e))]}),(0,L.jsx)(`div`,{className:`flex items-center gap-1`,children:[`all`,`running`].map(e=>(0,L.jsx)(`button`,{onClick:()=>i(e),className:`px-2 py-0.5 rounded text-xs transition-colors ${r===e?`bg-surface-overlay text-content`:`text-content-subtle hover:text-content hover:bg-surface-overlay`}`,children:e===`all`?`All`:`Running only`},e))}),s?.updatedAt&&(0,L.jsxs)(`span`,{className:`ml-auto text-xs text-content-subtle`,children:[`Updated `,new Date(s.updatedAt).toLocaleTimeString()]})]}),(0,L.jsx)(`div`,{className:`flex-1 overflow-auto p-6`,children:h===0?(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-64 text-content-subtle`,children:[(0,L.jsx)(`div`,{className:`text-4xl mb-3`,children:`📦`}),(0,L.jsx)(`div`,{className:`text-sm`,children:`No containers or agents found`}),(0,L.jsx)(`div`,{className:`text-xs mt-1`,children:`Docker may not be running or no workspaces are active`})]}):(0,L.jsx)(`div`,{className:`space-y-6`,children:m.map(t=>(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`h3`,{className:`text-xs font-semibold text-content-subtle uppercase tracking-wider mb-3`,children:[t.label,(0,L.jsxs)(`span`,{className:`ml-2 font-normal text-content-subtle/60`,children:[`(`,t.containers.length+t.agents.length,`)`]})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3`,children:[t.containers.map(e=>(0,L.jsx)(jRe,{container:e,history:(s?.containers,void 0),onClick:o},e.id)),t.agents.map(t=>(0,L.jsx)(MRe,{agent:t,onNavigate:e},t.id))]})]},t.key))})}),a&&(0,L.jsx)(PRe,{container:a,history:u??{timestamps:[],cpuPercent:[],memoryPercent:[]},onClose:()=>o(null)})]})}var P0=(0,I.createContext)({});function F0(e){let t=(0,I.useRef)(null);return t.current===null&&(t.current=e()),t.current}var I0=(0,I.createContext)(null),L0=(0,I.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`}),zRe=class extends I.Component{getSnapshotBeforeUpdate(e){let t=this.props.childRef.current;if(t&&e.isPresent&&!this.props.isPresent){let e=this.props.sizeRef.current;e.height=t.offsetHeight||0,e.width=t.offsetWidth||0,e.top=t.offsetTop,e.left=t.offsetLeft}return null}componentDidUpdate(){}render(){return this.props.children}};function BRe({children:e,isPresent:t}){let n=(0,I.useId)(),r=(0,I.useRef)(null),i=(0,I.useRef)({width:0,height:0,top:0,left:0}),{nonce:a}=(0,I.useContext)(L0);return(0,I.useInsertionEffect)(()=>{let{width:e,height:o,top:s,left:c}=i.current;if(t||!r.current||!e||!o)return;r.current.dataset.motionPopId=n;let l=document.createElement(`style`);return a&&(l.nonce=a),document.head.appendChild(l),l.sheet&&l.sheet.insertRule(`
187
187
  [data-motion-pop-id="${n}"] {
188
188
  position: absolute !important;
189
189
  width: ${e}px !important;
@@ -18,7 +18,7 @@
18
18
  }
19
19
  })();
20
20
  </script>
21
- <script type="module" crossorigin src="/assets/index-ByLmYGhW.js"></script>
21
+ <script type="module" crossorigin src="/assets/index-CzFZIb87.js"></script>
22
22
  <link rel="modulepreload" crossorigin href="/assets/chunk-BEqpzyXh.js">
23
23
  <link rel="stylesheet" crossorigin href="/assets/index-OEEbThNN.css">
24
24
  </head>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "panopticon-cli",
3
- "version": "0.6.6",
3
+ "version": "0.6.7",
4
4
  "description": "Multi-agent orchestration for AI coding assistants (Claude Code, Codex, Cursor, Gemini CLI)",
5
5
  "keywords": [
6
6
  "ai-agents",