nextclaw 0.16.30 → 0.16.32
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 +93 -52
- package/package.json +12 -12
- package/ui-dist/assets/{ChannelsList-DAx7wv0_.js → ChannelsList-Zeys_w43.js} +6 -6
- package/ui-dist/assets/ChatPage-DWOU_8P6.js +43 -0
- package/ui-dist/assets/DocBrowser-B9OaZjmg.js +1 -0
- package/ui-dist/assets/{DocBrowser-DKkE3Y4I.js → DocBrowser-BmtBLFU0.js} +1 -1
- package/ui-dist/assets/{DocBrowserContext-BcZRBsCg.js → DocBrowserContext-YIKkPb76.js} +1 -1
- package/ui-dist/assets/{LogoBadge-BIPDLEwK.js → LogoBadge-F7ZWdxLT.js} +1 -1
- package/ui-dist/assets/MarketplacePage-BfaTTqN6.js +1 -0
- package/ui-dist/assets/{MarketplacePage-Dlp5BgCh.js → MarketplacePage-Cd4faegU.js} +2 -2
- package/ui-dist/assets/{McpMarketplacePage-CwKtAil8.js → McpMarketplacePage-C09Ngs7O.js} +2 -2
- package/ui-dist/assets/ModelConfig-DJgdcgvQ.js +1 -0
- package/ui-dist/assets/ProvidersList-w0rVFIBf.js +1 -0
- package/ui-dist/assets/RemoteAccessPage-BJ_ckkOV.js +1 -0
- package/ui-dist/assets/RuntimeConfig-Cmn2xPQO.js +1 -0
- package/ui-dist/assets/{SearchConfig-v46R5a2U.js → SearchConfig-BT13qpR_.js} +1 -1
- package/ui-dist/assets/{SecretsConfig-CXvUpbB_.js → SecretsConfig-CvqEVn0B.js} +2 -2
- package/ui-dist/assets/{SessionsConfig-7vUHMtOh.js → SessionsConfig-DHHcYznk.js} +2 -2
- package/ui-dist/assets/{book-open-DzSduAaw.js → book-open-CXoF5nQC.js} +1 -1
- package/ui-dist/assets/chat-session-display-VW6ZMvZP.js +1 -0
- package/ui-dist/assets/{chunk-JZWAC4HX-C1vpvW4r.js → chunk-JZWAC4HX-CvRWvTy5.js} +1 -1
- package/ui-dist/assets/{config-Df97LeLR.js → config-DJswxxE8.js} +1 -1
- package/ui-dist/assets/{createLucideIcon-CcR5wVoU.js → createLucideIcon-CjGHOWb6.js} +1 -1
- package/ui-dist/assets/{dist-Dii9v3X9.js → dist-Cl2QB-2y.js} +1 -1
- package/ui-dist/assets/{dist-BMlnBah3.js → dist-nqTTbVdA.js} +1 -1
- package/ui-dist/assets/{external-link-CnSDrvJE.js → external-link-tIO7zING.js} +1 -1
- package/ui-dist/assets/{hash-CAnX6PNt.js → hash-JWUyl1pT.js} +1 -1
- package/ui-dist/assets/i18n-CDHMXlRZ.js +1 -0
- package/ui-dist/assets/index-BlH4-cBw.css +1 -0
- package/ui-dist/assets/{index-B0DzQqwv.js → index-C6d0xmtm.js} +3 -3
- package/ui-dist/assets/{label-CtIFj7_6.js → label-BIpeNu4r.js} +1 -1
- package/ui-dist/assets/loader-circle-Cs8XVFTw.js +1 -0
- package/ui-dist/assets/{logos-3KFNiOej.js → logos-DThdM9lk.js} +1 -1
- package/ui-dist/assets/{page-layout-BMwpn87D.js → page-layout-D3Xo605Z.js} +1 -1
- package/ui-dist/assets/plus-PHf8q-Ct.js +1 -0
- package/ui-dist/assets/{popover-BIzq25oH.js → popover-BJRUGA_H.js} +1 -1
- package/ui-dist/assets/provider-models-bz5y28rq.js +1 -0
- package/ui-dist/assets/{react-ji6GGP_j.js → react-7ZHqQtEV.js} +1 -1
- package/ui-dist/assets/refresh-ccw-CC6-_QuL.js +1 -0
- package/ui-dist/assets/{save-CMgYkJ-y.js → save-DJM5RRWW.js} +1 -1
- package/ui-dist/assets/search-C91yH_6y.js +1 -0
- package/ui-dist/assets/{security-config-Xi5DYW7j.js → security-config-T5zpg16O.js} +1 -1
- package/ui-dist/assets/{select-Cz82gl01.js → select-DSkTc61S.js} +1 -1
- package/ui-dist/assets/skeleton-Dzg-HOiN.js +1 -0
- package/ui-dist/assets/{status-dot-C7q1HvLH.js → status-dot-LNBlDu3q.js} +1 -1
- package/ui-dist/assets/{switch-DYswvkYj.js → switch-Bo-Y46HZ.js} +1 -1
- package/ui-dist/assets/tabs-custom-DXv507_2.js +1 -0
- package/ui-dist/assets/{trash-2-DfXI7-ap.js → trash-2-DFZmW6Gg.js} +1 -1
- package/ui-dist/assets/useConfirmDialog-Bs5Ll17m.js +1 -0
- package/ui-dist/assets/{useMutation-s2sn2yzh.js → useMutation-DrZrOgVL.js} +1 -1
- package/ui-dist/assets/x-D7Q1yqSF.js +1 -0
- package/ui-dist/index.html +18 -18
- package/ui-dist/assets/ChatPage-l2PYwCeB.js +0 -38
- package/ui-dist/assets/DocBrowser-CIHLqoIm.js +0 -1
- package/ui-dist/assets/MarketplacePage-TVeyVOuO.js +0 -1
- package/ui-dist/assets/ModelConfig-Dg6F3Ldb.js +0 -1
- package/ui-dist/assets/ProvidersList-f7bQdRxA.js +0 -1
- package/ui-dist/assets/RemoteAccessPage-w_dY7P4T.js +0 -1
- package/ui-dist/assets/RuntimeConfig-M4OKjmgU.js +0 -1
- package/ui-dist/assets/chat-session-display-CGfXhJoT.js +0 -1
- package/ui-dist/assets/i18n-CXBpwAwA.js +0 -1
- package/ui-dist/assets/index-BahpXJg8.css +0 -1
- package/ui-dist/assets/loader-circle-qgU4zQDw.js +0 -1
- package/ui-dist/assets/plus-C9cYVbL-.js +0 -1
- package/ui-dist/assets/provider-models-C8JQUd1E.js +0 -1
- package/ui-dist/assets/search-sl1OeJFl.js +0 -1
- package/ui-dist/assets/skeleton-rgIt7a5q.js +0 -1
- package/ui-dist/assets/tabs-custom-DKYQxrx1.js +0 -1
- package/ui-dist/assets/useConfirmDialog-CXDAxtRL.js +0 -1
- package/ui-dist/assets/x-MIimOGs6.js +0 -1
- /package/ui-dist/assets/{config-hints-fGnUjDe9.js → config-hints-WtpHP_DW.js} +0 -0
- /package/ui-dist/assets/{config-layout-B-7erZRN.js → config-layout-LQ10ozRC.js} +0 -0
- /package/ui-dist/assets/{marketplace-localization-CXeGRf6E.js → marketplace-localization-CxSTG9wr.js} +0 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import{_ as e,a as t,d as n,f as r,g as i,h as a,i as o,m as s,n as c,p as l,u}from"./i18n-CDHMXlRZ.js";import{a as d,c as f,i as p,n as m,o as h,r as g,s as _,u as v}from"./dist-Cl2QB-2y.js";import{c as y,o as b,s as x}from"./chunk-JZWAC4HX-CvRWvTy5.js";import{n as S,t as C}from"./react-7ZHqQtEV.js";import{D as w,O as T,_ as E,a as D,b as O,c as k,d as ee,f as te,g as A,h as j,i as ne,k as M,l as re,m as ie,n as ae,o as oe,p as se,r as N,s as ce,t as le,u as ue,v as de,y as fe}from"./select-DSkTc61S.js";import{t as P}from"./createLucideIcon-CjGHOWb6.js";import{t as pe}from"./book-open-CXoF5nQC.js";import{a as me,c as he,d as ge,i as _e,l as ve,n as ye,o as be,r as xe,s as Se,t as Ce,u as we}from"./chat-session-display-VW6ZMvZP.js";import{t as Te}from"./external-link-tIO7zING.js";import{i as Ee,n as De,o as Oe,t as ke}from"./provider-models-bz5y28rq.js";import{n as Ae,t as je}from"./logos-DThdM9lk.js";import{t as Me}from"./loader-circle-Cs8XVFTw.js";import{a as Ne,c as Pe,i as Fe,l as Ie,n as Le,o as Re,r as ze,s as Be,t as Ve,u as He}from"./MarketplacePage-Cd4faegU.js";import{t as Ue}from"./plus-PHf8q-Ct.js";import{t as We}from"./refresh-ccw-CC6-_QuL.js";import{t as Ge}from"./search-C91yH_6y.js";import{t as Ke}from"./trash-2-DFZmW6Gg.js";import{t as qe}from"./x-D7Q1yqSF.js";import{d as Je}from"./config-DJswxxE8.js";import{i as Ye}from"./DocBrowserContext-YIKkPb76.js";import{F as Xe,G as Ze,I as Qe,K as $e,L as et,N as tt,P as nt,R as rt,S as it,T as at,W as ot,a as st,at as ct,b as lt,c as ut,ct as dt,et as ft,f as pt,ft as mt,gt as ht,ht as gt,i as _t,it as vt,l as yt,lt as bt,n as xt,nt as St,o as Ct,ot as wt,p as Tt,pt as Et,r as Dt,rt as Ot,s as kt,t as At,tt as jt,ut as Mt,y as Nt}from"./index-C6d0xmtm.js";import{a as Pt,c as Ft,i as It,n as Lt,o as Rt,r as zt,s as Bt,t as Vt}from"./popover-BJRUGA_H.js";import{t as Ht}from"./LogoBadge-F7ZWdxLT.js";import{t as Ut}from"./label-BIpeNu4r.js";import{t as Wt}from"./useConfirmDialog-Bs5Ll17m.js";import{n as Gt,t as Kt}from"./page-layout-D3Xo605Z.js";var qt=P(`ArrowUp`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),Jt=P(`Brain`,[[`path`,{d:`M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z`,key:`l5xja`}],[`path`,{d:`M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z`,key:`ep3f8r`}],[`path`,{d:`M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4`,key:`1p4c4q`}],[`path`,{d:`M17.599 6.5a3 3 0 0 0 .399-1.375`,key:`tmeiqw`}],[`path`,{d:`M6.003 5.125A3 3 0 0 0 6.401 6.5`,key:`105sqy`}],[`path`,{d:`M3.477 10.896a4 4 0 0 1 .585-.396`,key:`ql3yin`}],[`path`,{d:`M19.938 10.5a4 4 0 0 1 .585.396`,key:`1qfode`}],[`path`,{d:`M6 18a4 4 0 0 1-1.967-.516`,key:`2e4loj`}],[`path`,{d:`M19.967 17.484A4 4 0 0 1 18 18`,key:`159ez6`}]]),Yt=P(`ChevronRight`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),Xt=P(`CodeXml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),Zt=P(`Copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Qt=P(`Ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),$t=P(`FileText`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),en=P(`FolderOpen`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),tn=P(`FolderUp`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`m9 13 3-3 3 3`,key:`1pxg3c`}]]),nn=P(`FolderX`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`m9.5 10.5 5 5`,key:`ra9qjz`}],[`path`,{d:`m14.5 10.5-5 5`,key:`l2rkpq`}]]),rn=P(`HeartPulse`,[[`path`,{d:`M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z`,key:`c3ymky`}],[`path`,{d:`M3.22 12H9.5l.5-1 2 4.5 2-7 1.5 3.5h5.27`,key:`1uw2ng`}]]),an=P(`House`,[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`1d0kgt`}]]),on=P(`MessageSquareText`,[[`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`,key:`1lielz`}],[`path`,{d:`M13 8H7`,key:`14i4kc`}],[`path`,{d:`M17 12H7`,key:`16if0g`}]]),sn=P(`Minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),cn=P(`Paperclip`,[[`path`,{d:`m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48`,key:`1u3ebp`}]]),ln=P(`Pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),un=P(`Play`,[[`polygon`,{points:`6 3 20 12 6 21 6 3`,key:`1oa8hb`}]]),dn=P(`Power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),fn=P(`Puzzle`,[[`path`,{d:`M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z`,key:`w46dr5`}]]),pn=P(`Terminal`,[[`polyline`,{points:`4 17 10 11 4 5`,key:`akl6gq`}],[`line`,{x1:`12`,x2:`20`,y1:`19`,y2:`19`,key:`q2wloq`}]]),mn=P(`TriangleAlert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),F=e(s(),1),I=(e=>(e.EndpointReady=`endpoint.ready`,e.EndpointError=`endpoint.error`,e.MessageRequest=`message.request`,e.MessageStreamRequest=`message.stream-request`,e.MessageSent=`message.sent`,e.MessageAccepted=`message.accepted`,e.MessageIncoming=`message.incoming`,e.MessageCompleted=`message.completed`,e.MessageFailed=`message.failed`,e.MessageAbort=`message.abort`,e.MessageTextStart=`message.text-start`,e.MessageTextDelta=`message.text-delta`,e.MessageTextEnd=`message.text-end`,e.MessageReasoningStart=`message.reasoning-start`,e.MessageReasoningDelta=`message.reasoning-delta`,e.MessageReasoningEnd=`message.reasoning-end`,e.MessageToolCallStart=`message.tool-call-start`,e.MessageToolCallArgs=`message.tool-call-args`,e.MessageToolCallArgsDelta=`message.tool-call-args-delta`,e.MessageToolCallEnd=`message.tool-call-end`,e.MessageToolCallResult=`message.tool-call-result`,e.MessageRead=`message.read`,e.MessageDelivered=`message.delivered`,e.MessageRecalled=`message.recalled`,e.MessageReaction=`message.reaction`,e.RunStarted=`run.started`,e.RunFinished=`run.finished`,e.RunError=`run.error`,e.RunMetadata=`run.metadata`,e.TypingStart=`typing.start`,e.TypingEnd=`typing.end`,e.PresenceUpdated=`presence.updated`,e))(I||{}),hn=/\[\[\s*reply_to_current\s*\]\]/gi,gn=/\[\[\s*reply_to\s*:\s*([^\]]+?)\s*\]\]/i;function _n(e){if(typeof e!=`string`)return;let t=e.trim();return t.length>0?t:void 0}function vn(e,t){let n=e,r;hn.test(n)&&(r=_n(t),n=n.replace(hn,``).trim());let i=n.match(gn)?.[1];return i&&(r=_n(i),n=n.replace(gn,``).trim()),r?{content:n,replyTo:r}:{content:n}}function yn(e,t=e.id){if(e.role!==`assistant`)return{...e,parts:[...e.parts],metadata:e.metadata?{...e.metadata}:void 0};let n=e.parts.findIndex(e=>e.type===`text`),r=e.metadata?{...e.metadata}:void 0,i=_n(r?.reply_to);if(n<0)return{...e,parts:[...e.parts],metadata:r};let a=e.parts[n];if(!a||a.type!==`text`)return{...e,parts:[...e.parts],metadata:r};let{content:o,replyTo:s}=vn(a.text,t),c=s??i,l=e.parts.flatMap((e,t)=>t!==n||e.type!==`text`?[e]:o.length===0?[]:[{...e,text:o}]);return c?{...e,parts:l,metadata:{...r,reply_to:c}}:{...e,parts:l,metadata:r}}function bn(e){let t=e.split(/\r?\n/),n=`message`,r=[];for(let e of t){let t=e.trimEnd();if(!(!t||t.startsWith(`:`))){if(t.startsWith(`event:`)){n=t.slice(6).trim()||`message`;continue}t.startsWith(`data:`)&&r.push(t.slice(5).trimStart())}}return r.length===0?null:{event:n,data:r.join(`
|
|
2
|
+
`)}}async function*xn(e){let t=e.getReader(),n=new TextDecoder,r=``;try{for(;;){let{value:e,done:i}=await t.read();if(i)break;r+=n.decode(e,{stream:!0});let{frames:a,rest:o}=Sn(r);r=o;for(let e of a)yield e}r+=n.decode();let{frames:e}=Sn(r,!0);for(let t of e)yield t}finally{t.releaseLock()}}function Sn(e,t=!1){let n=e.split(/\r?\n\r?\n/),r=n.pop()??``,i=[];for(let e of n){let t=bn(e);t&&i.push(t)}if(t&&r.trim()){let e=bn(r);return e&&i.push(e),{frames:i,rest:``}}return{frames:i,rest:r}}var Cn=`/ncp/agent`,wn=`ncp-http-agent-client`,Tn=class extends Error{ncpError;alreadyPublished;constructor(e,t=!1){super(e.message),this.name=`NcpHttpAgentClientError(${e.code})`,this.ncpError=e,this.alreadyPublished=t}};function En(e){let t=e.trim();if(!t)throw Error(`NcpHttpAgentClient requires a non-empty baseUrl.`);return new URL(t)}function Dn(e){if(e)return e;if(typeof globalThis.fetch==`function`)return globalThis.fetch.bind(globalThis);throw Error(`No fetch implementation found. Pass options.fetchImpl explicitly.`)}function On(e){let t=(e??Cn).trim();if(!t)return Cn;let n=t.startsWith(`/`)?t:`/${t}`;return n.endsWith(`/`)?n.slice(0,-1):n}async function kn(e){try{return(await e.text()).trim()}catch{return``}}function An(e){if(Pn(e))return e.ncpError;if(Mn(e))return e;let t=e instanceof Error?e.message:String(e??`Unknown error`);return{code:In(void 0),message:t,...e instanceof Error&&e.stack?{details:{stack:e.stack}}:{}}}function jn(e,t={}){return new Tn(e,t.alreadyPublished??!1)}function Mn(e){return Nn(e)&&typeof e.code==`string`&&typeof e.message==`string`}function Nn(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function Pn(e){return e instanceof Tn}var Fn={"config-error":`config-error`,"auth-error":`auth-error`,"runtime-error":`runtime-error`,"timeout-error":`timeout-error`,"abort-error":`abort-error`};function In(e){if(!e)return`runtime-error`;let t=Fn[e];if(t)return t;let n=e.toLowerCase();return n.includes(`timeout`)?`timeout-error`:n.includes(`abort`)||n.includes(`cancel`)?`abort-error`:n.includes(`auth`)?`auth-error`:n.includes(`config`)?`config-error`:`runtime-error`}function Ln(e){let t=zn(e);return!t||typeof t.type!=`string`||!t.type.trim()?null:t}function Rn(e){let t=zn(e);if(!t)return{code:`runtime-error`,message:e||`Unknown stream error.`};let n=typeof t.code==`string`?t.code:void 0,r=In(n),i=Nn(t.details)?t.details:{};return n&&n!==r&&(i.originalCode=n),{code:r,message:typeof t.message==`string`&&t.message?t.message:`Unknown stream error.`,...Object.keys(i).length>0?{details:i}:{}}}function zn(e){try{let t=JSON.parse(e);return Nn(t)?t:null}catch{return null}}var Bn=[`text`,`file`,`source`,`step-start`,`reasoning`,`tool-invocation`,`card`,`rich-text`,`action`,`extension`],Vn=class{manifest;baseUrl;basePath;fetchImpl;defaultHeaders;subscribers=new Set;activeControllers=new Set;started=!1;constructor(e){this.baseUrl=En(e.baseUrl),this.basePath=On(e.basePath),this.fetchImpl=Dn(e.fetchImpl),this.defaultHeaders=e.headers??{},this.manifest={endpointKind:`custom`,endpointId:e.endpointId?.trim()||wn,version:`0.1.0`,supportsStreaming:!0,supportsAbort:!0,supportsProactiveMessages:!1,supportsLiveSessionStream:!0,supportedPartTypes:Bn,expectedLatency:`seconds`,metadata:{transport:`http+sse`,scope:`agent`}}}async start(){this.started||(this.started=!0,this.publish({type:I.EndpointReady}))}async stop(){if(this.started){this.started=!1;for(let e of this.activeControllers)e.abort();this.activeControllers.clear()}}async emit(e){switch(e.type){case`message.request`:await this.send(e.payload);return;case`message.stream-request`:await this.stream(e.payload);return;case`message.abort`:await this.abort(e.payload);return;default:this.publish(e);return}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}async send(e){await this.ensureStarted(),await this.streamRequest({path:`/send`,method:`POST`,body:e})}async stream(e){await this.ensureStarted();let t=new URLSearchParams({sessionId:e.sessionId});await this.streamRequest({path:`/stream?${t.toString()}`,method:`GET`})}async abort(e){await this.ensureStarted();let t=new AbortController;this.activeControllers.add(t);try{let n=await this.fetchImpl(this.resolveUrl(`/abort`),{method:`POST`,headers:{...this.defaultHeaders,"content-type":`application/json`,accept:`application/json`},body:JSON.stringify(e),signal:t.signal});if(!n.ok)throw Error(`Abort request failed with HTTP ${n.status}: ${await kn(n)}`)}catch(e){if(t.signal.aborted)return;let n=An(e);throw this.publish({type:I.EndpointError,payload:n}),jn(n)}finally{this.activeControllers.delete(t)}}async ensureStarted(){this.started||await this.start()}publish(e){for(let t of this.subscribers)t(e)}resolveUrl(e){return new URL(`${this.basePath}${e}`,this.baseUrl)}async streamRequest(e){let t=new AbortController;this.activeControllers.add(t);try{let n=await this.fetchImpl(this.resolveUrl(e.path),{method:e.method,headers:{...this.defaultHeaders,accept:`text/event-stream`,...e.body===void 0?{}:{"content-type":`application/json`}},body:e.body===void 0?void 0:JSON.stringify(e.body),signal:t.signal});if(!n.ok)throw Error(`NCP stream request failed with HTTP ${n.status}: ${await kn(n)}`);if(!n.body)throw Error(`NCP stream response has no body.`);for await(let e of xn(n.body)){if(t.signal.aborted)return;this.handleSseFrame(e)}}catch(e){if(t.signal.aborted)return;if(Pn(e))throw e;let n=An(e);throw this.publish({type:I.EndpointError,payload:n}),jn(n)}finally{this.activeControllers.delete(t)}}handleSseFrame(e){if(e.event===`ncp-event`){let t=Ln(e.data);if(!t){this.publish({type:I.EndpointError,payload:{code:`runtime-error`,message:`Received malformed ncp-event frame.`}});return}this.publish(t);return}if(e.event===`error`){let t=Rn(e.data);throw this.publish({type:I.EndpointError,payload:t}),jn(t,{alreadyPublished:!0})}}};function Hn(e){return{...e,parts:[...e.parts],metadata:e.metadata?{...e.metadata}:void 0}}function Un(e){return Hn(yn(e))}function Wn(e){let t=e.error?.trim();return{code:`runtime-error`,message:t&&t.length>0?t:`Agent run failed.`,details:{sessionId:e.sessionId,messageId:e.messageId,threadId:e.threadId,runId:e.runId}}}function Gn(e,t){return t.trim()?e.id.startsWith(`tool-`)?!0:e.parts.some(e=>e.type===`tool-invocation`):!1}function Kn(e,t,n){for(let[r,i]of e)i===t&&e.set(r,n)}function qn(e,t,n){for(let[r,i]of e)i===n&&(e.delete(r),t.delete(r))}function Jn(e,t){for(let n=e.length-1;n>=0;--n){let r=e[n];if(r.type===`tool-invocation`&&r.toolCallId===t)return r}return null}function Yn(e,t){return Jn(e,t)?.toolName??null}function Xn(e,t){let n=[...e];for(let e=n.length-1;e>=0;--e){let r=n[e];if(r.type===`tool-invocation`&&r.toolCallId===t.toolCallId)return n[e]={...r,...t},n}return n.push(t),n}var Zn=`assistant`,Qn=class{messages=[];streamingMessage=null;error=null;activeRun=null;listeners=new Set;toolCallMessageIdByCallId=new Map;toolCallArgsRawByCallId=new Map;lastSettledRunId=null;snapshotCache=null;snapshotVersion=-1;stateVersion=0;getSnapshot=()=>{if(this.snapshotCache&&this.snapshotVersion===this.stateVersion)return this.snapshotCache;let e={messages:this.messages,streamingMessage:this.streamingMessage,error:this.error?{...this.error,details:this.error.details?{...this.error.details}:void 0}:null,activeRun:this.activeRun?{...this.activeRun}:null};return this.snapshotCache=e,this.snapshotVersion=this.stateVersion,e};subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));reset=()=>{this.messages.length===0&&!this.streamingMessage&&!this.error&&!this.activeRun&&this.toolCallMessageIdByCallId.size===0&&this.toolCallArgsRawByCallId.size===0||(this.messages=[],this.streamingMessage=null,this.error=null,this.activeRun=null,this.toolCallMessageIdByCallId.clear(),this.toolCallArgsRawByCallId.clear(),this.lastSettledRunId=null,this.stateVersion+=1,this.notifyListeners())};hydrate=e=>{this.messages=e.messages.map(e=>Un(e)),this.streamingMessage=null,this.error=null,this.activeRun=e.activeRun?{...e.activeRun,sessionId:e.activeRun.sessionId??e.sessionId,abortDisabledReason:e.activeRun.abortDisabledReason??null}:null,this.toolCallMessageIdByCallId.clear(),this.toolCallArgsRawByCallId.clear(),this.lastSettledRunId=null,this.stateVersion+=1,this.notifyListeners()};dispatch=e=>this.dispatchBatch([e]);dispatchBatch=async e=>{if(!e.length)return;let t=this.stateVersion;e.forEach(this.applyEvent),this.stateVersion!==t&&this.notifyListeners()};applyEvent=e=>{switch(e.type){case I.MessageSent:this.handleMessageSent(e.payload);break;case I.MessageAbort:this.handleMessageAbort(e.payload);break;case I.MessageTextStart:this.handleMessageTextStart(e.payload);break;case I.MessageTextDelta:this.handleMessageTextDelta(e.payload);break;case I.MessageTextEnd:this.handleMessageTextEnd(e.payload);break;case I.MessageReasoningStart:this.handleMessageReasoningStart(e.payload);break;case I.MessageReasoningDelta:this.handleMessageReasoningDelta(e.payload);break;case I.MessageReasoningEnd:this.handleMessageReasoningEnd(e.payload);break;case I.MessageToolCallStart:this.handleMessageToolCallStart(e.payload);break;case I.MessageToolCallArgs:this.handleMessageToolCallArgs(e.payload);break;case I.MessageToolCallArgsDelta:this.handleMessageToolCallArgsDelta(e.payload);break;case I.MessageToolCallEnd:this.handleMessageToolCallEnd(e.payload);break;case I.MessageToolCallResult:this.handleMessageToolCallResult(e.payload);break;case I.RunStarted:this.handleRunStarted(e.payload);break;case I.RunFinished:this.handleRunFinished(e.payload);break;case I.RunError:this.handleRunError(e.payload);break;case I.RunMetadata:this.handleRunMetadata(e.payload);break;case I.EndpointError:this.handleEndpointError(e.payload);break;default:break}};handleMessageSent=e=>{this.upsertMessage(e.message),this.setError(null)};handleMessageAbort=e=>{let t=e.messageId?.trim();if(this.clearActiveRun(),this.setError(null),this.streamingMessage&&(!t||this.streamingMessage.id===t)){let e=this.streamingMessage.id;this.upsertMessage({...this.streamingMessage,status:`final`}),this.replaceStreamingMessage(null),t?qn(this.toolCallMessageIdByCallId,this.toolCallArgsRawByCallId,t):qn(this.toolCallMessageIdByCallId,this.toolCallArgsRawByCallId,e)}};handleMessageTextStart=e=>{this.ensureStreamingMessage(e.sessionId,e.messageId,`streaming`),this.setError(null)};handleMessageTextDelta=e=>{if(!e.delta)return;let t=this.ensureStreamingMessage(e.sessionId,e.messageId,`streaming`),n=[...t.parts],r=n[n.length-1];r?.type===`text`?n[n.length-1]={type:`text`,text:`${r.text}${e.delta}`}:n.push({type:`text`,text:e.delta}),this.replaceStreamingMessage({...t,parts:n,status:`streaming`})};handleMessageTextEnd=e=>{this.streamingMessage?.id===e.messageId&&this.streamingMessage.status===`streaming`&&this.replaceStreamingMessage({...this.streamingMessage,status:`pending`})};handleMessageReasoningStart=e=>{this.ensureStreamingMessage(e.sessionId,e.messageId,`streaming`)};handleMessageReasoningDelta=e=>{if(!e.delta)return;let t=this.ensureStreamingMessage(e.sessionId,e.messageId,`streaming`),n=[...t.parts],r=n[n.length-1];r?.type===`reasoning`?n[n.length-1]={type:`reasoning`,text:`${r.text}${e.delta}`}:n.push({type:`reasoning`,text:e.delta}),this.replaceStreamingMessage({...t,parts:n,status:`streaming`})};handleMessageReasoningEnd=e=>{this.streamingMessage?.id,e.messageId};handleMessageToolCallStart=e=>{let t=this.resolveToolCallTargetMessage(e.sessionId,e.toolCallId,e.messageId);this.toolCallArgsRawByCallId.set(e.toolCallId,``);let n=Xn(t.parts,{type:`tool-invocation`,toolCallId:e.toolCallId,toolName:e.toolName,state:`partial-call`,args:``});this.replaceStreamingMessage({...t,parts:n,status:`streaming`}),this.setError(null)};handleMessageToolCallArgs=e=>{this.toolCallArgsRawByCallId.set(e.toolCallId,e.args),this.applyToolCallArgs(e.sessionId,e.toolCallId,e.args)};handleMessageToolCallArgsDelta=e=>{let t=`${this.toolCallArgsRawByCallId.get(e.toolCallId)??``}${e.delta}`;this.toolCallArgsRawByCallId.set(e.toolCallId,t),this.applyToolCallArgs(e.sessionId,e.toolCallId,t,e.messageId)};handleMessageToolCallEnd=e=>{let t=this.resolveToolCallTargetMessage(e.sessionId,e.toolCallId),n=this.toolCallArgsRawByCallId.get(e.toolCallId)??``,r=Xn(t.parts,{type:`tool-invocation`,toolCallId:e.toolCallId,toolName:Yn(t.parts,e.toolCallId)??`unknown`,state:`call`,args:n});this.replaceStreamingMessage({...t,parts:r,status:`streaming`})};handleMessageToolCallResult=e=>{if(!this.updateMessageContainingToolCall(e.toolCallId,(t,n)=>{let r={type:`tool-invocation`,toolCallId:e.toolCallId,toolName:n.toolName,state:`result`,args:n.args,result:e.content};return Xn(t.parts,r)})){let t=this.resolveToolCallTargetMessage(e.sessionId,e.toolCallId),n=Xn(t.parts,{type:`tool-invocation`,toolCallId:e.toolCallId,toolName:`unknown`,state:`result`,result:e.content});this.replaceStreamingMessage({...t,parts:n,status:`streaming`})}};handleRunStarted=e=>{this.isSettledRunId(e.runId)||(this.setError(null),this.activeRun={runId:e.runId??null,sessionId:e.sessionId},this.stateVersion+=1)};handleRunFinished=e=>{this.markRunAsSettled(e.runId??this.activeRun?.runId??null),this.settleStreamingMessage(`final`),this.setError(null),this.clearActiveRun()};handleRunError=e=>{this.markRunAsSettled(e.runId??this.activeRun?.runId??null),this.settleStreamingMessage(`error`),this.setError(Wn(e)),this.clearActiveRun()};handleRunMetadata=e=>{let t=e.metadata;if(t?.kind===`ready`){let e=t;if(this.isSettledRunId(e.runId))return;this.activeRun={runId:e.runId??this.activeRun?.runId??null,sessionId:e.sessionId??this.activeRun?.sessionId,abortDisabledReason:e.supportsAbort===!1?e.abortDisabledReason??`Unsupported`:null},this.stateVersion+=1}else t?.kind===`final`&&(this.markRunAsSettled(e.runId??this.activeRun?.runId??null),this.clearActiveRun())};handleEndpointError=e=>{if(e.code===`abort-error`){this.handleMessageAbort({sessionId:this.activeRun?.sessionId??this.streamingMessage?.sessionId??``,...this.streamingMessage?.id?{messageId:this.streamingMessage.id}:{}});return}this.settleStreamingMessage(`error`),this.clearActiveRun(),this.setError(e)};applyToolCallArgs=(e,t,n,r)=>{let i=this.resolveToolCallTargetMessage(e,t,r),a=Yn(i.parts,t)??`unknown`,o=Xn(i.parts,{type:`tool-invocation`,toolCallId:t,toolName:a,state:`partial-call`,args:n});this.replaceStreamingMessage({...i,parts:o,status:`streaming`})};ensureStreamingMessage=(e,t,n)=>{if(this.streamingMessage?.id===t){if(this.streamingMessage.status===n)return this.streamingMessage;let e={...this.streamingMessage,status:n};return this.replaceStreamingMessage(e),e}let r=this.messages.findIndex(e=>e.id===t);if(r>=0){let t=Hn(this.messages[r]),i=[...this.messages];i.splice(r,1),this.messages=i,this.stateVersion+=1;let a={...t,sessionId:e,status:n};return this.replaceStreamingMessage(a),a}let i=this.streamingMessage;if(i&&i.id!==t&&i.sessionId===e&&Gn(i,t)){let r={...i,id:t,sessionId:e,status:n};return Kn(this.toolCallMessageIdByCallId,i.id,t),this.replaceStreamingMessage(r),r}let a={id:t,sessionId:e,role:Zn,status:n,parts:[],timestamp:new Date().toISOString()};return this.replaceStreamingMessage(a),a};resolveToolCallTargetMessage=(e,t,n)=>{let r=n?.trim()||this.toolCallMessageIdByCallId.get(t)||this.streamingMessage?.id||`tool-${t}`;return this.toolCallMessageIdByCallId.set(t,r),this.ensureStreamingMessage(e,r,`streaming`)};updateMessageContainingToolCall=(e,t)=>{if(this.streamingMessage){let n=Jn(this.streamingMessage.parts,e);if(n){let e=t(this.streamingMessage,n);return this.replaceStreamingMessage({...this.streamingMessage,parts:e}),!0}}for(let n=this.messages.length-1;n>=0;--n){let r=this.messages[n],i=Jn(r.parts,e);if(!i)continue;let a=[...this.messages];return a[n]={...r,parts:t(r,i)},this.messages=a,this.stateVersion+=1,!0}return!1};upsertMessage=e=>{let t=Un(e),n=this.messages.findIndex(e=>e.id===t.id);if(n<0){this.messages=[...this.messages,t],this.stateVersion+=1;return}let r=[...this.messages];r[n]=t,this.messages=r,this.stateVersion+=1};replaceStreamingMessage=e=>{!e&&!this.streamingMessage||(this.streamingMessage=e?Un(e):null,this.stateVersion+=1)};setError=e=>{this.error?.code===e?.code&&this.error?.message===e?.message&&this.error?.details===e?.details&&this.error?.cause===e?.cause||(this.error=e?{...e,details:e.details?{...e.details}:void 0}:null,this.stateVersion+=1)};clearActiveRun=()=>{this.activeRun&&(this.activeRun=null,this.stateVersion+=1)};isSettledRunId=e=>!!e?.trim()&&e===this.lastSettledRunId;markRunAsSettled=e=>{this.lastSettledRunId=e?.trim()||null};settleStreamingMessage=e=>{if(!this.streamingMessage)return;let t={...this.streamingMessage,status:e};this.upsertMessage(t),this.replaceStreamingMessage(null),qn(this.toolCallMessageIdByCallId,this.toolCallArgsRawByCallId,t.id)};notifyListeners=()=>{let e=this.getSnapshot();for(let t of this.listeners)t(e)}},$n=16,er=class{constructor(e){this.dispatchBatch=e,this.queue=[],this.flushTimerId=null,this.isFlushing=!1,this.isDisposed=!1,this.enqueue=e=>{this.isDisposed||(this.queue.push(e),this.scheduleFlush())},this.dispose=()=>{this.isDisposed=!0,this.flushTimerId!==null&&(window.clearTimeout(this.flushTimerId),this.flushTimerId=null),this.queue.length=0},this.scheduleFlush=()=>{this.flushTimerId!==null||this.isFlushing||this.queue.length===0||(this.flushTimerId=window.setTimeout(()=>{this.flushTimerId=null,this.flush()},$n))},this.flush=async()=>{if(!(this.isDisposed||this.isFlushing||this.queue.length===0)){this.isFlushing=!0;try{for(;this.queue.length>0;){let e=this.queue.splice(0);await this.dispatchBatch(e)}}finally{this.isFlushing=!1,this.scheduleFlush()}}}}};function tr(e,t){let n=e.dispatchBatch;return typeof n==`function`?n.call(e,t):t.reduce((t,n)=>t.then(()=>e.dispatch(n)),Promise.resolve())}function nr(e,t){let n=`payload`in e?e.payload:null;return!n||typeof n!=`object`||!(`sessionId`in n)||typeof n.sessionId!=`string`?!0:n.sessionId===t}function rr(e){return e.parts.some(e=>e.type===`text`||e.type===`rich-text`||e.type===`reasoning`?e.text.trim().length>0:!0)}function ir(e,t){if(typeof e==`string`){let n=e.trim();return n?{sessionId:t,message:{id:`user-${Date.now().toString(36)}`,sessionId:t,role:`user`,status:`final`,parts:[{type:`text`,text:n}],timestamp:new Date().toISOString()}}:null}return rr(e.message)?{...e,sessionId:e.sessionId,message:{...e.message,sessionId:e.message.sessionId||e.sessionId}}:null}function ar(e){let t=(0,F.useRef)();return(!t.current||t.current.sessionId!==e)&&(t.current={sessionId:e,manager:new Qn}),t.current.manager}function or({sessionId:e,client:t,manager:n}){let r=(0,F.useSyncExternalStore)(e=>n.subscribe(()=>e()),()=>n.getSnapshot(),()=>n.getSnapshot()),[i,a]=(0,F.useState)(!1);(0,F.useEffect)(()=>{a(!1)},[e]),(0,F.useEffect)(()=>{let r=new er(e=>tr(n,e)),i=t.subscribe(t=>{nr(t,e)&&r.enqueue(t)});return()=>{i(),r.dispose(),t.stop()}},[t,n,e]);let o=r.streamingMessage?[...r.messages,r.streamingMessage]:r.messages,s=r.activeRun?.runId??null,c=!!r.activeRun;return{snapshot:r,visibleMessages:o,activeRunId:s,isRunning:c,isSending:i,send:async r=>{if(i||c)return;let o=ir(r,e);if(o){a(!0),await n.dispatch({type:I.MessageSent,payload:{sessionId:e,message:o.message,metadata:o.metadata}});try{await t.send(o)}finally{a(!1)}}},abort:async()=>{r.activeRun&&await t.abort({sessionId:e})},streamRun:async()=>{r.activeRun&&await t.stream({sessionId:e})}}}function sr(e){return e instanceof Error?e:Error(String(e))}function cr(e){return e.isHydrating||e.hydratedSessionId!==e.sessionId}function lr({sessionId:e,client:t,loadSeed:n,autoResumeRunningSession:r=!0}){let i=ar(e),a=or({sessionId:e,client:t,manager:i}),[o,s]=(0,F.useState)(!0),[c,l]=(0,F.useState)(null),[u,d]=(0,F.useState)(null),f=(0,F.useRef)({requestId:0,controller:null}),p=(0,F.useCallback)(async()=>{f.current.controller?.abort();let a=new AbortController,o=f.current.requestId+1;f.current={requestId:o,controller:a},await t.stop(),i.reset(),l(null),s(!0);try{let c=await n(e,a.signal);if(a.signal.aborted||f.current.requestId!==o)return;i.hydrate({sessionId:e,messages:c.messages,activeRun:c.status===`running`?{runId:null,sessionId:e,abortDisabledReason:null}:null}),l(null),d(e),s(!1),c.status===`running`&&r&&t.stream({sessionId:e}).catch(e=>{f.current.requestId===o&&l(sr(e))})}catch(t){if(a.signal.aborted||f.current.requestId!==o)return;l(sr(t)),d(e),s(!1)}finally{f.current.controller===a&&(f.current.controller=null)}},[r,t,n,i,e]);return(0,F.useEffect)(()=>(p(),()=>{f.current.controller?.abort(),f.current.controller=null}),[p]),{...a,isHydrating:cr({sessionId:e,hydratedSessionId:u,isHydrating:o}),hydrateError:c}}var ur=200*1024*1024,dr=`application/octet-stream`;function fr(e){let t=e.type.trim().toLowerCase();return t.length>0?t:dr}function pr(e,t){let n=t.acceptedMimeTypes&&t.acceptedMimeTypes.length>0?new Set(t.acceptedMimeTypes.map(e=>e.trim().toLowerCase())):null,r=t.maxBytes??209715200,i=fr(e);return n&&!n.has(i)?{ok:!1,rejected:{fileName:e.name,mimeType:i,sizeBytes:e.size,reason:`unsupported-type`}}:e.size>r?{ok:!1,rejected:{fileName:e.name,mimeType:i,sizeBytes:e.size,reason:`too-large`}}:{ok:!0,mimeType:i}}function mr(e){let t=e.parts&&e.parts.length>0?e.parts.map(e=>structuredClone(e)):[...e.text?.trim()??``?[{type:`text`,text:e.text.trim()}]:[],...(e.attachments??[]).map(e=>({type:`file`,name:e.name,mimeType:e.mimeType,...e.assetUri?.trim()?{assetUri:e.assetUri.trim()}:{},...e.url?.trim()?{url:e.url.trim()}:{},...e.contentBase64?.trim()?{contentBase64:e.contentBase64.trim()}:{},sizeBytes:e.sizeBytes}))];if(t.length===0)return null;let n=e.timestamp??new Date().toISOString(),r=e.messageId??`user-${Date.now().toString(36)}`;return{sessionId:e.sessionId,message:{id:r,sessionId:e.sessionId,role:`user`,status:`final`,parts:t,timestamp:n,...e.metadata?{metadata:e.metadata}:{}},...e.metadata?{metadata:e.metadata}:{}}}async function hr(e,t){let n=[],r=[];for(let i of e){let e=pr(i,t);if(!e.ok){r.push(e.rejected);continue}n.push(i)}if(n.length===0)return{attachments:[],rejected:r};try{return{attachments:await t.uploadBatch(n),rejected:r}}catch{return r.push(...n.map(e=>({fileName:e.name,mimeType:fr(e),sizeBytes:e.size,reason:`read-failed`}))),{attachments:[],rejected:r}}}var L=l(),gr={connected:{dotClass:`bg-emerald-500`},disconnected:{dotClass:`h-2.5 w-2.5 rounded-full border border-gray-400 bg-transparent`},connecting:{dotClass:`text-amber-600`}};function _r({status:e,className:t}){let n=gr[e],r=o(e===`connected`?`connected`:e===`disconnected`?`disconnected`:`connecting`);return(0,L.jsx)(Fe,{delayDuration:250,children:(0,L.jsxs)(Le,{children:[(0,L.jsx)(Ne,{asChild:!0,children:(0,L.jsx)(`span`,{role:`status`,"aria-label":r,className:u(`inline-flex h-5 w-5 items-center justify-center`,t),children:e===`connecting`?(0,L.jsx)(Me,{className:u(`h-3 w-3 animate-spin`,n.dotClass)}):(0,L.jsx)(`span`,{className:u(e===`connected`?`h-2 w-2 rounded-full`:``,n.dotClass)})})}),(0,L.jsx)(ze,{side:`bottom`,className:`text-xs`,children:r})]})})}var vr={wx:`weixin`,lark:`feishu`},yr={heartbeat:{icon:`heartbeat`},cron:{icon:`cron`}},br={codex:`chatSessionTypeCodex`,claude:`chatSessionTypeClaude`};function xr(e){return e?.trim().toLowerCase()??``}function Sr(e){return e.split(/[-_]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function Cr(e,t){let n=xr(e);if(!n||n===`native`)return null;let r=t.find(e=>xr(e.value)===n);return r?.label.trim()?r.label.trim():Sr(n)}function wr(e){let t=xr(e);if(!t)return null;let n=vr[t]??t;return je(n)?n:null}function Tr(e,t){let n=wr(e.channel??``);if(n)return{icon:{kind:`channel-logo`,channel:n},label:null};let r=yr[xr(e.type)];if(r)return{icon:{kind:`symbol`,icon:r.icon},label:null};let i=br[xr(e.sessionType)];return i?{icon:null,label:o(i)}:{icon:null,label:Cr(e.sessionType,t)}}function Er({icon:e,className:t}){return e.kind===`channel-logo`?(0,L.jsx)(Dr,{channel:e.channel,className:t}):e.icon===`heartbeat`?(0,L.jsx)(rn,{className:u(`h-3.5 w-3.5`,t)}):(0,L.jsx)(ht,{className:u(`h-3.5 w-3.5`,t)})}function Dr({channel:e,className:t}){return(0,L.jsx)(Ht,{name:e,src:je(e),className:u(`h-4 w-4 rounded-[4px] border border-gray-200/80 bg-white`,t),imgClassName:`h-3 w-3 object-contain`,fallback:(0,L.jsx)(ge,{className:`h-3 w-3 text-gray-500`})})}function Or(e){let{session:t,active:n,runStatus:r,context:i,title:a,isEditing:s,draftLabel:l,isSaving:d,onSelect:f,onStartEditing:p,onDraftLabelChange:m,onSave:g,onCancel:_}=e,v=n?`text-gray-700`:`text-gray-500`;return(0,L.jsx)(`div`,{className:u(`w-full rounded-xl px-3 py-2 text-left transition-all text-[13px]`,n?`bg-gray-200 text-gray-900 font-semibold shadow-sm`:`text-gray-700 hover:bg-gray-200/60 hover:text-gray-900`),children:s?(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(ot,{value:l,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),g()):e.key===`Escape`&&(e.preventDefault(),_())},placeholder:o(`sessionsLabelPlaceholder`),className:`h-8 rounded-lg border-gray-300 bg-white text-xs`,autoFocus:!0,disabled:d}),(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,L.jsx)(`div`,{className:`min-w-0 text-[11px] text-gray-400 truncate`,children:t.key}),(0,L.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,L.jsx)(h,{type:`button`,size:`icon`,variant:`ghost`,className:`h-7 w-7 rounded-lg text-gray-500 hover:bg-white hover:text-gray-900`,onClick:()=>void g(),disabled:d,"aria-label":o(`save`),children:(0,L.jsx)(M,{className:`h-3.5 w-3.5`})}),(0,L.jsx)(h,{type:`button`,size:`icon`,variant:`ghost`,className:`h-7 w-7 rounded-lg text-gray-500 hover:bg-white hover:text-gray-900`,onClick:_,disabled:d,"aria-label":o(`cancel`),children:(0,L.jsx)(qe,{className:`h-3.5 w-3.5`})})]})]})]}):(0,L.jsxs)(`div`,{className:`group/session relative`,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:f,className:`w-full text-left`,children:[(0,L.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_0.875rem] items-center gap-1.5 pr-8`,children:[(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,L.jsx)(`span`,{className:`truncate font-medium`,children:a}),i.label?(0,L.jsx)(`span`,{className:u(`shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-semibold leading-none`,n?`border-gray-300 bg-white/80 text-gray-700`:`border-gray-200 bg-gray-100 text-gray-500`),children:i.label}):null,i.icon?(0,L.jsx)(`span`,{className:`inline-flex h-[1.125rem] w-[1.125rem] shrink-0 items-center justify-center`,children:(0,L.jsx)(Er,{icon:i.icon,className:v})}):null]}),(0,L.jsx)(`span`,{className:`inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center`,children:r?(0,L.jsx)(he,{status:r}):null})]}),(0,L.jsxs)(`div`,{className:`mt-0.5 text-[11px] text-gray-400 truncate`,children:[t.messageCount,` · `,c(t.updatedAt)]})]}),(0,L.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),p()},className:u(`absolute right-0 top-0 inline-flex h-7 w-7 items-center justify-center rounded-lg text-gray-400 transition-all hover:bg-white hover:text-gray-900`,n?`opacity-100`:`opacity-0 group-hover/session:opacity-100 group-focus-within/session:opacity-100`),"aria-label":o(`edit`),children:(0,L.jsx)(ln,{className:`h-3.5 w-3.5`})})]})})}function kr(){let e=v();return async t=>{try{et(e,await Xe(t.sessionKey,t.patch)),m.success(t.successMessage??o(`configSavedApplied`))}catch(e){throw m.error(o(`configSaveFailed`)+`: `+(e instanceof Error?e.message:String(e))),e}}}function Ar(){let e=kr();return async t=>{await e({sessionKey:t.sessionKey,patch:{label:t.label},successMessage:o(`configSavedApplied`)})}}var jr={selectedSessionKey:null,selectedAgentId:`main`,query:``},R=C(e=>({snapshot:jr,setSnapshot:t=>e(e=>({snapshot:{...e.snapshot,...t}}))}));function Mr(e,t){return e.filter(e=>ye(e,t))}function Nr(e={}){let t=R(e=>e.snapshot.query),n=lt({limit:e.limit??200}),r=(0,F.useMemo)(()=>{let e=n.data?.sessions??[],r=Mr(_e(e),t),i=new Map(e.map(e=>[e.sessionId,e]));return r.map(e=>({session:e,runStatus:i.get(e.key)?.status===`running`?`running`:void 0}))},[t,n.data?.sessions]);return{isLoading:n.isLoading,items:r}}var Pr=(0,F.createContext)(null);function Fr({presenter:e,children:t}){return(0,L.jsx)(Pr.Provider,{value:e,children:t})}function Ir(){let e=(0,F.useContext)(Pr);if(!e)throw Error(`usePresenter must be used inside ChatPresenterProvider`);return e}var Lr=e=>`[data-item-index="${e}"]`;function Rr(e){let t=e.getItemSelector??Lr;(0,F.useEffect)(()=>{if(!e.isEnabled||e.itemCount===0)return;let n=e.containerRef.current;n&&n.querySelector(t(e.activeIndex))?.scrollIntoView({block:`nearest`,inline:`nearest`})},[t,e.activeIndex,e.containerRef,e.isEnabled,e.itemCount])}function zr(){let e=(0,F.useRef)(null),[t,n]=(0,F.useState)(null);return(0,F.useEffect)(()=>{let t=e.current;if(!t||typeof ResizeObserver>`u`)return;let r=()=>{n(t.getBoundingClientRect().width)};r();let i=new ResizeObserver(()=>r());return i.observe(t),()=>i.disconnect()},[]),{elementRef:e,width:t}}function z(...e){return n(r(e))}var Br=F.forwardRef(({className:e,type:t,...n},r)=>(0,L.jsx)(`input`,{type:t,className:z(`flex h-9 w-full rounded-xl border border-gray-200/80 bg-white px-3.5 py-2 text-sm text-gray-900 file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-gray-300 placeholder:font-normal focus:outline-none focus:ring-1 focus:ring-primary/40 focus:border-primary/40 transition-colors disabled:cursor-not-allowed disabled:opacity-50`,e),ref:r,...n}));Br.displayName=`ChatInput`;var Vr=Bt,Hr=Ft,Ur=It,Wr=F.forwardRef(({className:e,sideOffset:t=8,align:n=`start`,...r},i)=>(0,L.jsx)(Rt,{children:(0,L.jsx)(Pt,{ref:i,sideOffset:t,align:n,className:z(`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})}));Wr.displayName=Pt.displayName;var Gr=ie,Kr=ce,qr=fe,Jr=F.forwardRef(({className:e,children:t,...n},r)=>(0,L.jsxs)(de,{ref:r,className:z(`flex h-9 w-full items-center justify-between whitespace-nowrap rounded-xl border border-gray-200/80 bg-white px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary/40 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1`,e),...n,children:[t,(0,L.jsx)(k,{asChild:!0,children:(0,L.jsx)(T,{className:`h-4 w-4 opacity-50`})})]}));Jr.displayName=de.displayName;var Yr=F.forwardRef(({className:e,...t},n)=>(0,L.jsx)(A,{ref:n,className:z(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,L.jsx)(w,{className:`h-4 w-4`})}));Yr.displayName=A.displayName;var Xr=F.forwardRef(({className:e,...t},n)=>(0,L.jsx)(j,{ref:n,className:z(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,L.jsx)(T,{className:`h-4 w-4`})}));Xr.displayName=j.displayName;var Zr=F.forwardRef(({className:e,children:t,position:n=`popper`,...r},i)=>(0,L.jsx)(se,{children:(0,L.jsxs)(oe,{ref:i,className:z(`relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md bg-white text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-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`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,...r,children:[(0,L.jsx)(Yr,{}),(0,L.jsx)(O,{className:z(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]`),children:t}),(0,L.jsx)(Xr,{})]})}));Zr.displayName=oe.displayName;var Qr=F.forwardRef(({className:e,...t},n)=>(0,L.jsx)(te,{ref:n,className:z(`px-2 py-1 text-[11px] font-semibold uppercase tracking-[0.08em] text-gray-500`,e),...t}));Qr.displayName=te.displayName;var $r=F.forwardRef(({className:e,children:t,...n},r)=>(0,L.jsxs)(re,{ref:r,className:z(`relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-gray-100 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 hover:bg-gray-100`,e),...n,children:[(0,L.jsx)(`span`,{className:`absolute right-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,L.jsx)(ue,{children:(0,L.jsx)(M,{className:`h-4 w-4`})})}),(0,L.jsx)(ee,{children:t})]}));$r.displayName=re.displayName;var ei=F.forwardRef(({className:e,...t},n)=>(0,L.jsx)(E,{ref:n,className:z(`-mx-1 my-1 h-px bg-gray-100`,e),...t}));ei.displayName=E.displayName;var ti=Pe,ni=Ie,ri=He,ii=F.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,L.jsx)(Be,{children:(0,L.jsx)(Re,{ref:r,sideOffset:t,className:z(`z-[var(--z-tooltip)] overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md 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),...n})}));ii.displayName=Re.displayName;var ai={Popover:Vr,PopoverAnchor:Ur,PopoverContent:Wr,PopoverTrigger:Hr,Input:Br,Select:Gr,SelectContent:Zr,SelectGroup:Kr,SelectItem:$r,SelectLabel:Qr,SelectSeparator:ei,SelectTrigger:Jr,SelectValue:qr,Tooltip:ni,TooltipContent:ii,TooltipProvider:ti,TooltipTrigger:ri},oi=680,si=.82,ci=560;function li(e){let{Popover:t,PopoverAnchor:n,PopoverContent:r}=ai,{elementRef:i,width:a}=zr(),o=(0,F.useRef)(null),{isOpen:s,isLoading:c,items:l,activeIndex:u,activeItem:d,texts:f,onSelectItem:p,onOpenChange:m,onSetActiveIndex:h}=e,g=(0,F.useMemo)(()=>{if(a)return Math.min(a>ci?a*si:a,oi)},[a]);return Rr({containerRef:o,activeIndex:u,itemCount:l.length,isEnabled:s&&!c,getItemSelector:e=>`[data-slash-index="${e}"]`}),(0,L.jsxs)(t,{open:s,onOpenChange:m,children:[(0,L.jsx)(n,{asChild:!0,children:(0,L.jsx)(`div`,{ref:i,className:`pointer-events-none absolute bottom-full left-3 right-3 h-0`})}),(0,L.jsx)(r,{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:e=>e.preventDefault(),style:g?{width:`${g}px`}:void 0,children:(0,L.jsxs)(`div`,{className:`grid min-h-[240px] grid-cols-[minmax(220px,300px)_minmax(0,1fr)]`,children:[(0,L.jsx)(`div`,{ref:o,role:`listbox`,"aria-label":f.slashSectionLabel,className:`custom-scrollbar max-h-[320px] overflow-y-auto border-r border-gray-200 p-2.5`,children:c?(0,L.jsx)(`div`,{className:`p-2 text-xs text-gray-500`,children:f.slashLoadingLabel}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`mb-2 px-2 text-[11px] font-semibold uppercase tracking-wide text-gray-500`,children:f.slashSectionLabel}),l.length===0?(0,L.jsx)(`div`,{className:`px-2 text-xs text-gray-400`,children:f.slashEmptyLabel}):(0,L.jsx)(`div`,{className:`space-y-1`,children:l.map((e,t)=>{let n=t===u;return(0,L.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n,"data-slash-index":t,onMouseEnter:()=>h(t),onClick:()=>p(e),className:`flex w-full items-start gap-2 rounded-lg px-2 py-1.5 text-left transition ${n?`bg-gray-100 text-gray-900`:`text-gray-700 hover:bg-gray-50`}`,children:[(0,L.jsx)(`span`,{className:`truncate text-xs font-semibold`,children:e.title}),(0,L.jsx)(`span`,{className:`truncate text-xs text-gray-500`,children:e.subtitle})]},e.key)})})]})}),(0,L.jsx)(`div`,{className:`max-w-[320px] p-3.5`,children:d?(0,L.jsxs)(`div`,{className:`space-y-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`inline-flex rounded-full bg-primary/10 px-2 py-0.5 text-[11px] font-semibold text-primary`,children:d.subtitle}),(0,L.jsx)(`span`,{className:`text-sm font-semibold text-gray-900`,children:d.title})]}),(0,L.jsx)(`p`,{className:`text-xs leading-5 text-gray-600`,children:d.description}),(0,L.jsx)(`div`,{className:`space-y-1`,children:d.detailLines.map(e=>(0,L.jsx)(`div`,{className:`rounded-md bg-gray-50 px-2 py-1 text-[11px] text-gray-600`,children:e},e))}),(0,L.jsx)(`div`,{className:`pt-1 text-[11px] text-gray-500`,children:f.slashSkillHintLabel})]}):(0,L.jsx)(`div`,{className:`text-xs text-gray-500`,children:f.slashHintLabel})})]})})]})}var ui=_(`inline-flex items-center justify-center whitespace-nowrap rounded-full text-sm font-medium ring-offset-background transition-all duration-fast focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary-600 active:bg-primary-700 shadow-sm`,destructive:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,outline:`border border-gray-200 bg-white hover:bg-gray-50 hover:text-gray-800 text-gray-600`,secondary:`bg-gray-100 text-gray-700 hover:bg-gray-200/80`,ghost:`hover:bg-gray-100/80 hover:text-gray-800`,link:`text-primary underline-offset-4 hover:underline`,primary:`bg-primary text-primary-foreground hover:bg-primary-600 active:bg-primary-700 shadow-sm`,subtle:`bg-gray-100 text-gray-600 hover:bg-gray-200/80`,"primary-outline":`border border-primary/30 text-primary hover:bg-primary hover:text-primary-foreground`},size:{default:`h-9 px-4 py-2`,sm:`h-8 px-3 text-xs`,lg:`h-11 px-5 text-[14px]`,xl:`h-12 px-6 text-[15px]`,icon:`h-9 w-9`}},defaultVariants:{variant:`default`,size:`default`}}),di=F.forwardRef(({className:e,variant:t,size:n,...r},i)=>(0,L.jsx)(`button`,{className:z(ui({variant:t,size:n,className:e})),ref:i,...r}));di.displayName=`ChatButton`;function fi(){return(0,L.jsx)(`span`,{"aria-hidden":`true`,"data-testid":`chat-stop-icon`,className:`block h-3 w-3 rounded-[2px] bg-gray-700 shadow-[inset_0_0_0_1px_rgba(17,24,39,0.06)]`})}function pi(e){let{Tooltip:t,TooltipContent:n,TooltipProvider:r,TooltipTrigger:i}=ai;return(0,L.jsxs)(`div`,{className:`flex flex-col items-end gap-1`,children:[e.sendError?.trim()?(0,L.jsx)(`div`,{className:`max-w-[420px] text-right text-[11px] text-red-600`,children:e.sendError}):null,(0,L.jsx)(`div`,{className:`flex items-center gap-2`,children:e.isSending?e.canStopGeneration?(0,L.jsx)(di,{size:`icon`,variant:`outline`,className:`h-8 w-8 rounded-full`,"aria-label":e.stopButtonLabel,onClick:()=>void e.onStop(),disabled:e.stopDisabled,children:(0,L.jsx)(fi,{})}):(0,L.jsx)(r,{children:(0,L.jsxs)(t,{children:[(0,L.jsx)(i,{asChild:!0,children:(0,L.jsx)(`span`,{children:(0,L.jsx)(di,{size:`icon`,variant:`outline`,className:`h-8 w-8 rounded-full`,"aria-label":e.stopButtonLabel,disabled:!0,children:(0,L.jsx)(fi,{})})})}),(0,L.jsx)(n,{side:`top`,children:(0,L.jsx)(`p`,{className:`text-xs`,children:e.stopHint})})]})}):(0,L.jsx)(di,{size:`icon`,className:`h-8 w-8 rounded-full`,"aria-label":e.sendButtonLabel,onClick:()=>void e.onSend(),disabled:e.sendDisabled,children:(0,L.jsx)(qt,{className:`h-5 w-5`})})})]})}function mi(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>[e.label,e.key,e.description].filter(e=>typeof e==`string`&&e.trim().length>0).join(` `).toLowerCase().includes(n)):e}function hi(e){let{Input:t,Popover:n,PopoverContent:r,PopoverTrigger:i}=ai,{picker:a}=e,o=(0,F.useRef)(null),s=(0,F.useId)(),[c,l]=(0,F.useState)(``),[u,d]=(0,F.useState)(0),f=(0,F.useMemo)(()=>new Set(a.selectedKeys),[a.selectedKeys]),p=a.selectedKeys.length,m=c.trim().length>0,h=(0,F.useMemo)(()=>{if(m)return null;let e=a.groups?.filter(e=>e.options.length>0)??[];return e.length>0?e:null},[m,a.groups]),g=(0,F.useMemo)(()=>h?h.flatMap(e=>e.options):mi(a.options,c),[h,a.options,c]);(0,F.useEffect)(()=>{d(0)},[c]),(0,F.useEffect)(()=>{d(e=>g.length===0?0:Math.min(e,g.length-1))},[g.length]),Rr({containerRef:o,activeIndex:u,itemCount:g.length,isEnabled:g.length>0,getItemSelector:e=>`[data-skill-index="${e}"]`});let _=e=>{if(f.has(e)){a.onSelectedKeysChange(a.selectedKeys.filter(t=>t!==e));return}a.onSelectedKeysChange([...a.selectedKeys,e])},v=e=>{if(g.length!==0){if(e.key===`ArrowDown`){e.preventDefault(),d(e=>Math.min(e+1,g.length-1));return}if(e.key===`ArrowUp`){e.preventDefault(),d(e=>Math.max(e-1,0));return}if(e.key===`Enter`){e.preventDefault();let t=g[u];t&&_(t.key)}}};return(0,L.jsxs)(n,{children:[(0,L.jsx)(i,{asChild:!0,children:(0,L.jsxs)(`button`,{type:`button`,"aria-haspopup":`listbox`,className:`inline-flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900`,children:[(0,L.jsx)(gt,{className:`h-4 w-4`}),(0,L.jsx)(`span`,{children:a.title}),p>0?(0,L.jsx)(`span`,{className:`ml-0.5 flex h-[18px] min-w-[18px] items-center justify-center rounded-full bg-primary/10 text-[10px] font-semibold text-primary`,children:p}):null]})}),(0,L.jsxs)(r,{side:`top`,align:`start`,className:`w-[360px] p-0`,children:[(0,L.jsxs)(`div`,{className:`space-y-2 border-b border-gray-100 px-4 py-3`,children:[(0,L.jsx)(`div`,{className:`text-sm font-semibold text-gray-900`,children:a.title}),(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(Ge,{className:`pointer-events-none absolute left-3 top-2.5 h-3.5 w-3.5 text-gray-400`}),(0,L.jsx)(t,{value:c,onChange:e=>l(e.target.value),onKeyDown:v,placeholder:a.searchPlaceholder,role:`combobox`,"aria-controls":s,"aria-expanded":`true`,"aria-autocomplete":`list`,"aria-activedescendant":g[u]?`${s}-option-${u}`:void 0,className:`h-8 rounded-lg pl-8 text-xs`})]})]}),(0,L.jsx)(`div`,{ref:o,id:s,role:`listbox`,"aria-multiselectable":`true`,className:`custom-scrollbar max-h-[320px] overflow-y-auto`,children:a.isLoading?(0,L.jsx)(`div`,{className:`p-4 text-xs text-gray-500`,children:a.loadingLabel}):g.length===0?(0,L.jsx)(`div`,{className:`p-4 text-center text-xs text-gray-500`,children:a.emptyLabel}):(0,L.jsx)(`div`,{className:`py-1`,children:(()=>{let e=h??[{key:`all-skills`,options:g}],t=0;return e.map(e=>(0,L.jsxs)(`div`,{children:[e.label?(0,L.jsx)(`div`,{className:`px-4 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-wide text-gray-500`,children:e.label}):null,e.options.map(e=>{let n=t;t+=1;let r=f.has(e.key),i=n===u;return(0,L.jsxs)(`button`,{type:`button`,id:`${s}-option-${n}`,role:`option`,"aria-selected":r,"data-skill-index":n,onClick:()=>_(e.key),onMouseEnter:()=>d(n),className:`flex w-full items-center gap-3 px-4 py-2.5 text-left transition-colors ${i?`bg-gray-50`:`hover:bg-gray-50`}`,children:[(0,L.jsx)(`div`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-gray-100 text-gray-500`,children:(0,L.jsx)(fn,{className:`h-4 w-4`})}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,L.jsx)(`span`,{className:`truncate text-sm text-gray-900`,children:e.label}),e.badgeLabel?(0,L.jsx)(`span`,{className:`shrink-0 rounded-full bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`,children:e.badgeLabel}):null]}),(0,L.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-gray-500`,children:e.description||e.key})]}),(0,L.jsx)(`div`,{className:`ml-3 shrink-0`,children:(0,L.jsx)(`span`,{className:r?`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:r?(0,L.jsx)(M,{className:`h-3 w-3`}):null})})]},e.key)})]},e.key))})()})}),a.manageHref&&a.manageLabel?(0,L.jsx)(`div`,{className:`border-t border-gray-100 px-4 py-2.5`,children:(0,L.jsxs)(`a`,{href:a.manageHref,className:`inline-flex items-center gap-1.5 text-xs font-medium text-primary transition-colors hover:text-primary/80`,children:[a.manageLabel,(0,L.jsx)(Te,{className:`h-3 w-3`})]})}):null]})]})}function gi({icon:e}){return e===`sparkles`?(0,L.jsx)(dt,{className:`h-3.5 w-3.5 shrink-0 text-primary`}):e===`brain`?(0,L.jsx)(Jt,{className:`h-3.5 w-3.5 shrink-0 text-gray-500`}):null}function _i({icon:e}){return e===`paperclip`?(0,L.jsx)(cn,{className:`h-4 w-4`}):(0,L.jsx)(gi,{icon:e})}function vi(e){return e===`model`?`min-w-[220px]`:e===`session-type`?`min-w-[140px]`:e===`thinking`?`min-w-[150px]`:``}function yi(e){return e===`model`?`w-[320px]`:e===`session-type`?`w-[220px]`:e===`thinking`?`w-[180px]`:``}function bi({item:e}){let{Select:t,SelectContent:n,SelectGroup:r,SelectItem:i,SelectLabel:a,SelectSeparator:o,SelectTrigger:s,SelectValue:c}=ai,l=e.groups?.filter(e=>e.options.length>0)??(e.options.length>0?[{key:`${e.key}-default`,options:e.options}]:[]),u=l.some(e=>e.options.length>0);return(0,L.jsxs)(t,{value:e.value,onValueChange:e.onValueChange,disabled:e.disabled,children:[(0,L.jsx)(s,{className:`h-8 w-auto rounded-lg border-0 bg-transparent px-3 text-xs font-medium text-gray-600 shadow-none hover:bg-gray-100 focus:ring-0 ${vi(e.key)}`,children:e.selectedLabel?(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-left`,children:[(0,L.jsx)(gi,{icon:e.icon}),(0,L.jsx)(`span`,{className:`truncate text-xs font-semibold text-gray-700`,children:e.selectedLabel})]}):e.loading?(0,L.jsx)(`div`,{className:`h-3 w-24 animate-pulse rounded bg-gray-200`}):(0,L.jsx)(c,{placeholder:e.placeholder})}),(0,L.jsxs)(n,{className:yi(e.key),children:[u?null:e.loading?(0,L.jsxs)(`div`,{className:`space-y-2 px-3 py-2`,children:[(0,L.jsx)(`div`,{className:`h-3 w-36 animate-pulse rounded bg-gray-200`}),(0,L.jsx)(`div`,{className:`h-3 w-28 animate-pulse rounded bg-gray-200`}),(0,L.jsx)(`div`,{className:`h-3 w-32 animate-pulse rounded bg-gray-200`})]}):e.emptyLabel?(0,L.jsx)(`div`,{className:`px-3 py-2 text-xs text-gray-500`,children:e.emptyLabel}):null,l.map((e,t)=>(0,L.jsxs)(`div`,{children:[t>0?(0,L.jsx)(o,{}):null,(0,L.jsxs)(r,{children:[e.label?(0,L.jsx)(a,{children:e.label}):null,e.options.map(e=>(0,L.jsx)(i,{value:e.value,className:`py-2`,children:e.description?(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,L.jsx)(`span`,{className:`truncate text-xs font-semibold text-gray-800`,children:e.label}),(0,L.jsx)(`span`,{className:`truncate text-[11px] text-gray-500`,children:e.description})]}):(0,L.jsx)(`span`,{className:`truncate text-xs font-semibold text-gray-800`,children:e.label})},e.value))]})]},e.key))]})]})}function xi(e){let{Tooltip:t,TooltipContent:n,TooltipProvider:r,TooltipTrigger:i}=ai;return(0,L.jsxs)(`div`,{className:`flex items-center justify-between px-3 pb-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-1`,children:[e.skillPicker?(0,L.jsx)(hi,{picker:e.skillPicker}):null,e.selects.map(e=>(0,L.jsx)(bi,{item:e},e.key)),e.accessories?.map(e=>{let a=(0,L.jsxs)(`button`,{type:`button`,className:`inline-flex items-center rounded-lg py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900 disabled:cursor-not-allowed disabled:text-gray-400 ${e.iconOnly?`h-8 w-8 justify-center px-0`:`gap-1.5 px-3`}`,onClick:e.onClick,disabled:e.disabled,"aria-label":e.label,children:[(0,L.jsx)(_i,{icon:e.icon}),e.iconOnly?null:(0,L.jsx)(`span`,{children:e.label})]});return e.tooltip?(0,L.jsx)(r,{children:(0,L.jsxs)(t,{children:[(0,L.jsx)(i,{asChild:!0,children:e.disabled?(0,L.jsx)(`span`,{className:`inline-flex`,children:a}):a}),(0,L.jsx)(n,{side:`top`,children:(0,L.jsx)(`p`,{className:`text-xs`,children:e.tooltip})})]})},e.key):(0,L.jsx)(`div`,{children:a},e.key)})]}),(0,L.jsx)(pi,{...e.actions})]})}function Si(){return`composer-${Math.random().toString(36).slice(2,10)}`}function Ci(e=``){return{id:Si(),type:`text`,text:e}}function wi(e){return{id:Si(),type:`token`,tokenKind:e.tokenKind,tokenKey:e.tokenKey,label:e.label}}function Ti(e){return e.type===`text`?e.text.length:1}function Ei(){return[Ci(``)]}function Di(e){return[Ci(e)]}function Oi(e){let t=[];for(let n of e){if(n.type===`text`){if(n.text.length===0)continue;let e=t[t.length-1];if(e?.type===`text`){t[t.length-1]={...e,text:e.text+n.text};continue}}t.push(n)}return t.length===0?Ei():t}function ki(e){return e.map(e=>e.type===`text`?e.text:``).join(``)}function Ai(e){return e.filter(e=>e.type===`text`).map(e=>e.text).join(``)}function ji(e,t){let n=[],r=new Set;for(let i of e)i.type!==`token`||i.tokenKind!==t||r.has(i.tokenKey)||(r.add(i.tokenKey),n.push(i.tokenKey));return n}function Mi(e,t,n,r){let i=Math.max(0,n-t),a=Math.max(0,t+e.text.length-r),o=[];return i>0&&o.push({...e,text:e.text.slice(0,i)}),a>0&&o.push({...e,text:e.text.slice(e.text.length-a)}),o}function Ni(e,t,n,r){return t<=n||e>=r}function Pi(e,t,n,r,i){return!n&&r>=i?(e.push(...t),!0):n}function Fi(e,t,n,r,i,a,o){let s=Mi(t,n,r,i);s[0]&&e.push(s[0]);let c=o;return c||=(e.push(...a),!0),s[1]&&e.push(s[1]),c}function Ii(e,t,n,r,i,a){return!r&&i<=a?(e.push(...n),!0):(e.push(t),r)}function Li(e,t,n,r){let i=Math.max(0,t),a=Math.max(i,n),o=[],s=0,c=!1;for(let t of e){let e=Ti(t),n=s,l=s+e;if(Ni(n,l,i,a)){c=Pi(o,r,c,n,a),o.push(t),s=l;continue}c=t.type===`text`?Fi(o,t,n,i,a,r,c):Ii(o,t,r,c,i,n),s=l}return c||o.push(...r),Oi(o)}function Ri(e,t){return Oi(e.filter(e=>e.type!==`token`||!t(e)))}function zi(e,t){if(!t||t.start!==t.end)return null;let n=ki(e),r=t.end,i=n.slice(0,r),a=/(?:^|\s)\/([^\s\uFFFC]*)$/.exec(i);if(!a)return null;let o=r-a[0].length+(a[0].startsWith(`/`)?0:1);return{query:(a[1]??``).trim().toLowerCase(),start:o,end:r}}function Bi(e,t,n){return e?e.start<n&&e.end>t:!1}function Vi(e){let t=new Map,n=0;for(let r of e)t.set(r.id,n),n+=Ti(r);return t}function Hi(e,t){let n=t;for(;n&&n.parentNode!==e;)n=n.parentNode;return n?Array.prototype.indexOf.call(e.childNodes,n):e.childNodes.length}function Ui(e,t,n){if(e instanceof HTMLElement){let t=e.dataset.composerNodeId;if(t)return n.find(e=>e.id===t)}return n[t]}function Wi(e,t,n){let r=0;for(let i=0;i<n;i+=1){let n=Ui(e.childNodes[i],i,t);n&&(r+=Ti(n))}return r}function Gi(e,t,n,r){let i=Hi(e,t),a=Wi(e,r,i),o=r[i];return o?.type===`text`?a+Math.min(n,o.text.length):a+Math.min(n,t.textContent?.length??0)}function Ki(e,t,n,r,i){return n.type===`text`?e.nodeType===Node.TEXT_NODE?r+Math.min(t,n.text.length):e===i?r+(t>0?n.text.length:0):r+n.text.length:e===i?r+(t>0?1:0):r+1}function qi(e,t,n,r,i){if(t===e)return Wi(e,r,n);if(t.nodeType===Node.TEXT_NODE&&t.parentNode===e)return Gi(e,t,n,r);let a=t instanceof HTMLElement?t.closest(`[data-composer-node-id]`):t.parentElement?.closest(`[data-composer-node-id]`)??null;if(!(a instanceof HTMLElement))return qi(e,e,Hi(e,t),r,i);let o=a.dataset.composerNodeId;if(!o)return 0;let s=r.find(e=>e.id===o),c=i.get(o)??0;return s?Ki(t,n,s,c,a):c}function Ji(e,t){let n=window.getSelection();if(!n||n.rangeCount===0)return null;let r=n.getRangeAt(0);if(!e.contains(r.startContainer)||!e.contains(r.endContainer))return null;let i=Vi(t),a=qi(e,r.startContainer,r.startOffset,t,i),o=qi(e,r.endContainer,r.endOffset,t,i);return{start:Math.min(a,o),end:Math.max(a,o)}}function Yi(e,t,n){if(!n)return;let r=window.getSelection();if(!r)return;let i=n=>{let r=0;for(let i=0;i<t.length;i+=1){let a=t[i],o=Ti(a),s=r,c=r+o,l=e.childNodes[i];if(!l){r=c;continue}if(a.type===`text`){if(n<=c)return{container:l.firstChild??l,offset:Math.max(0,Math.min(n-s,a.text.length))}}else{if(n<=s)return{container:e,offset:i};if(n<=c)return{container:e,offset:i+1}}r=c}return{container:e,offset:e.childNodes.length}},a=i(n.start),o=i(n.end),s=document.createRange();s.setStart(a.container,a.offset),s.setEnd(o.container,o.offset),r.removeAllRanges(),r.addRange(s)}function Xi(e){let t=[];for(let n of Array.from(e.childNodes)){if(n.nodeType===Node.TEXT_NODE){t.push(Ci(n.textContent??``));continue}if(!(n instanceof HTMLElement))continue;if(n.dataset.composerNodeType===`token`){let e=n.dataset.composerTokenKind,r=n.dataset.composerTokenKey,i=n.dataset.composerLabel;e&&r&&i&&t.push({id:n.dataset.composerNodeId??wi({tokenKind:e,tokenKey:r,label:i}).id,type:`token`,tokenKind:e,tokenKey:r,label:i});continue}let e=n.textContent??``;t.push({id:n.dataset.composerNodeId??Ci(e).id,type:`text`,text:e})}return Oi(t)}function Zi(e){let t=Xi(e);return{nodes:t,selection:Ji(e,t)}}var Qi=class{constructor(){this.nodes=Ei(),this.selection=null,this.sync=(e,t)=>(this.nodes=Oi(e),this.selection=t,this.getSnapshot()),this.setSelection=e=>(this.selection=e,this.getSnapshot()),this.replaceDocument=(e,t)=>(this.nodes=Oi(e),this.selection=t,this.getSnapshot()),this.insertText=e=>{let t=this.selection??{start:0,end:0};this.nodes=Li(this.nodes,t.start,t.end,[Ci(e)]);let n=t.start+e.length;return this.selection={start:n,end:n},this.getSnapshot()},this.insertFileToken=(e,t)=>this.insertToken(`file`,e,t),this.insertSkillToken=(e,t)=>this.getSelectedSkillKeys().includes(e)?this.getSnapshot():this.insertToken(`skill`,e,t,this.getSlashTrigger()),this.syncSelectedSkills=(e,t)=>{let n=this.getSelectedSkillKeys(),r=new Map(t.map(e=>[e.key,e])),i=e.find(e=>!n.includes(e));if(i){let e=r.get(i);return this.insertSkillToken(i,e?.label??i)}let a=n.find(t=>!e.includes(t));return a&&(this.nodes=Ri(this.nodes,e=>e.tokenKind===`skill`&&e.tokenKey===a)),this.getSnapshot()},this.deleteContent=e=>{let t=this.getDocumentLength(),n=this.selection??{start:t,end:t},r=n.start,i=n.end;if(n.start===n.end)if(e===`backward`&&n.start>0)r=n.start-1;else if(e===`forward`)i=n.end+1;else return this.getSnapshot();return this.nodes=Li(this.nodes,r,i,[]),this.selection={start:r,end:r},this.getSnapshot()},this.getSnapshot=()=>({nodes:this.nodes,selection:this.selection,nodeStartMap:Vi(this.nodes),documentLength:this.getDocumentLength(),selectedSkillKeys:this.getSelectedSkillKeys(),slashTrigger:this.getSlashTrigger()}),this.getDocumentLength=()=>this.nodes.reduce((e,t)=>e+Ti(t),0),this.getSelectedSkillKeys=()=>ji(this.nodes,`skill`),this.insertToken=(e,t,n,r=null)=>{let i=this.getDocumentLength(),a=r?.start??this.selection?.start??i,o=r?.end??this.selection?.end??a;return this.nodes=Li(this.nodes,a,o,[wi({tokenKind:e,tokenKey:t,label:n})]),this.selection={start:a+1,end:a+1},this.getSnapshot()},this.getSlashTrigger=()=>zi(this.nodes,this.selection)}};function $i(e){let{key:t,shiftKey:n,isComposing:r,isSlashMenuOpen:i,slashItemCount:a,activeSlashIndex:o,isSending:s,canStopGeneration:c}=e;if(t===`Enter`&&!n&&s)return{type:`consume`};if(i&&a>0){if(t===`ArrowDown`)return{type:`move-slash-index`,index:(o+1)%a};if(t===`ArrowUp`)return{type:`move-slash-index`,index:(o-1+a)%a};if(t===`Enter`&&!n||t===`Tab`)return{type:`insert-active-slash-item`}}return t===`Escape`?i?{type:`close-slash`}:s&&c?{type:`stop-generation`}:{type:`noop`}:t===`Enter`&&n?{type:`insert-line-break`}:t===`Enter`?{type:`send-message`}:!r&&(t===`Backspace`||t===`Delete`)?{type:`delete-content`,direction:t===`Backspace`?`backward`:`forward`}:{type:`noop`}}var ea=`http://www.w3.org/2000/svg`,ta=class{constructor(){this.render=(e,t)=>{if(!e)return;let n=document.createDocumentFragment();for(let e of t.nodes){let r=e.type===`text`?this.createTextNodeElement(e):this.createTokenNodeElement(e,t.selectedRange,t.nodeStartMap);r&&n.appendChild(r)}e.replaceChildren(n)},this.createTextNodeElement=e=>{if(e.text.length===0)return null;let t=document.createElement(`span`);return t.dataset.composerNodeId=e.id,t.dataset.composerNodeType=`text`,t.textContent=e.text,t},this.createTokenNodeElement=(e,t,n)=>{let r=n.get(e.id)??0,i=Bi(t,r,r+1),a=document.createElement(`span`);a.contentEditable=`false`,a.dataset.composerNodeId=e.id,a.dataset.composerNodeType=`token`,a.dataset.composerTokenKind=e.tokenKind,a.dataset.composerTokenKey=e.tokenKey,a.dataset.composerLabel=e.label,a.title=e.label,a.className=this.buildTokenClassName(e.tokenKind,i),a.append(this.createTokenIcon(e.tokenKind));let o=document.createElement(`span`);return o.className=e.tokenKind===`file`?`min-w-0 flex-1 truncate text-[12px] font-medium text-slate-700`:`truncate`,o.textContent=e.label,a.append(o),a},this.buildTokenClassName=(e,t)=>e===`file`?[`mx-[2px]`,`inline-flex`,`h-7`,`max-w-[min(100%,17rem)]`,`items-center`,`gap-1.5`,`rounded-lg`,`border`,`px-2`,`align-baseline`,`transition-[border-color,background-color,box-shadow,color]`,`duration-150`,t?`border-slate-300 bg-slate-100 text-slate-800 shadow-[0_0_0_2px_rgba(148,163,184,0.14)]`:`border-slate-200/80 bg-slate-50 text-slate-700`].join(` `):[`mx-[2px]`,`inline-flex`,`h-7`,`max-w-full`,`items-center`,`gap-1.5`,`rounded-lg`,`border`,`px-2`,`align-baseline`,`text-[11px]`,`font-medium`,`transition`,t?`border-primary/30 bg-primary/18 text-primary`:`border-primary/12 bg-primary/8 text-primary`].join(` `),this.createTokenIcon=e=>{let t=document.createElement(`span`);return t.className=e===`file`?`inline-flex h-4.5 w-4.5 shrink-0 items-center justify-center rounded-md bg-white text-slate-500 ring-1 ring-black/5`:`inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center text-primary/70`,t.append(e===`file`?this.createFileIcon():this.createSkillIcon()),t},this.createSkillIcon=()=>this.createSvgIcon([{tag:`path`,attrs:{d:`M8.5 2.75 2.75 6l5.75 3.25L14.25 6 8.5 2.75Z`}},{tag:`path`,attrs:{d:`M2.75 10 8.5 13.25 14.25 10`}},{tag:`path`,attrs:{d:`M2.75 6v4l5.75 3.25V9.25L2.75 6Z`}},{tag:`path`,attrs:{d:`M14.25 6v4L8.5 13.25V9.25L14.25 6Z`}}]),this.createFileIcon=()=>this.createSvgIcon([{tag:`path`,attrs:{d:`M3.25 4.25A1.5 1.5 0 0 1 4.75 2.75h6.5a1.5 1.5 0 0 1 1.5 1.5v7.5a1.5 1.5 0 0 1-1.5 1.5h-6.5a1.5 1.5 0 0 1-1.5-1.5v-7.5Z`}},{tag:`path`,attrs:{d:`m4.75 10 2.25-2.5 1.75 1.75 1.25-1.25 2 2`}},{tag:`path`,attrs:{d:`M9.75 6.25h.01`}}]),this.createSvgIcon=e=>{let t=document.createElementNS(ea,`svg`);t.setAttribute(`viewBox`,`0 0 16 16`),t.setAttribute(`fill`,`none`),t.setAttribute(`stroke`,`currentColor`),t.setAttribute(`stroke-width`,`1.25`),t.setAttribute(`stroke-linecap`,`round`),t.setAttribute(`stroke-linejoin`,`round`),t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`class`,`h-3 w-3`);for(let n of e){let e=document.createElementNS(ea,n.tag);for(let[t,r]of Object.entries(n.attrs))e.setAttribute(t,r);t.append(e)}return t}}},na=188,ra=class{constructor(e){this.controller=e,this.surfaceRenderer=new ta,this.sync=(e,t)=>this.controller.sync(e,t),this.syncSelectionFromRoot=e=>this.controller.setSelection(Ji(e,this.controller.getSnapshot().nodes)),this.restoreSelectionIfFocused=(e,t)=>{!e||document.activeElement!==e||Yi(e,this.controller.getSnapshot().nodes,t)},this.syncViewport=e=>{e&&(e.style.maxHeight=`${na}px`,e.style.overflowY=e.scrollHeight>na?`auto`:`hidden`)},this.renderSurface=e=>{this.surfaceRenderer.render(e.root,{nodes:e.snapshot.nodes,selectedRange:e.selectedRange,nodeStartMap:e.snapshot.nodeStartMap})},this.insertSlashItem=(e,t)=>{e.value&&t(this.controller.insertSkillToken(e.value,e.title))},this.syncSelectedSkills=(e,t,n)=>{n(this.controller.syncSelectedSkills(e,t))},this.handleBeforeInput=e=>{let{event:t,disabled:n,isComposing:r,commitSnapshot:i}=e,a=t.nativeEvent;n||r||a.isComposing||!(a.inputType===`insertText`||a.inputType===`insertReplacementText`)||!a.data||(t.preventDefault(),i(this.controller.insertText(a.data)))},this.handleInput=e=>{let{event:t,isComposing:n,commitSnapshot:r}=e,i=t.nativeEvent;if(n||i.isComposing)return;let a=t.currentTarget,o=Zi(a);r(this.controller.replaceDocument(o.nodes,o.selection))},this.handleCompositionEnd=e=>{let{event:t,commitSnapshot:n}=e,r=t.currentTarget,i=Zi(r);n(this.controller.replaceDocument(i.nodes,i.selection))},this.handleKeyDown=e=>{let{event:t,slashItems:n,activeSlashIndex:r,activeSlashItem:i,actions:a,commitSnapshot:o,insertSkillToken:s,onSlashItemSelect:c,onSlashActiveIndexChange:l,onSlashQueryChange:u,onSlashOpenChange:d}=e,f=this.controller.getSnapshot(),p=$i({key:t.key,shiftKey:t.shiftKey,isComposing:t.nativeEvent.isComposing,isSlashMenuOpen:f.slashTrigger!==null,slashItemCount:n.length,activeSlashIndex:r,isSending:a.isSending,canStopGeneration:a.canStopGeneration});p.type!==`noop`&&(t.preventDefault(),this.applyKeyboardAction({action:p,activeSlashItem:i,actions:a,commitSnapshot:o,insertSkillToken:s,onSlashItemSelect:c,onSlashActiveIndexChange:l,onSlashQueryChange:u,onSlashOpenChange:d}))},this.handlePaste=e=>{let{event:t,onFilesAdd:n,commitSnapshot:r}=e,i=Array.from(t.clipboardData.files??[]);if(i.length>0&&n){t.preventDefault(),n(i);return}let a=t.clipboardData.getData(`text/plain`);a&&(t.preventDefault(),r(this.controller.insertText(a)))},this.handleBlur=e=>{let{clearSelectedRange:t,onSlashQueryChange:n,onSlashOpenChange:r}=e;t(),n?.(null),r(!1)},this.applyKeyboardAction=e=>{let{action:t,activeSlashItem:n,actions:r,commitSnapshot:i,insertSkillToken:a,onSlashItemSelect:o,onSlashActiveIndexChange:s,onSlashQueryChange:c,onSlashOpenChange:l}=e;switch(t.type){case`move-slash-index`:s(t.index);return;case`insert-active-slash-item`:if(!n)return;o?.(n),a(n.value??n.key,n.title);return;case`close-slash`:c?.(null),l(!1);return;case`consume`:return;case`stop-generation`:r.onStop();return;case`insert-line-break`:i(this.controller.insertText(`
|
|
3
|
+
`));return;case`send-message`:r.onSend();return;case`delete-content`:i(this.controller.deleteContent(t.direction));return;case`noop`:return}}}},ia=class{constructor(){this.controller=new Qi,this.viewController=new ra(this.controller),this.rootElement=null,this.selection=null,this.selectedRange=null,this.snapshot=this.controller.getSnapshot(),this.config=null,this.isComposing=!1,this.bindRootElement=e=>{this.rootElement=e},this.update=e=>(this.config=e,this.snapshot=this.viewController.sync(e.nodes,this.selectedRange),{snapshot:this.snapshot,selectedRange:this.selectedRange,bindRootElement:this.bindRootElement,handleBeforeInput:this.handleBeforeInput,handleInput:this.handleInput,handleCompositionStart:this.handleCompositionStart,handleCompositionEnd:this.handleCompositionEnd,handleKeyDown:this.handleKeyDown,handlePaste:this.handlePaste,handleBlur:this.handleBlur,syncSelectionState:this.syncSelectionState,imperativeHandle:this.createHandle()}),this.createHandle=()=>({insertSlashItem:e=>{this.config?.onSlashItemSelect?.(e),this.viewController.insertSlashItem(e,this.commitSnapshot)},insertFileToken:(e,t)=>{this.commitSnapshot(this.controller.insertFileToken(e,t)),this.focusComposerSoon()},insertFileTokens:e=>{let t=null;for(let n of e)t=this.controller.insertFileToken(n.tokenKey,n.label);t&&(this.commitSnapshot(t),this.focusComposerSoon())},focusComposer:()=>{this.focusComposer()},syncSelectedSkills:(e,t)=>{this.viewController.syncSelectedSkills(e,t,this.commitSnapshot)}}),this.restoreDomAfterCommit=()=>{this.isComposing||this.viewController.restoreSelectionIfFocused(this.rootElement,this.selection)},this.renderSurface=()=>{this.isComposing||this.viewController.renderSurface({root:this.rootElement,snapshot:this.snapshot,selectedRange:this.selectedRange})},this.syncViewport=()=>{this.viewController.syncViewport(this.rootElement)},this.syncSelectionState=()=>{if(!this.rootElement||this.isComposing)return;let e=this.viewController.syncSelectionFromRoot(this.rootElement);this.selection=e.selection,this.selectedRange=e.selection,this.syncSlashState(e),this.requestRender()},this.handleBeforeInput=e=>{this.viewController.handleBeforeInput({event:e,disabled:this.requireConfig().disabled,isComposing:this.isComposing,commitSnapshot:this.commitSnapshot})},this.handleInput=e=>{this.viewController.handleInput({event:e,isComposing:this.isComposing,commitSnapshot:this.commitSnapshot})},this.handleCompositionStart=()=>{this.isComposing=!0},this.handleCompositionEnd=e=>{this.isComposing=!1,this.viewController.handleCompositionEnd({event:e,commitSnapshot:this.commitSnapshot})},this.handleKeyDown=e=>{let t=this.requireConfig();if(this.rootElement&&!this.isComposing){let e=this.viewController.syncSelectionFromRoot(this.rootElement);this.selection=e.selection,this.selectedRange=e.selection,this.snapshot=e}let n=t.slashItems[t.activeSlashIndex]??null;this.viewController.handleKeyDown({event:e,slashItems:t.slashItems,activeSlashIndex:t.activeSlashIndex,activeSlashItem:n,actions:t.actions,commitSnapshot:this.commitSnapshot,insertSkillToken:this.insertSkillToken,onSlashItemSelect:t.onSlashItemSelect,onSlashActiveIndexChange:t.onSlashActiveIndexChange,onSlashQueryChange:t.onSlashQueryChange,onSlashOpenChange:t.onSlashOpenChange})},this.handlePaste=e=>{this.viewController.handlePaste({event:e,onFilesAdd:this.requireConfig().onFilesAdd,commitSnapshot:this.commitSnapshot})},this.handleBlur=()=>{let e=this.requireConfig();this.isComposing=!1,this.viewController.handleBlur({clearSelectedRange:this.clearSelectedRange,onSlashQueryChange:e.onSlashQueryChange,onSlashOpenChange:e.onSlashOpenChange})},this.setSelectedRange=e=>{this.selectedRange=e,this.selection=e,this.requestRender()},this.clearSelectedRange=()=>{this.selectedRange=null,this.requestRender()},this.commitSnapshot=e=>{let t=this.requireConfig();this.selection=e.selection,this.selectedRange=e.selection,this.snapshot=e,t.onNodesChange(e.nodes),this.syncSlashState(e)},this.insertSkillToken=(e,t)=>{this.commitSnapshot(this.controller.insertSkillToken(e,t))},this.syncSlashState=e=>{let t=this.requireConfig();t.onSlashTriggerChange?.(e.slashTrigger),t.onSlashQueryChange?.(e.slashTrigger?.query??null),t.onSlashOpenChange(e.slashTrigger!==null)},this.requestRender=()=>{this.requireConfig().requestRender()},this.focusComposerSoon=()=>{if(typeof requestAnimationFrame==`function`){requestAnimationFrame(()=>this.focusComposer());return}this.focusComposer()},this.focusComposer=()=>{if(!this.rootElement)return;let e=this.selection;this.rootElement.focus();let t=()=>{this.rootElement&&(this.selection=e,this.selectedRange=e,this.viewController.restoreSelectionIfFocused(this.rootElement,e))};if(typeof requestAnimationFrame==`function`){requestAnimationFrame(t);return}t()},this.requireConfig=()=>{if(!this.config)throw Error(`ChatComposerRuntime is not configured.`);return this.config}}},aa=(0,F.forwardRef)(function(e,t){let{nodes:n,placeholder:r,disabled:i,slashItems:a,onSlashItemSelect:o,actions:s,onNodesChange:c,onFilesAdd:l,onSlashQueryChange:u,onSlashTriggerChange:d,onSlashOpenChange:f,onSlashActiveIndexChange:p,activeSlashIndex:m}=e,[h,g]=(0,F.useState)(0),[_]=(0,F.useState)(()=>new ia),{snapshot:v,bindRootElement:y,handleBeforeInput:b,handleInput:x,handleCompositionStart:S,handleCompositionEnd:C,handleKeyDown:w,handlePaste:T,handleBlur:E,syncSelectionState:D,imperativeHandle:O}=_.update({nodes:n,disabled:i,slashItems:a,onSlashItemSelect:o,actions:s,onNodesChange:c,onFilesAdd:l,onSlashQueryChange:u,onSlashTriggerChange:d,onSlashOpenChange:f,onSlashActiveIndexChange:p,activeSlashIndex:m,requestRender:()=>g(e=>e+1)});return(0,F.useImperativeHandle)(t,()=>O,[O]),(0,F.useLayoutEffect)(()=>{_.renderSurface(),_.restoreDomAfterCommit(),_.syncViewport()},[_,v.nodes,v.nodeStartMap,h]),(0,L.jsx)(`div`,{className:`px-4 py-2.5`,children:(0,L.jsx)(`div`,{className:`min-h-[60px]`,children:(0,L.jsx)(`div`,{ref:y,contentEditable:!i,suppressContentEditableWarning:!0,role:`textbox`,"aria-multiline":`true`,"data-placeholder":r,onBeforeInput:b,onInput:x,onCompositionStart:S,onCompositionEnd:C,onKeyDown:w,onKeyUp:D,onMouseUp:D,onFocus:D,onBlur:E,onPaste:T,className:`min-h-7 max-h-[188px] w-full overflow-y-auto whitespace-pre-wrap break-words bg-transparent py-0.5 text-sm leading-6 text-gray-800 outline-none empty:before:pointer-events-none empty:before:text-gray-400 empty:before:content-[attr(data-placeholder)]`})})})});function oa({hint:e}){return e?e.loading?(0,L.jsx)(`div`,{className:`px-4 pb-2`,children:(0,L.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-lg border border-gray-200 bg-gray-50 px-3 py-2`,children:[(0,L.jsx)(`span`,{className:`h-3 w-28 animate-pulse rounded bg-gray-200`}),(0,L.jsx)(`span`,{className:`h-3 w-16 animate-pulse rounded bg-gray-200`})]})}):(0,L.jsx)(`div`,{className:`px-4 pb-2`,children:(0,L.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-lg px-3 py-1.5 text-xs ${e.tone===`warning`?`border-amber-200 bg-amber-50 text-amber-800`:`border-gray-200 bg-gray-50 text-gray-700`}`,children:[e.text?(0,L.jsx)(`span`,{children:e.text}):null,e.actionLabel&&e.onAction?(0,L.jsx)(`button`,{type:`button`,onClick:e.onAction,className:`font-semibold underline-offset-2 hover:underline`,children:e.actionLabel}):null]})}):null}var sa=(0,F.forwardRef)(function(e,t){let n=(0,F.useRef)(null),[r,i]=(0,F.useState)(null),[a,o]=(0,F.useState)(0),[s,c]=(0,F.useState)(null),[l,u]=(0,F.useState)(null),d=s!==null&&l!==s,f=e.slashMenu.items[a]??null;(0,F.useEffect)(()=>{o(t=>e.slashMenu.items.length===0?0:Math.min(t,e.slashMenu.items.length-1))},[e.slashMenu.items.length]),(0,F.useEffect)(()=>{r!==null&&o(0)},[r]),(0,F.useEffect)(()=>{s===null&&l!==null&&u(null)},[s,l]);let p=(0,F.useMemo)(()=>e.toolbar.skillPicker?{...e.toolbar,skillPicker:{...e.toolbar.skillPicker,onSelectedKeysChange:t=>{n.current?.syncSelectedSkills(t,e.toolbar.skillPicker?.options??[])}}}:e.toolbar,[e.toolbar]);return(0,F.useImperativeHandle)(t,()=>({insertFileToken:(e,t)=>n.current?.insertFileToken(e,t),insertFileTokens:e=>n.current?.insertFileTokens(e),focusComposer:()=>n.current?.focusComposer()}),[]),(0,L.jsx)(`div`,{className:`border-t border-gray-200/80 bg-white p-4`,children:(0,L.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)]`,children:(0,L.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-card`,children:[(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(aa,{ref:n,nodes:e.composer.nodes,placeholder:e.composer.placeholder,disabled:e.composer.disabled,slashItems:e.slashMenu.items,onSlashItemSelect:e.slashMenu.onSelectItem,actions:e.toolbar.actions,activeSlashIndex:a,onNodesChange:e.composer.onNodesChange,onFilesAdd:e.composer.onFilesAdd,onSlashQueryChange:t=>{i(t),e.composer.onSlashQueryChange?.(t)},onSlashTriggerChange:e=>{c(e?.start??null)},onSlashOpenChange:e=>{!e&&s!==null&&u(s)},onSlashActiveIndexChange:o}),(0,L.jsx)(li,{isOpen:d,isLoading:e.slashMenu.isLoading,items:e.slashMenu.items,activeIndex:a,activeItem:f,texts:e.slashMenu.texts,onSelectItem:e=>{u(null),n.current?.insertSlashItem(e)},onOpenChange:e=>{!e&&s!==null&&u(s)},onSetActiveIndex:o})]}),(0,L.jsx)(oa,{hint:e.hint}),(0,L.jsx)(xi,{...p})]})})})});sa.displayName=`ChatInputBar`;function ca({role:e}){return e===`user`?(0,L.jsx)(`div`,{"data-testid":`chat-message-avatar-user`,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary text-white shadow-sm`,children:(0,L.jsx)(ve,{className:`h-4 w-4`})}):e===`tool`?(0,L.jsx)(`div`,{"data-testid":`chat-message-avatar-tool`,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-amber-100 text-amber-700 shadow-sm`,children:(0,L.jsx)(wt,{className:`h-4 w-4`})}):(0,L.jsx)(`div`,{"data-testid":`chat-message-avatar-assistant`,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-gradient-to-b from-gray-700 to-gray-950 text-white shadow-md ring-1 ring-inset ring-white/20`,children:(0,L.jsx)(ge,{className:`h-[18px] w-[18px] text-white/95`,strokeWidth:2.5})})}function la(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var ua=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,da=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,fa={};function pa(e,t){return((t||fa).jsx?da:ua).test(e)}var ma=/[ \t\n\f\r]/g;function ha(e){return typeof e==`object`?e.type===`text`?ga(e.value):!1:ga(e)}function ga(e){return e.replace(ma,``)===``}var _a=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};_a.prototype.normal={},_a.prototype.property={},_a.prototype.space=void 0;function va(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new _a(n,r,t)}function ya(e){return e.toLowerCase()}var B=class{constructor(e,t){this.attribute=t,this.property=e}};B.prototype.attribute=``,B.prototype.booleanish=!1,B.prototype.boolean=!1,B.prototype.commaOrSpaceSeparated=!1,B.prototype.commaSeparated=!1,B.prototype.defined=!1,B.prototype.mustUseProperty=!1,B.prototype.number=!1,B.prototype.overloadedBoolean=!1,B.prototype.property=``,B.prototype.spaceSeparated=!1,B.prototype.space=void 0;var ba=i({boolean:()=>V,booleanish:()=>H,commaOrSpaceSeparated:()=>wa,commaSeparated:()=>Ca,number:()=>U,overloadedBoolean:()=>Sa,spaceSeparated:()=>W}),xa=0,V=Ta(),H=Ta(),Sa=Ta(),U=Ta(),W=Ta(),Ca=Ta(),wa=Ta();function Ta(){return 2**++xa}var Ea=Object.keys(ba),Da=class extends B{constructor(e,t,n,r){let i=-1;if(super(e,t),Oa(this,`space`,r),typeof n==`number`)for(;++i<Ea.length;){let e=Ea[i];Oa(this,Ea[i],(n&ba[e])===ba[e])}}};Da.prototype.defined=!0;function Oa(e,t,n){n&&(e[t]=n)}function ka(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new Da(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[ya(r)]=r,n[ya(a.attribute)]=r}return new _a(t,n,e.space)}var Aa=ka({properties:{ariaActiveDescendant:null,ariaAtomic:H,ariaAutoComplete:null,ariaBusy:H,ariaChecked:H,ariaColCount:U,ariaColIndex:U,ariaColSpan:U,ariaControls:W,ariaCurrent:null,ariaDescribedBy:W,ariaDetails:null,ariaDisabled:H,ariaDropEffect:W,ariaErrorMessage:null,ariaExpanded:H,ariaFlowTo:W,ariaGrabbed:H,ariaHasPopup:null,ariaHidden:H,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:W,ariaLevel:U,ariaLive:null,ariaModal:H,ariaMultiLine:H,ariaMultiSelectable:H,ariaOrientation:null,ariaOwns:W,ariaPlaceholder:null,ariaPosInSet:U,ariaPressed:H,ariaReadOnly:H,ariaRelevant:null,ariaRequired:H,ariaRoleDescription:W,ariaRowCount:U,ariaRowIndex:U,ariaRowSpan:U,ariaSelected:H,ariaSetSize:U,ariaSort:null,ariaValueMax:U,ariaValueMin:U,ariaValueNow:U,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function ja(e,t){return t in e?e[t]:t}function Ma(e,t){return ja(e,t.toLowerCase())}var Na=ka({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:Ca,acceptCharset:W,accessKey:W,action:null,allow:null,allowFullScreen:V,allowPaymentRequest:V,allowUserMedia:V,alt:null,as:null,async:V,autoCapitalize:null,autoComplete:W,autoFocus:V,autoPlay:V,blocking:W,capture:null,charSet:null,checked:V,cite:null,className:W,cols:U,colSpan:null,content:null,contentEditable:H,controls:V,controlsList:W,coords:U|Ca,crossOrigin:null,data:null,dateTime:null,decoding:null,default:V,defer:V,dir:null,dirName:null,disabled:V,download:Sa,draggable:H,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:V,formTarget:null,headers:W,height:U,hidden:Sa,high:U,href:null,hrefLang:null,htmlFor:W,httpEquiv:W,id:null,imageSizes:null,imageSrcSet:null,inert:V,inputMode:null,integrity:null,is:null,isMap:V,itemId:null,itemProp:W,itemRef:W,itemScope:V,itemType:W,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:V,low:U,manifest:null,max:null,maxLength:U,media:null,method:null,min:null,minLength:U,multiple:V,muted:V,name:null,nonce:null,noModule:V,noValidate:V,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:V,optimum:U,pattern:null,ping:W,placeholder:null,playsInline:V,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:V,referrerPolicy:null,rel:W,required:V,reversed:V,rows:U,rowSpan:U,sandbox:W,scope:null,scoped:V,seamless:V,selected:V,shadowRootClonable:V,shadowRootDelegatesFocus:V,shadowRootMode:null,shape:null,size:U,sizes:null,slot:null,span:U,spellCheck:H,src:null,srcDoc:null,srcLang:null,srcSet:null,start:U,step:null,style:null,tabIndex:U,target:null,title:null,translate:null,type:null,typeMustMatch:V,useMap:null,value:H,width:U,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:W,axis:null,background:null,bgColor:null,border:U,borderColor:null,bottomMargin:U,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:V,declare:V,event:null,face:null,frame:null,frameBorder:null,hSpace:U,leftMargin:U,link:null,longDesc:null,lowSrc:null,marginHeight:U,marginWidth:U,noResize:V,noHref:V,noShade:V,noWrap:V,object:null,profile:null,prompt:null,rev:null,rightMargin:U,rules:null,scheme:null,scrolling:H,standby:null,summary:null,text:null,topMargin:U,valueType:null,version:null,vAlign:null,vLink:null,vSpace:U,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:V,disableRemotePlayback:V,prefix:null,property:null,results:U,security:null,unselectable:null},space:`html`,transform:Ma}),Pa=ka({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:wa,accentHeight:U,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:U,amplitude:U,arabicForm:null,ascent:U,attributeName:null,attributeType:null,azimuth:U,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:U,by:null,calcMode:null,capHeight:U,className:W,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:U,diffuseConstant:U,direction:null,display:null,dur:null,divisor:U,dominantBaseline:null,download:V,dx:null,dy:null,edgeMode:null,editable:null,elevation:U,enableBackground:null,end:null,event:null,exponent:U,externalResourcesRequired:null,fill:null,fillOpacity:U,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:Ca,g2:Ca,glyphName:Ca,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:U,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:U,horizOriginX:U,horizOriginY:U,id:null,ideographic:U,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:U,k:U,k1:U,k2:U,k3:U,k4:U,kernelMatrix:wa,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:U,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:U,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:U,overlineThickness:U,paintOrder:null,panose1:null,path:null,pathLength:U,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:W,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:U,pointsAtY:U,pointsAtZ:U,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:wa,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:wa,rev:wa,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:wa,requiredFeatures:wa,requiredFonts:wa,requiredFormats:wa,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:U,specularExponent:U,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:U,strikethroughThickness:U,string:null,stroke:null,strokeDashArray:wa,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:U,strokeOpacity:U,strokeWidth:null,style:null,surfaceScale:U,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:wa,tabIndex:U,tableValues:null,target:null,targetX:U,targetY:U,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:wa,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:U,underlineThickness:U,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:U,values:null,vAlphabetic:U,vMathematical:U,vectorEffect:null,vHanging:U,vIdeographic:U,version:null,vertAdvY:U,vertOriginX:U,vertOriginY:U,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:U,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:ja}),Fa=ka({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()}}),Ia=ka({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:Ma}),La=ka({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),Ra={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`},za=/[A-Z]/g,Ba=/-[a-z]/g,Va=/^data[-\w.:]+$/i;function Ha(e,t){let n=ya(t),r=t,i=B;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&Va.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(Ba,Wa);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!Ba.test(e)){let n=e.replace(za,Ua);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=Da}return new i(r,t)}function Ua(e){return`-`+e.toLowerCase()}function Wa(e){return e.charAt(1).toUpperCase()}var Ga=va([Aa,Na,Fa,Ia,La],`html`),Ka=va([Aa,Pa,Fa,Ia,La],`svg`);function qa(e){return e.join(` `).trim()}var Ja=a(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g,u=`
|
|
4
|
+
`,d=`/`,f=`*`,p=``,m=`comment`,h=`declaration`;function g(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,g=1;function v(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(u);g=~n?e.length-n:g+e.length}function y(){var e={line:l,column:g};return function(t){return t.position=new b(e),C(),t}}function b(e){this.start=e,this.end={line:l,column:g},this.source=t.source}b.prototype.content=e;function x(n){var r=Error(t.source+`:`+l+`:`+g+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=g,r.source=e,!t.silent)throw r}function S(t){var n=t.exec(e);if(n){var r=n[0];return v(r),e=e.slice(r.length),n}}function C(){S(i)}function w(e){var t;for(e||=[];t=T();)t!==!1&&e.push(t);return e}function T(){var t=y();if(!(d!=e.charAt(0)||f!=e.charAt(1))){for(var n=2;p!=e.charAt(n)&&(f!=e.charAt(n)||d!=e.charAt(n+1));)++n;if(n+=2,p===e.charAt(n-1))return x(`End of comment missing`);var r=e.slice(2,n-2);return g+=2,v(r),e=e.slice(n),g+=2,t({type:m,comment:r})}}function E(){var e=y(),t=S(a);if(t){if(T(),!S(o))return x(`property missing ':'`);var r=S(s),i=e({type:h,property:_(t[0].replace(n,p)),value:r?_(r[0].replace(n,p)):p});return S(c),i}}function D(){var e=[];w(e);for(var t;t=E();)t!==!1&&(e.push(t),w(e));return e}return C(),D()}function _(e){return e?e.replace(l,p):p}t.exports=g})),Ya=a((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.default=r;var n=t(Ja());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),Xa=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),Za=a(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(Ya()),r=Xa();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),Qa=eo(`end`),$a=eo(`start`);function eo(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function to(e){let t=$a(e),n=Qa(e);if(t&&n)return{start:t,end:n}}function no(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?io(e.position):`start`in e||`end`in e?io(e):`line`in e||`column`in e?ro(e):``}function ro(e){return ao(e&&e.line)+`:`+ao(e&&e.column)}function io(e){return ro(e&&e.start)+`-`+ro(e&&e.end)}function ao(e){return e&&typeof e==`number`?e:1}var G=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=no(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};G.prototype.file=``,G.prototype.name=``,G.prototype.reason=``,G.prototype.message=``,G.prototype.stack=``,G.prototype.column=void 0,G.prototype.line=void 0,G.prototype.ancestors=void 0,G.prototype.cause=void 0,G.prototype.fatal=void 0,G.prototype.place=void 0,G.prototype.ruleId=void 0,G.prototype.source=void 0;var oo=e(Za(),1),so={}.hasOwnProperty,co=new Map,lo=/[A-Z]/g,uo=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),fo=new Set([`td`,`th`]),po=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function mo(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=To(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=wo(n,t.jsx,t.jsxs)}let 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`?Ka:Ga,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=ho(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function ho(e,t,n){if(t.type===`element`)return go(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return _o(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return yo(e,t,n);if(t.type===`mdxjsEsm`)return vo(e,t);if(t.type===`root`)return bo(e,t,n);if(t.type===`text`)return xo(e,t)}function go(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=Ka,e.schema=i),e.ancestors.push(t);let a=jo(e,t.tagName,!1),o=Eo(e,t),s=Oo(e,t);return uo.has(t.tagName)&&(s=s.filter(function(e){return typeof e==`string`?!ha(e):!0})),So(e,o,a,t),Co(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function _o(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}Mo(e,t.position)}function vo(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Mo(e,t.position)}function yo(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=Ka,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:jo(e,t.name,!0),o=Do(e,t),s=Oo(e,t);return So(e,o,a,t),Co(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function bo(e,t,n){let r={};return Co(r,Oo(e,t)),e.create(t,e.Fragment,r,n)}function xo(e,t){return t.value}function So(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Co(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function wo(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function To(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=$a(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function Eo(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&so.call(t.properties,i)){let a=ko(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&fo.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function Do(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`)if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else Mo(e,t.position);else{let i=r.name,a;if(r.value&&typeof r.value==`object`)if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else Mo(e,t.position);else a=r.value===null?!0:r.value;n[i]=a}return n}function Oo(e,t){let n=[],r=-1,i=e.passKeys?new Map:co;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=ho(e,a,o);s!==void 0&&n.push(s)}return n}function ko(e,t,n){let r=Ha(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?la(n):qa(n)),r.property===`style`){let t=typeof n==`object`?n:Ao(e,String(n));return e.stylePropertyNameCase===`css`&&(t=No(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?Ra[r.property]||r.property:r.attribute,n]}}function Ao(e,t){try{return(0,oo.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new G("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=po+`#cannot-parse-style-attribute`,r}}function jo(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=pa(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=pa(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return so.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);Mo(e)}function Mo(e,t){let n=new G("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=po+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function No(e){let t={},n;for(n in e)so.call(e,n)&&(t[Po(n)]=e[n]);return t}function Po(e){let t=e.replace(lo,Fo);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function Fo(e){return`-`+e.toLowerCase()}var Io={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`]},Lo={};function Ro(e,t){let n=t||Lo;return zo(e,typeof n.includeImageAlt==`boolean`?n.includeImageAlt:!0,typeof n.includeHtml==`boolean`?n.includeHtml:!0)}function zo(e,t,n){if(Vo(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 Bo(e.children,t,n)}return Array.isArray(e)?Bo(e,t,n):``}function Bo(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=zo(e[i],t,n);return r.join(``)}function Vo(e){return!!(e&&typeof e==`object`)}var Ho=document.createElement(`i`);function Uo(e){let t=`&`+e+`;`;Ho.innerHTML=t;let n=Ho.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`||n===t?!1:n}function Wo(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+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);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function Go(e,t){return e.length>0?(Wo(e,e.length,0,t),e):t}var Ko={}.hasOwnProperty;function qo(e){let t={},n=-1;for(;++n<e.length;)Jo(t,e[n]);return t}function Jo(e,t){let n;for(n in t){let r=(Ko.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){Ko.call(r,a)||(r[a]=[]);let e=i[a];Yo(r[a],Array.isArray(e)?e:e?[e]:[])}}}function Yo(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);Wo(e,0,0,r)}function Xo(e,t){let 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 Zo(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var K=as(/[A-Za-z]/),q=as(/[\dA-Za-z]/),Qo=as(/[#-'*+\--9=?A-Z^-~]/);function $o(e){return e!==null&&(e<32||e===127)}var es=as(/\d/),ts=as(/[\dA-Fa-f]/),ns=as(/[!-/:-@[-`{-~]/);function J(e){return e!==null&&e<-2}function Y(e){return e!==null&&(e<0||e===32)}function X(e){return e===-2||e===-1||e===32}var rs=as(/\p{P}|\p{S}/u),is=as(/\s/);function as(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function os(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&q(e.charCodeAt(n+1))&&q(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function Z(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return X(r)?(e.enter(n),s(r)):t(r)}function s(r){return X(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var ss={tokenize:cs};function cs(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),Z(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return J(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var ls={tokenize:ds},us={tokenize:fs};function ds(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return Wo(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(us,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(us,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return J(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;Wo(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-- >r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function fs(e,t,n){return Z(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function ps(e){if(e===null||Y(e)||is(e))return 1;if(rs(e))return 2}function ms(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var hs={name:`attention`,resolveAll:gs,tokenize:_s};function gs(e,t){let n=-1,r,i,a,o,s,c,l,u;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;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};vs(d,-c),vs(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=Go(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=Go(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=Go(l,ms(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=Go(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=Go(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,Wo(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function _s(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=ps(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=ps(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function vs(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var ys={name:`autolink`,tokenize:bs};function bs(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return K(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||q(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||q(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||$o(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):Qo(t)?(e.consume(t),l):n(t)}function u(e){return q(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||q(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var xs={partial:!0,tokenize:Ss};function Ss(e,t,n){return r;function r(t){return X(t)?Z(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||J(e)?t(e):n(e)}}var Cs={continuation:{tokenize:Ts},exit:Es,name:`blockQuote`,tokenize:ws};function ws(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return X(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function Ts(e,t,n){let r=this;return i;function i(t){return X(t)?Z(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(Cs,t,n)(r)}}function Es(e){e.exit(`blockQuote`)}var Ds={name:`characterEscape`,tokenize:Os};function Os(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return ns(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var ks={name:`characterReference`,tokenize:As};function As(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=q,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=ts,u):(e.enter(`characterReferenceValue`),a=7,o=es,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===q&&!Uo(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var js={partial:!0,tokenize:Ps},Ms={concrete:!0,name:`codeFenced`,tokenize:Ns};function Ns(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),X(t)?Z(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||J(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(js,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||J(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):X(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),Z(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||J(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||J(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&X(t)?Z(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||J(t)?e.check(js,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||J(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),X(t)?Z(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),X(t)?Z(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||J(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function Ps(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var Fs={name:`codeIndented`,tokenize:Ls},Is={partial:!0,tokenize:Rs};function Ls(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),Z(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):J(t)?e.attempt(Is,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||J(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function Rs(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):J(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):Z(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):J(e)?i(e):n(e)}}var zs={name:`codeText`,previous:Vs,resolve:Bs,tokenize:Hs};function Bs(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 Vs(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function Hs(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):J(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||J(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var Us=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&Ws(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),Ws(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),Ws(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){let t=this.left.splice(e,1/0);Ws(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);Ws(this.left,t.reverse())}}};function Ws(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 Gs(e){let t={},n=-1,r,i,a,o,s,c,l,u=new Us(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,Ks(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(!(o[1].type===`linePrefix`||o[1].type===`listItemIndent`))break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return Wo(e,0,1/0,u.slice(0)),!l}function Ks(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var qs={resolve:Ys,tokenize:Xs},Js={partial:!0,tokenize:Zs};function Ys(e){return Gs(e),e}function Xs(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):J(t)?e.check(Js,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function Zs(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),Z(e,a,`linePrefix`)}function a(i){if(i===null||J(i))return n(i);let 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(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function Qs(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||$o(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||J(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||Y(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||$o(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function $s(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):J(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||J(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!X(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function ec(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):J(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),Z(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||J(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function tc(e,t){let n;return r;function r(i){return J(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):X(i)?Z(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var nc={name:`definition`,tokenize:ic},rc={partial:!0,tokenize:ac};function ic(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return $s.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=Zo(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return Y(t)?tc(e,l)(t):l(t)}function l(t){return Qs(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(rc,d,d)(t)}function d(t){return X(t)?Z(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||J(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function ac(e,t,n){return r;function r(t){return Y(t)?tc(e,i)(t):n(t)}function i(t){return ec(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return X(t)?Z(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||J(e)?t(e):n(e)}}var oc={name:`hardBreakEscape`,tokenize:sc};function sc(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return J(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var cc={name:`headingAtx`,resolve:lc,tokenize:uc};function lc(e,t){let n=e.length-2,r=3,i,a;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},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},Wo(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function uc(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||Y(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||J(n)?(e.exit(`atxHeading`),t(n)):X(n)?Z(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||Y(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var dc=`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`.split(`.`),fc=[`pre`,`script`,`style`,`textarea`],pc={concrete:!0,name:`htmlFlow`,resolveTo:gc,tokenize:_c},mc={partial:!0,tokenize:yc},hc={partial:!0,tokenize:vc};function gc(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 _c(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:re):K(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):K(a)?(e.consume(a),i=4,r.interrupt?t:re):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:re):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return K(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||Y(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&fc.includes(l)?(i=1,r.interrupt?t(s):O(s)):dc.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||q(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return X(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||K(t)?(e.consume(t),b):X(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||q(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):X(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):X(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||J(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||Y(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||X(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||J(t)?O(t):X(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),A):t===60&&i===1?(e.consume(t),j):t===62&&i===4?(e.consume(t),ie):t===63&&i===3?(e.consume(t),re):t===93&&i===5?(e.consume(t),M):J(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(mc,ae,k)(t)):t===null||J(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(hc,ee,ae)(t)}function ee(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),te}function te(t){return t===null||J(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function A(t){return t===45?(e.consume(t),re):O(t)}function j(t){return t===47?(e.consume(t),o=``,ne):O(t)}function ne(t){if(t===62){let n=o.toLowerCase();return fc.includes(n)?(e.consume(t),ie):O(t)}return K(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),ne):O(t)}function M(t){return t===93?(e.consume(t),re):O(t)}function re(t){return t===62?(e.consume(t),ie):t===45&&i===2?(e.consume(t),re):O(t)}function ie(t){return t===null||J(t)?(e.exit(`htmlFlowData`),ae(t)):(e.consume(t),ie)}function ae(n){return e.exit(`htmlFlow`),t(n)}}function vc(e,t,n){let r=this;return i;function i(t){return J(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function yc(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(xs,t,n)}}var bc={name:`htmlText`,tokenize:xc};function xc(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):K(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):K(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):J(t)?(o=d,j(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?A(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):J(t)?(o=h,j(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?A(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?A(t):J(t)?(o=v,j(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):J(t)?(o=y,j(t)):(e.consume(t),y)}function b(e){return e===62?A(e):y(e)}function x(t){return K(t)?(e.consume(t),S):n(t)}function S(t){return t===45||q(t)?(e.consume(t),S):C(t)}function C(t){return J(t)?(o=C,j(t)):X(t)?(e.consume(t),C):A(t)}function w(t){return t===45||q(t)?(e.consume(t),w):t===47||t===62||Y(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),A):t===58||t===95||K(t)?(e.consume(t),E):J(t)?(o=T,j(t)):X(t)?(e.consume(t),T):A(t)}function E(t){return t===45||t===46||t===58||t===95||q(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):J(t)?(o=D,j(t)):X(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):J(t)?(o=O,j(t)):X(t)?(e.consume(t),O):(e.consume(t),ee)}function k(t){return t===i?(e.consume(t),i=void 0,te):t===null?n(t):J(t)?(o=k,j(t)):(e.consume(t),k)}function ee(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||Y(t)?T(t):(e.consume(t),ee)}function te(e){return e===47||e===62||Y(e)?T(e):n(e)}function A(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function j(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),ne}function ne(t){return X(t)?Z(e,M,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):M(t)}function M(t){return e.enter(`htmlTextData`),o(t)}}var Sc={name:`labelEnd`,resolveAll:Ec,resolveTo:Dc,tokenize:Oc},Cc={tokenize:kc},wc={tokenize:Ac},Tc={tokenize:jc};function Ec(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&Wo(e,0,e.length,n),e}function Dc(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){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&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=Go(s,e.slice(a+1,a+r+3)),s=Go(s,[[`enter`,u,t]]),s=Go(s,ms(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=Go(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=Go(s,e.slice(o+1)),s=Go(s,[[`exit`,c,t]]),Wo(e,a,e.length,s),e}function Oc(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(Zo(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(Cc,u,o?u:d)(t):t===91?e.attempt(wc,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(Tc,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function kc(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return Y(t)?tc(e,a)(t):a(t)}function a(t){return t===41?u(t):Qs(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return Y(t)?tc(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?ec(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return Y(t)?tc(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function Ac(e,t,n){let r=this;return i;function i(t){return $s.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(Zo(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function jc(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var Mc={name:`labelStartImage`,resolveAll:Sc.resolveAll,tokenize:Nc};function Nc(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var Pc={name:`labelStartLink`,resolveAll:Sc.resolveAll,tokenize:Fc};function Fc(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var Ic={name:`lineEnding`,tokenize:Lc};function Lc(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),Z(e,t,`linePrefix`)}}var Rc={name:`thematicBreak`,tokenize:zc};function zc(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||J(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),X(t)?Z(e,s,`whitespace`)(t):s(t))}}var Bc={continuation:{tokenize:Wc},exit:Kc,name:`list`,tokenize:Uc},Vc={partial:!0,tokenize:qc},Hc={partial:!0,tokenize:Gc};function Uc(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:es(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(Rc,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return es(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(xs,r.interrupt?n:u,e.attempt(Vc,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return X(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function Wc(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(xs,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Z(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!X(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Hc,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,Z(e,e.attempt(Bc,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function Gc(e,t,n){let r=this;return Z(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function Kc(e){e.exit(this.containerState.type)}function qc(e,t,n){let r=this;return Z(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!X(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var Jc={name:`setextUnderline`,resolveTo:Yc,tokenize:Xc};function Yc(e,t){let n=e.length,r,i,a;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),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function Xc(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),X(t)?Z(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||J(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var Zc={tokenize:Qc};function Qc(e){let t=this,n=e.attempt(xs,r,e.attempt(this.parser.constructs.flowInitial,i,Z(e,e.attempt(this.parser.constructs.flow,i,e.attempt(qs,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var $c={resolveAll:rl()},el=nl(`string`),tl=nl(`text`);function nl(e){return{resolveAll:rl(e===`text`?il:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function rl(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function il(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var al=i({attentionMarkers:()=>pl,contentInitial:()=>sl,disable:()=>ml,document:()=>ol,flow:()=>ll,flowInitial:()=>cl,insideSpan:()=>fl,string:()=>ul,text:()=>dl}),ol={42:Bc,43:Bc,45:Bc,48:Bc,49:Bc,50:Bc,51:Bc,52:Bc,53:Bc,54:Bc,55:Bc,56:Bc,57:Bc,62:Cs},sl={91:nc},cl={[-2]:Fs,[-1]:Fs,32:Fs},ll={35:cc,42:Rc,45:[Jc,Rc],60:pc,61:Jc,95:Rc,96:Ms,126:Ms},ul={38:ks,92:Ds},dl={[-5]:Ic,[-4]:Ic,[-3]:Ic,33:Mc,38:ks,42:hs,60:[ys,bc],91:Pc,92:[oc,Ds],93:Sc,95:hs,96:zs},fl={null:[hs,$c]},pl={null:[42,95]},ml={null:[]};function hl(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=Go(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=ms(a,l.events,l),l.events):[]}function f(e,t){return _l(p(e),t)}function p(e){return gl(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){J(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&Wo(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function gl(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function _l(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){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(a)}i=a===-2,r.push(o)}return r.join(``)}function vl(e){let t={constructs:qo([al,...(e||{}).extensions||[]]),content:n(ss),defined:[],document:n(ls),flow:n(Zc),lazy:{},string:n(el),text:n(tl)};return t;function n(e){return n;function n(n){return hl(t,e,n)}}}function yl(e){for(;!Gs(e););return e}var bl=/[\0\t\n\r]/g;function xl(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&=(i.charCodeAt(0)===65279&&u++,void 0);u<i.length;){if(bl.lastIndex=u,c=bl.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var Sl=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Cl(e){return e.replace(Sl,wl)}function wl(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return Xo(n.slice(t?2:1),t?16:10)}return Uo(n)||e}var Tl={}.hasOwnProperty;function El(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),Dl(n)(yl(vl(n).document().write(xl()(e,t,!0))))}function Dl(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(be),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(ge),blockQuote:a(fe),characterEscape:T,characterReference:T,codeFenced:a(P),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(P,o),codeText:a(pe,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(me),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(he),hardBreakEscape:a(_e),hardBreakTrailing:a(_e),htmlFlow:a(ve,o),htmlFlowData:T,htmlText:a(ve,o),htmlTextData:T,image:a(ye),label:o,link:a(be),listItem:a(Se),listItemValue:f,listOrdered:a(xe,d),listUnordered:a(xe),paragraph:a(Ce),reference:oe,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(ge),strong:a(we),thematicBreak:a(Ee)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:de,autolinkProtocol:ue,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:N,characterReferenceMarkerNumeric:N,characterReferenceValue:ce,characterReference:le,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(te),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(k),htmlFlowData:E,htmlText:c(ee),htmlTextData:E,image:c(j),label:M,labelText:ne,lineEnding:D,link:c(A),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:se,resourceDestinationString:re,resourceTitleString:ie,resource:ae,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};kl(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];Tl.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||jl).call(a,void 0,e[0])}for(r.position={start:Ol(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:Ol(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(!(t[1].type===`linePrefix`||t[1].type===`blockQuotePrefix`||t[1].type===`blockQuotePrefixWhitespace`||t[1].type===`blockQuoteMarker`||t[1].type===`listItemIndent`))break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:Ol(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||jl).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+no({start:e.start,end:e.end})+`): it’s not open`);n.position.end=Ol(e.end)}function u(){return Ro(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=Zo(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function S(){this.data.setextHeadingSlurpLineEnding=!0}function C(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function T(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=Te(),n.position={start:Ol(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=Ol(e.end)}function D(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=Ol(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(T.call(this,e),E.call(this,e))}function O(){this.data.atHardBreak=!0}function k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function ee(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function te(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function A(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function j(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function ne(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=Cl(t),n.identifier=Zo(t).toLowerCase()}function M(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function re(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function ie(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function ae(){this.data.inReference=void 0}function oe(){this.data.referenceType=`collapsed`}function se(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=Zo(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function N(e){this.data.characterReferenceType=e.type}function ce(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=Xo(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=Uo(t);let i=this.stack[this.stack.length-1];i.value+=r}function le(e){let t=this.stack.pop();t.position.end=Ol(e.end)}function ue(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function de(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function fe(){return{type:`blockquote`,children:[]}}function P(){return{type:`code`,lang:null,meta:null,value:``}}function pe(){return{type:`inlineCode`,value:``}}function me(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function he(){return{type:`emphasis`,children:[]}}function ge(){return{type:`heading`,depth:0,children:[]}}function _e(){return{type:`break`}}function ve(){return{type:`html`,value:``}}function ye(){return{type:`image`,title:null,url:``,alt:null}}function be(){return{type:`link`,title:null,url:``,children:[]}}function xe(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function Se(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function Ce(){return{type:`paragraph`,children:[]}}function we(){return{type:`strong`,children:[]}}function Te(){return{type:`text`,value:``}}function Ee(){return{type:`thematicBreak`}}}function Ol(e){return{line:e.line,column:e.column,offset:e.offset}}function kl(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?kl(e,r):Al(e,r)}}function Al(e,t){let n;for(n in t)if(Tl.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function jl(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+no({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+no({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+no({start:t.start,end:t.end})+`) is still open`)}function Ml(e){let t=this;t.parser=n;function n(n){return El(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function Nl(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function Pl(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
|
|
7
|
+
`}]}function Fl(e,t){let n=t.value?t.value+`
|
|
8
|
+
`:``,r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=[`language-`+i[0]]);let a={type:`element`,tagName:`code`,properties:r,children:[{type:`text`,value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:`element`,tagName:`pre`,properties:{},children:[a]},e.patch(t,a),a}function Il(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Ll(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Rl(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=os(r.toLowerCase()),a=e.footnoteOrder.indexOf(r),o,s=e.footnoteCounts.get(r);s===void 0?(s=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=a+1,s+=1,e.footnoteCounts.set(r,s);let c={type:`element`,tagName:`a`,properties:{href:`#`+n+`fn-`+i,id:n+`fnref-`+i+(s>1?`-`+s:``),dataFootnoteRef:!0,ariaDescribedBy:[`footnote-label`]},children:[{type:`text`,value:String(o)}]};e.patch(t,c);let l={type:`element`,tagName:`sup`,properties:{},children:[c]};return e.patch(t,l),e.applyData(t,l)}function zl(e,t){let n={type:`element`,tagName:`h`+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Bl(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Vl(e,t){let n=t.referenceType,r=`]`;if(n===`collapsed`?r+=`[]`:n===`full`&&(r+=`[`+(t.label||t.identifier)+`]`),t.type===`imageReference`)return[{type:`text`,value:`![`+t.alt+r}];let i=e.all(t),a=i[0];a&&a.type===`text`?a.value=`[`+a.value:i.unshift({type:`text`,value:`[`});let o=i[i.length-1];return o&&o.type===`text`?o.value+=r:i.push({type:`text`,value:r}),i}function Hl(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Vl(e,t);let i={src:os(r.url||``),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`img`,properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)}function Ul(e,t){let n={src:os(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`img`,properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function Wl(e,t){let n={type:`text`,value:t.value.replace(/\r?\n|\r/g,` `)};e.patch(t,n);let r={type:`element`,tagName:`code`,properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function Gl(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Vl(e,t);let i={href:os(r.url||``)};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`a`,properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function Kl(e,t){let n={href:os(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`a`,properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function ql(e,t,n){let r=e.all(t),i=n?Jl(n):Yl(t),a={},o=[];if(typeof t.checked==`boolean`){let e=r[0],n;e&&e.type===`element`&&e.tagName===`p`?n=e:(n={type:`element`,tagName:`p`,properties:{},children:[]},r.unshift(n)),n.children.length>0&&n.children.unshift({type:`text`,value:` `}),n.children.unshift({type:`element`,tagName:`input`,properties:{type:`checkbox`,checked:t.checked,disabled:!0},children:[]}),a.className=[`task-list-item`]}let s=-1;for(;++s<r.length;){let e=r[s];(i||s!==0||e.type!==`element`||e.tagName!==`p`)&&o.push({type:`text`,value:`
|
|
9
|
+
`}),e.type===`element`&&e.tagName===`p`&&!i?o.push(...e.children):o.push(e)}let c=r[r.length-1];c&&(i||c.type!==`element`||c.tagName!==`p`)&&o.push({type:`text`,value:`
|
|
10
|
+
`});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function Jl(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=Yl(n[r])}return t}function Yl(e){return e.spread??e.children.length>1}function Xl(e,t){let n={},r=e.all(t),i=-1;for(typeof t.start==`number`&&t.start!==1&&(n.start=t.start);++i<r.length;){let e=r[i];if(e.type===`element`&&e.tagName===`li`&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes(`task-list-item`)){n.className=[`contains-task-list`];break}}let a={type:`element`,tagName:t.ordered?`ol`:`ul`,properties:n,children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)}function Zl(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Ql(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function $l(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function eu(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:`element`,tagName:`thead`,properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:`element`,tagName:`tbody`,properties:{},children:e.wrap(n,!0)},a=$a(t.children[1]),o=Qa(t.children[t.children.length-1]);a&&o&&(r.position={start:a,end:o}),i.push(r)}let a={type:`element`,tagName:`table`,properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)}function tu(e,t,n){let r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?`th`:`td`,a=n&&n.type===`table`?n.align:void 0,o=a?a.length:t.children.length,s=-1,c=[];for(;++s<o;){let n=t.children[s],r={},o=a?a[s]:void 0;o&&(r.align=o);let l={type:`element`,tagName:i,properties:r,children:[]};n&&(l.children=e.all(n),e.patch(n,l),l=e.applyData(n,l)),c.push(l)}let l={type:`element`,tagName:`tr`,properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function nu(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var ru=9,iu=32;function au(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(ou(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(ou(t.slice(i),i>0,!1)),a.join(``)}function ou(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===ru||t===iu;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===ru||t===iu;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function su(e,t){let n={type:`text`,value:au(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function cu(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var lu={blockquote:Nl,break:Pl,code:Fl,delete:Il,emphasis:Ll,footnoteReference:Rl,heading:zl,html:Bl,imageReference:Hl,image:Ul,inlineCode:Wl,linkReference:Gl,link:Kl,listItem:ql,list:Xl,paragraph:Zl,root:Ql,strong:$l,table:eu,tableCell:nu,tableRow:tu,text:su,thematicBreak:cu,toml:uu,yaml:uu,definition:uu,footnoteDefinition:uu};function uu(){}var du=typeof self==`object`?self:globalThis,fu=(e,t)=>{let n=(t,n)=>(e.set(n,t),t),r=i=>{if(e.has(i))return e.get(i);let[a,o]=t[i];switch(a){case 0:case-1:return n(o,i);case 1:{let e=n([],i);for(let t of o)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of o)e[r(t)]=r(n);return e}case 3:return n(new Date(o),i);case 4:{let{source:e,flags:t}=o;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of o)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of o)e.add(r(t));return e}case 7:{let{name:e,message:t}=o;return n(new du[e](t),i)}case 8:return n(BigInt(o),i);case`BigInt`:return n(Object(BigInt(o)),i);case`ArrayBuffer`:return n(new Uint8Array(o).buffer,o);case`DataView`:{let{buffer:e}=new Uint8Array(o);return n(new DataView(e),o)}}return n(new du[a](o),i)};return r},pu=e=>fu(new Map,e)(0),mu=``,{toString:hu}={},{keys:gu}=Object,_u=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=hu.call(e).slice(8,-1);switch(n){case`Array`:return[1,mu];case`Object`:return[2,mu];case`Date`:return[3,mu];case`RegExp`:return[4,mu];case`Map`:return[5,mu];case`Set`:return[6,mu];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:n.includes(`Error`)?[7,n]:[2,n]},vu=([e,t])=>e===0&&(t===`function`||t===`symbol`),yu=(e,t,n,r)=>{let i=(e,t)=>{let i=r.push(e)-1;return n.set(t,i),i},a=r=>{if(n.has(r))return n.get(r);let[o,s]=_u(r);switch(o){case 0:{let t=r;switch(s){case`bigint`:o=8,t=r.toString();break;case`function`:case`symbol`:if(e)throw TypeError(`unable to serialize `+s);t=null;break;case`undefined`:return i([-1],r)}return i([o,t],r)}case 1:{if(s){let e=r;return s===`DataView`?e=new Uint8Array(r.buffer):s===`ArrayBuffer`&&(e=new Uint8Array(r)),i([s,[...e]],r)}let e=[],t=i([o,e],r);for(let t of r)e.push(a(t));return t}case 2:{if(s)switch(s){case`BigInt`:return i([s,r.toString()],r);case`Boolean`:case`Number`:case`String`:return i([s,r.valueOf()],r)}if(t&&`toJSON`in r)return a(r.toJSON());let n=[],c=i([o,n],r);for(let t of gu(r))(e||!vu(_u(r[t])))&&n.push([a(t),a(r[t])]);return c}case 3:return i([o,r.toISOString()],r);case 4:{let{source:e,flags:t}=r;return i([o,{source:e,flags:t}],r)}case 5:{let t=[],n=i([o,t],r);for(let[n,i]of r)(e||!(vu(_u(n))||vu(_u(i))))&&t.push([a(n),a(i)]);return n}case 6:{let t=[],n=i([o,t],r);for(let n of r)(e||!vu(_u(n)))&&t.push(a(n));return n}}let{message:c}=r;return i([o,{name:s,message:c}],r)};return a},bu=(e,{json:t,lossy:n}={})=>{let r=[];return yu(!(t||n),!!t,new Map,r)(e),r},xu=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?pu(bu(e,t)):structuredClone(e):(e,t)=>pu(bu(e,t));function Su(e,t){let n=[{type:`text`,value:`↩`}];return t>1&&n.push({type:`element`,tagName:`sup`,properties:{},children:[{type:`text`,value:String(t)}]}),n}function Cu(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function wu(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||Su,r=e.options.footnoteBackLabel||Cu,i=e.options.footnoteLabel||`Footnotes`,a=e.options.footnoteLabelTagName||`h2`,o=e.options.footnoteLabelProperties||{className:[`sr-only`]},s=[],c=-1;for(;++c<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[c]);if(!i)continue;let a=e.all(i),o=String(i.identifier).toUpperCase(),l=os(o.toLowerCase()),u=0,d=[],f=e.footnoteCounts.get(o);for(;f!==void 0&&++u<=f;){d.length>0&&d.push({type:`text`,value:` `});let e=typeof n==`string`?n:n(c,u);typeof e==`string`&&(e={type:`text`,value:e}),d.push({type:`element`,tagName:`a`,properties:{href:`#`+t+`fnref-`+l+(u>1?`-`+u:``),dataFootnoteBackref:``,ariaLabel:typeof r==`string`?r:r(c,u),className:[`data-footnote-backref`]},children:Array.isArray(e)?e:[e]})}let p=a[a.length-1];if(p&&p.type===`element`&&p.tagName===`p`){let e=p.children[p.children.length-1];e&&e.type===`text`?e.value+=` `:p.children.push({type:`text`,value:` `}),p.children.push(...d)}else a.push(...d);let m={type:`element`,tagName:`li`,properties:{id:t+`fn-`+l},children:e.wrap(a,!0)};e.patch(i,m),s.push(m)}if(s.length!==0)return{type:`element`,tagName:`section`,properties:{dataFootnotes:!0,className:[`footnotes`]},children:[{type:`element`,tagName:a,properties:{...xu(o),id:`footnote-label`},children:[{type:`text`,value:i}]},{type:`text`,value:`
|
|
11
|
+
`},{type:`element`,tagName:`ol`,properties:{},children:e.wrap(s,!0)},{type:`text`,value:`
|
|
12
|
+
`}]}}var Tu=(function(e){if(e==null)return Au;if(typeof e==`function`)return ku(e);if(typeof e==`object`)return Array.isArray(e)?Eu(e):Du(e);if(typeof e==`string`)return Ou(e);throw Error(`Expected function, string, or object as test`)});function Eu(e){let t=[],n=-1;for(;++n<e.length;)t[n]=Tu(e[n]);return ku(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function Du(e){let t=e;return ku(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function Ou(e){return ku(t);function t(t){return t&&t.type===e}}function ku(e){return t;function t(t,n,r){return!!(ju(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function Au(){return!0}function ju(e){return typeof e==`object`&&!!e&&`type`in e}function Mu(e){return e}var Nu=[];function Pu(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=Tu(i),o=r?-1:1;s(e,void 0,[])();function s(e,i,c){let l=e&&typeof e==`object`?e:{};if(typeof l.type==`string`){let t=typeof l.tagName==`string`?l.tagName:typeof l.name==`string`?l.name:void 0;Object.defineProperty(u,`name`,{value:`node (`+Mu(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=Nu,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=Fu(n(e,c)),l[0]===!1))return l;if(`children`in e&&e.children){let t=e;if(t.children&&l[0]!==`skip`)for(d=(r?t.children.length:-1)+o,f=c.concat(t);d>-1&&d<t.children.length;){let e=t.children[d];if(u=s(e,d,f)(),u[0]===!1)return u;d=typeof u[1]==`number`?u[1]:d+o}}return l}}}function Fu(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?Nu:[e]}function Iu(e,t,n,r){let i,a,o;typeof t==`function`&&typeof n!=`function`?(a=void 0,o=t,i=n):(a=t,o=n,i=r),Pu(e,a,s,i);function s(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return o(e,r,n)}}var Lu={}.hasOwnProperty,Ru={};function zu(e,t){let n=t||Ru,r=new Map,i=new Map,a={all:s,applyData:Vu,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...lu,...n.handlers},one:o,options:n,patch:Bu,wrap:Uu};return Iu(e,function(e){if(e.type===`definition`||e.type===`footnoteDefinition`){let t=e.type===`definition`?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),a;function o(e,t){let n=e.type,r=a.handlers[n];if(Lu.call(a.handlers,n)&&r)return r(a,e,t);if(a.options.passThrough&&a.options.passThrough.includes(n)){if(`children`in e){let{children:t,...n}=e,r=xu(n);return r.children=a.all(e),r}return xu(e)}return(a.options.unknownHandler||Hu)(a,e,t)}function s(e){let t=[];if(`children`in e){let n=e.children,r=-1;for(;++r<n.length;){let i=a.one(n[r],e);if(i){if(r&&n[r-1].type===`break`&&(!Array.isArray(i)&&i.type===`text`&&(i.value=Wu(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=Wu(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function Bu(e,t){e.position&&(t.position=to(e))}function Vu(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;typeof t==`string`&&(n.type===`element`?n.tagName=t:n={type:`element`,tagName:t,properties:{},children:`children`in n?n.children:[n]}),n.type===`element`&&i&&Object.assign(n.properties,xu(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function Hu(e,t){let n=t.data||{},r=`value`in t&&!(Lu.call(n,`hProperties`)||Lu.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 Uu(e,t){let n=[],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 Wu(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Gu(e,t){let n=zu(e,t),r=n.one(e,void 0),i=wu(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
|
|
16
|
+
`},i)),a}function Ku(e,t){return e&&`run`in e?async function(n,r){let i=Gu(n,{file:r,...t});await e.run(i,r)}:function(n,r){return Gu(n,{file:r,...e||t})}}function qu(e){if(e)throw e}var Ju=a(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function Yu(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Xu(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a){r(a);return}for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?Zu(s,i)(...o):r(null,...o)}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function Zu(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var Qu={basename:$u,dirname:ed,extname:td,join:nd,sep:`/`};function $u(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);ad(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function ed(e){if(ad(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||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function td(e){ad(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function nd(...e){let t=-1,n;for(;++t<e.length;)ad(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:rd(n)}function rd(e){ad(e);let t=e.codePointAt(0)===47,n=id(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function id(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(!(i===o-1||a===1))if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=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,a=0}else s===46&&a>-1?a++:a=-1}return n}function ad(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var od={cwd:sd};function sd(){return`/`}function cd(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function ld(e){if(typeof e==`string`)e=new URL(e);else if(!cd(e)){let t=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:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return ud(e)}function ud(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var dd=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],fd=class{constructor(e){let t;t=e?cd(e)?{path:e}:typeof e==`string`||gd(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:od.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<dd.length;){let e=dd[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)dd.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?Qu.basename(this.path):void 0}set basename(e){md(e,`basename`),pd(e,`basename`),this.path=Qu.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?Qu.dirname(this.path):void 0}set dirname(e){hd(this.basename,`dirname`),this.path=Qu.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?Qu.extname(this.path):void 0}set extname(e){if(pd(e,`extname`),hd(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=Qu.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){cd(e)&&(e=ld(e)),md(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?Qu.basename(this.path,this.extname):void 0}set stem(e){md(e,`stem`),pd(e,`stem`),this.path=Qu.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new G(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function pd(e,t){if(e&&e.includes(Qu.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+Qu.sep+"`")}function md(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function hd(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function gd(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var _d=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),vd=e(Ju(),1),yd={}.hasOwnProperty,bd=new class e extends _d{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=Xu()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,vd.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(Cd(`data`,this.frozen),this.namespace[e]=t,this):yd.call(this.namespace,e)&&this.namespace[e]||void 0:e?(Cd(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=Ed(e),n=this.parser||this.Parser;return xd(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),xd(`process`,this.parser||this.Parser),Sd(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=Ed(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);Od(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),xd(`processSync`,this.parser||this.Parser),Sd(`processSync`,this.compiler||this.Compiler),this.process(e,r),Td(`processSync`,`process`,t),n;function r(e,r){t=!0,qu(e),n=r}}run(e,t,n){wd(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=Ed(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),Td(`runSync`,`run`,n),r;function i(e,t){qu(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=Ed(t),r=this.compiler||this.Compiler;return Sd(`stringify`,r),wd(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(Cd(`use`,this.frozen),e!=null)if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`)if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e);else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw 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");o(e.plugins),e.settings&&(r.settings=(0,vd.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null)if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];Yu(o)&&Yu(r)&&(r=(0,vd.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function xd(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function Sd(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function Cd(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function wd(e){if(!Yu(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function Td(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function Ed(e){return Dd(e)?e:new fd(e)}function Dd(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function Od(e){return typeof e==`string`||kd(e)}function kd(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var Ad=[],jd={allowDangerousHtml:!0},Md=/^(https?|ircs?|mailto|xmpp)$/i,Nd=[{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 Pd(e){let t=Fd(e),n=Id(e);return Ld(t.runSync(t.parse(n),n),e)}function Fd(e){let t=e.rehypePlugins||Ad,n=e.remarkPlugins||Ad,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...jd}:jd;return bd().use(Ml).use(n).use(Ku,r).use(t)}function Id(e){let t=e.children||``,n=new fd;return typeof t==`string`?n.value=t:``+t,n}function Ld(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||Rd;for(let e of Nd)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return Iu(e,l),mo(e,{Fragment:L.Fragment,components:i,ignoreInvalidStyle:!0,jsx:L.jsx,jsxs:L.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in Io)if(Object.hasOwn(Io,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=Io[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function Rd(e){let 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||Md.test(e.slice(0,t))?e:``}function zd(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function Bd(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function Vd(e,t,n){let r=Tu((n||{}).ignore||[]),i=Hd(t),a=-1;for(;++a<i.length;)Pu(e,`text`,o);function o(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return s(e,t)}function s(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function Hd(e){let t=[];if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([Ud(e[0]),Wd(e[1])])}return t}function Ud(e){return typeof e==`string`?new RegExp(Bd(e),`g`):e}function Wd(e){return typeof e==`function`?e:function(){return e}}var Gd=`phrasing`,Kd=[`autolink`,`link`,`image`,`label`];function qd(){return{transforms:[tf],enter:{literalAutolink:Yd,literalAutolinkEmail:Xd,literalAutolinkHttp:Xd,literalAutolinkWww:Xd},exit:{literalAutolink:ef,literalAutolinkEmail:$d,literalAutolinkHttp:Zd,literalAutolinkWww:Qd}}}function Jd(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:Gd,notInConstruct:Kd},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:Gd,notInConstruct:Kd},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:Gd,notInConstruct:Kd}]}}function Yd(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function Xd(e){this.config.enter.autolinkProtocol.call(this,e)}function Zd(e){this.config.exit.autolinkProtocol.call(this,e)}function Qd(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function $d(e){this.config.exit.autolinkEmail.call(this,e)}function ef(e){this.exit(e)}function tf(e){Vd(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,nf],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,rf]],{ignore:[`link`,`linkReference`]})}function nf(e,t,n,r,i){let a=``;if(!sf(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!af(n)))return!1;let o=of(n+r);if(!o[0])return!1;let s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0]}]};return o[1]?[s,{type:`text`,value:o[1]}]:s}function rf(e,t,n,r){return!sf(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function af(e){let 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 of(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(`)`),i=zd(e,`(`),a=zd(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function sf(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||is(n)||rs(n))&&(!t||n!==47)}_f.peek=gf;function cf(){this.buffer()}function lf(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function uf(){this.buffer()}function df(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function ff(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Zo(this.sliceSerialize(e)).toLowerCase(),n.label=t}function pf(e){this.exit(e)}function mf(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Zo(this.sliceSerialize(e)).toLowerCase(),n.label=t}function hf(e){this.exit(e)}function gf(){return`[`}function _f(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function vf(){return{enter:{gfmFootnoteCallString:cf,gfmFootnoteCall:lf,gfmFootnoteDefinitionLabelString:uf,gfmFootnoteDefinition:df},exit:{gfmFootnoteCallString:ff,gfmFootnoteCall:pf,gfmFootnoteDefinitionLabelString:mf,gfmFootnoteDefinition:hf}}}function yf(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:_f},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
|
|
17
|
+
`:` `)+r.indentLines(r.containerFlow(e,a.current()),t?xf:bf))),s(),o}}function bf(e,t,n){return t===0?e:xf(e,t,n)}function xf(e,t,n){return(n?``:` `)+e}var Sf=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];Df.peek=Of;function Cf(){return{canContainEols:[`delete`],enter:{strikethrough:Tf},exit:{strikethrough:Ef}}}function wf(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:Sf}],handlers:{delete:Df}}}function Tf(e){this.enter({type:`delete`,children:[]},e)}function Ef(e){this.exit(e)}function Df(e,t,n,r){let i=n.createTracker(r),a=n.enter(`strikethrough`),o=i.move(`~~`);return o+=n.containerPhrasing(e,{...i.current(),before:o,after:`~`}),o+=i.move(`~~`),a(),o}function Of(){return`~`}function kf(e){return e.length}function Af(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||kf,a=[],o=[],s=[],c=[],l=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>l&&(l=e[u].length);++a<e[u].length;){let o=jf(e[u][a]);if(n.alignDelimiters!==!1){let e=i(o);r[a]=e,(c[a]===void 0||e>c[a])&&(c[a]=e)}t.push(o)}o[u]=t,s[u]=r}let d=-1;if(typeof r==`object`&&`length`in r)for(;++d<l;)a[d]=Mf(r[d]);else{let e=Mf(r);for(;++d<l;)a[d]=e}d=-1;let f=[],p=[];for(;++d<l;){let e=a[d],t=``,r=``;e===99?(t=`:`,r=`:`):e===108?t=`:`:e===114&&(r=`:`);let i=n.alignDelimiters===!1?1:Math.max(1,c[d]-t.length-r.length),o=t+`-`.repeat(i)+r;n.alignDelimiters!==!1&&(i=t.length+i+r.length,i>c[d]&&(c[d]=i),p[d]=i),f[d]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let m=[];for(;++u<o.length;){let e=o[u],t=s[u];d=-1;let r=[];for(;++d<l;){let i=e[d]||``,o=``,s=``;if(n.alignDelimiters!==!1){let e=c[d]-(t[d]||0),n=a[d];n===114?o=` `.repeat(e):n===99?e%2?(o=` `.repeat(e/2+.5),s=` `.repeat(e/2-.5)):(o=` `.repeat(e/2),s=o):s=` `.repeat(e)}n.delimiterStart!==!1&&!d&&r.push(`|`),n.padding!==!1&&!(n.alignDelimiters===!1&&i===``)&&(n.delimiterStart!==!1||d)&&r.push(` `),n.alignDelimiters!==!1&&r.push(o),r.push(i),n.alignDelimiters!==!1&&r.push(s),n.padding!==!1&&r.push(` `),(n.delimiterEnd!==!1||d!==l-1)&&r.push(`|`)}m.push(n.delimiterEnd===!1?r.join(``).replace(/ +$/,``):r.join(``))}return m.join(`
|
|
18
|
+
`)}function jf(e){return e==null?``:String(e)}function Mf(e){let 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 Nf(e,t,n,r){let i=n.enter(`blockquote`),a=n.createTracker(r);a.move(`> `),a.shift(2);let o=n.indentLines(n.containerFlow(e,a.current()),Pf);return i(),o}function Pf(e,t,n){return`>`+(n?``:` `)+e}function Ff(e,t){return If(e,t.inConstruct,!0)&&!If(e,t.notInConstruct,!1)}function If(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 Lf(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
|
|
19
|
+
`&&Ff(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?``:` `;return`\\
|
|
20
|
+
`}function Rf(e,t){let n=String(e),r=n.indexOf(t),i=r,a=0,o=0;if(typeof t!=`string`)throw TypeError(`Expected substring`);for(;r!==-1;)r===i?++a>o&&(o=a):a=1,i=r+t.length,r=n.indexOf(t,i);return o}function zf(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 Bf(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function Vf(e,t,n,r){let i=Bf(n),a=e.value||``,o=i==="`"?`GraveAccent`:`Tilde`;if(zf(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,Hf);return e(),t}let s=n.createTracker(r),c=i.repeat(Math.max(Rf(a,i)+1,3)),l=n.enter(`codeFenced`),u=s.move(c);if(e.lang){let t=n.enter(`codeFencedLang${o}`);u+=s.move(n.safe(e.lang,{before:u,after:` `,encode:["`"],...s.current()})),t()}if(e.lang&&e.meta){let t=n.enter(`codeFencedMeta${o}`);u+=s.move(` `),u+=s.move(n.safe(e.meta,{before:u,after:`
|
|
21
|
+
`,encode:["`"],...s.current()})),t()}return u+=s.move(`
|
|
22
|
+
`),a&&(u+=s.move(a+`
|
|
23
|
+
`)),u+=s.move(c),l(),u}function Hf(e,t,n){return(n?``:` `)+e}function Uf(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function Wf(e,t,n,r){let i=Uf(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`definition`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`[`);return l+=c.move(n.safe(n.associationId(e),{before:l,after:`]`,...c.current()})),l+=c.move(`]: `),s(),!e.url||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`
|
|
24
|
+
`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),o(),l}function Gf(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function Kf(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function qf(e,t,n){let r=ps(e),i=ps(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}}Jf.peek=Yf;function Jf(e,t,n,r){let i=Gf(n),a=n.enter(`emphasis`),o=n.createTracker(r),s=o.move(i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=qf(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=Kf(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=qf(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+Kf(d));let p=o.move(i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function Yf(e,t,n){return n.options.emphasis||`*`}function Xf(e,t){let n=!1;return Iu(e,function(e){if(`value`in e&&/\r?\n|\r/.test(e.value)||e.type===`break`)return n=!0,!1}),!!((!e.depth||e.depth<3)&&Ro(e)&&(t.options.setext||n))}function Zf(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(Xf(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,{...a.current(),before:`
|
|
25
|
+
`,after:`
|
|
26
|
+
`});return r(),t(),o+`
|
|
27
|
+
`+(i===1?`=`:`-`).repeat(o.length-(Math.max(o.lastIndexOf(`\r`),o.lastIndexOf(`
|
|
28
|
+
`))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
|
|
29
|
+
`,...a.current()});return/^[\t ]/.test(l)&&(l=Kf(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}Qf.peek=$f;function Qf(e){return e.value||``}function $f(){return`<`}ep.peek=tp;function ep(e,t,n,r){let i=Uf(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function tp(){return`!`}np.peek=rp;function np(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function rp(){return`!`}ip.peek=ap;function ip(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e),i;if(e.atBreak)for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function ap(){return"`"}function op(e,t){let n=Ro(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))}sp.peek=cp;function sp(e,t,n,r){let i=Uf(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(op(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function cp(e,t,n){return op(e,n)?`<`:`[`}lp.peek=up;function lp(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function up(){return`[`}function dp(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function fp(e){let t=dp(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function pp(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function mp(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function hp(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?pp(n):dp(n),s=e.ordered?o===`.`?`)`:`.`:fp(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.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&&(c=!0),mp(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function gp(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function _p(e,t,n,r){let i=gp(n),a=n.bulletCurrent||dp(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function vp(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var yp=Tu([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function bp(e,t,n,r){return(e.children.some(function(e){return yp(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function xp(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Sp.peek=Cp;function Sp(e,t,n,r){let i=xp(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=qf(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=Kf(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=qf(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+Kf(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function Cp(e,t,n){return n.options.strong||`*`}function wp(e,t,n,r){return n.safe(e.value,r)}function Tp(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function Ep(e,t,n){let r=(mp(n)+(n.options.ruleSpaces?` `:``)).repeat(Tp(n));return n.options.ruleSpaces?r.slice(0,-1):r}var Dp={blockquote:Nf,break:Lf,code:Vf,definition:Wf,emphasis:Jf,hardBreak:Lf,heading:Zf,html:Qf,image:ep,imageReference:np,inlineCode:ip,link:sp,linkReference:lp,list:hp,listItem:_p,paragraph:vp,root:bp,strong:Sp,text:wp,thematicBreak:Ep};function Op(){return{enter:{table:kp,tableData:Np,tableHeader:Np,tableRow:jp},exit:{codeText:Pp,table:Ap,tableData:Mp,tableHeader:Mp,tableRow:Mp}}}function kp(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function Ap(e){this.exit(e),this.data.inTable=void 0}function jp(e){this.enter({type:`tableRow`,children:[]},e)}function Mp(e){this.exit(e)}function Np(e){this.enter({type:`tableCell`,children:[]},e)}function Pp(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Fp));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function Fp(e,t){return t===`|`?t:e}function Ip(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=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:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(`
|
|
31
|
+
`))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return Af(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=Dp.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function Lp(){return{exit:{taskListCheckValueChecked:zp,taskListCheckValueUnchecked:zp,paragraph:Bp}}}function Rp(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:Vp}}}function zp(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function Bp(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function Vp(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=Dp.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function Hp(){return[qd(),vf(),Cf(),Op(),Lp()]}function Up(e){return{extensions:[Jd(),yf(e),wf(),Ip(e),Rp()]}}var Wp={tokenize:im,partial:!0},Gp={tokenize:am,partial:!0},Kp={tokenize:om,partial:!0},qp={tokenize:sm,partial:!0},Jp={tokenize:cm,partial:!0},Yp={name:`wwwAutolink`,tokenize:nm,previous:lm},Xp={name:`protocolAutolink`,tokenize:rm,previous:um},Zp={name:`emailAutolink`,tokenize:tm,previous:dm},Qp={};function $p(){return{text:Qp}}for(var em=48;em<123;)Qp[em]=Zp,em++,em===58?em=65:em===91&&(em=97);Qp[43]=Zp,Qp[45]=Zp,Qp[46]=Zp,Qp[95]=Zp,Qp[72]=[Zp,Xp],Qp[104]=[Zp,Xp],Qp[87]=[Zp,Yp],Qp[119]=[Zp,Yp];function tm(e,t,n){let r=this,i,a;return o;function o(t){return!fm(t)||!dm.call(r,r.previous)||pm(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return fm(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(Jp,u,l)(t):t===45||t===95||q(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&K(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function nm(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!lm.call(r,r.previous)||pm(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(Wp,e.attempt(Gp,e.attempt(Kp,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function rm(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&um.call(r,r.previous)&&!pm(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(K(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||$o(t)||Y(t)||is(t)||rs(t)?n(t):e.attempt(Gp,e.attempt(Kp,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function im(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function am(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(qp,c,s)(t):t===null||Y(t)||is(t)||t!==45&&rs(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function om(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(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(qp,t,a)(o):o===null||Y(o)||is(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function sm(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||Y(o)||is(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||Y(e)||is(e)?t(e):r(e)}function a(e){return K(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):K(t)?(e.consume(t),o):n(t)}}function cm(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return q(e)?n(e):t(e)}}function lm(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Y(e)}function um(e){return!K(e)}function dm(e){return!(e===47||fm(e))}function fm(e){return e===43||e===45||e===46||e===95||q(e)}function pm(e){let t=e.length,n=!1;for(;t--;){let 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}var mm={tokenize:Sm,partial:!0};function hm(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:ym,continuation:{tokenize:bm},exit:xm}},text:{91:{name:`gfmFootnoteCall`,tokenize:vm},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:gm,resolveTo:_m}}}}function gm(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=Zo(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function _m(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`;let 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++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function vm(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||Y(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(Zo(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return Y(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function ym(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||Y(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=Zo(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return Y(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),Z(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function bm(e,t,n){return e.check(xs,t,e.attempt(mm,t,n))}function xm(e){e.exit(`gfmFootnoteDefinition`)}function Sm(e,t,n){let r=this;return Z(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function Cm(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&Wo(o,o.length,0,ms(s,e.slice(r+1,n),t)),Wo(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),Wo(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=ps(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=ps(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var wm=class{constructor(){this.map=[]}add(e,t,n){Tm(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function Tm(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 Em(e,t){let n=!1,r=[];for(;t<e.length;){let 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`){let e=r.length-1;r[e]=r[e]===`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 Dm(){return{flow:{null:{name:`table`,tokenize:Om,resolveAll:km}}}}function Om(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):J(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):X(t)?Z(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||Y(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,X(t)?Z(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return X(t)?Z(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||J(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return X(t)?Z(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||J(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||J(n)?(e.exit(`tableRow`),t(n)):X(n)?Z(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||Y(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function km(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new wm;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(jm(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=Am(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=Am(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=Am(f,t,o,i,n,d)):(o[0]=o[1],d=Am(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&jm(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=Em(t.events,n))}return e}function Am(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},Mm(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=Mm(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=Mm(t.events,n[2]),a=Mm(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},Mm(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function jm(e,t,n,r,i){let a=[],o=Mm(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function Mm(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var Nm={name:`tasklistCheck`,tokenize:Fm};function Pm(){return{text:{91:Nm}}}function Fm(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return Y(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return J(r)?t(r):X(r)?e.check({tokenize:Im},t,n)(r):n(r)}}function Im(e,t,n){return Z(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function Lm(e){return qo([$p(),hm(),Cm(e),Dm(),Pm()])}var Rm={};function zm(e){let t=this,n=e||Rm,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(Lm(n)),a.push(Hp()),o.push(Up(n))}function Bm(){return typeof navigator<`u`&&typeof navigator.clipboard?.writeText==`function`}function Vm(e){if(typeof document>`u`)return;let t=document.getSelection();t&&(t.removeAllRanges(),e.forEach(e=>t.addRange(e)))}function Hm(e){if(typeof document>`u`||!document.body)return!1;let t=document.activeElement instanceof HTMLElement?document.activeElement:null,n=t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement?t:null,r=n?{start:n.selectionStart,end:n.selectionEnd}:null,i=document.getSelection(),a=i?Array.from({length:i.rangeCount},(e,t)=>i.getRangeAt(t).cloneRange()):[],o=document.createElement(`textarea`);o.value=e,o.setAttribute(`readonly`,``),o.setAttribute(`aria-hidden`,`true`),o.style.position=`fixed`,o.style.top=`0`,o.style.left=`-9999px`,o.style.opacity=`0`,o.style.pointerEvents=`none`,o.style.fontSize=`12pt`,document.body.appendChild(o);try{o.focus({preventScroll:!0})}catch{o.focus()}o.select(),o.setSelectionRange(0,o.value.length);let s=!1;try{s=typeof document.execCommand==`function`&&document.execCommand(`copy`)}catch{s=!1}if(o.remove(),t)try{t.focus({preventScroll:!0})}catch{t.focus()}return n&&r?n.setSelectionRange(r.start,r.end):Vm(a),s}async function Um(e){if(!e)return!1;if(Bm())try{return await navigator.clipboard.writeText(e),!0}catch{return Hm(e)}return Hm(e)}var Wm=1300;function Gm(e){let[t,n]=(0,F.useState)(!1),r=(0,F.useCallback)(async()=>{e.text&&(await Um(e.text)?n(!0):n(!1))},[e.text]);return(0,F.useEffect)(()=>{if(!t||typeof window>`u`)return;let r=window.setTimeout(()=>n(!1),e.resetDelayMs??Wm);return()=>window.clearTimeout(r)},[t,e.resetDelayMs]),{copied:t,copy:r}}var Km=/language-([a-z0-9-]+)/i;function qm(e){return typeof e==`string`||typeof e==`number`?String(e):Array.isArray(e)?e.map(qm).join(``):``}function Jm(e){let t=qm(e);return t.endsWith(`
|
|
32
|
+
`)?t.slice(0,-1):t}function Ym(e){return(e?Km.exec(e):null)?.[1]?.toLowerCase()||`text`}function Xm(e){let t=(0,F.useMemo)(()=>Ym(e.className),[e.className]),n=(0,F.useMemo)(()=>Jm(e.children),[e.children]),{copied:r,copy:i}=Gm({text:n});return(0,L.jsxs)(`div`,{className:`chat-codeblock`,children:[(0,L.jsxs)(`div`,{className:`chat-codeblock-toolbar`,children:[(0,L.jsx)(`span`,{className:`chat-codeblock-language`,children:t}),(0,L.jsxs)(`button`,{type:`button`,className:`chat-codeblock-copy`,onClick:()=>void i(),"aria-label":r?e.texts.copiedCodeLabel:e.texts.copyCodeLabel,children:[r?(0,L.jsx)(M,{className:`h-3.5 w-3.5`}):(0,L.jsx)(Zt,{className:`h-3.5 w-3.5`}),(0,L.jsx)(`span`,{children:r?e.texts.copiedCodeLabel:e.texts.copyCodeLabel})]})]}),(0,L.jsx)(`pre`,{children:(0,L.jsx)(`code`,{className:e.className,children:n})})]})}var Zm=14e4,Qm=new Set([`http:`,`https:`,`mailto:`,`tel:`]);function $m(e){return e.length<=Zm?e:`${e.slice(0,Zm)}\n\n...`}function eh(e){if(!e)return null;if(e.startsWith(`#`)||e.startsWith(`/`)||e.startsWith(`./`)||e.startsWith(`../`))return e;try{let t=new URL(e);return Qm.has(t.protocol)?e:null}catch{return null}}function th(e){return/^https?:\/\//i.test(e)}function nh({text:e,role:t,texts:n,inline:r=!1}){let i=t===`user`,a=(0,F.useMemo)(()=>({p:({children:e})=>r?(0,L.jsx)(L.Fragment,{children:e}):(0,L.jsx)(`p`,{children:e}),a:({href:e,children:t,...n})=>{let r=eh(e);if(!r)return(0,L.jsx)(`span`,{className:`chat-link-invalid`,children:t});let i=th(r);return(0,L.jsx)(`a`,{...n,href:r,target:i?`_blank`:void 0,rel:i?`noreferrer noopener`:void 0,children:t})},table:({children:e,...t})=>(0,L.jsx)(`div`,{className:`chat-table-wrap`,children:(0,L.jsx)(`table`,{...t,children:e})}),input:({type:e,checked:t,...n})=>e===`checkbox`?(0,L.jsx)(`input`,{...n,type:`checkbox`,checked:t,readOnly:!0,disabled:!0,className:`chat-task-checkbox`}):(0,L.jsx)(`input`,{...n,type:e}),img:({src:e,alt:t,...n})=>{let r=eh(e);return r?(0,L.jsx)(`img`,{...n,src:r,alt:t||``,loading:`lazy`,decoding:`async`}):null},code:({className:e,children:t,...r})=>!e&&!String(t??``).includes(`
|
|
33
|
+
`)?(0,L.jsx)(`code`,{...r,className:z(`chat-inline-code`,e),children:t}):(0,L.jsx)(Xm,{className:e,texts:n,children:t})}),[r,n]);return(0,L.jsx)(r?`span`:`div`,{className:z(`chat-markdown`,i?`chat-markdown-user`:`chat-markdown-assistant`),children:(0,L.jsx)(Pd,{skipHtml:!0,remarkPlugins:[zm],components:a,children:$m(e)})})}function rh(e){return e.split(``).join(``).split(``).join(``).split(``).join(``).split(``).join(``).split(``).join(``).length>0}function ih(){return(0,L.jsxs)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.25`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:`h-3 w-3`,children:[(0,L.jsx)(`path`,{d:`M8.5 2.75 2.75 6l5.75 3.25L14.25 6 8.5 2.75Z`}),(0,L.jsx)(`path`,{d:`M2.75 10 8.5 13.25 14.25 10`}),(0,L.jsx)(`path`,{d:`M2.75 6v4l5.75 3.25V9.25L2.75 6Z`}),(0,L.jsx)(`path`,{d:`M14.25 6v4L8.5 13.25V9.25L14.25 6Z`})]})}function ah({kind:e,label:t,isUser:n}){let r=e===`skill`;return(0,L.jsxs)(`span`,{className:z(`mx-[2px] inline-flex h-7 max-w-full items-center gap-1.5 rounded-xl border px-2.5 align-baseline text-[11px] font-medium shadow-[0_0_0_1px_rgba(15,23,42,0.03)]`,r?n?`border-emerald-200/35 bg-emerald-400/18 text-emerald-50/95`:`border-emerald-200/70 bg-emerald-50 text-emerald-700`:n?`border-white/30 bg-white/18 text-white`:`border-slate-200/80 bg-slate-100 text-slate-700`),title:t,children:[(0,L.jsx)(`span`,{className:z(`inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center`,r?n?`text-emerald-100/90`:`text-emerald-600`:n?`text-white/70`:`text-slate-500`),children:(0,L.jsx)(ih,{})}),(0,L.jsx)(`span`,{className:`truncate`,children:t})]})}function oh({segments:e,role:t,texts:n}){let r=t===`user`;return(0,L.jsx)(`div`,{className:`whitespace-pre-wrap break-words leading-6`,children:e.map((e,i)=>e.type===`token`?(0,L.jsx)(ah,{kind:e.token.kind,label:e.token.label,isUser:r},`token-${i}-${e.token.kind}-${e.token.key}`):rh(e.text)?(0,L.jsx)(nh,{text:e.text,role:t,texts:n,inline:!0},`markdown-${i}`):(0,L.jsx)(`span`,{className:`whitespace-pre-wrap`,children:e.text},`space-${i}`))})}var sh={archive:`Archive`,audio:`Audio`,code:`Code`,data:`Data`,document:`Document`,generic:`File`,image:`Image`,pdf:`PDF`,sheet:`Sheet`,video:`Video`},ch={archive:`border-amber-200/80 bg-amber-100 text-amber-700`,audio:`border-fuchsia-200/80 bg-fuchsia-100 text-fuchsia-700`,code:`border-cyan-200/80 bg-cyan-100 text-cyan-700`,data:`border-slate-200/80 bg-slate-100 text-slate-700`,document:`border-blue-200/80 bg-blue-100 text-blue-700`,generic:`border-slate-200/80 bg-slate-100 text-slate-700`,image:`border-emerald-200/80 bg-emerald-100 text-emerald-700`,pdf:`border-rose-200/80 bg-rose-100 text-rose-700`,sheet:`border-lime-200/80 bg-lime-100 text-lime-700`,video:`border-violet-200/80 bg-violet-100 text-violet-700`},lh=new Set([`c`,`cpp`,`css`,`go`,`html`,`java`,`js`,`jsx`,`md`,`php`,`py`,`rb`,`rs`,`sh`,`sql`,`svg`,`ts`,`tsx`]),uh=new Set([`graphql`,`json`,`toml`,`xml`,`yaml`,`yml`]),dh=new Set([`doc`,`docx`,`odt`,`pages`,`rtf`,`txt`]),fh=new Set([`csv`,`numbers`,`ods`,`tsv`,`xls`,`xlsx`]),ph=new Set([`7z`,`bz2`,`gz`,`rar`,`tar`,`tgz`,`zip`]);function mh(e){if(!Number.isFinite(e)||e==null||e<0)return null;if(e===0)return`0 B`;let t=[`B`,`KB`,`MB`,`GB`,`TB`],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;let i=n>=10||r===0?0:1;return`${n.toFixed(i).replace(/\.0$/,``)} ${t[r]}`}function hh(e,t){let n=/\.([a-z0-9]{1,12})$/i.exec(e.trim());if(n?.[1])return n[1].toUpperCase();let r=(t.split(`/`)[1]??``).split(/[+.;-]/)[0]?.trim();return r?r.slice(0,6).toUpperCase():`FILE`}function gh(e,t){let n=/\.([a-z0-9]{1,12})$/i.exec(e.trim())?.[1]?.toLowerCase()??``,r=t.toLowerCase();return r.startsWith(`image/`)?`image`:r.startsWith(`audio/`)?`audio`:r.startsWith(`video/`)?`video`:r.includes(`pdf`)||n===`pdf`?`pdf`:ph.has(n)||/(zip|tar|gzip|rar|compressed|archive)/.test(r)?`archive`:fh.has(n)||/(spreadsheet|sheet|excel|csv)/.test(r)?`sheet`:uh.has(n)||/(json|xml|yaml|toml)/.test(r)?`data`:lh.has(n)||/(javascript|typescript|jsx|tsx|css|html)/.test(r)?`code`:dh.has(n)||/(msword|document|opendocument|rtf|text\/)/.test(r)?`document`:`generic`}function _h(e){let t=gh(e.label,e.mimeType),n=mh(e.sizeBytes);return{category:t,extension:hh(e.label,e.mimeType),sizeLabel:n,metaBadges:[sh[t],n].filter(e=>!!e)}}function vh(e,t){return(0,L.jsx)(`span`,{className:z(`inline-flex items-center rounded-full border px-2.5 py-1 text-[11px] font-medium`,t?`border-white/12 bg-white/10 text-white/82`:`border-slate-200/80 bg-slate-950/[0.04] text-slate-600`),children:e},e)}function yh(e,t){return(0,L.jsx)(`div`,{className:z(`truncate text-[11px]`,t?`text-white/58`:`text-slate-500`),children:e})}function bh(e,t,n){return(0,L.jsx)(`span`,{className:z(`inline-flex items-center rounded-full border px-2.5 py-1 text-[11px] font-medium`,n?t?`border-white/14 bg-white/12 text-white`:`border-slate-200/80 bg-white text-slate-700`:t?`border-white/10 bg-white/6 text-white/62`:`border-slate-200/70 bg-slate-100/80 text-slate-500`),children:e})}function xh({file:e,isUser:t=!1}){let{category:n,extension:r,metaBadges:i,sizeLabel:a}=_h(e),o=!!e.dataUrl,s=o?e.isImage?`Open preview`:`Open file`:`Attached`,c=r.slice(0,4),l=z(`block overflow-hidden rounded-[1.25rem] border transition duration-200`,t?`border-white/12 bg-white/10 text-white shadow-[0_18px_40px_-28px_rgba(15,23,42,0.85)]`:`border-slate-200/80 bg-white/95 text-slate-900 shadow-[0_20px_45px_-30px_rgba(15,23,42,0.28)]`,o&&(t?`hover:border-white/18 hover:bg-white/13`:`hover:border-slate-300 hover:bg-white hover:shadow-[0_24px_50px_-30px_rgba(15,23,42,0.3)]`));if(e.isImage&&e.dataUrl)return(0,L.jsx)(`a`,{href:e.dataUrl,target:`_blank`,rel:`noreferrer`,"aria-label":`Open preview: ${e.label}`,className:z(l,`group`),children:(0,L.jsxs)(`figure`,{children:[(0,L.jsxs)(`div`,{className:z(`relative overflow-hidden p-2`,t?`bg-white/[0.04]`:`bg-gradient-to-br from-slate-100 via-white to-slate-100`),children:[(0,L.jsx)(`img`,{src:e.dataUrl,alt:e.label,className:`block max-h-[22rem] w-full rounded-[1rem] object-cover shadow-[0_18px_40px_-26px_rgba(15,23,42,0.55)] transition duration-300 group-hover:scale-[1.01]`}),(0,L.jsxs)(`div`,{className:`pointer-events-none absolute inset-x-4 top-4 flex items-center justify-between`,children:[a?vh(a,t):(0,L.jsx)(`span`,{}),(0,L.jsx)(`span`,{className:z(`inline-flex items-center rounded-full border px-2.5 py-1 text-[11px] font-semibold tracking-[0.22em]`,t?`border-white/12 bg-slate-950/20 text-white`:ch[n]),children:c})]})]}),(0,L.jsxs)(`figcaption`,{className:`flex items-start gap-3 p-4`,children:[(0,L.jsx)(`div`,{className:z(`flex h-11 w-11 shrink-0 items-center justify-center rounded-[1rem] border text-[11px] font-semibold tracking-[0.22em]`,t?`border-white/12 bg-white/10 text-white`:ch[n]),children:c}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`div`,{className:`truncate text-sm font-semibold leading-5`,children:e.label}),(0,L.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:i.map(e=>vh(e,t))}),(0,L.jsx)(`div`,{className:`mt-2`,children:yh(e.mimeType,t)})]}),bh(s,t,!0)]})]})});let u=(0,L.jsxs)(`div`,{className:`flex items-start gap-3 p-3.5`,children:[(0,L.jsx)(`div`,{className:z(`flex h-14 w-14 shrink-0 items-center justify-center rounded-[1rem] border text-xs font-semibold tracking-[0.22em]`,t?`border-white/12 bg-white/10 text-white`:ch[n]),children:c}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`div`,{className:`truncate text-sm font-semibold leading-5`,children:e.label}),(0,L.jsxs)(`div`,{className:z(`mt-1 text-xs`,t?`text-white/68`:`text-slate-500`),children:[sh[n],` attachment`]})]}),bh(s,t,o)]}),(0,L.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:i.map(e=>vh(e,t))}),(0,L.jsx)(`div`,{className:`mt-2`,children:yh(e.mimeType,t)})]})]});return o?(0,L.jsx)(`a`,{href:e.dataUrl,target:`_blank`,rel:`noreferrer`,"aria-label":`Open file: ${e.label}`,className:z(l,`group`),children:u}):(0,L.jsx)(`div`,{className:l,children:u})}function Sh(e){let{isInProgress:t}=e,[n,r]=(0,F.useState)(t),[i,a]=(0,F.useState)(!1),o=(0,F.useRef)(t);(0,F.useEffect)(()=>{let e=o.current;!e&&t?(r(!0),a(!1)):e&&!t&&!i&&r(!1),o.current=t},[t,i]);function s(e){e.preventDefault();let i=!n;if(r(i),!i){a(!1);return}t&&a(!0)}return{isOpen:n,onSummaryClick:s}}function Ch({label:e,text:t,isUser:n,isInProgress:r}){let{isOpen:i,onSummaryClick:a}=Sh({isInProgress:r});return(0,L.jsxs)(`details`,{className:`mt-2`,open:i,children:[(0,L.jsx)(`summary`,{className:z(`cursor-pointer text-xs`,n?`text-primary-100`:`text-gray-500`),onClick:a,children:e}),(0,L.jsx)(`pre`,{className:z(`mt-2 w-fit max-w-[500px] whitespace-pre-wrap break-all rounded-lg p-2 text-[11px]`,n?`bg-primary-700/60`:`bg-gray-100`),children:t})]})}function wh({children:e,className:t}){return(0,L.jsx)(`div`,{className:z(`my-2 rounded-lg border border-amber-200/50 bg-amber-100/30 shadow-sm overflow-hidden text-[12px]`,`w-[280px] sm:w-[360px] md:w-[480px] min-w-full max-w-full transition-all flex flex-col`,t),children:e})}function Th({children:e,className:t}){return(0,L.jsx)(`div`,{className:z(`border-t border-amber-200/15 bg-amber-50/50 px-3 pt-1 pb-2 w-full overflow-hidden`,t),children:e})}var Eh={running:{text:`text-amber-500/80`,icon:Me,spin:!0},success:{text:`text-amber-500/80`,icon:M,spin:!1},error:{text:`text-amber-500/80`,icon:mn,spin:!1},cancelled:{text:`text-amber-500/80`,icon:sn,spin:!1}};function Dh({card:e}){let t=Eh[e.statusTone]||Eh.cancelled,n=t.icon;return(0,L.jsxs)(`span`,{className:z(`inline-flex items-center gap-1.5 text-[11px] font-medium leading-none shrink-0`,t.text),children:[(0,L.jsx)(n,{className:z(`h-3.5 w-3.5`,t.spin&&`animate-spin`),strokeWidth:3}),e.statusTone===`running`?e.statusLabel:null]})}function Oh({card:e,icon:t,expanded:n,canExpand:r,hideSummary:i=!1,onToggle:a}){let o=i?``:e.summary?.replace(/^(command|path|args|query|input):\s*/i,``)??``;return(0,L.jsxs)(`div`,{className:z(`flex items-center justify-between px-3 py-2.5 transition-colors bg-transparent`,r?`cursor-pointer hover:bg-amber-100/30`:``),onClick:a,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 font-mono min-w-0 max-w-[calc(100%-80px)] text-amber-950/80`,children:[(0,L.jsx)(t,{className:`h-4 w-4 text-amber-600/80 shrink-0`,strokeWidth:3}),(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,L.jsx)(`span`,{className:`font-bold shrink-0 tracking-tight`,children:e.toolName}),o&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`text-amber-300 font-bold select-none shrink-0`,children:`›`}),(0,L.jsx)(`span`,{className:`truncate flex-1 min-w-0 font-normal`,title:o,children:o})]})]})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,L.jsx)(Dh,{card:e}),r&&(n?(0,L.jsx)(T,{className:`h-4 w-4 text-amber-400/80`,strokeWidth:3}):(0,L.jsx)(Yt,{className:`h-4 w-4 text-amber-400/80`,strokeWidth:3}))]})]})}var kh=10;function Ah(e){e.scrollTop=e.scrollHeight}function jh(e){e.scrollRef.current&&(e.scheduledScrollFrameRef.current!==null&&cancelAnimationFrame(e.scheduledScrollFrameRef.current),e.scheduledScrollFrameRef.current=requestAnimationFrame(()=>{e.scheduledScrollFrameRef.current=null;let t=e.scrollRef.current;t&&(e.isProgrammaticScrollRef.current=!0,Ah(t))}))}function Mh(e){let t=(0,F.useRef)(!0),n=(0,F.useRef)(!1),r=(0,F.useRef)(null),i=(0,F.useRef)(!1),a=(0,F.useRef)(null);return(0,F.useEffect)(()=>{r.current!==e.resetKey&&(r.current=e.resetKey,t.current=!0,i.current=!0)},[e.resetKey]),(0,F.useEffect)(()=>{let e=a.current;return()=>{e!==null&&cancelAnimationFrame(e)}},[]),(0,F.useLayoutEffect)(()=>{!i.current||e.isLoading||!e.hasContent||e.scrollRef.current&&(i.current=!1,jh({scrollRef:e.scrollRef,scheduledScrollFrameRef:a,isProgrammaticScrollRef:n}))},[e.hasContent,e.isLoading,e.scrollRef]),(0,F.useLayoutEffect)(()=>{!t.current||!e.hasContent||e.scrollRef.current&&jh({scrollRef:e.scrollRef,scheduledScrollFrameRef:a,isProgrammaticScrollRef:n})},[e.contentVersion,e.hasContent,e.scrollRef]),{onScroll:()=>{if(n.current){n.current=!1;return}let r=e.scrollRef.current;r&&(t.current=r.scrollHeight-r.scrollTop-r.clientHeight<=(e.stickyThresholdPx??kh))}}}var Nh=`h-5 font-mono text-[11px] leading-5`,Ph=`sticky left-0 z-[1] flex h-5 items-center justify-center px-2.5 tabular-nums select-none`;function Fh(e){return typeof e==`number`?String(e):``}function Ih(e){return Fh(e.newLineNumber??e.oldLineNumber)}function Lh(e,t,n){return`${e}-${n}-${t.oldLineNumber??`x`}-${t.newLineNumber??`x`}`}function Rh(e){return typeof e.newLineNumber==`number`||typeof e.oldLineNumber==`number`}function zh(e){return e.lines.some(Rh)}function Bh(e){let t=e.lines.reduce((e,t)=>Rh(t)?Math.max(e,Ih(t).length):e,0);return`${Math.max(6.5,Math.min(8,t+3.5))}ch`}function Vh(e){if(e.showLineNumbers)return{gridTemplateColumns:`${e.lineNumberColumnWidth} minmax(0, 1fr)`}}function Hh(e){return e.kind===`remove`?`border-r border-rose-200 bg-rose-50 text-rose-700`:e.kind===`add`?`border-r border-emerald-200 bg-emerald-50 text-emerald-700`:`border-r border-stone-200 bg-stone-100 text-stone-500`}function Uh(e){return e.kind===`remove`?`bg-rose-50 text-rose-950`:e.kind===`add`?`bg-emerald-50 text-emerald-950`:`bg-white text-amber-950/80`}function Wh({line:e,showLineNumbers:t,lineNumberColumnWidth:n}){return(0,L.jsxs)(`div`,{"data-file-line-row":`true`,className:z(`grid w-max min-w-full`,Nh),style:Vh({showLineNumbers:t,lineNumberColumnWidth:n}),children:[t?(0,L.jsx)(`span`,{"data-file-line-number-cell":`true`,style:{width:n},className:z(Ph,Hh(e)),children:Ih(e)}):null,(0,L.jsx)(`span`,{"data-file-code-row":`true`,className:z(`block min-w-full whitespace-pre px-2.5`,Uh(e)),children:e.text||` `})]})}function Gh({block:e}){let t=zh(e),n=Bh(e);return(0,L.jsx)(`div`,{className:`overflow-x-auto custom-scrollbar-amber bg-white`,children:e.lines.map((e,r)=>(0,L.jsx)(Wh,{line:e,showLineNumbers:t,lineNumberColumnWidth:n},Lh(`row`,e,r)))})}function Kh(e){return e.display===`preview`}function qh(e){return e.rawText?e.rawText:e.lines.map(e=>[e.kind,e.oldLineNumber??``,e.newLineNumber??``,e.text].join(`:`)).join(`
|
|
34
|
+
`)}function Jh(e){return/^\+\d+$/.test(e)?`text-emerald-700`:/^-\d+$/.test(e)?`text-rose-700`:`text-stone-500`}function Yh(e){let t=e.split(`·`).map(e=>e.trim()).filter(e=>/^\+\d+$/.test(e)||/^-\d+$/.test(e));return t.length===0?null:(0,L.jsx)(`div`,{className:`flex shrink-0 items-center gap-x-1 whitespace-nowrap text-[10px] font-medium uppercase tracking-[0.08em]`,children:t.map((e,t)=>(0,L.jsxs)(F.Fragment,{children:[t>0?(0,L.jsx)(`span`,{className:`text-stone-300`,children:`·`}):null,(0,L.jsx)(`span`,{className:z(Jh(e)),children:e})]},`${e}-${t}`))})}function Xh({children:e,contentVersion:t,resetKey:n,className:r,scrollKind:i}){let a=(0,F.useRef)(null),{onScroll:o}=Mh({scrollRef:a,resetKey:n,isLoading:!1,hasContent:!0,contentVersion:t,stickyThresholdPx:20});return(0,L.jsx)(`div`,{ref:a,onScroll:o,"data-file-scroll-kind":i,className:z(`overflow-y-auto overscroll-contain bg-white custom-scrollbar-amber`,r),children:e})}function Zh({block:e,showPathRow:t,isFirst:n}){let{Tooltip:r,TooltipContent:i,TooltipProvider:a,TooltipTrigger:o}=ai,s=Kh(e),c=t||!!e.caption;return(0,L.jsxs)(`section`,{className:z(`overflow-hidden bg-white`,!n&&`border-t border-stone-200/80`),children:[c?(0,L.jsxs)(`div`,{className:z(`flex items-center justify-between gap-4 border-b border-stone-200/80 px-4 text-stone-700`,t?`py-2`:`py-1.5`),children:[(0,L.jsx)(`div`,{className:`min-w-0 flex-1`,children:t?(0,L.jsx)(a,{delayDuration:250,children:(0,L.jsxs)(r,{children:[(0,L.jsx)(o,{asChild:!0,children:(0,L.jsx)(`div`,{className:`truncate whitespace-nowrap font-mono text-[12px] font-medium text-stone-700`,title:e.path,children:e.path})}),(0,L.jsx)(i,{side:`top`,className:`max-w-[420px] text-xs font-mono break-all`,children:e.path})]})}):null}),e.caption?Yh(e.caption):null]}):null,e.lines.length>0?(0,L.jsx)(Xh,{resetKey:`block:${e.key}`,contentVersion:qh(e),className:`max-h-72`,scrollKind:`block`,children:(0,L.jsx)(Gh,{block:e})}):e.rawText?(0,L.jsx)(Xh,{resetKey:`raw:${e.key}`,contentVersion:e.rawText,className:`max-h-72`,scrollKind:`raw`,children:(0,L.jsx)(`div`,{className:`overflow-x-auto custom-scrollbar-amber`,children:(0,L.jsx)(`pre`,{className:`min-w-max whitespace-pre bg-white px-4 py-2 font-mono text-[11px] leading-5 text-amber-950/80`,children:e.rawText})})}):null,e.truncated&&!s?(0,L.jsx)(`div`,{className:`border-t border-stone-200/85 bg-stone-50 px-4 py-2 text-[10px] text-stone-500`,children:`Showing a shortened diff preview.`}):null]})}function Qh({card:e,className:t}){let n=e.fileOperation?.blocks??[],r=e.output?.trim()??``;return n.length===0&&!r?null:(0,L.jsxs)(`div`,{className:z(`overflow-hidden bg-white`,t),children:[n.map((e,t)=>(0,L.jsx)(Zh,{block:e,showPathRow:!0,isFirst:t===0},e.key)),r?(0,L.jsx)(Xh,{resetKey:`output:${e.toolName}:${e.summary??`none`}`,contentVersion:r,className:z(`max-h-56`,n.length>0&&`border-t border-stone-200/80`),scrollKind:`output`,children:(0,L.jsx)(`div`,{className:`overflow-x-auto custom-scrollbar-amber`,children:(0,L.jsx)(`pre`,{className:`min-w-max whitespace-pre bg-white px-4 py-2 font-mono text-[11px] leading-5 text-amber-950/80`,children:r})})}):null]})}var $h=200,eg=RegExp(`\x1B\\[[0-?]*[ -/]*[@-~]`,`g`);function tg(e){return typeof e==`string`&&e.length>0?e:null}function ng(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function rg(e){return e.replace(eg,``)}function ig(e){return`command`in e||`workingDir`in e||`exitCode`in e||`durationMs`in e||`stdout`in e||`stderr`in e||`aggregated_output`in e||`combinedOutput`in e}function ag(e){let t=tg(e.aggregated_output)??tg(e.combinedOutput)??tg(e.output);if(t)return t;let n=tg(e.stdout),r=tg(e.stderr);return!n&&!r?null:[n,r].filter(e=>!!e).join(`
|
|
35
|
+
`)}function og(e,t){if(ng(t)){let e=ag(t);if(e)return rg(e);if(ig(t))return``}if(!e)return``;let n=e.trim();if(!n.startsWith(`{`))return rg(e);try{let t=JSON.parse(n);if(!ng(t))return rg(e);let r=ag(t);return r?rg(r):ig(t)?``:rg(e)}catch{return rg(e)}}function sg({canExpand:e,isRunning:t,autoExpandWhileRunning:n=!0,expandOnError:r=!1,statusTone:i}){let[a,o]=(0,F.useState)(!1),[s,c]=(0,F.useState)(!1),l=(0,F.useRef)(null),u=(0,F.useRef)(t),d=(0,F.useRef)(!0);return(0,F.useEffect)(()=>()=>{l.current!==null&&window.clearTimeout(l.current)},[]),(0,F.useEffect)(()=>{if(r&&i===`error`&&e&&!s){l.current!==null&&(window.clearTimeout(l.current),l.current=null),o(!0),u.current=t,d.current=!1;return}n&&t&&e&&!s&&!a&&(d.current||!u.current)&&(l.current=window.setTimeout(()=>{o(!0),l.current=null},$h)),t||(l.current!==null&&(window.clearTimeout(l.current),l.current=null),u.current&&!s&&o(!1)),u.current=t,d.current=!1},[n,e,r,a,s,t,i]),{expanded:a,onToggle:()=>{e&&(l.current!==null&&(window.clearTimeout(l.current),l.current=null),o(e=>!e),c(!0))}}}function cg({label:e,tone:t,children:n}){let r={input:{shell:`border-stone-200/80 bg-stone-50/90`,header:`border-stone-200/80 bg-stone-100/85 text-stone-500`,dot:`bg-stone-400/80`,body:`text-stone-700`},output:{shell:`border-amber-200/70 bg-white/90`,header:`border-amber-200/70 bg-amber-50/90 text-amber-700`,dot:`bg-amber-500/80`,body:`text-amber-950/80`},error:{shell:`border-rose-200/80 bg-rose-50/85`,header:`border-rose-200/80 bg-rose-100/80 text-rose-700`,dot:`bg-rose-500/80`,body:`text-rose-950/85`}}[t];return(0,L.jsxs)(`section`,{className:z(`overflow-hidden rounded-md border shadow-[inset_0_1px_0_rgba(255,255,255,0.45)]`,r.shell),children:[(0,L.jsxs)(`div`,{className:z(`flex items-center gap-2 border-b px-3 py-2 text-[10px] font-semibold uppercase tracking-[0.16em]`,r.header),children:[(0,L.jsx)(`span`,{className:z(`h-1.5 w-1.5 rounded-full`,r.dot)}),(0,L.jsx)(`span`,{children:e})]}),(0,L.jsx)(`div`,{className:`w-full overflow-hidden`,children:(0,L.jsx)(`pre`,{className:z(`w-full max-w-full min-w-0 max-h-64 overflow-x-auto overflow-y-auto px-3 py-2.5 font-mono text-[12px] leading-relaxed whitespace-pre custom-scrollbar-amber`,r.body),children:n})})]})}function lg({card:e}){let t=og(e.output,e.outputData),n=e.statusTone===`running`,r=!!(e.summary?.trim()||t.trim().length>0),{expanded:i,onToggle:a}=sg({canExpand:t.trim().length>0||n,isRunning:n,expandOnError:r,statusTone:e.statusTone}),o=e.summary?.replace(/^(command|path|args|query|input):\s*/i,``);return(0,L.jsxs)(wh,{children:[(0,L.jsx)(Oh,{card:e,icon:pn,expanded:i,canExpand:t.trim().length>0||n,onToggle:a}),i&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`px-3 pb-2 font-mono w-full max-h-48 overflow-y-auto custom-scrollbar-amber min-h-0 text-[12px]`,children:(0,L.jsxs)(`div`,{className:`flex items-start gap-2 leading-relaxed`,children:[(0,L.jsx)(`span`,{className:`text-amber-500/50 font-medium shrink-0 select-none mt-[1px]`,children:`$`}),(0,L.jsx)(`div`,{className:`flex-1 min-w-0`,children:o?(0,L.jsxs)(`div`,{className:`text-amber-950/80 break-words whitespace-pre-wrap tracking-tight font-medium inline-block`,children:[o,n&&!t&&(0,L.jsx)(`span`,{className:`inline-block w-1.5 h-3 ml-1 bg-amber-500/60 animate-pulse align-middle`})]}):(0,L.jsx)(`div`,{className:`h-3 w-32 bg-amber-200/30 rounded animate-pulse mt-2`})})]})}),t&&(0,L.jsx)(Th,{children:(0,L.jsxs)(`pre`,{className:`font-mono text-[12px] text-amber-950/70 whitespace-pre-wrap break-all w-full max-w-full max-h-64 overflow-y-auto overflow-x-hidden min-w-0 custom-scrollbar-amber leading-relaxed px-0`,children:[t,n&&(0,L.jsx)(`span`,{className:`inline-block w-1.5 h-3 ml-1 bg-amber-500/60 animate-pulse align-middle`})]})})]})]})}function ug({card:e}){let t=e.output?.trim()??``,n=e.statusTone===`running`,r=!!e.fileOperation?.blocks.length,i=r||!!t,a=e.fileOperation?.blocks??[],o=a.reduce((e,t)=>e+t.lines.length,0),s=a.reduce((e,t)=>t.rawText?e+t.rawText.length:e+t.lines.reduce((e,t)=>e+t.text.length+1,0),0),c=!(n&&e.toolName===`write_file`&&(o>24||s>1200)),{expanded:l,onToggle:u}=sg({canExpand:i||n,isRunning:n,autoExpandWhileRunning:c,expandOnError:i,statusTone:e.statusTone});return(0,L.jsxs)(wh,{children:[(0,L.jsx)(Oh,{card:e,icon:e.toolName===`edit_file`||e.toolName===`write_file`||e.toolName===`apply_patch`||e.toolName===`file_change`?Xt:$t,expanded:l,canExpand:i||n,hideSummary:l&&r,onToggle:u}),l&&i&&(0,L.jsx)(Th,{className:`border-t border-amber-200/20 bg-transparent px-0 pt-0 pb-0`,children:(0,L.jsx)(Qh,{card:e})})]})}function dg({card:e}){let t=e.statusTone===`running`,n=e.output?.trim()??``,{expanded:r,onToggle:i}=sg({canExpand:!!n||t,isRunning:t,statusTone:e.statusTone});return(0,L.jsxs)(wh,{children:[(0,L.jsx)(Oh,{card:e,icon:Ge,expanded:r,canExpand:!!n||t,onToggle:i}),r&&n&&(0,L.jsx)(Th,{children:(0,L.jsx)(`pre`,{className:`font-mono text-[12px] text-amber-950/70 whitespace-pre-wrap break-all w-full max-w-full max-h-64 overflow-y-auto overflow-x-hidden min-w-0 custom-scrollbar-amber leading-relaxed`,children:n})})]})}function fg({card:e}){let t=e.input?.trim()??``,n=e.output?.trim()??``,r=e.statusTone===`running`,i=t.length>0,a=n.length>0,o=i||a,s=e.inputLabel?.trim()||`Input`,c=e.outputLabel?.trim()||`Output`,{expanded:l,onToggle:u}=sg({canExpand:o||r,isRunning:r,statusTone:e.statusTone});return(0,L.jsxs)(wh,{children:[(0,L.jsx)(Oh,{card:e,icon:Ae,expanded:l,canExpand:o||r,onToggle:u}),l&&o&&(0,L.jsxs)(Th,{className:`bg-transparent px-2.5 py-2.5`,children:[i&&(0,L.jsx)(cg,{label:s,tone:`input`,children:t}),i&&a&&(0,L.jsx)(`div`,{className:`h-2`}),a&&(0,L.jsx)(cg,{label:c,tone:e.statusTone===`error`?`error`:`output`,children:n})]})]})}function pg(e){let t=e.toLowerCase();return t===`exec`||t===`exec_command`||t===`execute_command`||t===`command_execution`||t===`bash`||t===`shell`||t.includes(`run_`)}function mg(e){let t=e.toLowerCase();return t===`read_file`||t===`write_file`||t===`edit_file`||t===`apply_patch`||t===`file_change`}function hg(e){let t=e.toLowerCase();return t===`grep_search`||t===`find_files`||t.includes(`search`)}function gg({card:e}){return pg(e.toolName)?(0,L.jsx)(lg,{card:e}):mg(e.toolName)?(0,L.jsx)(ug,{card:e}):hg(e.toolName)?(0,L.jsx)(dg,{card:e}):(0,L.jsx)(fg,{card:e})}function _g(e){return(0,L.jsxs)(`div`,{className:`rounded-lg border border-gray-200 bg-gray-50 px-2.5 py-2 text-xs text-gray-600`,children:[(0,L.jsxs)(`div`,{className:`font-semibold text-gray-700`,children:[e.label,`: `,e.rawType]}),e.text?(0,L.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap break-words text-[11px] text-gray-500`,children:e.text}):null]})}var vg=(0,F.memo)(function(e){let{message:t,texts:n}=e,{role:r}=t,i=r===`user`,a=t.status===`pending`||t.status===`streaming`;return(0,L.jsx)(`div`,{className:z(`inline-block w-fit max-w-full rounded-2xl border px-4 shadow-sm`,i?`border-primary bg-primary py-3 text-white`:r===`assistant`?`border-gray-200 bg-white pb-3 pt-4 text-gray-900`:`border-orange-200/80 bg-orange-50/70 py-3 text-gray-900`),children:(0,L.jsx)(`div`,{className:`space-y-2`,children:t.parts.map((e,o)=>{let{type:s}=e;return s===`markdown`?(0,L.jsx)(nh,{text:e.text,role:r,texts:n},`markdown-${o}`):s===`inline-content`?(0,L.jsx)(oh,{segments:e.segments,role:r,texts:n},`inline-content-${o}`):s===`reasoning`?(0,L.jsx)(Ch,{label:e.label,text:e.text,isUser:i,isInProgress:a&&o===t.parts.length-1},`reasoning-${o}`):s===`tool-card`?(0,L.jsx)(`div`,{className:`mt-0.5`,children:(0,L.jsx)(gg,{card:e.card})},`tool-${o}`):s===`file`?(0,L.jsx)(xh,{file:e.file,isUser:i},`file-${o}`):s===`unknown`?(0,L.jsx)(_g,{label:e.label,rawType:e.rawType,text:e.text},`unknown-${o}`):null})})})});function yg(e){return(0,L.jsxs)(`div`,{className:z(`px-1 text-[11px] leading-4 text-gray-400`,e.isUser?`text-right`:`text-left`),children:[e.roleLabel,` · `,e.timestampLabel]})}function bg({message:e,texts:t}){let n=(0,F.useMemo)(()=>e.parts.map(e=>e.type===`markdown`||e.type===`unknown`?e.text:``).filter(e=>!!e&&e.trim().length>0).join(`
|
|
36
|
+
|
|
37
|
+
`),[e.parts]),{copied:r,copy:i}=Gm({text:n});return n?(0,L.jsx)(`button`,{type:`button`,onClick:()=>void i(),className:`text-gray-400 hover:text-gray-600 transition-colors p-1 rounded-md hover:bg-gray-100 flex items-center justify-center`,"aria-label":r?t.copiedMessageLabel:t.copyMessageLabel,title:r?t.copiedMessageLabel:t.copyMessageLabel,children:r?(0,L.jsx)(M,{className:`h-3.5 w-3.5`}):(0,L.jsx)(Zt,{className:`h-3.5 w-3.5`})}):null}var xg=/\u200B|\u200C|\u200D|\u2060|\uFEFF/g;function Sg(e){let t=e.trim();return t?t.replace(xg,``).trim().length>0:!1}function Cg(e){return e.parts.some(e=>e.type===`markdown`||e.type===`reasoning`?Sg(e.text):!0)}function wg(){return(0,L.jsx)(`div`,{className:`flex items-center gap-2 px-1 py-0.5 text-[11px] text-gray-400`,children:(0,L.jsxs)(`div`,{className:`flex space-x-1 items-center h-full`,children:[(0,L.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full bg-gray-400 animate-pulse`}),(0,L.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full bg-gray-400 animate-pulse [animation-delay:200ms]`}),(0,L.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full bg-gray-400 animate-pulse [animation-delay:400ms]`})]})})}function Tg(e){let t=e.messages.filter(Cg),n=t.some(e=>e.role===`assistant`&&(e.status===`streaming`||e.status===`pending`));return(0,L.jsxs)(`div`,{className:z(`space-y-5`,e.className),children:[t.map(t=>{let n=t.role===`user`,r=!n&&(t.status===`streaming`||t.status===`pending`);return(0,L.jsxs)(`div`,{className:z(`flex gap-3`,n?`justify-end`:`justify-start`),children:[n?null:(0,L.jsx)(ca,{role:t.role}),(0,L.jsxs)(`div`,{className:z(`w-fit max-w-[92%] space-y-2`,n&&`flex flex-col items-end`),children:[(0,L.jsx)(vg,{message:t,texts:e.texts}),(0,L.jsx)(`div`,{className:z(`flex items-center gap-2`,n&&`justify-end`),children:r?(0,L.jsx)(wg,{}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(yg,{roleLabel:t.roleLabel,timestampLabel:t.timestampLabel,isUser:n}),n?null:(0,L.jsx)(bg,{message:t,texts:e.texts})]})})]}),n?(0,L.jsx)(ca,{role:t.role}):null]},t.id)}),e.isSending&&!n?(0,L.jsxs)(`div`,{className:`flex justify-start gap-3`,children:[(0,L.jsx)(ca,{role:`assistant`}),(0,L.jsx)(`div`,{className:`rounded-2xl border border-gray-200 bg-white px-4 py-3 text-sm text-gray-500 shadow-sm`,children:e.texts.typingLabel})]}):null]})}var Eg=`$`;function Dg(e){return`${Eg}${e}`}function Og(e,t){if(t.length===0)return;let n=e[e.length-1];if(n?.type===`text`){n.text+=t;return}e.push({type:`text`,text:t})}function kg(){return Ei()}function Ag(e){return Di(e)}function jg(e){return Ai(e)}function Mg(e){return ji(e,`skill`)}function Ng(e){return ji(e,`file`)}function Pg(e,t,n){let r=new Set(t),i=Ri(e,e=>e.tokenKind===`skill`&&!r.has(e.tokenKey)),a=ji(i,`skill`),o=new Map(n.map(e=>[e.ref,e])),s=t.filter(e=>!a.includes(e)).map(e=>wi({tokenKind:`skill`,tokenKey:e,label:o.get(e)?.name||e}));return s.length===0?i:Oi([...i,...s])}function Fg(e,t){let n=new Set(t.map(e=>e.id));return Ri(e,e=>e.tokenKind===`file`&&!n.has(e.tokenKey))}function Ig(e,t){let n=new Set(Ng(e));return t.filter(e=>n.has(e.id))}function Lg(e,t){let n=new Map(t.map(e=>[e.id,e])),r=[];for(let t of e){if(t.type===`text`){Og(r,t.text);continue}if(t.tokenKind===`skill`){Og(r,Dg(t.tokenKey));continue}if(t.tokenKind!==`file`)continue;let e=n.get(t.tokenKey);e&&r.push({type:`file`,name:e.name,mimeType:e.mimeType,...e.assetUri?{assetUri:e.assetUri}:{},...e.url?{url:e.url}:{},...e.contentBase64?{contentBase64:e.contentBase64}:{},sizeBytes:e.sizeBytes})}return r}var Rg={isProviderStateResolved:!1,composerNodes:kg(),attachments:[],draft:``,pendingSessionType:`native`,pendingProjectRoot:null,pendingProjectRootSessionKey:null,defaultSessionType:`native`,canStopGeneration:!1,stopDisabledReason:null,sendError:null,isSending:!1,modelOptions:[],selectedModel:``,selectedThinkingLevel:null,sessionTypeOptions:[],selectedSessionType:void 0,stopSupported:!1,stopReason:void 0,canEditSessionType:!1,sessionTypeUnavailable:!1,skillRecords:[],isSkillsLoading:!1,selectedSkills:[]},Q=C(e=>({snapshot:Rg,setSnapshot:t=>e(e=>({snapshot:{...e.snapshot,...t}}))}));function zg(e){let t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),r=n-864e5,i=n-7*864e5,a=[],s=[],c=[],l=[];for(let t of e){let{session:e}=t,o=new Date(e.updatedAt).getTime();o>=n?a.push(t):o>=r?s.push(t):o>=i?c.push(t):l.push(t)}let u=[];return a.length>0&&u.push({label:o(`chatSidebarToday`),items:a}),s.length>0&&u.push({label:o(`chatSidebarYesterday`),items:s}),c.length>0&&u.push({label:o(`chatSidebarPrevious7Days`),items:c}),l.length>0&&u.push({label:o(`chatSidebarOlder`),items:l}),u}function Bg(e){if(e.label&&e.label.trim())return e.label.trim();let t=e.key.split(`:`);return t[t.length-1]||e.key}function Vg(e){return e.ready===!1?e.reasonMessage?.trim()||o(`statusSetup`):o(`statusReady`)}var Hg=[{target:`/cron`,label:()=>o(`chatSidebarScheduledTasks`),icon:ht},{target:`/skills`,label:()=>o(`chatSidebarSkills`),icon:gt}];function Ug(){let e=Ir(),n=Ye(),[r,i]=(0,F.useState)(!1),[a,s]=(0,F.useState)(null),[c,l]=(0,F.useState)(``),[d,f]=(0,F.useState)(null),p=Q(e=>e.snapshot),m=R(e=>e.snapshot),g=At(e=>e.connectionStatus),{isLoading:_,items:v}=Nr(),{language:y,setLanguage:b}=Dt(),{theme:x,setTheme:S}=xt(),C=Ar(),w=o(rt.find(e=>e.value===x)?.labelKey??`themeWarm`),E=t.find(e=>e.value===y)?.label??y,D=(0,F.useMemo)(()=>zg(v),[v]),O=p.defaultSessionType||`native`,k=(0,F.useMemo)(()=>p.sessionTypeOptions.filter(e=>e.value!==O),[O,p.sessionTypeOptions]),ee=e=>{y!==e&&(b(e),window.location.reload())},te=e=>{s(e.key),l(e.label?.trim()??``)},A=()=>{s(null),l(``),f(null)},j=async e=>{let t=c.trim();if(t===(e.label?.trim()??``)){A();return}f(e.key);try{await C({sessionKey:e.key,label:t||null}),A()}catch{f(null)}};return(0,L.jsxs)(`aside`,{className:`w-[280px] shrink-0 flex flex-col h-full bg-secondary border-r border-gray-200/60`,children:[(0,L.jsx)(`div`,{className:`px-5 pt-5 pb-3`,children:(0,L.jsx)(kt,{className:`flex items-center gap-2.5 min-w-0`,suffix:(0,L.jsx)(_r,{status:g})})}),(0,L.jsx)(`div`,{className:`px-4 pb-3`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsxs)(h,{variant:`primary`,className:u(`min-w-0 rounded-xl`,k.length>0?`flex-1 rounded-r-md`:`w-full`),onClick:()=>{i(!1),e.chatSessionListManager.createSession(O)},children:[(0,L.jsx)(Ue,{className:`h-4 w-4 mr-2`}),o(`chatSidebarNewTask`)]}),k.length>0?(0,L.jsxs)(Vt,{open:r,onOpenChange:i,children:[(0,L.jsx)(zt,{asChild:!0,children:(0,L.jsx)(h,{variant:`primary`,size:`icon`,className:`h-9 w-10 shrink-0 rounded-xl rounded-l-md`,"aria-label":o(`chatSessionTypeLabel`),children:(0,L.jsx)(T,{className:`h-4 w-4`})})}),(0,L.jsxs)(Lt,{align:`end`,className:`w-64 p-2`,children:[(0,L.jsx)(`div`,{className:`px-2 py-1 text-[11px] font-medium uppercase tracking-wider text-gray-400`,children:o(`chatSessionTypeLabel`)}),(0,L.jsx)(`div`,{className:`mt-1 space-y-1`,children:k.map(t=>(0,L.jsxs)(`button`,{type:`button`,onClick:()=>{e.chatSessionListManager.createSession(t.value),i(!1)},className:`w-full rounded-xl px-3 py-2 text-left transition-colors hover:bg-gray-100`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,L.jsx)(`div`,{className:`text-[13px] font-medium text-gray-900`,children:t.label}),(0,L.jsx)(`span`,{className:u(`shrink-0 rounded-full px-2 py-0.5 text-[10px] font-semibold`,t.ready===!1?`bg-amber-100 text-amber-800`:`bg-emerald-100 text-emerald-700`),children:t.ready===!1?o(`statusSetup`):o(`statusReady`)})]}),(0,L.jsx)(`div`,{className:`mt-0.5 text-[11px] text-gray-500`,children:Vg(t)})]},t.value))})]})]}):null]})}),(0,L.jsx)(`div`,{className:`px-4 pb-3`,children:(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(Ge,{className:`h-3.5 w-3.5 absolute left-3 top-2.5 text-gray-400`}),(0,L.jsx)(ot,{value:m.query,onChange:t=>e.chatSessionListManager.setQuery(t.target.value),placeholder:o(`chatSidebarSearchPlaceholder`),className:`pl-8 h-9 rounded-lg text-xs`})]})}),(0,L.jsx)(`div`,{className:`px-3 pb-2`,children:(0,L.jsx)(`ul`,{className:`space-y-0.5`,children:Hg.map(e=>(0,L.jsx)(`li`,{children:(0,L.jsx)(st,{to:e.target,label:e.label(),icon:e.icon,density:`compact`})},e.target))})}),(0,L.jsx)(`div`,{className:`mx-4 border-t border-gray-200/60`}),(0,L.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar px-3 py-2`,children:_?(0,L.jsx)(`div`,{className:`text-xs text-gray-500 p-3`,children:o(`sessionsLoading`)}):D.length===0?(0,L.jsxs)(`div`,{className:`p-4 text-center`,children:[(0,L.jsx)(on,{className:`h-6 w-6 mx-auto mb-2 text-gray-300`}),(0,L.jsx)(`div`,{className:`text-xs text-gray-500`,children:o(`sessionsEmpty`)})]}):(0,L.jsx)(`div`,{className:`space-y-3`,children:D.map(t=>(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`px-2 py-1 text-[11px] font-medium text-gray-400 uppercase tracking-wider`,children:t.label}),(0,L.jsx)(`div`,{className:`space-y-0.5`,children:t.items.map(({session:t,runStatus:n})=>{let r=m.selectedSessionKey===t.key,i=Tr(t,p.sessionTypeOptions),o=a===t.key,s=d===t.key;return(0,L.jsx)(Or,{session:t,active:r,runStatus:n,context:i,title:Bg(t),isEditing:o,draftLabel:c,isSaving:s,onSelect:()=>e.chatSessionListManager.selectSession(t.key),onStartEditing:()=>te(t),onDraftLabelChange:l,onSave:()=>j(t),onCancel:A},t.key)})})]},t.label))})}),(0,L.jsxs)(`div`,{className:`px-3 py-3 border-t border-gray-200/60 space-y-0.5`,children:[(0,L.jsx)(st,{to:`/settings`,label:o(`settings`),icon:bt,density:`compact`}),(0,L.jsx)(_t,{onClick:()=>n.open(void 0,{kind:`docs`,newTab:!0,title:`Docs`}),icon:pe,label:o(`docBrowserHelp`),density:`compact`}),(0,L.jsx)(Ct,{value:x,onValueChange:e=>S(e),icon:Mt,label:o(`theme`),valueLabel:w,density:`compact`,children:rt.map(e=>(0,L.jsx)(N,{value:e.value,className:`text-xs`,children:o(e.labelKey)},e.value))}),(0,L.jsx)(Ct,{value:y,onValueChange:e=>ee(e),icon:Et,label:o(`language`),valueLabel:E,density:`compact`,children:t.map(e=>(0,L.jsx)(N,{value:e.value,className:`text-xs`,children:e.label},e.value))})]})]})}function Wg(e,t){if(!e||typeof e!=`object`||Array.isArray(e))return t;let n=e.error;if(!n||typeof n!=`object`||Array.isArray(n))return t;let r=n.message;return typeof r==`string`&&r.trim().length>0?r:t}async function Gg(e){let t=new FormData;for(let n of e)t.append(`files`,n);let n=await fetch(`${d}/api/ncp/assets`,{method:`POST`,body:t,credentials:`include`}),r=await n.json();if(!n.ok||!r.ok)throw Error(Wg(r,`Failed to put assets.`));return r.data.assets.map(e=>({id:e.id,name:e.name,mimeType:e.mimeType,sizeBytes:e.sizeBytes,assetUri:e.assetUri,url:e.url}))}var Kg={exactSpec:1200,exactLabel:1150,prefixSpec:1e3,prefixLabel:950,prefixToken:900,containsSpec:800,containsLabel:760,containsDescription:500,subsequence:300,fallback:1};function qg(e){let t=e.modelLabel.trim(),n=e.providerLabel.trim();return n?`${n}/${t}`:t}function Jg(e){return(e??``).trim().toLowerCase()}function Yg(e,t){if(!e||!t)return!1;let n=0;for(let r of t)if(r===e[n]&&(n+=1,n>=e.length))return!0;return!1}function Xg(e,t){let n=Jg(t);if(!n)return Kg.fallback;let r=Jg(e.key),i=Jg(e.label||e.key),a=Jg(`${e.descriptionZh??``} ${e.description??``}`),o=i.split(/[\s/_-]+/).filter(Boolean);return r===n?Kg.exactSpec:i===n?Kg.exactLabel:r.startsWith(n)?Kg.prefixSpec:i.startsWith(n)?Kg.prefixLabel:o.some(e=>e.startsWith(n))?Kg.prefixToken:r.includes(n)?Kg.containsSpec:i.includes(n)?Kg.containsLabel:a.includes(n)?Kg.containsDescription:Yg(n,i)||Yg(n,r)?Kg.subsequence:0}function Zg(e){return e>=Kg.exactLabel?4:e>=Kg.prefixToken?3:e>=Kg.containsLabel?2:e>0?1:0}function Qg(e){return new Map(e.map((e,t)=>[e,t]))}function $g(e,t){let n=Qg(t),r=[],i=[];for(let t of e){if(n.has(t.key)){r.push(t);continue}i.push(t)}return r.sort((e,t)=>(n.get(e.key)??1/0)-(n.get(t.key)??1/0)),[...r,...i]}function e_(e,t,n,r=[]){let i=new Intl.Collator(void 0,{sensitivity:`base`,numeric:!0}),a=Qg(r);return e.map((e,n)=>({record:e,order:n,score:Xg(e,t)})).filter(e=>e.score>0).sort((e,t)=>{let n=Zg(e.score),r=Zg(t.score);if(r!==n)return r-n;let o=a.get(e.record.key)??1/0,s=a.get(t.record.key)??1/0;if(o!==s)return o-s;if(t.score!==e.score)return t.score-e.score;let c=(e.record.label||e.record.key).trim(),l=(t.record.label||t.record.key).trim(),u=i.compare(c,l);return u===0?e.order-t.order:u}).map(({record:e})=>({key:`skill:${e.key}`,title:e.label||e.key,subtitle:n.slashSkillSubtitle,description:(e.descriptionZh??e.description??``).trim()||n.noSkillDescription,detailLines:[`${n.slashSkillSpecLabel}: ${e.key}`,...e.scopeLabel?[`${n.slashSkillScopeLabel}: ${e.scopeLabel}`]:[]],value:e.key}))}function t_(e){return e.map(e=>({key:e.key,label:e.label,description:e.descriptionZh||e.description||``,badgeLabel:e.badgeLabel}))}function n_(e){let t=$g(e.skillRecords,e.recentSkillValues??[]),n=new Set(e.groupedRecentSkillValues??[]),r=t_(t.filter(e=>n.has(e.key))),i=t_(t.filter(e=>!n.has(e.key)));return{title:e.texts.title,searchPlaceholder:e.texts.searchPlaceholder,emptyLabel:e.texts.emptyLabel,loadingLabel:e.texts.loadingLabel,isLoading:e.isLoading,manageLabel:e.texts.manageLabel,manageHref:`/marketplace/skills`,options:t_(t),groups:r.length>0?[{key:`recent-skills`,label:e.texts.recentSkillsLabel,options:r},{key:`all-skills`,label:e.texts.allSkillsLabel,options:i}].filter(e=>e.options.length>0):void 0,selectedKeys:e.selectedSkills,onSelectedKeysChange:e.onSelectedKeysChange}}function r_(e){return!e.isModelOptionsLoading&&!e.isModelOptionsEmpty?null:e.isModelOptionsLoading?{tone:`neutral`,loading:!0}:{tone:`warning`,text:e.texts.noModelOptionsLabel,actionLabel:e.texts.configureProviderLabel,onAction:e.onGoToProviders}}function i_(e){let t=e.modelOptions.find(t=>t.value===e.selectedModel),n=e.modelOptions[0],r=t??n,i=e.hasModelOptions?r?.value:void 0,a=new Set(e.recentModelValues??[]),o=new Map(e.modelOptions.map(e=>[e.value,e])),s=(e.recentModelValues??[]).map(e=>o.get(e)).filter(e=>!!e),c=e.modelOptions.filter(e=>!a.has(e.value)),l=s.length>0?[{key:`recent-models`,label:e.texts.recentModelsLabel,options:s.map(e=>({value:e.value,label:qg(e)}))},{key:`all-models`,label:e.texts.allModelsLabel,options:c.map(e=>({value:e.value,label:qg(e)}))}].filter(e=>e.options.length>0):void 0;return{key:`model`,value:i,placeholder:e.texts.modelSelectPlaceholder,selectedLabel:r?qg(r):void 0,icon:`sparkles`,options:e.modelOptions.map(e=>({value:e.value,label:qg(e)})),groups:l,disabled:!e.hasModelOptions,loading:e.isModelOptionsLoading,emptyLabel:e.texts.modelNoOptionsLabel,onValueChange:e.onValueChange}}function a_(e){let t=[];for(let n of[`off`,...e])t.includes(n)||t.push(n);return t}function o_(e){if(e.supportedLevels.length===0)return null;let t=a_(e.supportedLevels),n=t.includes(`off`)?`off`:t[0],r=e.selectedThinkingLevel&&t.includes(e.selectedThinkingLevel)&&e.selectedThinkingLevel||e.defaultThinkingLevel&&t.includes(e.defaultThinkingLevel)&&e.defaultThinkingLevel||n;return{key:`thinking`,value:r,placeholder:e.texts.thinkingLabels[r],selectedLabel:e.texts.thinkingLabels[r],icon:`brain`,options:t.map(t=>({value:t,label:e.texts.thinkingLabels[t]})),onValueChange:t=>e.onValueChange(t)}}var s_=class{constructor(e){this.options=e}read(){let e=this.getStorage();if(!e)return[];try{return this.normalizeList(JSON.parse(e.getItem(this.options.storageKey)??`[]`))}catch{return[]}}remember(e){let t=this.normalizeValue(e);if(!t)return this.read();let n=[t,...this.read().filter(e=>e!==t)].slice(0,this.options.limit);return this.write(n),n}resolveVisible(e){let t=this.normalizeList(e.availableValues,1/0);if(t.length<=e.minAvailableCount)return[];let n=new Set(t),r=[],i=Math.max(1,e.limit??this.options.limit);for(let e of this.read())if(!(!n.has(e)||r.includes(e))&&(r.push(e),r.length>=i))break;return r}write(e){let t=this.getStorage();if(t)try{t.setItem(this.options.storageKey,JSON.stringify(this.normalizeList(e)))}catch{}}getStorage(){return Object.prototype.hasOwnProperty.call(this.options,`storage`)?this.options.storage??null:typeof window>`u`?null:window.localStorage}normalizeList(e,t=this.options.limit){if(!Array.isArray(e))return[];let n=[];for(let r of e){let e=this.normalizeValue(r);if(!(!e||n.includes(e))&&(n.push(e),n.length>=t))break}return n}normalizeValue(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}},c_=new s_({storageKey:`nextclaw.chat.recent-models`,limit:3}),l_=new s_({storageKey:`nextclaw.chat.recent-skills`,limit:5});function u_(){return{off:o(`chatThinkingLevelOff`),minimal:o(`chatThinkingLevelMinimal`),low:o(`chatThinkingLevelLow`),medium:o(`chatThinkingLevelMedium`),high:o(`chatThinkingLevelHigh`),adaptive:o(`chatThinkingLevelAdaptive`),xhigh:o(`chatThinkingLevelXhigh`)}}function d_(e,t){return e.map(e=>({key:e.ref,label:e.name,scopeLabel:t[e.scope],description:e.description,descriptionZh:e.descriptionZh,badgeLabel:t[e.scope]}))}function f_(e){return e.map(e=>({value:e.value,modelLabel:e.modelLabel,providerLabel:e.providerLabel,thinkingCapability:e.thinkingCapability?{supported:e.thinkingCapability.supported,default:e.thinkingCapability.default??null}:null}))}function p_(){let e=Ir(),{language:t}=Dt(),n=Q(e=>e.snapshot),[r,i]=(0,F.useState)(null),a=(0,F.useRef)(null),s=(0,F.useRef)(null),c=(0,F.useMemo)(()=>({project:o(`chatSkillScopeProject`),workspace:o(`chatSkillScopeWorkspace`)}),[t]),l=(0,F.useMemo)(()=>({slashSkillSubtitle:o(`chatSlashTypeSkill`),slashSkillSpecLabel:o(`chatSlashSkillSpec`),slashSkillScopeLabel:o(`chatSlashSkillScope`),noSkillDescription:o(`chatSkillsPickerNoDescription`)}),[t]),u=(0,F.useMemo)(()=>d_(n.skillRecords,c),[n.skillRecords,c]),d=(0,F.useMemo)(()=>f_(n.modelOptions),[n.modelOptions]),f=c_.resolveVisible({availableValues:d.map(e=>e.value),minAvailableCount:5}),p=l_.resolveVisible({availableValues:u.map(e=>e.key),minAvailableCount:0}),h=l_.resolveVisible({availableValues:u.map(e=>e.key),minAvailableCount:4}),g=d.length>0,_=!n.isProviderStateResolved&&!g,v=n.isProviderStateResolved&&!g,y=(_||v)&&!n.isSending||n.sessionTypeUnavailable,b=typeof e.chatInputManager.addAttachments==`function`,x=_?``:o(g?`chatInputPlaceholder`:`chatModelNoOptions`),S=o(`chatPickerRecentModels`),C=o(`chatPickerAllModels`),w=o(`chatPickerRecent`),T=o(`chatPickerAllSkills`),E=(0,F.useMemo)(()=>e_(u,r??``,l,p),[r,u,l,p]),D=d.find(e=>e.value===n.selectedModel)?.thinkingCapability,O=D?.supported??[],k=n.stopDisabledReason===`__preparing__`?o(`chatStopPreparing`):n.stopDisabledReason?.trim()||o(`chatStopUnavailable`),ee=(0,F.useCallback)(e=>{if(e===`unsupported-type`){m.error(o(`chatInputAttachmentUnsupported`));return}if(e===`too-large`){m.error(o(`chatInputAttachmentTooLarge`).replace(`{maxMb}`,String(ur/(1024*1024))));return}m.error(o(`chatInputAttachmentReadFailed`))},[]),te=(0,F.useCallback)(async t=>{if(!b||t.length===0)return;let n=await hr(t,{uploadBatch:Gg});if(n.attachments.length>0){let t=e.chatInputManager.addAttachments?.(n.attachments)??[];t.length>0&&a.current?.insertFileTokens(t.map(e=>({tokenKey:e.id,label:e.name})))}n.rejected.length>0&&ee(n.rejected[0].reason)},[b,e.chatInputManager,ee]),A=[i_({modelOptions:d,recentModelValues:f,selectedModel:n.selectedModel,isModelOptionsLoading:_,hasModelOptions:g,onValueChange:e.chatInputManager.selectModel,texts:{modelSelectPlaceholder:o(`chatSelectModel`),modelNoOptionsLabel:o(`chatModelNoOptions`),recentModelsLabel:S,allModelsLabel:C}}),o_({supportedLevels:O,selectedThinkingLevel:n.selectedThinkingLevel,defaultThinkingLevel:D?.default??null,onValueChange:t=>e.chatInputManager.selectThinkingLevel(t),texts:{thinkingLabels:u_()}})].filter(e=>e!==null),j=n_({skillRecords:u,recentSkillValues:p,groupedRecentSkillValues:h,selectedSkills:n.selectedSkills,isLoading:n.isSkillsLoading,onSelectedKeysChange:e.chatInputManager.selectSkills,texts:{title:o(`chatSkillsPickerTitle`),searchPlaceholder:o(`chatSkillsPickerSearchPlaceholder`),emptyLabel:o(`chatSkillsPickerEmpty`),loadingLabel:o(`sessionsLoading`),manageLabel:o(`chatSkillsPickerManage`),recentSkillsLabel:w,allSkillsLabel:T}}),ne=Mg(n.composerNodes).length,M=n.draft.trim().length>0||n.attachments.length>0||ne>0;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(sa,{ref:a,composer:{nodes:n.composerNodes,placeholder:x,disabled:y,onNodesChange:e.chatInputManager.setComposerNodes,...b?{onFilesAdd:te}:{},onSlashQueryChange:i},slashMenu:{isLoading:n.isSkillsLoading,items:E,onSelectItem:t=>{t.value&&e.chatInputManager.rememberSkillSelection(t.value)},texts:{slashLoadingLabel:o(`chatSlashLoading`),slashSectionLabel:o(`chatSlashSectionSkills`),slashEmptyLabel:o(`chatSlashNoResult`),slashHintLabel:o(`chatSlashHint`),slashSkillHintLabel:o(`chatSlashSkillHint`)}},hint:r_({isModelOptionsLoading:_,isModelOptionsEmpty:v,onGoToProviders:e.chatInputManager.goToProviders,texts:{noModelOptionsLabel:o(`chatModelNoOptions`),configureProviderLabel:o(`chatGoConfigureProvider`)}}),toolbar:{selects:A,accessories:[{key:`attach`,label:o(`chatInputAttach`),icon:`paperclip`,iconOnly:!0,disabled:!b||y||n.isSending,...b?{onClick:()=>s.current?.click()}:{tooltip:o(`chatInputAttachComingSoon`)}}],skillPicker:j,actions:{sendError:n.sendError,isSending:n.isSending,canStopGeneration:n.canStopGeneration,sendDisabled:!M||!g||n.sessionTypeUnavailable,stopDisabled:!n.canStopGeneration,stopHint:k,sendButtonLabel:o(`chatSend`),stopButtonLabel:o(`chatStop`),onSend:e.chatInputManager.send,onStop:e.chatInputManager.stop}}}),b?(0,L.jsx)(`input`,{ref:s,type:`file`,multiple:!0,className:`hidden`,onChange:async e=>{let t=Array.from(e.target.files??[]);e.currentTarget.value=``,await te(t)}}):null]})}var m_=[`cmd`,`command`,`query`,`q`,`path`,`url`,`to`,`channel`,`agentId`,`sessionKey`];function h_(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function g_(e,t=2400){return e.length<=t?e:`${e.slice(0,t)}\n…`}function __(e){if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return String(e);if(e==null)return``;try{return g_(JSON.stringify(e,null,2))}catch{return String(e)}}function v_(e){if(h_(e))return e;if(typeof e!=`string`)return null;let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`))return null;try{let e=JSON.parse(t);return h_(e)?e:null}catch{return null}}function y_(e){let t=v_(e);if(!t){let t=__(e).trim();return t?g_(t,120):void 0}let n=[];for(let e of m_){let r=t[e];if(typeof r==`string`&&r.trim()?n.push(`${e}: ${r.trim()}`):(typeof r==`number`||typeof r==`boolean`)&&n.push(`${e}: ${String(r)}`),n.length>=2)break}return n.length>0?n.join(` · `):g_(__(t),140)}var b_=`ui_inline_tokens`,x_=`$`;function S_(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function C_(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function w_(e){let t=new Set,n=[];for(let r of e){let e=`${r.kind}:${r.key}:${r.rawText}`;t.has(e)||(t.add(e),n.push(r))}return n}function T_(e){let t=[];for(let n of e)n.type!==`token`||n.tokenKind!==`skill`||t.push({kind:`skill`,key:n.tokenKey,label:n.label,rawText:`${x_}${n.tokenKey}`});return w_(t)}function E_(e){let t=e?.[b_];if(!Array.isArray(t))return[];let n=[];for(let e of t){if(!S_(e))continue;let t=C_(e.kind),r=C_(e.key),i=C_(e.rawText);!t||!r||!i||n.push({kind:t,key:r,rawText:i,label:C_(e.label)??r})}return w_(n)}function D_(e,t){if(e.length===0||t.length===0)return e.length===0?[]:[{type:`text`,text:e}];let n=[...t].sort((e,t)=>t.rawText.length-e.rawText.length),r=[],i=0;for(;i<e.length;){let t=null;for(let r of n)if(e.startsWith(r.rawText,i)){t=r;break}if(!t){let t=i+1;for(;t<e.length&&!n.some(n=>e.startsWith(n.rawText,t));)t+=1;r.push({type:`text`,text:e.slice(i,t)}),i=t;continue}r.push({type:`token`,token:t}),i+=t.rawText.length}return r}var O_=/\u200B|\u200C|\u200D|\u2060|\uFEFF/g;function k_(e){let t=e.trim();return t&&t.replace(O_,``).trim()?t:null}function A_(e){return e.replace(O_,``).trim().length>0}function j_(e,t){let n=D_(e,t);if(n.length===0)return null;let r=[],i=!1;for(let e of n){if(e.type===`token`){i=!0,r.push({type:`token`,token:{kind:e.token.kind,key:e.token.key,label:e.token.label,rawText:e.token.rawText}});continue}e.text.length!==0&&(A_(e.text)&&(i=!0),r.push({type:`markdown`,text:e.text}))}return i?r:null}function M_(e,t){let n=j_(e.text,t);if(n&&n.some(e=>e.type===`token`))return{type:`inline-content`,segments:n};let r=k_(e.text);return r?{type:`markdown`,text:r}:null}function N_(e){return k_(e)}var P_=12e3,F_=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/;function I_(e){let t=e.replace(/\r\n/g,`
|
|
38
|
+
`).replace(/\r/g,`
|
|
39
|
+
`);return t===``?[]:t.split(`
|
|
40
|
+
`)}function L_(e){return typeof e==`number`?e+1:void 0}function R_(e){return{kind:e.kind,text:e.text,...typeof e.oldLineNumber==`number`?{oldLineNumber:e.oldLineNumber}:{},...typeof e.newLineNumber==`number`?{newLineNumber:e.newLineNumber}:{}}}function z_(e){let t=F_.exec(e);return t?{oldLineNumber:Number(t[1]),newLineNumber:Number(t[2])}:null}function B_(e){return I_(e.text).map((t,n)=>e.kind===`add`?R_({kind:`add`,text:t,newLineNumber:e.newStartLine+n}):R_({kind:`context`,text:t,oldLineNumber:e.oldStartLine+n,newLineNumber:e.newStartLine+n}))}function V_(e){let t=e.oldStartLine,n=e.newStartLine;return[...e.beforeLines.map(e=>{let n=R_({kind:`remove`,text:e,oldLineNumber:t});return t=L_(t),n}),...e.afterLines.map(e=>{let t=R_({kind:`add`,text:e,newLineNumber:n});return n=L_(n),t})]}function H_(e){let t=Array.from({length:e.beforeLines.length+1},()=>Array.from({length:e.afterLines.length+1},()=>0));for(let n=e.beforeLines.length-1;n>=0;--n)for(let r=e.afterLines.length-1;r>=0;--r)t[n][r]=e.beforeLines[n]===e.afterLines[r]?(t[n+1][r+1]??0)+1:Math.max(t[n+1][r]??0,t[n][r+1]??0);return t}function U_(e){for(let t=e.beforeIndex;t<e.beforeLines.length;t+=1)e.lines.push(R_({kind:`remove`,text:e.beforeLines[t]??``,oldLineNumber:e.oldLineNumber})),e.oldLineNumber=L_(e.oldLineNumber);for(let t=e.afterIndex;t<e.afterLines.length;t+=1)e.lines.push(R_({kind:`add`,text:e.afterLines[t]??``,newLineNumber:e.newLineNumber})),e.newLineNumber=L_(e.newLineNumber)}function W_(e){let t=I_(e.beforeText),n=I_(e.afterText);if(t.length*n.length>P_)return V_({beforeLines:t,afterLines:n,oldStartLine:e.oldStartLine,newStartLine:e.newStartLine});let r=H_({beforeLines:t,afterLines:n}),i=[],a=0,o=0,s=e.oldStartLine,c=e.newStartLine;for(;a<t.length&&o<n.length;){if(t[a]===n[o]){i.push(R_({kind:`context`,text:t[a]??``,oldLineNumber:s,newLineNumber:c})),a+=1,o+=1,s=L_(s),c=L_(c);continue}if((r[a+1][o]??0)>=(r[a][o+1]??0)){i.push(R_({kind:`remove`,text:t[a]??``,oldLineNumber:s})),a+=1,s=L_(s);continue}i.push(R_({kind:`add`,text:n[o]??``,newLineNumber:c})),o+=1,c=L_(c)}return U_({lines:i,beforeLines:t,afterLines:n,beforeIndex:a,afterIndex:o,oldLineNumber:s,newLineNumber:c}),i}var G_=120;function K_(e){let t=e.lines.filter(e=>e.kind===`add`).length,n=e.lines.filter(e=>e.kind===`remove`).length,r=[],i=e.operation?.trim().toLowerCase()??``;return i&&i!==`update`&&r.push(i),t>0&&r.push(`+${t}`),n>0&&r.push(`-${n}`),r.length>0?r.join(` · `):void 0}function q_(e){let t=e.operation?.trim().toLowerCase()??``;return{oldStartLine:typeof e.oldStartLine==`number`?e.oldStartLine:(t===`delete`||t===`remove`)&&e.beforeText!=null?1:void 0,newStartLine:typeof e.newStartLine==`number`?e.newStartLine:(t===`write`||t===`add`)&&e.afterText!=null?1:void 0}}function J_(e){return e.length<=G_?{lines:e,truncated:!1}:{lines:e.slice(0,G_),truncated:!0}}function Y_(e){let t=e.text.trim();if(!t)return null;let n=B_({text:t,kind:e.operation?.trim().toLowerCase()===`write`?`add`:`context`,oldStartLine:typeof e.oldStartLine==`number`?e.oldStartLine:1,newStartLine:typeof e.newStartLine==`number`?e.newStartLine:1});return{path:e.path,display:`preview`,caption:K_({operation:e.operation,lines:n}),lines:n}}function X_(e){let{oldStartLine:t,newStartLine:n}=q_(e),r=W_({beforeText:e.beforeText??``,afterText:e.afterText??``,oldStartLine:t,newStartLine:n}),i=J_(r);return i.lines.length===0?null:{path:e.path,display:`diff`,caption:K_({operation:e.operation,lines:r}),lines:i.lines,truncated:i.truncated}}function Z_(e){let t=J_(e.lines);return{path:e.path,display:`diff`,caption:K_({operation:e.operation,lines:e.lines}),lines:t.lines,truncated:t.truncated}}function Q_(e){return e.line.startsWith(`*** Update File: `)?(e.flushCurrent(),e.setCurrent(e.line.slice(17).trim(),`update`),!0):e.line.startsWith(`*** Add File: `)?(e.flushCurrent(),e.setCurrent(e.line.slice(14).trim(),`add`),!0):e.line.startsWith(`*** Delete File: `)?(e.flushCurrent(),e.setCurrent(e.line.slice(17).trim(),`delete`),!0):!1}function $_(e){let{currentLines:t,line:n}=e;return n.startsWith(`+`)?(t.push(R_({kind:`add`,text:n.slice(1),newLineNumber:e.newLineNumber})),{oldLineNumber:e.oldLineNumber,newLineNumber:L_(e.newLineNumber)}):n.startsWith(`-`)?(t.push(R_({kind:`remove`,text:n.slice(1),oldLineNumber:e.oldLineNumber})),{oldLineNumber:L_(e.oldLineNumber),newLineNumber:e.newLineNumber}):n.startsWith(` `)?(t.push(R_({kind:`context`,text:n.slice(1),oldLineNumber:e.oldLineNumber,newLineNumber:e.newLineNumber})),{oldLineNumber:L_(e.oldLineNumber),newLineNumber:L_(e.newLineNumber)}):{oldLineNumber:e.oldLineNumber,newLineNumber:e.newLineNumber}}function ev(e){let t=[],n=null,r=null,i=[],a,o,s=()=>{if(!n){i=[],r=null,a=void 0,o=void 0;return}t.push(Z_({path:n,operation:r,lines:i})),n=null,r=null,i=[],a=void 0,o=void 0};for(let t of I_(e)){if(Q_({line:t,flushCurrent:s,setCurrent:(e,t)=>{n=e,r=t}})||t.startsWith(`*** Move to: `)||t.startsWith(`*** Begin Patch`)||t.startsWith(`*** End Patch`))continue;if(t.startsWith(`@@`)){let e=z_(t);a=e?.oldLineNumber,o=e?.newLineNumber;continue}if(!n)continue;let e=$_({currentLines:i,line:t,oldLineNumber:a,newLineNumber:o});a=e.oldLineNumber,o=e.newLineNumber}return s(),t}function tv(e){let t=[],n=null,r=[],i,a,o=()=>{if(!n){r=[],i=void 0,a=void 0;return}t.push(Z_({path:n,operation:`update`,lines:r})),n=null,r=[],i=void 0,a=void 0};for(let t of I_(e)){if(t.startsWith(`+++ `)){o(),n=t.slice(4).trim().replace(/^b\//,``).replace(/^a\//,``);continue}if(t.startsWith(`--- `))continue;if(t.startsWith(`@@`)){let e=z_(t);i=e?.oldLineNumber,a=e?.newLineNumber;continue}if(!n)continue;let e=$_({currentLines:r,line:t,oldLineNumber:i,newLineNumber:a});i=e.oldLineNumber,a=e.newLineNumber}return o(),t}function nv(e){return e.includes(`*** Begin Patch`)?ev(e):e.includes(`--- `)&&e.includes(`+++ `)?tv(e):[]}function rv(e){switch(e){case`"`:case`\\`:case`/`:return e;case`b`:return`\b`;case`f`:return`\f`;case`n`:return`
|
|
41
|
+
`;case`r`:return`\r`;case`t`:return` `;default:return e}}function iv(e,t){let n=`"${t}"`,r=e.indexOf(n);if(r<0)return null;let i=e.indexOf(`:`,r+n.length);if(i<0)return null;let a=i+1;for(;a<e.length&&/\s/.test(e[a]??``);)a+=1;return e[a]===`"`?a+1:null}function av(e,t,n=1/0){let r=``,i=!1;for(let a=t;a<e.length;a+=1){let t=e[a];if(t==null)break;if(i){r+=rv(t),i=!1;continue}if(t===`\\`){i=!0;continue}if(t===`"`)return{value:r,truncated:!1};if(r+=t,r.length>=n)return{value:r,truncated:!0}}return r.length>0?{value:r,truncated:!1}:null}function ov(e,t,n=1/0){for(let r of t){let t=iv(e,r);if(t!=null)return av(e,t,n)}return null}function sv(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function cv(e){return typeof e==`string`&&e.trim()?e.trim():null}function lv(e){return typeof e==`number`&&Number.isInteger(e)&&e>0?e:typeof e==`string`&&/^\d+$/.test(e.trim())?Number(e.trim()):null}function uv(e){if(sv(e))return e;if(typeof e!=`string`)return null;let t=e.trim();if(!t.startsWith(`{`))return null;try{let e=JSON.parse(t);return sv(e)?e:null}catch{return null}}function dv(e){if(sv(e))return e;if(typeof e!=`string`)return null;let t=e.trim();if(!t.startsWith(`{`))return null;let n=ov(t,[`path`,`filePath`,`file_path`,`targetPath`,`target_path`,`filename`,`name`])?.value??null,r=ov(t,[`content`,`text`,`afterText`,`after_text`])?.value??null,i=ov(t,[`oldText`,`beforeText`,`before_text`])?.value??null,a=ov(t,[`newText`,`afterText`,`after_text`])?.value??null,o=ov(t,[`patch`,`diff`,`unifiedDiff`,`unified_diff`])?.value??null,s={};return n&&(s.path=n),r&&(s.content=r),i&&(s.oldText=i),a&&(s.newText=a),o&&(s.patch=o),Object.keys(s).length>0?s:null}function fv(e){return cv(e.path)??cv(e.filePath)??cv(e.file_path)??cv(e.targetPath)??cv(e.target_path)??cv(e.filename)??cv(e.name)}function pv(e){return $(e.operation)??$(e.op)??$(e.action)??$(e.kind)??$(e.type)??$(e.status)}function mv(e,t){for(let n of t){let t=lv(e[n]);if(t!==null)return t}return null}function hv(e){return mv(e,[`oldStartLine`,`old_start_line`,`startOldLine`,`start_old_line`,`oldLineStart`,`old_line_start`,`oldLineNumber`,`old_line_number`,`lineStart`,`line_start`,`startLine`,`start_line`,`lineNumber`,`line_number`])}function gv(e){return mv(e,[`newStartLine`,`new_start_line`,`startNewLine`,`start_new_line`,`newLineStart`,`new_line_start`,`newLineNumber`,`new_line_number`,`lineStart`,`line_start`,`startLine`,`start_line`,`lineNumber`,`line_number`])}function _v(e){return $(e.patch)??$(e.diff)??$(e.unifiedDiff)??$(e.unified_diff)}function vv(e){return $(e.beforeText)??$(e.before_text)??$(e.oldText)??$(e.old_text)??$(e.oldContent)??$(e.old_content)??$(e.before)??$(e.previous)}function yv(e){return $(e.afterText)??$(e.after_text)??$(e.newText)??$(e.new_text)??$(e.newContent)??$(e.new_content)??$(e.content)??$(e.text)??$(e.after)??$(e.updated)}var bv=new Set([`file_change`,`read_file`,`write_file`,`edit_file`,`apply_patch`]);function xv(e){let t=e.map((e,t)=>({key:`${e.path}-${t+1}`,path:e.path,display:e.display,...e.caption?{caption:e.caption}:{},lines:e.lines,...e.rawText?{rawText:e.rawText}:{},...e.truncated?{truncated:!0}:{}})).filter(e=>e.lines.length>0||!!e.rawText);if(t.length===0)return null;let n=t.map(e=>e.path);return{summary:n.length===1?n[0]:`${n.length} files · ${n.slice(0,2).join(` · `)}${n.length>2?` …`:``}`,fileOperation:{blocks:t}}}function Sv(e,t){let n=fv(e)??t,r=pv(e),i=hv(e),a=gv(e),o=_v(e);if(o){let e=nv(o);if(e.length>0)return e[0]??null}let s=vv(e),c=yv(e);if(s!=null||c!=null)return X_({path:n,beforeText:s,afterText:c,operation:r,oldStartLine:i,newStartLine:a});let l=$(e.preview);return l?Y_({path:n,text:l,operation:r,oldStartLine:i,newStartLine:a}):null}function Cv(e){if(!Array.isArray(e))return[];let t=[];return e.forEach((e,n)=>{if(typeof e==`string`){let n=nv(e);n.length>0&&t.push(...n);return}if(!sv(e))return;let r=Sv(e,fv(e)??`file-${n+1}`);if(r){t.push(r);return}let i=Array.isArray(e.changes)?Cv(e.changes):[];i.length>0&&t.push(...i)}),t}function wv(e){let t=uv(e.result)??uv(e.parsedArgs)??uv(e.args);return t?xv(Cv(t.changes)):null}function Tv(e){let t=uv(e.parsedArgs)??uv(e.args)??dv(e.args),n=t&&fv(t),r=$(e.result);return!n||!r?null:xv([Y_({path:n,text:r,operation:`read`})].filter(e=>!!e))}function Ev(e){if(e.status===`partial-call`&&typeof e.args==`string`){let t=ov(e.args,[`path`,`filePath`,`file_path`,`targetPath`,`target_path`,`filename`,`name`]),n=ov(e.args,[`content`,`text`,`afterText`,`after_text`]);if(t?.value&&n?.value){let e=Y_({path:t.value,text:n.value,operation:`write`});if(e)return xv([e])}}let t=uv(e.parsedArgs)??uv(e.args)??dv(e.args);if(!t)return null;let n=fv(t),r=$(t.content);return!n||!r?null:xv([Y_({path:n,text:r,operation:`write`})].filter(e=>!!e))}function Dv(e){let t=uv(e.result),n=uv(e.parsedArgs)??uv(e.args)??dv(e.args);if(!t&&!n)return null;let r=(t?fv(t):null)??(n?fv(n):null),i=(t?vv(t):null)??(n?vv(n):null),a=(t?yv(t):null)??(n?yv(n):null),o=(t?hv(t):null)??(n?hv(n):null),s=(t?gv(t):null)??(n?gv(n):null);return!r||i==null&&a==null?null:xv([X_({path:r,beforeText:i,afterText:a,operation:`edit`,oldStartLine:o,newStartLine:s})].filter(e=>!!e))}function Ov(e){let t=uv(e.parsedArgs),n=uv(e.args)??dv(e.args),r=$(e.args)??(t?$(t.patch):null)??(n?$(n.patch):null);return r?xv(nv(r)):null}function kv(e){return bv.has(e.toolName)?e.toolName===`file_change`?wv(e):e.toolName===`read_file`?Tv(e):e.toolName===`write_file`?Ev(e):e.toolName===`edit_file`?Dv(e):e.toolName===`apply_patch`?Ov(e):null:null}function Av(e){return typeof e==`object`&&!!e}function jv(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function Mv(e){return Av(e)&&(e.kind===`nextclaw.subagent_run`||typeof e.runId==`string`&&typeof e.status==`string`)?e:null}function Nv(e,t){return[jv(e.label)?`label: ${e.label?.trim()}`:null,jv(e.runId)?`run: ${e.runId?.trim()}`:null,jv(e.task)?`task: ${e.task?.trim()}`:null].filter(e=>!!e).join(` · `)||y_(t)}function Pv(e){let t=jv(e.runId),n=jv(e.label),r=jv(e.task),i=jv(e.status)?.toLowerCase(),a=e.result===void 0?``:__(e.result).trim(),o=jv(e.message),s=[t?`Run ID: ${t}`:null,n?`Label: ${n}`:null,r?`Task:\n${r}`:null,a?`${i===`failed`?`Error`:`Result`}:\n${a}`:o?`Status:\n${o}`:null].filter(e=>!!e);return s.length>0?s.join(`
|
|
42
|
+
|
|
43
|
+
`):void 0}function Fv(e){if(e.invocation.toolName!==`spawn`)return null;let t=Mv(e.invocation.result);if(!t)return null;let n=jv(t.status)?.toLowerCase(),r=Nv(t,e.invocation.args),i=Pv(t);return n===`failed`?{kind:`result`,name:e.invocation.toolName,detail:r,text:i,callId:e.invocation.toolCallId||void 0,hasResult:!!i,statusTone:`error`,statusLabel:e.texts.toolStatusFailedLabel}:n===`completed`?{kind:`result`,name:e.invocation.toolName,detail:r,text:i,callId:e.invocation.toolCallId||void 0,hasResult:!!i,statusTone:`success`,statusLabel:e.texts.toolStatusCompletedLabel}:{kind:`result`,name:e.invocation.toolName,detail:r,text:i,callId:e.invocation.toolCallId||void 0,hasResult:!!i,statusTone:`running`,statusLabel:e.texts.toolStatusRunningLabel}}function Iv(e){return typeof e==`object`&&!!e}function Lv(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function Rv(e){if(typeof e==`number`&&Number.isFinite(e)&&e>=0)return e;if(typeof e!=`string`)return null;let t=e.trim();if(!t)return null;let n=Number(t);return Number.isFinite(n)&&n>=0?n:null}function zv(e){return Iv(e)?`command`in e||`workingDir`in e||`exitCode`in e||`stdout`in e||`stderr`in e||`aggregated_output`in e||`combinedOutput`in e:!1}function Bv(e,t){if(!Iv(e))return null;let n=Iv(e.asset)?e.asset:Array.isArray(e.assets)&&e.assets.length>0&&Iv(e.assets[0])?e.assets[0]:null;if(!n)return null;let r=Lv(n.url),i=Lv(n.mimeType)??`application/octet-stream`,a=Rv(n.sizeBytes);return r?{type:`file`,file:{label:Lv(n.name)??(i.startsWith(`image/`)?t.imageAttachmentLabel:t.fileAttachmentLabel),mimeType:i,dataUrl:r,...a==null?{}:{sizeBytes:a},isImage:i.startsWith(`image/`)}}:null}function Vv(e,t){return{kind:e.kind,toolName:e.name,summary:e.detail,inputLabel:t.toolInputLabel,input:`input`in e&&typeof e.input==`string`?e.input:void 0,output:e.text,outputData:e.outputData,hasResult:!!e.hasResult,statusTone:e.statusTone,statusLabel:e.statusLabel,titleLabel:e.kind===`call`?t.toolCallLabel:t.toolResultLabel,outputLabel:t.toolOutputLabel,emptyLabel:t.toolNoOutputLabel,...`fileOperation`in e&&e.fileOperation?{fileOperation:e.fileOperation}:{}}}function Hv(e){let t=typeof e.status==`string`?e.status.trim().toLowerCase():``,n=typeof e.error==`string`&&e.error.trim().length>0;return e.cancelled===!0||t===`cancelled`?{kind:`result`,hasResult:!0,statusTone:`cancelled`,statusLabel:e.texts.toolStatusCancelledLabel}:n||t===`error`?{kind:`result`,hasResult:!0,statusTone:`error`,statusLabel:e.texts.toolStatusFailedLabel}:t===`result`||e.result!=null?{kind:`result`,hasResult:!0,statusTone:`success`,statusLabel:e.texts.toolStatusCompletedLabel}:{kind:`call`,hasResult:!1,statusTone:`running`,statusLabel:e.texts.toolStatusRunningLabel}}function Uv(e){if(typeof e!=`string`)return e;let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`))return e;try{return JSON.parse(t)}catch{return e}}function Wv(e,t){return __(t??Uv(e)).trim()||void 0}function Gv(e,t){let n=N_(e.reasoning);return n?{type:`reasoning`,text:n,label:t.reasoningLabel}:null}function Kv(e,t){let n=e.mimeType.startsWith(`image/`),r=Rv(e.sizeBytes);return{type:`file`,file:{label:typeof e.name==`string`&&e.name.trim()?e.name.trim():n?t.imageAttachmentLabel:t.fileAttachmentLabel,mimeType:e.mimeType,dataUrl:typeof e.url==`string`&&e.url.trim().length>0?e.url.trim():`data:${e.mimeType};base64,${e.data}`,...r==null?{}:{sizeBytes:r},isImage:n}}}function qv(e,t){let n=e.toolInvocation,r=Bv(n.result,t);if(r)return r;let i=Fv({invocation:n,texts:t});if(i)return{type:`tool-card`,card:Vv(i,t)};let a=Hv({status:n.status,error:n.error,cancelled:n.cancelled,result:n.result,texts:t}),o=kv({toolName:n.toolName,status:n.status,toolCallId:n.toolCallId,args:n.args,parsedArgs:n.parsedArgs,result:n.result}),s=o?.summary??y_(n.parsedArgs??n.args),c=o?void 0:Wv(n.args,n.parsedArgs),l=typeof n.error==`string`&&n.error.trim()?n.error.trim():n.result==null?``:__(n.result).trim(),u=!n.error&&zv(n.result),d=(!o?.fileOperation||!!n.error)&&!u;return{type:`tool-card`,card:Vv({kind:a.kind,name:n.toolName,detail:s,...c?{input:c}:{},text:d&&l?l:void 0,outputData:n.result,callId:n.toolCallId||void 0,hasResult:a.hasResult,statusTone:a.statusTone,statusLabel:a.statusLabel,...o?.fileOperation?{fileOperation:o.fileOperation}:{}},t)}}function Jv(e,t){return{type:`unknown`,label:t.unknownPartLabel,rawType:typeof e.type==`string`?e.type:`unknown`,text:__(e)}}function Yv(e){return e.type===`text`&&typeof e.text==`string`}function Xv(e){return e.type===`reasoning`&&typeof e.reasoning==`string`}function Zv(e){return e.type===`file`&&typeof e.mimeType==`string`&&typeof e.data==`string`}function Qv(e){return e.type!==`tool-invocation`||!Iv(e.toolInvocation)?!1:typeof e.toolInvocation.toolName==`string`}function $v(e){return Yv(e.part)?M_(e.part,e.inlineTokens):Xv(e.part)?Gv(e.part,e.texts):Zv(e.part)?Kv(e.part,e.texts):Qv(e.part)?qv(e.part,e.texts):Jv(e.part,e.texts)}function ey(e){let t=e.meta?.timestamp;return t&&Number.isFinite(Date.parse(t))?t:new Date().toISOString()}function ty(e,t){return e===`user`?t.user:e===`assistant`?t.assistant:e===`tool`?t.tool:e===`system`?t.system:t.fallback}function ny(e){return e===`user`||e===`assistant`||e===`tool`||e===`system`?e:`message`}function ry(e,t){return{id:e.id,role:ny(e.role),roleLabel:ty(e.role,t.texts.roleLabels),timestampLabel:t.formatTimestamp(ey(e)),status:e.meta?.status,parts:e.parts.map(n=>$v({part:n,inlineTokens:e.meta?.inlineTokens??[],texts:t.texts})).filter(e=>e!==null)}}var iy=new WeakMap;function ay(e){return{roleLabels:{user:o(`chatRoleUser`),assistant:o(`chatRoleAssistant`),tool:o(`chatRoleTool`),system:o(`chatRoleSystem`),fallback:o(`chatRoleMessage`)},reasoningLabel:o(`chatReasoning`),toolCallLabel:o(`chatToolCall`),toolResultLabel:o(`chatToolResult`),toolInputLabel:o(`chatToolInput`),toolNoOutputLabel:o(`chatToolNoOutput`),toolOutputLabel:o(`chatToolOutput`),toolStatusPreparingLabel:o(`chatToolStatusPreparing`),toolStatusRunningLabel:o(`chatToolStatusRunning`),toolStatusCompletedLabel:o(`chatToolStatusCompleted`),toolStatusFailedLabel:o(`chatToolStatusFailed`),toolStatusCancelledLabel:o(`chatToolStatusCancelled`),imageAttachmentLabel:o(`chatImageAttachment`),fileAttachmentLabel:o(`chatFileAttachment`),unknownPartLabel:o(`chatUnknownPart`)}}function oy(e){return{copyCodeLabel:o(`chatCodeCopy`),copiedCodeLabel:o(`chatCodeCopied`),copyMessageLabel:o(`chatMessageCopy`),copiedMessageLabel:o(`chatMessageCopied`),typingLabel:o(`chatTyping`)}}function sy({messages:e,isSending:t,className:n}){let{language:r}=Dt(),i=(0,F.useMemo)(()=>ay(r),[r]),a=(0,F.useMemo)(()=>e.map(e=>{let t=iy.get(e);if(t&&t.language===r)return t.viewModel;let n=xe(e),a=ry({id:n.id,role:n.role,meta:{timestamp:n.meta?.timestamp,status:n.meta?.status,inlineTokens:E_(e.metadata)},parts:n.parts},{formatTimestamp:e=>c(e,r),texts:i});return iy.set(e,{language:r,viewModel:a}),a}),[r,e,i]);return(0,L.jsx)(Tg,{messages:a,isSending:t,hasAssistantDraft:(0,F.useMemo)(()=>a.some(e=>e.role===`assistant`&&(e.status===`streaming`||e.status===`pending`)),[a]),className:n,texts:(0,F.useMemo)(()=>oy(r),[r])})}var cy=[{icon:mt,titleKey:`chatWelcomeCapability1Title`,descKey:`chatWelcomeCapability1Desc`},{icon:gt,titleKey:`chatWelcomeCapability2Title`,descKey:`chatWelcomeCapability2Desc`},{icon:ht,titleKey:`chatWelcomeCapability3Title`,descKey:`chatWelcomeCapability3Desc`}];function ly({onCreateSession:e}){return(0,L.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,L.jsxs)(`div`,{className:`max-w-lg w-full text-center`,children:[(0,L.jsx)(`div`,{className:`mx-auto mb-6 h-16 w-16 rounded-2xl bg-primary/10 flex items-center justify-center`,children:(0,L.jsx)(ge,{className:`h-8 w-8 text-primary`})}),(0,L.jsx)(`h2`,{className:`text-xl font-semibold text-gray-900 mb-2`,children:o(`chatWelcomeTitle`)}),(0,L.jsx)(`p`,{className:`text-sm text-gray-500 mb-8`,children:o(`chatWelcomeSubtitle`)}),(0,L.jsx)(`div`,{className:`grid grid-cols-3 gap-3`,children:cy.map(t=>{let n=t.icon;return(0,L.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:[(0,L.jsx)(`div`,{className:`h-9 w-9 rounded-xl bg-primary/8 flex items-center justify-center mb-3`,children:(0,L.jsx)(n,{className:`h-4.5 w-4.5 text-primary`})}),(0,L.jsx)(`div`,{className:`text-sm font-semibold text-gray-900 mb-1`,children:o(t.titleKey)}),(0,L.jsx)(`div`,{className:`text-[11px] text-gray-500 leading-relaxed`,children:o(t.descKey)})]},t.titleKey)})})]})})}function uy(){let e=kr();return async t=>{let n=t.projectRoot?o(`chatSessionProjectUpdated`):o(`chatSessionProjectCleared`);if(!t.persistToServer){Q.getState().setSnapshot({pendingProjectRoot:t.projectRoot,pendingProjectRootSessionKey:t.sessionKey}),m.success(n);return}await e({sessionKey:t.sessionKey,patch:{projectRoot:t.projectRoot},successMessage:n}),Q.getState().setSnapshot({pendingProjectRoot:t.projectRoot,pendingProjectRootSessionKey:t.sessionKey})}}function dy({icon:e,label:t,onClick:n,disabled:r=!1,destructive:i=!1}){return(0,L.jsxs)(`button`,{type:`button`,className:u(`flex w-full items-center gap-2 rounded-xl px-3 py-2 text-left text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50`,i?`text-destructive hover:bg-destructive/10`:`text-gray-700 hover:bg-gray-100`),onClick:n,disabled:r,children:[(0,L.jsx)(e,{className:`h-4 w-4 shrink-0`}),(0,L.jsx)(`span`,{children:t})]})}async function fy(e){let t=new URLSearchParams;typeof e?.path==`string`&&e.path.trim().length>0&&t.set(`path`,e.path.trim()),e?.includeFiles&&t.set(`includeFiles`,`1`);let n=t.toString(),r=await g.get(n?`/api/server-paths/browse?${n}`:`/api/server-paths/browse`);if(!r.ok)throw Error(r.error.message);return r.data}function py(e){return f({queryKey:[`server-path-browse`,e.path??null,e.includeFiles??!1],queryFn:()=>fy({path:e.path,includeFiles:e.includeFiles}),enabled:e.enabled??!0,staleTime:0})}var my=F.forwardRef(({className:e,children:t,...n},r)=>(0,L.jsx)(`div`,{ref:r,className:u(`overflow-auto`,e),...n,children:t}));my.displayName=`ScrollArea`;function hy({open:e,currentPath:t,isSaving:n,onOpenChange:r,onConfirm:i,title:a,description:s,pathLabel:c,pathPlaceholder:l,confirmLabel:u,hint:d}){let[f,p]=(0,F.useState)(``),[m,g]=(0,F.useState)(null),[_,v]=(0,F.useState)(``);(0,F.useEffect)(()=>{if(!e)return;let n=t?.trim()||null;p(n??``),g(n),v(``)},[t,e]);let y=py({path:m,enabled:e});(0,F.useEffect)(()=>{!e||!y.data||f.trim().length===0&&p(y.data.currentPath)},[y.data,f,e]);let b=f.trim(),x=b.length===0||n,S=(0,F.useMemo)(()=>y.error?y.error instanceof Error?y.error.message:String(y.error):null,[y.error]),C=_.trim().toLowerCase(),w=(0,F.useMemo)(()=>{let e=y.data?.entries??[];return C.length===0?e:e.filter(e=>{let t=e.name.toLowerCase(),n=e.path.toLowerCase();return t.includes(C)||n.includes(C)})},[y.data?.entries,C]),T=e=>{g(e),v(``),e&&p(e)};return(0,L.jsx)(ft,{open:e,onOpenChange:e=>{n||r(e)},children:(0,L.jsxs)(jt,{className:`max-h-[85vh] overflow-hidden sm:h-[42rem] sm:max-w-2xl sm:grid-rows-[auto_minmax(0,1fr)]`,children:[(0,L.jsxs)(vt,{children:[(0,L.jsx)(ct,{children:a}),s?(0,L.jsx)(St,{children:s}):null]}),(0,L.jsxs)(`form`,{className:`flex min-h-0 flex-col gap-4`,onSubmit:e=>{e.preventDefault(),!x&&i(b)},children:[(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(Ut,{htmlFor:`server-path-picker-input`,children:c}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(ot,{id:`server-path-picker-input`,value:f,onChange:e=>p(e.target.value),placeholder:l,autoFocus:!0,disabled:n}),(0,L.jsx)(h,{type:`button`,variant:`outline`,onClick:()=>T(b||null),disabled:n,children:o(`openPath`)})]})]}),(0,L.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-2xl border border-gray-200 bg-gray-50/70`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-gray-200 px-3 py-2`,children:[(0,L.jsxs)(h,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>T(y.data?.homePath??null),disabled:n||y.isLoading,children:[(0,L.jsx)(an,{className:`mr-1 h-4 w-4`}),o(`homeDirectory`)]}),(0,L.jsxs)(h,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>T(y.data?.parentPath??null),disabled:!y.data?.parentPath||n||y.isLoading,children:[(0,L.jsx)(tn,{className:`mr-1 h-4 w-4`}),o(`parentDirectory`)]}),(0,L.jsxs)(h,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>{y.refetch()},disabled:n||y.isLoading,children:[(0,L.jsx)(We,{className:`mr-1 h-4 w-4`}),o(`chatRefresh`)]})]}),(0,L.jsxs)(`div`,{className:`border-b border-gray-200 px-3 py-2`,children:[(0,L.jsx)(`div`,{className:`mb-2 text-xs font-medium text-gray-500`,children:o(`currentDirectory`)}),(0,L.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 text-xs text-gray-600`,children:y.data?.breadcrumbs.map((e,t)=>(0,L.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,L.jsx)(`button`,{type:`button`,className:`rounded px-1.5 py-0.5 hover:bg-gray-200`,onClick:()=>T(e.path),disabled:n,children:e.label}),t<y.data.breadcrumbs.length-1?(0,L.jsx)(Yt,{className:`h-3 w-3 text-gray-400`}):null]},e.path))})]}),(0,L.jsx)(`div`,{className:`border-b border-gray-200 px-3 py-2`,children:(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(Ge,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,L.jsx)(ot,{value:_,onChange:e=>v(e.target.value),placeholder:o(`pathPickerSearchPlaceholder`),disabled:n||y.isLoading,className:`pl-9`})]})}),(0,L.jsx)(my,{className:`min-h-0 flex-1 px-2 py-2`,children:y.isLoading?(0,L.jsx)(`div`,{className:`px-2 py-6 text-sm text-gray-500`,children:o(`loading`)}):S?(0,L.jsxs)(`div`,{className:`px-2 py-4 text-sm text-destructive`,children:[o(`pathBrowseFailed`),`: `,S]}):y.data&&w.length>0?(0,L.jsx)(`div`,{className:`space-y-1`,children:w.map(e=>(0,L.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-xl px-3 py-2 text-left text-sm text-gray-700 transition-colors hover:bg-white`,onClick:()=>T(e.path),disabled:n,children:[(0,L.jsx)(Oe,{className:`h-4 w-4 shrink-0 text-emerald-600`}),(0,L.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path))}):y.data&&y.data.entries.length>0?(0,L.jsx)(`div`,{className:`px-2 py-6 text-sm text-gray-500`,children:o(`pathPickerSearchEmpty`)}):(0,L.jsx)(`div`,{className:`px-2 py-6 text-sm text-gray-500`,children:o(`emptyDirectory`)})})]}),d?(0,L.jsx)(`p`,{className:`text-xs leading-relaxed text-gray-500`,children:d}):null,(0,L.jsxs)(Ot,{children:[(0,L.jsx)(h,{type:`button`,variant:`outline`,onClick:()=>r(!1),disabled:n,children:o(`cancel`)}),(0,L.jsx)(h,{type:`submit`,disabled:x,children:n?o(`saving`):u})]})]})]})})}function gy({open:e,currentProjectRoot:t,isSaving:n,onOpenChange:r,onSave:i}){return(0,L.jsx)(hy,{open:e,currentPath:t,isSaving:n,onOpenChange:r,onConfirm:i,title:o(`chatSessionProjectDialogTitle`),description:o(`chatSessionProjectDialogDescription`),pathLabel:o(`chatSessionProjectPathLabel`),pathPlaceholder:o(`chatSessionProjectPathPlaceholder`),confirmLabel:o(`chatSessionSetProject`),hint:o(`chatSessionProjectUpdateHint`)})}function _y({sessionKey:e,canDeleteSession:t,isDeletePending:n,projectRoot:r,onDeleteSession:i}){let a=uy(),[s,c]=(0,F.useState)(!1),[l,u]=(0,F.useState)(!1),[d,f]=(0,F.useState)(!1),p=n||d,m=async n=>{let r=t;f(!0);try{await a({sessionKey:e,projectRoot:n,persistToServer:r}),u(!1),c(!1)}finally{f(!1)}};return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(Vt,{open:s,onOpenChange:c,children:[(0,L.jsx)(zt,{asChild:!0,children:(0,L.jsx)(h,{variant:`ghost`,size:`icon`,className:`rounded-lg shrink-0 text-gray-400 hover:text-gray-700`,"aria-label":o(`chatSessionMoreActions`),disabled:p,children:(0,L.jsx)(Qt,{className:`h-4 w-4`})})}),(0,L.jsx)(Lt,{align:`end`,className:`w-56 p-2`,children:(0,L.jsxs)(`div`,{className:`space-y-1`,children:[(0,L.jsx)(dy,{icon:en,label:o(`chatSessionSetProject`),onClick:()=>{c(!1),u(!0)},disabled:p}),(0,L.jsx)(dy,{icon:Ke,label:o(`chatDeleteSession`),onClick:()=>{c(!1),i()},disabled:!t||p,destructive:!0})]})})]}),(0,L.jsx)(gy,{open:l,currentProjectRoot:r,isSaving:d,onOpenChange:u,onSave:m})]})}function vy({sessionKey:e,projectName:t,projectRoot:n,persistToServer:r}){let i=uy(),[a,s]=(0,F.useState)(!1),[c,l]=(0,F.useState)(!1),[u,d]=(0,F.useState)(!1),f=async t=>{d(!0);try{await i({sessionKey:e,projectRoot:t,persistToServer:r}),l(!1),s(!1)}finally{d(!1)}};return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(Vt,{open:a,onOpenChange:s,children:[(0,L.jsx)(zt,{asChild:!0,children:(0,L.jsx)(`button`,{type:`button`,title:n??void 0,className:`min-w-0 max-w-[320px] shrink rounded-full border border-emerald-200 bg-emerald-50 px-2 py-0.5 text-[11px] font-medium text-emerald-700 transition-colors hover:border-emerald-300 hover:bg-emerald-100 disabled:cursor-not-allowed disabled:opacity-60`,"aria-label":o(`chatSessionSetProject`),disabled:u,children:(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,L.jsx)(en,{className:`h-3.5 w-3.5 shrink-0`}),(0,L.jsx)(`span`,{className:`truncate`,children:t}),(0,L.jsx)(T,{className:`h-3 w-3 shrink-0 opacity-70`})]})})}),(0,L.jsxs)(Lt,{align:`start`,className:`w-72 p-2`,children:[(0,L.jsxs)(`div`,{className:`px-3 pb-2 pt-1`,children:[(0,L.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-emerald-700/80`,children:t}),n?(0,L.jsx)(`div`,{className:`mt-1 break-all text-xs text-gray-500`,children:n}):null]}),(0,L.jsxs)(`div`,{className:`space-y-1`,children:[(0,L.jsx)(dy,{icon:ln,label:o(`chatSessionSetProject`),onClick:()=>{s(!1),l(!0)},disabled:u}),(0,L.jsx)(dy,{icon:nn,label:o(`chatSessionClearProject`),onClick:()=>{f(null)},disabled:u})]})]})]}),(0,L.jsx)(gy,{open:c,currentProjectRoot:n,isSaving:u,onOpenChange:l,onSave:f})]})}var yy={isProviderStateResolved:!1,modelOptions:[],sessionTypeUnavailable:!1,sessionTypeUnavailableMessage:null,sessionTypeLabel:null,sessionKey:null,sessionDisplayName:void 0,sessionProjectRoot:null,sessionProjectName:null,canDeleteSession:!1,isDeletePending:!1,threadRef:null,isHistoryLoading:!1,messages:[],isSending:!1,isAwaitingAssistantOutput:!1},by=C(e=>({snapshot:yy,setSnapshot:t=>e(e=>({snapshot:{...e.snapshot,...t}}))}));function xy(){return(0,L.jsxs)(`section`,{className:`flex-1 min-h-0 flex flex-col overflow-hidden bg-gradient-to-b from-gray-50/60 to-white`,children:[(0,L.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar`,children:(0,L.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)] px-6 py-5`,children:(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsx)(`div`,{className:`h-6 w-48 animate-pulse rounded bg-gray-200`}),(0,L.jsx)(`div`,{className:`h-24 w-[78%] animate-pulse rounded-2xl bg-gray-200/80`}),(0,L.jsx)(`div`,{className:`h-20 w-[62%] animate-pulse rounded-2xl bg-gray-200/80`}),(0,L.jsx)(`div`,{className:`h-28 w-[84%] animate-pulse rounded-2xl bg-gray-200/80`})]})})}),(0,L.jsx)(`div`,{className:`border-t border-gray-200/80 bg-white p-4`,children:(0,L.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)]`,children:(0,L.jsxs)(`div`,{className:`rounded-2xl border border-gray-200 bg-white shadow-card p-4`,children:[(0,L.jsx)(`div`,{className:`h-16 w-full animate-pulse rounded-xl bg-gray-200/80`}),(0,L.jsxs)(`div`,{className:`mt-3 flex items-center justify-between`,children:[(0,L.jsx)(`div`,{className:`h-8 w-36 animate-pulse rounded-lg bg-gray-200/80`}),(0,L.jsx)(`div`,{className:`h-8 w-20 animate-pulse rounded-lg bg-gray-200/80`})]})]})})})]})}function Sy(){let e=Ir(),t=by(e=>e.snapshot),n=(0,F.useRef)(null),r=t.threadRef??n,i=!!(t.sessionKey||t.sessionTypeLabel),a=t.sessionDisplayName||(t.canDeleteSession&&t.sessionKey?t.sessionKey:null)||o(`chatSidebarNewTask`),s=!t.canDeleteSession&&t.messages.length===0&&!t.isSending,c=t.modelOptions.length>0,l=t.isProviderStateResolved&&!c,d=t.isHistoryLoading&&t.messages.length===0&&!t.isSending&&!t.isAwaitingAssistantOutput,{onScroll:f}=Mh({scrollRef:r,resetKey:t.sessionKey,isLoading:t.isHistoryLoading,hasContent:t.messages.length>0,contentVersion:t.messages[t.messages.length-1]??null});return t.isProviderStateResolved?(0,L.jsxs)(`section`,{className:`flex-1 min-h-0 flex flex-col overflow-hidden bg-gradient-to-b from-gray-50/60 to-white`,children:[(0,L.jsxs)(`div`,{className:u(`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`,i?`py-3 opacity-100`:`h-0 py-0 opacity-0 border-b-0`),children:[(0,L.jsxs)(`div`,{className:`min-w-0 flex-1 flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`text-sm font-medium text-gray-700 truncate`,children:a}),t.sessionTypeLabel?(0,L.jsx)(`span`,{className:`shrink-0 rounded-full border border-gray-200 bg-gray-100 px-2 py-0.5 text-[11px] font-medium text-gray-600`,children:t.sessionTypeLabel}):null,t.sessionProjectName?(0,L.jsx)(vy,{sessionKey:t.sessionKey??`draft`,projectName:t.sessionProjectName,projectRoot:t.sessionProjectRoot,persistToServer:t.canDeleteSession}):null]}),t.sessionKey?(0,L.jsx)(_y,{sessionKey:t.sessionKey,canDeleteSession:t.canDeleteSession,isDeletePending:t.isDeletePending,projectRoot:t.sessionProjectRoot,onDeleteSession:e.chatThreadManager.deleteSession}):null]}),l&&(0,L.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:[(0,L.jsx)(`span`,{className:`text-xs text-amber-800`,children:o(`chatModelNoOptions`)}),(0,L.jsx)(`button`,{type:`button`,onClick:e.chatThreadManager.goToProviders,className:`text-xs font-semibold text-amber-900 underline-offset-2 hover:underline`,children:o(`chatGoConfigureProvider`)})]}),t.sessionTypeUnavailable&&t.sessionTypeUnavailableMessage?.trim()&&(0,L.jsx)(`div`,{className:`px-5 py-2.5 border-b border-amber-200/70 bg-amber-50/70 shrink-0`,children:(0,L.jsx)(`span`,{className:`text-xs text-amber-800`,children:t.sessionTypeUnavailableMessage})}),(0,L.jsx)(`div`,{ref:r,onScroll:f,className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar`,children:s?(0,L.jsx)(ly,{onCreateSession:e.chatThreadManager.createSession}):d?(0,L.jsx)(`div`,{className:`h-full`}):t.messages.length===0?(0,L.jsx)(`div`,{className:`px-5 py-5 text-sm text-gray-500`,children:o(`chatNoMessages`)}):(0,L.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)] px-6 py-5`,children:(0,L.jsx)(sy,{messages:t.messages,isSending:t.isSending&&t.isAwaitingAssistantOutput},t.sessionKey??`draft`)})}),(0,L.jsx)(p_,{})]}):(0,L.jsx)(xy,{})}function Cy(e){return c(e??void 0)}function wy(e){return typeof e!=`number`||!Number.isFinite(e)?`-`:c(new Date(e))}function Ty(e){if(typeof e!=`number`||!Number.isFinite(e))return`-`;let t=Math.round(e/1e3);if(t<60)return`${t}s`;let n=Math.round(t/60);if(n<60)return`${n}m`;let r=Math.round(n/60);return r<24?`${r}h`:`${Math.round(r/24)}d`}function Ey(e){let t=e.schedule;return t.kind===`cron`?t.expr?`cron ${t.expr}`:`cron`:t.kind===`every`?`every ${Ty(t.everyMs)}`:t.kind===`at`?`at ${wy(t.atMs)}`:`-`}function Dy(e){return e.payload.deliver?`${e.payload.channel??`-`}:${e.payload.to??`-`}`:`-`}function Oy(e,t){let 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 ky(e,t){return t===`all`?!0:t===`enabled`?e.enabled:!e.enabled}function Ay(){let[e,t]=(0,F.useState)(``),[n,r]=(0,F.useState)(`all`),i=pt({all:!0}),a=Tt(),s=at(),c=it(),{confirm:l,ConfirmDialog:d}=Wt(),f=(0,F.useMemo)(()=>(i.data?.jobs??[]).filter(t=>Oy(t,e)).filter(e=>ky(e,n)),[i.data,e,n]),p=async e=>{await l({title:`${o(`cronDeleteConfirm`)}?`,description:e.name?`${e.name} (${e.id})`:e.id,variant:`destructive`,confirmLabel:o(`delete`)})&&a.mutate({id:e.id})},m=async e=>{let t=!e.enabled;await l({title:t?`${o(`cronEnableConfirm`)}?`:`${o(`cronDisableConfirm`)}?`,description:e.name?`${e.name} (${e.id})`:e.id,variant:t?`default`:`destructive`,confirmLabel:o(t?`cronEnable`:`cronDisable`)})&&s.mutate({id:e.id,enabled:t})},g=async e=>{let t=!e.enabled;await l({title:t?`${o(`cronRunForceConfirm`)}?`:`${o(`cronRunConfirm`)}?`,description:e.name?`${e.name} (${e.id})`:e.id,confirmLabel:o(`cronRunNow`)})&&c.mutate({id:e.id,force:t})};return(0,L.jsxs)(Gt,{fullHeight:!0,children:[(0,L.jsx)(Kt,{title:o(`cronPageTitle`),description:o(`cronPageDescription`),actions:(0,L.jsx)(h,{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:(0,L.jsx)(we,{className:u(`h-4 w-4`,i.isFetching&&`animate-spin`)})})}),(0,L.jsx)(`div`,{className:`mb-6`,children:(0,L.jsxs)(`div`,{className:`flex flex-wrap gap-3 items-center`,children:[(0,L.jsxs)(`div`,{className:`relative flex-1 min-w-[240px]`,children:[(0,L.jsx)(ot,{value:e,onChange:e=>t(e.target.value),placeholder:o(`cronSearchPlaceholder`),className:`pl-9`}),(0,L.jsx)(ht,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400`})]}),(0,L.jsx)(`div`,{className:`min-w-[180px]`,children:(0,L.jsxs)(le,{value:n,onValueChange:e=>r(e),children:[(0,L.jsx)(ne,{className:`w-full`,children:(0,L.jsx)(D,{placeholder:o(`cronStatusLabel`)})}),(0,L.jsxs)(ae,{children:[(0,L.jsx)(N,{value:`all`,children:o(`cronStatusAll`)}),(0,L.jsx)(N,{value:`enabled`,children:o(`cronStatusEnabled`)}),(0,L.jsx)(N,{value:`disabled`,children:o(`cronStatusDisabled`)})]})]})}),(0,L.jsxs)(`div`,{className:`text-xs text-gray-500 ml-auto`,children:[o(`cronTotalLabel`),`: `,i.data?.total??0,` / `,f.length]})]})}),(0,L.jsx)(`div`,{className:`flex-1 overflow-auto custom-scrollbar`,children:i.isLoading?(0,L.jsx)(`div`,{className:`text-sm text-gray-400 p-4 text-center`,children:o(`cronLoading`)}):f.length===0?(0,L.jsx)(`div`,{className:`text-sm text-gray-400 p-4 text-center`,children:o(`cronEmpty`)}):(0,L.jsx)(`div`,{className:`space-y-4`,children:f.map(e=>(0,L.jsx)(Ze,{className:`border border-gray-200`,children:(0,L.jsx)($e,{className:`pt-5 pb-5`,children:(0,L.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:[(0,L.jsxs)(`div`,{className:`min-w-[220px] flex-1`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`text-sm font-semibold text-gray-900`,children:e.name||e.id}),(0,L.jsx)(`span`,{className:`text-[10px] font-semibold px-2 py-0.5 rounded-full bg-gray-100 text-gray-500`,children:e.id}),(0,L.jsx)(`span`,{className:u(`text-[10px] font-semibold px-2 py-0.5 rounded-full`,e.enabled?`bg-emerald-50 text-emerald-700`:`bg-gray-100 text-gray-500`),children:e.enabled?o(`enabled`):o(`disabled`)}),e.deleteAfterRun&&(0,L.jsx)(`span`,{className:`text-[10px] font-semibold px-2 py-0.5 rounded-full bg-amber-50 text-amber-700`,children:o(`cronOneShot`)})]}),(0,L.jsxs)(`div`,{className:`mt-2 text-xs text-gray-500`,children:[o(`cronScheduleLabel`),`: `,Ey(e)]}),(0,L.jsx)(`div`,{className:`mt-2 text-sm text-gray-700 whitespace-pre-wrap break-words`,children:e.payload.message}),(0,L.jsxs)(`div`,{className:`mt-2 text-xs text-gray-500`,children:[o(`cronDeliverTo`),`: `,Dy(e)]})]}),(0,L.jsxs)(`div`,{className:`min-w-[220px] text-xs text-gray-500 space-y-2`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[o(`cronNextRun`),`:`]}),` `,Cy(e.state.nextRunAt)]}),(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[o(`cronLastRun`),`:`]}),` `,Cy(e.state.lastRunAt)]}),(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[o(`cronLastStatus`),`:`]}),` `,e.state.lastStatus??`-`]}),e.state.lastError&&(0,L.jsx)(`div`,{className:`text-[11px] text-red-500 break-words`,children:e.state.lastError})]}),(0,L.jsxs)(`div`,{className:`flex items-start gap-2 flex-wrap justify-end`,children:[(0,L.jsxs)(h,{variant:`subtle`,size:`sm`,onClick:()=>g(e),className:`gap-1`,children:[(0,L.jsx)(un,{className:`h-3.5 w-3.5`}),o(`cronRunNow`)]}),(0,L.jsxs)(h,{variant:e.enabled?`outline`:`primary`,size:`sm`,onClick:()=>m(e),className:`gap-1`,children:[(0,L.jsx)(dn,{className:`h-3.5 w-3.5`}),e.enabled?o(`cronDisable`):o(`cronEnable`)]}),(0,L.jsxs)(h,{variant:`destructive`,size:`sm`,onClick:()=>p(e),className:`gap-1`,children:[(0,L.jsx)(Ke,{className:`h-3.5 w-3.5`}),o(`delete`)]})]})]})})},e.id))})}),(0,L.jsx)(d,{})]})}function jy(e){let{view:t,routeSessionKey:n,selectedSessionKey:r,selectedAgentId:i,setSelectedSessionKey:a,setSelectedAgentId:o,selectedSessionKeyRef:s,resetStreamState:c,resolveAgentIdFromSessionKey:l}=e;(0,F.useEffect)(()=>{if(t===`chat`){if(n){r!==n&&a(n);return}r!==null&&(a(null),c())}},[c,n,r,a,t]),(0,F.useEffect)(()=>{let e=r?l(r):null;e&&i!==e&&o(e)},[l,i,r,o]),(0,F.useEffect)(()=>{s.current=r},[r,s])}function My({view:e,confirmDialog:t}){return(0,L.jsxs)(`div`,{className:`h-full flex`,children:[(0,L.jsx)(Ug,{}),e===`chat`?(0,L.jsx)(Sy,{}):(0,L.jsx)(`section`,{className:`flex-1 min-h-0 overflow-hidden bg-gradient-to-b from-gray-50/60 to-white`,children:e===`cron`?(0,L.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar`,children:(0,L.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)] px-6 py-5`,children:(0,L.jsx)(Ay,{})})}):(0,L.jsx)(`div`,{className:`h-full overflow-hidden`,children:(0,L.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:(0,L.jsx)(Ve,{forcedType:`skills`})})})}),t]})}function Ny(){return(e,t)=>fetch(e,{credentials:`include`,...t})}var Py=`sid_`;function Fy(e){let t=/^agent:([^:]+):/i.exec(e.trim());return t&&t[1]?.trim()||null}function Iy(e){let t=new TextEncoder().encode(e),n=``;for(let e of t)n+=String.fromCharCode(e);return`${Py}${btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)}`}function Ly(e){if(!e.startsWith(Py))return null;let t=e.slice(4).replace(/-/g,`+`).replace(/_/g,`/`),n=t.length%4==0?``:`=`.repeat(4-t.length%4);try{let e=atob(t+n),r=Uint8Array.from(e,e=>e.charCodeAt(0));return new TextDecoder().decode(r)}catch{return null}}function Ry(e){if(!e)return null;let t=Ly(e);if(t)return t;try{return decodeURIComponent(e)}catch{return e}}function zy(e){return`/chat/${Iy(e)}`}var By=`native`;function Vy(e){return typeof e==`string`?e.trim().toLowerCase()||`native`:By}function Hy(e,t){return e===`native`?o(`chatSessionTypeNative`):t?.trim()||e.trim().split(/[-_]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)||e}function Uy(e){let t=new Map;for(let n of e){let e=Vy(n.value);t.set(e,{value:e,label:n.label?.trim()||Hy(e),ready:n.ready??!0,reason:n.reason??null,reasonMessage:n.reasonMessage??null,supportedModels:n.supportedModels,recommendedModel:n.recommendedModel??null,cta:n.cta??null})}return t.has(`native`)||t.set(By,{value:By,label:Hy(By),ready:!0,reason:null,reasonMessage:null,supportedModels:void 0,recommendedModel:null,cta:null}),Array.from(t.values()).sort((e,t)=>e.value===`native`?-1:t.value===`native`?1:e.value.localeCompare(t.value))}function Wy(e){let{selectedSession:t,selectedSessionKey:n,pendingSessionType:r,setPendingSessionType:i,sessionTypesData:a}=e,s=(0,F.useMemo)(()=>Uy(a?.options??[]),[a?.options]),c=(0,F.useMemo)(()=>{let e=[...s],n=Vy(t?.sessionType);return e.some(e=>e.value===n)||e.push({value:n,label:Hy(n),ready:!0,reason:null,reasonMessage:null,supportedModels:void 0,recommendedModel:null,cta:null}),e.sort((e,t)=>e.value===`native`?-1:t.value===`native`?1:e.value.localeCompare(t.value))},[s,t?.sessionType]),l=(0,F.useMemo)(()=>Vy(a?.defaultType??`native`),[a?.defaultType]),u=(0,F.useRef)(null),d=(0,F.useMemo)(()=>Vy(t?.sessionType??r??l),[l,r,t?.sessionType]),f=(0,F.useMemo)(()=>c.find(e=>e.value===d)??null,[d,c]);(0,F.useEffect)(()=>{if(n)return;let e=typeof r==`string`?r.trim():``,t=Vy(r);(e.length===0||u.current===t||u.current===null&&t===`native`)&&(u.current=l,t!==l&&i(l))},[l,r,n,i]);let p=!n||!!t?.sessionTypeMutable,m=(0,F.useMemo)(()=>new Set(s.map(e=>e.value)),[s]);return{sessionTypeOptions:c,selectedSessionTypeOption:f,defaultSessionType:l,selectedSessionType:d,canEditSessionType:p,sessionTypeUnavailable:(0,F.useMemo)(()=>t&&!m.has(Vy(t.sessionType))?!0:f?.ready===!1,[m,t,f?.ready]),sessionTypeUnavailableMessage:(0,F.useMemo)(()=>t&&!m.has(Vy(t.sessionType))?`${Hy(d)} ${o(`chatSessionTypeUnavailableSuffix`)}`:f?.ready===!1?f.reasonMessage?.trim()||`${f.label} setup required`:null,[m,t,d,f])}}function Gy(e){return e?.trim().toLowerCase()||`native`}function Ky(e,t){if(typeof t!=`string`)return!1;let n=t.trim();return n?e.some(e=>e.value===n):!1}function qy(e,t){return typeof t==`string`&&e.includes(t)}function Jy(e){return e.length===0?null:e.includes(`off`)?`off`:e[0]??null}function Yy(e){let{currentValue:t,selectedSessionPreferredValue:n,fallbackPreferredValue:r,defaultValue:i,isValueSupported:a,firstAvailableValue:o,preferSessionPreferredValue:s=!1,preserveCurrentValueOnSessionChange:c=!1}=e;return a(t)&&(!s||c)?t:a(n)?n:a(r)?r:a(i)?i:o}function Xy(e){let{modelOptions:t}=e;return t.length===0?``:Yy({currentValue:e.currentSelectedModel,selectedSessionPreferredValue:e.selectedSessionPreferredModel,fallbackPreferredValue:e.fallbackPreferredModel,defaultValue:e.defaultModel,isValueSupported:e=>Ky(t,e),firstAvailableValue:t[0]?.value??``,preferSessionPreferredValue:e.preferSessionPreferredModel,preserveCurrentValueOnSessionChange:e.preserveCurrentSelectedModelOnSessionChange})}function Zy(e){let{supportedThinkingLevels:t}=e;return t.length===0?null:Yy({currentValue:e.currentSelectedThinkingLevel,selectedSessionPreferredValue:e.selectedSessionPreferredThinking,fallbackPreferredValue:e.fallbackPreferredThinking,defaultValue:e.defaultThinkingLevel,isValueSupported:e=>qy(t,e),firstAvailableValue:Jy(t)??`off`,preferSessionPreferredValue:e.preferSessionPreferredThinking,preserveCurrentValueOnSessionChange:e.preserveCurrentSelectedThinkingOnSessionChange})}function Qy(e){let t=Gy(e.sessionType),n,r=-1/0;for(let i of e.sessions){if(i.key===e.selectedSessionKey||Gy(i.sessionType)!==t)continue;let a=e.readPreference(i);if(a==null)continue;let o=Date.parse(i.updatedAt),s=Number.isFinite(o)?o:-1/0;(n===void 0||s>r)&&(n=a,r=s)}return n}function $y(e){return Qy({sessions:e.sessions,selectedSessionKey:e.selectedSessionKey,sessionType:e.sessionType,readPreference:e=>e.preferredModel?.trim()||void 0})}function eb(e){return Qy({sessions:e.sessions,selectedSessionKey:e.selectedSessionKey,sessionType:e.sessionType,readPreference:e=>e.preferredThinking??void 0})}function tb(e){let{isPreferenceAvailable:t,emptyValue:n,selectedSessionKey:r,selectedSessionExists:i=!1,setValue:a,resolveValue:o}=e,s=(0,F.useRef)(void 0),c=(0,F.useRef)(o);(0,F.useEffect)(()=>{c.current=o},[o]),(0,F.useEffect)(()=>{let e=s.current!==r;if(!t){a(n),s.current=r;return}a(t=>c.current({currentValue:t,sessionChanged:e,preserveCurrentValueOnSessionChange:e&&!!r&&!i})),s.current=r},[n,t,i,r,a])}function nb(e){let{modelOptions:t,selectedSessionKey:n,selectedSessionExists:r=!1,selectedSessionPreferredModel:i,fallbackPreferredModel:a,defaultModel:o,setSelectedModel:s}=e;tb({isPreferenceAvailable:t.length>0,emptyValue:``,selectedSessionKey:n,selectedSessionExists:r,setValue:s,resolveValue:({currentValue:e,sessionChanged:n,preserveCurrentValueOnSessionChange:r})=>Xy({currentSelectedModel:e,modelOptions:t,selectedSessionPreferredModel:i,fallbackPreferredModel:a,defaultModel:o,preferSessionPreferredModel:n,preserveCurrentSelectedModelOnSessionChange:r})})}function rb(e){let{supportedThinkingLevels:t,selectedSessionKey:n,selectedSessionExists:r=!1,selectedSessionPreferredThinking:i,fallbackPreferredThinking:a,defaultThinkingLevel:o,setSelectedThinkingLevel:s}=e;tb({isPreferenceAvailable:t.length>0,emptyValue:null,selectedSessionKey:n,selectedSessionExists:r,setValue:s,resolveValue:({currentValue:e,sessionChanged:n,preserveCurrentValueOnSessionChange:r})=>Zy({currentSelectedThinkingLevel:e,supportedThinkingLevels:t,selectedSessionPreferredThinking:i,fallbackPreferredThinking:a,defaultThinkingLevel:o,preferSessionPreferredThinking:n,preserveCurrentSelectedThinkingOnSessionChange:r})})}function ib(){return f({queryKey:[`ncp-session-types`],queryFn:Je,staleTime:1e4,retry:!1})}function ab(e,t){return e.filter(e=>ye(e,t))}function ob(e){if(!e.supportedModels||e.supportedModels.length===0)return e.modelOptions;let t=new Set(e.supportedModels),n=e.modelOptions.filter(e=>t.has(e.value));return n.length>0?n:e.modelOptions}function sb(e){let t=ut(),n=yt(),r=lt({limit:200}),i=ib(),a=Nt({sessionId:e.sessionKey,...Object.prototype.hasOwnProperty.call(e,`projectRootOverride`)?{projectRoot:e.projectRootOverride??null}:{}}),o=(t.isFetched||t.isSuccess)&&(n.isFetched||n.isSuccess),s=(0,F.useMemo)(()=>{let e=ke({meta:n.data,config:t.data,onlyConfigured:!0}),r=new Set,i=[];for(let t of e)for(let e of t.models){let n=De(t.prefix,e);!n||r.has(n)||(r.add(n),i.push({value:n,modelLabel:e,providerLabel:t.displayName,thinkingCapability:Ee(t.modelThinking,e,t.aliases)}))}return i.sort((e,t)=>{let n=e.providerLabel.localeCompare(t.providerLabel);return n===0?e.modelLabel.localeCompare(t.modelLabel):n})},[n.data,t.data]),c=(0,F.useMemo)(()=>r.data?.sessions??[],[r.data?.sessions]),l=(0,F.useMemo)(()=>_e(c),[c]),u=(0,F.useMemo)(()=>ab(l,e.query),[l,e.query]),d=(0,F.useMemo)(()=>l.find(t=>t.key===e.sessionKey)??null,[l,e.sessionKey]),f=(0,F.useMemo)(()=>a.data?.records??[],[a.data?.records]),p=Wy({selectedSession:d,selectedSessionKey:e.sessionKey,pendingSessionType:e.pendingSessionType,setPendingSessionType:e.setPendingSessionType,sessionTypesData:i.data}),m=(0,F.useMemo)(()=>ob({modelOptions:s,supportedModels:p.selectedSessionTypeOption?.supportedModels}),[s,p.selectedSessionTypeOption?.supportedModels]),h=(0,F.useMemo)(()=>$y({sessions:l,selectedSessionKey:e.sessionKey,sessionType:p.selectedSessionType}),[l,e.sessionKey,p.selectedSessionType]),g=(0,F.useMemo)(()=>m.find(t=>t.value===e.currentSelectedModel),[m,e.currentSelectedModel]),_=(0,F.useMemo)(()=>g?.thinkingCapability?.supported??[],[g?.thinkingCapability?.supported]),v=(0,F.useMemo)(()=>g?.thinkingCapability?.default??null,[g?.thinkingCapability?.default]),y=(0,F.useMemo)(()=>eb({sessions:l,selectedSessionKey:e.sessionKey,sessionType:p.selectedSessionType}),[l,e.sessionKey,p.selectedSessionType]);return nb({modelOptions:m,selectedSessionKey:e.sessionKey,selectedSessionExists:!!d,selectedSessionPreferredModel:d?.preferredModel,fallbackPreferredModel:p.selectedSessionTypeOption?.recommendedModel??h,defaultModel:p.selectedSessionTypeOption?.recommendedModel??t.data?.agents.defaults.model,setSelectedModel:e.setSelectedModel}),rb({supportedThinkingLevels:_,selectedSessionKey:e.sessionKey,selectedSessionExists:!!d,selectedSessionPreferredThinking:d?.preferredThinking??null,fallbackPreferredThinking:y??null,defaultThinkingLevel:v,setSelectedThinkingLevel:e.setSelectedThinkingLevel}),{configQuery:t,configMetaQuery:n,sessionsQuery:r,sessionTypesQuery:i,sessionSkillsQuery:a,isProviderStateResolved:o,modelOptions:m,sessionSummaries:c,sessions:u,skillRecords:f,selectedSession:d,...p}}var cb=class{constructor(e,t){this.uiManager=e,this.streamActionsManager=t,this.resolveUpdateValue=(e,t)=>typeof t==`function`?t(e):t,this.setSelectedAgentId=e=>{let t=R.getState().snapshot.selectedAgentId,n=this.resolveUpdateValue(t,e);n!==t&&R.getState().setSnapshot({selectedAgentId:n})},this.setSelectedSessionKey=e=>{let t=R.getState().snapshot.selectedSessionKey,n=this.resolveUpdateValue(t,e);n!==t&&R.getState().setSnapshot({selectedSessionKey:n})},this.createSession=e=>{let{snapshot:t}=Q.getState(),{defaultSessionType:n}=t,r=n||`native`,i=typeof e==`string`&&e.trim().length>0?e.trim():r;this.streamActionsManager.resetStreamState(),Q.getState().setSnapshot({pendingSessionType:i,pendingProjectRoot:null,pendingProjectRootSessionKey:null}),this.uiManager.goToChatRoot()},this.selectSession=e=>{this.uiManager.goToSession(e)},this.setQuery=e=>{let t=R.getState().snapshot.query,n=this.resolveUpdateValue(t,e);n!==t&&R.getState().setSnapshot({query:n})}}},lb=async()=>{},ub=()=>{},db=class{constructor(){this.actions={sendMessage:lb,stopCurrentRun:lb,resumeRun:lb,resetStreamState:ub,applyHistoryMessages:ub},this.bind=e=>{this.actions={...this.actions,...e}},this.sendMessage=e=>this.actions.sendMessage(e),this.stopCurrentRun=()=>this.actions.stopCurrentRun(),this.resumeRun=e=>this.actions.resumeRun(e),this.resetStreamState=()=>this.actions.resetStreamState(),this.applyHistoryMessages=(e,t)=>this.actions.applyHistoryMessages(e,t)}},fb=async e=>!1,pb=class{constructor(){this.state={pathname:``},this.actions={navigate:null,confirm:fb},this.syncState=e=>{this.state={...this.state,...e}},this.bindActions=e=>{this.actions={...this.actions,...e}},this.confirm=async e=>this.actions.confirm(e),this.navigateTo=(e,t)=>{this.actions.navigate&&(this.state.pathname===e&&!t?.replace||(this.actions.navigate(e,t),this.state.pathname=e))},this.goToProviders=()=>{this.navigateTo(`/providers`)},this.goToChatRoot=e=>{this.navigateTo(`/chat`,e)},this.goToSession=(e,t)=>{this.navigateTo(zy(e),t)}}};function mb(e){let t=e.trim();return t.length>0?t:null}function hb(e){return e??null}var gb=class{constructor(e){this.updateSession=e,this.inFlight=null,this.queued=null,this.syncSelectedSessionPreferences=()=>{let e=Q.getState().snapshot,t=R.getState().snapshot.selectedSessionKey;t&&this.enqueue({sessionKey:t,patch:{preferredModel:mb(e.selectedModel),preferredThinking:hb(e.selectedThinkingLevel)}})}}enqueue(e){this.queued=e,!this.inFlight&&this.startFlush()}startFlush(){this.inFlight=this.flush().catch(e=>{console.error(`Failed to sync chat session preferences: ${String(e)}`)}).finally(()=>{this.inFlight=null,this.queued&&this.startFlush()})}async flush(){for(;this.queued;){let e=this.queued;this.queued=null,await this.updateSession(e.sessionKey,e.patch)}}},_b=class{constructor(e,t,n){this.uiManager=e,this.streamActionsManager=t,this.getDraftSessionId=n,this.sessionPreferenceSync=new gb(Xe),this.buildAttachmentSignature=e=>[e.assetUri??``,e.url??``,e.name,e.mimeType,String(e.sizeBytes),e.contentBase64??``].join(`:`),this.hasSnapshotChanges=e=>{let t=Q.getState().snapshot;for(let[n,r]of Object.entries(e))if(!Object.is(t[n],r))return!0;return!1},this.resolveUpdateValue=(e,t)=>typeof t==`function`?t(e):t,this.isSameStringArray=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),this.syncComposerSnapshot=e=>{let t=Q.getState().snapshot.attachments,n=Ig(e,t);Q.getState().setSnapshot({composerNodes:e,attachments:n,draft:jg(e),selectedSkills:Mg(e)})},this.syncComposerSnapshotWithAttachments=(e,t)=>{Q.getState().setSnapshot({composerNodes:e,attachments:t,draft:jg(e),selectedSkills:Mg(e)})},this.dedupeAttachments=e=>{let t=new Set,n=[];for(let r of e){let e=this.buildAttachmentSignature(r);t.has(e)||(t.add(e),n.push(r))}return n},this.syncSnapshot=e=>{if(this.hasSnapshotChanges(e)&&(Q.getState().setSnapshot(e),Object.prototype.hasOwnProperty.call(e,`modelOptions`)||Object.prototype.hasOwnProperty.call(e,`selectedModel`)||Object.prototype.hasOwnProperty.call(e,`selectedThinkingLevel`))){let{selectedModel:e}=Q.getState().snapshot;this.reconcileThinkingForModel(e)}},this.setDraft=e=>{let t=Q.getState().snapshot.draft,n=this.resolveUpdateValue(t,e);n!==t&&this.syncComposerSnapshot(Ag(n))},this.setComposerNodes=e=>{let t=Q.getState().snapshot.composerNodes,n=this.resolveUpdateValue(t,e);Object.is(n,t)||this.syncComposerSnapshot(n)},this.addAttachments=e=>{if(e.length===0)return[];let t=Q.getState().snapshot,n=new Set(t.attachments.map(this.buildAttachmentSignature)),r=this.dedupeAttachments([...t.attachments,...e]),i=r.filter(e=>!n.has(this.buildAttachmentSignature(e)));if(i.length===0)return[];let a=Fg(t.composerNodes,r);return this.syncComposerSnapshotWithAttachments(a,r),i},this.restoreComposerState=(e,t)=>{let n=this.dedupeAttachments(t),r=Fg(e,n);this.syncComposerSnapshotWithAttachments(r,n)},this.setPendingSessionType=e=>{let t=Q.getState().snapshot.pendingSessionType,n=this.resolveUpdateValue(t,e);n!==t&&Q.getState().setSnapshot({pendingSessionType:n})},this.send=async()=>{let e=Q.getState().snapshot,t=R.getState().snapshot,n=e.draft.trim(),r=e.attachments,i=Lg(e.composerNodes,r);if(!i.some(e=>e.type!==`text`||e.text.trim().length>0))return;let{selectedSkills:a,composerNodes:o}=e,s=t.selectedSessionKey??this.getDraftSessionId();t.selectedSessionKey||this.uiManager.goToSession(s,{replace:!0}),this.setComposerNodes(kg()),await this.streamActionsManager.sendMessage({message:n,sessionKey:s,agentId:t.selectedAgentId,sessionType:e.selectedSessionType,model:e.selectedModel||void 0,thinkingLevel:e.selectedThinkingLevel??void 0,stopSupported:!0,requestedSkills:a,attachments:r,parts:i,restoreDraftOnError:!0,composerNodes:o})},this.stop=async()=>{await this.streamActionsManager.stopCurrentRun()},this.goToProviders=()=>{this.uiManager.goToProviders()},this.setSelectedModel=e=>{let t=Q.getState().snapshot.selectedModel,n=this.resolveUpdateValue(t,e);n!==t&&(Q.getState().setSnapshot({selectedModel:n}),this.reconcileThinkingForModel(n))},this.setSelectedThinkingLevel=e=>{let t=Q.getState().snapshot.selectedThinkingLevel,n=this.resolveUpdateValue(t,e);n!==t&&Q.getState().setSnapshot({selectedThinkingLevel:n})},this.selectSessionType=e=>{let t=Vy(e);Q.getState().setSnapshot({selectedSessionType:t,pendingSessionType:t})},this.setSelectedSkills=e=>{let t=Q.getState().snapshot,{selectedSkills:n}=t,r=this.resolveUpdateValue(n,e);this.isSameStringArray(r,n)||this.syncComposerSnapshot(Pg(t.composerNodes,r,t.skillRecords))},this.selectModel=e=>{this.setSelectedModel(e),c_.remember(e),this.sessionPreferenceSync.syncSelectedSessionPreferences()},this.selectThinkingLevel=e=>{this.setSelectedThinkingLevel(e),this.sessionPreferenceSync.syncSelectedSessionPreferences()},this.rememberSkillSelection=e=>{l_.remember(e)},this.selectSkills=e=>{let t=Q.getState().snapshot.selectedSkills;for(let n of e)t.includes(n)||this.rememberSkillSelection(n);this.setSelectedSkills(e)},this.resolveThinkingForModel=(e,t)=>{let n=e?.thinkingCapability;return!n||n.supported.length===0?null:t===`off`?`off`:t&&n.supported.includes(t)?t:n.default&&n.supported.includes(n.default)?n.default:`off`},this.reconcileThinkingForModel=e=>{let t=Q.getState().snapshot,n=t.modelOptions.find(t=>t.value===e),{selectedThinkingLevel:r}=t,i=this.resolveThinkingForModel(n,r);i!==r&&Q.getState().setSnapshot({selectedThinkingLevel:i})}}},vb=class{constructor(e,t,n){this.uiManager=e,this.sessionListManager=t,this.streamActionsManager=n,this.hasSnapshotChanges=e=>{let t=by.getState().snapshot;for(let[n,r]of Object.entries(e))if(!Object.is(t[n],r))return!0;return!1},this.syncSnapshot=e=>{this.hasSnapshotChanges(e)&&by.getState().setSnapshot(e)},this.deleteSession=()=>{this.deleteCurrentSession()},this.createSession=()=>{this.sessionListManager.createSession()},this.goToProviders=()=>{this.uiManager.goToProviders()},this.deleteCurrentSession=async()=>{let{snapshot:{selectedSessionKey:e}}=R.getState();if(e&&await this.uiManager.confirm({title:o(`chatDeleteSessionConfirm`),variant:`destructive`,confirmLabel:o(`delete`)})){by.getState().setSnapshot({isDeletePending:!0});try{await tt(e),Qe(S,e),S.removeQueries({queryKey:[`ncp-session-messages`,e]}),this.streamActionsManager.resetStreamState(),this.uiManager.goToChatRoot({replace:!0})}finally{by.getState().setSnapshot({isDeletePending:!1})}}}}},yb=class{constructor(){this.chatUiManager=new pb,this.chatStreamActionsManager=new db,this.chatSessionListManager=new cb(this.chatUiManager,this.chatStreamActionsManager),this.chatInputManager=new _b(this.chatUiManager,this.chatStreamActionsManager,()=>this.getDraftSessionId()),this.chatThreadManager=new vb(this.chatUiManager,this.chatSessionListManager,this.chatStreamActionsManager),this.draftSessionId=``,this.setDraftSessionId=e=>{this.draftSessionId=e}}getDraftSessionId(){return this.draftSessionId}};function bb(e){if(!Array.isArray(e))return[];let t=new Set;for(let n of e){let e=n.trim();e&&t.add(e)}return[...t]}function xb(e){let t={};e.model?.trim()&&(t.model=e.model.trim(),t.preferred_model=e.model.trim()),e.thinkingLevel?.trim()&&(t.thinking=e.thinkingLevel.trim(),t.preferred_thinking=e.thinkingLevel.trim()),e.sessionType?.trim()&&(t.session_type=e.sessionType.trim());let n=Se(e.projectRoot);n&&(t.project_root=n);let r=bb(e.requestedSkills);r.length>0&&(t.requested_skill_refs=r);let i=e.composerNodes?T_(e.composerNodes):[];return i.length>0&&(t[b_]=i),t}function Sb(e){return e instanceof Error?e.message.includes(`ncp session not found:`):!1}function Cb({view:e}){let[t]=(0,F.useState)(()=>new yb),[n,r]=(0,F.useState)(()=>me()),i=R(e=>e.snapshot.query),a=R(e=>e.snapshot.selectedSessionKey),o=R(e=>e.snapshot.selectedAgentId),s=Q(e=>e.snapshot.pendingSessionType),c=Q(e=>e.snapshot.pendingProjectRoot),l=Q(e=>e.snapshot.pendingProjectRootSessionKey),u=Q(e=>e.snapshot.selectedModel),{confirm:f,ConfirmDialog:m}=Wt(),h=b(),g=x(),{sessionId:_}=y(),v=(0,F.useRef)(null),S=(0,F.useRef)(a),C=(0,F.useRef)(!1),w=(0,F.useMemo)(()=>Ry(_),[_]),T=a??n,E=l===T,{sessionSkillsQuery:D,isProviderStateResolved:O,modelOptions:k,sessionSummaries:ee,skillRecords:te,selectedSession:A,sessionTypeOptions:j,defaultSessionType:ne,selectedSessionType:M,canEditSessionType:re,sessionTypeUnavailable:ie,sessionTypeUnavailableMessage:ae}=sb({query:i,sessionKey:T,projectRootOverride:E?c:void 0,currentSelectedModel:u,pendingSessionType:s,setPendingSessionType:t.chatInputManager.setPendingSessionType,setSelectedModel:t.chatInputManager.setSelectedModel,setSelectedThinkingLevel:t.chatInputManager.setSelectedThinkingLevel}),oe=(0,F.useRef)(ee);(0,F.useEffect)(()=>{oe.current=ee},[ee]);let[se]=(0,F.useState)(()=>new Vn({baseUrl:d,basePath:`/api/ncp/agent`,fetchImpl:Ny()})),N=lr({sessionId:T,client:se,loadSeed:(0,F.useCallback)(async(e,t)=>{t.throwIfAborted();let n=null;try{n=await nt(e,300)}catch(e){if(!Sb(e))throw e}t.throwIfAborted();let r=oe.current.find(t=>t.sessionId===e)??null;return{messages:n?.messages??[],status:r?.status===`running`?`running`:`idle`}},[])});(0,F.useEffect)(()=>{t.setDraftSessionId(n)},[n,t]),(0,F.useEffect)(()=>{if(a===null){let e=me();r(e),t.setDraftSessionId(e)}},[t,a]);let ce=E?c:A?.projectRoot??null,le=E?be(ce):A?.projectName??be(ce),ue=N.isSending||N.isRunning,de=N.isRunning,fe=N.isRunning,P=N.isRunning?null:`__preparing__`,pe=N.hydrateError?.message??N.snapshot.error?.message??null;(0,F.useEffect)(()=>{let e=()=>{C.current||N.isHydrating||N.isRunning||N.isSending||(C.current=!0,se.stream({sessionId:T}).catch(()=>void 0).finally(()=>{C.current=!1}))};return p.subscribe(t=>{t.type===`session.run-status`&&t.payload.sessionKey===T&&t.payload.status===`running`&&e()})},[N.isHydrating,N.isRunning,N.isSending,se,T]),(0,F.useEffect)(()=>{t.chatStreamActionsManager.bind({sendMessage:async e=>{if(e.sessionKey!==T)return;let n=xb({model:e.model,thinkingLevel:e.thinkingLevel,sessionType:e.sessionType,projectRoot:e.sessionKey===l?c:A?.projectRoot??null,requestedSkills:e.requestedSkills,composerNodes:e.composerNodes}),r=mr({sessionId:e.sessionKey,text:e.message,attachments:e.attachments,parts:e.parts,metadata:n});if(r)try{await N.send(r)}catch(n){throw e.restoreDraftOnError&&(e.composerNodes&&e.composerNodes.length>0?t.chatInputManager.restoreComposerState?.(e.composerNodes,e.attachments??[]):t.chatInputManager.setDraft(t=>t.trim().length===0?e.message:t)),n}},stopCurrentRun:async()=>{await N.abort()},resumeRun:async e=>{e.sessionKey===T&&await N.streamRun()},resetStreamState:()=>{S.current=null},applyHistoryMessages:()=>{}})},[N,c,l,t,A?.projectRoot,T]),(0,F.useEffect)(()=>{!A||l!==A.key||(A.projectRoot??null)!==c||Q.getState().setSnapshot({pendingProjectRoot:null,pendingProjectRootSessionKey:null})},[c,l,A]),jy({view:e,routeSessionKey:w,selectedSessionKey:a,selectedAgentId:o,setSelectedSessionKey:t.chatSessionListManager.setSelectedSessionKey,setSelectedAgentId:t.chatSessionListManager.setSelectedAgentId,selectedSessionKeyRef:S,resetStreamState:t.chatStreamActionsManager.resetStreamState,resolveAgentIdFromSessionKey:Fy}),(0,F.useEffect)(()=>{t.chatUiManager.syncState({pathname:h.pathname}),t.chatUiManager.bindActions({navigate:g,confirm:f})},[f,h.pathname,g,t]);let he=A?Ce(A):void 0,ge=j.find(e=>e.value===M)?.label??Hy(M);return(0,F.useEffect)(()=>{t.chatInputManager.syncSnapshot({isProviderStateResolved:O,defaultSessionType:ne,canStopGeneration:fe,stopDisabledReason:P,stopSupported:!0,stopReason:void 0,sendError:pe,isSending:ue,modelOptions:k,sessionTypeOptions:j,selectedSessionType:M,canEditSessionType:re,sessionTypeUnavailable:ie,skillRecords:te,isSkillsLoading:D.isLoading}),t.chatThreadManager.syncSnapshot({isProviderStateResolved:O,modelOptions:k,sessionTypeUnavailable:ie,sessionTypeUnavailableMessage:ae,sessionTypeLabel:ge,sessionKey:T,sessionDisplayName:he,sessionProjectRoot:ce,sessionProjectName:le,canDeleteSession:!!A,threadRef:v,isHistoryLoading:N.isHydrating,messages:N.visibleMessages,isSending:ue,isAwaitingAssistantOutput:de})},[N.isHydrating,re,fe,he,ge,ne,D.isLoading,de,O,ue,pe,k,t,le,ce,A,T,M,j,ie,ae,te,P,v,N.visibleMessages]),(0,L.jsx)(Fr,{presenter:t,children:(0,L.jsx)(My,{view:e,confirmDialog:(0,L.jsx)(m,{})})})}function wb({view:e}){return(0,L.jsx)(Cb,{view:e})}export{wb as ChatPage};
|