nextclaw 0.9.20 → 0.9.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +246 -5
- package/package.json +5 -5
- package/ui-dist/assets/{ChannelsList-BYpcdBFv.js → ChannelsList-C49JQ-Zt.js} +1 -1
- package/ui-dist/assets/ChatPage-DIx05c6s.js +36 -0
- package/ui-dist/assets/{DocBrowser-BvlLr302.js → DocBrowser-CpOosDEI.js} +1 -1
- package/ui-dist/assets/{LogoBadge-BID710eK.js → LogoBadge-CL_8ZPXU.js} +1 -1
- package/ui-dist/assets/{MarketplacePage-D_tl0hcj.js → MarketplacePage-BOzko5s9.js} +2 -2
- package/ui-dist/assets/{ModelConfig-BqeVEjhR.js → ModelConfig-BZ4ZfaQB.js} +1 -1
- package/ui-dist/assets/ProvidersList-fPpJ5gl6.js +1 -0
- package/ui-dist/assets/{RuntimeConfig-JyVczyri.js → RuntimeConfig-Dt9pLB9P.js} +1 -1
- package/ui-dist/assets/{SecretsConfig-ZSYdLpVY.js → SecretsConfig-C1PU0Yy8.js} +2 -2
- package/ui-dist/assets/{SessionsConfig-DhS0WDzb.js → SessionsConfig-EskBOofQ.js} +2 -2
- package/ui-dist/assets/{card-C7lYDup4.js → card-C7Gtw2Vs.js} +1 -1
- package/ui-dist/assets/index-Cn6_2To7.js +8 -0
- package/ui-dist/assets/{index-Bzp2eV6w.css → index-nEYGCJTC.css} +1 -1
- package/ui-dist/assets/{input-C9Q7iTLs.js → input-oBvxsnV9.js} +1 -1
- package/ui-dist/assets/{label-kgXDZMBc.js → label-C7F8lMpQ.js} +1 -1
- package/ui-dist/assets/{page-layout-BhDWJV70.js → page-layout-DO8BlScF.js} +1 -1
- package/ui-dist/assets/session-run-status-Kg0FwAPn.js +3 -0
- package/ui-dist/assets/{switch-CqwpGPEL.js → switch-C6a5GyZB.js} +1 -1
- package/ui-dist/assets/{tabs-custom-B4iGlgEu.js → tabs-custom-BatFap5k.js} +1 -1
- package/ui-dist/assets/{useConfirmDialog-C6M6VCjI.js → useConfirmDialog-zJzVKMdu.js} +2 -2
- package/ui-dist/assets/{vendor-Ch2nf8A7.js → vendor-TlME1INH.js} +82 -97
- package/ui-dist/index.html +3 -3
- package/ui-dist/assets/ChatPage-Bm4KmiRF.js +0 -34
- package/ui-dist/assets/ProvidersList-CdMUUfu2.js +0 -1
- package/ui-dist/assets/index-D0qBgcW3.js +0 -7
- package/ui-dist/assets/session-run-status-X3zQMK00.js +0 -5
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
var bo=Object.defineProperty;var So=(e,t,n)=>t in e?bo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var F=(e,t,n)=>So(e,typeof t!="symbol"?t+"":t,n);import{j as f,r as R,E as Ft,a0 as ko,a1 as Fn,A as zn,B as Bn,N as xn,a2 as wo,w as vo,x as Co,y as Io,a3 as yn,a4 as bn,a5 as Sn,a6 as yt,a7 as vi,a8 as Ro,a9 as Ci,aa as Ii,k as Ri,ab as To,ac as Ao,ad as Eo,ae as Mo,af as No,ag as Po,M as jo,ah as Lo,ai as _o,aj as Oo,ak as Ti,al as Ai,am as Do,an as Ei,ao as Mi,ap as ut,aq as Fo,ar as zo,as as Bo,at as $o,au as Uo,av as Ho,aw as Ko,ax as Vo,ay as qo,az as Wo,aA as Go,aB as Xo,p as Qo,aC as pr,aD as Yo,aE as Jo,aF as Ni,aG as Zo,aH as ea,aI as ta,D as na,aJ as ra,aK as ia}from"./vendor-TlME1INH.js";import{P as Pi,u as ji}from"./useConfirmDialog-zJzVKMdu.js";import{B as Pe,P as sa,a as oa}from"./page-layout-DO8BlScF.js";import{i as Li,j as aa,t as A,T as mr,L as gr,B as la,c as te,k as zt,S as ft,e as pt,g as mt,h as He,f as $n,l as ua,m as ca,n as da,o as ha,p as fa,u as pa,a as ma,q as ga,r as xa,s as ya,v as ba,w as Sa,x as ka,y as wa,z as va,A as Ca,C as Ia}from"./index-Cn6_2To7.js";import{I as Un}from"./input-oBvxsnV9.js";import{S as Ra,s as Ta,a as Aa,b as Ea,c as Ma,e as xr}from"./session-run-status-Kg0FwAPn.js";import{T as _i,a as Oi,b as Di,c as Fi,u as Na,M as Pa}from"./MarketplacePage-BOzko5s9.js";import{C as ja,a as La}from"./card-C7Gtw2Vs.js";import{b as _a,c as Oa}from"./provider-models-y4mUDcGF.js";import"./tabs-custom-BatFap5k.js";const zi=R.createContext(null);function Da({presenter:e,children:t}){return f.jsx(zi.Provider,{value:e,children:t})}function Bt(){const e=R.useContext(zi);if(!e)throw new Error("usePresenter must be used inside ChatPresenterProvider");return e}const Fa={sessionRunStatusByKey:new Map,isLocallyRunning:!1,activeBackendRunId:null},kn=Ft(e=>({snapshot:Fa,setSnapshot:t=>e(n=>({snapshot:{...n.snapshot,...t}}))})),za={sessions:[],selectedSessionKey:null,selectedAgentId:"main",query:"",isLoading:!1},oe=Ft(e=>({snapshot:za,setSnapshot:t=>e(n=>({snapshot:{...n.snapshot,...t}}))}));function Ba(e){const t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),r=n-864e5,i=n-7*864e5,s=[],o=[],a=[],l=[];for(const d of e){const c=new Date(d.updatedAt).getTime();c>=n?s.push(d):c>=r?o.push(d):c>=i?a.push(d):l.push(d)}const u=[];return s.length>0&&u.push({label:A("chatSidebarToday"),sessions:s}),o.length>0&&u.push({label:A("chatSidebarYesterday"),sessions:o}),a.length>0&&u.push({label:A("chatSidebarPrevious7Days"),sessions:a}),l.length>0&&u.push({label:A("chatSidebarOlder"),sessions:l}),u}function $a(e){if(e.label&&e.label.trim())return e.label.trim();const t=e.key.split(":");return t[t.length-1]||e.key}const Ua=[{target:"/cron",label:()=>A("chatSidebarScheduledTasks"),icon:zn},{target:"/skills",label:()=>A("chatSidebarSkills"),icon:Bn}];function Ha(){var c,p;const e=Bt(),t=oe(h=>h.snapshot),n=kn(h=>h.snapshot),{language:r,setLanguage:i}=Li(),{theme:s,setTheme:o}=aa(),a=A(((c=mr.find(h=>h.value===s))==null?void 0:c.labelKey)??"themeWarm"),l=((p=gr.find(h=>h.value===r))==null?void 0:p.label)??r,u=R.useMemo(()=>Ba(t.sessions),[t.sessions]),d=h=>{r!==h&&(i(h),window.location.reload())};return f.jsxs("aside",{className:"w-[280px] shrink-0 flex flex-col h-full bg-secondary border-r border-gray-200/60",children:[f.jsx("div",{className:"px-5 pt-5 pb-3",children:f.jsx(la,{})}),f.jsx("div",{className:"px-4 pb-3",children:f.jsxs(Pe,{variant:"primary",className:"w-full rounded-xl",onClick:e.chatSessionListManager.createSession,children:[f.jsx(ko,{className:"h-4 w-4 mr-2"}),A("chatSidebarNewTask")]})}),f.jsx("div",{className:"px-4 pb-3",children:f.jsxs("div",{className:"relative",children:[f.jsx(Fn,{className:"h-3.5 w-3.5 absolute left-3 top-2.5 text-gray-400"}),f.jsx(Un,{value:t.query,onChange:h=>e.chatSessionListManager.setQuery(h.target.value),placeholder:A("chatSidebarSearchPlaceholder"),className:"pl-8 h-9 rounded-lg text-xs"})]})}),f.jsx("div",{className:"px-3 pb-2",children:f.jsx("ul",{className:"space-y-0.5",children:Ua.map(h=>{const m=h.icon;return f.jsx("li",{children:f.jsx(xn,{to:h.target,className:({isActive:x})=>te("group w-full flex items-center gap-3 px-3 py-2 rounded-xl text-[13px] font-medium transition-all duration-150",x?"bg-gray-200 text-gray-900 font-semibold shadow-sm":"text-gray-600 hover:bg-gray-200/60 hover:text-gray-900"),children:({isActive:x})=>f.jsxs(f.Fragment,{children:[f.jsx(m,{className:te("h-4 w-4 transition-colors",x?"text-gray-900":"text-gray-500 group-hover:text-gray-800")}),f.jsx("span",{children:h.label()})]})})},h.target)})})}),f.jsx("div",{className:"mx-4 border-t border-gray-200/60"}),f.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto custom-scrollbar px-3 py-2",children:t.isLoading?f.jsx("div",{className:"text-xs text-gray-500 p-3",children:A("sessionsLoading")}):u.length===0?f.jsxs("div",{className:"p-4 text-center",children:[f.jsx(wo,{className:"h-6 w-6 mx-auto mb-2 text-gray-300"}),f.jsx("div",{className:"text-xs text-gray-500",children:A("sessionsEmpty")})]}):f.jsx("div",{className:"space-y-3",children:u.map(h=>f.jsxs("div",{children:[f.jsx("div",{className:"px-2 py-1 text-[11px] font-medium text-gray-400 uppercase tracking-wider",children:h.label}),f.jsx("div",{className:"space-y-0.5",children:h.sessions.map(m=>{const x=t.selectedSessionKey===m.key,S=n.sessionRunStatusByKey.get(m.key);return f.jsxs("button",{onClick:()=>e.chatSessionListManager.selectSession(m.key),className:te("w-full rounded-xl px-3 py-2 text-left transition-all text-[13px]",x?"bg-gray-200 text-gray-900 font-semibold shadow-sm":"text-gray-700 hover:bg-gray-200/60 hover:text-gray-900"),children:[f.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_0.875rem] items-center gap-1.5",children:[f.jsx("span",{className:"truncate font-medium",children:$a(m)}),f.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:S?f.jsx(Ra,{status:S}):null})]}),f.jsxs("div",{className:"mt-0.5 text-[11px] text-gray-400 truncate",children:[m.messageCount," · ",zt(m.updatedAt)]})]},m.key)})})]},h.label))})}),f.jsxs("div",{className:"px-3 py-3 border-t border-gray-200/60 space-y-0.5",children:[f.jsx(xn,{to:"/settings",className:({isActive:h})=>te("group w-full flex items-center gap-2.5 px-3 py-2 rounded-xl text-[13px] font-medium transition-all duration-150",h?"bg-gray-200 text-gray-900 font-semibold shadow-sm":"text-gray-600 hover:bg-gray-200/60 hover:text-gray-900"),children:({isActive:h})=>f.jsxs(f.Fragment,{children:[f.jsx(vo,{className:te("h-4 w-4 transition-colors",h?"text-gray-900":"text-gray-500 group-hover:text-gray-800")}),f.jsx("span",{children:A("settings")})]})}),f.jsxs(ft,{value:s,onValueChange:h=>o(h),children:[f.jsxs(pt,{className:"w-full h-auto rounded-xl border-0 bg-transparent shadow-none px-3 py-2 text-[13px] font-medium text-gray-600 hover:bg-gray-200/60 focus:ring-0",children:[f.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[f.jsx(Co,{className:"h-4 w-4 text-gray-400"}),f.jsx("span",{children:A("theme")})]}),f.jsx("span",{className:"ml-auto text-[11px] text-gray-500",children:a})]}),f.jsx(mt,{children:mr.map(h=>f.jsx(He,{value:h.value,className:"text-xs",children:A(h.labelKey)},h.value))})]}),f.jsxs(ft,{value:r,onValueChange:h=>d(h),children:[f.jsxs(pt,{className:"w-full h-auto rounded-xl border-0 bg-transparent shadow-none px-3 py-2 text-[13px] font-medium text-gray-600 hover:bg-gray-200/60 focus:ring-0",children:[f.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[f.jsx(Io,{className:"h-4 w-4 text-gray-400"}),f.jsx("span",{children:A("language")})]}),f.jsx("span",{className:"ml-auto text-[11px] text-gray-500",children:l})]}),f.jsx(mt,{children:gr.map(h=>f.jsx(He,{value:h.value,className:"text-xs",children:h.label},h.value))})]})]})]})}function je(e){return typeof e=="function"}function Bi(e){var t=function(r){Error.call(r),r.stack=new Error().stack},n=e(t);return n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n}var Gt=Bi(function(e){return function(n){e(this),this.message=n?n.length+` errors occurred during unsubscription:
|
|
2
|
+
`+n.map(function(r,i){return i+1+") "+r.toString()}).join(`
|
|
3
|
+
`):"",this.name="UnsubscriptionError",this.errors=n}});function wn(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var $t=(function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,n,r,i,s;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var a=yn(o),l=a.next();!l.done;l=a.next()){var u=l.value;u.remove(this)}}catch(x){t={error:x}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}else o.remove(this);var d=this.initialTeardown;if(je(d))try{d()}catch(x){s=x instanceof Gt?x.errors:[x]}var c=this._finalizers;if(c){this._finalizers=null;try{for(var p=yn(c),h=p.next();!h.done;h=p.next()){var m=h.value;try{yr(m)}catch(x){s=s??[],x instanceof Gt?s=bn(bn([],Sn(s)),Sn(x.errors)):s.push(x)}}}catch(x){r={error:x}}finally{try{h&&!h.done&&(i=p.return)&&i.call(p)}finally{if(r)throw r.error}}}if(s)throw new Gt(s)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)yr(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(n=this._finalizers)!==null&&n!==void 0?n:[]).push(t)}},e.prototype._hasParent=function(t){var n=this._parentage;return n===t||Array.isArray(n)&&n.includes(t)},e.prototype._addParent=function(t){var n=this._parentage;this._parentage=Array.isArray(n)?(n.push(t),n):n?[n,t]:t},e.prototype._removeParent=function(t){var n=this._parentage;n===t?this._parentage=null:Array.isArray(n)&&wn(n,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&wn(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=(function(){var t=new e;return t.closed=!0,t})(),e})(),$i=$t.EMPTY;function Ui(e){return e instanceof $t||e&&"closed"in e&&je(e.remove)&&je(e.add)&&je(e.unsubscribe)}function yr(e){je(e)?e():e.unsubscribe()}var Ka={Promise:void 0},Va={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setTimeout.apply(void 0,bn([e,t],Sn(n)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function qa(e){Va.setTimeout(function(){throw e})}function br(){}function Mt(e){e()}var Hi=(function(e){yt(t,e);function t(n){var r=e.call(this)||this;return r.isStopped=!1,n?(r.destination=n,Ui(n)&&n.add(r)):r.destination=Xa,r}return t.create=function(n,r,i){return new vn(n,r,i)},t.prototype.next=function(n){this.isStopped||this._next(n)},t.prototype.error=function(n){this.isStopped||(this.isStopped=!0,this._error(n))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(n){this.destination.next(n)},t.prototype._error=function(n){try{this.destination.error(n)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t})($t),Wa=(function(){function e(t){this.partialObserver=t}return e.prototype.next=function(t){var n=this.partialObserver;if(n.next)try{n.next(t)}catch(r){vt(r)}},e.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(r){vt(r)}else vt(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(n){vt(n)}},e})(),vn=(function(e){yt(t,e);function t(n,r,i){var s=e.call(this)||this,o;return je(n)||!n?o={next:n??void 0,error:r??void 0,complete:i??void 0}:o=n,s.destination=new Wa(o),s}return t})(Hi);function vt(e){qa(e)}function Ga(e){throw e}var Xa={closed:!0,next:br,error:Ga,complete:br},Qa=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function Ya(e){return e}function Ja(e){return e.length===0?Ya:e.length===1?e[0]:function(n){return e.reduce(function(r,i){return i(r)},n)}}var Pt=(function(){function e(t){t&&(this._subscribe=t)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(t,n,r){var i=this,s=el(t)?t:new vn(t,n,r);return Mt(function(){var o=i,a=o.operator,l=o.source;s.add(a?a.call(s,l):l?i._subscribe(s):i._trySubscribe(s))}),s},e.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(n){t.error(n)}},e.prototype.forEach=function(t,n){var r=this;return n=Sr(n),new n(function(i,s){var o=new vn({next:function(a){try{t(a)}catch(l){s(l),o.unsubscribe()}},error:s,complete:i});r.subscribe(o)})},e.prototype._subscribe=function(t){var n;return(n=this.source)===null||n===void 0?void 0:n.subscribe(t)},e.prototype[Qa]=function(){return this},e.prototype.pipe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return Ja(t)(this)},e.prototype.toPromise=function(t){var n=this;return t=Sr(t),new t(function(r,i){var s;n.subscribe(function(o){return s=o},function(o){return i(o)},function(){return r(s)})})},e.create=function(t){return new e(t)},e})();function Sr(e){var t;return(t=e??Ka.Promise)!==null&&t!==void 0?t:Promise}function Za(e){return e&&je(e.next)&&je(e.error)&&je(e.complete)}function el(e){return e&&e instanceof Hi||Za(e)&&Ui(e)}var tl=Bi(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Ne=(function(e){yt(t,e);function t(){var n=e.call(this)||this;return n.closed=!1,n.currentObservers=null,n.observers=[],n.isStopped=!1,n.hasError=!1,n.thrownError=null,n}return t.prototype.lift=function(n){var r=new kr(this,this);return r.operator=n,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new tl},t.prototype.next=function(n){var r=this;Mt(function(){var i,s;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var o=yn(r.currentObservers),a=o.next();!a.done;a=o.next()){var l=a.value;l.next(n)}}catch(u){i={error:u}}finally{try{a&&!a.done&&(s=o.return)&&s.call(o)}finally{if(i)throw i.error}}}})},t.prototype.error=function(n){var r=this;Mt(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=n;for(var i=r.observers;i.length;)i.shift().error(n)}})},t.prototype.complete=function(){var n=this;Mt(function(){if(n._throwIfClosed(),!n.isStopped){n.isStopped=!0;for(var r=n.observers;r.length;)r.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var n;return((n=this.observers)===null||n===void 0?void 0:n.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(n){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,n)},t.prototype._subscribe=function(n){return this._throwIfClosed(),this._checkFinalizedStatuses(n),this._innerSubscribe(n)},t.prototype._innerSubscribe=function(n){var r=this,i=this,s=i.hasError,o=i.isStopped,a=i.observers;return s||o?$i:(this.currentObservers=null,a.push(n),new $t(function(){r.currentObservers=null,wn(a,n)}))},t.prototype._checkFinalizedStatuses=function(n){var r=this,i=r.hasError,s=r.thrownError,o=r.isStopped;i?n.error(s):o&&n.complete()},t.prototype.asObservable=function(){var n=new Pt;return n.source=this,n},t.create=function(n,r){return new kr(n,r)},t})(Pt),kr=(function(e){yt(t,e);function t(n,r){var i=e.call(this)||this;return i.destination=n,i.source=r,i}return t.prototype.next=function(n){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.next)===null||i===void 0||i.call(r,n)},t.prototype.error=function(n){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.error)===null||i===void 0||i.call(r,n)},t.prototype.complete=function(){var n,r;(r=(n=this.destination)===null||n===void 0?void 0:n.complete)===null||r===void 0||r.call(n)},t.prototype._subscribe=function(n){var r,i;return(i=(r=this.source)===null||r===void 0?void 0:r.subscribe(n))!==null&&i!==void 0?i:$i},t})(Ne),We=(function(e){yt(t,e);function t(n){var r=e.call(this)||this;return r._value=n,r}return Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(n){var r=e.prototype._subscribe.call(this,n);return!r.closed&&n.next(this._value),r},t.prototype.getValue=function(){var n=this,r=n.hasError,i=n.thrownError,s=n._value;if(r)throw i;return this._throwIfClosed(),s},t.prototype.next=function(n){e.prototype.next.call(this,this._value=n)},t})(Ne);const re=[];for(let e=0;e<256;++e)re.push((e+256).toString(16).slice(1));function nl(e,t=0){return(re[e[t+0]]+re[e[t+1]]+re[e[t+2]]+re[e[t+3]]+"-"+re[e[t+4]]+re[e[t+5]]+"-"+re[e[t+6]]+re[e[t+7]]+"-"+re[e[t+8]]+re[e[t+9]]+"-"+re[e[t+10]]+re[e[t+11]]+re[e[t+12]]+re[e[t+13]]+re[e[t+14]]+re[e[t+15]]).toLowerCase()}let Xt;const rl=new Uint8Array(16);function il(){if(!Xt){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Xt=crypto.getRandomValues.bind(crypto)}return Xt(rl)}const sl=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),wr={randomUUID:sl};function Cn(e,t,n){var i;if(wr.randomUUID&&!e)return wr.randomUUID();e=e||{};const r=e.random??((i=e.rng)==null?void 0:i.call(e))??il();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=r[6]&15|64,r[8]=r[8]&63|128,nl(r)}var se=(e=>(e.CALL="call",e.RESULT="result",e.PARTIAL_CALL="partial-call",e.ERROR="error",e.CANCELLED="cancelled",e))(se||{}),K=(e=>(e.TEXT_START="TEXT_START",e.TEXT_DELTA="TEXT_DELTA",e.TEXT_END="TEXT_END",e.TOOL_CALL_START="TOOL_CALL_START",e.TOOL_CALL_ARGS="TOOL_CALL_ARGS",e.TOOL_CALL_ARGS_DELTA="TOOL_CALL_ARGS_DELTA",e.TOOL_CALL_END="TOOL_CALL_END",e.TOOL_CALL_RESULT="TOOL_CALL_RESULT",e.RUN_STARTED="RUN_STARTED",e.RUN_FINISHED="RUN_FINISHED",e.RUN_ERROR="RUN_ERROR",e.RUN_METADATA="RUN_METADATA",e.REASONING_START="REASONING_START",e.REASONING_DELTA="REASONING_DELTA",e.REASONING_END="REASONING_END",e))(K||{});function ol(e){return!e||e.remoteStopCapable&&e.remoteRunId?null:e.remoteStopCapable?"__preparing__":e.remoteStopReason??""}const al=e=>{try{return JSON.parse(e)}catch{return}},vr=e=>({toolCallId:e.id,toolName:e.function.name,args:e.function.arguments,parsedArgs:al(e.function.arguments),status:se.CALL});function ll(e,t){const n={error:"tool_call_interrupted",note:"User continued before tool produced a result."};return e.map(r=>{var i;return(i=r.parts)!=null&&i.length?{...r,parts:r.parts.map(s=>{if(s.type!=="tool-invocation"||![se.CALL,se.PARTIAL_CALL].includes(s.toolInvocation.status))return s;let o;if(typeof s.toolInvocation.args=="string")try{o=JSON.parse(s.toolInvocation.args)}catch{return{...s,toolInvocation:{...s.toolInvocation,args:JSON.stringify({}),parsedArgs:o,status:se.RESULT,result:{error:"invalid_args",raw:s.toolInvocation.args}}}}return{...s,toolInvocation:{...s.toolInvocation,args:s.toolInvocation.args,parsedArgs:o,status:se.RESULT,result:n}}})}:r})}function In(e){if(e instanceof DOMException&&e.name==="AbortError")return!0;if(e instanceof Error){if(e.name==="AbortError")return!0;const t=e.message.toLowerCase();return t.includes("aborted")||t.includes("abort")}return!1}function Cr(e){if(e instanceof Error){const n=e.message.trim();if(n)return n}return String(e??"").trim()||"Failed to send message"}function Ir(e,t){return{id:`local-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,role:"assistant",parts:[{type:"text",text:e}],meta:{source:"local",status:(t==null?void 0:t.status)??"final",sessionKey:t==null?void 0:t.sessionKey,timestamp:new Date().toISOString()}}}class ul{constructor(t){F(this,"currentMessageId");F(this,"currentReasoningMessageId");F(this,"currentReasoningContent","");F(this,"currentToolCallId");F(this,"currentToolCallMessageId");F(this,"currentToolCallName");F(this,"currentToolCallArgs","");F(this,"emittedToolCallIds",new Set);this.sessionManager=t}findAssistantMessageById(t){const n=t==null?void 0:t.trim();return n?this.sessionManager.getMessages().find(i=>i.role==="assistant"&&i.id===n)??null:null}findAssistantMessageByToolCallId(t){var r;if(!t)return null;const n=this.sessionManager.getMessages();for(let i=n.length-1;i>=0;i-=1){const s=n[i];if(s.role!=="assistant")continue;if((r=s.parts)==null?void 0:r.some(a=>a.type==="tool-invocation"&&a.toolInvocation.toolCallId===t))return s}return null}findAssistantMessageForCurrentTool(t){var r;const n=this.findAssistantMessageById(this.currentToolCallMessageId);return(r=n==null?void 0:n.parts)!=null&&r.some(i=>i.type==="tool-invocation"&&i.toolInvocation.toolCallId===t)?n:this.findAssistantMessageByToolCallId(t)}reset(){this.currentMessageId=void 0,this.currentReasoningMessageId=void 0,this.currentReasoningContent="",this.currentToolCallId=void 0,this.currentToolCallMessageId=void 0,this.currentToolCallName=void 0,this.currentToolCallArgs="",this.emittedToolCallIds.clear()}emitToolCallEvents(){const t=this.sessionManager.getMessages();for(const n of t)if(!(n.role!=="assistant"||!n.parts))for(const r of n.parts){if(r.type!=="tool-invocation")continue;const i=r.toolInvocation;i.status===se.CALL&&!this.emittedToolCallIds.has(i.toolCallId)&&(this.emittedToolCallIds.add(i.toolCallId),this.sessionManager.toolCall$.next({toolCall:{id:i.toolCallId,type:"function",function:{name:i.toolName,arguments:i.args}}}))}}handleEvent(t){switch(t.type){case K.RUN_STARTED:break;case K.TEXT_START:this.handleTextStart(t);break;case K.TEXT_DELTA:this.handleTextContent(t);break;case K.TEXT_END:this.handleTextEnd();break;case K.REASONING_START:this.handleReasoningStart(t);break;case K.REASONING_DELTA:this.handleReasoningContent(t);break;case K.REASONING_END:this.handleReasoningEnd();break;case K.TOOL_CALL_START:this.handleToolCallStart(t);break;case K.TOOL_CALL_ARGS_DELTA:this.handleToolCallArgsDelta(t);break;case K.TOOL_CALL_ARGS:this.handleToolCallArgs(t);break;case K.TOOL_CALL_END:this.handleToolCallEnd(),this.emitToolCallEvents();break;case K.TOOL_CALL_RESULT:this.handleToolCallResult(t);break}}handleTextStart(t){this.currentMessageId=t.messageId}appendTextDelta(t,n){const r=[...t.parts||[]],i=r[r.length-1];return i&&i.type==="text"?{...t,parts:[...r.slice(0,-1),{type:"text",text:`${i.text}${n}`}]}:{...t,parts:[...r,{type:"text",text:n}]}}handleTextContent(t){if(!t.delta||this.currentMessageId!==t.messageId)return;const r=this.sessionManager.getMessages().find(i=>i.role==="assistant"&&i.id===this.currentMessageId);r?this.sessionManager.updateMessage(this.appendTextDelta(r,t.delta)):this.sessionManager.addMessages([{id:this.currentMessageId,role:"assistant",parts:[{type:"text",text:t.delta}]}])}handleTextEnd(){this.currentMessageId=void 0}updateReasoningPart(t,n){var s;const r=[...t.parts||[]];let i=-1;for(let o=r.length-1;o>=0;o-=1)if(((s=r[o])==null?void 0:s.type)==="reasoning"){i=o;break}return i>=0?{...t,parts:[...r.slice(0,i),{type:"reasoning",reasoning:n,details:[]},...r.slice(i+1)]}:{...t,parts:[...r,{type:"reasoning",reasoning:n,details:[]}]}}handleReasoningStart(t){this.currentReasoningMessageId=t.messageId,this.currentReasoningContent=""}handleReasoningContent(t){if(!t.delta||this.currentReasoningMessageId!==t.messageId)return;this.currentReasoningContent+=t.delta;const n=this.currentReasoningContent,r=this.currentReasoningMessageId,s=this.sessionManager.getMessages().find(o=>o.role==="assistant"&&o.id===r);s?this.sessionManager.updateMessage(this.updateReasoningPart(s,n)):this.sessionManager.addMessages([{id:r,role:"assistant",parts:[{type:"reasoning",reasoning:n,details:[]}]}])}handleReasoningEnd(){this.currentReasoningMessageId=void 0,this.currentReasoningContent=""}handleToolCallStart(t){var l;this.currentToolCallId=t.toolCallId,this.currentToolCallName=t.toolName,this.currentToolCallArgs="",this.currentToolCallMessageId=t.messageId;const n={type:"tool-invocation",toolInvocation:{status:se.PARTIAL_CALL,toolCallId:this.currentToolCallId,toolName:this.currentToolCallName,args:""}},r=this.sessionManager.getMessages(),i=(l=t.messageId)==null?void 0:l.trim(),s=this.findAssistantMessageById(i);if(s){this.currentToolCallMessageId=s.id;const u=s.parts.find(d=>d.type==="tool-invocation"&&d.toolInvocation.toolCallId===this.currentToolCallId);if(u&&u.type==="tool-invocation"){this.currentToolCallArgs=u.toolInvocation.args;return}this.sessionManager.updateMessage({...s,parts:[...s.parts||[],n]});return}if(i){this.currentToolCallMessageId=i,this.sessionManager.addMessages([{id:i,role:"assistant",parts:[n]}]);return}const o=this.findAssistantMessageByToolCallId(this.currentToolCallId);if(o){this.currentToolCallMessageId=o.id;const u=o.parts.find(d=>d.type==="tool-invocation"&&d.toolInvocation.toolCallId===this.currentToolCallId);this.currentToolCallArgs=(u==null?void 0:u.type)==="tool-invocation"?u.toolInvocation.args:"";return}const a=r[r.length-1];if(a&&a.role==="assistant")this.currentToolCallMessageId=a.id,this.sessionManager.updateMessage({...a,parts:[...a.parts||[],n]});else{const u=Cn();this.currentToolCallMessageId=u,this.sessionManager.addMessages([{id:u,role:"assistant",parts:[n]}])}}handleToolCallArgsDelta(t){var i;if(this.currentToolCallId!==t.toolCallId)return;this.currentToolCallArgs+=t.argsDelta;const n=this.findAssistantMessageForCurrentTool(t.toolCallId);if(!n||n.role!=="assistant"||!((i=n.parts)!=null&&i.length))return;const r=[...n.parts];for(let s=r.length-1;s>=0;s--){const o=r[s];if(o.type==="tool-invocation"&&o.toolInvocation.toolCallId===t.toolCallId){let a;try{a=JSON.parse(this.currentToolCallArgs)}catch{}r[s]={...o,toolInvocation:{...o.toolInvocation,status:se.PARTIAL_CALL,args:this.currentToolCallArgs,parsedArgs:a}};break}}this.sessionManager.updateMessage({...n,parts:r})}handleToolCallArgs(t){this.currentToolCallId===t.toolCallId&&(this.currentToolCallArgs=t.args,this.handleToolCallArgsDelta({type:K.TOOL_CALL_ARGS_DELTA,toolCallId:t.toolCallId,argsDelta:""}))}handleToolCallEnd(){var t;if(!(!this.currentToolCallId||!this.currentToolCallName)){try{const n={id:this.currentToolCallId,type:"function",function:{name:this.currentToolCallName,arguments:this.currentToolCallArgs}},r=this.findAssistantMessageForCurrentTool(this.currentToolCallId);if(r&&r.role==="assistant"){const i=[...r.parts||[]];for(let s=i.length-1;s>=0;s--){const o=i[s];if(o.type==="tool-invocation"&&o.toolInvocation.toolCallId===this.currentToolCallId){i[s]={...o,toolInvocation:{...vr(n),status:se.CALL}};break}}this.sessionManager.updateMessage({...r,parts:i})}else{const i=((t=this.currentToolCallMessageId)==null?void 0:t.trim())||Cn();this.sessionManager.addMessages([{id:i,role:"assistant",parts:[{type:"tool-invocation",toolInvocation:{...vr(n),status:se.CALL}}]}])}}catch{}this.currentToolCallId=void 0,this.currentToolCallMessageId=void 0,this.currentToolCallName=void 0,this.currentToolCallArgs=""}}handleToolCallResult(t){this.sessionManager.addToolResult({toolCallId:t.toolCallId,result:t.content,status:se.RESULT})}}class cl{constructor(){F(this,"disposables",[]);F(this,"addDisposable",t=>{this.disposables.push(t)});F(this,"dispose",()=>{this.disposables.forEach(t=>t()),this.disposables=[]})}}class dl extends cl{constructor(n=null,r){super();F(this,"_messages$",new We([]));F(this,"messages$");F(this,"threadId$",new We(null));F(this,"isAgentResponding$",new We(!1));F(this,"activeRun$",new We(null));F(this,"lastError$",new We(null));F(this,"isAwaitingResponse$",new We(!1));F(this,"runCompleted$",new Ne);F(this,"runError$",new Ne);F(this,"runMetadata$",new Ne);F(this,"activeSubscription",null);F(this,"addMessagesEvent$",new Ne);F(this,"updateMessageEvent$",new Ne);F(this,"setMessagesEvent$",new Ne);F(this,"toolCall$",new Ne);F(this,"eventHandler",new ul(this));F(this,"runIdCounter",0);F(this,"metadataParsers");F(this,"callbacks");F(this,"getMessages",()=>this._messages$.getValue());F(this,"setMessages",n=>{this._messages$.next(n),this.setMessagesEvent$.next({messages:n})});F(this,"handleEvent",n=>{this.eventHandler.handleEvent(n)});F(this,"setCallbacks",n=>{this.callbacks=n});F(this,"reset",()=>{this.abortAgentRun(),this._messages$.next([]),this.eventHandler.reset(),this.threadId$.next(null),this.isAgentResponding$.next(!1),this.activeRun$.next(null),this.lastError$.next(null),this.isAwaitingResponse$.next(!1),this.runIdCounter+=1});F(this,"addMessages",n=>{const i=[...this.getMessages()];for(const s of n){const o=i.findIndex(a=>a.id===s.id);o>=0?i[o]=s:i.push(s)}this._messages$.next(i),this.addMessagesEvent$.next({messages:n}),this.isAwaitingResponse$.getValue()&&n.some(s=>s.role==="assistant")&&this.isAwaitingResponse$.next(!1)});F(this,"removeMessages",n=>{n.length!==0&&this._messages$.next(this.getMessages().filter(r=>!n.includes(r.id)))});F(this,"updateMessage",n=>{this._messages$.next(this.getMessages().map(r=>r.id===n.id?n:r)),this.updateMessageEvent$.next({message:n}),this.isAwaitingResponse$.getValue()&&n.role==="assistant"&&this.isAwaitingResponse$.next(!1)});F(this,"addToolResult",(n,r)=>{const i=this.getMessages().find(o=>o.parts.find(a=>a.type==="tool-invocation"&&a.toolInvocation.toolCallId===n.toolCallId));if(!i)return;const s={...i,parts:i.parts.map(o=>o.type==="tool-invocation"&&o.toolInvocation.toolCallId===n.toolCallId?{...o,toolInvocation:{...o.toolInvocation,result:n.result??void 0,status:n.status,error:n.error??void 0,cancelled:n.cancelled??void 0}}:o)};this.updateMessage(s)});F(this,"send",async n=>{(this.activeRun$.getValue()||this.activeSubscription)&&this.abortAgentRun(),this.lastError$.next(null);const r=n.message.trim();r&&(this.addMessages([{id:Cn(),role:"user",parts:[{type:"text",text:r}]}]),await this.runAgent({metadata:n.metadata,sessionId:n.sessionId,agentId:n.agentId,stopCapable:n.stopCapable,stopReason:n.stopReason,sourceMessage:r,restoreDraftOnError:n.restoreDraftOnError}))});F(this,"resume",async n=>{var o,a;const r=(o=n.remoteRunId)==null?void 0:o.trim(),i=(a=n.sessionId)==null?void 0:a.trim();if(!r)return;const s=this.activeRun$.getValue();(s==null?void 0:s.remoteRunId)!==r&&(s||(this.lastError$.next(null),await this.runAgent({metadata:n.metadata,sessionId:i,agentId:n.agentId,stopCapable:n.stopCapable,stopReason:n.stopReason})))});F(this,"stop",async()=>{var i,s;const n=this.activeRun$.getValue();if(!n)return;const r=n.sessionId;this.abortAgentRun(),r&&await((s=(i=this.callbacks).onRunSettled)==null?void 0:s.call(i,{sourceSessionId:r}))});F(this,"handleAgentResponse",n=>{this.activeSubscription&&this.activeSubscription.unsubscribe(),this.activeSubscription=n.subscribe(r=>{var i,s,o,a,l,u,d,c,p;if(r.type===K.RUN_METADATA){const h=r,m=this.activeRun$.getValue(),x=((i=h.runId)==null?void 0:i.trim())||(m?`ui-${m.localRunId}`:"");this.metadataParsers&&m&&this.isMatchingRun(m,x)&&this.processRunMetadata(m,h.metadata),this.runMetadata$.next({runId:x,metadata:h.metadata});return}if(this.handleEvent(r),r.type===K.RUN_FINISHED){this.isAgentResponding$.next(!1),this.isAwaitingResponse$.next(!1),this.activeSubscription=null;const h=this.activeRun$.getValue(),m=((s=r.runId)==null?void 0:s.trim())||(h?`ui-${h.localRunId}`:"");if(!h||!this.isMatchingRun(h,m))return;const x=h.sessionId;this.activeRun$.next(null),x&&((a=(o=this.callbacks).onRunSettled)==null||a.call(o,{sourceSessionId:x}))}else if(r.type===K.RUN_ERROR){this.isAgentResponding$.next(!1),this.isAwaitingResponse$.next(!1),this.activeSubscription=null;const h=this.activeRun$.getValue(),m=((l=r.runId)==null?void 0:l.trim())||(h?`ui-${h.localRunId}`:""),x=In(r.error);if(this.runError$.next({runId:m,error:r.error,isAbort:x}),!h||!this.isMatchingRun(h,m)){this.activeRun$.next(null);return}const S=h.sessionId;if(x){this.activeRun$.next(null),S&&((d=(u=this.callbacks).onRunSettled)==null||d.call(u,{sourceSessionId:S}));return}const g=Cr(r.error);this.lastError$.next(g),this.activeRun$.next(null),S&&this.addMessages([Ir(g,{sessionKey:S,status:"error"})]),(p=(c=this.callbacks).onRunError)==null||p.call(c,{error:g,sourceMessage:h.sourceMessage,restoreDraft:h.restoreDraftOnError})}})});F(this,"abortAgentRun",()=>{var n,r,i;(i=(n=this.agentProvider)==null?void 0:(r=n.agent).abortRun)==null||i.call(r),this.activeSubscription&&(this.activeSubscription.unsubscribe(),this.activeSubscription=null,this.isAgentResponding$.next(!1),this.isAwaitingResponse$.next(!1)),this.activeRun$.next(null)});F(this,"runAgent",async n=>{var o,a,l,u;if(!this.agentProvider)return;(this.activeRun$.getValue()||this.activeSubscription)&&this.abortAgentRun();const r=++this.runIdCounter,i=`ui-${r}`,s={localRunId:r,sessionId:n==null?void 0:n.sessionId,...n!=null&&n.agentId?{agentId:n.agentId}:{},remoteStopCapable:!!(n!=null&&n.stopCapable),...n!=null&&n.stopReason?{remoteStopReason:n.stopReason}:{},sourceMessage:n==null?void 0:n.sourceMessage,restoreDraftOnError:n==null?void 0:n.restoreDraftOnError};this.activeRun$.next(s),this.isAgentResponding$.next(!0),this.isAwaitingResponse$.next(!0);try{const d=ll(this.getMessages()),c=typeof(n==null?void 0:n.threadId)=="string"&&n.threadId.trim()?n.threadId:this.threadId$.getValue()??"",p=await this.agentProvider.agent.run({threadId:c,runId:i,messages:d,tools:this.agentProvider.getToolDefs(),context:this.agentProvider.getContexts(),...n!=null&&n.metadata?{metadata:n.metadata}:{}});this.handleAgentResponse(p)}catch(d){const c=In(d);c?console.info("Agent run aborted"):console.error("Error running agent:",d),this.isAgentResponding$.next(!1),this.isAwaitingResponse$.next(!1);const p=this.activeRun$.getValue();if(this.activeRun$.next(null),this.runError$.next({runId:i,error:d,isAbort:c}),!c&&p){const h=Cr(d);this.lastError$.next(h),p.sessionId&&this.addMessages([Ir(h,{sessionKey:p.sessionId,status:"error"})]),(a=(o=this.callbacks).onRunError)==null||a.call(o,{error:h,sourceMessage:p.sourceMessage,restoreDraft:p.restoreDraftOnError})}else c&&(p!=null&&p.sessionId)&&((u=(l=this.callbacks).onRunSettled)==null||u.call(l,{sourceSessionId:p.sessionId}))}});F(this,"processRunMetadata",(n,r)=>{if(!this.metadataParsers)return;const i=this.metadataParsers.parseReady(r);if(i){this.applyReadyMetadata(n,i);return}const s=this.metadataParsers.parseFinal(r);s&&this.applyFinalMetadata(n,s)});F(this,"applyReadyMetadata",(n,r)=>{var s,o,a,l,u;const i={...n};(s=r.remoteRunId)!=null&&s.trim()&&(i.remoteRunId=r.remoteRunId.trim()),typeof r.stopCapable=="boolean"&&(i.remoteStopCapable=r.stopCapable),(o=r.stopReason)!=null&&o.trim()&&(i.remoteStopReason=r.stopReason.trim()),(a=r.sessionId)!=null&&a.trim()&&(i.sessionId=r.sessionId.trim(),(u=(l=this.callbacks).onSessionChanged)==null||u.call(l,i.sessionId)),this.activeRun$.next(i)});F(this,"applyFinalMetadata",(n,r)=>{var o,a,l,u;const i=n.sessionId,s=r.sessionId;s&&s!==i&&((a=(o=this.callbacks).onSessionChanged)==null||a.call(o,s)),this.activeRun$.next(null),i&&((u=(l=this.callbacks).onRunSettled)==null||u.call(l,{sourceSessionId:i,resultSessionId:s}))});F(this,"isMatchingRun",(n,r)=>r.trim()?r===`ui-${n.localRunId}`:!1);F(this,"connectToolExecutor",()=>{const n=this.toolCall$.subscribe(async({toolCall:r})=>{var s;const i=(s=this.agentProvider)==null?void 0:s.getToolExecutor(r.function.name);if(i)try{const o=JSON.parse(r.function.arguments),a=await i(o);this.addToolResult({toolCallId:r.id,result:a,status:se.RESULT}),this.runAgent()}catch(o){console.error("[AgentChatController] handleAddToolResult error",o),this.addToolResult({toolCallId:r.id,error:o instanceof Error?o.message:String(o),status:se.ERROR}),this.runAgent()}});return()=>n.unsubscribe()});this.agentProvider=n;const{initialMessages:i=[],metadataParsers:s,callbacks:o={}}=r||{};this.metadataParsers=s??null,this.callbacks=o,this._messages$.next(i),this.messages$=this._messages$.asObservable(),this.agentProvider&&this.addDisposable(this.connectToolExecutor())}}function hl(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const fl=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,pl=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ml={};function Rr(e,t){return(ml.jsx?pl:fl).test(e)}const gl=/[ \t\n\f\r]/g;function xl(e){return typeof e=="object"?e.type==="text"?Tr(e.value):!1:Tr(e)}function Tr(e){return e.replace(gl,"")===""}class bt{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}bt.prototype.normal={};bt.prototype.property={};bt.prototype.space=void 0;function Ki(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new bt(n,r,t)}function Rn(e){return e.toLowerCase()}class pe{constructor(t,n){this.attribute=n,this.property=t}}pe.prototype.attribute="";pe.prototype.booleanish=!1;pe.prototype.boolean=!1;pe.prototype.commaOrSpaceSeparated=!1;pe.prototype.commaSeparated=!1;pe.prototype.defined=!1;pe.prototype.mustUseProperty=!1;pe.prototype.number=!1;pe.prototype.overloadedBoolean=!1;pe.prototype.property="";pe.prototype.spaceSeparated=!1;pe.prototype.space=void 0;let yl=0;const $=Ve(),ee=Ve(),Tn=Ve(),E=Ve(),Y=Ve(),Ye=Ve(),ge=Ve();function Ve(){return 2**++yl}const An=Object.freeze(Object.defineProperty({__proto__:null,boolean:$,booleanish:ee,commaOrSpaceSeparated:ge,commaSeparated:Ye,number:E,overloadedBoolean:Tn,spaceSeparated:Y},Symbol.toStringTag,{value:"Module"})),Qt=Object.keys(An);class Hn extends pe{constructor(t,n,r,i){let s=-1;if(super(t,n),Ar(this,"space",i),typeof r=="number")for(;++s<Qt.length;){const o=Qt[s];Ar(this,Qt[s],(r&An[o])===An[o])}}}Hn.prototype.defined=!0;function Ar(e,t,n){n&&(e[t]=n)}function et(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new Hn(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[Rn(r)]=r,n[Rn(s.attribute)]=r}return new bt(t,n,e.space)}const Vi=et({properties:{ariaActiveDescendant:null,ariaAtomic:ee,ariaAutoComplete:null,ariaBusy:ee,ariaChecked:ee,ariaColCount:E,ariaColIndex:E,ariaColSpan:E,ariaControls:Y,ariaCurrent:null,ariaDescribedBy:Y,ariaDetails:null,ariaDisabled:ee,ariaDropEffect:Y,ariaErrorMessage:null,ariaExpanded:ee,ariaFlowTo:Y,ariaGrabbed:ee,ariaHasPopup:null,ariaHidden:ee,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Y,ariaLevel:E,ariaLive:null,ariaModal:ee,ariaMultiLine:ee,ariaMultiSelectable:ee,ariaOrientation:null,ariaOwns:Y,ariaPlaceholder:null,ariaPosInSet:E,ariaPressed:ee,ariaReadOnly:ee,ariaRelevant:null,ariaRequired:ee,ariaRoleDescription:Y,ariaRowCount:E,ariaRowIndex:E,ariaRowSpan:E,ariaSelected:ee,ariaSetSize:E,ariaSort:null,ariaValueMax:E,ariaValueMin:E,ariaValueNow:E,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function qi(e,t){return t in e?e[t]:t}function Wi(e,t){return qi(e,t.toLowerCase())}const bl=et({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Ye,acceptCharset:Y,accessKey:Y,action:null,allow:null,allowFullScreen:$,allowPaymentRequest:$,allowUserMedia:$,alt:null,as:null,async:$,autoCapitalize:null,autoComplete:Y,autoFocus:$,autoPlay:$,blocking:Y,capture:null,charSet:null,checked:$,cite:null,className:Y,cols:E,colSpan:null,content:null,contentEditable:ee,controls:$,controlsList:Y,coords:E|Ye,crossOrigin:null,data:null,dateTime:null,decoding:null,default:$,defer:$,dir:null,dirName:null,disabled:$,download:Tn,draggable:ee,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:$,formTarget:null,headers:Y,height:E,hidden:Tn,high:E,href:null,hrefLang:null,htmlFor:Y,httpEquiv:Y,id:null,imageSizes:null,imageSrcSet:null,inert:$,inputMode:null,integrity:null,is:null,isMap:$,itemId:null,itemProp:Y,itemRef:Y,itemScope:$,itemType:Y,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:$,low:E,manifest:null,max:null,maxLength:E,media:null,method:null,min:null,minLength:E,multiple:$,muted:$,name:null,nonce:null,noModule:$,noValidate:$,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:$,optimum:E,pattern:null,ping:Y,placeholder:null,playsInline:$,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:$,referrerPolicy:null,rel:Y,required:$,reversed:$,rows:E,rowSpan:E,sandbox:Y,scope:null,scoped:$,seamless:$,selected:$,shadowRootClonable:$,shadowRootDelegatesFocus:$,shadowRootMode:null,shape:null,size:E,sizes:null,slot:null,span:E,spellCheck:ee,src:null,srcDoc:null,srcLang:null,srcSet:null,start:E,step:null,style:null,tabIndex:E,target:null,title:null,translate:null,type:null,typeMustMatch:$,useMap:null,value:ee,width:E,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Y,axis:null,background:null,bgColor:null,border:E,borderColor:null,bottomMargin:E,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:$,declare:$,event:null,face:null,frame:null,frameBorder:null,hSpace:E,leftMargin:E,link:null,longDesc:null,lowSrc:null,marginHeight:E,marginWidth:E,noResize:$,noHref:$,noShade:$,noWrap:$,object:null,profile:null,prompt:null,rev:null,rightMargin:E,rules:null,scheme:null,scrolling:ee,standby:null,summary:null,text:null,topMargin:E,valueType:null,version:null,vAlign:null,vLink:null,vSpace:E,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:$,disableRemotePlayback:$,prefix:null,property:null,results:E,security:null,unselectable:null},space:"html",transform:Wi}),Sl=et({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:ge,accentHeight:E,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:E,amplitude:E,arabicForm:null,ascent:E,attributeName:null,attributeType:null,azimuth:E,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:E,by:null,calcMode:null,capHeight:E,className:Y,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:E,diffuseConstant:E,direction:null,display:null,dur:null,divisor:E,dominantBaseline:null,download:$,dx:null,dy:null,edgeMode:null,editable:null,elevation:E,enableBackground:null,end:null,event:null,exponent:E,externalResourcesRequired:null,fill:null,fillOpacity:E,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Ye,g2:Ye,glyphName:Ye,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:E,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:E,horizOriginX:E,horizOriginY:E,id:null,ideographic:E,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:E,k:E,k1:E,k2:E,k3:E,k4:E,kernelMatrix:ge,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:E,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:E,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:E,overlineThickness:E,paintOrder:null,panose1:null,path:null,pathLength:E,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Y,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:E,pointsAtY:E,pointsAtZ:E,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ge,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ge,rev:ge,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ge,requiredFeatures:ge,requiredFonts:ge,requiredFormats:ge,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:E,specularExponent:E,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:E,strikethroughThickness:E,string:null,stroke:null,strokeDashArray:ge,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:E,strokeOpacity:E,strokeWidth:null,style:null,surfaceScale:E,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ge,tabIndex:E,tableValues:null,target:null,targetX:E,targetY:E,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ge,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:E,underlineThickness:E,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:E,values:null,vAlphabetic:E,vMathematical:E,vectorEffect:null,vHanging:E,vIdeographic:E,version:null,vertAdvY:E,vertOriginX:E,vertOriginY:E,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:E,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:qi}),Gi=et({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),Xi=et({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Wi}),Qi=et({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),kl={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},wl=/[A-Z]/g,Er=/-[a-z]/g,vl=/^data[-\w.:]+$/i;function Cl(e,t){const n=Rn(t);let r=t,i=pe;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&vl.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(Er,Rl);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!Er.test(s)){let o=s.replace(wl,Il);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=Hn}return new i(r,t)}function Il(e){return"-"+e.toLowerCase()}function Rl(e){return e.charAt(1).toUpperCase()}const Tl=Ki([Vi,bl,Gi,Xi,Qi],"html"),Kn=Ki([Vi,Sl,Gi,Xi,Qi],"svg");function Al(e){return e.join(" ").trim()}var Ge={},Yt,Mr;function El(){if(Mr)return Yt;Mr=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,o=/^[;\s]*/,a=/^\s+|\s+$/g,l=`
|
|
4
|
+
`,u="/",d="*",c="",p="comment",h="declaration";function m(S,g){if(typeof S!="string")throw new TypeError("First argument must be a string");if(!S)return[];g=g||{};var v=1,k=1;function T(O){var P=O.match(t);P&&(v+=P.length);var G=O.lastIndexOf(l);k=~G?O.length-G:k+O.length}function N(){var O={line:v,column:k};return function(P){return P.position=new w(O),U(),P}}function w(O){this.start=O,this.end={line:v,column:k},this.source=g.source}w.prototype.content=S;function _(O){var P=new Error(g.source+":"+v+":"+k+": "+O);if(P.reason=O,P.filename=g.source,P.line=v,P.column=k,P.source=S,!g.silent)throw P}function z(O){var P=O.exec(S);if(P){var G=P[0];return T(G),S=S.slice(G.length),P}}function U(){z(n)}function C(O){var P;for(O=O||[];P=j();)P!==!1&&O.push(P);return O}function j(){var O=N();if(!(u!=S.charAt(0)||d!=S.charAt(1))){for(var P=2;c!=S.charAt(P)&&(d!=S.charAt(P)||u!=S.charAt(P+1));)++P;if(P+=2,c===S.charAt(P-1))return _("End of comment missing");var G=S.slice(2,P-2);return k+=2,T(G),S=S.slice(P),k+=2,O({type:p,comment:G})}}function L(){var O=N(),P=z(r);if(P){if(j(),!z(i))return _("property missing ':'");var G=z(s),J=O({type:h,property:x(P[0].replace(e,c)),value:G?x(G[0].replace(e,c)):c});return z(o),J}}function W(){var O=[];C(O);for(var P;P=L();)P!==!1&&(O.push(P),C(O));return O}return U(),W()}function x(S){return S?S.replace(a,c):c}return Yt=m,Yt}var Nr;function Ml(){if(Nr)return Ge;Nr=1;var e=Ge&&Ge.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Ge,"__esModule",{value:!0}),Ge.default=n;const t=e(El());function n(r,i){let s=null;if(!r||typeof r!="string")return s;const o=(0,t.default)(r),a=typeof i=="function";return o.forEach(l=>{if(l.type!=="declaration")return;const{property:u,value:d}=l;a?i(u,d,l):d&&(s=s||{},s[u]=d)}),s}return Ge}var it={},Pr;function Nl(){if(Pr)return it;Pr=1,Object.defineProperty(it,"__esModule",{value:!0}),it.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,s=function(u){return!u||n.test(u)||e.test(u)},o=function(u,d){return d.toUpperCase()},a=function(u,d){return"".concat(d,"-")},l=function(u,d){return d===void 0&&(d={}),s(u)?u:(u=u.toLowerCase(),d.reactCompat?u=u.replace(i,a):u=u.replace(r,a),u.replace(t,o))};return it.camelCase=l,it}var st,jr;function Pl(){if(jr)return st;jr=1;var e=st&&st.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(Ml()),n=Nl();function r(i,s){var o={};return!i||typeof i!="string"||(0,t.default)(i,function(a,l){a&&l&&(o[(0,n.camelCase)(a,s)]=l)}),o}return r.default=r,st=r,st}var jl=Pl();const Ll=vi(jl),Yi=Ji("end"),Vn=Ji("start");function Ji(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function _l(e){const t=Vn(e),n=Yi(e);if(t&&n)return{start:t,end:n}}function ct(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Lr(e.position):"start"in e||"end"in e?Lr(e):"line"in e||"column"in e?En(e):""}function En(e){return _r(e&&e.line)+":"+_r(e&&e.column)}function Lr(e){return En(e&&e.start)+"-"+En(e&&e.end)}function _r(e){return e&&typeof e=="number"?e:1}class le extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},o=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?i=t:!s.cause&&t&&(o=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?s.ruleId=r:(s.source=r.slice(0,l),s.ruleId=r.slice(l+1))}if(!s.place&&s.ancestors&&s.ancestors){const l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position)}const a=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=a?a.line:void 0,this.name=ct(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=o&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}le.prototype.file="";le.prototype.name="";le.prototype.reason="";le.prototype.message="";le.prototype.stack="";le.prototype.column=void 0;le.prototype.line=void 0;le.prototype.ancestors=void 0;le.prototype.cause=void 0;le.prototype.fatal=void 0;le.prototype.place=void 0;le.prototype.ruleId=void 0;le.prototype.source=void 0;const qn={}.hasOwnProperty,Ol=new Map,Dl=/[A-Z]/g,Fl=new Set(["table","tbody","thead","tfoot","tr"]),zl=new Set(["td","th"]),Zi="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Bl(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=Gl(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=Wl(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Kn:Tl,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=es(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function es(e,t,n){if(t.type==="element")return $l(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return Ul(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Kl(e,t,n);if(t.type==="mdxjsEsm")return Hl(e,t);if(t.type==="root")return Vl(e,t,n);if(t.type==="text")return ql(e,t)}function $l(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=Kn,e.schema=i),e.ancestors.push(t);const s=ns(e,t.tagName,!1),o=Xl(e,t);let a=Gn(e,t);return Fl.has(t.tagName)&&(a=a.filter(function(l){return typeof l=="string"?!xl(l):!0})),ts(e,o,s,t),Wn(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function Ul(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}gt(e,t.position)}function Hl(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);gt(e,t.position)}function Kl(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=Kn,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:ns(e,t.name,!0),o=Ql(e,t),a=Gn(e,t);return ts(e,o,s,t),Wn(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function Vl(e,t,n){const r={};return Wn(r,Gn(e,t)),e.create(t,e.Fragment,r,n)}function ql(e,t){return t.value}function ts(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Wn(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Wl(e,t,n){return r;function r(i,s,o,a){const u=Array.isArray(o.children)?n:t;return a?u(s,o,a):u(s,o)}}function Gl(e,t){return n;function n(r,i,s,o){const a=Array.isArray(s.children),l=Vn(r);return t(i,s,o,a,{columnNumber:l?l.column-1:void 0,fileName:e,lineNumber:l?l.line:void 0},void 0)}}function Xl(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&qn.call(t.properties,i)){const s=Yl(e,i,t.properties[i]);if(s){const[o,a]=s;e.tableCellAlignToStyle&&o==="align"&&typeof a=="string"&&zl.has(t.tagName)?r=a:n[o]=a}}if(r){const s=n.style||(n.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function Ql(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const s=r.data.estree.body[0];s.type;const o=s.expression;o.type;const a=o.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else gt(e,t.position);else{const i=r.name;let s;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const a=r.value.data.estree.body[0];a.type,s=e.evaluater.evaluateExpression(a.expression)}else gt(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function Gn(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:Ol;for(;++r<t.children.length;){const s=t.children[r];let o;if(e.passKeys){const l=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(l){const u=i.get(l)||0;o=l+"-"+u,i.set(l,u+1)}}const a=es(e,s,o);a!==void 0&&n.push(a)}return n}function Yl(e,t,n){const r=Cl(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?hl(n):Al(n)),r.property==="style"){let i=typeof n=="object"?n:Jl(e,String(n));return e.stylePropertyNameCase==="css"&&(i=Zl(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?kl[r.property]||r.property:r.attribute,n]}}function Jl(e,t){try{return Ll(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new le("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=Zi+"#cannot-parse-style-attribute",i}}function ns(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let s=-1,o;for(;++s<i.length;){const a=Rr(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};o=o?{type:"MemberExpression",object:o,property:a,computed:!!(s&&a.type==="Literal"),optional:!1}:a}r=o}else r=Rr(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return qn.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);gt(e)}function gt(e,t){const n=new le("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=Zi+"#cannot-handle-mdx-estrees-without-createevaluater",n}function Zl(e){const t={};let n;for(n in e)qn.call(e,n)&&(t[eu(n)]=e[n]);return t}function eu(e){let t=e.replace(Dl,tu);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function tu(e){return"-"+e.toLowerCase()}const Jt={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},nu={};function Xn(e,t){const n=nu,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return rs(e,r,i)}function rs(e,t,n){if(ru(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Or(e.children,t,n)}return Array.isArray(e)?Or(e,t,n):""}function Or(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=rs(e[i],t,n);return r.join("")}function ru(e){return!!(e&&typeof e=="object")}const Dr=document.createElement("i");function Qn(e){const t="&"+e+";";Dr.innerHTML=t;const n=Dr.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function xe(e,t,n,r){const i=e.length;let s=0,o;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);s<r.length;)o=r.slice(s,s+1e4),o.unshift(t,0),e.splice(...o),s+=1e4,t+=1e4}function Se(e,t){return e.length>0?(xe(e,e.length,0,t),e):t}const Fr={}.hasOwnProperty;function is(e){const t={};let n=-1;for(;++n<e.length;)iu(t,e[n]);return t}function iu(e,t){let n;for(n in t){const i=(Fr.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let o;if(s)for(o in s){Fr.call(i,o)||(i[o]=[]);const a=s[o];su(i[o],Array.isArray(a)?a:a?[a]:[])}}}function su(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);xe(e,0,0,r)}function ss(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Ce(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const ue=De(/[A-Za-z]/),ae=De(/[\dA-Za-z]/),ou=De(/[#-'*+\--9=?A-Z^-~]/);function jt(e){return e!==null&&(e<32||e===127)}const Mn=De(/\d/),au=De(/[\dA-Fa-f]/),lu=De(/[!-/:-@[-`{-~]/);function D(e){return e!==null&&e<-2}function Q(e){return e!==null&&(e<0||e===32)}function H(e){return e===-2||e===-1||e===32}const Ut=De(new RegExp("\\p{P}|\\p{S}","u")),Ke=De(/\s/);function De(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function tt(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let o="";if(s===37&&ae(e.charCodeAt(n+1))&&ae(e.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(o=String.fromCharCode(s));else if(s>55295&&s<57344){const a=e.charCodeAt(n+1);s<56320&&a>56319&&a<57344?(o=String.fromCharCode(s,a),i=1):o="�"}else o=String.fromCharCode(s);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function q(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return o;function o(l){return H(l)?(e.enter(n),a(l)):t(l)}function a(l){return H(l)&&s++<i?(e.consume(l),a):(e.exit(n),t(l))}}const uu={tokenize:cu};function cu(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),q(e,t,"linePrefix")}function i(a){return e.enter("paragraph"),s(a)}function s(a){const l=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,o(a)}function o(a){if(a===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return D(a)?(e.consume(a),e.exit("chunkText"),s):(e.consume(a),o)}}const du={tokenize:hu},zr={tokenize:fu};function hu(e){const t=this,n=[];let r=0,i,s,o;return a;function a(k){if(r<n.length){const T=n[r];return t.containerState=T[1],e.attempt(T[0].continuation,l,u)(k)}return u(k)}function l(k){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();const T=t.events.length;let N=T,w;for(;N--;)if(t.events[N][0]==="exit"&&t.events[N][1].type==="chunkFlow"){w=t.events[N][1].end;break}g(r);let _=T;for(;_<t.events.length;)t.events[_][1].end={...w},_++;return xe(t.events,N+1,0,t.events.slice(T)),t.events.length=_,u(k)}return a(k)}function u(k){if(r===n.length){if(!i)return p(k);if(i.currentConstruct&&i.currentConstruct.concrete)return m(k);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(zr,d,c)(k)}function d(k){return i&&v(),g(r),p(k)}function c(k){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(k)}function p(k){return t.containerState={},e.attempt(zr,h,m)(k)}function h(k){return r++,n.push([t.currentConstruct,t.containerState]),p(k)}function m(k){if(k===null){i&&v(),g(0),e.consume(k);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),x(k)}function x(k){if(k===null){S(e.exit("chunkFlow"),!0),g(0),e.consume(k);return}return D(k)?(e.consume(k),S(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(k),x)}function S(k,T){const N=t.sliceStream(k);if(T&&N.push(null),k.previous=s,s&&(s.next=k),s=k,i.defineSkip(k.start),i.write(N),t.parser.lazy[k.start.line]){let w=i.events.length;for(;w--;)if(i.events[w][1].start.offset<o&&(!i.events[w][1].end||i.events[w][1].end.offset>o))return;const _=t.events.length;let z=_,U,C;for(;z--;)if(t.events[z][0]==="exit"&&t.events[z][1].type==="chunkFlow"){if(U){C=t.events[z][1].end;break}U=!0}for(g(r),w=_;w<t.events.length;)t.events[w][1].end={...C},w++;xe(t.events,z+1,0,t.events.slice(_)),t.events.length=w}}function g(k){let T=n.length;for(;T-- >k;){const N=n[T];t.containerState=N[1],N[0].exit.call(t,e)}n.length=k}function v(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function fu(e,t,n){return q(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Je(e){if(e===null||Q(e)||Ke(e))return 1;if(Ut(e))return 2}function Ht(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const s=e[i].resolveAll;s&&!r.includes(s)&&(t=s(t,n),r.push(s))}return t}const Nn={name:"attention",resolveAll:pu,tokenize:mu};function pu(e,t){let n=-1,r,i,s,o,a,l,u,d;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;l=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const c={...e[r][1].end},p={...e[n][1].start};Br(c,-l),Br(p,l),o={type:l>1?"strongSequence":"emphasisSequence",start:c,end:{...e[r][1].end}},a={type:l>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:p},s={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:l>1?"strong":"emphasis",start:{...o.start},end:{...a.end}},e[r][1].end={...o.start},e[n][1].start={...a.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=Se(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=Se(u,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",s,t]]),u=Se(u,Ht(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=Se(u,[["exit",s,t],["enter",a,t],["exit",a,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(d=2,u=Se(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):d=0,xe(e,r-1,n-r+3,u),n=r+u.length-d-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function mu(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Je(r);let s;return o;function o(l){return s=l,e.enter("attentionSequence"),a(l)}function a(l){if(l===s)return e.consume(l),a;const u=e.exit("attentionSequence"),d=Je(l),c=!d||d===2&&i||n.includes(l),p=!i||i===2&&d||n.includes(r);return u._open=!!(s===42?c:c&&(i||!p)),u._close=!!(s===42?p:p&&(d||!c)),t(l)}}function Br(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const gu={name:"autolink",tokenize:xu};function xu(e,t,n){let r=0;return i;function i(h){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s}function s(h){return ue(h)?(e.consume(h),o):h===64?n(h):u(h)}function o(h){return h===43||h===45||h===46||ae(h)?(r=1,a(h)):u(h)}function a(h){return h===58?(e.consume(h),r=0,l):(h===43||h===45||h===46||ae(h))&&r++<32?(e.consume(h),a):(r=0,u(h))}function l(h){return h===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):h===null||h===32||h===60||jt(h)?n(h):(e.consume(h),l)}function u(h){return h===64?(e.consume(h),d):ou(h)?(e.consume(h),u):n(h)}function d(h){return ae(h)?c(h):n(h)}function c(h){return h===46?(e.consume(h),r=0,d):h===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):p(h)}function p(h){if((h===45||ae(h))&&r++<63){const m=h===45?p:c;return e.consume(h),m}return n(h)}}const St={partial:!0,tokenize:yu};function yu(e,t,n){return r;function r(s){return H(s)?q(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||D(s)?t(s):n(s)}}const os={continuation:{tokenize:Su},exit:ku,name:"blockQuote",tokenize:bu};function bu(e,t,n){const r=this;return i;function i(o){if(o===62){const a=r.containerState;return a.open||(e.enter("blockQuote",{_container:!0}),a.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),s}return n(o)}function s(o){return H(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function Su(e,t,n){const r=this;return i;function i(o){return H(o)?q(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return e.attempt(os,t,n)(o)}}function ku(e){e.exit("blockQuote")}const as={name:"characterEscape",tokenize:wu};function wu(e,t,n){return r;function r(s){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(s),e.exit("escapeMarker"),i}function i(s){return lu(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const ls={name:"characterReference",tokenize:vu};function vu(e,t,n){const r=this;let i=0,s,o;return a;function a(c){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(c),e.exit("characterReferenceMarker"),l}function l(c){return c===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(c),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),s=31,o=ae,d(c))}function u(c){return c===88||c===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(c),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,o=au,d):(e.enter("characterReferenceValue"),s=7,o=Mn,d(c))}function d(c){if(c===59&&i){const p=e.exit("characterReferenceValue");return o===ae&&!Qn(r.sliceSerialize(p))?n(c):(e.enter("characterReferenceMarker"),e.consume(c),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return o(c)&&i++<s?(e.consume(c),d):n(c)}}const $r={partial:!0,tokenize:Iu},Ur={concrete:!0,name:"codeFenced",tokenize:Cu};function Cu(e,t,n){const r=this,i={partial:!0,tokenize:N};let s=0,o=0,a;return l;function l(w){return u(w)}function u(w){const _=r.events[r.events.length-1];return s=_&&_[1].type==="linePrefix"?_[2].sliceSerialize(_[1],!0).length:0,a=w,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),d(w)}function d(w){return w===a?(o++,e.consume(w),d):o<3?n(w):(e.exit("codeFencedFenceSequence"),H(w)?q(e,c,"whitespace")(w):c(w))}function c(w){return w===null||D(w)?(e.exit("codeFencedFence"),r.interrupt?t(w):e.check($r,x,T)(w)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(w))}function p(w){return w===null||D(w)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),c(w)):H(w)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),q(e,h,"whitespace")(w)):w===96&&w===a?n(w):(e.consume(w),p)}function h(w){return w===null||D(w)?c(w):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(w))}function m(w){return w===null||D(w)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),c(w)):w===96&&w===a?n(w):(e.consume(w),m)}function x(w){return e.attempt(i,T,S)(w)}function S(w){return e.enter("lineEnding"),e.consume(w),e.exit("lineEnding"),g}function g(w){return s>0&&H(w)?q(e,v,"linePrefix",s+1)(w):v(w)}function v(w){return w===null||D(w)?e.check($r,x,T)(w):(e.enter("codeFlowValue"),k(w))}function k(w){return w===null||D(w)?(e.exit("codeFlowValue"),v(w)):(e.consume(w),k)}function T(w){return e.exit("codeFenced"),t(w)}function N(w,_,z){let U=0;return C;function C(P){return w.enter("lineEnding"),w.consume(P),w.exit("lineEnding"),j}function j(P){return w.enter("codeFencedFence"),H(P)?q(w,L,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(P):L(P)}function L(P){return P===a?(w.enter("codeFencedFenceSequence"),W(P)):z(P)}function W(P){return P===a?(U++,w.consume(P),W):U>=o?(w.exit("codeFencedFenceSequence"),H(P)?q(w,O,"whitespace")(P):O(P)):z(P)}function O(P){return P===null||D(P)?(w.exit("codeFencedFence"),_(P)):z(P)}}}function Iu(e,t,n){const r=this;return i;function i(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const Zt={name:"codeIndented",tokenize:Tu},Ru={partial:!0,tokenize:Au};function Tu(e,t,n){const r=this;return i;function i(u){return e.enter("codeIndented"),q(e,s,"linePrefix",5)(u)}function s(u){const d=r.events[r.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?o(u):n(u)}function o(u){return u===null?l(u):D(u)?e.attempt(Ru,o,l)(u):(e.enter("codeFlowValue"),a(u))}function a(u){return u===null||D(u)?(e.exit("codeFlowValue"),o(u)):(e.consume(u),a)}function l(u){return e.exit("codeIndented"),t(u)}}function Au(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):D(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):q(e,s,"linePrefix",5)(o)}function s(o){const a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(o):D(o)?i(o):n(o)}}const Eu={name:"codeText",previous:Nu,resolve:Mu,tokenize:Pu};function Mu(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="codeTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function Nu(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Pu(e,t,n){let r=0,i,s;return o;function o(c){return e.enter("codeText"),e.enter("codeTextSequence"),a(c)}function a(c){return c===96?(e.consume(c),r++,a):(e.exit("codeTextSequence"),l(c))}function l(c){return c===null?n(c):c===32?(e.enter("space"),e.consume(c),e.exit("space"),l):c===96?(s=e.enter("codeTextSequence"),i=0,d(c)):D(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),l):(e.enter("codeTextData"),u(c))}function u(c){return c===null||c===32||c===96||D(c)?(e.exit("codeTextData"),l(c)):(e.consume(c),u)}function d(c){return c===96?(e.consume(c),i++,d):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(c)):(s.type="codeTextData",u(c))}}class ju{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&ot(this.left,r),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),ot(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),ot(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);ot(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);ot(this.left,n.reverse())}}}function ot(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function us(e){const t={};let n=-1,r,i,s,o,a,l,u;const d=new ju(e);for(;++n<d.length;){for(;n in t;)n=t[n];if(r=d.get(n),n&&r[1].type==="chunkFlow"&&d.get(n-1)[1].type==="listItemPrefix"&&(l=r[1]._tokenizer.events,s=0,s<l.length&&l[s][1].type==="lineEndingBlank"&&(s+=2),s<l.length&&l[s][1].type==="content"))for(;++s<l.length&&l[s][1].type!=="content";)l[s][1].type==="chunkText"&&(l[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,Lu(d,n)),n=t[n],u=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(o=d.get(s),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(i&&(d.get(i)[1].type="lineEndingBlank"),o[1].type="lineEnding",i=s);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;i&&(r[1].end={...d.get(i)[1].start},a=d.slice(i,n),a.unshift(r),d.splice(i,n-i+1,a))}}return xe(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!u}function Lu(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const s=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const a=o.events,l=[],u={};let d,c,p=-1,h=n,m=0,x=0;const S=[x];for(;h;){for(;e.get(++i)[1]!==h;);s.push(i),h._tokenizer||(d=r.sliceStream(h),h.next||d.push(null),c&&o.defineSkip(h.start),h._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(d),h._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),c=h,h=h.next}for(h=n;++p<a.length;)a[p][0]==="exit"&&a[p-1][0]==="enter"&&a[p][1].type===a[p-1][1].type&&a[p][1].start.line!==a[p][1].end.line&&(x=p+1,S.push(x),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(o.events=[],h?(h._tokenizer=void 0,h.previous=void 0):S.pop(),p=S.length;p--;){const g=a.slice(S[p],S[p+1]),v=s.pop();l.push([v,v+g.length-1]),e.splice(v,2,g)}for(l.reverse(),p=-1;++p<l.length;)u[m+l[p][0]]=m+l[p][1],m+=l[p][1]-l[p][0]-1;return u}const _u={resolve:Du,tokenize:Fu},Ou={partial:!0,tokenize:zu};function Du(e){return us(e),e}function Fu(e,t){let n;return r;function r(a){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(a)}function i(a){return a===null?s(a):D(a)?e.check(Ou,o,s)(a):(e.consume(a),i)}function s(a){return e.exit("chunkContent"),e.exit("content"),t(a)}function o(a){return e.consume(a),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function zu(e,t,n){const r=this;return i;function i(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),q(e,s,"linePrefix")}function s(o){if(o===null||D(o))return n(o);const a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function cs(e,t,n,r,i,s,o,a,l){const u=l||Number.POSITIVE_INFINITY;let d=0;return c;function c(g){return g===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(g),e.exit(s),p):g===null||g===32||g===41||jt(g)?n(g):(e.enter(r),e.enter(o),e.enter(a),e.enter("chunkString",{contentType:"string"}),x(g))}function p(g){return g===62?(e.enter(s),e.consume(g),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),h(g))}function h(g){return g===62?(e.exit("chunkString"),e.exit(a),p(g)):g===null||g===60||D(g)?n(g):(e.consume(g),g===92?m:h)}function m(g){return g===60||g===62||g===92?(e.consume(g),h):h(g)}function x(g){return!d&&(g===null||g===41||Q(g))?(e.exit("chunkString"),e.exit(a),e.exit(o),e.exit(r),t(g)):d<u&&g===40?(e.consume(g),d++,x):g===41?(e.consume(g),d--,x):g===null||g===32||g===40||jt(g)?n(g):(e.consume(g),g===92?S:x)}function S(g){return g===40||g===41||g===92?(e.consume(g),x):x(g)}}function ds(e,t,n,r,i,s){const o=this;let a=0,l;return u;function u(h){return e.enter(r),e.enter(i),e.consume(h),e.exit(i),e.enter(s),d}function d(h){return a>999||h===null||h===91||h===93&&!l||h===94&&!a&&"_hiddenFootnoteSupport"in o.parser.constructs?n(h):h===93?(e.exit(s),e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):D(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),d):(e.enter("chunkString",{contentType:"string"}),c(h))}function c(h){return h===null||h===91||h===93||D(h)||a++>999?(e.exit("chunkString"),d(h)):(e.consume(h),l||(l=!H(h)),h===92?p:c)}function p(h){return h===91||h===92||h===93?(e.consume(h),a++,c):c(h)}}function hs(e,t,n,r,i,s){let o;return a;function a(p){return p===34||p===39||p===40?(e.enter(r),e.enter(i),e.consume(p),e.exit(i),o=p===40?41:p,l):n(p)}function l(p){return p===o?(e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):(e.enter(s),u(p))}function u(p){return p===o?(e.exit(s),l(o)):p===null?n(p):D(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),q(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===o||p===null||D(p)?(e.exit("chunkString"),u(p)):(e.consume(p),p===92?c:d)}function c(p){return p===o||p===92?(e.consume(p),d):d(p)}}function dt(e,t){let n;return r;function r(i){return D(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):H(i)?q(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const Bu={name:"definition",tokenize:Uu},$u={partial:!0,tokenize:Hu};function Uu(e,t,n){const r=this;let i;return s;function s(h){return e.enter("definition"),o(h)}function o(h){return ds.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function a(h){return i=Ce(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),h===58?(e.enter("definitionMarker"),e.consume(h),e.exit("definitionMarker"),l):n(h)}function l(h){return Q(h)?dt(e,u)(h):u(h)}function u(h){return cs(e,d,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function d(h){return e.attempt($u,c,c)(h)}function c(h){return H(h)?q(e,p,"whitespace")(h):p(h)}function p(h){return h===null||D(h)?(e.exit("definition"),r.parser.defined.push(i),t(h)):n(h)}}function Hu(e,t,n){return r;function r(a){return Q(a)?dt(e,i)(a):n(a)}function i(a){return hs(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function s(a){return H(a)?q(e,o,"whitespace")(a):o(a)}function o(a){return a===null||D(a)?t(a):n(a)}}const Ku={name:"hardBreakEscape",tokenize:Vu};function Vu(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return D(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const qu={name:"headingAtx",resolve:Wu,tokenize:Gu};function Wu(e,t){let n=e.length-2,r=3,i,s;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},s={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},xe(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function Gu(e,t,n){let r=0;return i;function i(d){return e.enter("atxHeading"),s(d)}function s(d){return e.enter("atxHeadingSequence"),o(d)}function o(d){return d===35&&r++<6?(e.consume(d),o):d===null||Q(d)?(e.exit("atxHeadingSequence"),a(d)):n(d)}function a(d){return d===35?(e.enter("atxHeadingSequence"),l(d)):d===null||D(d)?(e.exit("atxHeading"),t(d)):H(d)?q(e,a,"whitespace")(d):(e.enter("atxHeadingText"),u(d))}function l(d){return d===35?(e.consume(d),l):(e.exit("atxHeadingSequence"),a(d))}function u(d){return d===null||d===35||Q(d)?(e.exit("atxHeadingText"),a(d)):(e.consume(d),u)}}const Xu=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Hr=["pre","script","style","textarea"],Qu={concrete:!0,name:"htmlFlow",resolveTo:Zu,tokenize:ec},Yu={partial:!0,tokenize:nc},Ju={partial:!0,tokenize:tc};function Zu(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function ec(e,t,n){const r=this;let i,s,o,a,l;return u;function u(b){return d(b)}function d(b){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(b),c}function c(b){return b===33?(e.consume(b),p):b===47?(e.consume(b),s=!0,x):b===63?(e.consume(b),i=3,r.interrupt?t:y):ue(b)?(e.consume(b),o=String.fromCharCode(b),S):n(b)}function p(b){return b===45?(e.consume(b),i=2,h):b===91?(e.consume(b),i=5,a=0,m):ue(b)?(e.consume(b),i=4,r.interrupt?t:y):n(b)}function h(b){return b===45?(e.consume(b),r.interrupt?t:y):n(b)}function m(b){const he="CDATA[";return b===he.charCodeAt(a++)?(e.consume(b),a===he.length?r.interrupt?t:L:m):n(b)}function x(b){return ue(b)?(e.consume(b),o=String.fromCharCode(b),S):n(b)}function S(b){if(b===null||b===47||b===62||Q(b)){const he=b===47,Ie=o.toLowerCase();return!he&&!s&&Hr.includes(Ie)?(i=1,r.interrupt?t(b):L(b)):Xu.includes(o.toLowerCase())?(i=6,he?(e.consume(b),g):r.interrupt?t(b):L(b)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(b):s?v(b):k(b))}return b===45||ae(b)?(e.consume(b),o+=String.fromCharCode(b),S):n(b)}function g(b){return b===62?(e.consume(b),r.interrupt?t:L):n(b)}function v(b){return H(b)?(e.consume(b),v):C(b)}function k(b){return b===47?(e.consume(b),C):b===58||b===95||ue(b)?(e.consume(b),T):H(b)?(e.consume(b),k):C(b)}function T(b){return b===45||b===46||b===58||b===95||ae(b)?(e.consume(b),T):N(b)}function N(b){return b===61?(e.consume(b),w):H(b)?(e.consume(b),N):k(b)}function w(b){return b===null||b===60||b===61||b===62||b===96?n(b):b===34||b===39?(e.consume(b),l=b,_):H(b)?(e.consume(b),w):z(b)}function _(b){return b===l?(e.consume(b),l=null,U):b===null||D(b)?n(b):(e.consume(b),_)}function z(b){return b===null||b===34||b===39||b===47||b===60||b===61||b===62||b===96||Q(b)?N(b):(e.consume(b),z)}function U(b){return b===47||b===62||H(b)?k(b):n(b)}function C(b){return b===62?(e.consume(b),j):n(b)}function j(b){return b===null||D(b)?L(b):H(b)?(e.consume(b),j):n(b)}function L(b){return b===45&&i===2?(e.consume(b),G):b===60&&i===1?(e.consume(b),J):b===62&&i===4?(e.consume(b),de):b===63&&i===3?(e.consume(b),y):b===93&&i===5?(e.consume(b),ye):D(b)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(Yu,be,W)(b)):b===null||D(b)?(e.exit("htmlFlowData"),W(b)):(e.consume(b),L)}function W(b){return e.check(Ju,O,be)(b)}function O(b){return e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),P}function P(b){return b===null||D(b)?W(b):(e.enter("htmlFlowData"),L(b))}function G(b){return b===45?(e.consume(b),y):L(b)}function J(b){return b===47?(e.consume(b),o="",ce):L(b)}function ce(b){if(b===62){const he=o.toLowerCase();return Hr.includes(he)?(e.consume(b),de):L(b)}return ue(b)&&o.length<8?(e.consume(b),o+=String.fromCharCode(b),ce):L(b)}function ye(b){return b===93?(e.consume(b),y):L(b)}function y(b){return b===62?(e.consume(b),de):b===45&&i===2?(e.consume(b),y):L(b)}function de(b){return b===null||D(b)?(e.exit("htmlFlowData"),be(b)):(e.consume(b),de)}function be(b){return e.exit("htmlFlow"),t(b)}}function tc(e,t,n){const r=this;return i;function i(o){return D(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s):n(o)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function nc(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(St,t,n)}}const rc={name:"htmlText",tokenize:ic};function ic(e,t,n){const r=this;let i,s,o;return a;function a(y){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(y),l}function l(y){return y===33?(e.consume(y),u):y===47?(e.consume(y),N):y===63?(e.consume(y),k):ue(y)?(e.consume(y),z):n(y)}function u(y){return y===45?(e.consume(y),d):y===91?(e.consume(y),s=0,m):ue(y)?(e.consume(y),v):n(y)}function d(y){return y===45?(e.consume(y),h):n(y)}function c(y){return y===null?n(y):y===45?(e.consume(y),p):D(y)?(o=c,J(y)):(e.consume(y),c)}function p(y){return y===45?(e.consume(y),h):c(y)}function h(y){return y===62?G(y):y===45?p(y):c(y)}function m(y){const de="CDATA[";return y===de.charCodeAt(s++)?(e.consume(y),s===de.length?x:m):n(y)}function x(y){return y===null?n(y):y===93?(e.consume(y),S):D(y)?(o=x,J(y)):(e.consume(y),x)}function S(y){return y===93?(e.consume(y),g):x(y)}function g(y){return y===62?G(y):y===93?(e.consume(y),g):x(y)}function v(y){return y===null||y===62?G(y):D(y)?(o=v,J(y)):(e.consume(y),v)}function k(y){return y===null?n(y):y===63?(e.consume(y),T):D(y)?(o=k,J(y)):(e.consume(y),k)}function T(y){return y===62?G(y):k(y)}function N(y){return ue(y)?(e.consume(y),w):n(y)}function w(y){return y===45||ae(y)?(e.consume(y),w):_(y)}function _(y){return D(y)?(o=_,J(y)):H(y)?(e.consume(y),_):G(y)}function z(y){return y===45||ae(y)?(e.consume(y),z):y===47||y===62||Q(y)?U(y):n(y)}function U(y){return y===47?(e.consume(y),G):y===58||y===95||ue(y)?(e.consume(y),C):D(y)?(o=U,J(y)):H(y)?(e.consume(y),U):G(y)}function C(y){return y===45||y===46||y===58||y===95||ae(y)?(e.consume(y),C):j(y)}function j(y){return y===61?(e.consume(y),L):D(y)?(o=j,J(y)):H(y)?(e.consume(y),j):U(y)}function L(y){return y===null||y===60||y===61||y===62||y===96?n(y):y===34||y===39?(e.consume(y),i=y,W):D(y)?(o=L,J(y)):H(y)?(e.consume(y),L):(e.consume(y),O)}function W(y){return y===i?(e.consume(y),i=void 0,P):y===null?n(y):D(y)?(o=W,J(y)):(e.consume(y),W)}function O(y){return y===null||y===34||y===39||y===60||y===61||y===96?n(y):y===47||y===62||Q(y)?U(y):(e.consume(y),O)}function P(y){return y===47||y===62||Q(y)?U(y):n(y)}function G(y){return y===62?(e.consume(y),e.exit("htmlTextData"),e.exit("htmlText"),t):n(y)}function J(y){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),ce}function ce(y){return H(y)?q(e,ye,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(y):ye(y)}function ye(y){return e.enter("htmlTextData"),o(y)}}const Yn={name:"labelEnd",resolveAll:lc,resolveTo:uc,tokenize:cc},sc={tokenize:dc},oc={tokenize:hc},ac={tokenize:fc};function lc(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&xe(e,0,e.length,n),e}function uc(e,t){let n=e.length,r=0,i,s,o,a;for(;n--;)if(i=e[n][1],s){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(o){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(s=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(o=n);const l={type:e[s][1].type==="labelLink"?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},u={type:"label",start:{...e[s][1].start},end:{...e[o][1].end}},d={type:"labelText",start:{...e[s+r+2][1].end},end:{...e[o-2][1].start}};return a=[["enter",l,t],["enter",u,t]],a=Se(a,e.slice(s+1,s+r+3)),a=Se(a,[["enter",d,t]]),a=Se(a,Ht(t.parser.constructs.insideSpan.null,e.slice(s+r+4,o-3),t)),a=Se(a,[["exit",d,t],e[o-2],e[o-1],["exit",u,t]]),a=Se(a,e.slice(o+1)),a=Se(a,[["exit",l,t]]),xe(e,s,e.length,a),e}function cc(e,t,n){const r=this;let i=r.events.length,s,o;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){s=r.events[i][1];break}return a;function a(p){return s?s._inactive?c(p):(o=r.parser.defined.includes(Ce(r.sliceSerialize({start:s.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(p),e.exit("labelMarker"),e.exit("labelEnd"),l):n(p)}function l(p){return p===40?e.attempt(sc,d,o?d:c)(p):p===91?e.attempt(oc,d,o?u:c)(p):o?d(p):c(p)}function u(p){return e.attempt(ac,d,c)(p)}function d(p){return t(p)}function c(p){return s._balanced=!0,n(p)}}function dc(e,t,n){return r;function r(c){return e.enter("resource"),e.enter("resourceMarker"),e.consume(c),e.exit("resourceMarker"),i}function i(c){return Q(c)?dt(e,s)(c):s(c)}function s(c){return c===41?d(c):cs(e,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(c)}function o(c){return Q(c)?dt(e,l)(c):d(c)}function a(c){return n(c)}function l(c){return c===34||c===39||c===40?hs(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(c):d(c)}function u(c){return Q(c)?dt(e,d)(c):d(c)}function d(c){return c===41?(e.enter("resourceMarker"),e.consume(c),e.exit("resourceMarker"),e.exit("resource"),t):n(c)}}function hc(e,t,n){const r=this;return i;function i(a){return ds.call(r,e,s,o,"reference","referenceMarker","referenceString")(a)}function s(a){return r.parser.defined.includes(Ce(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function o(a){return n(a)}}function fc(e,t,n){return r;function r(s){return e.enter("reference"),e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),i}function i(s){return s===93?(e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),e.exit("reference"),t):n(s)}}const pc={name:"labelStartImage",resolveAll:Yn.resolveAll,tokenize:mc};function mc(e,t,n){const r=this;return i;function i(a){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(a),e.exit("labelImageMarker"),s}function s(a){return a===91?(e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelImage"),o):n(a)}function o(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const gc={name:"labelStartLink",resolveAll:Yn.resolveAll,tokenize:xc};function xc(e,t,n){const r=this;return i;function i(o){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelLink"),s}function s(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const en={name:"lineEnding",tokenize:yc};function yc(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),q(e,t,"linePrefix")}}const Nt={name:"thematicBreak",tokenize:bc};function bc(e,t,n){let r=0,i;return s;function s(u){return e.enter("thematicBreak"),o(u)}function o(u){return i=u,a(u)}function a(u){return u===i?(e.enter("thematicBreakSequence"),l(u)):r>=3&&(u===null||D(u))?(e.exit("thematicBreak"),t(u)):n(u)}function l(u){return u===i?(e.consume(u),r++,l):(e.exit("thematicBreakSequence"),H(u)?q(e,a,"whitespace")(u):a(u))}}const fe={continuation:{tokenize:vc},exit:Ic,name:"list",tokenize:wc},Sc={partial:!0,tokenize:Rc},kc={partial:!0,tokenize:Cc};function wc(e,t,n){const r=this,i=r.events[r.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return a;function a(h){const m=r.containerState.type||(h===42||h===43||h===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!r.containerState.marker||h===r.containerState.marker:Mn(h)){if(r.containerState.type||(r.containerState.type=m,e.enter(m,{_container:!0})),m==="listUnordered")return e.enter("listItemPrefix"),h===42||h===45?e.check(Nt,n,u)(h):u(h);if(!r.interrupt||h===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(h)}return n(h)}function l(h){return Mn(h)&&++o<10?(e.consume(h),l):(!r.interrupt||o<2)&&(r.containerState.marker?h===r.containerState.marker:h===41||h===46)?(e.exit("listItemValue"),u(h)):n(h)}function u(h){return e.enter("listItemMarker"),e.consume(h),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||h,e.check(St,r.interrupt?n:d,e.attempt(Sc,p,c))}function d(h){return r.containerState.initialBlankLine=!0,s++,p(h)}function c(h){return H(h)?(e.enter("listItemPrefixWhitespace"),e.consume(h),e.exit("listItemPrefixWhitespace"),p):n(h)}function p(h){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(h)}}function vc(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(St,i,s);function i(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,q(e,t,"listItemIndent",r.containerState.size+1)(a)}function s(a){return r.containerState.furtherBlankLines||!H(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(kc,t,o)(a))}function o(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,q(e,e.attempt(fe,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function Cc(e,t,n){const r=this;return q(e,i,"listItemIndent",r.containerState.size+1);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(s):n(s)}}function Ic(e){e.exit(this.containerState.type)}function Rc(e,t,n){const r=this;return q(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const o=r.events[r.events.length-1];return!H(s)&&o&&o[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const Kr={name:"setextUnderline",resolveTo:Tc,tokenize:Ac};function Tc(e,t){let n=e.length,r,i,s;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!s&&e[n][1].type==="definition"&&(s=n);const o={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",s?(e.splice(i,0,["enter",o,t]),e.splice(s+1,0,["exit",e[r][1],t]),e[r][1].end={...e[s][1].end}):e[r][1]=o,e.push(["exit",o,t]),e}function Ac(e,t,n){const r=this;let i;return s;function s(u){let d=r.events.length,c;for(;d--;)if(r.events[d][1].type!=="lineEnding"&&r.events[d][1].type!=="linePrefix"&&r.events[d][1].type!=="content"){c=r.events[d][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||c)?(e.enter("setextHeadingLine"),i=u,o(u)):n(u)}function o(u){return e.enter("setextHeadingLineSequence"),a(u)}function a(u){return u===i?(e.consume(u),a):(e.exit("setextHeadingLineSequence"),H(u)?q(e,l,"lineSuffix")(u):l(u))}function l(u){return u===null||D(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const Ec={tokenize:Mc};function Mc(e){const t=this,n=e.attempt(St,r,e.attempt(this.parser.constructs.flowInitial,i,q(e,e.attempt(this.parser.constructs.flow,i,e.attempt(_u,i)),"linePrefix")));return n;function r(s){if(s===null){e.consume(s);return}return e.enter("lineEndingBlank"),e.consume(s),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const Nc={resolveAll:ps()},Pc=fs("string"),jc=fs("text");function fs(e){return{resolveAll:ps(e==="text"?Lc:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],s=n.attempt(i,o,a);return o;function o(d){return u(d)?s(d):a(d)}function a(d){if(d===null){n.consume(d);return}return n.enter("data"),n.consume(d),l}function l(d){return u(d)?(n.exit("data"),s(d)):(n.consume(d),l)}function u(d){if(d===null)return!0;const c=i[d];let p=-1;if(c)for(;++p<c.length;){const h=c[p];if(!h.previous||h.previous.call(r,r.previous))return!0}return!1}}}function ps(e){return t;function t(n,r){let i=-1,s;for(;++i<=n.length;)s===void 0?n[i]&&n[i][1].type==="data"&&(s=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==s+2&&(n[s][1].end=n[i-1][1].end,n.splice(s+2,i-s-2),i=s+2),s=void 0);return e?e(n,r):n}}function Lc(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],i=t.sliceStream(r);let s=i.length,o=-1,a=0,l;for(;s--;){const u=i[s];if(typeof u=="string"){for(o=u.length;u.charCodeAt(o-1)===32;)a++,o--;if(o)break;o=-1}else if(u===-2)l=!0,a++;else if(u!==-1){s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(a=0),a){const u={type:n===e.length||l||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?o:r.start._bufferIndex+o,_index:r.start._index+s,line:r.end.line,column:r.end.column-a,offset:r.end.offset-a},end:{...r.end}};r.end={...u.start},r.start.offset===r.end.offset?Object.assign(r,u):(e.splice(n,0,["enter",u,t],["exit",u,t]),n+=2)}n++}return e}const _c={42:fe,43:fe,45:fe,48:fe,49:fe,50:fe,51:fe,52:fe,53:fe,54:fe,55:fe,56:fe,57:fe,62:os},Oc={91:Bu},Dc={[-2]:Zt,[-1]:Zt,32:Zt},Fc={35:qu,42:Nt,45:[Kr,Nt],60:Qu,61:Kr,95:Nt,96:Ur,126:Ur},zc={38:ls,92:as},Bc={[-5]:en,[-4]:en,[-3]:en,33:pc,38:ls,42:Nn,60:[gu,rc],91:gc,92:[Ku,as],93:Yn,95:Nn,96:Eu},$c={null:[Nn,Nc]},Uc={null:[42,95]},Hc={null:[]},Kc=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Uc,contentInitial:Oc,disable:Hc,document:_c,flow:Fc,flowInitial:Dc,insideSpan:$c,string:zc,text:Bc},Symbol.toStringTag,{value:"Module"}));function Vc(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},s=[];let o=[],a=[];const l={attempt:_(N),check:_(w),consume:v,enter:k,exit:T,interrupt:_(w,{interrupt:!0})},u={code:null,containerState:{},defineSkip:x,events:[],now:m,parser:e,previous:null,sliceSerialize:p,sliceStream:h,write:c};let d=t.tokenize.call(u,l);return t.resolveAll&&s.push(t),u;function c(j){return o=Se(o,j),S(),o[o.length-1]!==null?[]:(z(t,0),u.events=Ht(s,u.events,u),u.events)}function p(j,L){return Wc(h(j),L)}function h(j){return qc(o,j)}function m(){const{_bufferIndex:j,_index:L,line:W,column:O,offset:P}=r;return{_bufferIndex:j,_index:L,line:W,column:O,offset:P}}function x(j){i[j.line]=j.column,C()}function S(){let j;for(;r._index<o.length;){const L=o[r._index];if(typeof L=="string")for(j=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===j&&r._bufferIndex<L.length;)g(L.charCodeAt(r._bufferIndex));else g(L)}}function g(j){d=d(j)}function v(j){D(j)?(r.line++,r.column=1,r.offset+=j===-3?2:1,C()):j!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=j}function k(j,L){const W=L||{};return W.type=j,W.start=m(),u.events.push(["enter",W,u]),a.push(W),W}function T(j){const L=a.pop();return L.end=m(),u.events.push(["exit",L,u]),L}function N(j,L){z(j,L.from)}function w(j,L){L.restore()}function _(j,L){return W;function W(O,P,G){let J,ce,ye,y;return Array.isArray(O)?be(O):"tokenize"in O?be([O]):de(O);function de(Z){return _e;function _e(ke){const Ae=ke!==null&&Z[ke],ne=ke!==null&&Z.null,ze=[...Array.isArray(Ae)?Ae:Ae?[Ae]:[],...Array.isArray(ne)?ne:ne?[ne]:[]];return be(ze)(ke)}}function be(Z){return J=Z,ce=0,Z.length===0?G:b(Z[ce])}function b(Z){return _e;function _e(ke){return y=U(),ye=Z,Z.partial||(u.currentConstruct=Z),Z.name&&u.parser.constructs.disable.null.includes(Z.name)?Ie():Z.tokenize.call(L?Object.assign(Object.create(u),L):u,l,he,Ie)(ke)}}function he(Z){return j(ye,y),P}function Ie(Z){return y.restore(),++ce<J.length?b(J[ce]):G}}}function z(j,L){j.resolveAll&&!s.includes(j)&&s.push(j),j.resolve&&xe(u.events,L,u.events.length-L,j.resolve(u.events.slice(L),u)),j.resolveTo&&(u.events=j.resolveTo(u.events,u))}function U(){const j=m(),L=u.previous,W=u.currentConstruct,O=u.events.length,P=Array.from(a);return{from:O,restore:G};function G(){r=j,u.previous=L,u.currentConstruct=W,u.events.length=O,a=P,C()}}function C(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function qc(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,s=t.end._bufferIndex;let o;if(n===i)o=[e[n].slice(r,s)];else{if(o=e.slice(n,i),r>-1){const a=o[0];typeof a=="string"?o[0]=a.slice(r):o.shift()}s>0&&o.push(e[i].slice(0,s))}return o}function Wc(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const s=e[n];let o;if(typeof s=="string")o=s;else switch(s){case-5:{o="\r";break}case-4:{o=`
|
|
5
|
+
`;break}case-3:{o=`\r
|
|
6
|
+
`;break}case-2:{o=t?" ":" ";break}case-1:{if(!t&&i)continue;o=" ";break}default:o=String.fromCharCode(s)}i=s===-2,r.push(o)}return r.join("")}function Gc(e){const r={constructs:is([Kc,...(e||{}).extensions||[]]),content:i(uu),defined:[],document:i(du),flow:i(Ec),lazy:{},string:i(Pc),text:i(jc)};return r;function i(s){return o;function o(a){return Vc(r,s,a)}}}function Xc(e){for(;!us(e););return e}const Vr=/[\0\t\n\r]/g;function Qc(){let e=1,t="",n=!0,r;return i;function i(s,o,a){const l=[];let u,d,c,p,h;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(o||void 0).decode(s)),c=0,t="",n&&(s.charCodeAt(0)===65279&&c++,n=void 0);c<s.length;){if(Vr.lastIndex=c,u=Vr.exec(s),p=u&&u.index!==void 0?u.index:s.length,h=s.charCodeAt(p),!u){t=s.slice(c);break}if(h===10&&c===p&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),c<p&&(l.push(s.slice(c,p)),e+=p-c),h){case 0:{l.push(65533),e++;break}case 9:{for(d=Math.ceil(e/4)*4,l.push(-2);e++<d;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:r=!0,e=1}c=p+1}return a&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}const Yc=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Jc(e){return e.replace(Yc,Zc)}function Zc(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return ss(n.slice(s?2:1),s?16:10)}return Qn(n)||e}const ms={}.hasOwnProperty;function ed(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),td(n)(Xc(Gc(n).document().write(Qc()(e,t,!0))))}function td(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(hr),autolinkProtocol:U,autolinkEmail:U,atxHeading:s(ur),blockQuote:s(ne),characterEscape:U,characterReference:U,codeFenced:s(ze),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(ze,o),codeText:s(uo,o),codeTextData:U,data:U,codeFlowValue:U,definition:s(co),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(ho),hardBreakEscape:s(cr),hardBreakTrailing:s(cr),htmlFlow:s(dr,o),htmlFlowData:U,htmlText:s(dr,o),htmlTextData:U,image:s(fo),label:o,link:s(hr),listItem:s(po),listItemValue:p,listOrdered:s(fr,c),listUnordered:s(fr),paragraph:s(mo),reference:b,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(ur),strong:s(go),thematicBreak:s(yo)},exit:{atxHeading:l(),atxHeadingSequence:N,autolink:l(),autolinkEmail:Ae,autolinkProtocol:ke,blockQuote:l(),characterEscapeValue:C,characterReferenceMarkerHexadecimal:Ie,characterReferenceMarkerNumeric:Ie,characterReferenceValue:Z,characterReference:_e,codeFenced:l(S),codeFencedFence:x,codeFencedFenceInfo:h,codeFencedFenceMeta:m,codeFlowValue:C,codeIndented:l(g),codeText:l(P),codeTextData:C,data:C,definition:l(),definitionDestinationString:T,definitionLabelString:v,definitionTitleString:k,emphasis:l(),hardBreakEscape:l(L),hardBreakTrailing:l(L),htmlFlow:l(W),htmlFlowData:C,htmlText:l(O),htmlTextData:C,image:l(J),label:ye,labelText:ce,lineEnding:j,link:l(G),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:he,resourceDestinationString:y,resourceTitleString:de,resource:be,setextHeading:l(z),setextHeadingLineSequence:_,setextHeadingText:w,strong:l(),thematicBreak:l()}};gs(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(I){let M={type:"root",children:[]};const B={stack:[M],tokenStack:[],config:t,enter:a,exit:u,buffer:o,resume:d,data:n},V=[];let X=-1;for(;++X<I.length;)if(I[X][1].type==="listOrdered"||I[X][1].type==="listUnordered")if(I[X][0]==="enter")V.push(X);else{const we=V.pop();X=i(I,we,X)}for(X=-1;++X<I.length;){const we=t[I[X][0]];ms.call(we,I[X][1].type)&&we[I[X][1].type].call(Object.assign({sliceSerialize:I[X][2].sliceSerialize},B),I[X][1])}if(B.tokenStack.length>0){const we=B.tokenStack[B.tokenStack.length-1];(we[1]||qr).call(B,void 0,we[0])}for(M.position={start:Oe(I.length>0?I[0][1].start:{line:1,column:1,offset:0}),end:Oe(I.length>0?I[I.length-2][1].end:{line:1,column:1,offset:0})},X=-1;++X<t.transforms.length;)M=t.transforms[X](M)||M;return M}function i(I,M,B){let V=M-1,X=-1,we=!1,Be,Ee,nt,rt;for(;++V<=B;){const me=I[V];switch(me[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{me[0]==="enter"?X++:X--,rt=void 0;break}case"lineEndingBlank":{me[0]==="enter"&&(Be&&!rt&&!X&&!nt&&(nt=V),rt=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:rt=void 0}if(!X&&me[0]==="enter"&&me[1].type==="listItemPrefix"||X===-1&&me[0]==="exit"&&(me[1].type==="listUnordered"||me[1].type==="listOrdered")){if(Be){let qe=V;for(Ee=void 0;qe--;){const Me=I[qe];if(Me[1].type==="lineEnding"||Me[1].type==="lineEndingBlank"){if(Me[0]==="exit")continue;Ee&&(I[Ee][1].type="lineEndingBlank",we=!0),Me[1].type="lineEnding",Ee=qe}else if(!(Me[1].type==="linePrefix"||Me[1].type==="blockQuotePrefix"||Me[1].type==="blockQuotePrefixWhitespace"||Me[1].type==="blockQuoteMarker"||Me[1].type==="listItemIndent"))break}nt&&(!Ee||nt<Ee)&&(Be._spread=!0),Be.end=Object.assign({},Ee?I[Ee][1].start:me[1].end),I.splice(Ee||V,0,["exit",Be,me[2]]),V++,B++}if(me[1].type==="listItemPrefix"){const qe={type:"listItem",_spread:!1,start:Object.assign({},me[1].start),end:void 0};Be=qe,I.splice(V,0,["enter",qe,me[2]]),V++,B++,nt=void 0,rt=!0}}}return I[M][1]._spread=we,B}function s(I,M){return B;function B(V){a.call(this,I(V),V),M&&M.call(this,V)}}function o(){this.stack.push({type:"fragment",children:[]})}function a(I,M,B){this.stack[this.stack.length-1].children.push(I),this.stack.push(I),this.tokenStack.push([M,B||void 0]),I.position={start:Oe(M.start),end:void 0}}function l(I){return M;function M(B){I&&I.call(this,B),u.call(this,B)}}function u(I,M){const B=this.stack.pop(),V=this.tokenStack.pop();if(V)V[0].type!==I.type&&(M?M.call(this,I,V[0]):(V[1]||qr).call(this,I,V[0]));else throw new Error("Cannot close `"+I.type+"` ("+ct({start:I.start,end:I.end})+"): it’s not open");B.position.end=Oe(I.end)}function d(){return Xn(this.stack.pop())}function c(){this.data.expectingFirstListItemValue=!0}function p(I){if(this.data.expectingFirstListItemValue){const M=this.stack[this.stack.length-2];M.start=Number.parseInt(this.sliceSerialize(I),10),this.data.expectingFirstListItemValue=void 0}}function h(){const I=this.resume(),M=this.stack[this.stack.length-1];M.lang=I}function m(){const I=this.resume(),M=this.stack[this.stack.length-1];M.meta=I}function x(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function S(){const I=this.resume(),M=this.stack[this.stack.length-1];M.value=I.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function g(){const I=this.resume(),M=this.stack[this.stack.length-1];M.value=I.replace(/(\r?\n|\r)$/g,"")}function v(I){const M=this.resume(),B=this.stack[this.stack.length-1];B.label=M,B.identifier=Ce(this.sliceSerialize(I)).toLowerCase()}function k(){const I=this.resume(),M=this.stack[this.stack.length-1];M.title=I}function T(){const I=this.resume(),M=this.stack[this.stack.length-1];M.url=I}function N(I){const M=this.stack[this.stack.length-1];if(!M.depth){const B=this.sliceSerialize(I).length;M.depth=B}}function w(){this.data.setextHeadingSlurpLineEnding=!0}function _(I){const M=this.stack[this.stack.length-1];M.depth=this.sliceSerialize(I).codePointAt(0)===61?1:2}function z(){this.data.setextHeadingSlurpLineEnding=void 0}function U(I){const B=this.stack[this.stack.length-1].children;let V=B[B.length-1];(!V||V.type!=="text")&&(V=xo(),V.position={start:Oe(I.start),end:void 0},B.push(V)),this.stack.push(V)}function C(I){const M=this.stack.pop();M.value+=this.sliceSerialize(I),M.position.end=Oe(I.end)}function j(I){const M=this.stack[this.stack.length-1];if(this.data.atHardBreak){const B=M.children[M.children.length-1];B.position.end=Oe(I.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(M.type)&&(U.call(this,I),C.call(this,I))}function L(){this.data.atHardBreak=!0}function W(){const I=this.resume(),M=this.stack[this.stack.length-1];M.value=I}function O(){const I=this.resume(),M=this.stack[this.stack.length-1];M.value=I}function P(){const I=this.resume(),M=this.stack[this.stack.length-1];M.value=I}function G(){const I=this.stack[this.stack.length-1];if(this.data.inReference){const M=this.data.referenceType||"shortcut";I.type+="Reference",I.referenceType=M,delete I.url,delete I.title}else delete I.identifier,delete I.label;this.data.referenceType=void 0}function J(){const I=this.stack[this.stack.length-1];if(this.data.inReference){const M=this.data.referenceType||"shortcut";I.type+="Reference",I.referenceType=M,delete I.url,delete I.title}else delete I.identifier,delete I.label;this.data.referenceType=void 0}function ce(I){const M=this.sliceSerialize(I),B=this.stack[this.stack.length-2];B.label=Jc(M),B.identifier=Ce(M).toLowerCase()}function ye(){const I=this.stack[this.stack.length-1],M=this.resume(),B=this.stack[this.stack.length-1];if(this.data.inReference=!0,B.type==="link"){const V=I.children;B.children=V}else B.alt=M}function y(){const I=this.resume(),M=this.stack[this.stack.length-1];M.url=I}function de(){const I=this.resume(),M=this.stack[this.stack.length-1];M.title=I}function be(){this.data.inReference=void 0}function b(){this.data.referenceType="collapsed"}function he(I){const M=this.resume(),B=this.stack[this.stack.length-1];B.label=M,B.identifier=Ce(this.sliceSerialize(I)).toLowerCase(),this.data.referenceType="full"}function Ie(I){this.data.characterReferenceType=I.type}function Z(I){const M=this.sliceSerialize(I),B=this.data.characterReferenceType;let V;B?(V=ss(M,B==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):V=Qn(M);const X=this.stack[this.stack.length-1];X.value+=V}function _e(I){const M=this.stack.pop();M.position.end=Oe(I.end)}function ke(I){C.call(this,I);const M=this.stack[this.stack.length-1];M.url=this.sliceSerialize(I)}function Ae(I){C.call(this,I);const M=this.stack[this.stack.length-1];M.url="mailto:"+this.sliceSerialize(I)}function ne(){return{type:"blockquote",children:[]}}function ze(){return{type:"code",lang:null,meta:null,value:""}}function uo(){return{type:"inlineCode",value:""}}function co(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function ho(){return{type:"emphasis",children:[]}}function ur(){return{type:"heading",depth:0,children:[]}}function cr(){return{type:"break"}}function dr(){return{type:"html",value:""}}function fo(){return{type:"image",title:null,url:"",alt:null}}function hr(){return{type:"link",title:null,url:"",children:[]}}function fr(I){return{type:"list",ordered:I.type==="listOrdered",start:null,spread:I._spread,children:[]}}function po(I){return{type:"listItem",spread:I._spread,checked:null,children:[]}}function mo(){return{type:"paragraph",children:[]}}function go(){return{type:"strong",children:[]}}function xo(){return{type:"text",value:""}}function yo(){return{type:"thematicBreak"}}}function Oe(e){return{line:e.line,column:e.column,offset:e.offset}}function gs(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?gs(e,r):nd(e,r)}}function nd(e,t){let n;for(n in t)if(ms.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function qr(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+ct({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+ct({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+ct({start:t.start,end:t.end})+") is still open")}function rd(e){const t=this;t.parser=n;function n(r){return ed(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function id(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function sd(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
7
|
+
`}]}function od(e,t){const n=t.value?t.value+`
|
|
8
|
+
`:"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let s={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(s.data={meta:t.meta}),e.patch(t,s),s=e.applyData(t,s),s={type:"element",tagName:"pre",properties:{},children:[s]},e.patch(t,s),s}function ad(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function ld(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function ud(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=tt(r.toLowerCase()),s=e.footnoteOrder.indexOf(r);let o,a=e.footnoteCounts.get(r);a===void 0?(a=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=s+1,a+=1,e.footnoteCounts.set(r,a);const l={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(a>1?"-"+a:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(o)}]};e.patch(t,l);const u={type:"element",tagName:"sup",properties:{},children:[l]};return e.patch(t,u),e.applyData(t,u)}function cd(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function dd(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function xs(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const i=e.all(t),s=i[0];s&&s.type==="text"?s.value="["+s.value:i.unshift({type:"text",value:"["});const o=i[i.length-1];return o&&o.type==="text"?o.value+=r:i.push({type:"text",value:r}),i}function hd(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return xs(e,t);const i={src:tt(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,s),e.applyData(t,s)}function fd(e,t){const n={src:tt(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function pd(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function md(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return xs(e,t);const i={href:tt(r.url||"")};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function gd(e,t){const n={href:tt(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function xd(e,t,n){const r=e.all(t),i=n?yd(n):ys(t),s={},o=[];if(typeof t.checked=="boolean"){const d=r[0];let c;d&&d.type==="element"&&d.tagName==="p"?c=d:(c={type:"element",tagName:"p",properties:{},children:[]},r.unshift(c)),c.children.length>0&&c.children.unshift({type:"text",value:" "}),c.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let a=-1;for(;++a<r.length;){const d=r[a];(i||a!==0||d.type!=="element"||d.tagName!=="p")&&o.push({type:"text",value:`
|
|
9
|
+
`}),d.type==="element"&&d.tagName==="p"&&!i?o.push(...d.children):o.push(d)}const l=r[r.length-1];l&&(i||l.type!=="element"||l.tagName!=="p")&&o.push({type:"text",value:`
|
|
10
|
+
`});const u={type:"element",tagName:"li",properties:s,children:o};return e.patch(t,u),e.applyData(t,u)}function yd(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r<n.length;)t=ys(n[r])}return t}function ys(e){const t=e.spread;return t??e.children.length>1}function bd(e,t){const n={},r=e.all(t);let i=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++i<r.length;){const o=r[i];if(o.type==="element"&&o.tagName==="li"&&o.properties&&Array.isArray(o.properties.className)&&o.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const s={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,s),e.applyData(t,s)}function Sd(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function kd(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function wd(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function vd(e,t){const n=e.all(t),r=n.shift(),i=[];if(r){const o={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],o),i.push(o)}if(n.length>0){const o={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},a=Vn(t.children[1]),l=Yi(t.children[t.children.length-1]);a&&l&&(o.position={start:a,end:l}),i.push(o)}const s={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,s),e.applyData(t,s)}function Cd(e,t,n){const r=n?n.children:void 0,s=(r?r.indexOf(t):1)===0?"th":"td",o=n&&n.type==="table"?n.align:void 0,a=o?o.length:t.children.length;let l=-1;const u=[];for(;++l<a;){const c=t.children[l],p={},h=o?o[l]:void 0;h&&(p.align=h);let m={type:"element",tagName:s,properties:p,children:[]};c&&(m.children=e.all(c),e.patch(c,m),m=e.applyData(c,m)),u.push(m)}const d={type:"element",tagName:"tr",properties:{},children:e.wrap(u,!0)};return e.patch(t,d),e.applyData(t,d)}function Id(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const Wr=9,Gr=32;function Rd(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),i=0;const s=[];for(;r;)s.push(Xr(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return s.push(Xr(t.slice(i),i>0,!1)),s.join("")}function Xr(e,t,n){let r=0,i=e.length;if(t){let s=e.codePointAt(r);for(;s===Wr||s===Gr;)r++,s=e.codePointAt(r)}if(n){let s=e.codePointAt(i-1);for(;s===Wr||s===Gr;)i--,s=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function Td(e,t){const n={type:"text",value:Rd(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function Ad(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const Ed={blockquote:id,break:sd,code:od,delete:ad,emphasis:ld,footnoteReference:ud,heading:cd,html:dd,imageReference:hd,image:fd,inlineCode:pd,linkReference:md,link:gd,listItem:xd,list:bd,paragraph:Sd,root:kd,strong:wd,table:vd,tableCell:Id,tableRow:Cd,text:Td,thematicBreak:Ad,toml:Ct,yaml:Ct,definition:Ct,footnoteDefinition:Ct};function Ct(){}const bs=-1,Kt=0,ht=1,Lt=2,Jn=3,Zn=4,er=5,tr=6,Ss=7,ks=8,Qr=typeof self=="object"?self:globalThis,Md=(e,t)=>{const n=(i,s)=>(e.set(s,i),i),r=i=>{if(e.has(i))return e.get(i);const[s,o]=t[i];switch(s){case Kt:case bs:return n(o,i);case ht:{const a=n([],i);for(const l of o)a.push(r(l));return a}case Lt:{const a=n({},i);for(const[l,u]of o)a[r(l)]=r(u);return a}case Jn:return n(new Date(o),i);case Zn:{const{source:a,flags:l}=o;return n(new RegExp(a,l),i)}case er:{const a=n(new Map,i);for(const[l,u]of o)a.set(r(l),r(u));return a}case tr:{const a=n(new Set,i);for(const l of o)a.add(r(l));return a}case Ss:{const{name:a,message:l}=o;return n(new Qr[a](l),i)}case ks:return n(BigInt(o),i);case"BigInt":return n(Object(BigInt(o)),i);case"ArrayBuffer":return n(new Uint8Array(o).buffer,o);case"DataView":{const{buffer:a}=new Uint8Array(o);return n(new DataView(a),o)}}return n(new Qr[s](o),i)};return r},Yr=e=>Md(new Map,e)(0),Xe="",{toString:Nd}={},{keys:Pd}=Object,at=e=>{const t=typeof e;if(t!=="object"||!e)return[Kt,t];const n=Nd.call(e).slice(8,-1);switch(n){case"Array":return[ht,Xe];case"Object":return[Lt,Xe];case"Date":return[Jn,Xe];case"RegExp":return[Zn,Xe];case"Map":return[er,Xe];case"Set":return[tr,Xe];case"DataView":return[ht,n]}return n.includes("Array")?[ht,n]:n.includes("Error")?[Ss,n]:[Lt,n]},It=([e,t])=>e===Kt&&(t==="function"||t==="symbol"),jd=(e,t,n,r)=>{const i=(o,a)=>{const l=r.push(o)-1;return n.set(a,l),l},s=o=>{if(n.has(o))return n.get(o);let[a,l]=at(o);switch(a){case Kt:{let d=o;switch(l){case"bigint":a=ks,d=o.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+l);d=null;break;case"undefined":return i([bs],o)}return i([a,d],o)}case ht:{if(l){let p=o;return l==="DataView"?p=new Uint8Array(o.buffer):l==="ArrayBuffer"&&(p=new Uint8Array(o)),i([l,[...p]],o)}const d=[],c=i([a,d],o);for(const p of o)d.push(s(p));return c}case Lt:{if(l)switch(l){case"BigInt":return i([l,o.toString()],o);case"Boolean":case"Number":case"String":return i([l,o.valueOf()],o)}if(t&&"toJSON"in o)return s(o.toJSON());const d=[],c=i([a,d],o);for(const p of Pd(o))(e||!It(at(o[p])))&&d.push([s(p),s(o[p])]);return c}case Jn:return i([a,o.toISOString()],o);case Zn:{const{source:d,flags:c}=o;return i([a,{source:d,flags:c}],o)}case er:{const d=[],c=i([a,d],o);for(const[p,h]of o)(e||!(It(at(p))||It(at(h))))&&d.push([s(p),s(h)]);return c}case tr:{const d=[],c=i([a,d],o);for(const p of o)(e||!It(at(p)))&&d.push(s(p));return c}}const{message:u}=o;return i([a,{name:l,message:u}],o)};return s},Jr=(e,{json:t,lossy:n}={})=>{const r=[];return jd(!(t||n),!!t,new Map,r)(e),r},_t=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Yr(Jr(e,t)):structuredClone(e):(e,t)=>Yr(Jr(e,t));function Ld(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function _d(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function Od(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||Ld,r=e.options.footnoteBackLabel||_d,i=e.options.footnoteLabel||"Footnotes",s=e.options.footnoteLabelTagName||"h2",o=e.options.footnoteLabelProperties||{className:["sr-only"]},a=[];let l=-1;for(;++l<e.footnoteOrder.length;){const u=e.footnoteById.get(e.footnoteOrder[l]);if(!u)continue;const d=e.all(u),c=String(u.identifier).toUpperCase(),p=tt(c.toLowerCase());let h=0;const m=[],x=e.footnoteCounts.get(c);for(;x!==void 0&&++h<=x;){m.length>0&&m.push({type:"text",value:" "});let v=typeof n=="string"?n:n(l,h);typeof v=="string"&&(v={type:"text",value:v}),m.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+p+(h>1?"-"+h:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(l,h),className:["data-footnote-backref"]},children:Array.isArray(v)?v:[v]})}const S=d[d.length-1];if(S&&S.type==="element"&&S.tagName==="p"){const v=S.children[S.children.length-1];v&&v.type==="text"?v.value+=" ":S.children.push({type:"text",value:" "}),S.children.push(...m)}else d.push(...m);const g={type:"element",tagName:"li",properties:{id:t+"fn-"+p},children:e.wrap(d,!0)};e.patch(u,g),a.push(g)}if(a.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:s,properties:{..._t(o),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:`
|
|
11
|
+
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(a,!0)},{type:"text",value:`
|
|
12
|
+
`}]}}const Vt=(function(e){if(e==null)return Bd;if(typeof e=="function")return qt(e);if(typeof e=="object")return Array.isArray(e)?Dd(e):Fd(e);if(typeof e=="string")return zd(e);throw new Error("Expected function, string, or object as test")});function Dd(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Vt(e[n]);return qt(r);function r(...i){let s=-1;for(;++s<t.length;)if(t[s].apply(this,i))return!0;return!1}}function Fd(e){const t=e;return qt(n);function n(r){const i=r;let s;for(s in e)if(i[s]!==t[s])return!1;return!0}}function zd(e){return qt(t);function t(n){return n&&n.type===e}}function qt(e){return t;function t(n,r,i){return!!($d(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function Bd(){return!0}function $d(e){return e!==null&&typeof e=="object"&&"type"in e}const ws=[],Ud=!0,Pn=!1,Hd="skip";function vs(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const s=Vt(i),o=r?-1:1;a(e,void 0,[])();function a(l,u,d){const c=l&&typeof l=="object"?l:{};if(typeof c.type=="string"){const h=typeof c.tagName=="string"?c.tagName:typeof c.name=="string"?c.name:void 0;Object.defineProperty(p,"name",{value:"node ("+(l.type+(h?"<"+h+">":""))+")"})}return p;function p(){let h=ws,m,x,S;if((!t||s(l,u,d[d.length-1]||void 0))&&(h=Kd(n(l,d)),h[0]===Pn))return h;if("children"in l&&l.children){const g=l;if(g.children&&h[0]!==Hd)for(x=(r?g.children.length:-1)+o,S=d.concat(g);x>-1&&x<g.children.length;){const v=g.children[x];if(m=a(v,x,S)(),m[0]===Pn)return m;x=typeof m[1]=="number"?m[1]:x+o}}return h}}}function Kd(e){return Array.isArray(e)?e:typeof e=="number"?[Ud,e]:e==null?ws:[e]}function nr(e,t,n,r){let i,s,o;typeof t=="function"&&typeof n!="function"?(s=void 0,o=t,i=n):(s=t,o=n,i=r),vs(e,s,a,i);function a(l,u){const d=u[u.length-1],c=d?d.children.indexOf(l):void 0;return o(l,c,d)}}const jn={}.hasOwnProperty,Vd={};function qd(e,t){const n=t||Vd,r=new Map,i=new Map,s=new Map,o={...Ed,...n.handlers},a={all:u,applyData:Gd,definitionById:r,footnoteById:i,footnoteCounts:s,footnoteOrder:[],handlers:o,one:l,options:n,patch:Wd,wrap:Qd};return nr(e,function(d){if(d.type==="definition"||d.type==="footnoteDefinition"){const c=d.type==="definition"?r:i,p=String(d.identifier).toUpperCase();c.has(p)||c.set(p,d)}}),a;function l(d,c){const p=d.type,h=a.handlers[p];if(jn.call(a.handlers,p)&&h)return h(a,d,c);if(a.options.passThrough&&a.options.passThrough.includes(p)){if("children"in d){const{children:x,...S}=d,g=_t(S);return g.children=a.all(d),g}return _t(d)}return(a.options.unknownHandler||Xd)(a,d,c)}function u(d){const c=[];if("children"in d){const p=d.children;let h=-1;for(;++h<p.length;){const m=a.one(p[h],d);if(m){if(h&&p[h-1].type==="break"&&(!Array.isArray(m)&&m.type==="text"&&(m.value=Zr(m.value)),!Array.isArray(m)&&m.type==="element")){const x=m.children[0];x&&x.type==="text"&&(x.value=Zr(x.value))}Array.isArray(m)?c.push(...m):c.push(m)}}}return c}}function Wd(e,t){e.position&&(t.position=_l(e))}function Gd(e,t){let n=t;if(e&&e.data){const r=e.data.hName,i=e.data.hChildren,s=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const o="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:o}}n.type==="element"&&s&&Object.assign(n.properties,_t(s)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function Xd(e,t){const n=t.data||{},r="value"in t&&!(jn.call(n,"hProperties")||jn.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function Qd(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
|
|
13
|
+
`});++r<e.length;)r&&n.push({type:"text",value:`
|
|
14
|
+
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
|
|
15
|
+
`}),n}function Zr(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function ei(e,t){const n=qd(e,t),r=n.one(e,void 0),i=Od(n),s=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&s.children.push({type:"text",value:`
|
|
16
|
+
`},i),s}function Yd(e,t){return e&&"run"in e?async function(n,r){const i=ei(n,{file:r,...t});await e.run(i,r)}:function(n,r){return ei(n,{file:r,...e||t})}}function ti(e){if(e)throw e}var tn,ni;function Jd(){if(ni)return tn;ni=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=function(u){return typeof Array.isArray=="function"?Array.isArray(u):t.call(u)==="[object Array]"},s=function(u){if(!u||t.call(u)!=="[object Object]")return!1;var d=e.call(u,"constructor"),c=u.constructor&&u.constructor.prototype&&e.call(u.constructor.prototype,"isPrototypeOf");if(u.constructor&&!d&&!c)return!1;var p;for(p in u);return typeof p>"u"||e.call(u,p)},o=function(u,d){n&&d.name==="__proto__"?n(u,d.name,{enumerable:!0,configurable:!0,value:d.newValue,writable:!0}):u[d.name]=d.newValue},a=function(u,d){if(d==="__proto__")if(e.call(u,d)){if(r)return r(u,d).value}else return;return u[d]};return tn=function l(){var u,d,c,p,h,m,x=arguments[0],S=1,g=arguments.length,v=!1;for(typeof x=="boolean"&&(v=x,x=arguments[1]||{},S=2),(x==null||typeof x!="object"&&typeof x!="function")&&(x={});S<g;++S)if(u=arguments[S],u!=null)for(d in u)c=a(x,d),p=a(u,d),x!==p&&(v&&p&&(s(p)||(h=i(p)))?(h?(h=!1,m=c&&i(c)?c:[]):m=c&&s(c)?c:{},o(x,{name:d,newValue:l(v,m,p)})):typeof p<"u"&&o(x,{name:d,newValue:p}));return x},tn}var Zd=Jd();const nn=vi(Zd);function Ln(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function eh(){const e=[],t={run:n,use:r};return t;function n(...i){let s=-1;const o=i.pop();if(typeof o!="function")throw new TypeError("Expected function as last argument, not "+o);a(null,...i);function a(l,...u){const d=e[++s];let c=-1;if(l){o(l);return}for(;++c<i.length;)(u[c]===null||u[c]===void 0)&&(u[c]=i[c]);i=u,d?th(d,a)(...u):o(null,...u)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),t}}function th(e,t){let n;return r;function r(...o){const a=e.length>o.length;let l;a&&o.push(i);try{l=e.apply(this,o)}catch(u){const d=u;if(a&&n)throw d;return i(d)}a||(l&&l.then&&typeof l.then=="function"?l.then(s,i):l instanceof Error?i(l):s(l))}function i(o,...a){n||(n=!0,t(o,...a))}function s(o){i(null,o)}}const Re={basename:nh,dirname:rh,extname:ih,join:sh,sep:"/"};function nh(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');kt(e);let n=0,r=-1,i=e.length,s;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(s){n=i+1;break}}else r<0&&(s=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let o=-1,a=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(s){n=i+1;break}}else o<0&&(s=!0,o=i+1),a>-1&&(e.codePointAt(i)===t.codePointAt(a--)?a<0&&(r=i):(a=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function rh(e){if(kt(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function ih(e){kt(e);let t=e.length,n=-1,r=0,i=-1,s=0,o;for(;t--;){const a=e.codePointAt(t);if(a===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),a===46?i<0?i=t:s!==1&&(s=1):i>-1&&(s=-1)}return i<0||n<0||s===0||s===1&&i===n-1&&i===r+1?"":e.slice(i,n)}function sh(...e){let t=-1,n;for(;++t<e.length;)kt(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":oh(n)}function oh(e){kt(e);const t=e.codePointAt(0)===47;let n=ah(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function ah(e,t){let n="",r=0,i=-1,s=0,o=-1,a,l;for(;++o<=e.length;){if(o<e.length)a=e.codePointAt(o);else{if(a===47)break;a=47}if(a===47){if(!(i===o-1||s===1))if(i!==o-1&&s===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(l=n.lastIndexOf("/"),l!==n.length-1){l<0?(n="",r=0):(n=n.slice(0,l),r=n.length-1-n.lastIndexOf("/")),i=o,s=0;continue}}else if(n.length>0){n="",r=0,i=o,s=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,s=0}else a===46&&s>-1?s++:s=-1}return n}function kt(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const lh={cwd:uh};function uh(){return"/"}function _n(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function ch(e){if(typeof e=="string")e=new URL(e);else if(!_n(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return dh(e)}function dh(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const r=t.codePointAt(n+2);if(r===70||r===102){const i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(t)}const rn=["history","path","basename","stem","extname","dirname"];class Cs{constructor(t){let n;t?_n(t)?n={path:t}:typeof t=="string"||hh(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":lh.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<rn.length;){const s=rn[r];s in n&&n[s]!==void 0&&n[s]!==null&&(this[s]=s==="history"?[...n[s]]:n[s])}let i;for(i in n)rn.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?Re.basename(this.path):void 0}set basename(t){on(t,"basename"),sn(t,"basename"),this.path=Re.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Re.dirname(this.path):void 0}set dirname(t){ri(this.basename,"dirname"),this.path=Re.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Re.extname(this.path):void 0}set extname(t){if(sn(t,"extname"),ri(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Re.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){_n(t)&&(t=ch(t)),on(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Re.basename(this.path,this.extname):void 0}set stem(t){on(t,"stem"),sn(t,"stem"),this.path=Re.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const i=this.message(t,n,r);throw i.fatal=!0,i}info(t,n,r){const i=this.message(t,n,r);return i.fatal=void 0,i}message(t,n,r){const i=new le(t,n,r);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function sn(e,t){if(e&&e.includes(Re.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Re.sep+"`")}function on(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function ri(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function hh(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const fh=(function(e){const r=this.constructor.prototype,i=r[e],s=function(){return i.apply(s,arguments)};return Object.setPrototypeOf(s,r),s}),ph={}.hasOwnProperty;class rr extends fh{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=eh()}copy(){const t=new rr;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(nn(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(un("data",this.frozen),this.namespace[t]=n,this):ph.call(this.namespace,t)&&this.namespace[t]||void 0:t?(un("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const i=n.call(t,...r);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=Rt(t),r=this.parser||this.Parser;return an("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),an("process",this.parser||this.Parser),ln("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(s,o){const a=Rt(t),l=r.parse(a);r.run(l,a,function(d,c,p){if(d||!c||!p)return u(d);const h=c,m=r.stringify(h,p);xh(m)?p.value=m:p.result=m,u(d,p)});function u(d,c){d||!c?o(d):s?s(c):n(void 0,c)}}}processSync(t){let n=!1,r;return this.freeze(),an("processSync",this.parser||this.Parser),ln("processSync",this.compiler||this.Compiler),this.process(t,i),si("processSync","process",n),r;function i(s,o){n=!0,ti(s),r=o}}run(t,n,r){ii(t),this.freeze();const i=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?s(void 0,r):new Promise(s);function s(o,a){const l=Rt(n);i.run(t,l,u);function u(d,c,p){const h=c||t;d?a(d):o?o(h):r(void 0,h,p)}}}runSync(t,n){let r=!1,i;return this.run(t,n,s),si("runSync","run",r),i;function s(o,a){ti(o),i=a,r=!0}}stringify(t,n){this.freeze();const r=Rt(n),i=this.compiler||this.Compiler;return ln("stringify",i),ii(t),i(t,r)}use(t,...n){const r=this.attachers,i=this.namespace;if(un("use",this.frozen),t!=null)if(typeof t=="function")l(t,n);else if(typeof t=="object")Array.isArray(t)?a(t):o(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function s(u){if(typeof u=="function")l(u,[]);else if(typeof u=="object")if(Array.isArray(u)){const[d,...c]=u;l(d,c)}else o(u);else throw new TypeError("Expected usable value, not `"+u+"`")}function o(u){if(!("plugins"in u)&&!("settings"in u))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");a(u.plugins),u.settings&&(i.settings=nn(!0,i.settings,u.settings))}function a(u){let d=-1;if(u!=null)if(Array.isArray(u))for(;++d<u.length;){const c=u[d];s(c)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function l(u,d){let c=-1,p=-1;for(;++c<r.length;)if(r[c][0]===u){p=c;break}if(p===-1)r.push([u,...d]);else if(d.length>0){let[h,...m]=d;const x=r[p][1];Ln(x)&&Ln(h)&&(h=nn(!0,x,h)),r[p]=[u,h,...m]}}}}const mh=new rr().freeze();function an(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function ln(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function un(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function ii(e){if(!Ln(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function si(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Rt(e){return gh(e)?e:new Cs(e)}function gh(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function xh(e){return typeof e=="string"||yh(e)}function yh(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const bh="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",oi=[],ai={allowDangerousHtml:!0},Sh=/^(https?|ircs?|mailto|xmpp)$/i,kh=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function wh(e){const t=vh(e),n=Ch(e);return Ih(t.runSync(t.parse(n),n),e)}function vh(e){const t=e.rehypePlugins||oi,n=e.remarkPlugins||oi,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...ai}:ai;return mh().use(rd).use(n).use(Yd,r).use(t)}function Ch(e){const t=e.children||"",n=new Cs;return typeof t=="string"&&(n.value=t),n}function Ih(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,s=t.disallowedElements,o=t.skipHtml,a=t.unwrapDisallowed,l=t.urlTransform||Rh;for(const d of kh)Object.hasOwn(t,d.from)&&(""+d.from+(d.to?"use `"+d.to+"` instead":"remove it")+bh+d.id,void 0);return nr(e,u),Bl(e,{Fragment:f.Fragment,components:i,ignoreInvalidStyle:!0,jsx:f.jsx,jsxs:f.jsxs,passKeys:!0,passNode:!0});function u(d,c,p){if(d.type==="raw"&&p&&typeof c=="number")return o?p.children.splice(c,1):p.children[c]={type:"text",value:d.value},c;if(d.type==="element"){let h;for(h in Jt)if(Object.hasOwn(Jt,h)&&Object.hasOwn(d.properties,h)){const m=d.properties[h],x=Jt[h];(x===null||x.includes(d.tagName))&&(d.properties[h]=l(String(m||""),h,d))}}if(d.type==="element"){let h=n?!n.includes(d.tagName):s?s.includes(d.tagName):!1;if(!h&&r&&typeof c=="number"&&(h=!r(d,c,p)),h&&p&&typeof c=="number")return a&&d.children?p.children.splice(c,1,...d.children):p.children.splice(c,1),c}}}function Rh(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||Sh.test(e.slice(0,t))?e:""}function li(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function Th(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function Ah(e,t,n){const i=Vt((n||{}).ignore||[]),s=Eh(t);let o=-1;for(;++o<s.length;)vs(e,"text",a);function a(u,d){let c=-1,p;for(;++c<d.length;){const h=d[c],m=p?p.children:void 0;if(i(h,m?m.indexOf(h):void 0,p))return;p=h}if(p)return l(u,d)}function l(u,d){const c=d[d.length-1],p=s[o][0],h=s[o][1];let m=0;const S=c.children.indexOf(u);let g=!1,v=[];p.lastIndex=0;let k=p.exec(u.value);for(;k;){const T=k.index,N={index:k.index,input:k.input,stack:[...d,u]};let w=h(...k,N);if(typeof w=="string"&&(w=w.length>0?{type:"text",value:w}:void 0),w===!1?p.lastIndex=T+1:(m!==T&&v.push({type:"text",value:u.value.slice(m,T)}),Array.isArray(w)?v.push(...w):w&&v.push(w),m=T+k[0].length,g=!0),!p.global)break;k=p.exec(u.value)}return g?(m<u.value.length&&v.push({type:"text",value:u.value.slice(m)}),c.children.splice(S,1,...v)):v=[u],S+v.length}}function Eh(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let r=-1;for(;++r<n.length;){const i=n[r];t.push([Mh(i[0]),Nh(i[1])])}return t}function Mh(e){return typeof e=="string"?new RegExp(Th(e),"g"):e}function Nh(e){return typeof e=="function"?e:function(){return e}}const cn="phrasing",dn=["autolink","link","image","label"];function Ph(){return{transforms:[zh],enter:{literalAutolink:Lh,literalAutolinkEmail:hn,literalAutolinkHttp:hn,literalAutolinkWww:hn},exit:{literalAutolink:Fh,literalAutolinkEmail:Dh,literalAutolinkHttp:_h,literalAutolinkWww:Oh}}}function jh(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:cn,notInConstruct:dn},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:cn,notInConstruct:dn},{character:":",before:"[ps]",after:"\\/",inConstruct:cn,notInConstruct:dn}]}}function Lh(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function hn(e){this.config.enter.autolinkProtocol.call(this,e)}function _h(e){this.config.exit.autolinkProtocol.call(this,e)}function Oh(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function Dh(e){this.config.exit.autolinkEmail.call(this,e)}function Fh(e){this.exit(e)}function zh(e){Ah(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Bh],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),$h]],{ignore:["link","linkReference"]})}function Bh(e,t,n,r,i){let s="";if(!Is(i)||(/^w/i.test(t)&&(n=t+n,t="",s="http://"),!Uh(n)))return!1;const o=Hh(n+r);if(!o[0])return!1;const a={type:"link",title:null,url:s+t+o[0],children:[{type:"text",value:t+o[0]}]};return o[1]?[a,{type:"text",value:o[1]}]:a}function $h(e,t,n,r){return!Is(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function Uh(e){const t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function Hh(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")");const i=li(e,"(");let s=li(e,")");for(;r!==-1&&i>s;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),s++;return[e,n]}function Is(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||Ke(n)||Ut(n))&&(!t||n!==47)}Rs.peek=Jh;function Kh(){this.buffer()}function Vh(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function qh(){this.buffer()}function Wh(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function Gh(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ce(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Xh(e){this.exit(e)}function Qh(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ce(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Yh(e){this.exit(e)}function Jh(){return"["}function Rs(e,t,n,r){const i=n.createTracker(r);let s=i.move("[^");const o=n.enter("footnoteReference"),a=n.enter("reference");return s+=i.move(n.safe(n.associationId(e),{after:"]",before:s})),a(),o(),s+=i.move("]"),s}function Zh(){return{enter:{gfmFootnoteCallString:Kh,gfmFootnoteCall:Vh,gfmFootnoteDefinitionLabelString:qh,gfmFootnoteDefinition:Wh},exit:{gfmFootnoteCallString:Gh,gfmFootnoteCall:Xh,gfmFootnoteDefinitionLabelString:Qh,gfmFootnoteDefinition:Yh}}}function ef(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:Rs},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,i,s,o){const a=s.createTracker(o);let l=a.move("[^");const u=s.enter("footnoteDefinition"),d=s.enter("label");return l+=a.move(s.safe(s.associationId(r),{before:l,after:"]"})),d(),l+=a.move("]:"),r.children&&r.children.length>0&&(a.shift(4),l+=a.move((t?`
|
|
17
|
+
`:" ")+s.indentLines(s.containerFlow(r,a.current()),t?Ts:tf))),u(),l}}function tf(e,t,n){return t===0?e:Ts(e,t,n)}function Ts(e,t,n){return(n?"":" ")+e}const nf=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];As.peek=lf;function rf(){return{canContainEols:["delete"],enter:{strikethrough:of},exit:{strikethrough:af}}}function sf(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:nf}],handlers:{delete:As}}}function of(e){this.enter({type:"delete",children:[]},e)}function af(e){this.exit(e)}function As(e,t,n,r){const i=n.createTracker(r),s=n.enter("strikethrough");let o=i.move("~~");return o+=n.containerPhrasing(e,{...i.current(),before:o,after:"~"}),o+=i.move("~~"),s(),o}function lf(){return"~"}function uf(e){return e.length}function cf(e,t){const n=t||{},r=(n.align||[]).concat(),i=n.stringLength||uf,s=[],o=[],a=[],l=[];let u=0,d=-1;for(;++d<e.length;){const x=[],S=[];let g=-1;for(e[d].length>u&&(u=e[d].length);++g<e[d].length;){const v=df(e[d][g]);if(n.alignDelimiters!==!1){const k=i(v);S[g]=k,(l[g]===void 0||k>l[g])&&(l[g]=k)}x.push(v)}o[d]=x,a[d]=S}let c=-1;if(typeof r=="object"&&"length"in r)for(;++c<u;)s[c]=ui(r[c]);else{const x=ui(r);for(;++c<u;)s[c]=x}c=-1;const p=[],h=[];for(;++c<u;){const x=s[c];let S="",g="";x===99?(S=":",g=":"):x===108?S=":":x===114&&(g=":");let v=n.alignDelimiters===!1?1:Math.max(1,l[c]-S.length-g.length);const k=S+"-".repeat(v)+g;n.alignDelimiters!==!1&&(v=S.length+v+g.length,v>l[c]&&(l[c]=v),h[c]=v),p[c]=k}o.splice(1,0,p),a.splice(1,0,h),d=-1;const m=[];for(;++d<o.length;){const x=o[d],S=a[d];c=-1;const g=[];for(;++c<u;){const v=x[c]||"";let k="",T="";if(n.alignDelimiters!==!1){const N=l[c]-(S[c]||0),w=s[c];w===114?k=" ".repeat(N):w===99?N%2?(k=" ".repeat(N/2+.5),T=" ".repeat(N/2-.5)):(k=" ".repeat(N/2),T=k):T=" ".repeat(N)}n.delimiterStart!==!1&&!c&&g.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&v==="")&&(n.delimiterStart!==!1||c)&&g.push(" "),n.alignDelimiters!==!1&&g.push(k),g.push(v),n.alignDelimiters!==!1&&g.push(T),n.padding!==!1&&g.push(" "),(n.delimiterEnd!==!1||c!==u-1)&&g.push("|")}m.push(n.delimiterEnd===!1?g.join("").replace(/ +$/,""):g.join(""))}return m.join(`
|
|
18
|
+
`)}function df(e){return e==null?"":String(e)}function ui(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function hf(e,t,n,r){const i=n.enter("blockquote"),s=n.createTracker(r);s.move("> "),s.shift(2);const o=n.indentLines(n.containerFlow(e,s.current()),ff);return i(),o}function ff(e,t,n){return">"+(n?"":" ")+e}function pf(e,t){return ci(e,t.inConstruct,!0)&&!ci(e,t.notInConstruct,!1)}function ci(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function di(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
|
|
19
|
+
`&&pf(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
|
|
20
|
+
`}function mf(e,t){const n=String(e);let r=n.indexOf(t),i=r,s=0,o=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===i?++s>o&&(o=s):s=1,i=r+t.length,r=n.indexOf(t,i);return o}function gf(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function xf(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function yf(e,t,n,r){const i=xf(n),s=e.value||"",o=i==="`"?"GraveAccent":"Tilde";if(gf(e,n)){const c=n.enter("codeIndented"),p=n.indentLines(s,bf);return c(),p}const a=n.createTracker(r),l=i.repeat(Math.max(mf(s,i)+1,3)),u=n.enter("codeFenced");let d=a.move(l);if(e.lang){const c=n.enter(`codeFencedLang${o}`);d+=a.move(n.safe(e.lang,{before:d,after:" ",encode:["`"],...a.current()})),c()}if(e.lang&&e.meta){const c=n.enter(`codeFencedMeta${o}`);d+=a.move(" "),d+=a.move(n.safe(e.meta,{before:d,after:`
|
|
21
|
+
`,encode:["`"],...a.current()})),c()}return d+=a.move(`
|
|
22
|
+
`),s&&(d+=a.move(s+`
|
|
23
|
+
`)),d+=a.move(l),u(),d}function bf(e,t,n){return(n?"":" ")+e}function ir(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function Sf(e,t,n,r){const i=ir(n),s=i==='"'?"Quote":"Apostrophe",o=n.enter("definition");let a=n.enter("label");const l=n.createTracker(r);let u=l.move("[");return u+=l.move(n.safe(n.associationId(e),{before:u,after:"]",...l.current()})),u+=l.move("]: "),a(),!e.url||/[\0- \u007F]/.test(e.url)?(a=n.enter("destinationLiteral"),u+=l.move("<"),u+=l.move(n.safe(e.url,{before:u,after:">",...l.current()})),u+=l.move(">")):(a=n.enter("destinationRaw"),u+=l.move(n.safe(e.url,{before:u,after:e.title?" ":`
|
|
24
|
+
`,...l.current()}))),a(),e.title&&(a=n.enter(`title${s}`),u+=l.move(" "+i),u+=l.move(n.safe(e.title,{before:u,after:i,...l.current()})),u+=l.move(i),a()),o(),u}function kf(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function xt(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Ot(e,t,n){const r=Je(e),i=Je(t);return r===void 0?i===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}Es.peek=wf;function Es(e,t,n,r){const i=kf(n),s=n.enter("emphasis"),o=n.createTracker(r),a=o.move(i);let l=o.move(n.containerPhrasing(e,{after:i,before:a,...o.current()}));const u=l.charCodeAt(0),d=Ot(r.before.charCodeAt(r.before.length-1),u,i);d.inside&&(l=xt(u)+l.slice(1));const c=l.charCodeAt(l.length-1),p=Ot(r.after.charCodeAt(0),c,i);p.inside&&(l=l.slice(0,-1)+xt(c));const h=o.move(i);return s(),n.attentionEncodeSurroundingInfo={after:p.outside,before:d.outside},a+l+h}function wf(e,t,n){return n.options.emphasis||"*"}function vf(e,t){let n=!1;return nr(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,Pn}),!!((!e.depth||e.depth<3)&&Xn(e)&&(t.options.setext||n))}function Cf(e,t,n,r){const i=Math.max(Math.min(6,e.depth||1),1),s=n.createTracker(r);if(vf(e,n)){const d=n.enter("headingSetext"),c=n.enter("phrasing"),p=n.containerPhrasing(e,{...s.current(),before:`
|
|
25
|
+
`,after:`
|
|
26
|
+
`});return c(),d(),p+`
|
|
27
|
+
`+(i===1?"=":"-").repeat(p.length-(Math.max(p.lastIndexOf("\r"),p.lastIndexOf(`
|
|
28
|
+
`))+1))}const o="#".repeat(i),a=n.enter("headingAtx"),l=n.enter("phrasing");s.move(o+" ");let u=n.containerPhrasing(e,{before:"# ",after:`
|
|
29
|
+
`,...s.current()});return/^[\t ]/.test(u)&&(u=xt(u.charCodeAt(0))+u.slice(1)),u=u?o+" "+u:o,n.options.closeAtx&&(u+=" "+o),l(),a(),u}Ms.peek=If;function Ms(e){return e.value||""}function If(){return"<"}Ns.peek=Rf;function Ns(e,t,n,r){const i=ir(n),s=i==='"'?"Quote":"Apostrophe",o=n.enter("image");let a=n.enter("label");const l=n.createTracker(r);let u=l.move("![");return u+=l.move(n.safe(e.alt,{before:u,after:"]",...l.current()})),u+=l.move("]("),a(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(a=n.enter("destinationLiteral"),u+=l.move("<"),u+=l.move(n.safe(e.url,{before:u,after:">",...l.current()})),u+=l.move(">")):(a=n.enter("destinationRaw"),u+=l.move(n.safe(e.url,{before:u,after:e.title?" ":")",...l.current()}))),a(),e.title&&(a=n.enter(`title${s}`),u+=l.move(" "+i),u+=l.move(n.safe(e.title,{before:u,after:i,...l.current()})),u+=l.move(i),a()),u+=l.move(")"),o(),u}function Rf(){return"!"}Ps.peek=Tf;function Ps(e,t,n,r){const i=e.referenceType,s=n.enter("imageReference");let o=n.enter("label");const a=n.createTracker(r);let l=a.move("![");const u=n.safe(e.alt,{before:l,after:"]",...a.current()});l+=a.move(u+"]["),o();const d=n.stack;n.stack=[],o=n.enter("reference");const c=n.safe(n.associationId(e),{before:l,after:"]",...a.current()});return o(),n.stack=d,s(),i==="full"||!u||u!==c?l+=a.move(c+"]"):i==="shortcut"?l=l.slice(0,-1):l+=a.move("]"),l}function Tf(){return"!"}js.peek=Af;function js(e,t,n){let r=e.value||"",i="`",s=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++s<n.unsafe.length;){const o=n.unsafe[s],a=n.compilePattern(o);let l;if(o.atBreak)for(;l=a.exec(r);){let u=l.index;r.charCodeAt(u)===10&&r.charCodeAt(u-1)===13&&u--,r=r.slice(0,u)+" "+r.slice(l.index+1)}}return i+r+i}function Af(){return"`"}function Ls(e,t){const n=Xn(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}_s.peek=Ef;function _s(e,t,n,r){const i=ir(n),s=i==='"'?"Quote":"Apostrophe",o=n.createTracker(r);let a,l;if(Ls(e,n)){const d=n.stack;n.stack=[],a=n.enter("autolink");let c=o.move("<");return c+=o.move(n.containerPhrasing(e,{before:c,after:">",...o.current()})),c+=o.move(">"),a(),n.stack=d,c}a=n.enter("link"),l=n.enter("label");let u=o.move("[");return u+=o.move(n.containerPhrasing(e,{before:u,after:"](",...o.current()})),u+=o.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),u+=o.move("<"),u+=o.move(n.safe(e.url,{before:u,after:">",...o.current()})),u+=o.move(">")):(l=n.enter("destinationRaw"),u+=o.move(n.safe(e.url,{before:u,after:e.title?" ":")",...o.current()}))),l(),e.title&&(l=n.enter(`title${s}`),u+=o.move(" "+i),u+=o.move(n.safe(e.title,{before:u,after:i,...o.current()})),u+=o.move(i),l()),u+=o.move(")"),a(),u}function Ef(e,t,n){return Ls(e,n)?"<":"["}Os.peek=Mf;function Os(e,t,n,r){const i=e.referenceType,s=n.enter("linkReference");let o=n.enter("label");const a=n.createTracker(r);let l=a.move("[");const u=n.containerPhrasing(e,{before:l,after:"]",...a.current()});l+=a.move(u+"]["),o();const d=n.stack;n.stack=[],o=n.enter("reference");const c=n.safe(n.associationId(e),{before:l,after:"]",...a.current()});return o(),n.stack=d,s(),i==="full"||!u||u!==c?l+=a.move(c+"]"):i==="shortcut"?l=l.slice(0,-1):l+=a.move("]"),l}function Mf(){return"["}function sr(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function Nf(e){const t=sr(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function Pf(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function Ds(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function jf(e,t,n,r){const i=n.enter("list"),s=n.bulletCurrent;let o=e.ordered?Pf(n):sr(n);const a=e.ordered?o==="."?")":".":Nf(n);let l=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){const d=e.children?e.children[0]:void 0;if((o==="*"||o==="-")&&d&&(!d.children||!d.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(l=!0),Ds(n)===o&&d){let c=-1;for(;++c<e.children.length;){const p=e.children[c];if(p&&p.type==="listItem"&&p.children&&p.children[0]&&p.children[0].type==="thematicBreak"){l=!0;break}}}}l&&(o=a),n.bulletCurrent=o;const u=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=s,i(),u}function Lf(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function _f(e,t,n,r){const i=Lf(n);let s=n.bulletCurrent||sr(n);t&&t.type==="list"&&t.ordered&&(s=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+s);let o=s.length+1;(i==="tab"||i==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);const a=n.createTracker(r);a.move(s+" ".repeat(o-s.length)),a.shift(o);const l=n.enter("listItem"),u=n.indentLines(n.containerFlow(e,a.current()),d);return l(),u;function d(c,p,h){return p?(h?"":" ".repeat(o))+c:(h?s:s+" ".repeat(o-s.length))+c}}function Of(e,t,n,r){const i=n.enter("paragraph"),s=n.enter("phrasing"),o=n.containerPhrasing(e,r);return s(),i(),o}const Df=Vt(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function Ff(e,t,n,r){return(e.children.some(function(o){return Df(o)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function zf(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Fs.peek=Bf;function Fs(e,t,n,r){const i=zf(n),s=n.enter("strong"),o=n.createTracker(r),a=o.move(i+i);let l=o.move(n.containerPhrasing(e,{after:i,before:a,...o.current()}));const u=l.charCodeAt(0),d=Ot(r.before.charCodeAt(r.before.length-1),u,i);d.inside&&(l=xt(u)+l.slice(1));const c=l.charCodeAt(l.length-1),p=Ot(r.after.charCodeAt(0),c,i);p.inside&&(l=l.slice(0,-1)+xt(c));const h=o.move(i+i);return s(),n.attentionEncodeSurroundingInfo={after:p.outside,before:d.outside},a+l+h}function Bf(e,t,n){return n.options.strong||"*"}function $f(e,t,n,r){return n.safe(e.value,r)}function Uf(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function Hf(e,t,n){const r=(Ds(n)+(n.options.ruleSpaces?" ":"")).repeat(Uf(n));return n.options.ruleSpaces?r.slice(0,-1):r}const zs={blockquote:hf,break:di,code:yf,definition:Sf,emphasis:Es,hardBreak:di,heading:Cf,html:Ms,image:Ns,imageReference:Ps,inlineCode:js,link:_s,linkReference:Os,list:jf,listItem:_f,paragraph:Of,root:Ff,strong:Fs,text:$f,thematicBreak:Hf};function Kf(){return{enter:{table:Vf,tableData:hi,tableHeader:hi,tableRow:Wf},exit:{codeText:Gf,table:qf,tableData:fn,tableHeader:fn,tableRow:fn}}}function Vf(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function qf(e){this.exit(e),this.data.inTable=void 0}function Wf(e){this.enter({type:"tableRow",children:[]},e)}function fn(e){this.exit(e)}function hi(e){this.enter({type:"tableCell",children:[]},e)}function Gf(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Xf));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function Xf(e,t){return t==="|"?t:e}function Qf(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
30
|
+
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:p,table:o,tableCell:l,tableRow:a}};function o(h,m,x,S){return u(d(h,x,S),h.align)}function a(h,m,x,S){const g=c(h,x,S),v=u([g]);return v.slice(0,v.indexOf(`
|
|
31
|
+
`))}function l(h,m,x,S){const g=x.enter("tableCell"),v=x.enter("phrasing"),k=x.containerPhrasing(h,{...S,before:s,after:s});return v(),g(),k}function u(h,m){return cf(h,{align:m,alignDelimiters:r,padding:n,stringLength:i})}function d(h,m,x){const S=h.children;let g=-1;const v=[],k=m.enter("table");for(;++g<S.length;)v[g]=c(S[g],m,x);return k(),v}function c(h,m,x){const S=h.children;let g=-1;const v=[],k=m.enter("tableRow");for(;++g<S.length;)v[g]=l(S[g],h,m,x);return k(),v}function p(h,m,x){let S=zs.inlineCode(h,m,x);return x.stack.includes("tableCell")&&(S=S.replace(/\|/g,"\\$&")),S}}function Yf(){return{exit:{taskListCheckValueChecked:fi,taskListCheckValueUnchecked:fi,paragraph:Zf}}}function Jf(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:ep}}}function fi(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function Zf(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let s=-1,o;for(;++s<i.length;){const a=i[s];if(a.type==="paragraph"){o=a;break}}o===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function ep(e,t,n,r){const i=e.children[0],s=typeof e.checked=="boolean"&&i&&i.type==="paragraph",o="["+(e.checked?"x":" ")+"] ",a=n.createTracker(r);s&&a.move(o);let l=zs.listItem(e,t,n,{...r,...a.current()});return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,u)),l;function u(d){return d+o}}function tp(){return[Ph(),Zh(),rf(),Kf(),Yf()]}function np(e){return{extensions:[jh(),ef(e),sf(),Qf(e),Jf()]}}const rp={tokenize:up,partial:!0},Bs={tokenize:cp,partial:!0},$s={tokenize:dp,partial:!0},Us={tokenize:hp,partial:!0},ip={tokenize:fp,partial:!0},Hs={name:"wwwAutolink",tokenize:ap,previous:Vs},Ks={name:"protocolAutolink",tokenize:lp,previous:qs},Le={name:"emailAutolink",tokenize:op,previous:Ws},Te={};function sp(){return{text:Te}}let $e=48;for(;$e<123;)Te[$e]=Le,$e++,$e===58?$e=65:$e===91&&($e=97);Te[43]=Le;Te[45]=Le;Te[46]=Le;Te[95]=Le;Te[72]=[Le,Ks];Te[104]=[Le,Ks];Te[87]=[Le,Hs];Te[119]=[Le,Hs];function op(e,t,n){const r=this;let i,s;return o;function o(c){return!On(c)||!Ws.call(r,r.previous)||or(r.events)?n(c):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),a(c))}function a(c){return On(c)?(e.consume(c),a):c===64?(e.consume(c),l):n(c)}function l(c){return c===46?e.check(ip,d,u)(c):c===45||c===95||ae(c)?(s=!0,e.consume(c),l):d(c)}function u(c){return e.consume(c),i=!0,l}function d(c){return s&&i&&ue(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(c)):n(c)}}function ap(e,t,n){const r=this;return i;function i(o){return o!==87&&o!==119||!Vs.call(r,r.previous)||or(r.events)?n(o):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(rp,e.attempt(Bs,e.attempt($s,s),n),n)(o))}function s(o){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(o)}}function lp(e,t,n){const r=this;let i="",s=!1;return o;function o(c){return(c===72||c===104)&&qs.call(r,r.previous)&&!or(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(c),e.consume(c),a):n(c)}function a(c){if(ue(c)&&i.length<5)return i+=String.fromCodePoint(c),e.consume(c),a;if(c===58){const p=i.toLowerCase();if(p==="http"||p==="https")return e.consume(c),l}return n(c)}function l(c){return c===47?(e.consume(c),s?u:(s=!0,l)):n(c)}function u(c){return c===null||jt(c)||Q(c)||Ke(c)||Ut(c)?n(c):e.attempt(Bs,e.attempt($s,d),n)(c)}function d(c){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(c)}}function up(e,t,n){let r=0;return i;function i(o){return(o===87||o===119)&&r<3?(r++,e.consume(o),i):o===46&&r===3?(e.consume(o),s):n(o)}function s(o){return o===null?n(o):t(o)}}function cp(e,t,n){let r,i,s;return o;function o(u){return u===46||u===95?e.check(Us,l,a)(u):u===null||Q(u)||Ke(u)||u!==45&&Ut(u)?l(u):(s=!0,e.consume(u),o)}function a(u){return u===95?r=!0:(i=r,r=void 0),e.consume(u),o}function l(u){return i||r||!s?n(u):t(u)}}function dp(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?s(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(Us,t,s)(o):o===null||Q(o)||Ke(o)?t(o):(e.consume(o),i)}function s(o){return o===41&&r++,e.consume(o),i}}function hp(e,t,n){return r;function r(a){return a===33||a===34||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===63||a===95||a===126?(e.consume(a),r):a===38?(e.consume(a),s):a===93?(e.consume(a),i):a===60||a===null||Q(a)||Ke(a)?t(a):n(a)}function i(a){return a===null||a===40||a===91||Q(a)||Ke(a)?t(a):r(a)}function s(a){return ue(a)?o(a):n(a)}function o(a){return a===59?(e.consume(a),r):ue(a)?(e.consume(a),o):n(a)}}function fp(e,t,n){return r;function r(s){return e.consume(s),i}function i(s){return ae(s)?n(s):t(s)}}function Vs(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Q(e)}function qs(e){return!ue(e)}function Ws(e){return!(e===47||On(e))}function On(e){return e===43||e===45||e===46||e===95||ae(e)}function or(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const pp={tokenize:wp,partial:!0};function mp(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:bp,continuation:{tokenize:Sp},exit:kp}},text:{91:{name:"gfmFootnoteCall",tokenize:yp},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:gp,resolveTo:xp}}}}function gp(e,t,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o;for(;i--;){const l=r.events[i][1];if(l.type==="labelImage"){o=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return a;function a(l){if(!o||!o._balanced)return n(l);const u=Ce(r.sliceSerialize({start:o.end,end:r.now()}));return u.codePointAt(0)!==94||!s.includes(u.slice(1))?n(l):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),t(l))}}function xp(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},a=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",s,t],["enter",o,t],["exit",o,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...a),e}function yp(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,o;return a;function a(c){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),l}function l(c){return c!==94?n(c):(e.enter("gfmFootnoteCallMarker"),e.consume(c),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",u)}function u(c){if(s>999||c===93&&!o||c===null||c===91||Q(c))return n(c);if(c===93){e.exit("chunkString");const p=e.exit("gfmFootnoteCallString");return i.includes(Ce(r.sliceSerialize(p)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(c)}return Q(c)||(o=!0),s++,e.consume(c),c===92?d:u}function d(c){return c===91||c===92||c===93?(e.consume(c),s++,u):u(c)}}function bp(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,o=0,a;return l;function l(m){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),u}function u(m){return m===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",d):n(m)}function d(m){if(o>999||m===93&&!a||m===null||m===91||Q(m))return n(m);if(m===93){e.exit("chunkString");const x=e.exit("gfmFootnoteDefinitionLabelString");return s=Ce(r.sliceSerialize(x)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),p}return Q(m)||(a=!0),o++,e.consume(m),m===92?c:d}function c(m){return m===91||m===92||m===93?(e.consume(m),o++,d):d(m)}function p(m){return m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),i.includes(s)||i.push(s),q(e,h,"gfmFootnoteDefinitionWhitespace")):n(m)}function h(m){return t(m)}}function Sp(e,t,n){return e.check(St,t,e.attempt(pp,t,n))}function kp(e){e.exit("gfmFootnoteDefinition")}function wp(e,t,n){const r=this;return q(e,i,"gfmFootnoteDefinitionIndent",5);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?t(s):n(s)}}function vp(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,a){let l=-1;for(;++l<o.length;)if(o[l][0]==="enter"&&o[l][1].type==="strikethroughSequenceTemporary"&&o[l][1]._close){let u=l;for(;u--;)if(o[u][0]==="exit"&&o[u][1].type==="strikethroughSequenceTemporary"&&o[u][1]._open&&o[l][1].end.offset-o[l][1].start.offset===o[u][1].end.offset-o[u][1].start.offset){o[l][1].type="strikethroughSequence",o[u][1].type="strikethroughSequence";const d={type:"strikethrough",start:Object.assign({},o[u][1].start),end:Object.assign({},o[l][1].end)},c={type:"strikethroughText",start:Object.assign({},o[u][1].end),end:Object.assign({},o[l][1].start)},p=[["enter",d,a],["enter",o[u][1],a],["exit",o[u][1],a],["enter",c,a]],h=a.parser.constructs.insideSpan.null;h&&xe(p,p.length,0,Ht(h,o.slice(u+1,l),a)),xe(p,p.length,0,[["exit",c,a],["enter",o[l][1],a],["exit",o[l][1],a],["exit",d,a]]),xe(o,u-1,l-u+3,p),l=u+p.length-2;break}}for(l=-1;++l<o.length;)o[l][1].type==="strikethroughSequenceTemporary"&&(o[l][1].type="data");return o}function s(o,a,l){const u=this.previous,d=this.events;let c=0;return p;function p(m){return u===126&&d[d.length-1][1].type!=="characterEscape"?l(m):(o.enter("strikethroughSequenceTemporary"),h(m))}function h(m){const x=Je(u);if(m===126)return c>1?l(m):(o.consume(m),c++,h);if(c<2&&!n)return l(m);const S=o.exit("strikethroughSequenceTemporary"),g=Je(m);return S._open=!g||g===2&&!!x,S._close=!x||x===2&&!!g,a(m)}}}class Cp{constructor(){this.map=[]}add(t,n,r){Ip(this,t,n,r)}consume(t){if(this.map.sort(function(s,o){return s[0]-o[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const s of i)t.push(s);i=r.pop()}this.map.length=0}}function Ip(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function Rp(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const s=r.length-1;r[s]=r[s]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function Tp(){return{flow:{null:{name:"table",tokenize:Ap,resolveAll:Ep}}}}function Ap(e,t,n){const r=this;let i=0,s=0,o;return a;function a(C){let j=r.events.length-1;for(;j>-1;){const O=r.events[j][1].type;if(O==="lineEnding"||O==="linePrefix")j--;else break}const L=j>-1?r.events[j][1].type:null,W=L==="tableHead"||L==="tableRow"?w:l;return W===w&&r.parser.lazy[r.now().line]?n(C):W(C)}function l(C){return e.enter("tableHead"),e.enter("tableRow"),u(C)}function u(C){return C===124||(o=!0,s+=1),d(C)}function d(C){return C===null?n(C):D(C)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),h):n(C):H(C)?q(e,d,"whitespace")(C):(s+=1,o&&(o=!1,i+=1),C===124?(e.enter("tableCellDivider"),e.consume(C),e.exit("tableCellDivider"),o=!0,d):(e.enter("data"),c(C)))}function c(C){return C===null||C===124||Q(C)?(e.exit("data"),d(C)):(e.consume(C),C===92?p:c)}function p(C){return C===92||C===124?(e.consume(C),c):c(C)}function h(C){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(C):(e.enter("tableDelimiterRow"),o=!1,H(C)?q(e,m,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(C):m(C))}function m(C){return C===45||C===58?S(C):C===124?(o=!0,e.enter("tableCellDivider"),e.consume(C),e.exit("tableCellDivider"),x):N(C)}function x(C){return H(C)?q(e,S,"whitespace")(C):S(C)}function S(C){return C===58?(s+=1,o=!0,e.enter("tableDelimiterMarker"),e.consume(C),e.exit("tableDelimiterMarker"),g):C===45?(s+=1,g(C)):C===null||D(C)?T(C):N(C)}function g(C){return C===45?(e.enter("tableDelimiterFiller"),v(C)):N(C)}function v(C){return C===45?(e.consume(C),v):C===58?(o=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(C),e.exit("tableDelimiterMarker"),k):(e.exit("tableDelimiterFiller"),k(C))}function k(C){return H(C)?q(e,T,"whitespace")(C):T(C)}function T(C){return C===124?m(C):C===null||D(C)?!o||i!==s?N(C):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(C)):N(C)}function N(C){return n(C)}function w(C){return e.enter("tableRow"),_(C)}function _(C){return C===124?(e.enter("tableCellDivider"),e.consume(C),e.exit("tableCellDivider"),_):C===null||D(C)?(e.exit("tableRow"),t(C)):H(C)?q(e,_,"whitespace")(C):(e.enter("data"),z(C))}function z(C){return C===null||C===124||Q(C)?(e.exit("data"),_(C)):(e.consume(C),C===92?U:z)}function U(C){return C===92||C===124?(e.consume(C),z):z(C)}}function Ep(e,t){let n=-1,r=!0,i=0,s=[0,0,0,0],o=[0,0,0,0],a=!1,l=0,u,d,c;const p=new Cp;for(;++n<e.length;){const h=e[n],m=h[1];h[0]==="enter"?m.type==="tableHead"?(a=!1,l!==0&&(pi(p,t,l,u,d),d=void 0,l=0),u={type:"table",start:Object.assign({},m.start),end:Object.assign({},m.end)},p.add(n,0,[["enter",u,t]])):m.type==="tableRow"||m.type==="tableDelimiterRow"?(r=!0,c=void 0,s=[0,0,0,0],o=[0,n+1,0,0],a&&(a=!1,d={type:"tableBody",start:Object.assign({},m.start),end:Object.assign({},m.end)},p.add(n,0,[["enter",d,t]])),i=m.type==="tableDelimiterRow"?2:d?3:1):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")?(r=!1,o[2]===0&&(s[1]!==0&&(o[0]=o[1],c=Tt(p,t,s,i,void 0,c),s=[0,0,0,0]),o[2]=n)):m.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(o[0]=o[1],c=Tt(p,t,s,i,void 0,c)),s=o,o=[s[1],n,0,0])):m.type==="tableHead"?(a=!0,l=n):m.type==="tableRow"||m.type==="tableDelimiterRow"?(l=n,s[1]!==0?(o[0]=o[1],c=Tt(p,t,s,i,n,c)):o[1]!==0&&(c=Tt(p,t,o,i,n,c)),i=0):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")&&(o[3]=n)}for(l!==0&&pi(p,t,l,u,d),p.consume(t.events),n=-1;++n<t.events.length;){const h=t.events[n];h[0]==="enter"&&h[1].type==="table"&&(h[1]._align=Rp(t.events,n))}return e}function Tt(e,t,n,r,i,s){const o=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",a="tableContent";n[0]!==0&&(s.end=Object.assign({},Qe(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const l=Qe(t.events,n[1]);if(s={type:o,start:Object.assign({},l),end:Object.assign({},l)},e.add(n[1],0,[["enter",s,t]]),n[2]!==0){const u=Qe(t.events,n[2]),d=Qe(t.events,n[3]),c={type:a,start:Object.assign({},u),end:Object.assign({},d)};if(e.add(n[2],0,[["enter",c,t]]),r!==2){const p=t.events[n[2]],h=t.events[n[3]];if(p[1].end=Object.assign({},h[1].end),p[1].type="chunkText",p[1].contentType="text",n[3]>n[2]+1){const m=n[2]+1,x=n[3]-n[2]-1;e.add(m,x,[])}}e.add(n[3]+1,0,[["exit",c,t]])}return i!==void 0&&(s.end=Object.assign({},Qe(t.events,i)),e.add(i,0,[["exit",s,t]]),s=void 0),s}function pi(e,t,n,r,i){const s=[],o=Qe(t.events,n);i&&(i.end=Object.assign({},o),s.push(["exit",i,t])),r.end=Object.assign({},o),s.push(["exit",r,t]),e.add(n+1,0,s)}function Qe(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const Mp={name:"tasklistCheck",tokenize:Pp};function Np(){return{text:{91:Mp}}}function Pp(e,t,n){const r=this;return i;function i(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),s)}function s(l){return Q(l)?(e.enter("taskListCheckValueUnchecked"),e.consume(l),e.exit("taskListCheckValueUnchecked"),o):l===88||l===120?(e.enter("taskListCheckValueChecked"),e.consume(l),e.exit("taskListCheckValueChecked"),o):n(l)}function o(l){return l===93?(e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),a):n(l)}function a(l){return D(l)?t(l):H(l)?e.check({tokenize:jp},t,n)(l):n(l)}}function jp(e,t,n){return q(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function Lp(e){return is([sp(),mp(),vp(e),Tp(),Np()])}const _p={};function Op(e){const t=this,n=e||_p,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(Lp(n)),s.push(tp()),o.push(np(n))}const mi=14e4,gi=220,Dp=/language-([a-z0-9-]+)/i,Fp=new Set(["http:","https:","mailto:","tel:"]);function zp(e){return e.length<=mi?e:`${e.slice(0,mi)}
|
|
32
|
+
|
|
33
|
+
…`}function Gs(e){return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(Gs).join(""):""}function Bp(e){const t=Gs(e);return t.endsWith(`
|
|
34
|
+
`)?t.slice(0,-1):t}function $p(e){var n;const t=e?Dp.exec(e):null;return((n=t==null?void 0:t[1])==null?void 0:n.toLowerCase())||"text"}function xi(e){if(!e)return null;if(e.startsWith("#")||e.startsWith("/")||e.startsWith("./")||e.startsWith("../"))return e;try{const t=new URL(e);return Fp.has(t.protocol)?e:null}catch{return null}}function Up(e){return/^https?:\/\//i.test(e)}function Hp({className:e,children:t}){const[n,r]=R.useState(!1),i=R.useMemo(()=>$p(e),[e]),s=R.useMemo(()=>Bp(t),[t]),o=R.useCallback(async()=>{var a;if(!(!s||typeof navigator>"u"||!((a=navigator.clipboard)!=null&&a.writeText)))try{await navigator.clipboard.writeText(s),r(!0)}catch{r(!1)}},[s]);return R.useEffect(()=>{if(!n||typeof window>"u")return;const a=window.setTimeout(()=>r(!1),1300);return()=>window.clearTimeout(a)},[n]),f.jsxs("div",{className:"chat-codeblock",children:[f.jsxs("div",{className:"chat-codeblock-toolbar",children:[f.jsx("span",{className:"chat-codeblock-language",children:i}),f.jsxs("button",{type:"button",className:"chat-codeblock-copy",onClick:o,"aria-label":n?A("chatCodeCopied"):A("chatCodeCopy"),children:[n?f.jsx(Ri,{className:"h-3.5 w-3.5"}):f.jsx(To,{className:"h-3.5 w-3.5"}),f.jsx("span",{children:n?A("chatCodeCopied"):A("chatCodeCopy")})]})]}),f.jsx("pre",{children:f.jsx("code",{className:e,children:s})})]})}function Kp(e){return e==="user"?A("chatRoleUser"):e==="assistant"?A("chatRoleAssistant"):e==="tool"?A("chatRoleTool"):e==="system"?A("chatRoleSystem"):A("chatRoleMessage")}function Vp(e){const t=e.toLowerCase();return t.includes("exec")||t.includes("shell")||t.includes("command")?f.jsx(Ao,{className:"h-3.5 w-3.5"}):t.includes("search")?f.jsx(Fn,{className:"h-3.5 w-3.5"}):t.includes("fetch")||t.includes("http")||t.includes("web")?f.jsx(Eo,{className:"h-3.5 w-3.5"}):t.includes("read")||t.includes("file")?f.jsx(Mo,{className:"h-3.5 w-3.5"}):t.includes("message")||t.includes("send")?f.jsx(No,{className:"h-3.5 w-3.5"}):t.includes("cron")||t.includes("schedule")?f.jsx(Po,{className:"h-3.5 w-3.5"}):f.jsx(Ii,{className:"h-3.5 w-3.5"})}function pn({role:e}){return e==="user"?f.jsx("div",{className:"h-8 w-8 rounded-full bg-primary text-white flex items-center justify-center shadow-sm",children:f.jsx(Ro,{className:"h-4 w-4"})}):e==="assistant"?f.jsx("div",{className:"h-8 w-8 rounded-full bg-slate-900 text-white flex items-center justify-center shadow-sm",children:f.jsx(Ci,{className:"h-4 w-4"})}):f.jsx("div",{className:"h-8 w-8 rounded-full bg-amber-100 text-amber-700 flex items-center justify-center shadow-sm",children:f.jsx(Ii,{className:"h-4 w-4"})})}function qp({text:e,role:t}){const n=t==="user",r=R.useMemo(()=>({a:({href:i,children:s,...o})=>{const a=xi(i);if(!a)return f.jsx("span",{className:"chat-link-invalid",children:s});const l=Up(a);return f.jsx("a",{...o,href:a,target:l?"_blank":void 0,rel:l?"noreferrer noopener":void 0,children:s})},table:({children:i,...s})=>f.jsx("div",{className:"chat-table-wrap",children:f.jsx("table",{...s,children:i})}),input:({type:i,checked:s,...o})=>i!=="checkbox"?f.jsx("input",{...o,type:i}):f.jsx("input",{...o,type:"checkbox",checked:s,readOnly:!0,disabled:!0,className:"chat-task-checkbox"}),img:({src:i,alt:s,...o})=>{const a=xi(i);return a?f.jsx("img",{...o,src:a,alt:s||"",loading:"lazy",decoding:"async"}):null},code:({className:i,children:s,...o})=>{const a=String(s??"");return!i&&!a.includes(`
|
|
35
|
+
`)?f.jsx("code",{...o,className:te("chat-inline-code",i),children:s}):f.jsx(Hp,{className:i,children:s})}}),[]);return f.jsx("div",{className:te("chat-markdown",n?"chat-markdown-user":"chat-markdown-assistant"),children:f.jsx(wh,{skipHtml:!0,remarkPlugins:[Op],components:r,children:zp(e)})})}function Wp({card:e}){var o;const t=e.kind==="call"?A("chatToolCall"):A("chatToolResult"),n=((o=e.text)==null?void 0:o.trim())??"",r=n.length>gi||n.includes(`
|
|
36
|
+
`),i=r?`${n.slice(0,gi)}…`:n,s=e.kind==="result"||e.hasResult;return f.jsxs("div",{className:"rounded-xl border border-amber-200/80 bg-amber-50/60 px-3 py-2.5",children:[f.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-amber-800 font-semibold",children:[Vp(e.name),f.jsx("span",{children:t}),f.jsx("span",{className:"font-mono text-[11px] text-amber-900/80",children:e.name})]}),e.detail&&f.jsx("div",{className:"mt-1 text-[11px] text-amber-800/90 font-mono break-words",children:e.detail}),s&&f.jsx("div",{className:"mt-2",children:n?r?f.jsxs("details",{className:"group",children:[f.jsx("summary",{className:"cursor-pointer text-[11px] text-amber-700",children:A("chatToolOutput")}),f.jsx("pre",{className:"mt-2 rounded-lg border border-amber-200 bg-amber-100/40 p-2 text-[11px] whitespace-pre-wrap break-words text-amber-900",children:n})]}):f.jsx("pre",{className:"rounded-lg border border-amber-200 bg-amber-100/40 p-2 text-[11px] whitespace-pre-wrap break-words text-amber-900",children:i}):f.jsx("div",{className:"text-[11px] text-amber-700/80",children:A("chatToolNoOutput")})})]})}function Gp({reasoning:e,isUser:t}){return f.jsxs("details",{className:"mt-3",children:[f.jsx("summary",{className:te("cursor-pointer text-xs",t?"text-primary-100":"text-gray-500"),children:A("chatReasoning")}),f.jsx("pre",{className:te("mt-2 text-[11px] whitespace-pre-wrap break-words rounded-lg p-2",t?"bg-primary-700/60":"bg-gray-100"),children:e})]})}function Xp(e){var n;const t=(n=e.meta)==null?void 0:n.timestamp;return t&&Number.isFinite(Date.parse(t))?t:new Date().toISOString()}function Qp({message:e}){const t=e.role,n=t==="user",r=e.parts.map((i,s)=>{if(i.type==="text"){const o=i.text.trim();return o?f.jsx(qp,{text:o,role:t},`text-${s}`):null}if(i.type==="reasoning"){const o=i.reasoning.trim();return o?f.jsx(Gp,{reasoning:o,isUser:n},`reasoning-${s}`):null}if(i.type==="tool-invocation"){const o=i.toolInvocation,a=Ta(o.parsedArgs??o.args),l=typeof o.error=="string"&&o.error.trim()?o.error.trim():o.result!=null?Aa(o.result).trim():"",u=o.status==="result"||o.status==="error"||o.status==="cancelled",d={kind:o.status==="result"&&!o.args?"result":"call",name:o.toolName,detail:a,text:l||void 0,callId:o.toolCallId||void 0,hasResult:u};return f.jsx("div",{className:"mt-0.5",children:f.jsx(Wp,{card:d})},`tool-${o.toolCallId||s}`)}return null}).filter(i=>i!==null);return f.jsx("div",{className:te("inline-block w-fit max-w-full rounded-2xl border px-4 py-3 shadow-sm",n?"bg-primary text-white border-primary":t==="assistant"?"bg-white text-gray-900 border-gray-200":"bg-orange-50/70 text-gray-900 border-orange-200/80"),children:f.jsx("div",{className:"space-y-2",children:r})})}function Yp({uiMessages:e,isSending:t,className:n}){const r=e.some(i=>{var s;return((s=i.meta)==null?void 0:s.status)==="streaming"});return f.jsxs("div",{className:te("space-y-5",n),children:[e.map(i=>{const{role:s}=i,o=s==="user",a=Xp(i);return f.jsxs("div",{className:te("flex gap-3",o?"justify-end":"justify-start"),children:[!o&&f.jsx(pn,{role:s}),f.jsxs("div",{className:te("max-w-[92%] w-fit space-y-2",o&&"flex flex-col items-end"),children:[f.jsx(Qp,{message:i}),f.jsxs("div",{className:te("text-[11px] px-1",o?"text-primary-300":"text-gray-400"),children:[Kp(s)," · ",zt(a)]})]}),o&&f.jsx(pn,{role:s})]},i.id)}),t&&!r&&f.jsxs("div",{className:"flex gap-3 justify-start",children:[f.jsx(pn,{role:"assistant"}),f.jsx("div",{className:"rounded-2xl border border-gray-200 bg-white px-4 py-3 text-sm text-gray-500 shadow-sm",children:A("chatTyping")})]})]})}const Jp=[{icon:jo,titleKey:"chatWelcomeCapability1Title",descKey:"chatWelcomeCapability1Desc"},{icon:Bn,titleKey:"chatWelcomeCapability2Title",descKey:"chatWelcomeCapability2Desc"},{icon:zn,titleKey:"chatWelcomeCapability3Title",descKey:"chatWelcomeCapability3Desc"}];function Zp({onCreateSession:e}){return f.jsx("div",{className:"h-full flex items-center justify-center p-8",children:f.jsxs("div",{className:"max-w-lg w-full text-center",children:[f.jsx("div",{className:"mx-auto mb-6 h-16 w-16 rounded-2xl bg-primary/10 flex items-center justify-center",children:f.jsx(Ci,{className:"h-8 w-8 text-primary"})}),f.jsx("h2",{className:"text-xl font-semibold text-gray-900 mb-2",children:A("chatWelcomeTitle")}),f.jsx("p",{className:"text-sm text-gray-500 mb-8",children:A("chatWelcomeSubtitle")}),f.jsx("div",{className:"grid grid-cols-3 gap-3",children:Jp.map(t=>{const n=t.icon;return f.jsxs("button",{onClick:e,className:"rounded-2xl border border-gray-200 bg-white p-4 text-left shadow-card hover:shadow-card-hover transition-shadow cursor-pointer",children:[f.jsx("div",{className:"h-9 w-9 rounded-xl bg-primary/8 flex items-center justify-center mb-3",children:f.jsx(n,{className:"h-4.5 w-4.5 text-primary"})}),f.jsx("div",{className:"text-sm font-semibold text-gray-900 mb-1",children:A(t.titleKey)}),f.jsx("div",{className:"text-[11px] text-gray-500 leading-relaxed",children:A(t.descKey)})]},t.titleKey)})})]})})}const em=920;function tm(e){const t=/^\/([^\s]*)$/.exec(e);return t?(t[1]??"").trim().toLowerCase():null}function At(e){return(e??"").trim().toLowerCase()}function yi(e,t){if(!e||!t)return!1;let n=0;for(const r of t)if(r===e[n]&&(n+=1,n>=e.length))return!0;return!1}function nm(e,t){const n=At(t);if(!n)return 1;const r=At(e.spec),i=At(e.label||e.spec),s=At(`${e.descriptionZh??""} ${e.description??""}`),o=i.split(/[\s/_-]+/).filter(Boolean);return r===n?1200:i===n?1150:r.startsWith(n)?1e3:i.startsWith(n)?950:o.some(a=>a.startsWith(n))?900:r.includes(n)?800:i.includes(n)?760:s.includes(n)?500:yi(n,i)||yi(n,r)?300:0}function rm(e,t){const n=new Intl.Collator(void 0,{sensitivity:"base",numeric:!0});return e.map((i,s)=>({record:i,score:nm(i,t),order:s})).filter(i=>i.score>0).sort((i,s)=>{if(s.score!==i.score)return s.score-i.score;const o=(i.record.label||i.record.spec).trim(),a=(s.record.label||s.record.spec).trim(),l=n.compare(o,a);return l!==0?l:i.order-s.order}).map(i=>i.record).map(i=>({kind:"skill",key:`skill:${i.spec}`,title:i.label||i.spec,subtitle:A("chatSlashTypeSkill"),description:(i.descriptionZh??i.description??"").trim()||A("chatSkillsPickerNoDescription"),detailLines:[`${A("chatSlashSkillSpec")}: ${i.spec}`],skillSpec:i.spec}))}function im(e){const[t,n]=R.useState(0),[r,i]=R.useState(!1),[s,o]=R.useState(null),a=R.useRef(null),l=R.useRef(null),u=R.useMemo(()=>tm(e.draft),[e.draft]),d=e.draft.startsWith("/"),c=u??"",p=R.useMemo(()=>rm(e.skillRecords,c),[c,e.skillRecords]),h=R.useMemo(()=>[...p],[p]),m=u!==null&&!r,x=h[t]??null,S=e.isSkillsLoading,g=s?Math.min(s,em):void 0;R.useEffect(()=>{const T=a.current;if(!T||typeof ResizeObserver>"u")return;const N=()=>{o(T.getBoundingClientRect().width)};N();const w=new ResizeObserver(()=>N());return w.observe(T),()=>w.disconnect()},[]),R.useEffect(()=>{if(!m||h.length===0){n(0);return}n(T=>T<0?0:T>=h.length?h.length-1:T)},[m,h.length]),R.useEffect(()=>{!d&&r&&i(!1)},[r,d]),R.useEffect(()=>{if(!m||S||h.length===0)return;const T=l.current;if(!T)return;const N=T.querySelector(`[data-slash-index="${t}"]`);N==null||N.scrollIntoView({block:"nearest",inline:"nearest"})},[t,S,m,h.length]);const v=R.useCallback(T=>{T.kind==="skill"&&T.skillSpec&&(e.selectedSkills.includes(T.skillSpec)||e.onSelectedSkillsChange([...e.selectedSkills,T.skillSpec]),e.onDraftChange(""),i(!1))},[e]),k=R.useCallback(T=>{if(m&&!T.nativeEvent.isComposing&&(T.key===" "||T.code==="Space")&&i(!0),m&&h.length>0){if(T.key==="ArrowDown"){T.preventDefault(),n(N=>(N+1)%h.length);return}if(T.key==="ArrowUp"){T.preventDefault(),n(N=>(N-1+h.length)%h.length);return}if(T.key==="Enter"&&!T.shiftKey||T.key==="Tab"){T.preventDefault();const N=h[t];N&&v(N);return}}if(T.key==="Escape"){if(m){T.preventDefault(),i(!0);return}if(e.isSending&&e.canStopGeneration){T.preventDefault(),e.onStop();return}}T.key==="Enter"&&!T.shiftKey&&(T.preventDefault(),e.onSend())},[t,v,m,e,h]);return{slashAnchorRef:a,slashListRef:l,isSlashPanelOpen:m,isSlashPanelLoading:S,resolvedSlashPanelWidth:g,skillSlashItems:p,activeSlashIndex:t,activeSlashItem:x,onSelectSlashItem:v,onSlashPanelOpenChange:T=>{T||i(!0)},onSetActiveSlashIndex:n,onTextareaKeyDown:k}}function sm(e){const t=e.selectedSkills.map(r=>{const i=e.skillRecords.find(s=>s.spec===r);return{spec:r,label:(i==null?void 0:i.label)||r}}),n=im({draft:e.draft,onDraftChange:e.onDraftChange,onSend:e.onSend,onStop:e.onStop,isSending:e.isSending,canStopGeneration:e.canStopGeneration,isSkillsLoading:e.isSkillsLoading,selectedSkills:e.selectedSkills,onSelectedSkillsChange:e.onSelectedSkillsChange,skillRecords:e.skillRecords});return{selectedSkillRecords:t,...n}}var Wt="Popover",[Xs]=Fo(Wt,[Ai]),wt=Ai(),[om,Fe]=Xs(Wt),Qs=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:s,modal:o=!1}=e,a=wt(t),l=R.useRef(null),[u,d]=R.useState(!1),[c,p]=Lo({prop:r,defaultProp:i??!1,onChange:s,caller:Wt});return f.jsx(_o,{...a,children:f.jsx(om,{scope:t,contentId:Oo(),triggerRef:l,open:c,onOpenChange:p,onOpenToggle:R.useCallback(()=>p(h=>!h),[p]),hasCustomAnchor:u,onCustomAnchorAdd:R.useCallback(()=>d(!0),[]),onCustomAnchorRemove:R.useCallback(()=>d(!1),[]),modal:o,children:n})})};Qs.displayName=Wt;var Ys="PopoverAnchor",Js=R.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=Fe(Ys,n),s=wt(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:a}=i;return R.useEffect(()=>(o(),()=>a()),[o,a]),f.jsx(Ti,{...s,...r,ref:t})});Js.displayName=Ys;var Zs="PopoverTrigger",eo=R.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=Fe(Zs,n),s=wt(n),o=Ei(t,i.triggerRef),a=f.jsx(Mi.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":so(i.open),...r,ref:o,onClick:ut(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?a:f.jsx(Ti,{asChild:!0,...s,children:a})});eo.displayName=Zs;var ar="PopoverPortal",[am,lm]=Xs(ar,{forceMount:void 0}),to=e=>{const{__scopePopover:t,forceMount:n,children:r,container:i}=e,s=Fe(ar,t);return f.jsx(am,{scope:t,forceMount:n,children:f.jsx(Pi,{present:n||s.open,children:f.jsx(Do,{asChild:!0,container:i,children:r})})})};to.displayName=ar;var Ze="PopoverContent",no=R.forwardRef((e,t)=>{const n=lm(Ze,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,s=Fe(Ze,e.__scopePopover);return f.jsx(Pi,{present:r||s.open,children:s.modal?f.jsx(cm,{...i,ref:t}):f.jsx(dm,{...i,ref:t})})});no.displayName=Ze;var um=$o("PopoverContent.RemoveScroll"),cm=R.forwardRef((e,t)=>{const n=Fe(Ze,e.__scopePopover),r=R.useRef(null),i=Ei(t,r),s=R.useRef(!1);return R.useEffect(()=>{const o=r.current;if(o)return zo(o)},[]),f.jsx(Bo,{as:um,allowPinchZoom:!0,children:f.jsx(ro,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ut(e.onCloseAutoFocus,o=>{var a;o.preventDefault(),s.current||(a=n.triggerRef.current)==null||a.focus()}),onPointerDownOutside:ut(e.onPointerDownOutside,o=>{const a=o.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0,u=a.button===2||l;s.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:ut(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})})}),dm=R.forwardRef((e,t)=>{const n=Fe(Ze,e.__scopePopover),r=R.useRef(!1),i=R.useRef(!1);return f.jsx(ro,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var o,a;(o=e.onCloseAutoFocus)==null||o.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:s=>{var l,u;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const o=s.target;((u=n.triggerRef.current)==null?void 0:u.contains(o))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&i.current&&s.preventDefault()}})}),ro=R.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,disableOutsidePointerEvents:o,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:u,onInteractOutside:d,...c}=e,p=Fe(Ze,n),h=wt(n);return Uo(),f.jsx(Ho,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s,children:f.jsx(Ko,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:d,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:u,onDismiss:()=>p.onOpenChange(!1),children:f.jsx(Vo,{"data-state":so(p.open),role:"dialog",id:p.contentId,...h,...c,ref:t,style:{...c.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),io="PopoverClose",hm=R.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=Fe(io,n);return f.jsx(Mi.button,{type:"button",...r,ref:t,onClick:ut(e.onClick,()=>i.onOpenChange(!1))})});hm.displayName=io;var fm="PopoverArrow",pm=R.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=wt(n);return f.jsx(qo,{...i,...r,ref:t})});pm.displayName=fm;function so(e){return e?"open":"closed"}var mm=Qs,gm=Js,xm=eo,ym=to,oo=no;const ao=mm,bm=xm,Sm=gm,lr=R.forwardRef(({className:e,sideOffset:t=8,align:n="start",...r},i)=>f.jsx(ym,{children:f.jsx(oo,{ref:i,sideOffset:t,align:n,className:te("z-[var(--z-popover,50)] w-72 overflow-hidden rounded-2xl border border-gray-200/50 bg-white p-4 shadow-lg animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...r})}));lr.displayName=oo.displayName;function km({records:e,isLoading:t=!1,selectedSkills:n,onSelectedSkillsChange:r}){const{language:i}=Li(),[s,o]=R.useState(""),a=R.useMemo(()=>new Set(n),[n]),l=n.length,u=R.useMemo(()=>{const c=s.trim().toLowerCase();return c?e.filter(p=>[p.label,p.spec,p.description,p.descriptionZh].filter(m=>typeof m=="string"&&m.trim().length>0).join(" ").toLowerCase().includes(c)):e},[s,e]),d=c=>{var h;const p=(h=c.spec)==null?void 0:h.trim();if(p){if(a.has(p)){r(n.filter(m=>m!==p));return}r([...n,p])}};return f.jsxs(ao,{children:[f.jsx(bm,{asChild:!0,children:f.jsxs("button",{type:"button",className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium text-gray-600 hover:bg-gray-100 hover:text-gray-900 transition-colors",children:[f.jsx(Bn,{className:"h-4 w-4"}),f.jsx("span",{children:A("chatSkillsPickerTitle")}),l>0&&f.jsx("span",{className:"ml-0.5 min-w-[18px] h-[18px] flex items-center justify-center rounded-full bg-primary/10 text-primary text-[10px] font-semibold",children:l})]})}),f.jsxs(lr,{side:"top",align:"start",className:"w-[360px] p-0",children:[f.jsxs("div",{className:"space-y-2 border-b border-gray-100 px-4 py-3",children:[f.jsx("div",{className:"text-sm font-semibold text-gray-900",children:A("chatSkillsPickerTitle")}),f.jsxs("div",{className:"relative",children:[f.jsx(Fn,{className:"pointer-events-none absolute left-3 top-2.5 h-3.5 w-3.5 text-gray-400"}),f.jsx(Un,{value:s,onChange:c=>o(c.target.value),placeholder:A("chatSkillsPickerSearchPlaceholder"),className:"h-8 rounded-lg pl-8 text-xs"})]})]}),f.jsx("div",{className:"max-h-[320px] overflow-y-auto custom-scrollbar",children:t?f.jsx("div",{className:"p-4 text-xs text-gray-500",children:A("sessionsLoading")}):u.length===0?f.jsx("div",{className:"p-4 text-xs text-gray-500 text-center",children:A("chatSkillsPickerEmpty")}):f.jsx("div",{className:"py-1",children:u.map(c=>{var p,h;return f.jsxs("button",{type:"button",onClick:()=>d(c),className:"flex w-full items-center gap-3 px-4 py-2.5 text-left transition-colors hover:bg-gray-50",children:[f.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-gray-100 text-gray-500",children:f.jsx(Wo,{className:"h-4 w-4"})}),f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsx("span",{className:"truncate text-sm text-gray-900",children:c.label||c.spec}),c.origin==="builtin"&&f.jsx("span",{className:"shrink-0 text-[10px] bg-primary/10 text-primary px-1.5 py-0.5 rounded-full font-medium",children:A("chatSkillsPickerOfficial")})]}),f.jsx("div",{className:"mt-0.5 truncate text-xs text-gray-500",children:((p=i==="zh"?c.descriptionZh:c.description)==null?void 0:p.trim())||((h=c.description)==null?void 0:h.trim())||A("chatSkillsPickerNoDescription")})]}),f.jsx("div",{className:"ml-3 shrink-0",children:f.jsx("span",{className:a.has(c.spec)?"inline-flex h-5 w-5 items-center justify-center rounded-full bg-primary text-white":"inline-flex h-5 w-5 items-center justify-center rounded-full border border-gray-300 bg-white",children:a.has(c.spec)&&f.jsx(Ri,{className:"h-3 w-3"})})})]},c.spec)})})}),f.jsx("div",{className:"px-4 py-2.5 border-t border-gray-100",children:f.jsxs(xn,{to:"/marketplace/skills",className:"inline-flex items-center gap-1.5 text-xs font-medium text-primary hover:text-primary/80 transition-colors",children:[A("chatSkillsPickerManage"),f.jsx(Go,{className:"h-3 w-3"})]})})]})]})}const wm={isProviderStateResolved:!1,draft:"",pendingSessionType:"native",defaultSessionType:"native",canStopGeneration:!1,stopDisabledReason:null,sendError:null,isSending:!1,modelOptions:[],selectedModel:"",sessionTypeOptions:[],selectedSessionType:void 0,stopSupported:!1,stopReason:void 0,canEditSessionType:!1,sessionTypeUnavailable:!1,skillRecords:[],isSkillsLoading:!1,selectedSkills:[]},ie=Ft(e=>({snapshot:wm,setSnapshot:t=>e(n=>({snapshot:{...n.snapshot,...t}}))}));function vm(){return f.jsx(_i,{children:f.jsxs(Oi,{children:[f.jsx(Di,{asChild:!0,children:f.jsx("button",{type:"button",disabled:!0,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium text-gray-400 cursor-not-allowed",children:f.jsx(Xo,{className:"h-4 w-4"})})}),f.jsx(Fi,{side:"top",children:f.jsx("p",{className:"text-xs",children:A("chatInputAttachComingSoon")})})]})})}function Cm(e){return f.jsxs(ft,{value:e.hasModelOptions?e.selectedModel:void 0,onValueChange:e.onSelectedModelChange,disabled:!e.hasModelOptions,children:[f.jsx(pt,{className:"h-8 w-auto min-w-[220px] rounded-lg border-0 bg-transparent shadow-none text-xs font-medium text-gray-600 hover:bg-gray-100 focus:ring-0 px-3",children:e.selectedModelOption?f.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-left",children:[f.jsx(Qo,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),f.jsxs("span",{className:"truncate text-xs font-semibold text-gray-700",children:[e.selectedModelOption.providerLabel,"/",e.selectedModelOption.modelLabel]})]}):e.isModelOptionsLoading?f.jsx("div",{className:"h-3 w-24 animate-pulse rounded bg-gray-200"}):f.jsx($n,{placeholder:A("chatSelectModel")})}),f.jsxs(mt,{className:"w-[320px]",children:[e.modelOptions.length===0&&(e.isModelOptionsLoading?f.jsxs("div",{className:"space-y-2 px-3 py-2",children:[f.jsx("div",{className:"h-3 w-36 animate-pulse rounded bg-gray-200"}),f.jsx("div",{className:"h-3 w-28 animate-pulse rounded bg-gray-200"}),f.jsx("div",{className:"h-3 w-32 animate-pulse rounded bg-gray-200"})]}):f.jsx("div",{className:"px-3 py-2 text-xs text-gray-500",children:A("chatModelNoOptions")})),e.modelOptions.map(t=>f.jsx(He,{value:t.value,className:"py-2",children:f.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[f.jsx("span",{className:"truncate text-xs font-semibold text-gray-800",children:t.modelLabel}),f.jsx("span",{className:"truncate text-[11px] text-gray-500",children:t.providerLabel})]})},t.value))]})]})}function Im(e){var t;return f.jsxs("div",{className:"flex flex-col items-end gap-1",children:[((t=e.sendError)==null?void 0:t.trim())&&f.jsx("div",{className:"max-w-[420px] text-right text-[11px] text-red-600",children:e.sendError}),f.jsx("div",{className:"flex items-center gap-2",children:e.isSending?e.canStopGeneration?f.jsx(Pe,{size:"icon",variant:"outline",className:"h-8 w-8 rounded-full",onClick:()=>void e.onStop(),children:f.jsx(pr,{className:"h-3 w-3 fill-current"})}):f.jsx(_i,{children:f.jsxs(Oi,{children:[f.jsx(Di,{asChild:!0,children:f.jsx("span",{children:f.jsx(Pe,{size:"icon",variant:"outline",className:"h-8 w-8 rounded-full",disabled:!0,children:f.jsx(pr,{className:"h-3 w-3 fill-current"})})})}),f.jsx(Fi,{side:"top",children:f.jsx("p",{className:"text-xs",children:e.resolvedStopHint})})]})}):f.jsx(Pe,{size:"icon",className:"h-8 w-8 rounded-full",onClick:()=>void e.onSend(),disabled:e.draft.trim().length===0||!e.hasModelOptions||e.sessionTypeUnavailable,children:f.jsx(Yo,{className:"h-5 w-5"})})})]})}function Rm(e){return e.shouldShowSessionTypeSelector?f.jsxs(ft,{value:e.selectedSessionType,onValueChange:e.onSelectedSessionTypeChange,disabled:!e.canEditSessionType,children:[f.jsx(pt,{className:"h-8 w-auto min-w-[140px] rounded-lg border-0 bg-transparent shadow-none text-xs font-medium text-gray-600 hover:bg-gray-100 focus:ring-0 px-3",children:e.selectedSessionTypeOption?f.jsx("span",{className:"truncate text-xs font-semibold text-gray-700",children:e.selectedSessionTypeOption.label}):f.jsx($n,{placeholder:A("chatSessionTypeLabel")})}),f.jsx(mt,{className:"w-[220px]",children:e.sessionTypeOptions.map(t=>f.jsx(He,{value:t.value,className:"py-2",children:f.jsx("span",{className:"truncate text-xs font-semibold text-gray-800",children:t.label})},t.value))})]}):null}function Tm(){var l;const e=Bt(),t=ie(u=>u.snapshot),n=t.modelOptions.length>0,r=!t.isProviderStateResolved&&!n,i=t.modelOptions.find(u=>u.value===t.selectedModel),s=t.canEditSessionType&&(t.sessionTypeOptions.length>1||!!(t.selectedSessionType&&t.selectedSessionType!=="native")),o=t.sessionTypeOptions.find(u=>u.value===t.selectedSessionType)??(t.selectedSessionType?{value:t.selectedSessionType,label:t.selectedSessionType}:null),a=t.stopDisabledReason==="__preparing__"?A("chatStopPreparing"):((l=t.stopDisabledReason)==null?void 0:l.trim())||A("chatStopUnavailable");return f.jsxs("div",{className:"flex items-center justify-between px-3 pb-3",children:[f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(km,{records:t.skillRecords,isLoading:t.isSkillsLoading,selectedSkills:t.selectedSkills,onSelectedSkillsChange:e.chatInputManager.selectSkills}),f.jsx(Rm,{shouldShowSessionTypeSelector:s,selectedSessionType:t.selectedSessionType,selectedSessionTypeOption:o,sessionTypeOptions:t.sessionTypeOptions,onSelectedSessionTypeChange:e.chatInputManager.selectSessionType,canEditSessionType:t.canEditSessionType}),f.jsx(Cm,{modelOptions:t.modelOptions,selectedModel:t.selectedModel,selectedModelOption:i,onSelectedModelChange:e.chatInputManager.selectModel,isModelOptionsLoading:r,hasModelOptions:n}),f.jsx(vm,{})]}),f.jsx(Im,{sendError:t.sendError,draft:t.draft,hasModelOptions:n,sessionTypeUnavailable:t.sessionTypeUnavailable,isSending:t.isSending,canStopGeneration:t.canStopGeneration,resolvedStopHint:a,onSend:e.chatInputManager.send,onStop:e.chatInputManager.stop})]})}function Am(e){return!e.isModelOptionsLoading&&!e.isModelOptionsEmpty?null:e.isModelOptionsLoading?f.jsx("div",{className:"px-4 pb-2",children:f.jsxs("div",{className:"inline-flex items-center gap-2 rounded-lg border border-gray-200 bg-gray-50 px-3 py-2",children:[f.jsx("span",{className:"h-3 w-28 animate-pulse rounded bg-gray-200"}),f.jsx("span",{className:"h-3 w-16 animate-pulse rounded bg-gray-200"})]})}):f.jsx("div",{className:"px-4 pb-2",children:f.jsxs("div",{className:"inline-flex items-center gap-2 rounded-lg border border-amber-200 bg-amber-50 px-3 py-1.5 text-xs text-amber-800",children:[f.jsx("span",{children:A("chatModelNoOptions")}),f.jsx("button",{type:"button",onClick:e.onGoToProviders,className:"font-semibold text-amber-900 underline-offset-2 hover:underline",children:A("chatGoConfigureProvider")})]})})}function Em(e){return e.records.length===0?null:f.jsx("div",{className:"px-4 pb-2",children:f.jsx("div",{className:"flex flex-wrap items-center gap-2",children:e.records.map(t=>f.jsxs("button",{type:"button",onClick:()=>e.onSelectedSkillsChange(e.selectedSkills.filter(n=>n!==t.spec)),className:"inline-flex max-w-[200px] items-center gap-1.5 rounded-full bg-primary/10 px-2.5 py-1 text-xs font-medium text-primary",children:[f.jsx("span",{className:"truncate",children:t.label}),f.jsx(Jo,{className:"h-3 w-3 shrink-0"})]},t.spec))})})}function Mm({slashAnchorRef:e,slashListRef:t,isSlashPanelOpen:n,isSlashPanelLoading:r,resolvedSlashPanelWidth:i,skillSlashItems:s,activeSlashIndex:o,activeSlashItem:a,onSelectSlashItem:l,onSlashPanelOpenChange:u,onSetActiveSlashIndex:d}){return f.jsxs(ao,{open:n,onOpenChange:u,children:[f.jsx(Sm,{asChild:!0,children:f.jsx("div",{ref:e,className:"pointer-events-none absolute left-3 right-3 bottom-full h-0"})}),f.jsx(lr,{side:"top",align:"start",sideOffset:10,className:"z-[70] max-w-[calc(100vw-1.5rem)] overflow-hidden rounded-2xl border border-gray-200 bg-white/95 p-0 shadow-2xl backdrop-blur-md",onOpenAutoFocus:c=>c.preventDefault(),style:i?{width:`${i}px`}:void 0,children:f.jsxs("div",{className:"grid min-h-[240px] grid-cols-[minmax(260px,340px)_minmax(0,1fr)]",children:[f.jsx("div",{ref:t,className:"max-h-[320px] overflow-y-auto border-r border-gray-200 p-3 custom-scrollbar",children:r?f.jsx("div",{className:"p-2 text-xs text-gray-500",children:A("chatSlashLoading")}):f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"mb-2 px-2 text-[11px] font-semibold uppercase tracking-wide text-gray-500",children:A("chatSlashSectionSkills")}),s.length===0?f.jsx("div",{className:"px-2 text-xs text-gray-400",children:A("chatSlashNoResult")}):f.jsx("div",{className:"space-y-1",children:s.map((c,p)=>{const h=p===o;return f.jsxs("button",{type:"button","data-slash-index":p,onMouseEnter:()=>d(p),onClick:()=>l(c),className:`flex w-full items-start gap-2 rounded-lg px-2 py-1.5 text-left transition ${h?"bg-gray-100 text-gray-900":"text-gray-700 hover:bg-gray-50"}`,children:[f.jsx("span",{className:"truncate text-xs font-semibold",children:c.title}),f.jsx("span",{className:"truncate text-xs text-gray-500",children:c.subtitle})]},c.key)})})]})}),f.jsx("div",{className:"p-4",children:a?f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"inline-flex rounded-full bg-primary/10 px-2 py-0.5 text-[11px] font-semibold text-primary",children:a.subtitle}),f.jsx("span",{className:"text-sm font-semibold text-gray-900",children:a.title})]}),f.jsx("p",{className:"text-xs leading-5 text-gray-600",children:a.description}),f.jsx("div",{className:"space-y-1",children:a.detailLines.map(c=>f.jsx("div",{className:"rounded-md bg-gray-50 px-2 py-1 text-[11px] text-gray-600",children:c},c))}),f.jsx("div",{className:"pt-1 text-[11px] text-gray-500",children:A("chatSlashSkillHint")})]}):f.jsx("div",{className:"text-xs text-gray-500",children:A("chatSlashHint")})})]})})]})}function Nm(){const e=Bt(),t=ie(l=>l.snapshot),n=t.modelOptions.length>0,r=!t.isProviderStateResolved&&!n,i=t.isProviderStateResolved&&!n,s=(r||i)&&!t.isSending||t.sessionTypeUnavailable,o=r?"":n?A("chatInputPlaceholder"):A("chatModelNoOptions"),a=sm({draft:t.draft,onDraftChange:e.chatInputManager.setDraft,onSend:e.chatInputManager.send,onStop:e.chatInputManager.stop,canStopGeneration:t.canStopGeneration,isSending:t.isSending,skillRecords:t.skillRecords,isSkillsLoading:t.isSkillsLoading,selectedSkills:t.selectedSkills,onSelectedSkillsChange:e.chatInputManager.selectSkills});return f.jsx("div",{className:"border-t border-gray-200/80 bg-white p-4",children:f.jsx("div",{className:"mx-auto w-full max-w-[min(1120px,100%)]",children:f.jsxs("div",{className:"rounded-2xl border border-gray-200 bg-white shadow-card overflow-hidden",children:[f.jsxs("div",{className:"relative",children:[f.jsx("textarea",{value:t.draft,onChange:l=>e.chatInputManager.setDraft(l.target.value),disabled:s,onKeyDown:a.onTextareaKeyDown,placeholder:o,className:"w-full min-h-[68px] max-h-[220px] resize-y bg-transparent outline-none text-sm px-4 py-3 text-gray-800 placeholder:text-gray-400"}),f.jsx(Mm,{slashAnchorRef:a.slashAnchorRef,slashListRef:a.slashListRef,isSlashPanelOpen:a.isSlashPanelOpen,isSlashPanelLoading:a.isSlashPanelLoading,resolvedSlashPanelWidth:a.resolvedSlashPanelWidth,skillSlashItems:a.skillSlashItems,activeSlashIndex:a.activeSlashIndex,activeSlashItem:a.activeSlashItem,onSelectSlashItem:a.onSelectSlashItem,onSlashPanelOpenChange:a.onSlashPanelOpenChange,onSetActiveSlashIndex:a.onSetActiveSlashIndex})]}),f.jsx(Am,{isModelOptionsLoading:r,isModelOptionsEmpty:i,onGoToProviders:e.chatInputManager.goToProviders}),f.jsx(Em,{records:a.selectedSkillRecords,selectedSkills:t.selectedSkills,onSelectedSkillsChange:e.chatInputManager.selectSkills}),f.jsx(Tm,{})]})})})}const Pm={isProviderStateResolved:!1,modelOptions:[],sessionTypeUnavailable:!1,sessionTypeUnavailableMessage:null,selectedSessionKey:null,sessionDisplayName:void 0,canDeleteSession:!1,isDeletePending:!1,threadRef:null,isHistoryLoading:!1,uiMessages:[],isSending:!1,isAwaitingAssistantOutput:!1},lt=Ft(e=>({snapshot:Pm,setSnapshot:t=>e(n=>({snapshot:{...n.snapshot,...t}}))})),jm=10;function Lm(){return f.jsxs("section",{className:"flex-1 min-h-0 flex flex-col overflow-hidden bg-gradient-to-b from-gray-50/60 to-white",children:[f.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto custom-scrollbar",children:f.jsx("div",{className:"mx-auto w-full max-w-[min(1120px,100%)] px-6 py-5",children:f.jsxs("div",{className:"space-y-4",children:[f.jsx("div",{className:"h-6 w-48 animate-pulse rounded bg-gray-200"}),f.jsx("div",{className:"h-24 w-[78%] animate-pulse rounded-2xl bg-gray-200/80"}),f.jsx("div",{className:"h-20 w-[62%] animate-pulse rounded-2xl bg-gray-200/80"}),f.jsx("div",{className:"h-28 w-[84%] animate-pulse rounded-2xl bg-gray-200/80"})]})})}),f.jsx("div",{className:"border-t border-gray-200/80 bg-white p-4",children:f.jsx("div",{className:"mx-auto w-full max-w-[min(1120px,100%)]",children:f.jsxs("div",{className:"rounded-2xl border border-gray-200 bg-white shadow-card p-4",children:[f.jsx("div",{className:"h-16 w-full animate-pulse rounded-xl bg-gray-200/80"}),f.jsxs("div",{className:"mt-3 flex items-center justify-between",children:[f.jsx("div",{className:"h-8 w-36 animate-pulse rounded-lg bg-gray-200/80"}),f.jsx("div",{className:"h-8 w-20 animate-pulse rounded-lg bg-gray-200/80"})]})]})})})]})}function _m(){var m;const e=Bt(),t=lt(x=>x.snapshot),n=R.useRef(null),r=t.threadRef??n,i=R.useRef(!0),s=R.useRef(!1),o=R.useRef(null),a=R.useRef(!1),l=!t.selectedSessionKey&&t.uiMessages.length===0&&!t.isSending,u=t.modelOptions.length>0,d=t.isProviderStateResolved&&!u,c=t.isHistoryLoading&&t.uiMessages.length===0&&!t.isSending&&!t.isAwaitingAssistantOutput,p=R.useCallback(()=>{const x=r.current;x&&(s.current=!0,x.scrollTop=x.scrollHeight)},[r]),h=R.useCallback(()=>{if(s.current){s.current=!1;return}const x=r.current;if(!x)return;const S=x.scrollHeight-x.scrollTop-x.clientHeight;i.current=S<=jm},[r]);return R.useEffect(()=>{o.current!==t.selectedSessionKey&&(o.current=t.selectedSessionKey,i.current=!0,a.current=!0)},[t.selectedSessionKey]),R.useLayoutEffect(()=>{a.current&&(t.isHistoryLoading||t.uiMessages.length===0||(a.current=!1,p()))},[p,t.isHistoryLoading,t.uiMessages]),R.useLayoutEffect(()=>{i.current&&t.uiMessages.length!==0&&p()},[p,t.uiMessages]),t.isProviderStateResolved?f.jsxs("section",{className:"flex-1 min-h-0 flex flex-col overflow-hidden bg-gradient-to-b from-gray-50/60 to-white",children:[f.jsxs("div",{className:te("px-5 border-b border-gray-200/60 bg-white/80 backdrop-blur-sm flex items-center justify-between shrink-0 overflow-hidden transition-all duration-200",t.selectedSessionKey?"py-3 opacity-100":"h-0 py-0 opacity-0 border-b-0"),children:[f.jsx("div",{className:"min-w-0 flex-1",children:f.jsx("span",{className:"text-sm font-medium text-gray-700 truncate",children:t.sessionDisplayName||t.selectedSessionKey})}),f.jsx(Pe,{variant:"ghost",size:"icon",className:"rounded-lg shrink-0 text-gray-400 hover:text-destructive",onClick:e.chatThreadManager.deleteSession,disabled:!t.canDeleteSession||t.isDeletePending,children:f.jsx(Ni,{className:"h-4 w-4"})})]}),d&&f.jsxs("div",{className:"px-5 py-2.5 border-b border-amber-200/70 bg-amber-50/70 flex items-center justify-between gap-3 shrink-0",children:[f.jsx("span",{className:"text-xs text-amber-800",children:A("chatModelNoOptions")}),f.jsx("button",{type:"button",onClick:e.chatThreadManager.goToProviders,className:"text-xs font-semibold text-amber-900 underline-offset-2 hover:underline",children:A("chatGoConfigureProvider")})]}),t.sessionTypeUnavailable&&((m=t.sessionTypeUnavailableMessage)==null?void 0:m.trim())&&f.jsx("div",{className:"px-5 py-2.5 border-b border-amber-200/70 bg-amber-50/70 shrink-0",children:f.jsx("span",{className:"text-xs text-amber-800",children:t.sessionTypeUnavailableMessage})}),f.jsx("div",{ref:r,onScroll:h,className:"flex-1 min-h-0 overflow-y-auto custom-scrollbar",children:l?f.jsx(Zp,{onCreateSession:e.chatThreadManager.createSession}):c?f.jsx("div",{className:"h-full"}):t.uiMessages.length===0?f.jsx("div",{className:"px-5 py-5 text-sm text-gray-500",children:A("chatNoMessages")}):f.jsx("div",{className:"mx-auto w-full max-w-[min(1120px,100%)] px-6 py-5",children:f.jsx(Yp,{uiMessages:t.uiMessages,isSending:t.isSending&&t.isAwaitingAssistantOutput})})}),f.jsx(Nm,{})]}):f.jsx(Lm,{})}function bi(e){return zt(e??void 0)}function Om(e){return typeof e!="number"||!Number.isFinite(e)?"-":zt(new Date(e))}function Dm(e){if(typeof e!="number"||!Number.isFinite(e))return"-";const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.round(t/60);if(n<60)return`${n}m`;const r=Math.round(n/60);return r<24?`${r}h`:`${Math.round(r/24)}d`}function Fm(e){const t=e.schedule;return t.kind==="cron"?t.expr?`cron ${t.expr}`:"cron":t.kind==="every"?`every ${Dm(t.everyMs)}`:t.kind==="at"?`at ${Om(t.atMs)}`:"-"}function zm(e){if(!e.payload.deliver)return"-";const t=e.payload.channel??"-",n=e.payload.to??"-";return`${t}:${n}`}function Bm(e,t){const n=t.trim().toLowerCase();return n?[e.id,e.name,e.payload.message,e.payload.channel??"",e.payload.to??""].join(" ").toLowerCase().includes(n):!0}function $m(e,t){return t==="all"?!0:t==="enabled"?e.enabled:!e.enabled}function Um(){var m;const[e,t]=R.useState(""),[n,r]=R.useState("all"),i=ua({all:!0}),s=ca(),o=da(),a=ha(),{confirm:l,ConfirmDialog:u}=ji(),d=R.useMemo(()=>{var S;return(((S=i.data)==null?void 0:S.jobs)??[]).filter(g=>Bm(g,e)).filter(g=>$m(g,n))},[i.data,e,n]),c=async x=>{await l({title:`${A("cronDeleteConfirm")}?`,description:x.name?`${x.name} (${x.id})`:x.id,variant:"destructive",confirmLabel:A("delete")})&&s.mutate({id:x.id})},p=async x=>{const S=!x.enabled;await l({title:S?`${A("cronEnableConfirm")}?`:`${A("cronDisableConfirm")}?`,description:x.name?`${x.name} (${x.id})`:x.id,variant:S?"default":"destructive",confirmLabel:S?A("cronEnable"):A("cronDisable")})&&o.mutate({id:x.id,enabled:S})},h=async x=>{const S=!x.enabled;await l({title:S?`${A("cronRunForceConfirm")}?`:`${A("cronRunConfirm")}?`,description:x.name?`${x.name} (${x.id})`:x.id,confirmLabel:A("cronRunNow")})&&a.mutate({id:x.id,force:S})};return f.jsxs(sa,{fullHeight:!0,children:[f.jsx(oa,{title:A("cronPageTitle"),description:A("cronPageDescription"),actions:f.jsx(Pe,{variant:"ghost",size:"icon",className:"h-9 w-9 rounded-lg text-gray-400 hover:text-gray-700 hover:bg-gray-100",onClick:()=>i.refetch(),children:f.jsx(Zo,{className:te("h-4 w-4",i.isFetching&&"animate-spin")})})}),f.jsx("div",{className:"mb-6",children:f.jsxs("div",{className:"flex flex-wrap gap-3 items-center",children:[f.jsxs("div",{className:"relative flex-1 min-w-[240px]",children:[f.jsx(Un,{value:e,onChange:x=>t(x.target.value),placeholder:A("cronSearchPlaceholder"),className:"pl-9"}),f.jsx(zn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"})]}),f.jsx("div",{className:"min-w-[180px]",children:f.jsxs(ft,{value:n,onValueChange:x=>r(x),children:[f.jsx(pt,{className:"w-full",children:f.jsx($n,{placeholder:A("cronStatusLabel")})}),f.jsxs(mt,{children:[f.jsx(He,{value:"all",children:A("cronStatusAll")}),f.jsx(He,{value:"enabled",children:A("cronStatusEnabled")}),f.jsx(He,{value:"disabled",children:A("cronStatusDisabled")})]})]})}),f.jsxs("div",{className:"text-xs text-gray-500 ml-auto",children:[A("cronTotalLabel"),": ",((m=i.data)==null?void 0:m.total)??0," / ",d.length]})]})}),f.jsx("div",{className:"flex-1 overflow-auto custom-scrollbar",children:i.isLoading?f.jsx("div",{className:"text-sm text-gray-400 p-4 text-center",children:A("cronLoading")}):d.length===0?f.jsx("div",{className:"text-sm text-gray-400 p-4 text-center",children:A("cronEmpty")}):f.jsx("div",{className:"space-y-4",children:d.map(x=>f.jsx(ja,{className:"border border-gray-200",children:f.jsx(La,{className:"pt-5 pb-5",children:f.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[f.jsxs("div",{className:"min-w-[220px] flex-1",children:[f.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[f.jsx("span",{className:"text-sm font-semibold text-gray-900",children:x.name||x.id}),f.jsx("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-full bg-gray-100 text-gray-500",children:x.id}),f.jsx("span",{className:te("text-[10px] font-semibold px-2 py-0.5 rounded-full",x.enabled?"bg-emerald-50 text-emerald-700":"bg-gray-100 text-gray-500"),children:x.enabled?A("enabled"):A("disabled")}),x.deleteAfterRun&&f.jsx("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-full bg-amber-50 text-amber-700",children:A("cronOneShot")})]}),f.jsxs("div",{className:"mt-2 text-xs text-gray-500",children:[A("cronScheduleLabel"),": ",Fm(x)]}),f.jsx("div",{className:"mt-2 text-sm text-gray-700 whitespace-pre-wrap break-words",children:x.payload.message}),f.jsxs("div",{className:"mt-2 text-xs text-gray-500",children:[A("cronDeliverTo"),": ",zm(x)]})]}),f.jsxs("div",{className:"min-w-[220px] text-xs text-gray-500 space-y-2",children:[f.jsxs("div",{children:[f.jsxs("span",{className:"font-medium text-gray-700",children:[A("cronNextRun"),":"]})," ",bi(x.state.nextRunAt)]}),f.jsxs("div",{children:[f.jsxs("span",{className:"font-medium text-gray-700",children:[A("cronLastRun"),":"]})," ",bi(x.state.lastRunAt)]}),f.jsxs("div",{children:[f.jsxs("span",{className:"font-medium text-gray-700",children:[A("cronLastStatus"),":"]})," ",x.state.lastStatus??"-"]}),x.state.lastError&&f.jsx("div",{className:"text-[11px] text-red-500 break-words",children:x.state.lastError})]}),f.jsxs("div",{className:"flex items-start gap-2 flex-wrap justify-end",children:[f.jsxs(Pe,{variant:"subtle",size:"sm",onClick:()=>h(x),className:"gap-1",children:[f.jsx(ea,{className:"h-3.5 w-3.5"}),A("cronRunNow")]}),f.jsxs(Pe,{variant:x.enabled?"outline":"primary",size:"sm",onClick:()=>p(x),className:"gap-1",children:[f.jsx(ta,{className:"h-3.5 w-3.5"}),x.enabled?A("cronDisable"):A("cronEnable")]}),f.jsxs(Pe,{variant:"destructive",size:"sm",onClick:()=>c(x),className:"gap-1",children:[f.jsx(Ni,{className:"h-3.5 w-3.5"}),A("delete")]})]})]})})},x.id))})}),f.jsx(u,{})]})}function Hm(e){const{modelOptions:t,selectedSessionPreferredModel:n,defaultModel:r,setSelectedModel:i}=e;R.useEffect(()=>{if(t.length===0){i("");return}i(s=>{var l;if(t.some(u=>u.value===s))return s;const o=n==null?void 0:n.trim();if(o&&t.some(u=>u.value===o))return o;const a=r==null?void 0:r.trim();return a&&t.some(u=>u.value===a)?a:((l=t[0])==null?void 0:l.value)??""})},[r,t,n,i])}function Km(e){var v;const{view:t,selectedSessionKey:n,activeBackendRunId:r,isLocallyRunning:i,resumeRun:s}=e,[o,a]=R.useState(null),l=R.useRef(!1),u=R.useRef(new Map),d=R.useRef(new Map),c=R.useRef(new Map),p=R.useRef(r),h=R.useRef(new Set);R.useEffect(()=>{n&&h.current.add(n)},[n]),R.useEffect(()=>{n&&i&&h.current.delete(n)},[i,n]);const m=fa(t==="chat"?{states:["queued","running"],limit:200,syncActiveStates:!0,isLocallyRunning:i}:void 0),x=R.useMemo(()=>{var k;return Ea(((k=m.data)==null?void 0:k.runs)??[])},[(v=m.data)==null?void 0:v.runs]),S=R.useMemo(()=>{const k=Ma(x);if(o){const T=x.get(o.sessionKey)??null;T&&(!o.runId||T.runId===o.runId)&&k.delete(o.sessionKey)}return k},[x,o]),g=R.useMemo(()=>{if(!n)return null;const k=x.get(n)??null;return(!k||!o||o.sessionKey!==n?!1:!o.runId||k.runId===o.runId)?null:k},[x,n,o]);return R.useEffect(()=>{r&&(p.current=r)},[r]),R.useEffect(()=>{if(t!=="chat"||!n||!g||!h.current.has(n)||i||r===g.runId||u.current.get(n)===g.runId)return;const T=d.current.get(n);if(T&&T===g.runId)return;const N=c.current.get(n);if(typeof N=="number"){const w=Date.parse(g.requestedAt??"");if(Number.isFinite(w)){if(w<=N+2e3)return}else if(Date.now()-N<=8e3)return}u.current.set(n,g.runId),h.current.delete(n),s(g)},[r,g,i,s,n,t]),R.useEffect(()=>{if(!n){u.current.clear(),d.current.clear(),c.current.clear(),h.current.clear();return}x.has(n)||(u.current.delete(n),d.current.delete(n),c.current.delete(n))},[x,n]),R.useEffect(()=>{var T,N,w;const k=l.current;if(l.current=i,!i&&k&&n){const _=((T=p.current)==null?void 0:T.trim())||((w=(N=x.get(n))==null?void 0:N.runId)==null?void 0:w.trim());_&&d.current.set(n,_),c.current.set(n,Date.now()),a({sessionKey:n,..._?{runId:_}:{}}),m.refetch()}},[x,i,n,m]),R.useEffect(()=>{if(!o)return;const k=x.get(o.sessionKey)??null;if(!k){a(null);return}o.runId&&k.runId!==o.runId&&a(null)},[x,o]),R.useEffect(()=>{i&&(o==null?void 0:o.sessionKey)===n&&a(null)},[i,n,o]),{sessionRunStatusByKey:S}}const Vm={parseReady:e=>e.driver!=="nextbot-stream"||e.kind!=="ready"?null:{remoteRunId:typeof e.backendRunId=="string"?e.backendRunId:void 0,sessionId:typeof e.sessionKey=="string"?e.sessionKey:void 0,stopCapable:typeof e.stopSupported=="boolean"?e.stopSupported:void 0,stopReason:typeof e.stopReason=="string"?e.stopReason:void 0},parseFinal:e=>e.driver!=="nextbot-stream"||e.kind!=="final"?null:{sessionId:typeof e.sessionKey=="string"?e.sessionKey:void 0,hasOutput:!!e.hasAssistantSessionEvent}};function qm(e,t){return{driver:"nextbot-stream",mode:"send",payload:e,requestedSkills:t}}function Wm(e){const t=Number.isFinite(e.eventCount)&&e.eventCount>0?Math.max(0,Math.trunc(e.eventCount)):void 0;return{driver:"nextbot-stream",mode:"resume",runId:e.runId,...typeof t=="number"?{fromEventIndex:t}:{},sessionKey:e.sessionKey,...e.agentId?{agentId:e.agentId}:{},stopSupported:e.stopSupported,...e.stopReason?{stopReason:e.stopReason}:{}}}function Gm(e){if(!Array.isArray(e))return[];const t=new Set;for(const n of e){const r=n.trim();r&&t.add(r)}return[...t]}function Xm(e){var x;const t=new Set(["tool","tool_result","toolresult","function"]),n=[];let r=0,i=0,s=null;const o=(S,g)=>(r+=1,`history-${S}-${g||"unknown"}-${r}`),a=S=>{const g=typeof S=="string"?S:JSON.stringify(S??{});try{return{args:g,parsedArgs:JSON.parse(g)}}catch{return{args:g}}},l=(S,g)=>{for(let v=S.length-1;v>=0;v-=1){const k=S[v];if(k.type==="tool-invocation"&&k.toolInvocation.toolCallId===g)return v}return-1},u=S=>s?(s={...s,meta:{...s.meta,timestamp:S}},s):(i+=1,s={id:`history-assistant-${i}-${S||"unknown"}`,role:"assistant",parts:[],meta:{source:"history",status:"final",timestamp:S}},s),d=()=>{s&&(s.parts.length>0&&n.push(s),s=null)},c=(S,g)=>{if(!g)return;const v=u(S);v.parts=[...v.parts,{type:"text",text:g}]},p=(S,g)=>{if(!g)return;const v=u(S);v.parts=[...v.parts,{type:"reasoning",reasoning:g,details:[]}]},h=S=>{const g=u(S.timestamp),v=l(g.parts,S.toolCallId),k={type:"tool-invocation",toolInvocation:{status:se.CALL,toolCallId:S.toolCallId,toolName:S.toolName,args:S.args,parsedArgs:S.parsedArgs}};if(v>=0){g.parts=[...g.parts.slice(0,v),k,...g.parts.slice(v+1)];return}g.parts=[...g.parts,k]},m=S=>{if(!S.toolCallId)return;const g=u(S.timestamp),v=l(g.parts,S.toolCallId);if(v<0){g.parts=[...g.parts,{type:"tool-invocation",toolInvocation:{status:se.RESULT,toolCallId:S.toolCallId,toolName:S.toolName,args:"{}",parsedArgs:void 0,result:S.result}}];return}const k=g.parts[v];k.type==="tool-invocation"&&(g.parts=[...g.parts.slice(0,v),{...k,toolInvocation:{...k.toolInvocation,status:se.RESULT,result:S.result}},...g.parts.slice(v+1)])};for(const S of e){const g=(x=S.role)==null?void 0:x.toLowerCase().trim();if(!g)continue;const v=S.timestamp;if(g==="user"||g==="system"||g==="data"){d();const k=xr(S.content).trim();if(!k)continue;n.push({id:o(g,v),role:g,parts:[{type:"text",text:k}],meta:{source:"history",status:"final",timestamp:v}});continue}if(g==="assistant"){const k=xr(S.content).trim();if(k&&c(v,k),typeof S.reasoning_content=="string"&&S.reasoning_content.trim()&&p(v,S.reasoning_content.trim()),Array.isArray(S.tool_calls))for(const T of S.tool_calls){if(!T||typeof T!="object")continue;const N=T,w=N.function,_=typeof w=="object"&&w?w:null,z=typeof N.id=="string"?N.id.trim():"";if(!z)continue;const U=typeof(_==null?void 0:_.name)=="string"?_.name:typeof N.name=="string"?N.name:"tool",C=a((_==null?void 0:_.arguments)??N.arguments??"");h({timestamp:v,toolCallId:z,toolName:U,args:C.args,parsedArgs:C.parsedArgs})}continue}if(t.has(g)){const k=typeof S.tool_call_id=="string"?S.tool_call_id.trim():"",T=typeof S.name=="string"&&S.name.trim()?S.name.trim():"tool";m({timestamp:v,toolCallId:k,toolName:T,result:S.content})}}return d(),n}function Et(e){const[t,n]=R.useState(e.getValue());return R.useEffect(()=>{const r=e.subscribe(n);return()=>r.unsubscribe()},[e]),t}function Qm(e,t){const[n,r]=R.useState(t);return R.useEffect(()=>{const i=e.subscribe(r);return()=>i.unsubscribe()},[e]),n}function Ym(e,t){const n=R.useRef(e);R.useEffect(()=>{n.current=e});const r=R.useRef(null);R.useEffect(()=>{t.setCallbacks({onRunSettled:async({sourceSessionId:g,resultSessionId:v})=>{const k=n.current;await k.refetchSessions();const T=k.selectedSessionKeyRef.current;(!T||T===g||v&&T===v)&&await k.refetchHistory()},onRunError:({sourceMessage:g,restoreDraft:v})=>{v&&n.current.setDraft(k=>k.trim().length===0&&g?g:k)},onSessionChanged:g=>{n.current.setSelectedSessionKey(v=>v===g?v:g)}})},[t]);const i=Qm(t.messages$,t.getMessages()),s=Et(t.isAgentResponding$),o=Et(t.isAwaitingResponse$),a=Et(t.activeRun$),l=Et(t.lastError$),u=(a==null?void 0:a.remoteRunId)??null,d=ol(a),c=!!(a&&(d===null||a.remoteStopCapable&&!u)),p=R.useCallback(async g=>{const v=Gm(g.requestedSkills),k=qm(g,v);await t.send({message:g.message,sessionId:g.sessionKey,agentId:g.agentId,metadata:k,restoreDraftOnError:g.restoreDraftOnError,stopCapable:g.stopSupported,stopReason:g.stopReason})},[t]),h=R.useCallback(async g=>{var N,w;const v=(N=g.runId)==null?void 0:N.trim(),k=(w=g.sessionKey)==null?void 0:w.trim();if(!v||!k)return;const T=Wm(g);await t.resume({remoteRunId:v,sessionId:k,agentId:g.agentId,metadata:T,stopCapable:g.stopSupported,stopReason:g.stopReason})},[t]),m=R.useCallback(async()=>{await t.stop()},[t]),x=R.useCallback(()=>{r.current=null,t.reset()},[t]),S=R.useCallback((g,v)=>{if(!!(t.activeRun$.getValue()||t.isAgentResponding$.getValue()))return;const T=n.current.selectedSessionKeyRef.current;if(T!==r.current&&(r.current=T,t.getMessages().length>0&&t.setMessages([])),!T){t.getMessages().length>0&&t.setMessages([]);return}v!=null&&v.isLoading&&g.length===0||t.setMessages(Xm(g))},[t]);return{uiMessages:i,isSending:s,isAwaitingAssistantOutput:o,canStopCurrentRun:c,stopDisabledReason:d,lastSendError:l,activeBackendRunId:u,sendMessage:p,stopCurrentRun:m,resumeRun:h,resetStreamState:x,applyHistoryMessages:S}}const Dn="sid_";function Jm(e){var r;const t=/^agent:([^:]+):/i.exec(e.trim());if(!t)return null;const n=(r=t[1])==null?void 0:r.trim();return n||null}function Zm(e){const t=Math.random().toString(36).slice(2,8);return`agent:${e}:ui:direct:web-${Date.now().toString(36)}${t}`}function eg(e){const t=new TextEncoder().encode(e);let n="";for(const i of t)n+=String.fromCharCode(i);const r=btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"");return`${Dn}${r}`}function tg(e){if(!e.startsWith(Dn))return null;const t=e.slice(Dn.length).replace(/-/g,"+").replace(/_/g,"/"),n=t.length%4===0?"":"=".repeat(4-t.length%4);try{const r=atob(t+n),i=Uint8Array.from(r,s=>s.charCodeAt(0));return new TextDecoder().decode(i)}catch{return null}}function ng(e){if(!e)return null;const t=tg(e);if(t)return t;try{return decodeURIComponent(e)}catch{return e}}function rg(e){return`/chat/${eg(e)}`}const ve="native";function Ue(e){return typeof e!="string"?ve:e.trim().toLowerCase()||ve}function Dt(e,t){return e==="native"?A("chatSessionTypeNative"):e==="codex-sdk"?A("chatSessionTypeCodex"):e==="claude-agent-sdk"?A("chatSessionTypeClaude"):(t==null?void 0:t.trim())||e}function ig(e){var n;const t=new Map;for(const r of e){const i=Ue(r.value);t.set(i,{value:i,label:((n=r.label)==null?void 0:n.trim())||Dt(i)})}return t.has(ve)||t.set(ve,{value:ve,label:Dt(ve)}),Array.from(t.values()).sort((r,i)=>r.value===ve?-1:i.value===ve?1:r.value.localeCompare(i.value))}function sg(e){const{selectedSession:t,selectedSessionKey:n,pendingSessionType:r,setPendingSessionType:i,sessionTypesData:s}=e,o=R.useMemo(()=>ig((s==null?void 0:s.options)??[]),[s==null?void 0:s.options]),a=R.useMemo(()=>{const m=[...o],x=Ue(t==null?void 0:t.sessionType);return m.some(S=>S.value===x)||m.push({value:x,label:Dt(x)}),m.sort((S,g)=>S.value===ve?-1:g.value===ve?1:S.value.localeCompare(g.value))},[o,t==null?void 0:t.sessionType]),l=R.useMemo(()=>Ue((s==null?void 0:s.defaultType)??ve),[s==null?void 0:s.defaultType]),u=R.useMemo(()=>Ue((t==null?void 0:t.sessionType)??r??l),[l,r,t==null?void 0:t.sessionType]);R.useEffect(()=>{n||i(l)},[l,n,i]);const d=!n||!!(t!=null&&t.sessionTypeMutable),c=R.useMemo(()=>new Set(o.map(m=>m.value)),[o]),p=!!(t&&!c.has(Ue(t.sessionType))),h=p?`${Dt(u)} ${A("chatSessionTypeUnavailableSuffix")}`:null;return{sessionTypeOptions:a,defaultSessionType:l,selectedSessionType:u,canEditSessionType:d,sessionTypeUnavailable:p,sessionTypeUnavailableMessage:h}}function og(e){var x,S,g,v;const t=pa(),n=ma(),r=ga({q:e.query.trim()||void 0,limit:120,activeMinutes:0}),i=Na("skill"),s=xa({sessionKey:e.selectedSessionKey,agentId:e.selectedAgentId}),o=ya(e.selectedSessionKey,300),a=ba(),l=(t.isFetched||t.isSuccess)&&(n.isFetched||n.isSuccess),u=R.useMemo(()=>{const k=_a({meta:n.data,config:t.data,onlyConfigured:!0}),T=new Set,N=[];for(const w of k)for(const _ of w.models){const z=Oa(w.prefix,_);!z||T.has(z)||(T.add(z),N.push({value:z,modelLabel:_,providerLabel:w.displayName}))}return N.sort((w,_)=>{const z=w.providerLabel.localeCompare(_.providerLabel);return z!==0?z:w.modelLabel.localeCompare(_.modelLabel)})},[n.data,t.data]),d=R.useMemo(()=>{var k;return((k=r.data)==null?void 0:k.sessions)??[]},[(x=r.data)==null?void 0:x.sessions]),c=R.useMemo(()=>{var k;return((k=i.data)==null?void 0:k.records)??[]},[(S=i.data)==null?void 0:S.records]),p=R.useMemo(()=>d.find(k=>k.key===e.selectedSessionKey)??null,[e.selectedSessionKey,d]),h=sg({selectedSession:p,selectedSessionKey:e.selectedSessionKey,pendingSessionType:e.pendingSessionType,setPendingSessionType:e.setPendingSessionType,sessionTypesData:a.data});Hm({modelOptions:u,selectedSessionPreferredModel:p==null?void 0:p.preferredModel,defaultModel:(g=t.data)==null?void 0:g.agents.defaults.model,setSelectedModel:e.setSelectedModel});const m=R.useMemo(()=>{var k;return((k=o.data)==null?void 0:k.messages)??[]},[(v=o.data)==null?void 0:v.messages]);return{configQuery:t,configMetaQuery:n,sessionsQuery:r,installedSkillsQuery:i,chatCapabilitiesQuery:s,historyQuery:o,sessionTypesQuery:a,isProviderStateResolved:l,modelOptions:u,sessions:d,skillRecords:c,selectedSession:p,historyMessages:m,...h}}function ag(e){if(e.label&&e.label.trim())return e.label.trim();const t=e.key.split(":");return t[t.length-1]||e.key}class lg{constructor(t,n){this.uiManager=t,this.streamActionsManager=n,this.hasSnapshotChanges=r=>{const i=ie.getState().snapshot;for(const[s,o]of Object.entries(r))if(!Object.is(i[s],o))return!0;return!1},this.resolveUpdateValue=(r,i)=>typeof i=="function"?i(r):i,this.syncSnapshot=r=>{this.hasSnapshotChanges(r)&&ie.getState().setSnapshot(r)},this.setDraft=r=>{const i=ie.getState().snapshot.draft,s=this.resolveUpdateValue(i,r);s!==i&&ie.getState().setSnapshot({draft:s})},this.setPendingSessionType=r=>{const i=ie.getState().snapshot.pendingSessionType,s=this.resolveUpdateValue(i,r);s!==i&&ie.getState().setSnapshot({pendingSessionType:s})},this.send=async()=>{const r=ie.getState().snapshot,i=oe.getState().snapshot,s=r.draft.trim();if(!s)return;const o=r.selectedSkills,a=!!i.selectedSessionKey,l=i.selectedSessionKey??Zm(i.selectedAgentId);a||this.uiManager.goToSession(l,{replace:!0}),this.setDraft(""),this.setSelectedSkills([]),await this.streamActionsManager.sendMessage({message:s,sessionKey:l,agentId:i.selectedAgentId,sessionType:r.selectedSessionType,model:r.selectedModel||void 0,stopSupported:r.stopSupported,stopReason:r.stopReason,requestedSkills:o,restoreDraftOnError:!0})},this.stop=async()=>{await this.streamActionsManager.stopCurrentRun()},this.goToProviders=()=>{this.uiManager.goToProviders()},this.setSelectedModel=r=>{const i=ie.getState().snapshot.selectedModel,s=this.resolveUpdateValue(i,r);s!==i&&ie.getState().setSnapshot({selectedModel:s})},this.selectSessionType=r=>{const i=Ue(r);ie.getState().setSnapshot({selectedSessionType:i,pendingSessionType:i}),this.syncRemoteSessionType(i)},this.setSelectedSkills=r=>{const i=ie.getState().snapshot.selectedSkills,s=this.resolveUpdateValue(i,r);Object.is(s,i)||ie.getState().setSnapshot({selectedSkills:s})},this.selectModel=r=>{this.setSelectedModel(r)},this.selectSkills=r=>{this.setSelectedSkills(r)},this.syncRemoteSessionType=async r=>{const i=oe.getState().snapshot,s=i.selectedSessionKey;if(!s)return;const o=i.sessions.find(a=>a.key===s);o!=null&&o.sessionTypeMutable&&Ue(o.sessionType)!==r&&await Sa(s,{sessionType:r})}}}function ug(e,t){if(e===t)return!0;if(e.size!==t.size)return!1;for(const[n,r]of e.entries())if(!Object.is(r,t.get(n)))return!1;return!0}class cg{constructor(){this.syncSnapshot=t=>{const n=kn.getState().snapshot,r=t.sessionRunStatusByKey;(!r||ug(n.sessionRunStatusByKey,r))&&(t.isLocallyRunning===void 0||Object.is(n.isLocallyRunning,t.isLocallyRunning))&&(t.activeBackendRunId===void 0||Object.is(n.activeBackendRunId,t.activeBackendRunId))||kn.getState().setSnapshot(t)}}}class dg{constructor(t,n){this.uiManager=t,this.streamActionsManager=n,this.hasSnapshotChanges=r=>{const i=oe.getState().snapshot;for(const[s,o]of Object.entries(r))if(!Object.is(i[s],o))return!0;return!1},this.resolveUpdateValue=(r,i)=>typeof i=="function"?i(r):i,this.syncSnapshot=r=>{this.hasSnapshotChanges(r)&&oe.getState().setSnapshot(r)},this.setSelectedAgentId=r=>{const i=oe.getState().snapshot.selectedAgentId,s=this.resolveUpdateValue(i,r);s!==i&&oe.getState().setSnapshot({selectedAgentId:s})},this.setSelectedSessionKey=r=>{const i=oe.getState().snapshot.selectedSessionKey,s=this.resolveUpdateValue(i,r);s!==i&&oe.getState().setSnapshot({selectedSessionKey:s})},this.createSession=()=>{const r=ie.getState().snapshot.defaultSessionType||"native";this.streamActionsManager.resetStreamState(),this.setSelectedSessionKey(null),ie.getState().setSnapshot({pendingSessionType:r}),this.uiManager.goToChatRoot()},this.selectSession=r=>{this.setSelectedSessionKey(r),this.uiManager.goToSession(r)},this.setQuery=r=>{const i=oe.getState().snapshot.query,s=this.resolveUpdateValue(i,r);s!==i&&oe.getState().setSnapshot({query:s})}}}const mn=async()=>{},Si=()=>{};class hg{constructor(){this.actions={sendMessage:mn,stopCurrentRun:mn,resumeRun:mn,resetStreamState:Si,applyHistoryMessages:Si},this.bind=t=>{this.actions={...this.actions,...t}},this.sendMessage=t=>this.actions.sendMessage(t),this.stopCurrentRun=()=>this.actions.stopCurrentRun(),this.resumeRun=t=>this.actions.resumeRun(t),this.resetStreamState=()=>this.actions.resetStreamState(),this.applyHistoryMessages=(t,n)=>this.actions.applyHistoryMessages(t,n)}}const fg=async()=>{};class pg{constructor(t,n,r){this.uiManager=t,this.sessionListManager=n,this.streamActionsManager=r,this.actions={refetchSessions:fg},this.bindActions=i=>{this.actions={...this.actions,...i}},this.hasSnapshotChanges=i=>{const s=lt.getState().snapshot;for(const[o,a]of Object.entries(i))if(!Object.is(s[o],a))return!0;return!1},this.syncSnapshot=i=>{this.hasSnapshotChanges(i)&<.getState().setSnapshot(i)},this.deleteSession=()=>{this.deleteCurrentSession()},this.createSession=()=>{this.sessionListManager.createSession()},this.goToProviders=()=>{this.uiManager.goToProviders()},this.deleteCurrentSession=async()=>{const i=oe.getState().snapshot.selectedSessionKey;if(!(!i||!await this.uiManager.confirm({title:A("chatDeleteSessionConfirm"),variant:"destructive",confirmLabel:A("delete")}))){lt.getState().setSnapshot({isDeletePending:!0});try{await ka(i),this.streamActionsManager.resetStreamState(),oe.getState().setSnapshot({selectedSessionKey:null}),this.uiManager.goToChatRoot({replace:!0}),await this.actions.refetchSessions()}finally{lt.getState().setSnapshot({isDeletePending:!1})}}}}}const mg=async e=>!1;class gg{constructor(){this.state={pathname:""},this.actions={navigate:null,confirm:mg},this.syncState=t=>{this.state={...this.state,...t}},this.bindActions=t=>{this.actions={...this.actions,...t}},this.confirm=async t=>this.actions.confirm(t),this.navigateTo=(t,n)=>{this.actions.navigate&&(this.state.pathname===t&&!(n!=null&&n.replace)||(this.actions.navigate(t,n),this.state.pathname=t))},this.goToProviders=()=>{this.navigateTo("/providers")},this.goToChatRoot=t=>{this.navigateTo("/chat",t)},this.goToSession=(t,n)=>{this.navigateTo(rg(t),n)}}}function xg(e){return e.delta?e.started?[{type:K.TEXT_DELTA,messageId:e.messageId,delta:e.delta}]:[{type:K.TEXT_START,messageId:e.messageId},{type:K.TEXT_DELTA,messageId:e.messageId,delta:e.delta}]:[]}function yg(e){return!1}function bg(e){var n,r;return((r=(n=e.message)==null?void 0:n.role)==null?void 0:r.toLowerCase().trim())==="assistant"}function Sg(e){var o;const{event:t,messageId:n}=e,r=t.message;if(!r)return[];const i=(o=r.role)==null?void 0:o.toLowerCase().trim();if(!i)return[];const s=[];if(typeof r.reasoning_content=="string"&&r.reasoning_content.trim()&&(s.push({type:K.REASONING_START,messageId:n}),s.push({type:K.REASONING_DELTA,messageId:n,delta:r.reasoning_content.trim()}),s.push({type:K.REASONING_END,messageId:n})),Array.isArray(r.tool_calls))for(let a=0;a<r.tool_calls.length;a+=1){const l=r.tool_calls[a];if(!l||typeof l!="object")continue;const u=l,d=u.function,c=typeof d=="object"&&d?d:null,p=typeof t.seq=="number"?String(t.seq):"unknown",h=typeof u.id=="string"?u.id:`tool-${p}-${a}`,m=typeof(c==null?void 0:c.name)=="string"?c.name:typeof u.name=="string"?u.name:"tool",x=(c==null?void 0:c.arguments)??u.arguments??"",S=typeof x=="string"?x:JSON.stringify(x??{});s.push({type:K.TOOL_CALL_START,messageId:n,toolCallId:h,toolName:m}),s.push({type:K.TOOL_CALL_ARGS,toolCallId:h,args:S}),s.push({type:K.TOOL_CALL_END,toolCallId:h})}if(i==="tool"||i==="tool_result"||i==="toolresult"||i==="function"){const a=typeof r.tool_call_id=="string"?r.tool_call_id.trim():"";a&&s.push({type:K.TOOL_CALL_RESULT,toolCallId:a,content:r.content})}return s}function lo(){return`stream-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function kg(e,t){const n={};return e.sessionType&&(n.session_type=e.sessionType),t.length>0&&(n.requested_skills=t),{message:e.message,...e.runId?{runId:e.runId}:{},sessionKey:e.sessionKey,agentId:e.agentId,...e.model?{model:e.model}:{},...Object.keys(n).length>0?{metadata:n}:{},channel:"ui",chatId:"web-ui"}}async function wg(e){return wa(kg(e.item,e.requestedSkills),{signal:e.signal,onReady:e.onReady,onDelta:e.onDelta,onSessionEvent:e.onSessionEvent})}async function vg(e){return va({runId:e.runId,...typeof e.fromEventIndex=="number"?{fromEventIndex:e.fromEventIndex}:{}},{signal:e.signal,onReady:e.onReady,onDelta:e.onDelta,onSessionEvent:e.onSessionEvent})}async function Cg(e){var t;if(e.backendStopSupported)try{const n=new Set,r=(t=e.backendRunId)==null?void 0:t.trim();if(r&&(n.add(r),await gn(r)))return;const i=await Ig(e);for(const s of i){if(n.has(s))continue;if(n.add(s),await gn(s))return}if(r&&await gn(r))return}catch{}}async function gn(e){const t=e.trim();if(!t)return!1;try{return(await Ca({runId:t})).stopped===!0}catch{return!1}}async function Ig(e){var i;const t=(i=e.sessionKey)==null?void 0:i.trim();if(!t)return[];const n=8,r=120;for(let s=0;s<n;s+=1){const o=await Rg(e,t);if(o.length>0)return o;s<n-1&&await Tg(r)}return[]}async function Rg(e,t){try{const n=await Ia({sessionKey:t,states:["queued","running"],limit:50}),r=n.runs.filter(i=>{var s;return((s=i.runId)==null?void 0:s.trim())&&i.sessionKey===t&&i.agentId===e.agentId}).map(i=>i.runId.trim());return r.length>0?r:n.runs.filter(i=>{var s;return((s=i.runId)==null?void 0:s.trim())&&i.sessionKey===t}).map(i=>i.runId.trim())}catch{return[]}}function Tg(e){return new Promise(t=>{window.setTimeout(t,e)})}function Ag(){const e=Date.now().toString(36),t=Math.random().toString(36).slice(2,10);return`run-${e}-${t}`}function Eg(e){const t=e.metadata;if(!t||typeof t!="object"||Array.isArray(t))return null;const n=t;if(n.driver!=="nextbot-stream")return null;const r=n.mode;if(r==="send"){const i=n.payload;if(!i||typeof i!="object"||Array.isArray(i))return null;const s=Array.isArray(n.requestedSkills)?n.requestedSkills.filter(o=>typeof o=="string"):[];return{driver:"nextbot-stream",mode:"send",payload:i,requestedSkills:s}}if(r==="resume"){const i=typeof n.runId=="string"?n.runId.trim():"";if(!i)return null;const s=typeof n.fromEventIndex=="number"&&Number.isFinite(n.fromEventIndex)?Math.max(0,Math.trunc(n.fromEventIndex)):void 0,o=typeof n.sessionKey=="string"?n.sessionKey.trim():"",a=typeof n.agentId=="string"?n.agentId.trim():"",l=typeof n.stopSupported=="boolean"?n.stopSupported:void 0,u=typeof n.stopReason=="string"?n.stopReason.trim():"";return{driver:"nextbot-stream",mode:"resume",runId:i,...typeof s=="number"?{fromEventIndex:s}:{},...o?{sessionKey:o}:{},...a?{agentId:a}:{},...typeof l=="boolean"?{stopSupported:l}:{},...u?{stopReason:u}:{}}}return null}function Mg(e){var t;if(e.mode==="send"){const n=((t=e.payload.runId)==null?void 0:t.trim())||"";return{localRunId:0,sessionKey:e.payload.sessionKey,...e.payload.agentId?{agentId:e.payload.agentId}:{},...n?{backendRunId:n}:{},backendStopSupported:!!e.payload.stopSupported,...e.payload.stopReason?{backendStopReason:e.payload.stopReason}:{}}}return{localRunId:0,sessionKey:e.sessionKey??"",...e.agentId?{agentId:e.agentId}:{},backendRunId:e.runId,backendStopSupported:!!e.stopSupported,...e.stopReason?{backendStopReason:e.stopReason}:{}}}function Ng(e){var n;return e.mode!=="send"||((n=e.payload.runId)==null?void 0:n.trim())?e:{...e,payload:{...e.payload,runId:Ag()}}}function Pg(e,t){var n,r,i;e.backendRunId=((n=t.runId)==null?void 0:n.trim())||e.backendRunId,e.backendStopSupported=typeof t.stopSupported=="boolean"?t.stopSupported:e.backendStopSupported,(r=t.stopReason)!=null&&r.trim()&&(e.backendStopReason=t.stopReason.trim()),(i=t.sessionKey)!=null&&i.trim()&&(e.sessionKey=t.sessionKey.trim())}function jg(){return{deltaMessageId:lo(),deltaStarted:!1,deltaClosed:!1,hasAssistantSessionEvent:!1,hasAssistantOutput:!1}}function Lg(e){var t,n,r;return{driver:"nextbot-stream",kind:"ready",...(t=e.sessionKey)!=null&&t.trim()?{sessionKey:e.sessionKey.trim()}:{},...(n=e.runId)!=null&&n.trim()?{backendRunId:e.runId.trim()}:{},...typeof e.stopSupported=="boolean"?{stopSupported:e.stopSupported}:{},...(r=e.stopReason)!=null&&r.trim()?{stopReason:e.stopReason.trim()}:{},...e.requestedAt?{requestedAt:e.requestedAt}:{}}}function _g(e,t){return{driver:"nextbot-stream",kind:"final",sessionKey:e.sessionKey,reply:e.reply,hasAssistantSessionEvent:t}}function ki(e,t,n){e({type:K.RUN_METADATA,runId:t,metadata:n})}function wi(e,t){!e.deltaStarted||e.deltaClosed||(t({type:K.TEXT_END,messageId:e.deltaMessageId}),e.deltaClosed=!0)}function Og(e,t,n){const r=xg({messageId:e.deltaMessageId,delta:n.delta,started:e.deltaStarted});r.length>0&&(e.deltaStarted=!0,e.deltaClosed=!1,e.hasAssistantOutput=!0);for(const i of r)t(i)}function Dg(e,t,n){yg(n.data),bg(n.data)&&(e.hasAssistantSessionEvent=!0);for(const r of Sg({event:n.data,messageId:e.deltaMessageId}))t(r)}function Fg(e,t,n){const r=n.trim();if(e.hasAssistantOutput||!r)return;const i=lo();t({type:K.TEXT_START,messageId:i}),t({type:K.TEXT_DELTA,messageId:i,delta:r}),t({type:K.TEXT_END,messageId:i})}class zg{constructor(){this.activeAbortController=null,this.activeRunState=null,this.buildMissingMetadataObservable=t=>new Pt(n=>{n.next({type:K.RUN_ERROR,runId:t,error:"nextbot runtime metadata is required"}),n.complete()}),this.openRunStream=t=>{const{metadata:n,signal:r,onReady:i,onDelta:s,onSessionEvent:o}=t;return n.mode==="send"?wg({item:n.payload,requestedSkills:n.requestedSkills,signal:r,onReady:i,onDelta:s,onSessionEvent:o}):vg({runId:n.runId,fromEventIndex:n.fromEventIndex,signal:r,onReady:i,onDelta:s,onSessionEvent:o})},this.finalizeRunState=(t,n)=>{this.activeAbortController===t&&(this.activeAbortController=null),this.activeRunState===n&&(this.activeRunState=null)},this.createRunObservable=({metadata:t,clientRunId:n,abortController:r,runState:i})=>new Pt(s=>{const o=jg();let a=!1;const l=d=>{a||s.next(d)};return l({type:K.RUN_STARTED,runId:n}),this.openRunStream({metadata:t,signal:r.signal,onReady:d=>{this.activeRunState&&Pg(this.activeRunState,d),ki(l,n,Lg(d))},onDelta:d=>{Og(o,l,d)},onSessionEvent:d=>{Dg(o,l,d)}}).then(d=>{wi(o,l),Fg(o,l,d.reply),ki(l,n,_g(d,o.hasAssistantSessionEvent)),l({type:K.RUN_FINISHED,runId:n}),s.complete()}).catch(d=>{wi(o,l),In(d)||l({type:K.RUN_ERROR,runId:n,error:d instanceof Error?d.message:String(d)}),s.complete()}).finally(()=>{this.finalizeRunState(r,i)}),()=>{a=!0,r.abort(),this.activeAbortController===r&&(this.activeAbortController=null)}}),this.abortRun=()=>{var n;const t=this.activeRunState;t!=null&&t.backendStopSupported&&Cg(t),(n=this.activeAbortController)==null||n.abort(),this.activeAbortController=null,this.activeRunState=null},this.run=t=>{const n=Eg(t),r=typeof t.runId=="string"&&t.runId.trim()?t.runId:`run-${Date.now()}`;if(!n)return this.buildMissingMetadataObservable(r);const i=Ng(n);this.abortRun();const s=new AbortController;this.activeAbortController=s;const o=Mg(i);return this.activeRunState=o,this.createRunObservable({metadata:i,clientRunId:r,abortController:s,runState:o})}}}class Bg{constructor(){this.chatUiManager=new gg,this.runtimeAgent=new zg,this.chatController=new dl({agent:this.runtimeAgent,getToolDefs:()=>[],getContexts:()=>[],getToolExecutor:()=>{}},{metadataParsers:Vm}),this.chatStreamActionsManager=new hg,this.chatInputManager=new lg(this.chatUiManager,this.chatStreamActionsManager),this.chatSessionListManager=new dg(this.chatUiManager,this.chatStreamActionsManager),this.chatRunStatusManager=new cg,this.chatThreadManager=new pg(this.chatUiManager,this.chatSessionListManager,this.chatStreamActionsManager)}}function $g(e){const{view:t,routeSessionKey:n,selectedSessionKey:r,selectedAgentId:i,setSelectedSessionKey:s,setSelectedAgentId:o,selectedSessionKeyRef:a,resetStreamState:l}=e;R.useEffect(()=>{if(t==="chat"){if(n){r!==n&&s(n);return}r!==null&&(s(null),l())}},[l,n,r,s,t]),R.useEffect(()=>{const u=r?Jm(r):null;u&&i!==u&&o(u)},[i,r,o]),R.useEffect(()=>{a.current=r},[r,a])}function Ug({view:e,confirmDialog:t}){return f.jsxs("div",{className:"h-full flex",children:[f.jsx(Ha,{}),e==="chat"?f.jsx(_m,{}):f.jsx("section",{className:"flex-1 min-h-0 overflow-hidden bg-gradient-to-b from-gray-50/60 to-white",children:e==="cron"?f.jsx("div",{className:"h-full overflow-auto custom-scrollbar",children:f.jsx("div",{className:"mx-auto w-full max-w-[min(1120px,100%)] px-6 py-5",children:f.jsx(Um,{})})}):f.jsx("div",{className:"h-full overflow-hidden",children:f.jsx("div",{className:"mx-auto flex h-full min-h-0 w-full max-w-[min(1120px,100%)] flex-col px-6 py-5",children:f.jsx(Pa,{forcedType:"skills"})})})}),t]})}function ex({view:e}){var ke,Ae;const[t]=R.useState(()=>new Bg),n=oe(ne=>ne.snapshot.query),r=oe(ne=>ne.snapshot.selectedSessionKey),i=oe(ne=>ne.snapshot.selectedAgentId),s=ie(ne=>ne.snapshot.pendingSessionType),{confirm:o,ConfirmDialog:a}=ji(),l=na(),u=ra(),{sessionId:d}=ia(),c=R.useRef(null),p=R.useRef(r),h=R.useMemo(()=>ng(d),[d]),{sessionsQuery:m,installedSkillsQuery:x,chatCapabilitiesQuery:S,historyQuery:g,isProviderStateResolved:v,modelOptions:k,sessions:T,skillRecords:N,selectedSession:w,historyMessages:_,sessionTypeOptions:z,defaultSessionType:U,selectedSessionType:C,canEditSessionType:j,sessionTypeUnavailable:L,sessionTypeUnavailableMessage:W}=og({query:n,selectedSessionKey:r,selectedAgentId:i,pendingSessionType:s,setPendingSessionType:t.chatInputManager.setPendingSessionType,setSelectedModel:t.chatInputManager.setSelectedModel}),{uiMessages:O,isSending:P,isAwaitingAssistantOutput:G,canStopCurrentRun:J,stopDisabledReason:ce,lastSendError:ye,activeBackendRunId:y,sendMessage:de,stopCurrentRun:be,resumeRun:b,resetStreamState:he,applyHistoryMessages:Ie}=Ym({selectedSessionKeyRef:p,setSelectedSessionKey:t.chatSessionListManager.setSelectedSessionKey,setDraft:t.chatInputManager.setDraft,refetchSessions:m.refetch,refetchHistory:g.refetch},t.chatController);console.log("[ChatPage] uiMessages",{uiMessages:O,historyMessages:_}),R.useEffect(()=>{t.chatStreamActionsManager.bind({sendMessage:de,stopCurrentRun:be,resumeRun:b,resetStreamState:he,applyHistoryMessages:Ie})},[Ie,t,he,b,de,be]);const{sessionRunStatusByKey:Z}=Km({view:e,selectedSessionKey:r,activeBackendRunId:y,isLocallyRunning:P||!!y,resumeRun:t.chatStreamActionsManager.resumeRun});$g({view:e,routeSessionKey:h,selectedSessionKey:r,selectedAgentId:i,setSelectedSessionKey:t.chatSessionListManager.setSelectedSessionKey,setSelectedAgentId:t.chatSessionListManager.setSelectedAgentId,selectedSessionKeyRef:p,resetStreamState:t.chatStreamActionsManager.resetStreamState}),R.useEffect(()=>{t.chatStreamActionsManager.applyHistoryMessages(_,{isLoading:g.isLoading})},[_,g.isLoading,t]),R.useEffect(()=>{t.chatUiManager.syncState({pathname:l.pathname}),t.chatUiManager.bindActions({navigate:u,confirm:o})},[o,l.pathname,u,t]);const _e=w?ag(w):void 0;return R.useEffect(()=>{t.chatThreadManager.bindActions({refetchSessions:m.refetch})},[t,m.refetch]),R.useEffect(()=>{var ne,ze;t.chatInputManager.syncSnapshot({isProviderStateResolved:v,defaultSessionType:U,canStopGeneration:J,stopDisabledReason:ce,stopSupported:((ne=S.data)==null?void 0:ne.stopSupported)??!1,stopReason:(ze=S.data)==null?void 0:ze.stopReason,sendError:ye,isSending:P,modelOptions:k,sessionTypeOptions:z,selectedSessionType:C,canEditSessionType:j,sessionTypeUnavailable:L,skillRecords:N,isSkillsLoading:x.isLoading}),t.chatSessionListManager.syncSnapshot({sessions:T,query:n,isLoading:m.isLoading}),t.chatRunStatusManager.syncSnapshot({sessionRunStatusByKey:Z,isLocallyRunning:P||!!y,activeBackendRunId:y}),t.chatThreadManager.syncSnapshot({isProviderStateResolved:v,modelOptions:k,sessionTypeUnavailable:L,sessionTypeUnavailableMessage:W,selectedSessionKey:r,sessionDisplayName:_e,canDeleteSession:!!w,threadRef:c,isHistoryLoading:g.isLoading,uiMessages:O,isSending:P,isAwaitingAssistantOutput:G})},[y,j,J,_e,(ke=S.data)==null?void 0:ke.stopReason,(Ae=S.data)==null?void 0:Ae.stopSupported,U,g.isLoading,x.isLoading,G,v,P,ye,O,k,t,n,w,r,i,C,Z,z,L,W,T,m.isLoading,ce,c,N]),f.jsx(Da,{presenter:t,children:f.jsx(Ug,{view:e,confirmDialog:f.jsx(a,{})})})}export{ex as ChatPage};
|